CS156: The Calculus of Computation Zohar Manna Winter 2010

Similar documents
First-Order Logic (FOL)

AAA615: Formal Methods. Lecture 2 First-Order Logic

First-Order Logic First-Order Theories. Roopsha Samanta. Partly based on slides by Aaron Bradley and Isil Dillig

Decision Procedures. Jochen Hoenicke. Software Engineering Albert-Ludwigs-University Freiburg. Winter Term 2015/16

Predicate Logic: Sematics Part 1

Syntax. Notation Throughout, and when not otherwise said, we assume a vocabulary V = C F P.

First-Order Predicate Logic. Basics

Overview. CS389L: Automated Logical Reasoning. Lecture 7: Validity Proofs and Properties of FOL. Motivation for semantic argument method

The Calculus of Computation: Decision Procedures with Applications to Verification. Part I: FOUNDATIONS. by Aaron Bradley Zohar Manna

Outline. Formale Methoden der Informatik First-Order Logic for Forgetters. Why PL1? Why PL1? Cont d. Motivation

CS156: The Calculus of Computation

Outline. Logic. Definition. Theorem (Gödel s Completeness Theorem) Summary of Previous Week. Undecidability. Unification

3. The Logic of Quantified Statements Summary. Aaron Tan August 2017

First Order Logic (FOL) 1 znj/dm2017

CS156: The Calculus of Computation

Learning Goals of CS245 Logic and Computation

Classical First-Order Logic

Computational Logic. Davide Martinenghi. Spring Free University of Bozen-Bolzano. Computational Logic Davide Martinenghi (1/26)

Introduction to Sets and Logic (MATH 1190)

Predicate Calculus - Semantics 1/4

Logic for Computer Scientists

Logic for Computer Scientists

Automated Reasoning Lecture 5: First-Order Logic

CS156: The Calculus of Computation Zohar Manna Winter 2010

Recall that the expression x > 3 is not a proposition. Why?

Classical First-Order Logic

Section Summary. Predicate logic Quantifiers. Negating Quantifiers. Translating English to Logic. Universal Quantifier Existential Quantifier

CS 514, Mathematics for Computer Science Mid-semester Exam, Autumn 2017 Department of Computer Science and Engineering IIT Guwahati

First-Order Logic. 1 Syntax. Domain of Discourse. FO Vocabulary. Terms

Logic: First Order Logic (Part I)

The Calculus of Computation: Decision Procedures with Applications to Verification. by Aaron Bradley Zohar Manna. Springer 2007

Logic Part I: Classical Logic and Its Semantics

Predicate Logic. CSE 191, Class Note 02: Predicate Logic Computer Sci & Eng Dept SUNY Buffalo

CS156: The Calculus of Computation Zohar Manna Autumn 2008

Section Summary. Section 1.5 9/9/2014

CSE507. Satisfiability Modulo Theories. Computer-Aided Reasoning for Software. Emina Torlak

Propositional Logic Not Enough

Logic for Computer Scientists

Computational Logic. Standardization of Interpretations. Damiano Zanardini

Introduction to Logic in Computer Science: Autumn 2006

COMP9414: Artificial Intelligence First-Order Logic

06 From Propositional to Predicate Logic

Exercises 1 - Solutions

03 Review of First-Order Logic

Logic and Modelling. Introduction to Predicate Logic. Jörg Endrullis. VU University Amsterdam

CS2742 midterm test 2 study sheet. Boolean circuits: Predicate logic:

Review. Propositional Logic. Propositions atomic and compound. Operators: negation, and, or, xor, implies, biconditional.

Informal Statement Calculus

Mathematical Logic Part Three

Predicate Calculus lecture 1

Transparencies to accompany Rosen, Discrete Mathematics and Its Applications Section 1.3. Section 1.3 Predicates and Quantifiers

Discrete Mathematics and Its Applications


First-Order Logic. Chapter Overview Syntax

Predicate Calculus. Formal Methods in Verification of Computer Systems Jeremy Johnson

CS 730/730W/830: Intro AI

Predicate Calculus - Syntax

Lecture 13: Soundness, Completeness and Compactness

7. Propositional Logic. Wolfram Burgard and Bernhard Nebel

Classical Propositional Logic

3. Only sequences that were formed by using finitely many applications of rules 1 and 2, are propositional formulas.

Example. Lemma. Proof Sketch. 1 let A be a formula that expresses that node t is reachable from s

