Z3
Public Member Functions | Data Fields
Probe Class Reference

Public Member Functions

def __init__
 
def __deepcopy__
 
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 8718 of file z3py.py.

Constructor & Destructor Documentation

def __init__ (   self,
  probe,
  ctx = None 
)

Definition at line 8723 of file z3py.py.

8723  def __init__(self, probe, ctx=None):
8724  self.ctx = _get_ctx(ctx)
8725  self.probe = None
8726  if isinstance(probe, ProbeObj):
8727  self.probe = probe
8728  elif isinstance(probe, float):
8729  self.probe = Z3_probe_const(self.ctx.ref(), probe)
8730  elif _is_int(probe):
8731  self.probe = Z3_probe_const(self.ctx.ref(), float(probe))
8732  elif isinstance(probe, bool):
8733  if probe:
8734  self.probe = Z3_probe_const(self.ctx.ref(), 1.0)
8735  else:
8736  self.probe = Z3_probe_const(self.ctx.ref(), 0.0)
8737  else:
8738  if z3_debug():
8739  _z3_assert(isinstance(probe, str), "probe name expected")
8740  try:
8741  self.probe = Z3_mk_probe(self.ctx.ref(), probe)
8742  except Z3Exception:
8743  raise Z3Exception("unknown probe '%s'" % probe)
8744  Z3_probe_inc_ref(self.ctx.ref(), self.probe)
8745 
Z3_probe Z3_API Z3_probe_const(Z3_context x, double val)
Return a probe that always evaluates to val.
Z3_probe Z3_API Z3_mk_probe(Z3_context c, Z3_string name)
Return a probe associated with the given name. The complete list of probes may be obtained using the ...
def __init__
Definition: z3py.py:8723
void Z3_API Z3_probe_inc_ref(Z3_context c, Z3_probe p)
Increment the reference counter of the given probe.
def z3_debug()
Definition: z3py.py:70
def __del__ (   self)

Definition at line 8749 of file z3py.py.

