Copyright | (c) Iago Abal, 2013 (c) David Castro, 2013 |
---|---|
License | BSD3 |
Maintainer | Iago Abal <iago.abal@gmail.com>, David Castro <david.castro.dcp@gmail.com> |
Safe Haskell | None |
Language | Haskell98 |
A simple monadic wrapper for Base
.
- class (Monad m, MonadIO m) => MonadZ3 m where
- getSolver :: m (Maybe Solver)
- getContext :: m Context
- data Z3 a
- module Z3.Opts
- data Logic
- evalZ3 :: Z3 a -> IO a
- evalZ3With :: Maybe Logic -> Opts -> Z3 a -> IO a
- data Symbol
- data AST
- data Sort
- data FuncDecl
- data App
- data Pattern
- data Model
- data Result
- mkStringSymbol :: MonadZ3 z3 => String -> z3 Symbol
- mkBoolSort :: MonadZ3 z3 => z3 Sort
- mkIntSort :: MonadZ3 z3 => z3 Sort
- mkRealSort :: MonadZ3 z3 => z3 Sort
- mkFuncDecl :: MonadZ3 z3 => Symbol -> [Sort] -> Sort -> z3 FuncDecl
- mkApp :: MonadZ3 z3 => FuncDecl -> [AST] -> z3 AST
- mkConst :: MonadZ3 z3 => Symbol -> Sort -> z3 AST
- mkTrue :: MonadZ3 z3 => z3 AST
- mkFalse :: MonadZ3 z3 => z3 AST
- mkEq :: MonadZ3 z3 => AST -> AST -> z3 AST
- mkNot :: MonadZ3 z3 => AST -> z3 AST
- mkIte :: MonadZ3 z3 => AST -> AST -> AST -> z3 AST
- mkIff :: MonadZ3 z3 => AST -> AST -> z3 AST
- mkImplies :: MonadZ3 z3 => AST -> AST -> z3 AST
- mkXor :: MonadZ3 z3 => AST -> AST -> z3 AST
- mkAnd :: MonadZ3 z3 => [AST] -> z3 AST
- mkOr :: MonadZ3 z3 => [AST] -> z3 AST
- mkDistinct :: MonadZ3 z3 => [AST] -> z3 AST
- mkAdd :: MonadZ3 z3 => [AST] -> z3 AST
- mkMul :: MonadZ3 z3 => [AST] -> z3 AST
- mkSub :: MonadZ3 z3 => [AST] -> z3 AST
- mkUnaryMinus :: MonadZ3 z3 => AST -> z3 AST
- mkDiv :: MonadZ3 z3 => AST -> AST -> z3 AST
- mkMod :: MonadZ3 z3 => AST -> AST -> z3 AST
- mkRem :: MonadZ3 z3 => AST -> AST -> z3 AST
- mkLt :: MonadZ3 z3 => AST -> AST -> z3 AST
- mkLe :: MonadZ3 z3 => AST -> AST -> z3 AST
- mkGt :: MonadZ3 z3 => AST -> AST -> z3 AST
- mkGe :: MonadZ3 z3 => AST -> AST -> z3 AST
- mkInt2Real :: MonadZ3 z3 => AST -> z3 AST
- mkReal2Int :: MonadZ3 z3 => AST -> z3 AST
- mkIsInt :: MonadZ3 z3 => AST -> z3 AST
- mkNumeral :: MonadZ3 z3 => String -> Sort -> z3 AST
- mkInt :: (MonadZ3 z3, Integral a) => a -> z3 AST
- mkReal :: (MonadZ3 z3, Real r) => r -> z3 AST
- mkPattern :: MonadZ3 z3 => [AST] -> z3 Pattern
- mkBound :: MonadZ3 z3 => Int -> Sort -> z3 AST
- mkForall :: MonadZ3 z3 => [Pattern] -> [Symbol] -> [Sort] -> AST -> z3 AST
- mkExists :: MonadZ3 z3 => [Pattern] -> [Symbol] -> [Sort] -> AST -> z3 AST
- getBool :: MonadZ3 z3 => AST -> z3 (Maybe Bool)
- getInt :: MonadZ3 z3 => AST -> z3 Integer
- getReal :: MonadZ3 z3 => AST -> z3 Rational
- eval :: MonadZ3 z3 => Model -> AST -> z3 (Maybe AST)
- evalT :: (MonadZ3 z3, Traversable t) => Model -> t AST -> z3 (Maybe (t AST))
- showModel :: MonadZ3 z3 => Model -> z3 String
- showContext :: MonadZ3 z3 => z3 String
- assertCnstr :: MonadZ3 z3 => AST -> z3 ()
- check :: MonadZ3 z3 => z3 Result
- getModel :: MonadZ3 z3 => z3 (Result, Maybe Model)
- delModel :: MonadZ3 z3 => Model -> z3 ()
- withModel :: (Applicative z3, MonadZ3 z3) => (Model -> z3 a) -> z3 (Result, Maybe a)
- push :: MonadZ3 z3 => z3 ()
- pop :: MonadZ3 z3 => Int -> z3 ()
- data ASTPrintMode
- setASTPrintMode :: MonadZ3 z3 => ASTPrintMode -> z3 ()
- astToString :: MonadZ3 z3 => AST -> z3 String
- patternToString :: MonadZ3 z3 => Pattern -> z3 String
- sortToString :: MonadZ3 z3 => Sort -> z3 String
- funcDeclToString :: MonadZ3 z3 => FuncDecl -> z3 String
Documentation
module Z3.Opts
Warning: New Z3 API support is still incomplete and fragile: you may experience segmentation faults!
Solvers available in Z3.
These are described at http://smtlib.cs.uiowa.edu/logics.html
WARNING: Support for solvers is fragile, you may experience segmentation faults!
AUFLIA | Closed formulas over the theory of linear integer arithmetic and arrays extended with free sort and function symbols but restricted to arrays with integer indices and values. |
AUFLIRA | Closed linear formulas with free sort and function symbols over one- and two-dimentional arrays of integer index and real value. |
AUFNIRA | Closed formulas with free function and predicate symbols over a theory of arrays of arrays of integer index and real value. |
LRA | Closed linear formulas in linear real arithmetic. |
QF_ABV | Closed quantifier-free formulas over the theory of bitvectors and bitvector arrays. |
QF_AUFBV | Closed quantifier-free formulas over the theory of bitvectors and bitvector arrays extended with free sort and function symbols. |
QF_AUFLIA | Closed quantifier-free linear formulas over the theory of integer arrays extended with free sort and function symbols. |
QF_AX | Closed quantifier-free formulas over the theory of arrays with extensionality. |
QF_BV | Closed quantifier-free formulas over the theory of fixed-size bitvectors. |
QF_IDL | Difference Logic over the integers. In essence, Boolean combinations of inequations of the form x - y < b where x and y are integer variables and b is an integer constant. |
QF_LIA | Unquantified linear integer arithmetic. In essence, Boolean combinations of inequations between linear polynomials over integer variables. |
QF_LRA | Unquantified linear real arithmetic. In essence, Boolean combinations of inequations between linear polynomials over real variables. |
QF_NIA | Quantifier-free integer arithmetic. |
QF_NRA | Quantifier-free real arithmetic. |
QF_RDL | Difference Logic over the reals. In essence, Boolean combinations of inequations of the form x - y < b where x and y are real variables and b is a rational constant. |
QF_UF | Unquantified formulas built over a signature of uninterpreted (i.e., free) sort and function symbols. |
QF_UFBV | Unquantified formulas over bitvectors with uninterpreted sort function and symbols. |
QF_UFIDL | Difference Logic over the integers (in essence) but with uninterpreted sort and function symbols. |
QF_UFLIA | Unquantified linear integer arithmetic with uninterpreted sort and function symbols. |
QF_UFLRA | Unquantified linear real arithmetic with uninterpreted sort and function symbols. |
QF_UFNRA | Unquantified non-linear real arithmetic with uninterpreted sort and function symbols. |
UFLRA | Linear real arithmetic with uninterpreted sort and function symbols. |
UFNIA | Non-linear integer arithmetic with uninterpreted sort and function symbols. |
Types
Kind of AST used to represent function symbols.
A kind of Z3 AST used to represent constant and function declarations.
A kind of AST used to represent pattern and multi-patterns used to guide quantifier instantiation.
Satisfiability result
Result of a satisfiability check.
Symbols
mkStringSymbol :: MonadZ3 z3 => String -> z3 Symbol Source
Create a Z3 symbol using a string.
Sorts
mkBoolSort :: MonadZ3 z3 => z3 Sort Source
Create the boolean type.
mkRealSort :: MonadZ3 z3 => z3 Sort Source
Create the real type.
Constants and Applications
mkIte :: MonadZ3 z3 => AST -> AST -> AST -> z3 AST Source
Create an AST node representing an if-then-else: ite(t1, t2, t3).
mkImplies :: MonadZ3 z3 => AST -> AST -> z3 AST Source
Create an AST node representing t1 implies t2.
mkAnd :: MonadZ3 z3 => [AST] -> z3 AST Source
Create an AST node representing args[0] and ... and args[num_args-1].
mkOr :: MonadZ3 z3 => [AST] -> z3 AST Source
Create an AST node representing args[0] or ... or args[num_args-1].
mkDistinct :: MonadZ3 z3 => [AST] -> z3 AST Source
The distinct construct is used for declaring the arguments pairwise distinct.
mkAdd :: MonadZ3 z3 => [AST] -> z3 AST Source
Create an AST node representing args[0] + ... + args[num_args-1].
mkMul :: MonadZ3 z3 => [AST] -> z3 AST Source
Create an AST node representing args[0] * ... * args[num_args-1].
mkSub :: MonadZ3 z3 => [AST] -> z3 AST Source
Create an AST node representing args[0] - ... - args[num_args - 1].
mkUnaryMinus :: MonadZ3 z3 => AST -> z3 AST Source
Create an AST node representing -arg.
mkInt2Real :: MonadZ3 z3 => AST -> z3 AST Source
Coerce an integer to a real.
mkReal2Int :: MonadZ3 z3 => AST -> z3 AST Source
Coerce a real to an integer.
Numerals
Quantifiers
Accessors
getBool :: MonadZ3 z3 => AST -> z3 (Maybe Bool) Source
Returns Just True
, Just False
, or Nothing
for undefined.
Models
evalT :: (MonadZ3 z3, Traversable t) => Model -> t AST -> z3 (Maybe (t AST)) Source
Evaluate a collection of AST nodes in the given model.
showContext :: MonadZ3 z3 => z3 String Source
Convert Z3's logical context into a string.
Constraints
assertCnstr :: MonadZ3 z3 => AST -> z3 () Source
Assert a constraing into the logical context.
check :: MonadZ3 z3 => z3 Result Source
Check whether the given logical context is consistent or not.
String Conversion
data ASTPrintMode Source
Pretty-printing mode for converting ASTs to strings. The mode can be one of the following:
- Z3_PRINT_SMTLIB_FULL: Print AST nodes in SMTLIB verbose format.
- Z3_PRINT_LOW_LEVEL: Print AST nodes using a low-level format.
- Z3_PRINT_SMTLIB_COMPLIANT: Print AST nodes in SMTLIB 1.x compliant format.
- Z3_PRINT_SMTLIB2_COMPLIANT: Print AST nodes in SMTLIB 2.x compliant format.
setASTPrintMode :: MonadZ3 z3 => ASTPrintMode -> z3 () Source
Set the mode for converting expressions to strings.
astToString :: MonadZ3 z3 => AST -> z3 String Source
Convert an AST to a string.
patternToString :: MonadZ3 z3 => Pattern -> z3 String Source
Convert a pattern to a string.
sortToString :: MonadZ3 z3 => Sort -> z3 String Source
Convert a sort to a string.
funcDeclToString :: MonadZ3 z3 => FuncDecl -> z3 String Source
Convert a FuncDecl to a string.