123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217(**************************************************************************)(* This file is part of BINSEC. *)(* *)(* Copyright (C) 2016-2026 *)(* CEA (Commissariat à l'énergie atomique et aux énergies *)(* alternatives) *)(* *)(* you can redistribute it and/or modify it under the terms of the GNU *)(* Lesser General Public License as published by the Free Software *)(* Foundation, version 2.1. *)(* *)(* It is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file licenses/LGPLv2.1). *)(* *)(**************************************************************************)typestatus=Sat|Unsat|UnknownmoduletypeTERM=sigmodulerecBl:sigtypetvalconst:string->t(** [const name] creates the (first-order) boolean constant named [name] .
*)valtop:t(** The value [true]. *)valbot:t(** The value [false]. *)vallognot:t->t(** [lognot x y] creates the boolean [not] operation of [x]. *)vallogand:t->t->t(** [logand x y] creates the boolean [and] operation between [x] and [y]. *)vallogor:t->t->t(** [logor x y] creates the boolean [or] operation between [x] and [y]. *)vallogxor:t->t->t(** [logxor x y] creates the boolean [xor] operation between [x] and [y]. *)valite:t->t->t->t(** [ite x y z] creates the boolean [ite] operation between [y] and [z]
according to [x]. *)valequal:t->t->t(** [equal x y ] creates the boolean [=] operation between [x] and [y]. *)valdiff:t->t->t(** [diff x y ] creates the boolean [<>] operation between [x] and [y]. *)valimplies:t->t->t(** [implies x y] creates the boolean [=>] operation between [x] and [y]. *)valto_bv:t->Bv.t(** [to_bv x] cast the boolean [x] as a 1-bit bitvector. *)endandBv:sigtypetvalconst:int->string->t(** [const size name] creates the (first-order) constant of [size] bits
named [name] . *)valvalue:int->Z.t->t(** [value sz bv] creates a constant from the bitvector value [bv] of size
[sz]. *)includeBinsec_base.Sigs.COMPARISONwithtypet:=tandtypeboolean:=Bl.tincludeBinsec_base.Sigs.ARITHMETICwithtypet:=tincludeBinsec_base.Sigs.EXTENDED_LOGICALwithtypet:=tvallognand:t->t->t(** [lognand x y] creates the [nand] bitvector operation between [x] and
[y]. *)vallognor:t->t->t(** [lognor x y] creates the [nor] bitvector operation between [x] and [y].
*)vallogxnor:t->t->t(** [logxnor x y] creates the [xnor] bitvector operation between [x] and
[y]. *)includeBinsec_base.Sigs.SHIFT_ROTwithtypet:=tandtypeindex:=tvalrotate_lefti:t->int->t(** [rotate_lefti x i] same as [rotate_left] but with a constant index. *)valrotate_righti:t->int->t(** [rotate_righti x i] same as [rotate_right] but with a constant index. *)valappend:t->t->t(** [append x y] creates the concatenation of the two bitvectors [x] and
[y]. *)valextract:hi:int->lo:int->t->t(** [extract ~hi ~lo x] extracts the sub-bitvector of [x] starting from bit
[lo] and ending at bit [hi] (included). *)valuext:int->t->t(** [uext n x] zero-extends the bitvector [x] by adding [n] bits. *)valsext:int->t->t(** [sext n x] sign extends the bitvector [x] copying [n] times the most
significant bit. *)valite:Bl.t->t->t->t(** [ite x y z] creates the bitvector [ite] operation between [y] and [z]
according to [x]. *)valsucc:t->t(** [succ x] creates the bitvector [x + 1] operation. *)valto_bl:t->Bl.t(** [to_bl x] cast the 1-bit bitvector [x] as a boolean. *)endandAx:sigtypettypesortvalsort:idx:int->int->sort(** [sort ~idx elm] creates a new array kind that maps [idx]-bit bitvector
indexes to [elm]-bit bitvector values. *)valconst:sort->string->t(** [const sort name] creates the (first-order) constant array named [name].
*)valstore:t->Bv.t->Bv.t->t(** [store a i x] creates the array [store] operation of the byte [x] at
index [i] in the array [a]. *)valselect:t->Bv.t->Bv.t(** [select a i] creates the array [select] operation of one byte at index
[i] in the array [a]. *)valequal:t->t->Bl.t(** [equal x y ] creates the array [=] operation between [x] and [y]. *)valdiff:t->t->Bl.t(** [diff x y ] creates the array [<>] operation between [x] and [y]. *)valite:Bl.t->t->t->t(** [ite x y z] creates the array [ite] operation between [y] and [z]
according to [x]. *)endendmoduletypeS=sig(** An incremental solver instance. *)includeTERMvalassert_formula:Bl.t->unit(** [assert_formula bl] assert the boolean entry in the solver instance.
@param bl The boolean entry to assert. *)valpush:unit->unit(** [push ()] creates a backup point of the current solver context. *)valpop:unit->unit(** [pop ()] discard all the assertions since the last backup point, restoring
the solver context in the same state as before the [push ()]. Invalid uses
may fail in an unpredictable fashion. *)valcheck_sat:?timeout:float->unit->status(** [check_sat ()] checks if the current formula is satisfiable.
@return Sat, Unsat or Unknown. *)valcheck_sat_assuming:?timeout:float->Bl.t->status(** [check_sat_assuming e] checks if the current formula is satisfiable with
the assumtion [e].
@return Sat, Unsat or Unknown. *)valget_bv_value:Bv.t->Z.t(** [get_bv_value expr] returns the assignment of the expression [expr] if
[check_sat] returned [Sat]. Invalid uses may fail in an unpredictable
fashion.
@param expr The expression to get the assignment.
@return The bitvector assignment of [expr]. *)valfold_ax_values:(Z.t->Z.t->'a->'a)->Ax.t->'a->'a(** [fold_ax_values f ax v] iter through the assignment of the array [ax] if
[check_sat] returned [Sat]. Invalid uses may fail in an unpredictable
fashion.
@param ax The expression to get the assignment. *)valclose:unit->unit(** [close ()] will destroy the solver instance and release its ressources.
Calling any function on this instance afterward is invalid and may fail in
an unpredictable fashion. *)end(** A solver instance factory. *)moduletypeOPEN=functor()->Stype('bl,'bv,'ax)t=(moduleSwithtypeBl.t='blandtypeBv.t='bvandtypeAx.t='ax)