5105 AI Propositional Logic
5105 AI Propositional Logic
5105 AI Propositional Logic
Lecture (5)
Propositional Logic
Propositions: Example
Today is Monday
The grass is wet
It is raining
proposition = statement
Logic = the study of the logic relationships between objects
Propositions are connected by logical operators.
Precedence of Operators
Operator Precedence
() 1
¬ 2
∧ 3
Ⅴ 4
⇒ 5
⇔ 6
E.g ¬p Λq = (¬p ) Λq
p Λq Ⅴ r = (p Λq ) Ⅴ r
10
ㅡ p Ⅴ q Λr = p Ⅴ (q Λr)
17
Faculty of Computer Science 9
Faculty of Computer Science 10
Propositional Logic: Syntax and Semantics
E.g., “Maria will find a good job when she learns discrete mathematics.”
“If Maria learns discrete mathematics, then she will find a good
job.”
Propositional Logic: Syntax and Semantics
Exercise 2.3
LP & AI
Modus Ponens
Resolution rule, A ∨ B, ¬B ∨ C
A∨C
A ∨ B, B ⇒ C
(resolvent)
A∨C
If A is false then ?
12
ㅡ
18
Resolution
implementation simpler
24 search space is reduced and computation time
ㅡ
17 decreased.
Proof Systems and Resolution
Formalization
Resolution Transformation
Proof into normal form
Proof
25
ㅡ
17
• Example 2.2
• Despite studying English for seven long years with brilliant success, I
must admit that when I hear English people speaking English I'm
totally perplexed.
• Recently, moved by noble feelings, I picked up three hitchhikers, a
father, mother, and daughter, who I quickly realized were English and
only spoke English. At each of the sentences that follow I wavered
between two possible interpretations. They told me the following (the
second possible meaning is in parentheses):
• The father: We are going to Spain (we are from Newcastle). The
mother: We are not going to Spain and are from Newcastle (we
stopped in Paris and are not going to Spain). The daughter: We are not
from Newcastle (we stopped in Paris). What about this charming
English family?
• (S)8 is added.
• Res(2, 8) : ()9
• ¬S ∧ N ∧ P holds.
Formalization:
• The first girl’s jump succeeds: A, First girl’s bet: (A ⇔ ¬B),
• the second girl’s jump succeeds: B, second girl’s bet: (B ⇔ ¬C),
• the third girl’s jump succeeds: C. third girl’s bet: (C ⇔ ¬A).
Claim: the three cannot all win their bets:
Q≡¬((A ⇔ ¬B) ∧ (B ⇔ ¬C) ∧ (C ⇔ ¬A))
It must now be shown by resolution that ¬Q is unsatisfiable.
Clauses
Case Study: Answer
Formalization
• The first girl’s jump succeeds: A,
First girl’s bet: (A ⇔ ¬B),
• The second girl’s jump succeeds: B,
Second girl’s bet: (B ⇔ ¬C),
• The third girl’s jump succeeds: C.
Third girl’s bet: (C ⇔ ¬A).
30
ㅡ
17 Claim: the three cannot all win their bets:
Q≡¬((A ⇔ ¬B) ∧ (B ⇔ ¬C) ∧ (C ⇔ ¬A))
Horn LP & AI
Clauses
Case Study: Answer
CNF
Clauses
Case Study: Answer
Resolution Proof
Res(1, 6) : (C ∨¬B)7
Res(4, 7) : (C)8
Res(2, 5) : (B ∨¬C)9
Res(3, 9) : (¬C)10
Res(8, 10) : ()
32
ㅡ
17
Horn Clauses
clause in CNF (¬A1 ∨・・・∨¬Am ∨ B1 ∨・・・∨Bn) ≡or (equivalently)
A1 ∧・・・∧Am⇒B1 ∨・・・∨Bn
e.g., “If the weather is nice and there is snow on the ground, I will go skiing
or I will work.”
The receiver of this message knows for certain that the sender is not going
swimming.
• “If the weather is nice and there is snow on the ground, I will go skiing.”.
The receiver now knows definitively.
• clauses with at most one positive literal is called definite clauses.
• These clauses have the advantage that they only allow one conclusion and
are thus distinctly simpler to interpret.
Clauses
Horn Clauses : Definition
Clauses
(nice_weather)1 (snowfall⇒snow)3
(nice_weather ∧
(snowfall)2 snow⇒skiing)4
to know whether skiing holds, let’s use generalized modus ponens as an inference rule
A1 ∧・・・∧Am, A1 ∧・・・∧Am⇒B
B
MP(2, 3) : (snow)5 MP(1, 5, 4) : (skiing)6
1 In this case, modus ponens can derive many unnecessary formulas if one begins with
the wrong clauses.
7
— 2 Modus ponens use forward chaining systems, which start with facts and finally derive
19 the query
Horn LP & AI
Clauses
Backward Chaining
ㅡ
37 breadth first search depth first search
17
infinite number of Reasonable number of
possible conclusions possible final answers
Horn LP & AI
Clauses
SLD Resolution Proof
(nice_weather)1
(snowfall)2
(snowfall⇒snow)3
(nice_weather ∧ snow⇒skiing)4
(skiing⇒f )5
38
ㅡ
17 Res(5, 4) : (nice_weather ∧
snow⇒f )6
Res(6, 1) : (snow⇒f )7
Res(7, 3) : (snowfall⇒f )8
Res(8, 2) : ()
Horn Clauses LP & AI
Clauses
Applications and Limitations
• propositional logic is
employed in simple
applications
Application
Clauses
Exercise
Clauses
Exercise
2 Transform to CNF
(¬P ∨ Q ∨ S ∨ T)1 ∧
(¬T)2 ∧ (¬Q)3 ∧
43
ㅡ
17
Horn LP & AI
Clauses
Exercise
3 Resolution Proof
Res(4,1) : ¬U ∨ T ∨ ¬S,¬P ∨ Q ∨ S ∨ T
(¬U ∨ T ∨ ¬P ∨ Q)7
Res(7,5) : ¬U ∨ T ∨ ¬P ∨ Q, ¬U ∨ T ∨ P
(¬U ∨ T ∨ Q)8
Res(8,3) : ¬U ∨ T ∨ Q, ¬Q
(¬U ∨ T) 9
44 Res(9,2) : ¬U ∨ T, ¬T
ㅡ (¬U) 10
17
Res(6,10): ()
Horn LP & AI
Clauses
Practice
• For example, simple expert systems can certainly work with propositional logic.
• However, the variables must all be discrete, with only a few values, and there
may not be any cross relations between variables.