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

Constructor & Destructor Documentation

def __init__ (   self,
  probe,
  ctx = None 
)

Definition at line 8609 of file z3py.py.

8609  def __init__(self, probe, ctx=None):
8610  self.ctx = _get_ctx(ctx)
8611  self.probe = None
8612  if isinstance(probe, ProbeObj):
8613  self.probe = probe
8614  elif isinstance(probe, float):
8615  self.probe = Z3_probe_const(self.ctx.ref(), probe)
8616  elif _is_int(probe):
8617  self.probe = Z3_probe_const(self.ctx.ref(), float(probe))
8618  elif isinstance(probe, bool):
8619  if probe:
8620  self.probe = Z3_probe_const(self.ctx.ref(), 1.0)
8621  else:
8622  self.probe = Z3_probe_const(self.ctx.ref(), 0.0)
8623  else:
8624  if z3_debug():
8625  _z3_assert(isinstance(probe, str), "probe name expected")
8626  try:
8627  self.probe = Z3_mk_probe(self.ctx.ref(), probe)
8628  except Z3Exception:
8629  raise Z3Exception("unknown probe '%s'" % probe)
8630  Z3_probe_inc_ref(self.ctx.ref(), self.probe)
8631 
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:8609
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:62
def __del__ (   self)

Definition at line 8635 of file z3py.py.

8635  def __del__(self):
8636  if self.probe is not None and self.ctx.ref() is not None and Z3_probe_dec_ref is not None:
8637  Z3_probe_dec_ref(self.ctx.ref(), self.probe)
8638 
def __del__(self)
Definition: z3py.py:8635
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 8724 of file z3py.py.

8724  def __call__(self, goal):
8725  """Evaluate the probe `self` in the given goal.
8726 
8727  >>> p = Probe('size')
8728  >>> x = Int('x')
8729  >>> g = Goal()
8730  >>> g.add(x > 0)
8731  >>> g.add(x < 10)
8732  >>> p(g)
8733  2.0
8734  >>> g.add(x < 20)
8735  >>> p(g)
8736  3.0
8737  >>> p = Probe('num-consts')
8738  >>> p(g)
8739  1.0
8740  >>> p = Probe('is-propositional')
8741  >>> p(g)
8742  0.0
8743  >>> p = Probe('is-qflia')
8744  >>> p(g)
8745  1.0
8746  """
8747  if z3_debug():
8748  _z3_assert(isinstance(goal, (Goal, BoolRef)), "Z3 Goal or Boolean expression expected")
8749  goal = _to_goal(goal)
8750  return Z3_probe_apply(self.ctx.ref(), self.probe, goal.goal)
8751 
8752 
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:62
def __call__(self, goal)
Definition: z3py.py:8724
def __deepcopy__ (   self,
  memo = {} 
)

Definition at line 8632 of file z3py.py.

8632  def __deepcopy__(self, memo={}):
8633  return Probe(self.probe, self.ctx)
8634 
def __deepcopy__
Definition: z3py.py:8632
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 8695 of file z3py.py.

Referenced by Probe.__ne__().

8695  def __eq__(self, other):
8696  """Return a probe that evaluates to "true" when the value returned by `self`
8697  is equal to the value returned by `other`.
8698 
8699  >>> p = Probe('size') == 2
8700  >>> x = Int('x')
8701  >>> g = Goal()
8702  >>> g.add(x > 0)
8703  >>> g.add(x < 10)
8704  >>> p(g)
8705  1.0
8706  """
8707  return Probe(Z3_probe_eq(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
8708 
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:8695
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 8681 of file z3py.py.

8681  def __ge__(self, other):
8682  """Return a probe that evaluates to "true" when the value returned by `self`
8683  is greater than or equal to the value returned by `other`.
8684 
8685  >>> p = Probe('size') >= 2
8686  >>> x = Int('x')
8687  >>> g = Goal()
8688  >>> g.add(x > 0)
8689  >>> g.add(x < 10)
8690  >>> p(g)
8691  1.0
8692  """
8693  return Probe(Z3_probe_ge(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
8694 
def __ge__(self, other)
Definition: z3py.py:8681
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 8653 of file z3py.py.

8653  def __gt__(self, other):
8654  """Return a probe that evaluates to "true" when the value returned by `self`
8655  is greater than the value returned by `other`.
8656 
8657  >>> p = Probe('size') > 10
8658  >>> x = Int('x')
8659  >>> g = Goal()
8660  >>> g.add(x > 0)
8661  >>> g.add(x < 10)
8662  >>> p(g)
8663  0.0
8664  """
8665  return Probe(Z3_probe_gt(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
8666 
def __gt__(self, other)
Definition: z3py.py:8653
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 8667 of file z3py.py.

8667  def __le__(self, other):
8668  """Return a probe that evaluates to "true" when the value returned by `self`
8669  is less than or equal to the value returned by `other`.
8670 
8671  >>> p = Probe('size') <= 2
8672  >>> x = Int('x')
8673  >>> g = Goal()
8674  >>> g.add(x > 0)
8675  >>> g.add(x < 10)
8676  >>> p(g)
8677  1.0
8678  """
8679  return Probe(Z3_probe_le(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
8680 
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:8667
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 8639 of file z3py.py.

8639  def __lt__(self, other):
8640  """Return a probe that evaluates to "true" when the value returned by `self`
8641  is less than the value returned by `other`.
8642 
8643  >>> p = Probe('size') < 10
8644  >>> x = Int('x')
8645  >>> g = Goal()
8646  >>> g.add(x > 0)
8647  >>> g.add(x < 10)
8648  >>> p(g)
8649  1.0
8650  """
8651  return Probe(Z3_probe_lt(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
8652 
def __lt__(self, other)
Definition: z3py.py:8639
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 8709 of file z3py.py.

8709  def __ne__(self, other):
8710  """Return a probe that evaluates to "true" when the value returned by `self`
8711  is not equal to the value returned by `other`.
8712 
8713  >>> p = Probe('size') != 2
8714  >>> x = Int('x')
8715  >>> g = Goal()
8716  >>> g.add(x > 0)
8717  >>> g.add(x < 10)
8718  >>> p(g)
8719  0.0
8720  """
8721  p = self.__eq__(other)
8722  return Probe(Z3_probe_not(self.ctx.ref(), p.probe), self.ctx)
8723 
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:8709
def __eq__(self, other)
Definition: z3py.py:8695

Field Documentation

ctx
probe