mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 09:05:31 +00:00
add py_value to selected classes in python bindings, add mode for input-assertion based lookahead solving
This commit is contained in:
parent
7e4681d836
commit
05f166f736
18 changed files with 374 additions and 184 deletions
|
@ -263,7 +263,7 @@ extern "C" {
|
|||
if (ous.str().empty()) ous << e.what();
|
||||
SET_ERROR_CODE(Z3_PARSER_ERROR, ous.str());
|
||||
}
|
||||
Z3_CATCH_CORE();
|
||||
Z3_CATCH_CORE({});
|
||||
RETURN_Z3(mk_c(c)->mk_external_string(std::move(ous).str()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -447,6 +447,10 @@ class AstRef(Z3PPObject):
|
|||
"""
|
||||
return Z3_get_ast_hash(self.ctx_ref(), self.as_ast())
|
||||
|
||||
def py_value(self):
|
||||
"""Return a Python value that is equivalent to `self`."""
|
||||
return None
|
||||
|
||||
|
||||
def is_ast(a):
|
||||
"""Return `True` if `a` is an AST node.
|
||||
|
@ -1611,6 +1615,13 @@ class BoolRef(ExprRef):
|
|||
|
||||
def __invert__(self):
|
||||
return Not(self)
|
||||
|
||||
def py_value(self):
|
||||
if is_true(self):
|
||||
return True
|
||||
if is_false(self):
|
||||
return False
|
||||
return None
|
||||
|
||||
|
||||
|
||||
|
@ -3045,6 +3056,9 @@ class IntNumRef(ArithRef):
|
|||
"""
|
||||
return Z3_get_numeral_binary_string(self.ctx_ref(), self.as_ast())
|
||||
|
||||
def py_value(self):
|
||||
return Z3_get_numeral_double(self.ctx_ref(), self.as_ast())
|
||||
|
||||
|
||||
class RatNumRef(ArithRef):
|
||||
"""Rational values."""
|
||||
|
@ -3142,6 +3156,9 @@ class RatNumRef(ArithRef):
|
|||
"""
|
||||
return Fraction(self.numerator_as_long(), self.denominator_as_long())
|
||||
|
||||
def py_value(self):
|
||||
return Z3_get_numeral_double(self.ctx_ref(), self.as_ast())
|
||||
|
||||
|
||||
class AlgebraicNumRef(ArithRef):
|
||||
"""Algebraic irrational values."""
|
||||
|
@ -11005,6 +11022,9 @@ class SeqRef(ExprRef):
|
|||
return string_at(chars, size=string_length.value).decode("latin-1")
|
||||
return Z3_ast_to_string(self.ctx_ref(), self.as_ast())
|
||||
|
||||
def py_value(self):
|
||||
return self.as_string()
|
||||
|
||||
def __le__(self, other):
|
||||
return _to_expr_ref(Z3_mk_str_le(self.ctx_ref(), self.as_ast(), other.as_ast()), self.ctx)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue