Z3
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Data Fields
Probe Class Reference

Public Member Functions

def __init__
 
def __del__
 
def __lt__
 
def __gt__
 
def __le__
 
def __ge__
 
def __eq__
 
def __ne__
 
def __call__
 

Data Fields

 ctx
 
 probe
 

Detailed Description

Probes are used to inspect a goal (aka problem) and collect information that may be used to decide which solver and/or preprocessing step will be used.

Definition at line 6700 of file z3py.py.

Constructor & Destructor Documentation

def __init__ (   self,
  probe,
  ctx = None 
)

Definition at line 6702 of file z3py.py.

6703  def __init__(self, probe, ctx=None):
6704  self.ctx = _get_ctx(ctx)
6705  self.probe = None
6706  if isinstance(probe, ProbeObj):
6707  self.probe = probe
6708  elif isinstance(probe, float):
6709  self.probe = Z3_probe_const(self.ctx.ref(), probe)
6710  elif _is_int(probe):
6711  self.probe = Z3_probe_const(self.ctx.ref(), float(probe))
6712  elif isinstance(probe, bool):
6713  if probe:
6714  self.probe = Z3_probe_const(self.ctx.ref(), 1.0)
6715  else:
6716  self.probe = Z3_probe_const(self.ctx.ref(), 0.0)
6717  else:
6718  if __debug__:
6719  _z3_assert(isinstance(probe, str), "probe name expected")
6720  try:
6721  self.probe = Z3_mk_probe(self.ctx.ref(), probe)
6722  except Z3Exception:
6723  raise Z3Exception("unknown probe '%s'" % probe)
6724  Z3_probe_inc_ref(self.ctx.ref(), self.probe)
def __init__
Definition: z3py.py:6702
void Z3_API Z3_probe_inc_ref(__in Z3_context c, __in Z3_probe p)
Increment the reference counter of the given probe.
Z3_probe Z3_API Z3_probe_const(__in Z3_context x, __in double val)
Return a probe that always evaluates to val.
Z3_probe Z3_API Z3_mk_probe(__in Z3_context c, __in Z3_string name)
Return a probe associated with the given name. The complete list of probes may be obtained using the ...
def __del__ (   self)

Definition at line 6725 of file z3py.py.

6726  def __del__(self):
6727  if self.probe != None:
6728  Z3_probe_dec_ref(self.ctx.ref(), self.probe)
def __del__
Definition: z3py.py:6725
void Z3_API Z3_probe_dec_ref(__in Z3_context c, __in Z3_probe p)
Decrement the reference counter of the given probe.

Member Function Documentation

def __call__ (   self,
  goal 
)
Evaluate the probe `self` in the given goal.

>>> p = Probe('size')
>>> x = Int('x')
>>> g = Goal()
>>> g.add(x > 0)
>>> g.add(x < 10)
>>> p(g)
2.0
>>> g.add(x < 20)
>>> p(g)
3.0
>>> p = Probe('num-consts')
>>> p(g)
1.0
>>> p = Probe('is-propositional')
>>> p(g)
0.0
>>> p = Probe('is-qflia')
>>> p(g)
1.0

Definition at line 6808 of file z3py.py.

6809  def __call__(self, goal):
6810  """Evaluate the probe `self` in the given goal.
6811 
6812  >>> p = Probe('size')
6813  >>> x = Int('x')
6814  >>> g = Goal()
6815  >>> g.add(x > 0)
6816  >>> g.add(x < 10)
6817  >>> p(g)
6818  2.0
6819  >>> g.add(x < 20)
6820  >>> p(g)
6821  3.0
6822  >>> p = Probe('num-consts')
6823  >>> p(g)
6824  1.0
6825  >>> p = Probe('is-propositional')
6826  >>> p(g)
6827  0.0
6828  >>> p = Probe('is-qflia')
6829  >>> p(g)
6830  1.0
6831  """
6832  if __debug__:
6833  _z3_assert(isinstance(goal, Goal) or isinstance(goal, BoolRef), "Z3 Goal or Boolean expression expected")
6834  goal = _to_goal(goal)
6835  return Z3_probe_apply(self.ctx.ref(), self.probe, goal.goal)
def __call__
Definition: z3py.py:6808
double Z3_API Z3_probe_apply(__in Z3_context c, __in Z3_probe p, __in Z3_goal g)
Execute the probe over the goal. The probe always produce a double value. "Boolean" probes return 0...
def __eq__ (   self,
  other 
)
Return a probe that evaluates to "true" when the value returned by `self` is equal to the value returned by `other`.

>>> p = Probe('size') == 2
>>> x = Int('x')
>>> g = Goal()
>>> g.add(x > 0)
>>> g.add(x < 10)
>>> p(g)
1.0

Definition at line 6781 of file z3py.py.

Referenced by Probe.__ne__().

