Starting from:

$30

CSC421 Artificial Intelligence Assignment 3 Solved

Question 1
(p|q| − r)&((−r|q|p)− ((r|q)& − q& − p))

I

                         N          (p ∨ q∨qr) ∧ ((r∧qq∧qp) ∨ ((r ∨ q)∧qq∧qp))

D          (p ∨ q∨qr) ∧ (((r∧qq∧qp) ∨ (r ∨ q)) ∧ (((r∧qq∧qp)∨qq)) ∧ (((r∧qq∧qp)∨qp))) D       (p ∨ q∨qr) ∧ (((r ∨ r ∨ q) ∧ (qq ∨ r ∨ q) ∧ (qp ∨ r ∨ q)

∧ (r∨qq) ∧ (qq∨qq) ∧ (qp∨qq) ∧ (r∨qp) ∧ (qq∨qp) ∧ (qp∨qp)))

O

1      {p,q,qr}

2      {r,q}

3      {qq,r,q} 4  {qp,r,q}

5         {r,qq}

6         {qq}

7         {qp,qq}

8         {r,qp}

9         {qq,qp}

10      {qp}

Resolution

11      {p,q}

12      {p} 13      {}

Question 2
∃g(Greyhound(g) ∧ ∀r(Rabbit⇒ (r) ⇒ Faster(g,r))) ∀x∀y(Horse(x) ∧ Dog(y) Faster(x,y))

neg conclusion: q(∀x∀r(Horse⇒(x) ∧ Rabbit(r) ⇒ Faster(x,r))) ∀x∀r(Horse(x) ∧ Rabbit(r) Faster(x,r))

Now turn them to clausal form and do the resolution steps.

                  ∀x∀                                                          x,y))

            I     ∀x∀y(q((            (x) ∧           (y)) ∨               (x,y))

          N          ∀x∀y(qHorse(x)∨qDog(y) ∨ Faster(x,y))

E qHorse(x)∨qDog(y) ∨ Faster(x,y)

          O         {qHorse(x),qDog(y),Faster(x,y)}

I    ∃g(Greyhound(g) ∧ ∀r(qRabbit(r)⇒∨ Faster(g,r))) ∃g(Greyhound(g) ∧ ∀r(Rabbit(r)       Faster(g,r)))

           E           ∃g(Greyhound(g) ∧ (qRabbit(r) ∨ Faster(g,r)))

          A            Greyhound(Grey) ∧ (qRabbit(r) ∨ Faster(Grey,r)))

          O       {Greyhound(Grey)}

{qRabbit(r),Faster(Grey,r)}
Conclusion:

                     q(∀x∀r(Horse(x) ∧ Rabbit(r)            Faster(x,r)))

I q(∀x∀r(q((Horse(x) ∧ Rabbit(⇒r)) ∨ Faster(x,r)))

N q(∀x∀r(qHorse(x)∨qRabbit(r) ∨ Faster(x,r))) N         ∃x∃rq(qHorse(x)∨qRabbit(r) ∨ Faster(x,r)))

          N          ∃x∃r(Horse(x) ∧ Rabbit(r)∧qFaster(x,r))

           A            Horse(Happy) ∧ Rabbit(Rein)∧qFaster(Happy,Rein)

          O      {Horse(Happy)}

{Rabbit(Rein)}

{qFaster(Happy,Rein)}

And the backgroud knowledge:

∀g(Greyghound(g) ⇒ Dog(g))

∀x∀y∀z(Faster(x,y) ∧ Faster(y,z) ⇒ Faster(x,z))

                    ∀g(Greyghound(g)          Dog(g))

            I       ∀gqGreyghound(g)⇒∨ Dog(g))

A qGreyghound(g) ∨ Dog(g))

          O        {qGreyghound(g),Dog(g)}

I     x∀y∀z(q(Faster(x,y) ∧ Faster(y,z))⇒∨ Faster(x,z)) ∀x∀y∀z(Faster(x,y) ∧ Faster(y,z)       Faster(x,z))

          N           ∀y∀z(qFaster(x,y)∨qFaster(y,z) ∨ Faster(x,z))

A qFaster(x,y)∨qFaster(y,z) ∨ Faster(x,z)

          O           {qFaster(x,y),qFaster(y,z),Faster(x,z)}
