mathlib documentation

data.​fin2

data.​fin2

inductive fin2  :
ℕ → Type

An alternate definition of fin n defined as an inductive type instead of a subtype of nat. This is useful for its induction principle and different definitional equalities.

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

Equations
def fin2.​elim0 {C : fin2 0 → Sort u} (i : fin2 0) :
C i

def fin2.​to_nat {n : ℕ} :
fin2 n → ℕ

convert a fin2 into a nat

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 : ℕ} :
fin2 n → fin2 n → fin2 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  :
ℕ → ℕ → Type
  • h : m < n

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

Instances
@[instance]

Equations
@[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