CS 236501 Introduction To AI: Tutorial 8 Resolution

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 20

CS 236501

Introduction to AI

Tutorial 8
Resolution
Problem Definition
Input
1. Database containing formally represented facts: First-order
logic sentences converted into clause form.
2. Inference rule: Resolution principle (MP & MT)

Goal: An inference procedure

Requirements:
1. Soundness – every sentence produced by the procedure will
be “true”.
2. Completeness – every “true” sentence can be produced by the
procedure

Feb 18, 20 Intro. to AI – Tutorial 8 2


Definitions
• Terms:
– Constants (e.g. “c1”, “c2”)
– Variables (e.g. “x1”, “x2”)
– Functions (e.g. “f(x1, x2)”)

• Predicate – Indicator function on terminals.


– e.g. EVEN(t) : Numbers  {TRUE, FALSE}

• Atom – the application of a predicate on a literal.


– e.g. EVEN(t)

• Literal – A predicate or its negation


– e.g. EVEN(t), ¬EVEN(t)

Feb 18, 20 Intro. to AI – Tutorial 8 3


Definitions
• Formulae - Recursively defined:
– Every Atom is a formula
– If w1, w2 are formulae, then so are:

w1 , w1  w2 , w1  w2 , w1  w2 , w1 , w1

• Clause – Disjunction (or) of literals.


– e.g. L1 V L2 V ¬L3 (can be written as: {L1, L2 ,¬L3})

Feb 18, 20 Intro. to AI – Tutorial 8 4


The Resolution Principle
• Given:
– A clause Φ containing the literal: φ
– A clause Ψ containing the literal: ¬φ

• We can conclude:
– (Φ – {φ}) U (Ψ – {¬φ})

• Or in the generalized version…

Feb 18, 20 Intro. to AI – Tutorial 8 5


The Resolution Principle
• Given:
– A clause Φ containing the literal: φ
– A clause Ψ containing the literal: ¬ψ

– A most general unifier g of φ and ¬ψ

• We can conclude:
– ((Φ – {φ}) U (Ψ – {¬ψ})) | g

Feb 18, 20 Intro. to AI – Tutorial 8 6


The Resolution Procedure
• Let DB be a set of true sentences without
contradictions, and C be a sentence we want to
prove.

The Idea - proof by negation:


• Assume ¬C and try to find a contradiction.

Intuition
• If all DB sentences are true, and assuming ¬C
creates a contradiction then C must be inferred from
DB.

Feb 18, 20 Intro. to AI – Tutorial 8 7


The Resolution Procedure
1. Convert: DB U {¬C} to clause form.

2. If there is a contradiction in DB, C was proved.


Terminate.

3. Select two clauses and add their resolvents to the


current DB. If there are no resolvable clauses – the
procedure fails, terminate. Else, go to step 2.

Feb 18, 20 Intro. to AI – Tutorial 8 8


Conversion to Clause Form
1. Eliminate all :
– Replace AB with ¬A V B

2. Distribute negations:
– Replace ¬¬A with A
–   A  B  withA  B
– …

3. Eliminate existential quantifiers by replacing with


Skölem constants or functions:
– 
e.g. xy  P1  x, y   P2  x, y   x P1  x, f  x   P2  x, f  x  
Feb 18, 20 Intro. to AI – Tutorial 8 9
Conversion to Clause Form
4. Rename variables to avoid duplicates between
different quantifiers.

5. Drop all universal quantifiers

6. Put expression into conjunctive normal form (CNF).

7. Convert to clauses (sets of literals).

8. Rename variables to avoid duplicates between


different clauses.

Feb 18, 20 Intro. to AI – Tutorial 8 10


Conversion to Clauses - Example
• Initial expression:
 y  on  x, y   bigger  y , x   
  
  
x brick  x   y  on  y, x   brick  y  
  
  
y, z  on  x, y   on  x, z   equal  y , z   


• Remove implications:
 y  on  x, y   bigger  y , x   
  
  
x brick  x   y  on  y, x   brick  y  
  
  
y, z   on  x, y   on  x, z   equal  y, z   


Feb 18, 20 Intro. to AI – Tutorial 8 11


Conversion to Clauses - Example
• Previous step:
 y  on  x, y   bigger  y , x   
  
  
