LRW

Writing

Three nodes, eight states

Song's executable object is a row of three-node columns. Eight tokens cover application, commit and flush; Nurun's typed expression IR carries the same algebra.

9 min readCopy Markdown
  • language
  • verification
  • systems
  • ai

Song's executable object is a row of three-node columns, and eight states in a column name every token the machine runs. I built the format so the artefact itself can be read and edited without a screen: one column is one token, a bump is 1, a flat node is 0.

top 1, middle 0, bottom 1: apply; pop right then left, push their application

bits
101
token
.
name
apply
effect
pop right then left, push their application
With JavaScript, click a node to flip it; without it, the column shows 101, apply. Literary braille uses six or eight dots in a rectangle. Table source.

A refreshable braille display or a three-actuator keyer can carry the column, and the code can be learned by touch. The tri-cell is a different code with three nodes. The artefact is the editable object; text is a text codec over it.

The eight tokens are the combinators K, S, I and iota, plus apply, commit and flush and blank.

bitstokennameeffect
000Blankblankno semantic effect
001KKpush K
010SSpush S
011;commitcopy one term to the tape, clear the stack
100Iidentitypush I
101.applypop right then left, push their application
110iiotapush iota
111!flushwrite the tape, clear it

Blank is a real token. It occupies a cell and does nothing, so a row can be padded and edited without changing the programme. The codec is case-sensitive because i and I are different tokens; the speech record gives "lower-case i, iota" for i and "capital I, identity" for I.

The row is the programme

programmeiiiii....;!
stack, top at right
empty
output tape
empty

Cell 10: flush. The tape held 1 term; it is written and cleared.

committed term
i i i i i . . . .
normal form
S
reduction steps
11
With JavaScript, click a cell or drag the slider to run the row one token at a time; without it, the figure shows the completed row. Stack terms are shown as token rows with the top at the right; the tape holds committed terms. The certificate for this row is s.cert.

The stream is postfix. The row has no brackets and no names.

The programme iiiii....;! is 11 cells. Five iotas and four dots build one term. It normalises to S in 11 reduction steps, and the certificate records each step.

programmecellsnormal formreduction steps
ii.;!5S K (K K)3
iiii...;!9K9
iiiii....;!11S11
iK.;!5S2

A programme can compute a combinator without containing its glyph. ii.;! behaves as the identity function: S K (K K) applied to any argument returns that argument. The token table still has an I token; the certificate's normal form is S K (K K).

Short commands, long data

programme term iiiii....
9
numeral 72, before cancellation
723
numeral 72, after cancellation
303
h.iota
1,450 bytes
before
723 term tokens
after
303 term tokens
saved
420 term tokens, 58.09%
Bar length is term tokens; commit and flush are excluded. The programme term is gold, the cancelled numeral is red, and the source programme is 11 cells. h.iota, h-clean.iota and the cancellation record.

The surface data language has no digits. A Church numeral n is a function that applies another function n times. The numeral for 72, the byte value of H, is 723 term tokens; its text file is 1,450 bytes. Cancellation takes it to 303 term tokens and the cleaned programme still writes H; the record gives the command and both hashes. A number's term grows with its value, so a practical programme needs a compact encoding in the surface language or integers at a lower layer: the Core layer has integers; the artefact stream has terms.

The shape of the obligation

Surface

  1. three bitseight-entry total tabletoken.core
  2. token rowpush, apply, commit, flushstream.core
  3. termreduction produces a certificateterm.core
  4. normal formchecker replays every steps.cert

Native, first multiplication

  1. operationcell productsong-cell-correct.lean
  2. ten stepsx86-64 codesong-cell-program.lean
  3. bytes32 encoded bytessong-cell-mul.hex
  4. decoder and stepstated x86-64 semanticssong-cell-correct.lean
  5. hardware and conventionsilicon matches the model