8749  def __del__(self):
8750  if self.probe is not None and self.ctx.ref() is not None and Z3_probe_dec_ref is not None:
8751  Z3_probe_dec_ref(self.ctx.ref(), self.probe)
8752 
def __del__(self)
Definition: z3py.py:8749
void Z3_API Z3_probe_dec_ref(Z3_context c, 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 8838 of file z3py.py.

8838  def __call__(self, goal):
8839  """Evaluate the probe `self` in the given goal.
8840 
8841  >>> p = Probe('size')
8842  >>> x = Int('x')
8843  >>> g = Goal()
8844  >>> g.add(x > 0)
8845  >>> g.add(x < 10)
8846  >>> p(g)
8847  2.0
8848  >>> g.add(x < 20)
8849  >>> p(g)
8850  3.0
8851  >>> p = Probe('num-consts')
8852  >>> p(g)
8853  1.0
8854  >>> p = Probe('is-propositional')
8855  >>> p(g)
8856  0.0
8857  >>> p = Probe('is-qflia')
8858  >>> p(g)
8859  1.0
8860  """
8861  if z3_debug():
8862  _z3_assert(isinstance(goal, (Goal, BoolRef)), "Z3 Goal or Boolean expression expected")
8863  goal = _to_goal(goal)
8864  return Z3_probe_apply(self.ctx.ref(), self.probe, goal.goal)
8865 
8866 
double Z3_API Z3_probe_apply(Z3_context c, Z3_probe p, Z3_goal g)
Execute the probe over the goal. The probe always produce a double value. "Boolean" probes return 0...
def z3_debug()
Definition: z3py.py:70
def __call__(self, goal)
Definition: z3py.py:8838
def __deepcopy__ (   self,
  memo = {} 
)

Definition at line 8746 of file z3py.py.

8746  def __deepcopy__(self, memo={}):
8747  return Probe(self.probe, self.ctx)
8748 
def __deepcopy__
Definition: z3py.py:8746
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 8809 of file z3py.py.

Referenced by Probe.__ne__().

8809  def __eq__(self, other):
8810  """Return a probe that evaluates to "true" when the value returned by `self`
8811  is equal to the value returned by `other`.
8812 
8813  >>> p = Probe('size') == 2
8814  >>> x = Int('x')
8815  >>> g = Goal()
8816  >>> g.add(x > 0)
8817  >>> g.add(x < 10)
8818  >>> p(g)
8819  1.0
8820  """
8821  return Probe(Z3_probe_eq(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
8822 
Z3_probe Z3_API Z3_probe_eq(Z3_context x, Z3_probe p1, 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:8809
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 8795 of file z3py.py.

8795  def __ge__(self, other):
8796  """Return a probe that evaluates to "true" when the value returned by `self`
8797  is greater than or equal to the value returned by `other`.
8798 
8799  >>> p = Probe('size') >= 2
8800  >>> x = Int('x')
8801  >>> g = Goal()
8802  >>> g.add(x > 0)
8803  >>> g.add(x < 10)
8804  >>> p(g)
8805  1.0
8806  """
8807  return Probe(Z3_probe_ge(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
8808 
def __ge__(self, other)
Definition: z3py.py:8795
Z3_probe Z3_API Z3_probe_ge(Z3_context x, Z3_probe p1, 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 8767 of file z3py.py.

8767  def __gt__(self, other):
8768  """Return a probe that evaluates to "true" when the value returned by `self`
8769  is greater than the value returned by `other`.
8770 
8771  >>> p = Probe('size') > 10
8772  >>> x = Int('x')
8773  >>> g = Goal()
8774  >>> g.add(x > 0)
8775  >>> g.add(x < 10)
8776  >>> p(g)
8777  0.0
8778  """
8779  return Probe(Z3_probe_gt(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
8780 
def __gt__(self, other)
Definition: z3py.py:8767
Z3_probe Z3_API Z3_probe_gt(Z3_context x, Z3_probe p1, 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 8781 of file z3py.py.

8781  def __le__(self, other):
8782  """Return a probe that evaluates to "true" when the value returned by `self`
8783  is less than or equal to the value returned by `other`.
8784 
8785  >>> p = Probe('size') <= 2
8786  >>> x = Int('x')
8787  >>> g = Goal()
8788  >>> g.add(x > 0)
8789  >>> g.add(x < 10)
8790  >>> p(g)
8791  1.0
8792  """
8793  return Probe(Z3_probe_le(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
8794 
Z3_probe Z3_API Z3_probe_le(Z3_context x, Z3_probe p1, 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 __le__(self, other)
Definition: z3py.py:8781
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 8753 of file z3py.py.

8753  def __lt__(self, other):
8754  """Return a probe that evaluates to "true" when the value returned by `self`
8755  is less than the value returned by `other`.
8756 
8757  >>> p = Probe('size') < 10
8758  >>> x = Int('x')
8759  >>> g = Goal()
8760  >>> g.add(x > 0)
8761  >>> g.add(x < 10)
8762  >>> p(g)
8763  1.0
8764  """
8765  return Probe(Z3_probe_lt(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
8766 
def __lt__(self, other)
Definition: z3py.py:8753
Z3_probe Z3_API Z3_probe_lt(Z3_context x, Z3_probe p1, 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 8823 of file z3py.py.

8823  def __ne__(self, other):
8824  """Return a probe that evaluates to "true" when the value returned by `self`
8825  is not equal to the value returned by `other`.
8826 
8827  >>> p = Probe('size') != 2
8828  >>> x = Int('x')
8829  >>> g = Goal()
8830  >>> g.add(x > 0)
8831  >>> g.add(x < 10)
8832  >>> p(g)
8833  0.0
8834  """
8835  p = self.__eq__(other)
8836  return Probe(Z3_probe_not(self.ctx.ref(), p.probe), self.ctx)
8837 
Z3_probe Z3_API Z3_probe_not(Z3_context x, Z3_probe p)
Return a probe that evaluates to "true" when p does not evaluate to true.
def __ne__(self, other)
Definition: z3py.py:8823
def __eq__(self, other)
Definition: z3py.py:8809

Field Documentation

ctx
probe