A command-line REPL for manipulating and reducing lambda calculus expressions with support for β-reduction, η-reduction, substitution, and α-equivalence checking.
- Expression Creation: Build lambda terms and variables
- Lambda Calculus Operations:
- β-reduction: Apply functions to arguments
- η-reduction: Simplify redundant abstractions (supports multi-parameter reduction)
- Capture-avoiding substitution
- Application of terms
- Equivalence Checking: Test if two expressions are logically equivalent (α-equivalence after normalization)
- Interactive REPL: Manage expressions with save/show/list/delete commands
CreateVar <name>- Create a variableCreateExpr <expr>- Parse and create an expression (use//for λ)
Apply <expr1> <expr2>- Apply two expressions togetherSubstitute <expr> <var> <replacement>- Replace all free occurrences of a variableEquivalent <expr1> <expr2>- Checks that two expressions are α-equivalentBetaRed <expr>- β-reduce to normal formEtaRed <expr>- η-reduce to normal formBetaEtaRed <expr>- βη-reduce to normal form
Commands- Display all available commandsShortcuts- Display all available command shortcutsRename <name> <newName>- Rename an expressionDelete <expr>- Remove an expressionDeleteAll- Remove all expressionShow <name>- Display a specific expressionList- List all saved expressionsQuit- Exit the interpreter
- Python 3.8 or higher
From the repository root:
python3 src/main.pyOr if you're in the src directory:
python3 main.pylambda-interpreter/
├── src/
│ ├── ast.py # AST node definitions (Variable, Abstraction, Application)
│ ├── parser.py # Parse lambda expressions from strings
│ ├── substitution.py # Capture-avoiding substitution logic
│ ├── reduction.py # β and η reduction algorithms
│ ├── equivalence.py # α-equivalence and logical equivalence checking
│ ├── utils.py # Helper functions
│ ├── repl.py # REPL implementation
│ └── main.py # Entry point
├── README.md
└── LICENSE
Contributions are welcome! :]
If you’d like to help improve this lambda interpreter, please follow these steps:
- Fork the repository and create a new branch from main.
- Open a Pull Request with:
- A clear description of what you changed or added
- The reasoning behind it
If you’re unsure about an idea or want feedback before starting, feel free to open an issue to discuss it first.
Thanks for helping make this project better! 💜
This software is licensed under the MIT license.