Skip to main content

Module tactic_script

Module tactic_script 

Source
Expand description

A tiny proof-script language over the crate::tactic combinators — proofs as TEXT, the way a Lean/Coq proof reads. This is the self-contained seam toward a full English vernacular: it has no dependency on the surface language, so it compiles a script string straight into a composed Tactic.

Grammar (precedence low → high):

script  := seq
seq     := chain (';' chain)*          // run in order
chain   := atom ('<;>' atom)*          // `t1 <;> t2`: t2 on the goals t1 spawned
atom    := '(' script ')'
         | 'first' '[' script ('|' script)* ']'   // first that applies (backtracks)
         | 'try' atom                              // run if it applies, else no-op
         | 'repeat' atom                           // apply until it stops applying
         | 'all_goals' atom | 'any_goals' atom     // every / at least one open goal
         | 'focus' atom                            // Lean's bullet: must close its goal
         | NAME ARG*                               // a primitive tactic
term    := factor (('+'|'-') factor)*  // the argument of exact/use/have/refine
factor  := app ('*' app)*
app     := primary primary*            // juxtaposition: application
primary := NAME | '?' NAME? | '(' term (',' term)* ')'

Primitive tactics: intro a b, exact <term>, apply h, rfl, cases h with a b, rewrite h [at <k> | at <hyp> [<k>]], exists <term>, assumption, simp only [h], decide, omega, linarith, ring, crush, calc h1 h2 …, by_rule <Rule>, split, left, right, auto, induction n, by_contra h, have h from <term>, refine <term>.

rewrite’s at clause carries both aspects of positional rewriting: at <k> is Lean’s nth_rewrite (the POSITION, in the goal) and at <hyp> is Lean’s rw … at h (the LOCATION); at <hyp> <k> is both.

Structs§

ScriptError
A script parse error, with a human-readable reason.
ScriptedTheorem
One theorem of a scripted library: proved from its own premises plus the conclusions of the theorems it cites, by running script to a kernel-checked proof. The unit the prove_scripted_library driver discharges in citation order.
TacticEnv
A registry of USER-DEFINED tactics (M) — the metaprogramming seam. A user names a composite tactic (built from primitives and combinators) with TacticEnv::define, and may then reference it BY NAME in any later script, including from within other user-defined tactics. This is “write your own tactic in the language”, without Rust — the definitions are stored as source and re-expanded (depth-bounded, so a recursive definition is rejected rather than looping) wherever the name appears.

Functions§

canonical
Map an English-esque verb to its canonical tactic name. Suppose/assume/let all mean intro; automatically/trivially mean auto; and so on — the vocabulary that lets a proof read like prose. Case-insensitive. Public so an editor highlights exactly the words the engine accepts.
parse_script
Compile a proof-script string into a composed Tactic (no user-defined tactics).
parse_script_with_env
Compile a proof-script string with USER-DEFINED tactics resolved from env (M).
prove_scripted_library
Discharge a library of scripted theorems in citation order, on a shared axioms base. Each theorem is proved by its ScriptedTheorem::script from its premises, the axioms, and the conclusions of the theorems it cites (already proved); a proved conclusion becomes a citable lemma for later theorems — the scraped-Euclid-graph discipline, now driven by tactic scripts. Results come back in INPUT order.