Z3
 
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
Tactic Class Reference

Public Member Functions

 __init__ (self, tactic, ctx=None)
 
 __deepcopy__ (self, memo={})
 
 __del__ (self)
 
 solver (self, logFile=None)
 
 apply (self, goal, *arguments, **keywords)
 
 __call__ (self, goal, *arguments, **keywords)
 
 help (self)
 
 param_descrs (self)
 

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

Constructor & Destructor Documentation

◆ __init__()

__init__ (   self,
  tactic,
  ctx = None 
)

Definition at line 8522 of file z3py.py.

8522 def __init__(self, tactic, ctx=None):
8523 self.ctx = _get_ctx(ctx)
8524 self.tactic = None
8525 if isinstance(tactic, TacticObj):
8526 self.tactic = tactic
8527 else:
8528 if z3_debug():
8529 _z3_assert(isinstance(tactic, str), "tactic name expected")
8530 try:
8531 self.tactic = Z3_mk_tactic(self.ctx.ref(), str(tactic))
8532 except Z3Exception:
8533 raise Z3Exception("unknown tactic '%s'" % tactic)
8534 Z3_tactic_inc_ref(self.ctx.ref(), self.tactic)
8535
Z3_tactic Z3_API Z3_mk_tactic(Z3_context c, Z3_string name)
Return a tactic associated with the given name. The complete list of tactics may be obtained using th...
void Z3_API Z3_tactic_inc_ref(Z3_context c, Z3_tactic t)
Increment the reference counter of the given tactic.

◆ __del__()

__del__ (   self)

Definition at line 8539 of file z3py.py.

8539 def __del__(self):
8540 if self.tactic is not None and self.ctx.ref() is not None and Z3_tactic_dec_ref is not None:
8541 Z3_tactic_dec_ref(self.ctx.ref(), self.tactic)
8542
void Z3_API Z3_tactic_dec_ref(Z3_context c, Z3_tactic g)
Decrement the reference counter of the given tactic.

Member Function Documentation

◆ __call__()

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

8577 def __call__(self, goal, *arguments, **keywords):
8578 """Apply tactic `self` to the given goal or Z3 Boolean expression using the given options.
8579
8580 >>> x, y = Ints('x y')
8581 >>> t = Tactic('solve-eqs')
8582 >>> t(And(x == 0, y >= x + 1))
8583 [[y >= 1]]
8584 """
8585 return self.apply(goal, *arguments, **keywords)
8586

◆ __deepcopy__()

__deepcopy__ (   self,
  memo = {} 
)

Definition at line 8536 of file z3py.py.

8536 def __deepcopy__(self, memo={}):
8537 return Tactic(self.tactic, self.ctx)
8538

◆ apply()

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

8560 def apply(self, goal, *arguments, **keywords):
8561 """Apply tactic `self` to the given goal or Z3 Boolean expression using the given options.
8562
8563 >>> x, y = Ints('x y')
8564 >>> t = Tactic('solve-eqs')
8565 >>> t.apply(And(x == 0, y >= x + 1))
8566 [[y >= 1]]
8567 """
8568 if z3_debug():
8569 _z3_assert(isinstance(goal, (Goal, BoolRef)), "Z3 Goal or Boolean expressions expected")
8570 goal = _to_goal(goal)
8571 if len(arguments) > 0 or len(keywords) > 0:
8572 p = args2params(arguments, keywords, self.ctx)
8573 return ApplyResult(Z3_tactic_apply_ex(self.ctx.ref(), self.tactic, goal.goal, p.params), self.ctx)
8574 else:
8575 return ApplyResult(Z3_tactic_apply(self.ctx.ref(), self.tactic, goal.goal), self.ctx)
8576
Z3_apply_result Z3_API Z3_tactic_apply_ex(Z3_context c, Z3_tactic t, Z3_goal g, Z3_params p)
Apply tactic t to the goal g using the parameter set p.
Z3_apply_result Z3_API Z3_tactic_apply(Z3_context c, Z3_tactic t, Z3_goal g)
Apply tactic t to the goal g.

◆ help()

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

Definition at line 8587 of file z3py.py.

8587 def help(self):
8588 """Display a string containing a description of the available options for the `self` tactic."""
8589 print(Z3_tactic_get_help(self.ctx.ref(), self.tactic))
8590
Z3_string Z3_API Z3_tactic_get_help(Z3_context c, Z3_tactic t)
Return a string containing a description of parameters accepted by the given tactic.

◆ param_descrs()

param_descrs (   self)
Return the parameter description set.

Definition at line 8591 of file z3py.py.

8591 def param_descrs(self):
8592 """Return the parameter description set."""
8593 return ParamDescrsRef(Z3_tactic_get_param_descrs(self.ctx.ref(), self.tactic), self.ctx)
8594
8595
Z3_param_descrs Z3_API Z3_tactic_get_param_descrs(Z3_context c, Z3_tactic t)
Return the parameter description set for the given tactic object.

◆ solver()

solver (   self,
  logFile = None 
)
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 8543 of file z3py.py.

8543 def solver(self, logFile=None):
8544 """Create a solver using the tactic `self`.
8545
8546 The solver supports the methods `push()` and `pop()`, but it
8547 will always solve each `check()` from scratch.
8548
8549 >>> t = Then('simplify', 'nlsat')
8550 >>> s = t.solver()
8551 >>> x = Real('x')
8552 >>> s.add(x**2 == 2, x > 0)
8553 >>> s.check()
8554 sat
8555 >>> s.model()
8556 [x = 1.4142135623?]
8557 """
8558 return Solver(Z3_mk_solver_from_tactic(self.ctx.ref(), self.tactic), self.ctx, logFile)
8559
Z3_solver Z3_API Z3_mk_solver_from_tactic(Z3_context c, Z3_tactic t)
Create a new solver that is implemented using the given tactic. The solver supports the commands Z3_s...

