Z3
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 6922 of file z3py.py.

Constructor & Destructor Documentation

def __init__ (   self,
  probe,
  ctx = None 
)

Definition at line 6924 of file z3py.py.

6925  def __init__(self, probe, ctx=None):
6926  self.ctx = _get_ctx(ctx)
6927  self.probe = None
6928  if isinstance(probe, ProbeObj):
6929  self.probe = probe
6930  elif isinstance(probe, float):
6931  self.probe = Z3_probe_const(self.ctx.ref(), probe)
6932  elif _is_int(probe):
6933  self.probe = Z3_probe_const(self.ctx.ref(), float(probe))
6934  elif isinstance(probe, bool):
6935  if probe:
6936  self.probe = Z3_probe_const(self.ctx.ref(), 1.0)
6937  else:
6938  self.probe = Z3_probe_const(self.ctx.ref(), 0.0)
6939  else:
6940  if __debug__:
6941  _z3_assert(isinstance(probe, str), "probe name expected")
6942  try:
6943  self.probe = Z3_mk_probe(self.ctx.ref(), probe)
6944  except Z3Exception:
6945  raise Z3Exception("unknown probe '%s'" % probe)
6946  Z3_probe_inc_ref(self.ctx.ref(), self.probe)
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:6924
void Z3_API Z3_probe_inc_ref(Z3_context c, Z3_probe p)
Increment the reference counter of the given probe.
def __del__ (   self)

Definition at line 6947 of file z3py.py.

6948  def __del__(self):
6949  if self.probe != None:
6950  Z3_probe_dec_ref(self.ctx.ref(), self.probe)
def __del__
Definition: z3py.py:6947
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 7030 of file z3py.py.

7031  def __call__(self, goal):
7032  """Evaluate the probe `self` in the given goal.
7033 
7034  >>> p = Probe('size')
7035  >>> x = Int('x')
7036  >>> g = Goal()
7037  >>> g.add(x > 0)
7038  >>> g.add(x < 10)
7039  >>> p(g)
7040  2.0
7041  >>> g.add(x < 20)
7042  >>> p(g)
7043  3.0
7044  >>> p = Probe('num-consts')
7045  >>> p(g)
7046  1.0
7047  >>> p = Probe('is-propositional')
7048  >>> p(g)
7049  0.0
7050  >>> p = Probe('is-qflia')
7051  >>> p(g)
7052  1.0
7053  """
7054  if __debug__:
7055  _z3_assert(isinstance(goal, Goal) or isinstance(goal, BoolRef), "Z3 Goal or Boolean expression expected")
7056  goal = _to_goal(goal)
7057  return Z3_probe_apply(self.ctx.ref(), self.probe, goal.goal)
def __call__
Definition: z3py.py:7030
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. &quot;Boolean&quot; 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 7003 of file z3py.py.

Referenced by Probe.__ne__().

7004  def __eq__(self, other):
7005  """Return a probe that evaluates to "true" when the value returned by `self` is equal to the value returned by `other`.
7006 
7007  >>> p = Probe('size') == 2
7008  >>> x = Int('x')
7009  >>> g = Goal()
7010  >>> g.add(x > 0)
7011  >>> g.add(x < 10)
7012  >>> p(g)
7013  1.0
7014  """
7015  return Probe(Z3_probe_eq(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
def __eq__
Definition: z3py.py:7003
Z3_probe Z3_API Z3_probe_eq(Z3_context x, Z3_probe p1, Z3_probe p2)
Return a probe that evaluates to &quot;true&quot; 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 6990 of file z3py.py.

6991  def __ge__(self, other):
6992  """Return a probe that evaluates to "true" when the value returned by `self` is greater than or equal to the value returned by `other`.
6993 
6994  >>> p = Probe('size') >= 2
6995  >>> x = Int('x')
6996  >>> g = Goal()
6997  >>> g.add(x > 0)
6998  >>> g.add(x < 10)
6999  >>> p(g)
7000  1.0
7001  """
7002  return Probe(Z3_probe_ge(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
Z3_probe Z3_API Z3_probe_ge(Z3_context x, Z3_probe p1, Z3_probe p2)
Return a probe that evaluates to &quot;true&quot; when the value returned by p1 is greater than or equal to the...
def __ge__
Definition: z3py.py:6990
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 6964 of file z3py.py.

6965  def __gt__(self, other):
6966  """Return a probe that evaluates to "true" when the value returned by `self` is greater than the value returned by `other`.
6967 
6968  >>> p = Probe('size') > 10
6969  >>> x = Int('x')
6970  >>> g = Goal()
6971  >>> g.add(x > 0)
6972  >>> g.add(x < 10)
6973  >>> p(g)
6974  0.0
6975  """
6976  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(Z3_context x, Z3_probe p1, Z3_probe p2)
Return a probe that evaluates to &quot;true&quot; when the value returned by p1 is greater than the value retur...
def __gt__
Definition: z3py.py:6964
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 6977 of file z3py.py.

6978  def __le__(self, other):
6979  """Return a probe that evaluates to "true" when the value returned by `self` is less than or equal to the value returned by `other`.
6980 
6981  >>> p = Probe('size') <= 2
6982  >>> x = Int('x')
6983  >>> g = Goal()
6984  >>> g.add(x > 0)
6985  >>> g.add(x < 10)
6986  >>> p(g)
6987  1.0
6988  """
6989  return Probe(Z3_probe_le(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
Z3_probe Z3_API Z3_probe_le(Z3_context x, Z3_probe p1, Z3_probe p2)
Return a probe that evaluates to &quot;true&quot; when the value returned by p1 is less than or equal to the va...
def __le__
Definition: z3py.py:6977
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 6951 of file z3py.py.

6952  def __lt__(self, other):
6953  """Return a probe that evaluates to "true" when the value returned by `self` is less than the value returned by `other`.
6954 
6955  >>> p = Probe('size') < 10
6956  >>> x = Int('x')
6957  >>> g = Goal()
6958  >>> g.add(x > 0)
6959  >>> g.add(x < 10)
6960  >>> p(g)
6961  1.0
6962  """
6963  return Probe(Z3_probe_lt(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
def __lt__
Definition: z3py.py:6951
Z3_probe Z3_API Z3_probe_lt(Z3_context x, Z3_probe p1, Z3_probe p2)
Return a probe that evaluates to &quot;true&quot; 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 7016 of file z3py.py.

7017  def __ne__(self, other):
7018  """Return a probe that evaluates to "true" when the value returned by `self` is not equal to the value returned by `other`.
7019 
7020  >>> p = Probe('size') != 2
7021  >>> x = Int('x')
7022  >>> g = Goal()
7023  >>> g.add(x > 0)
7024  >>> g.add(x < 10)
7025  >>> p(g)
7026  0.0
7027  """
7028  p = self.__eq__(other)
7029  return Probe(Z3_probe_not(self.ctx.ref(), p.probe), self.ctx)
def __eq__
Definition: z3py.py:7003
Z3_probe Z3_API Z3_probe_not(Z3_context x, Z3_probe p)
Return a probe that evaluates to &quot;true&quot; when p does not evaluate to true.
def __ne__
Definition: z3py.py:7016

Field Documentation

ctx

Definition at line 6925 of file z3py.py.

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

probe

Definition at line 6926 of file z3py.py.

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