🐑 Lamb: A Lambda Calculus Engine
🧠 What is lambda calculus?
-
video 1: Introduction and boolean logic. The first few minutes are a bit confusing, but it starts to make sense at about
6:50 -
video 2: Continuation of video 1. Features combinators and numerals.
-
blog: Another introduction. Moves slower than the two videos above and doesn't assume CS knowledge. Four-part series.
-
handout: A handout I've written on lambda calculus. Solutions are available somewhere on
git.betalupi.com. You'll have to find them yourself if you want them.
📦 Installation
Method 1: PyPi
- (Optional but recommended) make and enter a venv
- On Windows, run the following in cmd or powershell:
cd Desktoppython -m venv lamb.\Scripts\activate
pip install lamb-enginelamb
Method 2: Git
- Clone this repository.
- Make and enter a virtual environment.
cdinto this directory- Run
pip install . - Run
lamb
📖 Usage
Type expressions into the prompt, and Lamb will evaluate them.
Use your \ (backslash) key to type a λ.
To define macros, use =. For example,
==> T = λab.a
==> F = λab.a
==> NOT = λa.a F T
Note that there are spaces in λa.a F T. With no spaces, aFT will be parsed as one variable.
Lambda functions can only take single-letter, lowercase arguments. λA.A is not valid syntax.
Free variables will be shown with a ', like a'.
Macros are case-sensitive. If you define a macro MAC and accidentally write mac in the prompt, mac will become a free variable.
Numbers will automatically be converted to Church numerals. For example, the following line will reduce to T.
==> 3 NOT F
If an expression takes too long to evaluate, you may interrupt reduction with Ctrl-C.
Exit the prompt with Ctrl-C or Ctrl-D.
There are many useful macros in macros.lamb. Download the file, then load them with the :load command:
==> :load macros.lamb
You can also pass files to lamb directly to have them loaded at startup:
lamb file1 file2
Use your up/down arrows to recall history.
Have fun!
🗃️ Commands
Lamb understands many commands. Prefix them with a : in the prompt.
:help Print a help message
:clear Clear the screen
:rlimit [int | None] Set maximum reduction limit. :rlimit none sets no limit.
:macros List macros.
:mdel [macro] Delete a macro
:delmac Delete all macros
:step [yes | no] Enable or disable step-by-step reduction. Toggle if no argument is given. When reducing by steps, the prompt tells you what kind of reduction was done last:
M: Macro expansionC: Church expansionH: History expansionF: Function application
:expand [yes | no] Enable or disable full expansion. Toggle if no argument is given. If full expansion is enabled, ALL macros will be expanded when printing output.
:save [filename]
:load [filename]
Save or load macros from a file.
The lines in a file look exactly the same as regular entries in the prompt, but can only contain macro definitions. See macros.lamb for an example.
Todo:
- Prevent macro-chaining recursion
- Cleanup warnings
- Truncate long expressions in warnings
- Loop detection
- α-equivalence check
- Unchurch command: make church numerals human-readable
- Better syntax highlighting
- Tab-complete file names and commands
- Load default macros without manually downloading
macros.lamb(viarequests, maybe?) - Tests
Metadata
Release files for lamb-engine 1.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lamb_engine-1.1.9.tar.gz | 31.5 kB | Without provenance | Details for lamb_engine-1.1.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lamb_engine-1.1.9-py3-none-any.whl | Python 3 | none | any | Details for lamb_engine-1.1.9-py3-none-any.whl |
Total release size: 63.1 kB
Release files / lamb_engine-1.1.9.tar.gz
| Download URL | lamb_engine-1.1.9.tar.gz |
|---|---|
| Size | 31.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2ef9eb5133f9195d367a37ac58bf3f58adcf271f8f5adc9dae8c388a50de7546
|
|
BLAKE2b-256 checksum How to use checksums |
592f6463a34290d4f72bc4a463943d8061f85c4e1271ea0ec661692b4ab3fd47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.10
|
Release files / lamb_engine-1.1.9-py3-none-any.whl
| Download URL | lamb_engine-1.1.9-py3-none-any.whl |
|---|---|
| Size | 31.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
68efa3a456b68a98a20322d3bb9d90c85fc80756bb43c443c0bb69d74b72e6cf
|
|
BLAKE2b-256 checksum How to use checksums |
6b08280bf4c84ed52ff38eb45e5c0abcb0870a7c4a1960808d9a6d547a1af932
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.10
|
Security for lamb-engine 1.1.9
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.