Ass3-Solutions

advertisement
Assignment 3 Solutions
CSE2309/3309 CSC2091/3091 - Artificial Intelligence
CSE2309/3309 CSC2091/3091
Artificial Intelligence - Assignment 3
(Propositional Logic and First Order Predicate Calculus)
Solutions from Richard Nichols and Lam Phuong Lam
Question 1
F: The French team will win at least one gold medal.
G: The German team will win at least one gold medal.
D: The Danish team will win at least one gold medal.
P: The French team is plagued with injuries.
S: The star German runner is disqualified.
R: It rains during most of the competition.
F G D
F  G  D
a. At least one (of the three teams) will win a gold medal.
b. At most one of them will win a gold medal.
( F  G  D )  (F  G  D )  (F  G  D )  (F  G  D )
( F  G  D )  (F  G  D )  (F  G  D )  (F  G  D )
or
( F  (G  D))  (G  (F  D))  ( D  (G  F ))
c. Exactly one of them will win a gold medal.
( F  G  D )  (F  G  D )  (F  G  D )
(G  [D  F ])  ( D  [G  F ])  ( F  [D  G ])
d. Provided it doesn't rain during most of the competition and their star runner isn't
disqualified, the Germans will win a gold medal if either of the other teams does.
( R  S  ( F  D ) )  G
( F

D)

(( R

S )

G)
e. The Germans will win a gold medal only if it doesn't rain during most of the competition and
their star runner is not disqualified.
G

( R
 S )
( R  S )  G (AN: Note "only if" is opposite direction to "if")
Page 1
Assignment 3 Solutions
CSE2309/3309 CSC2091/3091 - Artificial Intelligence
Question 2
a.
(Smoke  Fire)  (Smoke  Fire)
Convert to clausal form:
: (Smoke  Fire)  (Smoke  Fire)
=  (Smoke  Fire)  (Smoke  Fire)
= (Smoke  Fire)  Smoke  Fire
Now construct truth table:
Smoke
T
T
F
F
Fire
T
F
T
F
Fire
F
T
F
T
Smoke  Fire
F
T
F
F
(Smoke  Fire)  Smoke  Fire
T
T
F
T
From the result column it can be seen that this expression is neither valid nor unsatisfiable.
b.
Smoke  Fire Fire
Already in clausal form: Smoke  Fire Fire
Now construct truth table:
Smoke
T
T
F
F
Fire
T
F
T
F
Fire
F
T
F
T
Smoke  Fire Fire
T
T
T
T
From the result column it can be seen that this expression is always true, therefore -- valid.
Page 2
Assignment 3 Solutions
c.
CSE2309/3309 CSC2091/3091 - Artificial Intelligence
[(Smoke  Heat)  Fire]  [(Smoke  Fire)  (Heat  Fire)]
Convert to clausal form:
: [(Smoke  Heat)  Fire]  [(Smoke  Fire)  (Heat  Fire)]
= [(Smoke  Heat)  Fire]  [(Smoke  Fire)  (Heat  Fire)]
= (Smoke  Heat  Fire)  (Smoke  Fire  Heat  Fire)
= (Smoke  Heat  Fire)  (Smoke  Fire  Heat)
= Smoke  Heat  Fire
Now construct truth table:
Heat
Smoke
Fire
Smoke
Heat
T
T
T
T
F
F
F
F
T
T
F
F
T
T
F
F
T
F
T
F
T
F
T
F
F
F
T
T
F
F
T
T
F
F
F
F
T
T
T
T
Smoke  Heat
 Fire
T
F
T
T
T
T
T
T
From the result column it can be seen that this expression is neither valid nor unsatisfiable.
d.
{[Smoke  Fire]  [(Smoke  Heat)  Fire]}
Convert to clausal form:
: {[Smoke  Fire]  [(Smoke  Heat)  Fire]}
= {[Smoke  Fire]  [(Smoke  Heat)  Fire]}
= {[Smoke  Fire]  [(Smoke  Heat)  Fire]}
= [Smoke  Fire]  [Smoke  Heat  Fire]
= [Smoke  Fire]  [Smoke  Heat  Fire]
= (Smoke  Fire)  Smoke  Heat  Fire
Now construct truth table:
Heat
Smoke
Fire
Smoke
Fire
T
T
T
T
F
F
F
F
T
T
F
F
T
T
F
F
T
F
T
F
T
F
T
F
F
F
T
T
F
F
T
T
F
T
F
T
F
T
F
T
Smoke 
Fire
T
F
T
T
T
F
T
T
(Smoke  Fire)  Smoke
 Heat  Fire
