Chapter 7 METHODS OF INFERENCE Expert Systems sstseng

  • Slides: 69
Download presentation
Chapter 7 METHODS OF INFERENCE 知識推論法 Expert Systems sstseng

Chapter 7 METHODS OF INFERENCE 知識推論法 Expert Systems sstseng

模式 (Mood) • Patterns of Categorical Statement Figure-1 Figure-2 Figure-3 Figure-4 MP SM PM

模式 (Mood) • Patterns of Categorical Statement Figure-1 Figure-2 Figure-3 Figure-4 MP SM PM SM MP MS PM MS AAA-1 MP SM AAA-2 PM SM AAA-3 MP MS AAA-4 PM MS 大前提 小前提 • 4種AAA模式 形態 大前提 小前提 Expert Systems sstseng 7

 • ex: AEE-1的決策程序 所有M為P 沒有S為M ∴沒有S為P Expert Systems sstseng 10

• ex: AEE-1的決策程序 所有M為P 沒有S為M ∴沒有S為P Expert Systems sstseng 10

ex: IAI-1的決策程序 某些P為M 所有M為S ∴某些P為S Expert Systems sstseng 12

ex: IAI-1的決策程序 某些P為M 所有M為S ∴某些P為S Expert Systems sstseng 12

有限狀態機器 ( Finite State Machine ) • 用以辨識 WHILE和WRITE的有限狀態機器 Expert Systems sstseng 15

有限狀態機器 ( Finite State Machine ) • 用以辨識 WHILE和WRITE的有限狀態機器 Expert Systems sstseng 15

Ex: 旅行推銷員問題 ( Travel Salesman Problem ) Expert Systems sstseng 18

Ex: 旅行推銷員問題 ( Travel Salesman Problem ) Expert Systems sstseng 18

7. 3 規則式推論(Rules of Inference) • 三段論( Syllogism ) 只是邏輯陳述的其中一 種方式. • 命題邏輯(Propositional logic)

7. 3 規則式推論(Rules of Inference) • 三段論( Syllogism ) 只是邏輯陳述的其中一 種方式. • 命題邏輯(Propositional logic) p q p______ q 這種命題邏輯的推論型態有很多種名子: direct reasoning(直接推論), modus ponens(離斷率), law of detachment(分離律), and assuming the antecedent(假設前提). Expert Systems sstseng 21

Law of Inference       Schemata 1. Law of Detachment     p→q p ∴q 2. Law of the

Law of Inference       Schemata 1. Law of Detachment     p→q p ∴q 2. Law of the Contrapositive p→q ∴~q→~p 3. Law of Modus Tollens p→q ~q ∴~p 4. Chain Rules(Law of the Syllogism) p→q q→r ∴p→r 5. Law of Disjunctive Inference p q ~p ∴q ~(~p) ∴p 6. Law of the Double Negation Expert Systems sstseng p q ~q ∴p 23

7. De Morgan’s Law ~(p q) ∴~p ~q ~(p q) ∴~p ~q 8. Law

7. De Morgan’s Law ~(p q) ∴~p ~q ~(p q) ∴~p ~q 8. Law of Simplification p q ∴p ~(p q) ∴~q 9. Law of Conjunction p q ∴p q 10. Law of Disjunctive Addition p ∴p q 11. Law of Conjunctive Argument ~(p q) p ∴~q ~(p q) q ∴~p Table 3. 8 Some Rules of Inference for Propositional Logic Expert Systems sstseng

命題邏輯分解 命題邏輯 ( Resolution in propositional Logic ) 1. 將命題(proposition)轉換成clause form形式. 2. 重複以下動作直到產生矛盾或是無法再繼續 (1)

命題邏輯分解 命題邏輯 ( Resolution in propositional Logic ) 1. 將命題(proposition)轉換成clause form形式. 2. 重複以下動作直到產生矛盾或是無法再繼續 (1) 選擇兩個clauses, 我們稱之為parent clauses (2) 將parent clauses作disjunction, 產生出來的 clause稱為resolvent, 再把有L和~L這樣形式的 元素移除 (3) 若最後resolvent是空的(empty), 則矛盾產生; 若否則再加入另一個clause作disjunction, 同(2) Expert Systems sstseng 25

