mirror of
https://github.com/Z3Prover/z3
synced 2026-02-16 22:01:44 +00:00
Merge pull request #8623 from danielzgtg/feat/__abs__
Alias ArithRef.__abs__ to Abs
This commit is contained in:
commit
e58c689d42
1 changed files with 11 additions and 0 deletions
|
|
@ -2804,6 +2804,17 @@ class ArithRef(ExprRef):
|
|||
a, b = _coerce_exprs(self, other)
|
||||
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):
|
||||
"""Return `True` if `a` is an arithmetical expression.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue