PROOFS IN PREDICATE LOGIC AND COMPLETENESS; WHAT DECIDABILITY MEANS HUTH AND RYAN 2.3, SUPPLEMENTARY NOTES 2 Neil D. Jones DIKU 2005 12 September, 2005 Some slides today new, some based on logic 2004 (Nils Andersen)
OUTLINE Proof rules for the new logic: Propositional connectives Equality Quantifiers Quantifier equivalences Soundness Gödel s completeness theorem (only what it says, not how it is proven) Decidability in general Decidability of propositional logic 1
SUBSTITUTION Definition 2.6: For a formula ϕ, a variable x and a term t we use ϕ[t/x] to denote the result of replacing each free occurrence of x in ϕ with t 1. Examples: y(x < y)[0/x] is y(0 < y). But consider y(x < y)[y/x]; unintended effect! Definition 2.7: For a formula ϕ, a variable x and a term t: t is free for x in ϕ, if for each variable y occurring free in t, whenever ϕ contains a subformula of form yψ or yψ, no free occurrence of x is contained in ψ. In other words: no free occurrence of x in ϕ lies in the scope of a quantifier binding a variable free in t. Convention 2.8: When using the notation ϕ[t/x] we implicitly assume that t is free for x in ϕ. 1 Mnemonics: divide away x, and replace it with t. Other notation in use is Sub x t (ϕ), ϕ[x := t] and ϕ x[t] 2
PROPOSITIONAL CONNECTIVES The old rules I, I, e 1, e 2, I 1, I 2, e, I, e, I, e, I, e, e are carried over (used without change). So, as a technical device, is added to the language of formulas (or it could be considered as an abbreviation for any formula of the form P (...) P (...)). 3
PROOF RULES FOR EQUALITY t = t =I t 1 = t 2 φ[t 1 /x] φ[t 2 /x] =e These rules suffice for symmetry and transitivity as well: Proof of symmetry: Proof of transitivity: 1 t 1 = t 2 premise 2 t 1 = t 1 =I 3 t 2 = t 1 =e 1,2 (using φ x = t 1 ) 1 t 2 = t 3 premise 2 t 1 = t 2 premise 3 t 1 = t 3 =e 1,2 (using φ t 1 = x) 4
PROOF RULES FOR UNIVERSAL QUANTIFIERS xφ φ[t/x] xe x 0. φ[x 0 /x] xφ xi 5
PROOF RULES FOR EXISTENTIAL QUANTIFIERS φ[t/x] xφ xi xφ x 0 φ[x 0 /x]. χ χ xe 6
QUANTIFIER EQUIVALENCES xφ x φ xφ x φ x yφ y xφ x yφ y xφ x(φ ψ) xφ xψ x(φ ψ) xφ xψ x(φ ψ) xφ xψ Provided x is not free in ψ, the following is valid: x(φ ψ) xφ ψ x(φ ψ) xψ ψ x(φ ψ) xφ ψ x(φ ψ) xφ ψ x(ψ φ) ψ xφ x(ψ φ) ψ xφ x(φ ψ) xφ ψ x(φ ψ) xφ ψ But note the following directed deductions: xφ xψ x(φ ψ) x(φ ψ) xφ xψ 7
SOUNDNESS AND COMPLETENESS Let M be a model (interpretation) for predicate calculus formulas. Definition Formula φ is valid iff M = φ holds for every model M. Definition Proof system is sound iff for any closed predicate formula φ we have: φ implies M = φ for every modelm In brief: any provable formula is valid. Proof system is complete iff for any closed predicate formula φ : φ if M = φ for every modelm In brief: any valid formula is provable. Remark: Validity is a very strong condition to place on a formula φ: φ must hold in all models. In contrast to most mathematical reasoning: about one model at a time. 8
GÖDEL S COMPLETENESS THEOREM The proof system described in Huth and Ryan s book is both sound and complete: For any closed predicate formula, φ iff M = φ for every model M. Proof ideas (Gödel s completeness theorem): 1. Soundness: This is straightforward. 2. Completeness: This is much trickier, as it involves constructing a model of φ just in case φ is not provable. Since Gödel s original proof a variety of simpler alternatives have been devised, but all are too subtle and technically involved to present here. 9
ON THE PROOF OF GÖDEL S COMPLETENESS THEOREM This is decidedly nontrivial. The trickiest part is the Herbrand property: If φ then I = φ holds finitely for some interpretation I, i.e., an interpretation I can be found such that there is a finite counterexample to φ. A final remark. Gödel s completeness theorem is the basis of the logic programming language PROLOG. The computation paradigm of PROLOG is systematically to search for a refutation of the negation of the current goal, in essence searching for such finite counterexamples. 10
COMPUTABILITY Church-Turing s thesis: All computation mechanisms are equally strong. (Programming languages, lambda calculus, Turing machines, recursive functions, rewriting systems, Markov algorithms etc.) A (decision) problem (over an alphabet Σ) is a subset A Σ. A Σ Definition A decision problem A over Σ is decidable if there is a program p that computes its characteristic function: { true if x A [[p]](x) = false if x / A (for any input x Σ ). 11
THE ORIGIN OF ALL UNSOLVABLE PROBLEMS Theorem The following function is not computed by any program: { true if [[p]](d) halts halt(p, d) = false otherwise Proof Suppose halt were computed by some program q, i.e., { true if [[p]](d) halts [[q]](p.d) = false otherwise Let the form of q be: read X; C; write Y 12
BUILD A NEW PROGRAM r FROM q read X; X := cons X X; (* Does program X stop on input X? *) C; (* Apply program q to answer this *) if Y then while Y do Y:=Y (* Loop if X halts on input X *) else write Y (* Terminate if it does not stop *) Consider the input X = r. Now either [[r]](r) halts or it loops. If [[r]](r) halts, then r reaches the else branch, so Y = false holds after command C. This implies [[r]](r) loops by the assumption that q computes halt. If [[r]](r) loops, then reaches the then branch. But then Y = true holds after C, so [[r]](r) halts since q computes halt, another contradiction. The only unjustified assumption was the existence of a program q that computes halt, so this must be false. 13
THE PROPOSITIONAL CALCULUS IS DECIDABLE Provability in the propositional calculus is decidable: Theorem The following function is computable by some program: provable(φ) = { true if φ false otherwise Proof By completeness, φ is true if and only if = φ. We can decide = φ by constructing a truth-table for φ, with one row for every combination of truth values for the propositional variables in φ. This can be done in time O(2 φ ). Whether it can be done in polynomial time is a question that has been open for many years, as it would imply p = np. Next lecture: Provability in the predicate calculus is undecidable. 14