The console language
alon
alon is the language this site speaks. It is deliberately small - numbers, strings, lists, records, functions, and a pipeline operator - because it is not trying to be a general purpose language. What it adds instead is a set of first-class values that the rest of QHoTT already deals in: circuits, claims, unitaries, verification reports, type theory developments and registrable artifacts.
Everything below runs in your browser. The interpreter calls the same verifier that Verify uses and the same kernel that Explorer uses; there is no second implementation that could disagree with them.
New to the subject matter? Start Here explains what a circuit and a proof are before the syntax matters.
The shape of a program
The pipeline operator |> passes its left-hand value in as the first argument, which is why every builtin that works on a circuit, a report or an artifact takes it in that position. A long pipeline is split across lines by starting each continuation with |>.
circuit "ghz" {
qubits 3
h 0
cx 0 1
cx 1 2
}
|> verify([is_unitary(), prepares("000", "111")])
|> artifact("ghz-3")
|> digest()A circuit block holds the textual gate format verbatim, so anything that can be pasted into the verifier works here unchanged. A theory block holds type theory declarations and is checked against the prelude by the kernel.
let paths = theory "paths" {
def invRight : (A : Type) -> (x : A) -> (y : A) -> (p : Id A x y)
-> Id (Id A x x) (trans A x y x p (sym A x y p)) (refl A x)
:= \A x y p. J A x (\b q. Id (Id A x x) (trans A x b x q (sym A x b q)) (refl A x))
(refl (Id A x x) (refl A x)) y p
}
paths.ok
paths.axiomsRefutation is a result, not an error. A claim that fails comes back as a report whose verdict is refuted, carrying the first matrix entry that disagrees; a declaration the kernel rejects is reported with the kernel's own reason and the declarations after it are still checked.
prelude()
|> filter(fn (d) -> len(d.axioms) > 0)
|> map(fn (d) -> d.name + " depends on " + join(d.axioms))
verify(bell, is_identity()).verdict # "refuted", with a witnessRun :syntax in the console for the full language reference, or help("verify") for any single builtin.
Values
Beyond the usual scalars and containers, alon has one value type per object the system produces. Each one answers to field access, and fields(v) lists what it responds to.
| Value | Produced by | Fields |
|---|---|---|
| circuit | circuit { }, parse_circuit, inverse, seq | name, qubits, gates, ops, source |
| claim | is_unitary, equals, prepares, and the rest | kind, label |
| unitary | matrix | qubits, dim, entries |
| report | verify | verdict, verified, checks, failures, qubits, gates, depth, tcount |
| theory | theory { }, check_theory, run_example | ok, checked, failed, names, axioms, declarations |
| term | nf | normal, type, source |
| artifact | artifact | label, kind, schema, verdict, verified, claims |
Builtins
The whole standard library. Every entry is a thin binding to the verifier, the kernel or the registry; none of them reimplements anything, which is the only reason a result in the console can be trusted to mean what the same result means elsewhere on this site.
core
Values, text and lists.
| print(value, ...) -> nil | Writes each argument to the console on its own line. |
| type(value) -> string | The name of a value's type. |
| str(value) -> string | Renders a value as text, the same way the console would. |
| show(value) -> string | A compact one-line rendering, useful inside messages. |
| num(string) -> number | Parses text as a number. |
| json(value) -> string | Serialises a value as indented JSON. |
| len(list | string | record) -> number | Number of items, characters or fields. |
| fields(value) -> list | The field names a value responds to. |
| range(count) | range(from, to) -> list | Whole numbers from `from` up to but not including `to`. |
| map(list, fn) -> list | Applies a function to every item. |
| filter(list, fn) -> list | Keeps the items for which the function is true. |
| fold(list, start, fn) -> value | Left fold: `fn(accumulator, item)` across the list. |
| all(list) -> bool | True when every item is truthy. |
| any(list) -> bool | True when at least one item is truthy. |
| count(list, value) -> number | How many items equal the given value. |
| join(list, separator) -> string | Concatenates the rendered items with a separator. |
| assert(condition, message?) -> bool | Raises an error when the condition is false; returns true otherwise. |
quantum
Clifford+T circuits, their exact semantics, and claims about them.
| parse_circuit(source, name?) -> circuit | Builds a circuit from the textual gate format, same as a circuit { } block. |
| gates() -> list | Every gate the verifier understands, with its arity and meaning. |
| max_qubits() -> number | The widest circuit the exact verifier will build a unitary for. |
| matrix(circuit) -> unitary | The circuit's unitary, computed exactly over Z[omega][1/sqrt(2)]. |
| state(circuit) -> list | The non-zero amplitudes of the state the circuit prepares from |0...0>. |
| probabilities(circuit) -> list | Measurement probabilities for every basis state, in index order. |
| inverse(circuit) -> circuit | The circuit reversed, with every gate replaced by its adjoint. |
| seq(circuit, circuit) -> circuit | Runs one circuit after another; both must have the same width. |
| depth(circuit) -> number | Circuit depth under greedy layering. |
| tcount(circuit) -> number | Number of T and T-dagger gates, the usual cost measure for fault tolerance. |
| source(circuit) -> string | The circuit back in textual form, ready to paste or store. |
| is_unitary() -> claim | Claims U-dagger U = I exactly. |
| is_identity() -> claim | Claims the circuit is semantically a no-op. |
| is_self_inverse() -> claim | Claims applying the circuit twice is the identity. |
| cancels_inverse() -> claim | Claims the gate-by-gate adjoint undoes the circuit. |
| is_classical() -> claim | Claims the unitary is a permutation matrix, so the circuit is a reversible Boolean function. |
| equals(circuit) -> claim | Claims this circuit denotes the same unitary as another, entry for entry. |
| equals_up_to_phase(circuit) -> claim | As equals, but allowing an unobservable global phase from the eight units omega^k. |
| commutes_with(circuit) -> claim | Claims the two circuits may be reordered without changing semantics. |
| prepares("00", "11") -> claim | Claims the circuit maps |0...0> to an equal superposition over the listed basis states. |
| verify(circuit, claims?) -> report | Decides each claim exactly and returns a report. Defaults to is_unitary(). |
| holds(report) -> bool | True when every claim in the report was discharged. |
theory
The Martin-Lof kernel: the prelude, normalisation, and checking new developments.
| prelude() -> list | Every name the standard library defines, with its type. |
| lookup(name) -> record | The declared type of a prelude name, and the axioms it leans on. |
| search(text) -> list | Prelude names whose name or type mentions the given text. |
| nf(term) -> term | Normalises a closed term against the prelude and reports its type. |
| type_of(term) -> string | The inferred type of a closed term, as the kernel prints it. |
| same(term, term) -> bool | True when two closed terms have the same normal form. |
| check_theory(source, label?) -> theory | Checks declarations written as text; the theory { } block is sugar for this. |
| examples() -> list | The worked developments shipped with the explorer. |
| example(id) -> record | One worked development, including its source and the point it makes. |
| run_example(id) -> theory | Checks a worked development with the kernel and returns the result. |
| kernel() -> record | What the kernel is, and what it deliberately is not. |
chain
Reproducible digests, and the Solana registry that anchors them.
| artifact(label, report | theory) -> artifact | Packages a verification result into the object the registry commits to. |
| digest(artifact) -> string | SHA-256 of the canonical payload: the 32 bytes the chain stores, as hex. |
| canonical(artifact) -> string | The exact JSON string that gets hashed: sorted keys, no loose whitespace. |
| hash(string) -> string | SHA-256 of arbitrary text, for checking a digest by hand. |
| registry() -> record | Where the registry lives, what it gates on, and which cluster is configured. |
| registration(artifact, uri?) -> record | The exact register_proof payload and the account the record would occupy. |
| record_address(artifact) -> string | The PDA a record derives from its digest, so duplicates are impossible. |
| explorer("address" | "tx", value) -> string | An explorer link on the configured cluster. |
| schemas() -> list | The artifact schema identifiers the digest format is versioned by. |
help
Finding your way around.
| help(name?) -> string | Lists the builtins, or explains one builtin or one group. |
| builtins() -> list | Every builtin name, as data. |
What alon is not
- There are no loops and no recursion through
let, because a console that can hang the page is a worse console. Iteration ismap,filterandfoldover finite lists. - There is no mutation. A binding can be shadowed by a later
let, but no value is ever changed in place, so a report printed earlier still says what it said. - Nothing is submitted to a chain.
registrationreturns the exact payload and the account the record would occupy; signing needs a wallet holding the gating mint, which lives on Registry. - The language has no type system of its own. Errors are reported when a builtin is handed the wrong kind of value, naming the argument and what it expected.