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.to_nat,opt_of_nat,of_nat': Conversions to and fromℕ.of_nat' mtakes a proof thatm < nthrough the classis_lt.add k: Takesi : fin2 ntoi + k : fin2 (n + k).left: Embedsfin2 nintofin2 (n + k).insert_perm a: Permutation offin2 nwhich cycles0, ..., a - 1and leavesa, ..., n - 1unchanged.remap_left 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 n_1.fs = H2 n_1
- fin2.cases' H1 H2 fin2.fz = H1
Ex falso. The dependent eliminator for the empty fin2 0 type.
Converts a natural into a fin2 if it is in range
Equations
insert_perm a is a permutation of fin2 n with the following properties:
insert_perm a i = i+1ifi < ainsert_perm a a = 0insert_perm a i = iifi > a
remap_left 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, remap_left f k (m + i) = n + i).
Equations
- fin2.remap_left f k.succ i.fs = (fin2.remap_left f k i).fs
- fin2.remap_left f k.succ fin2.fz = fin2.fz
- fin2.remap_left f 0 i = f i
- h : m < n
This is a simple type class inference prover for proof obligations
of the form m < n where m n : ℕ.
Instances
Equations
- fin2.is_lt.zero n = {h := _}
Equations
- fin2.is_lt.succ m n = {h := _}
Equations
- fin2.inhabited = {default := fin2.fz 0}