---
title: Three nodes, eight states
searchTitle: A tri-cell IR for Song
description: 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.
date: 2026-11-26
tags: [language, verification, systems, ai]
---

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

:::tricell

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 [[codec|text codec]] over it.

The eight tokens are the [[combinator|combinators]] [[k-comb|K]], [[s-comb|S]], [[i-comb|I]] and [[iota|iota]], plus apply, [[commit-flush|commit and flush]] and blank.

| bits | token | name | effect |
|---|---|---|---|
| `000` | `Blank` | blank | no semantic effect |
| `001` | `K` | K | push K |
| `010` | `S` | S | push S |
| `011` | `;` | commit | copy one [[term]] to the [[tape]], clear the [[stack]] |
| `100` | `I` | identity | push I |
| `101` | `.` | apply | pop right then left, push their [[application|application]] |
| `110` | `i` | iota | push iota |
| `111` | `!` | flush | write 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](/evidence/song-tri-cell/speech.txt) gives "lower-case i, iota" for `i` and "capital I, identity" for `I`.

## The row is the programme

:::cellstream

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 [[normal-form|normalises]] to `S` in 11 reduction steps, and the [[certificate]] records each step.

| programme | cells | normal form | reduction steps |
|---|---:|---|---:|
| `ii.;!` | 5 | `S K (K K)` | 3 |
| `iiii...;!` | 9 | `K` | 9 |
| `iiiii....;!` | 11 | `S` | 11 |
| `iK.;!` | 5 | `S` | 2 |

A programme can compute a combinator without containing its [[glyph|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

:::datacost

The surface data language has no digits. A [[church-numeral|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](/evidence/song-tri-cell/h.iota) is 1,450 bytes. [[cancellation]] takes it to 303 term tokens and the cleaned programme still writes `H`; the [record](/evidence/song-tri-cell/cancel.txt) 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|Core]] layer has integers; the artefact stream has terms.

## The shape of the obligation

:::proofchain

The surface has eight tokens and eight transition cases: blank, four pushes, dot, commit and flush. The token decoder is a [[total-function|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|Lean]] [[refinement]] of the token and stream layer.

The [[native-code|native]] proof covers a different layer. It follows multiplication in the algebra's [[cell|Cell]] on the [[split-complex|σ = +1]] [[faces|face]], over [[word|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|Hardware correspondence]] and the [[calling-convention|C calling convention]] are assumptions.

The language has no [[pointer|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|verifier]] checks a candidate from an untrusted [[resolver|resolver]]; the [intent design](/evidence/song-intent/verifier.txt) records the boundary. It returns a [[witness]], and a wrong candidate fails the check.

## Direct compilation

:::compilechart

Song's [[compiler]] emits [[machine-code|machine code]] directly. It does not lower to the [[llvm|LLVM]] [[intermediate-language|IR]] and call an LLVM [[backend]]. The 100-function benchmark measured compile-and-[[linker|link]] latency: Song 5.8 ms, Rust 47.8 ms, Clang 52.6 ms, GCC 135.5 ms. Those are [[median|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 [[optimizer|optimisation]] work and produce different executables. This is latency for that workload. [[cranelift|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 [[compute-kernel|kernel]]) and a sparse [[matrix|matrix]]-vector multiply ([[spmv|spmv]], 447 kernel lines).

| programme | songc | rustc -O | rustc -O0 | gcc -O2 |
|---|---:|---:|---:|---:|
| l1 print | 74 | 225 | 196 | 113 |
| spmv | 139 | 668 | 392 | 319 |

The `-O` flag sets an optimisation level: `-O0` turns optimisation off, and `-O2` is GCC's usual optimisation level. The table reports [[wall-user-time|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|object emission]]; the [[front-end|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|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|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 [[type|typed]] expression IR ([source](/evidence/nurun-scalar-ir/ir.md)): `Int`, `Bool`, `Cell` and `Face`, with `let`, `if`, application and [[checked-arithmetic|checked]] 64-bit arithmetic. The [[evaluator]] returns a typed [[fault]] on overflow, division by zero, a [[shift|shift]] outside its range, an invalid face, a missing [[channel|channel]], or an exhausted [[fuel]] or depth budget. The front end is untrusted; the evaluator over the checked programme is the [[extraction|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).

:::nurun

The compiled Nurun kernel measured here is a [[q8-0|Q8_0]] output head, and it comes from its own [[tensor|Tensor]] IR. The [[scalar|scalar]] IR above has no [[floating-point|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|Apeiron]]'s head directly; B wraps that head in Nurun's [[computation-graph|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](/evidence/nurun-q8-head/method-note.txt)). 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 tri-cell table, the stream transition and the term operations are in [token.core](/evidence/song-tri-cell/token.core), [stream.core](/evidence/song-tri-cell/stream.core) and [term.core](/evidence/song-tri-cell/term.core).
- The certificates for the terms in `ii.;!`, `iiii...;!`, `iiiii....;!` and `iK.;!` are [identity.cert](/evidence/song-tri-cell/identity.cert), [k.cert](/evidence/song-tri-cell/k.cert), [s.cert](/evidence/song-tri-cell/s.cert) and [ik.cert](/evidence/song-tri-cell/ik.cert). The certificate for `iiiii....` records 11 steps and verdict `EQUAL`.
- The numeral record is [h.iota](/evidence/song-tri-cell/h.iota), 1,450 bytes; [h-clean.iota](/evidence/song-tri-cell/h-clean.iota) is the cancelled 303-term-token form, and [cancel.txt](/evidence/song-tri-cell/cancel.txt) records the command. The manifest with hashes is [manifest.json](/evidence/song-tri-cell/manifest.json).
- The native proof, its instruction table and the 32-byte image are [song-cell-correct.lean](/evidence/research-results/song-cell-correct.lean), [song-cell-program.lean](/evidence/research-results/song-cell-program.lean) and [song-cell-mul.hex](/evidence/research-results/song-cell-mul.hex).
- The 100-function compile benchmark is [results.json](/evidence/song-gen2-compile/results.json) with [method.txt](/evidence/song-gen2-compile/method.txt). The l1, spmv, phase-split, programme-scale and self-compile figures are in [compile-time.json](/evidence/song-compile-time/compile-time.json) with [method.txt](/evidence/song-compile-time/method.txt). The two snapshots used different compiler versions; the gen2 method does not name its host.
- The Nurun Q8_0 head receipt is [receipt.md](/evidence/nurun-q8-head/receipt.md) and [receipt.json](/evidence/nurun-q8-head/receipt.json); [method-note.txt](/evidence/nurun-q8-head/method-note.txt) records the arm definitions, the conversion and the bytes read per call.
- Nurun's scalar IR, its types and its fault list are in [ir.md](/evidence/nurun-scalar-ir/ir.md), copied from `nurun/docs/ir.md`; the [manifest](/evidence/nurun-scalar-ir/manifest.json) records the revision and hash.
- Song's verifier, resolver and witness path is quoted in [verifier.txt](/evidence/song-intent/verifier.txt), from `song/docs/ROADMAP.md` at revision `7be43b5`; the [manifest](/evidence/song-intent/manifest.json) records the hash.
- The speech record is [speech.txt](/evidence/song-tri-cell/speech.txt).

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