Sign function #
This file defines the sign function for types with zero and a decidable less-than relation, and proves some basic theorems about it.
Equations
- instDecidableEqSignType x y = if h : x.toCtorIdx = y.toCtorIdx then isTrue ⋯ else isFalse ⋯
Equations
- instInhabitedSignType = { default := SignType.zero }
Equations
- SignType.instZero = { zero := SignType.zero }
Equations
- SignType.instNeg = { neg := fun (s : SignType) => match s with | SignType.neg => SignType.pos | SignType.zero => SignType.zero | SignType.pos => SignType.neg }
Equations
- SignType.instMul = { mul := fun (x y : SignType) => match x with | SignType.neg => -y | SignType.zero => SignType.zero | SignType.pos => y }
The less-than-or-equal relation on signs.
- of_neg: ∀ (a : SignType), SignType.neg.LE a
- zero: SignType.zero.LE SignType.zero
- of_pos: ∀ (a : SignType), a.LE SignType.pos
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- SignType.instBoundedOrder = BoundedOrder.mk
Turn a SignType
into zero, one, or minus one. This is a coercion instance, but note it is
only a CoeTC
instance: see note [use has_coe_t].
Equations
- ↑SignType.zero = 0
- ↑SignType.pos = 1
- ↑SignType.neg = -1
Instances For
Casting out of SignType
respects composition with suitable bundled homomorphism types.
SignType.cast
as a MulWithZeroHom
.
Equations
- SignType.castHom = { toFun := SignType.cast, map_zero' := ⋯, map_one' := ⋯, map_mul' := ⋯ }
Instances For
The sign of an element is 1 if it's positive, -1 if negative, 0 otherwise.
Equations
Instances For
SignType.sign
respects strictly monotone zero-preserving maps.
SignType.sign
as a MonoidWithZeroHom
for a nontrivial ordered semiring. Note that linearity
is required; consider ℂ with the order z ≤ w
iff they have the same imaginary part and
z - w ≤ 0
in the reals; then 1 + I
and 1 - I
are incomparable to zero, and thus we have:
0 * 0 = SignType.sign (1 + I) * SignType.sign (1 - I) ≠ SignType.sign 2 = 1
.
(Complex.orderedCommRing
)
Equations
- signHom = { toFun := ⇑SignType.sign, map_zero' := ⋯, map_one' := ⋯, map_mul' := ⋯ }
Instances For
We can decompose a sum of absolute value n
into a sum of n
signs.
We can decompose a sum of absolute value less than n
into a sum of at most n
signs.