File: Mathlib/Data/Sign.lean

full_name: SignType
code: /-- The type of signs. -/
inductive SignType
  | zero
  | neg
  | pos
  deriving DecidableEq, Inhabited
goal: Type

full_name: instInhabitedSignType
code: /-- The type of signs. -/
inductive SignType
  | zero
  | neg
  | pos
  deriving DecidableEq, Inhabited
goal: Inhabited SignType

full_name: instDecidableEqSignType
code: /-- The type of signs. -/
inductive SignType
  | zero
  | neg
  | pos
  deriving DecidableEq, Inhabited
goal: DecidableEq SignType

full_name: SignType.pos
code: /-- The type of signs. -/
inductive SignType
  | zero
  | neg
  | pos
  deriving DecidableEq, Inhabited
goal: SignType

full_name: SignType.neg
code: /-- The type of signs. -/
inductive SignType
  | zero
  | neg
  | pos
  deriving DecidableEq, Inhabited
goal: SignType

full_name: SignType.zero
code: /-- The type of signs. -/
inductive SignType
  | zero
  | neg
  | pos
  deriving DecidableEq, Inhabited
goal: SignType

full_name: SignType.instFintype
code: instance : Fintype SignType 
goal: Fintype SignType

full_name: SignType.instZero
code: instance : Zero SignType 
goal: Zero SignType

full_name: SignType.instOne
code: instance : One SignType 
goal: One SignType

full_name: SignType.instNeg
code: instance : Neg SignType 
goal: Neg SignType

full_name: SignType.zero_eq_zero
code: @[simp]
theorem zero_eq_zero : zero = 0 
goal: SignType.zero = 0

full_name: SignType.neg_eq_neg_one
code: @[simp]
theorem neg_eq_neg_one : neg = -1 
goal: SignType.neg = -1

full_name: SignType.pos_eq_one
code: @[simp]
theorem pos_eq_one : pos = 1 
goal: SignType.pos = 1

full_name: SignType.instMul
code: instance : Mul SignType 
goal: Mul SignType

full_name: SignType.LE.of_neg
code: /-- The less-than-or-equal relation on signs. -/
protected inductive LE : SignType → SignType → Prop
  | of_neg (a) : SignType.LE neg a
  | zero : SignType.LE zero zero
  | of_pos (a) : SignType.LE a pos
goal: SignType.neg.LE a

full_name: SignType.LE.zero
code: /-- The less-than-or-equal relation on signs. -/
protected inductive LE : SignType → SignType → Prop
  | of_neg (a) : SignType.LE neg a
  | zero : SignType.LE zero zero
  | of_pos (a) : SignType.LE a pos
goal: SignType.zero.LE SignType.zero

full_name: SignType.LE
code: /-- The less-than-or-equal relation on signs. -/
protected inductive LE : SignType → SignType → Prop
  | of_neg (a) : SignType.LE neg a
  | zero : SignType.LE zero zero
  | of_pos (a) : SignType.LE a pos
goal: SignType → SignType → Prop

full_name: SignType.LE.of_pos
code: /-- The less-than-or-equal relation on signs. -/
protected inductive LE : SignType → SignType → Prop
  | of_neg (a) : SignType.LE neg a
  | zero : SignType.LE zero zero
  | of_pos (a) : SignType.LE a pos
goal: a.LE SignType.pos

full_name: SignType.instLE
code: instance : LE SignType 
goal: LE SignType

full_name: SignType.LE.decidableRel
code: instance LE.decidableRel : DecidableRel SignType.LE 
goal: DecidableRel SignType.LE

full_name: SignType.decidableEq
code: instance decidableEq : DecidableEq SignType 
goal: DecidableEq SignType

full_name: _private.Mathlib.Data.Sign.0.SignType.mul_comm
code: private lemma mul_comm : ∀ (a b : SignType), a * b = b * a 
goal: a * b = b * a

full_name: _private.Mathlib.Data.Sign.0.SignType.mul_assoc
code: private lemma mul_assoc : ∀ (a b c : SignType), (a * b) * c = a * (b * c) 
goal: a * b * c = a * (b * c)

