Equations
Instances For
coercions and constructions #
Equations
Instances For
Equations
Instances For
Equations
Instances For
This is not a global instance, but may be activated locally via open Fin.NatCast in ....
This is not an instance because the binop% elaborator assumes that
there are no non-trivial coercion loops,
but this introduces a coercion from Nat to Fin n and back.
Non-trivial loops lead to undesirable and counterintuitive elaboration behavior.
For example, for x : Fin k and n : Nat,
it causes x < n to be elaborated as x < ↑n rather than ↑x < n,
silently introducing wraparound arithmetic.
Instances For
This is not a global instance, but may be activated locally via open Fin.IntCast in ....
See the doc-string for Fin.NatCast.instNatCast for more details.
Equations
- Fin.IntCast.instIntCast n = { intCast := Fin.intCast }
Instances For
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
Equations
Instances For
pred #
Recursion and induction principles #
An induction principle for Fin that considers a given i : Fin n as given by a sequence of i
applications of Fin.succ.
The cases in the induction are:
zerodemonstrates the motive for(0 : Fin (n + 1))for all boundsnsuccdemonstrates the motive forFin.succapplied to an arbitraryFinfor an arbitrary boundn
Unlike Fin.induction, the motive quantifies over the bound, and the bound varies at each inductive
step. Fin.succRecOn is a version of this induction principle that takes the Fin argument first.
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
An induction principle for Fin that considers a given i : Fin n as given by a sequence of i
applications of Fin.succ.
The cases in the induction are:
zerodemonstrates the motive for(0 : Fin (n + 1))for all boundsnsuccdemonstrates the motive forFin.succapplied to an arbitraryFinfor an arbitrary boundn
Unlike Fin.induction, the motive quantifies over the bound, and the bound varies at each inductive
step. Fin.succRec is a version of this induction principle that takes the Fin argument last.
Equations
- i.succRecOn zero succ = Fin.succRec zero succ i
Instances For
Proves a statement by induction on the underlying Nat value in a Fin (n + 1).
For the induction:
zerois the base case, demonstratingmotive 0.succis the inductive step, assuming the motive fori : Fin n(lifted toFin (n + 1)withFin.castSucc) and demonstrating it fori.succ.
Fin.inductionOn is a version of this induction principle that takes the Fin as its first
parameter, Fin.cases is the corresponding case analysis operator, and Fin.reverseInduction is a
version that starts at the greatest value instead of 0.
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
Proves a statement by induction on the underlying Nat value in a Fin (n + 1).
For the induction:
zerois the base case, demonstratingmotive 0.succis the inductive step, assuming the motive fori : Fin n(lifted toFin (n + 1)withFin.castSucc) and demonstrating it fori.succ.
Fin.induction is a version of this induction principle that takes the Fin as its last
parameter.
Equations
- i.inductionOn zero succ = Fin.induction zero succ i
Instances For
Proves a statement by cases on the underlying Nat value in a Fin (n + 1).
The two cases are:
zero, used when the value is of the form(0 : Fin (n + 1))succ, used when the value is of the form(j : Fin n).succ
The corresponding induction principle is Fin.induction.
Equations
- Fin.cases zero succ i = Fin.induction zero (fun (i : Fin n) (x : motive i.castSucc) => succ i) i
Instances For
Proves a statement by reverse induction on the underlying Nat value in a Fin (n + 1).
For the induction:
lastis the base case, demonstratingmotive (Fin.last n).castis the inductive step, assuming the motive for(j : Fin n).succand demonstrating it for the predecessorj.castSucc.
Fin.induction is the non-reverse induction principle.
Equations
- Fin.reverseInduction last cast i = Fin.reverseInduction.go✝ cast i n ⋯ ⋯ last
Instances For
Proves a statement by cases on the underlying Nat value in a Fin (n + 1), checking whether the
value is the greatest representable or a predecessor of some other.
The two cases are:
The corresponding induction principle is Fin.reverseInduction.
Equations
- Fin.lastCases last cast i = Fin.reverseInduction last (fun (i : Fin n) (x : motive i.succ) => cast i) i
Instances For
A case analysis operator for i : Fin (m + n) that separately handles the cases where i < m and
where m ≤ i < m + n.
The first case, where i < m, is handled by left. In this case, i can be represented as
Fin.castAdd n (j : Fin m).
The second case, where m ≤ i < m + n, is handled by right. In this case, i can be represented
as Fin.natAdd m (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) ⋯)