A closer for what EC leaves to auto => /# #
auto_close
EC closes the logical goals its program tactics leave with smt (/#, smt(…)). We have no
SMT solver (by decision), but those goals come in a few shapes, and auto_close takes them
apart the way one does by hand:
- introduce everything, take the hypotheses apart (
∧,∃,∨), substitute the equations of variables (the states of EC'ssp:σ = x.set v τ); - simplify the reads through writes everywhere, the hypotheses included (
simp_reads_all; through the inliner's renamings,rename_reads), and theglobof a region past writes outside it (glob_simp, EC's implicit={glob D}); - the tests back to propositions (
decide … = true), indicators of events (indicatorE P = 1); - split the goal (
∧,if), and close each part byrfl, an assumption (either way round),trivial,omega(EC's/#on counters), orsimp_all.
It closes the goal or fails, leaving it untouched. It does not know the lemmas EC's smt(l)
is given: state those first (have := l …).
e is a name (a variable with an accessible name) or a tuple of names.
EC's <<- on reads: an equation between a read of the state (FRO.m.get σ.globals) and a
named variable (EC's elim* => hs0) rewrites the read into the name everywhere, so the closer
works with the names (subst_vars would eliminate the name instead).
Equations
- GaudisCrypt.tacticSubst_reads = Lean.ParserDescr.node `GaudisCrypt.tacticSubst_reads 1024 (Lean.ParserDescr.nonReservedSymbol "subst_reads" false)
Instances For
The state a read is of: σ for G.get σ and G.get σ.globals.
Equations
- One or more equations did not get rendered due to their size.
Instances For
EC's memories as one: an equation between reads of the same variable in two states (the frame
X.get τ = X.get σ that conseq and call leave for what the code does not modify, or ={x})
rewrites the read of the later state (in the context) into the earlier one's, everywhere. One
direction for every pair of states, so the rewriting cannot loop; of two equations saying the same
(X.get τ₁ = X.get τ₂ from an invariant, X.get τ₂ = X.get τ₁ from a frame) one is dropped, so
that simp_all does not loop on them either.
Equations
- GaudisCrypt.tacticSubst_frames = Lean.ParserDescr.node `GaudisCrypt.tacticSubst_frames 1024 (Lean.ParserDescr.nonReservedSymbol "subst_frames" false)
Instances For
EC's progress on implications: a hypothesis p → q whose premise p is another hypothesis
(up to reducible unfolding) becomes q; repeated while one applies.
Equations
- GaudisCrypt.tacticMp_hyps = Lean.ParserDescr.node `GaudisCrypt.tacticMp_hyps 1024 (Lean.ParserDescr.nonReservedSymbol "mp_hyps" false)
Instances For
EC's <<*: an equation between a named variable (EC's elim* => hs) and an anonymous one
(a read generalized by the closer) eliminates the anonymous one, so the names stay.
Equations
- GaudisCrypt.tacticSubst_named = Lean.ParserDescr.node `GaudisCrypt.tacticSubst_named 1024 (Lean.ParserDescr.nonReservedSymbol "subst_named" false)
Instances For
simp_reads on the goal and every hypothesis (a hypothesis simplified to False closes the
goal).
Equations
- GaudisCrypt.tacticSimp_reads_all = Lean.ParserDescr.node `GaudisCrypt.tacticSimp_reads_all 1024 (Lean.ParserDescr.nonReservedSymbol "simp_reads_all" false)
Instances For
The steps auto_close and auto_progress share: introduce, take the hypotheses apart,
substitute, simplify the reads and the tests (see the module docstring).
Equations
- GaudisCrypt.tacticAuto_prep = Lean.ParserDescr.node `GaudisCrypt.tacticAuto_prep 1024 (Lean.ParserDescr.nonReservedSymbol "auto_prep" false)
Instances For
What EC leaves to auto => /#: see the module docstring.
Equations
- GaudisCrypt.tacticAuto_close = Lean.ParserDescr.node `GaudisCrypt.tacticAuto_close 1024 (Lean.ParserDescr.nonReservedSymbol "auto_close" false)
Instances For
simp_all; done, failing (as an ordinary error, so first goes on) also when simp_all runs
into a runtime limit (a rewriting cycle among the hypotheses, e.g. the frames of EC's while
reaching the recursion limit), which try/first would not catch.
Equations
- GaudisCrypt.tacticSimp_all_done_safe = Lean.ParserDescr.node `GaudisCrypt.tacticSimp_all_done_safe 1024 (Lean.ParserDescr.nonReservedSymbol "simp_all_done_safe" false)
Instances For
EC's progress (auto => />; progress): auto_close's steps, the goals it cannot close
left (split as far as it goes), for the lemmas EC's smt calls are given.
Equations
- GaudisCrypt.tacticAuto_progress = Lean.ParserDescr.node `GaudisCrypt.tacticAuto_progress 1024 (Lean.ParserDescr.nonReservedSymbol "auto_progress" false)
Instances For
generalize_reads_all: every read of a variable in a state (x.get σ, X.get σ.globals,
σ a local) a fresh variable, in the goal and the hypotheses: EC's view of a memory as its
variables' values.
Equations
- GaudisCrypt.tacticGeneralize_reads_all = Lean.ParserDescr.node `GaudisCrypt.tacticGeneralize_reads_all 1024 (Lean.ParserDescr.nonReservedSymbol "generalize_reads_all" false)
Instances For
The instances of the lemma lemName (∀ xs, P xs) at the terms of targets: each subterm of its
conclusion that mentions all its non-instance arguments (a pattern, size l of size_ge0 : 0 ≤ size l) matched (reducibly) against each target term, the instance kept when that fixes the
arguments (the instance arguments synthesized).
Equations
- One or more equations did not get rendered due to their size.
Instances For
ec_instances [l₁, …]: the instances of the lemmas lᵢ (∀ xs, P xs) at the terms of the
goal and the hypotheses, as hypotheses (what EC's provers instantiate on the goal's terms: a
smt(List.size_ge0) on 0 <= size p). At most 64.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The instances of the lemma lemName at the terms targets: an application in its
conclusion with the head of a target term and one of the lemma's arguments matched against
it; then the instance arguments synthesized and the hypotheses (arguments that are proofs)
found among the local hypotheses. Kept when that fixes every argument.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The application subterms of src that are terms of the local context (no variable of a
binder: Meta.forEachExpr opens them).
Equations
- One or more equations did not get rendered due to their size.
Instances For
ec_instances_chain [l₁, …]: as ec_instances, over three rounds (the instances' own terms
are terms to instantiate at: a chain of lemmas), with the lemmas' hypotheses found among the
local ones.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The predicates of the file being checked that the goal or its hypotheses mention:
definitions with values in Prop (EC's pred, whose body its provers see).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The term of a parameter that is a fact: a lemma l with no modifier whose term is not a
name.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The facts among smt_close's parameters (terms that are not a name: a lemma applied to
its arguments) and the others (lemma names, with modifiers).
Equations
- GaudisCrypt.ECClose.splitParams ps = Array.partition (fun (p : Lean.Syntax) => (GaudisCrypt.ECClose.factTerm? p).isSome) ps
Instances For
The lemma names among smt_close's parameters (plain identifiers).
Equations
- GaudisCrypt.ECClose.paramIdents ps = Array.filterMap (fun (p : Lean.Syntax) => Option.map (fun (x : Lean.Syntax) => { raw := x }) (p.find? fun (x : Lean.Syntax) => x.isIdent)) ps
Instances For
Whether a parameter of smt_close is the name of a closed lemma: a constant with no
argument but instances (dbool_ll : is_lossless dbool, an axiom of a theory such as
gt0_n : 0 < n). There is nothing to instantiate in it: it is a fact (and grind does not
take it as a lemma when its instance is built from the context: "unknown free variable").
Equations
- One or more equations did not get rendered due to their size.
Instances For
The parameters of smt_close that grind is given: the lemma names that are not closed
lemmas (ECClose.isClosedLemma), with their modifiers.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The preparation of smt_close: its facts as hypotheses, before the preprocessing (which
puts them in the form of the goal).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The closing step of smt_close on one goal: see smt_close.
Equations
- One or more equations did not get rendered due to their size.
Instances For
EC's smt(l₁, …): auto_close's preprocessing, the reads of the states as variables
(generalize_reads_all), their equations substituted, then grind with the lemmas lᵢ; if that
fails, once more with the lemmas' instances at the goal's terms as hypotheses (ec_instances:
EC's provers instantiate them there, grind's E-matching may not, through definitions).
Then, what EC's provers also do:
- the predicates of the file being checked that the goal mentions are unfolded (EC's
pred: its body is known to the provers; a predicate of the library is named,smt_close [P]); - linear arithmetic over an ordered field (
linarith:grinddoes not do it over the reals); - the lemmas are instantiated in a chain (
ec_instances_chain: at the terms of the instances too, their hypotheses taken from the context), for EC'ssmt(l₁ l₂ l₃)on a chain of (in)equalities between probabilities.
A parameter that is not a name — a lemma applied to its arguments, smt_close [l A m] — is a
fact: it becomes a hypothesis first. So does the name of a lemma with no argument but
instances (smt_close [dbool_ll, gt0_n]).
Equations
- One or more equations did not get rendered due to their size.