Theorem: Composition.eq_ones_iff_length
File: Mathlib/Combinatorics/Enumerative/Composition.lean

tactic: constructor
state_before: n : ℕ
c✝ c : Composition n
⊢ c = ones n ↔ c.length = n
state_after: case mp
n : ℕ
c✝ c : Composition n
⊢ c = ones n → c.length = n

case mpr
n : ℕ
c✝ c : Composition n
⊢ c.length = n → c = ones n

tactic: rintro rfl
state_before: case mp
n : ℕ
c✝ c : Composition n
⊢ c = ones n → c.length = n
state_after: case mp
n : ℕ
c : Composition n
⊢ (ones n).length = n

tactic: exact ones_length n
state_before: case mp
n : ℕ
c : Composition n
⊢ (ones n).length = n
state_after: no goals

tactic: contrapose
state_before: case mpr
n : ℕ
c✝ c : Composition n
⊢ c.length = n → c = ones n
state_after: case mpr
n : ℕ
c✝ c : Composition n
⊢ ¬c = ones n → ¬c.length = n

tactic: intro H length_n
state_before: case mpr
n : ℕ
c✝ c : Composition n
⊢ ¬c = ones n → ¬c.length = n
state_after: case mpr
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : c.length = n
⊢ False

tactic: apply lt_irrefl n
state_before: case mpr
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : c.length = n
⊢ False
state_after: case mpr
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : c.length = n
⊢ n < n

tactic: calc
  n = ∑ i : Fin c.length, 1 := by simp [length_n]
  _ < ∑ i : Fin c.length, c.blocksFun i := by
    {
    obtain ⟨i, hi, i_blocks⟩ : ∃ i ∈ c.blocks, 1 < i := ne_ones_iff.1 H
    rw [← ofFn_blocksFun, mem_ofFn c.blocksFun, Set.mem_range] at hi
    obtain ⟨j : Fin c.length, hj : c.blocksFun j = i⟩ := hi
    rw [← hj] at i_blocks
    exact Finset.sum_lt_sum (fun i _ => one_le_blocksFun c i) ⟨j, Finset.mem_univ _, i_blocks⟩
    }
  _ = n := c.sum_blocksFun
state_before: case mpr
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : c.length = n
⊢ n < n
state_after: no goals

tactic: simp [length_n]
state_before: n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : c.length = n
⊢ n = ∑ i : Fin c.length, 1
state_after: no goals

tactic: obtain ⟨i, hi, i_blocks⟩ : ∃ i ∈ c.blocks, 1 < i := ne_ones_iff.1 H
state_before: n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : c.length = n
⊢ ∑ i : Fin c.length, 1 < ∑ i : Fin c.length, c.blocksFun i
state_after: case intro.intro
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : c.length = n
i : ℕ
hi : i ∈ c.blocks
i_blocks : 1 < i
⊢ ∑ i : Fin c.length, 1 < ∑ i : Fin c.length, c.blocksFun i

tactic: rw [← ofFn_blocksFun, mem_ofFn c.blocksFun, Set.mem_range] at hi
state_before: case intro.intro
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : c.length = n
i : ℕ
hi : i ∈ c.blocks
i_blocks : 1 < i
⊢ ∑ i : Fin c.length, 1 < ∑ i : Fin c.length, c.blocksFun i
state_after: case intro.intro
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : c.length = n
i : ℕ
hi : ∃ y, c.blocksFun y = i
i_blocks : 1 < i
⊢ ∑ i : Fin c.length, 1 < ∑ i : Fin c.length, c.blocksFun i

tactic: obtain ⟨j : Fin c.length, hj : c.blocksFun j = i⟩ := hi
state_before: case intro.intro
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : c.length = n
i : ℕ
hi : ∃ y, c.blocksFun y = i
i_blocks : 1 < i
⊢ ∑ i : Fin c.length, 1 < ∑ i : Fin c.length, c.blocksFun i
state_after: case intro.intro.intro
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : c.length = n
i : ℕ
i_blocks : 1 < i
j : Fin c.length
hj : c.blocksFun j = i
⊢ ∑ i : Fin c.length, 1 < ∑ i : Fin c.length, c.blocksFun i

tactic: rw [← hj] at i_blocks
state_before: case intro.intro.intro
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : c.length = n
i : ℕ
i_blocks : 1 < i
j : Fin c.length
hj : c.blocksFun j = i
⊢ ∑ i : Fin c.length, 1 < ∑ i : Fin c.length, c.blocksFun i
state_after: case intro.intro.intro
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : c.length = n
i : ℕ
j : Fin c.length
i_blocks : 1 < c.blocksFun j
hj : c.blocksFun j = i
⊢ ∑ i : Fin c.length, 1 < ∑ i : Fin c.length, c.blocksFun i

tactic: exact Finset.sum_lt_sum (fun i _ => one_le_blocksFun c i) ⟨j, Finset.mem_univ _, i_blocks⟩
state_before: case intro.intro.intro
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : c.length = n
i : ℕ
j : Fin c.length
i_blocks : 1 < c.blocksFun j
hj : c.blocksFun j = i
⊢ ∑ i : Fin c.length, 1 < ∑ i : Fin c.length, c.blocksFun i
state_after: no goals