cs182 intelligent machines: reasoning, actions and plans section 5

14
CS182 Intelligent Machines: Reasoning, Actions and Plans Section 5

Upload: david-york

Post on 13-Jan-2016

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS182 Intelligent Machines: Reasoning, Actions and Plans Section 5

CS182 Intelligent Machines: Reasoning, Actions and Plans

Section 5

Page 2: CS182 Intelligent Machines: Reasoning, Actions and Plans Section 5

Propositional Logic: Conversion to CNF (1)

• CNF (Conjunctive Normal Form): A conjunction of clauses, where a clause is a disjunction of literals

(A B C) (D E) … (X Y) Z∨ ∨ ∧ ∨ ∧ ∧ ∨ ∧

• Convert the following sentence into CNF:(X Y) (Z ¬(¬X (Z Y)))C∧ ∧ ∨ ∨ ∧

Page 3: CS182 Intelligent Machines: Reasoning, Actions and Plans Section 5

Propositional Logic: Conversion to CNF (2)

• Rules you might want to use:- De Morgan: “Pushing” negation into parentheses

¬(A B)=¬A ¬B∧ ∨¬(A B)=¬A ¬B∨ ∧

- Distributivity:A (B C)=(A B) (A C)∧ ∨ ∧ ∨ ∧A (B C)=(A B) (A C)∨ ∧ ∨ ∧ ∨

- Implication elimination: Get around the “”AB = ¬A B∨

Page 4: CS182 Intelligent Machines: Reasoning, Actions and Plans Section 5

Propositional Logic: Conversion to CNF (3)

(X Y∧ )∧(Z ¬∨ (¬X (Z Y)∨ ∧ ))C= ¬((X Y∧ )∧(Z ¬∨ (¬X (Z Y)∨ ∧ )))C [Implication elimination]= (¬(X Y∧ ) ¬∨ (Z ¬∨ (¬X (Z Y)∨ ∧ ))) C ∨ [De Morgan]= ((¬X ¬Y∨ )∨¬(Z ¬∨ (¬X (Z Y)∨ ∧ ))) C ∨ [De Morgan]= ((¬X ¬Y∨ )∨(¬Z∧(¬X∨(Z Y)∧ ))) C ∨ [De Morgan]= ((¬X ¬Y∨ )∨(¬Z ∧ ((¬X Z∨ ) (¬X Y)∧ ∨ ))) C ∨ [Distributivity]= ((¬X ¬Y ¬Z∨ ∨ )∧(¬X ¬Y ¬X Z∨ ∨ ∨ ) (¬X ¬Y ¬X Y)∧ ∨ ∨ ∨ )∨C [Distributivity]= (¬X ¬Y ¬Z C∨ ∨ ∨ )∧(¬X ¬Y ¬X Z C∨ ∨ ∨ ∨ ) (¬X ¬Y ¬X Y C) ∧ ∨ ∨ ∨ ∨[Distributivity]

Page 5: CS182 Intelligent Machines: Reasoning, Actions and Plans Section 5

First-order Logic: Representing Facts(1)

Are the following representations correct?• No man is both a butcher and a vegetarian.

- What this really means?Anything in this world is a male butcher who is not a vegetarian.

- What is the correct representation? [ ]

Page 6: CS182 Intelligent Machines: Reasoning, Actions and Plans Section 5

First-order Logic: Representing Facts(2)

• The only vegetarian butchers are woman [ ]

- What this really means?Anything in the world is a female vegetarian butcher.

- What is the correct representation? [ ]

Page 7: CS182 Intelligent Machines: Reasoning, Actions and Plans Section 5

First-order Logic: Representing Facts(3)

How to represent the following facts?• All men who are not butchers like some

vegetarian. [) ()]

• No man likes any woman who is a vegetarian butcher.

]

Page 8: CS182 Intelligent Machines: Reasoning, Actions and Plans Section 5

First Order Logic: Functions (1)

Representing facts in Map Coloring problems– Predicates?

• Country(x), Borders(x,y)

– Functions?• Map-Color(x)

