Inference in First Order Logic. Inference in First Order Logic : Artificial Intelligence Behrang Mohit and Davide Fossati

15381: Artificial Intelligence Behrang Mohit and Davide Fossati Inference  in  First  Order  Logic   Some  slides,  graphics  and  ideas  are  borro...
Author: Rosalyn Ryan
4 downloads 0 Views 459KB Size
15381: Artificial Intelligence Behrang Mohit and Davide Fossati

Inference  in  First  Order  Logic  

Some  slides,  graphics  and  ideas  are  borrowed  or  adapted  from  courses  offered  by  Stuart  Russell,  Hwee  Tou  Ng,     Rebecca  Hwa  and  Milos  Hauskrecht.  

Inference  in  First  Order  Logic   •  We  learned  about  inference  in  proposiAonal  logic   •  Modus  Ponen   •  And  eliminaAon   •  …  

•  We  learned  about  proposiAonalizing  the  FOL  statements   •  Doing  inference  in  proposiAonal  logic  

2  

1

Unifica4on   •  UnificaAon:  Finding  the  appropriate  subsAtuAons  for  variables   •  Eliminates  the  instanAaAon  step     ∀x  King(x)  ∧  Greedy(x)  ⇒  Evil(x)   King(John)   ∀y  Greedy(y)   •  Here  we  don’t  explicitly  know  that  John  is  greedy.  

•  We  can  get  the  inference  immediately  if  we  can  find  a  subsAtuAon  θ  such   that  King(x)  and  Greedy(x)  match  King(John)  and  Greedy(y)   θ  =  {x/John,y/John}  works  

Unifica4on   Unify(α,β)  =  θ  if      αθ  =  βθ     • 

 

Takes  two  sentences  and  returns  a  unifier  for  them  

Let’s  say  we  have  query  knows(john,  x):  whom  does  John  know? p        q        θ       Knows(John,x)    Knows(John,Jane)       Knows(John,x)  Knows(y,OJ)         Knows(John,x)    Knows(y,Mother(y))     Knows(John,x)  Knows(x,OJ)      

 

2

Unifica4on  

Unify(α,β)  =  θ  if      αθ  =  βθ     p        q       Knows(John,x)    Knows(John,Jane)   Knows(John,x)  Knows(y,OJ)     Knows(John,x)    Knows(y,Mother(y)) Knows(John,x)  Knows(x,OJ)      

 θ        {x/Jane}          

Unifica4on  

p       Knows(John,x)   Knows(John,x) Knows(John,x)   Knows(John,x)

 q        Knows(John,Jane)    Knows(y,OJ)      Knows(y,Mother(y))  Knows(x,OJ)    

 θ        {x/Jane}    {x/O  J,  y/John}          

3

Unifica4on  

p       Knows(John,x)   Knows(John,x) Knows(John,x)   Knows(John,x)

 q        Knows(John,Jane)    Knows(y,OJ)      Knows(y,Mother(y))  Knows(x,OJ)      

 θ        {x/Jane}    {x/O  J,  y/John}    {y/John,  x/Mother(John)}  

Unifica4on  

p        q        θ       Knows(John,x)    Knows(John,Jane)    {x/Jane}   Knows(John,x)  Knows(y,OJ)      {x/O  J,  y/John}   Knows(John,x)    Knows(y,Mother(y))  {y/John,  x/Mother(John)}   Knows(John,x)  Knows(x,OJ)      fail   •  Standardizing  apart  eliminates  overlap  of  variables,  e.g.,  Knows(z17,OJ)  

4

Modus  Ponens  in  proposi4onal  logic   •  Modus  ponens   •  If  both  sentences  in  the  premise  are  True,  the  conclusion  is  True  

9  

Forward  and  backward  chaining   •  Modus  Ponens  (for  Horn  Form):  complete  for  Horn  KBs   α1,  …  ,αn,

 

 α1  ∧  …  ∧  αn  ⇒  β   β  