full_name: SignType.instCommGroupWithZero
code: instance : CommGroupWithZero SignType 
goal: CommGroupWithZero SignType

full_name: _private.Mathlib.Data.Sign.0.SignType.le_antisymm
code: private lemma le_antisymm (a b : SignType) (_ : a ≤ b) (_ : b ≤ a) : a = b 
goal: a ≤ b → b ≤ a → a = b

full_name: _private.Mathlib.Data.Sign.0.SignType.le_trans
code: private lemma le_trans (a b c : SignType) (_ : a ≤ b) (_ : b ≤ c) : a ≤ c 
goal: a ≤ b → b ≤ c → a ≤ c

full_name: SignType.instLinearOrder
code: instance : LinearOrder SignType 
goal: LinearOrder SignType

full_name: SignType.instBoundedOrder
code: instance : BoundedOrder SignType 
goal: BoundedOrder SignType

full_name: SignType.instHasDistribNeg
code: instance : HasDistribNeg SignType 
goal: HasDistribNeg SignType

full_name: SignType.fin3Equiv
code: /-- `SignType` is equivalent to `Fin 3`. -/
def fin3Equiv : SignType ≃* Fin 3 
goal: SignType ≃* Fin 3

full_name: SignType.nonneg_iff
code: theorem nonneg_iff {a : SignType} : 0 ≤ a ↔ a = 0 ∨ a = 1 
goal: 0 ≤ a ↔ a = 0 ∨ a = 1

full_name: SignType.nonneg_iff_ne_neg_one
code: theorem nonneg_iff_ne_neg_one {a : SignType} : 0 ≤ a ↔ a ≠ -1 
goal: 0 ≤ a ↔ a ≠ -1

full_name: SignType.neg_one_lt_iff
code: theorem neg_one_lt_iff {a : SignType} : -1 < a ↔ 0 ≤ a 
goal: -1 < a ↔ 0 ≤ a

full_name: SignType.nonpos_iff
code: theorem nonpos_iff {a : SignType} : a ≤ 0 ↔ a = -1 ∨ a = 0 
goal: a ≤ 0 ↔ a = -1 ∨ a = 0

full_name: SignType.nonpos_iff_ne_one
code: theorem nonpos_iff_ne_one {a : SignType} : a ≤ 0 ↔ a ≠ 1 
goal: a ≤ 0 ↔ a ≠ 1

full_name: SignType.lt_one_iff
code: theorem lt_one_iff {a : SignType} : a < 1 ↔ a ≤ 0 
goal: a < 1 ↔ a ≤ 0

full_name: SignType.neg_iff
code: @[simp]
theorem neg_iff {a : SignType} : a < 0 ↔ a = -1 
goal: a < 0 ↔ a = -1

full_name: SignType.le_neg_one_iff
code: @[simp]
theorem le_neg_one_iff {a : SignType} : a ≤ -1 ↔ a = -1 
goal: a ≤ -1 ↔ a = -1

full_name: SignType.pos_iff
code: @[simp]
theorem pos_iff {a : SignType} : 0 < a ↔ a = 1 
goal: 0 < a ↔ a = 1

full_name: SignType.one_le_iff
code: @[simp]
theorem one_le_iff {a : SignType} : 1 ≤ a ↔ a = 1 
goal: 1 ≤ a ↔ a = 1

full_name: SignType.neg_one_le
code: @[simp]
theorem neg_one_le (a : SignType) : -1 ≤ a 
goal: -1 ≤ a

full_name: SignType.le_one
code: @[simp]
theorem le_one (a : SignType) : a ≤ 1 
goal: a ≤ 1

full_name: SignType.not_lt_neg_one
code: @[simp]
theorem not_lt_neg_one (a : SignType) : ¬a < -1 
goal: ¬a < -1

full_name: SignType.not_one_lt
code: @[simp]
theorem not_one_lt (a : SignType) : ¬1 < a 
goal: ¬1 < a

full_name: SignType.self_eq_neg_iff
code: @[simp]
theorem self_eq_neg_iff (a : SignType) : a = -a ↔ a = 0 
goal: a = -a ↔ a = 0

