The persistent @[param] constant database #
The term-level translator ParamTranslate.translate consumes a db : NameMap (Expr × Expr) mapping an abstract constant c to its transferred counterpart
c' together with a witness wᶜ : RArrow PA PB c c'. Without an ambient store
that database must be assembled and passed by hand at each call site.
This module makes the database persistent and ambient:
- a persistent environment extension (
paramExt) whose state is aNameMap (Name × Name)— abstract const name ↦(transferred const, witness lemma). Built withLean.registerSimplePersistentEnvExtension; theaddImportedFnre-folds entries from imported modules, so registrations survive across files. - an attribute
@[param]that, given a lemmacR : RArrow PA PB c c', peels theRArrowapplication from the lemma's type (the last two of its eight application arguments are the abstract constcand the transferred constc') and storesc.constName ↦ (c'.constName, lemmaName). getParamDB : MetaM (NameMap (Expr × Expr))— materialises the extension state into theNameMap (Expr × Expr)thattranslateconsumes, turning each(c', lemmaName)into(Expr.const c' [], Expr.const lemmaName []).- a driver command
#param_translate tthat runstranslate {} (← getParamDB) tagainst the ambient registry and logs the transferred term and the proof's type.
A witness is registered once with @[param], and the translator resolves the
constant from the registry with no explicit db argument.
The persistent @[param] database #
The persistent environment extension backing @[param]. Its state maps an
abstract constant's name to (transferred const name, witness lemma name).
addEntryFn inserts a single registration; addImportedFn re-folds all
entries contributed by imported modules so the database is cross-file.
Peel RArrow PA PB c c' from a lemma's type. RArrow has four implicit type
arguments {A A' B B'}, two relation arguments PA PB, and the two function
arguments f f' — eight application arguments in total. The abstract constant
c and its transferred counterpart c' are the last two; their
head-constant names are returned.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Materialise the persistent @[param] registry into the NameMap (Expr × Expr)
that ParamTranslate.translate consumes: each stored (c', lemmaName) becomes
(Expr.const c' [], Expr.const lemmaName []).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Driver command #
#param_translate t runs the term-level parametricity translation ⟦t⟧
against the ambient @[param] registry (no explicit database), logging
the transferred term and the type of the relatedness proof.
Equations
- One or more equations did not get rendered due to their size.