Previous topic

Boolector Python API documentation

Module Index: boolector

class boolector.Boolector

Bases: builtins.object

The class representing a Boolector instance.

Add(a, b)

Create a bit vector addition.

Parameters a and b 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:
Returns:

A bit vector node with the same bit width as a and b.

Return type:

BoolectorNode

And(a, b)

Create a bit vector and.

Parameters a and b 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:
Returns:

A bit vector node with the same bit width as a and b.

Return type:

BoolectorNode

Apply(args, fun)

Create a function application on function fun with arguments args (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)

See Fun(), UF().

Parameters:
  • args (list) – A list of arguments to be applied.
  • fun (BoolectorNode) – Function to apply arguments args to.
Returns:

A function application on function fun with arguments args.

Return type:

BoolectorNode

Array(elem_width, index_width, symbol = None)

Create a one-dimensional bit vector array variable of size 2**index_width with elements of bit width elem_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 via Dump(). 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 width elem_width.

Return type:

BoolectorNode

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(n)

Add a constraint.

Use this function to assert node n. Added constraints can not be removed.

Parameters:n (BoolectorNode) – Bit vector expression with bit width 1.
Assume(n)

Add an assumption.

Use this function to assume node n. You must enable Boolector’s incremental usage via Set_opt() before you can add assumptions. In contrast to assertions added via Assert(), assumptions are discarded after each call to Sat(). Assumptions and assertions are logicall combined via Boolean and. Assumption handling in Boolector is analogous to assumptions in MiniSAT.

Parameters:n (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

Note

If Lingeling is used as SAT solver, Boolector can be cloned at any time, since Lingeling also supports cloning. However, if you use Clone() with MiniSAT or PicoSAT (no cloning suppport), Boolector can only be cloned prior to the first Sat() call.

Concat(a, b)

Create the concatenation of two bit vectors.

Parameters:
Returns:

A bit vector node with bitwidth bit width of a + bit width of b.

Return type:

BoolectorNode

Cond(cond, a, b)

Create an if-then-else.

If condition cond is true, then a is returned, else b is returned. a and b 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 or b.

Return type:

BoolectorNode

Const(c, width = 1)

Create a bit vector constant of value c and bit width width.

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 width width.

Return type:

BoolectorNode

Note

Parameter width is only required if c 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, ‘smt1’ for SMT-LIB v1, and ‘smt2’ for SMT-LIB v2).
  • outile – Output file name (default: stdout).
Eq(a, b)

Create a bit vector or array equality.

Parameters a and b 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:
Returns:

A bit vector node with bit width one.

Return type:

BoolectorNode

Failed(n)

Determine if assumption n is a failed assumption.

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:n (BoolectorNode) – Bit vector expression with bit width 1.
Returns:True if assumption is failed, and false otherwise.
Return type:int
Fun(params, body)

Create a function with function body body, parameterized over params.

This kind of node is similar to macros in the SMT-LIB v2 standard.

See Param(), Apply().

Parameters:
  • params (list) – A list of function parameters.
  • body (BoolectorNode) – Function body parameterized over params.
Returns:

A function over parameterized expression body.

Return type:

BoolectorNode

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 to codomain.

Return type:

BoolectorSort

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 and b must have bit width one (see Automatic Constant Conversion).

Parameters:
Returns:

A Boolean equivalence a <=> b.

Return type:

BoolectorNode

Implies(a, b)

Create a Boolean implication.

Parameters a and b 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:

BoolectorNode

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 and b 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:
Returns:

A bit vector node with the same bit width as a and b.

Return type:

BoolectorNode

Nand(a, b)

Create a bit vector nand.

Parameters a and b must have the same bit width (see Automatic Constant Conversion).

Parameters:
Returns:

A bit vector node with the same bit width as a and b.

Return type:

BoolectorNode

Ne(a, b)

Create a bit vector or array inequality.

Parameters a and b 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:
Returns:

A bit vector node with bit width one.

Return type:

BoolectorNode

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 and b must have the same bit width (see Automatic Constant Conversion).

Parameters:
Returns:

A bit vector node with the same bit width as a and b.

Return type:

BoolectorNode

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 and b 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:
Returns:

A bit vector node with the same bit width as a and b.

Return type:

BoolectorNode

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.

See Fun(), Apply().

Parameters:
  • width (int) – Bit width of the function parameter.
  • symbol (str) – Symbol of the function parameter.
Returns:

A function parameter with bit width width.

Return type:

BoolectorNode

Parse(file)

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:file (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 or UNSAT) in the incremental case, and UNKNOWN otherwise. Return value status indicates a (known) status (SAT or UNSAT) as specified in the input file. In case of an error, an explanation of that error is stored in error_msg.
Print_model(outfile = None)

Print model to output file.

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 variables x and y. 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 variable A, 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.

Parameters:outfile (str) – Output file name (default: stdout).
Read(a, b)

Create a read on array a at position b (see Automatic Constant Conversion).

It is also possible to create a read as follows (see Python Operator Overloading):

read = a[b]
Parameters:
Returns:

