resolution

package module
v0.0.0-...-921fd5e Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2021 License: AGPL-3.0 Imports: 4 Imported by: 0

README

resolution

A Go implementation of SLD and SLG resolution

Documentation

Overview

This package implements the SLG resolution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AST

type AST interface {
	Description() string
}

An abstract AST.

type ASTRule

type ASTRule struct {
	// contains filtered or unexported fields
}

A syntactic rule.

func (*ASTRule) Description

func (a *ASTRule) Description() string

A textual representation of the rule.

func (*ASTRule) Sem

func (a *ASTRule) Sem() *Rule

type ASTTerm

type ASTTerm interface {
	AST
	Sem(vars map[string]*Variable) Term
}

type ASTValue

type ASTValue struct {
	// contains filtered or unexported fields
}

func (*ASTValue) Description

func (a *ASTValue) Description() string

func (*ASTValue) Sem

func (a *ASTValue) Sem(vars map[string]*Variable) Term

type ASTVar

type ASTVar struct {
	// contains filtered or unexported fields
}

func (*ASTVar) Description

func (a *ASTVar) Description() string

func (*ASTVar) Sem

func (a *ASTVar) Sem(vars map[string]*Variable) Term

type Context

type Context struct {
	// contains filtered or unexported fields
}

func NewContext

func NewContext() *Context

func (*Context) Clone

func (c *Context) Clone() *Context

type Rule

type Rule struct {
	Head *Value
	Body []*Value
	// contains filtered or unexported fields
}

func NewRule

func NewRule(head *Value, body []*Value) *Rule

func (*Rule) AddUse

func (r *Rule) AddUse()

func (*Rule) InstantiateVariables

func (r *Rule) InstantiateVariables() (*Value, []*Value)

func (*Rule) RelinquishUse

func (r *Rule) RelinquishUse()

func (*Rule) String

func (r *Rule) String() string

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer() *Server

type Signature

type Signature struct {
	Functor string
	Arity   int
}

type Snapshot

type Snapshot struct {
	// contains filtered or unexported fields
}

type Term

type Term interface {
	CtxString(*Context) string
	Unify(*Context, Term, func(*Context))
	Ground(*Context) *Value
}

type Theory

type Theory struct {
	//Rules []*Rule
	Rules map[Signature][]*Rule
}

func NewTheory

func NewTheory(rules []*Rule) *Theory

func NewTheoryFromSource

func NewTheoryFromSource(code string) (*Theory, error)

Creates a new theory from the provided source code.

func (*Theory) AddRule

func (th *Theory) AddRule(rule *Rule)

func (*Theory) AddRules

func (th *Theory) AddRules(rules []*Rule)

func (*Theory) AddRulesFromSource

func (th *Theory) AddRulesFromSource(code string) error

Adds rules from the provided source code.

func (*Theory) Infer

func (th *Theory) Infer(context *Context, goal *Value, cb func(*Context) bool)

func (*Theory) InferTabled

func (th *Theory) InferTabled(context *Context, goal *Value, cb func(*Context) bool)

func (*Theory) Rollback

func (th *Theory) Rollback(ss *Snapshot)

func (*Theory) Snapshot

func (th *Theory) Snapshot() *Snapshot

func (*Theory) String

func (th *Theory) String() string

type Value

type Value struct {
	Functor string
	Args    []Term
}

func NewValue

func NewValue(vars map[string]*Variable, functor string, args ...string) *Value

func (*Value) CtxString

func (p *Value) CtxString(context *Context) string

func (*Value) Ground

func (v *Value) Ground(context *Context) *Value

func (*Value) InstantiateVariables

func (p *Value) InstantiateVariables(vars map[string]*Variable) *Value

func (*Value) Signature

func (v *Value) Signature() Signature

func (*Value) TableSignature

func (v *Value) TableSignature(context *Context) string

func (*Value) Unify

func (p1 *Value) Unify(context *Context, p2 Term, cb func(*Context))

Unifies two terms using the provided context.

type Variable

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

func (*Variable) Bind

func (v *Variable) Bind(context *Context, t Term)

func (*Variable) CtxString

func (v *Variable) CtxString(context *Context) string

func (*Variable) Ground

func (v *Variable) Ground(context *Context) *Value

func (*Variable) Pointee

func (v *Variable) Pointee(context *Context) Term

func (*Variable) SetPointee

func (v *Variable) SetPointee(context *Context, t Term)

func (*Variable) Unify

func (v *Variable) Unify(context *Context, t Term, cb func(*Context))

Jump to

Keyboard shortcuts

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