module Smtlib: sig .. end
An OCaml API for working with SMT-LIB-based solvers, such as Z3.
Starting solvers.
type solver
A handle to a Z3 process.
val make_solver : string -> solver
make_solver path produces a handle to a Z3 process.
The argument path must be the path to the Z3 executable. If z3 is on the
PATH, this can just be "z3".
This command starts Z3 with the flags -in and -smt2.
High-level API.
This high-level API to Z3 provides simple functions to construct
terms and send commands to Z3. If Z3 produces an error in response to a
command, that error is raised as an OCaml exception.
type identifier =
type sort =
type term =
type check_sat_result =
val declare_const : solver -> identifier -> sort -> unit
declare_const solver x sort runs the command (declare-const x sort)
val assert_ : solver -> term -> unit
assert_ solver term runs the command (assert term)
val check_sat : solver -> check_sat_result
check_sat solver runs the command (check-sat)
val get_model : solver -> (identifier * term) list
val push : solver -> unit
push solver runs the command (push)
val pop : solver -> unit
pop solver runs the command (pop)
val int_sort : sort
The expression Int for the solver.
val bool_sort : sort
The expression Bool for the solver.
val array_sort : sort -> sort -> sort
array_sort dom range produces (array dom range)
val int_to_term : int -> term
val bool_to_term : bool -> term
val const : string -> term
const x produces Const (Id x), which represents a reference to a
variable declared with (declare-const x sort)
val equals : term -> term -> term
equals e1 e2 produces (= e1 e2)
val and_ : term -> term -> term
and e1 e2 produces (and e1 e2). In addition, nested ands are flattened
to make debugging easier.
val or_ : term -> term -> term
or e1 e2 produces (or e1 e2). In addition, nested ors are flattened
to make debugging easier.
val not_ : term -> term
not e produces (not e).
val ite : term -> term -> term -> term
ite e1 e2 e3 produces (ite e1 e2 e3)
val implies : term -> term -> term
implies e1 e2 produces (=> e1 e2).
val add : term -> term -> term
add e1 e2 produces (+ e1 e2).
val sub : term -> term -> term
sub e1 e2 produces (- e1 e2).
val mul : term -> term -> term
mul e1 e2 produces ( * e1 e2).
val lt : term -> term -> term
lt e1 e2 produces (< e1 e2).
val gt : term -> term -> term
> e1 e2 produces (> e1 e2).
val lte : term -> term -> term
lte e1 e2 produces (<= e1 e2).
val gte : term -> term -> term
gte e1 e2 produces (>= e1 e2).
Bit-Vectors
val bv_sort : int -> sort
bv_sort n produces (_ BitVec n).
val bv : int -> int -> term
bv n w produces a bit-vector of width w that represents the integer n.
val bvadd : term -> term -> term
val bvsub : term -> term -> term
val bvmul : term -> term -> term
val bvurem : term -> term -> term
val bvsrem : term -> term -> term
val bvsmod : term -> term -> term
val bvshl : term -> term -> term
val bvlshr : term -> term -> term
val bvashr : term -> term -> term
val bvor : term -> term -> term
val bvand : term -> term -> term
val bvnand : term -> term -> term
val bvnor : term -> term -> term
val bvxnor : term -> term -> term
val bvneg : term -> term
val bvnot : term -> term
Low-level interface
type sexp = Smtlib_syntax.sexp =
| |
SList of sexp list |
| |
SSymbol of string |
| |
SString of string |
| |
SKeyword of string |
| |
SInt of int |
| |
SBitVec of int * int |
The variant of s-expressions used by SMT-LIB.
val command : solver -> sexp -> sexp
command solver sexp sends a command to the solver and reads a response.
val sexp_to_string : sexp -> string
sexp_to_string sexp returns the s-expressions as a string.