Copyright | (c) Galois Inc 2014-2020. |
---|---|
License | BSD3 |
Maintainer | Joe Hendrix <jhendrix@galois.com> |
Safe Haskell | None |
Language | Haskell2010 |
This defines common definitions used in writing SMTLIB (2.0 and later), and
yices outputs from Expr
values.
The writer is designed to support solvers with arithmetic, propositional logic, bitvector, tuples (aka. structs), and arrays.
It maps complex Expr values to either structs or arrays depending on what the solver supports (structs are preferred if both are supported).
It maps multi-dimensional arrays to either arrays with structs as indices if structs are supported or nested arrays if they are not.
The solver should detect when something is not supported and give an error rather than sending invalid output to a file.
Synopsis
- class Num v => SupportTermOps v where
- boolExpr :: Bool -> v
- notExpr :: v -> v
- andAll :: [v] -> v
- orAll :: [v] -> v
- (.&&) :: v -> v -> v
- (.||) :: v -> v -> v
- (.==) :: v -> v -> v
- (./=) :: v -> v -> v
- impliesExpr :: v -> v -> v
- letExpr :: [(Text, v)] -> v -> v
- ite :: v -> v -> v -> v
- sumExpr :: [v] -> v
- termIntegerToReal :: v -> v
- termRealToInteger :: v -> v
- integerTerm :: Integer -> v
- rationalTerm :: Rational -> v
- (.<=) :: v -> v -> v
- (.<) :: v -> v -> v
- (.>) :: v -> v -> v
- (.>=) :: v -> v -> v
- intAbs :: v -> v
- intDiv :: v -> v -> v
- intMod :: v -> v -> v
- intDivisible :: v -> Natural -> v
- bvTerm :: NatRepr w -> BV w -> v
- bvNeg :: v -> v
- bvAdd :: v -> v -> v
- bvSub :: v -> v -> v
- bvMul :: v -> v -> v
- bvSLe :: v -> v -> v
- bvULe :: v -> v -> v
- bvSLt :: v -> v -> v
- bvULt :: v -> v -> v
- bvUDiv :: v -> v -> v
- bvURem :: v -> v -> v
- bvSDiv :: v -> v -> v
- bvSRem :: v -> v -> v
- bvAnd :: v -> v -> v
- bvOr :: v -> v -> v
- bvXor :: v -> v -> v
- bvNot :: v -> v
- bvShl :: v -> v -> v
- bvLshr :: v -> v -> v
- bvAshr :: v -> v -> v
- bvConcat :: v -> v -> v
- bvExtract :: NatRepr w -> Natural -> Natural -> v -> v
- bvTestBit :: NatRepr w -> Natural -> v -> v
- bvSumExpr :: NatRepr w -> [v] -> v
- floatTerm :: FloatPrecisionRepr fpp -> BigFloat -> v
- floatNeg :: v -> v
- floatAbs :: v -> v
- floatSqrt :: RoundingMode -> v -> v
- floatAdd :: RoundingMode -> v -> v -> v
- floatSub :: RoundingMode -> v -> v -> v
- floatMul :: RoundingMode -> v -> v -> v
- floatDiv :: RoundingMode -> v -> v -> v
- floatRem :: v -> v -> v
- floatFMA :: RoundingMode -> v -> v -> v -> v
- floatEq :: v -> v -> v
- floatFpEq :: v -> v -> v
- floatLe :: v -> v -> v
- floatLt :: v -> v -> v
- floatIsNaN :: v -> v
- floatIsInf :: v -> v
- floatIsZero :: v -> v
- floatIsPos :: v -> v
- floatIsNeg :: v -> v
- floatIsSubnorm :: v -> v
- floatIsNorm :: v -> v
- floatCast :: FloatPrecisionRepr fpp -> RoundingMode -> v -> v
- floatRound :: RoundingMode -> v -> v
- floatFromBinary :: FloatPrecisionRepr fpp -> v -> v
- bvToFloat :: FloatPrecisionRepr fpp -> RoundingMode -> v -> v
- sbvToFloat :: FloatPrecisionRepr fpp -> RoundingMode -> v -> v
- realToFloat :: FloatPrecisionRepr fpp -> RoundingMode -> v -> v
- floatToBV :: Natural -> RoundingMode -> v -> v
- floatToSBV :: Natural -> RoundingMode -> v -> v
- floatToReal :: v -> v
- realIsInteger :: v -> v
- realDiv :: v -> v -> v
- realSin :: v -> v
- realCos :: v -> v
- realATan2 :: v -> v -> v
- realSinh :: v -> v
- realCosh :: v -> v
- realExp :: v -> v
- realLog :: v -> v
- smtFnApp :: v -> [v] -> v
- smtFnUpdate :: Maybe (v -> [v] -> v -> v)
- lambdaTerm :: Maybe ([(Text, Some TypeMap)] -> v -> v)
- fromText :: Text -> v
- type ArrayConstantFn v = [Some TypeMap] -> Some TypeMap -> v -> v
- class SupportTermOps (Term h) => SMTWriter h where
- forallExpr :: [(Text, Some TypeMap)] -> Term h -> Term h
- existsExpr :: [(Text, Some TypeMap)] -> Term h -> Term h
- arrayConstant :: Maybe (ArrayConstantFn (Term h))
- arraySelect :: Term h -> [Term h] -> Term h
- arrayUpdate :: Term h -> [Term h] -> Term h -> Term h
- commentCommand :: f h -> Builder -> Command h
- assertCommand :: f h -> Term h -> Command h
- assertNamedCommand :: f h -> Term h -> Text -> Command h
- pushCommand :: f h -> Command h
- popCommand :: f h -> Command h
- popManyCommands :: f h -> Int -> [Command h]
- resetCommand :: f h -> Command h
- checkCommands :: f h -> [Command h]
- checkWithAssumptionsCommands :: f h -> [Text] -> [Command h]
- getUnsatAssumptionsCommand :: f h -> Command h
- getUnsatCoreCommand :: f h -> Command h
- setOptCommand :: f h -> Text -> Text -> Command h
- declareCommand :: f h -> Text -> Assignment TypeMap args -> TypeMap rtp -> Command h
- defineCommand :: f h -> Text -> [(Text, Some TypeMap)] -> TypeMap rtp -> Term h -> Command h
- declareStructDatatype :: WriterConn t h -> Assignment TypeMap args -> IO ()
- structCtor :: Assignment TypeMap args -> [Term h] -> Term h
- structProj :: Assignment TypeMap args -> Index args tp -> Term h -> Term h
- stringTerm :: ByteString -> Term h
- stringLength :: Term h -> Term h
- stringIndexOf :: Term h -> Term h -> Term h -> Term h
- stringContains :: Term h -> Term h -> Term h
- stringIsPrefixOf :: Term h -> Term h -> Term h
- stringIsSuffixOf :: Term h -> Term h -> Term h
- stringSubstring :: Term h -> Term h -> Term h -> Term h
- stringAppend :: [Term h] -> Term h
- resetDeclaredStructs :: WriterConn t h -> IO ()
- writeCommand :: WriterConn t h -> Command h -> IO ()
- class SMTWriter h => SMTReadWriter h where
- smtEvalFuns :: WriterConn t h -> InputStream Text -> SMTEvalFunctions h
- smtSatResult :: f h -> InputStream Text -> IO (SatResult () ())
- smtUnsatCoreResult :: f h -> InputStream Text -> IO [Text]
- smtUnsatAssumptionsResult :: f h -> InputStream Text -> IO [(Bool, Text)]
- type SMTEvalBVArrayFn h w v = (1 <= w, 1 <= v) => NatRepr w -> NatRepr v -> Term h -> IO (Maybe (GroundArray (SingleCtx (BaseBVType w)) (BaseBVType v)))
- newtype SMTEvalBVArrayWrapper h = SMTEvalBVArrayWrapper {
- unEvalBVArrayWrapper :: forall w v. SMTEvalBVArrayFn h w v
- type family Term (h :: Type) :: Type
- app :: Builder -> [Builder] -> Builder
- app_list :: Builder -> [Builder] -> Builder
- builder_list :: [Builder] -> Builder
- data WriterConn t (h :: Type)
- connState :: WriterConn t h -> h
- newWriterConn :: OutputStream Text -> InputStream Text -> AcknowledgementAction t cs -> String -> ProblemFeatures -> SymbolVarBimap t -> cs -> IO (WriterConn t cs)
- resetEntryStack :: WriterConn t h -> IO ()
- popEntryStackToTop :: WriterConn t h -> IO Int
- entryStackHeight :: WriterConn t h -> IO Int
- pushEntryStack :: WriterConn t h -> IO ()
- popEntryStack :: WriterConn t h -> IO ()
- type family Command (h :: Type) :: Type
- addCommand :: SMTWriter h => WriterConn t h -> Command h -> IO ()
- addCommandNoAck :: SMTWriter h => WriterConn t h -> Command h -> IO ()
- addCommands :: SMTWriter h => WriterConn t h -> [Command h] -> IO ()
- mkFreeVar :: SMTWriter h => WriterConn t h -> Assignment TypeMap args -> TypeMap rtp -> IO Text
- bindVarAsFree :: SMTWriter h => WriterConn t h -> ExprBoundVar t tp -> IO ()
- data TypeMap (tp :: BaseType) where
- BoolTypeMap :: TypeMap BaseBoolType
- IntegerTypeMap :: TypeMap BaseIntegerType
- RealTypeMap :: TypeMap BaseRealType
- BVTypeMap :: 1 <= w => !(NatRepr w) -> TypeMap (BaseBVType w)
- FloatTypeMap :: !(FloatPrecisionRepr fpp) -> TypeMap (BaseFloatType fpp)
- Char8TypeMap :: TypeMap (BaseStringType Char8)
- ComplexToStructTypeMap :: TypeMap BaseComplexType
- ComplexToArrayTypeMap :: TypeMap BaseComplexType
- PrimArrayTypeMap :: !(Assignment TypeMap (idxl ::> idx)) -> !(TypeMap tp) -> TypeMap (BaseArrayType (idxl ::> idx) tp)
- FnArrayTypeMap :: !(Assignment TypeMap (idxl ::> idx)) -> TypeMap tp -> TypeMap (BaseArrayType (idxl ::> idx) tp)
- StructTypeMap :: !(Assignment TypeMap idx) -> TypeMap (BaseStructType idx)
- typeMap :: WriterConn t h -> BaseTypeRepr tp -> Either BaseTypeError (TypeMap tp)
- freshBoundVarName :: SMTWriter h => WriterConn t h -> DefineStyle -> [(Text, Some TypeMap)] -> TypeMap rtp -> Term h -> IO Text
- assumeFormula :: SMTWriter h => WriterConn t h -> Term h -> IO ()
- assumeFormulaWithName :: SMTWriter h => WriterConn t h -> Term h -> Text -> IO ()
- assumeFormulaWithFreshName :: SMTWriter h => WriterConn t h -> Term h -> IO Text
- data DefineStyle
- newtype AcknowledgementAction t h = AckAction {
- runAckAction :: WriterConn t h -> Command h -> IO ()
- nullAcknowledgementAction :: AcknowledgementAction t h
- assume :: SMTWriter h => WriterConn t h -> BoolExpr t -> IO ()
- mkSMTTerm :: SMTWriter h => WriterConn t h -> Expr t tp -> IO (Term h)
- mkFormula :: SMTWriter h => WriterConn t h -> BoolExpr t -> IO (Term h)
- mkAtomicFormula :: SMTWriter h => WriterConn t h -> BoolExpr t -> IO Text
- data SMTEvalFunctions h = SMTEvalFunctions {
- smtEvalBool :: Term h -> IO Bool
- smtEvalBV :: forall w. NatRepr w -> Term h -> IO (BV w)
- smtEvalReal :: Term h -> IO Rational
- smtEvalFloat :: forall fpp. FloatPrecisionRepr fpp -> Term h -> IO (BV (FloatPrecisionBits fpp))
- smtEvalBvArray :: Maybe (SMTEvalBVArrayWrapper h)
- smtEvalString :: Term h -> IO ByteString
- smtExprGroundEvalFn :: forall t h. SMTWriter h => WriterConn t h -> SMTEvalFunctions h -> IO (GroundEvalFn t)
- data CollectorResults h a = CollectorResults {
- crResult :: !a
- crBindings :: ![(Text, Term h)]
- crFreeConstants :: ![(Text, Some TypeMap)]
- crSideConds :: ![Term h]
- mkBaseExpr :: SMTWriter h => Expr t tp -> SMTCollector t h (Term h)
- runInSandbox :: SupportTermOps (Term h) => WriterConn t h -> SMTCollector t h a -> IO (CollectorResults h a)
- data RoundingMode
Type classes
class Num v => SupportTermOps v where Source #
A class of values containing rational and operations.
boolExpr, notExpr, andAll, orAll, (.==), letExpr, ite, termIntegerToReal, termRealToInteger, integerTerm, rationalTerm, (.<=), intAbs, intDiv, intMod, intDivisible, bvTerm, bvNeg, bvAdd, bvSub, bvMul, bvSLe, bvULe, bvSLt, bvULt, bvUDiv, bvURem, bvSDiv, bvSRem, bvAnd, bvOr, bvXor, bvNot, bvShl, bvLshr, bvAshr, bvConcat, bvExtract, floatTerm, floatNeg, floatAbs, floatSqrt, floatAdd, floatSub, floatMul, floatDiv, floatRem, floatFMA, floatEq, floatFpEq, floatLe, floatLt, floatIsNaN, floatIsInf, floatIsZero, floatIsPos, floatIsNeg, floatIsSubnorm, floatIsNorm, floatCast, floatRound, floatFromBinary, bvToFloat, sbvToFloat, realToFloat, floatToBV, floatToSBV, floatToReal, realIsInteger, realDiv, realSin, realCos, realATan2, realSinh, realCosh, realExp, realLog, smtFnApp, fromText
boolExpr :: Bool -> v Source #
(.&&) :: v -> v -> v infixr 3 Source #
(.||) :: v -> v -> v infixr 2 Source #
(.==) :: v -> v -> v infix 4 Source #
Compare two elements for equality.
(./=) :: v -> v -> v infix 4 Source #
Compare two elements for in-equality.
impliesExpr :: v -> v -> v Source #
letExpr :: [(Text, v)] -> v -> v Source #
Create a let expression. This is a "sequential" let, which is syntactic sugar for a nested series of single let bindings. As a consequence, bound variables are in scope for the right-hand-sides of subsequent bindings.
ite :: v -> v -> v -> v Source #
Create an if-then-else expression.
Add a list of values together.
termIntegerToReal :: v -> v Source #
Convert an integer expression to a real.
termRealToInteger :: v -> v Source #
Convert a real expression to an integer.
integerTerm :: Integer -> v Source #
Convert an integer to a term.
rationalTerm :: Rational -> v Source #
Convert a rational to a term.
(.<=) :: v -> v -> v infix 4 Source #
Less-then-or-equal
(.<) :: v -> v -> v infix 4 Source #
Less-then
(.>) :: v -> v -> v infix 4 Source #
Greater then
(.>=) :: v -> v -> v infix 4 Source #
Greater then or equal
Integer theory terms
intDiv :: v -> v -> v Source #
intMod :: v -> v -> v Source #
intDivisible :: v -> Natural -> v Source #
bvTerm :: NatRepr w -> BV w -> v Source #
Create expression from bitvector.
bvUDiv :: v -> v -> v Source #
bvURem :: v -> v -> v Source #
bvSDiv :: v -> v -> v Source #
bvSRem :: v -> v -> v Source #
bvLshr :: v -> v -> v Source #
bvAshr :: v -> v -> v Source #
bvConcat :: v -> v -> v Source #
Concatenate two bitvectors together.
bvExtract :: NatRepr w -> Natural -> Natural -> v -> v Source #
bvExtract w i n v
extracts bits [i..i+n) from v
as a new
bitvector. v
must contain at least w
elements, and i+n
must be less than or equal to w
. The result has n
elements.
The least significant bit of v
should have index 0
.
bvTestBit :: NatRepr w -> Natural -> v -> v Source #
bvTestBit w i x
returns predicate that holds if bit i
in x
is set to true. w
should be the number of bits in x
.
bvSumExpr :: NatRepr w -> [v] -> v Source #
floatTerm :: FloatPrecisionRepr fpp -> BigFloat -> v Source #
floatSqrt :: RoundingMode -> v -> v Source #
floatAdd :: RoundingMode -> v -> v -> v Source #
floatSub :: RoundingMode -> v -> v -> v Source #
floatMul :: RoundingMode -> v -> v -> v Source #
floatDiv :: RoundingMode -> v -> v -> v Source #
floatRem :: v -> v -> v Source #
floatFMA :: RoundingMode -> v -> v -> v -> v Source #
floatEq :: v -> v -> v Source #
floatFpEq :: v -> v -> v Source #
floatLe :: v -> v -> v Source #
floatLt :: v -> v -> v Source #
floatIsNaN :: v -> v Source #
floatIsInf :: v -> v Source #
floatIsZero :: v -> v Source #
floatIsPos :: v -> v Source #
floatIsNeg :: v -> v Source #
floatIsSubnorm :: v -> v Source #
floatIsNorm :: v -> v Source #
floatCast :: FloatPrecisionRepr fpp -> RoundingMode -> v -> v Source #
floatRound :: RoundingMode -> v -> v Source #
floatFromBinary :: FloatPrecisionRepr fpp -> v -> v Source #
bvToFloat :: FloatPrecisionRepr fpp -> RoundingMode -> v -> v Source #
sbvToFloat :: FloatPrecisionRepr fpp -> RoundingMode -> v -> v Source #
realToFloat :: FloatPrecisionRepr fpp -> RoundingMode -> v -> v Source #
floatToBV :: Natural -> RoundingMode -> v -> v Source #
floatToSBV :: Natural -> RoundingMode -> v -> v Source #
floatToReal :: v -> v Source #
realIsInteger :: v -> v Source #
Predicate that holds if a real number is an integer.
realDiv :: v -> v -> v Source #
realATan2 :: v -> v -> v Source #
smtFnApp :: v -> [v] -> v Source #
Apply the arguments to the given function.
smtFnUpdate :: Maybe (v -> [v] -> v -> v) Source #
Update a function value to return a new value at the given point.
This may be Nothing if solver has no builtin function for update.
lambdaTerm :: Maybe ([(Text, Some TypeMap)] -> v -> v) Source #
Function for creating a lambda term if output supports it.
Yices support lambda expressions, but SMTLIB2 does not. The function takes arguments and the expression.
Instances
type ArrayConstantFn v Source #
class SupportTermOps (Term h) => SMTWriter h where Source #
Typeclass need to generate SMTLIB commands.
forallExpr, existsExpr, arraySelect, arrayUpdate, commentCommand, assertCommand, assertNamedCommand, pushCommand, popCommand, resetCommand, checkCommands, checkWithAssumptionsCommands, getUnsatAssumptionsCommand, getUnsatCoreCommand, setOptCommand, declareCommand, defineCommand, declareStructDatatype, structCtor, structProj, stringTerm, stringLength, stringIndexOf, stringContains, stringIsPrefixOf, stringIsSuffixOf, stringSubstring, stringAppend, resetDeclaredStructs, writeCommand
forallExpr :: [(Text, Some TypeMap)] -> Term h -> Term h Source #
Create a forall expression
existsExpr :: [(Text, Some TypeMap)] -> Term h -> Term h Source #
Create an exists expression
arrayConstant :: Maybe (ArrayConstantFn (Term h)) Source #
Create a constant array
This may return Nothing if the solver does not support constant arrays.
arraySelect :: Term h -> [Term h] -> Term h Source #
Select an element from an array
arrayUpdate :: Term h -> [Term h] -> Term h -> Term h Source #
'arrayUpdate a i v' returns an array that contains value v
at
index i
, and the same value as in a
at every other index.
commentCommand :: f h -> Builder -> Command h Source #
Create a command that just defines a comment.
assertCommand :: f h -> Term h -> Command h Source #
Create a command that asserts a formula.
assertNamedCommand :: f h -> Term h -> Text -> Command h Source #
Create a command that asserts a formula and attaches the given name to it (primarily for the purposes of later reporting unsatisfiable cores).
pushCommand :: f h -> Command h Source #
Push 1 new scope
popCommand :: f h -> Command h Source #
Pop 1 existing scope
popManyCommands :: f h -> Int -> [Command h] Source #
Pop several scopes.
resetCommand :: f h -> Command h Source #
Reset the solver state, forgetting all pushed frames and assertions
checkCommands :: f h -> [Command h] Source #
Check if the current set of assumption is satisfiable. May require multiple commands. The intial commands require an ack. The last one does not.
checkWithAssumptionsCommands :: f h -> [Text] -> [Command h] Source #
Check if a collection of assumptions is satisfiable in the current context. The assumptions must be given as the names of literals already in scope.
getUnsatAssumptionsCommand :: f h -> Command h Source #
Ask the solver to return an unsatisfiable core from among the assumptions passed into the previous "check with assumptions" command.
getUnsatCoreCommand :: f h -> Command h Source #
Ask the solver to return an unsatisfiable core from among the named assumptions
previously asserted using the assertNamedCommand
after an unsatisfiable
checkCommand
.
setOptCommand :: f h -> Text -> Text -> Command h Source #
Set an option/parameter.
declareCommand :: f h -> Text -> Assignment TypeMap args -> TypeMap rtp -> Command h Source #
Declare a new symbol with the given name, arguments types, and result type.
Define a new symbol with the given name, arguments, result type, and associated expression.
The argument contains the variable name and the type of the variable.
declareStructDatatype :: WriterConn t h -> Assignment TypeMap args -> IO () Source #
Declare a struct datatype if is has not been already given the number of arguments in the struct.
structCtor :: Assignment TypeMap args -> [Term h] -> Term h Source #
Build a struct term with the given types and fields
structProj :: Assignment TypeMap args -> Index args tp -> Term h -> Term h Source #
Project a field from a struct with the given types
stringTerm :: ByteString -> Term h Source #
Produce a term representing a string literal
stringLength :: Term h -> Term h Source #
Compute the length of a term
stringIndexOf :: Term h -> Term h -> Term h -> Term h Source #
stringIndexOf s t i
computes the first index following or at i
where t
appears within s
as a substring, or -1 if no such
index exists
stringContains :: Term h -> Term h -> Term h Source #
Test if the first string contains the second string
stringIsPrefixOf :: Term h -> Term h -> Term h Source #
Test if the first string is a prefix of the second string
stringIsSuffixOf :: Term h -> Term h -> Term h Source #
Test if the first string is a suffix of the second string
stringSubstring :: Term h -> Term h -> Term h -> Term h Source #
stringSubstring s off len
extracts the substring of s
starting at index off
and
having length len
. The result of this operation is undefined if off
and len
to not specify a valid substring of s
; in particular, we must have off+len <= length(s)
.
stringAppend :: [Term h] -> Term h Source #
Append the given strings
resetDeclaredStructs :: WriterConn t h -> IO () Source #
Forget all previously-declared struct types.
writeCommand :: WriterConn t h -> Command h -> IO () Source #
Write a command to the connection.
Instances
class SMTWriter h => SMTReadWriter h where Source #
Used when we need two way communication with the solver.
smtEvalFuns :: WriterConn t h -> InputStream Text -> SMTEvalFunctions h Source #
Get functions for parsing values out of the solver.
smtSatResult :: f h -> InputStream Text -> IO (SatResult () ()) Source #
Parse a set result from the solver's response.
smtUnsatCoreResult :: f h -> InputStream Text -> IO [Text] Source #
Parse a list of names of assumptions that form an unsatisfiable core. These correspond to previously-named assertions.
smtUnsatAssumptionsResult :: f h -> InputStream Text -> IO [(Bool, Text)] Source #
Parse a list of names of assumptions that form an unsatisfiable core. The boolean indicates the polarity of the atom: true for an ordinary atom, false for a negated atom.
Instances
SMTReadWriter Connection Source # | |
Defined in What4.Solver.Yices smtEvalFuns :: WriterConn t Connection -> InputStream Text -> SMTEvalFunctions Connection Source # smtSatResult :: f Connection -> InputStream Text -> IO (SatResult () ()) Source # smtUnsatCoreResult :: f Connection -> InputStream Text -> IO [Text] Source # smtUnsatAssumptionsResult :: f Connection -> InputStream Text -> IO [(Bool, Text)] Source # | |
SMTLib2Tweaks a => SMTReadWriter (Writer a) Source # | |
Defined in What4.Protocol.SMTLib2 smtEvalFuns :: WriterConn t (Writer a) -> InputStream Text -> SMTEvalFunctions (Writer a) Source # smtSatResult :: f (Writer a) -> InputStream Text -> IO (SatResult () ()) Source # smtUnsatCoreResult :: f (Writer a) -> InputStream Text -> IO [Text] Source # smtUnsatAssumptionsResult :: f (Writer a) -> InputStream Text -> IO [(Bool, Text)] Source # |
type SMTEvalBVArrayFn h w v = (1 <= w, 1 <= v) => NatRepr w -> NatRepr v -> Term h -> IO (Maybe (GroundArray (SingleCtx (BaseBVType w)) (BaseBVType v))) Source #
newtype SMTEvalBVArrayWrapper h Source #
SMTEvalBVArrayWrapper | |
|
Terms
type family Term (h :: Type) :: Type Source #
A term in the output language.
Instances
type Term Connection Source # | |
Defined in What4.Solver.Yices | |
type Term (Writer a) Source # | |
Defined in What4.Protocol.SMTLib2 |
builder_list :: [Builder] -> Builder Source #
SMTWriter
data WriterConn t (h :: Type) Source #
connState :: WriterConn t h -> h Source #
The specific connection information.
:: OutputStream Text | Stream to write queries onto |
-> InputStream Text | Input stream to read responses from
(may be the |
-> AcknowledgementAction t cs | An action to consume solver acknowledgement responses |
-> String | Name of solver for reporting purposes. |
-> ProblemFeatures | Indicates what features are supported by the solver. |
-> SymbolVarBimap t | A bijective mapping between variables and their canonical name (if any). |
-> cs | State information specific to the type of connection |
-> IO (WriterConn t cs) |
resetEntryStack :: WriterConn t h -> IO () Source #
Clear the entry stack, and start with a fresh one.
popEntryStackToTop :: WriterConn t h -> IO Int Source #
Pop all but the topmost stack entry. Return the number of entries on the stack prior to popping.
entryStackHeight :: WriterConn t h -> IO Int Source #
Return the number of pushed stack frames. Note, this is one fewer than the number of entries in the stack beacuse the base entry is the top-level context that is not in the scope of any push.
pushEntryStack :: WriterConn t h -> IO () Source #
Push a new frame to the stack for maintaining the writer cache.
popEntryStack :: WriterConn t h -> IO () Source #
type family Command (h :: Type) :: Type Source #
Instances
type Command Connection Source # | |
Defined in What4.Solver.Yices | |
type Command (Writer a) Source # | |
Defined in What4.Protocol.SMTLib2 |
addCommand :: SMTWriter h => WriterConn t h -> Command h -> IO () Source #
Write a command to the connection along with position information if it differs from the last position.
addCommandNoAck :: SMTWriter h => WriterConn t h -> Command h -> IO () Source #
addCommands :: SMTWriter h => WriterConn t h -> [Command h] -> IO () Source #
Write a sequence of commands. All but the last should have acknowledgement.
mkFreeVar :: SMTWriter h => WriterConn t h -> Assignment TypeMap args -> TypeMap rtp -> IO Text Source #
Create a new variable with the given name.
bindVarAsFree :: SMTWriter h => WriterConn t h -> ExprBoundVar t tp -> IO () Source #
Consider the bound variable as free within the current assumption frame.
data TypeMap (tp :: BaseType) where Source #
TypeMap
defines how a given BaseType
maps to an SMTLIB type.
It is necessary as there may be several ways in which a base type can be encoded.
BoolTypeMap :: TypeMap BaseBoolType | |
IntegerTypeMap :: TypeMap BaseIntegerType | |
RealTypeMap :: TypeMap BaseRealType | |
BVTypeMap :: 1 <= w => !(NatRepr w) -> TypeMap (BaseBVType w) | |
FloatTypeMap :: !(FloatPrecisionRepr fpp) -> TypeMap (BaseFloatType fpp) | |
Char8TypeMap :: TypeMap (BaseStringType Char8) | |
ComplexToStructTypeMap :: TypeMap BaseComplexType | |
ComplexToArrayTypeMap :: TypeMap BaseComplexType | |
PrimArrayTypeMap :: !(Assignment TypeMap (idxl ::> idx)) -> !(TypeMap tp) -> TypeMap (BaseArrayType (idxl ::> idx) tp) | |
FnArrayTypeMap :: !(Assignment TypeMap (idxl ::> idx)) -> TypeMap tp -> TypeMap (BaseArrayType (idxl ::> idx) tp) | |
StructTypeMap :: !(Assignment TypeMap idx) -> TypeMap (BaseStructType idx) |
typeMap :: WriterConn t h -> BaseTypeRepr tp -> Either BaseTypeError (TypeMap tp) Source #
Given a solver connection and a base type repr, typeMap
attempts to
find the best encoding for a variable of that type supported by teh solver.
:: SMTWriter h | |
=> WriterConn t h | |
-> DefineStyle | |
-> [(Text, Some TypeMap)] | Names of variables in term and associated type. |
-> TypeMap rtp | Type of expression. |
-> Term h | |
-> IO Text |
Create a variable name eqivalent to the given expression.
assumeFormula :: SMTWriter h => WriterConn t h -> Term h -> IO () Source #
Assume that the given formula holds.
assumeFormulaWithName :: SMTWriter h => WriterConn t h -> Term h -> Text -> IO () Source #
assumeFormulaWithFreshName :: SMTWriter h => WriterConn t h -> Term h -> IO Text Source #
data DefineStyle Source #
Instances
Eq DefineStyle Source # | |
Defined in What4.Protocol.SMTWriter (==) :: DefineStyle -> DefineStyle -> Bool # (/=) :: DefineStyle -> DefineStyle -> Bool # | |
Show DefineStyle Source # | |
Defined in What4.Protocol.SMTWriter showsPrec :: Int -> DefineStyle -> ShowS # show :: DefineStyle -> String # showList :: [DefineStyle] -> ShowS # |
newtype AcknowledgementAction t h Source #
An action for consuming an acknowledgement message from the solver, if it is configured to produce ack messages.
AckAction | |
|
nullAcknowledgementAction :: AcknowledgementAction t h Source #
An acknowledgement action that does nothing
SMTWriter operations
assume :: SMTWriter h => WriterConn t h -> BoolExpr t -> IO () Source #
Write assume formula predicates for asserting predicate holds.
mkSMTTerm :: SMTWriter h => WriterConn t h -> Expr t tp -> IO (Term h) Source #
Write a expression to SMT
mkFormula :: SMTWriter h => WriterConn t h -> BoolExpr t -> IO (Term h) Source #
Write a logical expression.
mkAtomicFormula :: SMTWriter h => WriterConn t h -> BoolExpr t -> IO Text Source #
data SMTEvalFunctions h Source #
SMTEvalFunctions | |
|
:: forall t h. SMTWriter h | |
=> WriterConn t h | Connection to SMT solver. |
-> SMTEvalFunctions h | |
-> IO (GroundEvalFn t) |
The function creates a function for evaluating elts to concrete values given a connection to an SMT solver along with some functions for evaluating different types of terms to concrete values.
data CollectorResults h a Source #
This describes the result that was collected from the solver.
CollectorResults | |
|
mkBaseExpr :: SMTWriter h => Expr t tp -> SMTCollector t h (Term h) Source #
Convert an element to a base expression.
runInSandbox :: SupportTermOps (Term h) => WriterConn t h -> SMTCollector t h a -> IO (CollectorResults h a) Source #
This runs the side collector and collects the results.
Reexports
data RoundingMode Source #
Rounding modes for IEEE-754 floating point operations.
RNE | Round to nearest even. |
RNA | Round to nearest away. |
RTP | Round toward plus Infinity. |
RTN | Round toward minus Infinity. |
RTZ | Round toward zero. |