Simple_smt
val atom : string -> sexp
val is_atom : sexp -> bool
val to_list : sexp -> Sexplib.Sexp.t list option
val nat_k : int -> sexp
Non-negative numeric constant.
val nat_zk : Z.t -> sexp
Non-negative numeric constant.
val ifam : string -> int list -> sexp
Int-indexed family
Symbols are either simple or quoted (c.f. SMTLIB v2.6 S3.1). This predicate indicates whether a character is allowed in a simple symbol. Note that only ASCII letters are allowed.
val symbol : Stdlib.String.t -> sexp
Make an SMT name, quoting if needed. Note that even with quoting the name should not contain pipe (|) or backslash (\)
val t_bool : sexp
The type of booleans.
val bool_k : bool -> sexp
Boolean constant
If-then-else. This is polymorphic and can be used to construct any term.
val t_int : sexp
The type of integers.
val t_real : sexp
The type of reals.
val int_k : int -> sexp
Integer constant
val int_zk : Z.t -> sexp
Integer constant
val real_k : Q.t -> sexp
Real constant.
val t_bits : int -> sexp
t_bits w
is the type of bit vectors of width w
.
val bv_nat_bin : int -> Z.t -> sexp
A bit-vector represented in binary.
val bv_nat_hex : int -> Z.t -> sexp
A bit-vector represented in hex.
val bv_bin : int -> Z.t -> sexp
A bit-vector represented in binary. The number should fit in the given number of bits.
val bv_hex : int -> Z.t -> sexp
A bit-vector represented in hex .
val bv_k : int -> Z.t -> sexp
Make a bit-vector literal. Uses hex representation if the size is a multiple of 4, and binary otherwise.
Extend to the signed equivalent bitvector by the given number of bits.
bv_extract i j x
is a sub-vector of x
. i
is the larger bit index, j
is the smaller one, and indexing is inclusive.
arr_const kt vt v
is an array of type Array kt vt
where all elements are v
. v
should be of type vt
.
arr_store arr ix val
is an array that is the same as arr
, except at index ix
it has val
Some solvers support theories outside of SMTLIB and, unfortunately, there is no standard for what things are called. We use this flag to decide how to generate terms for those cases.
val set_empty : solver_extensions -> sexp -> sexp
set_empty ext t
is the empty set with elements of type t
val set_universe : solver_extensions -> sexp -> sexp
set_universe ext t
is the universal set with elements of type t
val set_insert : solver_extensions -> sexp -> sexp -> sexp
set_insert ext x xs
is a set that has all elements of xs
and also x
val set_union : solver_extensions -> sexp -> sexp -> sexp
set_union ext xs ys
has all elements from xs
and also from ys
val set_intersection : solver_extensions -> sexp -> sexp -> sexp
set_intersection ext xs ys
has the elements that are in both xs
and ys
val set_difference : solver_extensions -> sexp -> sexp -> sexp
set_difference ext xs ys
has the elements of xs
that are not in ys
val set_complement : solver_extensions -> sexp -> sexp
set_complement ext xs
has all elements that are not in xs
val set_member : solver_extensions -> sexp -> sexp -> sexp
set_member ext x xs
is true if x
is a member of xs
val set_subset : solver_extensions -> sexp -> sexp -> sexp
set_subset ext xs ys
is true if all elements of xs
are also in ys
The S-Expressions in this section define commands to the SMT solver. These can be sent to solver using ack_command
.
val simple_command : string list -> sexp
A command made out of just atoms.
val set_option : string -> string -> sexp
set_option opt val
sets option opt
to value val
.
val set_logic : string -> sexp
Set the logic to use.
val push : int -> sexp
Push a new scope.
val pop : int -> sexp
Pop a scope.
val declare_sort : string -> int -> sexp
declare_sort name arity
declares a type name
, which expect arity
type parameters.
declare_fun name param_types result_type
declareas a function expecting arguments with types param_types
and computes a value of type result_type
.
define_fun name params result_type definition
defines a function called name
, with the given parameters (name, type)
, that computes a value of result_type
, using definition
.
define name type definition
defines a constant name
, of type type
defined as definition
.
type con_field = string * sexp
The fields of an ADT constructor: (field_name, field_type)
declare_datatype name type_params cons
define an ADT called name
with type parameters type_params
and constructors cons
. Each constructor is of the form (name, fields)
.
type solver = {
command : sexp -> sexp;
stop : unit -> Unix.process_status;
force_stop : unit -> Unix.process_status;
config : solver_config;
}
A connection to a solver
exception UnexpectedSolverResponse of sexp
Issue a command and wait for it to succeed. Throws UnexpectedSolverResponse
val pp_result :
Ppx_deriving_runtime.Format.formatter ->
result ->
Ppx_deriving_runtime.unit
val show_result : result -> Ppx_deriving_runtime.string
Check if the current set of assumptions are consistent. Throws UnexpectedSolverResponse
.
Get all definitions currently in scope. Only valid after a Sat
result. See also model_eval
.
Get the values of some s-expressions. Only valid after a Sat
result. Throws UnexpectedSolverResponse
.
Evalute the given expression in the current context. Only valid after a Sat
result. Throws UnexpectedSolverResponse
.
val to_bool : sexp -> bool
Try to decode an s-expression as a boolean Throws UnexpectedSolverResponse
.
val to_bits : int -> bool -> sexp -> Z.t
Try to decode an s-expression as a bitvector of the given width. The 2nd argument indicates if the number is signed. Throws UnexpectedSolverResponse
.
val to_z : sexp -> Z.t
Try to decode an s-expression as an integer. Throws UnexpectedSolverResponse
.
val to_q : sexp -> Q.t
Try to decode an s-expression as a rational number. Throws UnexpectedSolverResponse
.
Try to decode an s-expression as constructor with field values. Throws UnexpectedSolverResponse
.
val new_solver : solver_config -> solver
type model_evaluator = {
eval : (string * (string * sexp) list * sexp * sexp) list -> sexp -> sexp;
First define some local variables, then evaluate the expression
*)stop : unit -> Unix.process_status;
force_stop : unit -> Unix.process_status;
}
A connection to a solver, specialized for evaluting in the context of a model
val model_eval : solver_config -> sexp -> model_evaluator
val quiet_log : solver_log
val printf_log : 'a -> solver_log
val cvc5 : solver_config
val z3 : solver_config