Skip to content

Commit 09b3652

Browse files
committed
feat: add impl (#1)
Signed-off-by: Sn0rt <[email protected]>
1 parent 1687e67 commit 09b3652

File tree

7 files changed

+1212
-206
lines changed

7 files changed

+1212
-206
lines changed

Cargo.lock

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7+
uuid = { version = "1.3", features = ["v4"] }

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Lambda Calculus Interpreter
2+
3+
This project implements a Lambda Calculus interpreter in Rust. It supports various operations and Church encodings for numbers and boolean values.
4+
5+
## Supported Instructions
6+
7+
The interpreter supports the following instructions and operations:
8+
9+
1. **Basic Lambda Calculus**
10+
- Variable: `x`, `y`, `z`, etc.
11+
- Abstraction: `λx. <expression>`
12+
- Application: `(<expression> <expression>)`
13+
14+
2. **Church Numerals**
15+
- Encoding: Automatically handled by the interpreter
16+
- Decoding: Automatically handled by the interpreter
17+
- Addition: `add`
18+
- Subtraction: `subtract`
19+
- Multiplication: `multiply`
20+
- Predecessor: `pred`
21+
- Successor: `succ`
22+
- Is Zero: `is_zero`
23+
24+
3. **Church Booleans**
25+
- True: `true` (encoded as `λx. λy. x`)
26+
- False: `false` (encoded as `λx. λy. y`)
27+
- And: `and`
28+
- Or: `or`
29+
- Not: `not`
30+
31+
4. **Control Flow**
32+
- If-Then-Else: `ifelse`
33+
34+
5. **Pairs**
35+
- Create Pair: `pair`
36+
- First Element: `fst`
37+
- Second Element: `snd`
38+
39+
6. **Recursion**
40+
- Y Combinator: `Y`
41+
42+
## Usage Examples
43+
44+
Here are some examples of how to use the interpreter:
45+
46+
1. Church Numeral Addition:
47+
```
48+
(add (church_encode 2) (church_encode 3))
49+
```
50+
51+
2. Boolean Operations:
52+
```
53+
(and true false)
54+
(or true false)
55+
(not true)
56+
```
57+
58+
3. Conditional Statement:
59+
```
60+
(ifelse (is_zero 0) 42 58)
61+
```
62+
63+
4. Factorial using Y Combinator:
64+
```
65+
(Y (λf. λn. (ifelse (is_zero n) 1 (multiply n (f (pred n))))))
66+
```
67+
68+
## Running Tests
69+
70+
To run the tests and see examples of the interpreter in action, use the following command:
71+
72+
```rust
73+
$ cargo test
74+
```

docs/lambda.pdf

406 KB
Binary file not shown.

0 commit comments

Comments
 (0)