Theorem: Fin.exists_eq_add_of_lt
File: Mathlib/Data/Fin/Basic.lean

tactic: cases n
state_before: n✝ m n : ℕ
a b : Fin (n + 1)
h : a < b
⊢ ∃ k < b, k + 1 ≤ b ∧ b = a + k + 1
state_after: case zero
n m : ℕ
a b : Fin (0 + 1)
h : a < b
⊢ ∃ k < b, k + 1 ≤ b ∧ b = a + k + 1

case succ
n m n✝ : ℕ
a b : Fin (n✝ + 1 + 1)
h : a < b
⊢ ∃ k < b, k + 1 ≤ b ∧ b = a + k + 1

tactic: obtain ⟨k, hk⟩ : ∃ k : ℕ, (b : ℕ) = a + k + 1 := Nat.exists_eq_add_of_lt h
state_before: case succ
n m n✝ : ℕ
a b : Fin (n✝ + 1 + 1)
h : a < b
⊢ ∃ k < b, k + 1 ≤ b ∧ b = a + k + 1
state_after: case succ.intro
n m n✝ : ℕ
a b : Fin (n✝ + 1 + 1)
h : a < b
k : ℕ
hk : ↑b = ↑a + k + 1
⊢ ∃ k < b, k + 1 ≤ b ∧ b = a + k + 1

tactic: have hkb : k < b := by omega
state_before: case succ.intro
n m n✝ : ℕ
a b : Fin (n✝ + 1 + 1)
h : a < b
k : ℕ
hk : ↑b = ↑a + k + 1
⊢ ∃ k < b, k + 1 ≤ b ∧ b = a + k + 1
state_after: case succ.intro
n m n✝ : ℕ
a b : Fin (n✝ + 1 + 1)
h : a < b
k : ℕ
hk : ↑b = ↑a + k + 1
hkb : k < ↑b
⊢ ∃ k < b, k + 1 ≤ b ∧ b = a + k + 1

tactic: refine ⟨⟨k, hkb.trans b.is_lt⟩, hkb, ?_, ?_⟩
state_before: case succ.intro
n m n✝ : ℕ
a b : Fin (n✝ + 1 + 1)
h : a < b
k : ℕ
hk : ↑b = ↑a + k + 1
hkb : k < ↑b
⊢ ∃ k < b, k + 1 ≤ b ∧ b = a + k + 1
state_after: case succ.intro.refine_1
n m n✝ : ℕ
a b : Fin (n✝ + 1 + 1)
h : a < b
k : ℕ
hk : ↑b = ↑a + k + 1
hkb : k < ↑b
⊢ ⟨k, ⋯⟩ + 1 ≤ b

case succ.intro.refine_2
n m n✝ : ℕ
a b : Fin (n✝ + 1 + 1)
h : a < b
k : ℕ
hk : ↑b = ↑a + k + 1
hkb : k < ↑b
⊢ b = a + ⟨k, ⋯⟩ + 1

tactic: simp [Fin.ext_iff, Fin.val_add, ← hk, Nat.mod_eq_of_lt b.is_lt]
state_before: case succ.intro.refine_2
n m n✝ : ℕ
a b : Fin (n✝ + 1 + 1)
h : a < b
k : ℕ
hk : ↑b = ↑a + k + 1
hkb : k < ↑b
⊢ b = a + ⟨k, ⋯⟩ + 1
state_after: no goals

tactic: cases' a with a ha
state_before: case zero
n m : ℕ
a b : Fin (0 + 1)
h : a < b
⊢ ∃ k < b, k + 1 ≤ b ∧ b = a + k + 1
state_after: case zero.mk
n m : ℕ
b : Fin (0 + 1)
a : ℕ
ha : a < 0 + 1
h : ⟨a, ha⟩ < b
⊢ ∃ k < b, k + 1 ≤ b ∧ b = ⟨a, ha⟩ + k + 1

tactic: cases' b with b hb
state_before: case zero.mk
n m : ℕ
b : Fin (0 + 1)
a : ℕ
ha : a < 0 + 1
h : ⟨a, ha⟩ < b
⊢ ∃ k < b, k + 1 ≤ b ∧ b = ⟨a, ha⟩ + k + 1
state_after: case zero.mk.mk
n m a : ℕ
ha : a < 0 + 1
b : ℕ
hb : b < 0 + 1
h : ⟨a, ha⟩ < ⟨b, hb⟩
⊢ ∃ k < ⟨b, hb⟩, k + 1 ≤ ⟨b, hb⟩ ∧ ⟨b, hb⟩ = ⟨a, ha⟩ + k + 1

tactic: simp only [Nat.zero_eq, Nat.zero_add, Nat.lt_one_iff] at ha hb
state_before: case zero.mk.mk
n m a : ℕ
ha : a < 0 + 1
b : ℕ
hb : b < 0 + 1
h : ⟨a, ha⟩ < ⟨b, hb⟩
⊢ ∃ k < ⟨b, hb⟩, k + 1 ≤ ⟨b, hb⟩ ∧ ⟨b, hb⟩ = ⟨a, ha⟩ + k + 1
state_after: case zero.mk.mk
n m a : ℕ
ha✝ : a < 0 + 1
b : ℕ
hb✝ : b < 0 + 1
h : ⟨a, ha✝⟩ < ⟨b, hb✝⟩
ha : a = 0
hb : b = 0
⊢ ∃ k < ⟨b, hb✝⟩, k + 1 ≤ ⟨b, hb✝⟩ ∧ ⟨b, hb✝⟩ = ⟨a, ha✝⟩ + k + 1

tactic: simp [ha, hb] at h
state_before: case zero.mk.mk
n m a : ℕ
ha✝ : a < 0 + 1
b : ℕ
hb✝ : b < 0 + 1
h : ⟨a, ha✝⟩ < ⟨b, hb✝⟩
ha : a = 0
hb : b = 0
⊢ ∃ k < ⟨b, hb✝⟩, k + 1 ≤ ⟨b, hb✝⟩ ∧ ⟨b, hb✝⟩ = ⟨a, ha✝⟩ + k + 1
state_after: no goals

tactic: omega
state_before: n m n✝ : ℕ
a b : Fin (n✝ + 1 + 1)
h : a < b
k : ℕ
hk : ↑b = ↑a + k + 1
⊢ k < ↑b
state_after: no goals

tactic: rw [Fin.le_iff_val_le_val, Fin.val_add_one]
state_before: case succ.intro.refine_1
n m n✝ : ℕ
a b : Fin (n✝ + 1 + 1)
h : a < b
k : ℕ
hk : ↑b = ↑a + k + 1
hkb : k < ↑b
⊢ ⟨k, ⋯⟩ + 1 ≤ b
state_after: case succ.intro.refine_1
n m n✝ : ℕ
a b : Fin (n✝ + 1 + 1)
h : a < b
k : ℕ
hk : ↑b = ↑a + k + 1
hkb : k < ↑b
⊢ (if ⟨k, ⋯⟩ = last (n✝ + 1) then 0 else ↑⟨k, ⋯⟩ + 1) ≤ ↑b

tactic: split_ifs <;> simp [Nat.succ_le_iff, hkb]
state_before: case succ.intro.refine_1
n m n✝ : ℕ
a b : Fin (n✝ + 1 + 1)
h : a < b
k : ℕ
hk : ↑b = ↑a + k + 1
hkb : k < ↑b
⊢ (if ⟨k, ⋯⟩ = last (n✝ + 1) then 0 else ↑⟨k, ⋯⟩ + 1) ≤ ↑b
state_after: no goals