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
.fz
corresponds to0
andfs n
corresponds ton
.Fin2.toNat
,Fin2.optOfNat
,Fin2.ofNat'
: Conversions to and fromℕ
.ofNat' m
takes a proof thatm < n
through the classFin2.IsLT
.Fin2.add k
: Takesi : Fin2 n
toi + k : Fin2 (n + k)
.Fin2.left
: EmbedsFin2 n
intoFin2 (n + k)
.Fin2.insertPerm a
: Permutation ofFin2 n
which cycles0, ..., a - 1
and leavesa, ..., n - 1
unchanged.Fin2.remapLeft f
: FunctionFin2 (m + k) → Fin2 (n + k)
by applyingf : Fin m → Fin n
to0, ..., m - 1
and sendingm + i
ton + 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
Converts a natural into a Fin2
if it is in range
Equations
- Fin2.optOfNat x = none
- Fin2.optOfNat 0 = some Fin2.fz
- Fin2.optOfNat k.succ = Fin2.fs <$> Fin2.optOfNat k
Instances For
insertPerm a
is a permutation of Fin2 n
with the following properties:
insertPerm a i = i+1
ifi < a
insertPerm a a = 0
insertPerm a i = i
ifi > 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_4 }