tactic.go

Tactics, Goals, Probes, and Parameters for goal-based solving

Types

type ApplyResult

ApplyResult represents the result of applying a tactic to a goal.

Methods:

NumSubgoals

func (ar *ApplyResult) NumSubgoals() uint

NumSubgoals returns the number of subgoals in the result.

String

func (ar *ApplyResult) String() string

String returns the string representation of the apply result.

Subgoal

func (ar *ApplyResult) Subgoal(i uint) *Goal

Subgoal returns the i-th subgoal.

type Context

Context methods (receiver omitted for clarity)

Methods:

GetProbeDescr

func (c *Context) GetProbeDescr(name string) string

GetProbeDescr returns a description of the probe with the given name.

GetTacticDescr

func (c *Context) GetTacticDescr(name string) string

GetTacticDescr returns a description of the tactic with the given name.

MkGoal

func (c *Context) MkGoal(models, unsatCores, proofs bool) *Goal

MkGoal creates a new goal.

MkParams

func (c *Context) MkParams() *Params

MkParams creates a new parameter set.

MkProbe

func (c *Context) MkProbe(name string) *Probe

MkProbe creates a probe with the given name.

MkTactic

func (c *Context) MkTactic(name string) *Tactic

MkTactic creates a tactic with the given name.

NewSolverFromTactic

func (c *Context) NewSolverFromTactic(t *Tactic) *Solver

NewSolverFromTactic creates a solver from the given tactic. The solver uses the tactic to solve goals.

ParOr

func (c *Context) ParOr(tactics []*Tactic) *Tactic

ParOr creates a tactic that applies the given tactics in parallel.

ProbeConst

func (c *Context) ProbeConst(val float64) *Probe

ProbeConst creates a probe that always evaluates to the given value.

TacticCond

func (c *Context) TacticCond(p *Probe, t1, t2 *Tactic) *Tactic

TacticCond creates a conditional tactic: if p then t1 else t2.

TacticFail

func (c *Context) TacticFail() *Tactic

TacticFail creates a tactic that always fails.

TacticFailIf

func (c *Context) TacticFailIf(p *Probe) *Tactic

TacticFailIf creates a tactic that fails if the probe p evaluates to false.

TacticFailIfNotDecided

func (c *Context) TacticFailIfNotDecided() *Tactic

TacticFailIfNotDecided creates a tactic that fails if the goal is not trivially satisfiable (empty) or trivially unsatisfiable (contains false).

TacticSkip

func (c *Context) TacticSkip() *Tactic

TacticSkip creates a tactic that always succeeds.

TacticWhen

func (c *Context) TacticWhen(p *Probe, t *Tactic) *Tactic

When creates a conditional tactic that applies t only if probe p evaluates to true.

type Goal

Goal represents a set of formulas that can be solved or transformed.

Methods:

Assert

func (g *Goal) Assert(constraint *Expr)

Assert adds a constraint to the goal.

ConvertModel

func (g *Goal) ConvertModel(m *Model) *Model

ConvertModel converts a model from the original goal into a model for this goal. Use this when a tactic has transformed the goal and you need a model for the original.

Depth

func (g *Goal) Depth() uint

Depth returns the depth of the goal. It tracks how many times the goal was transformed by a tactic.

Formula

func (g *Goal) Formula(i uint) *Expr

Formula returns the i-th formula in the goal.

IsDecidedSat

func (g *Goal) IsDecidedSat() bool

IsDecidedSat returns true if the goal is decided to be satisfiable.

IsDecidedUnsat

func (g *Goal) IsDecidedUnsat() bool

IsDecidedUnsat returns true if the goal is decided to be unsatisfiable.

IsInconsistent

func (g *Goal) IsInconsistent() bool

IsInconsistent returns true if the goal contains the formula false.

NumExprs

func (g *Goal) NumExprs() uint

NumExprs returns the number of expressions in the goal.

Precision

func (g *Goal) Precision() uint

Precision returns the precision of the goal as a uint. Possible values: 0 = precise, 1 = under-approximation, 2 = over-approximation, 3 = under+over.