Referenced by Solver.__del__(), Solver.assert_and_track(), Solver.assert_exprs(), Solver.check(), Solver.model(), Solver.num_scopes(), Solver.pop(), Solver.push(), Solver.reset(), and Solver.set().

Field Documentation

◆ ctx

ctx

Definition at line 8523 of file z3py.py.

Referenced by ArithRef.__add__(), BitVecRef.__add__(), BitVecRef.__and__(), FuncDeclRef.__call__(), AstMap.__contains__(), AstRef.__copy__(), Goal.__copy__(), AstVector.__copy__(), FuncInterp.__copy__(), ModelRef.__copy__(), AstRef.__deepcopy__(), Datatype.__deepcopy__(), ParamsRef.__deepcopy__(), ParamDescrsRef.__deepcopy__(), Goal.__deepcopy__(), AstVector.__deepcopy__(), AstMap.__deepcopy__(), FuncEntry.__deepcopy__(), FuncInterp.__deepcopy__(), ModelRef.__deepcopy__(), Statistics.__deepcopy__(), Context.__del__(), AstRef.__del__(), ScopedConstructor.__del__(), ScopedConstructorList.__del__(), ParamsRef.__del__(), ParamDescrsRef.__del__(), Goal.__del__(), AstVector.__del__(), AstMap.__del__(), FuncEntry.__del__(), FuncInterp.__del__(), ModelRef.__del__(), Statistics.__del__(), Solver.__del__(), ArithRef.__div__(), BitVecRef.__div__(), ExprRef.__eq__(), ArithRef.__ge__(), BitVecRef.__ge__(), AstVector.__getitem__(), ModelRef.__getitem__(), Statistics.__getitem__(), AstMap.__getitem__(), ArithRef.__gt__(), BitVecRef.__gt__(), BitVecRef.__invert__(), ArithRef.__le__(), BitVecRef.__le__(), AstVector.__len__(), AstMap.__len__(), ModelRef.__len__(), Statistics.__len__(), BitVecRef.__lshift__(), ArithRef.__lt__(), BitVecRef.__lt__(), ArithRef.__mod__(), BitVecRef.__mod__(), BoolRef.__mul__(), ArithRef.__mul__(), BitVecRef.__mul__(), ExprRef.__ne__(), ArithRef.__neg__(), BitVecRef.__neg__(), BitVecRef.__or__(), ArithRef.__pow__(), ArithRef.__radd__(), BitVecRef.__radd__(), BitVecRef.__rand__(), ArithRef.__rdiv__(), BitVecRef.__rdiv__(), ParamsRef.__repr__(), ParamDescrsRef.__repr__(), AstMap.__repr__(), Statistics.__repr__(), BitVecRef.__rlshift__(), ArithRef.__rmod__(), BitVecRef.__rmod__(), ArithRef.__rmul__(), BitVecRef.__rmul__(), BitVecRef.__ror__(), ArithRef.__rpow__(), BitVecRef.__rrshift__(), BitVecRef.__rshift__(), ArithRef.__rsub__(), BitVecRef.__rsub__(), BitVecRef.__rxor__(), AstVector.__setitem__(), AstMap.__setitem__(), ArithRef.__sub__(), BitVecRef.__sub__(), BitVecRef.__xor__(), DatatypeSortRef.accessor(), ExprRef.arg(), FuncEntry.arg_value(), FuncInterp.arity(), Goal.as_expr(), Solver.assert_and_track(), Goal.assert_exprs(), Solver.assert_exprs(), QuantifierRef.body(), Solver.check(), Goal.convert_model(), AstRef.ctx_ref(), ExprRef.decl(), ModelRef.decls(), ArrayRef.default(), RatNumRef.denominator(), Goal.depth(), Goal.dimacs(), FuncDeclRef.domain(), ArraySortRef.domain_n(), FuncInterp.else_value(), FuncInterp.entry(), AstMap.erase(), ModelRef.eval(), Goal.get(), ParamDescrsRef.get_documentation(), ModelRef.get_interp(), Statistics.get_key_value(), ParamDescrsRef.get_kind(), ParamDescrsRef.get_name(), ModelRef.get_sort(), ModelRef.get_universe(), Goal.inconsistent(), AstMap.keys(), Statistics.keys(), Solver.model(), SortRef.name(), QuantifierRef.no_pattern(), FuncEntry.num_args(), FuncInterp.num_entries(), Solver.num_scopes(), ModelRef.num_sorts(), FuncDeclRef.params(), QuantifierRef.pattern(), AlgebraicNumRef.poly(), Solver.pop(), Goal.prec(), ModelRef.project(), ModelRef.project_with_witness(), Solver.push(), AstVector.push(), QuantifierRef.qid(), FuncDeclRef.range(), ArraySortRef.range(), DatatypeSortRef.recognizer(), Context.ref(), AstMap.reset(), Solver.reset(), AstVector.resize(), Solver.set(), ParamsRef.set(), Goal.sexpr(), AstVector.sexpr(), ModelRef.sexpr(), ParamDescrsRef.size(), Goal.size(), QuantifierRef.skolem_id(), AstVector.translate(), AstRef.translate(), Goal.translate(), ModelRef.translate(), ExprRef.update(), ParamsRef.validate(), FuncEntry.value(), QuantifierRef.var_name(), and QuantifierRef.var_sort().

◆ tactic

tactic

Definition at line 8524 of file z3py.py.