[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"6QpgwgZVto":3},"# LangLib: Esoteric Programming Languages, Formally\n\nAn open-source library of the semantics of esoteric and fun programming\nlanguages, written in [Lean 4](https://lean-lang.org/).\n\nEsoteric languages are not meant for realistic software. They exist to make\na point, to win a bet, to parody a committee, or simply to be difficult.\nOver the last fifty years they have accumulated into a large body of design\nknowledge: single-instruction machines, programs that are string-rewriting\nrules, programs laid out on a grid that wraps at every edge, programs that\nencrypt themselves as they run. This knowledge is scattered across personal\npages, wikis, and long-dead FTP servers, and a good deal of it is folklore:\nclaims repeated confidently and checked by nobody.\n\nThis project archives that knowledge in a form that cannot rot. Every\nlanguage gets a written specification, an executable reference semantics,\nand machine-checked answers to the questions people actually argue about,\nstarting with what each language can compute. On top of that sits a\ncompiler from a language a human would willingly write in, whose\ncorrectness is proved rather than tested.\n\nFor each language, LangLib provides:\n\n* a **specification** in `docs/\u003Clangname>/`, summarising the language's\n  history, semantics, and quirks, with credits to its authors;\n* a **parser**, a **reference interpreter**, and a **standalone runner**\n  written in Lean, under `Langlib/Languages/\u003CLangname>/`;\n* **examples** you can run for fun, and a **test suite**, including\n  differential tests against non-Lean reference implementations where\n  available;\n* a **computational-class result**: a claim that the language is or is not\n  Turing complete, and a machine-checked proof of it;\n* where the language can host one — Turing complete, or, like Malbolge,\n  merely roomy enough — a **compiler from\n  [Turpentine](docs/turpentine/spec.md)** (`.turp`), the small readable\n  imperative language that sits on top of the collection. It is named for\n  the solvent: a [Turing tarpit](https://en.wikipedia.org/wiki/Turing_tarpit)\n  is a language where everything is possible and nothing is easy, and\n  turpentine dissolves tar. Two compilation schemes are possible, one\n  hand-written and one derived from the completeness proof, and the\n  library keeps both.\n\n## Languages\n\nCurrently implemented (see [docs/README.md](docs/README.md) for the full\nstatus matrix, including compilers):\n\n* [befunge93](docs/befunge93/spec.md) (Chris Pressey, 1993), a stack machine\n  whose pointer roams a wrapping grid\n* [brainfuck](docs/brainfuck/spec.md) (Urban Müller, 1993), eight\n  one-character commands on a tape of bytes\n* [brainloller](docs/brainloller/spec.md) (Lode Vandevenne, 2005),\n  brainfuck encoded in pixels\n* [deadfish](docs/deadfish/spec.md) (Jonathan Todd Skinner, 2006), four\n  commands, one accumulator, no loops\n* [fractran](docs/fractran/spec.md) (John Conway, 1987), whose programs are\n  lists of fractions\n* [javagen](docs/javagen/spec.md) (Radu Grigore's 2017 core; LangLib, 2026),\n  computation by subtype proof search\n* [malbolge](docs/malbolge/spec.md) (Ben Olmstead, 1998), designed to be as\n  hard to program as possible\n* [malbolge-unshackled](docs/malbolge-unshackled/spec.md) (Ørjan Johansen,\n  2007), Malbolge with the memory bound taken out, which is what makes it\n  Turing complete\n* [ook](docs/ook/spec.md) (David Morgan-Mar, 2001), brainfuck for orangutans\n* [piet](docs/piet/spec.md) (David Morgan-Mar, 2002), whose programs are\n  abstract paintings\n* [ski](docs/ski/spec.md) (Schönfinkel 1924, Curry 1930), not an esolang\n  but the combinator calculus underneath Unlambda, and the other half of\n  the library's functional route to universality\n* [subleq](docs/subleq/spec.md) (folklore, de-facto spec by\n  Oleg Mazonka), one instruction: subtract, branch if the result is ≤ 0\n* [thue](docs/thue/spec.md) (John Colagioia, 2000), whose programs are\n  string-rewriting rules\n* [Turpentine](docs/turpentine/spec.md): the library's own human-readable\n  front end, named for what dissolves a Turing tarpit\n* [unlambda](docs/unlambda/spec.md) (David Madore, 1999), a functional\n  language with no variables and no lambdas\n* [velato](docs/velato/spec.md) (Daniel Temkin, 2009), whose programs are\n  MIDI files: the pitches and their order are the code\n* [whitespace](docs/whitespace/spec.md) (Edwin Brady & Chris Morris, 2003),\n  where only spaces, tabs and newlines are code\n\n## Current status\n\n| Language | Turing-complete (TC) | TC claim mechanised | Turpentine compiler |\n|----------|--------------------------|------------------------------|---------------------|\n| [befunge93](docs/befunge93/spec.md) | [no with byte cells, yes with ours](docs/befunge93/spec.md#computational-class-and-why-our-deviations-matter) | **[yes](docs/befunge93/computability.md)**, for the byte core | [none: 2000 cells](docs/befunge93/compiler.md) |\n| [brainfuck](docs/brainfuck/spec.md) | yes | **[yes](docs/brainfuck/computability.md)** | [derived](Langlib/Languages/Turpentine/Compile/Derived.lean#L108) (certified), and [bespoke](docs/brainfuck/compiler.md) (trusted) |\n| [brainloller](docs/brainloller/spec.md) | yes, via brainfuck | **[yes](docs/brainloller/computability.md)**, bar the [pixel walk](docs/brainloller/computability.md) | [derived](Langlib/Languages/Turpentine/Compile/Derived.lean#L136) (certified), and [bespoke](docs/brainloller/compiler.md) (trusted) |\n| [deadfish](docs/deadfish/spec.md) | no, every program halts | **[yes](docs/deadfish/computability.md)** | [planned, output only](docs/deadfish/compiler.md) |\n| [fractran](docs/fractran/spec.md) | yes | **[yes](docs/fractran/computability.md)** | [derived](Langlib/Languages/Turpentine/Compile/Derived.lean#L113) (certified), and [bespoke](docs/fractran/compiler.md) (trusted) |\n| [javagen](docs/javagen/spec.md) | yes | **[yes](docs/javagen/computability.md)** | [derived](Langlib/Languages/Turpentine/Compile/Derived.lean#L96) (certified), and [bespoke](docs/javagen/compiler.md) (trusted) |\n| [malbolge](docs/malbolge/spec.md) | no, 59049 words | **[yes](docs/malbolge/computability.md)** | [bespoke](docs/malbolge/compiler.md) (trusted, input-free programs whose output fits); no derived one ever — not Turing complete |\n| [malbolge-unshackled](docs/malbolge-unshackled/spec.md) | yes | [open](docs/malbolge-unshackled/computability.md) | [bespoke](docs/malbolge-unshackled/compiler.md) (trusted, input-free fragment); no derived one while the TC claim is open |\n| [ook](docs/ook/spec.md) | yes, via brainfuck | **[yes](docs/ook/computability.md)** | [derived](Langlib/Languages/Turpentine/Compile/Derived.lean#L131) (certified), and [bespoke](docs/ook/compiler.md) (trusted) |\n| [piet](docs/piet/spec.md) | yes | **[yes](docs/piet/computability.md)** | [derived](Langlib/Languages/Turpentine/Compile/Derived.lean#L125) (certified), and [bespoke](docs/piet/compiler.md) (trusted) |\n| [ski](docs/ski/spec.md) | yes | **[yes](docs/ski/computability.md)** | [derived](Langlib/Languages/Turpentine/Compile/Derived.lean#L149) (certified); [bespoke: compile to unlambda instead](docs/ski/compiler.md) |\n| [subleq](docs/subleq/spec.md) | yes | **[yes](docs/subleq/computability.md)** | [derived](Langlib/Languages/Turpentine/Compile/Derived.lean#L104) (certified), and [bespoke](docs/subleq/compiler.md) ([certified on a fragment](docs/subleq/compiler.md)) |\n| [thue](docs/thue/spec.md) | yes | **[yes](docs/thue/computability.md)** | [derived](Langlib/Languages/Turpentine/Compile/Derived.lean#L119) (certified); [bespoke planned](docs/thue/compiler.md) |\n| [Turpentine](docs/turpentine/spec.md) | yes | open | [(it is the source)](docs/turpentine/spec.md) |\n| [unlambda](docs/unlambda/spec.md) | yes | **[yes](docs/unlambda/computability.md)** | [derived](Langlib/Languages/Turpentine/Compile/Derived.lean#L142) (certified), and [bespoke](docs/unlambda/compiler.md) (trusted) |\n| [velato](docs/velato/spec.md) | [yes, with unbounded ints](docs/velato/spec.md#computational-class) | **[yes](docs/velato/computability.md)** | [derived](Langlib/Languages/Turpentine/Compile/Derived.lean#L163) (certified), and [bespoke](docs/velato/compiler.md) ([certified on a fragment, behaviourally, input included](docs/velato/compiler.md)) |\n| [whitespace](docs/whitespace/spec.md) | yes | **[yes](docs/whitespace/computability.md)** | [derived](Langlib/Languages/Turpentine/Compile/Derived.lean#L100) (certified), and [bespoke](docs/whitespace/compiler.md) ([certified on a fragment, behaviourally](docs/whitespace/compiler.md)) |\n\n\n* **Turing-complete (TC)** states the computational-class claim;\n  **TC claim mechanised** says whether it has been proved here. Its links\n  lead to the language's `computability.md`; **open** means no proof yet.\n* **Derived** compilers come from completeness proofs and are certified.\n  They accept an I/O-free fragment whose result is stored in `answer`;\n  their generated programs are large.\n* **Bespoke** compilers are hand-written for each target, with compact output\n  and broader language support. Their links lead to `compiler.md`, which\n  describes the supported fragment, implementation and proofs.\n* **Trusted** means tested but unproved. **Certified on a fragment** means\n  correctness is proved for part of the accepted language.\n  **Behaviourally** additionally means preserving completed I/O traces;\n  **input included** means the proof covers runtime reads too.\n* **Planned** means the compiler is not implemented; **none** means no\n  backend is planned for that target.\n\nSee [the full status matrix](docs/README.md) for per-stage details and\n[verified compilers](#verified-compilers) below for the correctness contracts.\n\n## What a language is\n\nOne definition carries the whole library: running a program, proving a\ncompiler correct, and claiming a language is or is not Turing complete are\nall stated against it.\n\n**[`ProgLang L`](Langlib/Common/Compilation.lean#L96)** is what every\nlanguage here supplies.\n\n```lean\nclass ProgLang (L : Type) where\n  Prog  : Type                              -- abstract syntax\n  parse : String → Except String Prog\n  run   : Prog → Input → Nat → RunResult    -- program, input, fuel\n```\n\n`L` is an empty tag type that *names* the language rather than being its\nprogram type, so `Befunge93` and `BoundedByteBefunge93` can be two\nlanguages with two different answers.\n[`Input`](Langlib/Common/Io.lean#L79) and\n[`RunResult`](Langlib/Common/Io.lean#L329) are the shared\nexecution model: a byte stream with a read cursor, and the bytes a run\nemitted together with how it ended. The `Nat` is **fuel**, a step budget,\nwhich is what makes `run` a total function even of a program that never\nterminates — it returns `outOfFuel` instead of diverging.\n\n**[`LawfulProgLang L`](Langlib/Common/Compilation.lean#L125)** requires\nthat a completed run return the same result with any larger fuel budget.\nThis keeps fuel a step budget: once a correctness proof establishes a\nresult, every sufficiently large run produces it. All language instances\nsatisfy this law, which compiler certificates and `TuringComplete` require.\nBoth classes live in\n[`Langlib/Common/Compilation.lean`](Langlib/Common/Compilation.lean).\n\n## Computability\n\nEsoteric-language folklore is full of claims nobody has checked. Every\nlanguage here gets a claim about its computational class and a\nmachine-checked proof of it. Per-language status is in the\n[status matrix](docs/README.md), with detailed\n[computability accounts in each language’s documentation](docs/README.md#computability-accounts).\nEvery result is audited by\n[`scripts/axioms.lean`](scripts/axioms.lean), because a proof resting on\n`sorry` type-checks exactly like a real one.\n\n### The yardstick: the URM\n\nAn **unlimited register machine** (URM), as Shepherdson and Sturgis defined\nit: countably many registers holding natural numbers, and four instructions\n— zero a register, increment it, copy one register to another, and jump to\nan instruction when two registers hold the same value. That is enough to\ncompute every computable function, and small enough that simulating it\ninside a toy language is a day's work rather than a career.\n\nLangLib does not define it. It comes from\n[cslib](https://github.com/leanprover/cslib), Lean's library of\ncomputer-science formalisations, so the claims are phrased in a vocabulary\nother people already use: [`Instr` and `Program`][cslib-defs], the step\nrelation [`Step`][cslib-step], and [`HaltsWithResult`][cslib-halts], which\nsays a program run on an input vector halts with a given number in\nregister 0.\n\n[cslib-defs]: https://github.com/leanprover/cslib/blob/3951377e5a3f5772737f11cd62bc5bb6a72f95d1/Cslib/Computability/URM/Defs.lean#L44\n[cslib-step]: https://github.com/leanprover/cslib/blob/3951377e5a3f5772737f11cd62bc5bb6a72f95d1/Cslib/Computability/URM/Execution.lean#L59\n[cslib-halts]: https://github.com/leanprover/cslib/blob/3951377e5a3f5772737f11cd62bc5bb6a72f95d1/Cslib/Computability/URM/Execution.lean#L186\n\n[Our additions](Langlib/Computability/Common/URM.lean) are an *executable*\ninterpreter — [`step`](Langlib/Computability/Common/URM.lean#L61) and\n[`run`](Langlib/Computability/Common/URM.lean#L72) — which cslib's relational\nsemantics deliberately is not, plus the lemmas\n([`step_eq_some_iff_Step`](Langlib/Computability/Common/URM.lean#L111),\n[`steps_run`](Langlib/Computability/Common/URM.lean#L142),\n[`haltsWithResult_of_haltsIn`](Langlib/Computability/Common/URM.lean#L188)) tying\nthe two together, so differential tests can run a URM program while every\ntheorem is still stated against cslib's relation.\n\n### The computability claims\n\nThese live in\n[`Langlib/Common/Computability.lean`](Langlib/Common/Computability.lean),\nshared infrastructure rather than per-language files, so a claim means the\nsame thing for every language.\n\n**[`TuringComplete L`](Langlib/Common/Computability.lean#L115)** packages a\nrunnable URM compiler and output decoder. It compiles a program together\nwith its input vector into a closed target computation, run on `Input.empty`.\nIt requires\nanswer preservation for halting sources and `.outOfFuel` at every finite\ntarget budget for divergent sources.\n\nAll twelve witnesses satisfy both obligations. With interpreter lawfulness,\nthey give halting/result equivalence, valid outputs, and runtime-error\nfreedom. See [the proof routes](docs/divergence-preservation.md).\nThe URM input vector is embedded in the compiled artifact; the completeness\ncontract has no runtime input encoding parameter. [How input is represented](docs/certified-compilation.md#why-the-derived-contract-is-closed)\nexplains the derived and streaming cases.\n[`computes_of_turingComplete`](Langlib/Common/Computability.lean#L284)\nrelates the claim to cslib's URM-computable functions.\n\n**[`BoundedStorage L`](Langlib/Common/Computability.lean#L336)** is the\nnegative claim: a configuration type, a bound on it per program and input,\nan injection into `{0, …, bound - 1}`, and two laws saying the machine is\ndeterministic and that halting depends only on the configuration. From\nthose, [`halting_decidable`](Langlib/Common/Computability.lean#L495)\nfollows once and for all — a run that has not halted within `bound` steps\nhas repeated a configuration and never will. A language with this witness\nhas no *computable* `TuringComplete` witness: with an effective compiler,\n`TuringComplete.halts_iff` would reduce undecidable URM halting to decidable\ntarget halting. This is a meta-theorem rather than a Lean corollary because\nthe effectiveness of arbitrary Lean functions is not formalized here; see\n[the docstring](Langlib/Common/Computability.lean).\n\n**[`BoundedRun L`](Langlib/Common/Computability.lean#L368)** asks for the\nsame laws only where the pigeonhole argument uses them: at configurations a\nrun actually reaches. Every `BoundedStorage` gives one. It exists because a\nlanguage can have a state *type* that is wide (an unbounded array, an\noutput that grows, an input cursor whose range depends on the input) while\nits reachable states are few, which is exactly Malbolge's situation.\n\n[Befunge-93](docs/befunge93/spec.md) shows why this is worth doing. It is\nusually called incomplete because of its 80 by 25 playfield, but the real\nargument is that the reference implementation gives it byte-sized cells,\nmaking it a pushdown automaton — a stack machine, strictly weaker than a\nTuring machine. Our cells hold unbounded integers, so the language we\nimplement *is* complete. Same name, two languages, and nobody\nnoticed until the claim had to be written down precisely enough to prove.\n\n## Verified compilers\n\nTurpentine offers two compilation routes:\n\n* **Bespoke** backends produce compact code and support as much of\n  Turpentine as each target can host, including I/O where available.\n  They are the default. [Subleq](docs/subleq/compiler.md),\n  [Whitespace](docs/whitespace/compiler.md) and [Velato](docs/velato/compiler.md)\n  have correctness proofs for specific fragments; the matrix links to\n  each backend's documentation.\n* **Derived** backends compose the verified\n  [Turpentine-to-URM pass](Langlib/Languages/Turpentine/Compile/URM.lean)\n  with a target's `TuringComplete` witness. The composition is proved once\n  for every target. It produces large programs and accepts an I/O-free\n  fragment, so bespoke backends remain useful for practical execution and\n  broader source-language support.\n\n`compile` and `exec` accept `--bespoke` or `--tc` and report which scheme\nproduced the program.\n\n### Two notions of correct\n\n* **[`CertifiedCompilerNoIO`](Langlib/Common/Compilation.lean#L151)**\n  preserves the decoded answer of a closed computation. The target runs\n  on empty input. This is the derived compilers' contract.\n* **[`CertifiedCompiler`](Langlib/Common/Compilation.lean#L329)** also\n  preserves completed I/O traces under explicit input and trace encodings.\n  It quantifies over runtime input. [Whitespace](docs/whitespace/compiler.md)\n  satisfies it for an output-only fragment; [Velato](docs/velato/compiler.md)\n  covers reads too, on NUL-free input streams.\n\nBoth require **divergence preservation**: a divergent source computation\nexhausts every finite target fuel budget, without halting or failing.\n[`agree`](Langlib/Common/Compilation.lean#L181) shows that two closed\ncertificates for one target decode the same answer on computations both\naccept.\n\nSee [certified compilation](docs/certified-compilation.md) for the pipeline\nand fragment boundaries, and [verification](docs/verification.md) for the\nfull contracts and their relationship.\n\nTurpentine is deeply embedded in Lean and modelled on\n[Velvet](https://github.com/verse-lab/velvet). The longer-term plan is to\ncompile shallowly-embedded Velvet to Turpentine, and from there to any\nesolang here, by relational compilation.\n\n## Building\n\nInstall [elan](https://github.com/leanprover/elan), then:\n\n```\nlake build          # build the libraries and runners\nlake test           # run the test suite\n```\n\n## Running programs\n\nEach language ships a runner named after it. Programs read from stdin and\nwrite to stdout, so pipe or redirect input, and the result is printed to\nyour terminal. One example per language, with what you should see:\n\nBrainfuck says hello.\n\n```\nlake exe brainfuck Langlib/Examples/Brainfuck/hello.b\n```\n\nOutput:\n\n```\nHello World!\n```\n\nBrainfuck reverses a word, reading it from stdin.\n\n```\necho -n stressed | lake exe brainfuck --eof zero Langlib/Examples/Brainfuck/rev.b\n```\n\nOutput:\n\n```\ndesserts\n```\n\nErik Bosman's 505-byte brainfuck quine prints itself, so `diff` says nothing.\n\n```\nlake exe brainfuck Langlib/Examples/Brainfuck/quine.b | diff - Langlib/Examples/Brainfuck/quine.b\n```\n\nWhitespace says hello, using a program made entirely of spaces and tabs.\n\n```\nlake exe whitespace Langlib/Examples/Whitespace/hello.ws\n```\n\nOutput:\n\n```\nHello, World!\n```\n\nOok! says hello, because brainfuck was not quite unreadable enough.\n\n```\nlake exe ook Langlib/Examples/Ook/hello.ook\n```\n\nOutput:\n\n```\nHello World!\n```\n\nDeadfish prints the ASCII codes of a greeting, one number per line, since\nprinting letters is beyond it.\n\n```\nlake exe deadfish Langlib/Examples/Deadfish/hello.df\n```\n\nOutput:\n\n```\n72\n101\n108\n...\n```\n\nSubleq counts down on a machine with exactly one instruction.\n\n```\nlake exe subleq Langlib/Examples/Subleq/countdown.sq\n```\n\nOutput:\n\n```\n9876543210\n```\n\nFRACTRAN runs Conway's PRIMEGAME, which prints the primes as exponents of\ntwo. It has no halting condition, so cap it with `--fuel`.\n\n```\nlake exe fractran --n 2 --out pow2 --fuel 2000000 Langlib/Examples/Fractran/primegame.ft\n```\n\nOutput:\n\n```\n2\n3\n5\n7\n...\n```\n\nPiet says hi, using a program that is an abstract painting.\n\n```\nlake exe piet Langlib/Examples/Piet/hi.ppm\n```\n\nOutput:\n\n```\nHi\n```\n\nBrainloller runs a brainfuck program encoded as coloured pixels.\n\n```\nlake exe brainloller Langlib/Examples/Brainloller/hello.ppm\n```\n\nOutput:\n\n```\nHello World!\n```\n\nMalbolge prints the hello world that a search program found in 2000,\nbecause no human could write one. The capitalisation is not a typo.\n\n```\nlake exe malbolge Langlib/Examples/Malbolge/hello.mal\n```\n\nOutput:\n\n```\nHEllO WORld\n```\n\nMalbolge Unshackled runs a program nobody wrote: `compiled/primes.mu` is\nwhat the bespoke backend emits for a Turpentine source, checked into the\ntree and run here on Unshackled's own interpreter.\n\n```\nlake exe malbolge-unshackled --fuel 100000 Langlib/Examples/MalbolgeUnshackled/compiled/primes.mu\n```\n\nOutput:\n\n```\n2\n3\n5\n7\n11\n13\n17\n19\n23\n29\n```\n\nVelato greets the world. Its source is a MIDI file, or -- as here, so that a\nrepository can review it -- the same pitches written out as note names.\n\n```\nlake exe velato Langlib/Examples/Velato/hello.vel\n```\n\nOutput:\n\n```\nHello, World!\n```\n\nVelato shows what each note was doing, which is how you find out whether the\npiece you wrote says what you meant. This is velato.net's own worked\nexample, and the labels come from the parser rather than from a second guess\nat the grammar.\n\n```\nlake exe velato --notes Langlib/Examples/Velato/print-h.vel\n```\n\nOutput:\n\n```\n  #  note   role\n  1  C4     root\n  2  A4     cmd\n  3  G4     print\n  4  E4     value\n  5  F4     char\n  6  A4     7\n  7  D#4    2\n  8  G4     end num\n```\n\nVelato engraves a program as sheet music, and will also write it as a MIDI\nfile or synthesise it to audio; `scripts/velato-audio.sh` plays the result.\n\n```\nlake exe velato --sheet /tmp/primes.pdf Langlib/Examples/Velato/primes.vel\n```\n\nTurpentine, the readable front end, computes an integer square root.\n\n```\necho 17 | lake exe turpentine run Langlib/Examples/Turpentine/isqrt.turp\n```\n\nOutput:\n\n```\n4\n```\n\nTurpentine prints the primes up to 20, using the same trial division you would\nwrite in any language.\n\n```\necho 20 | lake exe turpentine run Langlib/Examples/Turpentine/primes.turp\n```\n\nOutput:\n\n```\n2\n3\n5\n7\n11\n13\n17\n19\n```\n\n### Compiling Turpentine\n\nTurpentine programs can be interpreted, compiled to an esolang, or\ncompiled and run in one step. Both compilers are available for each\ntarget: `--bespoke` (hand-written, whole language, compact, unverified) and\n`--tc` (derived from the target's Turing-completeness proof, correct\nby construction, larger, and restricted to an I/O-free fragment). Passing\nneither uses the bespoke one; passing both is an error.\n\nInterpret it.\n\n```\necho 17 | lake exe turpentine run Langlib/Examples/Turpentine/isqrt.turp\n```\n\nOutput:\n\n```\n4\n```\n\nCompile and run in one step, using the hand-written backend.\n\n```\necho 17 | lake exe turpentine exec --via whitespace --bespoke Langlib/Examples/Turpentine/isqrt.turp\n```\n\nOutput:\n\n```\n4\n```\n\nEmit the target program instead, and note that the message says which\ncompiler produced it.\n\n```\nlake exe turpentine compile --to subleq --bespoke -o /tmp/isqrt.sq Langlib/Examples/Turpentine/isqrt.turp\n```\n\nOutput:\n\n```\nturpentine: wrote 22615 bytes to /tmp/isqrt.sq [bespoke, hand-written and unverified]\n```\n\nThat file is an ordinary subleq program, so run it with subleq's own\nrunner.\n\n```\necho 17 | lake exe subleq /tmp/isqrt.sq\n```\n\nOutput:\n\n```\n4\n```\n\nOne target's compiled program is a *picture*. The Piet backend lays the\nprogram out as corridors of colour wired together with white, and emits a\nPPM.\n\n```\nlake exe turpentine compile --to piet --bespoke -o /tmp/tri.ppm Langlib/Examples/Turpentine/suite/triangle.turp\n```\n\nOutput:\n\n```\nturpentine: wrote 43779 bytes to /tmp/tri.ppm [bespoke, hand-written and unverified]\n```\n\nThat is an 88 x 42 codel image, and it runs like any other Piet program.\n\n```\nlake exe piet /tmp/tri.ppm\n```\n\nOutput:\n\n```\n*\n**\n***\n****\n*****\n```\n\nAnother target has no machine in it at all. The Unlambda backend turns a\nprogram into a *term*: a statement is a function from a state to the next\none, `while` is a fixed point, and the binders come out by bracket\nabstraction. A greeting is short enough to read.\n\n```\ncat Langlib/Examples/Unlambda/compiled/hello.unl\n```\n\nOutput (the program starts with three backquotes, so this block is fenced\nwith four):\n\n````\n# compiled by turpentine, bespoke backend to unlambda: 63 builtins.\n```s`k``s``s``s``s``s``s``s``s``s``s``s``s``s``s``s``s``s``s``s`k.H`k.e`k.l`k.l`k.o`k.,`k. `k.T`k.u`k.r`k.p`k.e`k.n`k.t`k.i`k.n`k.e`k.!`kri`kii\n````\n\nThat file is what `turpentine compile --to unlambda` emitted for\n`hello.turp`, and it runs on Unlambda's own interpreter.\n\n```\nlake exe unlambda Langlib/Examples/Unlambda/compiled/hello.unl\n```\n\nOutput:\n\n```\nHello, Turpentine!\n```\n\nThe certified compiler needs a program in its fragment: no I/O, no\nsubtraction, and the result left in a variable called `answer`. Arrays are\nin, since the dispatch-chain work landed.\n`sumsq.turp` is written that way, and sums the squares below 5.\n\n```\nlake exe turpentine exec --via whitespace --tc Langlib/Examples/Turpentine/sumsq.turp\n```\n\nOutput:\n\n```\n30\n```\n\nOutside that fragment it says which construct is the problem rather than\nemitting something it cannot justify.\n\n```\necho 17 | lake exe turpentine exec --via whitespace --tc Langlib/Examples/Turpentine/isqrt.turp\n```\n\nOutput:\n\n```\nturpentine exec: the certified URM fragment needs a variable named 'answer' to hold the answer: a URM has no output, so register 0 at halt is all there is\nturpentine: the certified compiler accepts only the I/O-free fragment\n  (no input or output, no subtraction, and the result in a\n  variable named 'answer'); arrays, division and modulo are\n  supported, and the message above names what was rejected.\nturpentine: retry with --bespoke to compile the whole language.\nturpentine: nothing was run\n```\n\nEvery mode, including emitting to stdout and what the two schemes cost, is\nin [certified-compilation.md](docs/certified-compilation.md).\n\nEvery runner accepts `--fuel N` (step budget), `--verbose` (report how the\nrun ended: halted, runtime error, or out of fuel), and `--help`. Exit codes:\n0 halted, 1 runtime error, 2 out of fuel, 3 parse or usage error. Example\nprograms state their own usage in a comment where the language permits one;\neach language's README under `Langlib/Languages/` has the full example\ninventory.\n\n## Documentation\n\n* [docs/README.md](docs/README.md): the status matrix, one row per\n  language, with computational class and compiler status.\n* [docs/PLAN.md](docs/PLAN.md): the staged workplan.\n* [docs/certified-compilation.md](docs/certified-compilation.md): verified\n  compilation via the URM, with dependency diagrams.\n* [docs/verification.md](docs/verification.md): what compiler correctness\n  means here and how the proofs factor.\n* [docs/conformance.md](docs/conformance.md): the conformance suite —\n  twenty programs, one expected output each, run on every language that\n  can host them, compiled *and* hand-written.\n* [docs/TESTING.md](docs/TESTING.md): the two test layers, and what to\n  install to run the differential tests.\n* [docs/ROADMAP.md](docs/ROADMAP.md): candidate languages.\n* [docs/RELATED.md](docs/RELATED.md): other people's formalisations.\n* [docs/PROGRESS.md](docs/PROGRESS.md): dated log, newest first.\n* Per language: `docs/\u003Clangname>/spec.md` and\n  `docs/\u003Clangname>/compiler.md`.\n\n## Contributing\n\nContributions of new languages, examples, tests, and proofs are welcome. See\n[CONTRIBUTING.md](CONTRIBUTING.md) for how to add a language and what the\nlibrary expects from a submission.\n\n## Miscellanea\n\nA survey of related efforts is in [docs/RELATED.md](docs/RELATED.md).\n\n## License\n\nLangLib is distributed under the Apache 2.0 license (see [LICENSE](LICENSE)).\nThe library only implements languages whose designs are in the public domain\nor otherwise freely implementable; all example programs are either original,\nin the public domain, or credited to their authors under permissive terms.\n",1789154820764]