mirror of
https://github.com/Z3Prover/z3
synced 2026-06-01 22:57:51 +00:00
Alias ArithRef.__abs__ to Abs
This integrates with the `abs(Int('x'))` Python builtin.
This commit is contained in:
parent
e2486eff77
commit
c172b58268
1 changed files with 11 additions and 0 deletions
|
|
@ -2804,6 +2804,17 @@ class ArithRef(ExprRef):
|
||||||
a, b = _coerce_exprs(self, other)
|
a, b = _coerce_exprs(self, other)
|
||||||
return BoolRef(Z3_mk_ge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
|
return BoolRef(Z3_mk_ge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
|
||||||
|
|
||||||
|
def __abs__(self):
|
||||||
|
"""Return an expression representing `abs(self)`.
|
||||||
|
|
||||||
|
>>> x = Int('x')
|
||||||
|
>>> abs(x)
|
||||||
|
If(x > 0, x, -x)
|
||||||
|
>>> eq(abs(x), Abs(x))
|
||||||
|
True
|
||||||
|
"""
|
||||||
|
return Abs(self)
|
||||||
|
|
||||||
|
|
||||||
def is_arith(a):
|
def is_arith(a):
|
||||||
"""Return `True` if `a` is an arithmetical expression.
|
"""Return `True` if `a` is an arithmetical expression.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue