This project is a simple λ-Calculus interpreter with support for macro definitions. It parses lambda expressions, expands macros, and performs beta-reduction to normalize expressions.
- Lambda calculus parsing: Supports variables, abstractions (
λx. …), and applications(f x). - Macro expansion: Define reusable lambda expressions in a configuration file.
- Expression normalization: Reduces lambda expressions using beta-reduction.
- Supports α-conversion to avoid variable capture during substitution.
Run the interpreter with a lambda calculus program and a macro file:
python app.py program.lc macros.cfgMacros are defined in macros.cfg as NAME = EXPRESSION.
Example:
TWO = (λf.(λx.(f (f x))))
ADD = (λm.(λn.(λf.(λx.((m f) ((n f) x))))))
- Macro names must be valid variable names.
- Macros can reference other macros; the interpreter will expand.
- The normalizer uses a step limit (100,000 by default) to prevent infinite reductions.