@[notation_class]
attribute for @[simps]
#
This declares the @[notation_class]
attribute, which is used to give smarter default projections
for @[simps]
.
We put this in a separate file so that we can already tag some declarations with this attribute
in the file where we declare @[simps]
. For further documentation, see Tactic.Simps.Basic
.
The @[notation_class]
attribute specifies that this is a notation class,
and this notation should be used instead of projections by @[simps]
.
- This is only important if the projection is written differently using notation, e.g.
+
usesHAdd.hAdd
, notAdd.add
and0
usesOfNat.ofNat
notZero.zero
. We also add it to non-heterogenous notation classes, likeNeg
, but it doesn't do much for any class that extendsNeg
. @[notation_class *
is used to configure theSimps.findCoercionArgs] SetLike
andFunLike
coercions.- The first name argument is the projection name we use as the key to search for this class (default: name of first projection of the class).
- The second argument is the name of a declaration that has type
findArgType
which is defined to beName → Name → Array Expr → MetaM (Array (Option Expr))
. This declaration specifies how to generate the arguments of the notation class from the arguments of classes that use the projection.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The type of methods to find arguments for automatic projections for simps
.
We partly define this as a separate definition so that the unused arguments linter doesn't complain.
Equations
- Simps.findArgType = (Lean.Name → Lean.Name → Array Lean.Expr → Lean.MetaM (Array (Option Lean.Expr)))
Instances For
Find arguments for a notation class
Equations
- One or more equations did not get rendered due to their size.
Instances For
Find arguments by duplicating the first argument. Used for pow
.
Equations
- Simps.copyFirst x x args = pure (Array.map some (Array.push args (Option.getD args[0]? default)))
Instances For
Find arguments by duplicating the first argument. Used for smul
.
Equations
- Simps.copySecond x x args = pure (Array.map some (Array.push args (Option.getD args[1]? default)))
Instances For
Find arguments by prepending ℕ
and duplicating the first argument. Used for nsmul
.
Equations
- Simps.nsmulArgs x x args = pure (Array.map some (#[Lean.Expr.const `Nat [], Option.getD args[0]? default] ++ args))
Instances For
Find arguments by prepending ℤ
and duplicating the first argument. Used for zsmul
.
Equations
- Simps.zsmulArgs x x args = pure (Array.map some (#[Lean.Expr.const `Int [], Option.getD args[0]? default] ++ args))
Instances For
Find arguments for the Zero
class.
Equations
- Simps.findZeroArgs x x args = pure #[some (Option.getD args[0]? default), some (Lean.mkRawNatLit 0)]
Instances For
Find arguments for the One
class.
Equations
- Simps.findOneArgs x x args = pure #[some (Option.getD args[0]? default), some (Lean.mkRawNatLit 1)]
Instances For
Find arguments of a coercion class (FunLike
or SetLike
)
Equations
- One or more equations did not get rendered due to their size.
Instances For
- className : Lean.Name
className
is the name of the class we are looking for. - isNotation : Bool
isNotation
is a boolean that specifies whether this is notation (false for the coercionsFunLike
andSetLike
). If this is set to true, we add the current class as hypothesis during type-class synthesis. - findArgs : Lean.Name
The method to find the arguments of the class.
Data needed to generate automatic projections. This data is associated to a name of a projection in a structure that must be used to trigger the search.
Instances For
Equations
- Simps.instInhabitedAutomaticProjectionData = { default := { className := default, isNotation := default, findArgs := default } }
@[notation_class]
attribute. Note: this is not a NameMapAttribute
because we key on the
argument of the attribute, not the declaration name.