3
0
Fork 0
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:
Nikolaj Bjorner 2026-02-15 17:17:21 -08:00 committed by GitHub
commit e58c689d42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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