10/17/2015Michael Frank / Kees van Deemter1 University of Aberdeen, Computing Science CS3518 Lecture on Models and Satisfiability Further details: K.Rosen,

Slides:



Advertisements
Similar presentations
Artificial Intelligence
Advertisements

Completeness and Expressiveness
Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen CS2013 Mathematics.
Mathematics for Computing Science
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 1: (Part 2): The Foundations: Logic and Proofs.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
2009/91 Predicates and Quantifiers (§1.3) In the sentence “x is greater than 3”: The phrase “x” denotes the subject - the object or entity that the sentence.
1 Predicate Logic Rosen 6 th ed., § Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.
Module #1 - Logic 5/16/2015Michael Frank / Kees van Deemter1 Predicate Logic Rosen 5 th ed., §§ (but much extended) ~135 slides, ~5 lectures.
CS128 – Discrete Mathematics for Computer Science
CSE 311 Foundations of Computing I Lecture 6 Predicate Logic Autumn 2011 CSE 3111.
From Chapter 4 Formal Specification using Z David Lightfoot
First Order Logic (chapter 2 of the book) Lecture 3: Sep 14.
Monadic Predicate Logic is Decidable Boolos et al, Computability and Logic (textbook, 4 th Ed.)
EE1J2 - Slide 1 EE1J2 – Discrete Maths Lecture 6 Limitations of propositional logic Introduction to predicate logic Symbols, terms and formulae, Parse.
CSE115/ENGR160 Discrete Mathematics 01/20/11 Ming-Hsuan Yang UC Merced 1.
EE1J2 - Slide 1 EE1J2 – Discrete Maths Lecture 11 Introduction to Predicate Logic Limitations of Propositional Logic Predicates, quantifiers and propositions.
Adapted from Discrete Math
First Order Logic. This Lecture Last time we talked about propositional logic, a logic on simple statements. This time we will talk about first order.
Predicates and Quantifiers
Module #1 - Logic 8/28/2015Michael Frank / Kees van Deemter1 Remember: I. Construct a model where 1 and 4 are true, while 2 and 3 are false Let the u.d.
CSci 2011 Discrete Mathematics Lecture 3 CSci 2011.
Intro to Discrete Structures
Logical Equivalence & Predicate Logic
Mathematical Structures A collection of objects with operations defined on them and the accompanying properties form a mathematical structure or system.
MATH 224 – Discrete Mathematics
DECIDABILITY OF PRESBURGER ARITHMETIC USING FINITE AUTOMATA Presented by : Shubha Jain Reference : Paper by Alexandre Boudet and Hubert Comon.
1st-order Predicate Logic (FOL)
1.1 CompSci 102© Michael Frank Today’s topics Propositional equivalencesPropositional equivalences Predicate logicPredicate logic Reading: Sections Reading:
Review I Rosen , 3.1 Know your definitions!
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
Logic CL4 Episode 16 0 The language of CL4 The rules of CL4 CL4 as a conservative extension of classical logic The soundness and completeness of CL4 The.
First Order Logic Lecture 2: Sep 9. This Lecture Last time we talked about propositional logic, a logic on simple statements. This time we will talk about.
Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
Fundamentals of Logic 1. What is a valid argument or proof? 2. Study system of logic 3. In proving theorems or solving problems, creativity and insight.
Hazırlayan DISCRETE COMPUTATIONAL STRUCTURES Propositional Logic PROF. DR. YUSUF OYSAL.
CompSci 102 Discrete Math for Computer Science
Module #1 - Logic 11/24/2015Michael Frank / Kees van Deemter1 University of Aberdeen, Computing Science CS3511 Discrete Methods Kees van Deemter Slides.
1 Introduction to Abstract Mathematics Chapter 2: The Logic of Quantified Statements. Predicate Calculus Instructor: Hayk Melikya 2.3.
Chapter 2 Logic 2.1 Statements 2.2 The Negation of a Statement 2.3 The Disjunction and Conjunction of Statements 2.4 The Implication 2.5 More on Implications.
1 Introduction to Abstract Mathematics Predicate Logic Instructor: Hayk Melikya Purpose of Section: To introduce predicate logic (or.
Chapter 2 Symbolic Logic. Section 2-1 Truth, Equivalence and Implication.
CS 285- Discrete Mathematics Lecture 4. Section 1.3 Predicate logic Predicate logic is an extension of propositional logic that permits concisely reasoning.
CSNB143 – Discrete Structure Topic 4 – Logic. Learning Outcomes Students should be able to define statement. Students should be able to identify connectives.
First Order Logic Lecture 3: Sep 13 (chapter 2 of the book)
Chapter 2 Fundamentals of Logic 1. What is a valid argument or proof?
Chapter 7. Propositional and Predicate Logic Fall 2013 Comp3710 Artificial Intelligence Computing Science Thompson Rivers University.
1 Chapter 2.1 Chapter 2.2 Chapter 2.3 Chapter 2.4 All images are copyrighted to their respective copyright holders and reproduced here for academic purposes.
Mathematics for Comter I Lecture 3: Logic (2) Propositional Equivalences Predicates and Quantifiers.
1 Introduction to Abstract Mathematics Chapter 3: The Logic of Quantified Statements. Predicate Calculus Instructor: Hayk Melikya 3.1.
Section 1.4. Propositional Functions Propositional functions become propositions (and have truth values) when their variables are each replaced by a value.
Foundations of Discrete Mathematics Chapter 1 By Dr. Dalia M. Gil, Ph.D.
Discrete Mathematical Structures: Theory and Applications 1 Logic: Learning Objectives  Learn about statements (propositions)  Learn how to use logical.
1 Section 7.1 First-Order Predicate Calculus Predicate calculus studies the internal structure of sentences where subjects are applied to predicates existentially.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
Introduction to Set Theory (§1.6) A set is a new type of structure, representing an unordered collection (group, plurality) of zero or more distinct (different)
Chapter 1 Logic and proofs
CENG 424-Logic for CS Introduction Based on the Lecture Notes of Konstantin Korovin, Valentin Goranko, Russel and Norvig, and Michael Genesereth.
Chapter 7. Propositional and Predicate Logic
3. The Logic of Quantified Statements Summary
Discrete Math - Module #1 - Logic
Lecture 1 – Formal Logic.
CS201: Data Structures and Discrete Mathematics I
First Order Logic Rosen Lecture 3: Sept 11, 12.
Chapter 7. Propositional and Predicate Logic
Predicates and Quantifiers
Foundations of Discrete Mathematics
CS201: Data Structures and Discrete Mathematics I
Presentation transcript:

10/17/2015Michael Frank / Kees van Deemter1 University of Aberdeen, Computing Science CS3518 Lecture on Models and Satisfiability Further details: K.Rosen, Discrete Mathematics & Its Applications (any edition), chapter on logic

These slides are not meant as a general- purpose introduction, but as preparation forThese slides are not meant as a general- purpose introduction, but as preparation for –a proof that monadic Predicate Logic is decidable –a proof that full Predicate is undecidable 10/17/2015Michael Frank / Kees van Deemter2

First Propositional Logic 10/17/2015Michael Frank / Kees van Deemter3

The syntax of propositional logic Atoms: p1, p2, p3,..Atoms: p1, p2, p3,.. Formulas:Formulas: –All atoms are formulas –For all , if  is a formula then ¬  is a formula –For all  and , if  and  are formulas then the following are formulas: (    ), (    ), (    ) (etc.) CS2013 Univ of Aberdeen4

Subformulas A formula that is a substring of a formula ψ is a subformula of ψA formula that is a substring of a formula ψ is a subformula of ψ Example:  (  p   q) has these subformulas:Example:  (  p   q) has these subformulas: 10/17/2015Michael Frank / Kees van Deemter5

Subformulas A formula that is a substring of a formula ψ is a subformula of ψA formula that is a substring of a formula ψ is a subformula of ψ Example:  (  p   q) has these subformulas:  (  p   q), (  p   q),  p,  q, p, qExample:  (  p   q) has these subformulas:  (  p   q), (  p   q),  p,  q, p, q 10/17/2015Michael Frank / Kees van Deemter6

Tautologies A tautology is a compound proposition that is true no matter what the truth values of its atomic propositions are! Ex. p   p [What is its truth table?] CS2013 Univ of Aberdeen7

Tautologies When every row of the truth table gives.When every row of the truth table gives T. Example: p   p T T FT F T TFExample: p   p T T FT F T TF CS2013 Univ of Aberdeen8

Contradictions A contradiction is a compound proposition that is false no matter what! Ex. p   p [Truth table?] CS2013 Univ of Aberdeen9

Contradictions When every row of the truth table gives FWhen every row of the truth table gives F Example: p   p T F FT F F TFExample: p   p T F FT F F TF CS2013 Univ of Aberdeen10

Propositional Equivalence Two syntactically (i.e., textually) different compound propositions may be semantically identical (i.e., have the same meaning). Here semantically identical means just that they have the same truth table for input truth values of the propositions. We call them logically equivalent. Notation: …  … CS2013 Univ of Aberdeen11

Logical Equivalence Compound proposition p is logically equivalent to compound proposition q, written p  q, IFF p and q contain the same truth values in all rows of their truth tables CS2013 Univ of Aberdeen12

Ex. Prove that p  q   (  p   q). Proving Equivalence via Truth Tables F T T T T T T T T T F F F F F F F F T T CS2013 Univ of Aberdeen13 Shows that OR is equivalent to a combination of NOT and AND.

Logical consequence Formula φ has formula ψ as a logical consequence if ψ “follows from φ”Formula φ has formula ψ as a logical consequence if ψ “follows from φ” Formally: every assignment of truth values that makes φ true makes ψ true as wellFormally: every assignment of truth values that makes φ true makes ψ true as well Notation: φ |= ψNotation: φ |= ψ φ and ψ are logically equivalent iff φ |= ψ and ψ |= φφ and ψ are logically equivalent iff φ |= ψ and ψ |= φ 10/17/2015Michael Frank / Kees van Deemter14

Ex. Prove that p&q   p Example of one-sided logical consequence CS2013 Univ of Aberdeen15 Each row that has T for p&q has T for  p.

10/17/2015Michael Frank / Kees van Deemter16 First-Order Predicate logic (FOPL) An extension of Propositional LogicAn extension of Propositional Logic Sometimes called quantificational logic, because it allows us to quantify over objects in a domainSometimes called quantificational logic, because it allows us to quantify over objects in a domain E.g. saying that all/some objects have a propertyE.g. saying that all/some objects have a property –Some odd numbers are prime Futher extensions exist, e.g. second-order logic, which quantifies over properties, e.g.Futher extensions exist, e.g. second-order logic, which quantifies over properties, e.g. –4 and 2+2 share all their semantic properties Topic #3 – Predicate Logic

10/17/2015Michael Frank / Kees van Deemter17 Predicates/relations with n places Full FOPL permits predicates of any finite number of arguments. E.g.:Full FOPL permits predicates of any finite number of arguments. E.g.: S(x) = “x is even” (1 arg.) R(x,y) = “x adores y” (2 arg.) P(x,y,z) = “x gave y the grade z” (3 arg.) Q(x,y,z,u)= “ x*(y+z)=u ” (4 arg.) Topic #3 – Predicate Logic

10/17/2015Michael Frank / Kees van Deemter18 Syntax of predicate logic (for 1- and 2-place predicates) Variable: x,y,z,… Constants: a,b,c,…Variable: x,y,z,… Constants: a,b,c,… 1-place predicates: P,Q,…1-place predicates: P,Q,… 2-place predicates: R,S,…2-place predicates: R,S,… Atomic formulas: If  is a 1-pace predicate and  a variable or constant then  (  ) is an atomic formula.Atomic formulas: If  is a 1-pace predicate and  a variable or constant then  (  ) is an atomic formula. If  is a 2-pace predicate and  and  are variables or constants then  ( ,  ) is an atomic formula. If  is a 2-pace predicate and  and  are variables or constants then  ( ,  ) is an atomic formula.

10/17/2015Michael Frank / Kees van Deemter19 Syntax of predicate logic (for 1- and 2-place predicates) (Wellformed) Formulas: All atomic formulas are formulasAll atomic formulas are formulas If  and  are formulas then , (   ), (  ), (   ) are formulas.If  and  are formulas then , (   ), (  ), (   ) are formulas. If  is a formula then  x  and  x  are formulas. (Likewise,  y  and  y , and so on.)If  is a formula then  x  and  x  are formulas. (Likewise,  y  and  y , and so on.)

10/17/2015Michael Frank / Kees van Deemter20 Meaning of Quantified Expressions First, informally:  x P(x) means for all x in the u.d., P holds.  x P(x) means for all x in the u.d., P holds.  x P(x) means there exist x in the u.d. (that is, 1 or more) such that P(x) is true.  x P(x) means there exist x in the u.d. (that is, 1 or more) such that P(x) is true. Topic #3 – Predicate Logic

10/17/2015Michael Frank / Kees van Deemter21 Free and Bound Variables An expression like P(x) is said to have a free variable x (i.e., x is not “defined”).An expression like P(x) is said to have a free variable x (i.e., x is not “defined”). A quantifier (either  or  ) operates on an expression having one or more free variables, and binds one or more of those variables, to produce an expression having one or more bound variables.A quantifier (either  or  ) operates on an expression having one or more free variables, and binds one or more of those variables, to produce an expression having one or more bound variables. Topic #3 – Predicate Logic

10/17/2015Michael Frank / Kees van Deemter22 Example of Binding P(x,y) has 2 free variables, x and y.P(x,y) has 2 free variables, x and y.  x P(x,y) has 1 free variable, and one bound variable.  x P(x,y) has 1 free variable, and one bound variable. An expression with zero free variables is called a sentence.An expression with zero free variables is called a sentence. Topic #3 – Predicate Logic

10/17/2015Michael Frank / Kees van Deemter23 Free variables, defined formally The free-variable occurrences in an Atom are: all the variable occurrences in that AtomThe free-variable occurrences in an Atom are: all the variable occurrences in that Atom The free-variable occurrences in  are: the free- variable occurrences in The free-variable occurrences in  are: the free- variable occurrences in  The free-variable occurrences in (  connective  ) are: the free-variable occurrences in  plus the free-variable occurrences in The free-variable occurrences in (  connective  ) are: the free-variable occurrences in  plus the free-variable occurrences in  The free-variable occurrences in  x  and  x  are: the free-variable occurrences in  except for all/any occurrences of x.The free-variable occurrences in  x  and  x  are: the free-variable occurrences in  except for all/any occurrences of x. Topic #3 – Predicate Logic

10/17/2015Michael Frank / Kees van Deemter24 A more precise definition of the truth/falsity of quantified formulas Formulation is simplified somewhat because we assume that every object in the u.d. D has a `name` (i.e., a constant referring to it).Formulation is simplified somewhat because we assume that every object in the u.d. D has a `name` (i.e., a constant referring to it). Notation:  (x:=a) is the result of substituting all free occurrences of the variable x in  by the constant aNotation:  (x:=a) is the result of substituting all free occurrences of the variable x in  by the constant a Topic #3 – Predicate Logic

10/17/2015Michael Frank / Kees van Deemter25 A more precise definition Let  be a formula. Then  x  is true in D if at least one expression  (x:=a) is true in D, and false otherwise.Let  be a formula. Then  x  is true in D if at least one expression  (x:=a) is true in D, and false otherwise. A simple example:  = P(x)A simple example:  = P(x) P(x) is a formula, hence  x P(x) is true in D if at least one expression of the form P(a) is true in D, and false otherwise. Topic #3 – Predicate Logic

10/17/2015Michael Frank / Kees van Deemter26 Similarly for  Let  be a formula. Then the proposition  x  is true in D if every expression of the form  (x:=a) is true in D, and false otherwise.Let  be a formula. Then the proposition  x  is true in D if every expression of the form  (x:=a) is true in D, and false otherwise. A simple example:  = P(x)A simple example:  = P(x) P(x) is a formula, hence  x P(x) is true in D if every expression P(a) is true in D, and false otherwise. P(x) is a formula, hence  x P(x) is true in D if every expression P(a) is true in D, and false otherwise. Topic #3 – Predicate Logic

10/17/2015Michael Frank / Kees van Deemter27 Predicate logic A formula of FOPL is True (False) with respect to a modelA formula of FOPL is True (False) with respect to a model Model = domain of objects plus specification of the “meanings” of the predicates, e.g., byModel = domain of objects plus specification of the “meanings” of the predicates, e.g., by –listing explicitly which objects the predicate is true of

10/17/2015Michael Frank / Kees van Deemter28 Interactions between quantifiers and connectives Let the u.d. be parking spaces at UF. Let P(x) be “x is occupied.” Let Q(x) be “x is free of charge.” 1.  x (Q(x)  P(x)) 2.  x (Q(x)  P(x)) 3.  x (Q(x)  P(x)) 4.  x (Q(x)  P(x))

10/17/2015Michael Frank / Kees van Deemter29 I. Construct English paraphrases Let the u.d. be parking spaces at UF. Let P(x) be “x is occupied.” Let Q(x) be “x is free of charge.” 1.  x (Q(x)  P(x)) 2.  x (Q(x)  P(x)) 3.  x (Q(x)  P(x)) 4.  x (Q(x)  P(x))

10/17/2015Michael Frank / Kees van Deemter30 I. Construct English paraphrases 1.  x (Q(x)  P(x)) Some places are free of charge and occupied 2.  x (Q(x)  P(x)) All places are free of charge and occupied 3.  x (Q(x)  P(x)) All places that are free of charge are occupied 4.  x (Q(x)  P(x)) For some places x, if x is free of charge then x is occupied

10/17/2015Michael Frank / Kees van Deemter31 II. Construct a model where 1 and 4 are true, while 2 and 3 are false Let the u.d. be parking spaces at UF. Let P(x) be “x is occupied.” Let Q(x) be “x is free of charge.” 1.  x (Q(x)  P(x)) 2.  x (Q(x)  P(x)) 3.  x (Q(x)  P(x)) 4.  x (Q(x)  P(x))

10/17/2015Michael Frank / Kees van Deemter32 II. Construct a model where 1 and 4 are true, while 2 and 3 are false 1.  x (Q(x)  P(x)) (true for place a below) 2.  x (Q(x)  P(x)) (false for places b below) 3.  x (Q(x)  P(x)) (false for place b below) 4.  x (Q(x)  P(x)) (true for place a below) One solution: a model with exactly two objects in it. One object has the property Q and the property P; the other object has the property Q but not the property P. In a diagram: a: Q P b: Q not-P a: Q P b: Q not-P

10/17/2015Michael Frank / Kees van Deemter33 III. Construct a model where 1 and 3 and 4 are true, but 2 is false 1.  x (Q(x)  P(x)) 2.  x (Q(x)  P(x)) 3.  x (Q(x)  P(x)) 4.  x (Q(x)  P(x)) Here is such a model (using a diagram). It has just two objects in its u.d., called a and b: a: Q P b: not-Q P a: Q P b: not-Q P

10/17/2015Michael Frank / Kees van Deemter34 Formally what is a model? A model M is a pair where D is a set (an u.d.), and I is a suitable ‘interpretation’ function. Informally speaking, a given M defines one way of giving a concrete ‘meaning’ to the symbols (other than  ) in your formulas.A model M is a pair where D is a set (an u.d.), and I is a suitable ‘interpretation’ function. Informally speaking, a given M defines one way of giving a concrete ‘meaning’ to the symbols (other than  ) in your formulas. If a is an individual constant then I(a)  DIf a is an individual constant then I(a)  D If P is a 1-place predicate then I(P)  DIf P is a 1-place predicate then I(P)  D If R is a 2-place predicate then I(P) is a set of pairs ( ,  ) such that   D, and   DIf R is a 2-place predicate then I(P) is a set of pairs ( ,  ) such that   D, and   D

10/17/2015Michael Frank / Kees van Deemter35 An example of a model Suppose M = (D,I) where D={John,Mary,Bill} and I(j)=John, I(m)=Mary, I(b)=Bill, I(B)={John,Bill} I(G)={Mary} I(A)={(John,Mary),(Bill,Mary)}Suppose M = (D,I) where D={John,Mary,Bill} and I(j)=John, I(m)=Mary, I(b)=Bill, I(B)={John,Bill} I(G)={Mary} I(A)={(John,Mary),(Bill,Mary)} Note: John is a person (i.e., a part of the world) j is an individual constant (i.e., a part of the language of predicate logic). j “names” John.Note: John is a person (i.e., a part of the world) j is an individual constant (i.e., a part of the language of predicate logic). j “names” John.

10/17/2015Michael Frank / Kees van Deemter36 Formally (where M = ) atomic formulas Here is the start of the new truth definition: A formula of the form P(a) is true with respect to M iff I(a)  I(P).A formula of the form P(a) is true with respect to M iff I(a)  I(P). A formula of the form R(a,b) is true with respect to M iff (I(a),I(b))  I(R).A formula of the form R(a,b) is true with respect to M iff (I(a),I(b))  I(R).

10/17/2015Michael Frank / Kees van Deemter37 Formally (where M = ) formulas with propositional connectives A formula of the form  is true wrt M iff  is false wrt MA formula of the form  is true wrt M iff  is false wrt M A formula of the form  is true wrt M iff  is true wrt M or  is true wrt M or bothA formula of the form  is true wrt M iff  is true wrt M or  is true wrt M or both A formula of the form  is true wrt M iff  is true wrt M and  is true wrt MA formula of the form  is true wrt M iff  is true wrt M and  is true wrt M A formula of the form    is true wrt M iff  is false wrt M or  is true wrt M or bothA formula of the form    is true wrt M iff  is false wrt M or  is true wrt M or both

10/17/2015Michael Frank / Kees van Deemter38 Formally (where M = ) quantified formulas A formula of the form  x  is true wrt M iff at least one expression  (x:=a) is true wrt M. (More precisely: there is an a such that...)A formula of the form  x  is true wrt M iff at least one expression  (x:=a) is true wrt M. (More precisely: there is an a such that...) A formula of the form  x  is true wrt M iff all expressions  (x:=a) are true wrt M. (More precisely: for all a,...)A formula of the form  x  is true wrt M iff all expressions  (x:=a) are true wrt M. (More precisely: for all a,...) (End of truth definition.)(End of truth definition.)

10/17/2015Michael Frank / Kees van Deemter39 models: some illustrations Suppose M= (D,I), where D={John,Mary,Bill}, and I(j)=John, I(m)=Mary, I(b)=Bill, and I(B)={John,Bill} I(G)={Mary} I(A)={(John,Mary),(Bill,Mary)}Suppose M= (D,I), where D={John,Mary,Bill}, and I(j)=John, I(m)=Mary, I(b)=Bill, and I(B)={John,Bill} I(G)={Mary} I(A)={(John,Mary),(Bill,Mary)} Is B(j) true wrt M?Is B(j) true wrt M?

10/17/2015Michael Frank / Kees van Deemter40 models: some illustrations Suppose M=( D,I), where D={John,Mary,Bill}, and I(j)=John, I(m)=Mary, I(b)=Bill, and I(B)={John,Bill} I(G)={Mary} I(A)={(John,Mary),(Bill,Mary)}Suppose M=( D,I), where D={John,Mary,Bill}, and I(j)=John, I(m)=Mary, I(b)=Bill, and I(B)={John,Bill} I(G)={Mary} I(A)={(John,Mary),(Bill,Mary)} Is B(j) true wrt M? YesIs B(j) true wrt M? Yes

10/17/2015Michael Frank / Kees van Deemter41 models: some illustrations Suppose M=(D,I), where D={John,Mary,Bill}, and I(j)=John, I(m)=Mary, I(b)=Bill, and I(B)={John,Bill} I(G)={Mary} I(A)={(John,Mary),(Bill,Mary)}Suppose M=(D,I), where D={John,Mary,Bill}, and I(j)=John, I(m)=Mary, I(b)=Bill, and I(B)={John,Bill} I(G)={Mary} I(A)={(John,Mary),(Bill,Mary)} Is B(j) true wrt M? YesIs B(j) true wrt M? Yes Is B(j)  B(b)  A(m,m) true wrt M?Is B(j)  B(b)  A(m,m) true wrt M?

10/17/2015Michael Frank / Kees van Deemter42 models: some illustrations Suppose M=(D,I), where D={John,Mary,Bill}, and I(j)=John, I(m)=Mary, I(b)=Bill, and I(B)={John,Bill} I(G)={Mary} I(A)={(John,Mary),(Bill,Mary)}Suppose M=(D,I), where D={John,Mary,Bill}, and I(j)=John, I(m)=Mary, I(b)=Bill, and I(B)={John,Bill} I(G)={Mary} I(A)={(John,Mary),(Bill,Mary)} Is B(j) true wrt M? YesIs B(j) true wrt M? Yes Is B(j)  B(b)  A(m,m) true wrt M? NoIs B(j)  B(b)  A(m,m) true wrt M? No

10/17/2015Michael Frank / Kees van Deemter43 models: some illustrations Suppose M=(D,I), where D={John,Mary,Bill}, and I(j)=John, I(m)=Mary, I(b)=Bill, and I(B)={John,Bill} I(G)={Mary} I(A)={(John,Mary),(Bill,Mary)}Suppose M=(D,I), where D={John,Mary,Bill}, and I(j)=John, I(m)=Mary, I(b)=Bill, and I(B)={John,Bill} I(G)={Mary} I(A)={(John,Mary),(Bill,Mary)} Is B(j) true wrt M? YesIs B(j) true wrt M? Yes Is B(j)  B(b)  A(m,m) true wrt M? NoIs B(j)  B(b)  A(m,m) true wrt M? No Is  x(B(x)  A(x,m)) true wrt M?Is  x(B(x)  A(x,m)) true wrt M?

10/17/2015Michael Frank / Kees van Deemter44 models: some illustrations Suppose M=(D,I), where D={John,Mary,Bill}, and I(j)=John, I(m)=Mary, I(b)=Bill, and I(B)={John,Bill} I(G)={Mary} I(A)={(John,Mary),(Bill,Mary)}Suppose M=(D,I), where D={John,Mary,Bill}, and I(j)=John, I(m)=Mary, I(b)=Bill, and I(B)={John,Bill} I(G)={Mary} I(A)={(John,Mary),(Bill,Mary)} Is B(j) true wrt M? YesIs B(j) true wrt M? Yes Is B(j)  B(b)  A(m,m) true wrt M? NoIs B(j)  B(b)  A(m,m) true wrt M? No Is  x(B(x)  A(x,m)) true wrt M? YesIs  x(B(x)  A(x,m)) true wrt M? Yes

10/17/2015Michael Frank / Kees van Deemter45 models: some illustrations  x(B(x)  A(x,m)) true wrt M iff all expressions B(a)  A(a,m) are true wrt M. These are the following: B(j)  A(j,m) B(b)  A(b,m) B(m)  A(m,m)

10/17/2015Michael Frank / Kees van Deemter46 why is the latter formula true?  x(B(x)  A(x,m)) true wrt M iff all expressions B(a)  A(a,m) are true wrt M. These are the following: B(j)  A(j,m) true wrt M B(b)  A(b,m) true wrt M B(m)  A(m,m)

10/17/2015Michael Frank / Kees van Deemter47 why is the latter formula true?  x(B(x)  A(x,m)) true wrt M iff all expressions B(a)  A(a,m) are true wrt M. These are the following: B(j)  A(j,m) true wrt M B(b)  A(b,m) true wrt M B(m)  A(m,m) true wrt M (antecedent false!) Consequently  x(B(x)  A(x,m)) is true wrt M

Logical Consequence in Predicate Logic (compare Propositional Logic) Formula φ has formula ψ as a logical consequence if ψ “follows from φ”Formula φ has formula ψ as a logical consequence if ψ “follows from φ” Formally: every model that makes φ true makes ψ true as wellFormally: every model that makes φ true makes ψ true as well Notation: φ |= ψNotation: φ |= ψ φ and ψ are logically equivalent iff φ |= ψ and ψ |= φφ and ψ are logically equivalent iff φ |= ψ and ψ |= φ 10/17/2015Michael Frank / Kees van Deemter48

Example  x (P(x)  Q(x)) ?|=? (  x P(x))  (  x Q(x)) (  x P(x))  (  x Q(x)) ?|=?  x (P(x)  Q(x)) 10/17/2015Michael Frank / Kees van Deemter49

Logical Consequence Example  x (P(x)  Q(x)) |= (  x P(x))  (  x Q(x)) Is true (  x P(x))  (  x Q(x)) |=  x (P(x)  Q(x)) Is false A model of (  x P(x))  (  x Q(x)) that’s not a model of  x (P(x)  Q(x)): a:P not Q b Q notP 10/17/2015Michael Frank / Kees van Deemter50

Satisfiability A sentence φ is satisfiable if there is a model M such that M |= φA sentence φ is satisfiable if there is a model M such that M |= φ Examples:  x (P(x)  Q(x))   (  x (P(x)  Q(x))) is satisfiable (you’ve seen a model)  (  x (P(x)  Q(x))   (  x (P(x)  Q(x)))) is also satisfiable. Here’s a model: a:P Q b Q notPExamples:  x (P(x)  Q(x))   (  x (P(x)  Q(x))) is satisfiable (you’ve seen a model)  (  x (P(x)  Q(x))   (  x (P(x)  Q(x)))) is also satisfiable. Here’s a model: a:P Q b Q notP 10/17/2015Michael Frank / Kees van Deemter51

10/17/2015Michael Frank / Kees van Deemter52 Quantifier Equivalence Laws Expanding quantifiers: If u.d.=a,b,c,…  x P(x)  P(a)  P(b)  P(c)  …  x P(x)  P(a)  P(b)  P(c)  …Expanding quantifiers: If u.d.=a,b,c,…  x P(x)  P(a)  P(b)  P(c)  …  x P(x)  P(a)  P(b)  P(c)  … Topic #3 – Predicate Logic

10/17/2015Michael Frank / Kees van Deemter53 Remember In propositional logic, we can strictly speaking only build formulas of finite size.In propositional logic, we can strictly speaking only build formulas of finite size. E.g., we can write P(a)  P(b) P(a)  P(b)  P(c) P(a)  P(b)  P(c)  P(d), etc.E.g., we can write P(a)  P(b) P(a)  P(b)  P(c) P(a)  P(b)  P(c)  P(d), etc. But this way, we could never say that all natural numbers have PBut this way, we could never say that all natural numbers have P

Optional bonus topics This is to give you more insight in the strengths limitations of FOPLThis is to give you more insight in the strengths limitations of FOPL None of this is necessary for understanding the proof that followNone of this is necessary for understanding the proof that follow 10/17/2015Michael Frank / Kees van Deemter54

10/17/2015Michael Frank / Kees van Deemter55 Example: one As per their name, quantifiers can be used to express that a predicate is true of a given quantity (number) of objects.As per their name, quantifiers can be used to express that a predicate is true of a given quantity (number) of objects. Example: Can predicate logic say “there exists at most one object with property P”?Example: Can predicate logic say “there exists at most one object with property P”?

10/17/2015Michael Frank / Kees van Deemter56 Example: at most one Example: Can predicate logic say “there exists at most one object with property P”?Example: Can predicate logic say “there exists at most one object with property P”? Yes (provided we have equality): Yes (provided we have equality):  x  y (( P(x)  P(y))  x= y )  x  y (( P(x)  P(y))  x= y )

10/17/2015Michael Frank / Kees van Deemter57 Example: one Can predicate logic say “there exists exactly one object with property P”?Can predicate logic say “there exists exactly one object with property P”?

10/17/2015Michael Frank / Kees van Deemter58 Example: one Can predicate logic say “there exists exactly one object with property P”?  xP(x)   x  y (( P(x)  P(y))  x= y)Can predicate logic say “there exists exactly one object with property P”?  xP(x)   x  y (( P(x)  P(y))  x= y) “There exist x such that P(x)” and “There exists at most one x such that P(x)”“There exist x such that P(x)” and “There exists at most one x such that P(x)” Abbreviation:  !x P(x) (“there exists exactly one x such that P(x)”)Abbreviation:  !x P(x) (“there exists exactly one x such that P(x)”)

10/17/2015Michael Frank / Kees van Deemter59 Example: one Another way to write this:Another way to write this:  x ( P(x)   y ( P(y)  y  x ) ) “There is an x such that P(x), such that there is no y such that P(y) and y  x.”  x ( P(x)   y ( P(y)  y  x ) ) “There is an x such that P(x), such that there is no y such that P(y) and y  x.”  x binds x throughout the conjunction:  x ( P(x)   y ( P(y)  y  x ) )  x binds x throughout the conjunction:  x ( P(x)   y ( P(y)  y  x ) )

10/17/2015Michael Frank / Kees van Deemter60 At least two Can predicate logic say “there exist at least two objects with property P”?Can predicate logic say “there exist at least two objects with property P”?

10/17/2015Michael Frank / Kees van Deemter61 At least two Can predicate logic say “there exist at least two objects with property P”?Can predicate logic say “there exist at least two objects with property P”? Yes:  x  y ( (P(x)  P(y))  x  y )Yes:  x  y ( (P(x)  P(y))  x  y ) Incorrect would be  xP(x)   y(P(y)  x  y), (where x occurs free, and which therefore does not express a proposition)Incorrect would be  xP(x)   y(P(y)  x  y), (where x occurs free, and which therefore does not express a proposition)

10/17/2015Michael Frank / Kees van Deemter62 Exactly two Can predicate logic say “there exist exactly two objects with property P”?Can predicate logic say “there exist exactly two objects with property P”?

10/17/2015Michael Frank / Kees van Deemter63 Exactly wo Can predicate logic say “there exist exactly two objects with property P”?Can predicate logic say “there exist exactly two objects with property P”? Yes:Yes:  x  y ( P(x)  P(y)  x  y   z ( P(z)  (z= x  z= y) ) )  x  y ( P(x)  P(y)  x  y   z ( P(z)  (z= x  z= y) ) )

10/17/2015Michael Frank / Kees van Deemter64 What’s wrong with  x  y (P(x)  P(y)  x  y)   z ( P(z)  (z= x  z= y ) ) as a formalisation of ‘exactly two’?  x  y (P(x)  P(y)  x  y)   z ( P(z)  (z= x  z= y ) ) as a formalisation of ‘exactly two’?

10/17/2015Michael Frank / Kees van Deemter65 What’s wrong with  x  y (P(x)  P(y)  x  y)   z ( P(z)  (z= x  z= y ) ) as a formalisation of ‘exactly two’?  x  y (P(x)  P(y)  x  y)   z ( P(z)  (z= x  z= y ) ) as a formalisation of ‘exactly two’? This is a conjunction of two separate propositions. As a result, x and y are not bound, so this is not even a propositionThis is a conjunction of two separate propositions. As a result, x and y are not bound, so this is not even a proposition

10/17/2015Michael Frank / Kees van Deemter66 infinitely many Can predicate logic say “there exist infinitely many objects with property P”?Can predicate logic say “there exist infinitely many objects with property P”? No! [This follows from the so-called Compactness Theorem: “An infinite set S of formulas has a model iff every finite subset of S has a model”]No! [This follows from the so-called Compactness Theorem: “An infinite set S of formulas has a model iff every finite subset of S has a model”] How about finitely many?How about finitely many?

10/17/2015Michael Frank / Kees van Deemter67 finitely many How about finitely many?How about finitely many? Suppose there existed a formula  = “there exist only finitely many x such that so and so”Suppose there existed a formula  = “there exist only finitely many x such that so and so” Then  = “there exist infinitely many x such that so and so”Then  = “there exist infinitely many x such that so and so” We know that such a formula does not existWe know that such a formula does not exist So, also  does not existSo, also  does not exist

10/17/2015Michael Frank / Kees van Deemter68 ( Of course if we allow infinite conjunctions then all this can be expressed:  !x P(x)   2!x P(x)   3!x P(x)  … ) ( Of course if we allow infinite conjunctions then all this can be expressed:  !x P(x)   2!x P(x)   3!x P(x)  … )

10/17/2015Michael Frank / Kees van Deemter69 Can predicate logic say “most objects have property P”?Can predicate logic say “most objects have property P”? No! [This follows from the Compactness Theorem as well. Again, this is unless we allow infinitely long disjunctions.]No! [This follows from the Compactness Theorem as well. Again, this is unless we allow infinitely long disjunctions.] Can predicate logic say “many objects have property P”?Can predicate logic say “many objects have property P”? No, only precisely defined quantitiesNo, only precisely defined quantities

10/17/2015Michael Frank / Kees van Deemter70 Logic Programming Some programming languages are based entirely on (a part of) predicate logicSome programming languages are based entirely on (a part of) predicate logic The most famous one is called Prolog.The most famous one is called Prolog. A Prolog program is a set of propositions (“facts”) and (“rules”) in predicate logic.A Prolog program is a set of propositions (“facts”) and (“rules”) in predicate logic. The input to the program is a “query” proposition.The input to the program is a “query” proposition. –Want to know if it is true or false. The Prolog interpreter does some automated deduction to determine whether the query follows from the facts.The Prolog interpreter does some automated deduction to determine whether the query follows from the facts.

10/17/2015Michael Frank / Kees van Deemter71 Facts in Prolog A fact in Prolog represents a simple, non- compound proposition in predicate logic.A fact in Prolog represents a simple, non- compound proposition in predicate logic. –E.g., likes(john,mary) –Lowercase symbols are used for constants and predicates, uppercase is used for variables.

10/17/2015Michael Frank / Kees van Deemter72 Rules in Prolog A rule in Prolog represents a universally quantified proposition of the general form  x  y (P(x,y)→Q(x)), where x and y are variables, P a possibly compound predicate, and Q an atomic proposition.A rule in Prolog represents a universally quantified proposition of the general form  x  y (P(x,y)→Q(x)), where x and y are variables, P a possibly compound predicate, and Q an atomic proposition. In Prolog: q(X) :- p(X,Y).In Prolog: q(X) :- p(X,Y). i.e., the ,  quantifiers are implicit. Example: likable(X) :- likes(Y,X).Example: likable(X) :- likes(Y,X).

10/17/2015Michael Frank / Kees van Deemter73 Rules in Prolog Note that  x  y (P(x,y)→Q(x)) is equivalent to  x((  y P(x,y)→Q(x))Note that  x  y (P(x,y)→Q(x)) is equivalent to  x((  y P(x,y)→Q(x)) In other words, Q(x) holds if you can find a y such that P(x,y)In other words, Q(x) holds if you can find a y such that P(x,y)

10/17/2015Michael Frank / Kees van Deemter74 Conjunction and Disjunction Logical conjunction is encoded using multiple comma-separated terms in a rule.Logical conjunction is encoded using multiple comma-separated terms in a rule. Logical disjunction is encoded using multiple rules.Logical disjunction is encoded using multiple rules. E.g.,  x ((P(x)  Q(x))  R(x))→S(x) can be rendered in Prolog as:E.g.,  x ((P(x)  Q(x))  R(x))→S(x) can be rendered in Prolog as: s(X) :- p(X),q(X) s(X) :- r(X)

10/17/2015Michael Frank / Kees van Deemter75 Deduction in Prolog When a query is input to the Prolog interpreter,When a query is input to the Prolog interpreter, –it searches its database to determine if the query can be proven true from the available facts. –if so, it returns “yes”, if not, “no” (!) –If the query contains any variables, all values that make the query true are printed.

10/17/2015Michael Frank / Kees van Deemter76 Simple Prolog Example An example input program:An example input program:likes(john,mary).likes(mary,fred).likes(fred,mary). likable(X) :- likes(Y,X). An example query: ? likable(Z) returns:...An example query: ? likable(Z) returns:...

10/17/2015Michael Frank / Kees van Deemter77 Simple Prolog Example An example input program:An example input program:likes(john,mary).likes(mary,fred).likes(fred,mary). likable(X) :- likes(Y,X). An example query: ? likable(Z) returns: mary fredAn example query: ? likable(Z) returns: mary fred

10/17/2015Michael Frank / Kees van Deemter78 Relation between PROLOG and Predicate Logic PROLOG cannot use all predicate logic formulas. (It covers a decidable “fragment” of predicate logic.)PROLOG cannot use all predicate logic formulas. (It covers a decidable “fragment” of predicate logic.) It uses ‘negation as failure’It uses ‘negation as failure’ Based on these limitations, PROLOG-based deduction is decidable.Based on these limitations, PROLOG-based deduction is decidable. PROLOG is more than just logic (I/O, cut!), but logic is its hard core.PROLOG is more than just logic (I/O, cut!), but logic is its hard core.

10/17/2015Michael Frank / Kees van Deemter79 Bonus: Number Theory Examples Let u.d. = the natural numbers 0, 1, 2, … What do the following mean?  x (E(x)  (  y x=2y))  x (E(x)  (  y x=2y))  x ( P(x)  (x>1   yz x=yz  y  1  z  1 ) )  x ( P(x)  (x>1   yz x=yz  y  1  z  1 ) ) Topic #3 – Predicate Logic

10/17/2015Michael Frank / Kees van Deemter80 Bonus: more Number Theory Examples Let u.d. = the natural numbers 0, 1, 2, …Let u.d. = the natural numbers 0, 1, 2, … “A number x has the property E if and only if it is equal to 2 times some other number.” (even!)  x (E(x)  (  y x=2y))“A number x has the property E if and only if it is equal to 2 times some other number.” (even!)  x (E(x)  (  y x=2y)) “A number has P, iff it’s greater than 1 and it isn’t the product of any non-unity numbers.” (prime!)“A number has P, iff it’s greater than 1 and it isn’t the product of any non-unity numbers.” (prime!)  x ( P(x)  (x>1   yz x=yz  y  1  z  1 ) )  x ( P(x)  (x>1   yz x=yz  y  1  z  1 ) ) Topic #3 – Predicate Logic

10/17/2015Michael Frank / Kees van Deemter81 Goldbach’s Conjecture (unproven) Using E(x) and P(x) from previous slide,  x( [x>2  E(x)] →  x( [x>2  E(x)] →  p  q P(p)  P(q)  p+q = x).  p  q P(p)  P(q)  p+q = x). Topic #3 – Predicate Logic

10/17/2015Michael Frank / Kees van Deemter82 Goldbach’s Conjecture (unproven) Using E(x) and P(x) from previous slide,  x( [x>2  E(x)] →  x( [x>2  E(x)] →  p  q P(p)  P(q)  p+q = x).  p  q P(p)  P(q)  p+q = x). “Every even number greater than 2 is the sum of two primes.” Topic #3 – Predicate Logic