-2

All of the solutions for the zebra puzzle have a variable for each of the properties and a domain with the possible values. For instance A for Nationalities, B for pets, ...

Ai with i = 1..5 and the domain for example {Dutch, Spanish, Italian, French, English}

As I've seen in the n-queens puzzle, there can always be multiple representations for a constraint problem. What could be alternative representations for the zebra puzzle?

For example, I was thinking about following representation:

  • HouseOne indices 1..4 with domain {1,2,3,4,5}
  • HouseTwo indices 1..4 with domain {1,2,3,4,5}
  • HouseThree indices 1..4 with domain {1,2,3,4,5}
  • HouseFour indices 1..4 with domain {1,2,3,4,5}
  • HouseFive indices 1..4 with domain {1,2,3,4,5}

Could this work?

D.W.
  • 167,959
  • 22
  • 232
  • 500
Lieven Cardoen
  • 127
  • 1
  • 6

1 Answers1

1

One representation is as a constraint program.

Another possible representation is as SAT. One of the key steps in representing this using SAT is to encode "one-out-of-$n$" constraints (where a particular object corresponds to a unique other object, so we need it to correspond to exactly one out of the $n$ possible partners for it); these can be encoded in SAT in multiple possible ways. See Encoding 1-out-of-n constraint for SAT solvers for an overview of some technique for that.

Another possible representation is as an integer linear program (ILP).

Yet another possible representation would be to represent it in the Alloy constraint language. Alloy is especially good when you have many constraint variables that are functions or relations over finite domains, and you need to enforce some constraints on those variables. This looks attractive for the zebra puzzle, because the zebra puzzle involves relationships between (for example) houses and house-owners, and those relations could be encoded as an (unknown) relation or function.

D.W.
  • 167,959
  • 22
  • 232
  • 500