Resolution:

1      {qHorse(x1),qDog(y1),Faster(x1,y1)}

2      {Greyhound(Grey)}

3      {qRabbit(r1),Faster(Grey,r1)}

4      {qGreyghound(g1),Dog(g1)}

5      {qFaster(x2,y2),qFaster(y2,z1),Faster(x2,z1)} 6        {Horse(Happy)}

7
{Rabbit(Rein)}
 
8
{qFaster(Happy,Rein)}
 
9
{Dog(Grey)}
2,4
10
{Faster(Grey,Rein)}
3,7
11
{qHorse(x1),Faster(x1,Grey)}
1,9
12
{Faster(Happy,Grey)}
6,11
13
{qFaster(Grey,z1),Faster(Happy,z1)}
5,12
14
{Faster(Happy,Rein)}
10,13
15
{}
8,14
Question 3
q∃y(Bird(y) ∧ Large(y⇒) ∧ LiveonHon(y)) ∀x(Hummingbird(x)         Richcolor(x))

∀y(Bird(y)∧qLiveonHon(y) qRichcolor(y))

∀x(Hummingbird(x) ⇒⇒ Bird⇒(x)) (Background) ∀x(Hummingbird(x) qLarge(x)) (Conlusion)

Prover 9:

1(allx(hummingbird(x)− richcolor(x)))[assumption].

2(allx − (bird(x)&large(x)&liveonhon(x)))[assumption].

3(allx(bird(x)& − liveonhon(x)− −richcolor(x)))[assumption].

4(allx(hummingbird(x)− bird(x)))[assumption].

5(allx(hummingbird(x)− −large(x)))[goal].

6hummingbird(c1).[deny(5)].

7  − hummingbird(x)|richcolor(x).[clausify(1)].

8  − hummingbird(x)|bird(x).[clausify(4)].

9bird(c1).[resolve(6,a,8,a)].

10 − bird(x)| − large(x)| − liveonhon(x).[clausify(2)].

11 − bird(x)|liveonhon(x)| − richcolor(x).[clausify(3)].

12 − large(c1)| − liveonhon(c1).[resolve(9,a,10,a)].

13large(c1).[deny(5)].

14liveonhon(c1)| − richcolor(c1).[resolve(9,a,11,a)].

15richcolor(c1).[resolve(6,a,7,a)].

16liveonhon(c1).[resolve(14,b,15,a)].

17 − liveonhon(c1).[resolve(12,a,13,a)].

18$F.[resolve(16,a,17,a)].

Question 4
mg = My gardener; wl = worth listening to on military subjects; ar = able to remember the battle of waterloo; old=very old

∃x(person(x) ∧ mg(x) ∧ wl(x)).

             ∀y((person(y) ∧ ar(y))           old(y)).

∀z((person(z) ∧ wl(z)) ⇒ar(z)).

∃m(person(x) ∧ mg(m)⇒∧ old(m)).(conclusion)

Prover 9:

1(existsx(person(x)&mg(x)&wl(x)))[assumption].

2(allx(person(x)&ar(x)− old(x)))[assumption].

3(allx(person(x)&wl(x)− ar(x)))[assumption].

4(existsm(person(m)&mg(m)&old(m)))[goal].

5 − person(x)| − ar(x)|old(x).[clausify(2)].

6person(c1).[clausify(1)].

7  − person(x)| − wl(x)|ar(x).[clausify(3)].

8  − person(x)| − mg(x)| − old(x).[deny(4)].

9  − mg(c1)| − old(c1).[resolve(8,a,6,a)].

10mg(c1).[clausify(1)].

11 − wl(c1)|ar(c1).[resolve(7,a,6,a)].

12wl(c1).[clausify(1)].

13ar(c1).[resolve(11,a,12,a)].

14 − ar(c1)|old(c1).[resolve(5,a,6,a)].

15old(c1).[resolve(13,a,14,a)].

16 − old(c1).[resolve(9,a,10,a)].

17$F.[resolve(15,a,16,a)].

Question 5
P(P13) = P(P22) = P(P31) = 0.01

P(p13|b12,b21) = αX22 X(P(b12|p13,p22) · P(b21|p22,p31) · P(p13) · P(p22) · P(p31))

                                             p        p31

