mathlib3 documentation

data.fin.fin2

Inductive type variant of fin #

THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.

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 #

inductive fin2  :

An alternate definition of fin n defined as an inductive type instead of a subtype of .

Instances for fin2
@[protected]
def fin2.cases' {n : } {C : fin2 n.succ Sort u} (H1 : C fin2.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
def fin2.elim0 {C : fin2 0 Sort u} (i : fin2 0) :
C i

Ex falso. The dependent eliminator for the empty fin2 0 type.

def fin2.to_nat {n : } :

Converts a fin2 into a natural.

Equations
def fin2.opt_of_nat {n : } (k : ) :

Converts a natural into a fin2 if it is in range

Equations
def fin2.add {n : } (i : fin2 n) (k : ) :
fin2 (n + k)

i + k : fin2 (n + k) when i : fin2 n and k : ℕ

Equations
def fin2.left (k : ) {n : } :
fin2 n fin2 (k + n)

left k is the embedding fin2 n → fin2 (k + n)

Equations
def fin2.insert_perm {n : } :

insert_perm a is a permutation of fin2 n with the following properties:

  • insert_perm a i = i+1 if i < a
  • insert_perm a a = 0
  • insert_perm a i = i if i > a
Equations
def fin2.remap_left {m n : } (f : fin2 m fin2 n) (k : ) :
fin2 (m + k) fin2 (n + k)

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
@[class]
structure fin2.is_lt (m n : ) :
  • h : m < n

This is a simple type class inference prover for proof obligations of the form m < n where m n : ℕ.

Instances of this typeclass
Instances of other typeclasses for fin2.is_lt
  • fin2.is_lt.has_sizeof_inst
@[protected, instance]
def fin2.is_lt.zero (n : ) :
Equations
@[protected, instance]
def fin2.is_lt.succ (m n : ) [l : fin2.is_lt m n] :
Equations
def fin2.of_nat' {n : } (m : ) [fin2.is_lt m n] :

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
@[protected, instance]
Equations