R7N Lens Flash

Docs · Looking something up

Reference

The commands, the formats and the contracts, for when you know what you are looking for.

The full documents (README.md, AGENTS.md and docs/) are in the source download.

Commands#

These are the ones you will use most. flash help VERB explains one, and flash help all lists every one.

The project

flash start
get Lean if needed, make or find a project, build it, set flash up
flash start --lean
the same, with a plain Lean project instead of Mathlib
flash start --yes
the same, without asking first (for scripts)
flash init
set flash up in a Lean project you have already built
flash which
the pin this directory uses, and the rule that chose it
flash doctor
check the installation and the route, each problem with its fix
flash config
every setting, its value and where it came from
flash config set KEY VALUE
change one setting, in flash.toml
flash pin refresh NAME
set the pin up again after lake update or a new toolchain

Checking and proving

flash check FILE
Lean’s messages; exit 0 when the file has no error
flash check --exact FILE
against exactly the file’s imports
flash prove FILE
proofs for the file’s sorries, in order
flash prove FILE --write
and write them into the file
flash prove FILE --decl NAME
one declaration
flash prove --engine c
the C search alone (8.x’s flash search)
flash search FILE
in 9.0.x, flash prove’s alias

Looking before you write

flash twins FILE
the declarations of FILE that already exist, under any name
flash find WORDS
declarations by name
flash type NAME
a declaration’s statement
flash suggest FILE
the lemmas that apply at the file’s first open sorry
flash why FILE LEMMA
where LEMMA stopped on that goal
flash resolve NAME
where a declaration lives, its state, the import that brings it

Claims

flash frontier
the open claims, the most rested-on first
flash frontier --take --as ID
lease the first free open claim for ten minutes
flash frontier --release NAME
give it back
flash frontier --refresh
re-check stale files, one at a time
flash frontier --retire NAME --why TEXT
retire a claim whose file stays
flash watch NAME --until STATE
wait until a claim reaches a state

The solution interface

flash si FILE.lean
each claim as the kernel holds it
flash si FILE.lean --to text
the text layer; --to latex and --to lean likewise
flash si --project -o si/
every file of the project, one document a module

The installation

flash status
the project’s Lean workers, as one JSON line
flash down
stop every process of the pin, and verify it
flash self list
the installed releases (self use V, self update, self gc)
flash metrics
measure checks, searches and twins on this machine
flash help agents
how an AI agent should use flash

The judged line#

r7n is a second kernel, built into flash. For each theorem it judges the argument as a composition: the proof term, with every constant it uses taken as given and typed by that constant’s own statement. Its verdict is the judged line of the solution interface.

It runs by itself: once a module of a project checks clean, r7n judges its proofs in the background, and flash frontier counts the verdicts beside the claims. interface.judge = "off" turns this off, and flash si --no-judge leaves the line out of a .si. Lean stays the authority: no verdict changes a claim’s state.

VerdictWhat it means
composedr7n accepts the proof as a composition of the statements it uses, Lean checks it without unfolding a definition (instances and reducible ones aside), and no auxiliary declaration of the claim’s own carries part of it. An open claim composes through sorryAx.
computation · WHEREThe argument needs a step Lean takes by computation: unfolding a definition, a recursor, a literal. WHERE says at what: the statement, a constant’s type, the proof against its statement, or a step of the proof.
none · WHYThe argument could not be judged. Either it does not fit r7n’s fixed capacities (64 postulates in one context, 128 uses in one judgment, 64 KiB of postulate types, 512 levels of term depth), or part of it lives in an auxiliary declaration made by elaboration.

The .si format and layers#

A .si is plain text: a header, then one block per declaration. A claim is shown only in a text that, elaborated again in the same environment and in a fresh scope, gives a term with the declaration’s own identity.

The header

LineWhat it holds
si 1the format
@module Mthe module of the source
@import A Bthe source’s imports
@pin Pthe setup the claims were rendered in
@goal TEXTwhat the work is for, written by people and kept

A block

A block starts with claim NAME, def NAME, axiom NAME, type NAME, decl NAME or gone NAME, followed by key lines:

KeyWhat it holds
idthe identity of the statement, 64 hex digits
stateproved, open, reduced to A · B, error or defined
twinthe index holds the same statement under this name
for · assume · givena data binder, a hypothesis, an instance binder
show · is · valuethe conclusion; a definition’s type and value
rests · usesthe project’s theorems the proof uses; the library’s
axiomsthe axioms it depends on, or none; sorryAx means still open
judgedr7n’s verdict on the argument
notewhat elaboration chose that the display can hide: truncated subtraction and division on ℕ, a coercion and its types, a numeral’s type, an auto-bound implicit, an instance synthesis would not find
renderthe rung whose text came back, or none
because · tried · belief · decidenotes written by people, kept by identity
stalethe statement changed since the notes were written

