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.
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 x = match x with | Fin2.fz => H1 | Fin2.fs n => H2 n
Instances For
Ex falso. The dependent eliminator for the empty Fin2 0 type.
Equations
- Fin2.elim0 a = nomatch a
Instances For
Converts a Fin2 into a natural.
Equations
- Fin2.toNat Fin2.fz = 0
- Fin2.toNat (Fin2.fs i) = Nat.succ (Fin2.toNat i)
Instances For
Converts a natural into a Fin2 if it is in range
Equations
- Fin2.optOfNat x = none
- Fin2.optOfNat 0 = some Fin2.fz
- Fin2.optOfNat (Nat.succ k) = Fin2.fs <$> Fin2.optOfNat k
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
- Fin2.insertPerm Fin2.fz Fin2.fz = Fin2.fz
- Fin2.insertPerm Fin2.fz (Fin2.fs j) = Fin2.fs j
- Fin2.insertPerm (Fin2.fs a) Fin2.fz = Fin2.fs Fin2.fz
- Fin2.insertPerm (Fin2.fs i) (Fin2.fs j) = match Fin2.insertPerm i j with | Fin2.fz => Fin2.fz | Fin2.fs k => Fin2.fs (Fin2.fs k)
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 (Nat.succ a) Fin2.fz = Fin2.fz
- Fin2.remapLeft f (Nat.succ a) (Fin2.fs i) = Fin2.fs (Fin2.remapLeft f a i)
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' (Nat.succ m) = Fin2.fs (Fin2.ofNat' m)
Instances For
Equations
- Fin2.instInhabitedFin2OfNatNatInstOfNatNat = { default := Fin2.fz }
Equations
- One or more equations did not get rendered due to their size.
- Fin2.instFintype 0 = { elems := ∅, complete := Fin2.instFintype.proof_4 }