F
F
F
F
F
F
F
F
From the result column it can be seen that this expression is always false, therefore unsatisfiable.
Page 3
Assignment 3 Solutions
CSE2309/3309 CSC2091/3091 - Artificial Intelligence
Question 3
If the rain continues, then the river rises. If rain continues and the river rises, then the bridge will wash out.
If continuation of rain will wash the bridge out, then a single road is not sufficient for the town. Either a
single road is sufficient for the town or the traffic engineers have made a mistake. Prove the traffic
engineers have made a mistake.
Symbols:
- Rain continues.
- River rises.
- Bridge washes out.
- Single road is not enough.
- Engineers have made a mistake.
C
R
B
S
E
Axioms:
1.
2.
3.
CR
(R  C)  B
(C  B)  S
C  R
R  C  B
Or
Or
Or
(C  B)  S =
(C  B)  S =
(S  C)  (S  B)
- (S  C)
- (S  B)
S  E
So:
3.1
3.2
4.
SE
Or
Required to Prove: E
C  R ,  R   C  B
C  C  B
 C  C  B
2.
C  B
C  B , C  S
3.
BS
B  S , B  S
4.
S
S  E, S
5.
E
1.
Used resolution because R and R can't both be true.
Eliminated one C.
Used resolution because C and C can't both be true.
Used resolution because B and B can't both be true.
Used Modus Ponens.
Result: The engineers made a mistake.
Quad Erat Demonstrandum - It is proven!
Page 4
Assignment 3 Solutions
CSE2309/3309 CSC2091/3091 - Artificial Intelligence
Question 4
If Mr. Smith is the brakeman's next-door neighbor, then Mr. Smith lives halfway between Detroit and
Chicago. If Mr. Smith lives halfway between Detroit and Chicago, then he does not live in Chicago. Mr.
Smith is the brakeman's next-door neighbor. If Mr. Robinson lives in Detroit, then he does not live in
Chicago. Mr. Robinson lives in Detroit. Mr. Smith lives in Chicago or else either Mr. Robinson or Mr.
Jones lives in Chicago. If Mr. Jones lives in Chicago, then the brakeman is Jones. Prove the brakeman is
Jones.
Symbols:
SN
SH
SC
RD
RC
JC
JB
- Mr Smith is Brakeman's next door neighbour.
- Mr Smith lives halfway between Detroit and Chicago.
- Mr Smith lives in Chicago.
- Mr Robinson lives in Detroit.
- Mr Robinson lives in Chicago.
- Mr Jones lives in Chicago.
- Mr Jones is the brakeman.
Axioms:
1 : SN
2 : RD
3 : SN  SH
4 : SH  SC
5 : RD  RC
6 : SC  ( RC  JC )
7 : JC  JB
Required to Prove: JB
SN  SH , SN
SH
SH  SC , SH
2:
SC
SC  ( RC  JC ), SC
3:
RC  JC
RD  RC , RD
4:
RC
RC  JC , RC
5:
JC
JC  JB, JC
6:
JB
1:
Result: Mr Smith lives halfway between Detroit and Chicago.
Result: Mr Smith doesn't live in Chicago.
Result: Mr Robinson or Mr Jones live in Chicago.
Result: Mr Robinson doesn't live in Chicago.
Result: Therefore Mr Jones lives in Chicago.
Result: Mr Jones is the Brakeman.
Quad Erat Demonstrandum - It is proven!
Page 5
Assignment 3 Solutions
CSE2309/3309 CSC2091/3091 - Artificial Intelligence
Question 5
Show by a resolution refutation that the following formulas is a tautology:
(P  Q)  [(R v P)  (R v Q)]
First must expand into clausal form:
( P  Q)  [( R  P)  ( R  Q)]
 (P  Q)  [( R  P)  ( R  Q)]
 ( P   Q )  ( R  P )  R  Q
Now negate the whole expression, ready to perform resolution:
: (( P  Q)  (R  P)  R  Q)
 (P  Q)  ( R  P)  R  Q
