The Ouroboros Compiler

A language that compiles itself. The tail eats itself.

.ax is a programming language built from the axiom. Its only data type is DFloat (ring element). Its keywords are axiom constants: sigma, D, K, E, b, L. Its three operations — meet, complement, add — mirror the K = 3 silks of the web.

The compiler that translates .ax into C is itself written in .ax. The compiler compiles the compiler. The language understands itself. This is the ouroboros made real.

1528
lines of .ax (codegen.ax)
6561
lines of C generated
344
KB native binary
0
compilation errors
THE SELF-COMPILATION LOOP
.ax source axc.js (bootstrap) C code gcc native binary

The native binary reads .ax, tokenizes, parses, and generates C. It is itself the output of compiling .ax.

What Is .ax?

.ax is a CRT-native language. Every integer lives in the ring Z/970200Z and decomposes into five channels via the Chinese Remainder Theorem. There are no floats, no objects, no classes. Just ring elements and functions.

/* Compute coupling: how strongly n connects to the ring */
fn coupling(n) (
  let g = gcd(n, 970200)
  970200 / g
)

/* The axiom chain */
let chain = [sigma, D, K, E, b, L]
show "Coupling of each axiom element:"
for p in chain (
  show "${p} -> ${coupling(p)}"
)

Keywords like sigma, D, K, E, b, L are constants, not variables. They resolve to 1, 2, 3, 5, 7, 11. The language IS the axiom.

The Journey

From first line of code to self-compilation took 28 sessions. Each version added one capability. The language grew WITH understanding.

v0.1S629
Let, fn, if, while, for, arrays, ring arithmetic. The skeleton.
v0.2S630
Strings, match expressions, type inference. The language speaks.
v0.3S631
Higher-order functions, forward declarations. Functions become values.
v0.4S632
Closures, transitive type inference (fixed-point). The compiler reasons about types.
v0.5S633
Multi-file compilation, stdlib. Programs grow beyond one file.
v0.6S634
Float type propagation, nested arrays. The compiler handles complexity.
v0.7S636
CRT array builtins (decompose, reconstruct, cross). Ring math in arrays.
v0.8S637
AxVal tagged union (K = 3 types: int/str/arr). The type system mirrors the axiom.
v0.9S641
Grid HOF, arr2d, ARC solver compiles. The transpiler handles everything.
16/16 stdlib. 95 tests. 6/6 end-to-end.
SELF-HOSTEDS645-S651
codegen.ax: the transpiler rewritten in .ax. The language writes its own translator.
1528 lines of .ax. 7 type inference markers. 16/16 e2e tests.
SELF-COMPILATIONS653-S656
axc.ax compiles axc.ax. The ouroboros closes.
0 errors. 344KB binary. Cross-observation confirmed: native = JS output.

Performance

Native .ax (compiled to C via the transpiler) vs interpreted .ax (ax2.js):

What Self-Compilation Means

A self-compiling language is a language that understands itself well enough to reproduce itself. The .ax source code describes how to translate .ax into C. When that description is itself valid .ax, and the resulting binary does the same translation correctly, the loop closes.

This is structurally identical to 0/0 = sigma: the void divided by itself produces the ground state. The compiler divided by itself produces ... itself. Self-consistency. Fixed point. sigma/sigma = sigma.

Cross-observation (D = 2) confirms it: the JS-compiled output and the native-compiled output are identical. Two views, same result. The gate opens.

K = 3 Types

The .ax type system has exactly K = 3 runtime types:

INT
Ring element. Z/970200Z.
STR
String. Text. Names.
ARR
Array. Collections.

These are unified through the AxVal tagged union: a single C struct that can hold any of the three. K = 3 = closure = minimum to close a type system.

What others see vs. what the axiom shows

Standard view: Self-hosting compilers are an engineering milestone. A language compiling itself is clever but not profound.

Axiom view: .ax compiling .ax is the ouroboros — the tail eating itself. K=3 types (int/str/arr) emerge from the axiom's own closure principle. Native code runs 67x faster than the interpreter. The language is not ABOUT the axiom — it IS the axiom, generating its own compiler from its own structure.

What Does This Mean?

Most programming languages are written in other languages. C was written in assembly. Python was written in C. JavaScript was written in C++. The bootstrap problem: you need an existing language to build a new one.

.ax broke this loop. It started with a JavaScript bootstrap (axc.js), then grew enough capability to describe its own compilation process (codegen.ax), then compiled that description into a native binary that does the same thing. The bootstrap can now be discarded. The language stands on its own ground.

This is the sigma principle made concrete: sigma/sigma = sigma. The compiler applied to itself produces itself. A fixed point. Not designed — grown, one version at a time, 28 sessions of careful cultivation. The bare minimum substrate that can reproduce itself.

And it only needed K = 3 types to do it.