Quick start

For people willing to get hands quickly on coding:

Install

$ pip install calchylus

Open Hy

$ hy

Import

(require [calchylus.lambdas [*]])

Initialize

(with-alpha-conversion-and-macros L ,)

Lambda dance

(L x y , (x (x (x (x (x y))))) a b) ; output: (a (a (a (a (a b)))))
(FIBONACCI SEVEN x y) ; output: (x (x (x (x (x (x (x (x (x (x (x (x (x y)))))))))))))

Explanation

calchylus module works in Windows, Linux, and MacOS operating systems. 3.7 or greater is required. The whole great Python ecosystem can be installed from Anaconda.

Install Hy language interpreter and calchylus module by using pip Python package management tool:

$ pip install calchylus

Open Hy, since calchylus is mostly written as Hy macros:

$ hy

Import Lambda calculus macros:

(require [calchylus.lambdas [*]])

Define Lambda function indicator letter L and Lambda argument-body separator character , with one of the initializer macros:

(with-alpha-conversion-and-macros L ,)

By with-alpha-conversion-and-macros we want to say that arguments should be internally renamed to prevent argument name collision and that we want to load custom macros representing Lambda forms.

Now, we are ready to evaluate Lambda expressions. Here we apply Church numeral five to the two values, a and b:

(L x y , (x (x (x (x (x y))))) a b)

[output]

(a (a (a (a (a b)))))

Without going deeper into this yet, we can see that all x got replaced by a and all y got replaced by b.

Predefined macros are available as shorthands for the most common Lambda forms. For example, calculating the seventh Fibonacci number can be done by using the Church numeral SEVEN and the FIBONACCI shorthands:

(FIBONACCI SEVEN x y)

[output]

(x (x (x (x (x (x (x (x (x (x (x (x (x y)))))))))))))

That is the Church numeral 13, the seventh Fibonacci number.

In calcylus these custom macro shorthands representing Lambda forms serves as a mathematical and logical foundation for a prototype programming language that is based on purely untyped Lambda calculus.