Cantor Interpreter implements a small, mathematically-grounded programming language built around Cantor’s pairing function. Every program takes one or more natural numbers as input, encodes them into a single integer using the Cantor pairing function, and returns a natural number. Functions are built by composing a small set of combinators —Documentation Index
Fetch the complete documentation index at: https://mintlify.com/felipenugo/cantor-interpreter/llms.txt
Use this file to discover all available pages before exploring further.
comp, pair, compair, mu, and primrec — on top of seven built-in primitives.
Installation
Install Python dependencies and generate the ANTLR4 parser in minutes.
Quickstart
Write and run your first Cantor program with a working example.
Language Reference
Understand the grammar, combinators, imports, and extended mode.
Standard Library
Explore the seven built-in functions and Cantor pairing helpers.
What is the Cantor language?
The Cantor language is a minimalist, Turing-complete programming model where all computation is expressed as function composition over natural numbers. There are no variables, no loops, and no data structures — only functions that transform a single natural number into another. Multiple inputs are passed by encoding them with Cantor’s pairing function before execution begins. The language ships with five combinators:| Combinator | Description |
|---|---|
comp f g | Function composition: f(g(x)) |
pair f g | Returns the Cantor pair <f(x), g(x)> |
compair f g h | Shorthand for f(<g(x), h(x)>) — requires extended |
mu f | Minimization: first k where f(<x, k>) ≠ 0 |
primrec f g h | Primitive recursion from 0 to x — requires extended |
Install dependencies
Install Python 3.12, Java 11+, and the ANTLR runtime via
pip install -r requirements.txt.Run a program
Execute any
.cantor file: echo "3 2" | python3 cantor.py tests/programs/phase1-core/suma.cantorKey features
ANTLR4 Grammar
The full language is defined in a single
cantor.g4 grammar file, generating the lexer, parser, and visitor automatically.Cantor Pairing
Multi-argument functions are encoded via Cantor’s elegant bijection between ℕ² and ℕ.
Import System
Compose programs across multiple
.cantor files with the import directive.Test Suite
End-to-end tests using
.cantor + .inp + .out triples across six program phases.