Now take each term and perform resolution:
( R  P)
( P  Q )
( P  Q )
( R  P)
R
P
Q
R
Q
P
P
P
nil
The negation of the statement we're trying to prove has evaluated to nil , therefore the inverse (the original
statement) must be a tautology. Quad Erat Demonstrandum.
Page 6
Assignment 3 Solutions
CSE2309/3309 CSC2091/3091 - Artificial Intelligence
Question 6
Represent the following English sentences using predicate calculus:
a.
Every chicken hatched from an egg.
x y ( ( chicken(x)  egg(y) )  hatchedFrom(x,y) )
or simply: x y ( hatchedFrom(x,y) )
b.
Someone profited from the Great Depression.
x ( person(x)  profitedFrom(x,GreatDepression) )
or simply: x ( profitedFrom(x,GreatDepression) )
c.
Some language is spoken by everyone in this room.
y x ( ( language(y)  person(x)  inThisRoom(x) )  spoke(x,y) )
or simply: y x ( inThisRoom(x)  spoke(x,y) )
d.
One of the coats in the closet belongs to Sarah.
x ( coat(x)  inCloset(x)  belongsTo(Sarah) )
e.
All people are created equal.
X Y ([person(x)  person(y)  xy]  createdEqual(x,y) )
f.
Everybody loves somebody sometime.
x y t ( ( person(x)  person(y)  time(t) )  loves(x,y,t) )
g.
An apple a day keeps the doctor away.
d ( (day(d)  a (apple(a)  eat(a,d) ))  t visitDoctor(x,t) )
Page 7
Assignment 3 Solutions
CSE2309/3309 CSC2091/3091 - Artificial Intelligence
Question 7
Prove the validity of the following wff using the method of resolution refutation:
X Y [P(f(X))  Q(f(B))]  [P(f(A))  P(Y)  Q(Y)]
Convert the WFF to a clause:
1.
Eliminate "" and "".
X Y [P(f(X))  Q(f(B))]  [P(f(A))  P(Y)  Q(Y)]
2.
Move "" in as far as possible.
X Y [P(f(X))  Q(f(B))]  [P(f(A))  P(Y)  Q(Y)]
X Y [P(f(X))  Q(f(B))]  [P(f(A))  P(Y)  Q(Y)]
X Y P(f(X))  Q(f(B))  [P(f(A))  P(Y)  Q(Y)]
3.
Eliminate "".
Let X equal a constant "x" and Y equal a constant "f(x)".
P(f(x))  Q(f(B))  [P(f(A))  P(f(x))  Q(f(x))]
4.
Eliminate "". - No need.
5.
Put into Clausal form. - No need.
The final statement in clausal form: P(f(x))  Q(f(B))  [P(f(A))  P(y)  Q(y)].
Now negate the clause for resolution:
{P(f(x))  Q(f(B))  [P(f(A))  P(f(x))  Q(f(x))]} =
{P(f(x))  Q(f(B))  [P(f(A))  P(f(x))  Q(f(x))]} =
{P(f(x1))  Q(f(B))  [P(f(A))  P(f(x2))  Q(f(x2))]}
Resolution:
P(f(x1))
P(f(A))  P(f(x2))  Q(f(x2))
Q(f(B))
{x2/B}
P(f(A))  P(f(B))
{x1/B}
P(f(A))
{x1/A}
nil
Page 8
The negation of the statement
we're trying to prove has
evaluated to nil , therefore the
inverse (the original statement)
must be valid.
Quad Erat Demonstrandum.
Assignment 3 Solutions
CSE2309/3309 CSC2091/3091 - Artificial Intelligence
Question 8
Prove using resolution refutation that Fido will die, given the axioms:
1. Fido is a dog.
2. All dogs are animals.
3. All animals will die.
Axioms:
1.
2.
3.
dog(Fido).
X dog(X)  animal(X).
X animal(X)  dies(X).
Required to prove: dies(Fido)
So negate the goal and try to make a contradiction. Therefore add "  dies(Fido)" to the list of axioms and
begin resolution:
Final (clausal) list of axioms:
1.
2.
3.
4.
dog(Fido).
dog(X1)  animal(X1).
animal(X2)  dies(X2).
dies(Fido).
Resolution:
dog(Fido)
dog(X1)  animal(X1)
animal(X1)  dies(X1)
dies(Fido)
{X2/X1}
dog(X1)  dies(X1)
{X1/Fido}
dog(Fido)
nil
The negation of the statement we're trying to prove has evaluated to nil , therefore the inverse (the original
statement) must be true. Quad Erat Demonstrandum.
Page 9
Assignment 3 Solutions
CSE2309/3309 CSC2091/3091 - Artificial Intelligence
Question 9
Anyone passing his or her CSE1303 exam and winning the lottery is happy. But anyone who studies or is
lucky can pass all his or her exams. Mary did not study but she is lucky. Anyone who is lucky wins the
lottery. Is Mary happy? Use resolution refutation to prove your answer.
Represent the axioms in predicate calculus:
1.
2.
3.
4.
5.
X ([pass(X, CSE1303)  win(X, lotto)]  happy(X))
X Y ([studies(X)  lucky(X)]  pass(X, Y))
studies(Mary)
lucky(Mary)
X (lucky(X)  win(X, lotto))
Convert axioms to clauses:
1.
2.
3.
4.
5.
Eliminate 
Convert to CNF
Eliminate 
Eliminate 
Convert to CNF
Eliminate 
and split.
Nothing to do.
Nothing to do.
Eliminate 
Eliminate 
X [pass(X, CSE1303)  win(X, lotto)]  happy(X)
X pass(X, CSE1303)  win(X, lotto)  happy(X)
pass(X, CSE1303)  win(X, lotto)  happy(X)
X Y ([studies(X)  lucky(X)]  pass(X, Y))
X Y ([studies(X)  lucky(X)]  pass(X, Y))
X Y ([studies(X)  pass(X, Y)]  [lucky(X)  pass(X, Y)])
2.1. studies(X)  pass(X, Y)
2.2. lucky(X)  pass(X, Y)
studies(Mary)
lucky(Mary)
X (lucky(X)  win(X, lotto))
lucky(X)  win(X, lotto)
And we wish to prove: happy(Mary)
So negate the goal and try to make a contradiction. Therefore add "happy(Mary)" to the list of axioms.
Final list of axioms: (with variables renamed)
1.
2.
3.
4.
5.
6.
7.
pass(X1, CSE1303)  win(X1, lotto)  happy(X1)
studies(X2)  pass(X2, Y1)
lucky(X3)  pass(X3, Y2)
studies(Mary)
lucky(Mary)
lucky(X4)  win(X4, lotto)
happy(Mary)
Page 10
Assignment 3 Solutions
pass(X1, CSE1303) 
win(X1, lotto)  happy(X1)
CSE2309/3309 CSC2091/3091 - Artificial Intelligence
happy(Mary)
{X1/Mary}
pass(Mary, CSE1303) 
win(Mary, lotto)
lucky(X3) 
pass(X3, Y2)
studies(Mary)
lucky(Mary)
lucky(X4)  win(X4,
lotto)
studies(X2) 
pass(X2, Y1)
{X4/Mary}
{X3/Mary}
win(Mary, lotto)
pass(Mary, Y2)
{Y2/CSE1303}
win(Mary, lotto)
nil
The negation of the statement we're trying to prove has evaluated to nil , therefore the inverse (the original statement) must be true. Quad Erat Demonstrandum.
Page 11
Richard Nichols - ID#12602930
Assignment III
CSE2309 - Artificial Intelligence
Question 10
All people who are not poor and are smart are happy. Those people who read are not stupid. John can read
and is wealthy. Happy people have exciting lives. Can anyone be found with an exciting life? Use
resolution refutation to prove your answer.
Represent the axioms in predicate calculus:
1.
2.
3.
4.
5.
X ([poor(X)  stupid(X)]  happy(X))
X (reads(X)  stupid(X))
reads(John)
poor(John)
X (happy(X)  exciting(life, X))
Convert axioms to clauses:
1.
2.
3.
4.
5.
Eliminate 
Convert to CNF
Eliminate 
Eliminate 
Eliminate 
Nothing to do.
Nothing to do.
Eliminate 
Eliminate 
X ( [poor(X)  stupid(X)]  happy(X))
X (poor(X)  stupid(X)  happy(X))
poor(X)  stupid(X)  happy(X)
X (reads(X)  stupid(X))
reads(X)  stupid(X)
reads(John)
poor(John)
X (happy(X)  exciting(life, X))
happy(X)  exciting(life, X)
And we wish to prove: X exciting(life, X)
So negate the goal and try to make a contradiction. Therefore add "exciting(life, X)" to the list of axioms.
Final list of axioms: (renamed variables)
1.
2.
3.
4.
5.
6.
poor(X1)  stupid(X1)  happy(X1)
reads(X2)  stupid(X2)
reads(John)
poor(John)
happy(X3)  exciting(life, X3)
exciting(life, X4)
Page 12
Richard Nichols - ID#12602930
poor(X1)  stupid(X1)  happy(X1)
{X1/John}
Assignment III
reads(X2)  stupid(X2)
CSE2309 - Artificial Intelligence
reads(John)
poor(John)
{X2/John}
happy(X3)  exciting(life, X3)
exciting(life, X4)
{X4/X3}
happy(X3
)
stupid(John)
{X3/John}
poor(John)  happy(John)
happy(John)
nil
The negation of the statement we're trying to prove has evaluated to nil , therefore the inverse (the original statement) must be true. Quad Erat Demonstrandum.
Page 13
Download