The predicate calculus is complete

Logic. Foundations of First Order Logic. franconi. Enrico Franconi

Inference in first-order logic

Motivation. CS389L: Automated Logical Reasoning. Lecture 10: Overview of First-Order Theories. Signature and Axioms of First-Order Theory

Intelligent Agents. First Order Logic. Ute Schmid. Cognitive Systems, Applied Computer Science, Bamberg University. last change: 19.

Herbrand Theorem, Equality, and Compactness

THE LANGUAGE OF FIRST-ORDER LOGIC (FOL) Sec2 Sec1(1-16)

Propositional and Predicate Logic. jean/gbooks/logic.html

Section Summary. Predicate logic Quantifiers. Negating Quantifiers. Translating English to Logic. Universal Quantifier Existential Quantifier

Chapter 2: The Logic of Quantified Statements. January 22, 2010

Introduction to Predicate Logic Part 1. Professor Anita Wasilewska Lecture Notes (1)

Introduction to Logic in Computer Science: Autumn 2007

Syntax of FOL. Introduction to Logic in Computer Science: Autumn Tableaux for First-order Logic. Syntax of FOL (2)

2-4: The Use of Quantifiers

Computational Logic. Recall of First-Order Logic. Damiano Zanardini

Language of Propositional Logic

Predicate Calculus. CS 270 Math Foundations of Computer Science Jeremy Johnson

PROOFS IN PREDICATE LOGIC AND COMPLETENESS; WHAT DECIDABILITY MEANS HUTH AND RYAN 2.3, SUPPLEMENTARY NOTES 2

Section 2.1: Introduction to the Logic of Quantified Statements

Logic. Knowledge Representation & Reasoning Mechanisms. Logic. Propositional Logic Predicate Logic (predicate Calculus) Automated Reasoning

Tecniche di Verifica. Introduction to Propositional Logic

Propositional logic. First order logic. Alexander Clark. Autumn 2014

CS 730/830: Intro AI. 3 handouts: slides, asst 6, asst 7. Wheeler Ruml (UNH) Lecture 12, CS / 16. Reasoning.

First Order Logic (FOL)

A Little Logic. Propositional Logic. Satisfiability Problems. Solving Sudokus. First Order Logic. Logic Programming

Logic and Computation

Class 29 - November 3 Semantics for Predicate Logic

Why Learning Logic? Logic. Propositional Logic. Compound Propositions

KE/Tableaux. What is it for?

All psychiatrists are doctors All doctors are college graduates All psychiatrists are college graduates

First Order Logic: Syntax and Semantics

Introduction to Metalogic

Halting and Equivalence of Program Schemes in Models of Arbitrary Theories

Predicate Logic - Undecidability

Foundations of Artificial Intelligence

Foundations of Artificial Intelligence

22c:145 Artificial Intelligence. First-Order Logic. Readings: Chapter 8 of Russell & Norvig.

Predicate Logic - Semantic Tableau

Transcription:

