{-# OPTIONS_GHC -Wall -Werror #-}
module Documentation.SBV.Examples.Puzzles.DogCatMouse where
import Data.SBV
puzzle :: IO AllSatResult
puzzle :: IO AllSatResult
puzzle = forall a. Provable a => a -> IO AllSatResult
allSat forall a b. (a -> b) -> a -> b
$ do
[SInteger
dog, SInteger
cat, SInteger
mouse] <- [String] -> Symbolic [SInteger]
sIntegers [String
"dog", String
"cat", String
"mouse"]
[SBool] -> SymbolicT IO SBool
solve [ SInteger
dog forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
1
, SInteger
cat forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
1
, SInteger
mouse forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
1
, SInteger
dog forall a. Num a => a -> a -> a
+ SInteger
cat forall a. Num a => a -> a -> a
+ SInteger
mouse forall a. EqSymbolic a => a -> a -> SBool
.== SInteger
100
, SReal
15 forall {a}. (Integral a, SymVal a) => SReal -> SBV a -> SReal
`per` SInteger
dog forall a. Num a => a -> a -> a
+ SReal
1 forall {a}. (Integral a, SymVal a) => SReal -> SBV a -> SReal
`per` SInteger
cat forall a. Num a => a -> a -> a
+ SReal
0.25 forall {a}. (Integral a, SymVal a) => SReal -> SBV a -> SReal
`per` SInteger
mouse forall a. EqSymbolic a => a -> a -> SBool
.== SReal
100
]
where SReal
p per :: SReal -> SBV a -> SReal
`per` SBV a
q = SReal
p forall a. Num a => a -> a -> a
* (forall a b.
(Integral a, HasKind a, Num a, SymVal a, HasKind b, Num b,
SymVal b) =>
SBV a -> SBV b
sFromIntegral SBV a
q :: SReal)