full_name: SignType.neg_eq_self_iff
code: @[simp]
theorem neg_eq_self_iff (a : SignType) : -a = a ↔ a = 0 
goal: -a = a ↔ a = 0

full_name: SignType.neg_one_lt_one
code: @[simp]
theorem neg_one_lt_one : (-1 : SignType) < 1 
goal: -1 < 1

full_name: SignType.cast
code: /-- 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]. -/
@[coe]
def cast : SignType → α
  
goal: SignType → α

full_name: SignType.instCoeTC
code: instance : CoeTC SignType α 
goal: CoeTC SignType α

full_name: SignType.map_cast'
code: /-- Casting out of `SignType` respects composition with functions preserving `0, 1, -1`. -/
lemma map_cast' {β : Type*} [One β] [Neg β] [Zero β]
    (f : α → β) (h₁ : f 1 = 1) (h₂ : f 0 = 0) (h₃ : f (-1) = -1) (s : SignType) :
    f s = s 
goal: f ↑s = ↑s

full_name: SignType.map_cast
code: /-- Casting out of `SignType` respects composition with suitable bundled homomorphism types. -/
lemma map_cast {α β F : Type*} [AddGroupWithOne α] [One β] [SubtractionMonoid β]
    [FunLike F α β] [AddMonoidHomClass F α β] [OneHomClass F α β] (f : F) (s : SignType) :
    f s = s 
goal: f ↑s = ↑s

full_name: SignType.coe_zero
code: @[simp]
theorem coe_zero : ↑(0 : SignType) = (0 : α) 
goal: ↑0 = 0

full_name: SignType.coe_one
code: @[simp]
theorem coe_one : ↑(1 : SignType) = (1 : α) 
goal: ↑1 = 1

full_name: SignType.coe_neg_one
code: @[simp]
theorem coe_neg_one : ↑(-1 : SignType) = (-1 : α) 
goal: ↑(-1) = -1

full_name: SignType.coe_neg
code: @[simp, norm_cast]
lemma coe_neg {α : Type*} [One α] [SubtractionMonoid α] (s : SignType) :
    (↑(-s) : α) = -↑s 
goal: ↑(-s) = -↑s

full_name: SignType.intCast_cast
code: /-- Casting `SignType → ℤ → α` is the same as casting directly `SignType → α`. -/
@[simp, norm_cast]
lemma intCast_cast {α : Type*} [AddGroupWithOne α] (s : SignType) : ((s : ℤ) : α) = s 
goal: ↑↑s = ↑s

full_name: SignType.castHom
code: /-- `SignType.cast` as a `MulWithZeroHom`. -/
@[simps]
def castHom {α} [MulZeroOneClass α] [HasDistribNeg α] : SignType →*₀ α 
goal: SignType →*₀ α

full_name: SignType.castHom_apply
code: /-- `SignType.cast` as a `MulWithZeroHom`. -/
@[simps]
def castHom {α} [MulZeroOneClass α] [HasDistribNeg α] : SignType →*₀ α 
goal: ∀ (a : SignType), SignType.castHom a = ↑a

full_name: SignType.univ_eq
code: theorem univ_eq : (Finset.univ : Finset SignType) = {0, -1, 1} 
goal: Finset.univ = {0, -1, 1}

full_name: SignType.range_eq
code: theorem range_eq {α} (f : SignType → α) : Set.range f = {f zero, f neg, f pos} 
goal: Set.range f = {f SignType.zero, f SignType.neg, f SignType.pos}

full_name: SignType.coe_mul
code: @[simp, norm_cast] lemma coe_mul {α} [MulZeroOneClass α] [HasDistribNeg α] (a b : SignType) :
    ↑(a * b) = (a : α) * b 
goal: ↑(a * b) = ↑a * ↑b

full_name: SignType.coe_pow
code: @[simp, norm_cast] lemma coe_pow {α} [MonoidWithZero α] [HasDistribNeg α] (a : SignType) (k : ℕ) :
    ↑(a ^ k) = (a : α) ^ k 
goal: ↑(a ^ k) = ↑a ^ k