Reset

func (g *Goal) Reset()

Reset removes all formulas from the goal.

Size

func (g *Goal) Size() uint

Size returns the number of formulas in the goal.

String

func (g *Goal) String() string

String returns the string representation of the goal.

ToDimacsString

func (g *Goal) ToDimacsString(includeNames bool) string

ToDimacsString converts the goal to a string in DIMACS format. If includeNames is true, formula names are included as comments.

Translate

func (g *Goal) Translate(target *Context) *Goal

Translate creates a copy of the goal in the target context.

type Params

Params represents a parameter set.

Methods:

SetBool

func (p *Params) SetBool(key string, value bool)

SetBool sets a Boolean parameter.

SetDouble

func (p *Params) SetDouble(key string, value float64)

SetDouble sets a double parameter.

SetSymbol

func (p *Params) SetSymbol(key string, value *Symbol)

SetSymbol sets a symbol parameter.

SetUint

func (p *Params) SetUint(key string, value uint)

SetUint sets an unsigned integer parameter.

String

func (p *Params) String() string

String returns the string representation of the parameters.

type Probe

Probe represents a probe for checking properties of goals.

Methods:

And

func (p *Probe) And(p2 *Probe) *Probe

ProbeAnd creates a probe that is the conjunction of p1 and p2.

Apply

func (p *Probe) Apply(g *Goal) float64

Apply evaluates the probe on a goal.

Eq

func (p *Probe) Eq(p2 *Probe) *Probe

ProbeEq creates a probe that evaluates to true if p1 == p2.

Ge

func (p *Probe) Ge(p2 *Probe) *Probe

ProbeGe creates a probe that evaluates to true if p1 >= p2.

Gt

func (p *Probe) Gt(p2 *Probe) *Probe

ProbeGt creates a probe that evaluates to true if p1 > p2.

Le

func (p *Probe) Le(p2 *Probe) *Probe

ProbeLe creates a probe that evaluates to true if p1 <= p2.

Lt

func (p *Probe) Lt(p2 *Probe) *Probe

ProbeLt creates a probe that evaluates to true if p1 < p2.

Not

func (p *Probe) Not() *Probe

ProbeNot creates a probe that is the negation of p.

Or

func (p *Probe) Or(p2 *Probe) *Probe

ProbeOr creates a probe that is the disjunction of p1 and p2.

type Tactic

Tactic represents a Z3 tactic for transforming goals.

Methods:

AndThen

func (t *Tactic) AndThen(t2 *Tactic) *Tactic

AndThen creates a tactic that applies t1 and then t2.

Apply

func (t *Tactic) Apply(g *Goal) *ApplyResult

Apply applies the tactic to a goal.

ApplyEx

func (t *Tactic) ApplyEx(g *Goal, params *Params) *ApplyResult

ApplyEx applies the tactic to a goal with the given parameters.

GetHelp

func (t *Tactic) GetHelp() string

GetHelp returns help information for the tactic.

GetParamDescrs

func (t *Tactic) GetParamDescrs() *ParamDescrs

GetParamDescrs returns parameter descriptions for the tactic.

OrElse

func (t *Tactic) OrElse(t2 *Tactic) *Tactic

OrElse creates a tactic that applies t1, and if it fails, applies t2.

ParAndThen

func (t *Tactic) ParAndThen(t2 *Tactic) *Tactic

ParAndThen creates a tactic that applies t to a goal and then t2 to every subgoal produced by t, processing subgoals in parallel.

Repeat

func (t *Tactic) Repeat(max uint) *Tactic

Repeat creates a tactic that applies t repeatedly (at most max times).

TryFor

func (t *Tactic) TryFor(ms uint) *Tactic

TryFor returns a tactic that applies t for at most ms milliseconds. If t does not terminate in ms milliseconds, then it fails.

UsingParams

func (t *Tactic) UsingParams(params *Params) *Tactic

UsingParams returns a tactic that applies t using the given parameters.