Documentation ¶
Index ¶
- Variables
- func ComparisonString(tokenComparison tokenKind) (s string)
- func Debug(level int, s ...interface{})
- func Expansion(func(Groundable) (changed bool, result []Groundable, err error)) (bool, error)
- func IsMarkedAsFree(v string) bool
- func TermTranslation(termIterator TermIterator, transform func(Term) (Term, bool, error)) (changed bool, err error)
- type Clause
- type Constraint
- func (constraint Constraint) Copy() (cons Constraint)
- func (constraint Constraint) FreeVars() *strset.Set
- func (constraint *Constraint) GroundBoolExpression() (isGround bool, result bool)
- func (constraint Constraint) IsInstantiation() (is bool, variable string, value string, err error)
- func (constraint *Constraint) String() string
- type Groundable
- type Iterator
- type LineNumberInfo
- type Literal
- type LiteralError
- type Predicate
- type Program
- func (p *Program) CheckArityOfLiterals() error
- func (p *Program) CheckFactsInIterators() error
- func (p *Program) CheckNoExplicitDeclarationAndNonGroundExplicit() error
- func (p *Program) CheckNoGeneratorsOrIterators() error
- func (p *Program) CheckSearch() error
- func (p *Program) CheckUnboundVariables() error
- func (p *Program) CleanIteratorFromGroundBoolExpressions() (bool, error)
- func (p *Program) CleanRulesFromGroundBoolExpression() (bool, error)
- func (p *Program) CollectExplicitTupleDefinitions() (bool, error)
- func (p *Program) CollectGroundFacts() (changed bool, err error)
- func (p *Program) CollectGroundTuples() (bool, error)
- func (p *Program) CollectStringTermsToIntegers() error
- func (p *Program) ConstraintSimplification() (bool, error)
- func (p *Program) ConvertHeadOnlyIteratorsToLiterals() (bool, error)
- func (p *Program) ExpandGroundRanges() (changed bool, err error)
- func (p *Program) ExtractQuantors()
- func (p *Program) FindFactsThatAreFullyCollected() (changed bool, err error)
- func (p *Program) InsertLiteralTuple(lit Literal) error
- func (p *Program) InstantiateAndRemoveFactFromGenerator() (changed bool, err error)
- func (p *Program) InstantiateAndRemoveFactFromIterator() (changed bool, err error)
- func (p *Program) InstantiateExplicitNonGroundLiterals() (changed bool, err error)
- func (p *Program) InstantiateNonGroundLiterals() (changed bool, err error)
- func (p *Program) IsSATProblem() bool
- func (p *Program) MergeConsecutiveQuantificationLevels()
- func (p *Program) OutputRuleString(rule *Rule) string
- func (p *Program) OutputString(literal Literal) string
- func (p *Program) OutputTermString(term string) (s string)
- func (p *Program) Print()
- func (p *Program) PrintDebug(level int)
- func (p *Program) PrintFacts()
- func (p *Program) PrintQuantification()
- func (p *Program) PrintRules()
- func (p *Program) PrintTuples()
- func (p *Program) RemoveClausesWithExplicitLiteralAndTuplesThatDontExist() (bool, error)
- func (p *Program) RemoveClausesWithTuplesThatDontExist() (bool, error)
- func (p *Program) RemoveLiteralsWithEmptyIterators() (bool, error)
- func (p *Program) RemoveNegatedGroundGenerator() (changed bool, err error)
- func (p *Program) RemoveRules(ifTrueRemove func(r Rule) bool) (changed bool, err error)
- func (p *Program) RemoveRulesWithGenerators() (bool, error)
- func (p *Program) RemoveRulesWithNegatedGroundGenerator() (changed bool, err error)
- func (p *Program) ReplaceConstantsAndMathFunctions()
- func (p *Program) RuleExpansion(check func(r Rule) bool, expand func(Rule) ([]Rule, error)) (changed bool, err error)
- func (p *Program) RuleTransformation(check func(r Rule) bool, transformation func(Rule) (Rule, error)) (changed bool, err error)
- func (p *Program) TermExpansion(check func(r Term) bool, expand func(Term) ([]Term, error)) (changed bool, err error)
- func (p *Program) TransformConstraintsToInstantiation() (bool, error)
- func (p *Program) TransformConstraintsToInstantiationIterator() (bool, error)
- type Rule
- func (rule Rule) AllLiterals() (literals []*Literal)
- func (rule Rule) AllTerms() (terms []*Term)
- func (rule Rule) Copy() (newRule Rule)
- func (rule *Rule) Debug() string
- func (rule *Rule) FreeVars() *strset.Set
- func (rule *Rule) IsFact() bool
- func (rule *Rule) IsGround() bool
- func (rule *Rule) Simplify(assignment map[string]string) (bool, error)
- func (rule *Rule) String() string
- type RuleError
- type SepToken
- type Term
- type TermIterator
- type Token
- type Tokens
Constants ¶
This section is empty.
Variables ¶
var (
DebugLevel int
)
Functions ¶
func ComparisonString ¶
func ComparisonString(tokenComparison tokenKind) (s string)
func Expansion ¶
func Expansion(func(Groundable) (changed bool, result []Groundable, err error)) (bool, error)
func IsMarkedAsFree ¶
func TermTranslation ¶
Types ¶
type Constraint ¶
is a math expression that evaluates to true or false Constraints can contain variables supported are <,>,<=,>=,== E.g..: A*3v<=v5-2*R/7#mod3.
func (Constraint) Copy ¶
func (constraint Constraint) Copy() (cons Constraint)
func (Constraint) FreeVars ¶
func (constraint Constraint) FreeVars() *strset.Set
func (*Constraint) GroundBoolExpression ¶
func (constraint *Constraint) GroundBoolExpression() (isGround bool, result bool)
func (Constraint) IsInstantiation ¶
func (constraint Constraint) IsInstantiation() (is bool, variable string, value string, err error)
Checks if constraint is of the form X==<math>, or <math>==X ( math is ground ) It also does very simple equation solving for equations with one variable, like X-3+1==<math> .
func (*Constraint) String ¶
func (constraint *Constraint) String() string
type Groundable ¶
type Groundable interface { Terms() []*Term Literals() *[]Literal Constraints() *[]Constraint Generators() *[]Literal Copy() Groundable }
/ IDEA to unify treatment of Iterator and Rule
type Iterator ¶
type Iterator struct { Constraints []Constraint Conditionals []Literal Head Literal }
type LineNumberInfo ¶
type LineNumberInfo struct {
// contains filtered or unexported fields
}
type Literal ¶
type LiteralError ¶
func (LiteralError) Error ¶
func (err LiteralError) Error() string
type Program ¶
type Program struct { Rules []Rule Constants map[string]string // grounding stuff, backups, hashmaps PredicateToArity map[Predicate]int // PredicateExplicit map[Predicate]bool // If there is a explicit quantification for predicate FinishCollectingFacts map[Predicate]bool // True if no more rules with that predicate in in the head. PredicateToTuples map[Predicate][][]string // Contains a slice of all tuples PredicateTupleMap map[string]bool // hashmap that contains all positive and negative ground atoms in the program // handle string terms // String terms are replaced by integers. // These two mappings are the bijective mapping from integers to these strings: String2IntId map[string]int // StringReplacement IntId2String map[int]string // StringReplacement //Quantification Alternation [][]Literal // contains filtered or unexported fields }
func ParseProgram ¶
func ParseProgramFromStrings ¶
func ParseProgramFromStrings(lines []string, where []LineNumberInfo) (p Program, err error)
func (*Program) CheckArityOfLiterals ¶
func (*Program) CheckFactsInIterators ¶
func (*Program) CheckNoExplicitDeclarationAndNonGroundExplicit ¶
func (*Program) CheckNoGeneratorsOrIterators ¶
func (*Program) CheckSearch ¶
func (*Program) CheckUnboundVariables ¶
Check that there are no unbound variables All variables that only occur in exactly one term are not bound by others and must be marked as free and unbound (i.e. starting with underscore _)
func (*Program) CleanIteratorFromGroundBoolExpressions ¶
Remove Iterator if with false constraint Remove true constraints from Iterator
func (*Program) CleanRulesFromGroundBoolExpression ¶
Remove Rules with false constraint Remove true constraints from Rule This is essentially Unit Propagation on Constraint Instantiation
func (*Program) CollectExplicitTupleDefinitions ¶
Check if rule contains #exist or #forall literal! At version 3.0 of BULE, a definition rule has to have exactly 1 literal in the generator, 1 literal be ground, and have question mark! Then take literal and add tuple and add to quantification level
func (*Program) CollectGroundFacts ¶
func (*Program) CollectGroundTuples ¶
func (*Program) CollectStringTermsToIntegers ¶
If a term matches Constant term expression (as a string) then replace it by a number and remember this in maps. Replace this everywhere ! Assumptions: Integers above 1*10^9 never used in the programs !
func (*Program) ConstraintSimplification ¶
func (*Program) ConvertHeadOnlyIteratorsToLiterals ¶
func (*Program) ExpandGroundRanges ¶
func (*Program) ExtractQuantors ¶
func (p *Program) ExtractQuantors()
func (*Program) FindFactsThatAreFullyCollected ¶
A fact is fully collected if it does not occur as a head in any rule. Exception is #exist and #forall
func (*Program) InsertLiteralTuple ¶
func (*Program) InstantiateAndRemoveFactFromGenerator ¶
This resolves facts with clauses.
func (*Program) InstantiateAndRemoveFactFromIterator ¶
This resolves facts with clauses.
func (*Program) InstantiateExplicitNonGroundLiterals ¶
This resolves facts with clauses.
func (*Program) InstantiateNonGroundLiterals ¶
This resolves facts with clauses.
func (*Program) IsSATProblem ¶
func (*Program) MergeConsecutiveQuantificationLevels ¶
func (p *Program) MergeConsecutiveQuantificationLevels()
Translates forallQ and existsQ into quantification
func (*Program) OutputRuleString ¶
func (*Program) OutputString ¶
This is equivalent to the String() method but maps onto the string terms, if term is string
func (*Program) OutputTermString ¶
func (*Program) PrintDebug ¶
func (*Program) PrintFacts ¶
func (p *Program) PrintFacts()
func (*Program) PrintQuantification ¶
func (p *Program) PrintQuantification()
func (*Program) PrintRules ¶
func (p *Program) PrintRules()
func (*Program) PrintTuples ¶
func (p *Program) PrintTuples()
func (*Program) RemoveClausesWithExplicitLiteralAndTuplesThatDontExist ¶
func (*Program) RemoveClausesWithTuplesThatDontExist ¶
func (*Program) RemoveLiteralsWithEmptyIterators ¶
func (*Program) RemoveNegatedGroundGenerator ¶
func (*Program) RemoveRules ¶
Remove all rules where check is true.
func (*Program) RemoveRulesWithGenerators ¶
func (*Program) RemoveRulesWithNegatedGroundGenerator ¶
func (*Program) ReplaceConstantsAndMathFunctions ¶
func (p *Program) ReplaceConstantsAndMathFunctions()
func (*Program) RuleExpansion ¶
func (p *Program) RuleExpansion(check func(r Rule) bool, expand func(Rule) ([]Rule, error)) (changed bool, err error)
goes through all rules and expands expands if check is true. Note that this does not expand the generated rules. (i.e. it does not run until fixpoint)
func (*Program) RuleTransformation ¶
func (p *Program) RuleTransformation(check func(r Rule) bool, transformation func(Rule) (Rule, error)) (changed bool, err error)
goes through all rules and translates if check is true. Singleton version of RuleExpansion
func (*Program) TermExpansion ¶
func (p *Program) TermExpansion(check func(r Term) bool, expand func(Term) ([]Term, error)) (changed bool, err error)
Check terms in literals and expands the rules according to the *first* term found according to it's expansion.
func (*Program) TransformConstraintsToInstantiation ¶
for each Constraint X==<Value> Rewrite all Terms with X <- <Value>
func (*Program) TransformConstraintsToInstantiationIterator ¶
for each Constraint X==<Value> Rewrite all Terms with X <- <Value> Only within Iterators
type Rule ¶
type Rule struct { LineNumber LineNumberInfo Parent *Rule Generators []Literal Constraints []Constraint Literals []Literal Iterators []Iterator IsQuestionMark bool // if final token is tokenQuestionMark then it generates, otherwise tokenDot // contains filtered or unexported fields }
func (Rule) AllLiterals ¶
type TermIterator ¶
type TermIterator interface {
AllTerms() []*Term
}