Predicate logic explained
“All circles are red. This is a circle. So this is red.” Everyone sees that the conclusion follows, and yet no truth table shows it: the three statements have no parts that a truth table could take apart. What makes the step work is the structure inside the sentences, the objects they speak about and the word “all”. Predicate logic puts that structure into the notation, and with it comes a question propositional logic never had: a sentence is no longer true or false by itself, but true or false in a world.
What a quantifier says
A predicate is a statement with a gap: Circle(x) says that x is a circle, LeftOf(x, y) that x stands further left than y. Fill the gaps with particular objects and you get something true or false; leave them open and you have a property or a relation. The quantifiers close the gaps in the two ways that matter. ∀x A says that A holds whatever object x stands for, and ∃x A that it holds for at least one. So ∀x (Circle(x) → Red(x)) is “every circle is red”, and ∃x (Square(x) ∧ Green(x)) is “some square is green”. Everything else is the familiar propositional machinery: ¬, ∧, ∨, → and ↔, with ¬ binding tightest and ↔ loosest. One more thing is usually added, the equals sign: x = y says that x and y are the same object, which is what lets logic count.
Truth in a structure
A sentence of predicate logic has no truth value on its own. To give it one you need a structure, also called a model or an interpretation: a non-empty set of objects, the domain, and for each predicate the list of objects, or pairs of objects, it holds of. The explorer makes the structure visible. The domain is the objects on the board; Circle, Red and Large hold of the objects that look that way, LeftOf and Above compare their columns and rows, Adjacent means side by side in a row or a column, and a, b, c are names you can attach to objects. Then the rules of Alfred Tarski's definition of truth, from 1933, say exactly what the sentence means: ∀x A is true when A comes out true for every object in turn, ∃x A when it comes out true for at least one. The explorer follows those rules step by step and keeps the object that decided each one, which is why it can show a witness for a true ∃ and a counterexample for a false ∀.
Scope, bound and free variables
A quantifier reaches over a part of the formula, its scope, and the variable it introduces is bound inside it. A variable outside any such scope is free, and a formula with a free variable is not a sentence: Circle(x) → Red(x) is neither true nor false, it is a property that some objects have and others do not. This is the most common slip in writing logic, and it comes from the scope being shorter than intended. In ∀x Circle(x) → Red(x) the quantifier stops at Circle(x), so the sentence says “if everything is a circle, then x is red”, with x free. Brackets fix it: ∀x (Circle(x) → Red(x)). Which letters stand for what is a matter of convention, and the usual one is followed here: x, y, z and the letters near them are variables, a, b, c near the front of the alphabet are names.
Why ∀x ∃y is not ∃y ∀x
Two quantifiers of different kinds do not commute, and this is where careful reading pays. ∀x ∃y Adjacent(x, y) says that every object has something next to it: the y may be a different one for each x. ∃y ∀x Adjacent(x, y) says that one single object is next to all of them. The second is the stronger claim, and it implies the first whenever the world is not empty, never the other way round. The same shape appears all over mathematics: for every ε there is a δ (continuity) says much less than there is a δ for every ε (uniform continuity), and for every number there is a larger prime is true while there is a prime larger than every number is false. Two quantifiers of the same kind do commute: ∀x ∀y and ∀y ∀x say the same thing, and so do ∃x ∃y and ∃y ∃x.
Vacuous truth and the empty case
“Every square in this world is red” is true when there is no square at all, because an implication with a false if-part is true and so no object can be a counterexample. The same world also makes “no square is red” true, which looks like a contradiction until you see that both sentences only say what happens if there is a square. Mathematicians live with this: every element of the empty set has any property you like, and the convention keeps the laws of logic simple. When something must really exist, the sentence has to say so: ∃x Square(x) ∧ ∀x (Square(x) → Red(x)). The limiting case is the empty world, where every sentence beginning with ∀ is true and every sentence beginning with ∃ is false. Standard first-order logic in fact forbids an empty domain, so that ∀x A always implies ∃x A; the explorer still lets you empty the board, because seeing a ∀ turn true with nothing on it is the quickest way to understand the convention.
Counting with equality
The quantifiers alone cannot count, but with = they can. “There is at least one triangle” is ∃x Triangle(x); “at least two” is ∃x ∃y (x ≠ y ∧ Triangle(x) ∧ Triangle(y)), where the x ≠ y does the work. “At most two” says that among any three triangles two must coincide: ∀x ∀y ∀z ((Triangle(x) ∧ Triangle(y) ∧ Triangle(z)) → (x = y ∨ x = z ∨ y = z)). Put the last two together and you have exactly two. Exactly one has a shorter form, ∃x (Triangle(x) ∧ ∀y (Triangle(y) → y = x)), which is the pattern behind the ∃! of ordinary mathematical writing and behind Bertrand Russell's analysis of “the” in his theory of descriptions of 1905.
Equivalent forms
Some rewritings always keep the meaning. A negation moves through a quantifier and swaps it: ¬∀x A is the same as ∃x ¬A, and ¬∃x A the same as ∀x ¬A, the quantifier form of De Morgan's laws. Pushing every negation inwards until only predicates are negated gives the negation normal form. Pulling every quantifier out to the front gives the prenex form, such as ∀x ∃y (¬Circle(x) ∨ Adjacent(x, y)); this needs care, because a variable may have to be renamed, and it holds only when the domain is not empty. The explorer shows both forms for the selected sentence and you can check them against the current world. What cannot be moved is the order of a ∀ and an ∃, which is precisely the point of the section above.
From Frege to the limits of logic
Gottlob Frege's Begriffsschrift of 1879 introduced quantifiers and bound variables, in a two-dimensional notation almost nobody adopted; Charles Sanders Peirce, with his student Oscar Howard Mitchell, arrived at quantifiers independently in 1885, and the symbols ∀ and ∃ we use today came later, ∃ from Giuseppe Peano and ∀ from Gerhard Gentzen. The theory that followed drew a sharp line. Kurt Gödel proved in his dissertation of 1929, published in 1930, that first-order logic is complete: every sentence true in all structures can be derived in a finite proof. But Alonzo Church and Alan Turing showed, independently in 1936, that no program can decide for every sentence whether it is valid; the best possible is a search that always halts when the sentence is valid and may run forever when it is not. Truth in finite structures is no easier: Boris Trakhtenbrot proved in 1950 that it, too, is undecidable. Small fragments are well behaved, among them the one-place predicates, shown decidable by Leopold Löwenheim in 1915. This is why the explorer searches only up to a bounded size and says how far it looked.
Explore it
Open the explorer to build a world and test sentences in it. Click a cell to add an object, drag it to move it, give it a shape, a colour, a size and a name, and type as many sentences as you like: each is marked true or false and the marks follow every change. Select one to see why, with the deciding object ringed on the board and an evaluation tree that walks through the quantifiers one object at a time. The lessons go through the classic pitfalls — ∀∃ against ∃∀, → against ∧ after a quantifier, vacuous truth, negating a quantifier, counting with = — and three challenges ask you to change the world until the sentences come out as required, one of which cannot be done and shows why.
Frequently asked questions
Is predicate logic the same as first-order logic?
In practice yes. “Predicate logic” is the general name for logic with predicates and quantifiers; “first-order” adds that the quantifiers range over objects only. Second-order logic also quantifies over properties and relations, which allows sentences such as “every property either holds of this object or does not”, and loses the completeness theorem in exchange. The explorer is first-order, with one-place and two-place predicates and the equals sign.
Why is ∀x (Circle(x) → Red(x)) written with an arrow?
Because the sentence is about all objects, not only about circles: it says of each object that if it is a circle, it is red. ∀x (Circle(x) ∧ Red(x)) would say that every object is a red circle, which is a much stronger claim and is false as soon as anything else is on the board. The same difference runs the other way for ∃: “some square is green” needs ∧, because ∃x (Square(x) → Green(x)) is already true of anything that is not a square.
Can a computer check whether two sentences always mean the same?
Only up to a point. Testing them in one world is easy, and testing all worlds up to a given size is a matter of time. But no program can decide for every pair of first-order sentences whether they agree in every structure, by the result of Church and Turing. A finite search that finds no difference is therefore evidence, not proof: it rules out the small worlds and leaves the rest open. The known equivalences, such as ¬∀x A ≡ ∃x ¬A, are proved once and for all by the rules of the semantics, not by trying worlds.
What is a counterexample, exactly?
For a false ∀x A, an object that makes A false: it alone refutes the claim about all objects. For a true ∃x A the matching notion is a witness, an object that makes A true. In a nested sentence the two combine: to refute ∀x ∃y A you need an x for which no y works, and the explorer shows that as a counterexample for the ∀ and a “no object works” line for the ∃ under it.
Ready to try it?
Open PictorX in your browser — no install, no credit card required to start.
Open the predicate logic explorer