testedcertificateprovedassumption
Boxes run left to right. Bone: tested definitions. Gold: a certificate the checker replays. Red: a Lean theorem. Dashed: an assumption. Surface sources are token.core, stream.core, term.core and s.cert. Native sources are song-cell-correct.lean, song-cell-program.lean and song-cell-mul.hex.

The surface has eight tokens and eight transition cases: blank, four pushes, dot, commit and flush. The token decoder is a total function on three bits: all eight values map to a token. A proof about this layer has eight transition cases; a general-purpose parser has no such fixed list.

The table and transition are Core definitions, and the certificate checker replays term reductions. The surface chain is tested and replayable; it is not a Lean refinement of the token and stream layer.

The native proof covers a different layer. It follows multiplication in the algebra's Cell on the σ = +1 face, over 64-bit words where overflow wraps, through ten x86-64 instructions and 32 encoded bytes. This is a pair of numbers, not the three-bit tri-cell. mulBody_correct covers every combination of four 64-bit inputs and the return slot in the stated machine model; mulBody_cellMul names the result, and mulBody_preserves_memory shows the ten transitions leave data memory unchanged. Hardware correspondence and the C calling convention are assumptions.

The language has no pointers and no allocation operator, so a token cannot name memory. Its state is a stack of terms and a tape. The memory result covers one operation in one model; it does not connect a cell row to a running programme or prove operating-system isolation.

One format for a model

A model can emit a row that fails a transition or one that runs and computes the wrong answer. i.;! fails at cell 1. i pushes iota, then . needs two terms and finds one; stream-step returns StackUnderflow(1, 1). The other errors are CommitArity(index, count) and StreamDeep(index, depth). Each error carries the cell index and the count or depth that failed.

The cell stream is the canonical object, and speech and braille are renderers. A model can emit cells, or text that decodes to cells. A row still has to apply only where two terms are on the stack, and commit only where one is.

Song's verifier checks a candidate from an untrusted resolver; the intent design records the boundary. It returns a witness, and a wrong candidate fails the check.

Direct compilation

050100140 ms Song 5.8 Rust 47.8 Clang 52.6 GCC 135.5
date
4 October 2026
samples
seven interleaved, one warm-up
workload
100 arithmetic functions, three calls
timing
process launch to executable, link included
Horizontal length is wall milliseconds; the axis is linear and the Song bar is gold. Measurements and method.

Song's compiler emits machine code directly. It does not lower to the LLVM IR and call an LLVM backend. The 100-function benchmark measured compile-and-link latency: Song 5.8 ms, Rust 47.8 ms, Clang 52.6 ms, GCC 135.5 ms. Those are medians of seven interleaved samples.

The workload has no proof obligations. The archived gen2 Song compiler, not a compiler for the cell stream, is compared with GCC 16.2.1, Clang 23.1.1 and rustc 1.97.0-nightly; the compilers do different optimisation work and produce different executables. This is latency for that workload. Cranelift is not measured.

The l1 and spmv snapshot used GCC 15.2.0 and rustc 1.99.0-nightly on an Intel Core i5-10210U, with no Clang and an unrelated Python analysis using about half a core. The programmes are a print programme (l1, with a 423-line kernel) and a sparse matrix-vector multiply (spmv, 447 kernel lines).

programmesongcrustc -Orustc -O0gcc -O2
l1 print74225196113
spmv139668392319

The -O flag sets an optimisation level: -O0 turns optimisation off, and -O2 is GCC's usual optimisation level. The table reports wall milliseconds from source to executable. The songc and rustc -O columns are medians of seven paired alternating runs; the other columns are medians of five to twenty runs. Songc does no optimisation, so rustc -O0 is the closer output-quality arm. The rustc -O gap is 3.0x on l1 and 4.8x on spmv; the rustc -O0 gap is 2.6x and 2.8x. GCC is a C compiler with its own backend; it is a baseline, not the LLVM path.

