def build(self, btor: Boolector): ret = None if self.op == UnaryExprType.Not: ret = btor.Not(self.expr.build(btor)) return ret ExprModel.build(self, btor)
def build(self, btor: Boolector, ctx_width=-1): ret = None e_w = self.expr.width() if e_w > ctx_width: ctx_width = e_w if self.op == UnaryExprType.Not: ret = btor.Not(self.expr.build(btor, ctx_width)) return ret
# Variables _var = b.Var(_bvsort, "var_symbol") # Try getting the assignment of _var without a call to Sat(), # raises Exception try: print("Expect exception to be raised (no previous call to Sat()).") print("{} {}".format(_var.symbol, _var.assignment)) except BoolectorException as e: print("Caught exception: " + str(e)) _param = b.Param(_bvsort, "param_symbol") # used as function parameters _array = b.Array(_arrsort, "array_symbol") _uf = b.UF(_funsort) # One's complement _not0 = b.Not(_const) _not1 = ~_const # Two's complement _neg0 = b.Neg(_zero) _neg1 = -_zero # Reduction operations on bit vectors _redor = b.Redor(_ones) _redxor = b.Redxor(_one) _redand = b.Redand(_uint) # Slicing of bit vectors _slice0 = b.Slice(_param, 8, 0) _slice1 = _param[8:0] _slice3 = _param[:] # copy
# x <= 100 ulte_x = btor.Ulte(x, hundred) btor.Assert(ulte_x) # 0 < y ult_y = btor.Ult(zero, y) btor.Assert(ult_y) # y <= 100 ulte_y = btor.Ulte(y, hundred) btor.Assert(ulte_y) # x * y mul = btor.Mul(x, y) # x * y < 100 ult = btor.Ult(mul, hundred) btor.Assert(ult) umulo = btor.Umulo(x, y) numulo = btor.Not(umulo) # prevent overflow btor.Assert(numulo) res = btor.Sat() print("Expect: sat") print("Boolector: ", end='') if res == btor.SAT: print("sat") elif res == btor.UNSAT: print("unsat") else: print("unknown") print("") # prints "x: 00000100" print("assignment of {}: {}".format(x.symbol, x.assignment))