Z3
Public Member Functions | Data Fields
Probe Class Reference

Public Member Functions

def __init__ (self, probe, ctx=None)
 
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 6922 of file z3py.py.

Constructor & Destructor Documentation

def __init__ (   self,
  probe,
  ctx = None 
)

Definition at line 6924 of file z3py.py.

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

Definition at line 6947 of file z3py.py.

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

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

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

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

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

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

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

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

Field Documentation

ctx
probe