R7N Lens Flash

R7N for Lean 4

Formal made faster

The Lean Environment Navigation System (LENS) and its flash CLI work beside you in Lean 4. They check your files as you write, find the proofs they are missing, and can write them in for you. Lens Flash can only ever tell you what Lean’s kernel has checked.

For Linux on x86_64, under the Apache License 2.0. The command is flash. R7N is the family of tools Lens Flash belongs to.

1 of 2

Welcome to Lens Flash.

We’re glad you’re here. LENS is a companion for working in Lean 4, and flash is how you talk to it: it checks what you write, finds the proofs you’re missing, and can write them in for you.

What flash does

Each is a single command, shown with what flash prints, trimmed a little.

  1. It proves, and Lean decides

    Where your file has a sorry, Lean’s placeholder for a missing proof, flash prove runs Lean’s own tactics in the warm worker that checks the file — grind, simp, exact?, aesop, omega and the rest of the portfolio, several at once — and then the C search on whatever is still open. A proof is reported only when the file with it written in checks again with no error, no sorry left and only the standard axioms. A goal nothing closes is reported open, with what is left; a false one is refuted.

    flash prove Chain.lean
      4:2      proved   double_pos   by grind [double]
      7:2      proved   c_two   by grind [double]
     10:2     open     not_always
    Chain.lean: 3 sorries — 2 closed, 0 refuted, 1 open  (3.5 s, 4 threads); --write writes them
  2. Proofs build on each other

    The sorries in a file are searched from the top down, and each search can use the theorems above it, including the ones it has just proved. Here c_two is proved with the project’s lemma double_pos, and then c_four follows from c_two.

    flash prove Chain.lean --write
    Chain.lean, as written
    theorem c_two (m : Nat) (hm : 0 < m) : 0 < double (double m) := by
      apply Nat.add_pos_left <;> (apply double_pos <;> assumption)
    
    theorem c_four (k : Nat) (hk : 0 < k) : 0 < double (double (double (double k))) := by
      apply c_two <;> (apply c_two <;> assumption)
  3. You always know what is left

    When a goal follows only from lemmas that are not proved yet, flash names them, and never calls the goal proved. flash frontier lists what is left to prove, the lemmas that most of your work rests on first. Once those are proved, everything waiting on them is proved without you asking.

    flash frontier
    …
    open     doc_h1                                   DocH.lean
    open     doc_h2                                   DocH.lean
    …
  4. Every theorem, as the kernel holds it

    flash si shows each theorem of a file as the kernel holds it: its hypotheses and its statement, in a form that elaborates back to exactly the term Lean checked, what its proof rests on, and any other theorem with the same statement. It writes the solution interface (.si), and the same as text, LaTeX or Lean.

    flash si Chain.lean --to text
    …
    proved    c_two
              the same statement as doc_a
              m : Nat
              hm : 0 < m
            ⊢ 0 < double (double m)
              rests on double_pos
    …
  5. Many agents can share a project

    Programs working in one project share its Lean workers and everything Lean has already answered. flash frontier --take gives each agent a different lemma to work on, and flash watch returns the moment a theorem you are waiting for is proved.

    flash frontier --take --as agent-1
    took doc_h1 (/path/to/project/LeanOnly/DocH.lean) for 10 minutes; 0 rest on it

How a session goes

You set a project up once. After that it is a short loop: write some Lean, check it, let flash prove what is missing, and go again.

  1. Set the project up

    Once. flash start gets Lean if you need it, makes or finds your project, and sets flash up; in a project you have already built, flash init does the last part.

    flash start
  2. Check a file

    You get Lean’s own messages. The exit status is 0 when the file has no error; a sorry is only a warning.

    flash check Work.lean
    ok  errors 0  sorries 3  … ms  exact
    Work.lean:3:8: warning: declaration uses `sorry`
  3. Prove what’s missing

    flash runs Lean’s tactics at every sorry, then the C search on what’s left, and Lean checks each proof with the whole file. --write puts them in.

    flash prove Work.lean
    Work.lean: 3 of 3 proved (w_add, w_double, w_append); … s

To try it from nothing, step by step, follow Get started →