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 12789 of file z3py.py.

Member Function Documentation

◆ __add__()

__add__ ( self,
other )

Definition at line 12803 of file z3py.py.

12803 def __add__(self, other):
12804 return self._binary(other, Z3_mk_ff_add)
12805

◆ __mul__()

__mul__ ( self,
other )

Definition at line 12809 of file z3py.py.

12809 def __mul__(self, other):
12810 return self._binary(other, Z3_mk_ff_mul)
12811

◆ __neg__()

__neg__ ( self)

Definition at line 12815 of file z3py.py.

12815 def __neg__(self):
12816 return FiniteFieldRef(Z3_mk_ff_neg(self.ctx_ref(), self.as_ast()), self.ctx)
12817
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 12824 of file z3py.py.

12824 def __pow__(self, n):
12825 if not isinstance(n, int) or n < 0:
12826 raise Z3Exception("finite-field exponent must be a nonnegative integer")
12827 result, base = FiniteFieldVal(1, self.sort()), self
12828 while n:
12829 if n & 1:
12830 result = result * base
12831 n >>= 1
12832 if n:
12833 base = base * base
12834 return result
12835
12836

◆ __radd__()

__radd__ ( self,
other )

Definition at line 12806 of file z3py.py.

12806 def __radd__(self, other):
12807 return self + other
12808

◆ __rmul__()

__rmul__ ( self,
other )

Definition at line 12812 of file z3py.py.

12812 def __rmul__(self, other):
12813 return self * other
12814

◆ __rsub__()

__rsub__ ( self,
other )

Definition at line 12821 of file z3py.py.

12821 def __rsub__(self, other):
12822 return self.sort().cast(other) + -self
12823

◆ __sub__()

__sub__ ( self,
other )

Definition at line 12818 of file z3py.py.

12818 def __sub__(self, other):
12819 return self + -self.sort().cast(other)
12820

◆ _binary()

_binary ( self,
other,
operation )
protected

Definition at line 12798 of file z3py.py.

12798 def _binary(self, other, operation):
12799 other = self.sort().cast(other)
12800 args = (Ast * 2)(self.as_ast(), other.as_ast())
12801 return FiniteFieldRef(operation(self.ctx_ref(), 2, args), self.ctx)
12802

◆ as_long()

as_long ( self)

Definition at line 12793 of file z3py.py.

12793 def as_long(self):
12794 if not Z3_is_numeral_ast(self.ctx_ref(), self.as_ast()):
12795 raise Z3Exception("finite-field numeral expected")
12796 return int(Z3_get_numeral_string(self.ctx_ref(), self.as_ast()))
12797
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 12790 of file z3py.py.

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