Z3
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions | Data Fields
Tactic Class Reference

Public Member Functions

def __init__
def __del__
def solver
def apply
def __call__
def help
def param_descrs

Data Fields

 ctx
 tactic

Detailed Description

Tactics transform, solver and/or simplify sets of constraints (Goal). A Tactic can be converted into a Solver using the method solver().

Several combinators are available for creating new tactics using the built-in ones: Then(), OrElse(), FailIf(), Repeat(), When(), Cond().

Definition at line 6656 of file z3py.py.


Constructor & Destructor Documentation

def __init__ (   self,
  tactic,
  ctx = None 
)

Definition at line 6661 of file z3py.py.

06661 
06662     def __init__(self, tactic, ctx=None):
06663         self.ctx    = _get_ctx(ctx)
06664         self.tactic = None
06665         if isinstance(tactic, TacticObj):
06666             self.tactic = tactic
06667         else:
06668             if __debug__:
06669                 _z3_assert(isinstance(tactic, str), "tactic name expected")
06670             try:
06671                 self.tactic = Z3_mk_tactic(self.ctx.ref(), str(tactic))
06672             except Z3Exception:
06673                 raise Z3Exception("unknown tactic '%s'" % tactic)
06674         Z3_tactic_inc_ref(self.ctx.ref(), self.tactic)

def __del__ (   self)

Definition at line 6675 of file z3py.py.

06675 
06676     def __del__(self):
06677         if self.tactic != None:
06678             Z3_tactic_dec_ref(self.ctx.ref(), self.tactic)


Member Function Documentation

def __call__ (   self,
  goal,
  arguments,
  keywords 
)
Apply tactic `self` to the given goal or Z3 Boolean expression using the given options.

>>> x, y = Ints('x y')
>>> t = Tactic('solve-eqs')
>>> t(And(x == 0, y >= x + 1))
[[y >= 1]]

Definition at line 6713 of file z3py.py.

06713 
06714     def __call__(self, goal, *arguments, **keywords):
06715         """Apply tactic `self` to the given goal or Z3 Boolean expression using the given options.
06716         
06717         >>> x, y = Ints('x y')
06718         >>> t = Tactic('solve-eqs')
06719         >>> t(And(x == 0, y >= x + 1))
06720         [[y >= 1]]
06721         """
06722         return self.apply(goal, *arguments, **keywords)

def apply (   self,
  goal,
  arguments,
  keywords 
)
Apply tactic `self` to the given goal or Z3 Boolean expression using the given options.

>>> x, y = Ints('x y')
>>> t = Tactic('solve-eqs')
>>> t.apply(And(x == 0, y >= x + 1))
[[y >= 1]]

Definition at line 6696 of file z3py.py.

Referenced by Tactic.__call__().

06696 
06697     def apply(self, goal, *arguments, **keywords):
06698         """Apply tactic `self` to the given goal or Z3 Boolean expression using the given options.
06699         
06700         >>> x, y = Ints('x y')
06701         >>> t = Tactic('solve-eqs')
06702         >>> t.apply(And(x == 0, y >= x + 1))
06703         [[y >= 1]]
06704         """
06705         if __debug__:
06706             _z3_assert(isinstance(goal, Goal) or isinstance(goal, BoolRef), "Z3 Goal or Boolean expressions expected")
06707         goal = _to_goal(goal)
06708         if len(arguments) > 0 or len(keywords) > 0:
06709             p = args2params(arguments, keywords, self.ctx)
06710             return ApplyResult(Z3_tactic_apply_ex(self.ctx.ref(), self.tactic, goal.goal, p.params), self.ctx)
06711         else:
06712             return ApplyResult(Z3_tactic_apply(self.ctx.ref(), self.tactic, goal.goal), self.ctx)

def help (   self)
Display a string containing a description of the available options for the `self` tactic.

Definition at line 6723 of file z3py.py.

06723 
06724     def help(self):
06725         """Display a string containing a description of the available options for the `self` tactic."""
06726         print(Z3_tactic_get_help(self.ctx.ref(), self.tactic))

def param_descrs (   self)
Return the parameter description set.

