File

advertisement
Propositional logic
It represents real-world facts as logical
propositions in well formed formulas.
It presented as an atomic propositions,
and complex sentences can be created using
AND, OR, and other operators.
CS 301 AI nd ES
1
Example
It is raining RAINING
It is sunny SUNNY
It is windy WINDY
If it is raining, then it is not sunny
RAINING 
¬SUNNY
CS 301 AI nd ES
2
Classical sentences
Socrates is a man
SOCRATESMAN
Plato is a man
PLATOMAN
MAN (SOCRATES)
MAN (PLATO)
Now is reflects the structure of representation reflects the
structure of knowledge itself.
CS 301 AI nd ES
3
Predicate logic
In represents the logic there are objects,
properties, functions (Relations) are involved.
It serves a useful way of representing and
manipulating some of kinds of knowledge.
CS 301 AI nd ES
4
Resolution
• Resolution is a technique for proving theorems in
predicate calculus
• Resolution proves a theorem by negating the
statement to be proved and adding the negated goal
to the set of axioms that are known or have been
assumed to be true
CS 301 AI nd ES
5
Example
• We wish to prove that
“Fido will die” from the statements that
“Fido is a dog” and
“all dogs are animals” and
“all animals will die”
CS 301 AI nd ES
6
Equivalent Reasoning by Resolution
• Convert these predicates to clause form
Predicate Form
Clause Form
Dog(fido)
Dog(fido)
x: [dog(x)animal(x)]
¬ dog(x) V animal(x)
y:[animal(y) die(y)]
¬ animal(y) V die(y)
CS 301 AI nd ES
7
Apply Resolution
• Negate the conclusion that fido will die
¬die(fido)
¬dog(x) V animal(x)
¬animal(y) V die(y)
[Y/X]
dog(fido)
¬dog(y) V die(y)
[fido/Y]
die(fido) ¬die(fido)
a Null clauseHence fido will die
CS 301 AI nd ES
8
Steps in Resolution
1. Put the premises or axioms into clause form
2. Add the negations of what is to be proved in clause
form, to the set of axioms
3. Resolve these clauses together, producing new
clauses that logically follow from them
4. Produce a contradiction by generating the empty
clause
5. The substitutions used to produce the empty clause
are those under which the opposite of the negated
goal is true
CS 301 AI nd ES
9
Marcus was a man
Man (Marcus)
Marcus was a Pompeian
Pompeian(Marcus)
All Pompeian were Romans
x:Pompeian(x)  Roman(x)
Ceaser was a ruler
Ruler(Ceaser)
All Romans were either loyal to Ceaser or Hated him
x: Roman(x)  loyalto(x,Caesar) V hate (x, Caesar)
Everyone is loyal to someone
x: y: loyalto (x,y)
People only try to assassinate rulers they are not loyol to
x: y : Person(x) ᴧ ruler(y) ᴧ tryassassinate (x,y  ¬ loyalto(x,y)
CS 301 AI nd ES
10
Marcus tried to assassinate Caesar.
Tryassassinate (Marcus, Caeser)
CS 301 AI nd ES
11
Question : Was Marcus loyal to Ceasar?
Proventhis : Marcus was not loyal to Ceasar
Prove
(If we got Marcus was not loyal to Ceasor otherwise Marcus was Loyal. )
1. Man (Marcus)
2. Pompeian(Marcus)
3.
x:Pompeian(x)  Roman(x)
4. Ruler(Ceaser)
5. x: Roman(x)  loyalto(x,Caesar) V hate (x, Caesar)
6. x: y: loyalto (x,y)
7. x: y :[Person(x) ᴧ ruler(y) ᴧ tryassassinate (x,y)
] ¬ loyalto(x,y)
8. Tryassassinate (Marcus, Caeser)
All men are people
9. x: man (x)  person(x)
CS 301 AI nd ES
12
Another Example
Anyone passing the Artificial Intelligence
exam and winning the lottery is happy. But
anyone who studies or is lucky can pass all
their exams. Gopal did not study but he is
lucky. Anyone who is lucky wins the lottery. Is
Gopal happy?
CS 301 AI nd ES
13
Another Example
Anyone passing the AI Exam and winning the lottery
is happy
X:[pass(x,AI) Λ win(x, lottery) happy(x)]
Anyone who studies or is lucky can pass all their
exams
X : Y [studies(x) V lucky(x) pass(x,y)]
gopal did not study but he is lucky
¬ study(gopal) Λ lucky(gopal)
Anyone who is lucky wins the lottery
X: [lucky(x) win(x,lottery)]
CS 301 AI nd ES
14
Change to clause Form
1.
2.
3.
4.
5.
6.
7.
¬pass(X,AI) V ¬win(X,lottery) V happy(X)
¬study(Y) V pass(Y,Z)
¬lucky(W) V pass(W,V)
¬study(gopal)
Lucky(gopal)
¬lucky(u) V win(u,lottery)
Add negation of the conclusion ¬happy(gopal)
CS 301 AI nd ES
15
¬pass(X,AI) V ¬win(X,lottery) V happy(X)
win(u,lottery) V ¬lucky(u)
u/v
¬pass(u,AI) V happy(u) V ¬lucky(u)
gopal/u
¬happy(gopal)
¬pass(gopal,AI) V ¬lucky(gopal)
lucky(gopal)
¬ pass(gopal,AI)
gop/v,AI/w
¬lucky(v) V pass(V,W)
¬lucky(gopal) lucky(gopal)
CS 301 AI nd ES
NULL
16
Example
● Consider the following logic program.
GRANDFATHER (x, y)  FATHER (x, z) , PARENT (z, y)
PARENT (x, y)  FATHER (x, y)
PARENT (x, y)  MOTHER (x, y)
FATHER ( abraham, robert)
FATHER ( robert, mike)
● In FOL above program is represented as a set of clauses as:
S = {
}
GRANDFATHER (x, y) V ~FATHER (x, z) V ~ PARENT (z, y),
PARENT(x, y) V ~ FATHER (x, y),
PARENT(x, y) V ~ MOTHER (x, y),
FATHER ( abraham, robert),
FATHER ( robert, mike)
Example
● Let us number the clauses of S as follows:
i.
GRANDFATHER(x, y) V ~FATHER(x, z) V ~PARENT(z, y)
ii.
iii.
iv.
v.
PARENT(x, y) V ~ FATHER (x, y)
PARENT(x, y) V ~ MOTHER (x, y),
FATHER ( abraham, robert)
FATHER ( robert, mike)
Question : “Is abraham a grandfather of mike ?"
● Ground Query “Is abraham a grandfather of mike ?"
 GRANDFATHER (abraham, mike).
● In FOPL, ~GRANDFATHER(abraham, mike) is negation of goal
{ GRANDFATHER (abraham, mike).
● Include {~goal} in the set S and show using resolution
refutation that S  {~ goal} is unsatisfiable in order to
conclude the goal.
● Let ~ goal is numbered as ( vi) in continuation of first five
clauses of S listed above.
vi. ~ GRANDFATHER (abraham, mike)
● Resolution tree is given on next slide:
Resolution
(i)
( vi )
{x / abraham, y / mike}
( iv)
~ FATHER(abraham, z) V ~PARENT(z, mike)
{z / robert}
~ PARENT (robert, mike)
~ FATHER (robert, mike)
Answer:
Yes
( ii)
(v)
Alpha-beta pruning example
F
Minimax without pruning
Depth-first search
Visit C, A, F,
Visit G, heuristics evaluates to 2
Visit H, heuristics evaluates to 3
Back up {2,3} to F. max(F)=3
G
H
I
J
Unevaluated nodes
Back up to A. β(A)=3. Temporary min(A) is 3.
3 is the ceiling for node A's score.
Visit B according to depth-first order.
Visit I. Evaluates to 5.
Max(B)>=5. α(B)=5.
It does not matter what the value of J is, min(A)=3. β-prune J.
Alpha-beta pruning improves search efficiency of minimax without sacrificing accuracy.
Download