LamCalc

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2018 License: MIT Imports: 4 Imported by: 0

README

LamCalc

LamCalc is a simple library in Go to evaluate and work with lambda calculus.

This project also contains the cLC (cLamCalc) which is a commandline application build upon LamCalc to experiment with and learn about lambda calculus.

To learn more about the library and the cLC visit the project's wiki.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxReductions = 10000

MaxReductions determines the maximum amount of expansions before we give up use a negative value to have no limit (use with care...)

Functions

This section is empty.

Types

type Abst added in v1.1.0

type Abst [1]Term

Abst represents a lambda abstraction

func (Abst) AlphaEquivalent added in v1.1.0

func (la Abst) AlphaEquivalent(other Term) bool

AlphaEquivalent checks whether a Abst and a Term are identical

func (Abst) AorReduce added in v1.1.0

func (la Abst) AorReduce() (Term, error)

AorReduce reduces a lambda abstraction using applicative order

func (Abst) BetaReduce added in v1.1.0

func (la Abst) BetaReduce(sub Term) Term

BetaReduce substitutes the locally bound variable of the Abst by sub

func (Abst) EtaReduce added in v1.1.0

func (la Abst) EtaReduce() Term

EtaReduce applies eta-reduction to the Abst when possible

func (Abst) NorReduce added in v1.1.0

func (la Abst) NorReduce() (Term, error)

NorReduce reduces a lambda abstraction using normal order

func (Abst) Reduce added in v1.1.0

func (la Abst) Reduce() (Term, error)

Reduce reduces a lambda abstraction

func (Abst) Serialize added in v1.1.0

func (la Abst) Serialize() string

Serialize returns the lambda abstraction as a De Bruijn index representation

func (Abst) String added in v1.1.0

func (la Abst) String() string

String returns the lambda abstraction as a string

func (Abst) WHNF added in v1.1.0

func (la Abst) WHNF() Abst

WHNF returns the abstraction

type Appl added in v1.1.0

type Appl [2]Term

Appl represents an application

func (Appl) AlphaEquivalent added in v1.1.0

func (lx Appl) AlphaEquivalent(other Term) bool

AlphaEquivalent checks whether the Appl is identical to a Term

func (Appl) AorReduce added in v1.1.0

func (lx Appl) AorReduce() (Term, error)

AorReduce reduces an application using applicative order

func (Appl) EtaReduce added in v1.1.0

func (lx Appl) EtaReduce() Term

EtaReduce applies eta-reduction to the Appl when possible

func (Appl) NorReduce added in v1.1.0

func (lx Appl) NorReduce() (Term, error)

NorReduce reduces an application using normal order

func (Appl) Reduce added in v1.1.0

func (lx Appl) Reduce() (Term, error)

Reduce reduces an application

func (Appl) Serialize added in v1.1.0

func (lx Appl) Serialize() string

Serialize returns the application as a De Bruijn index representation

func (Appl) String added in v1.1.0

func (lx Appl) String() string

String returns the Lambda Expression as a string

func (Appl) WHNF added in v1.1.0

func (lx Appl) WHNF() Abst

WHNF encapsulates the expression in a lambda abstraction

type Term added in v1.1.0

type Term interface {
	AlphaEquivalent(Term) bool
	EtaReduce() Term

	String() string

	Reduce() (Term, error)
	NorReduce() (Term, error)
	AorReduce() (Term, error)

	WHNF() Abst

	Serialize() string
	// contains filtered or unexported methods
}

Term is a general type to represent both Applns, Absts and Vars

func Deserialize added in v1.1.0

func Deserialize(inpt string) (Term, error)

Deserialize turns a De Bruijn index representation into the internal representation

func MustDeserialize added in v1.1.0

func MustDeserialize(inpt string) Term

MustDeserialize turns a De Bruijn index representation into the internal representation, panics on error

type Var added in v1.1.0

type Var uint

Var is the De Bruijn index of a variable minus one

func (Var) AlphaEquivalent added in v1.1.0

func (lv Var) AlphaEquivalent(other Term) bool

AlphaEquivalent checks whether a Var and a Term are identical

func (Var) AorReduce added in v1.1.0

func (lv Var) AorReduce() (Term, error)

AorReduce returns the variable itself

func (Var) EtaReduce added in v1.1.0

func (lv Var) EtaReduce() Term

EtaReduce returns the variable

func (Var) NorReduce added in v1.1.0

func (lv Var) NorReduce() (Term, error)

NorReduce returns the variable itself

func (Var) Reduce added in v1.1.0

func (lv Var) Reduce() (Term, error)

Reduce returns the variable itself

func (Var) Serialize added in v1.1.0

func (lv Var) Serialize() string

Serialize returns the variable as a De Bruijn index representation

func (Var) String added in v1.1.0

func (lv Var) String() string

String returns the lambda variable as a string

func (Var) WHNF added in v1.1.0

func (lv Var) WHNF() Abst

WHNF encapsulates the Lambda variable inside of a lambda abstraction

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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