Documentation

Mathlib.Data.Sign.Defs

Sign type #

This file defines the type of signs $\{-1, 0, 1\}$ and its basic arithmetic instances.

inductive SignType :

The type of signs.

Instances For
    inductive SignType.LE :

    The less-than-or-equal relation on signs.

    Instances For

      SignType is equivalent to Fin 3.

      Equations
        Instances For
          @[simp]
          theorem SignType.neg_iff {a : SignType} :
          a < 0 a = -1
          @[simp]
          theorem SignType.le_neg_one_iff {a : SignType} :
          a -1 a = -1
          @[simp]
          theorem SignType.pos_iff {a : SignType} :
          0 < a a = 1
          @[simp]
          theorem SignType.one_le_iff {a : SignType} :
          1 a a = 1
          @[simp]
          theorem SignType.le_one (a : SignType) :
          a 1
          @[simp]
          theorem SignType.neg_lt_neg_iff {a b : SignType} :
          -a < -b b < a
          def SignType.cast {α : Type u_1} [Zero α] [One α] [Neg α] :
          SignTypeα

          Turn a SignType into zero, one, or minus one. This is a coercion instance.

          Equations
            Instances For
              instance SignType.instCoeDep {α : Type u_1} [Zero α] [One α] [Neg α] (s : SignType) :

              This can't be a CoeTail or Coe instance because we don't want it to fire when SignType isn't involved in the coercion (or CoeHead or CoeOut because of outParams). The only other user-exposed option is CoeDep then, which allows us to match on both given and expected type.

              Equations
                theorem SignType.map_cast' {α : Type u_1} [Zero α] [One α] [Neg α] {β : Type u_2} [One β] [Neg β] [Zero β] (f : αβ) (h₁ : f 1 = 1) (h₂ : f 0 = 0) (h₃ : f (-1) = -1) (s : SignType) :
                f s = s

                Casting out of SignType respects composition with functions preserving 0, 1, -1.

                theorem SignType.map_cast {α : Type u_2} {β : Type u_3} {F : Type u_4} [AddGroupWithOne α] [One β] [SubtractionMonoid β] [FunLike F α β] [AddMonoidHomClass F α β] [OneHomClass F α β] (f : F) (s : SignType) :
                f s = s

                Casting out of SignType respects composition with suitable bundled homomorphism types.

                @[simp]
                theorem SignType.coe_zero {α : Type u_1} [Zero α] [One α] [Neg α] :
                0 = 0
                @[simp]
                theorem SignType.coe_one {α : Type u_1} [Zero α] [One α] [Neg α] :
                1 = 1
                @[simp]
                theorem SignType.coe_neg_one {α : Type u_1} [Zero α] [One α] [Neg α] :
                (-1) = -1
                @[simp]
                theorem SignType.coe_neg {α : Type u_2} [One α] [SubtractionMonoid α] (s : SignType) :
                ↑(-s) = -s
                def SignType.sign {α : Type u_1} [Zero α] [Preorder α] [DecidableLT α] :

                The sign of an element is 1 if it's positive, -1 if negative, 0 otherwise.

                Equations
                  Instances For
                    theorem sign_apply {α : Type u_1} [Zero α] [Preorder α] [DecidableLT α] {a : α} :
                    SignType.sign a = if 0 < a then 1 else if a < 0 then -1 else 0
                    @[simp]
                    theorem sign_zero {α : Type u_1} [Zero α] [Preorder α] [DecidableLT α] :
                    @[simp]
                    theorem sign_pos {α : Type u_1} [Zero α] [Preorder α] [DecidableLT α] {a : α} (ha : 0 < a) :
                    @[simp]
                    theorem sign_neg {α : Type u_1} [Zero α] [Preorder α] [DecidableLT α] {a : α} (ha : a < 0) :
                    theorem sign_eq_one_iff {α : Type u_1} [Zero α] [Preorder α] [DecidableLT α] {a : α} :
                    theorem sign_eq_neg_one_iff {α : Type u_1} [Zero α] [Preorder α] [DecidableLT α] {a : α} :
                    SignType.sign a = -1 a < 0
                    theorem StrictMono.sign_comp {α : Type u_1} [Zero α] [LinearOrder α] {β : Type u_2} {F : Type u_3} [Zero β] [Preorder β] [DecidableLT β] [FunLike F α β] [ZeroHomClass F α β] {f : F} (hf : StrictMono f) (a : α) :

                    SignType.sign respects strictly monotone zero-preserving maps.

                    @[simp]
                    theorem sign_eq_zero_iff {α : Type u_1} [Zero α] [LinearOrder α] {a : α} :
                    theorem sign_ne_zero {α : Type u_1} [Zero α] [LinearOrder α] {a : α} :
                    @[simp]
                    theorem sign_nonneg_iff {α : Type u_1} [Zero α] [LinearOrder α] {a : α} :
                    @[simp]
                    theorem sign_nonpos_iff {α : Type u_1} [Zero α] [LinearOrder α] {a : α} :
                    theorem sign_eq_sign_or_eq_neg {α : Type u_1} [Zero α] [LinearOrder α] {a b : α} (ha : a 0) (hb : b 0) :