= α[P(b12|p13,p22) · P(b21|p22,p31) · P(p13) · P(p22) · P(p31)+

P(b12|p13,qp22) · P(b21|qp22,p31) · P(p13) · P(qp22) · P(p31)+

P(b12|p13,p22) · P(b21|p22,qp31) · P(p13) · P(p22) · P(qp31)+

P(b12p13,p22) · P(b21|qp22,qp31) · P(p13) · P(qp22) · P(qp31)]

= α[1 · 1 · 0.01 · 0.01 · 0.01 + 1 · 1 · 0.01 · 0.99 · 0.01+

1 · 1 · 0.01 · 0.01 · 0.99 + 0] = α(0.000001 + 0.000099 + 0.000099) = 0.000199α

P(qp13|b12,b21) = αX22 X(P(b12|qp13,p22) · P(b21|p22,p31) · P(qp13) · P(p22) · P(p31))

                                             p        p31

= α[P(b12|qp13,p22) · P(b21|p22,p31) · P(qp13) · P(p22) · P(p31)+

P(b12|qp13,qp22) · P(b21|qp22,p31) · P(qp13) · P(qp22) · P(p31)+

P(b12|qp13,p22) · P(b21|p22,qp31) · P(qp13) · P(p22) · P(qp31)+

P(b12|qp13,p22) · P(b21|qp22,qp31) · P(qp13) · P(qp22) · P(qp31)]

= α[1 · 1 · 0.99 · 0.01 · 0.01 + 0 + 1 · 1 · 0.99 · 0.01 · 0.99 + 0)

= α(0.000099 + 0.009801) = 0.0099α

α = 1/(0.000199 + 0.0099) = 99.02

P(p13|b12,b21) = 0.0197

P(qp13|b12,b21) = 0.9803

P(p31|b12,b21) = αX13 X(P(b12|p13,p22) · P(b21|p22,p31) · P(p13) · P(p22) · P(p31))

                                             p        p22

= 0.0197

P(qp31|b12,b21) = αX13 X(P(b12|p13,p22) · P(b21|p22,qp31) · P(p13) · P(p22) · P(qp31))

                                             p        p22

= 0.9803

P(p22|b12,b21) = αX13 X(P(b12|p13,p22) · P(b21|p22,p31) · P(p13) · P(p22) · P(p31))

                                             p        p31

= α[P(b12|p13,p22) · P(b21|p22,p31) · P(p13) · P(p22) · P(p31)+

P(b12|qp13,p22) · P(b21|p22,p31) · P(qp13) · P(p22) · P(p31)+

P(b12|p13,p22) · P(b21|p22,qp31) · P(p13) · P(p22) · P(qp31)+

P(b12|qp13,p22) · P(b21|p22,qp31) · P(qp13) · P(p22) · P(qp31)]

= α(1 · 1 · 0.01 · 0.01 · 0.01 + 1 · 1 · 0.01 · 0.01 · 0.99

+ 1 · 1 · 0.01 · 0.01 · 0.99 + 1 · 1 · 0.99 · 0.01 · 0.99)

= 0.01α

P(qp22|b12,b21) = αX13 X(P(b12|p13,qp22) · P(b21|qp22,p31) · P(p13) · P(qp22) · P(p31))

                                             p        p31

= α[P(b12|p13,qp22) · P(b21|qp22,p31) · P(p13) · P(qp22) · P(p31)+

P(b12|qp13,qp22) · P(b21|qp22,p31) · P(qp13) · P(qp22) · P(p31)+

P(b12|p13,qp22) · P(b21|qp22,qp31) · P(p13) · P(qp22) · P(qp31)+

P(b12|qp13,qp22) · P(b21|qp22,qp31) · P(qp13) · P(qp22) · P(qp31)]

= α(1 · 1 · 0.01 · 0.99 · 0.01 + 0 + 0 + 0) = 0.000099α

α = 1/(0.01 + 0.000099) = 99.02

P(p22|b12,b21) = 0.9902

P(qp22|b12,b21) = 0.0098

Going to [2,2] is almost certain death. So, a probabilistic agent will never choose to go to [2,2]. On the other hand, to a logical agent, squares [1,3], [2,2], [3,1] look the same. So, the logical agent would choose either one with equal chance (1/3). By doing that, the agent will die with a chance of about 1/3.

