Propositional logic It represents real-world facts as logical propositions in well formed formulas....

21
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. 1 CS 301 AI nd ES

Transcript of Propositional logic It represents real-world facts as logical propositions in well formed formulas....

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.

1CS 301 AI nd ES

Example

It is raining RAININGIt is sunny SUNNYIt is windy WINDYIf it is raining, then it is not sunny

RAINING ¬SUNNY

2CS 301 AI nd ES

Classical sentences

Socrates is a manSOCRATESMANPlato is a manPLATOMAN

MAN (SOCRATES)MAN (PLATO)

Now is reflects the structure of representation reflects the structure of knowledge itself.

3CS 301 AI nd ES

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.

4CS 301 AI nd ES

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

5CS 301 AI nd ES

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”

6CS 301 AI nd ES

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)

7CS 301 AI nd ES

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 clauseHence fido will die8CS 301 AI nd ES

Steps in Resolution

1. Put the premises or axioms into clause form2. Add the negations of what is to be proved in clause

form, to the set of axioms3. Resolve these clauses together, producing new

clauses that logically follow from them4. Produce a contradiction by generating the empty

clause5. The substitutions used to produce the empty clause

are those under which the opposite of the negated goal is true

9CS 301 AI nd ES

Marcus was a manMan (Marcus)Marcus was a PompeianPompeian(Marcus)All Pompeian were Romans x:Pompeian(x) Roman(x)Ceaser was a rulerRuler(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)10CS 301 AI nd ES

Marcus tried to assassinate Caesar. Tryassassinate (Marcus, Caeser)

11CS 301 AI nd ES

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 people9. x: man (x) person(x)

Question : Was Marcus loyal to Ceasar?Prove this : Marcus was not loyal to Ceasar

(If we got Marcus was not loyal to Ceasor otherwise Marcus was Loyal. )

[ ]

12CS 301 AI nd ES

Proven

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?

13CS 301 AI nd ES

Another ExampleAnyone passing the AI Exam and winning the lottery

is happyX:[pass(x,AI) Λ win(x, lottery) happy(x)]Anyone who studies or is lucky can pass all their

examsX : 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 lotteryX: [lucky(x) win(x,lottery)]

14CS 301 AI nd ES

Change to clause Form

1. ¬pass(X,AI) V ¬win(X,lottery) V happy(X)2. ¬study(Y) V pass(Y,Z)3. ¬lucky(W) V pass(W,V)4. ¬study(gopal)5. Lucky(gopal)6. ¬lucky(u) V win(u,lottery)7. Add negation of the conclusion ¬happy(gopal)

15CS 301 AI nd ES

¬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)16CS 301 AI nd ES NULL

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. PARENT(x, y) V ~ FATHER (x, y)iii. PARENT(x, y) V ~ MOTHER (x, y), iv. FATHER ( abraham, robert)v. 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) ( ii)

~ FATHER (robert, mike) (v)

Answer: Yes

Alpha-beta pruning example

Unevaluated nodes

Minimax without pruning

Depth-first searchVisit C, A, F, Visit G, heuristics evaluates to 2Visit H, heuristics evaluates to 3Back up {2,3} to F. max(F)=3

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.

F

G H IJ