Documentation
Back to VisualizerLearn how to use the Lambda Calculus Visualizer
Getting Started
What is the Lambda Calculus Visualizer?
The Lambda Calculus Visualizer is an interactive tool that helps you understand how lambda calculus works by visualizing mathematical expressions. It shows how familiar arithmetic operations can be represented and evaluated using lambda calculus.
Basic Usage
- Enter a mathematical expression in the calculator (e.g.,
3+2
) - Click "=" or press Enter to evaluate
- The expression will be converted to lambda calculus and visualized
- Use the animation controls to step through the evaluation process
- Read the explanations in the educational panel to understand each step
Supported Operations
The calculator currently supports:
- Addition (
+
) - Subtraction (
-
) - Multiplication (
*
) - Parentheses for expression grouping
Lambda Calculus
What is Lambda Calculus?
Lambda calculus is a formal system in mathematical logic developed by Alonzo Church in the 1930s. It provides a mathematical foundation for functional programming and serves as a theoretical basis for computation.
Core Concepts
Variables
Represented as circles in the visualization. Variables are placeholders for values.
Abstractions (Functions)
Represented as diamonds in the visualization. An abstraction λx.M
defines a function with parameter x
and body M
.
Applications
Represented as rectangles in the visualization. An application (M N)
applies function M
to argument N
.
Beta Reduction
The fundamental computation step in lambda calculus. When a function is applied to an argument, the parameter in the function body is replaced with the argument:(λx.M) N → M[x := N]
Church Encodings
Church encodings allow us to represent data (like numbers) and operations (like addition) using only functions. This visualizer uses Church numerals to represent numbers.
Church Numerals
A Church numeral represents a number n
as a function that applies another function n
times:
0 = λf.λx.x 1 = λf.λx.f x 2 = λf.λx.f (f x) 3 = λf.λx.f (f (f x)) ...and so on
Visualization Guide
Understanding Tromp Diagrams
The visualizer uses Tromp diagrams to represent lambda expressions. These diagrams provide a visual representation of the structure of lambda terms.
Animation Controls
The animation controls allow you to navigate through the steps of beta reduction:
- Use the play/pause button to start or stop the automatic animation
- Use the previous/next buttons to navigate steps manually
- Adjust the speed slider to control how fast the animation plays
- Use the step slider to jump to a specific reduction step
Interactive Features
- You can zoom and pan the diagram to explore larger expressions
- Nodes being reduced are highlighted with a glowing effect
- For complex expressions, a minimap appears to help with navigation
- Toggle "Show Lambda Notation" to see the textual representation
Examples
Basic Addition
Try entering 2+3
in the calculator.
This will be converted to a lambda expression applying the Church addition function to Church numerals 2 and 3. The visualization will show how the expression reduces to 5.
Multiplication
Try entering 3*2
in the calculator.
This will demonstrate how multiplication works in lambda calculus, showing the repeated application of addition.
Complex Expressions
Try entering 2*(3+1)
in the calculator.
This will show how parenthesized expressions are evaluated, first computing the inner expression 3+1
and then multiplying the result by 2.