•  Can  be  used  with  forward  chaining  or  backward  chaining.   •  These  algorithms  are  very  natural  and  run  in  linear  Ame  

5

Forward  chaining   •  Idea:  fire  any  rule  whose  premises  are  saAsfied  in  the  KB,   •  add  its  conclusion  to  the  KB,  unAl  query  is  found  

Forward  chaining  example  

6

Forward  chaining  example  

Forward  chaining  example  

7

Forward  chaining  example  

Forward  chaining  example  

8

Forward  chaining  example  

Forward  chaining  example  

9

Forward  chaining  example  

Forward  chaining   •  Idea:  fire  any  rule  whose  premises  are  saAsfied  in  the  KB,   •  add  its  conclusion  to  the  KB,  unAl  query  is  found  

10

From  PL  to  FOL   •  Modus  Ponens  in  proposiAonal  logic   •  Modus  Ponens  (for  Horn  Form)   α1,  …  ,αn,  

 α1  ∧  …  ∧  αn  ⇒  β   β  

•  Forward  chaining  in  proposiAonal  logic   •  Modus  Ponens  in  forward  direcAon  and  add  atomic  sentences  

First  order  definite  clauses   •  Definite  clauses:  SituaAon    Response   •  Atomic   •  ImplicaAon  with  conjuncAve  premise   King  (x)  AND  Greedy(x)    Evil  (x)   King  (John)   Greedy  (x)  

22  

11

Generalized  Modus  Ponens  (GMP)   p1',  p2',  …  ,  pn',  (  p1  ∧  p2  ∧  …  ∧  pn  ⇒q)   where                                                  qθ   p1'  is  King(John)        p1  is  King(x)     p2'  is  Greedy(y)        p2  is  Greedy(x)     θ  is  {x/John,y/John}    q  is  Evil(x)     qθ  is  Evil(John)  

pi'θ = pi θ for all i

•  All  variables  assumed  universally  quanAfied   •  GMP  is  lihed  version  of  modus  ponens   •  Lihing  from  the  ground  (variable-­‐free)  to  FOL  

Example  knowledge  base   •  The  law  says  that  it  is  a  crime  for  an  American  to  sell  weapons  to   hosAle  naAons.    The  country  Nono,  an  enemy  of  America,  has   some  missiles,  and  all  of  its  missiles  were  sold  to  it  by  Colonel   West,  who  is  American.   •  Prove  that  Col.  West  is  a  criminal  

12

Example  knowledge  base  contd.   ...  it  is  a  crime  for  an  American  to  sell  weapons  to  hosAle  naAons:   Nono  …  has  some  missiles,  i.e.,  ∃x  Owns(Nono,x)  ∧  Missile(x):   …  all  of  its  missiles  were  sold  to  it  by  Colonel  West   Missiles  are  weapons:   An  enemy  of  America  counts  as  "hosAle“:   West,  who  is  American  …   The  country  Nono,  an  enemy  of  America  …  

Example  knowledge  base  contd.   ...  it  is  a  crime  for  an  American  to  sell  weapons  to  hosAle  naAons:   Nono  …  has  some  missiles,  i.e.,  ∃x  Owns(Nono,x)  ∧  Missile(x):   …  all  of  its  missiles  were  sold  to  it  by  Colonel  West   Missiles  are  weapons:   An  enemy  of  America  counts  as  "hosAle“:   West,  who  is  American  …   American(West)  

The  country  Nono,  an  enemy  of  America  …   Enemy(Nono,America)  

13

Example  knowledge  base  contd.   ...  it  is  a  crime  for  an  American  to  sell  weapons  to  hosAle  naAons:   Nono  …  has  some  missiles,  i.e.,  ∃x  Owns(Nono,x)  ∧  Missile(x):   …  all  of  its  missiles  were  sold  to  it  by  Colonel  West   Missiles  are  weapons:  

Missile(x)  ⇒  Weapon(x)  

