Predicates and Quantifiers
Propositional logic cannot express statements such as "every prime greater than is odd" without flattening the whole sentence into one atomic symbol. Predicate logic opens the sentence and exposes its variables. A predicate such as becomes a proposition only after is assigned a value or after a quantifier says how broadly is being asserted.
This is the language used for definitions, theorems, loop invariants, database queries, and specifications. Universal quantifiers support claims about all objects in a domain. Existential quantifiers support claims that at least one object exists. Much of proof writing is the disciplined process of introducing, transforming, and eliminating these quantifiers.
Definitions
A predicate or propositional function is a statement containing variables. For example, : "" is not a proposition until the domain of is known and is given a value or quantified. Over the real numbers, is true. Over the same domain, : "" is true for some values but not all.
The domain of discourse is the set of objects a variable is allowed to represent. Changing the domain can change the truth value. The statement is false over the real numbers, false over the integers, but true over the nonnegative integers only for or ; if the domain is , it is true.
The two basic quantifiers are:
- Universal quantifier: means " is true for every in the domain."
- Existential quantifier: means "there is at least one in the domain for which is true."
A unique existence statement, written , means there is exactly one object satisfying . It abbreviates
Variables inside a quantifier's scope are bound. Variables not bound by a quantifier are free. A formula with free variables is not a complete proposition until those variables are assigned or quantified.
Key results
Negating quantified statements reverses the quantifier and negates the predicate:
These are De Morgan laws for quantifiers. The first says that to refute "everyone has property ," it is enough to find one counterexample. The second says that to refute "someone has property ," one must show that no object has it.
Quantifier order matters. In general,
is not equivalent to
The first allows to depend on . The second requires one single that works for every . For example, over the integers, is true, because each integer has a larger integer. But is false, because no fixed integer is larger than every integer.
Universal statements are usually proved by choosing an arbitrary element of the domain and proving the predicate for it. Existential statements are usually proved by constructing a witness. To disprove a universal statement, produce a counterexample. To disprove an existential statement, prove a universal negation.
Nested quantifiers also interact with implication. The statement
does not assert that any object satisfies . It asserts that every object that satisfies also satisfies . This is why mathematical definitions often have the form "for all , if has the hypotheses, then has the conclusion."
Visual
| Claim form | Meaning | How to prove | How to disprove |
|---|---|---|---|
| every object works | take arbitrary and prove | find one with | |
| at least one object works | give a witness and prove | prove | |
| each has a possibly different | give a rule for in terms of | find one with no possible | |
| one works for all | give a single universal witness | show every candidate fails for some |
Worked example 1: Negate a nested statement
Problem. Let the domain be the integers. Negate the statement
Then decide whether the original statement is true.
Method.
- Start with the negation:
- Move the negation through the universal quantifier:
- Move the negation through the existential quantifier:
- Apply De Morgan's law inside:
Checked answer. The negation says: "There is an integer such that every integer is either not greater than or is not even." The original statement is true. Given any integer , choose if and choose if . In both cases is even and . The chosen is allowed to depend on , which is exactly what permits.
Worked example 2: Compare quantifier orders
Problem. Over the real numbers, compare the truth values of:
and
Method.
- For , choose an arbitrary real number .
- We need a real number satisfying .
- The equation gives , which is a real number.
- Therefore each has a witness, so the first statement is true.
- For , suppose a single real number worked for every .
- Taking gives .
- Taking gives , so .
- No single can be both and .
Checked answer. The first statement is true and the second is false. The only difference is quantifier order. In the first, may depend on ; in the second, one fixed must work for all .
Code
def forall(domain, predicate):
return all(predicate(x) for x in domain)
def exists(domain, predicate):
return any(predicate(x) for x in domain)
domain = range(-5, 6)
statement1 = forall(
domain,
lambda x: exists(domain, lambda y: x + y == 0),
)
statement2 = exists(
domain,
lambda y: forall(domain, lambda x: x + y == 0),
)
print(statement1)
print(statement2)
On the finite sample domain , the output is True and False. Finite testing is not a proof over all real numbers, but it reflects the same quantifier-order difference that the proof establishes.
Common pitfalls
- Forgetting to state the domain. A quantified formula can change truth value when the domain changes.
- Reversing quantifier order. usually means "a custom response for each input"; means "one response fits all inputs."
- Negating only the predicate and forgetting to flip the quantifier.
- Treating as "many." It means at least one unless uniqueness is explicitly stated.
- Proving a universal statement by testing several examples. Examples can suggest a proof, but they do not prove "for all."
- Using a special element when proving a universal statement. The chosen element must be arbitrary.
When translating English, identify the domain before choosing quantifiers. "Every student has taken a math course" might mean every student in a class, every student at a university, or every student in some database table. The predicate and the truth value both depend on this domain. A good translation states the domain in words or in the formula.
Restricted quantifiers can be written with implications or conjunctions. "Every prime greater than is odd" becomes . "There exists a prime greater than " becomes . Universal restrictions usually use implication; existential restrictions usually use conjunction. Reversing these patterns changes the meaning.
For nested quantifiers, read from left to right while tracking dependency. In , the witness may be chosen after seeing . In , the witness is chosen before any and must work for all of them. This dependency is often the whole point of the statement.
A useful translation check is to negate the formula and see whether the result matches the ordinary-language failure case. The negation of "every server has a backup" should be "some server has no backup." If the symbolic negation says something different, the original quantifier or connective was probably mistranslated.
When a statement contains several variables, specify whether they share a domain. In over integers, both variables are integers. In applied settings, might range over users while ranges over permissions or files. Mixed-domain predicates should make each variable's type explicit.
Connections
- Propositional logic supplies the connectives inside quantified formulas.
- Proof techniques explains arbitrary-element proofs, counterexamples, and existence proofs.
- Sets and set operations provides domains, membership, and subset language.
- Relations expresses properties such as reflexive and transitive with quantified statements.