Page 3 of 35 Page 4 of 35 quantifiers CS156: The Calculus of Computation Zohar Manna Winter 2010 Chapter 2: First-Order Logic (FOL) existential quantifier x. F [x] there exists an x such that F [x] Note: the dot notation ( x., x.) means the scope of the quantifier should extend as far as possible. universal quantifier for all x, F [x] FOL formula x. F [x] Page 1 of 35 literal, application of logical connectives (,,,, ) to formulae, or application of a quantifier to a formula First-Order Logic (FOL) Also called Predicate Logic or Predicate Calculus FOL Syntax variables x, y, z, constants a, b, c, functions f, g, h, terms variables, constants or n-ary function applied to n terms as arguments a, x, f (a), g(x, b), f (g(x, f (b))); f (g(x, f (b, y)))?? predicates p, q, r, atom,, or an n-ary predicate applied to n terms literal atom or its negation p(f (x), g(x, f (x))), p(f (x), g(x, f (x))) Note: 0-ary functions: constants 0-ary predicates (propositional variables): P, Q, R,... Page 2 of 35 FOL formula x. p(f (x), x) ( y. p(f (g(x, y)), g(x, y)) ) q(x, f (x)) }{{} G } {{ } F The scope of x is F. The scope of y is G. The formula reads: for all x, if p(f (x), x) then there exists a y such that p(f (g(x, y)), g(x, y)) and q(x, f (x))

Page 7 of 35 Page 8 of 35 FOL Semantics An interpretation I : (DI, αi ) consists of: Domain DI non-empty set of values or objects cardinality DI deck of cards (finite) integers (countably infinite) reals (uncountably infinite) Assignment αi each variable x assigned value xi DI each n-ary function f assigned fi : D n I DI In particular, each constant a (0-ary function) assigned value ai DI each n-ary predicate p assigned pi : DI n {true, false} In particular, each propositional variable P (0-ary predicate) assigned truth value (true, false) Page 5 of 35 Semantics: Quantifiers An x-variant of interpretation I : (DI, αi ) is an interpretation J : (DJ, αj) such that DI = DJ αi [y] = αj[y] for all symbols y, except possibly x That is, I and J agree on everything except possibly the value of x. F : p(f (x, y), z) p(y, g(z, x)) Interpretation I : (DI, αi ) with DI = Z = {, 2, 1, 0, 1, 2, } { } f +, g, p >, αi : x 13, y 42, z 1 Therefore, we can write FI : 13 + 42 > 1 42 > 1 13. F is true under I. Consider F : x. f (x) = g(x) and the interpretation I : (D : {, }, αi ) in which Page 6 of 35 Denote by J : I {x v} the x-variant of I in which αj[x] = v for some v DI. Then I = x. F I = x. F iff for all v DI, I {x v} = F iff there exists v DI, s.t. I {x v} = F αi : {f ( ), f ( ), g( ), g( ) }. The truth value of F under I is false; i.e., I [F ] = false.

Satisfiability and Validity I F is satisfiable iff there exists I s.t. I = F F is valid iff for all I, I = F F is valid iff F is unsatisfiable Semantic rules: given an interpretation I with domain DI, valid? I = x. F [x] I {x v} = F [x] I = x. F [x] I {x v} = F [x] Is I = x. F [x] I {x v} = F [x] I = x. F [x] I {x v} = F [x] for any v DI for a fresh v DI for a fresh v DI for any v DI F : ( x. p(x)) ( x. p(x)) Page 9 of 35 Suppose not. Then there is an I such that I = F (assumption). First case: 1a. I = ( x. p(x)) ( x. p(x)) assumption and 2a. I = x. p(x) 1a and 3a. I = x. p(x) 1a and 4a. I = x. p(x) 3a and 5a. I {x v} = p(x) 4a and, v DI fresh 6a. I {x v} = p(x) 5a and 7a. I {x v} = p(x) 2a and 6a and 7a are contradictory. Page 11 of 35 Contradiction rule A contradiction exists if two variants of the original interpretation I disagree on the truth value of an n-ary predicate p for a given tuple of domain values: J : I = p(s1,..., sn) K : I = p(t1,..., tn) I = for i {1,..., n}, αj[si] = αk [ti] Intuition: The variants J and K are constructed only through the rules for quantification. Hence, the truth value of p on the given tuple of domain values is already established by I. Therefore, the disagreement between J and K on the truth value of p indicates a problem with I. Example (continued): Second case: 1b. I = ( x. p(x)) ( x. p(x)) Page 10 of 35 assumption and 2b. I = x. p(x) 1b and 3b. I = x. p(x) 1b and 4b. I {x v} = p(x) 2b and, v DI fresh 5b. I = x. p(x) 3b and 6b. I {x v} = p(x) 5b and 7b. I {x v} = p(x) 6b and 4b and 7b are contradictory. Both cases end in contradictions for arbitrary I. Thus F is valid. Page 12 of 35

Page 15 of 35 Page 16 of 35 Prove is valid. F : p(a) x. p(x) Translations of English Sentences (famous theorems) into FOL The length of one side of a triangle is less than the sum of the lengths of the other two sides Assume otherwise; i.e., F is false under interpretation I : (DI, αi ): 1. I = F assumption 2. I = p(a) 1 and 3. I = x. p(x) 1 and 4. I {x αi [a]} = p(x) 3 and 2 and 4 are contradictory. Thus, F is valid. x, y, z. triangle(x, y, z) length(x) < length(y)+length(z) Fermat s Last Theorem. n. integer(n) n > 2 x, y, z. integer(x) integer(y) integer(z) x > 0 y > 0 z > 0 exp(x, n) + exp(y, n) exp(z, n) is invalid. Show that F : ( x. p(x, x)) ( x. y. p(x, y)) Find interpretation I such that F is false under I. Choose DI = {0, 1} pi = {(0, 0), (1, 1)} Page 13 of 35 i.e., pi (0, 0) and pi (1, 1) are true pi (0, 1) and pi (1, 0) are false I [ x. p(x, x)] = true and I [ x. y. p(x, y)] = false. If we can find a falsifying interpretation for F, then F is invalid. Is F : ( x. p(x, x)) ( x. y. p(x, y)) valid? Substitution Page 14 of 35 Suppose we want to replace one term with another in a formula; e.g., we want to rewrite as follows: F : y. (p(x, y) p(y, x)) G : y. (p(a, y) p(y, a)). We call the mapping from x to a a substitution denoted as We write F σ for the formula G. σ : {x a}. Another convenient notation is F [x] for a formula containing the variable x and F [a] for F σ.

Substitution Definition (Substitution) A substitution is a mapping from terms to terms; e.g., σ : {t1 s1,..., tn sn}. By F σ we denote the application of σ to formula F ; i.e., the formula F where all occurrences of t1,..., tn are replaced by s1,..., sn. For a formula named F [x] we write F [t] as shorthand for F [x]{x t}. Renaming Replace x in x by x and all free occurrences 1 of x in G[x], the scope of x, by x : Same for x: where x is a fresh variable. Example (renaming): x. G[x] x. G[x ]. x. G[x] x. G[x ], ( x. p(x) x. q(x)) r(x) replace by the equivalent formula x x free Safe Substitution I Care has to be taken in the presence of quantifiers: [x] : y. y = Succ(x) free Page 17 of 35 ( y. p(y) z. q(z)) r(x) 1 Note: these occurrences are free in G[x], not in x. G[x]. Page 18 of 35 Safe Substitution II Consider the following formula and substitution: F : ( x. p(x, y)) q(f (y), x) free What is F [y]? We need to rename bound variables occurring in the substitution: F [x] : y. y = Succ(x) Bound variable renaming does not change the models of a formula: ( y. y = Succ(x)) ( y. y = Succ(x)) Then under safe substitution Note that the only bound variable in F is the x in p(x, y). The variables x and y are free everywhere else. What is F σ? Use safe substitution! 1. Rename the bound x with a fresh name x : F : ( x. p(x, y)) q(f (y), x) 2. F σ : ( x. p(x, f (x))) q(h(x, y), g(x)) F [y] : y. y = Succ(y) Page 19 of 35 Page 20 of 35

Page 23 of 35 Page 24 of 35 Safe Substitution III Proposition (Substitution of Equivalent Formulae) σ : {F1 G1,, Fn Gn} s.t. for each i, Fi Gi If F σ is a safe substitution, then F F σ. Page 21 of 35 Semantic Tableaux (with Substitution) We assume that there are infinitely many constant symbols. The following rules are used for quantifiers: I = x. F [x] I = F [t] I = x. F [x] I = F [a] I = x. F [x] I = F [a] for any term t for a fresh constant a for a fresh constant a I = x. F [x] for any term t I = F [t] The contradiction rule is similar to that of propositional logic: I = p(t1,..., tn) I = p(t1,..., tn) I = Page 22 of 35 Show that F : ( x. y. p(x, y)) ( x. y. p(y, x)) is valid. Rename to F : ( x. y. p(x, y)) ( x. y. p(y, x )). Assume otherwise. 1. I = F assumption 2. I = x. y. p(x, y) 1 and 3. I = x. y. p(y, x ) 1 and 4. I = y. p(a, y) 2, (a fresh) 5. I = y. p(y, b) 3, (b fresh) 6. I = p(a, b) 4, (t := b) 7. I = p(a, b) 5, (t := a) 8. I = 6, 7 contradictory Thus, the formula is valid. Is F : ( x. p(x, x)) ( x. y. p(x, y)) valid? Rename to F : ( z. p(z, z)) ( x. y. p(x, y)) Assume I falsifies F and apply semantic argument: 1. I = F assumption 2. I = z. p(z, z) 1 and 3. I = x. y. p(x, y) 1 and 4. I = p(a1, a1) 2,, a1 DI fresh 5. I = y. p(a1, y) 3, 6. I = p(a1, a2) 5,, a2 DI fresh 7. I = p(a2, a2) 2, 8. I = y. p(a2, y) 3, 9. I = p(a2, a3) 8,, a3 DI fresh.

Page 27 of 35 Page 28 of 35 No contradiction. Falsifying interpretation I : true y = x, DI = N, pi (x, y) = false y = x + 1, arbitrary otherwise. Formula Schemata Formula ( x. p(x)) ( x. p(x)) Formula Schema H1 : ( x. F ) ( x. F ) place holder Formula Schema (with side condition) H2 : ( x. F ) F provided x / free(f ) Valid Formula Schema H is valid iff it is valid for any FOL formula Fi obeying the side conditions. H1 and H2 are valid. Substitution σ of H σ : {F1 G1,..., Fn Gn} Page 25 of 35 Proving Validity of Formula Schemata I Prove validity of Page 26 of 35 mapping place holders Fi of H to FOL formulae Gi, obeying the side conditions of H Proposition (Formula Schema) If H is a valid formula schema, and σ is a substitution obeying H s side conditions, then Hσ is also valid. H : ( x. F ) F provided x / free(f ) is valid. σ : {F p(y)} obeys the side condition. H : ( x. F ) F provided x / free(f ). Proof by contradiction. Consider the two directions of. First case 1. I = x. F assumption 2. I = F assumption 3. I = F 1,, since x free(f ) 4. I = 2, 3 Therefore Hσ : x. p(y) p(y) is valid.

Proving Validity of Formula Schemata II Second Case 1. I = x. F assumption 2. I = F assumption 3. I = x. F 1 and 4. I = F 3,, since x free(f ) 5. I = 2, 4 Hence, H is a valid formula schema. 2. Prenex Normal Form (PNF) All quantifiers appear at the beginning of the formula Q1x1 Qnxn. F [x1,, xn] where Qi {, } and F is quantifier-free. Page 29 of 35 Every FOL formula F can be transformed to formula F in PNF s.t. F F : Write F in NNF, rename quantified variables to fresh names, and move all quantifiers to the front. Be careful! Normal Forms 1. Negation Normal Forms (NNF) Apply the additional equivalences (left-to-right) x. F [x] x. F [x] x. F [x] x. F [x] when converting PL formulae into NNF. G : x. ( y. p(x, y) p(x, z)) w.p(x, w). 1. x. ( y. p(x, y) p(x, z)) w. p(x, w) 2. x. ( y. p(x, y) p(x, z)) w. p(x, w) F1 F2 F1 F2 3. x. ( y. (p(x, y) p(x, z))) w. p(x, w) x. F [x] x. F [x] 4. G : x. ( y. p(x, y) p(x, z)) w. p(x, w) G in NNF and G G. Find equivalent PNF of F : x. ( y. p(x, y) p(x, z)) y. p(x, y) 1. Write F in NNF to the end of the formula Page 30 of 35 F1 : x. ( y. p(x, y) p(x, z)) y. p(x, y) 2. Rename quantified variables to fresh names F2 : x. ( y. p(x, y) p(x, z)) w. p(x, w) Both are in the scope of x 3. Remove all quantifiers to produce quantifier-free formula F3 : p(x, y) p(x, z) p(x, w) Page 31 of 35 Page 32 of 35

Page 35 of 35 4. Add the quantifiers before F3 Alternately, F4 : x. y. w. p(x, y) p(x, z) p(x, w) F 4 : x. w. y. p(x, y) p(x, z) p(x, w) Note: In F2, y is in the scope of x, therefore the order of quantifiers must be x y. Also, w is in the scope of x, therefore the order of the quantifiers must be x w F4 F and F 4 F Note: However, possibly, G F and G F, for G : y. w. x. p(x, y) p(x, z) p(x, w) Decidability of FOL FOL is undecidable (Turing & Church) There does not exist an algorithm for deciding if a FOL formula F is {valid, satisfiable}; i.e., that always halts and says yes if F is {valid, satisfiable} or no if F is {invalid, unsatisfiable}. FOL is semi-decidable There is a procedure that always halts and says yes if F is {valid, unsatisfiable}, but may not halt if F is {invalid, satisfiable}. On the other hand, PL is decidable There does exist an algorithm for deciding if a PL formula F is {valid, satisfiable}; e.g., the truth-table procedure. G : w. x. y.. Semantic Argument Method Page 33 of 35 To show FOL formula F is valid, assume I = F and derive a contradiction I = in all branches Method is sound If every branch of a semantic argument proof reaches I =, then F is valid Method is complete Each valid formula F has a semantic argument proof in which every branch reaches I = Page 34 of 35