Type tags that turn additive structures into multiplicative, and vice versa #
We define two type tags:
Additive α
: turns any multiplicative structure onα
into the corresponding additive structure onAdditive α
;Multiplicative α
: turns any additive structure onα
into the corresponding multiplicative structure onMultiplicative α
.
We also define instances Additive.*
and Multiplicative.*
that actually transfer the structures.
See also #
This file is similar to Order.Synonym
.
If α
carries some additive structure, then Multiplicative α
carries the corresponding
multiplicative structure.
Equations
- Multiplicative α = α
Instances For
Reinterpret x : α
as an element of Additive α
.
Equations
- Additive.ofMul = { toFun := fun (x : α) => x, invFun := fun (x : Additive α) => x, left_inv := ⋯, right_inv := ⋯ }
Instances For
Recursion principle for Additive
, supported by cases
and induction
.
Equations
- Additive.rec ofMul a = ofMul (Additive.toMul a)
Instances For
Reinterpret x : α
as an element of Multiplicative α
.
Equations
- Multiplicative.ofAdd = { toFun := fun (x : α) => x, invFun := fun (x : Multiplicative α) => x, left_inv := ⋯, right_inv := ⋯ }
Instances For
Recursion principle for Multiplicative
, supported by cases
and induction
.
Equations
- Multiplicative.rec ofAdd a = ofAdd (Multiplicative.toAdd a)
Instances For
Equations
- instInhabitedAdditive = { default := Additive.ofMul default }
Equations
- instInhabitedMultiplicative = { default := Multiplicative.ofAdd default }
Equations
- instUniqueAdditive = Additive.toMul.unique
Equations
Equations
Equations
Equations
- Additive.add = { add := fun (x y : Additive α) => Additive.ofMul (Additive.toMul x * Additive.toMul y) }
Equations
- Multiplicative.mul = { mul := fun (x y : Multiplicative α) => Multiplicative.ofAdd (Multiplicative.toAdd x + Multiplicative.toAdd y) }
Equations
Equations
Equations
Equations
Equations
- instZeroAdditiveOfOne = { zero := Additive.ofMul 1 }
Equations
- instOneMultiplicativeOfZero = { one := Multiplicative.ofAdd 0 }
Equations
Equations
Equations
- Additive.addMonoid = AddMonoid.mk ⋯ ⋯ Monoid.npow ⋯ ⋯
Equations
Equations
Equations
Equations
Equations
Equations
- Additive.neg = { neg := fun (x : Additive α) => Multiplicative.ofAdd (Additive.toMul x)⁻¹ }
Equations
- Multiplicative.inv = { inv := fun (x : Multiplicative α) => Additive.ofMul (-Multiplicative.toAdd x) }
Equations
- Additive.sub = { sub := fun (x y : Additive α) => Additive.ofMul (Additive.toMul x / Additive.toMul y) }
Equations
- Multiplicative.div = { div := fun (x y : Multiplicative α) => Multiplicative.ofAdd (Multiplicative.toAdd x - Multiplicative.toAdd y) }
Equations
Equations
Equations
Equations
Equations
Equations
Equations
Equations
Equations
Equations
If α
has some multiplicative structure and coerces to a function,
then Additive α
should also coerce to the same function.
This allows Additive
to be used on bundled function types with a multiplicative structure, which
is often used for composition, without affecting the behavior of the function itself.
Equations
- Additive.coeToFun = { coe := fun (a : Additive α) => CoeFun.coe (Additive.toMul a) }
If α
has some additive structure and coerces to a function,
then Multiplicative α
should also coerce to the same function.
This allows Multiplicative
to be used on bundled function types with an additive structure, which
is often used for composition, without affecting the behavior of the function itself.
Equations
- Multiplicative.coeToFun = { coe := fun (a : Multiplicative α) => CoeFun.coe (Multiplicative.toAdd a) }