Vous êtes sur la page 1sur 7

1 1ARTIFICIAL INTELLIGENCE (CS331/CS531) ARTIFICIAL INTELLIGENCE (CS331/CS531)

ASSIGNMENT 2 ASSIGNMENT 2
SOLUTION SOLUTION
(There can be many different answers to each question, the solutions shows only
one of the correct answer)
1. Translate the following English sentences into first-order logic formulas. Invent a
suitable vocabulary
a) Some students take A!
X((student(X) ^ takes_ADB(X))
b) Every student who takes A! "asses it
X((student(X)^takes_ADB(Xasses(X))
c) #o good student flunks an e$am
!X(("ood_student(X) ^ flunks_e#am(X))
d) !rothers are siblings %e$"ress the fact that &sibling' is a symmetric
relation)
X$(brother(X,$)^bother($,X) )siblin"s(X,$))
e) (arry and )otter are friends
friends(harry,otter) ^ friends(otter , harry)
f) *ne+s mother is one+s female "arent
X$( mother_of(X,$) % female(X) ^ arent(X,$))
g) A cousin is a child of a "arent+s sibling
X$(cousin (X,$) ) &
' (( arent_of ((,$) ^ siblin" (',() ^ arent_of (',X) ^
! (')()))
h) Every "erson has only one mother
X $ * (mother_of (X,*) ^ mother_of($,*) & X ) $)
i) If it isn+t cloudy tomorrow, (arry will go to the -oo and will not take his
umbrella with him.
! cloudy (tomorrow) & "o (harry , +oo) ^ ! takes (harry, umbrella)
.) Some birds are crows but no birds are s/uirrels
X ( (bird(X) ^ crow (X) ) ^ ! * ( birds(*) ^ squirrel (*))
k) If one or more lives are lost then all lives are lost
X (life (X) ^ lost (X) ) & $ (life ($) & lost ($))
0amous 1uotations2
l) 3ou can fool some "eo"le all of the time, and all of the "eo"le some of
the time, but you cannot fool all of the "eo"le all of the time.
X ( eole (X) ^ time (T) & can_fool (X)) ^
$ , ( time ($) ^ eole (,) & can_fool (,)) ^
( eole (() ^ time (') & ! can_fool(())
m) All for one, and one for all4
($ X is-or(X,$) ) ^ ( $ X is-or(X,$))
n) If you5re not for us, you5re against us.
$ X ! is-or(X,$) & $ X isA"ainst(X,$)
o) The enemy of your enemy is your friend.
* $ X (enemy(X,$) ^ enemy($,*) & friend(X,*) )
6. Translate the following formulas into natural English, according to their intuitive
intended meaning2
a) 7%male%7) 8 female%7))
./eryone is either a male or a female
b) 7 %%father%7) 9 male%7)) : %mother%7) 9 female%7)))
./ery father is a male and e/ery mother is a female
c) ;7%father%7) : mother%7))
'o one can be both a father and a mother
<. Argue why 7 3 0%7, 3) is not logically e/uivalent to 3 7 0%7, 3). =omment on
the formula 0%7, 3) > mother%7, 3).
X $ -(X, $) means that there e#ists a articular X for A00 $1 That is, there is
some one who is the mother of e/eryone1
2n the other hand, $ X -(X, $) means that for A00 $ there e#ists some X1 That
is, e/eryone has a mother1
?. (anging !asket )roblem
@e have a basket hanger with three hooks %a to", middle, and bottom hook). @e have a
green, blue, and yellow basket, and we can hang one on each hook. Each of the
baskets can contain one kind of fruit2 a""les, "eaches, and lemons. The following should
hold true2
The to" basket holds lemons.
The blue basket is hanging somewhere
below the basket containing the "eaches.
The yellow basket is hanging somewhere
above the green basket.
S"ecify the re"resentation of the states, o"erators, goal, start state and cost function.
3tates4 There is ossibility to han" the basket in 56 ways on the /arious hooks1
Also the fruits can be resent in 56 ways in the different baskets1 Therefore, total
number of ossible states 56 X 56 ) 7 X 7 ) 57
2erators4 8an"in" a basket on a articular hook, mo/in" u 9 down a basket,
uttin" 9 takin" out fruit
:oal4
,lacin" Basket -ruit
To $ellow 0emons
(iddle :reen ,eaches
Bottom Blue Ales
3tart 3tate4 Any of the 57 states
2;
Baskets emty And 'ot hun"
<ost -unction4 'umber of actions to achie/e the "oal state
A. Bissionaries and =annibals
There are three missionaries and three cannibals on the left bank of a river.
They wish to cross over to the right bank using a boat that can only carry two at a
time.
The number of cannibals on either bank must never e$ceed the number of
missionaries on the same bank, otherwise the missionaries will become the
cannibals5 dinner4
a) S"ecify the re"resentation of the states, o"erators, goal, start state and cost
function.
b) )lan a se/uence of crossings that will take everyone safely across.
3tates4 A state could be
(CannibalLeft, MissionaryLeft, BoatPos, CannibalRight, MissionaryRight)
(=, =, ;>:8T, ?, ?)
ie. 2 cannibals and 2 missionaries on the left bank of the river, the boat is on the
right side, together ith ! cannibal and ! missionary
2erators4 A cannibal or missionary can either mo/e to the left or the ri"ht of the
ri/er1 A le"al mo/e is one which in/ol/es mo/in" u to two eole to the oosite
bank (such that cannibals don@t outnumber missionaries on either bank)1
:oal4 5 missionaries, 5 cannibals on the ri"ht side of the ri/er1
3tart4 5 missioniaries, 5 cannibals on the left side of the ri/er1
<ost function4 Deendin" on the state reresentation, the rocedure with which
the cost function is e/aluated may /ary1 <an be ? unit for each mo/ement until
"oal state1
C. A new o"erator, , or e$clusive-or, may be defined by the following truth table2
) 1
) 1
T T 0
T 0 T
0 T T
0 0 0
=reate a "ro"ositional calculus e$"ression using only :, 8 and ; that is e/uivalent to
) 1. )rove their e/uivalence using truth tables.
, A , A !, !A , ^ !A !, ^ A (, ^ !A) B (!, ^ A)
T T - - - - - -
T - T - T T - T
- T T T - - T T
- - - T T - - -
(, A) ) ((P ^ !A) B (!P ^ A))
D. )rove that im"lication is transitive in the "ro"ositional calculus, that is, that
%%)91) : %1 9 E)) 9 %) 9 E)
, A ; ,&A A&; ((,&A) ^ (A &
;))
,&A ((,&A) ^ (A & ;)) &
(, & ;)
T T T T T T T T
T T - T - - - T
T - T - T - T T
T - - - T - - T
- T T T T T T T
- T - T - - T T
- - T T T T T T
- - - T T T T T
3ince there is no counter e#amle (i1e1 no case in which ((,&A) ^ (A & ;)) & (, &
;) is false) which shows that imlication is transiti/e1
F. Attem"t to unify the following "airs of e$"ressions. Either show their most general
unifiers or e$"lain why they will not unify.
a) "%7,3) and "%a,G)
C a 9 X , $ 9 * D
b) "%7,7) and "%a,b)
<anEt be unified
c) ancestor%7,3) and ancestor%bill, father%bill))
C bill 9 X , father(bill) 9 $ D
d) ancestor%7,father%7)) and ancestor%david,george)
e) /%7) and ;/%a)
<anEt be unified
H. a) =om"ose the substitution sets IaJ7, 3JGK and I7J@, bJ3K
3? ) Ca9X , $9*D
3= ) CX9F, b9$D
3?13=
?) Aly 3= to 3?
3?= ) Cb9*D
Add elements of 3? ) Cb9*, a9XD
=) Add 3= to 3?
3?= ) Cb9* , a9X, X9F , b9$D
5) 3?= ) Cb9* , a9F , b9$D
3=13?
?) Aly 3? to 3=
3=? ) Ca9FD
Add elements of 3= ) Ca9F, b9$D
=) Add 3? to 3=
3=? ) Ca9F , b9$, a9X , $9*D
5) 3=? ) Ca9F , b9$, a9X , $9*D
b) )rove that com"osition of substitution sets is associative
Associati/e ,roerty4 #1(y1+) ) (#1y)1+
3? ) a9b 35 ) c9a 3G ) d9c
3? X 3= ) c9b (3? X 3=) X 35 ) c9b X d9e ) d9b
3= X 35 ) d9a (3= X 35) X 3? ) d9a X a9b ) d9b
Therefore, comosition is associati/e
c) =onstruct an e$am"le to show that com"osition is not commutative
-rom Ha) we can see that 3?= I 3=? therefore, comosition is not
commutati/e
1L. @rite a set of logical "redicates that will "erform sim"le automobile diagnostics %e.g.
if the engine wont turn over and the lights wont come on, then the battery is bad). on+t
try to be too elaborate, but cover the cases of bad battery, out of gas, bad s"ark "lugs
and bad starter motor.
! resent (en"ine_ower) ^ ! resent (li"ht) & bad (battery)
! resent (en"ine_ower) ^ ! resent (sarks) & bad (sarks_lu"s)
! resent (en"ine_ower) ^ ! resent(bad_started_motor) &bad(sark_lu"s)
! resent (en"ine_ower) ^ ! resent (turn_on) & bad (out_of_"as)
1
1
1
(other similar redicates)
11. I married a widow %lets call her @) who has a grown-u" daughter %call her ). By
father %0), who visited us /uite often, fell in love with my ste" daughter and married her.
(ence, my father became my son-in-law and my ste"-daughter became my mother.
Some months later, my wife gave birth to a son %S1), who became the brother-in-law of
my father, as well as my uncle. The wife of my father, that is, my ste" daughter, also had
a son %S6).
Msing "redicate calculus create a series of e$"ressions that re"resent the situation in the
above story. Add e$"ressions defining basic family relations such as the definition of
father-in-law and use modus "onens on this system to "rove the conclusion that &I am
my own grand daughter'.
?1 father (X,$) ^ father ($,*) & "randfather (X,*)
=1 father (X,$) ^ married ($,*) & fatherJinJlaw (X,*)
51 father (X,$) ^ mother ($,*) & "randfather (X,*)
G1 father (X,$) ^ father (X,*) & brother ($,*)
K1 brother (X,$) ^ "randfather (*,$) & "randfather (*,X)
71 married (>,F)
L1 married (-,D)
M1 father (>,3?)
H1 father (>,D)
?N1father (-,3=)
??1father (-,>)
?=1mother (D,3=)
?51"randfather(>,3=)
O3>': 54
H ^ ?= & "randfather (>, 3=) (;.3O0T ?)
O3>': G4
?N ^ ?? & brother (3=,>) (;.3O0T =)
O3>': K4 brother (X,$) ^ "randfather (*,$) & "randfather (*,X)
;esult= ^ ;esult?
brother (> , 3=) ^ "randfather (>, 3=) & "randfather (>, >)
T8.;.-2;., > A( ($ 2F' :;A'D-AT8.;
'ote4J .ach question can ha/e /arious answers, the solution has only shown one
of them6

Vous aimerez peut-être aussi