An  enemy  of  America  counts  as  "hosAle“:   Enemy(x,America)  ⇒  HosDle(x)  

West,  who  is  American  …   American(West)  

The  country  Nono,  an  enemy  of  America  …   Enemy(Nono,America)  

Example  knowledge  base  contd.   ...  it  is  a  crime  for  an  American  to  sell  weapons  to  hosAle  naAons:   Nono  …  has  some  missiles,  i.e.,  ∃x  Owns(Nono,x)  ∧  Missile(x):   Owns(Nono,M1)  and  Missile(M1)  

…  all  of  its  missiles  were  sold  to  it  by  Colonel  West   Missile(x)  ∧  Owns(Nono,x)  ⇒  Sells(West,x,Nono)  

Missiles  are  weapons:  

Missile(x)  ⇒  Weapon(x)  

An  enemy  of  America  counts  as  "hosAle“:   Enemy(x,America)  ⇒  HosDle(x)  

West,  who  is  American  …   American(West)  

The  country  Nono,  an  enemy  of  America  …   Enemy(Nono,America)  

14

Example  knowledge  base  contd.   ...  it  is  a  crime  for  an  American  to  sell  weapons  to  hosAle  naAons:   American(x)  ∧  Weapon(y)  ∧  Sells(x,y,z)  ∧  HosDle(z)  ⇒  Criminal(x)  

Nono  …  has  some  missiles,  i.e.,  ∃x  Owns(Nono,x)  ∧  Missile(x):   Owns(Nono,M1)  and  Missile(M1)  

…  all  of  its  missiles  were  sold  to  it  by  Colonel  West   Missile(x)  ∧  Owns(Nono,x)  ⇒  Sells(West,x,Nono)  

Missiles  are  weapons:  

Missile(x)  ⇒  Weapon(x)  

An  enemy  of  America  counts  as  "hosAle“:   Enemy(x,America)  ⇒  HosDle(x)  

West,  who  is  American  …   American(West)  

The  country  Nono,  an  enemy  of  America  …   Enemy(Nono,America)  

Example  knowledge  base  contd.   ...  it  is  a  crime  for  an  American  to  sell  weapons  to  hosAle  naAons:   American(x)  ∧  Weapon(y)  ∧  Sells(x,y,z)  ∧  HosDle(z)  ⇒  Criminal(x)  

Nono  …  has  some  missiles,  i.e.,  ∃x  Owns(Nono,x)  ∧  Missile(x):   Owns(Nono,M1)  and  Missile(M1)  

…  all  of  its  missiles  were  sold  to  it  by  Colonel  West   Missile(x)  ∧  Owns(Nono,x)  ⇒  Sells(West,x,Nono)  

Missiles  are  weapons:  

Missile(x)  ⇒  Weapon(x)  

An  enemy  of  America  counts  as  "hosAle“:   Enemy(x,America)  ⇒  HosDle(x)  

West,  who  is  American  …   American(West)  

The  country  Nono,  an  enemy  of  America  …   Enemy(Nono,America)  

15

Forward  chaining  algorithm  

Forward  chaining  proof  

16

Forward  chaining  proof  

Forward  chaining  proof  

17

Proper4es  of  forward  chaining   •  Sound  and  complete  for  first-­‐order  definite  clauses   •  May  not  terminate  in  general  if  α  is  not  entailed   •  This  is  unavoidable:  entailment  with  definite  clauses  is   semidecidable  

Backward  chaining  algorithm  

18

Backward  chaining  example  

Backward  chaining  example  

19

Backward  chaining  example  

Backward  chaining  example  

20

Backward  chaining  example  

Backward  chaining  example  

21

Backward  chaining  example  

Backward  chaining  example  

22

Proper4es  of  backward  chaining   •  Depth-­‐first  recursive  proof  search:  space  is  linear  in  size  of  proof   •  Widely  used  for  logic  programming  

Communica4on  Homework  

23