Implementation of the Lambda calculus
Project description
lambda_calculus
The lambda_calculus
package contains classes which implement basic operations of the lambda calculus.
To use it, simply import the classes Variable
, Abstraction
and Application
from this package
and nest them to create more complex lambda terms.
You can also use the visitors
subpackage to define your own operations on terms or
use predefined ones from the terms
subpackage.
Requirements
Python >= 3.10 is required to use this package.
Installation
python3 -m pip install lambda-calculus
Examples
(λy.(λx.(λy. + x y)) y 3) 4
from lambda_calculus import Variable, Abstraction, Application
term = Application(Variable("+"), Variable("x"))
term = Application(term, Variable("y"))
term = Abstraction("y", term)
term = Abstraction("x", term)
term = Application(term, Variable("y"))
term = Application(term, Variable("3"))
term = Abstraction("y", term)
term = Application(term, Variable("4"))
using utility methods:
from lambda_calculus import Variable, Abstraction, Application
x = Variable.with_valid_name("x")
y = Variable.with_valid_name("y")
term = Application.with_arguments(Variable.with_valid_name("+"), (x, y))
term = Abstraction.curried(("x", "y"), term)
term = Application.with_arguments(term, (y, Variable.with_valid_name("3")))
term = Abstraction("y", term)
term = Application(term, Variable.with_valid_name("4"))
evaluation:
from lambda_calculus import Variable, Application
from lambda_calculus.visitors.normalisation import BetaNormalisingVisitor
assert BetaNormalisingVisitor().skip_intermediate(term) == Application.with_arguments(
Variable("+"),
(Variable("4"), Variable("3"))
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lambda_calculus-1.10.1.tar.gz
(20.5 kB
view hashes)
Built Distribution
Close
Hashes for lambda_calculus-1.10.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad1ca2f87fb56076ff11d8828c27f606b312cad24f89dd0f96d7974bb506ebf3 |
|
MD5 | f3c45adc3625d81a7917594e2774a96a |
|
BLAKE2b-256 | 9a3aded47a65f1cabed1708a7b462a177601d21e3ea2aab0022e0998073b5265 |