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:

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.

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.

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.

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.

NumExprs

func (g *Goal) NumExprs() uint

NumExprs returns the number of expressions in the goal.

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.

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.

GetHelp

func (t *Tactic) GetHelp() string

GetHelp returns help information for the tactic.

OrElse

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

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

Repeat

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

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