Documentation

Mathlib.Order.Fin.Basic

Fin n forms a bounded linear order #

This file contains the linear ordered instance on Fin n.

Fin n is the type whose elements are natural numbers smaller than n. This file expands on the development in the core library.

Main definitions #

Instances #

Extra instances to short-circuit type class resolution #

These also prevent non-computable instances being used to construct these instances non-computably.

Miscellaneous lemmas #

theorem Fin.bot_eq_zero (n : ℕ) :
⊥ = 0
@[simp]
theorem Fin.rev_bot {n : ℕ} [NeZero n] :
⊥.rev = ⊤
@[simp]
theorem Fin.rev_top {n : ℕ} [NeZero n] :
⊤.rev = ⊥
theorem Fin.rev_last_eq_bot (n : ℕ) :
(last n).rev = ⊥
theorem Fin.strictMono_pred_comp {n : ℕ} {α : Type u_1} [Preorder α] {f : α → Fin (n + 1)} (hf : ∀ (a : α), f a ≠ 0) (hf₂ : StrictMono f) :
StrictMono fun (a : α) => (f a).pred ⋯
theorem Fin.monotone_pred_comp {n : ℕ} {α : Type u_1} [Preorder α] {f : α → Fin (n + 1)} (hf : ∀ (a : α), f a ≠ 0) (hf₂ : Monotone f) :
Monotone fun (a : α) => (f a).pred ⋯
theorem Fin.strictMono_castPred_comp {n : ℕ} {α : Type u_1} [Preorder α] {f : α → Fin (n + 1)} (hf : ∀ (a : α), f a ≠ last n) (hf₂ : StrictMono f) :
StrictMono fun (a : α) => (f a).castPred ⋯
theorem Fin.monotone_castPred_comp {n : ℕ} {α : Type u_1} [Preorder α] {f : α → Fin (n + 1)} (hf : ∀ (a : α), f a ≠ last n) (hf₂ : Monotone f) :
Monotone fun (a : α) => (f a).castPred ⋯
theorem Fin.strictMono_iff_lt_succ {n : ℕ} {α : Type u_1} [Preorder α] {f : Fin (n + 1) → α} :
StrictMono f ↔ ∀ (i : Fin n), f i.castSucc < f i.succ

A function f on Fin (n + 1) is strictly monotone if and only if f i < f (i + 1) for all i.

theorem Fin.monotone_iff_le_succ {n : ℕ} {α : Type u_1} [Preorder α] {f : Fin (n + 1) → α} :
Monotone f ↔ ∀ (i : Fin n), f i.castSucc ≤ f i.succ

A function f on Fin (n + 1) is monotone if and only if f i ≤ f (i + 1) for all i.

theorem Fin.strictAnti_iff_succ_lt {n : ℕ} {α : Type u_1} [Preorder α] {f : Fin (n + 1) → α} :
StrictAnti f ↔ ∀ (i : Fin n), f i.succ < f i.castSucc

A function f on Fin (n + 1) is strictly antitone if and only if f (i + 1) < f i for all i.

theorem Fin.antitone_iff_succ_le {n : ℕ} {α : Type u_1} [Preorder α] {f : Fin (n + 1) → α} :
Antitone f ↔ ∀ (i : Fin n), f i.succ ≤ f i.castSucc

A function f on Fin (n + 1) is antitone if and only if f (i + 1) ≤ f i for all i.

Monotonicity #

theorem Fin.cast_strictMono {k l : ℕ} (h : k = l) :
theorem Fin.strictMono_castLE {m n : ℕ} (h : n ≤ m) :
theorem Fin.strictMono_addNat {n : ℕ} (m : ℕ) :
StrictMono fun (x : Fin n) => x.addNat m
theorem Fin.strictMono_succAbove {n : ℕ} (p : Fin (n + 1)) :
StrictMono p.succAbove
theorem Fin.succAbove_lt_succAbove_iff {n : ℕ} {p : Fin (n + 1)} {i j : Fin n} :
p.succAbove i < p.succAbove j ↔ i < j
theorem Fin.succAbove_le_succAbove_iff {n : ℕ} {p : Fin (n + 1)} {i j : Fin n} :
p.succAbove i ≤ p.succAbove j ↔ i ≤ j
theorem Fin.predAbove_right_monotone {n : ℕ} (p : Fin n) :
Monotone p.predAbove
theorem Fin.predAbove_left_monotone {n : ℕ} (i : Fin (n + 1)) :
Monotone fun (p : Fin n) => p.predAbove i
def Fin.predAboveOrderHom {n : ℕ} (p : Fin n) :
Fin (n + 1) →o Fin n

Fin.predAbove p as an OrderHom.

