Inductive type variant of Fin #
Fin is defined as a subtype of ℕ. This file defines an equivalent type, Fin2, which is
defined inductively. This is useful for its induction principle and different definitional
equalities.
Main declarations #
Fin2 n: Inductive type variant ofFin n.fzcorresponds to0andfs ncorresponds ton.Fin2.toNat,Fin2.optOfNat,Fin2.ofNat': Conversions to and fromℕ.ofNat' mtakes a proof thatm < nthrough the classFin2.IsLT.Fin2.add k: Takesi : Fin2 ntoi + k : Fin2 (n + k).Fin2.left: EmbedsFin2 nintoFin2 (n + k).Fin2.insertPerm a: Permutation ofFin2 nwhich cycles0, ..., a - 1and leavesa, ..., n - 1unchanged.Fin2.remapLeft f: FunctionFin2 (m + k) → Fin2 (n + k)by applyingf : Fin m → Fin nto0, ..., m - 1and sendingm + iton + i.
def
Fin2.cases'
{n : ℕ}
{C : Fin2 n.succ → Sort u}
(H1 : C fz)
(H2 : (n_1 : Fin2 n) → C n_1.fs)
(i : Fin2 n.succ)
:
C i
Define a dependent function on Fin2 (succ n) by giving its value at
zero (H1) and by giving a dependent function on the rest (H2).
Equations
- Fin2.cases' H1 H2 Fin2.fz = H1
- Fin2.cases' H1 H2 n_1.fs = H2 n_1
Instances For
insertPerm a is a permutation of Fin2 n with the following properties:
insertPerm a i = i+1ifi < ainsertPerm a a = 0insertPerm a i = iifi > a
Equations
Instances For
remapLeft f k : Fin2 (m + k) → Fin2 (n + k) applies the function
f : Fin2 m → Fin2 n to inputs less than m, and leaves the right part
on the right (that is, remapLeft f k (m + i) = n + i).
Equations
- Fin2.remapLeft f 0 i = f i
- Fin2.remapLeft f _k.succ Fin2.fz = Fin2.fz
- Fin2.remapLeft f _k.succ i.fs = (Fin2.remapLeft f _k i).fs
Instances For
Use type class inference to infer the boundedness proof, so that we can directly convert a
Nat into a Fin2 n. This supports notation like &1 : Fin 3.
Equations
- Fin2.ofNat' x✝¹ = absurd ⋯ ⋯
- Fin2.ofNat' 0 = Fin2.fz
- Fin2.ofNat' m.succ = (Fin2.ofNat' m).fs
Instances For
Equations
- Fin2.instInhabitedOfNatNat = { default := Fin2.fz }
Equations
- One or more equations did not get rendered due to their size.
- Fin2.instFintype 0 = { elems := ∅, complete := Fin2.instFintype._proof_1 }