Module Index: boolector¶
-
class
boolector.
Boolector
¶ Bases:
object
The class representing a Boolector instance.
-
Add
(a, b)¶ Create a bit vector addition.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).It is also possible to create an addition as follows (see Python Operator Overloading):
bvadd = a + b
Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with the same bit width as
a
andb
.Return type: - a (
-
And
(a, b)¶ Create a bit vector and.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).It is also possible to create an and as follows (see Python Operator Overloading):
bvand = a & b
Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with the same bit width as
a
andb
.Return type: - a (
-
Apply
(args, fun)¶ Create a function application on function
fun
with argumentsargs
(see Automatic Constant Conversion).It is also possible to create a function application as follows (see Python Operator Overloading):
app = fun(arg_0, ..., arg_n)
Parameters: - args (list) – A list of arguments to be applied.
- fun (
BoolectorNode
) – Function to apply argumentsargs
to.
Returns: A function application on function
fun
with argumentsargs
.Return type:
-
Array
(elem_width, index_width, symbol = None)¶ Create a one-dimensional bit vector array variable of size
2**index_width
with elements of bit widthelem_width
.An array variable’s symbol is used as a simple means of identfication, either when printing a model via
Print_model()
, or generating file dumps viaDump()
. A symbol must be unique but may be None in case that no symbol should be assigned.Parameters: - elem_width – Bit width of the array elements.
- index_width – Bit width of the array indices.
- symbol (str) – Symbol of the array variable.
Returns: An array variable of size
2**index_width
with elements of bit widthelem_width
.Return type: Note
In contrast to composite expressions, which are maintained uniquely w.r.t. to their kind, inputs (and consequently, bit width), array variables are not. Hence, each call to this function returns a fresh bit vector array variable.
-
Assert
(a, ...)¶ Add one or more constraints.
Added constraints can not be removed.
Parameters: a ( BoolectorNode
) – Bit vector expression with bit width 1.
-
Assume
(a, ...)¶ - Add one or more assumptions.
You must enable Boolector’s incremental usage via
Set_opt()
before you can add assumptions. In contrast to assertions added viaAssert()
, assumptions are discarded after each call toSat()
. Assumptions and assertions are logicall combined via Boolean and. Assumption handling in Boolector is analogous to assumptions in MiniSAT.Parameters: a ( BoolectorNode
) – Bit vector expression with bit width 1.
-
BitVecSort
(width)¶ Create bit vector sort of bit width
width
.Currently, sorts in Boolector are used for uninterpreted functions, only.
See
UF()
.Parameters: width (int) – Bit width. Returns: Bit vector sort of bit width width
.Return type: BoolectorSort
-
BoolSort
()¶ Create Boolean sort.
Currently, sorts in Boolector are used for uninterpreted functions, only.
See
UF()
.Returns: Sort of type Boolean. Return type: BoolectorSort
-
Clone
()¶ Clone an instance of Boolector.
The resulting Boolector instance is an exact (but disjunct) copy of its parent instance. Consequently, in a clone and its parent, nodes with the same id correspond to each other. Use
Match()
to match corresponding nodes.Returns: The exact (but disjunct) copy of a Boolector instance. Return type: Boolector
-
Concat
(a, b)¶ Create the concatenation of two bit vectors.
Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with bitwidth
bit width of a + bit width of b
.Return type: - a (
-
Cond
(cond, a, b)¶ Create an if-then-else.
If condition
cond
is true, thena
is returned, elseb
is returned.a
andb
must be either both arrays or both bit vectors (see Automatic Constant Conversion).Parameters: - cond (
BoolectorNode
) – Bit vector condition with bit width one. - a (
BoolectorNode
) – Array or bit vector operand representing the then case. - b (
BoolectorNode
) – Array or bit vector operand representing the else case.
Returns: Either
a
orb
.Return type: - cond (
-
Const
(c, width = 1)¶ Create a bit vector constant of value
c
and bit widthwidth
.Parameters: - c (int, bool, str) – Value of the constant.
- width (int) – Bit width of the constant.
Returns: A bit vector constant of value
c
and bit widthwidth
.Return type: Note
Parameter
width
is only required ifc
is an integer.
-
Dec
(n)¶ Create a bit vector expression that decrements bit vector
n
by one.Parameters: n ( BoolectorNode
) – A bit vector node.Returns: A bit vector with the same bit width as n
, decremented by one.Return type: BoolectorNode
-
Dump
(format = "btor", outfile = None)¶ Dump input formula to output file.
Parameters: - format (str.) – A file format identifier string (use ‘btor’ for BTOR, ‘smt2’ for SMT-LIB v2, ‘aig’ for binary AIGER (QF_BV only), and ‘aag’ for ASCII AIGER (QF_BV only)).
- outile – Output file name (default: stdout).
-
Eq
(a, b)¶ Create a bit vector or array equality.
Parameters
a
andb
are either bit vectors with the same bit width, or arrays of the same type (see Automatic Constant Conversion).It is also possible to create an equality as follows (see Python Operator Overloading):
eq = a == b
Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with bit width one.
Return type: - a (
-
Failed
(a, ...)¶ Determine if any of the given assumptions are failed assumptions.
Failed assumptions are those assumptions, that force an input formula to become unsatisfiable. Failed assumptions handling in Boolector is analogous to failed assumptions in MiniSAT.
See
Assume()
.Parameters: a ( BoolectorNode
) – Bit vector expression with bit width 1.Returns: list of boolean values, where True indicates that the assumption at given index is failed, and false otherwise. Return type: list(bool)
-
Fixate_assumptions
()¶ Add all assumptions added since the last
Sat()
call as assertions.See
Assume()
.
-
Fun
(params, body)¶ Create a function with function body
body
, parameterized overparams
.This kind of node is similar to macros in the SMT-LIB v2 standard.
Parameters: - params (list) – A list of function parameters.
- body (
BoolectorNode
) – Function body parameterized overparams
.
Returns: A function over parameterized expression
body
.Return type: Note
As soon as a parameter is bound to a function, it can not be reused in other functions. Call a function via
Apply()
.
-
FunSort
(domain, codomain)¶ Create function sort.
Currently, sorts in Boolector are used for uninterpreted functions, only.
See
UF()
.Parameters: - domain (list) – A list of all the function arguments’ sorts.
- codomain (
BoolectorSort
) – The sort of the function’s return value.
Returns: Function sort, which maps
domain
tocodomain
.Return type:
-
Get_opt
(opt)¶ Get the Boolector option with name
opt
.For a list of all available options, see
Set_opt()
.Parameters: opt (str) – Option name. Returns: Option with name opt
.Return type: BoolectorOpt
-
Iff
(a, b)¶ Create a Boolean equivalence.
Parameters
a
andb
must have bit width one (see Automatic Constant Conversion).Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A Boolean equivalence
a
<=>b
.Return type: - a (
-
Implies
(a, b)¶ Create a Boolean implication.
Parameters
a
andb
must have bit width one (see Automatic Constant Conversion).Parameters: - a (
BoolectorNode
) – Bit vector node representing the premise. - b (
BoolectorNode
) – Bit vector node representing the conclusion.
Returns: A Boolean implication
a
=>b
.Return type: - a (
-
Inc
(n)¶ Create a bit vector expression that increments bit vector
n
by one.Parameters: n ( BoolectorNode
) – A bit vector node.Returns: A bit vector with the same bit width as n
, incremented by one.Return type: BoolectorNode
-
Match
(n)¶ Retrieve the node matching given node
n
by id.This is intended to be used for handling expressions of a cloned instance (see
Clone()
).E.g.,
btor = Boolector() v = btor.Var(16, "x") clone = btor.Clone() v_cloned = clone.Match(v)
Parameters: n ( BoolectorNode
) – Boolector node.Returns: The Boolector node that matches given node n
by id.Return type: BoolectorNode
Note
Only nodes created before the
Clone()
call can be matched.
-
Mul
(a, b)¶ Create a bit vector multiplication.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).It is also possible to create a multiplication as follows (see Python Operator Overloading):
bvmul = a * b
Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with the same bit width as
a
andb
.Return type: - a (
-
Nand
(a, b)¶ Create a bit vector nand.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with the same bit width as
a
andb
.Return type: - a (
-
Ne
(a, b)¶ Create a bit vector or array inequality.
Parameters
a
andb
are either bit vectors with the same bit width, or arrays of the same type (see Automatic Constant Conversion).It is also possible to create an inequality as follows (see Python Operator Overloading):
ne = a != b
Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with bit width one.
Return type: - a (
-
Neg
(n)¶ Create the two’s complement of bit vector node
n
.It is also possible to create the two’s complement as follows (see Python Operator Overloading):
bvneg = -n
Parameters: n ( BoolectorNode
) – A bit vector node.Returns: The two’s complement of bit vector node n
.Return type: BoolectorNode
-
Nor
(a, b)¶ Create a bit vector nor.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with the same bit width as
a
andb
.Return type: - a (
-
Not
(n)¶ Create the one’s complement of bit vector node
n
.It is also possible to create the one’s complement as follows (see Python Operator Overloading):
bvnot = ~n
Parameters: n ( BoolectorNode
) – A bit vector node.Returns: The one’s complement of bit vector node n
.Return type: BoolectorNode
-
Options
()¶ Get a
BoolectorOptions
iterator.E.g.,
btor = Boolector() options = btor.Options() for o in options: # do something
Returns: An iterator to iterate over all Boolector options. Return type: BoolectorOptions
-
Or
(a, b)¶ Create a bit vector or.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).It is also possible to create an or as follows (see Python Operator Overloading):
bvor = a | b
Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with the same bit width as
a
andb
.Return type: - a (
-
Param
(width, symbol = None)¶ Create a function parameter with bit width
width
.This kind of node is used to create parameterized expressions, which in turn are used to create functions. Once a parameter is bound to a function, it cannot be reused in other functions.
Parameters: Returns: A function parameter with bit width
width
.Return type:
-
Parse
(infile, outfile = None)¶ Parse input file.
Input file format may be either BTOR, SMT-LIB v1, or SMT-LIB v2, the file type is detected automatically.
E.g.,
btor = Boolector() (result, status, error_msg) = btor.Parse("example.btor")
Parameters: infile (str) – Input file name. Returns: A tuple (result, status, error_msg), where return value result
indicates an error (PARSE_ERROR
) if any, and else denotes the satisfiability result (SAT
orUNSAT
) in the incremental case, andUNKNOWN
otherwise. Return valuestatus
indicates a (known) status (SAT
orUNSAT
) as specified in the input file. In case of an error, an explanation of that error is stored inerror_msg
.
-
Print_model
(format = "btor", outfile = None)¶ Print model to output file.
Supported model formats are Boolector’s own model format (“btor”) and SMT-LIB v2 (“smt2”).
This function prints the model for all inputs to output file
outfile
, e.g.:btor.Print_model()
A possible model would be:
2 00000100 x 3 00010101 y 4[00] 01 A
which in this case prints the assignments of array variable
A
, and bit vector variablesx
andy
. For bit vector variables, the first column indicates the id of an input, the second column its assignment, and the third column its name (symbol), if any. Array variableA
, on the other hand, has id 4, is an array with index and element bit width of 2, and its value at index 0 is 1.The corresponding model in SMT-LIB v2 format would be:
btor.Print_model(format="smt2")
(model (define-fun x () (_ BitVec 8) #b00000100) (define-fun y () (_ BitVec 8) #b00010101) (define-fun y ( (y_x0 (_ BitVec 2))) (ite (= y_x0 #b00) #b01 #00)) )
Parameters: - format – Model output format (default: “btor”).
- outfile (str) – Output file name (default: stdout).
-
Read
(a, b)¶ Create a read on array
a
at positionb
(see Automatic Constant Conversion).It is also possible to create a read as follows (see Python Operator Overloading):
read = a[b]
Parameters: - a (
BoolectorNode
) – Array operand. - b (
BoolectorNode
) – Bit vector operand.
Returns: A bit vector node with the same bitwidth as the elements of array
a
.Return type: - a (
-
Redand
(n)¶ Create an and reduction of node
n
.All bits of node
n
are combined by an Boolean and.Parameters: n ( BoolectorNode
) – A bit vector node.Returns: The and reduction of node n
.Return type: BoolectorNode
-
Redor
(n)¶ Create an or reduction of node
n
.All bits of node
n
are combined by an Boolean or.Parameters: n ( BoolectorNode
) – A bit vector node.Returns: The or reduction of node n
.Return type: BoolectorNode
-
Redxor
(n)¶ Create an xor reduction of node
n
.All bits of node
n
are combined by an Boolean xor.Parameters: n ( BoolectorNode
) – A bit vector node.Returns: The xor reduction of node n
.Return type: BoolectorNode
-
Rol
(a, b)¶ Create a rotate left.
Given bit vector node
b
, the value it represents is the number of bits by which nodea
is rotated to the left (see Automatic Constant Conversion).Parameters: - a (
BoolectorNode
) – First bit vector operand where the bit width is a power of two and greater than 1. - b (
BoolectorNode
) – Second bit vector operand with bit width log2 of the bit width ofa
.
Returns: A bit vector node with the same bit width as
a
.Return type: - a (
-
Ror
(a, b)¶ Create a rotate right.
Given bit vector node
b
, the value it represents is the number of bits by which nodea
is rotated to the right (see Automatic Constant Conversion).Parameters: - a (
BoolectorNode
) – First bit vector operand where the bit width is a power of two and greater than 1. - b (
BoolectorNode
) – Second bit vector operand with bit width log2 of the bit width ofa
.
Returns: A bit vector node with the same bit width as
a
.Return type: - a (
-
Saddo
(a, b)¶ Create a signed bit vector addition overflow detection.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with bit width one, which indicates if the addition of
a
andb
overflows in case both operands are treated as signed.Return type: - a (
-
Sat
(lod_limit = -1, sat_limit = -1)¶ Solve an input formula.
An input formula is defined by constraints added via
Assert()
. You can guide the search for a solution to an input formula by making assumptions viaAssume()
.If you want to call this function multiple times, you must enable Boolector’s incremental usage mode via
Set_opt()
. Otherwise, this function may only be called once.You can limit the search by the number of lemmas generated (
lod_limit
) and the number of conflicts encountered by the underlying SAT solver (sat_limit
).Parameters: Returns: SAT
if the input formula is satisfiable (under possibly given assumptions),UNSAT
if it is unsatisfiable, andUNKNOWN
if the instance could not be solved within given limits.Note
Assertions and assumptions are combined via Boolean and.
See also
-
Sdiv
(a, b)¶ Create a signed bit vector division.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with the same bit width as
a
andb
.Return type: Note
Signed division is expressed by means of unsigned division, where either node is normalized in case that its sign bit is 1. If the sign bits of
a
andb
do not match, two’s complement is performed on the result of the previous unsigned division. Hence, the behavior in case of a division by zero depends onUdiv()
.- a (
-
Sdivo
(a, b)¶ Create a signed bit vector division overflow detection.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion). An overflow can occur ifa
represents INT_MIN andb
represents -1.Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with bit width one, which indicates if the division of
a
andb
overflows in case both operands are treated as signed.Return type: Note
Unsigned bit vector division does not overflow.
- a (
-
Set_opt
(opt, value)¶ Set option.
List of available options:
model_gen
Enable (value
: 1 or 2) or disable (value
: 0) generation of a model for satisfiable instances.There are two modes for model generation:- generate model for asserted expressions only (
value
: 1) - generate model for all expressions (
value
: 2)
- generate model for asserted expressions only (
incremental
Enable (value
: 1) incremental mode.Note that incremental usage turns off some optimization techniques. Disabling incremental usage is currently not supported.incremental_all
Enable (value
: 1) or disable (value
: 0) incremental solving of all formulas when parsing an input file.Note that currently, incremental mode while parsing an input file is only supported for SMT-LIB v1 input.incremental_in_depth
Set incremental in-depth mode width (value
: int) when parsing an input file.Note that currently, incremental mode while parsing an input file is only supported for SMT-LIB v1 input.incremental_look_ahead
Set incremental look_ahead mode width (value
: int) when parsing an input file.Note that currently, incremental mode while parsing an input file is only supported for SMT-LIB v1 input.incremental_interval
Set incremental interval mode width (value
: int) when parsing an input file.Note that currently, incremental mode while parsing an input file is only supported for SMT-LIB v1 input.input_format
If unspecified, Boolector automatically detects the input file format while parsing.output_number_format
Force output number format (value
: binary: 0, hexadecimal: 1, decimal: 2):Boolector uses binary by default.output_format
Boolector uses BTOR by default.rewrite_level
Set the rewrite level (value
: 0-3) of the rewriting engine.Boolector uses rewrite level 3 by default, rewrite levels are classified as follows:- 0: no rewriting
- 1: term level rewriting
- 2: more simplification techniques
- 3: full rewriting/simplification
Do not alter the rewrite level of the rewriting engine after creating expressions.rewrite_level_pbr
Set the rewrite level (value
: 0-3) for partial beta reduction.Boolector uses rewrite level 1 by default. Rewrite levels are classified as above.beta_reduce_all
Enable (
value
: 1) or disable (value
: 0) the eager elimination of lambda expressions via beta reduction.probe_beta_reduce_all
Enable (
value
: 1) or disable (value
: 0) probing of beta_reduce_all until a given lemmas on demand (pbr_lod_limit) or SAT conflicts limit (pbra_sat_limit).pbra_lod_limit
Set lemmas on demand limit for probe_beta_reduce_all.
pbra_sat_limit
Set SAT conflicts limit for probe_beta_reduce_all.
pbra_ops_factor
Set factor by which the size of the beta reduced formula may be greater than the original formula (for probe_beta_reduce_all).
dual_prop
Enable (
value
: 1) or disable (value
: 0) dual propagation optimization.just
Enable (
value
: 1) or disable (value
: 0) justification optimization.ucopt
Enable (
value
: 1) or disable (value
: 0) unconstrained optimization.lazy_synthesize
Enable (
value
: 1) or disable (value
: 0) lazy synthesis of bit vector expressions.eliminate_slices
Enable (
value
: 1) or disable (value
: 0) slice elimination on bit vector variables.pretty_print
Enable (
value
: 1) or disable (value
: 0) pretty printing when dumping.verbosity
Set the level of verbosity.
Parameters:
-
Set_sat_solver
(solver, optstr = None, clone = True)¶ Set the SAT solver to use.
E.g.,
btor = Boolector() btor.Set_sat_solver("MiniSAT")
Option
clone
enables non-incremental SAT solver usage (for every SAT call) by means of internal SAT solver cloning. Use this option with caution (might have a positive or negative impact on overall performance).Parameters: Returns: True if setting the SAT solver was successful and False otherwise.
Return type: Note
Parameters
optstr
andclone
are currently only supported by Lingeling.
-
Set_term
(fun, args)¶ Set a termination callback function.
Use this function to force Boolector to prematurely terminate if callback function
fun
returns True. Argumentsargs
tofun
may be passed as a single Python object (in case thatfun
takes only one argument), a tuple, or a list of arguments.E.g.,
import time def fun1 (arg): # timeout after 1 sec. return time.time() - arg > 1.0 def fun2 (arg0, arg1): # do something and return True/False ... btor = Boolector() btor.Set_term(fun1, time.time()) btor.Set_term(fun1, (time.time(),)) btor.Set_term(fun1, [time.time()]) btor.Set_term(fun2, (arg0, arg1)) btor.Set_term(run2, [arg0, arg1])
Parameters: - fun – A python function.
- args – A function argument or a list or tuple of function arguments.
-
Sext
(n, width)¶ Create signed extension.
Bit vector node
n
is padded withwidth
bits, where the padded value depends on the value of the most significant bit of noden
.Parameters: - n (
BoolectorNode
) – A bit vector node. - width (int) – Number of bits to pad.
Returns: A bit vector extended by
width
bits.Return type: - n (
-
Sgt
(a, b)¶ Create a signed greater than.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with bit width one.
Return type: - a (
-
Sgte
(a, b)¶ Create a signed greater than or equal.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with bit width one.
Return type: - a (
-
Simplify
()¶ Simplify current input formula.
Returns: SAT
if the input formula was simplified to true,UNSAT
if it was simplified to false, andUNKNOWN
, otherwise.Note
Each call to
Sat()
simplifies the input formula as a preprocessing step.
-
Slice
(n, upper, lower)¶ Create a bit vector slice of node
n
from indexupper
to indexlower
.It is also possible to use Python slices on bit vectors as follows:
n[upper:lower] # creates slice with upper limit 'upper' and lower limit 'lower' n[upper:] # creates slice with upper limit 'upper' and lower limit 0 n[:lower] # creates slice with upper limit 'n.width - 1' and lower limit 'lower' n[:] # creates copy of node 'n'
Parameters: - n (
BoolectorNode
) – A bit vector node. - upper (int) – Upper index, which must be greater than or equal to zero, and less than the bit width of node
n
. - lower (int) – Lower index, which must be greater than or equal to zero, and less than or equal to
upper
.
Returns: A Bit vector with bit width
upper
-lower
+ 1.Return type: - n (
-
Sll
(a, b)¶ Create a logical shift left.
Given bit vector node
b
, the value it represents is the number of zeroes shifted into nodea
from the right (see Automatic Constant Conversion).It is also possible to create a logical shift left as follows (see Python Operator Overloading):
bvshl = a << b
Parameters: - a (
BoolectorNode
) – First bit vector operand where the bit width is a power of two and greater than 1. - b (
BoolectorNode
) – Second bit vector operand with bit width log2 of the bit width ofa
.
Returns: A bit vector node with the same bit width as
a
.Return type: - a (
-
Slt
(a, b)¶ Create a signed less than.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with bit width one.
Return type: - a (
-
Slte
(a, b)¶ Create a signed less than or equal.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with bit width one.
Return type: - a (
-
Smod
(a, b)¶ Create a signed remainder where its sign matches the sign of the divisor.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).If
b
is zero, the result depends onUrem()
.Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with the same bit width as
a
andb
.Return type: - a (
-
Smulo
(a, b)¶ Create a signed bit vector multiplication overflow detection.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with bit width one, which indicates if the multiplication of
a
andb
overflows in case both operands are treated as signed.Return type: - a (
-
Sra
(a, b)¶ Create an arithmetic shift right.
Analogously to
Srl()
, but whether zeroes or ones are shifted in depends on the most significant bit of nodea
(see Automatic Constant Conversion).Parameters: - a (
BoolectorNode
) – First bit vector operand where the bit width is a power of two and greater than 1. - b (
BoolectorNode
) – Second bit vector operand with bit width log2 of the bit width ofa
.
Returns: A bit vector node with the same bit width as
a
.Return type: - a (
-
Srem
(a, b)¶ Create a signed remainder.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion). Ifb
is 0, the result of the unsigned remainder isa
. Ifb
is 0, the result of the unsigned remainder isa
.Analogously to
Sdiv()
, the signed remainder is expressed by means of the unsigned remainder, where either node is normalized in case that its sign bit is 1. Hence, in case thatb
is zero, the result depends onUrem()
.Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with the same bit width as
a
andb
.Return type: - a (
-
Srl
(a, b)¶ Create a logical shift right.
Given bit vector node
b
, the value it represents is the number of zeroes shifted into nodea
from the left (see Automatic Constant Conversion).It is also possible to create a logical shift right as follows (see Python Operator Overloading):
bvshr = a >> b
Parameters: - a (
BoolectorNode
) – First bit vector operand where the bit width is a power of two and greater than 1. - b (
BoolectorNode
) – Second bit vector operand with bit width log2 of the bit width ofa
.
Returns: A bit vector node with the same bit width as
a
.Return type: - a (
-
Ssubo
(a, b)¶ Create a signed bit vector subtraction overflow detection.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with bit width one, which indicates if the subtraction of
a
andb
overflows in case both operands are treated as signed.Return type: - a (
-
Sub
(a, b)¶ Create a bit vector subtraction.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).It is also possible to create a subtraction as follows (see Python Operator Overloading):
bvsub = a - b
Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with the same bit width as
a
andb
.Return type: - a (
-
Terminate
()¶ Determine if Boolector has been terminated (and/or terminate Boolector) via the previously configured termination callback function.
See
Set_term()
.:return True if termination condition is fulfilled, else False. :rtype: bool
-
UF
(sort, symbol)¶ Create an uninterpreted function with sort
sort
and symbolsymbol
.An uninterpreted function’s symbol is used as a simple means of identification, either when printing a model via
Print_model()
, or generating file dumps viaDump()
. A symbol must be unique but may be None in case that no symbol should be assigned.Parameters: - sort (BoolectorSort) – Sort of the uninterpreted function.
- symbol (str) – Name of the uninterpreted function.
Returns: A function over parameterized expression
body
.Return type: Note
In contrast to composite expressions, which are maintained uniquely w.r.t. to their kind, inputs (and consequently, bit width), uninterpreted functions are not. Hence, each call to this function returns a fresh uninterpreted function.
-
Uaddo
(a, b)¶ Create an unsigned bit vector addition overflow detection.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with bit width one, which indicates if the addition of
a
andb
overflows in case both operands are treated as unsigned.Return type: - a (
-
Udiv
(a, b)¶ Create an unsigned bit vector division.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion). Ifa
is 0, the division’s result is -1.It is also possible to create an unsigned division as follows (see Python Operator Overloading):
bvudiv = a / b
Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with the same bit width as
a
andb
.Return type: Note
This behavior (division by zero returns -1) does not exactly comply with the SMT-LIB v1 and v2 standards, where division by zero is handled as an uninterpreted function. Our semantics are motivated by real circuits where division by zero cannot be uninterpreted and consequently returns a result.
- a (
-
Uext
(n, width)¶ Create unsigned extension.
Bit vector node
n
is padded withwidth
zeroes.Parameters: - n (
BoolectorNode
) – A bit vector node. - width (int) – Number of zeros to pad.
Returns: A bit vector extended by
width
zeroes.Return type: - n (
-
Ugt
(a, b)¶ Create an unsigned greater than.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).It is also possible to create an unsigned greater than as follows (see Python Operator Overloading):
ugt = a > b
Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with bit width one.
Return type: - a (
-
Ugte
(a, b)¶ Create an unsigned greater than or equal.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).It is also possible to create an unsigned greater than or equal as follows (see Python Operator Overloading):
ugte = a >= b
Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with bit width one.
Return type: - a (
-
Ult
(a, b)¶ Create an unsigned less than.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).It is also possible to create an unsigned less than as follows (see Python Operator Overloading):
lt = a < b
Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with bit width one.
Return type: - a (
-
Ulte
(a, b)¶ Create an unsigned less than or equal.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).It is also possible to create an unsigned less than or equal as follows (see Python Operator Overloading):
lte = a <= b
Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with bit width one.
Return type: - a (
-
Umulo
(a, b)¶ Create an unsigned bit vector multiplication overflow detection.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with bit width one, which indicates if the multiplication of
a
andb
overflows in case both operands are treated as unsigned.Return type: - a (
-
Urem
(a, b)¶ Create an unsigned remainder.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion). Ifb
is 0, the result of the unsigned remainder isa
.It is also possible to create an unsigned remainder as follows (see Python Operator Overloading):
bvurem = a % b
Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with the same bit width as
a
andb
.Return type: Note
As in
Udiv()
, the behavior ifb
is 0 does not exactly comply to the SMT-LIB v1 and v2 standards, where the result ist handled as uninterpreted function. Our semantics are motivated by real circuits, where result can not be uninterpreted.- a (
-
Usubo
(a, b)¶ Create an unsigned bit vector subtraction overflow detection.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with bit width one, which indicates if the subtraction of
a
andb
overflows in case both operands are treated as unsigned.Return type: - a (
-
Var
(width, symbol = None)¶ Create a bit vector variable with bit width
width
.A variable’s symbol is used as a simple means of identification, either when printing a model via
Print_model()
, or generating file dumps viaDump()
. A symbol must be unique but may be None in case that no symbol should be assigned.Parameters: Returns: A bit vector variable with bit width
width
.Return type: Note
In contrast to composite expressions, which are maintained uniquely w.r.t. to their kind, inputs (and consequently, bit width), variables are not. Hence, each call to this function returns a fresh bit vector variable.
-
Write
(array, index, value)¶ Create a write on array
array
at positionindex
with valuevalue
(see Automatic Constant Conversion).The array is updated at exactly one position, all other elements remain unchanged. The bit width of
index
must be the same as the bit width of the indices ofarray
. The bit width ofvalue
must be the same as the bit width of the elements ofarray
.Parameters: - array (
BoolectorNode
) – Array operand. - index (
BoolectorNode
) – Bit vector index. - value (
BoolectorNode
) – Bit vector value.
Returns: An array where the value at
index
has been updated withvalue
.Return type: - array (
-
Xnor
(a, b)¶ Create a bit vector xnor.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with the same bit width as
a
andb
.Return type: - a (
-
Xor
(a, b)¶ Create a bit vector xor.
Parameters
a
andb
must have the same bit width (see Automatic Constant Conversion).It is also possible to create an xor as follows (see Python Operator Overloading):
bvxor = a ^ b
Parameters: - a (
BoolectorNode
) – First bit vector operand. - b (
BoolectorNode
) – Second bit vector operand.
Returns: A bit vector node with the same bit width as
a
andb
.Return type: - a (
-
-
class
boolector.
BoolectorArrayNode
¶ Bases:
boolector.BoolectorNode
The class representing a Boolector array node.
-
index_width
¶ The bit with of the Boolector array node indices.
-
-
class
boolector.
BoolectorBVNode
¶ Bases:
boolector.BoolectorNode
The class representing a Boolector bit vector node.
-
class
boolector.
BoolectorConstNode
¶ Bases:
boolector.BoolectorBVNode
The class representing Boolector constant nodes.
-
bits
¶ The bit string of a Boolector constant node.
-
-
exception
boolector.
BoolectorException
¶ Bases:
Exception
The class representing a Boolector exception.
-
class
boolector.
BoolectorFunNode
¶ Bases:
boolector.BoolectorNode
The class representing a Boolector function node.
-
arity
¶ The arity of a Boolector function node.
-
-
class
boolector.
BoolectorNode
¶ Bases:
object
The class representing a Boolector node.
-
Dump
(format = "btor", outfile = None)¶ Dump node to output file.
Parameters: - format (str) – A file format identifier string (use ‘btor’ for BTOR and ‘smt2’ for SMT-LIB v2).
- outfile (str) – Output file name (default: stdout).
-
assignment
¶ The assignment of a Boolector node.
May be queried only after a preceding call to
Sat()
returnedSAT
.If the queried node is a bit vector, its assignment is represented as string. If it is an array, its assignment is represented as a list of tuples
(index, value)
. If it is a function, its assignment is represented as a list of tuples(arg_0, ..., arg_n, value)
.
-
symbol
¶ The symbol of a Boolector node.
A node’s symbol is used as a simple means of identfication, either when printing a model via
Print_model()
, or generating file dumps viaDump()
.
-
width
¶ The bit width of a Boolector node.
If the node is an array, this indicates the bit width of the array elements. If the node is a function, this indicates the bit with of the function’s return value.
-
-
class
boolector.
BoolectorOpt
¶ Bases:
object
The class representing a Boolector option.
-
desc
¶ The description of a Boolector option.
-
dflt
¶ The default value of a Boolector option.
-
lng
¶ The long name of a Boolector option.
-
max
¶ The maximum value of a Boolector option.
-
min
¶ The minimum value of a Boolector option.
-
shrt
¶ The short name of a Boolector option.
-
val
¶ The current value of a Boolector option.
-