x brick  x   y  on  y, x   brick  y  
  
  
y, z   on  x, y   on  x, z   equal  y, z   


• Move negations inwards:


 y  on  x, y   bigger  y, x   
  
  
x brick  x   y  on  y, x   brick  y  
  
  
y, z  on  x, y   on  x, z   equal  y , z   


Feb 18, 20 Intro. to AI – Tutorial 8 12


Conversion to Clauses - Example
• Previous step:
 y  on  x, y   bigger  y, x   
  
  
x brick  x   y  on  y, x   brick  y  
  
  
y, z  on  x, y   on  x, z   equal  y , z   


• Remove existential quantifiers:



 
 
 on  x,support  x   bigger support  x  , x    

  
x brick  x   y  on  y, x   brick  y  
  
   
y, z  on  x, y   on  x, z   equal  y , z   


Feb 18, 20 Intro. to AI – Tutorial 8 13


Conversion to Clauses - Example
• Previous step:

 
 
 on  x,support  x   bigger support  x  , x    

  
x brick  x   y  on  y, x   brick  y  
  
   
y, z  on  x, y   on  x, z   equal  y , z   


• Rename variables:

 
 
 on  x,support  x   bigger support  x  , x    

  
x brick  x   y  on  y, x   brick  y  
  
  
w, z  on  x, w   on  x, z   equal  w, z   


Feb 18, 20 Intro. to AI – Tutorial 8 14


Conversion to Clauses - Example
• Previous step:

 
 
 on  x,support  x   bigger support  x  , x    

  
x brick  x   y  on  y, x   brick  y  
  
  
w, z  on  x, w   on  x, z   equal  w, z   
 

• Remove universals quantifiers:



 
 
 on  x,support  x   bigger support  x  , x    

  
brick  x    on  y, x   brick  y  
  
   
  on  x, w   on  x, z   equal  w, z  


Feb 18, 20 Intro. to AI – Tutorial 8 15


Conversion to Clauses - Example
• Previous step:




 on  x,support  x   bigger support  x  , x    

 
  brick  x   

  on  y , x   brick  y    


 
 
 
on  x, w   on  x, z   equal  w, z  
 

• Convert to CNF:
brick  x   on  x,support  x  
brick  x   bigger support  x  , x  
brick  x   on  y, x   brick  y  
brick  x   on  x, w   on  x, z   equal  w, z 

Feb 18, 20 Intro. to AI – Tutorial 8 16


Conversion to Clauses - Example
• Previous step:
brick  x   on  x,support  x  
brick  x   bigger support  x  , x  
brick  x   on  y, x   brick  y  
brick  x   on  x, w   on  x, z   equal  w, z 

• Convert to clauses:
brick  x  , on  x,support  x ,
brick  x  , bigger support  x  , x ,
brick  x  , on  y, x  , brick  y ,
brick  x  , on  x, w  , on  x, z  , equal  w, z 

Feb 18, 20 Intro. to AI – Tutorial 8 17


Conversion to Clauses - Example
• Previous step:
brick  x  , on  x,support  x ,
brick  x  , bigger support  x  , x ,
brick  x  , on  y, x  , brick  y ,
brick  x  , on  x, w  , on  x, z  , equal  w, z 
• Rename variables:
brick  x1  , on  x1 ,support  x1 ,
brick  x  , bigger support  x  , x ,
2 2 2

brick  x  , on  y, x  , brick  y ,


3 3

brick  x  , on  x , w  , on  x , z  , equal  w, z 


4 4 4

Feb 18, 20 Intro. to AI – Tutorial 8 18


Simple Example
• The problem:
– “Heads I win, tails you lose.”
– Use resolution to show I always win.

• Facts representation:
1. H  Win  Me 
2. T  Loose You 
3. H  T
4. Loose You   Win  Me 

Goal : Win  Me 

Feb 18, 20 Intro. to AI – Tutorial 8 19


Simple Example
• Proof:
1. H ,Win  Me 
2. T , Loose You 
3. H , T 
4. Loose You  ,Win  Me 
5. Win  Me 
6. T ,Win  Me  2, 4
7. T ,Win  Me  1,3
8. Win  Me  6, 7
9. {} 5,8

Feb 18, 20 Intro. to AI – Tutorial 8 20

You might also like