Summary Summary Last Lecture sequent calculus Automated Reasoning Georg Moser Institute of Computer Science @ UIBK Winter 013 (Normalisation and Strong Normalisation) let Π be a proof in minimal logic 1 a reduction sequence Π = Π 1,, Π n computable upper bound n on the maximal length of any reduction sequence Corollary if T 0 is complete and T 1, T are satisfiable extensions of T 0, then T 1 T is satisfiable GM (Institute of Computer Science @ UIBK) Automated Reasoning 17/1 Summary let G be a set of universal sentences (of L) without =, then the following is equivalent 1 G is satisfiable G has a Herbrand model 3 finite G 0 Gr(G), G 0 has a Herbrand model Corollary x 1 x n G(x 1,, x n ) is valid iff there are ground terms t k 1,, tk n, k N and the following is valid: G(t 1 1,, t1 n) G(t k 1,, tk n ) formula, formula G not containing individual, nor function constants, nor = such that G GM (Institute of Computer Science @ UIBK) Automated Reasoning 18/1 Summary Outline of the Lecture Propositional Logic short reminder of propositional logic, soundness and completeness theorem, natural deduction, propositional resolution irst Order Logic introduction, syntax, semantics, undecidability of first-order, Löwenheim- Skolem, compactness, model existence theorem, natural deduction, completeness, sequent calculus, normalisation Properties of irst Order Logic Craig s Interpolation, Robinson s Joint Consistency, Herbrand s Limits and xtensions of irst Order Logic, Curry-Howard Isomorphism, Limits, Second-Order Logic GM (Institute of Computer Science @ UIBK) Automated Reasoning 19/1
Background: Russel s paradox according to naive set theory, any definable collection is a set; this is not a good idea Proof 1 let R := {x x x} as x x is a definition (= a predicate) this should be set 3 so either R R, or R R, but R R R R R R R R 4 hence R R R R, which is a contradiction 5 thus naive set theory is inconsistent Oops, what to do? Brouwer s Way Out (174) Change Mathematics! intuitionistic logic is a restriction of classical logic, where certain formulas are no longer derivable for example A A is no longer valid its interpretation in intuitionistic logic is: there is an argument for A or there is a argument for A (= from the assumption A we can prove a contradiction) GM (Institute of Computer Science @ UIBK) Automated Reasoning 130/1 GM (Institute of Computer Science @ UIBK) Automated Reasoning 131/1 A Problem with the xcluded Middle solutions of the equation x y = z with x and y irrational and z rational Proof 1 is an irrational number one of the following two cases has to occur: is rational, then is irrational, then x = y = z = x = y = z = ( ) = = prototypical example of a non-constructive proof : i introduction : i : i elimination : e G G : i G : e : e : e GM (Institute of Computer Science @ UIBK) Automated Reasoning 13/1 GM (Institute of Computer Science @ UIBK) Automated Reasoning 133/1
Remark note the absence of introduction elimination : i : e : e : e (Alternative) an equivalent formalisation of intutitionistic logic is given by sequent calculus with the following restriction: sequents Γ : 1 (Brower, Heyting, Kolmogorow (Kreisel) Interpretation) an argument for is an argument for and an argument for is an argument of or an argument for is a transformation of an argument for into an argument for is interpreted as no argument for can exist the formal definition needs Kripke models GM (Institute of Computer Science @ UIBK) Automated Reasoning 134/1 GM (Institute of Computer Science @ UIBK) Automated Reasoning 135/1 Kripke Models a frame is a pair (W, ), where W denotes a nonempty set of worlds and denotes a preorder on W a Kripke model on a frame = (W, ) is a triple K = (W,, (A p ) p W ) such that for all p: 1 A p = (A p, a p ) A p is a non-empty set (the domain in world p) 3 A p is a mapping that associates predicate constants to domains predicate symbols P, p, q W, (a 1,, a n ) A n p: p q, A p = P(a 1,, a n ) implies A q = P(a 1,, a n ) we set A = p W A p Convention suppose (x 1,, x n ) is formula with free variables x 1,, x n ; we write (a 1,, a n ) for the interpretation of x i by a i A in for a given Kripke model K = (W,, (A p ) p W ) the satisfaction relation is defined as follows: K, p K, p K, p P(a 1,, a n ) if A p = P(a 1,, a n ) K, p A B iff K, p A and K, p B K, p A B iff K, p A or K, p B K, p A B iff for all q p: K, q A implies K, q B a formula is valid in K if K, p for all p W GM (Institute of Computer Science @ UIBK) Automated Reasoning 136/1 GM (Institute of Computer Science @ UIBK) Automated Reasoning 137/1
Some Transfer Results Natural Deduction vs Sequent Calculus Natural Deduction for Minimal Logic natural deduction (and the sequent calculus) for intuitionistic logic is sound and complete introduction A A elimination natural deduction is strongly normalising sequent calculus admits cut-eliminiation Γ Γ Γ Γ, G Γ, G Γ G Craig s interpolation theoremm holds for intutitionistic logic Γ, Γ GM (Institute of Computer Science @ UIBK) Automated Reasoning 138/1 GM (Institute of Computer Science @ UIBK) Automated Reasoning 139/1 Natural Deduction vs Sequent Calculus A Sequent Calculus for Minimal Logic left right, Γ C, Γ C : l Γ 1 Γ Γ 1, Γ, Γ C, Γ C : l, Γ 1 C, Γ C, Γ 1, Γ C : l : r Γ : r Γ 1, Γ C, Γ 1, Γ C : l Γ, : l : r Natural Deduction vs Sequent Calculus Lemma let S = (Γ C) be a sequent; proof Π of S in natural deduction iff proof Ψ of S in the sequent calculus Proof direction from left to right is shown by induction on the length of Π, ie, on the number of sequents in Π 1 the base case is immediate as Π A A iff Ψ A A for the step case, consider the case that Π has the following form: Π 0 by induction hypothesis a sequent calculus proof Ψ 0 of GM (Institute of Computer Science @ UIBK) Automated Reasoning 140/1 GM (Institute of Computer Science @ UIBK) Automated Reasoning 141/1
Natural Deduction vs Sequent Calculus Proof (cont d) 3 the following is a correct proof: Natural Deduction vs Sequent Calculus Natural Deduction Structural Rules Ψ 0 : l cut 4 all other cases are similar the other direction follows by induction on the length of Ψ contraction weakening A, A, Γ C A, Γ C Γ C A, Γ C Question is this really correct? Answer no, we forgot about the structural rules in the direction from right to left Observations note the restriction to one formula in the succedent contraction and weakening can also be represented by changed axioms and representation of sequents GM (Institute of Computer Science @ UIBK) Automated Reasoning 14/1 GM (Institute of Computer Science @ UIBK) Automated Reasoning 143/1 Natural Deduction vs Sequent Calculus Outline of the Lecture Propositional Logic short reminder of propositional logic, soundness and completeness theorem, natural deduction, propositional resolution irst Order Logic introduction, syntax, semantics, undecidability of first-order, Löwenheim- Skolem, compactness, model existence theorem, natural deduction, completeness, sequent calculus, normalisation Properties of irst Order Logic Craig s Interpolation, Robinson s Joint Consistency, Herbrand s Limits and xtensions of irst Order Logic, Curry-Howard Isomorphism, Second-Order Logic Typed λ-calculus Typed λ-calculus (types and terms) we define the set of types T and typed λ-terms as follows: a variable type: α,, γ, if σ, τ are types, then (σ τ) is a (product) type if σ, τ are types, then (σ τ) is a (function) type any (typed) variable x : σ is a (typed) term if M : σ, N : τ are terms, then M, N : σ τ is a term if M : σ τ is a term, then fst(m) : σ and snd(m) : τ are terms if M : τ is a term, x : σ a variable, then the abstraction (λx σ M) : σ τ is a term if M : σ τ, N : σ are terms, then the application (MN) : τ is a term GM (Institute of Computer Science @ UIBK) Automated Reasoning 144/1 GM (Institute of Computer Science @ UIBK) Automated Reasoning 145/1
Typed λ-calculus Typed λ-calculus the following are (well-formed, typed) terms λfxfx : (σ τ) σ τ λxx, λyy : (σ σ) (τ τ) but λxxx cannot be typed! the set of free variables of a term is defined as follows V(x) = {x} V(λxM) = V(M) {x} V(MN) = V( M, N ) = V(M) V(N) V(fst(M)) = V(snd(M)) = V(M) (informal) occurrences of x in the scope of λ are called bound GM (Institute of Computer Science @ UIBK) Automated Reasoning 146/1 (substitution) M[x := N] denotes the result of substituting N for x in M x[x := N] = N and if x y, then y[x := N] = y (λxm)[x := N] = λxm (λym)[x := N] = λy(m[x := N]), if x y and y V(N) (M 1 M )[x := N] = (M 1 [x := N])(M [x := N]) M 1, M [x := N] = M 1 [x := N], M [x := N] fst(m)[x := N] = fst(m[x := N]) snd(m)[x := N] = snd(m[x := N]) (-reduction) (λxm)n M[x := N] fst( M, N ) M snd( M, N ) N GM (Institute of Computer Science @ UIBK) Automated Reasoning 147/1 Typed λ-calculus Lemma -reduction is closed under context: LM LN ML NL λxm λxn M N = M, L N, L L, M L, N fst(m) fst(n) snd(m) snd(n) (λf λxfx)(λxx + 1)0 (λx(λxx + 1)x)0 (λxx + 1)0 1 GM (Institute of Computer Science @ UIBK) Automated Reasoning 148/1 Curry-Howard Isomorphism Type Checking Γ M : σ Γ N : τ Γ M, N : σ τ Remarks x : σ, Γ x : σ ref pair Γ M : σ τ Γ fst(m) : σ fst Γ M : σ τ Γ snd(m) : τ snd Γ, x : σ M : τ Γ λxm : σ τ abs Γ M : σ τ Γ N : σ Γ MN : τ 1 different to type checking system in functional programming we have type assignment for product types weakening is incorporated into the axiom, sequents arepresented as sets GM (Institute of Computer Science @ UIBK) Automated Reasoning 149/1 app
Types as ormulas Types as ormulas (Types as ormulas) (ref) (Ax) + structural rules (pair) ( : i) (abs) ( : i) (fst) ( : e) (app) ( : e) (snd) ( : e) Question what is the correspondence to? Answer sum types! a (binary) sum type describes a set of values drawn from exactly two given types GM (Institute of Computer Science @ UIBK) Automated Reasoning 150/1 Types as ormulas Type System for Sum Types Γ M : σ Γ inl(m) : σ + τ Γ N : τ Γ inr(n) : σ + τ Γ M : σ + τ Γ, x : σ N 1 : γ Γ, y : τ N : γ Γ case M of inl(x) N 1 inr(y) N : γ (-reduction, cont d) (λxm)n M[x := N] fst( M, N ) snd( M, N ) M N case inl(m) of inl(x) N 1 inr(y) N N1 [x := M] case inr(n) of inl(x) N 1 inr(y) N N [y := N] GM (Institute of Computer Science @ UIBK) Automated Reasoning 151/1 Types as ormulas Curry-Howard Correspondence Proofs as Programs Proofs as Programs (Types as ormulas (cont d)) (ref) (Ax) + structural rules (pair) ( : i) (abs) ( : i) (fst) ( : e) (app) ( : e) (snd) ( : e) (inl) ( : i) (inr) ( : i) (case) ( : e) (Curry-Howard) (normalisation) Π 1 Π Γ M : σ Γ N : τ Γ M, N : σ τ Γ fst( M, N ) : σ = Π 1 Γ M : σ the Curry-Howard correspondence (aka Curry-Howard isomorophism) consists of the following parts: 1 formulas = types proof = programs 3 normalisation = computation (-reduction) fst( M, N ) M GM (Institute of Computer Science @ UIBK) Automated Reasoning 15/1 GM (Institute of Computer Science @ UIBK) Automated Reasoning 153/1
Proofs as Programs Proofs as Programs (normalisation) Π 1 Γ, x : σ M : τ Γ λxm : σ τ Γ (λxm)n : τ Π Γ N : σ = Π 1 [x\π ] Γ M[x := N] : τ Discussion act the Curry-Howard correspondence extends to many systems, for example intuitionistic logic and λ-calculus Hilbert axioms and combinatory logic linear logic and interaction nets the proof Π 1 [x\π ] represents the proof obtained from Π 1 by substituting Π into Π 1 instead of the use of ref wrt x (-reduction) (λxm)n M Observations the Curry-Howard correspondence 1 links logic with programming, ie, provides an explanation for the sucess of logic in computer science allows to mutual enrich both areas 3 provides a formally verified form of programming 4 GM (Institute of Computer Science @ UIBK) Automated Reasoning 154/1 GM (Institute of Computer Science @ UIBK) Automated Reasoning 155/1 Proofs as Programs strong normalisation of simply typed λ-calculus is typically proved via strong normalisation of minimal logic similarily, undecidablilty of type inhabitation of dependent types follows from undeciabilty of intuitionistic predicate logic correspondencence between interaction nets and linear logic provides type system to interaction nets formalisation of the theory of forbidden patterns for rewrite strategies in Isabelle provides a machine-checked theory code export from Isabelle provides OCaml code that has been integrated into T T T GM (Institute of Computer Science @ UIBK) Automated Reasoning 156/1