Docs · Working in a project
Working in a project
How flash fits into a real project: setting it up, keeping proofs, working with imports, sharing the work between agents, changing a setting, and reading claims through the solution interface.
Setting up a project#
There are two ways in. flash start does everything for you: it gets Lean if you need it, makes a project or uses the one you are in, builds it, and sets flash up. In a Lean project you have already built, flash init does just the last part.
flash startflash initflash start prints its plan and asks once (Continue? [Y/n]) before it installs or downloads anything; flash start --yes goes ahead without asking, for scripts. Outside a project it makes one, my-proofs unless you name another with flash start NAME, with Lean 4.35.0 and Mathlib; flash start --lean makes a plain Lean project instead. Lean takes about 3 GB, in ~/.elan, and Mathlib’s prebuilt files about 7 GB, downloaded once; flash’s own store grows to 1 to 2.5 GB as you work. Have about 12 GB free.
Either way, flash makes the project’s pin: the setup it keeps for that project, with its toolchain, its index, its Lean workers and its store. The first time, it compiles its Lean side with the project’s toolchain and indexes Lean, your dependencies and your modules; each happens once per toolchain, and once per build of the dependencies. It writes .flash-pin, so that every command run in the project uses the pin. It needs no settings: flash runs fully without a flash.toml.
When it stops
| What it says | What to do |
|---|---|
flash start: notes already exists and is not a Lean project. Give a new folder: flash start NAME | A folder with that name is in the way. Name a new one: flash start NAME. |
flash start: cannot make a project in / (you cannot write there). Go to a folder of yours first (cd ~), or name one: flash start ~/my-proofs | You cannot write in the folder you are in. Go to one of yours (cd ~), or name a folder. |
flash: the Lean project /home/you/proofs is not set up for flash yet: run flash init there (or flash start, which also builds it) | Any command run in a Lean project before it is set up says this. Run flash init in the project, or flash start if it is not built yet. |
flash: nothing is set up here yet: run flash start to make a project with Mathlib, or flash init in a Lean project you have | Any command run before anything is set up, or outside a project, says this. Run flash start, or go into your project first. |
flash init: this project is not built yet. Run flash start here: it builds the project and sets it up (or lake build, then flash init) | Run flash start in the project. The same advice comes when Mathlib is not downloaded in the project yet, or Lean is not installed. |
flash start: neither curl nor wget is installed; install one of them (sudo apt install curl), then run flash start again | Lean’s installer needs one of them. Install curl, then run flash start again. |
Nothing was changed. | You answered no to the plan. Run flash start again when you are ready. |
lens-flash install: it needs curl or wget: install one (sudo apt install curl), then run this again | From the installer. Install curl, then run the install line again. |
lens-flash install: could not reach https://r7n.solutions/download: check your connection (or proxy) and try again | From the installer. Check your connection, or your proxy if you use one, then run the install line again. |
lens-flash install: there is no lens-flash-9.0.0-linux-x86_64.tar.gz at https://r7n.solutions/download | From the installer: the site does not have the release it asked for. Run the install line again, so you have the current installer, or download by hand from the Download page. |
install.sh: could not add /home/you/.local/bin to PATH in /home/you/.profile (not writable): add this line to your shell's startup file yourself: export PATH="/home/you/.local/bin:$PATH" | Not an error: flash is installed, but a startup file could not be changed. Add the line it gives to your shell’s startup file yourself, then open a new terminal. |
The messages people meet most often, and what to do, are on Get started →
When something changes
- After
lake updateor a change of toolchain,flash pin refresh NAMEsets the pin up again. flash whichshows the pin a directory uses and the rule that chose it.flash doctorchecks everything and says how to fix what is wrong.flash pin listlists the pins.
Which project a command belongs to
A command belongs to the nearest directory, at or above the file it works on, that holds a flash.toml, a lakefile.toml or a lakefile.lean. A command run from somewhere else takes the settings of the file it is given, not of the directory it runs in.
Writing proofs and imports#
flash prove FILE --write writes each proof it finds into the file, in place of its sorry, and --no-write only shows it. Without either flag, write.proofs decides: ask, the default, shows; auto writes. A written file is checked at once, so its claims become proved and whatever rests on them follows.
A proof is placed for its sorry. The hypothesis names are the file’s, only the tactic that worked is kept, and the whole file is checked with the proof in place before you see it. A proof is only placed in a declaration that has a single sorry.
With write.layout = compact a proof stays exactly as found. With explicit, the default, a top-level A <;> B is split over two lines wherever the file still checks with fewer warnings.
Imports, with no build step
- A module of your project that checks without errors (sorries allowed) is usable from every other file, and by every search, as soon as it checks.
- Before a check or a search, flash builds each of your modules the file imports that has no current build, and tells you:
flash: LeanOnly.DocA built (it had no current build). - The statement is the unit. An edit to a proof changes nothing downstream. An edit to a statement makes stale exactly the modules that cite it; a module that imports it but cites only unchanged declarations keeps its build.
- A search may use a theorem from one of your modules that the file does not import yet. The proof is checked with the import added, and
--writewrites the import after the file’s own. Withwrite.imports = ask, flash names the import and writes nothing. - Once the project is set up, flash never needs
lake build: it builds what each file imports by itself.lake buildbuilds only the modules your project’s root file imports (MyProofs.leanin a project fromflash start), so a file the root file does not import is not built by it. Do not run it while you work; at the end, it builds the project as ordinary Lean.
How the store keeps builds current →
What runs in the background
| What | When | Setting |
|---|---|---|
| A prove run on each new sorry | after a check finds an open theorem, while the machine is quiet; one job a claim, each on its own pin; in your own projects only, never on shared pins | prove.background |
| r7n’s judgment of each proof | after a module checks clean | interface.judge |
| Resolution | when a theorem becomes proved: the files that rest on it are checked again, and what was reduced to it is searched again | always |
| The index merge | once the project has been quiet for 20 seconds | always |
| Retiring a worker | when it has been idle for resources.idle | resources.idle |
flash status counts the prove jobs running, and flash down stops every process of the pin and verifies it.
Several agents at once#
Programs working in one project share its Lean workers, its remembered answers and its claims. None of them needs a Lean or a Mathlib of its own, and their checks run in parallel, one per worker.
Give each agent its own file or module, so that no two edit one file at once. Claims depend only on what was checked and found, not on the order things happened, so beyond that the agents need not coordinate.
The frontier
flash frontier lists the open claims first, the ones most work rests on first, and then the reduced ones with what they are reduced to.
flash frontierleanonly: 5 proved · 4 found · 1 reduced · 2 open open doc_h1 DocH.lean open doc_h2 DocH.lean reduced t_main Sketch.lean to t_false
Once r7n has judged the proofs of a module that checks clean, the first line ends with its counts, for example r7n: 9 composed · 2 computation · 0 none. The judged line →
Leases, and waiting for a lemma
flash frontier --take --as agent-1 # the first open claim nobody holds, for ten minutes flash frontier --release doc_h1 # give it back flash frontier --all # the frontier with the taken claims too flash watch doc_main --until proved # wait until a claim reaches a state
flash frontier --take --as agent-1took doc_h1 (/path/to/project/LeanOnly/DocH.lean) for 10 minutes; 0 rest on it
flash watch doc_main --until proveddoc_main: reduced → proved
Two takes never get the same claim, and a plain flash frontier leaves taken claims out. flash watch returns as soon as a named claim changes state, or reaches the one you name; with --timeout S it gives up after S seconds and exits with 1.
flash frontier itself is a read and starts no check. flash frontier --refresh re-checks stale files one at a time, and flash frontier --retire NAME --why TEXT retires a claim whose file stays.
Proofs that finish themselves
Here doc_main is reduced to doc_a, a lemma in another module. One agent writes the reduced proof, another proves doc_a, and flash checks DocMain.lean again by itself:
flash prove DocMain.lean --write # reduced to doc_a; the proof is written, given doc_a flash watch doc_main --until proved & # another agent waits for it flash prove LeanOnly/DocA.lean --write # proves doc_a; doc_main: reduced → proved
Settings#
flash runs fully with no settings at all. To change one, put it in a flash.toml in the project’s directory, or use flash config set, which writes it there for you. flash config set --user writes it for every project.
| Key | Values | Default | What it does |
|---|---|---|---|
search.checks | 1 to 1000 | 60 | Lean checks a search may spend on one goal |
search.depth | 1 to 5 | 3 | lemma steps a search chains |
prove.background | off, idle, always | idle, in your own projects only, never on shared pins | whether new sorries are proved without being asked: never, while the machine is quiet, or as soon as a check finds them (9.0.0; search.background before it, still read with a notice) |
search.reduce | true, false | true | when nothing proves a goal, search again with the open lemmas above it and report the goal reduced to them |
write.proofs | auto, ask | ask | auto: flash prove FILE writes the proofs it finds; ask: it shows them, and --write writes |
write.layout | compact, explicit | explicit | compact: a proof as found; explicit: a top-level A <;> B over two lines where that lowers Lean’s warnings |
write.imports | auto, ask | auto | auto: a proof that needs one of your modules is written with its import; ask: the import is named and nothing is written |
interface.judge | on, off | on | whether r7n judges the proofs of each module that checks clean |
interface.default | si, text, latex, lean | si | the layer flash si writes when neither --to nor the extension of -o names one |
resources.workers | auto, or 1 to 16 | auto | the cap on Lean workers; auto sizes it from the machine’s memory and cores |
resources.idle | a duration | 10m | how long an idle Lean worker waits before it retires (30s, 10m, 1h) |
Where a value comes from
The first of these that sets a value wins:
- the command’s flags (
--checks,--depth,--write,--no-write,--to) - the environment:
FLASH_and the key in upper case, with.as_(FLASH_SEARCH_DEPTH=4) - the project’s
flash.toml - your own
~/.config/lens-flash/config.toml - the default
Seeing and changing settings
| Command | What it does |
|---|---|
flash config | every setting, its value, and where the value came from |
flash config get KEY | one value |
flash config set KEY VALUE | writes one value into the project’s flash.toml, keeping the rest of the file as you wrote it; refused outside a Lean project, where it would apply to nothing |
flash config set --user KEY VALUE | writes one value into ~/.config/lens-flash/config.toml, for every project |
[search] checks = 120 background = "off" [write] proofs = "auto"
What flash cannot use, it names under not read in flash config, and on each command’s standard error: a line it cannot read, a key it does not know (with the nearest one it does), a key set twice, and a [profile] or [intent] section left from release 8.0. A value that is not allowed is set aside, and the next source decides:
FLASH_SEARCH_DEPTH=9 flash config…
not read:
the environment: FLASH_SEARCH_DEPTH=9 is set aside (search.depth takes a number from 1 to 5)
flash config set refuses a value that is not allowed, or a key that does not exist, and writes nothing (exit 2).
The solution interface#
The solution interface (.si) shows each claim of a Lean file as the kernel holds it: its binders, hypotheses and conclusion, its state, what its proof rests on, its axioms, and r7n’s verdict on its argument. What you read is exactly what the kernel was handed.
flash si DocKinds.leanclaim t_sub
id 544738f7b3c58cc7d1c0de53cdb6cabcd790a9a0659d487b8d1fef68d6d5383b
state proved
for a : Nat
for b : Nat
assume h : a - b = 0
show @LE.le Int Int.instLEInt (↑a - ↑b) 0
rests none
uses Decidable.byContradiction · Or.elim · Lean.Omega.Int.ofNat_sub_dichotomy · …
axioms propext · Quot.sound
judged none · its argument is partly in t_sub._proof_1, made by its own elaboration, which r7n takes as given
note ℕ subtraction a - b (truncated: 0 when the right side is larger)
note coercion ↑a : Nat → Int
note coercion ↑b : Nat → Int
note numeral 0 : Int
render 1
A few things to notice in this claim:
statesays it is proved.restsandusessay which of your theorems, and which library theorems, the proof uses.- The
notelines name what Lean’s usual display can hide: here a truncated subtraction on ℕ, two coercions toInt, and the type of a numeral. judgedis r7n’s verdict. Here it could not judge, because part of the argument lives in an auxiliary declaration that elaboration made.
Notes of your own
You can write lines of your own into a .si: because, tried, belief and decide in a claim, and @goal at the top. When you write the .si again over the old one with flash si FILE.lean -o FILE.si, your notes follow each claim by its identity: through a rename, and through a changed statement, where they are marked stale.
The whole project, and other layers
flash si --project -o si/ # one document a module, in import order flash si --project --to latex > project.tex # one LaTeX document
The same claims come as text for a terminal (--to text), as a LaTeX document (--to latex), or as Lean with every proof left as sorry (--to lean). -o never writes over a source, and Lean is never written into the project.