Definition at line 6727 of file z3py.py.

06727 
06728     def param_descrs(self):
06729         """Return the parameter description set."""
06730         return ParamDescrsRef(Z3_tactic_get_param_descrs(self.ctx.ref(), self.tactic), self.ctx)

def solver (   self)
Create a solver using the tactic `self`.

The solver supports the methods `push()` and `pop()`, but it
will always solve each `check()` from scratch.

>>> t = Then('simplify', 'nlsat')
>>> s = t.solver()
>>> x = Real('x')
>>> s.add(x**2 == 2, x > 0)
>>> s.check()
sat
>>> s.model()
[x = 1.4142135623?]

Definition at line 6679 of file z3py.py.

06679 
06680     def solver(self):
06681         """Create a solver using the tactic `self`.
06682 
06683         The solver supports the methods `push()` and `pop()`, but it
06684         will always solve each `check()` from scratch.
06685         
06686         >>> t = Then('simplify', 'nlsat')
06687         >>> s = t.solver()
06688         >>> x = Real('x')
06689         >>> s.add(x**2 == 2, x > 0)
06690         >>> s.check()
06691         sat
06692         >>> s.model()
06693         [x = 1.4142135623?]
06694         """
06695         return Solver(Z3_mk_solver_from_tactic(self.ctx.ref(), self.tactic), self.ctx)


Field Documentation

ctx

Definition at line 6661 of file z3py.py.

Referenced by ArithRef::__add__(), BitVecRef::__add__(), BitVecRef::__and__(), FuncDeclRef::__call__(), ArithRef::__div__(), BitVecRef::__div__(), ExprRef::__eq__(), Probe::__eq__(), ArithRef::__ge__(), BitVecRef::__ge__(), Probe::__ge__(), ArrayRef::__getitem__(), ArithRef::__gt__(), BitVecRef::__gt__(), Probe::__gt__(), BitVecRef::__invert__(), ArithRef::__le__(), BitVecRef::__le__(), Probe::__le__(), BitVecRef::__lshift__(), ArithRef::__lt__(), BitVecRef::__lt__(), Probe::__lt__(), ArithRef::__mod__(), BitVecRef::__mod__(), ArithRef::__mul__(), BitVecRef::__mul__(), ExprRef::__ne__(), Probe::__ne__(), ArithRef::__neg__(), BitVecRef::__neg__(), BitVecRef::__or__(), ArithRef::__pow__(), ArithRef::__radd__(), BitVecRef::__radd__(), BitVecRef::__rand__(), ArithRef::__rdiv__(), BitVecRef::__rdiv__(), BitVecRef::__rlshift__(), ArithRef::__rmod__(), BitVecRef::__rmod__(), ArithRef::__rmul__(), BitVecRef::__rmul__(), BitVecRef::__ror__(), ArithRef::__rpow__(), BitVecRef::__rrshift__(), BitVecRef::__rshift__(), ArithRef::__rsub__(), BitVecRef::__rsub__(), BitVecRef::__rxor__(), ArithRef::__sub__(), BitVecRef::__sub__(), BitVecRef::__xor__(), DatatypeSortRef::accessor(), Tactic::apply(), AlgebraicNumRef::approx(), ExprRef::arg(), QuantifierRef::body(), BoolSortRef::cast(), DatatypeSortRef::constructor(), ExprRef::decl(), RatNumRef::denominator(), FuncDeclRef::domain(), ArraySortRef::domain(), SortRef::kind(), ArrayRef::mk_default(), SortRef::name(), FuncDeclRef::name(), QuantifierRef::no_pattern(), RatNumRef::numerator(), Tactic::param_descrs(), QuantifierRef::pattern(), FuncDeclRef::range(), ArraySortRef::range(), DatatypeSortRef::recognizer(), Tactic::solver(), ExprRef::sort(), BoolRef::sort(), QuantifierRef::sort(), ArithRef::sort(), BitVecRef::sort(), ArrayRef::sort(), DatatypeRef::sort(), QuantifierRef::var_name(), and QuantifierRef::var_sort().

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines