Eine aufbereitete Darstellung der Quelle

 
     
 
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung


Quelle  Fin.lean   Sprache: Lean

 

/-
Copyright (c) 2022 Eric Rodriguez. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Rodriguez
-/

module

public import Mathlib.Order.Fin.Basic
public import Mathlib.Order.SuccPred.Basic

/-!
# `SuccOrder` and `PredOrder` of `Fin n`

In this file, we show that `Fin n` is both a `SuccOrder` and a `PredOrder`. Note that they are
also archimedean, but this is derived from the general instance for well-orderings as opposed
to a specific `Fin` instance.
-/


public section


namespace Fin

instance : ∀ {n : ℕ}, SuccOrder (Fin n)
  | 0 => by constructor <;> intro a <;> exact elim0 a
  | n + 1 =>
    SuccOrder.ofCore (Fin.lastCases (Fin.last n) Fin.succ)
      (fun {i} hi j ↦ by
        obtain ⟨i, rfl⟩ := Fin.eq_castSucc_of_ne_last (by simpa using! hi)
        simp [castSucc_lt_iff_succ_le])
      (fun i hi ↦ by
        obtain rfl : i = Fin.last n := by simpa using! hi
        simp)

lemma orderSucc_eq {n : ℕ} :
    Order.succ = Fin.lastCases (Fin.last n) Fin.succ := rfl

lemma orderSucc_apply {n : ℕ} (i : Fin (n + 1)) :
    Order.succ i = Fin.lastCases (Fin.last n) Fin.succ i := rfl

@[simp]
lemma orderSucc_last (n : ℕ) :
    Order.succ (Fin.last n) = Fin.last n := by
  simp [orderSucc_apply]

@[simp]
lemma orderSucc_castSucc {n : ℕ} (i : Fin n) :
    Order.succ i.castSucc = i.succ := by
  simp [orderSucc_apply]

instance : ∀ {n : ℕ}, PredOrder (Fin n)
  | 0 => by constructor <;> first | intro a; exact elim0 a
  | n + 1 =>
    PredOrder.ofCore
      (Fin.cases 0 Fin.castSucc)
      (fun {i} hi j ↦ by
        obtain ⟨i, rfl⟩ := Fin.eq_succ_of_ne_zero (by simpa using! hi)
        simp [le_castSucc_iff])
      (fun i hi ↦ by
        obtain rfl : i = 0 := by simpa using! hi
        rfl)

lemma orderSucc_lt_iff : ∀ {n : ℕ} {i j : Fin n}, Order.succ j < i ↔ (j : ℕ) + 1 < i
  | n + 1, i, j => by
    induction j using Fin.lastCases with
    | last => rw [Fin.orderSucc_last]; grind
    | cast j' => rw [Fin.orderSucc_castSucc]; grind

lemma orderPred_eq {n : ℕ} :
    Order.pred = Fin.cases 0 Fin.castSucc (n := n) := rfl

lemma orderPred_apply {n : ℕ} (i : Fin (n + 1)) :
    Order.pred i = Fin.cases 0 Fin.castSucc i := rfl

@[simp]
lemma orderPred_zero (n : ℕ) :
    Order.pred (0 : Fin (n + 1)) = 0 :=
  rfl

@[simp]
lemma orderPred_succ {n : ℕ} (i : Fin n) :
    Order.pred i.succ = i.castSucc :=
  rfl

lemma lt_orderPred_iff : ∀ {n : ℕ} {i j : Fin n}, i < Order.pred j ↔ (i : ℕ) + 1 < j
  | n + 1, i, j => by
    induction j using Fin.cases with
    | zero => rw [orderPred_zero]; grind
    | succ j' => rw [Fin.orderPred_succ]; grind

end Fin

Messung
CHZG
9310010097

¤ Dauer der Verarbeitung: 0.11 Sekunden  ¤

*© Formatika GbR, Deutschland







                                                                                                                                                                                                                                                                                                                                                                                                     

 

Neuigkeiten

Aktuelles
Motto des Tages

Open Source Software


Gedichte
Musik
Bilder

Jenseits des Üblichen

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1,188,088
#Domains=862,510