Formal Methods 101: Second-Order (and Higher-Order) Logic

This is part 5 of the Formal Methods 101 series. Second-order logic extends first-order logic so that it can quantify over sets. First-order logic may only quantify over the variables in a domain of discourse (a set); second-order logic may also quantify over sets themselves.

What second-order logic adds

In first-order logic a quantifier picks out single elements of the domain. In second-order logic a quantifier can also pick out whole sets of those elements, so we can state properties of sets and not only of individual elements. Second-order logic is even more expressive than first-order logic, and it can be used to build more extensive and complex models of a domain of discourse.

Three rows. First-order logic quantifies over single elements of the domain D: one dot is picked out. Second-order logic quantifies over sets of elements: a group of three dots is circled. Third-order logic quantifies over sets of sets: three overlapping groups of dots are circled together.
Each order of logic quantifies over what the order below it ranges over: elements, then sets of elements, then sets of sets.

An example expression

Here is an example second-order expression, with the set variables T and Q written in the same way as the element variables:

(∃T)(∀Q)(∀D)(∃A)((T ⊂ Q) ∧ (A, D ∈ T) ∧ ((C(x, y) ∧ ¬D) → ((A ∧ E(t, z)) ∨ F)))

This is read: there exists a set T, for all sets Q, for all D, there exists an A, such that the set T is a proper subset of a set from Q, and A and D are elements of the set T, and C and not D implies A and E, or F.

Higher-order logics

Higher-order logics (third, fourth, fifth order, and so on) extend the quantification operators to quantifications over quantifications over quantifications, and so on. This is analogous to types of types of types in type theory, which is the connection to the types of programming languages.