A bit vector node with the same bitwidth as the elements of array a.

Return type:

BoolectorNode

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 node a 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 of a.
Returns:

A bit vector node with the same bit width as a.

Return type:

BoolectorNode

Ror(a, b)

Create a rotate right.

Given bit vector node b, the value it represents is the number of bits by which node a 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 of a.
Returns:

A bit vector node with the same bit width as a.

Return type:

BoolectorNode

Saddo(a, b)

Create a signed bit vector addition overflow detection.

Parameters a and b must have the same bit width (see Automatic Constant Conversion).

Parameters:
Returns:

A bit vector node with bit width one, which indicates if the addition of a and b overflows in case both operands are treated as signed.

Return type:

BoolectorNode

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 via Assume().

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:
  • lod_limit (int) – Limit for Lemmas on Demand (-1: unlimited).
  • sat_limit (int) – Conflict limit for the SAT solver (-1: unlimited).
Returns:

SAT if the input formula is satisfiable (under possibly given assumptions), UNSAT if it is unsatisfiable, and UNKNOWN if the instance could not be solved within given limits.

Note

Assertions and assumptions are combined via Boolean and.

See also

assignment

Sdiv(a, b)

Create a signed bit vector division.

Parameters a and b must have the same bit width (see Automatic Constant Conversion).

Parameters:
Returns:

A bit vector node with the same bit width as a and b.

Return type:

BoolectorNode

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 and b 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 on Udiv().

Sdivo(a, b)

Create a signed bit vector division overflow detection.

Parameters a and b must have the same bit width (see Automatic Constant Conversion). An overflow can occur if a represents INT_MIN and b represents -1.

Parameters:
Returns:

A bit vector node with bit width one, which indicates if the division of a and b overflows in case both operands are treated as signed.

Return type:

BoolectorNode

Note

Unsigned bit vector division does not overflow.

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)
  • 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 parsin 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

    Force input file format (value: BTOR: -1, SMT-LIB v1: 1, SMT-LIB v2: 2) when parsing an input file.
    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

    Force output file format (value: BTOR: -1, SMT-LIB v1: 1, SMT-LIB v2: 2).
    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:
  • opt (str) – Option name.
  • value (int) – Option value.
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:
  • solver (str) – Solver identifier string.
  • optstr (str) – Solver option string.
  • clone (bool) – Force non-incremental SAT solver usage.
Returns:

True if setting the SAT solver was successful and False otherwise.

Return type:

bool

Note

Parameters optstr and clone are currently only supported by Lingeling.

Sext(n, width)

Create signed extension.

Bit vector node n is padded with width bits, where the padded value depends on the value of the most significant bit of node n.

Parameters:
  • n (BoolectorNode) – A bit vector node.
  • width (int) – Number of bits to pad.
Returns:

A bit vector extended by width bits.

Return type:

BoolectorNode

Sgt(a, b)

Create a signed greater than.

Parameters a and b must have the same bit width (see Automatic Constant Conversion).

Parameters:
Returns:

A bit vector node with bit width one.

Return type:

BoolectorNode

Sgte(a, b)

Create a signed greater than or equal.

Parameters a and b must have the same bit width (see Automatic Constant Conversion).

Parameters:
Returns:

A bit vector node with bit width one.

Return type:

BoolectorNode

Simplify()

Simplify current input formula.

Returns:SAT if the input formula was simplified to true, UNSAT if it was simplified to false, and UNKNOWN, 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 index upper to index lower.

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:

BoolectorNode

Sll(a, b)

Create a logical shift left.

Given bit vector node b, the value it represents is the number of zeroes shifted into node a 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 of a.
Returns:

A bit vector node with the same bit width as a.

Return type:

BoolectorNode

Slt(a, b)

Create a signed less than.

Parameters a and b must have the same bit width (see Automatic Constant Conversion).

Parameters:
Returns:

A bit vector node with bit width one.

Return type:

BoolectorNode

Slte(a, b)

Create a signed less than or equal.

Parameters a and b must have the same bit width (see Automatic Constant Conversion).

Parameters:
Returns:

A bit vector node with bit width one.

Return type:

BoolectorNode

Smod(a, b)

Create a signed remainder where its sign matches the sign of the divisor.

Parameters a and b must have the same bit width (see Automatic Constant Conversion).

If b is zero, the result depends on Urem().

Parameters:
Returns:

A bit vector node with the same bit width as a and b.

Return type:

BoolectorNode

Smulo(a, b)

Create a signed bit vector multiplication overflow detection.

Parameters a and b must have the same bit width (see Automatic Constant Conversion).

Parameters:
Returns:

A bit vector node with bit width one, which indicates if the multiplication of a and b overflows in case both operands are treated as signed.

Return type:

