enum

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package enum provides algorithms to perform model enumeration on formulas in LogicNG.

An enumeration can be performed on a formula:

assert := assert.New(t)
fac := f.NewFactory()
p := parser.New(fac)
formula := p.ParseUnsafe("A & (B | C)")
models := enum.OnFormula(fac, formula, fac.Vars("A", "B", "C")) // will produce 3 models

or directly on a SAT solver

solver := sat.NewMiniSatSolver(fac)
models = enum.OnSolver(solver, fac.Vars("A", "B", "C")) // will produce 3 models

Model enumeration is one use case of the model iteration in the iter package and can be configured as described there.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalCNF

func CanonicalCNF(fac f.Factory, formula f.Formula) f.Formula

CanonicalCNF returns a canonical CNF of the given formula.

func CanonicalCNFWithHandler added in v0.4.0

func CanonicalCNFWithHandler(fac f.Factory, formula f.Formula, iterHandler iter.Handler) (cnf f.Formula, ok bool)

CanonicalCNF returns a canonical CNF of the given formula. The given iterHandler can be used to abort the computation. If the enumeration was aborted, the ok flag is false.

func CanonicalDNF

func CanonicalDNF(fac f.Factory, formula f.Formula) f.Formula

CanonicalDNF returns a canonical DNF of the given formula.

func CanonicalDNFWithHandler added in v0.4.0

func CanonicalDNFWithHandler(fac f.Factory, formula f.Formula, iterHandler iter.Handler) (cnf f.Formula, ok bool)

CanonicalDNF returns a canonical DNF of the given formula. The given iterHandler can be used to abort the computation. If the enumeration was aborted, the ok flag is false.

func OnFormula

func OnFormula(
	fac f.Factory,
	formula f.Formula,
	variables []f.Variable,
	additionalVariables ...f.Variable,
) []*model.Model

OnFormula enumerates all models of a formula over the given variables. The additionalVariables will be included in each model, but are not iterated over.

func OnFormulaWithConfig

func OnFormulaWithConfig(
	fac f.Factory,
	formula f.Formula,
	variables []f.Variable,
	config *iter.Config,
	additionalVariables ...f.Variable,
) ([]*model.Model, bool)

OnFormulaWithConfig enumerates all models of a formula over the given variables. The additionalVariables will be included in each model, but are not iterated over. The config can be used to influence the model iteration process by setting a handler and/or an iteration strategy.

func OnSolver

func OnSolver(solver *sat.Solver, variables []f.Variable, additionalVariables ...f.Variable) []*model.Model

OnSolver enumerates all models on the given SAT solver over the given variables. The additionalVariables will be included in each model, but are not iterated over.

func OnSolverWithConfig

func OnSolverWithConfig(
	solver *sat.Solver,
	variables []f.Variable,
	config *iter.Config,
	additionalVariables ...f.Variable,
) ([]*model.Model, bool)

OnSolverWithConfig enumerates all models on the given SAT solver over the given variables. The additionalVariables will be included in each model, but are not iterated over. The config can be used to influence the model iteration process by setting a handler and/or an iteration strategy.

func ToBDDOnFormula

func ToBDDOnFormula(
	fac f.Factory,
	formula f.Formula,
	variables []f.Variable,
) *bdd.BDD

ToBDDOnFormula enumerates all models of a formula over the given variables and tathers the result in a BDD.

func ToBDDOnFormulaWithConfig

func ToBDDOnFormulaWithConfig(
	fac f.Factory,
	formula f.Formula,
	variables []f.Variable,
	config *iter.Config,
) (*bdd.BDD, bool)

ToBDDOnFormulaWithConfig enumerates all models of a formula over the given variables and gathers the result in a BDD. The config can be used to influence the model iteration process by setting a handler and/or an iteration strategy.

func ToBDDOnSolver

func ToBDDOnSolver(solver *sat.Solver, variables []f.Variable) *bdd.BDD

ToBDDOnSolver enumerates all models on the given SAT solver over the given variables and gathers the result in a BDD.

func ToBDDOnSolverWithConfig

func ToBDDOnSolverWithConfig(
	solver *sat.Solver,
	variables []f.Variable,
	config *iter.Config,
) (*bdd.BDD, bool)

ToBDDOnSolverWithConfig enumerates all models on the given SAT solver over the given variables and gathers the result in a BDD. The config can be used to influence the model iteration process by setting a handler and/or an iteration strategy.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL