Sign function #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
This file defines the sign function for types with zero and a decidable less-than relation, and proves some basic theorems about it.
The type of signs.
Instances for sign_type
- sign_type.has_sizeof_inst
- sign_type.inhabited
- sign_type.fintype
- sign_type.has_zero
- sign_type.has_one
- sign_type.has_neg
- sign_type.has_mul
- sign_type.has_le
- sign_type.comm_group_with_zero
- sign_type.linear_order
- sign_type.bounded_order
- sign_type.has_distrib_neg
- sign_type.has_coe_t
- sign_type.topological_space
- sign_type.discrete_topology
Equations
Equations
Equations
- sign_type.has_neg = {neg := λ (s : sign_type), sign_type.has_neg._match_1 s}
- sign_type.has_neg._match_1 sign_type.pos = sign_type.neg
- sign_type.has_neg._match_1 sign_type.neg = sign_type.pos
- sign_type.has_neg._match_1 sign_type.zero = sign_type.zero
Equations
- sign_type.has_mul = {mul := λ (x y : sign_type), sign_type.has_mul._match_1 y x}
- sign_type.has_mul._match_1 y sign_type.pos = y
- sign_type.has_mul._match_1 y sign_type.neg = -y
- sign_type.has_mul._match_1 y sign_type.zero = sign_type.zero
- of_neg : ∀ (a : sign_type), sign_type.neg.le a
- zero : sign_type.zero.le sign_type.zero
- of_pos : ∀ (a : sign_type), a.le sign_type.pos
The less-than relation on signs.
Instances for sign_type.le
Equations
Equations
- sign_type.le.decidable_rel = λ (a b : sign_type), a.cases_on (b.cases_on (decidable.is_true sign_type.le.zero) (decidable.is_false sign_type.le.decidable_rel._proof_1) (decidable.is_true _)) (b.cases_on (decidable.is_true _) (decidable.is_true _) (decidable.is_true _)) (b.cases_on (decidable.is_false sign_type.le.decidable_rel._proof_2) (decidable.is_false sign_type.le.decidable_rel._proof_3) (decidable.is_true _))
Equations
- sign_type.comm_group_with_zero = {mul := has_mul.mul sign_type.has_mul, mul_assoc := sign_type.comm_group_with_zero._proof_1, one := 1, one_mul := sign_type.comm_group_with_zero._proof_2, mul_one := sign_type.comm_group_with_zero._proof_3, npow := comm_monoid_with_zero.npow._default 1 has_mul.mul sign_type.comm_group_with_zero._proof_4 sign_type.comm_group_with_zero._proof_5, npow_zero' := sign_type.comm_group_with_zero._proof_6, npow_succ' := sign_type.comm_group_with_zero._proof_7, mul_comm := sign_type.comm_group_with_zero._proof_8, zero := 0, zero_mul := sign_type.comm_group_with_zero._proof_9, mul_zero := sign_type.comm_group_with_zero._proof_10, inv := id sign_type, div := group_with_zero.div._default has_mul.mul sign_type.comm_group_with_zero._proof_11 1 sign_type.comm_group_with_zero._proof_12 sign_type.comm_group_with_zero._proof_13 (comm_monoid_with_zero.npow._default 1 has_mul.mul sign_type.comm_group_with_zero._proof_4 sign_type.comm_group_with_zero._proof_5) sign_type.comm_group_with_zero._proof_14 sign_type.comm_group_with_zero._proof_15 id, div_eq_mul_inv := sign_type.comm_group_with_zero._proof_16, zpow := group_with_zero.zpow._default has_mul.mul sign_type.comm_group_with_zero._proof_17 1 sign_type.comm_group_with_zero._proof_18 sign_type.comm_group_with_zero._proof_19 (comm_monoid_with_zero.npow._default 1 has_mul.mul sign_type.comm_group_with_zero._proof_4 sign_type.comm_group_with_zero._proof_5) sign_type.comm_group_with_zero._proof_20 sign_type.comm_group_with_zero._proof_21 id, zpow_zero' := sign_type.comm_group_with_zero._proof_22, zpow_succ' := sign_type.comm_group_with_zero._proof_23, zpow_neg' := sign_type.comm_group_with_zero._proof_24, exists_pair_ne := sign_type.comm_group_with_zero._proof_25, inv_zero := sign_type.comm_group_with_zero._proof_26, mul_inv_cancel := sign_type.comm_group_with_zero._proof_27}
Equations
- sign_type.linear_order = {le := has_le.le sign_type.has_le, lt := partial_order.lt._default has_le.le, le_refl := sign_type.linear_order._proof_1, le_trans := sign_type.linear_order._proof_2, lt_iff_le_not_le := sign_type.linear_order._proof_3, le_antisymm := sign_type.linear_order._proof_4, le_total := sign_type.linear_order._proof_5, decidable_le := sign_type.le.decidable_rel, decidable_eq := decidable_eq_of_decidable_le sign_type.le.decidable_rel, decidable_lt := decidable_lt_of_decidable_le sign_type.le.decidable_rel, max := max_default (λ (a b : sign_type), sign_type.le.decidable_rel a b), max_def := sign_type.linear_order._proof_10, min := min_default (λ (a b : sign_type), sign_type.le.decidable_rel a b), min_def := sign_type.linear_order._proof_11}
Equations
- sign_type.bounded_order = {top := 1, le_top := sign_type.le.of_pos, bot := -1, bot_le := sign_type.le.of_neg}
Equations
- sign_type.has_distrib_neg = {neg := has_neg.neg sign_type.has_neg, neg_neg := sign_type.has_distrib_neg._proof_1, neg_mul := sign_type.has_distrib_neg._proof_2, mul_neg := sign_type.has_distrib_neg._proof_3}
sign_type
is equivalent to fin 3
.
Equations
- sign_type.fin3_equiv = {to_fun := λ (a : sign_type), a.rec_on 0 (-1) 1, inv_fun := λ (a : fin 3), sign_type.fin3_equiv._match_1 a, left_inv := sign_type.fin3_equiv._proof_3, right_inv := sign_type.fin3_equiv._proof_4, map_mul' := sign_type.fin3_equiv._proof_5}
- sign_type.fin3_equiv._match_1 ⟨n + 3, h⟩ = _.elim
- sign_type.fin3_equiv._match_1 ⟨2, h⟩ = -1
- sign_type.fin3_equiv._match_1 ⟨1, h⟩ = 1
- sign_type.fin3_equiv._match_1 ⟨0, h⟩ = 0
Turn a sign_type
into zero, one, or minus one. This is a coercion instance, but note it is
only a has_coe_t
instance: see note [use has_coe_t].
Equations
- sign_type.pos.cast = 1
- sign_type.neg.cast = -1
- sign_type.zero.cast = 0
Equations
- sign_type.has_coe_t = {coe := sign_type.cast _inst_3}
sign_type.cast
as a mul_with_zero_hom
.
Equations
- sign_type.cast_hom = {to_fun := sign_type.cast (neg_zero_class.to_has_neg α), map_zero' := _, map_one' := _, map_mul' := _}
sign
as a monoid_with_zero_hom
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 = sign (1 + i) * sign (1 - i) ≠ sign 2 = 1
. (complex.ordered_comm_ring
)
We can decompose a sum of absolute value n
into a sum of n
signs.