1/46 logical agents عاملهاي منطقي chapter 7 (part 2) modified by vali derhami

46
1/46 Logical Agents ي ق ط ن م اي ه ل ما عChapter 7 (part 2) Modified by Vali Derhami

Upload: melvin-lindsey

Post on 18-Jan-2018

221 views

Category:

Documents


0 download

DESCRIPTION

3/46 Reasoning Patterns in Propositional Logic Inference rules: The patterns of inference: 1-Modus Ponens (قياس استثنايي) 2-And –Elimination تمامي هم ارزهاي منطقي در اسلايد 28از قسمت اول مي توانند بعنوان قاعده استنتاج بكار روند اثبات : دنباله اي از كاربردهاي قواعد اسنتاج يكنواختي: مجموعه جملات ايجاب شده فقط زماني مي تواند افزايش يابند كه اطلاعاتي به پايگاه دانش افزوده شود.

TRANSCRIPT

Page 1: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

1/46

Logical Agentsمنطقي عاملهاي

Chapter 7 (part 2)Modified by Vali Derhami

Page 2: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

2/46

Proof methods• Proof methods divide into (roughly) two kinds:

– Application of inference rules• Legitimate (sound) generation of new sentences from old• Proof = a sequence of inference rule applications

Can use inference rules as operators in a standard search algorithm

• Typically require transformation of sentences into a normal form

– Model checking• truth table enumeration (always exponential in n)• heuristic search in model space (sound but incomplete)

e.g., min-conflicts-like hill-climbing algorithms

•• improved backtracking, e.g., Davis--Putnam-

Logemann-Loveland (DPLL)

Page 3: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

3/46