full_name: SignType.coe_zpow
code: @[simp, norm_cast] lemma coe_zpow {α} [GroupWithZero α] [HasDistribNeg α] (a : SignType) (k : ℤ) :
    ↑(a ^ k) = (a : α) ^ k 
goal: ↑(a ^ k) = ↑a ^ k

full_name: SignType.sign
code: /-- The sign of an element is 1 if it's positive, -1 if negative, 0 otherwise. -/
def SignType.sign : α →o SignType 
goal: α →o SignType

full_name: sign_apply
code: theorem sign_apply : sign a = ite (0 < a) 1 (ite (a < 0) (-1) 0) 
goal: SignType.sign a = if 0 < a then 1 else if a < 0 then -1 else 0

full_name: sign_zero
code: @[simp]
theorem sign_zero : sign (0 : α) = 0 
goal: SignType.sign 0 = 0

full_name: sign_pos
code: @[simp]
theorem sign_pos (ha : 0 < a) : sign a = 1 
goal: SignType.sign a = 1

full_name: sign_neg
code: @[simp]
theorem sign_neg (ha : a < 0) : sign a = -1 
goal: SignType.sign a = -1

full_name: sign_eq_one_iff
code: theorem sign_eq_one_iff : sign a = 1 ↔ 0 < a 
goal: SignType.sign a = 1 ↔ 0 < a

full_name: sign_eq_neg_one_iff
code: theorem sign_eq_neg_one_iff : sign a = -1 ↔ a < 0 
goal: SignType.sign a = -1 ↔ a < 0

full_name: StrictMono.sign_comp
code: /-- `SignType.sign` respects strictly monotone zero-preserving maps. -/
lemma StrictMono.sign_comp {β F : Type*} [Zero β] [Preorder β] [DecidableRel ((· < ·) : β → β → _)]
    [FunLike F α β] [ZeroHomClass F α β] {f : F} (hf : StrictMono f) (a : α) :
    sign (f a) = sign a 
goal: SignType.sign (f a) = SignType.sign a

full_name: sign_eq_zero_iff
code: @[simp]
theorem sign_eq_zero_iff : sign a = 0 ↔ a = 0 
goal: SignType.sign a = 0 ↔ a = 0

full_name: sign_ne_zero
code: theorem sign_ne_zero : sign a ≠ 0 ↔ a ≠ 0 
goal: SignType.sign a ≠ 0 ↔ a ≠ 0

full_name: sign_nonneg_iff
code: @[simp]
theorem sign_nonneg_iff : 0 ≤ sign a ↔ 0 ≤ a 
goal: 0 ≤ SignType.sign a ↔ 0 ≤ a

full_name: sign_nonpos_iff
code: @[simp]
theorem sign_nonpos_iff : sign a ≤ 0 ↔ a ≤ 0 
goal: SignType.sign a ≤ 0 ↔ a ≤ 0

full_name: sign_one
code: theorem sign_one : sign (1 : α) = 1 
goal: SignType.sign 1 = 1

full_name: sign_intCast
code: @[simp]
lemma sign_intCast {α : Type*} [OrderedRing α] [Nontrivial α]
    [DecidableRel ((· < ·) : α → α → Prop)] (n : ℤ) :
    sign (n : α) = sign n 
goal: SignType.sign ↑n = SignType.sign n

full_name: sign_mul
code: theorem sign_mul (x y : α) : sign (x * y) = sign x * sign y 
goal: SignType.sign (x * y) = SignType.sign x * SignType.sign y

full_name: sign_mul_abs
code: @[simp] theorem sign_mul_abs (x : α) : (sign x * |x| : α) = x 
goal: ↑(SignType.sign x) * |x| = x

full_name: abs_mul_sign
code: @[simp] theorem abs_mul_sign (x : α) : (|x| * sign x : α) = x 
goal: |x| * ↑(SignType.sign x) = x

full_name: sign_mul_self
code: @[simp]
theorem sign_mul_self (x : α) : sign x * x = |x| 
goal: ↑(SignType.sign x) * x = |x|

