Propositional logic cannot express "every" and "some". Quantifiers add this power. Normal forms then give a standard shape to any statement.
Predicates and Quantifiers
A predicate is a statement with a variable, such as P(x): "x is greater than 3". It becomes a proposition when x is given a value, or when it is quantified. The universal quantifier ∀x P(x) means "P(x) is true for every x in the domain". The existential quantifier ∃x P(x) means "there is at least one x for which P(x) is true". The domain, or universe of discourse, must be stated, since the truth value depends on it. Over the integers, ∃x (x² = 4) is true, and ∀x (x² ≥ 0) is true, but ∀x (x > 0) is false.
Definition: Quantifier. A symbol that states how many elements of a domain satisfy a predicate: the universal quantifier ∀ means for all, and the existential quantifier ∃ means there exists.
Negating Quantified Statements
The negations follow De Morgan's laws for quantifiers: ¬∀x P(x) ≡ ∃x ¬P(x), and ¬∃x P(x) ≡ ∀x ¬P(x). The negation of "every student passed" is "some student did not pass", not "no student passed". When quantifiers are nested, their order matters: ∀x ∃y (x + y = 0) is true over the integers, since each x has an inverse, but ∃y ∀x (x + y = 0) is false.
Conjunctive and Disjunctive Normal Forms
A literal is a variable or its negation. A statement is in disjunctive normal form (DNF) if it is an OR of terms, each of which is an AND of literals, such as (p ∧ q) ∨ (¬p ∧ r). It is in conjunctive normal form (CNF) if it is an AND of clauses, each of which is an OR of literals, such as (p ∨ q) ∧ (¬p ∨ r). Every statement has an equivalent DNF and CNF. To convert, first remove → and ↔ using p → q ≡ ¬p ∨ q, then move ¬ inward by De Morgan's laws and double negation, and finally apply the distributive law. From a truth table, the DNF is the OR of one term for each row in which the statement is true, and the CNF is the AND of one clause for each row in which it is false. CNF is the input form of SAT solvers, used in chip design and planning.
Table 1.3: DNF and CNF
| Feature | DNF | CNF |
|---|---|---|
| Outer operation | OR | AND |
| Inner operation | AND | OR |
| From truth table | Rows that are T | Rows that are F |
| Example | (p ∧ q) ∨ ¬r | (p ∨ q) ∧ ¬r |
Example 1.3: Converting to CNF and DNF
Problem: Find the CNF and DNF of p → (q ∧ r).
Solution:
- Remove the conditional: ¬p ∨ (q ∧ r). This is already a DNF: ¬p ∨ (q ∧ r).
- Distribute ∨ over ∧: (¬p ∨ q) ∧ (¬p ∨ r). This is the CNF.
Result: DNF: ¬p ∨ (q ∧ r). CNF: (¬p ∨ q) ∧ (¬p ∨ r).
from itertools import product
f = lambda p, q, r: (not p) or (q and r)
cnf = lambda p, q, r: ((not p) or q) and ((not p) or r)
print(all(f(*v) == cnf(*v) for v in product([1, 0], repeat=3)))
Output
True
Common mistakes
- Negating "all are" as "none are". The correct negation is "some are not".
- Swapping the order of nested quantifiers, which can change the meaning.
- Mixing up CNF, an AND of ORs, with DNF, an OR of ANDs.
Key takeaways
- ∀ means for all, ∃ means there exists.
- ¬∀x P(x) ≡ ∃x ¬P(x), and ¬∃x P(x) ≡ ∀x ¬P(x).
- DNF is an OR of ANDs, CNF is an AND of ORs.
- From a truth table, DNF uses the true rows and CNF the false rows.
Practice questions
- Negate "every number is positive".
- What is a literal?
- Is (p ∨ q) ∧ ¬r in CNF?
Answers to the practice questions
- "Some number is not positive", ∃x ¬P(x).
- A variable or its negation.
- Yes, it is an AND of clauses that are ORs of literals.
Sources
- Official BCA syllabus Mathematics Foundations to Computer Science II, course code 25BCA402DS01, Unit I
