Individuals and Relations It is useful to view the world as - PowerPoint PPT Presentation
Individuals and Relations It is useful to view the world as consisting of individuals (objects, things) and relations among individuals. Often features are made from relations among individuals and functions of individuals. Reasoning in terms
Example Queries in ( kim , r 123) . KB = part of ( r 123 , cs building ) . in ( X , Y ) ← part of ( Z , Y ) ∧ in ( X , Z ) . Query Answer ? part of ( r 123 , B ) . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.2, Page 3
Example Queries in ( kim , r 123) . KB = part of ( r 123 , cs building ) . in ( X , Y ) ← part of ( Z , Y ) ∧ in ( X , Z ) . Query Answer ? part of ( r 123 , B ) . part of ( r 123 , cs building ) ? part of ( r 023 , cs building ) . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.2, Page 4
Example Queries in ( kim , r 123) . KB = part of ( r 123 , cs building ) . in ( X , Y ) ← part of ( Z , Y ) ∧ in ( X , Z ) . Query Answer ? part of ( r 123 , B ) . part of ( r 123 , cs building ) ? part of ( r 023 , cs building ) . no ? in ( kim , r 023) . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.2, Page 5
Example Queries in ( kim , r 123) . KB = part of ( r 123 , cs building ) . in ( X , Y ) ← part of ( Z , Y ) ∧ in ( X , Z ) . Query Answer ? part of ( r 123 , B ) . part of ( r 123 , cs building ) ? part of ( r 023 , cs building ) . no ? in ( kim , r 023) . no ? in ( kim , B ) . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.2, Page 6
Example Queries in ( kim , r 123) . KB = part of ( r 123 , cs building ) . in ( X , Y ) ← part of ( Z , Y ) ∧ in ( X , Z ) . Query Answer ? part of ( r 123 , B ) . part of ( r 123 , cs building ) ? part of ( r 023 , cs building ) . no ? in ( kim , r 023) . no ? in ( kim , B ) . in ( kim , r 123) in ( kim , cs building ) � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.2, Page 7
Electrical Environment outside power cb1 w5 s1 w1 circuit breaker cb2 s2 w2 w3 off s3 w0 switch on w6 w4 two-way p2 switch l1 light p1 l2 power outlet � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.2, Page 8
Axiomatizing the Electrical Environment % light ( L ) is true if L is a light light ( l 1 ) . light ( l 2 ) . % down ( S ) is true if switch S is down down ( s 1 ) . up ( s 2 ) . up ( s 3 ) . % ok ( D ) is true if D is not broken ok ( l 1 ) . ok ( l 2 ) . ok ( cb 1 ) . ok ( cb 2 ) . ? light ( l 1 ) . = ⇒ � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.2, Page 9
Axiomatizing the Electrical Environment % light ( L ) is true if L is a light light ( l 1 ) . light ( l 2 ) . % down ( S ) is true if switch S is down down ( s 1 ) . up ( s 2 ) . up ( s 3 ) . % ok ( D ) is true if D is not broken ok ( l 1 ) . ok ( l 2 ) . ok ( cb 1 ) . ok ( cb 2 ) . ? light ( l 1 ) . = yes ⇒ ? light ( l 6 ) . = ⇒ � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.2, Page 10
Axiomatizing the Electrical Environment % light ( L ) is true if L is a light light ( l 1 ) . light ( l 2 ) . % down ( S ) is true if switch S is down down ( s 1 ) . up ( s 2 ) . up ( s 3 ) . % ok ( D ) is true if D is not broken ok ( l 1 ) . ok ( l 2 ) . ok ( cb 1 ) . ok ( cb 2 ) . ? light ( l 1 ) . = yes ⇒ ? light ( l 6 ) . = no ⇒ ? up ( X ) . = ⇒ � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.2, Page 11
Axiomatizing the Electrical Environment % light ( L ) is true if L is a light light ( l 1 ) . light ( l 2 ) . % down ( S ) is true if switch S is down down ( s 1 ) . up ( s 2 ) . up ( s 3 ) . % ok ( D ) is true if D is not broken ok ( l 1 ) . ok ( l 2 ) . ok ( cb 1 ) . ok ( cb 2 ) . ? light ( l 1 ) . = yes ⇒ ? light ( l 6 ) . = no ⇒ ? up ( X ) . = up ( s 2 ), up ( s 3 ) ⇒ � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.2, Page 12
connected to ( X , Y ) is true if component X is connected to Y connected to ( w 0 , w 1 ) ← up ( s 2 ) . connected to ( w 0 , w 2 ) ← down ( s 2 ) . connected to ( w 1 , w 3 ) ← up ( s 1 ) . connected to ( w 2 , w 3 ) ← down ( s 1 ) . connected to ( w 4 , w 3 ) ← up ( s 3 ) . connected to ( p 1 , w 3 ) . ? connected to ( w 0 , W ) . = ⇒ � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.2, Page 13
connected to ( X , Y ) is true if component X is connected to Y connected to ( w 0 , w 1 ) ← up ( s 2 ) . connected to ( w 0 , w 2 ) ← down ( s 2 ) . connected to ( w 1 , w 3 ) ← up ( s 1 ) . connected to ( w 2 , w 3 ) ← down ( s 1 ) . connected to ( w 4 , w 3 ) ← up ( s 3 ) . connected to ( p 1 , w 3 ) . ? connected to ( w 0 , W ) . = W = w 1 ⇒ ? connected to ( w 1 , W ) . = ⇒ � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.2, Page 14
connected to ( X , Y ) is true if component X is connected to Y connected to ( w 0 , w 1 ) ← up ( s 2 ) . connected to ( w 0 , w 2 ) ← down ( s 2 ) . connected to ( w 1 , w 3 ) ← up ( s 1 ) . connected to ( w 2 , w 3 ) ← down ( s 1 ) . connected to ( w 4 , w 3 ) ← up ( s 3 ) . connected to ( p 1 , w 3 ) . ? connected to ( w 0 , W ) . = W = w 1 ⇒ ? connected to ( w 1 , W ) . = no ⇒ ? connected to ( Y , w 3 ) . = ⇒ � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.2, Page 15
connected to ( X , Y ) is true if component X is connected to Y connected to ( w 0 , w 1 ) ← up ( s 2 ) . connected to ( w 0 , w 2 ) ← down ( s 2 ) . connected to ( w 1 , w 3 ) ← up ( s 1 ) . connected to ( w 2 , w 3 ) ← down ( s 1 ) . connected to ( w 4 , w 3 ) ← up ( s 3 ) . connected to ( p 1 , w 3 ) . ? connected to ( w 0 , W ) . = W = w 1 ⇒ ? connected to ( w 1 , W ) . = no ⇒ ? connected to ( Y , w 3 ) . = Y = w 2 , Y = w 4 , Y = p 1 ⇒ ? connected to ( X , W ) . = ⇒ � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.2, Page 16
connected to ( X , Y ) is true if component X is connected to Y connected to ( w 0 , w 1 ) ← up ( s 2 ) . connected to ( w 0 , w 2 ) ← down ( s 2 ) . connected to ( w 1 , w 3 ) ← up ( s 1 ) . connected to ( w 2 , w 3 ) ← down ( s 1 ) . connected to ( w 4 , w 3 ) ← up ( s 3 ) . connected to ( p 1 , w 3 ) . ? connected to ( w 0 , W ) . = W = w 1 ⇒ ? connected to ( w 1 , W ) . = no ⇒ ? connected to ( Y , w 3 ) . = Y = w 2 , Y = w 4 , Y = p 1 ⇒ ? connected to ( X , W ) . = X = w 0 , W = w 1 , . . . ⇒ � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.2, Page 17
% lit ( L ) is true if the light L is lit lit ( L ) ← light ( L ) ∧ ok ( L ) ∧ live ( L ) . % live ( C ) is true if there is power coming into C live ( Y ) ← connected to ( Y , Z ) ∧ live ( Z ) . live ( outside ) . This is a recursive definition of live . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.2, Page 18
Recursion and Mathematical Induction above ( X , Y ) ← on ( X , Y ) . above ( X , Y ) ← on ( X , Z ) ∧ above ( Z , Y ) . This can be seen as: Recursive definition of above : prove above in terms of a base case ( on ) or a simpler instance of itself; or Way to prove above by mathematical induction: the base case is when there are no blocks between X and Y , and if you can prove above when there are n blocks between them, you can prove it when there are n + 1 blocks. � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.2, Page 19
Limitations Suppose you had a database using the relation: enrolled ( S , C ) which is true when student S is enrolled in course C . Can you define the relation: empty course ( C ) which is true when course C has no students enrolled in it? Why? or Why not? � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.2, Page 20
Limitations Suppose you had a database using the relation: enrolled ( S , C ) which is true when student S is enrolled in course C . Can you define the relation: empty course ( C ) which is true when course C has no students enrolled in it? Why? or Why not? empty course ( C ) doesn’t logically follow from a set of enrolled relation because there are always models where someone is enrolled in a course! � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.2, Page 21
Reasoning with Variables An instance of an atom or a clause is obtained by uniformly substituting terms for variables. A substitution is a finite set of the form { V 1 / t 1 , . . . , V n / t n } , where each V i is a distinct variable and each t i is a term. The application of a substitution σ = { V 1 / t 1 , . . . , V n / t n } to an atom or clause e , written e σ , is the instance of e with every occurrence of V i replaced by t i . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 1
Application Examples The following are substitutions: σ 1 = { X / A , Y / b , Z / C , D / e } σ 2 = { A / X , Y / b , C / Z , D / e } σ 3 = { A / V , X / V , Y / b , C / W , Z / W , D / e } The following shows some applications: p ( A , b , C , D ) σ 1 = p ( X , Y , Z , e ) σ 1 = p ( A , b , C , D ) σ 2 = p ( X , Y , Z , e ) σ 2 = p ( A , b , C , D ) σ 3 = p ( X , Y , Z , e ) σ 3 = � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 2
Application Examples The following are substitutions: σ 1 = { X / A , Y / b , Z / C , D / e } σ 2 = { A / X , Y / b , C / Z , D / e } σ 3 = { A / V , X / V , Y / b , C / W , Z / W , D / e } The following shows some applications: p ( A , b , C , D ) σ 1 = p ( A , b , C , e ) p ( X , Y , Z , e ) σ 1 = p ( A , b , C , D ) σ 2 = p ( X , Y , Z , e ) σ 2 = p ( A , b , C , D ) σ 3 = p ( X , Y , Z , e ) σ 3 = � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 3
Application Examples The following are substitutions: σ 1 = { X / A , Y / b , Z / C , D / e } σ 2 = { A / X , Y / b , C / Z , D / e } σ 3 = { A / V , X / V , Y / b , C / W , Z / W , D / e } The following shows some applications: p ( A , b , C , D ) σ 1 = p ( A , b , C , e ) p ( X , Y , Z , e ) σ 1 = p ( A , b , C , e ) p ( A , b , C , D ) σ 2 = p ( X , Y , Z , e ) σ 2 = p ( A , b , C , D ) σ 3 = p ( X , Y , Z , e ) σ 3 = � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 4
Application Examples The following are substitutions: σ 1 = { X / A , Y / b , Z / C , D / e } σ 2 = { A / X , Y / b , C / Z , D / e } σ 3 = { A / V , X / V , Y / b , C / W , Z / W , D / e } The following shows some applications: p ( A , b , C , D ) σ 1 = p ( A , b , C , e ) p ( X , Y , Z , e ) σ 1 = p ( A , b , C , e ) p ( A , b , C , D ) σ 2 = p ( X , b , Z , e ) p ( X , Y , Z , e ) σ 2 = p ( A , b , C , D ) σ 3 = p ( X , Y , Z , e ) σ 3 = � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 5
Application Examples The following are substitutions: σ 1 = { X / A , Y / b , Z / C , D / e } σ 2 = { A / X , Y / b , C / Z , D / e } σ 3 = { A / V , X / V , Y / b , C / W , Z / W , D / e } The following shows some applications: p ( A , b , C , D ) σ 1 = p ( A , b , C , e ) p ( X , Y , Z , e ) σ 1 = p ( A , b , C , e ) p ( A , b , C , D ) σ 2 = p ( X , b , Z , e ) p ( X , Y , Z , e ) σ 2 = p ( X , b , Z , e ) p ( A , b , C , D ) σ 3 = p ( X , Y , Z , e ) σ 3 = � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 6
Application Examples The following are substitutions: σ 1 = { X / A , Y / b , Z / C , D / e } σ 2 = { A / X , Y / b , C / Z , D / e } σ 3 = { A / V , X / V , Y / b , C / W , Z / W , D / e } The following shows some applications: p ( A , b , C , D ) σ 1 = p ( A , b , C , e ) p ( X , Y , Z , e ) σ 1 = p ( A , b , C , e ) p ( A , b , C , D ) σ 2 = p ( X , b , Z , e ) p ( X , Y , Z , e ) σ 2 = p ( X , b , Z , e ) p ( A , b , C , D ) σ 3 = p ( V , b , W , e ) p ( X , Y , Z , e ) σ 3 = � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 7
Application Examples The following are substitutions: σ 1 = { X / A , Y / b , Z / C , D / e } σ 2 = { A / X , Y / b , C / Z , D / e } σ 3 = { A / V , X / V , Y / b , C / W , Z / W , D / e } The following shows some applications: p ( A , b , C , D ) σ 1 = p ( A , b , C , e ) p ( X , Y , Z , e ) σ 1 = p ( A , b , C , e ) p ( A , b , C , D ) σ 2 = p ( X , b , Z , e ) p ( X , Y , Z , e ) σ 2 = p ( X , b , Z , e ) p ( A , b , C , D ) σ 3 = p ( V , b , W , e ) p ( X , Y , Z , e ) σ 3 = p ( V , b , W , e ) � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 8
Unifiers Substitution σ is a unifier of e 1 and e 2 if e 1 σ = e 2 σ . Substitution σ is a most general unifier (mgu) of e 1 and e 2 if ◮ σ is a unifier of e 1 and e 2 ; and ◮ if substitution σ ′ also unifies e 1 and e 2 , then e σ ′ is an instance of e σ for all atoms e . If two atoms have a unifier, they have a most general unifier. � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 9
Unification Example Which of the following are unifiers of p ( A , b , C , D ) and p ( X , Y , Z , e ): σ 1 = { X / A , Y / b , Z / C , D / e } σ 2 = { Y / b , D / e } σ 3 = { X / A , Y / b , Z / C , D / e , W / a } σ 4 = { A / X , Y / b , C / Z , D / e } σ 5 = { X / a , Y / b , Z / c , D / e } σ 6 = { A / a , X / a , Y / b , C / c , Z / c , D / e } σ 7 = { A / V , X / V , Y / b , C / W , Z / W , D / e } σ 8 = { X / A , Y / b , Z / A , C / A , D / e } Which are most general unifiers? � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 10
Unification Example p ( A , b , C , D ) and p ( X , Y , Z , e ) have as unifiers: σ 1 = { X / A , Y / b , Z / C , D / e } σ 4 = { A / X , Y / b , C / Z , D / e } σ 7 = { A / V , X / V , Y / b , C / W , Z / W , D / e } σ 6 = { A / a , X / a , Y / b , C / c , Z / c , D / e } σ 8 = { X / A , Y / b , Z / A , C / A , D / e } σ 3 = { X / A , Y / b , Z / C , D / e , W / a } The first three are most general unifiers. The following substitutions are not unifiers: σ 2 = { Y / b , D / e } σ 5 = { X / a , Y / b , Z / c , D / e } � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 11
1: procedure unify ( t 1 , t 2 ) ⊲ Returns mgu of t 1 and t 2 or ⊥ . E ← { t 1 = t 2 } ⊲ Set of equality statements 2: S ← {} ⊲ Substitution 3: while E � = {} do 4: select and remove x = y from E 5: if y is not identical to x then 6: if x is a variable then 7: replace x with y in E and S 8: S ← { x / y } ∪ S 9: else if y is a variable then 10: replace y with x in E and S 11: S ← { y / x } ∪ S 12: else if x is p ( x 1 , . . . , x n ) and y is 13: p ( y 1 , . . . , y n ) then E ← E ∪ { x 1 = y 1 , . . . , x n = y n } 14: else 15: return ⊥ ⊲ t 1 and t 2 do not unify 16: return S ⊲ S is mgu of t 1 and t 2 17: � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 12
Logical Consequence Atom g is a logical consequence of KB if and only if: g is an instance of a fact in KB , or there is an instance of a rule g ← b 1 ∧ . . . ∧ b k in KB such that each b i is a logical consequence of KB . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 13
Aside: Debugging false conclusions To debug answer g that is false in the intended interpretation: If g is a fact in KB , this fact is wrong. Otherwise, suppose g was proved using the rule: g ← b 1 ∧ . . . ∧ b k where each b i is a logical consequence of KB . ◮ If each b i is true in the intended interpretation, this clause is false in the intended interpretation. ◮ If some b i is false in the intended interpretation, debug b i . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 14
Proofs A proof is a mechanically derivable demonstration that a formula logically follows from a knowledge base. Given a proof procedure, KB ⊢ g means g can be derived from knowledge base KB . Recall KB | = g means g is true in all models of KB . A proof procedure is sound if KB ⊢ g implies KB | = g . A proof procedure is complete if KB | = g implies KB ⊢ g . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 15
Bottom-up proof procedure KB ⊢ g if there is g ′ added to C in this procedure where g = g ′ θ : C := {} ; repeat select clause “ h ← b 1 ∧ . . . ∧ b m ” in KB such that there is a substitution θ such that for all i , there exists b ′ i ∈ C and θ ′ i where b i θ = b ′ i θ ′ i and there is no h ′ ∈ C and θ ′ such that h ′ θ ′ = h θ C := C ∪ { h θ } until no more clauses can be selected. � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 16
Example live ( Y ) ← connected to ( Y , Z ) ∧ live ( Z ) . live ( outside ) . connected to ( w 6 , w 5 ) . connected to ( w 5 , outside ) . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 17
Example live ( Y ) ← connected to ( Y , Z ) ∧ live ( Z ) . live ( outside ) . connected to ( w 6 , w 5 ) . connected to ( w 5 , outside ) . C = { live ( outside ) , connected to ( w 6 , w 5 ) , connected to ( w 5 , outside ) , live ( w 5 ) , live ( w 6 ) } � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 18
Soundness of bottom-up proof procedure If KB ⊢ g then KB | = g . Suppose there is a g such that KB ⊢ g and KB �| = g . Then there must be a first atom added to C that has an instance that isn’t true in every model of KB . Call it h . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 19
Soundness of bottom-up proof procedure If KB ⊢ g then KB | = g . Suppose there is a g such that KB ⊢ g and KB �| = g . Then there must be a first atom added to C that has an instance that isn’t true in every model of KB . Call it h . Suppose h isn’t true in model I of KB . There must be an instance of clause in KB of form h ′ ← b 1 ∧ . . . ∧ b m where � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 20
Soundness of bottom-up proof procedure If KB ⊢ g then KB | = g . Suppose there is a g such that KB ⊢ g and KB �| = g . Then there must be a first atom added to C that has an instance that isn’t true in every model of KB . Call it h . Suppose h isn’t true in model I of KB . There must be an instance of clause in KB of form h ′ ← b 1 ∧ . . . ∧ b m where h = h ′ θ and b i θ is an instance of an element of C . ◮ Each b i θ is true in I . ◮ h is false in I . ◮ So an instance of this clause is false in I . ◮ Therefore I isn’t a model of KB . ◮ Contradiction. � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 21
Fixed Point The C generated by the bottom-up algorithm is called a fixed point. C can be infinite; we require the selection to be fair. Herbrand interpretation: The domain is the set of constants. We invent a constant if the KB or query doesn’t contain one. Each constant denotes itself. � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 22
Fixed Point The C generated by the bottom-up algorithm is called a fixed point. C can be infinite; we require the selection to be fair. Herbrand interpretation: The domain is the set of constants. We invent a constant if the KB or query doesn’t contain one. Each constant denotes itself. Let I be the Herbrand interpretation in which every ground instance of every element of the fixed point is true and every other atom is false. � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 23
Fixed Point The C generated by the bottom-up algorithm is called a fixed point. C can be infinite; we require the selection to be fair. Herbrand interpretation: The domain is the set of constants. We invent a constant if the KB or query doesn’t contain one. Each constant denotes itself. Let I be the Herbrand interpretation in which every ground instance of every element of the fixed point is true and every other atom is false. I is a model of KB . Proof: � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 24
Fixed Point The C generated by the bottom-up algorithm is called a fixed point. C can be infinite; we require the selection to be fair. Herbrand interpretation: The domain is the set of constants. We invent a constant if the KB or query doesn’t contain one. Each constant denotes itself. Let I be the Herbrand interpretation in which every ground instance of every element of the fixed point is true and every other atom is false. I is a model of KB . Proof: suppose h ← b 1 ∧ . . . ∧ b m in KB is false in I . Then h is false and each b i is true in I . Thus h can be added to C . Contradiction to C being the fixed point. I is called a Minimal Model. � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 25
Completeness If KB | = g then KB ⊢ g . Suppose KB | = g . Then g is true in all models of KB . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 26
Completeness If KB | = g then KB ⊢ g . Suppose KB | = g . Then g is true in all models of KB . Thus g is true in the minimal model. � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 27
Completeness If KB | = g then KB ⊢ g . Suppose KB | = g . Then g is true in all models of KB . Thus g is true in the minimal model. Thus g is in the fixed point. � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 28
Completeness If KB | = g then KB ⊢ g . Suppose KB | = g . Then g is true in all models of KB . Thus g is true in the minimal model. Thus g is in the fixed point. Thus g is generated by the bottom up algorithm. � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 29
Completeness If KB | = g then KB ⊢ g . Suppose KB | = g . Then g is true in all models of KB . Thus g is true in the minimal model. Thus g is in the fixed point. Thus g is generated by the bottom up algorithm. Thus KB ⊢ g . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 30
Top-down Proof procedure A generalized answer clause is of the form yes ( t 1 , . . . , t k ) ← a 1 ∧ a 2 ∧ . . . ∧ a m , where t 1 , . . . , t k are terms and a 1 , . . . , a m are atoms. � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 31
Top-down Proof procedure A generalized answer clause is of the form yes ( t 1 , . . . , t k ) ← a 1 ∧ a 2 ∧ . . . ∧ a m , where t 1 , . . . , t k are terms and a 1 , . . . , a m are atoms. The SLD resolution of this generalized answer clause on a i with the clause a ← b 1 ∧ . . . ∧ b p , where a i and a have most general unifier θ , is ( yes ( t 1 , . . . , t k ) ← a 1 ∧ . . . ∧ a i − 1 ∧ b 1 ∧ . . . ∧ b p ∧ a i +1 ∧ . . . ∧ a m ) θ. � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 32
Top-down Proof Procedure To solve query ? B with variables V 1 , . . . , V k : Set ac to generalized answer clause yes ( V 1 , . . . , V k ) ← B while ac is not an answer do Suppose ac is yes ( t 1 , . . . , t k ) ← a 1 ∧ a 2 ∧ . . . ∧ a m select atom a i in the body of ac choose clause a ← b 1 ∧ . . . ∧ b p in KB Rename all variables in a ← b 1 ∧ . . . ∧ b p Let θ be the most general unifier of a i and a . Fail if they don’t unify Set ac to ( yes ( t 1 , . . . , t k ) ← a 1 ∧ . . . ∧ a i − 1 ∧ b 1 ∧ . . . ∧ b p ∧ a i +1 ∧ . . . ∧ a m ) θ end while . Answer is V 1 = t 1 , . . . , V k = t k where ac is yes ( t 1 , . . . , t k ) ← � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 33
Example live ( Y ) ← connected to ( Y , Z ) ∧ live ( Z ) . live ( outside ) . connected to ( w 6 , w 5 ) . connected to ( w 5 , outside ) . ? live ( A ) . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 34
Example live ( Y ) ← connected to ( Y , Z ) ∧ live ( Z ) . live ( outside ) . connected to ( w 6 , w 5 ) . connected to ( w 5 , outside ) . ? live ( A ) . yes ( A ) ← live ( A ) . yes ( A ) ← connected to ( A , Z 1 ) ∧ live ( Z 1 ) . yes ( w 6 ) ← live ( w 5 ) . yes ( w 6 ) ← connected to ( w 5 , Z 2 ) ∧ live ( Z 2 ) . yes ( w 6 ) ← live ( outside ) . yes ( w 6 ) ← . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 35
Function Symbols Often we want to refer to individuals in terms of components. Examples: 4:55 p.m. English sentences. A classlist. We extend the notion of term. So that a term can be f ( t 1 , . . . , t n ) where f is a function symbol and the t i are terms. In an interpretation and with a variable assignment, term f ( t 1 , . . . , t n ) denotes an individual in the domain. One function symbol and one constant can refer to infinitely many individuals. � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 36
Lists A list is an ordered sequence of elements. Let’s use the constant nil to denote the empty list, and the function cons ( H , T ) to denote the list with first element H and rest-of-list T . These are not built-in. The list containing sue , kim and randy is cons ( sue , cons ( kim , cons ( randy , nil ))) append ( X , Y , Z ) is true if list Z contains the elements of X followed by the elements of Y append ( nil , Z , Z ) . append ( cons ( A , X ) , Y , cons ( A , Z )) ← append ( X , Y , Z ) . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 37
Unification with function symbols Consider a knowledge base consisting of one fact: lt ( X , s ( X )) . Should the following query succeed? ask lt ( Y , Y ) . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 38
Unification with function symbols Consider a knowledge base consisting of one fact: lt ( X , s ( X )) . Should the following query succeed? ask lt ( Y , Y ) . What does the top-down proof procedure give? � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 39
Unification with function symbols Consider a knowledge base consisting of one fact: lt ( X , s ( X )) . Should the following query succeed? ask lt ( Y , Y ) . What does the top-down proof procedure give? Solution: variable X should not unify with a term that contains X inside. E.g., X should not unify with s ( X ). Simple modification of the unification algorithm, which Prolog does not do! � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.3, Page 40
Complete Knowledge Assumption Often you want to assume that your knowledge is complete. Example: assume that a database of what students are enrolled in a course is complete. We don’t want to have to state all negative enrolment facts! The definite clause language is monotonic: adding clauses can’t invalidate a previous conclusion. Under the complete knowledge assumption, the system is non-monotonic: adding clauses can invalidate a previous conclusion. � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.4, Page 1
Equality Equality is a special predicate symbol with a standard domain-independent intended interpretation. Suppose interpretation I = � D , φ, π � . t 1 and t 2 are ground terms then t 1 = t 2 is true in interpretation I if t 1 and t 2 denote the same individual. That is, t 1 = t 2 if φ ( t 1 ) is the same as φ ( t 2 ). t 1 � = t 2 when t 1 and t 2 denote different individuals. � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.4, Page 2
Equality Equality is a special predicate symbol with a standard domain-independent intended interpretation. Suppose interpretation I = � D , φ, π � . t 1 and t 2 are ground terms then t 1 = t 2 is true in interpretation I if t 1 and t 2 denote the same individual. That is, t 1 = t 2 if φ ( t 1 ) is the same as φ ( t 2 ). t 1 � = t 2 when t 1 and t 2 denote different individuals. Example: D = { ✂ , ☎ , ✎ } . φ ( phone ) = ☎ , φ ( pencil ) = ✎ , φ ( telephone ) = ☎ What equalities and inequalities hold? � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.4, Page 3
Equality Equality is a special predicate symbol with a standard domain-independent intended interpretation. Suppose interpretation I = � D , φ, π � . t 1 and t 2 are ground terms then t 1 = t 2 is true in interpretation I if t 1 and t 2 denote the same individual. That is, t 1 = t 2 if φ ( t 1 ) is the same as φ ( t 2 ). t 1 � = t 2 when t 1 and t 2 denote different individuals. Example: D = { ✂ , ☎ , ✎ } . φ ( phone ) = ☎ , φ ( pencil ) = ✎ , φ ( telephone ) = ☎ What equalities and inequalities hold? phone = telephone , phone = phone , pencil = pencil , telephone = telephone pencil � = phone , pencil � = telephone � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.4, Page 4
Equality Equality is a special predicate symbol with a standard domain-independent intended interpretation. Suppose interpretation I = � D , φ, π � . t 1 and t 2 are ground terms then t 1 = t 2 is true in interpretation I if t 1 and t 2 denote the same individual. That is, t 1 = t 2 if φ ( t 1 ) is the same as φ ( t 2 ). t 1 � = t 2 when t 1 and t 2 denote different individuals. Example: D = { ✂ , ☎ , ✎ } . φ ( phone ) = ☎ , φ ( pencil ) = ✎ , φ ( telephone ) = ☎ What equalities and inequalities hold? phone = telephone , phone = phone , pencil = pencil , telephone = telephone pencil � = phone , pencil � = telephone Equality does not mean similarity! � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.4, Page 5
Properties of Equality Equality is: Reflexive: X = X Symmetric: if X = Y then Y = X Transitive: if X = Y and Y = Z then X = Z For each n -ary function symbol f f ( X 1 , . . . , X n ) = f ( Y 1 , . . . , Y n ) if X 1 = Y 1 and · · · and X n = Y n . For each n -ary predicate symbol p p ( X 1 , . . . , X n ) if p ( Y 1 , . . . , Y n ) and X 1 = Y 1 and · · · and X n = Y n . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.4, Page 6
Unique Names Assumption Suppose the only clauses for enrolled are enrolled ( sam , cs 222) enrolled ( chris , cs 222) enrolled ( sam , cs 873) To conclude ¬ enrolled ( chris , cs 873), what do we need to assume? � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.4, Page 7
Unique Names Assumption Suppose the only clauses for enrolled are enrolled ( sam , cs 222) enrolled ( chris , cs 222) enrolled ( sam , cs 873) To conclude ¬ enrolled ( chris , cs 873), what do we need to assume? ◮ All other enrolled facts are false ◮ Inequalities: sam � = chris ∧ cs 873 � = cs 222 The unique names assumption (UNA) is the assumption that distinct ground terms denote different individuals. � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.4, Page 8
Completion of a knowledge base: propositional case Suppose the rules for atom a are a ← b 1 . . . . a ← b n . equivalently a ← b 1 ∨ . . . ∨ b n . Under the Complete Knowledge Assumption, if a is true, one of the b i must be true: a → b 1 ∨ . . . ∨ b n . Thus, the clauses for a mean a ↔ b 1 ∨ . . . ∨ b n � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.4, Page 9
Clark Normal Form The Clark normal form of the clause p ( t 1 , . . . , t k ) ← B . is the clause p ( V 1 , . . . , V k ) ← ∃ W 1 . . . ∃ W m V 1 = t 1 ∧ . . . ∧ V k = t k ∧ B . where V 1 , . . . , V k are k variables that did not appear in the original clause W 1 , . . . , W m are the original variables in the clause. � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.4, Page 10
Clark Normal Form The Clark normal form of the clause p ( t 1 , . . . , t k ) ← B . is the clause p ( V 1 , . . . , V k ) ← ∃ W 1 . . . ∃ W m V 1 = t 1 ∧ . . . ∧ V k = t k ∧ B . where V 1 , . . . , V k are k variables that did not appear in the original clause W 1 , . . . , W m are the original variables in the clause. When the clause is an atomic clause, B is true . Often can be simplified by replacing ∃ W V = W ∧ p ( W ) with P ( V ). � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.4, Page 11
Clark normal form For the clauses student ( mary ) . student ( sam ) . student ( X ) ← undergrad ( X ) . the Clark normal form is student ( V ) ← V = mary . student ( V ) ← V = sam . student ( V ) ← ∃ X V = X ∧ undergrad ( X ) . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.4, Page 12
Clark’s Completion Suppose all of the clauses for p are put into Clark normal form, with the same set of introduced variables, giving p ( V 1 , . . . , V k ) ← B 1 . . . . p ( V 1 , . . . , V k ) ← B n . which is equivalent to p ( V 1 , . . . , V k ) ← B 1 ∨ . . . ∨ B n . Clark’s completion of predicate p is the equivalence ∀ V 1 . . . ∀ V k p ( V 1 , . . . , V k ) ↔ B 1 ∨ . . . ∨ B n If there are no clauses for p , � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.4, Page 13
Clark’s Completion Suppose all of the clauses for p are put into Clark normal form, with the same set of introduced variables, giving p ( V 1 , . . . , V k ) ← B 1 . . . . p ( V 1 , . . . , V k ) ← B n . which is equivalent to p ( V 1 , . . . , V k ) ← B 1 ∨ . . . ∨ B n . Clark’s completion of predicate p is the equivalence ∀ V 1 . . . ∀ V k p ( V 1 , . . . , V k ) ↔ B 1 ∨ . . . ∨ B n If there are no clauses for p , the completion results in ∀ V 1 . . . ∀ V k p ( V 1 , . . . , V k ) ↔ false Clark’s completion of a knowledge base consists of the completion of every predicate symbol along the unique names assumption. � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.4, Page 14
Completion example p ← q ∧ ∼ r . p ← s . q ← ∼ s . r ← ∼ t . t . s ← w . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.4, Page 15
Completion Example Consider the recursive definition: passed each ([ ] , St , MinPass ) . passed each ([ C | R ] , St , MinPass ) ← passed ( St , C , MinPass ) ∧ passed each ( R , St , MinPass ) . In Clark normal form, this can be written as � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.4, Page 16
Completion Example Consider the recursive definition: passed each ([ ] , St , MinPass ) . passed each ([ C | R ] , St , MinPass ) ← passed ( St , C , MinPass ) ∧ passed each ( R , St , MinPass ) . In Clark normal form, this can be written as passed each ( L , S , M ) ← L = [ ] . passed each ( L , S , M ) ← ∃ C ∃ R L = [ C | R ] ∧ passed ( S , C , M ) ∧ passed each ( R , S , M ) . Here we renamed the variables as appropriate. Thus, Clark’s completion of passed each is � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.4, Page 17
Completion Example Consider the recursive definition: passed each ([ ] , St , MinPass ) . passed each ([ C | R ] , St , MinPass ) ← passed ( St , C , MinPass ) ∧ passed each ( R , St , MinPass ) . In Clark normal form, this can be written as passed each ( L , S , M ) ← L = [ ] . passed each ( L , S , M ) ← ∃ C ∃ R L = [ C | R ] ∧ passed ( S , C , M ) ∧ passed each ( R , S , M ) . Here we renamed the variables as appropriate. Thus, Clark’s completion of passed each is ∀ L ∀ S ∀ M passed each ( L , S , M ) ↔ L = [ ] ∨ ∃ C ∃ R L = [ C | R ] ∧ passed ( S , C , M ) ∧ passed each ( R , S , M ) . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.4, Page 18
Clark’s Completion of a KB Clark’s completion of a knowledge base consists of the completion of every predicate. The completion of an n -ary predicate p with no clauses is p ( V 1 , . . . , V n ) ↔ false . You can interpret negations in the body of clauses. ∼ a means a is false under the complete knowledge assumption. ∼ a is replaced by ¬ a in the completion. This is negation as failure. � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.4, Page 19
Defining empty course Given database of: course ( C ) that is true if C is a course enrolled ( S , C ) that is true if student S is enrolled in course C . Define empty course ( C ) that is true if there are no students enrolled in course C . � D. Poole and A. Mackworth 2016 c Artificial Intelligence, Lecture 13.4, Page 20
Recommend
More recommend
Explore More Topics
Stay informed with curated content and fresh updates.