Z3
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Data Fields
AstVector Class Reference
+ Inheritance diagram for AstVector:

Public Member Functions

def __init__
 
def __del__
 
def __len__
 
def __getitem__
 
def __setitem__
 
def push
 
def resize
 
def __contains__
 
def translate
 
def __repr__
 
def sexpr
 
- Public Member Functions inherited from Z3PPObject
def use_pp
 

Data Fields

 vector
 
 ctx
 

Detailed Description

A collection (vector) of ASTs.

Definition at line 4801 of file z3py.py.

Constructor & Destructor Documentation

def __init__ (   self,
  v = None,
  ctx = None 
)

Definition at line 4804 of file z3py.py.

4805  def __init__(self, v=None, ctx=None):
4806  self.vector = None
4807  if v == None:
4808  self.ctx = _get_ctx(ctx)
4809  self.vector = Z3_mk_ast_vector(self.ctx.ref())
4810  else:
4811  self.vector = v
4812  assert ctx != None
4813  self.ctx = ctx
4814  Z3_ast_vector_inc_ref(self.ctx.ref(), self.vector)
void Z3_API Z3_ast_vector_inc_ref(__in Z3_context c, __in Z3_ast_vector v)
Increment the reference counter of the given AST vector.
def __init__
Definition: z3py.py:4804
Z3_ast_vector Z3_API Z3_mk_ast_vector(__in Z3_context c)
Return an empty AST vector.
def __del__ (   self)

Definition at line 4815 of file z3py.py.

4816  def __del__(self):
4817  if self.vector != None:
4818  Z3_ast_vector_dec_ref(self.ctx.ref(), self.vector)
def __del__
Definition: z3py.py:4815
void Z3_API Z3_ast_vector_dec_ref(__in Z3_context c, __in Z3_ast_vector v)
Decrement the reference counter of the given AST vector.

Member Function Documentation

def __contains__ (   self,
  item 
)
Return `True` if the vector contains `item`.

>>> x = Int('x')
>>> A = AstVector()
>>> x in A
False
>>> A.push(x)
>>> x in A
True
>>> (x+1) in A
False
>>> A.push(x+1)
>>> (x+1) in A
True
>>> A
[x, x + 1]

Definition at line 4888 of file z3py.py.

4889  def __contains__(self, item):
4890  """Return `True` if the vector contains `item`.
4891 
4892  >>> x = Int('x')
4893  >>> A = AstVector()
4894  >>> x in A
4895  False
4896  >>> A.push(x)
4897  >>> x in A
4898  True
4899  >>> (x+1) in A
4900  False
4901  >>> A.push(x+1)
4902  >>> (x+1) in A
4903  True
4904  >>> A
4905  [x, x + 1]
4906  """
4907  for elem in self:
4908  if elem.eq(item):
4909  return True
4910  return False
def __contains__
Definition: z3py.py:4888
def __getitem__ (   self,
  i 
)
Return the AST at position `i`.

>>> A = AstVector()
>>> A.push(Int('x') + 1)
>>> A.push(Int('y'))
>>> A[0]
x + 1
>>> A[1]
y

Definition at line 4832 of file z3py.py.

4833  def __getitem__(self, i):
4834  """Return the AST at position `i`.
4835 
4836  >>> A = AstVector()
4837  >>> A.push(Int('x') + 1)
4838  >>> A.push(Int('y'))
4839  >>> A[0]
4840  x + 1
4841  >>> A[1]
4842  y
4843  """
4844  if i >= self.__len__():
4845  raise IndexError
4846  return _to_ast_ref(Z3_ast_vector_get(self.ctx.ref(), self.vector, i), self.ctx)
def __len__
Definition: z3py.py:4819
def __getitem__
Definition: z3py.py:4832
Z3_ast Z3_API Z3_ast_vector_get(__in Z3_context c, __in Z3_ast_vector v, __in unsigned i)
Return the AST at position i in the AST vector v.
def __len__ (   self)
Return the size of the vector `self`.

>>> A = AstVector()
>>> len(A)
0
>>> A.push(Int('x'))
>>> A.push(Int('x'))
>>> len(A)
2

Definition at line 4819 of file z3py.py.

Referenced by AstVector.__getitem__().

4820  def __len__(self):
4821  """Return the size of the vector `self`.
4822 
4823  >>> A = AstVector()
4824  >>> len(A)
4825  0
4826  >>> A.push(Int('x'))
4827  >>> A.push(Int('x'))
4828  >>> len(A)
4829  2
4830  """
4831  return int(Z3_ast_vector_size(self.ctx.ref(), self.vector))
def __len__
Definition: z3py.py:4819
unsigned Z3_API Z3_ast_vector_size(__in Z3_context c, __in Z3_ast_vector v)
Return the size of the given AST vector.
def __repr__ (   self)

Definition at line 4924 of file z3py.py.

4925  def __repr__(self):
4926  return obj_to_string(self)
def __repr__
Definition: z3py.py:4924
def __setitem__ (   self,
  i,
  v 
)
Update AST at position `i`.

>>> A = AstVector()
>>> A.push(Int('x') + 1)
>>> A.push(Int('y'))
>>> A[0]
x + 1
>>> A[0] = Int('x')
>>> A[0]
x

