Copyright | (c) Levent Erkok |
---|---|
License | BSD3 |
Maintainer | erkokl@gmail.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Solution to "Malice and Alice," from George J. Summers' Logical Deduction Puzzles:
A man and a woman were together in a bar at the time of the murder. The victim and the killer were together on a beach at the time of the murder. One of Alice’s two children was alone at the time of the murder. Alice and her husband were not together at the time of the murder. The victim's twin was not the killer. The killer was younger than the victim. Who killed who?
Synopsis
- data Location
- data Sex
- data Role
- type SLocation = SBV Location
- sAlone :: SBV Location
- sBeach :: SBV Location
- sBar :: SBV Location
- type SSex = SBV Sex
- sFemale :: SBV Sex
- sMale :: SBV Sex
- type SRole = SBV Role
- sBystander :: SBV Role
- sKiller :: SBV Role
- sVictim :: SBV Role
- data Person f = Person {}
- newtype Const a = Const {
- getConst :: a
- newPerson :: String -> Symbolic (Person SBV)
- getPerson :: Person SBV -> Query (Person Const)
- killer :: IO ()
- puzzle :: IO [Person Const]
Documentation
Locations
Instances
Sexes
Instances
Roles
Instances
sBystander :: SBV Role Source #
A person has a name, age, together with location and sex. We parameterize over a function so we can use this struct both in a concrete context and a symbolic context. Note that the name is always concrete.
Helper functor
getPerson :: Person SBV -> Query (Person Const) Source #
Get the concrete value of the person in the model
Solve the puzzle. We have:
>>>
killer
Alice 48 Bar Female Bystander Husband 47 Beach Male Killer Brother 48 Beach Male Victim Daughter 20 Alone Female Bystander Son 21 Bar Male Bystander
That is, Alice's brother was the victim and Alice's husband was the killer.