The type Fin 0 is uninhabited, so it can be used to derive any result whatsoever.
This is similar to Empty.elim. It can be thought of as a compiler-checked assertion that a code
path is unreachable, or a logical contradiction from which False and thus anything else could be
derived.
Instances For
Equations
- Fin.ofNat' n a = Fin.ofNat n a
Instances For
Remark: land/lor can be defined without using (% n), but we are trying to minimize the number of Nat theorems needed to bootstrap Lean.
Division of bounded numbers, usually invoked via the / operator.
The resulting value is that computed by the / operator on Nat. In particular, the result of
division by 0 is 0.
Examples:
(5 : Fin 10) / (2 : Fin 10) = (2 : Fin 10)(5 : Fin 10) / (0 : Fin 10) = (0 : Fin 10)(5 : Fin 10) / (7 : Fin 10) = (0 : Fin 10)
Instances For
Bitwise right shift of bounded numbers.
This operator corresponds to logical rather than arithmetic bit shifting. The new bits are always
0.
Examples:
(15 : Fin 16) >>> (1 : Fin 16) = (7 : Fin 16)(15 : Fin 16) >>> (2 : Fin 16) = (3 : Fin 16)(15 : Fin 17) >>> (2 : Fin 17) = (3 : Fin 17)
Instances For
Equations
- Fin.instShiftLeft = { shiftLeft := Fin.shiftLeft }
Equations
- Fin.instShiftRight = { shiftRight := Fin.shiftRight }
Equations
- Fin.instInhabited = { default := 0 }
Replaces the bound with another that is suitable for the value.
The proof embedded in i can be used to cast to a larger bound even if the concrete value is not
known.
Examples:
example : Fin 12 := (7 : Fin 10).castLT (by decide : 7 < 12)
example (i : Fin 10) : Fin 12 :=
i.castLT <| by
cases i; simp; omega
Instances For
Coarsens a bound to one at least as large.
See also Fin.castAdd for a version that represents the larger bound with addition rather than an
explicit inequality proof.
Equations
- Fin.castLE h i = ⟨↑i, ⋯⟩
Instances For
Coarsens a bound to one at least as large.
See also Fin.natAdd and Fin.addNat for addition functions that increase the bound, and
Fin.castLE for a version that uses an explicit inequality proof.
Equations
- Fin.castAdd m = Fin.castLE ⋯
Instances For
Coarsens a bound by one.
Equations
Instances For
Adds a natural number to a Fin, increasing the bound.
This is a generalization of Fin.succ.
Fin.natAdd is a version of this function that takes its Nat parameter first.
Examples:
Fin.addNat (5 : Fin 8) 3 = (8 : Fin 11)Fin.addNat (0 : Fin 8) 1 = (1 : Fin 9)Fin.addNat (1 : Fin 8) 2 = (3 : Fin 10)
Instances For
Adds a natural number to a Fin, increasing the bound.
This is a generalization of Fin.succ.
Fin.addNat is a version of this function that takes its Nat parameter second.
Examples:
Fin.natAdd 3 (5 : Fin 8) = (8 : Fin 11)Fin.natAdd 1 (0 : Fin 8) = (1 : Fin 9)Fin.natAdd 1 (2 : Fin 8) = (3 : Fin 9)
Equations
- Fin.natAdd n i = ⟨n + ↑i, ⋯⟩
Instances For
Subtraction of a natural number from a Fin, with the bound narrowed.
This is a generalization of Fin.pred. It is guaranteed to not underflow or wrap around.
Examples:
(5 : Fin 9).subNat 2 (by decide) = (3 : Fin 7)(5 : Fin 9).subNat 0 (by decide) = (5 : Fin 9)(3 : Fin 9).subNat 3 (by decide) = (0 : Fin 6)
Equations
- Fin.subNat m i h = ⟨↑i - m, ⋯⟩