Logic Aart Middeldorp Vincent van Oostrom Franziska Rapp Christian Sternagel Department of Computer Science University of Innsbruck WS 2017/2018 AM (DCS @ UIBK) week 11 2/38 Definitions elimination x φ e φ[t/x] provided t is free for x in φ introduction φ[t/x] i x φ Definition (possibly infinite) set of formulas Γ, formula ψ sequent Γ ψ is valid if there exists (finite) natural deduction proof of ψ in which all premises are from Γ introduction elimination x 0. φ[x 0 /x] x φ i x φ x 0 χ φ[x 0 /x]. χ e (Gödel s Completeness ) natural deduction for predicate logic is sound and complete: Γ ψ Γ ψ is valid where x 0 is fresh variable that is used only inside box AM (DCS @ UIBK) week 11 3/38 AM (DCS @ UIBK) week 11 4/38
Overview Part I: Propositional Logic (Quantifier Equivalences) x φ x φ x φ x φ x φ x ψ x (φ ψ) x φ x ψ x (φ ψ) x y φ y x φ x y φ y x φ if x is not free in ψ then x φ ψ x (φ ψ) x φ ψ x (φ ψ) x φ ψ x (φ ψ) x φ ψ x (φ ψ) ψ x φ x (ψ φ) x φ ψ x (φ ψ) ψ x φ x (ψ φ) x φ ψ x (φ ψ) algebraic normal forms, binary decision diagrams, conjunctive normal forms, DPLL, Horn clauses, natural deduction, Post s adequacy theorem, resolution, SAT, semantics, soundness and completeness, sorting networks, syntax, Tseitin s transformation Part II: compactness, first-order theories, Gödel s incompleteness theorem, Löwenheim- Skolem, natural deduction, quantifier equivalences, reachability, resolution, second-order logic,, semantics, syntax, undecidability, unification Part III: Model Checking adequacy, branching-time temporal logic, CTL, fairness, linear-time temporal logic, model checking algorithms AM (DCS @ UIBK) week 11 5/38 AM (DCS @ UIBK) week 11 6/38 (Church) validity in predicate logic is undecidable: there is no algorithm input: formula φ in predicate logic output: yes if φ holds no if φ does not hold Proof Idea reduction from Post correspondence problem Post Correspondence Problem instance: question: finite sequence of pairs (s 1, t 1 ),..., (s k, t k ) of non-empty bitstrings is there sequence (i 1, i 2,..., i n ) with n 1 such that s i1 s i2... s in = t i1 t i2... t in? AM (DCS @ UIBK) week 11 7/38 AM (DCS @ UIBK) week 11 8/38
s 1 1 2 3 s i : 1 10111 10 t i : 11 101 01 2 1 2 3 s i : 10 011 101 t i : 101 11 011 3 1 2 3 s i : 01 1 0 t i : 0 101 1 solution 2 1 1 s 10111 1 1 = 1011111 t 101 11 11 = 1011111 no solution solution 1 3 1 1 3 1 3 1 1 3 1 1 2 1 1 2 2 1 3 3 2 1 1 3 1 2 1 1 3 3 1 2 1 1 1 3 2 1 2 1 2 2 3 2 validity in predicate logic is undecidable Proof Idea translate PCP instance C into predicate logic formula φ such that φ C has solution (Post) Post correspondence problem is undecidable AM (DCS @ UIBK) week 11 9/38 AM (DCS @ UIBK) week 11 10/38 Proof let C = ((s 1, t 1 ), (s 2, t 2 ),..., (s k, t k )) function symbols e: constant f 0, f 1 : arity 1 predicate symbol P: arity 2 if b 1, b 2,..., b n {0, 1} then f b1 b 2 b n (t) denotes f bn ( (f b2 (f b1 (t))) ) φ = φ 1 φ 2 φ 3 with φ 1 = k P(f si (e), f ti (e)) i=1 φ 2 = v w ( P(v, w) ) k P(f si (v), f ti (w)) i=1 C = ((10, 101), (011, 11), (10, 0)) φ = P(f 0 (f 1 (e)), f 1 (f 0 (f 1 (e)))) P(f 1 (f 1 (f 0 (e))), f 1 (f 1 (e))) P(f 0 (f 1 (e)), f 0 (e)) v w ( P(v, w) P(f 0 (f 1 (v)), f 1 (f 0 (f 1 (w)))) z P(z, z) P(f 1 (f 1 (f 0 (v))), f 1 (f 1 (w))) P(f 0 (f 1 (v)), f 0 (w)) ) φ 3 = z P(z, z) φ C has solution AM (DCS @ UIBK) week 11 11/38 AM (DCS @ UIBK) week 11 12/38
Remark unification and skolemization are required to extend resolution from propositional logic to predicate logic Greek alphabet alpha α A iota ι I rho ρ P beta β B kappa κ K sigma σ ς Σ gamma γ Γ lambda λ Λ tau τ T delta δ mu µ M upsilon υ Υ epsilon ɛ ε E nu ν N phi φ ϕ Φ zeta ζ Z xi ξ Ξ chi χ X eta η H omicron o O psi ψ Ψ theta θ ϑ Θ pi π Π omega ω Ω AM (DCS @ UIBK) week 11 13/38 AM (DCS @ UIBK) week 11 14/38 Definition substitution is set of variable bindings θ = {x 1 t 1,..., x n t n } with terms t 1,..., t n and pairwise different variables x 1,..., x n given substitution θ = {x 1 t 1,..., x n t n } and expression E, instance Eθ of E is obtained by simultaneously replacing each occurrence of x i in E by t i composition of substitutions θ = {x 1 t 1,..., x n t n } and σ = {y 1 s 1,..., y k s k } is substitution θσ = {x 1 t 1 σ,..., x n t n σ} {y i s i y i x j for all 1 j n} Lemma composition of substitutions is associative: Definitions (ρσ)τ = ρ(στ) substitution θ is at least as general as substitution σ if θµ = σ for some substitution µ unifier of set S of terms is substitution θ such that sθ = tθ for all terms s, t S most general unifier (mgu) is at least as general as any other unifier θ = { x g(y, z), y a } E = P(f (y), x, y) σ = { x f (y), z f (x) } Eθ = P(f (a), g(y, z), a) θσ = { x g(y, f (x)), y a, z f (x) } Eσ = P(f (y), f (y), y) σθ = { x f (a), z f (g(y, z)), y a } terms f (x, g(y), x) and f (z, g(u), h(u)) are unifiable: { x h(a), y a, z h(a), u a } {u a } unifiers { x h(u), y u, z h(u) } mgu { x h(g(u)), y g(u), z h(g(u)), u g(u) } { u g(u) } AM (DCS @ UIBK) week 11 15/38 AM (DCS @ UIBK) week 11 16/38
unifiable terms have mgu which can be computed by unification algorithm Algorithm d decomposition f (x, g(y), x) f (z, g(u), h(u)) d x z, g(y) g(u), x h(u) E 1, f (s 1,..., s n ) f (t 1,..., t n ), E 2 E 1, s 1 t 1,..., s n t n, E 2 v { x z } g(y) g(u), z h(u) t removal of trivial equations d mgu { x h(u), y u, z h(u) } E 1, t t, E 2 E 1, E 2 y u, z h(u) v { y u } v variable elimination z h(u) E 1, x t, E 2 (E 1, E 2 )σ and E 1, t x, E 2 (E 1, E 2 )σ if x does not occur in t (occurs check) and σ = {x t} v { z h(u) } AM (DCS @ UIBK) week 11 17/38 AM (DCS @ UIBK) week 11 18/38 there are no infinite derivations U σ1 V σ2 W σ3 if s and t are unifiable then for every maximal derivation s t σ1 E 1 σ2 E 2 σ3 σn E n E n = σ 1 σ 2 σ 3 σ n is mgu of s and t Optional Failure Rules E 1, f (s 1,..., s n ) g(t 1,..., t m ), E 2 E 1, x t, E 2 E 1, t x, E 2 if x occurs in t and x t AM (DCS @ UIBK) week 11 19/38 AM (DCS @ UIBK) week 11 20/38
Definitions prenex normal form is predicate logic formula Q 1 x 1 Q 2 x 2... Q n x n φ with Q i {, } and φ quantifier free Skolem normal form is closed (no free variables) prenex normal form x 1 x 2... x n φ with φ quantifier free CNF x y ((P(f (x)) P(g(y)) Q(g(y))) ( Q(g(y)) P(g(y)) Q(g(x)))) { { P(f (x)), P(g(y)), Q(g(y)) }, { Q(g(y)), P(g(y)), Q(g(x)) } } formula φ prenex normal form ψ such that φ ψ Proof 1 rename all bound variables such that all variables in quantifications are distinct 2 push logical connectives through quantifiers: x φ x φ x φ x φ x φ ψ x (φ ψ) φ x ψ x (φ ψ) x φ ψ x (φ ψ) φ x ψ x (φ ψ) x φ ψ x (φ ψ) φ x ψ x (φ ψ) x φ ψ x (φ ψ) φ x ψ x (φ ψ) x φ ψ x (φ ψ) φ x ψ x (φ ψ) x φ ψ x (φ ψ) φ x ψ x (φ ψ) AM (DCS @ UIBK) week 11 21/38 AM (DCS @ UIBK) week 11 22/38 Definition formulas φ and ψ are equisatisfiable (φ ψ) if φ is satisfiable ψ is satisfiable sentence φ Skolem normal form ψ such that φ ψ Proof () 1 transform φ into closed prenex normal form Q 1 x 1 Q 2 x 2... Q n x n χ with χ in CNF 2 repeatedly replace by x 1... x i 1 x i Q i+1 x i+1... Q n x n ψ x 1... x i 1 Q i+1 x i+1... Q n x n ψ[f (x 1,..., x i 1 )/x i ] where f is new function symbol of arity i 1 s z x y ((P(x) P(y) Q(z)) ( Q(x) P(y) Q(z))) { x f (z) } z y ((P(f (z)) P(y) Q(z)) ( Q(f (z)) P(y) Q(z))) { y g(z) } z ((P(f (z)) P(g(z)) Q(z)) ( Q(f (z)) P(g(z)) Q(z))) x y ( z P(z) u (Q(x, u) v Q(y, v))) x y z u v (P(z) ( Q(x, u) Q(y, v))) { y f (x) } {z g(x) } x u v (P(g(x)) ( Q(x, u) Q(f (x), v))) { v h(x, u) } x u (P(g(x)) ( Q(x, u) Q(f (x), h(x, u)))) AM (DCS @ UIBK) week 11 23/38 AM (DCS @ UIBK) week 11 24/38
Definitions literal is atom p or negation of atom p clause is set of literals {l 1,..., l n }, representing l 1 l n Propositional Logic Propositional Logic clausal form is set of clauses {C 1,..., C m }, representing C 1 C m literals l 1 and l 2 are complementary if l 1 = l2 c clauses C 1 and C 2 clash if literal l with l C 1 and l c C 2 resolvent of clashing clauses C 1 and C 2 is clause (C 1 \ {l}) (C 2 \ {l c }) AM (DCS @ UIBK) week 11 25/38 AM (DCS @ UIBK) week 11 26/38 Propositional Logic input: clausal form S output: yes if S is satisfiable no if S is unsatisfiable 1 repeatedly add resolvent of pair of clashing clauses in S 2 return no as soon as empty clause is derived 3 return yes if all clashing clauses have been resolved Definition refutation of S is resolution derivation of from S Propositional Logic resolution is sound and complete: clausal form S is unsatisfiable if and only if S admits refutation AM (DCS @ UIBK) week 11 27/38 AM (DCS @ UIBK) week 11 28/38
Definitions literal is atom P(t 1,..., t n ) or negation of atom P(t 1,..., t n ) clause is set of literals {l 1,..., l n }, representing l 1 l n clausal form is set of clauses {C 1,..., C m }, representing (C 1 C m ) clauses C 1 and C 2 without common variables clash if literals l 1 C 1 and l 2 C 2 such that l 1 and l2 c are unifiable resolvent of clashing clauses C 1 and C 2 is clause where θ is mgu of l 1 and l c 2 ((C 1 \ {l 1 }) (C 2 \ {l 2 }))θ (1) 1. { P(x), Q(x), R(x, f (x)) } 2. { P(x), Q(x), S(f (x)) } 3. { T (a) } 4. { P(a) } 5. { R(a, y), T (y) } 6. { T (x), Q(x) } 7. { T (x), S(x) } 8. { Q(a) } resolve 3, 6 { x a } 9. { Q(a), S(f (a)) } resolve 2, 4 { x a } 10. { Q(a), R(a, f (a)) } resolve 1, 4 { x a } 11. { S(f (a)) } resolve 8, 9 12. { R(a, f (a)) } resolve 8, 10 13. { T (f (a)) } resolve 5, 12 { y f (a) } 14. { S(f (a)) } resolve 7, 13 { x f (a) } 15. resolve 11,14 AM (DCS @ UIBK) week 11 29/38 AM (DCS @ UIBK) week 11 30/38 (2) 1. { P(x, y), P(y, x) } 2. { P(x, y), P(y, z), P(x, z) } 3. { P(x, f (x)) } 4. { P(x, x) } 3. { P(x, f (x )) } rename 3 5. { P(f (x), x) } resolve 1, 3 { y f (x), x x } 6. { P(f (x), z), P(x, z) } resolve 2, 3 { y f (x), x x } 5. { P(f (x ), x ) } rename 5 7. { P(z, z) } resolve 6, 5 { x z, x z } 8. resolve 4, 7 { x z } x y z ( ( P(x, y) P(y, x)) ( P(x, y) P(y, z) P(x, z)) P(x, f (x)) P(x, x) ) resolution is sound: clausal form S is unsatisfiable if S admits refutation Problem resolution is incomplete 1. { P(x), P(y) } 2. { P(x ), P(y ) } 3. { P(y), P(y ) } resolve 1, 2 { x x } unsatisfiable but no refutation AM (DCS @ UIBK) week 11 31/38 AM (DCS @ UIBK) week 11 32/38
with Factoring Solution incorporate factoring: Cσ is a factor of C if two or more literals in C have mgu σ 1. { P(x), P(y) } 2. { P(x ), P(y ) } 3. { P(x) } factor 1 4. { P(x ) } factor 2 5. resolve 3, 4 input: clausal form S output: yes if S is satisfiable no if S is unsatisfiable if S is satisfiable (or unsatisfiable) 1 repeatedly add resolvents (renaming clauses if necessary) and factors 2 return no as soon as empty clause is derived 3 return yes if all clashing clauses have been resolved and factoring produces no new clauses (modulo renaming) 1. { R(x), Q(f (x)) } 1. { R(x ), Q(f (x )) } rename 1 2. { R(f (x)), Q(f (y)) } 4. { Q(f (y)), Q(f (f (x))) } resolve 1, 2 { x f (x) } 3. { Q(f (f (f (a)))) } 5. { Q(f (f (x))) } factor 4 { y f (x) } 6. resolve 3, 5 { x f (a) } AM (DCS @ UIBK) week 11 33/38 AM (DCS @ UIBK) week 11 34/38 resolution with factoring is sound and complete: clausal form S is unsatisfiable if and only if S admits refutation Validity Procedure sentence φ 1 transform φ into Skolem normal form ψ 1. { P(x), P(f (x)) } 2. { P(a) } 3. { P(f (a)) } resolve 1, 2 { x a } 4. { P(f (f (a))) } resolve 1, 3 { x f (a) } 5. { P(f (f (f (a)))) } resolve 1, 4 { x f (f (a)) } 6. { P(f (f (f (f (a))))) } resolve 1, 5 { x f (f (f (a))) } 2 extract clausal form S from ψ 3 apply resolution to S 4 φ is valid if and only if S admits a refutation. AM (DCS @ UIBK) week 11 35/38 AM (DCS @ UIBK) week 11 36/38
Huth and Ryan Section 2.5 Wikipedia [ accessed August 14, 2017 ] Wikipedia [ accessed August 15, 2017 ] Wikipedia [ accessed August 15, 2017 ] AM (DCS @ UIBK) week 11 37/38 AM (DCS @ UIBK) week 11 38/38