Equations
  • p.predAboveOrderHom = { toFun := p.predAbove, monotone' := ⋯ }
Instances For
    @[simp]
    theorem Fin.predAboveOrderHom_coe {n : ℕ} (p : Fin n) (i : Fin (n + 1)) :
    p.predAboveOrderHom i = p.predAbove i

    Order isomorphisms #

    def Fin.orderIsoSubtype {n : ℕ} :
    Fin n ≃o { i : ℕ // i < n }

    The equivalence Fin n ≃ {i // i < n} is an order isomorphism.

    Equations
    Instances For
      @[simp]
      theorem Fin.orderIsoSubtype_symm_apply {n : ℕ} (a : { i : ℕ // i < n }) :
      (RelIso.symm orderIsoSubtype) a = ⟨↑a, ⋯⟩
      @[simp]
      theorem Fin.orderIsoSubtype_apply {n : ℕ} (a : Fin n) :
      orderIsoSubtype a = ⟨↑a, ⋯⟩
      def Fin.castOrderIso {m n : ℕ} (eq : n = m) :

      Fin.cast as an OrderIso.

      castOrderIso eq i embeds i into an equal Fin type.

      Equations
      Instances For
        @[simp]
        theorem Fin.castOrderIso_symm_apply {m n : ℕ} (eq : n = m) (i : Fin m) :
        @[simp]
        theorem Fin.castOrderIso_apply {m n : ℕ} (eq : n = m) (i : Fin n) :
        (castOrderIso eq) i = Fin.cast eq i
        @[deprecated Fin.castOrderIso (since := "2024-05-23")]
        def Fin.castIso {m n : ℕ} (eq : n = m) :

        Alias of Fin.castOrderIso.


        Fin.cast as an OrderIso.

        castOrderIso eq i embeds i into an equal Fin type.

        Equations
        Instances For
          @[simp]
          theorem Fin.symm_castOrderIso {m n : ℕ} (h : n = m) :
          @[deprecated Fin.symm_castOrderIso (since := "2024-05-23")]
          theorem Fin.symm_castIso {m n : ℕ} (h : n = m) :

          Alias of Fin.symm_castOrderIso.

          @[simp]
          theorem Fin.castOrderIso_refl {n : ℕ} (h : n = n := ⋯) :
          @[deprecated Fin.castOrderIso_refl (since := "2024-05-23")]
          theorem Fin.castIso_refl {n : ℕ} (h : n = n := ⋯) :

          Alias of Fin.castOrderIso_refl.

          theorem Fin.castOrderIso_toEquiv {m n : ℕ} (h : n = m) :
          (castOrderIso h).toEquiv = Equiv.cast ⋯

          While in many cases Fin.castOrderIso is better than Equiv.cast/cast, sometimes we want to apply a generic lemma about cast.

          @[deprecated Fin.castOrderIso_toEquiv (since := "2024-05-23")]
          theorem Fin.castIso_to_equiv {m n : ℕ} (h : n = m) :
          (castOrderIso h).toEquiv = Equiv.cast ⋯

          Alias of Fin.castOrderIso_toEquiv.


          While in many cases Fin.castOrderIso is better than Equiv.cast/cast, sometimes we want to apply a generic lemma about cast.

          Fin.rev n as an order-reversing isomorphism.

          Equations
          Instances For
            @[simp]
            theorem Fin.revOrderIso_apply {n : ℕ} (a✝ : (Fin n)ᵒᵈ) :
            revOrderIso a✝ = (OrderDual.ofDual a✝).rev
            @[simp]
            theorem Fin.revOrderIso_symm_apply {n : ℕ} (i : Fin n) :
            revOrderIso.symm i = OrderDual.toDual i.rev

            Order embeddings #

            The inclusion map Fin n → ℕ is an order embedding.

            Equations
            Instances For
              @[simp]
              theorem Fin.valOrderEmb_apply (n : ℕ) (self : Fin n) :
              (valOrderEmb n) self = ↑self
              instance Fin.Lt.isWellOrder (n : ℕ) :
              IsWellOrder (Fin n) fun (x1 x2 : Fin n) => x1 < x2

              The ordering on Fin n is a well order.

              @[simp]
              def Fin.castLEOrderEmb {m n : ℕ} (h : n ≤ m) :

              Fin.castLE as an OrderEmbedding.

              castLEEmb h i embeds i into a larger Fin type.

              Equations
              Instances For
                @[simp]
                theorem Fin.castLEOrderEmb_apply {m n : ℕ} (h : n ≤ m) (i : Fin n) :
                @[simp]
                theorem Fin.castLEOrderEmb_toEmbedding {m n : ℕ} (h : n ≤ m) :
                (castLEOrderEmb h).toEmbedding = { toFun := castLE h, inj' := ⋯ }
                def Fin.castAddOrderEmb {n : ℕ} (m : ℕ) :
                Fin n ↪o Fin (n + m)

                Fin.castAdd as an OrderEmbedding.

                castAddEmb m i embeds i : Fin n in Fin (n+m). See also Fin.natAddEmb and Fin.addNatEmb.

                Equations
                Instances For
                  @[simp]
                  theorem Fin.castAddOrderEmb_apply {n : ℕ} (m : ℕ) (a✝ : Fin n) :
                  (castAddOrderEmb m) a✝ = castAdd m a✝
                  @[simp]
                  theorem Fin.castAddOrderEmb_toEmbedding {n : ℕ} (m : ℕ) :
                  (castAddOrderEmb m).toEmbedding = { toFun := castAdd m, inj' := ⋯ }
                  @[simp]
                  theorem Fin.castSuccOrderEmb_toEmbedding {n : ℕ} :
                  castSuccOrderEmb.toEmbedding = { toFun := castSucc, inj' := ⋯ }
                  @[simp]
                  theorem Fin.castSuccOrderEmb_apply {n : ℕ} (a✝ : Fin n) :
                  castSuccOrderEmb a✝ = a✝.castSucc
                  def Fin.addNatOrderEmb {n : ℕ} (m : ℕ) :
                  Fin n ↪o Fin (n + m)

                  Fin.addNat as an OrderEmbedding.

                  addNatOrderEmb m i adds m to i, generalizes Fin.succ.

                  Equations
                  Instances For
                    @[simp]
                    theorem Fin.addNatOrderEmb_toEmbedding {n : ℕ} (m : ℕ) :
                    (addNatOrderEmb m).toEmbedding = { toFun := fun (x : Fin n) => x.addNat m, inj' := ⋯ }
                    @[simp]
                    theorem Fin.addNatOrderEmb_apply {n : ℕ} (m : ℕ) (x✝ : Fin n) :
                    (addNatOrderEmb m) x✝ = x✝.addNat m
                    def Fin.natAddOrderEmb {m : ℕ} (n : ℕ) :
                    Fin m ↪o Fin (n + m)

                    Fin.natAdd as an OrderEmbedding.

                    natAddOrderEmb n i adds n to i "on the left".

                    Equations
                    Instances For
                      @[simp]
                      theorem Fin.natAddOrderEmb_toEmbedding {m : ℕ} (n : ℕ) :
                      (natAddOrderEmb n).toEmbedding = { toFun := natAdd n, inj' := ⋯ }
                      @[simp]
                      theorem Fin.natAddOrderEmb_apply {m : ℕ} (n : ℕ) (i : Fin m) :
                      def Fin.succAboveOrderEmb {n : ℕ} (p : Fin (n + 1)) :
                      Fin n ↪o Fin (n + 1)

                      Fin.succAbove p as an OrderEmbedding.

                      Equations
                      Instances For
                        @[simp]
                        theorem Fin.succAboveOrderEmb_apply {n : ℕ} (p : Fin (n + 1)) (i : Fin n) :
                        p.succAboveOrderEmb i = p.succAbove i
                        @[simp]
                        theorem Fin.succAboveOrderEmb_toEmbedding {n : ℕ} (p : Fin (n + 1)) :
                        p.succAboveOrderEmb.toEmbedding = { toFun := p.succAbove, inj' := ⋯ }

                        Uniqueness of order isomorphisms #

                        @[simp]
                        theorem Fin.coe_orderIso_apply {m n : ℕ} (e : Fin n ≃o Fin m) (i : Fin n) :
                        ↑(e i) = ↑i

                        If e is an orderIso between Fin n and Fin m, then n = m and e is the identity map. In this lemma we state that for each i : Fin n we have (e i : ℕ) = (i : ℕ).

                        @[deprecated StrictMono.range_inj (since := "2024-09-17")]
                        theorem Fin.strictMono_unique {n : ℕ} {α : Type u_1} [Preorder α] {f g : Fin n → α} (hf : StrictMono f) (hg : StrictMono g) (h : Set.range f = Set.range g) :
                        f = g

                        Two strictly monotone functions from Fin n are equal provided that their ranges are equal.

                        @[deprecated OrderEmbedding.range_inj (since := "2024-09-17")]
                        theorem Fin.orderEmbedding_eq {n : ℕ} {α : Type u_1} [Preorder α] {f g : Fin n ↪o α} (h : Set.range ⇑f = Set.range ⇑g) :
                        f = g

                        Two order embeddings of Fin n are equal provided that their ranges are equal.