full_name: self_mul_sign
code: @[simp]
theorem self_mul_sign (x : α) : x * sign x = |x| 
goal: x * ↑(SignType.sign x) = |x|

full_name: signHom
code: /-- `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`) -/
def signHom : α →*₀ SignType 
goal: α →*₀ SignType

full_name: sign_pow
code: theorem sign_pow (x : α) (n : ℕ) : sign (x ^ n) = sign x ^ n 
goal: SignType.sign (x ^ n) = SignType.sign x ^ n

full_name: Left.sign_neg
code: theorem Left.sign_neg [CovariantClass α α (· + ·) (· < ·)] (a : α) : sign (-a) = -sign a 
goal: SignType.sign (-a) = -SignType.sign a

full_name: Right.sign_neg
code: theorem Right.sign_neg [CovariantClass α α (Function.swap (· + ·)) (· < ·)] (a : α) :
    sign (-a) = -sign a 
goal: SignType.sign (-a) = -SignType.sign a

full_name: sign_sum
code: theorem sign_sum {ι : Type*} {s : Finset ι} {f : ι → α} (hs : s.Nonempty) (t : SignType)
    (h : ∀ i ∈ s, sign (f i) = t) : sign (∑ i ∈ s, f i) = t 
goal: SignType.sign (∑ i ∈ s, f i) = t

full_name: Int.sign_eq_sign
code: theorem sign_eq_sign (n : ℤ) : Int.sign n = SignType.sign n 
goal: n.sign = ↑(SignType.sign n)

full_name: _private.Mathlib.Data.Sign.0.exists_signed_sum_aux
code: private theorem exists_signed_sum_aux {α : Type u_1} [DecidableEq α] (s : Finset α) (f : α → ℤ) :
    ∃ (β : Type u_1) (t : Finset β) (sgn : β → SignType) (g : β → α),
      (∀ b, g b ∈ s) ∧
        (t.card = ∑ a ∈ s, (f a).natAbs) ∧
          ∀ a ∈ s, (∑ b ∈ t, if g b = a then (sgn b : ℤ) else 0) = f a 
goal: ∃ β t sgn g,
  (∀ (b : β), g b ∈ s) ∧ t.card = ∑ a ∈ s, (f a).natAbs ∧ ∀ a ∈ s, (∑ b ∈ t, if g b = a then ↑(sgn b) else 0) = f a

full_name: exists_signed_sum
code: /-- We can decompose a sum of absolute value `n` into a sum of `n` signs. -/
theorem exists_signed_sum {α : Type u_1} [DecidableEq α] (s : Finset α) (f : α → ℤ) :
    ∃ (β : Type u_1) (_ : Fintype β) (sgn : β → SignType) (g : β → α),
      (∀ b, g b ∈ s) ∧
        (Fintype.card β = ∑ a ∈ s, (f a).natAbs) ∧
          ∀ a ∈ s, (∑ b, if g b = a then (sgn b : ℤ) else 0) = f a 
goal: ∃ β x sgn g,
  (∀ (b : β), g b ∈ s) ∧
    Fintype.card β = ∑ a ∈ s, (f a).natAbs ∧ ∀ a ∈ s, (∑ b : β, if g b = a then ↑(sgn b) else 0) = f a

full_name: exists_signed_sum'
code: /-- We can decompose a sum of absolute value less than `n` into a sum of at most `n` signs. -/
theorem exists_signed_sum' {α : Type u_1} [Nonempty α] [DecidableEq α] (s : Finset α) (f : α → ℤ)
    (n : ℕ) (h : (∑ i ∈ s, (f i).natAbs) ≤ n) :
    ∃ (β : Type u_1) (_ : Fintype β) (sgn : β → SignType) (g : β → α),
      (∀ b, g b ∉ s → sgn b = 0) ∧
        Fintype.card β = n ∧ ∀ a ∈ s, (∑ i, if g i = a then (sgn i : ℤ) else 0) = f a 
goal: ∃ β x sgn g,
  (∀ (b : β), g b ∉ s → sgn b = 0) ∧ Fintype.card β = n ∧ ∀ a ∈ s, (∑ i : β, if g i = a then ↑(sgn i) else 0) = f a