1 / 34

L ogics for D ata and K nowledge R epresentation

L ogics for D ata and K nowledge R epresentation. Exercises: First Order Logics (FOL). Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto Giunchiglia, Rui Zhang and Vincenzo Maltese. Logical Modeling. Language L. Theory T. Data Knowledge. Interpretation.

zhen
Download Presentation

L ogics for D ata and K nowledge R epresentation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Logics for Data and KnowledgeRepresentation Exercises: First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto Giunchiglia, Rui Zhang and Vincenzo Maltese

  2. Logical Modeling Language L Theory T Data Knowledge Interpretation Modeling Entailment World Mental Model ⊨ I Realization Domain D Model M Meaning SEMANTIC GAP 2

  3. The need for greater expressive power • We need FOL for a greater expressive power. In FOL we have: • constants/individuals (e.g. 2) • variables (e.g. x) • Unary predicates (e.g. Man) • N-ary predicates (eg. Near) • functions (e.g. Sum, Exp) • quantifiers (∀, ∃) • equality symbol = (optional) 3

  4. Syntax

  5. Alphabet of symbols in FOL • Variables x1, x2, …, y, z • Constants a1, a2, …, b, c • Predicate symbols A11, A12, …, Anm • Function symbols f11, f12, …, fnm • Logical symbols ∧, ∨, ,  , ∀, ∃ • Auxiliary symbols ( ) • Indexes on top are used to denote the number of arguments, called arity, in predicates and functions. • Indexes on the bottom are used to disambiguate between symbols having the same name. • Predicates of arity =1 correspond to properties or concepts

  6. Terms • Terms can be defined using the following BNF grammar: <term> ::= <variable> | <constant> | <function> (<term> {,<term>}*) • A term is called a closed term iff it does not contain variables x, 2, SQRT(x), Sum(2, 3), Sum(2, x), Average(x1, x2, x3) Sum(2, 3)

  7. Well formed formulas • Well formed formulas (wff) can be defined in BNF as follows: <atomic formula> ::= <predicate> (<term> {,<term>}*) | <term> = <term> <wff> ::= <atomic formula> | ¬<wff> |<wff> ∧ <wff> | <wff> ∨ <wff> | <wff>  <wff> | ∀ <variable> <wff> | ∃ <variable> <wff> NOTE: We can also write ∃x.P(x) or ∃x:P(x) as notation (with ‘.’ or “:”) Man(x) Odd(3)∀x (Odd(x)  Even(x))∃x (Dog(x)  White(x))∃x ∃y (Dog(x)  Dog(y) (x = y))∀x (Even(x)  GreaterThan(x,2)  ∃y∃z (Prime(y)  Prime(z)  x = Sum(y,z)))

  8. Write in FOL the following NL sentences • “Einstein is a scientist” Scientist(einstein) • “There is a monkey” ∃x Monkey(x) • “There exists a dog which is black” ∃x (Dog(x)  Black(x)) • “All persons have a name” ∀x (Person(x)  ∃y Name(x, y))

  9. Write in FOL the following NL sentences • “The sum of two odd numbers is even” ∀x ∀y ( Odd(x)  Odd(y)  Even(Sum(x,y)) ) • “A father is a male person having at least one child” ∀x ( Father(x)  Person(x)  Male(x)  ∃y hasChilden(x, y) ) • “There is exactly one dog” ∃x Dog(x)  ∀x ∀y ( Dog(x)  Dog(y) x = y ) • “There are at least two dogs” ∃x ∃y ( Dog(x)  Dog(y)  (x = y) ) 9

  10. The use of FOL in mathematics • Express in FOL the fact that every natural number x multiplied by 1 returns x (identity): ∀x( Natural(x)  (Mult(x, 1)=x) ) • Express in FOL the fact that the multiplication of two natural numbers is commutative: ∀x∀y( Natural(x)  Natural(y) (Mult(x, y)=Mult(y, x)) ) 10

  11. The use of FOL in mathematics • FOL has being introduced to express mathematical properties • The set of axioms describing the properties of equality between natural numbers (by Peano): Axioms about equality • ∀x1 (x1 = x1) reflexivity • ∀x1 ∀x2 (x1 = x2 x2 = x1) symmetricity • ∀x1 ∀x2 ∀x3 (x1 = x2x2 = x3x1 = x3) transitivity • ∀x1 ∀x2 (x1 = x2 S(x1) = S(x2)) successor NOTE: Other axioms can be given for the properties of the successor, the addition (+) and the multiplication (x). 11

  12. Modeling the club of married problem There are exactly three people in the club, Tom, Sue and Mary. Tom and Sue are married. If a member of the club is married, their spouse is also in the club. Mary is not married. L = {tom, sue, mary, Club, Married} Club(tom)  Club(sue)  Club(mary)  ∀x (Club(x)  (x = tom  x = sue  x = mary)) Married(tom, sue) ∀x ∀y ((Club(x)  Married(x, y))  Club(y))  ∃x Married(mary, x) 12

  13. Modeling the club of married problem (II) There are exactly three people in the club, Tom, Sue and Mary. Tom and Sue are married. If a member of the club is married, their spouse is also in the club. Add enough common sense FOL statements (e.g. everyone has at most one spouse, nobody can be married to himself or herself, Tom, Sue and Mary are different people) to make it entail that Mary is not married in FOL. L = {tom, sue, mary, Club, Married} S1: Club(tom)  Club(sue)  Club(mary)  ∀x (Club(x)  (x = tom  x = sue  x = mary)) S2: Married(tom, sue) S3: ∀x ∀y ((Club(x)  Married(x, y))  Club(y)) S4:  ∃x Married(mary, x) 13

  14. Modeling the club of married problem (III) There are exactly three people in the club, Tom, Sue and Mary. Tom and Sue are married. If a member of the club is married, their spouse is also in the club. Add enough common sense FOL statements (e.g. everyone has at most one spouse, nobody can be married to himself or herself, Tom, Sue and Mary are different people) to make it entail that Mary is not married in FOL. We need to add the following: S5: ∀x ∀y ((Married(x, y)  Married(y, x)) simmetry S6: ∀x ∀y ∀z ((Married(x, y)  Married(x, z)  y = z) at most one wife S7:  ∃x Married(x, x) nobody is married with himself/herself S8:  (tom=sue)   (tom=mary)   (mary=sue) unique name assumption 14

  15. Analogy with Databases “List name, position and manager of the employees” γ = Employee(x, y, z) Qγ = All the tuples in the Relation “List managers of the employees named Enzo” γ = ∃y Employee(Enzo, y, z) Qγ = {(Fausto)} EMPLOYEE

  16. SELECT “List name and position of the employees having a manager” γ = ∃z Employee(x, y, z) Qγ = {(Enzo, PhD), (Fausto, Professor), (Feroz, PhD)} EMPLOYEE

  17. FILTER “List name and position of the employees with Fausto as manager” γ = ∃z Employee(x, y, Fausto, z) Qγ = {(Enzo, PhD)} “List name and position of the employees with age > 28” γ = ∃w ∃z (Employee(x, y, z, w) ∧ (w > 28)) Qγ = {(Enzo, PhD), (Fausto, Professor)} EMPLOYEE

  18. JOIN “List name of faculty members and their department” γ = ∃y ∃z ( Faculty(x, y, z) ∧ Dept(x, w) ) Qγ = {(Enzo, DISI), (Fausto, DISI), (Feroz, MATH)} “List name of faculty members who belong to all departments” γ = ∀w (∃x Dept(x, w)  ∃y ∃z (Faculty(x, y, z) ∧ Dept(x, w))) FACULTY DEPT

  19. Semantics

  20. Interpretation 20

  21. Example of Interpretation • ∆ = {tom, sue, mary, club, married, age, sum} • Constants: • I(tom) = Tom, I(sue) = Sue, I(mary) = Mary • Unary predicates: • Club(tom), Club(sue), Club(Mary) • Binary predicates: • Married(tom, sue) • Functions: • age(tom) = 40, age(sue) = 35, age(mary) =18 • sum(3, 5) = 8 age sum 21

  22. Interpretation of terms 22

  23. Interpretation of terms Constants I(tom)[a] = I(tom) = Tom I(sue)[a] = I(sue) = Sue Variables I(x) [a] = a(x) = tom I(y) [a] = a(y) = sue I(z) [a] = a(z) = 3 Functions I(age(x))) [a] = I(age) (I(x)[a]) = age(a(x)) = age(tom) = 40 I(sum(z, 5))[a] = I(sum) I(I(z)[a], I(5)[a]) = sum(a(z), 5) = sum(3,5) = 8 23

  24. Satisfiability of a formula 24

  25. Satisfiability of simple formulas (I) Satisfiability is given w.r.t an assignment a. Verify the following: I ⊨ tom = sue [a] verify whether: I(tom) [a] = I(sue) [a] I ⊨ Married(tom, sue) [a] verify whether: <I(tom) [a], I(sue) [a]>  Married I ⊨ Married(tom, y) [a] verify whether: <I(tom) [a], I(y) [a]>  Married I ⊨  Married(tom, y) [a] verify whether: <I(tom) [a], I(y) [a]>  Married I ⊨ ∃x Married(mary, x) [a] verify whether there exist any d such that <Mary, d>  Married I ⊨ ∀x Married(mary, x) [a] verify whether for all d <Mary, d>  Married 25

  26. Satisfiability of simple formulas (II) • ∆ = {0, 1, 2, 3} constants = {zero} variables = {x} predicate symbols = {even, odd} functions = {succ} γ1 : ∀x (even(x)  odd(succ(x))) γ2 : even(zero) γ3 : odd(zero) Is there any I and a such that I ⊨ γ1 γ2 [a]? I(zero)[a] = I(zero) = 0 I(succ(x))[a] = I(succ)(I(x)[a]) = S(n) = {0 if n=3, n+1 otherwise} I(even) = {0, 2} I(odd) = {1, 3} Is there any I and a such that I ⊨ γ1 γ3 [a]? Yes! Just invert the interpretation of even and odd. 26

  27. Modeling “blocks world” 27

  28. Satisfiability of the problem of blocks • Express the following problem in FOL: “There are 3 blocks A, B, C in a stack. Each block can be either black or white. We know that the block A is on the bottom. A block is on the top if there are no blocks above it. It is possible to be on top if and only if the block is black”. C B A • Constants = {a, b, c} • Predicates = {Black, White, Top} • Relations = {Above} γ1 : ∃x Above(a,x) γ2 : Top(y)  Black(y) ∃z Above(z,y) 28

  29. Satisfiability of the problem of blocks (II) • Constants = {a, b, c} • Predicates = {Black, White, Top} • Relations = {Above} γ1 : ∃x Above(a,x) γ2 : Top(y)  Black(y) ∃z Above(z,y) • Is Γ = {γ1, γ2} satisfiable? Is there any I and an assignment a such that I ⊨ γ1 [a] and I ⊨ γ2 [a]? ∆ = {A, B, C} I(a) = A I(b) = B I(c) = C I(Black) = {A, C} I(White) = {B} I(Top) = {C} I(Above) = {<B,A>, <C,B>} I(y)[a] = a(y) = C NOTE: we can assign a different color to A and B. y is free. C B A 29

  30. Entailment (logical consequence) Given: α : ∀x ∀y ∃z (p(x, y)  (p(x, z)  p(z, y))) β : ∀x ∀y (p(x, y)  ∃z (p(x, z)  p(z, y))) Does α⊨ β? Yes, because in α we can put ∃z inside: ∀x ∀y (∃z p(x, y)  ∃z (p(x, z)  p(z, y))) z is not in the scope of ∃z p(x, y) and therefore we obtain β 30

  31. Entailment (logical consequence) For all formulas of the form p(x, y): 1. Is ∃x∃y p(x, y) ⊨ ∃y∃x p(x, y)? 2. Is ∃x∀y p(x, y) ⊨ ∀y∃x p(x, y)? 3. Is ∀x∃y p(x, y) ⊨ ∃y∀x p(x, y)? If no provide a counterexample. Assume p(x, y) is x  y. (1) Yes. The two formulas both says that there are at least two objects which are related via p. (2) Yes. The first formula says that there is an x such that for all y we have x  y. We can take x = 0. The second formula says that for all y there exist an x such that x  y. x = 0 is fine again. (3) In this case is No. The first formula says that for all x there exist a y such that x  y. We can take y = Succ(x). The second formula says that there exists a y such that for all x we have x  y. We should take y = +. 31

  32. Reasoning

  33. Model checking 33

  34. How to prove validity in finite domains Is it possible to prove that: ⊨ ∀x (Person(x) Male(x)) [a] where D = {a, b, c} We have only 3 possible assignments a(x) = a, a(x) = b, a(x) = c We can translate it as follows: P: (Person(a)  Male(a))  (Person(b)  Male(b))  (Person(c)  Male(c)) P: (Person(a)  Male(a))  (Person(b)  Male(b))  (Person(c)  Male(c)) P: (Person-a  Male-a)  (Person-b  Male-b)  (Person-c  Male-c) We check that DPLL(P) returns false. 34

More Related