Definition at line 4847 of file z3py.py.

4848  def __setitem__(self, i, v):
4849  """Update AST at position `i`.
4850 
4851  >>> A = AstVector()
4852  >>> A.push(Int('x') + 1)
4853  >>> A.push(Int('y'))
4854  >>> A[0]
4855  x + 1
4856  >>> A[0] = Int('x')
4857  >>> A[0]
4858  x
4859  """
4860  if i >= self.__len__():
4861  raise IndexError
4862  Z3_ast_vector_set(self.ctx.ref(), self.vector, i, v.as_ast())
def __len__
Definition: z3py.py:4819
def __setitem__
Definition: z3py.py:4847
void Z3_API Z3_ast_vector_set(__in Z3_context c, __in Z3_ast_vector v, __in unsigned i, __in Z3_ast a)
Update position i of the AST vector v with the AST a.
def push (   self,
  v 
)
Add `v` in the end of the vector.

>>> A = AstVector()
>>> len(A)
0
>>> A.push(Int('x'))
>>> len(A)
1

Definition at line 4863 of file z3py.py.

4864  def push(self, v):
4865  """Add `v` in the end of the vector.
4866 
4867  >>> A = AstVector()
4868  >>> len(A)
4869  0
4870  >>> A.push(Int('x'))
4871  >>> len(A)
4872  1
4873  """
4874  Z3_ast_vector_push(self.ctx.ref(), self.vector, v.as_ast())
void Z3_API Z3_ast_vector_push(__in Z3_context c, __in Z3_ast_vector v, __in Z3_ast a)
Add the AST a in the end of the AST vector v. The size of v is increased by one.
def resize (   self,
  sz 
)
Resize the vector to `sz` elements.

>>> A = AstVector()
>>> A.resize(10)
>>> len(A)
10
>>> for i in range(10): A[i] = Int('x')
>>> A[5]
x

Definition at line 4875 of file z3py.py.

4876  def resize(self, sz):
4877  """Resize the vector to `sz` elements.
4878 
4879  >>> A = AstVector()
4880  >>> A.resize(10)
4881  >>> len(A)
4882  10
4883  >>> for i in range(10): A[i] = Int('x')
4884  >>> A[5]
4885  x
4886  """
4887  Z3_ast_vector_resize(self.ctx.ref(), self.vector, sz)
def resize
Definition: z3py.py:4875
void Z3_API Z3_ast_vector_resize(__in Z3_context c, __in Z3_ast_vector v, __in unsigned n)
Resize the AST vector v.
def sexpr (   self)
Return a textual representation of the s-expression representing the vector.

Definition at line 4927 of file z3py.py.

Referenced by Fixedpoint.__repr__().

4928  def sexpr(self):
4929  """Return a textual representation of the s-expression representing the vector."""
4930  return Z3_ast_vector_to_string(self.ctx.ref(), self.vector)
Z3_string Z3_API Z3_ast_vector_to_string(__in Z3_context c, __in Z3_ast_vector v)
Convert AST vector into a string.
def translate (   self,
  other_ctx 
)
Copy vector `self` to context `other_ctx`.

>>> x = Int('x')
>>> A = AstVector()
>>> A.push(x)
>>> c2 = Context()
>>> B = A.translate(c2)
>>> B
[x]

Definition at line 4911 of file z3py.py.

4912  def translate(self, other_ctx):
4913  """Copy vector `self` to context `other_ctx`.
4914 
4915  >>> x = Int('x')
4916  >>> A = AstVector()
4917  >>> A.push(x)
4918  >>> c2 = Context()
4919  >>> B = A.translate(c2)
4920  >>> B
4921  [x]
4922  """
4923  return AstVector(Z3_ast_vector_translate(self.ctx.ref(), self.vector, other_ctx.ref()), other_ctx)
def translate
Definition: z3py.py:4911
Z3_ast_vector Z3_API Z3_ast_vector_translate(__in Z3_context s, __in Z3_ast_vector v, __in Z3_context t)
Translate the AST vector v from context s into an AST vector in context t.

Field Documentation

ctx

Definition at line 4807 of file z3py.py.

Referenced by Probe.__eq__(), Probe.__ge__(), AstVector.__getitem__(), AstMap.__getitem__(), ApplyResult.__getitem__(), Probe.__gt__(), Probe.__le__(), Probe.__lt__(), Probe.__ne__(), Fixedpoint.add_rule(), Tactic.apply(), ApplyResult.as_expr(), Fixedpoint.assert_exprs(), ApplyResult.convert_model(), Fixedpoint.get_answer(), Fixedpoint.get_assertions(), Fixedpoint.get_cover_delta(), Fixedpoint.get_rules(), AstMap.keys(), Fixedpoint.param_descrs(), Tactic.param_descrs(), Fixedpoint.parse_file(), Fixedpoint.parse_string(), Fixedpoint.set(), Tactic.solver(), Fixedpoint.statistics(), Solver.to_smt2(), and Fixedpoint.update_rule().

vector

Definition at line 4805 of file z3py.py.

Referenced by AstVector.__del__(), AstVector.__getitem__(), AstVector.__len__(), AstVector.__setitem__(), AstVector.push(), AstVector.resize(), AstVector.sexpr(), and AstVector.translate().