https://github.com/dokutan/combinator-playground
An interpreter for Combinatory logic with a few additional features.
https://github.com/dokutan/combinator-playground
combinators combinators-calculus combinatory-logic
Last synced: 18 days ago
JSON representation
An interpreter for Combinatory logic with a few additional features.
- Host: GitHub
- URL: https://github.com/dokutan/combinator-playground
- Owner: dokutan
- License: agpl-3.0
- Created: 2026-01-03T17:41:57.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2026-07-09T16:52:29.000Z (about 1 month ago)
- Last Synced: 2026-07-09T18:19:45.364Z (about 1 month ago)
- Topics: combinators, combinators-calculus, combinatory-logic
- Language: Clojure
- Homepage:
- Size: 53.7 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Combinator Playground
An interpreter for [Combinatory logic](https://en.wikipedia.org/wiki/Combinatory_logic) with a few additional features.
## Usage
The intended usage is from a Clojure REPL. With [Leiningen](https://leiningen.org/) installed, a REPL can be started with `lein repl`. Alternatively use an integration into your favorite editor to evaluate expressions.
```clojure
;; reduce KIxy (returns a vector of intermediate results)
(reduce* SKI '(K I x y))
;; convert λx.λy.y to SKI and then to BCKW calculus
(-> '[x [y y]] lambda->SKI* last SKI->BCKW)
;; perform a brute force search for all BCKW terms of size 3 that are equivalent to I
(search BCKW 3 ['x] (partial = 'x) 10)
```
## Features
For function documentation, check the docstrings, either in the source code or with `(doc fn)`.
- `reduce*` reduce an expression using the given combinators with intermediate results ([reduce.clj](src/combinator_playground/reduce.clj))
- `lambda->SKI*`, `lambda->BCKW*` convert lambda to SKI/BCKW calculus ([lambda.clj](src/combinator_playground/lambda.clj))
- `SKI->BCKW`, ... convert between combinators ([combinators.clj](src/combinator_playground/combinators.clj))
- `search` search for expressions ([search.clj](src/combinator_playground/search.clj))
The following graph shows the implemented conversions.
```mermaid
graph TD;
lambda[λ]-->|lambda->SKI*|SKI;
lambda[λ]-->|lambda->BCKW*|BCKW;
SKI-->|I->SK|SK;
SKI-->|SKI->BCKW|BCKW;
SK-->|SKI->BCKW|BCKW;
SKI-->|SKI->X|X/iota;
SK-->|SKI->X|X/iota;
BCKW-->|BCKW->SKI|SKI;
MTAB-->|MTAB->BCKW|BCKW;
BCKW-->|BCKW->MTAB|MTAB;
```
# See also
- https://dallaylaen.github.io/ski-interpreter/quest.html (solutions for some quests are in [quests.clj](src/combinator_playground/quests.clj))
- https://blog.happyfellow.dev/a-riddle/ ([riddle.txt](resources/riddle.txt) and a solution in [riddle.clj](src/combinator_playground/riddle.clj))
- https://combinatorylogic.com/table.html