Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

1

2 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

3 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

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

5 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

6 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

7 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

8 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

9 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

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

11 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

12 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

13 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

14 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.

15 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

16 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.

17 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

18 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

19 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.

20 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.)

21 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

22 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

23 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

24 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

25 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

26 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

27 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

28 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

29 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))

30 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))

31 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

32 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))

33 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

34 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

35 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

36 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.

37 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).

38 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

39 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.)

40 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?

41 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

42 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?

43 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

44 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?

45 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

46 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)

47 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)

48 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

49 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

50 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

51 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

52 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

53 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

54 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

55 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

56 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”?

57 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 )

58 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”?

59 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)”)

60 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 ) )

61 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”?

62 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)

63 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”?

64 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) ) )

65 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’?

66 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

67 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?

68 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

69 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)  … )

70 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

71 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.

72 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.

73 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).

74 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)

75 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)

76 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.

77 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:...

78 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

79 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.

80 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

81 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

82 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

83 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


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

Similar presentations


Ads by Google