Copyright | (c) Levent Erkok |
---|---|
License | BSD3 |
Maintainer | erkokl@gmail.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Documentation.SBV.Examples.Puzzles.DieHard
Description
Solves the die-hard riddle: In the movie Die Hard 3, the heroes must obtain exactly 4 gallons of water using a 5 gallon jug, a 3 gallon jug, and a water faucet. We use a bounded-model-checking style search to find a solution.
Synopsis
- data Action
- type SAction = SBV Action
- sInitial :: SBV Action
- sFillBig :: SBV Action
- sFillSmall :: SBV Action
- sEmptyBig :: SBV Action
- sEmptySmall :: SBV Action
- sBigToSmall :: SBV Action
- sSmallToBig :: SBV Action
- data State a b = State {}
- type SState = State SInteger SAction
- type CState = State Integer Action
- dieHard :: IO ()
Documentation
Possible actions
Constructors
Initial | |
FillBig | |
FillSmall | |
EmptyBig | |
EmptySmall | |
BigToSmall | |
SmallToBig |
Instances
sEmptySmall :: SBV Action Source #
Symbolic version of the constructor EmptySmall
.
sBigToSmall :: SBV Action Source #
Symbolic version of the constructor BigToSmall
.
sSmallToBig :: SBV Action Source #
Symbolic version of the constructor SmallToBig
.
We represent the state with two quantities, the amount of water in each jug. The action is how we got into this state.
Instances
Queriable IO SState Source # |
| ||||
Defined in Documentation.SBV.Examples.Puzzles.DieHard Associated Types
| |||||
(Show a, Show b) => Show (State a b) Source # | Show instance | ||||
type QueryResult SState Source # | |||||
Defined in Documentation.SBV.Examples.Puzzles.DieHard |
Solve the problem using a BMC search. We have:
>>>
dieHard
BMC Cover: Iteration: 0 BMC Cover: Iteration: 1 BMC Cover: Iteration: 2 BMC Cover: Iteration: 3 BMC Cover: Iteration: 4 BMC Cover: Iteration: 5 BMC Cover: Iteration: 6 BMC Cover: Satisfying state found at iteration 6 Big: 0, Small: 0 (Initial) Big: 5, Small: 0 (FillBig) Big: 2, Small: 3 (BigToSmall) Big: 2, Small: 0 (EmptySmall) Big: 0, Small: 2 (BigToSmall) Big: 5, Small: 2 (FillBig) Big: 4, Small: 3 (BigToSmall)