A phase-split rustc run on hello and spmv puts the LLVM share at 10 ms of a 201 ms hello compile and 258 ms of a 604 ms spmv compile. On hello, the 10 ms is object emission; the front end and the external link are separate costs. On spmv, the front end matched the LLVM share. Removing the LLVM layer removes that share; the front end and the link remain.

At compiler scale, songc self-compiled 20,440 lines in 57.6 s wall and 53.5 s user, the median of six runs; wall times ranged from 39.4 to 68.0 s. Cargo built Song's 22,622-line Rust implementation in 81.3 s wall and 75.2 s user with -j1 -C codegen-units=1, which serialises the build to one thread. The default parallel build took 39.7 s wall and 132.0 s user. Single-threaded, songc is 1.4x faster in wall and CPU time; the parallel rustc build is 1.45x faster in wall time and spends 2.5x the CPU. The programmes differ, so this is a scale indicator. programs/lang/host_laws.slang, 453 lines, took 24.8 s in raw songc, so compile time also varies with the programme.

The compile-time number I care about is the law check, because it runs on every build. In gen2, song build, which includes the law check, took 1.93 s on l1 and 2.02 s on spmv for 38 laws over two files, 26 times the raw songc time on l1.

A direct compiler has fewer layers between source and bytes, but the proof still has to cover the code generator. LLVM has its own correctness work and a larger optimiser. The fixed instruction sequence here is small enough to state its effect as a theorem.

A typed IR in a renderer

Nurun is a graphics project. Its programmable layer is a typed expression IR (source): Int, Bool, Cell and Face, with let, if, application and checked 64-bit arithmetic. The evaluator returns a typed fault on overflow, division by zero, a shift outside its range, an invalid face, a missing channel, or an exhausted fuel or depth budget. The front end is untrusted; the evaluator over the checked programme is the extraction target.

The type checker runs before evaluation. A model can emit a small expression; the checker rejects one that does not type; the evaluator returns a checked fault instead of silently wrapping the result or aborting the process. The tri-cell stream has no types and no arithmetic. Nurun and Song share the algebra: Cell is the same pair construction, and Face is the same three-way sign (negative, zero or positive).

0.870.900.951.001.051.08 1.0 B/A 1.021 C/B 0.928 C/A 0.948 Cmap/C 1.002
A
Apeiron head, 7.377 ms
B
Nurun graph, 7.697 ms
C
Nurun C, 7.053 ms
Cmap
C without graph, 7.127 ms
shape
Q8_0 output head, 151,936 × 1,024; 165,306,368 bytes read per call
host
Intel Core i5-10210U, four threads
Each row is the range of five paired ratios; the dot is the median and the number at right is its value. Bone rows cross 1.0, so the five pairs do not resolve the difference; gold rows sit clear of 1.0 on one side. The axis is linear. Receipt, raw rounds and method note.

The compiled Nurun kernel measured here is a Q8_0 output head, and it comes from its own Tensor IR. The scalar IR above has no floating-point type and no tensor type. The Tensor IR carries the matrix shapes and the operations; the weights are read from the model file. The head is 151,936 × 1,024, read on the laptop CPU with four threads.

A calls Apeiron's head directly; B wraps that head in Nurun's graph; C runs the same graph over C code emitted by Nurun; Cmap calls that C without the graph. B/A measures the graph and the output conversion: the five paired ratios range from 0.946 to 1.069, so the interval includes 1.0. B converts Apeiron's 64-bit integer output scores to 32-bit floating point inside the timed call, and C writes those floats directly, so part of C's lower time is the conversion B performs (method note). The five paired C/B ratios range from 0.895 to 0.938, so the interval excludes 1.0. B, C and Cmap each returned the reference's five highest-scoring outputs in their own top five at all 32 positions (160/160 slots). One head; the scheduler and the rest of the model are unmeasured.

Sources and limits

The accessibility claim covers the encoding and the speech transcript, not a blind participant session or tactile hardware.