Question 6
1

 

2

 

3

P(happy|party,smart,qcreative)

= αXXXX [P(happy,mac,success,hw,project,party,smart,qcreative)]

mac project hw success

= αXXXX [P(happy|mac,success,party) · P(mac|qcreative,smart)·

mac project hw success

P(success|project,hw) · P(hw|party,smart) · P(project|qcreative,smart)·

P(party) · P(smart) · P(qcreative)]

= αP(party) · P(smart) · P(qcreative) · X ·P(project|qcreative,smart)

project

X
X P(happy|mac,success,party) · P(mac|qcreative,smart)·

 mac hw success

P(success|project,hw) · P(hw|party,smart)

= αP(party) · P(smart) · P(qcreative) · X ·P(project|qcreative,smart)

project

[P(happy|mac,success,party) · P(mac|qcreative,smart)·

P(success|project,hw) · P(hw|party,smart)+

P(happy|qmac,success,party) · P(qmac|qcreative,smart)·

P(success|project,hw) · P(hw|party,smart)+

P(happy|mac,success,party) · P(mac|qcreative,smart)·

P(success|project,qhw) · P(qhw|party,smart)+

P(happy|mac,qsuccess,party) · P(mac|qcreative,smart)·

P(qsuccess|project,hw) · P(hw|party,smart)+

P(happy|qmac,qsuccess,party) · P(qmac|qcreative,smart)·

P(qsuccess|project,hw) · P(hw|party,smart)+

P(happy|qmac,success,party) · P(qmac|qcreative,smart)·

P(success|project,qhw) · P(qhw|party,smart)+

P(happy|mac,qsuccess,party) · P(mac|qcreative,smart)·

P(qsuccess|project,qhw) · P(qhw|party,smart)+

P(happy|qmac,qsuccess,party) · P(qmac|qcreative,smart)·

P(qsuccess|project,qhw) · P(qhw|party,smart)]

= 0.692

P(qhappy|party,smart,qcreative)

= αXXXX [P(qhappy,mac,success,hw,project,party,smart,qcreative)]

mac project hw success

= αXXXX [P(qhappy|mac,success,party) · P(mac|qcreative,smart)·

mac project hw success

P(success|project,hw) · P(hw|party,smart) · P(project|qcreative,smart)·

P(party) · P(smart) · P(qcreative)]

= αP(party) · P(smart) · P(qcreative) · X ·P(project|qcreative,smart)

project

X
X P(qhappy|mac,success,party) · P(mac|qcreative,smart)·

 mac hw success

P(success|project,hw) · P(hw|party,smart)

= αP(party) · P(smart) · P(qcreative) · X ·P(project|qcreative,smart)

project

[P(qhappy|mac,success,party) · P(mac|qcreative,smart)·

P(success|project,hw) · P(hw|party,smart)+

P(qhappy|qmac,success,party) · P(qmac|qcreative,smart)·

P(success|project,hw) · P(hw|party,smart)+

P(qhappy|mac,success,party) · P(mac|qcreative,smart)·

P(success|project,qhw) · P(qhw|party,smart)+

P(qhappy|mac,qsuccess,party) · P(mac|qcreative,smart)·

P(qsuccess|project,hw) · P(hw|party,smart)+

P(qhappy|qmac,qsuccess,party) · P(qmac|qcreative,smart)·

P(qsuccess|project,hw) · P(hw|party,smart)+

P(qhappy|qmac,success,party) · P(qmac|qcreative,smart)·

P(success|project,qhw) · P(qhw|party,smart)+

P(qhappy|mac,qsuccess,party) · P(mac|qcreative,smart)·

P(qsuccess|project,qhw) · P(qhw|party,smart)+

P(qhappy|qmac,qsuccess,party) · P(qmac|qcreative,smart)·

P(qsuccess|project,qhw) · P(qhw|party,smart)]

= 0.308

4

P(happy|smart,creative) = 0.58156

5

P(happy|qparty,hw,project) = 0.32045

6

P(happy|mac) = 0.56272

7

P(party|smart) = 0.6022

8

P(party|smart,happy) = 0.79265

More products