-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A monad for interfacing with external SMT solvers -- -- Hasmtlib is a library for generating SMTLib2-problems using a monad. -- It takes care of encoding your problem, marshaling the data to an -- external solver and parsing and interpreting the result into Haskell -- types. It is highly inspired by ekmett/ersatz which does the same for -- QSAT. Communication with external solvers is handled by -- tweag/smtlib-backends. @package hasmtlib @version 2.0.0 module Language.Hasmtlib.Boolean class Boolean b -- | Lift a Bool bool :: Boolean b => Bool -> b -- | The true constant true = bool True true :: Boolean b => b -- | The false constant false = bool False false :: Boolean b => b -- | Logical conjunction. (&&) :: Boolean b => b -> b -> b -- | Logical disjunction (inclusive or). (||) :: Boolean b => b -> b -> b -- | Logical implication. (==>) :: Boolean b => b -> b -> b -- | Logical implication with arrow reversed. -- --
-- forall x y. (x ==> y) === (y <== x) --(<==) :: Boolean b => b -> b -> b -- | Logical equivalence. (<==>) :: Boolean b => b -> b -> b -- | Logical negation not :: Boolean b => b -> b -- | Exclusive-or xor :: Boolean b => b -> b -> b infixr 3 && infixr 2 || infixr 0 ==> infix 4 `xor` -- | The logical conjunction of several values. and :: (Foldable t, Boolean b) => t b -> b -- | The logical disjunction of several values. or :: (Foldable t, Boolean b) => t b -> b -- | The negated logical conjunction of several values. -- --
-- nand = not . and --nand :: (Foldable t, Boolean b) => t b -> b -- | The negated logical disjunction of several values. -- --
-- nor = not . or --nor :: (Foldable t, Boolean b) => t b -> b -- | The logical conjunction of the mapping of a function over several -- values. all :: (Foldable t, Boolean b) => (a -> b) -> t a -> b -- | The logical disjunction of the mapping of a function over several -- values. any :: (Foldable t, Boolean b) => (a -> b) -> t a -> b instance Language.Hasmtlib.Boolean.Boolean GHC.Types.Bool instance Language.Hasmtlib.Boolean.Boolean Data.Bit.Internal.Bit instance GHC.TypeNats.KnownNat n => Language.Hasmtlib.Boolean.Boolean (Data.Vector.Unboxed.Sized.Vector n Data.Bit.Internal.Bit) module Language.Hasmtlib.Integraled -- | Integral-like class for clean API. In context hide the Preludes -- Integral. class Integraled a quot :: Integraled a => a -> a -> a rem :: Integraled a => a -> a -> a div :: Integraled a => a -> a -> a mod :: Integraled a => a -> a -> a quotRem :: Integraled a => a -> a -> (a, a) quotRem :: (Integraled a, Integral a) => a -> a -> (a, a) divMod :: Integraled a => a -> a -> (a, a) divMod :: (Integraled a, Integral a) => a -> a -> (a, a) instance Language.Hasmtlib.Integraled.Integraled GHC.Types.Int instance Language.Hasmtlib.Integraled.Integraled GHC.Num.Integer.Integer instance Language.Hasmtlib.Integraled.Integraled GHC.Types.Word instance Language.Hasmtlib.Integraled.Integraled GHC.Num.Natural.Natural instance Language.Hasmtlib.Integraled.Integraled GHC.Word.Word8 instance Language.Hasmtlib.Integraled.Integraled GHC.Word.Word16 instance Language.Hasmtlib.Integraled.Integraled GHC.Word.Word32 instance Language.Hasmtlib.Integraled.Integraled GHC.Word.Word64 instance GHC.Real.Integral a => Language.Hasmtlib.Integraled.Integraled (Data.Functor.Identity.Identity a) instance forall k a (b :: k). GHC.Real.Integral a => Language.Hasmtlib.Integraled.Integraled (Data.Functor.Const.Const a b) module Language.Hasmtlib.Internal.Render -- | Render values to their SMTLib2-Lisp form, represented as -- Builder. class Render a render :: Render a => a -> Builder renderUnary :: Render a => Builder -> a -> Builder renderBinary :: (Render a, Render b) => Builder -> a -> b -> Builder renderTernary :: (Render a, Render b, Render c) => Builder -> a -> b -> c -> Builder renderNary :: Render a => Builder -> [a] -> Builder -- | Render values to their sequential SMTLib2-Lisp form, represented as a -- Seq Builder. class RenderSeq a renderSeq :: RenderSeq a => a -> Seq Builder instance Language.Hasmtlib.Internal.Render.Render GHC.Types.Bool instance Language.Hasmtlib.Internal.Render.Render GHC.TypeNats.Nat instance Language.Hasmtlib.Internal.Render.Render GHC.Num.Integer.Integer instance Language.Hasmtlib.Internal.Render.Render GHC.Types.Double instance Language.Hasmtlib.Internal.Render.Render GHC.Types.Char instance Language.Hasmtlib.Internal.Render.Render GHC.Base.String instance Language.Hasmtlib.Internal.Render.Render Data.ByteString.Builder.Internal.Builder module Language.Hasmtlib.Internal.Bitvec -- | Unsigned and length-indexed bitvector with MSB first. newtype Bitvec (n :: Nat) Bitvec :: Vector n Bit -> Bitvec (n :: Nat) [unBitvec] :: Bitvec (n :: Nat) -> Vector n Bit bvReverse :: Bitvec n -> Bitvec n bvReplicate :: forall n. KnownNat n => Bit -> Bitvec n bvReplicate' :: forall n proxy. KnownNat n => proxy n -> Bit -> Bitvec n bvGenerate :: forall n. KnownNat n => (Finite n -> Bit) -> Bitvec n bvConcat :: Bitvec n -> Bitvec m -> Bitvec (n + m) bvTake' :: forall n m proxy. KnownNat n => proxy n -> Bitvec (n + m) -> Bitvec n bvDrop' :: forall n m proxy. KnownNat n => proxy n -> Bitvec (n + m) -> Bitvec m bvSplitAt' :: forall n m proxy. KnownNat n => proxy n -> Bitvec (n + m) -> (Bitvec n, Bitvec m) bvToList :: Bitvec n -> [Bit] bvFromListN :: forall n. KnownNat n => [Bit] -> Maybe (Bitvec n) bvFromListN' :: forall n. KnownNat n => Proxy n -> [Bit] -> Maybe (Bitvec n) bvRotL :: forall n i. KnownNat (Mod i n) => Proxy i -> Bitvec n -> Bitvec n bvRotR :: forall n i. KnownNat (Mod i n) => Proxy i -> Bitvec n -> Bitvec n bvShL :: KnownNat n => Bitvec n -> Bitvec n -> Maybe (Bitvec n) bvLShR :: KnownNat n => Bitvec n -> Bitvec n -> Maybe (Bitvec n) bvZeroExtend :: KnownNat i => Proxy i -> Bitvec n -> Bitvec (n + i) bvExtract :: forall n i j. (KnownNat i, KnownNat ((j - i) + 1), (i + (n - i)) ~ n, (((j - i) + 1) + ((n - i) - ((j - i) + 1))) ~ (n - i)) => Proxy i -> Proxy j -> Bitvec n -> Bitvec ((j - i) + 1) instance GHC.TypeNats.KnownNat n => Language.Hasmtlib.Boolean.Boolean (Language.Hasmtlib.Internal.Bitvec.Bitvec n) instance GHC.Classes.Ord (Language.Hasmtlib.Internal.Bitvec.Bitvec n) instance GHC.Classes.Eq (Language.Hasmtlib.Internal.Bitvec.Bitvec n) instance GHC.Show.Show (Language.Hasmtlib.Internal.Bitvec.Bitvec n) instance Language.Hasmtlib.Internal.Render.Render (Language.Hasmtlib.Internal.Bitvec.Bitvec n) instance GHC.TypeNats.KnownNat n => GHC.Num.Num (Language.Hasmtlib.Internal.Bitvec.Bitvec n) instance GHC.TypeNats.KnownNat n => GHC.Enum.Bounded (Language.Hasmtlib.Internal.Bitvec.Bitvec n) instance GHC.TypeNats.KnownNat n => GHC.Enum.Enum (Language.Hasmtlib.Internal.Bitvec.Bitvec n) instance GHC.TypeNats.KnownNat n => GHC.Real.Real (Language.Hasmtlib.Internal.Bitvec.Bitvec n) instance GHC.TypeNats.KnownNat n => GHC.Real.Integral (Language.Hasmtlib.Internal.Bitvec.Bitvec n) module Language.Hasmtlib.Type.ArrayMap -- | Class that allows access to a map-like array where specific values are -- is the default value or overwritten values. Every index has a value by -- default. Values at indices can be overwritten manually. -- -- Based on McCarthy`s basic array theory. -- -- Therefore the following axioms must hold: -- --
-- AllC '[] k = () -- AllC (c ': cs) k = (c k, AllC cs k) --type family AllC cs k :: Constraint -- | An existential wrapper that hides some SMTSort and a list of -- Constraints holding for it. data SomeSMTSort cs f [SomeSMTSort] :: forall cs f (t :: SMTSort). AllC cs t => f t -> SomeSMTSort cs f instance GHC.Show.Show (Language.Hasmtlib.Type.SMTSort.SSMTSort t) instance GHC.Classes.Eq (Language.Hasmtlib.Type.SMTSort.SSMTSort t) instance GHC.Classes.Ord (Language.Hasmtlib.Type.SMTSort.SSMTSort t) instance Data.GADT.Internal.GEq Language.Hasmtlib.Type.SMTSort.SSMTSort instance Data.GADT.Internal.GCompare Language.Hasmtlib.Type.SMTSort.SSMTSort instance Language.Hasmtlib.Type.SMTSort.KnownSMTSort 'Language.Hasmtlib.Type.SMTSort.IntSort instance Language.Hasmtlib.Type.SMTSort.KnownSMTSort 'Language.Hasmtlib.Type.SMTSort.RealSort instance Language.Hasmtlib.Type.SMTSort.KnownSMTSort 'Language.Hasmtlib.Type.SMTSort.BoolSort instance GHC.TypeNats.KnownNat n => Language.Hasmtlib.Type.SMTSort.KnownSMTSort ('Language.Hasmtlib.Type.SMTSort.BvSort n) instance (Language.Hasmtlib.Type.SMTSort.KnownSMTSort k, Language.Hasmtlib.Type.SMTSort.KnownSMTSort v, GHC.Classes.Ord (Language.Hasmtlib.Type.SMTSort.HaskellType k)) => Language.Hasmtlib.Type.SMTSort.KnownSMTSort ('Language.Hasmtlib.Type.SMTSort.ArraySort k v) instance Language.Hasmtlib.Internal.Render.Render (Language.Hasmtlib.Type.SMTSort.SSMTSort t) module Language.Hasmtlib.Iteable -- | If condition (p :: b) then (t :: a) else (f :: a) -- --
-- >>> ite true "1" "2" -- "1" -- -- >>> ite false 100 42 -- 42 --class Iteable b a ite :: Iteable b a => b -> a -> a -> a ite :: (Iteable b a, Iteable b c, Applicative f, f c ~ a) => b -> a -> a -> a instance Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) (Language.Hasmtlib.Internal.Expr.Expr t) instance Language.Hasmtlib.Iteable.Iteable GHC.Types.Bool a instance Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) a => Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) [a] instance Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) a => Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) (GHC.Maybe.Maybe a) instance Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) a => Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) (Data.Sequence.Internal.Seq a) instance Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) a => Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) (Data.Tree.Tree a) instance Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) () instance (Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) a, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) b) => Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) (a, b) instance (Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) a, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) b, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) c) => Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) (a, b, c) instance (Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) a, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) b, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) c, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) d) => Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) (a, b, c, d) instance (Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) a, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) b, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) c, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) d, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) e) => Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) (a, b, c, d, e) instance (Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) a, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) b, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) c, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) d, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) e, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) f) => Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) (a, b, c, d, e, f) instance (Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) a, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) b, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) c, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) d, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) e, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) f, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) g) => Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) (a, b, c, d, e, f, g) instance (Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) a, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) b, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) c, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) d, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) e, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) f, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) g, Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) h) => Language.Hasmtlib.Iteable.Iteable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.BoolSort) (a, b, c, d, e, f, g, h) module Language.Hasmtlib.Equatable -- | Test two as on equality as SMT-Expression. -- --
-- x <- var @RealType -- y <- var -- assert $ y === x && not (y /== x) --class Equatable a -- | Test whether two values are equal in the SMT-Problem. (===) :: Equatable a => a -> a -> Expr BoolSort -- | Test whether two values are equal in the SMT-Problem. (===) :: (Equatable a, Generic a, GEquatable (Rep a)) => a -> a -> Expr BoolSort -- | Test whether two values are not equal in the SMT-Problem. (/==) :: Equatable a => a -> a -> Expr BoolSort infix 4 === infix 4 /== class GEquatable f (===#) :: GEquatable f => f a -> f a -> Expr BoolSort instance (Language.Hasmtlib.Type.SMTSort.KnownSMTSort t, GHC.Classes.Eq (Language.Hasmtlib.Type.SMTSort.HaskellType t)) => Language.Hasmtlib.Equatable.Equatable (Language.Hasmtlib.Internal.Expr.Expr t) instance Language.Hasmtlib.Equatable.Equatable a => Language.Hasmtlib.Equatable.GEquatable (GHC.Generics.K1 i a) instance Language.Hasmtlib.Equatable.Equatable () instance Language.Hasmtlib.Equatable.Equatable GHC.Base.Void instance Language.Hasmtlib.Equatable.Equatable GHC.Types.Int instance Language.Hasmtlib.Equatable.Equatable GHC.Num.Integer.Integer instance Language.Hasmtlib.Equatable.Equatable GHC.Num.Natural.Natural instance Language.Hasmtlib.Equatable.Equatable GHC.Types.Word instance Language.Hasmtlib.Equatable.Equatable GHC.Word.Word8 instance Language.Hasmtlib.Equatable.Equatable GHC.Word.Word16 instance Language.Hasmtlib.Equatable.Equatable GHC.Word.Word32 instance Language.Hasmtlib.Equatable.Equatable GHC.Word.Word64 instance Language.Hasmtlib.Equatable.Equatable GHC.Int.Int8 instance Language.Hasmtlib.Equatable.Equatable GHC.Int.Int16 instance Language.Hasmtlib.Equatable.Equatable GHC.Int.Int32 instance Language.Hasmtlib.Equatable.Equatable GHC.Int.Int64 instance Language.Hasmtlib.Equatable.Equatable GHC.Types.Char instance Language.Hasmtlib.Equatable.Equatable GHC.Types.Float instance Language.Hasmtlib.Equatable.Equatable GHC.Types.Double instance Language.Hasmtlib.Equatable.Equatable GHC.Types.Ordering instance Language.Hasmtlib.Equatable.Equatable GHC.Types.Bool instance Language.Hasmtlib.Equatable.GEquatable GHC.Generics.U1 instance Language.Hasmtlib.Equatable.GEquatable GHC.Generics.V1 instance forall k (f :: k -> *) (g :: k -> *). (Language.Hasmtlib.Equatable.GEquatable f, Language.Hasmtlib.Equatable.GEquatable g) => Language.Hasmtlib.Equatable.GEquatable (f GHC.Generics.:*: g) instance forall k (f :: k -> *) (g :: k -> *). (Language.Hasmtlib.Equatable.GEquatable f, Language.Hasmtlib.Equatable.GEquatable g) => Language.Hasmtlib.Equatable.GEquatable (f GHC.Generics.:+: g) instance forall k (f :: k -> *) i (c :: GHC.Generics.Meta). Language.Hasmtlib.Equatable.GEquatable f => Language.Hasmtlib.Equatable.GEquatable (GHC.Generics.M1 i c f) module Language.Hasmtlib.Orderable -- | Compare two as as SMT-Expression. -- --
-- x <- var @RealSort -- y <- var -- assert $ x >? y -- assert $ x === min' 42 100 --class Equatable a => Orderable a (<=?) :: Orderable a => a -> a -> Expr BoolSort (<=?) :: (Orderable a, Generic a, GOrderable (Rep a)) => a -> a -> Expr BoolSort (>=?) :: Orderable a => a -> a -> Expr BoolSort () :: Orderable a => a -> a -> Expr BoolSort (>?) :: Orderable a => a -> a -> Expr BoolSort infix 4 <=? infix 4 >=? infix 4 infix 4 >? -- | Minimum of two as SMT-Expression. min' :: (Orderable a, Iteable (Expr BoolSort) a) => a -> a -> a -- | Maximum of two as SMT-Expression. max' :: (Orderable a, Iteable (Expr BoolSort) a) => a -> a -> a class GEquatable f => GOrderable f (#) :: GOrderable f => f a -> f a -> Expr BoolSort (<=?#) :: GOrderable f => f a -> f a -> Expr BoolSort instance Language.Hasmtlib.Orderable.Orderable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.IntSort) instance Language.Hasmtlib.Orderable.Orderable (Language.Hasmtlib.Internal.Expr.Expr 'Language.Hasmtlib.Type.SMTSort.RealSort) instance GHC.TypeNats.KnownNat n => Language.Hasmtlib.Orderable.Orderable (Language.Hasmtlib.Internal.Expr.Expr ('Language.Hasmtlib.Type.SMTSort.BvSort n)) instance Language.Hasmtlib.Orderable.Orderable a => Language.Hasmtlib.Orderable.GOrderable (GHC.Generics.K1 i a) instance Language.Hasmtlib.Orderable.Orderable () instance Language.Hasmtlib.Orderable.Orderable GHC.Base.Void instance Language.Hasmtlib.Orderable.Orderable GHC.Types.Int instance Language.Hasmtlib.Orderable.Orderable GHC.Num.Integer.Integer instance Language.Hasmtlib.Orderable.Orderable GHC.Num.Natural.Natural instance Language.Hasmtlib.Orderable.Orderable GHC.Types.Word instance Language.Hasmtlib.Orderable.Orderable GHC.Word.Word8 instance Language.Hasmtlib.Orderable.Orderable GHC.Word.Word16 instance Language.Hasmtlib.Orderable.Orderable GHC.Word.Word32 instance Language.Hasmtlib.Orderable.Orderable GHC.Word.Word64 instance Language.Hasmtlib.Orderable.Orderable GHC.Int.Int8 instance Language.Hasmtlib.Orderable.Orderable GHC.Int.Int16 instance Language.Hasmtlib.Orderable.Orderable GHC.Int.Int32 instance Language.Hasmtlib.Orderable.Orderable GHC.Int.Int64 instance Language.Hasmtlib.Orderable.Orderable GHC.Types.Char instance Language.Hasmtlib.Orderable.Orderable GHC.Types.Float instance Language.Hasmtlib.Orderable.Orderable GHC.Types.Double instance Language.Hasmtlib.Orderable.Orderable GHC.Types.Ordering instance Language.Hasmtlib.Orderable.Orderable GHC.Types.Bool instance Language.Hasmtlib.Orderable.GOrderable GHC.Generics.U1 instance Language.Hasmtlib.Orderable.GOrderable GHC.Generics.V1 instance forall k (f :: k -> *) (g :: k -> *). (Language.Hasmtlib.Orderable.GOrderable f, Language.Hasmtlib.Orderable.GOrderable g) => Language.Hasmtlib.Orderable.GOrderable (f GHC.Generics.:*: g) instance forall k (f :: k -> *) (g :: k -> *). (Language.Hasmtlib.Orderable.GOrderable f, Language.Hasmtlib.Orderable.GOrderable g) => Language.Hasmtlib.Orderable.GOrderable (f GHC.Generics.:+: g) instance forall k (f :: k -> *) i (c :: GHC.Generics.Meta). Language.Hasmtlib.Orderable.GOrderable f => Language.Hasmtlib.Orderable.GOrderable (GHC.Generics.M1 i c f) module Language.Hasmtlib.Type.Expr -- | An internal SMT variable with a phantom-type which holds an Int -- as it's identifier. newtype SMTVar (t :: SMTSort) SMTVar :: Int -> SMTVar (t :: SMTSort) [_varId] :: SMTVar (t :: SMTSort) -> Int varId :: forall t_aswJ t_asD2. Iso (SMTVar t_aswJ) (SMTVar t_asD2) Int Int -- | A wrapper for values of SMTSorts. data Value (t :: SMTSort) [IntValue] :: HaskellType IntSort -> Value IntSort [RealValue] :: HaskellType RealSort -> Value RealSort [BoolValue] :: HaskellType BoolSort -> Value BoolSort [BvValue] :: HaskellType (BvSort n) -> Value (BvSort n) [ArrayValue] :: (KnownSMTSort k, KnownSMTSort v, Ord (HaskellType k)) => HaskellType (ArraySort k v) -> Value (ArraySort k v) -- | Unwrap a value from Value. unwrapValue :: Value t -> HaskellType t -- | Wrap a value into Value. wrapValue :: forall t. KnownSMTSort t => HaskellType t -> Value t -- | A SMT expression. For internal use only. For building expressions use -- the corresponding instances (Num, Boolean, ...). data Expr (t :: SMTSort) -- | Test multiple expressions on equality within in the -- SMT-Problem. equal :: (Eq (HaskellType t), KnownSMTSort t, Foldable f) => f (Expr t) -> Expr BoolSort -- | Test multiple expressions on distinctness within in the -- SMT-Problem. distinct :: (Eq (HaskellType t), KnownSMTSort t, Foldable f) => f (Expr t) -> Expr BoolSort -- | Bitvector shift left bvShL :: KnownNat n => Expr (BvSort n) -> Expr (BvSort n) -> Expr (BvSort n) -- | Bitvector logical shift right bvLShR :: KnownNat n => Expr (BvSort n) -> Expr (BvSort n) -> Expr (BvSort n) -- | Concat two bitvectors bvConcat :: (KnownNat n, KnownNat m) => Expr (BvSort n) -> Expr (BvSort m) -> Expr (BvSort (n + m)) -- | Rotate bitvector left bvRotL :: (KnownNat n, KnownNat i, KnownNat (Mod i n)) => Proxy i -> Expr (BvSort n) -> Expr (BvSort n) -- | Rotate bitvector right bvRotR :: (KnownNat n, KnownNat i, KnownNat (Mod i n)) => Proxy i -> Expr (BvSort n) -> Expr (BvSort n) -- | Converts an expression of type RealSort to type IntSort. toIntSort :: Expr RealSort -> Expr IntSort -- | Converts an expression of type IntSort to type RealSort. toRealSort :: Expr IntSort -> Expr RealSort -- | Checks whether an expression of type RealSort may be safely -- converted to type IntSort. isIntSort :: Expr RealSort -> Expr BoolSort -- | A universal quantification for any specific SMTSort. If the -- type cannot be inferred, apply a type-annotation. Nested quantifiers -- are also supported. -- -- Usage: -- --
-- assert $ -- for_all @IntSort $ x -> -- x + 0 === x && 0 + x === x -- ---- -- The lambdas x is all-quantified here. It will only be scoped -- for the lambdas body. for_all :: forall t. KnownSMTSort t => (Expr t -> Expr BoolSort) -> Expr BoolSort -- | An existential quantification for any specific SMTSort If the -- type cannot be inferred, apply a type-annotation. Nested quantifiers -- are also supported. -- -- Usage: -- --
-- assert $ -- for_all @(BvSort 8) $ x -> -- exists $ y -> -- x - y === 0 -- ---- -- The lambdas y is existentially quantified here. It will only -- be scoped for the lambdas body. exists :: forall t. KnownSMTSort t => (Expr t -> Expr BoolSort) -> Expr BoolSort -- | Select a value from an array. select :: (KnownSMTSort k, KnownSMTSort v, Ord (HaskellType k)) => Expr (ArraySort k v) -> Expr k -> Expr v -- | Store a value in an array. store :: (KnownSMTSort k, KnownSMTSort v, Ord (HaskellType k)) => Expr (ArraySort k v) -> Expr k -> Expr v -> Expr (ArraySort k v) module Language.Hasmtlib.Counting count' :: forall t f. (Functor f, Foldable f, Num (Expr t)) => Proxy t -> f (Expr BoolSort) -> Expr t count :: forall t f. (Functor f, Foldable f, Num (Expr t)) => f (Expr BoolSort) -> Expr t -- | Out of many bool-expressions build a formula which encodes that at -- most k of them are true atMost :: forall t f. (Functor f, Foldable f, Num (Expr t), Orderable (Expr t)) => Expr t -> f (Expr BoolSort) -> Expr BoolSort -- | Out of many bool-expressions build a formula which encodes that at -- least k of them are true atLeast :: forall t f. (Functor f, Foldable f, Num (Expr t), Orderable (Expr t)) => Expr t -> f (Expr BoolSort) -> Expr BoolSort -- | Out of many bool-expressions build a formula which encodes that -- exactly k of them are true exactly :: forall t f. (Functor f, Foldable f, Num (Expr t), Orderable (Expr t)) => Expr t -> f (Expr BoolSort) -> Expr BoolSort module Language.Hasmtlib.Type.Solution -- | Function that turns a state into a result and a solution. type Solver s m = s -> m (Result, Solution) -- | Results of check-sat commands. data Result Unsat :: Result Unknown :: Result Sat :: Result -- | A Solution is a dependent map DMap from SSMTSorts t to -- IntMap t. type Solution = DMap SSMTSort IntValueMap -- | Newtype for IntMap Value so we can use it as -- right-hand-side of DMap. newtype IntValueMap t IntValueMap :: IntMap (Value t) -> IntValueMap t -- | A solution for a single variable. data SMTVarSol (t :: SMTSort) SMTVarSol :: SMTVar t -> Value t -> SMTVarSol (t :: SMTSort) -- | A variable in the SMT-Problem [_solVar] :: SMTVarSol (t :: SMTSort) -> SMTVar t -- | An assignment for this variable in a solution [_solVal] :: SMTVarSol (t :: SMTSort) -> Value t solVar :: forall t_aI8J. Lens' (SMTVarSol t_aI8J) (SMTVar t_aI8J) solVal :: forall t_aI8J. Lens' (SMTVarSol t_aI8J) (Value t_aI8J) -- | Alias class for constraint Ord (HaskellType t) class Ord (HaskellType t) => OrdHaskellType t -- | An existential wrapper that hides some known SMTSort with an -- Ord HaskellType type SomeKnownOrdSMTSort f = SomeSMTSort '[KnownSMTSort, OrdHaskellType] f -- | Create a Solution from some SMTVarSols. fromSomeVarSols :: [SomeKnownOrdSMTSort SMTVarSol] -> Solution instance GHC.Classes.Ord (Language.Hasmtlib.Type.SMTSort.HaskellType t) => Language.Hasmtlib.Type.Solution.OrdHaskellType t instance GHC.Classes.Ord Language.Hasmtlib.Type.Solution.Result instance GHC.Classes.Eq Language.Hasmtlib.Type.Solution.Result instance GHC.Show.Show Language.Hasmtlib.Type.Solution.Result instance GHC.Base.Monoid (Language.Hasmtlib.Type.Solution.IntValueMap t) instance GHC.Base.Semigroup (Language.Hasmtlib.Type.Solution.IntValueMap t) instance GHC.Show.Show (Language.Hasmtlib.Type.Solution.IntValueMap t) instance GHC.Show.Show (Language.Hasmtlib.Type.Solution.SMTVarSol t) module Language.Hasmtlib.Codec -- | Compute the default Decoded Type for every -- functor-wrapper. Useful for instances using default signatures. type family DefaultDecoded a :: Type -- | Lift values to SMT-Values or decode them. class Codec a where { type Decoded a :: Type; type Decoded a = DefaultDecoded a; } -- | Decode a value using given solution. decode :: Codec a => Solution -> a -> Maybe (Decoded a) -- | Decode a value using given solution. decode :: (Codec a, Traversable f, Codec b, a ~ f b, Decoded a ~ f (Decoded b)) => Solution -> a -> Maybe (Decoded a) -- | Encode a value as constant. encode :: Codec a => Decoded a -> a -- | Encode a value as constant. encode :: (Codec a, Functor f, Codec b, a ~ f b, Decoded a ~ f (Decoded b)) => Decoded a -> a instance Language.Hasmtlib.Type.SMTSort.KnownSMTSort t => Language.Hasmtlib.Codec.Codec (Language.Hasmtlib.Internal.Expr.Expr t) instance Language.Hasmtlib.Codec.Codec () instance (Language.Hasmtlib.Codec.Codec a, Language.Hasmtlib.Codec.Codec b) => Language.Hasmtlib.Codec.Codec (a, b) instance (Language.Hasmtlib.Codec.Codec a, Language.Hasmtlib.Codec.Codec b, Language.Hasmtlib.Codec.Codec c) => Language.Hasmtlib.Codec.Codec (a, b, c) instance (Language.Hasmtlib.Codec.Codec a, Language.Hasmtlib.Codec.Codec b, Language.Hasmtlib.Codec.Codec c, Language.Hasmtlib.Codec.Codec d) => Language.Hasmtlib.Codec.Codec (a, b, c, d) instance (Language.Hasmtlib.Codec.Codec a, Language.Hasmtlib.Codec.Codec b, Language.Hasmtlib.Codec.Codec c, Language.Hasmtlib.Codec.Codec d, Language.Hasmtlib.Codec.Codec e) => Language.Hasmtlib.Codec.Codec (a, b, c, d, e) instance (Language.Hasmtlib.Codec.Codec a, Language.Hasmtlib.Codec.Codec b, Language.Hasmtlib.Codec.Codec c, Language.Hasmtlib.Codec.Codec d, Language.Hasmtlib.Codec.Codec e, Language.Hasmtlib.Codec.Codec f) => Language.Hasmtlib.Codec.Codec (a, b, c, d, e, f) instance (Language.Hasmtlib.Codec.Codec a, Language.Hasmtlib.Codec.Codec b, Language.Hasmtlib.Codec.Codec c, Language.Hasmtlib.Codec.Codec d, Language.Hasmtlib.Codec.Codec e, Language.Hasmtlib.Codec.Codec f, Language.Hasmtlib.Codec.Codec g) => Language.Hasmtlib.Codec.Codec (a, b, c, d, e, f, g) instance (Language.Hasmtlib.Codec.Codec a, Language.Hasmtlib.Codec.Codec b, Language.Hasmtlib.Codec.Codec c, Language.Hasmtlib.Codec.Codec d, Language.Hasmtlib.Codec.Codec e, Language.Hasmtlib.Codec.Codec f, Language.Hasmtlib.Codec.Codec g, Language.Hasmtlib.Codec.Codec h) => Language.Hasmtlib.Codec.Codec (a, b, c, d, e, f, g, h) instance Language.Hasmtlib.Codec.Codec a => Language.Hasmtlib.Codec.Codec [a] instance Language.Hasmtlib.Codec.Codec a => Language.Hasmtlib.Codec.Codec (Data.IntMap.Internal.IntMap a) instance Language.Hasmtlib.Codec.Codec a => Language.Hasmtlib.Codec.Codec (Data.Map.Internal.Map k a) instance Language.Hasmtlib.Codec.Codec a => Language.Hasmtlib.Codec.Codec (GHC.Maybe.Maybe a) instance Language.Hasmtlib.Codec.Codec a => Language.Hasmtlib.Codec.Codec (Data.Sequence.Internal.Seq a) instance Language.Hasmtlib.Codec.Codec a => Language.Hasmtlib.Codec.Codec (Data.Tree.Tree a) instance (Language.Hasmtlib.Codec.Codec a, Language.Hasmtlib.Codec.Codec b) => Language.Hasmtlib.Codec.Codec (Data.Either.Either a b) module Language.Hasmtlib.Type.MonadSMT -- | A MonadState that holds an SMT-Problem. class MonadState s m => MonadSMT s m -- | Construct a variable. This is mainly intended for internal use. In the -- API use var' instead. -- --
-- x :: SMTVar RealType <- smtvar' (Proxy @RealType) --smtvar' :: forall t. (MonadSMT s m, KnownSMTSort t) => Proxy t -> m (SMTVar t) -- | Construct a variable as expression. -- --
-- x :: Expr RealType <- var' (Proxy @RealType) --var' :: forall t. (MonadSMT s m, KnownSMTSort t) => Proxy t -> m (Expr t) -- | Assert a boolean expression. -- --
-- x :: Expr IntType <- var @IntType -- assert $ x + 5 === 42 --assert :: MonadSMT s m => Expr BoolSort -> m () -- | Set an SMT-Solver-Option. -- --
-- setOption $ Incremental True --setOption :: MonadSMT s m => SMTOption -> m () -- | Set the logic for the SMT-Solver to use. -- --
-- setLogic "QF_LRA" --setLogic :: MonadSMT s m => String -> m () -- | Wrapper for var' which hides the Proxy. var :: forall t s m. (KnownSMTSort t, MonadSMT s m) => m (Expr t) -- | Wrapper for smtvar' which hides the Proxy. This is -- mainly intended for internal use. In the API use var instead. smtvar :: forall t s m. (KnownSMTSort t, MonadSMT s m) => m (SMTVar t) -- | Create a constant. -- --
-- >>> constant True -- Constant (BoolValue True) ---- --
-- >>> let x :: Integer = 10 ; constant x -- Constant (IntValue 10) ---- --
-- >>> constant @IntType 5 -- Constant (IntValue 5) ---- --
-- >>> constant @(BvType 8) 5 -- Constant (BvValue 0000101) --constant :: KnownSMTSort t => HaskellType t -> Expr t -- | Maybe assert a boolean expression. Asserts given expression if -- Maybe is a Just. Does nothing otherwise. assertMaybe :: MonadSMT s m => Maybe (Expr BoolSort) -> m () -- | Assign quantified variables to all quantified subexpressions of an -- expression. This shall only be used internally. Usually before -- rendering an assert. quantify :: MonadSMT s m => Expr t -> m (Expr t) -- | A MonadSMT that allows incremental solving. class MonadSMT s m => MonadIncrSMT s m | m -> s -- | Push a new context (one) to the solvers context-stack. push :: MonadIncrSMT s m => m () -- | Pop the solvers context-stack by one. pop :: MonadIncrSMT s m => m () -- | Run check-sat on the current problem. checkSat :: MonadIncrSMT s m => m Result -- | Run get-model on the current problem. This can be used to decode -- temporary models within the SMT-Problem. -- --
-- x <- var @RealSort -- y <- var -- assert $ x >? y && y <? (-1) -- res <- checkSat -- case res of -- Unsat -> print "Unsat. Cannot get model." -- r -> do -- model <- getModel -- liftIO $ print $ decode model x --getModel :: MonadIncrSMT s m => m Solution -- | Evaluate any expressions value in the solvers model. Requires a -- Sat or Unknown check-sat response beforehand. -- --
-- x <- var @RealSort -- assert $ x >? 10 -- res <- checkSat -- case res of -- Unsat -> print "Unsat. Cannot get value for x." -- r -> do -- x' <- getValue x -- liftIO $ print $ show r ++ ": x = " ++ show x' --getValue :: (MonadIncrSMT s m, KnownSMTSort t) => Expr t -> m (Maybe (Decoded (Expr t))) -- | First run checkSat and then getModel on the current -- problem. solve :: (MonadIncrSMT s m, MonadIO m) => m (Result, Solution) -- | A MonadState that holds an OMT-Problem. An OMT-Problem is a -- 'SMT-Problem' with additional optimization targets. class MonadSMT s m => MonadOMT s m -- | Minimizes a numerical expression within the OMT-Problem. -- -- For example, below minimization: -- --
-- x <- var @IntSort -- assert $ x >? -2 -- minimize x ---- -- will give x := -1 as solution. minimize :: (MonadOMT s m, KnownSMTSort t, Num (Expr t)) => Expr t -> m () -- | Maximizes a numerical expression within the OMT-Problem. -- -- For example, below maximization: -- --
-- x <- var @(BvSort 8) -- maximize x ---- -- will give x := 11111111 as solution. maximize :: (MonadOMT s m, KnownSMTSort t, Num (Expr t)) => Expr t -> m () -- | Asserts a soft boolean expression. May take a weight and an identifier -- for grouping. -- -- For example, below a soft constraint with weight 2.0 and identifier -- "myId" for grouping: -- --
-- x <- var @BoolSort -- assertSoft x (Just 2.0) (Just "myId") ---- -- Omitting the weight will default it to 1.0. -- --
-- x <- var BoolSort -- y <- var BoolSort -- assertSoft x -- assertSoft y (Just "myId") --assertSoft :: MonadOMT s m => Expr BoolSort -> Maybe Double -> Maybe String -> m () -- | Like assertSoft but forces a weight and omits the group-id. assertSoftWeighted :: MonadOMT s m => Expr BoolSort -> Double -> m () module Language.Hasmtlib.Type.SMT -- | The state of the SMT-problem. data SMT SMT :: {-# UNPACK #-} !Int -> !Seq (SomeKnownSMTSort SMTVar) -> !Seq (Expr BoolSort) -> Maybe String -> [SMTOption] -> SMT -- | Last Id assigned to a new var [_lastVarId] :: SMT -> {-# UNPACK #-} !Int -- | All constructed variables [_vars] :: SMT -> !Seq (SomeKnownSMTSort SMTVar) -- | All asserted formulas [_formulas] :: SMT -> !Seq (Expr BoolSort) -- | Logic for the SMT-Solver [_mlogic] :: SMT -> Maybe String -- | All manually configured SMT-Solver-Options [_options] :: SMT -> [SMTOption] vars :: Lens' SMT (Seq (SomeKnownSMTSort SMTVar)) options :: Lens' SMT [SMTOption] mlogic :: Lens' SMT (Maybe String) lastVarId :: Lens' SMT Int formulas :: Lens' SMT (Seq (Expr 'BoolSort)) renderSetLogic :: Builder -> Builder renderDeclareVar :: forall t. KnownSMTSort t => SMTVar t -> Builder renderAssert :: Expr BoolSort -> Builder renderVars :: Seq (SomeKnownSMTSort SMTVar) -> Seq Builder instance Data.Default.Class.Default Language.Hasmtlib.Type.SMT.SMT instance Control.Monad.State.Class.MonadState Language.Hasmtlib.Type.SMT.SMT m => Language.Hasmtlib.Type.MonadSMT.MonadSMT Language.Hasmtlib.Type.SMT.SMT m instance Language.Hasmtlib.Internal.Render.RenderSeq Language.Hasmtlib.Type.SMT.SMT module Language.Hasmtlib.Type.OMT -- | An assertion of a booolean expression in OMT that may be weighted. data SoftFormula SoftFormula :: Expr BoolSort -> Maybe Double -> Maybe String -> SoftFormula [_formula] :: SoftFormula -> Expr BoolSort [_mWeight] :: SoftFormula -> Maybe Double [_mGroupId] :: SoftFormula -> Maybe String mWeight :: Lens' SoftFormula (Maybe Double) mGroupId :: Lens' SoftFormula (Maybe String) formula :: Lens' SoftFormula (Expr 'BoolSort) -- | A newtype for numerical expressions that are target of a minimization. newtype Minimize t Minimize :: Expr t -> Minimize t [_targetMin] :: Minimize t -> Expr t -- | A newtype for numerical expressions that are target of a maximization. newtype Maximize t Maximize :: Expr t -> Maximize t [_targetMax] :: Maximize t -> Expr t -- | The state of the OMT-problem. data OMT OMT :: SMT -> !Seq (SomeKnownSMTSort Minimize) -> !Seq (SomeKnownSMTSort Maximize) -> !Seq SoftFormula -> OMT -- | The underlying SMT-Problem [_smt] :: OMT -> SMT -- | All expressions to minimize [_targetMinimize] :: OMT -> !Seq (SomeKnownSMTSort Minimize) -- | All expressions to maximize [_targetMaximize] :: OMT -> !Seq (SomeKnownSMTSort Maximize) -- | All soft assertions of boolean expressions [_softFormulas] :: OMT -> !Seq SoftFormula targetMinimize :: Lens' OMT (Seq (SomeKnownSMTSort Minimize)) targetMaximize :: Lens' OMT (Seq (SomeKnownSMTSort Maximize)) softFormulas :: Lens' OMT (Seq SoftFormula) smt :: Lens' OMT SMT instance Data.Default.Class.Default Language.Hasmtlib.Type.OMT.OMT instance Control.Monad.State.Class.MonadState Language.Hasmtlib.Type.OMT.OMT m => Language.Hasmtlib.Type.MonadSMT.MonadSMT Language.Hasmtlib.Type.OMT.OMT m instance Language.Hasmtlib.Type.MonadSMT.MonadSMT Language.Hasmtlib.Type.OMT.OMT m => Language.Hasmtlib.Type.MonadSMT.MonadOMT Language.Hasmtlib.Type.OMT.OMT m instance Language.Hasmtlib.Internal.Render.Render Language.Hasmtlib.Type.OMT.SoftFormula instance Language.Hasmtlib.Type.SMTSort.KnownSMTSort t => Language.Hasmtlib.Internal.Render.Render (Language.Hasmtlib.Type.OMT.Minimize t) instance Language.Hasmtlib.Type.SMTSort.KnownSMTSort t => Language.Hasmtlib.Internal.Render.Render (Language.Hasmtlib.Type.OMT.Maximize t) instance Language.Hasmtlib.Internal.Render.RenderSeq Language.Hasmtlib.Type.OMT.OMT instance GHC.Show.Show Language.Hasmtlib.Type.OMT.SoftFormula module Language.Hasmtlib.Internal.Parser answerParser :: Parser (Result, Solution) resultParser :: Parser Result anyModelParser :: Parser Solution defaultModelParser :: Parser Solution smt2ModelParser :: Parser Solution parseSomeSol :: Parser (SomeKnownOrdSMTSort SMTVarSol) parseSomeSort :: Parser (SomeKnownOrdSMTSort SSMTSort) parseSomeBitVecSort :: Parser (SomeKnownOrdSMTSort SSMTSort) parseSomeArraySort :: Parser (SomeKnownOrdSMTSort SSMTSort) parseExpr' :: forall prxy t. KnownSMTSort t => prxy t -> Parser (Expr t) parseExpr :: forall t. KnownSMTSort t => Parser (Expr t) var :: Parser (Expr t) constant :: forall t. KnownSMTSort t => Parser (HaskellType t) constantExpr :: forall t. KnownSMTSort t => Parser (Expr t) anyBitvector :: KnownNat n => Proxy n -> Parser (Bitvec n) binBitvector :: KnownNat n => Proxy n -> Parser (Bitvec n) hexBitvector :: KnownNat n => Proxy n -> Parser (Bitvec n) literalBitvector :: KnownNat n => Proxy n -> Parser (Bitvec n) constArray :: forall k v. (KnownSMTSort v, Ord (HaskellType k)) => Proxy k -> Proxy v -> Parser (ConstArray (HaskellType k) (HaskellType v)) parseSelect :: forall k v. (KnownSMTSort k, KnownSMTSort v, Ord (HaskellType k)) => Proxy k -> Parser (Expr v) parseStore :: forall k v. (KnownSMTSort k, KnownSMTSort v, Ord (HaskellType k)) => Parser (Expr (ArraySort k v)) unary :: forall t r. KnownSMTSort t => ByteString -> (Expr t -> Expr r) -> Parser (Expr r) binary :: forall t r. KnownSMTSort t => ByteString -> (Expr t -> Expr t -> Expr r) -> Parser (Expr r) nary :: forall t r. KnownSMTSort t => ByteString -> ([Expr t] -> Expr r) -> Parser (Expr r) smtPi :: Parser (Expr RealSort) toRealFun :: Parser (Expr RealSort) toIntFun :: Parser (Expr IntSort) isIntFun :: Parser (Expr BoolSort) smtIte :: forall t. KnownSMTSort t => Parser (Expr t) anyValue :: Num a => Parser a -> Parser a negativeValue :: Num a => Parser a -> Parser a parseRatioDouble :: Parser Double parseToRealDouble :: Parser Double parseBool :: Parser Bool getValueParser :: KnownSMTSort t => SMTVar t -> Parser (SMTVarSol t) module Language.Hasmtlib.Type.Pipe -- | A pipe to the solver. If Solver is Queuing then all -- commands that do not expect an answer are sent to the queue. All -- commands that expect an answer have the queue to be sent to the solver -- before sending the command itself. If Solver is not -- Queuing, all commands are sent to the solver immediately. data Pipe Pipe :: {-# UNPACK #-} !Int -> Maybe String -> !Solver -> Pipe -- | Last Id assigned to a new var [_lastPipeVarId] :: Pipe -> {-# UNPACK #-} !Int -- | Logic for the SMT-Solver [_mPipeLogic] :: Pipe -> Maybe String -- | Active pipe to the backend [_pipe] :: Pipe -> !Solver pipe :: Lens' Pipe Solver mPipeLogic :: Lens' Pipe (Maybe String) lastPipeVarId :: Lens' Pipe Int instance (Control.Monad.State.Class.MonadState Language.Hasmtlib.Type.Pipe.Pipe m, Control.Monad.IO.Class.MonadIO m) => Language.Hasmtlib.Type.MonadSMT.MonadSMT Language.Hasmtlib.Type.Pipe.Pipe m instance (Control.Monad.State.Class.MonadState Language.Hasmtlib.Type.Pipe.Pipe m, Control.Monad.IO.Class.MonadIO m) => Language.Hasmtlib.Type.MonadSMT.MonadIncrSMT Language.Hasmtlib.Type.Pipe.Pipe m instance (Language.Hasmtlib.Type.MonadSMT.MonadSMT Language.Hasmtlib.Type.Pipe.Pipe m, Control.Monad.IO.Class.MonadIO m) => Language.Hasmtlib.Type.MonadSMT.MonadOMT Language.Hasmtlib.Type.Pipe.Pipe m module Language.Hasmtlib.Solver.Common -- | A newtype-wrapper for Config which configures a solver via -- external process. newtype ProcessSolver ProcessSolver :: Config -> ProcessSolver [conf] :: ProcessSolver -> Config -- | Creates a Solver from a ProcessSolver solver :: (RenderSeq s, MonadIO m) => ProcessSolver -> Solver s m -- | Creates a debugging Solver from a ProcessSolver debug :: (RenderSeq s, Default (Debugger s), MonadIO m) => ProcessSolver -> Solver s m -- | Creates an interactive session with a solver by creating and returning -- an alive process-handle Handle. interactiveSolver :: MonadIO m => ProcessSolver -> m (Solver, Handle) -- | A type holding actions for debugging states. data Debugger s Debugger :: (s -> IO ()) -> (Seq Builder -> IO ()) -> (ByteString -> IO ()) -> (ByteString -> IO ()) -> Debugger s [debugState] :: Debugger s -> s -> IO () [debugProblem] :: Debugger s -> Seq Builder -> IO () [debugResultResponse] :: Debugger s -> ByteString -> IO () [debugModelResponse] :: Debugger s -> ByteString -> IO () -- | A Solver which holds an external process with a SMT-Solver. -- This will: -- --
-- import Language.Hasmtlib -- -- main :: IO () -- main = do -- res <- solveWith (solver cvc5) $ do -- setLogic "QF_LIA" -- -- x <- var @IntSort -- -- assert $ x >? 0 -- -- return x -- -- print res --solveWith :: (Monad m, Default s, Codec a) => Solver s m -> StateT s m a -> m (Result, Maybe (Decoded a)) -- | Pipes an SMT-problem interactively to the solver. Enables incremental -- solving by default. Here is a small example of how to use it for -- solving a problem utilizing the solvers incremental stack: -- --
-- import Language.Hasmtlib -- import Control.Monad.IO.Class -- -- main :: IO () -- main = do -- cvc5Living <- interactiveSolver cvc5 -- interactiveWith cvc5Living $ do -- setOption $ Incremental True -- setOption $ ProduceModels True -- setLogic "QF_LIA" -- -- x <- var IntSort -- -- assert $ x >? 0 -- -- (res, sol) <- solve -- liftIO $ print res -- liftIO $ print $ decode sol x -- -- push -- y <- var IntSort -- -- assert $ y <? 0 -- assert $ x === y -- -- res' <- checkSat -- liftIO $ print res' -- pop -- -- res'' <- checkSat -- liftIO $ print res'' -- -- return () --interactiveWith :: (MonadIO m, WithSolver s) => (Solver, Handle) -> StateT s m () -> m () -- | Solves the current problem with respect to a minimal solution for a -- given numerical expression. -- -- Does not rely on MaxSMT/OMT. Instead uses iterative refinement. -- -- If you want access to intermediate results, use -- solveMinimizedDebug instead. solveMinimized :: (MonadIncrSMT Pipe m, MonadIO m, KnownSMTSort t, Orderable (Expr t)) => Expr t -> m (Result, Solution) -- | Like solveMinimized but with access to intermediate results. solveMinimizedDebug :: (MonadIncrSMT Pipe m, MonadIO m, KnownSMTSort t, Orderable (Expr t)) => (Solution -> IO ()) -> Expr t -> m (Result, Solution) -- | Solves the current problem with respect to a maximal solution for a -- given numerical expression. -- -- Does not rely on MaxSMT/OMT. Instead uses iterative refinement. -- -- If you want access to intermediate results, use -- solveMaximizedDebug instead. solveMaximized :: (MonadIncrSMT Pipe m, MonadIO m, KnownSMTSort t, Orderable (Expr t)) => Expr t -> m (Result, Solution) -- | Like solveMaximized but with access to intermediate results. solveMaximizedDebug :: (MonadIncrSMT Pipe m, MonadIO m, KnownSMTSort t, Orderable (Expr t)) => (Solution -> IO ()) -> Expr t -> m (Result, Solution) instance Language.Hasmtlib.Type.Solver.WithSolver Language.Hasmtlib.Type.Pipe.Pipe module Language.Hasmtlib.Variable -- | Construct a variable datum of a data-type by creating variables for -- all its fields. -- --
-- data V3 a = V3 a a a -- instance Variable a => V3 a ---- --
-- >>> varV3 <- variable @(V3 (Expr RealType)) ; varV3 -- V3 (Var RealType) (Var RealType) (Var RealType) --class Variable a variable :: (Variable a, MonadSMT s m) => m a variable :: (Variable a, MonadSMT s m, Applicative f, Traversable f, Variable b, a ~ f b) => m a -- | Wrapper for variable which takes a Proxy variable' :: forall s m a. (MonadSMT s m, Variable a) => Proxy a -> m a instance Language.Hasmtlib.Type.SMTSort.KnownSMTSort t => Language.Hasmtlib.Variable.Variable (Language.Hasmtlib.Internal.Expr.Expr t) instance Language.Hasmtlib.Variable.Variable () instance (Language.Hasmtlib.Variable.Variable a, Language.Hasmtlib.Variable.Variable b) => Language.Hasmtlib.Variable.Variable (a, b) instance (Language.Hasmtlib.Variable.Variable a, Language.Hasmtlib.Variable.Variable b, Language.Hasmtlib.Variable.Variable c) => Language.Hasmtlib.Variable.Variable (a, b, c) instance (Language.Hasmtlib.Variable.Variable a, Language.Hasmtlib.Variable.Variable b, Language.Hasmtlib.Variable.Variable c, Language.Hasmtlib.Variable.Variable d) => Language.Hasmtlib.Variable.Variable (a, b, c, d) instance (Language.Hasmtlib.Variable.Variable a, Language.Hasmtlib.Variable.Variable b, Language.Hasmtlib.Variable.Variable c, Language.Hasmtlib.Variable.Variable d, Language.Hasmtlib.Variable.Variable e) => Language.Hasmtlib.Variable.Variable (a, b, c, d, e) instance (Language.Hasmtlib.Variable.Variable a, Language.Hasmtlib.Variable.Variable b, Language.Hasmtlib.Variable.Variable c, Language.Hasmtlib.Variable.Variable d, Language.Hasmtlib.Variable.Variable e, Language.Hasmtlib.Variable.Variable f) => Language.Hasmtlib.Variable.Variable (a, b, c, d, e, f) instance (Language.Hasmtlib.Variable.Variable a, Language.Hasmtlib.Variable.Variable b, Language.Hasmtlib.Variable.Variable c, Language.Hasmtlib.Variable.Variable d, Language.Hasmtlib.Variable.Variable e, Language.Hasmtlib.Variable.Variable f, Language.Hasmtlib.Variable.Variable g) => Language.Hasmtlib.Variable.Variable (a, b, c, d, e, f, g) instance (Language.Hasmtlib.Variable.Variable a, Language.Hasmtlib.Variable.Variable b, Language.Hasmtlib.Variable.Variable c, Language.Hasmtlib.Variable.Variable d, Language.Hasmtlib.Variable.Variable e, Language.Hasmtlib.Variable.Variable f, Language.Hasmtlib.Variable.Variable g, Language.Hasmtlib.Variable.Variable h) => Language.Hasmtlib.Variable.Variable (a, b, c, d, e, f, g, h) instance Language.Hasmtlib.Variable.Variable a => Language.Hasmtlib.Variable.Variable (GHC.Maybe.Maybe a) instance Language.Hasmtlib.Variable.Variable b => Language.Hasmtlib.Variable.Variable (Data.Either.Either a b) module Language.Hasmtlib