Writing / Repost
Three nodes, eight states
A tri-cell instruction format for Song, and the typed IR that carries the same algebra.
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.
A refreshable braille display or a three-actuator keyer can carry the column, and the code can be learned by touch. Literary braille uses six or eight dots in a rectangle. 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.
| 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 |
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 gives "lower-case i, iota" for i and "capital I, identity" for I.
The row is the programme
The stream is postfix. The row has no brackets and no names.
The programme iiiii....;! is 11 cells; in bits it is 110 110 110 110 110 101 101 101 101 011 111. Five iotas and four dots build the term i i i i i . . . ., which normalises to S in 11 reduction steps; commit copies the term to the tape, flush writes it, 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. 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
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
| layer | object | status | what it covers | source |
|---|---|---|---|---|
| surface | three bits | tested | eight-entry total table | token.core |
| surface | token row | tested | push, apply, commit, flush | stream.core |
| surface | term | certificate | reduction produces a certificate | term.core |
| surface | normal form | certificate | checker replays every step | s.cert |
| Native, first multiplication | operation | proved | Cell product | song-cell-correct.lean |
| native, first multiplication | ten steps | proved | X86-64 code | song-cell-program.lean |
| native, first multiplication | bytes | proved | 32 encoded bytes | song-cell-mul.hex |
| native, first multiplication | decoder and step | proved | stated x86-64 semantics | song-cell-correct.lean |
| native, first multiplication | hardware and convention | assumption | Hardware correspondence and the C calling convention | none |
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 that fixed list; a general-purpose parser has no such list.
The surface chain 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. 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.
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
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).
| 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 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).
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 Intel Core i5-10210U with four threads, 165,306,368 bytes read per call.
| ratio | range of five pairs | median | resolves |
|---|---|---|---|
| B/A | 0.946 to 1.069 | 1.021 | no |
| C/B | 0.895 to 0.938 | 0.928 | yes |
| C/A | 0.883 to 0.956 | 0.948 | yes |
| Cmap/C | 0.992 to 1.011 | 1.002 | no |
A calls Apeiron's head directly (7.377 ms); B wraps that head in Nurun's graph (7.697 ms); C runs the same graph over C code emitted by Nurun (7.053 ms); Cmap calls that C without the graph (7.127 ms). B/A measures the graph and the output conversion. 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). 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, stream.core and term.core.
- The certificates for the terms in
ii.;!,iiii...;!,iiiii....;!andiK.;!are identity.cert, k.cert, s.cert and ik.cert. The certificate foriiiii....records 11 steps and verdictEQUAL. - The numeral record is h.iota, 1,450 bytes; h-clean.iota is the cancelled 303-term-token form, and cancel.txt records the command. The manifest with hashes is manifest.json.
- The native proof, its instruction table and the 32-byte image are song-cell-correct.lean, song-cell-program.lean and song-cell-mul.hex.
- The 100-function compile benchmark is results.json with method.txt. The l1, spmv, phase-split, programme-scale and self-compile figures are in compile-time.json with 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 and receipt.json; 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, copied from
nurun/docs/ir.md; the manifest records the revision and hash. - Song's verifier, resolver and witness path is quoted in verifier.txt, from
song/docs/ROADMAP.mdat revision7be43b5; the manifest records the hash. - The speech record is speech.txt.
The accessibility claim covers the encoding and the speech transcript, not a blind participant session or tactile hardware.