Module docstring
{"# Simps attribute
This file defines the @[simps] attribute, to automatically generate simp lemmas
reducing a definition when projections are applied to it.
Implementation Notes
There are three attributes being defined here
* @[simps] is the attribute for objects of a structure or instances of a class. It will
automatically generate simplification lemmas for each projection of the object/instance that
contains data. See the doc strings for Lean.Parser.Attr.simps and Simps.Config
for more details and configuration options.
* structureExt (just an environment extension, not actually an attribute)
is automatically added to structures that have been used in @[simps]
at least once. This attribute contains the data of the projections used for this structure
by all following invocations of @[simps].
* @[notation_class] should be added to all classes that define notation, like Mul and
Zero. This specifies that the projections that @[simps] used are the projections from
these notation classes instead of the projections of the superclasses.
Example: if Mul is tagged with @[notation_class] then the projection used for Semigroup
will be fun α hα ↦ @Mul.mul α (@Semigroup.toMul α hα) instead of @Semigroup.mul.
[this is not correctly implemented in Lean 4 yet]
Possible Future Improvements
- If multiple declarations are generated from a
simpswithout explicit projection names, then only the first one is shown when mousing oversimps.
Changes w.r.t. Lean 3
There are some small changes in the attribute. None of them should have great effects
* The attribute will now raise an error if it tries to generate a lemma when there already exists
a lemma with that name (in Lean 3 it would generate a different unique name)
* transparency.none has been replaced by TransparencyMode.reducible
* The attr configuration option has been split into isSimp and attrs (for extra attributes)
* Because Lean 4 uses bundled structures, this means that simps applied to anything that
implements a notation class will almost certainly require a user-provided custom simps projection.
Tags
structures, projections, simp, simplifier, generates declarations ","Declare notation classes. "}