The render ladder

flash tries each rung in turn, from the most readable form to the most explicit, and stops at the first whose text comes back as the same term:

RungThe text
1Lean’s ordinary display
2with Lean’s own analysis of what must be explicit to elaborate back
3with the types of coercions and numerals
4without notation
5with every implicit argument
6with everything: implicit arguments, instances, coercions, universes

A claim no rung brings back is reported as render none, and its statement is not shown.

The four layers

LayerCommandWhat it is
.siflash si FILE.lean -o FILE.sithe format above
textflash si FILE.lean --to textfor a terminal: each claim’s state first, the statement as hypotheses over ⊢
LaTeXflash si FILE.si --to latex -o FILE.texa standalone document, for lualatex or xelatex
Leanflash si FILE.si --to lean -o FILE.leaneach claim declared again, proofs left as sorry

Without --to, the extension of -o names the layer, and without either, interface.default does. The Lean that --to lean writes is checked: a claim that does not come back is named, and the exit status is 1. Lean to .si to Lean is a fixed point: the second .si and the second Lean equal the third, byte for byte.

For AI agents#

flash help agents prints the contract for an AI agent proving theorems in a Lean 4 project.

start
flash which          # the pin this directory uses, and the rule that chose it
flash init           # if the rule is not the project's workspace or its .flash-pin (once)
flash help agents    # the contract, and this project's section

What an agent can rely on

  • "proved": true means Lean checked it: no error, no sorry, only the standard axioms, and not using the goal itself. Nothing else is a proof.
  • "reason": "reduced" is not a proof. The goal follows from the lemmas in "reduced_to", which still have a sorry. Report it that way.
  • Checking is cheap once a worker holds a file’s imports, and a source checked before is answered from memory ("memo": true). Check after every edit rather than reasoning about whether it will compile.
  • flash builds whatever a file imports that has no current build, so do not run lake build while you work, and do not run lake update or change the toolchain.

The loop

  1. Look before you write: flash twins FILE, flash find WORDS, flash type NAME, flash resolve NAME.
  2. State the theorem and the lemmas it needs, each with sorry, above it or in modules it imports.
  3. Check with flash check FILE --json, and fix errors before proving.
  4. Prove with flash prove FILE --json, which prints one JSON object a declaration; --write puts the proofs in.
  5. Act on each reason (Reading a result →). With several agents, take lemmas with flash frontier --take --as ID --json.
  6. Repeat until flash check FILE shows sorries 0.

Exit statuses#

Command0123
flash check FILE or DIRno errorserrorscould not check
flash prove FILE --decl NAMEproveda goal openrefuseda goal refuted
flash prove FILEnothing left opena goal openrefuseda goal refuted
flash frontier --taketook onenothing free to takeerror
flash watch NAMEthe state changedthe timeout passederror
flash resolve NAMEknownnot known hereerror
flash sievery claim showna claim not shown, or Lean written that did not come backerror

JSON#

flash check FILE --json prints one object; flash check DIR --json one a line, as {"file": PATH, "result": …}.
FieldWhat it holds
oktrue when the file has no error
sorrieshow many declarations use sorry
messagesLean’s messages: pos ([line, column]), severity, text
declseach declaration: name, kind, axioms (with sorryAx among them, still open)
memotrue when the answer was remembered
environmentthe pin, the imports, the libraries and their builds
flash prove FILE --json prints one object; the summary goes to standard error.
FieldWhat it holds
goalseach sorry: decl, pos, kind, goal as Lean prints it, verdict (proved, reduced, refuted, open), by, text (what replaces the sorry), rests, counterexample, extract, tried (each tactic: by, ok, ms, cause, error)
declseach declaration: name, verdict, goals, closed, axioms (from the re-check)
filledthe source with every checked closure in place (what --write writes)
changedwhether filled differs from the file
errors_before, errors_afterthe file’s errors before and after the closures were written in
portfolio, jobs, heartbeats, wall_mswhat ran: the tactics in order, threads, each run’s caps

The C search alone (flash prove --engine c) has its own JSON, 8.x’s flash search JSON.

The other commands with --json
CommandPrints
flash frontier --jsonpin, the four counts, judged (r7n’s counts), frontier (each with name, where, rests_on_it, and leased_by when taken) and reduced_claims (each with reduced_to)
flash frontier --take --as ID --jsontake: name, where, by, until, rests_on_it
flash resolve NAME --jsonname, found, state, module, where, import
flash watch NAME --jsonname, from, to, where, when the state changes
flash twins FILE --jsonschema flash-twins/1: each declaration with its identity, statement and twins
flash si FILE.lean --jsoneach claim as the worker answered it