z3-0.3.0: Bindings for the Z3 Theorem Prover

Copyright(c) Iago Abal, 2013 (c) David Castro, 2013
LicenseBSD3
MaintainerIago Abal <iago.abal@gmail.com>, David Castro <david.castro.dcp@gmail.com>
Safe HaskellNone
LanguageHaskell98

Z3.Monad

Contents

Description

A simple monadic wrapper for Base.

Synopsis

Documentation

class (Monad m, MonadIO m) => MonadZ3 m where Source

Instances

module Z3.Opts

data Logic Source

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!

Constructors

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.

Instances

evalZ3 :: Z3 a -> IO a Source

Eval a Z3 script with default configuration options.

evalZ3With :: Maybe Logic -> Opts -> Z3 a -> IO a Source

Eval a Z3 script.

Types

data Symbol Source

A Z3 Lisp-link symbol.

data AST Source

A Z3 AST node.

data Sort Source

Kind of Z3 AST representing types.

data FuncDecl Source

Kind of AST used to represent function symbols.

data App Source

A kind of Z3 AST used to represent constant and function declarations.

Instances

data Pattern Source

A kind of AST used to represent pattern and multi-patterns used to guide quantifier instantiation.

data Model Source

A model for the constraints asserted into the logical context.

Instances

Satisfiability result

data Result Source

Result of a satisfiability check.

Constructors

Sat 
Unsat 
Undef 

Symbols

Sorts

Constants and Applications

mkFuncDecl :: MonadZ3 z3 => Symbol -> [Sort] -> Sort -> z3 FuncDecl Source

A Z3 function

mkIte :: MonadZ3 z3 => AST -> AST -> AST -> z3 AST Source

Create an AST node representing an if-then-else: ite(t1, t2, t3).

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#ga94417eed5c36e1ad48bcfc8ad6e83547

mkAnd :: MonadZ3 z3 => [AST] -> z3 AST Source

Create an AST node representing args[0] and ... and args[num_args-1].

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#gacde98ce4a8ed1dde50b9669db4838c61

mkOr :: MonadZ3 z3 => [AST] -> z3 AST Source

Create an AST node representing args[0] or ... or args[num_args-1].

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#ga00866d16331d505620a6c515302021f9

mkDistinct :: MonadZ3 z3 => [AST] -> z3 AST Source

The distinct construct is used for declaring the arguments pairwise distinct.

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#gaa076d3a668e0ec97d61744403153ecf7

mkAdd :: MonadZ3 z3 => [AST] -> z3 AST Source

Create an AST node representing args[0] + ... + args[num_args-1].

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#ga4e4ac0a4e53eee0b4b0ef159ed7d0cd5

mkMul :: MonadZ3 z3 => [AST] -> z3 AST Source

Create an AST node representing args[0] * ... * args[num_args-1].

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#gab9affbf8401a18eea474b59ad4adc890

mkSub :: MonadZ3 z3 => [AST] -> z3 AST Source

Create an AST node representing args[0] - ... - args[num_args - 1].

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#ga4f5fea9b683f9e674fd8f14d676cc9a9

Numerals

mkInt :: (MonadZ3 z3, Integral a) => a -> z3 AST Source

Create a numeral of sort int.

mkReal :: (MonadZ3 z3, Real r) => r -> z3 AST Source

Create a numeral of sort real.

Quantifiers

mkBound :: MonadZ3 z3 => Int -> Sort -> z3 AST Source

mkForall :: MonadZ3 z3 => [Pattern] -> [Symbol] -> [Sort] -> AST -> z3 AST Source

mkExists :: MonadZ3 z3 => [Pattern] -> [Symbol] -> [Sort] -> AST -> z3 AST Source

Accessors

getInt :: MonadZ3 z3 => AST -> z3 Integer Source

Return the integer value

getReal :: MonadZ3 z3 => AST -> z3 Rational Source

Return rational value

Models

eval :: MonadZ3 z3 => Model -> AST -> z3 (Maybe AST) Source

Evaluate an AST node in the given model.

evalT :: (MonadZ3 z3, Traversable t) => Model -> t AST -> z3 (Maybe (t AST)) Source

Evaluate a collection of AST nodes in the given model.

showModel :: MonadZ3 z3 => Model -> z3 String Source

Convert the given model into a string.

showContext :: MonadZ3 z3 => z3 String Source

Convert Z3's logical context into a string.

Constraints

check :: MonadZ3 z3 => z3 Result Source

Check whether the given logical context is consistent or not.

withModel :: (Applicative z3, MonadZ3 z3) => (Model -> z3 a) -> z3 (Result, Maybe a) Source

push :: MonadZ3 z3 => z3 () Source

Create a backtracking point.

pop :: MonadZ3 z3 => Int -> z3 () Source

Backtrack n backtracking points.

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.