Sei sulla pagina 1di 6

(This page contains course notes for Artificial Intelligence taught in the Autumn of 2015.

If you
have come here from a search engine or the like, you may wish to visit the course home page for
more material, or visit my home page for possibly more up to date versions.)

Introduction: AI in the Old School


The following is known as the the Einstein Puzzle or the Zebra Puzzle:

1. There are five houses. Each of the five houses is painted a different color, and their
inhabitants are of different national extractions, own different pets, drink different
beverages and smoke different brands of American cigarettes.
2. The Englishman lives in the red house.
3. The Spaniard owns the dog.
4. Coffee is drunk in the green house.
5. The Ukrainian drinks tea.
6. The green house is immediately to the right of the ivory house.
7. The Old Gold smoker owns snails.
8. Kools are smoked in the yellow house.
9. Milk is drunk in the middle house.
10. The Norwegian lives in the first house.
11. The man who smokes Chesterfields lives in the house next to the man with the fox.
12. Kools are smoked in the house next to the house where the horse is kept.
13. The Lucky Strike smoker drinks orange juice.
14. The Japanese smokes Parliaments.
15. The Norwegian lives next to the blue house.

Who drinks water? Who owns the zebra? (this version due to wikipedia) So, loosely, the practice
of Artificial Intelligence is the making of smart things. When trying to teach it we have the
unfortunate difficulty that "smart" is ill defined. What do you mean when you say "smart
things"? People spend a lot of time arguing about this, but frankly, that bores me. But we do
know examples of smart things. Smart things can solve the zebra puzzle. If a thing can't solve the
zebra puzzle, it's not smart. Thus if we want to make smart things, we better figure out how to
make things that can solve the puzzle. How do we do that? Let's first look at how we might solve
the puzzle:

 Lets build a table of what we know. Each cell contains a list of the possible values each
house might contain. We initially don't know where anything is:

Properties 1 2 3 4 5
Nationality ESUNJ ESUNJ ESUNJ ESUNJ ESUNJ
Color RGIYB RGIYB RGIYB RGIYB RGIYB
Drink CTMOW CTMOW CTMOW CTMOW CTMOW
Cigarette OKCLP OKCLP OKCLP OKCLP OKCLP
Pet DSFHZ DSFHZ DSFHZ DSFHZ DSFHZ
 Let's start applying some rules and crossing out possibilities, like 9, followed by 4, 5, and
13:

Properties 1 2 3 4 5
Nationality ESUNJ ESUNJ ESNJ ESUNJ ESUNJ
Color RGIYB RGIYB RIYB RGIYB RGIYB
Drink CTOW CTOW M CTOW CTOW
Cigarette OKCLP OKCLP OKCP OKCLP OKCLP
Pet DSFHZ DSFHZ DSFHZ DSFHZ DSFHZ

 Now, lets go with 6, then 4

Properties 1 2 3 4 5
Nationality ESUNJ ESUNJ ESNJ ESUNJ ESUNJ
Color RIYB RGIYB RIYB RGIYB RGYB
Drink TOW CTOW M CTOW CTOW
Cigarette OKCLP OKCLP OKCP OKCLP OKCLP
Pet DSFHZ DSFHZ DSFHZ DSFHZ DSFHZ

 10, 15,2,3,4,5,8,14