Given Axioms Converted to Clause Form p p 1. (p q) r  ~p  

Given Axioms Converted to Clause Form p p 1. (p q) r  ~p   ~q (s t) q ~s   q ~t   q t   t r   2. 3. 4. 5. Figure.  命題邏輯的facts (A Few Facts in Propositional Logic) Expert Systems sstseng 26

~pˇ~qˇr ~r p ~p ˇ~q ~q ~t ˇq ~t Figure.  命題邏輯之解 (Resolution in Propositional

~pˇ~qˇr ~r p ~p ˇ~q ~q ~t ˇq ~t Figure.  命題邏輯之解 (Resolution in Propositional Expert Systems sstseng Logic) t

 • 第二敘述邏輯 (The second order logic) 的 量詞 (quantifiers)範圍含括函數符號 (function symbols)與敘述符號( predicate symbols)

• 第二敘述邏輯 (The second order logic) 的 量詞 (quantifiers)範圍含括函數符號 (function symbols)與敘述符號( predicate symbols) • 如果P是一文件中的任一敘述(predicate –則 – x =y = ( for every P [P(x) P(y) ] Expert Systems sstseng 31

7. 4 推斷鏈 3 Initial    D facts A 2 D 2 A 1 B C

7. 4 推斷鏈 3 Initial    D facts A 2 D 2 A 1 B C D 1 E Solution inference +… + inference Chain backward Chaining(向後鏈結) forward Chaining(向前鏈結) 從事實來推論結果 假設可能的解答是成立的, 再 尋求相關的證據證明之 Expert Systems sstseng

 • 變數替代( Unification ) 將變數(variable)用事實(fact)取代, 反覆的進行變 數替代最後即可得出結論. rule 1:A 1 and B 1

• 變數替代( Unification ) 將變數(variable)用事實(fact)取代, 反覆的進行變 數替代最後即可得出結論. rule 1:A 1 and B 1   C 1 rule 2:A 2 and C 1 D 2 rule 3: A 3 and B 2 D 3 rule 4:C 1 and D 3 G facts:A 1 is true B 1 is true A 2 is true A 3 is true B 2 is true Expert Systems sstseng 34

 • 前向推論( Forward reasoning ):     {A 1, A 2, A 3, B 1,

• 前向推論( Forward reasoning ):     {A 1, A 2, A 3, B 1, B 2, B 3} C 1 } fire r 1 {A 1, A 2, A 3, B 1, B 2, B 3,    D 2 } fire r 2 {A 1, A 2, A 3, B 1, B 2, B 3, C 1,    match    {r 1, r 3} match    {r 1, r 2, r 3} fire r 3 {A 1, A 2, A 3, B 1, B 2, B 3, C 1 D 2,    D 3 }   {r 1, r 2, r 3, r 4} fire r 4 {A 1, A 2, A 3, B 1, B 2, B 3, C 1 D 2, D 3,    G} GOAL Expert Systems sstseng 35

rule 1:A 1 and B 1 C 1 rule 2:A 2 and C 1

rule 1:A 1 and B 1 C 1 rule 2:A 2 and C 1 D 2 rule 3: A 3 and B 2 D 3 rule 4:C 1 and D 3 D 4 rule 5: C 1 and D 4 G’ facts: A 1, A 2, B 1, B 2, A 3 Expert Systems sstseng 36

 • 後向推論( Backward reasoning ): 1. 假設 G’ 成立 R 5 Verify C

• 後向推論( Backward reasoning ): 1. 假設 G’ 成立 R 5 Verify C 1 and D 4 訊問使用者D 4之值, 若為 False則G’不成立 R 1 Verify A 1 and B 1 OK OK 2. 假設 G 成立 R 4 Verify C 1 and D 3 R 3 Verify A 1 and B 1 OK OK Verify A 3 and B 2 OK OK Expert Systems sstseng 37

A 1 A 2 B 1 A 3 B 2 C 1 D 2

A 1 A 2 B 1 A 3 B 2 C 1 D 2 D 3 ? G GOAL Expert Systems sstseng

 • 前向鏈結( Good application of forward chaining ) Goal Facts Broad and Not

• 前向鏈結( Good application of forward chaining ) Goal Facts Broad and Not Deep    or too many possible goals Expert Systems sstseng 39

 • 後向鏈結( Good application of backward chaining ) Narrow and Deep GOALS Facts

• 後向鏈結( Good application of backward chaining ) Narrow and Deep GOALS Facts Expert Systems sstseng 40

 • 前向鏈結( Forward Chaining )  Planning  Monitoring  Control  Data-driven  Explanation not facilitated •

• 前向鏈結( Forward Chaining )  Planning  Monitoring  Control  Data-driven  Explanation not facilitated • 後向鏈結( Backward chaining )  Diagnosis  Goal-driven  Explanation facilitated Expert Systems sstseng

類比 (Analogy) • 將舊有相關的情境作為推論的參考 • Consider tic-tac-toe with values as a magic square (15

類比 (Analogy) • 將舊有相關的情境作為推論的參考 • Consider tic-tac-toe with values as a magic square (15 game) » 6 » 7 » 2 1 5 9 8 3 4 • 18 game from set {2, 3, 4, 5, 6, 7, 8, 9, 10} • 21 game from set {3, 4, 5, 6, 7, 8, 9, 10, 11} Expert Systems sstseng 42

7. 5 Reasoning Under Uncertainty (不確定性推論) • 不確定性 (Uncertainty)是指在作決策時缺少足夠的資訊. • 處理不確定性的理論有: Classical probability, Bayescian

7. 5 Reasoning Under Uncertainty (不確定性推論) • 不確定性 (Uncertainty)是指在作決策時缺少足夠的資訊. • 處理不確定性的理論有: Classical probability, Bayescian probability, Dempster-Shafer theory, and Zadeh’s fuzzy theory. • 在 MYCIN 和 PROSPECTOR的系統中, 即使所有前提確 實證明了結論是未知的, 也會產生很多結論. Expert Systems sstseng 44

導致不確定的錯誤 Example Turn the value off Turn value-1 off Value is stuck Value is

導致不確定的錯誤 Example Turn the value off Turn value-1 off Value is stuck Value is not stuck Turn value-1 to 5. 4 or 6 or 0 Value-1 setting is 5. 4 or 5. 5 or 5. 1 Value-1 setting is 7. 5 Value-1 is not stuck because it’s never been stuck before Output is normal and so value-1 is in good condition Error Ambiguous Incomplete Incorrect False positive False negative Imprecise Inaccurate Unreliable Random error Systematic error Invalid induction Reason What value? Which way? Correct is on Value is not stuck Value is stuck Correct is 5. 4 Correct is 9. 2 Equipment error Statistical fluctuation Miscalibration Value is stuck Invalid deduction Value is stuck in open position • 假說是需被驗證的. • Type 1 error (false positive) 是指接受了一個不會成立(F)的假設. • Type 2 error (false negative) 是指否決了一個會被成立(T)的假設. Expert Systems sstseng 45

 • 度量的誤差(Error of measurement) – 精確度(Precision) • 公釐量尺的精確度比公分量尺高. – 正確性(accuracy) Expert Systems sstseng

• 度量的誤差(Error of measurement) – 精確度(Precision) • 公釐量尺的精確度比公分量尺高. – 正確性(accuracy) Expert Systems sstseng 46

演繹錯誤 (Deductive errors)  p→q  q  ∴ p If the value is in good condition,

演繹錯誤 (Deductive errors)  p→q  q  ∴ p If the value is in good condition, than the output is normal The output is normal ∴ The value is in good condition. Expert Systems sstseng 49

硬碟損壞的決策樹 Act No Crash P(C’ | X’)=0. 5 P(C’∩X’)=0. 1 Crash P(C | X’)=0.

硬碟損壞的決策樹 Act No Crash P(C’ | X’)=0. 5 P(C’∩X’)=0. 1 Crash P(C | X’)=0. 5 P(C ∩X’)=0. 1 Prior Choose Brand X P(X)=0. 8 Don’t Choose Brand X P(X’)=0. 2 P(Hi) Crash P(C | X)=0. 75 No Crash P(C’ | X)=0. 25 P(C’ ∩ X)=0. 2 P(C ∩X)=0. 6 Conditional P(E | Hi ) Joint -P(E ∩ Hi ) =P(E | Hi ) P( Hi ) 0. 1 P(X’ | C’) = 0. 1+0. 2 =1/3 0. 1 P(X’ | C) = 0. 1+0. 6 =1/7 0. 2 P(X | C’) = 0. 2+0. 1 =2/3 Expert Systems sstseng 0. 6 P(X | C) = 0. 6+0. 1 =6/7 Posterior P(H i | E) = P (E ∩ Hi)      i. P(E∩Hi)

假設推論與向後歸納 (Hypothetical Reasoning and Backward Induction. ) Probabilities No Oil P(O’)=0. 4 Prior P(O)=0.

假設推論與向後歸納 (Hypothetical Reasoning and Backward Induction. ) Probabilities No Oil P(O’)=0. 4 Prior P(O)=0. 6 Subjective Opinion of Site - P (Hi) -Test +Test P(- | O’) P(+ | O’) P(- | O) P(+ | O) =0. 9 =0. 1 =0. 2 =0. 8 P(-∩O’) P(+∩O’) P(-∩O) P(+∩O) =0. 36 =0. 04 =0. 12 =0. 48 P(+)=P(+∩O)+P(+∩O’)=0. 48+0. 04=0. 52 Conditional Seismic Test Result Joint P(E∩H) =P(E | Hi) P(-)=P(-∩O)+P(-∩O’)=0. 12+0. 36=0. 48 Expert Systems sstseng 53

-Test +Test Probabilities P(-)=0. 48 P(+)=0. 52 Unconditional P (E) No Oil Oil P(O’|-)

-Test +Test Probabilities P(-)=0. 48 P(+)=0. 52 Unconditional P (E) No Oil Oil P(O’|-) P(O’|+) P(O|+) = (9)(4) = (2)(6) = (1)(4) = (8)(6) 0. 48 = 3/4 = 1/4 0. 52 = 1/13 Posterior of Site - P(Hi | E) P ( E| Hi) P (Hi) =    P(E) = 12/13 P(-∩O) P(+∩O) Joint -P(E∩H) =0. 36 =0. 04 =0. 12 =0. 48 =P(Hi | E) P(E) Expert Systems sstseng

 • • Oil release , if successful Drilling expense Seismic survey Expected payoff

• • Oil release , if successful Drilling expense Seismic survey Expected payoff (success) $1250000 -$200000 -$50000 • 846153=1000000 *12/13 – 1000000*1/13 • Fail • -500000= 1000000*1/4 - 1000000*3/4 • Expected payoff (total) • 416000= 846153*0. 52 – 50000 * 0. 48 Expert Systems sstseng 55

時態推論 (Temporal reasoning) 和Markov chain • 時態推論(Temporal reasoning): 推論的事 件和時間相關 • 時態邏輯(Temporal logic) •

時態推論 (Temporal reasoning) 和Markov chain • 時態推論(Temporal reasoning): 推論的事 件和時間相關 • 時態邏輯(Temporal logic) • The system’s progression through a sequence of status is called a Stochastic process(隨機過程) if it is probabilistic. Expert Systems sstseng 56

– P 11 P 12 – P 21 P 22 – Pmn 是指從狀態m轉換到狀態n的機率. S

– P 11 P 12 – P 21 P 22 – Pmn 是指從狀態m轉換到狀態n的機率. S = { P 1, P 2, …, Pn} where P 1+P 2+…+Pn= 1 S 2 = S 1 T S 2 = [0. 8, 0. 2] = [0. 2, 0. 8] 0. 1 0. 9 0. 6 0. 4 Expert Systems sstseng 57

The odds of belief • “這個病人渾身佈滿紅疹” • 提議A: “這個病人罹患麻疹” • P(A|B) : (在B事件下A成立的可信度)is not

The odds of belief • “這個病人渾身佈滿紅疹” • 提議A: “這個病人罹患麻疹” • P(A|B) : (在B事件下A成立的可信度)is not necessarily a probability if the events and propositions can not be repeated or has a math basis. Expert Systems sstseng 59

 • 在C事件下A, B相斥的機率 =P(A|C)/ P(B|C) • If B = A’ – odds =P(A|C)/

• 在C事件下A, B相斥的機率 =P(A|C)/ P(B|C) • If B = A’ – odds =P(A|C)/ P(A’|C) =P(A|C)/ (1 -P(A|C) ) • Likelihood of P = 0. 95 – Odds =. 95/(1 -. 95) = 19 to 1 Expert Systems sstseng 60

Sufficiency and necessity Bayes’ Theorem is P(E | H)P(H)        P(H|E) = P(E) Negation P(H’|E)

Sufficiency and necessity Bayes’ Theorem is P(E | H)P(H)        P(H|E) = P(E) Negation P(H’|E) = P(E | H’)P(H’)   P(E) Expert Systems sstseng   61

P(H | E)  P(E | H) P(H) = P(H’ | E)  P(E | H’)

P(H | E)  P(E | H) P(H) = P(H’ | E)  P(E | H’) P(H’) Defining the prior odds on H as     P(H) O(H) =     P(H’)       P(H | E) O(H | E) =       P(H’ | E) Likelihood ratio Expert Systems sstseng 62

   P(E | H) LS=    P(E | H’) O(H | E) = LS O(H) odds-likelihood

   P(E | H) LS=    P(E | H’) O(H | E) = LS O(H) odds-likelihood form of Bayes’ Theorem. The factor LS is also called likelihood of sufficiency because if LS =∞ then the evidence E is logically sufficient for concluding that H is true. Expert Systems sstseng 63

Likelihood of necessity, LN, is defined similarly to LS as P(H | E’)    O(H

Likelihood of necessity, LN, is defined similarly to LS as P(H | E’)    O(H | E’)  P(E’ | H)   P(H’ | E’) LN= = =     O(H)   P(E’ | H’)   P(H) P(H’) O(H | E’) = LN O(H) LN=0, then P(H | E’) = 0. This means that H must be false when E’ true. Thus if E is not present then H is false, which means that E is necessary for H. Expert Systems sstseng 64

LS     Effect on Hypothesis 0      H is false when E is true or      E’ is

LS     Effect on Hypothesis 0      H is false when E is true or      E’ is necessary for concluding H Small(0<LS<<1)    E is unfavorable for concluding H 1      E has no effect on belief of H Large(1<<LS)     E is favorable for concluding H       E is logically sufficient for H or      Observing E means H must be true Expert Systems sstseng 65

LN       Effect on Hypothesis 0    H is false when E is true or E

LN       Effect on Hypothesis 0    H is false when E is true or E is necessary for H small(0<LN<<1)  Absence of E is unfavorable for concluding H 1        Absence of E has no effect on H large(1<<LN)    Absence of E is favorable of H         Absence of E is logically sufficient for H Expert Systems sstseng

推論鏈中不確定性 (Uncertainty in inference chains) • Uncertainty may be present in rules, evidence used

推論鏈中不確定性 (Uncertainty in inference chains) • Uncertainty may be present in rules, evidence used by the rules, or both. Expert Systems sstseng 67

Expert Inconsistency If LS > 1 then P(E | H’) < P(E | H)

Expert Inconsistency If LS > 1 then P(E | H’) < P(E | H) 1 – P(E | H’) > 1 – P(E | H)    1 -P(E | H) LN=    1 -P(E | H’) <1 Case 1:LS>1 and LN <1 Case 2:LS<1 and LN >1 Case 3:LS= LN = 1 Expert Systems sstseng 68

Exercise 1. 考慮以下的事實與規則,試以前向鏈結和後向鏈結描 述其推論過程。 事實: A 1, A 2, A 3, A 4, B

Exercise 1. 考慮以下的事實與規則,試以前向鏈結和後向鏈結描 述其推論過程。 事實: A 1, A 2, A 3, A 4, B 1, B 2 規則: R 1: A 1 and A 3 --> C 2 R 2: A 1 and B 1 --> C 1 R 3: A 2 and C 2 --> D 2 R 4: A 3 and B 2 --> D 3 R 5: C 1 and D 2 --> G 1 R 6: B 1 and B 2 --> D 4 R 7: A 1 and A 2 and A 3 --> D 2 R 8: C 1 and D 3 --> G 2 R 9: C 2 and A 4 --> G 3 目標: G 1, G 2 and G 3 Expert Systems sstseng 69