Copyright | (c) Levent Erkok |
---|---|
License | BSD3 |
Maintainer | erkokl@gmail.com |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Solves the following logic puzzle, attributed to Albert Einstein:
- The Briton lives in the red house.
- The Swede keeps dogs as pets.
- The Dane drinks tea.
- The green house is left to the white house.
- The owner of the green house drinks coffee.
- The person who plays football rears birds.
- The owner of the yellow house plays baseball.
- The man living in the center house drinks milk.
- The Norwegian lives in the first house.
- The man who plays volleyball lives next to the one who keeps cats.
- The man who keeps the horse lives next to the one who plays baseball.
- The owner who plays tennis drinks beer.
- The German plays hockey.
- The Norwegian lives next to the blue house.
- The man who plays volleyball has a neighbor who drinks water.
Who owns the fish?
Synopsis
- data Color
- type SColor = SBV Color
- sBlue :: SBV Color
- sYellow :: SBV Color
- sWhite :: SBV Color
- sGreen :: SBV Color
- sRed :: SBV Color
- data Nationality
- type SNationality = SBV Nationality
- sGerman :: SBV Nationality
- sNorwegian :: SBV Nationality
- sSwede :: SBV Nationality
- sDane :: SBV Nationality
- sBriton :: SBV Nationality
- data Beverage
- type SBeverage = SBV Beverage
- sWater :: SBV Beverage
- sBeer :: SBV Beverage
- sMilk :: SBV Beverage
- sCoffee :: SBV Beverage
- sTea :: SBV Beverage
- data Pet
- type SPet = SBV Pet
- sFish :: SBV Pet
- sBird :: SBV Pet
- sCat :: SBV Pet
- sHorse :: SBV Pet
- sDog :: SBV Pet
- data Sport
- = Football
- | Baseball
- | Volleyball
- | Hockey
- | Tennis
- type SSport = SBV Sport
- sTennis :: SBV Sport
- sHockey :: SBV Sport
- sVolleyball :: SBV Sport
- sBaseball :: SBV Sport
- sFootball :: SBV Sport
- fishOwner :: IO ()
Documentation
Colors of houses
Instances
data Nationality Source #
Nationalities of the occupants
Instances
type SNationality = SBV Nationality Source #
Symbolic version of the type Nationality
.
sNorwegian :: SBV Nationality Source #
Symbolic version of the constructor Norwegian
.
Beverage choices
Instances
Pets they keep
Instances
Sports they engage in
Instances
sVolleyball :: SBV Sport Source #
Symbolic version of the constructor Volleyball
.
We have:
>>>
fishOwner
German
It's not hard to modify this program to grab the values of all the assignments, i.e., the full
solution to the puzzle. We leave that as an exercise to the interested reader!
NB. We use the satTrackUFs
configuration to indicate that the uninterpreted function
changes do not matter for generating different values. All we care is that the fishOwner changes!