Skip to content

practicallywrong/lambda-calculus-interpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

λ-Calculus Interpreter

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.

Features

  • 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.

Usage

Run the interpreter with a lambda calculus program and a macro file:

python app.py program.lc macros.cfg

Defining Macros

Macros 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.

Notes

  • The normalizer uses a step limit (100,000 by default) to prevent infinite reductions.

About

man i hate clgs

Resources

Stars

Watchers

Forks

Languages