Theorem: Composition.mem_range_embedding_iff
File: Mathlib/Combinatorics/Composition.lean

tactic: constructor
state_before: n : ℕ
c : Composition n
j : Fin n
i : Fin (length c)
⊢ j ∈ Set.range ↑(embedding c i) ↔ sizeUpTo c ↑i ≤ ↑j ∧ ↑j < sizeUpTo c (Nat.succ ↑i)

tactic: intro h
state_before: case mp
n : ℕ
c : Composition n
j : Fin n
i : Fin (length c)
⊢ j ∈ Set.range ↑(embedding c i) → sizeUpTo c ↑i ≤ ↑j ∧ ↑j < sizeUpTo c (Nat.succ ↑i)

tactic: rcases Set.mem_range.2 h with ⟨k, hk⟩
state_before: case mp
n : ℕ
c : Composition n
j : Fin n
i : Fin (length c)
h : j ∈ Set.range ↑(embedding c i)
⊢ sizeUpTo c ↑i ≤ ↑j ∧ ↑j < sizeUpTo c (Nat.succ ↑i)

tactic: rw [Fin.ext_iff] at hk
state_before: case mp.intro
n : ℕ
c : Composition n
j : Fin n
i : Fin (length c)
h : j ∈ Set.range ↑(embedding c i)
k : Fin (blocksFun c i)
hk : (fun y => ↑(embedding c i) y) k = j
⊢ sizeUpTo c ↑i ≤ ↑j ∧ ↑j < sizeUpTo c (Nat.succ ↑i)

tactic: dsimp at hk
state_before: case mp.intro
n : ℕ
c : Composition n
j : Fin n
i : Fin (length c)
h : j ∈ Set.range ↑(embedding c i)
k : Fin (blocksFun c i)
hk : ↑((fun y => ↑(embedding c i) y) k) = ↑j
⊢ sizeUpTo c ↑i ≤ ↑j ∧ ↑j < sizeUpTo c (Nat.succ ↑i)

tactic: rw [← hk]
state_before: case mp.intro
n : ℕ
c : Composition n
j : Fin n
i : Fin (length c)
h : j ∈ Set.range ↑(embedding c i)
k : Fin (blocksFun c i)
hk : sizeUpTo c ↑i + ↑k = ↑j
⊢ sizeUpTo c ↑i ≤ ↑j ∧ ↑j < sizeUpTo c (Nat.succ ↑i)

tactic: simp [sizeUpTo_succ', k.is_lt]
state_before: case mp.intro
n : ℕ
c : Composition n
j : Fin n
i : Fin (length c)
h : j ∈ Set.range ↑(embedding c i)
k : Fin (blocksFun c i)
hk : sizeUpTo c ↑i + ↑k = ↑j
⊢ sizeUpTo c ↑i ≤ sizeUpTo c ↑i + ↑k ∧ sizeUpTo c ↑i + ↑k < sizeUpTo c (Nat.succ ↑i)

tactic: intro h
state_before: case mpr
n : ℕ
c : Composition n
j : Fin n
i : Fin (length c)
⊢ sizeUpTo c ↑i ≤ ↑j ∧ ↑j < sizeUpTo c (Nat.succ ↑i) → j ∈ Set.range ↑(embedding c i)

tactic: apply Set.mem_range.2
state_before: case mpr
n : ℕ
c : Composition n
j : Fin n
i : Fin (length c)
h : sizeUpTo c ↑i ≤ ↑j ∧ ↑j < sizeUpTo c (Nat.succ ↑i)
⊢ j ∈ Set.range ↑(embedding c i)

tactic: refine' ⟨⟨j - c.sizeUpTo i, _⟩, _⟩
state_before: case mpr
n : ℕ
c : Composition n
j : Fin n
i : Fin (length c)
h : sizeUpTo c ↑i ≤ ↑j ∧ ↑j < sizeUpTo c (Nat.succ ↑i)
⊢ ∃ y, ↑(embedding c i) y = j

tactic: rw [tsub_lt_iff_left, ← sizeUpTo_succ']
state_before: case mpr.refine'_1
n : ℕ
c : Composition n
j : Fin n
i : Fin (length c)
h : sizeUpTo c ↑i ≤ ↑j ∧ ↑j < sizeUpTo c (Nat.succ ↑i)
⊢ ↑j - sizeUpTo c ↑i < blocksFun c i

tactic: exact h.2
state_before: case mpr.refine'_1
n : ℕ
c : Composition n
j : Fin n
i : Fin (length c)
h : sizeUpTo c ↑i ≤ ↑j ∧ ↑j < sizeUpTo c (Nat.succ ↑i)
⊢ ↑j < sizeUpTo c (↑i + 1)

tactic: exact h.1
state_before: case mpr.refine'_1
n : ℕ
c : Composition n
j : Fin n
i : Fin (length c)
h : sizeUpTo c ↑i ≤ ↑j ∧ ↑j < sizeUpTo c (Nat.succ ↑i)
⊢ sizeUpTo c ↑i ≤ ↑j

tactic: rw [Fin.ext_iff]
state_before: case mpr.refine'_2
n : ℕ
c : Composition n
j : Fin n
i : Fin (length c)
h : sizeUpTo c ↑i ≤ ↑j ∧ ↑j < sizeUpTo c (Nat.succ ↑i)
⊢ ↑(embedding c i) { val := ↑j - sizeUpTo c ↑i, isLt := (_ : ↑j - sizeUpTo c ↑i < blocksFun c i) } = j

tactic: exact add_tsub_cancel_of_le h.1
state_before: case mpr.refine'_2
n : ℕ
c : Composition n
j : Fin n
i : Fin (length c)
h : sizeUpTo c ↑i ≤ ↑j ∧ ↑j < sizeUpTo c (Nat.succ ↑i)
⊢ ↑(↑(embedding c i) { val := ↑j - sizeUpTo c ↑i, isLt := (_ : ↑j - sizeUpTo c ↑i < blocksFun c i) }) = ↑j