Skip to main content

lambda_calculus

Hatch project Tests codecov Documentation Status

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.

More information is available on Read the Docs.

Notice

This package is intended to be used for educational purposes and is not optimized for speed.

Furthermore, it expects all terms to be finite, which means the absence of cycles.

RecursionError may be raised if the visitors get passed an infinite term or the evaluation is too complex.

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

Nesting

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"))

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"))

Method Chaining

from lambda_calculus import Variable, Abstraction, Application

x = Variable.with_valid_name("x")
y = Variable.with_valid_name("y")

term = Variable("+") \
    .apply_to(x, y) \
    .abstract("x", "y") \
    .apply_to(y, Variable("3")) \
    .abstract("y") \
    .apply_to(Variable("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"))
)

Metadata

Release files for lambda-calculus 3.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lambda-calculus 3.1.1
File Size Uploaded Provenance
lambda_calculus-3.1.1.tar.gz 33.8 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for lambda-calculus 3.1.1
File Interpreter ABI Platform
lambda_calculus-3.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 64.6 kB

Release files / lambda_calculus-3.1.1.tar.gz

Download URL lambda_calculus-3.1.1.tar.gz
Size 33.8 kB
Tags Source
SHA-256 checksum
How to use checksums
97c4f311edcd6685b839bc21bc41c1635a79090f69634d832ce4adc8c76c9a4b
BLAKE2b-256 checksum
How to use checksums
a1bb48efbfab7ff23235ff933c94faf19608b9947f10327c14edba899ed94f6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / lambda_calculus-3.1.1-py3-none-any.whl

Download URL lambda_calculus-3.1.1-py3-none-any.whl
Size 30.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
444c4f3b21daf81c52c4379463db855d003973080d40108ed87dc3c4c4f9db8b
BLAKE2b-256 checksum
How to use checksums
a126a6dc0afe325856c1954900fc49c95d43370b9f815950d47545ac74ece630
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for lambda-calculus 3.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for lambda_calculus-3.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page