https://github.com/sdiehl/bnlc
Binary lambda calculus
https://github.com/sdiehl/bnlc
Last synced: 6 months ago
JSON representation
Binary lambda calculus
- Host: GitHub
- URL: https://github.com/sdiehl/bnlc
- Owner: sdiehl
- Created: 2013-05-31T05:41:12.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-07-02T15:35:01.000Z (over 12 years ago)
- Last Synced: 2025-03-27T18:52:30.163Z (7 months ago)
- Language: Python
- Size: 105 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Binary Lambda Calculus in Python
--------------------------------The binary lambda calculus is defined as the following sequence
of bytes:```
e : 00 e (Lam)
| 01 e e (App)
| [1] 0 (Var)
```The var rule encodes DeBruijn indices with the following pattern:
```
0 = 10
1 = 110
2 = 1110
3 = 11110
```For example the SKI calculus can be expressed in Python as the
following lambda expressions:```python
I = lambda x: x
K = lambda x: lambda y: x
S = lambda x: lambda y: lambda z: x(z)(y(z)) # (x z)(y z)
```Or in the binary lambda calculus as:
```
I = 0010
K = 000010110
S = 00000010110111001011011101101110
```The smallest eval machine for the binary lambda caluclus is the
following program:```
01010001
10100000
00010101
10000000
00011110
00010111
11100111
10000101
11001111
000000111
10000101101
1011100111110
000111110000101
11101001 11010010
11001110 00011011
00001011 11100001
11110000 11100110
11110111 11001111
01110110 00011001
00011010 00011010
```Source: http://www.ioccc.org/2012/tromp/hint.html