Module docstring
{"# Typeclasses for algebraic operations
Notation typeclass for Inv, the multiplicative analogue of Neg.
We also introduce notation classes SMul and VAdd for multiplicative and additive
actions.
SMul is typically, but not exclusively, used for scalar multiplication-like operators.
See the module Algebra.AddTorsor for a motivating example for the name VAdd (vector addition).
Note Zero has already been defined in core Lean.
Notation
a • bis used as notation forHSMul.hSMul a b.a +ᵥ bis used as notation forHVAdd.hVAdd a b.
","We have a macro to make x • y notation participate in the expression tree elaborator,
like other arithmetic expressions such as +, *, /, ^, =, inequalities, etc.
The macro is using the leftact% elaborator introduced in
this RFC.
As a concrete example of the effect of this macro, consider ```lean variable [Ring R] [AddCommMonoid M] [Module R M] (r : R) (N : Submodule R M) (m : M) (n : N)
check m + r • n
``
Without the macro, the expression would elaborate asm + ↑(r • n : ↑N) : M.
With the macro, the expression elaborates asm + r • (↑n : M) : M.
To get the first interpretation, one can writem + (r • n :)`.
Here is a quick review of the expression tree elaborator:
1. It builds up an expression tree of all the immediately accessible operations
that are marked with binop%, unop%, leftact%, rightact%, binrel%, etc.
2. It elaborates every leaf term of this tree
(without an expected type, so as if it were temporarily wrapped in (... :)).
3. Using the types of each elaborated leaf, it computes a supremum type they can all be
coerced to, if such a supremum exists.
4. It inserts coercions around leaf terms wherever needed.
The hypothesis is that individual expression trees tend to be calculations with respect to a single algebraic structure.
Note(kmill): If we were to remove HSMul and switch to using SMul directly,
then the expression tree elaborator would not be able to insert coercions within the right operand;
they would likely appear as ↑(x • y) rather than x • ↑y, unlike other arithmetic operations.
"}