6782  def __eq__(self, other):
6783  """Return a probe that evaluates to "true" when the value returned by `self` is equal to the value returned by `other`.
6784 
6785  >>> p = Probe('size') == 2
6786  >>> x = Int('x')
6787  >>> g = Goal()
6788  >>> g.add(x > 0)
6789  >>> g.add(x < 10)
6790  >>> p(g)
6791  1.0
6792  """
6793  return Probe(Z3_probe_eq(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
def __eq__
Definition: z3py.py:6781
Z3_probe Z3_API Z3_probe_eq(__in Z3_context x, __in Z3_probe p1, __in Z3_probe p2)
Return a probe that evaluates to "true" when the value returned by p1 is equal to the value returned ...
def __ge__ (   self,
  other 
)
Return a probe that evaluates to "true" when the value returned by `self` is greater than or equal to the value returned by `other`.

>>> p = Probe('size') >= 2
>>> x = Int('x')
>>> g = Goal()
>>> g.add(x > 0)
>>> g.add(x < 10)
>>> p(g)
1.0

Definition at line 6768 of file z3py.py.

6769  def __ge__(self, other):
6770  """Return a probe that evaluates to "true" when the value returned by `self` is greater than or equal to the value returned by `other`.
6771 
6772  >>> p = Probe('size') >= 2
6773  >>> x = Int('x')
6774  >>> g = Goal()
6775  >>> g.add(x > 0)
6776  >>> g.add(x < 10)
6777  >>> p(g)
6778  1.0
6779  """
6780  return Probe(Z3_probe_ge(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
def __ge__
Definition: z3py.py:6768
Z3_probe Z3_API Z3_probe_ge(__in Z3_context x, __in Z3_probe p1, __in Z3_probe p2)
Return a probe that evaluates to "true" when the value returned by p1 is greater than or equal to the...
def __gt__ (   self,
  other 
)
Return a probe that evaluates to "true" when the value returned by `self` is greater than the value returned by `other`.

>>> p = Probe('size') > 10
>>> x = Int('x')
>>> g = Goal()
>>> g.add(x > 0)
>>> g.add(x < 10)
>>> p(g)
0.0

Definition at line 6742 of file z3py.py.

6743  def __gt__(self, other):
6744  """Return a probe that evaluates to "true" when the value returned by `self` is greater than the value returned by `other`.
6745 
6746  >>> p = Probe('size') > 10
6747  >>> x = Int('x')
6748  >>> g = Goal()
6749  >>> g.add(x > 0)
6750  >>> g.add(x < 10)
6751  >>> p(g)
6752  0.0
6753  """
6754  return Probe(Z3_probe_gt(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
Z3_probe Z3_API Z3_probe_gt(__in Z3_context x, __in Z3_probe p1, __in Z3_probe p2)
Return a probe that evaluates to "true" when the value returned by p1 is greater than the value retur...
def __gt__
Definition: z3py.py:6742
def __le__ (   self,
  other 
)
Return a probe that evaluates to "true" when the value returned by `self` is less than or equal to the value returned by `other`.

>>> p = Probe('size') <= 2
>>> x = Int('x')
>>> g = Goal()
>>> g.add(x > 0)
>>> g.add(x < 10)
>>> p(g)
1.0

Definition at line 6755 of file z3py.py.

6756  def __le__(self, other):
6757  """Return a probe that evaluates to "true" when the value returned by `self` is less than or equal to the value returned by `other`.
6758 
6759  >>> p = Probe('size') <= 2
6760  >>> x = Int('x')
6761  >>> g = Goal()
6762  >>> g.add(x > 0)
6763  >>> g.add(x < 10)
6764  >>> p(g)
6765  1.0
6766  """
6767  return Probe(Z3_probe_le(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
def __le__
Definition: z3py.py:6755
Z3_probe Z3_API Z3_probe_le(__in Z3_context x, __in Z3_probe p1, __in Z3_probe p2)
Return a probe that evaluates to "true" when the value returned by p1 is less than or equal to the va...
def __lt__ (   self,
  other 
)
Return a probe that evaluates to "true" when the value returned by `self` is less than the value returned by `other`.

>>> p = Probe('size') < 10
>>> x = Int('x')
>>> g = Goal()
>>> g.add(x > 0)
>>> g.add(x < 10)
>>> p(g)
1.0

Definition at line 6729 of file z3py.py.

6730  def __lt__(self, other):
6731  """Return a probe that evaluates to "true" when the value returned by `self` is less than the value returned by `other`.
6732 
6733  >>> p = Probe('size') < 10
6734  >>> x = Int('x')
6735  >>> g = Goal()
6736  >>> g.add(x > 0)
6737  >>> g.add(x < 10)
6738  >>> p(g)
6739  1.0
6740  """
6741  return Probe(Z3_probe_lt(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
def __lt__
Definition: z3py.py:6729
Z3_probe Z3_API Z3_probe_lt(__in Z3_context x, __in Z3_probe p1, __in Z3_probe p2)
Return a probe that evaluates to "true" when the value returned by p1 is less than the value returned...
def __ne__ (   self,
  other 
)
Return a probe that evaluates to "true" when the value returned by `self` is not equal to the value returned by `other`.

>>> p = Probe('size') != 2
>>> x = Int('x')
>>> g = Goal()
>>> g.add(x > 0)
>>> g.add(x < 10)
>>> p(g)
0.0

Definition at line 6794 of file z3py.py.

6795  def __ne__(self, other):
6796  """Return a probe that evaluates to "true" when the value returned by `self` is not equal to the value returned by `other`.
6797 
6798  >>> p = Probe('size') != 2
6799  >>> x = Int('x')
6800  >>> g = Goal()
6801  >>> g.add(x > 0)
6802  >>> g.add(x < 10)
6803  >>> p(g)
6804  0.0
6805  """
6806  p = self.__eq__(other)
6807  return Probe(Z3_probe_not(self.ctx.ref(), p.probe), self.ctx)
def __eq__
Definition: z3py.py:6781
Z3_probe Z3_API Z3_probe_not(__in Z3_context x, __in Z3_probe p)
Return a probe that evaluates to "true" when p does not evaluate to true.
def __ne__
Definition: z3py.py:6794

Field Documentation

ctx

Definition at line 6703 of file z3py.py.

Referenced by Probe.__eq__(), Probe.__ge__(), Probe.__gt__(), Probe.__le__(), Probe.__lt__(), and Probe.__ne__().

probe

Definition at line 6704 of file z3py.py.

Referenced by Probe.__call__(), Probe.__del__(), Probe.__eq__(), Probe.__ge__(), Probe.__gt__(), Probe.__le__(), and Probe.__lt__().