Foundations of mathematics
Predicate logic
Predicate logic extends propositional logic with quantifiers ("for all , ") and ("there exists such that "), letting us formalize statements about every element or some element of a domain, and reason about them with Tarski's satisfaction semantics.
IntuitionFor all vs. there exists
"Every student in this room passed the exam" and "some student in this room passed the exam" are very different claims, even though both are about the same room. Predicate logic makes this precision explicit: a predicate is a property that becomes a true/false proposition once is filled in with a specific object from a domain (a universe of discourse) . The universal quantifier asserts holds for every object in ; the existential quantifier asserts holds for at least one object in .
UndergraduateFormal syntax and quantifier negation
Definition: Quantifiers and free/bound variables
Given a domain and a predicate : ("for all , ") is true in iff holds for every element of ; ("there exists such that ") is true iff holds for at least one element. A variable inside the scope of a quantifier binding it is bound; otherwise it is free. A formula with no free variables is a sentence, and has a definite truth value in a given structure.
This law says: "not everyone has property " means exactly "someone lacks ". Its dual, , says "no one has property " is the same as "everyone lacks ". These two laws are the quantifier analogues of De Morgan's laws for , and are the key step for pushing all negations inward to reach prenex normal form — a formula with all quantifiers moved to the front, e.g. with quantifier-free.
| Formula | Equivalent prenex form |
|---|---|
UndergraduateKey theorems: instantiation and quantifier order
For any structure with domain , any assignment , and any term substitutable for in : if , then . In rule form: .
Why is it true?
means "no matter what we plug in for , holds" — so plugging in any specific term must still make hold. This is the rule that turns general laws into concrete instances: from "" we instantiate at to get "", the first premise of the classic syllogism.
Proof
We argue directly from Tarski's satisfaction semantics, which defines truth in a structure recursively on formula structure.
By the semantic clause for : . Assume the hypothesis ; by this clause, holds for every , with no exception.
Since the claim holds for every , it holds in particular for , the element that the term denotes in under . Substituting this specific gives .
By the Substitution Lemma (a standard result relating variable assignment to term substitution, provable by induction on the structure of ): , valid precisely because is substitutable for in (no free variable of becomes accidentally bound). Applying the lemma converts into .
Since , , and were arbitrary, the inference from to preserves truth in every structure under every assignment: the rule is sound.
For any structure and formula : . The converse implication does not hold in general.
Why is it true?
demands a single witness that works for every (a "fixed" witness), while only demands that each has some witness, possibly a different one for each (a "moving" witness). A fixed witness is automatically a moving witness (just reuse it), but not conversely — this is exactly the difference between "someone loves everybody" (one universal lover) and "everybody is loved by someone" (possibly different admirers), a classic source of ambiguity in natural language that predicate logic disambiguates.
Proof
Forward direction. Assume . By the semantic clause for , ; applying it here gives some with .
By the clause for applied to this, holds for every , since the ranges over all of regardless of which we later pick.
Now fix an arbitrary to verify . From the previous paragraph, taking gives , which exhibits itself as a witness for under ; hence .
Since was arbitrary, holds for every , which is exactly the semantic clause for . This proves .
Converse fails: a counterexample. Let have domain (the integers) and interpret as "". Then is TRUE: for every integer , taking gives . But is FALSE: it would require a single integer larger than every integer , and no such maximum integer exists (for any candidate , the integer violates ). So holds while fails, showing the converse implication is false in general.
UndergraduateReal-World Applications and Worked Examples
SQL has no native "for all" keyword, so relational databases encode using the quantifier negation law: "" becomes `NOT EXISTS (... WHERE NOT P ...)`, i.e. programmers implement via double negation of exactly as in . Formal specification languages (Z notation, Hoare logic pre/postconditions, TLA+) use and directly to state correctness properties like "every array index is within bounds" or "there exists a valid execution path", which verification tools then check by instantiation and quantifier-elimination techniques.
Example: Relational division: "bought every product"
A database has tables `Purchases(customer, product)` and `Products(product)`. Formalize "customer bought every product" in predicate logic, then translate into a SQL query using only `NOT EXISTS`.
Solution
Let mean " appears in Purchases" and mean " appears in Products". "Customer bought every product" is .
SQL lacks , so apply the quantifier negation law to , i.e. rewrite the universal as "there is NO product that customer did NOT buy": .
This translates directly: `SELECT c FROM Customers c WHERE NOT EXISTS (SELECT FROM Products p WHERE NOT EXISTS (SELECT FROM Purchases WHERE customer = c.c AND product = p.product))` — the classic "double NOT EXISTS" pattern implementing relational division, a direct application of universal-to-existential quantifier negation.
Example: Formal specification: sortedness invariant
A sorting routine's postcondition is specified as over an array of length . A verifier wants to check the specific instance at . Which inference rule justifies extracting from the postcondition, and what is the resulting formula?
Solution
Let denote . The postcondition is .
By the soundness of universal instantiation proved above, for any term in the domain — here take : from we validly infer , i.e. .
Since is true whenever (a side condition the verifier checks separately, e.g. from the array's declared length), Modus Ponens then yields as desired — exactly the instance the verifier wanted to check, obtained by chaining universal instantiation with Modus Ponens.
Which formula is logically equivalent to ?
With domain and meaning "", which of these is TRUE?
SQL's `NOT EXISTS (... WHERE NOT P ...)` pattern implements which quantifier over ?
Given is true in structure , which conclusion is justified by universal instantiation for a term ?
References
- Herbert B. Enderton (2001). A Mathematical Introduction to Logic
- David Hilbert, Wilhelm Ackermann (1928). Grundzüge der theoretischen Logik