coercions and constructions #
order #
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
.
castSucc i
is positive when i
is positive
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 = Fin.elim0 i
- Fin.succRec zero succ { val := 0, isLt := isLt } = Eq.mpr ⋯ (zero n)
- Fin.succRec zero succ { val := Nat.succ i, isLt := h } = succ n { val := i, isLt := ⋯ } (Fin.succRec zero succ { val := i, isLt := ⋯ })
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
- Fin.succRecOn i 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 { val := 0, isLt := hi } = Eq.mpr ⋯ zero
- Fin.induction zero succ { val := Nat.succ i, isLt := hi } = succ { val := i, isLt := ⋯ } (Fin.induction zero succ { val := i, isLt := ⋯ })
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
- Fin.inductionOn i 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 (Fin.castSucc i)) => 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 := { val := ↑i, isLt := ⋯ }; cast j (Fin.reverseInduction last cast (Fin.succ j))
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 (Fin.succ i)) => 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 (Fin.castLT i hi) else ⋯ ▸ right (Fin.subNat m (Fin.cast ⋯ i) ⋯)