How to Solve the Zebra Problem - University College Corkcsweb.ucc.ie/~dongen/ZEBRA.pdf · How to...
Transcript of How to Solve the Zebra Problem - University College Corkcsweb.ucc.ie/~dongen/ZEBRA.pdf · How to...
How to Solve the Zebra Problem
M.R.C. van Dongen
Delivered 15 June 2001. Re-designed 12 October 2002.
Problem Formulation
There are five houses of different colours, inhabited by different
nationals, with different pets, drinks, and sports.
Furthermore, there are the following 14 additional constraints which
I have changed for the occasion:
1. The Englishman lives in the red house.
2. The Spaniard owns a dog.
3. The man in the green house drinks coffee.
4. The Irishman drinks tea.
5. The green house is to the right of the ivory house.
6. The Go player owns snails.
7. The man in the yellow house plays cricket.
8. The guy in the house int he middle drinks milk.
9. The Nigerian lives in the first house.1
10. The judo player lives next to the man who has a fox.
11. The cricketer lives next to the man who has a horse.
12. The poker player drinks orange juice.
13. The Japanese plays polo.1Originally, this was “at the end” but this would make the problem too easy.
14. The Nigerian lives next to the blue house.
14. The Nigerian lives next to the blue house.
The question is:
14. The Nigerian lives next to the blue house.
The question is: Who owns the zebra
14. The Nigerian lives next to the blue house.
The question is: Who owns the zebra and who drinks Guinness?
Some History
According to folklore, the Zebra Problem was designed by the
English logician Charles Lutwidge Dodgson (a.k.a. Lewis Carroll.
Born: 27 Jan 1832, Died: 14 Jan 1898).
Some History
According to folklore, the Zebra Problem was designed by the
English logician Charles Lutwidge Dodgson (a.k.a. Lewis Carroll.
Born: 27 Jan 1832, Died: 14 Jan 1898). I don’t have a reference. If
you do, then please let me know.
Modeling the Problem
We can model the problem as a CSP. We number the houses (left to
right) from 1 to 5. We then assign houses to things and we reduce
the problem to the following:
• The number assigned to the person who drinks Guinness is the
same as the number assigned to Guinness;
• The number assigned to the person who owns the zebra is the
same as the number assigned to the zebra.
nationalities Englishman = A1, Spaniard = A2, Irishman = A3,
Nigerian = A4, Japanese = A5.
plays go = B1, cricket = B2, judo = B3, poker = B4, polo = B5.
drinks coffee = C1, tea = C2, milk = C3, orange juice = C4,
Guinness = C5,
pets dog = D1, snails = D2, fox = D3, horse = D4, zebra = D5.
colours red = E1, green = E2, ivory = E3, yellow = E4, blue =E5.
If X is a letter then Xi 6= Xj ⇐⇒ i 6= j. Furthermore, we have:
1. The Englishman (A1) lives in the red (E1) house: A1 = E1.
2. The Spaniard (A2) owns a dog (D1): A2 = D1.
3. The man in the green (E2) house drinks coffee (C1): E2 = C1.
4. The Irishman (A3) drinks tea (C2): A3 = C2.
5. The green (E2) house is to the right of the ivory (E3) house:
E2 − E3 = 1.
6. The Go (B1) player owns snails (D2): B1 = D2.
7. The man in the yellow (E4) house plays cricket (B2): E4 = B2.
8. The guy in the house in the middle drinks milk (C3): C3 = 3.
9. The Nigerian (A4) lives in the first house: A4 = 1.
10. The Judo (B3) player lives next to the man who has a fox (D3):
|B3 −D3 | = 1.
11. The cricketer (B2) lives next to the man who has a horse (D4):
|B2 −D4 | = 1.
12. The poker (B4) player drinks orange juice (C4): B4 = C4.
13. The Japanese (A5) plays polo (B5): A5 = B5.
14. The Nigerian (A4) lives next to the blue (E5) house: |A4−E5 | = 1.
12345
A1
12
34
5
A2
12345
A3
12
34
5
A41 2 3 4 5A5
12
34
5
B1
12345
B2
1 2 3 4 5B3
12345
B4
12
34
5
B5
12345
C1
12
34
5
C2
12
34
5
C3
1 2 3 4 5C4
12345
C5
12345
D1
1 2 3 4 5D2
12
34
5
D3
12
34
5
D4
12345
D5
12
34
5
E1
12345
E2
12345
E3
1 2 3 4 5E4
12
34
5
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
Initial CSP.
12345
A1
12
34
5
A2
12345
A3
12
34
5
A41 2 3 4 5A5
12
34
5
B1
12345
B2
1 2 3 4 5B3
12345
B4
12
34
5
B5
12345
C1
12
34
5
C2
12
34
5
C3
1 2 3 4 5C4
12345
C5
12345
D1
1 2 3 4 5D2
12
34
5
D3
12
34
5
D4
12345
D5
12
34
5
E1
12345
E2
12345
E3
1 2 3 4 5E4
12
34
5
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
Because of the unary constraints (Rules 8 and 9) A4
must be 1 and C3 must be 3.
12345
A1
12
34
5
A2
12345
A3
12
34
5
A41 2 3 4 5A5
12
34
5
B1
12345
B2
1 2 3 4 5B3
12345
B4
12
34
5
B5
12345
C1
12
34
5
C2
12
34
5
C3
1 2 3 4 5C4
12345
C5
12345
D1
1 2 3 4 5D2
12
34
5
D3
12
34
5
D4
12345
D5
12
34
5
E1
12345
E2
12345
E3
1 2 3 4 5E4
12
34
5
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
We can remove the red values.
12345
A1
12
34
5
A2
12345
A3
1A
41 2 3 4 5A5
12
34
5
B1
12345
B2
1 2 3 4 5B3
12345
B4
12
34
5
B5
12345
C1
12
34
5
C2
3
C3
1 2 3 4 5C4
12345
C5
12345
D1
1 2 3 4 5D2
12
34
5
D3
12
34
5
D4
12345
D5
12
34
5
E1
12345
E2
12345
E3
1 2 3 4 5E4
12
34
5
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
The resulting CSP is called Node-Consistent.
12345
A1
12
34
5
A2
12345
A3
1A
41 2 3 4 5A5
12
34
5
B1
12345
B2
1 2 3 4 5B3
12345
B4
12
34
5
B5
12345
C1
12
34
5
C2
3
C3
1 2 3 4 5C4
12345
C5
12345
D1
1 2 3 4 5D2
12
34
5
D3
12
34
5
D4
12345
D5
12
34
5
E1
12345
E2
12345
E3
1 2 3 4 5E4
12
34
5
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
Some Values have no Support.
12345
A1
12
34
5
A2
12345
A3
1A
41 2 3 4 5A5
12
34
5
B1
12345
B2
1 2 3 4 5B3
12345
B4
12
34
5
B5
12345
C1
12
34
5
C2
3
C3
1 2 3 4 5C4
12345
C5
12345
D1
1 2 3 4 5D2
12
34
5
D3
12
34
5
D4
12345
D5
12
34
5
E1
12345
E2
12345
E3
1 2 3 4 5E4
12
34
5
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
Let’s mark them for removal and colour them red.
12345
A1
12
34
5
A2
12345
A3
1A
41 2 3 4 5A5
12
34
5
B1
12345
B2
1 2 3 4 5B3
12345
B4
12
34
5
B5
12345
C1
12
34
5
C2
3
C3
1 2 3 4 5C4
12345
C5
12345
D1
1 2 3 4 5D2
12
34
5
D3
12
34
5
D4
12345
D5
12
34
5
E1
12345
E2
12345
E3
1 2 3 4 5E4
12
34
5
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
If we propagate the consequences of removing thered values, more values will lose support.
2345
A1
23
45
A2
2345
A3
1A
42 3 4 5A5
12
34
5
B1
12345
B2
1 2 3 4 5B3
12345
B4
12
34
5
B5
12
45
C1
12
45
C2
3
C3
1 2 4 5C4
12
45
C5
12345
D1
1 2 3 4 5D2
12
34
5
D3
12
34
5
D4
12345
D5
12
34
5
E1
2345
E2
1234
E3
1 2 3 4 5E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
Remove and Propagate.
2345
A1
23
45
A2
2345
A3
1A
42 3 4 5A5
12
34
5
B1
12345
B2
1 2 3 4 5B3
12345
B4
12
34
5
B5
12
45
C1
12
45
C2
3
C3
1 2 4 5C4
12
45
C5
12345
D1
1 2 3 4 5D2
12
34
5
D3
12
34
5
D4
12345
D5
12
34
5
E1
2345
E2
1234
E3
1 2 3 4 5E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
Remove and Propagate.
2345
A1
23
45
A2
2
45
A3
1A
42 3 4 5A5
12
34
5
B1
12345
B2
1 2 3 4 5B3
12
45
B4
23
45
B5
2
45
C1
24
5
C2
3
C3
1 2 4 5C4
12
45
C5
2345
D1
1 2 3 4 5D2
12
34
5
D3
12
34
5
D4
12345
D5
34
5
E1
45
E2
1
34
E3
1 3 4 5E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
More Propagation.
2345
A1
23
45
A2
2
45
A3
1A
42 3 4 5A5
12
34
5
B1
12345
B2
1 2 3 4 5B3
12
45
B4
23
45
B5
2
45
C1
24
5
C2
3
C3
1 2 4 5C4
12
45
C5
2345
D1
1 2 3 4 5D2
12
34
5
D3
12
34
5
D4
12345
D5
34
5
E1
45
E2
1
34
E3
1 3 4 5E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
More Values will lose Support.
345
A1
23
45
A2
2
45
A3
1A
42 3 4 5A5
12
34
5
B1
1
345
B2
1 2 3 4 5B3
12
45
B4
23
45
B5
45
C1
24
5
C2
3
C3
1 2 4 5C4
12
45
C5
2345
D1
1 2 3 4 5D2
12
34
5
D3
12
34
5
D4
12345
D5
34
5
E1
45
E2
34
E3
1 3 4 5E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
More Propagation. . .
345
A1
23
45
A2
2
45
A3
1A
42 3 4 5A5
12
34
5
B1
1
345
B2
1 2 3 4 5B3
12
45
B4
23
45
B5
45
C1
24
5
C2
3
C3
1 2 4 5C4
12
45
C5
2345
D1
1 2 3 4 5D2
12
34
5
D3
23
45
D4
12345
D5
34
5
E1
45
E2
34
E3
1 3 4 5E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
We have reached a Fix-point
345
A1
23
45
A2
2
45
A3
1A
42 3 4 5A5
12
34
5
B1
1
345
B2
1 2 3 4 5B3
12
45
B4
23
45
B5
45
C1
24
5
C2
3
C3
1 2 4 5C4
12
45
C5
2345
D1
1 2 3 4 5D2
12
34
5
D3
23
45
D4
12345
D5
34
5
E1
45
E2
34
E3
1 3 4 5E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
The resulting CSP is called Arc-consistent.
345
A1
23
45
A2
2
45
A3
1A
42 3 4 5A5
12
34
5
B1
1
345
B2
1 2 3 4 5B3
12
45
B4
23
45
B5
45
C1
24
5
C2
3
C3
1 2 4 5C4
12
45
C5
2345
D1
1 2 3 4 5D2
12
34
5
D3
23
45
D4
12345
D5
34
5
E1
45
E2
34
E3
1 3 4 5E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
E4’s domain contains 1.
345
A1
23
45
A2
2
45
A3
1A
42 3 4 5A5
12
34
5
B1
1
345
B2
1 2 3 4 5B3
12
45
B4
23
45
B5
45
C1
24
5
C2
3
C3
1 2 4 5C4
12
45
C5
2345
D1
1 2 3 4 5D2
12
34
5
D3
23
45
D4
12345
D5
34
5
E1
45
E2
34
E3
1 3 4 5E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
The domains of the other Ei do not contain 1.
345
A1
23
45
A2
2
45
A3
1A
42 3 4 5A5
12
34
5
B1
1
345
B2
1 2 3 4 5B3
12
45
B4
23
45
B5
45
C1
24
5
C2
3
C3
1 2 4 5C4
12
45
C5
2345
D1
1 2 3 4 5D2
12
34
5
D3
23
45
D4
12345
D5
34
5
E1
45
E2
34
E3
1 3 4 5E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
E4 must be 1.
345
A1
34
5
A2
2
45
A3
1A
42 3 4 5A5
34
5
B1
1
B2
2 3 4 5B3
2
45
B4
23
45
B5
45
C1
24
5
C2
3
C3
2 4 5C4
12
45
C5
345
D1
3 4 5D2
13
45
D3
2
D4
1
345
D5
34
5
E1
45
E2
34
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
After Assignment E4 = 1 and Arc-Consistency.
345
A1
34
5
A2
2
45
A3
1A
42 3 4 5A5
34
5
B1
1
B2
2 3 4 5B3
2
45
B4
23
45
B5
45
C1
24
5
C2
3
C3
2 4 5C4
12
45
C5
345
D1
3 4 5D2
13
45
D3
2
D4
1
345
D5
34
5
E1
45
E2
34
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
C5’s domain contains 1.
345
A1
34
5
A2
2
45
A3
1A
42 3 4 5A5
34
5
B1
1
B2
2 3 4 5B3
2
45
B4
23
45
B5
45
C1
24
5
C2
3
C3
2 4 5C4
12
45
C5
345
D1
3 4 5D2
13
45
D3
2
D4
1
345
D5
34
5
E1
45
E2
34
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
The domains of the other Ci do not contain 1.
345
A1
34
5
A2
2
45
A3
1A
42 3 4 5A5
34
5
B1
1
B2
2 3 4 5B3
2
45
B4
23
45
B5
45
C1
24
5
C2
3
C3
2 4 5C4
12
45
C5
345
D1
3 4 5D2
13
45
D3
2
D4
1
345
D5
34
5
E1
45
E2
34
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
C5 must be 1.
345
A1
34
5
A2
2
45
A3
1A
42 3 4 5A5
34
5
B1
1
B2
2 3 4 5B3
2
45
B4
23
45
B5
45
C1
24
5
C2
3
C3
2 4 5C4
1
C5
345
D1
3 4 5D2
13
45
D3
2
D4
1
345
D5
34
5
E1
45
E2
34
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
After Assignment C5 = 1 and Arc-Consistency.
345
A1
34
5
A2
2
45
A3
1A
42 3 4 5A5
34
5
B1
1
B2
2 3 4 5B3
2
45
B4
23
45
B5
45
C1
24
5
C2
3
C3
2 4 5C4
1
C5
345
D1
3 4 5D2
13
45
D3
2
D4
1
345
D5
34
5
E1
45
E2
34
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
Start MAC-Search (Maintain Arc-Consistency).
345
A1
34
5
A2
2
45
A3
1A
42 3 4 5A5
34
5
B1
1
B2
2 3 4 5B3
2
45
B4
23
45
B5
45
C1
24
5
C2
3
C3
2 4 5C4
1
C5
345
D1
3 4 5D2
13
45
D3
2
D4
1
345
D5
34
5
E1
45
E2
34
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
Select C1 as Current Variable.
5
A1
34
A2
2
A3
1A
43 4A5
34
B1
1
B2
2 3 4B3
5
B43
4
B5
4
C1
2
C2
3
C3
5C4
1
C5
34
D1
3 4D2
13
45
D3
2
D4
1
345
D5
5
E1
4
E2
3
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
After Assignment C1 = 4 and Arc-Consistency.
5
A1
34
A2
2
A3
1A
43 4A5
34
B1
1
B2
2 3 4B3
5
B43
4
B5
4
C1
2
C2
3
C3
5C4
1
C5
34
D1
3 4D2
13
45
D3
2
D4
1
345
D5
5
E1
4
E2
3
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
Select B1 as Current Variable.
A1
A2
A3
A4A5
B1
B2
B3
B4
B5
C1
C2
C3
C4
C5
D1
D2
D3
D4
D5
E1
E2
E3
E4
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
After Assignment B1 = 3 and Arc-Consistency.
A1
A2
A3
A4A5
B1
B2
B3
B4
B5
C1
C2
C3
C4
C5
D1
D2
D3
D4
D5
E1
E2
E3
E4
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
All domains are empty. We must backtrack on B1.
5
A1
34
A2
2
A3
1A
43 4A5
34
B1
1
B2
2 3 4B3
5
B43
4
B5
4
C1
2
C2
3
C3
5C4
1
C5
34
D1
3 4D2
13
45
D3
2
D4
1
345
D5
5
E1
4
E2
3
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
Next Assignment to B1.
A1
A2
A3
A4A5
B1
B2
B3
B4
B5
C1
C2
C3
C4
C5
D1
D2
D3
D4
D5
E1
E2
E3
E4
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
After Assignment B1 = 4 and Arc-Consistency.
A1
A2
A3
A4A5
B1
B2
B3
B4
B5
C1
C2
C3
C4
C5
D1
D2
D3
D4
D5
E1
E2
E3
E4
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
We must backtrack on C1.
345
A1
34
5
A2
2
45
A3
1A
42 3 4 5A5
34
5
B1
1
B2
2 3 4 5B3
2
45
B4
23
45
B5
45
C1
24
5
C2
3
C3
2 4 5C4
1
C5
345
D1
3 4 5D2
13
45
D3
2
D4
1
345
D5
34
5
E1
45
E2
34
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
Next Assignment to C1.
3
A1
45
A2
2
4
A3
1A
42 4 5A5
34
5
B1
1
B2
2 3 4 5B3
2
4
B4
24
5
B5
5
C1
24
C2
3
C3
2 4C4
1
C5
45
D1
3 4 5D2
13
45
D3
2
D4
1
345
D5
3
E1
5
E2
4
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
After Assignment C1 = 5 and Arc-Consistency.
3
A1
45
A2
2
4
A3
1A
42 4 5A5
34
5
B1
1
B2
2 3 4 5B3
2
4
B4
24
5
B5
5
C1
24
C2
3
C3
2 4C4
1
C5
45
D1
3 4 5D2
13
45
D3
2
D4
1
345
D5
3
E1
5
E2
4
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
Select B4 as Current Variable.
A1
A2
A3
A4A5
B1
B2
B3
B4
B5
C1
C2
C3
C4
C5
D1
D2
D3
D4
D5
E1
E2
E3
E4
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
After Assignment B4 = 2 and Arc-Consistency.
A1
A2
A3
A4A5
B1
B2
B3
B4
B5
C1
C2
C3
C4
C5
D1
D2
D3
D4
D5
E1
E2
E3
E4
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
Backtrack on B4.
3
A1
45
A2
2
4
A3
1A
42 4 5A5
34
5
B1
1
B2
2 3 4 5B3
2
4
B4
24
5
B5
5
C1
24
C2
3
C3
2 4C4
1
C5
45
D1
3 4 5D2
13
45
D3
2
D4
1
345
D5
3
E1
5
E2
4
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
Next Assignment to B4.
3
A1
4
A2
2
A3
1A
45A5
3
B1
1
B2
2B3
4
B45
B5
5
C1
2
C2
3
C3
4C4
1
C5
4
D1
3D2
1D
3
2
D4
5
D5
3
E1
5
E2
4
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
After Assignment B4 = 4 and Arc-Consistency.
3
A1
4
A2
2
A3
1A
45A5
3
B1
1
B2
2B3
4
B45
B5
5
C1
2
C2
3
C3
4C4
1
C5
4
D1
3D2
1D
3
2
D4
5
D5
3
E1
5
E2
4
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
All domains are singletons.
3
A1
4
A2
2
A3
1A
45A5
3
B1
1
B2
2B3
4
B45
B5
5
C1
2
C2
3
C3
4C4
1
C5
4
D1
3D2
1D
3
2
D4
5
D5
3
E1
5
E2
4
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
All constraints are satisfied.
3
A1
4
A2
2
A3
1A
45A5
3
B1
1
B2
2B3
4
B45
B5
5
C1
2
C2
3
C3
4C4
1
C5
4
D1
3D2
1D
3
2
D4
5
D5
3
E1
5
E2
4
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
We have solved the problem.
3
A1
4
A2
2
A3
1A
45A5
3
B1
1
B2
2B3
4
B45
B5
5
C1
2
C2
3
C3
4C4
1
C5
4
D1
3D2
1D
3
2
D4
5
D5
3
E1
5
E2
4
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
D5 = 5 (the zebra).
3
A1
4
A2
2
A3
1A
45A5
3
B1
1
B2
2B3
4
B45
B5
5
C1
2
C2
3
C3
4C4
1
C5
4
D1
3D2
1D
3
2
D4
5
D5
3
E1
5
E2
4
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
D5 = 5 (the zebra). A5 = 5 (the Japanese).
3
A1
4
A2
2
A3
1A
45A5
3
B1
1
B2
2B3
4
B45
B5
5
C1
2
C2
3
C3
4C4
1
C5
4
D1
3D2
1D
3
2
D4
5
D5
3
E1
5
E2
4
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
D5 = 5 (the zebra). A5 = 5 (the Japanese).Therefore, the Japanese owns the zebra.
3
A1
4
A2
2
A3
1A
45A5
3
B1
1
B2
2B3
4
B45
B5
5
C1
2
C2
3
C3
4C4
1
C5
4
D1
3D2
1D
3
2
D4
5
D5
3
E1
5
E2
4
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
To some this may have come as a complete surprise.
3
A1
4
A2
2
A3
1A
45A5
3
B1
1
B2
2B3
4
B45
B5
5
C1
2
C2
3
C3
4C4
1
C5
4
D1
3D2
1D
3
2
D4
5
D5
3
E1
5
E2
4
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
C5 = 1 (Guinness).
3
A1
4
A2
2
A3
1A
45A5
3
B1
1
B2
2B3
4
B45
B5
5
C1
2
C2
3
C3
4C4
1
C5
4
D1
3D2
1D
3
2
D4
5
D5
3
E1
5
E2
4
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
C5 = 1 (Guinness). A4 = 1 (the Nigerian).
3
A1
4
A2
2
A3
1A
45A5
3
B1
1
B2
2B3
4
B45
B5
5
C1
2
C2
3
C3
4C4
1
C5
4
D1
3D2
1D
3
2
D4
5
D5
3
E1
5
E2
4
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
C5 = 1 (Guinness). A4 = 1 (the Nigerian).Therefore, the Nigerian drinks Guinness.
3
A1
4
A2
2
A3
1A
45A5
3
B1
1
B2
2B3
4
B45
B5
5
C1
2
C2
3
C3
4C4
1
C5
4
D1
3D2
1D
3
2
D4
5
D5
3
E1
5
E2
4
E3
1E4
2
E5
A1 EnglishmanA2 SpaniardA3 IrishmanA4 NigerianA5 JapaneseB1 goB2 cricketB3 judoB4 pokerB5 poloC1 coffeeC2 teaC3 milkC4 orangejuiceC5 GuinnessD1 dogD2 snailsD3 foxD4 horseD5 zebraE1 redE2 greenE3 ivoryE4 yellowE5 blue
Given that Lagos has a large Guinness brewery, thisshould not have come as a complete surprise.