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 : SignType.toCtorIdx x = SignType.toCtorIdx y then isTrue (_ : x = y) else isFalse (_ : x = y → False)
Equations
- instInhabitedSignType = { default := SignType.zero }
Equations
- SignType.instZeroSignType = { zero := SignType.zero }
Equations
- SignType.instOneSignType = { one := SignType.pos }
Equations
- One or more equations did not get rendered due to their size.
Equations
- SignType.instMulSignType = { 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.LE SignType.neg a
- zero: SignType.LE SignType.zero SignType.zero
- of_pos: ∀ (a : SignType), SignType.LE a SignType.pos
Instances For
Equations
- SignType.instLESignType = { le := SignType.LE }
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
Equations
- SignType.instBoundedOrderSignTypeInstLESignType = 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
- ↑x = match x with | SignType.zero => 0 | SignType.pos => 1 | SignType.neg => -1
Instances For
SignType.cast
as a MulWithZeroHom
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The sign of an element is 1 if it's positive, -1 if negative, 0 otherwise.
Equations
- One or more equations did not get rendered due to their size.
Instances For
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
- One or more equations did not get rendered due to their size.
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.