Reasoning Patterns in Propositional Logic • Inference rules: The patterns of inference: 1-Modus Ponens ( استثنايي (قياس

2-And –Elimination

اساليد • در منطقي ارزهاي هم مي 28تمامي اول قسمت ازروند بكار استنتاج قاعده بعنوان توانند

اسنتاج : • قواعد كاربردهاي از اي دنباله اثباتتواند يكنواختي:• مي زماني فقط شده ايجاب جمالت مجموعه

. شود افزوده دانش پايگاه به اطالعاتي كه يابند افزايش

Page 4: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

4/46

Resolution تحليل: ساده: استنتاج روش يك تحليل

جستجوي الگوريتم هر با شدن همراه صورت دراستنتاج الگوريتم يك ميكند كاملكامل، ايجاد را

• In Wumpus world, consider the agent returns from [2,1] to [1,1] and then goes to [1,2], where it perceives a stench, but no breeze. We add the following facts to the

knowledge base:

Page 5: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

5/46

( ادامه ( تحليل

we can now derive the absence of pits in [2,2] and [1,3],([1,1] is already known(

:

Respect to R11 and R12:

Respect to R10 (R10 : P11), and R16:

Known from past:

Respect to R15 and Rr13:

Page 6: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

6/46

) تحليل ادامه(Conjunctive Normal Form (CNF)( نرمال (عطفيفرم

conjunction of disjunctions of literals (clauses)هم ANDتركيب با كه ليترال .ORاز اند شده

Literal: a atomic sentence. Ex; P , Q , or , AClause: a disjunction of literals.

E.g., (A B) (B C D)

• Unit resolution inference rule:

Where li and m are complementary literals

Page 7: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

7/46

) تحليل ادامه(• Full Resolution inference rule (for CNF):

l1 … lk, m1 … mn

l1 … li-1 li+1 … lk m1 … mj-1 mj+1 ... mn

where li and mj are complementary literals. E.g., P1,3 P2,2, P2,2

P1,3• Using any complete search, • Resolution is sound and complete

for propositional logic اثبات براي تواند مي هميشه تحليل توجه،

شود استفاده جمله يك ياتكذيب

••

Page 8: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

8/46

Conversion to CNFعطفي نرمال فرم به تبديل

B1,1 (P1,2 P2,1) 1. Eliminate , replacing α β with (α β)(β α). (B1,1 (P1,2 P2,1)) ((P1,2 P2,1) B1,1)

2. Eliminate , replacing α β with α β.

3. Move inwards using de Morgan's rules and double-negation:(B1,1 P1,2 P2,1) ((P1,2 P2,1) B1,1)

4. Apply distributivity law ( over ) and flatten:(B1,1 P1,2 P2,1) (P1,2 B1,1) (P2,1 B1,1)

–• (B1,1 (P1,2 P2,1)) ((P1,2 P2,1) B1,1)

Page 9: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

9/46

Resolution algorithm

• Proof by contradiction, i.e., to Prove KB a, show KBα unsatisfiable

Page 10: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

10/46

Steps in Resolution algorithm• (KB a) is converted into CNF.• The resolution rule is applied to the resulting clauses.

Each pair that contains complementary literals is resolved to produce a new clause, which is added to the set if it is not already present.

• The process continues until one of two things happens: 1- two clauses resolve to yield the empty clause,

in which case KB entails a. 2- there are no new clauses that can be added, in which case KB does not entail a.

Page 11: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

11/46

Resolution example

• KB = (B1,1 (P1,2 P2,1)) B1,1 ,α = P1,2

Page 12: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

13/46

Forward and backward chaining• Horn Form (restricted): عطفي نرمال فرم از اي شده محدود فرم

است. ORتركيب • است مثبت آنها از يكي حداكثر كه ها ليترال از• : آن شرطي- 1مزاياي فرم به تبديل

P 1,1 B1,1 P1,2

(P 1,1 P1,2) B1,1

(P 1,1 P1,2) B1,1

KB = conjunction of Horn clauses– Horn clause =

• proposition symbol; or• (conjunction of symbols) symbol

– E.g., C (B A) (C D B)معين – بند را دارند مثبت ليترال يك دقيقا كه هورني مي )Definite clause(بندهاي

نامند

Page 13: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

14/46

Forward and backward chaining•2- : استثنايي قياس از استفاده با استناج اجازه

• Modus Ponens (for Horn Form): complete for Horn KBs

α1, … ,αn, α1 … αn ββ

• Can be used with forward chaining or backward chaining.

هورن- 3• بندهاي در ايجاب مورد در گيري تصميم زمانخطي بصورت دانش پايگاه اندازه حسب بر تواند مي

باشد: • These algorithms are very natural and run in

linear time•

Page 14: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

15/46

Forward and backward chaining

A Horn clause with no positive literals can be written as an implication whose conclusion is the literal False.Ex: —wumpus cannot be in both [1,1] and [1,2]—is equivalent to . Such sentences are called integrity (کامل ( constraints in the database world,

Page 15: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

16/46

Forward chaining• Idea: fire any rule whose premises are satisfied in the

KB,– add its conclusion to the KB, until query is found

Page 16: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

17/46

Forward chaining algorithm

• Forward chaining is sound and complete for Horn KB

Page 17: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

18/46

Forward chaining example

Page 18: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

19/46

Forward chaining example

Page 19: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

20/46

Forward chaining example

Page 20: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

21/46

Forward chaining example

Page 21: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

22/46

Forward chaining example

Page 22: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

23/46

Forward chaining example

Page 23: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

24/46

Forward chaining example

Page 24: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

25/46

Forward chaining example

Page 25: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

26/46

Proof of completeness• FC derives every atomic sentence that is

entailed by KB1. FC reaches a fixed point where no new atomic

sentences are derived2. Consider the final state as a model m, assigning

true/false to symbols3. Every clause in the original KB is true in m

a1 … ak b4. Hence m is a model of KB5. If KB╞ q, q is true in every model of KB, including m

Page 26: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

27/46

Backward chainingIdea: work backwards from the query q:

to prove q by BC,check if q is known already, orprove by BC all premises of some rule concluding q

Avoid loops: check if new subgoal is already on the goal stack

Avoid repeated work: check if new subgoal has already been proved true, or has already failed

Page 27: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

28/46

Backward chaining example

Page 28: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

29/46

Backward chaining example

Page 29: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

30/46

Backward chaining example

Page 30: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

31/46

Backward chaining example

Page 31: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

32/46

Backward chaining example

Page 32: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

33/46

Backward chaining example

Page 33: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

34/46

Backward chaining example

Page 34: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

35/46

Backward chaining example

Page 35: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

36/46

Backward chaining example

Page 36: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

37/46

Backward chaining example

Page 37: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

38/46

Forward vs. backward chaining• FC is data-driven, automatic, unconscious processing

( هدف بي .appropritate for Design, Control ,(پروسس– e.g., object recognition, routine decisions

• May do lots of work that is irrelevant to the goal

• BC is goal-driven, appropriate for problem-solving, Diagnosis,– e.g., Where are my keys? How do I get into a PhD program?

• Complexity of BC can be much less than linear in size of KB

Page 38: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

39/46

Efficient propositional inferenceTwo families of efficient algorithms for propositional

inference on Model checking:

Complete backtracking search algorithms– DPLL algorithm (Davis, Putnam, Logemann, Loveland)

Incomplete local search algorithms– WalkSAT algorithm

Page 39: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

40/46

The DPLL algorithmDetermine if an input propositional logic sentence (in CNF) is satisfiable.

. مدل يافتن براي اول عمق روش از استفادهImprovements over truth table enumeration:

1. Early terminationA clause is true if any literal is true.A sentence is false if any clause is false.

2. Pure symbol heuristicPure symbol: always appears with the same "sign" in all clauses. e.g., In the three clauses (A B), (B C), (C A), A and B are pure, C is impure. Make a pure symbol literal true.

كه شودند دهی مقدار اي گونه به تواند مي خالص هاي سمبل مقدار لذا باشد داشته مدلي جمله آگركند صحيح را اشان مربوطه .بند

3. Unit clause heuristicUnit clause: only one literal in the clauseThe only literal in a unit clause must be true.

درخت انشعاب از قبل واحد بندهای تمام دهی مقدار واقع در

Page 40: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

41/46

The DPLL algorithm

Page 41: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

42/46

The WalkSAT algorithm• Incomplete, local search algorithm

• . ارزيابي تابع كند ارضا را بندها تمام كه Wاست انتسابي يافتن هدف. آيد مي بر كار اين عهده از بشمارد را نشده ارضا بندهاي Wتعداد كه• On every iteration, the algorithm picks an unsatisfied

clause and picks a symbol in the clause to flip. It chooses randomly between two ways to pick which symbol to flip: A) a "min-conflicts" step that minimizes the number of unsatisfied clauses in the new state, and B) a random walk" step that picks the symbol randomly.

• Evaluation function: The min-conflict heuristic of minimizing the number of unsatisfied clauses

• Balance between greediness and randomness

Page 42: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

43/46

The WalkSAT algorithm

Page 43: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

44/46

Hard satisfiability problems

• Consider random 3-CNF sentences. e.g.,(D B C) (B A C) (C B E) (E D B) (B E C)

m = number of clauses n = number of symbols

– Hard problems seem to cluster near m/n = 4.3 (critical point)

Page 44: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

45/46

Hard satisfiability problems

Page 45: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

46/46

Hard satisfiability problems

• Median runtime for 100 satisfiable random 3-CNF sentences, n = 50

Page 46: 1/46 Logical Agents عاملهاي منطقي Chapter 7 (part 2) Modified by Vali Derhami

47/46

) 8، 5تکالیف : • - و ( د تا تست 9الف سواالت و