US is colored blue, and borders with Canada. Represent these facts and what they imply about Canada’s color:• Country(Canada)• Country(US)• Borders(US, Canada)• Map-Color(US) = Blue• (Country(Canada) Country(US) Borders(US, Canada) ∧ ∧ ∧ Map-Color(US)= Blue) ¬(Map-Color(Canada)=Blue)⇒

Page 9: CS182 Intelligent Machines: Reasoning, Actions and Plans Section 5

First Order Logic: Functions (2)

• No two adjacent countries have the same map color– Which of the following is correct?

∀x, y Country(x) Country(y) Borders(x, y) ¬(Map-Color(x) = Map-∧ ∧ ∧Color(y))

This means that all things in the world are countries that border each other and have different colors!

∀x, y (Country(x) Country(y) Borders(x, y)) Map-Color(x = y)∧ ∧ ⇒

This is not valid since Map-Color(x=y) is syntactically wrong.

Page 10: CS182 Intelligent Machines: Reasoning, Actions and Plans Section 5

First Order Logic: Functions (3)

∀x, y (Country(x) Country(y) Borders(x, y)) ∧ ∧ ⇒¬(Map-Color(x) = Map-Color(y)).Yay!

∀x, y ¬Country(x) ¬Country(y) ¬Borders(x, y)∨ ∨ ∨¬(Map-Color(x) = Map-Color(y)).Yay! (equivalent to above)

¬ x y (Country(x) Country(y) Borders(x, y) (Map-Color(x) = ∃ ∃ ∧ ∧ ∧Map-Color(y))).Yay! (equivalent to above)

Page 11: CS182 Intelligent Machines: Reasoning, Actions and Plans Section 5

Predicates or Functions?• A person born in the UK, each of whose parents is a UK citizen or a UK

resident, is a UK citizen by birth. ∀x Person(x) Born(x,UK) ( y Parent(y, x) ∧ ∧ ∀ ⇒(( r Citizen(y,UK,r)) Resident(y,UK))) Citizen(x,UK,Birth). ∃ ∨ ⇒

∀x Person(x) Born(x,UK) (Citizen(Father(x),UK,) Resident(Father(x),UK)) ∃ ∃ ∧ ∧ ∨) (Citizen(Mother(x),UK,) Resident(Mother(x),UK)) Citizen(x,UK,Birth). ∧ ∨ ⇒

• A person born outside the UK, one of whose parents is a UK citizen by birth, is a UK citizen by descent.

∀x Person(x) Born(x,UK) ( y Parent(y, x) Citizen(y,UK,Birth)) ∧ ∧ ∃ ∧ ⇒Citizen(x,UK,Descent).

∀x Person(x) Born(x,UK) (Citizen(Father(x),UK,Birth) ∧ ∧ ∨Citizen(Mother(x),UK,Birth)) Citizen(x,UK,Descent).⇒

Page 12: CS182 Intelligent Machines: Reasoning, Actions and Plans Section 5

Representing Facts in FOL – Hard Mode (1)

For each of the following sentences, first define the predicates and functions required, then write the sentence:

• There is an agent who sells policies only to people who are not insured. ∃x Agent(x) y, z (Policy(y) Sells(x, y, z)) (Person(z)∧∀ ∧ ⇒ ∧ Insured(z))

• There is a barber who shaves all men in town who do not shave themselves.

∃x y Barber(x) Man(y) Shaves(y, y) Shaves(x, y)∀ ∧ ∧ ⇒

Page 13: CS182 Intelligent Machines: Reasoning, Actions and Plans Section 5

Representing Facts in FOL – Hard Mode (2)

• TFs can be clear to some of the students all of the time, and they can be clear to all of the students some of the time, but they can't be clear to all of the students all of the time.

∀ x TF(x) ⇒( y t Student(y) Clear(x, y, t)) ∃ ∀ ∧ ∧( t y Student(y) Clear (x, y, t)) ∃ ∀ ⇒ ∧( t y Student (y) Clear(x, y, t))∀ ∀ ⇒

Page 14: CS182 Intelligent Machines: Reasoning, Actions and Plans Section 5

Bonus: Monty Python Logic

• http://www.youtube.com/watch?v=GpMjakNhZTc