Skip to content

Latest commit

History

History
47 lines (39 loc) 路 1.66 KB

File metadata and controls

47 lines (39 loc) 路 1.66 KB

Lambda Calculus Calculator

About

A toy calculator for playing with the Lambda Calculus I made a while ago. Uses de Bruijn representation of lambda terms internally to avoid 伪-headaches. Written in Haskell. Still very much incomplete and subject to whatever changes I feel like making.

Usage

Display a term 馃攷

The term will be silently 伪-converted so that variables are chosen in alphabetical order.

>> (位xy.x)(位x.x)
(位ab.a)(位a.a)

Perform leftmost reduction 馃憟

Use the :leftmost or :lm command to perform leftmost reduction.

>> :leftmost (位xy.x)(位x.x)
位ab.b
>> :lm (位x.xx)(位x.xx)
(位a.aa)(位a.aa)

You can't leftmost reduce something which is in 尾-normal form.

>> :lm (位x.xx)
(尾-normal) 位a.aa

Find the 尾-normal form 馃槆

Use :betanormal or :bn to find the 尾-normal form.

>> :bn (位x.xx)(位x.x)
位a.a

Convert to DeBruijn notation 馃敩

Use :debruijn or :db to view the De Bruijn notation.

>> :debruijn (位x.xx)(位x.xx)
(位 0 0) (位 0 0)
>> :db (位x.xx)(位xyz.xz)(位x.xx)
(位 0 0) (位 位 位 2 0) (位 0 0)

Installation

Compile with ghc -O2 main.hs -o lambda and run ./lambda. It is often a good idea to run it with rlwrap (use rlwrap ./lambda) so you can edit what you write.