Z3
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Data Fields
Probe Class Reference

Public Member Functions

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

Constructor & Destructor Documentation

def __init__ (   self,
  probe,
  ctx = None 
)

Definition at line 7892 of file z3py.py.

7893  def __init__(self, probe, ctx=None):
7894  self.ctx = _get_ctx(ctx)
7895  self.probe = None
7896  if isinstance(probe, ProbeObj):
7897  self.probe = probe
7898  elif isinstance(probe, float):
7899  self.probe = Z3_probe_const(self.ctx.ref(), probe)
7900  elif _is_int(probe):
7901  self.probe = Z3_probe_const(self.ctx.ref(), float(probe))
7902  elif isinstance(probe, bool):
7903  if probe:
7904  self.probe = Z3_probe_const(self.ctx.ref(), 1.0)
7905  else:
7906  self.probe = Z3_probe_const(self.ctx.ref(), 0.0)
7907  else:
7908  if z3_debug():
7909  _z3_assert(isinstance(probe, str), "probe name expected")
7910  try:
7911  self.probe = Z3_mk_probe(self.ctx.ref(), probe)
7912  except Z3Exception:
7913  raise Z3Exception("unknown probe '%s'" % probe)
7914  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:7892
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:58
def __del__ (   self)

Definition at line 7918 of file z3py.py.

7919  def __del__(self):
7920  if self.probe is not None and self.ctx.ref() is not None:
7921  Z3_probe_dec_ref(self.ctx.ref(), self.probe)
def __del__
Definition: z3py.py:7918
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 8001 of file z3py.py.

8002  def __call__(self, goal):
8003  """Evaluate the probe `self` in the given goal.
8004 
8005  >>> p = Probe('size')
8006  >>> x = Int('x')
8007  >>> g = Goal()
8008  >>> g.add(x > 0)
8009  >>> g.add(x < 10)
8010  >>> p(g)
8011  2.0
8012  >>> g.add(x < 20)
8013  >>> p(g)
8014  3.0
8015  >>> p = Probe('num-consts')
8016  >>> p(g)
8017  1.0
8018  >>> p = Probe('is-propositional')
8019  >>> p(g)
8020  0.0
8021  >>> p = Probe('is-qflia')
8022  >>> p(g)
8023  1.0
8024  """
8025  if z3_debug():
8026  _z3_assert(isinstance(goal, Goal) or isinstance(goal, BoolRef), "Z3 Goal or Boolean expression expected")
8027  goal = _to_goal(goal)
8028  return Z3_probe_apply(self.ctx.ref(), self.probe, goal.goal)
def __call__
Definition: z3py.py:8001
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:58
def __deepcopy__ (   self,
  memo = {} 
)

Definition at line 7915 of file z3py.py.

7916  def __deepcopy__(self, memo={}):
7917  return Probe(self.probe, self.ctx)
def __deepcopy__
Definition: z3py.py:7915
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 7974 of file z3py.py.

Referenced by Probe.__ne__().

7975  def __eq__(self, other):
7976  """Return a probe that evaluates to "true" when the value returned by `self` is equal to the value returned by `other`.
7977 
7978  >>> p = Probe('size') == 2
7979  >>> x = Int('x')
7980  >>> g = Goal()
7981  >>> g.add(x > 0)
7982  >>> g.add(x < 10)
7983  >>> p(g)
7984  1.0
7985  """
7986  return Probe(Z3_probe_eq(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
def __eq__
Definition: z3py.py:7974
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 __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 7961 of file z3py.py.

7962  def __ge__(self, other):
7963  """Return a probe that evaluates to "true" when the value returned by `self` is greater than or equal to the value returned by `other`.
7964 
7965  >>> p = Probe('size') >= 2
7966  >>> x = Int('x')
7967  >>> g = Goal()
7968  >>> g.add(x > 0)
7969  >>> g.add(x < 10)
7970  >>> p(g)
7971  1.0
7972  """
7973  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 "true" when the value returned by p1 is greater than or equal to the...
def __ge__
Definition: z3py.py:7961
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 7935 of file z3py.py.

7936  def __gt__(self, other):
7937  """Return a probe that evaluates to "true" when the value returned by `self` is greater than the value returned by `other`.
7938 
7939  >>> p = Probe('size') > 10
7940  >>> x = Int('x')
7941  >>> g = Goal()
7942  >>> g.add(x > 0)
7943  >>> g.add(x < 10)
7944  >>> p(g)
7945  0.0
7946  """
7947  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 "true" when the value returned by p1 is greater than the value retur...
def __gt__
Definition: z3py.py:7935
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 7948 of file z3py.py.

7949  def __le__(self, other):
7950  """Return a probe that evaluates to "true" when the value returned by `self` is less than or equal to the value returned by `other`.
7951 
7952  >>> p = Probe('size') <= 2
7953  >>> x = Int('x')
7954  >>> g = Goal()
7955  >>> g.add(x > 0)
7956  >>> g.add(x < 10)
7957  >>> p(g)
7958  1.0
7959  """
7960  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 "true" when the value returned by p1 is less than or equal to the va...
def __le__
Definition: z3py.py:7948
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 7922 of file z3py.py.

7923  def __lt__(self, other):
7924  """Return a probe that evaluates to "true" when the value returned by `self` is less than the value returned by `other`.
7925 
7926  >>> p = Probe('size') < 10
7927  >>> x = Int('x')
7928  >>> g = Goal()
7929  >>> g.add(x > 0)
7930  >>> g.add(x < 10)
7931  >>> p(g)
7932  1.0
7933  """
7934  return Probe(Z3_probe_lt(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
def __lt__
Definition: z3py.py:7922
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 7987 of file z3py.py.

7988  def __ne__(self, other):
7989  """Return a probe that evaluates to "true" when the value returned by `self` is not equal to the value returned by `other`.
7990 
7991  >>> p = Probe('size') != 2
7992  >>> x = Int('x')
7993  >>> g = Goal()
7994  >>> g.add(x > 0)
7995  >>> g.add(x < 10)
7996  >>> p(g)
7997  0.0
7998  """
7999  p = self.__eq__(other)
8000  return Probe(Z3_probe_not(self.ctx.ref(), p.probe), self.ctx)
def __eq__
Definition: z3py.py:7974
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__
Definition: z3py.py:7987

Field Documentation

ctx

Definition at line 7893 of file z3py.py.

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

probe

Definition at line 7894 of file z3py.py.

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