{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -Wall -Werror #-}
module Documentation.SBV.Examples.Misc.Enumerate where
import Data.SBV
data E = A | B | C
mkSymbolicEnumeration ''E
elts :: IO AllSatResult
elts :: IO AllSatResult
elts = forall a. Provable a => a -> IO AllSatResult
allSat forall a b. (a -> b) -> a -> b
$ \(SBV E
x::SE) -> SBV E
x forall a. EqSymbolic a => a -> a -> SBool
.== SBV E
x
four :: IO SatResult
four :: IO SatResult
four = forall a. Provable a => a -> IO SatResult
sat forall a b. (a -> b) -> a -> b
$ \SBV E
a SBV E
b SBV E
c (SBV E
d::SE) -> forall a. EqSymbolic a => [a] -> SBool
distinct [SBV E
a, SBV E
b, SBV E
c, SBV E
d]
maxE :: IO SatResult
maxE :: IO SatResult
maxE = forall a. Provable a => a -> IO SatResult
sat forall a b. (a -> b) -> a -> b
$ do SBV E
mx <- forall a. SymVal a => String -> Symbolic (SBV a)
sbvExists String
"maxE"
SBV E
e <- forall a. SymVal a => String -> Symbolic (SBV a)
sbvForall String
"e"
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ SBV E
mx forall a. OrdSymbolic a => a -> a -> SBool
.>= (SBV E
e::SE)
minE :: IO SatResult
minE :: IO SatResult
minE = forall a. Provable a => a -> IO SatResult
sat forall a b. (a -> b) -> a -> b
$ do SBV E
mx <- forall a. SymVal a => String -> Symbolic (SBV a)
sbvExists String
"minE"
SBV E
e <- forall a. SymVal a => String -> Symbolic (SBV a)
sbvForall String
"e"
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ SBV E
mx forall a. OrdSymbolic a => a -> a -> SBool
.<= (SBV E
e::SE)