Z3
Public Member Functions | Data Fields
Probe Class Reference

Public Member Functions

def __init__
 
def __del__ (self)
 
def __lt__ (self, other)
 
def __gt__ (self, other)
 
def __le__ (self, other)
 
def __ge__ (self, other)
 
def __eq__ (self, other)
 
def __ne__ (self, other)
 
def __call__ (self, goal)
 

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

Constructor & Destructor Documentation

def __init__ (   self,
  probe,
  ctx = None 
)

Definition at line 6725 of file z3py.py.

6725  def __init__(self, probe, ctx=None):
6726  self.ctx = _get_ctx(ctx)
6727  self.probe = None
6728  if isinstance(probe, ProbeObj):
6729  self.probe = probe
6730  elif isinstance(probe, float):
6731  self.probe = Z3_probe_const(self.ctx.ref(), probe)
6732  elif _is_int(probe):
6733  self.probe = Z3_probe_const(self.ctx.ref(), float(probe))
6734  elif isinstance(probe, bool):
6735  if probe:
6736  self.probe = Z3_probe_const(self.ctx.ref(), 1.0)
6737  else:
6738  self.probe = Z3_probe_const(self.ctx.ref(), 0.0)
6739  else:
6740  if __debug__:
6741  _z3_assert(isinstance(probe, str), "probe name expected")
6742  try:
6743  self.probe = Z3_mk_probe(self.ctx.ref(), probe)
6744  except Z3Exception:
6745  raise Z3Exception("unknown probe '%s'" % probe)
6746  Z3_probe_inc_ref(self.ctx.ref(), self.probe)
6747 
def __init__
Definition: z3py.py:6725
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 6748 of file z3py.py.

6748  def __del__(self):
6749  if self.probe != None:
6750  Z3_probe_dec_ref(self.ctx.ref(), self.probe)
6751 
def __del__(self)
Definition: z3py.py:6748
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 6831 of file z3py.py.

6831  def __call__(self, goal):
6832  """Evaluate the probe `self` in the given goal.
6833 
6834  >>> p = Probe('size')
6835  >>> x = Int('x')
6836  >>> g = Goal()
6837  >>> g.add(x > 0)
6838  >>> g.add(x < 10)
6839  >>> p(g)
6840  2.0
6841  >>> g.add(x < 20)
6842  >>> p(g)
6843  3.0
6844  >>> p = Probe('num-consts')
6845  >>> p(g)
6846  1.0
6847  >>> p = Probe('is-propositional')
6848  >>> p(g)
6849  0.0
6850  >>> p = Probe('is-qflia')
6851  >>> p(g)
6852  1.0
6853  """
6854  if __debug__:
6855  _z3_assert(isinstance(goal, Goal) or isinstance(goal, BoolRef), "Z3 Goal or Boolean expression expected")
6856  goal = _to_goal(goal)
6857  return Z3_probe_apply(self.ctx.ref(), self.probe, goal.goal)
6858 
def __call__(self, goal)
Definition: z3py.py:6831
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 6804 of file z3py.py.

Referenced by Probe.__ne__().

6804  def __eq__(self, other):
6805  """Return a probe that evaluates to "true" when the value returned by `self` is equal to the value returned by `other`.
6806 
6807  >>> p = Probe('size') == 2
6808  >>> x = Int('x')
6809  >>> g = Goal()
6810  >>> g.add(x > 0)
6811  >>> g.add(x < 10)
6812  >>> p(g)
6813  1.0
6814  """
6815  return Probe(Z3_probe_eq(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
6816 
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 __eq__(self, other)
Definition: z3py.py:6804
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 6791 of file z3py.py.

6791  def __ge__(self, other):
6792  """Return a probe that evaluates to "true" when the value returned by `self` is greater than or equal to the value returned by `other`.
6793 
6794  >>> p = Probe('size') >= 2
6795  >>> x = Int('x')
6796  >>> g = Goal()
6797  >>> g.add(x > 0)
6798  >>> g.add(x < 10)
6799  >>> p(g)
6800  1.0
6801  """
6802  return Probe(Z3_probe_ge(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
6803 
def __ge__(self, other)
Definition: z3py.py:6791
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 6765 of file z3py.py.

6765  def __gt__(self, other):
6766  """Return a probe that evaluates to "true" when the value returned by `self` is greater than the value returned by `other`.
6767 
6768  >>> p = Probe('size') > 10
6769  >>> x = Int('x')
6770  >>> g = Goal()
6771  >>> g.add(x > 0)
6772  >>> g.add(x < 10)
6773  >>> p(g)
6774  0.0
6775  """
6776  return Probe(Z3_probe_gt(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
6777 
def __gt__(self, other)
Definition: z3py.py:6765
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 __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 6778 of file z3py.py.

6778  def __le__(self, other):
6779  """Return a probe that evaluates to "true" when the value returned by `self` is less than or equal to the value returned by `other`.
6780 
6781  >>> p = Probe('size') <= 2
6782  >>> x = Int('x')
6783  >>> g = Goal()
6784  >>> g.add(x > 0)
6785  >>> g.add(x < 10)
6786  >>> p(g)
6787  1.0
6788  """
6789  return Probe(Z3_probe_le(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
6790 
def __le__(self, other)
Definition: z3py.py:6778
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 6752 of file z3py.py.

6752  def __lt__(self, other):
6753  """Return a probe that evaluates to "true" when the value returned by `self` is less than the value returned by `other`.
6754 
6755  >>> p = Probe('size') < 10
6756  >>> x = Int('x')
6757  >>> g = Goal()
6758  >>> g.add(x > 0)
6759  >>> g.add(x < 10)
6760  >>> p(g)
6761  1.0
6762  """
6763  return Probe(Z3_probe_lt(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
6764 
def __lt__(self, other)
Definition: z3py.py:6752
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 6817 of file z3py.py.

6817  def __ne__(self, other):
6818  """Return a probe that evaluates to "true" when the value returned by `self` is not equal to the value returned by `other`.
6819 
6820  >>> p = Probe('size') != 2
6821  >>> x = Int('x')
6822  >>> g = Goal()
6823  >>> g.add(x > 0)
6824  >>> g.add(x < 10)
6825  >>> p(g)
6826  0.0
6827  """
6828  p = self.__eq__(other)
6829  return Probe(Z3_probe_not(self.ctx.ref(), p.probe), self.ctx)
6830 
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__(self, other)
Definition: z3py.py:6817
def __eq__(self, other)
Definition: z3py.py:6804

Field Documentation

ctx
probe