File: .lake/packages/lean4/src/lean/Init/Data/Fin/Basic.lean

full_name: Fin.coeToNat
code: instance coeToNat : CoeOut (Fin n) Nat 
goal: CoeOut (Fin n) Nat

full_name: Fin.elim0
code: /--
From the empty type `Fin 0`, any desired result `α` can be derived. This is simlar to `Empty.elim`.
-/
def elim0.{u} {α : Sort u} : Fin 0 → α
  
goal: Fin 0 → α

full_name: Fin.succ
code: /--
Returns the successor of the argument.

The bound in the result type is increased:
```
(2 : Fin 3).succ = (3 : Fin 4)
```
This differs from addition, which wraps around:
```
(2 : Fin 3) + 1 = (0 : Fin 3)
```
-/
def succ : Fin n → Fin n.succ
  
goal: Fin n → Fin n.succ

full_name: Fin.ofNat
code: /--
Returns `a` modulo `n + 1` as a `Fin n.succ`.
-/
protected def ofNat {n : Nat} (a : Nat) : Fin n.succ 
goal: Fin n.succ

full_name: Fin.ofNat'
code: /--
Returns `a` modulo `n` as a `Fin n`.

The assumption `n > 0` ensures that `Fin n` is nonempty.
-/
protected def ofNat' {n : Nat} (a : Nat) (h : n > 0) : Fin n 
goal: Fin n

full_name: _private.«.lake».packages.lean4.src.lean.Init.Data.Fin.Basic.0.Fin.mlt
code: private theorem mlt {b : Nat} : {a : Nat} → a < n → b % n < n
  
goal: a < n → b % n < n

full_name: Fin.add
code: /-- Addition modulo `n` -/
protected def add : Fin n → Fin n → Fin n
  
goal: Fin n → Fin n → Fin n

full_name: Fin.mul
code: /-- Multiplication modulo `n` -/
protected def mul : Fin n → Fin n → Fin n
  
goal: Fin n → Fin n → Fin n

full_name: Fin.sub
code: /-- Subtraction modulo `n` -/
protected def sub : Fin n → Fin n → Fin n
  /-
  The definition of `Fin.sub` has been updated to improve performance.
  The right-hand-side of the following `match` was originally
  ```
  ⟨(a + (n - b)) % n, mlt h⟩
  ```
  This caused significant performance issues when testing definitional equality,
  such as `x =?= x - 1` where `x : Fin n` and `n` is a big number,
  as Lean spent a long time reducing
  ```
  ((n - 1) + x.val) % n
  ```
  For example, this was an issue for `Fin 2^64` (i.e., `UInt64`).
  This change improves performance by leveraging the fact that `Nat.add` is defined
  using recursion on the second argument.
  See issue #4413.
  -/
  
goal: Fin n → Fin n → Fin n

full_name: Fin.mod
code: protected def mod : Fin n → Fin n → Fin n
  
goal: Fin n → Fin n → Fin n

full_name: Fin.div
code: protected def div : Fin n → Fin n → Fin n
  
goal: Fin n → Fin n → Fin n

full_name: Fin.modn
code: def modn : Fin n → Nat → Fin n
  
goal: Fin n → Nat → Fin n

full_name: Fin.land
code: def land : Fin n → Fin n → Fin n
  
goal: Fin n → Fin n → Fin n

full_name: Fin.lor
code: def lor : Fin n → Fin n → Fin n
  
goal: Fin n → Fin n → Fin n

full_name: Fin.xor
code: def xor : Fin n → Fin n → Fin n
  
goal: Fin n → Fin n → Fin n

full_name: Fin.shiftLeft
code: def shiftLeft : Fin n → Fin n → Fin n
  
goal: Fin n → Fin n → Fin n

full_name: Fin.shiftRight
code: def shiftRight : Fin n → Fin n → Fin n
  
goal: Fin n → Fin n → Fin n

full_name: Fin.«instAdd_.lake»
code: instance : Add (Fin n) 
goal: Add (Fin n)

full_name: Fin.«instSub_.lake»
code: instance : Sub (Fin n) 
goal: Sub (Fin n)

full_name: Fin.«instMul_.lake»
code: instance : Mul (Fin n) 
goal: Mul (Fin n)

full_name: Fin.«instMod_.lake»
code: instance : Mod (Fin n) 
goal: Mod (Fin n)

full_name: Fin.«instDiv_.lake»
code: instance : Div (Fin n) 
goal: Div (Fin n)

full_name: Fin.«instAndOp_.lake»
code: instance : AndOp (Fin n) 
goal: AndOp (Fin n)

full_name: Fin.«instOrOp_.lake»
code: instance : OrOp (Fin n) 
goal: OrOp (Fin n)

full_name: Fin.«instXor_.lake»
code: instance : Xor (Fin n) 
goal: Xor (Fin n)

full_name: Fin.«instShiftLeft_.lake»
code: instance : ShiftLeft (Fin n) 
goal: ShiftLeft (Fin n)

full_name: Fin.«instShiftRight_.lake»
code: instance : ShiftRight (Fin n) 
goal: ShiftRight (Fin n)

full_name: Fin.instOfNat
code: instance instOfNat : OfNat (Fin (no_index (n+1))) i 
goal: OfNat (Fin (n + 1)) i