Properties 1 2 3 4 5
Nationality N SUJ ESJ ESUJ ESUJ
Color RIY B RIY RGIY RGY
Drink OW TOW M CTOW CTOW
Cigarette OKCL OCLP OKCP OKCLP OKCLP
Pet SFHZ DSFHZ DSFHZ DSFHZ DSFHZ

 2, then 6 (note that house 4 can't be red), then 2 again

Properties 1 2 3 4 5
Nationality N SUJ ESJ SUJ ESUJ
Color Y B RI GI RG
Drink OW TOW M CTOW CTOW
Cigarette OKCL OCLP OKCP OKCLP OKCLP
Pet SFHZ DSFHZ DSFHZ DSFHZ DSFHZ

 8, then 12,3,7,13

Properties 1 2 3 4 5
Nationality N UJ ESJ SUJ ESUJ
Color Y B RI GI RG
Drink W TO M CTO CTO
Cigarette K CLP OCP OCLP OCLP
Pet FZ H DSFZ DSFZ DSFZ

 Here, I get stuck. It doesn't appear there's anything left to apply. What we need to do is
try out some guesses, and see what comes of it. This is called searching because it's as if
we're looking around for the answer.
 Let's focus on the cigarette smoked in house 2. We have 3 choices, Lucky Strike,
Chesterfield, or Parliament. Lets try one, say, Lucky Strike, where we can apply 11, 13,
and 5:

Properties 1 2 3 4 5
Nationality N J ESJ SUJ ESUJ
Color Y B RI GI RG
Drink W O M CT CT
Cigarette K L OCP OCLP OCLP
Pet Z H DSF DSF DSF

 But rule 14 says the japanese should be smoking the Parliaments, not Lucky Strike! We
have a contradiction, and thus we can conclude that the man in house 2 does not smoke
Lucky Strikes.
 So, lets try Parliaments instead. We can then apply rules 14, and 5:

Properties 1 2 3 4 5
Nationality N J ESJ SUJ ESUJ
Color Y B RI GI RG
Drink W O M CTO CTO
Cigarette K P OCP OCLP OCLP
Pet FZ H DSFZ DSFZ DSFZ

 But rule 13 says that the Lucky Strike smoker drinks OJ, so we have another
contradiction. It must be that the Chesterfield smoker lives in house 2. We can then apply
rule 11:

Properties 1 2 3 4 5
Nationality N UJ ESJ SUJ ESUJ
Color Y B RI GI RG
Drink W TO M CTO CTO
Cigarette K C OP OLP OLP
Pet FZ H DSFZ DSZ DSZ

 We can also apply rule 13, followed by 5.


Properties 1 2 3 4 5
Nationality N U ESJ SJ ESJ
Color Y B RI GI RG
Drink W T M CO CO
Cigarette K C OP OLP OLP
Pet FZ H DSFZ DSZ DSZ

 But we're stuck again, aren't we? I guess we'll have to do more search. Let's go fox
hunting. What if the fox is in house 3? (wishful thinking since we would place the water
and the zebra in the same house)

Properties 1 2 3 4 5
Nationality N U ESJ SJ ESJ
Color Y B RI GI RG
Drink W T M CO CO
Cigarette K C OP OLP OLP
Pet Z H F DS DS

 We can apply rules 3 and 7 to clean up a little:

Properties 1 2 3 4 5
Nationality N U EJ SJ ESJ
Color Y B RI GI RG
Drink W T M CO CO
Cigarette K C P OL OL
Pet Z H F DS DS

 But we're stuck again. Let's try another guess. How about the Old Gold smoker? Let's try
him in house 4. We can then apply 7, 3, 2 and 13.

Properties 1 2 3 4 5
Nationality N U E J S
Color Y B R I G
Drink W T M C O
Cigarette K C P O O
Pet Z H F S D

 This has the Spaniard in green house 5 drinking OJ, but rule 4 says the green house
drinks coffee. Fail. OK, maybe the Old Gold smoker is in house 5. Then we apply 7, 3,
13, 4, 2.

Properties 1 2 3 4 5
Nationality N U E S J
Color Y B R I G
Drink W T M O C
Cigarette K C P L O
Pet Z H F D S

 But rule 14 says the Parliament smoker is Japanese. Another fail. So neither option
works, and our original guess at the location of fox was wrong. It must be in house 1.

Properties 1 2 3 4 5
Nationality N U ESJ SJ ESJ
Color Y B RI GI RG
Drink W T M CO CO
Cigarette K C OP OLP OLP
Pet F H DSZ DSZ DSZ

 Too bad that tells us almost nothing. Let's resolve the coffee. Try it in 4. That means we
can apply 4, 13, 2, 3,

Properties 1 2 3 4 5
Nationality N U SJ SJ E
Color Y B I G R
Drink W T M C O
Cigarette K C OP OP L
Pet F H DS DS Z

 So far, so good. Let's try the Spaniard in house 3. then apply 3 and 7.

Properties 1 2 3 4 5
Nationality N U S J E
Color Y B I G R
Drink W T M C O
Cigarette K C P O L
Pet F H D S Z

 But once again, we have a Japanese Old Gold smoker. Fail, try Spaniard in house 4. Rule
3, then 7

Properties 1 2 3 4 5
Nationality N U J S E
Color Y B I G R
Drink W T M C O
Cigarette K C O P L
Pet F H S D Z

 And one more fail, and another dead end. We must have guessed wrong on coffee. Let's
backtrack, and put coffee in house 5. We apply 4, 2, 3, 13, 7, 14, 14, 7, 3

Properties 1 2 3 4 5
Nationality N U E S J
Color Y B R I G
Drink W T M O C
Cigarette K C O L P
Pet F H S D Z

 And we're done. w00t.


 Your homework is posted, due next monday.

Potrebbero piacerti anche