coercions and constructions #
order #
last #
addition, numerals, and coercion from Nat #
succ and casts into larger Fin types #
Version of succ_one_eq_two
to be used by dsimp
For rewriting in the reverse direction, see Fin.cast_castAdd_left
.
The cast of the successor is the successor of the cast. See Fin.succ_cast_eq
for rewriting in
the reverse direction.
For rewriting in the reverse direction, see Fin.cast_addNat_left
.
For rewriting in the reverse direction, see Fin.cast_natAdd_right
.
pred #
recursion and induction principles #
Define motive n i
by induction on i : Fin n
interpreted as (0 : Fin (n - i)).succ.succ…
.
This function has two arguments: zero n
defines 0
-th element motive (n+1) 0
of an
(n+1)
-tuple, and succ n i
defines (i+1)
-st element of (n+1)
-tuple based on n
, i
, and
i
-th element of n
-tuple.
Equations
- Fin.succRec zero succ i = i.elim0
- Fin.succRec zero succ ⟨0, isLt⟩ = ⋯.mpr (zero n)
- Fin.succRec zero succ ⟨i.succ, h⟩ = succ n ⟨i, ⋯⟩ (Fin.succRec zero succ ⟨i, ⋯⟩)
Instances For
Define motive n i
by induction on i : Fin n
interpreted as (0 : Fin (n - i)).succ.succ…
.
This function has two arguments:
zero n
defines the 0
-th element motive (n+1) 0
of an (n+1)
-tuple, and
succ n i
defines the (i+1)
-st element of an (n+1)
-tuple based on n
, i
,
and the i
-th element of an n
-tuple.
A version of Fin.succRec
taking i : Fin n
as the first argument.
Equations
- i.succRecOn zero succ = Fin.succRec zero succ i
Instances For
Define motive i
by induction on i : Fin (n + 1)
via induction on the underlying Nat
value.
This function has two arguments: zero
handles the base case on motive 0
,
and succ
defines the inductive step using motive i.castSucc
.
Equations
- Fin.induction zero succ ⟨i, hi⟩ = Fin.induction.go zero succ i hi
Instances For
Equations
- Fin.induction.go zero succ 0 hi = ⋯.mpr zero
- Fin.induction.go zero succ i.succ hi = succ ⟨i, ⋯⟩ (Fin.induction.go zero succ i ⋯)
Instances For
Define motive i
by induction on i : Fin (n + 1)
via induction on the underlying Nat
value.
This function has two arguments: zero
handles the base case on motive 0
,
and succ
defines the inductive step using motive i.castSucc
.
A version of Fin.induction
taking i : Fin (n + 1)
as the first argument.
Equations
- i.inductionOn zero succ = Fin.induction zero succ i
Instances For
Define f : Π i : Fin n.succ, motive i
by separately handling the cases i = 0
and
i = j.succ
, j : Fin n
.
Equations
- Fin.cases zero succ i = Fin.induction zero (fun (i : Fin n) (x : motive i.castSucc) => succ i) i
Instances For
Define motive i
by reverse induction on i : Fin (n + 1)
via induction on the underlying Nat
value. This function has two arguments: last
handles the base case on motive (Fin.last n)
,
and cast
defines the inductive step using motive i.succ
, inducting downwards.
Equations
- Fin.reverseInduction last cast i = if hi : i = Fin.last n then _root_.cast ⋯ last else let j := ⟨↑i, ⋯⟩; cast j (Fin.reverseInduction last cast j.succ)
Instances For
Define f : Π i : Fin n.succ, motive i
by separately handling the cases i = Fin.last n
and
i = j.castSucc
, j : Fin n
.
Equations
- Fin.lastCases last cast i = Fin.reverseInduction last (fun (i : Fin n) (x : motive i.succ) => cast i) i
Instances For
Define f : Π i : Fin (m + n), motive i
by separately handling the cases i = castAdd n i
,
j : Fin m
and i = natAdd m j
, j : Fin n
.
Equations
- Fin.addCases left right i = if hi : ↑i < m then ⋯ ▸ left (i.castLT hi) else ⋯ ▸ right (Fin.subNat m (Fin.cast ⋯ i) ⋯)