full_name: Fin.«instInhabitedHAddNatOfNat_.lake»
code: instance : Inhabited (Fin (no_index (n+1))) 
goal: Inhabited (Fin (n + 1))

full_name: Fin.zero_eta
code: @[simp] theorem zero_eta : (⟨0, Nat.zero_lt_succ _⟩ : Fin (n + 1)) = 0 
goal: ⟨0, ⋯⟩ = 0

full_name: Fin.val_ne_of_ne
code: theorem val_ne_of_ne {i j : Fin n} (h : i ≠ j) : val i ≠ val j 
goal: ↑i ≠ ↑j

full_name: Fin.modn_lt
code: theorem modn_lt : ∀ {m : Nat} (i : Fin n), m > 0 → (modn i m).val < m
  
goal: m > 0 → ↑(i.modn m) < m

full_name: Fin.val_lt_of_le
code: theorem val_lt_of_le (i : Fin b) (h : b ≤ n) : i.val < n 
goal: ↑i < n

full_name: Fin.pos
code: protected theorem pos (i : Fin n) : 0 < n 
goal: 0 < n

full_name: Fin.last
code: /-- The greatest value of `Fin (n+1)`. -/
@[inline] def last (n : Nat) : Fin (n + 1) 
goal: Fin (n + 1)

full_name: Fin.castLT
code: /-- `castLT i h` embeds `i` into a `Fin` where `h` proves it belongs into.  -/
@[inline] def castLT (i : Fin m) (h : i.1 < n) : Fin n 
goal: Fin n

full_name: Fin.castLE
code: /-- `castLE h i` embeds `i` into a larger `Fin` type.  -/
@[inline] def castLE (h : n ≤ m) (i : Fin n) : Fin m 
goal: Fin m

full_name: Fin.cast
code: /-- `cast eq i` embeds `i` into an equal `Fin` type. -/
@[inline] def cast (eq : n = m) (i : Fin n) : Fin m 
goal: Fin m

full_name: Fin.castAdd
code: /-- `castAdd m i` embeds `i : Fin n` in `Fin (n+m)`. See also `Fin.natAdd` and `Fin.addNat`. -/
@[inline] def castAdd (m) : Fin n → Fin (n + m) 
goal: Fin n → Fin (n + m)

full_name: Fin.castSucc
code: /-- `castSucc i` embeds `i : Fin n` in `Fin (n+1)`. -/
@[inline] def castSucc : Fin n → Fin (n + 1) 
goal: Fin n → Fin (n + 1)

full_name: Fin.addNat
code: /-- `addNat m i` adds `m` to `i`, generalizes `Fin.succ`. -/
def addNat (i : Fin n) (m) : Fin (n + m) 
goal: Fin (n + m)

full_name: Fin.natAdd
code: /-- `natAdd n i` adds `n` to `i` "on the left". -/
def natAdd (n) (i : Fin m) : Fin (n + m) 
goal: Fin (n + m)

full_name: Fin.rev
code: /-- Maps `0` to `n-1`, `1` to `n-2`, ..., `n-1` to `0`. -/
@[inline] def rev (i : Fin n) : Fin n 
goal: Fin n

full_name: Fin.subNat
code: /-- `subNat i h` subtracts `m` from `i`, generalizes `Fin.pred`. -/
@[inline] def subNat (m) (i : Fin (n + m)) (h : m ≤ i) : Fin n 
goal: Fin n

full_name: Fin.pred
code: /-- Predecessor of a nonzero element of `Fin (n+1)`. -/
@[inline] def pred {n : Nat} (i : Fin (n + 1)) (h : i ≠ 0) : Fin n 
goal: Fin n

full_name: Fin.val_inj
code: theorem val_inj {a b : Fin n} : a.1 = b.1 ↔ a = b 
goal: ↑a = ↑b ↔ a = b

full_name: Fin.val_congr
code: theorem val_congr {n : Nat} {a b : Fin n} (h : a = b) : (a : Nat) = (b : Nat) 
goal: ↑a = ↑b

full_name: Fin.val_le_of_le
code: theorem val_le_of_le {n : Nat} {a b : Fin n} (h : a ≤ b) : (a : Nat) ≤ (b : Nat) 
goal: ↑a ≤ ↑b

full_name: Fin.val_le_of_ge
code: theorem val_le_of_ge {n : Nat} {a b : Fin n} (h : a ≥ b) : (b : Nat) ≤ (a : Nat) 
goal: ↑b ≤ ↑a

full_name: Fin.val_add_one_le_of_lt
code: theorem val_add_one_le_of_lt {n : Nat} {a b : Fin n} (h : a < b) : (a : Nat) + 1 ≤ (b : Nat) 
goal: ↑a + 1 ≤ ↑b

full_name: Fin.val_add_one_le_of_gt
code: theorem val_add_one_le_of_gt {n : Nat} {a b : Fin n} (h : a > b) : (b : Nat) + 1 ≤ (a : Nat) 
goal: ↑b + 1 ≤ ↑a

full_name: Fin.exists_iff
code: theorem exists_iff {p : Fin n → Prop} : (Exists fun i => p i) ↔ Exists fun i => Exists fun h => p ⟨i, h⟩ 
goal: (Exists fun i => p i) ↔ Exists fun i => Exists fun h => p ⟨i, h⟩