Logic is the study of reasoning. In Computer Science, formal logic is used to verify properties of programs, circuits, and protocols.
Propositions & Connectives
A Proposition is a statement that is either True () or False (). We combine simple propositions using logical connectives.
| Connective | Symbol | Name | Meaning |
|---|---|---|---|
| Negation | NOT | True iff is False. | |
| Conjunction | AND | True iff both and are True. | |
| Disjunction | OR | True iff is True or is True (or both). | |
| Implication | IMPLIES | False iff is True and is False. | |
| XOR | Exclusive OR | True iff exactly one of is True. |
The Implication Trap ()
- If the Hypothesis () is False, the implication is vacuously true, regardless of .
Quantifiers
Predicate logic extends propositional logic by introducing variables and quantifiers. Let be a predicate (a function returning a boolean).
-
Universal Quantifier ()
- : “For all in set , is true.”
- Disproof: Find one counterexample.
-
Existential Quantifier ()
- : “There exists an element in such that is true.”
- Proof: Find one example.
Negating Quantifiers
-
- To say “Not everyone likes pizza” is to say “There is someone who does not like pizza”.
Logical Equivalence
Two statements are logically equivalent () if they have the same truth value in every possible scenario (same Truth Table).
Crucial Equivalences:
- Contrapositive:
- Note: The Converse () is NOT equivalent.
- Implication as OR: