Download presentation

Presentation is loading. Please wait.

Published byConnor Ramirez Modified over 2 years ago

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

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

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
4 Syntax

5
Alphabet of symbols in FOL Variables x 1, x 2, …, y, z Constants a 1, a 2, …, b, c Predicate symbols A 1 1, A 1 2, …, A n m Function symbolsf 1 1, f 1 2, …, f n m 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 5

6
Terms Terms can be defined using the following BNF grammar: ::= | | ( {, }*) A term is called a closed term iff it does not contain variables 6 x, 2, SQRT(x), Sum(2, 3), Sum(2, x), Average(x 1, x 2, x 3 ) Sum(2, 3)

7
Well formed formulas Well formed formulas (wff) can be defined in BNF as follows: ::= ( {, }*) | = ::= | ¬ | | | | | NOTE: We can also write x.P(x) or x:P(x) as notation (with. or :) 7 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)) 8

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

11
The use of FOL in mathematics 11 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 1. x 1 (x 1 = x 1 )reflexivity 2. x 1 x 2 (x 1 = x 2 x 2 = x 1 )symmetricity 3. x 1 x 2 x 3 (x 1 = x 2 x 2 = x 3 x 1 = x 3 )transitivity 4. x 1 x 2 (x 1 = x 2 S( x 1 ) = S(x 2 ))successor NOTE: Other axioms can be given for the properties of the successor, the addition (+) and the multiplication (x).

12
Modeling the club of married problem 12 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) 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.

13
Modeling the club of married problem (II) 13 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) 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.

14
Modeling the club of married problem (III) 14 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 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.

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)} 15 NAMEPOSITIONMANAGER EnzoPhDFausto ProfessorBassi FerozPhDEnzo 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)} 16 NAMEPOSITIONMANAGER EnzoPhDFausto ProfessorBassi FerozPhDEnzo 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)} 17 NAMEPOSITIONMANAGERAGE EnzoPhDFausto35 FaustoProfessorBassi40 FerozPhDEnzo20 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))) 18 NAMEPOSITIONMANAGER EnzoPhDFausto ProfessorBassi FerozPhDEnzo NAMEDEPT EnzoDISI FaustoDISI FerozMATH FACULTYDEPT

19
19 Semantics

20
Interpretation 20

21
Example of Interpretation 21 = {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 MARRIED TomSue RobertMary CLUB Tom Sue Mary 1 Tom Sue Mary age sum

22
Interpretation of terms 22

23
Interpretation of terms 23 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

24
Satisfiability of a formula 24

25
Satisfiability of simple formulas (I) 25 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: Married I Married(tom, y) [a]verify whether: Married I x Married(mary, x) [a]verify whether there exist any d such that Married I x Married(mary, x) [a]verify whether for all d Married

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 28 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. A B C Constants = {a, b, c} Predicates = {Black, White, Top} Relations = {Above} γ 1 : x Above(a,x) γ 2 : Top(y) Black(y) z Above(z,y)

29
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) = {, } I (y)[a] = a(y) = C NOTE: we can assign a different color to A and B. y is free. Satisfiability of the problem of blocks (II) 29 A B C

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
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) We check that DPLL( P) returns false. 34

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google