terms

package
v0.0.0-...-958f0fa Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: MPL-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Counter <-chan *big.Int

stream of pointers to big integers for renaming variables

Functions

func Arity

func Arity(t Term) int

func AtomicFormula

func AtomicFormula(t Term) bool

func Equal

func Equal(t1, t2 Term) bool

func Err

func Err(s *sc.Scanner, str string)

func Functor

func Functor(t Term) (result string, ok bool)

func Ground

func Ground(t Term, b Bindings) bool

func Normalize

func Normalize(s string) string

func Predicate

func Predicate(t Term) (string, bool)

Predicate is a synonym for Functor

func Tok2str

func Tok2str(tok rune) string

Types

type Atom

type Atom string

func (Atom) OccurVars

func (t Atom) OccurVars() Vars

func (Atom) String

func (t Atom) String() string

func (Atom) Type

func (t Atom) Type() Type

type BindEle

type BindEle struct {
	Var  Variable
	T    Term
	Next Bindings
}

type Bindings

type Bindings *BindEle

func AddBinding

func AddBinding(v Variable, t Term, b Bindings) Bindings

func Match

func Match(t1, t2 Term, env Bindings) (env2 Bindings, ok bool)

func Unify

func Unify(head, goal Term, env Bindings) (env2 Bindings, ok bool)

Unify head-term with goal-term

func Unify1

func Unify1(t1, t2 Term, renaming bool, visited Vars, env Bindings) (env2 Bindings, ok bool)

type Bool

type Bool bool

func (Bool) OccurVars

func (t Bool) OccurVars() Vars

func (Bool) String

func (t Bool) String() string

func (Bool) Type

func (t Bool) Type() Type

type Compound

type Compound struct {
	Functor string
	Id      *big.Int
	Prio    int
	EMap    *EnvMap

	IsActive bool
	Args     []Term
	// contains filtered or unexported fields
}

func CopyCompound

func CopyCompound(c Compound) (c1 Compound)

func (Compound) Arity

func (t Compound) Arity() int

func (Compound) OccurVars

func (t Compound) OccurVars() Vars

func (Compound) String

func (t Compound) String() string

func (Compound) Type

func (t Compound) Type() Type

type EnvMap

type EnvMap map[int][]Bindings

type Float

type Float float64

func (Float) OccurVars

func (t Float) OccurVars() Vars

func (Float) String

func (t Float) String() string

func (Float) Type

func (t Float) Type() Type

type Int

type Int int

func (Int) OccurVars

func (t Int) OccurVars() Vars

func (Int) String

func (t Int) String() string

func (Int) Type

func (t Int) Type() Type

type List

type List []Term

func (List) OccurVars

func (t List) OccurVars() Vars

func (List) String

func (t List) String() string

func (List) Type

func (t List) Type() Type

type String

type String string

func (String) OccurVars

func (t String) OccurVars() Vars

func (String) String

func (t String) String() string

func (String) Type

func (t String) Type() Type

type Term

type Term interface {
	OccurVars() Vars
	String() string
	Type() Type
}

func Assignexpr

func Assignexpr(s *sc.Scanner, tok1 rune) (t Term, tok rune, ok bool)

<expression> | <variable> ':=' <exspression>

func Factor_name

func Factor_name(name string, s *sc.Scanner, tok1 rune) (t Term, tok rune, ok bool)

<bi_0 name> | <name>'(”)' | <name> '(' <expression> [',' <expression>]0..n ')'

func GetBinding

func GetBinding(v Variable, b Bindings) (t Term, ok bool)

func NewCompound

func NewCompound(f string, args []Term) Term

func Object

func Object(t Term) (result Term, ok bool)

func ReadString

func ReadString(src string) (result Term, ok bool)

func RenameAndSubstitute

func RenameAndSubstitute(t Term, idx *big.Int, env Bindings) Term

Substitute: replace variables in the term t with their bindings in the env or in the Build-In environment (BIVarEqTerm), if they are bound. If their are not bound rename the body-varaible of the rule (very late renaming). Follows variable chains, so that if a variable is bound to a variable, the second variable is also substituted if it is bound in env, recursively.

func Subject

func Subject(t Term) (result Term, ok bool)

func Substitute

func Substitute(t Term, env Bindings) Term

Substitute: replace variables in the term t with their bindings in the env, if they are bound. Follows variable chains, so that if a variable is bound to a variable, the second variable is also substituted if it is bound in env, recursively.

func SubstituteBiEnv

func SubstituteBiEnv(t Term, biEnv Bindings) (Term, bool)

Substitute: replace variables in the term t with their bindings in the Build-In environment (BIVarEqTerm), if they are bound. Follows variable chains, so that if a variable is bound to a variable, the second variable is also substituted if it is bound in env, recursively.

type Type

type Type int
const (
	AtomType Type = iota
	BoolType
	IntType
	FloatType
	StringType
	CompoundType
	ListType
	VariableType
)

type Variable

type Variable struct {
	Name string
	// contains filtered or unexported fields
}

func NewVariable

func NewVariable(name string) Variable

func (Variable) OccurVars

func (t Variable) OccurVars() Vars

func (Variable) Rename

func (v Variable) Rename() Variable

func (Variable) String

func (v Variable) String() string

func (Variable) Type

func (t Variable) Type() Type

type Vars

type Vars []Variable

Jump to

Keyboard shortcuts

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