Z3
Public Member Functions | Data Fields
Probe Class Reference

Public Member Functions

def __init__ (self, probe, ctx=None)
 
def __deepcopy__ (self, memo={})
 
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 7925 of file z3py.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  probe,
  ctx = None 
)

Definition at line 7927 of file z3py.py.

7927  def __init__(self, probe, ctx=None):
7928  self.ctx = _get_ctx(ctx)
7929  self.probe = None
7930  if isinstance(probe, ProbeObj):
7931  self.probe = probe
7932  elif isinstance(probe, float):
7933  self.probe = Z3_probe_const(self.ctx.ref(), probe)
7934  elif _is_int(probe):
7935  self.probe = Z3_probe_const(self.ctx.ref(), float(probe))
7936  elif isinstance(probe, bool):
7937  if probe:
7938  self.probe = Z3_probe_const(self.ctx.ref(), 1.0)
7939  else:
7940  self.probe = Z3_probe_const(self.ctx.ref(), 0.0)
7941  else:
7942  if z3_debug():
7943  _z3_assert(isinstance(probe, str), "probe name expected")
7944  try:
7945  self.probe = Z3_mk_probe(self.ctx.ref(), probe)
7946  except Z3Exception:
7947  raise Z3Exception("unknown probe '%s'" % probe)
7948  Z3_probe_inc_ref(self.ctx.ref(), self.probe)
7949 
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 z3_debug()
Definition: z3py.py:58

◆ __del__()

def __del__ (   self)

Definition at line 7953 of file z3py.py.

7953  def __del__(self):
7954  if self.probe is not None and self.ctx.ref() is not None:
7955  Z3_probe_dec_ref(self.ctx.ref(), self.probe)
7956 
void Z3_API Z3_probe_dec_ref(Z3_context c, Z3_probe p)
Decrement the reference counter of the given probe.

Member Function Documentation

◆ __call__()

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

8036  def __call__(self, goal):
8037  """Evaluate the probe `self` in the given goal.
8038 
8039  >>> p = Probe('size')
8040  >>> x = Int('x')
8041  >>> g = Goal()
8042  >>> g.add(x > 0)
8043  >>> g.add(x < 10)
8044  >>> p(g)
8045  2.0
8046  >>> g.add(x < 20)
8047  >>> p(g)
8048  3.0
8049  >>> p = Probe('num-consts')
8050  >>> p(g)
8051  1.0
8052  >>> p = Probe('is-propositional')
8053  >>> p(g)
8054  0.0
8055  >>> p = Probe('is-qflia')
8056  >>> p(g)
8057  1.0
8058  """
8059  if z3_debug():
8060  _z3_assert(isinstance(goal, Goal) or isinstance(goal, BoolRef), "Z3 Goal or Boolean expression expected")
8061  goal = _to_goal(goal)
8062  return Z3_probe_apply(self.ctx.ref(), self.probe, goal.goal)
8063 
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

◆ __deepcopy__()

def __deepcopy__ (   self,
  memo = {} 
)

Definition at line 7950 of file z3py.py.

7950  def __deepcopy__(self, memo={}):
7951  return Probe(self.probe, self.ctx)
7952 

◆ __eq__()

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

8009  def __eq__(self, other):
8010  """Return a probe that evaluates to "true" when the value returned by `self` is equal to the value returned by `other`.
8011 
8012  >>> p = Probe('size') == 2
8013  >>> x = Int('x')
8014  >>> g = Goal()
8015  >>> g.add(x > 0)
8016  >>> g.add(x < 10)
8017  >>> p(g)
8018  1.0
8019  """
8020  return Probe(Z3_probe_eq(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
8021 
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 ...

Referenced by Probe.__ne__().

◆ __ge__()

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

7996  def __ge__(self, other):
7997  """Return a probe that evaluates to "true" when the value returned by `self` is greater than or equal to the value returned by `other`.
7998 
7999  >>> p = Probe('size') >= 2
8000  >>> x = Int('x')
8001  >>> g = Goal()
8002  >>> g.add(x > 0)
8003  >>> g.add(x < 10)
8004  >>> p(g)
8005  1.0
8006  """
8007  return Probe(Z3_probe_ge(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
8008 
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...

◆ __gt__()

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

7970  def __gt__(self, other):
7971  """Return a probe that evaluates to "true" when the value returned by `self` is greater than the value returned by `other`.
7972 
7973  >>> p = Probe('size') > 10
7974  >>> x = Int('x')
7975  >>> g = Goal()
7976  >>> g.add(x > 0)
7977  >>> g.add(x < 10)
7978  >>> p(g)
7979  0.0
7980  """
7981  return Probe(Z3_probe_gt(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
7982 
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...

◆ __le__()

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

7983  def __le__(self, other):
7984  """Return a probe that evaluates to "true" when the value returned by `self` is less than or equal to the value returned by `other`.
7985 
7986  >>> p = Probe('size') <= 2
7987  >>> x = Int('x')
7988  >>> g = Goal()
7989  >>> g.add(x > 0)
7990  >>> g.add(x < 10)
7991  >>> p(g)
7992  1.0
7993  """
7994  return Probe(Z3_probe_le(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
7995 
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...

◆ __lt__()

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

7957  def __lt__(self, other):
7958  """Return a probe that evaluates to "true" when the value returned by `self` is less than the value returned by `other`.
7959 
7960  >>> p = Probe('size') < 10
7961  >>> x = Int('x')
7962  >>> g = Goal()
7963  >>> g.add(x > 0)
7964  >>> g.add(x < 10)
7965  >>> p(g)
7966  1.0
7967  """
7968  return Probe(Z3_probe_lt(self.ctx.ref(), self.probe, _to_probe(other, self.ctx).probe), self.ctx)
7969 
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...

◆ __ne__()

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

8022  def __ne__(self, other):
8023  """Return a probe that evaluates to "true" when the value returned by `self` is not equal to the value returned by `other`.
8024 
8025  >>> p = Probe('size') != 2
8026  >>> x = Int('x')
8027  >>> g = Goal()
8028  >>> g.add(x > 0)
8029  >>> g.add(x < 10)
8030  >>> p(g)
8031  0.0
8032  """
8033  p = self.__eq__(other)
8034  return Probe(Z3_probe_not(self.ctx.ref(), p.probe), self.ctx)
8035 
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.

Field Documentation

◆ ctx

ctx

◆ probe

probe