Mathematical Logic: Foundations, Proof, and Computation
Mathematical logic studies the formal systems underlying all of mathematics. From propositional connectives to Gödel's incompleteness theorems, from Turing machines to type theory, this field answers the deepest questions about what can be proved, what can be computed, and what mathematical truth itself means.
1. Propositional Logic
Propositional logic is the simplest formal system, capturing reasoning about atomic statements combined with logical connectives. Every statement is either true or false — no quantification, no internal structure. Despite its simplicity, propositional logic underlies circuit design, SAT solving, and classical deduction.
Syntax and Connectives
A propositional formula is built from atomic propositions (p, q, r, ...) using connectives. The standard connectives are negation (NOT), conjunction (AND), disjunction (OR), implication (IMPLIES), and biconditional (IFF). Any formula can be written using only NOT and AND, or using only NOT and OR — these minimal sets are called functionally complete bases. Even a single connective suffices: NAND (NOT AND) is by itself functionally complete.
Standard connectives with precedence (highest to lowest):
- NOT p negation, unary, highest precedence
- p AND q conjunction
- p OR q disjunction
- p IMPLIES q implication, right-associative
- p IFF q biconditional, lowest precedence
Truth Tables
A truth table lists the truth value of a compound formula for every possible assignment of truth values to its atomic propositions. For n propositions there are 2^n rows. Truth tables provide a complete decision procedure for propositional logic — a formula is a tautology if and only if every row shows TRUE.
Key connective truth tables:
| p | q | NOT p | p AND q | p OR q | p IMPLIES q | p IFF q |
|---|---|---|---|---|---|---|
| T | T | F | T | T | T | T |
| T | F | F | F | T | F | F |
| F | T | T | F | T | T | F |
| F | F | T | F | F | T | T |
Note: p IMPLIES q is FALSE only when p is TRUE and q is FALSE — the vacuous truth of implication with false antecedent.
Tautologies and Logical Equivalences
A tautology is a formula true under every truth assignment. A contradiction is always false. Two formulas are logically equivalent if they have identical truth tables. The most important equivalences form the algebraic laws of propositional logic.
Fundamental logical equivalences:
- Double negation: NOT NOT p equiv p
- De Morgan 1: NOT (p AND q) equiv (NOT p) OR (NOT q)
- De Morgan 2: NOT (p OR q) equiv (NOT p) AND (NOT q)
- Contrapositive: (p IMPLIES q) equiv (NOT q IMPLIES NOT p)
- Implication: (p IMPLIES q) equiv (NOT p OR q)
- Distributivity: p AND (q OR r) equiv (p AND q) OR (p AND r)
- Absorption: p AND (p OR q) equiv p
- Idempotence: p AND p equiv p
Normal Forms: CNF and DNF
Every propositional formula can be converted to two standard forms. A literal is an atomic proposition or its negation. A clause is a disjunction of literals. Conjunctive Normal Form (CNF) is a conjunction of clauses — the standard input for SAT solvers. A minterm is a conjunction of literals. Disjunctive Normal Form (DNF) is a disjunction of minterms.
Conversion algorithm to CNF:
- Eliminate biconditionals: (p IFF q) becomes (p IMPLIES q) AND (q IMPLIES p)
- Eliminate implications: (p IMPLIES q) becomes (NOT p OR q)
- Push negations inward using De Morgan's laws
- Eliminate double negations
- Distribute AND over OR to flatten into conjunction of clauses
CNF is central to automated reasoning because SAT solvers work directly on CNF formulas using the DPLL algorithm or CDCL (Conflict-Driven Clause Learning). The satisfiability problem for CNF is NP-complete (3-SAT is the canonical instance).
2. Predicate Logic (First-Order Logic)
First-order logic (FOL) extends propositional logic with a richer language: variables ranging over a domain, function symbols, relation symbols (predicates), and quantifiers. It is the standard formal language of mathematics — virtually all classical mathematics can be expressed in first-order logic over appropriate axioms.
Syntax: Terms and Formulas
A first-order signature specifies constant symbols, function symbols (with arities), and relation symbols (with arities). Terms are built from variables and constants using function symbols. Atomic formulas apply a relation symbol to terms. Complex formulas combine atomics with propositional connectives and quantifiers.
Grammar of first-order formulas:
- Terms: variables x, y, z | constants c | f(t1,...,tn)
- Atoms: R(t1,...,tn) | t1 = t2
- Formulas: atom | NOT phi | phi AND psi | phi OR psi
- | phi IMPLIES psi | FORALL x. phi | EXISTS x. phi
Free and Bound Variables
A variable occurrence is bound if it falls within the scope of a quantifier binding that variable, and free otherwise. A sentence is a formula with no free variables — sentences have definite truth values in a given interpretation. Formulas with free variables express properties depending on how those variables are assigned.
Examples:
- FORALL x. (P(x) IMPLIES Q(x)) -- sentence, no free variables
- P(x) IMPLIES Q(y) -- x and y are free
- FORALL x. P(x, y) -- x is bound, y is free
- EXISTS x. (x gt 0 AND x lt y) -- x is bound, y is free
Interpretations and Models
An interpretation (or structure) for a signature consists of: a non-empty domain D, an element of D for each constant, a function on D for each function symbol, and a relation on D for each relation symbol. A sentence is true in an interpretation if it holds when evaluated in that domain.
A model of a theory T is an interpretation in which every sentence of T is true. Semantic consequence (T entails phi, written T |= phi) means phi is true in every model of T. The central concern of model theory is the relationship between theories and their models.
Key concept: Satisfiability vs. Validity
- Satisfiable: true in at least one interpretation
- Valid (tautology): true in every interpretation
- Unsatisfiable: true in no interpretation
- phi is valid iff NOT phi is unsatisfiable — used by resolution provers
Quantifier Laws and Prenex Normal Form
Quantifiers obey important laws governing their interaction with connectives and each other. Every first-order formula can be converted to Prenex Normal Form (PNF): a string of quantifiers followed by a quantifier-free matrix. PNF is used in the Herbrand theorem and undecidability proofs.
Quantifier duality laws:
- NOT FORALL x. P(x) equiv EXISTS x. NOT P(x)
- NOT EXISTS x. P(x) equiv FORALL x. NOT P(x)
- FORALL x. (P(x) AND Q(x)) equiv (FORALL x. P(x)) AND (FORALL x. Q(x))
- EXISTS x. (P(x) OR Q(x)) equiv (EXISTS x. P(x)) OR (EXISTS x. Q(x))
- FORALL x. FORALL y. P(x,y) equiv FORALL y. FORALL x. P(x,y)
3. Proof Systems
A proof system provides formal rules for deriving conclusions from premises. The central meta-theoretic properties are soundness (every provable formula is valid) and completeness (every valid formula is provable). Different proof systems trade off between human readability and mathematical tractability.
Natural Deduction
Natural deduction, introduced by Gentzen in 1935, provides introduction and elimination rules for each connective. Proofs are trees of formulas. A key feature is the discharge of assumptions: from an assumption A derive B, then discharge A to conclude A IMPLIES B. This mirrors actual mathematical practice.
Selected natural deduction rules:
- AND-Intro: from A and B, derive A AND B
- AND-Elim: from A AND B, derive A (or B)
- IMPLIES-Intro: from B under assumption A, derive A IMPLIES B
- IMPLIES-Elim: from A and A IMPLIES B, derive B (modus ponens)
- FORALL-Intro: from P(x) with x not free in assumptions, derive FORALL x. P(x)
- FORALL-Elim: from FORALL x. P(x), derive P(t) for any term t
- EXISTS-Intro: from P(t), derive EXISTS x. P(x)
- RAA: from NOT A deriving contradiction, derive A (classical)
Sequent Calculus
Gentzen's sequent calculus LK operates on sequents of the form Gamma |- Delta, meaning: if all formulas in Gamma hold, then at least one formula in Delta holds. Structural rules (weakening, contraction, exchange) manipulate the context. Logical rules introduce connectives on left or right. The key result is the cut-elimination theorem: any proof using the cut rule can be converted to a cut-free proof.
Cut rule (the central structural rule):
From (Gamma |- A, Delta) and (Gamma', A |- Delta'), conclude (Gamma, Gamma' |- Delta, Delta')
Cut-elimination (Gentzen's Hauptsatz) shows cut is admissible — proofs without it have the subformula property, making them analyzable by inspection.
Resolution
Resolution, introduced by Robinson in 1965, is the basis for automated theorem proving and logic programming (Prolog). The resolution rule: from clause (A OR C) and clause (NOT A OR D), derive clause (C OR D). To prove a formula phi, negate it, convert to CNF, and apply resolution until the empty clause (contradiction) is derived.
Hilbert Systems
Hilbert-style systems use a small set of axiom schemas and typically only modus ponens as an inference rule. Though proofs are cumbersome for humans, Hilbert systems are mathematically clean and easy to reason about meta-theoretically. The deduction theorem — if T plus A proves B then T proves A IMPLIES B — is a key meta-theorem.
Soundness and Completeness
Soundness: if phi is provable in the system, then phi is logically valid. Completeness: if phi is logically valid, then phi is provable. Together they mean proof and truth coincide. For propositional logic, truth tables give a simple decision procedure. For first-order logic, Gödel's completeness theorem (1929) establishes this equivalence.
4. Gödel's Completeness Theorem
Kurt Gödel's 1929 doctoral dissertation proved that first-order logic is complete. This established FOL as the right formal language for mathematics and culminated efforts to give logic solid meta-theoretic foundations.
Statement
Gödel's Completeness Theorem (1929): Let T be a set of first-order sentences and phi a first-order sentence. Then T semantically entails phi (every model of T satisfies phi) if and only if phi is syntactically derivable from T (there is a formal proof of phi from T).
Equivalently: a set of sentences T is satisfiable if and only if T is consistent (no contradiction is derivable from T).
Significance
Completeness means the proof rules of first-order logic are adequate — they capture all logical truths. If something is true in every model, there is always a finite proof of it. This justifies the axiomatic method: to reason about all models of a theory, it suffices to reason syntactically from the axioms.
The completeness theorem should not be confused with completeness of specific theories. First-order logic (the proof system) is complete. But specific theories like Peano arithmetic are incomplete — Gödel's incompleteness theorem addresses this distinct phenomenon.
Henkin Construction
The standard proof of completeness uses the Henkin construction. Given a consistent theory T, one builds a maximal consistent extension T* by adding new witness constants (Henkin constants) for each existential statement. The canonical model has the equivalence classes of terms as its domain, with interpretation determined by T*. This model satisfies exactly T.
Henkin construction steps:
- Extend the language with countably many new constant symbols c_1, c_2, ...
- Enumerate all sentences of the extended language
- Iteratively: if EXISTS x. P(x) is consistent with the current set, add P(c_i) for a fresh constant
- Complete to a maximal consistent set using a Lindenbaum-style construction
- Build the term model: domain = equivalence classes of closed terms under provable equality
- Verify this model satisfies every sentence in the maximal consistent set
5. Gödel's Incompleteness Theorems
In 1931, two years after his completeness theorem, Gödel published the most profound results in the history of mathematical logic. The incompleteness theorems showed that Hilbert's program — finding a complete, consistent, decidable axiomatization of all mathematics — is impossible.
Peano Arithmetic and Sufficient Strength
The theorems apply to any formal system F satisfying: (1) F is consistent, (2) F is recursively axiomatizable, and (3) F is sufficiently strong to express elementary arithmetic — specifically Peano Arithmetic (PA) or even the weaker Robinson arithmetic Q.
Peano Arithmetic key axioms:
- PA1: FORALL x. (S(x) not= 0) -- zero is not a successor
- PA2: FORALL x y. (S(x) = S(y) IMPLIES x = y) -- successor is injective
- PA3-4: Definitions of addition and multiplication by recursion
- PA5 (Induction schema): for each formula phi(x):
- (phi(0) AND FORALL x.(phi(x) IMPLIES phi(S(x)))) IMPLIES FORALL x. phi(x)
Gödel Numbering
The technical core of the incompleteness proofs is Gödel numbering: a systematic encoding of syntactic objects (symbols, formulas, proofs) as natural numbers. Each symbol gets a number; a sequence is encoded using prime factorization. This allows arithmetic to talk about its own syntax — every statement about provability becomes a statement about natural numbers.
Crucially, the provability predicate Prov(n) — meaning the formula with Gödel number n is provable in F — is expressible in the language of arithmetic. This enables self-reference via the Fixed Point (Diagonal) Lemma.
First Incompleteness Theorem
First Incompleteness Theorem: Any consistent formal system F that is sufficiently strong to express basic arithmetic contains a sentence G_F such that neither G_F nor its negation is provable in F. Therefore F is incomplete.
The Gödel sentence G_F is constructed by the Fixed Point Lemma to satisfy: G_F is equivalent (in F) to the claim that G_F is not provable in F. If F proves G_F, then G_F is false — contradiction. If F proves NOT G_F, then G_F is true but F has proved its negation — contradiction (by Rosser's improvement, just consistency suffices). Therefore neither is provable. G_F is in fact true in the standard model of arithmetic.
Second Incompleteness Theorem
Second Incompleteness Theorem: No consistent formal system F satisfying the above conditions can prove its own consistency. The sentence Con(F) expressing that F is consistent is not provable in F.
The proof shows that if F proved Con(F), it could prove G_F — but G_F is unprovable. Con(F) can be expressed arithmetically as the claim that no Gödel number of a proof of 0=1 exists. The second theorem ended Hilbert's hope of finding a finitary consistency proof for all of mathematics within mathematics itself.
6. Computability Theory
Computability theory studies what can in principle be computed by an ideal machine with unlimited time and memory. It was developed independently by Turing, Church, Kleene, and Post in the 1930s, and the equivalence of their formalisms is a profound mathematical fact in itself.
Turing Machines
A Turing machine consists of: a finite set of states Q, a finite tape alphabet (including a blank symbol), a transition function delta(state, symbol) = (new state, new symbol, direction L/R), an initial state, and halting states. The machine reads and writes on an infinite tape, moving left or right. A function is Turing-computable if some Turing machine computes it — halting with the output whenever the function is defined, running forever otherwise.
Key Turing machine variants (all equivalent in power):
- Multi-tape TM: multiple tapes and heads — polynomially faster but same power
- Non-deterministic TM: chooses among transitions; accepts if any branch accepts
- Universal TM: takes a description of TM M and input w, simulates M on w
- Oracle TM: has access to a black-box oracle; used in recursion theory hierarchy
Church-Turing Thesis
The Church-Turing thesis is the informal claim that any function computable by an effective procedure is Turing-computable. This is not a theorem — it cannot be proved because "effective procedure" is informal. But every proposed model of computation (lambda calculus, recursive functions, Post systems, RAM machines, cellular automata) turns out equivalent to Turing machines.
The Halting Problem
The halting problem is the canonical undecidable problem. Turing's 1936 proof is a masterpiece of diagonalization.
Proof sketch (by contradiction):
- Assume H is a TM deciding HALT: H(M, w) = YES iff M halts on w
- Construct D(M): run H(M, M); if YES then loop forever; if NO then halt
- Run D(D): H(D,D)=YES means D halts on D — but D loops. Contradiction.
- H(D,D)=NO means D does not halt on D — but D halts. Contradiction.
- Therefore H cannot exist.
Rice's Theorem
Rice's theorem vastly generalizes the halting problem: any non-trivial semantic property of programs is undecidable. A property of partial functions is non-trivial if it is neither true of all functions nor false of all functions. Examples: whether a program computes a total function, whether it outputs 42 on some input, whether it computes the same function as another program — all undecidable by Rice's theorem.
Rice's theorem explains why program analysis is fundamentally limited: no general-purpose static analyzer can decide any interesting property of program behavior. Practical static analyzers are necessarily either unsound or incomplete.
Degrees of Unsolvability
Not all undecidable problems are equal. The Turing degree of a problem A is the equivalence class of problems Turing-reducible to A and vice versa. The halting problem is Turing-complete for the class of recursively enumerable (r.e.) sets. There exist infinitely many incomparable Turing degrees between decidable and the halting problem. The arithmetic hierarchy classifies problems by the quantifier alternation needed to define them.
7. Decidability of Theories
A first-order theory T is decidable if there exists an algorithm that determines, for any first-order sentence phi, whether T proves phi. Decidability results identify theories where automated reasoning is possible; undecidability results explain where it is not.
Decidable Theories
Important decidable theories:
- Presburger Arithmetic: first-order theory of natural numbers with addition only (no multiplication). Decidable by quantifier elimination. Used in hardware verification and compiler optimizations.
- Tarski's Real Closed Fields: first-order theory of the real numbers with addition, multiplication, and order. Decidable by quantifier elimination (Tarski, 1948). Every statement about real algebraic geometry is decidable.
- Propositional logic: decidable by truth tables (co-NP complete). All tautologies can be verified, but verification may take exponential time.
- Theory of algebraically closed fields: first-order theory of the complex numbers is decidable by quantifier elimination (Chevalley's theorem).
- Monadic second-order logic over trees: decidable (Rabin 1969). Underlies decidability of many program logics and XML querying.
Undecidable Theories
Important undecidable theories:
- Peano Arithmetic (PA): undecidable by Gödel's theorems.
- Natural numbers with multiplication: adding multiplication to Presburger arithmetic jumps from decidable to undecidable.
- First-order logic itself: validity in first-order logic is undecidable (Church-Turing, 1936).
- Hilbert's Tenth Problem: deciding whether a Diophantine equation has integer solutions is undecidable (Matiyasevich, 1970).
Quantifier Elimination
A theory T admits quantifier elimination if every first-order formula is provably equivalent in T to a quantifier-free formula. Quantifier elimination directly yields decidability for theories with decidable quantifier-free fragments. The technique involves showing that existential quantifiers can be eliminated by algebraic manipulation, then iterating for nested quantifiers.
8. Model Theory
Model theory studies the relationship between formal languages and their interpretations (models). It asks: what structures satisfy a given theory? How do different models of the same theory relate? What properties can first-order logic express?
Compactness Theorem
Compactness Theorem: A set of first-order sentences T has a model if and only if every finite subset of T has a model.
Compactness follows from the completeness theorem: if every finite subset is satisfiable, every finite subset is consistent, hence T is consistent (by finiteness of proofs), hence T has a model. Applications include constructing non-standard models. Take T = PA plus sentences saying a new constant c exceeds each standard number. Every finite subset is satisfiable, so by compactness T has a model containing an element larger than every standard natural — a non-standard model with "infinite" elements.
Löwenheim-Skolem Theorems
- Downward LS theorem: If a countable first-order theory has an infinite model, it has a countable model. First-order theories cannot rule out smaller models.
- Upward LS theorem: If T has an infinite model, it has models of every infinite cardinality. First-order theories cannot characterize a structure up to isomorphism if that structure is infinite.
- Skolem's paradox: ZFC set theory, which proves uncountable sets exist, has a countable model. The set R in that model is "uncountable" in the model's internal sense, but the model itself is countable from outside. Resolution: uncountability is relative to what bijections exist in the model.
Elementary Equivalence
Two structures M and N are elementarily equivalent (M equiv N) if they satisfy the same first-order sentences. Elementary equivalence is weaker than isomorphism — non-isomorphic structures can be elementarily equivalent. For example, the ordered field of real numbers R is elementarily equivalent to any non-standard real closed field, even though they are not isomorphic.
Ultraproducts
Given structures M_i (for i in an index set I) and an ultrafilter U on I, the ultraproduct is a new structure whose elements are equivalence classes of functions from I to the union of the M_i, with two functions identified if they agree on a set in U. By Los's theorem, a first-order sentence holds in the ultraproduct iff the set of indices where it holds is in U. Ultraproducts provide a powerful construction tool — non-standard analysis can be developed rigorously via ultraproducts of the reals.
9. Proof Theory
Proof theory studies proofs as mathematical objects, analyzing their structure, complexity, and information content. It was Hilbert's original approach to foundations, and though incompleteness showed its limits, proof theory remains vibrant with connections to computability and ordinal analysis.
Gentzen's Cut Elimination
The cut rule in sequent calculus allows using a lemma: derive A somewhere, then use A elsewhere. Cut elimination (Hauptsatz) proves that any proof with cuts can be transformed into a cut-free proof — at the cost of potentially enormous size increase (non-elementary in general).
Cut-free proofs have the subformula property: every formula appearing in the proof is a subformula of the endsequent. This makes cut-free proofs analyzable and yields consistency proofs. A cut-free proof of a contradiction in LK would have to contain the contradiction as a subformula from the start, which is impossible.
Ordinal Analysis
Gentzen proved consistency of PA in 1936 using transfinite induction up to the ordinal epsilon_0 (the smallest ordinal satisfying omega^x = x). This ordinal is the proof-theoretic ordinal of PA — a measure of the theory's strength. Each theory has a characteristic ordinal measuring how much transfinite induction it can prove.
Proof-theoretic ordinals of key theories:
- Robinson arithmetic Q: omega (weakest arithmetic)
- Primitive recursive arithmetic: omega^omega
- Peano arithmetic PA: epsilon_0
- ATR_0 (analysis): Gamma_0 (Feferman-Schütte ordinal)
- Pi_1^1-CA_0: Bachmann-Howard ordinal
Reverse Mathematics
Reverse mathematics, pioneered by Friedman and Simpson, asks which axioms are actually necessary to prove standard mathematical theorems. Working over a weak base theory (RCA_0, roughly computable mathematics), one determines the exact subsystem of second-order arithmetic needed for each theorem. Remarkably, most theorems fall into one of five systems (the "Big Five"), suggesting deep structural reasons for their equivalence.
10. Set Theory Connections
Set theory provides the standard foundational framework for all of mathematics. The Zermelo-Fraenkel axioms with Choice (ZFC) are the accepted foundation, and mathematical logic studies both what ZFC can prove and what it cannot.
ZFC Axioms
The ZFC axioms:
- Extensionality: sets with the same elements are equal
- Empty set: there exists a set with no elements
- Pairing: for any a, b, the set containing exactly a and b exists
- Union: for any set A, the union of all elements of A exists
- Power set: for any set A, the set of all subsets of A exists
- Infinity: there exists an infinite set containing 0 and closed under successor
- Separation schema: for any set A and formula phi, the subset satisfying phi exists
- Replacement schema: the image of a set under a definable function is a set
- Foundation: every non-empty set has a membership-minimal element
- Choice (AC): every family of non-empty sets has a choice function
Independence Results
Gödel (1938) showed that the Axiom of Choice and the Continuum Hypothesis (CH, asserting 2^aleph_0 = aleph_1) are consistent with ZF by constructing the constructible universe L. Cohen (1963) showed that AC and CH are independent of ZF and ZFC respectively, using the method of forcing. Forcing builds new models by adjoining generic sets satisfying controlled properties.
Since Cohen, hundreds of set-theoretic statements have been shown independent of ZFC. The independence of CH means that neither "the real numbers have cardinality aleph_1" nor its negation follows from the standard axioms.
Large Cardinals
Large cardinal axioms assert the existence of very large infinite cardinals with strong reflection properties. They form a natural linear hierarchy of consistency strength beyond ZFC: inaccessible cardinals, Mahlo cardinals, measurable cardinals, Woodin cardinals, and supercompact cardinals. These axioms are not provable from ZFC (by the second incompleteness theorem) but are widely accepted as natural and justified by set theorists.
Measurable cardinals (those admitting a non-principal countably complete ultrafilter) are deeply connected to model theory — their existence is equivalent to the existence of a non-trivial elementary embedding from the universe V into a transitive inner model.
11. Type Theory and the Curry-Howard Correspondence
Type theory provides an alternative foundation for mathematics where types play the role of sets and terms play the role of elements. Unlike set theory, type theory is constructive by design and directly corresponds to functional programming — a proof is literally a program.
Simply Typed Lambda Calculus
Church's lambda calculus assigns a type to every term. Types are built from base types (nat, bool) using the function type constructor (A to B). A term of type A to B is a function taking terms of type A to terms of type B. The simply typed lambda calculus is strongly normalizing — all computations terminate — but not Turing-complete.
Type formation and reduction:
- Types: A, B := base | A -> B | A times B | A + B | 1 | 0
- Terms: t := x | lambda x:A. t | t u | (t, u) | fst t | snd t
- Typing: Gamma |- lambda x:A. t : A -> B if Gamma, x:A |- t : B
- Beta reduction: (lambda x:A. t) u --> t[u/x]
The Curry-Howard Correspondence
The Curry-Howard isomorphism reveals that the simply typed lambda calculus is the same thing as intuitionistic propositional logic, viewed from different angles. Propositions are types; proofs are programs.
| Logic | Type Theory / Programming |
|---|---|
| Proposition A | Type A |
| Proof of A | Program of type A |
| A IMPLIES B | Function type A -> B |
| A AND B | Product type A times B |
| A OR B | Sum type A + B |
| True | Unit type 1 (one element) |
| False | Empty type 0 (no elements) |
| FORALL x:A. B(x) | Dependent function type Pi x:A. B(x) |
| EXISTS x:A. B(x) | Dependent pair type Sigma x:A. B(x) |
Dependent Types
Dependent type theory allows types to depend on terms. The dependent function type Pi x:A. B(x) generalizes A to B when B does not depend on x. A term of type Pi x:A. B(x) is a function that takes a:A and produces a term of type B(a). This allows types to express precise specifications: the type of vectors of length n, or the type of proofs that p is prime.
Proof assistants like Coq (based on the Calculus of Constructions), Agda, and Lean use dependent types. In these systems, writing a function of the right type is the same as proving a theorem. The compiler type-checks the proof — no human referee needed.
Homotopy Type Theory (HoTT)
Homotopy Type Theory reinterprets Martin-Löf type theory through the lens of homotopy theory. The key insight (the univalence axiom, due to Voevodsky) is that equivalent types are identical. This gives a natural account of isomorphism invariance. HoTT provides a foundation where types are spaces, and proofs of equality are paths.
12. Applications: Formal Verification and Automated Reasoning
Mathematical logic is not merely foundational philosophy — it underpins practical tools for building reliable software, hardware, and databases.
Formal Verification
Formal verification uses mathematical proof to guarantee that a system meets its specification. Model checking exhaustively explores finite state spaces to verify temporal logic properties (safety: nothing bad ever happens; liveness: something good eventually happens). Deductive verification uses theorem provers to handle infinite-state systems via program annotations in Hoare logic or separation logic.
Notable formal verification achievements:
- CompCert: formally verified C compiler (Coq), used in safety-critical aviation software
- seL4: formally verified operating system microkernel (Isabelle/HOL)
- Flyspeck: formal proof of Kepler's sphere-packing conjecture (HOL Light, 2014)
- Feit-Thompson odd order theorem: formalized in Coq (2012, 170,000 lines)
- Four color theorem: verified by Gonthier in Coq (2005)
SAT Solvers
Modern SAT solvers decide propositional satisfiability for formulas with millions of variables. The DPLL algorithm (Davis-Putnam- Logemann-Loveland, 1962) uses backtracking search with unit propagation and pure literal elimination. CDCL (Conflict-Driven Clause Learning) adds conflict analysis that learns new clauses from dead ends, enabling dramatic performance gains.
SAT solvers are used in chip verification (bounded model checking), automated test generation, planning, and as back-ends for SMT solvers, which handle quantifier-free fragments of first-order theories like linear arithmetic and arrays.
Automated Theorem Proving
Automated theorem provers (ATPs) attempt to prove first-order theorems without human guidance. Resolution-based provers (Vampire, E, SPASS) apply resolution and paramodulation to clausified problems. They compete in the CASC competition on thousands of benchmark problems. ATPs are effective for discrete mathematics and algebraic problems.
Database Query Languages
Relational algebra and SQL are directly rooted in first-order logic. A relational database is a model (interpretation) of a first-order language where relations are table instances. Relational algebra operations (select, project, join, union, difference) correspond to first-order formula operations. Codd's theorem establishes the equivalence of relational algebra and domain relational calculus, a fragment of first-order logic.
Datalog — a restricted logic programming language — has exactly the expressive power of least fixed-point logic on finite structures, and is used in program analysis, knowledge graphs, and network analysis.
Interactive Theorem Provers
Interactive theorem provers (ITPs) require human guidance but verify every step mechanically. The main systems are: Coq (Calculus of Inductive Constructions), Lean 4 (dependent type theory, with the growing Mathlib library), Isabelle/HOL (classical higher-order logic), and Agda (Martin-Löf type theory). ITPs are increasingly used for research-level mathematics.
13. Practice Problems
Work through these problems to solidify your understanding. Click to reveal the solution after attempting each problem.
Problem 1: Truth Tables and Tautologies
Show that (p IMPLIES q) IFF (NOT q IMPLIES NOT p) is a tautology using a truth table, then identify which logical law this demonstrates.
Show Solution
Solution:
Evaluate both sides for all four assignments of p and q:
- p=T, q=T: (T IMPLIES T) IFF (F IMPLIES F) = T IFF T = T
- p=T, q=F: (T IMPLIES F) IFF (T IMPLIES F) = F IFF F = T
- p=F, q=T: (F IMPLIES T) IFF (F IMPLIES T) = T IFF T = T
- p=F, q=F: (F IMPLIES F) IFF (T IMPLIES T) = T IFF T = T
All rows are T, so the formula is a tautology. This demonstrates the contrapositive law: an implication is logically equivalent to its contrapositive. Proving "if NOT q then NOT p" is exactly as strong as proving "if p then q."
Problem 2: CNF Conversion
Convert the formula (p IFF q) to Conjunctive Normal Form (CNF).
Show Solution
Solution:
- Eliminate IFF: (p IFF q) becomes (p IMPLIES q) AND (q IMPLIES p)
- Eliminate IMPLIES: becomes (NOT p OR q) AND (NOT q OR p)
- Check: no nested negations to push in, no AND inside OR
- Result in CNF: (NOT p OR q) AND (NOT q OR p)
This is already in CNF — a conjunction of two clauses. Clause 1 says p implies q; Clause 2 says q implies p. SAT solvers operate directly on these clause sets.
Problem 3: Free and Bound Variables
Identify all free and bound variable occurrences in: FORALL x. (P(x, y) IMPLIES EXISTS y. Q(x, y, z))
Show Solution
Solution:
- x in P(x,y): bound — within scope of FORALL x
- y in P(x,y): FREE — not within scope of any quantifier binding y here
- x in Q(x,y,z): bound — within scope of FORALL x
- y in Q(x,y,z): bound — within scope of EXISTS y
- z in Q(x,y,z): FREE — no quantifier binds z anywhere
Free variables: y (first occurrence only), z. The y in P(x,y) and the y in Q(x,y,z) are distinct — EXISTS y creates a new scope that shadows the outer y. Good practice uses distinct variable names to avoid this confusion.
Problem 4: Applying the Compactness Theorem
Use the compactness theorem to show that if a graph G can be k-colored for every finite subgraph, then G can be k-colored even if G is infinite. Outline the argument.
Show Solution
Solution outline:
- Create a first-order language with a constant c_v for each vertex v and k color constants
- Write sentences: for each vertex v, exactly one of the k color predicates holds of c_v
- Write sentences: for each edge (u,v) and each color i, c_u and c_v cannot both have color i
- Let T be this (potentially infinite) set of sentences
- Every finite subset of T involves finitely many vertices forming a finite subgraph, which is k-colorable by hypothesis — so every finite subset has a model
- By compactness, T has a model, which provides a k-coloring of all of G
Problem 5: Why Gödel Numbering Is Necessary
Explain why Gödel numbering is necessary for the incompleteness theorems. What would go wrong if arithmetic could not talk about its own syntax?
Show Solution
Solution:
The incompleteness proof requires constructing a sentence G that says "G is not provable." For G to say anything about provability, the formal language must express facts about proofs — but proofs are finite syntactic objects that live outside the formal system.
Gödel numbering encodes each formula and proof as a natural number. The provability predicate Prov(n) — true iff n is the Gödel number of a provable formula — becomes an arithmetic predicate. This brings syntax inside the formal system.
Without this encoding, arithmetic cannot achieve the self-reference needed for the diagonal argument. The self-referential sentence G would have no way to refer to itself as a mathematical object. Gödel numbering is what makes the system rich enough to turn on itself.
Problem 6: Curry-Howard Types
Under the Curry-Howard correspondence, what type corresponds to the logical tautology (A IMPLIES (B IMPLIES A))? Write a lambda calculus term of that type.
Show Solution
Solution:
Under Curry-Howard, IMPLIES corresponds to the function type arrow. So A IMPLIES (B IMPLIES A) corresponds to type A -> (B -> A), conventionally written A -> B -> A.
Term: lambda a:A. lambda b:B. a
This term takes an argument a of type A, then an argument b of type B, and returns a — ignoring b entirely. This is the K combinator. The proof of the tautology "if A then (if B then A)" is exactly: given evidence of A, ignore any evidence of B, and return the evidence of A. In Haskell this is the const function.
Problem 7: Decidability Analysis
Determine whether each is decidable or undecidable and briefly justify: (a) whether a propositional formula is a tautology; (b) whether a first-order sentence is valid in all structures; (c) whether a Diophantine equation has integer solutions; (d) whether a Turing machine halts on the empty input.
Show Solution
Solution:
- (a) Propositional tautology: DECIDABLE. Truth tables provide a finite decision procedure — evaluate under all 2^n truth assignments. It is co-NP-complete but decidable.
- (b) First-order validity: UNDECIDABLE. By Church and Turing (1936), no algorithm decides which first-order sentences are valid. The theory is only semi-decidable: valid sentences are recursively enumerable via Gödel's completeness theorem, but non-valid sentences cannot be systematically identified.
- (c) Diophantine equations: UNDECIDABLE. Hilbert's 10th problem, solved negatively by Matiyasevich (1970): no algorithm decides whether an arbitrary polynomial equation with integer coefficients has an integer solution.
- (d) Halting on empty input: UNDECIDABLE. This is a special case of the halting problem. By Rice's theorem, any non-trivial property of the partial function computed by a TM is undecidable, and "halts on empty input" is non-trivial.
Problem 8: Löwenheim-Skolem Application
Explain why first-order logic cannot characterize the natural numbers up to isomorphism. What does this imply about non-standard models, and why does it not contradict Peano's axioms being about the natural numbers?
Show Solution
Solution:
By the upward Löwenheim-Skolem theorem, any theory with an infinite model (like PA with its standard model N) has models of every infinite cardinality. These non-standard models are not isomorphic to N — they contain elements beyond the standard naturals (0, 1, 2, ...) that are larger than every standard natural but satisfy all the same first-order sentences as N.
By the downward LS theorem, all countable non-standard models of PA are elementarily equivalent to N but not isomorphic to it.
This does not contradict PA being "about" natural numbers because PA is a first-order theory, and first-order logic lacks the expressive power to pin down a unique structure. Second-order Peano arithmetic — where the induction axiom quantifies over all subsets — does characterize N up to isomorphism, but second-order logic loses completeness: Gödel's completeness theorem does not apply to second-order logic.
Quick Reference: Key Results
| Result | Author(s) | Year | Significance |
|---|---|---|---|
| Completeness of FOL | Gödel | 1929 | Proof and truth coincide in first-order logic |
| First Incompleteness | Gödel | 1931 | Arithmetic cannot be axiomatized completely |
| Second Incompleteness | Gödel | 1931 | No system proves its own consistency |
| Halting Undecidability | Turing | 1936 | No algorithm decides program termination |
| FOL Undecidability | Church, Turing | 1936 | No algorithm decides FOL validity |
| Cut Elimination | Gentzen | 1935 | Subformula property, PA consistency proof |
| Compactness | Gödel, Malcev | 1930s | Non-standard models, transfer principles |
| Löwenheim-Skolem | Löwenheim, Skolem | 1915-1920 | FOL cannot control cardinality |
| Rice's Theorem | Rice | 1953 | Non-trivial program properties undecidable |
| CH Independence | Gödel, Cohen | 1938, 1963 | Continuum Hypothesis independent of ZFC |
| Curry-Howard | Curry, Howard | 1934, 1969 | Proofs are programs, propositions are types |
| Hilbert's 10th (neg.) | Matiyasevich et al. | 1970 | Diophantine satisfiability undecidable |
Further Study
Standard References
- Enderton — A Mathematical Introduction to Logic
- Shoenfield — Mathematical Logic (classical treatment)
- Chang and Keisler — Model Theory
- Soare — Turing Computability
- Buss (ed.) — Handbook of Proof Theory
Type Theory and Foundations
- Homotopy Type Theory (HoTT Book) — free online
- Pierce — Types and Programming Languages
- Girard — Proofs and Types
- The Lean 4 Mathlib documentation
- Software Foundations (Coq) — free online
Set Theory
- Kunen — Set Theory: An Introduction to Independence Proofs
- Jech — Set Theory (comprehensive)
- Cohen — Set Theory and the Continuum Hypothesis
Computability
- Sipser — Introduction to the Theory of Computation
- Rogers — Theory of Recursive Functions and Effective Computability
- Odifreddi — Classical Recursion Theory