BoolectorNode

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 node a (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 of a.
Returns:

A bit vector node with the same bit width as a.

Return type:

BoolectorNode

Srem(a, b)

Create a signed remainder.

Parameters a and b must have the same bit width (see Automatic Constant Conversion). If b is 0, the result of the unsigned remainder is a. If b is 0, the result of the unsigned remainder is a.

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 that b is zero, the result depends on Urem().

Parameters:
Returns:

A bit vector node with the same bit width as a and b.

Return type:

BoolectorNode

Srl(a, b)

Create a logical shift right.

Given bit vector node b, the value it represents is the number of zeroes shifted into node a 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 of a.
Returns:

A bit vector node with the same bit width as a.

Return type:

BoolectorNode

Ssubo(a, b)

Create a signed bit vector subtraction overflow detection.

Parameters a and b must have the same bit width (see Automatic Constant Conversion).

Parameters:
Returns:

A bit vector node with bit width one, which indicates if the subtraction of a and b overflows in case both operands are treated as signed.

Return type:

BoolectorNode

Sub(a, b)

Create a bit vector subtraction.

Parameters a and b 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:
Returns:

A bit vector node with the same bit width as a and b.

Return type:

BoolectorNode

UF(sort, symbol)

Create an uninterpreted function with sort sort and symbol symbol.

An uninterpreted function’s symbol is used as a simple means of identfication, either when printing a model via Print_model(), or generating file dumps via Dump(). A symbol must be unique but may be None in case that no symbol should be assigned.

See Apply(), FunSort().

Parameters:
  • sort (BoolectorSort) – Sort of the uninterpreted function.
  • symbol (str) – Name of the uninterpreted function.
Returns:

A function over parameterized expression body.

Return type:

BoolectorNode

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 and b must have the same bit width (see Automatic Constant Conversion).

Parameters:
Returns:

A bit vector node with bit width one, which indicates if the addition of a and b overflows in case both operands are treated as unsigned.

Return type:

BoolectorNode

Udiv(a, b)

Create an unsigned bit vector division.

Parameters a and b must have the same bit width (see Automatic Constant Conversion). If a 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:
Returns:

A bit vector node with the same bit width as a and b.

Return type:

BoolectorNode

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.

Uext(n, width)

Create unsigned extension.

Bit vector node n is padded with width 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:

BoolectorNode

Ugt(a, b)

Create an unsigned greater than.

Parameters a and b 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:
Returns:

A bit vector node with bit width one.

Return type:

BoolectorNode

Ugte(a, b)

Create an unsigned greater than or equal.

Parameters a and b 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:
Returns:

A bit vector node with bit width one.

Return type:

BoolectorNode

Ult(a, b)

Create an unsigned less than.

Parameters a and b 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:
Returns:

A bit vector node with bit width one.

Return type:

BoolectorNode

Ulte(a, b)

Create an unsigned less than or equal.

Parameters a and b 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:
Returns:

A bit vector node with bit width one.

Return type:

BoolectorNode

Umulo(a, b)

Create an unsigned bit vector multiplication overflow detection.

Parameters a and b must have the same bit width (see Automatic Constant Conversion).

Parameters:
Returns:

A bit vector node with bit width one, which indicates if the multiplication of a and b overflows in case both operands are treated as unsigned.

Return type:

BoolectorNode

Urem(a, b)

Create an unsigned remainder.

Parameters a and b must have the same bit width (see Automatic Constant Conversion). If b is 0, the result of the unsigned remainder is a.

It is also possible to create an unsigned remainder as follows (see Python Operator Overloading):

bvurem = a % b
Parameters:
Returns:

A bit vector node with the same bit width as a and b.

Return type:

BoolectorNode

Note

As in Udiv(), the behavior if b 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.

Usubo(a, b)

Create an unsigned bit vector subtraction overflow detection.

Parameters a and b must have the same bit width (see Automatic Constant Conversion).

Parameters:
Returns:

A bit vector node with bit width one, which indicates if the subtraction of a and b overflows in case both operands are treated as unsigned.

Return type:

BoolectorNode

Var(width, symbol = None)

Create a bit vector variable with bit width width.

A variable’s symbol is used as a simple means of identfication, either when printing a model via Print_model(), or generating file dumps via Dump(). A symbol must be unique but may be None in case that no symbol should be assigned.

Parameters:
  • width (int) – Bit width of the variable.
  • symbol (str) – Symbol of the variable.
Returns:

A bit vector variable with bit width width.

Return type:

BoolectorNode

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 position index with value value (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 of array. The bit width of value must be the same as the bit width of the elements of array.

Parameters:
Returns:

An array where the value at index has been updated with value.

Return type:

BoolectorNode

Xnor(a, b)

Create a bit vector xnor.

Parameters a and b must have the same bit width (see Automatic Constant Conversion).

Parameters:
Returns:

A bit vector node with the same bit width as a and b.

Return type:

BoolectorNode

Xor(a, b)

Create a bit vector xor.

Parameters a and b 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:
Returns:

A bit vector node with the same bit width as a and b.

Return type:

BoolectorNode

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: builtins.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: builtins.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, ‘smt1’ for SMT-LIB v1, 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() returned SAT.

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 via Dump().

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: builtins.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.

class boolector.BoolectorOptions

Bases: builtins.object

The class representing a Boolector option iterator (see Options()).

class boolector.BoolectorSort

Bases: builtins.object

The class representing a Boolector sort.