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

Constructor & Destructor Documentation

def __init__ (   self,
  probe,
  ctx = None 
)

Definition at line 6702 of file z3py.py.

6702  def __init__(self, probe, ctx=None):
6703  self.ctx = _get_ctx(ctx)
6704  self.probe = None
6705  if isinstance(probe, ProbeObj):
6706  self.probe = probe
6707  elif isinstance(probe, float):
6708  self.probe = Z3_probe_const(self.ctx.ref(), probe)
6709  elif _is_int(probe):
6710  self.probe = Z3_probe_const(self.ctx.ref(), float(probe))
6711  elif isinstance(probe, bool):
6712  if probe:
6713  self.probe = Z3_probe_const(self.ctx.ref(), 1.0)
6714  else:
6715  self.probe = Z3_probe_const(self.ctx.ref(), 0.0)
6716  else:
6717  if __debug__:
6718  _z3_assert(isinstance(probe, str), "probe name expected")
6719  try:
6720  self.probe = Z3_mk_probe(self.ctx.ref(), probe)
6721  except Z3Exception:
6722  raise Z3Exception("unknown probe '%s'" % probe)
6723  Z3_probe_inc_ref(self.ctx.ref(), self.probe)
6724 
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.

6725  def __del__(self):
6726  if self.probe != None:
6727  Z3_probe_dec_ref(self.ctx.ref(), self.probe)
6728 
def __del__(self)
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.

6808  def __call__(self, goal):
6809  """Evaluate the probe `self` in the given goal.
6810 
6811  >>> p = Probe('size')
6812  >>> x = Int('x')
6813  >>> g = Goal()
6814  >>> g.add(x > 0)
6815  >>> g.add(x < 10)
6816  >>> p(g)
6817  2.0
6818  >>> g.add(x < 20)
6819  >>> p(g)
6820  3.0
6821  >>> p = Probe('num-consts')
6822  >>> p(g)
6823  1.0
6824  >>> p = Probe('is-propositional')
6825  >>> p(g)
6826  0.0
6827  >>> p = Probe('is-qflia')
6828  >>> p(g)
6829  1.0
6830  """
6831  if __debug__:
6832  _z3_assert(isinstance(goal, Goal) or isinstance(goal, BoolRef), "Z3 Goal or Boolean expression expected")
6833  goal = _to_goal(goal)
6834  return Z3_probe_apply(self.ctx.ref(), self.probe, goal.goal)
6835 
def __call__(self, goal)
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__().

6781  def __eq__(self, other):
6782  """Return a probe that evaluates to "true" when the value returned by `self` is equal to the value returned by `other`.
6783 
6784  >>> p = Probe('size') == 2
6785  >>> x = Int('x')
6786  >>> g = Goal()
6787  >>> g.add(x > 0)
6788  >>> g.add(x < 10)
6789  >>> p(g)
6790  1.0
6791  """
6792  return Probe(Z3_probe_eq(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
6793 
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:6781
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.

6768  def __ge__(self, other):
6769  """Return a probe that evaluates to "true" when the value returned by `self` is greater than or equal to the value returned by `other`.
6770 
6771  >>> p = Probe('size') >= 2
6772  >>> x = Int('x')
6773  >>> g = Goal()
6774  >>> g.add(x > 0)
6775  >>> g.add(x < 10)
6776  >>> p(g)
6777  1.0
6778  """
6779  return Probe(Z3_probe_ge(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
6780 
def __ge__(self, other)
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.

6742  def __gt__(self, other):
6743  """Return a probe that evaluates to "true" when the value returned by `self` is greater than the value returned by `other`.
6744 
6745  >>> p = Probe('size') > 10
6746  >>> x = Int('x')
6747  >>> g = Goal()
6748  >>> g.add(x > 0)
6749  >>> g.add(x < 10)
6750  >>> p(g)
6751  0.0
6752  """
6753  return Probe(Z3_probe_gt(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
6754 
def __gt__(self, other)
Definition: z3py.py:6742
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 6755 of file z3py.py.

6755  def __le__(self, other):
6756  """Return a probe that evaluates to "true" when the value returned by `self` is less than or equal to the value returned by `other`.
6757 
6758  >>> p = Probe('size') <= 2
6759  >>> x = Int('x')
6760  >>> g = Goal()
6761  >>> g.add(x > 0)
6762  >>> g.add(x < 10)
6763  >>> p(g)
6764  1.0
6765  """
6766  return Probe(Z3_probe_le(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
6767 
def __le__(self, other)
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.

6729  def __lt__(self, other):
6730  """Return a probe that evaluates to "true" when the value returned by `self` is less than the value returned by `other`.
6731 
6732  >>> p = Probe('size') < 10
6733  >>> x = Int('x')
6734  >>> g = Goal()
6735  >>> g.add(x > 0)
6736  >>> g.add(x < 10)
6737  >>> p(g)
6738  1.0
6739  """
6740  return Probe(Z3_probe_lt(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
6741 
def __lt__(self, other)
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.

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

Field Documentation

ctx
probe