Z3
Loading...
Searching...
No Matches
FiniteFieldRef Class Reference
Inheritance diagram for FiniteFieldRef:

Public Member Functions

 sort (self)
 as_long (self)
 __add__ (self, other)
 __radd__ (self, other)
 __mul__ (self, other)
 __rmul__ (self, other)
 __neg__ (self)
 __sub__ (self, other)
 __rsub__ (self, other)
 __pow__ (self, n)
Public Member Functions inherited from ExprRef
 as_ast (self)
 get_id (self)
 sort_kind (self)
 __eq__ (self, other)
 __hash__ (self)
 __ne__ (self, other)
 params (self)
 decl (self)
 kind (self)
 num_args (self)
 arg (self, idx)
 children (self)
 update (self, *args)
 from_string (self, s)
 serialize (self)
Public Member Functions inherited from AstRef
 __init__ (self, ast, ctx=None)
 __del__ (self)
 __deepcopy__ (self, memo={})
 __str__ (self)
 __repr__ (self)
 __eq__ (self, other)
 __hash__ (self)
 __nonzero__ (self)
 __bool__ (self)
 sexpr (self)
 ctx_ref (self)
 eq (self, other)
 translate (self, target)
 __copy__ (self)
 hash (self)
 py_value (self)
Public Member Functions inherited from Z3PPObject
 use_pp (self)

Protected Member Functions

 _binary (self, other, operation)
Protected Member Functions inherited from Z3PPObject
 _repr_html_ (self)

Additional Inherited Members

Data Fields inherited from AstRef
 ast = ast
 ctx = _get_ctx(ctx)

Detailed Description

Definition at line 12656 of file z3py.py.

Member Function Documentation

◆ __add__()

__add__ ( self,
other )

Definition at line 12670 of file z3py.py.

12670 def __add__(self, other):
12671 return self._binary(other, Z3_mk_ff_add)
12672

◆ __mul__()

__mul__ ( self,
other )

Definition at line 12676 of file z3py.py.

12676 def __mul__(self, other):
12677 return self._binary(other, Z3_mk_ff_mul)
12678

◆ __neg__()

__neg__ ( self)

Definition at line 12682 of file z3py.py.

12682 def __neg__(self):
12683 return FiniteFieldRef(Z3_mk_ff_neg(self.ctx_ref(), self.as_ast()), self.ctx)
12684
Z3_ast Z3_API Z3_mk_ff_neg(Z3_context c, Z3_ast a)
Additive inverse in a prime field.

◆ __pow__()

__pow__ ( self,
n )

Definition at line 12691 of file z3py.py.

12691 def __pow__(self, n):
12692 if not isinstance(n, int) or n < 0:
12693 raise Z3Exception("finite-field exponent must be a nonnegative integer")
12694 result, base = FiniteFieldVal(1, self.sort()), self
12695 while n:
12696 if n & 1:
12697 result = result * base
12698 n >>= 1
12699 if n:
12700 base = base * base
12701 return result
12702
12703

◆ __radd__()

__radd__ ( self,
other )

Definition at line 12673 of file z3py.py.

12673 def __radd__(self, other):
12674 return self + other
12675

◆ __rmul__()

__rmul__ ( self,
other )

Definition at line 12679 of file z3py.py.

12679 def __rmul__(self, other):
12680 return self * other
12681

◆ __rsub__()

__rsub__ ( self,
other )

Definition at line 12688 of file z3py.py.

12688 def __rsub__(self, other):
12689 return self.sort().cast(other) + -self
12690

◆ __sub__()

__sub__ ( self,
other )

Definition at line 12685 of file z3py.py.

12685 def __sub__(self, other):
12686 return self + -self.sort().cast(other)
12687

◆ _binary()

_binary ( self,
other,
operation )
protected

Definition at line 12665 of file z3py.py.

12665 def _binary(self, other, operation):
12666 other = self.sort().cast(other)
12667 args = (Ast * 2)(self.as_ast(), other.as_ast())
12668 return FiniteFieldRef(operation(self.ctx_ref(), 2, args), self.ctx)
12669

◆ as_long()

as_long ( self)

Definition at line 12660 of file z3py.py.

12660 def as_long(self):
12661 if not Z3_is_numeral_ast(self.ctx_ref(), self.as_ast()):
12662 raise Z3Exception("finite-field numeral expected")
12663 return int(Z3_get_numeral_string(self.ctx_ref(), self.as_ast()))
12664
bool Z3_API Z3_is_numeral_ast(Z3_context c, Z3_ast a)
Z3_string Z3_API Z3_get_numeral_string(Z3_context c, Z3_ast a)
Return numeral value, as a decimal string of a numeric constant term.

◆ sort()

sort ( self)
Return the sort of expression `self`.

>>> x = Int('x')
>>> (x + 1).sort()
Int
>>> y = Real('y')
>>> (x + y).sort()
Real

Reimplemented from ExprRef.

Definition at line 12657 of file z3py.py.

12657 def sort(self):
12658 return FiniteFieldSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
12659
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.