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

tactic: rw [← not_iff_not]
state_before: n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
⊢ c ≠ single n hn ↔ ∀ (i : Fin (length c)), blocksFun c i < n

tactic: push_neg
state_before: n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
⊢ ¬c ≠ single n hn ↔ ¬∀ (i : Fin (length c)), blocksFun c i < n

tactic: constructor
state_before: n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
⊢ c = single n hn ↔ ∃ i, n ≤ blocksFun c i

tactic: rintro rfl
state_before: case mp
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
⊢ c = single n hn → ∃ i, n ≤ blocksFun c i

tactic: exact ⟨⟨0, by simp⟩, by simp⟩
state_before: case mp
n✝ : ℕ
c : Composition n✝
n : ℕ
hn : 0 < n
⊢ ∃ i, n ≤ blocksFun (single n hn) i

tactic: simp
state_before: n✝ : ℕ
c : Composition n✝
n : ℕ
hn : 0 < n
⊢ 0 < length (single n hn)

tactic: simp
state_before: n✝ : ℕ
c : Composition n✝
n : ℕ
hn : 0 < n
⊢ n ≤ blocksFun (single n hn) { val := 0, isLt := (_ : 0 < 1) }

tactic: rintro ⟨i, hi⟩
state_before: case mpr
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
⊢ (∃ i, n ≤ blocksFun c i) → c = single n hn

tactic: rw [eq_single_iff_length]
state_before: case mpr.intro
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
i : Fin (length c)
hi : n ≤ blocksFun c i
⊢ c = single n hn

tactic: have : ∀ j : Fin c.length, j = i := by
  intro j
  by_contra ji
  apply lt_irrefl (∑ k, c.blocksFun k)
  calc
    (∑ k, c.blocksFun k) ≤ c.blocksFun i := by simp only [c.sum_blocksFun, hi]
    _ < ∑ k, c.blocksFun k :=
      Finset.single_lt_sum ji (Finset.mem_univ _) (Finset.mem_univ _) (c.one_le_blocksFun j)
        fun _ _ _ => zero_le _
state_before: case mpr.intro
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
i : Fin (length c)
hi : n ≤ blocksFun c i
⊢ length c = 1

tactic: simpa using Fintype.card_eq_one_of_forall_eq this
state_before: case mpr.intro
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
i : Fin (length c)
hi : n ≤ blocksFun c i
this : ∀ (j : Fin (length c)), j = i
⊢ length c = 1

tactic: intro j
state_before: n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
i : Fin (length c)
hi : n ≤ blocksFun c i
⊢ ∀ (j : Fin (length c)), j = i

tactic: by_contra ji
state_before: n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
i : Fin (length c)
hi : n ≤ blocksFun c i
j : Fin (length c)
⊢ j = i

tactic: apply lt_irrefl (∑ k, c.blocksFun k)
state_before: n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
i : Fin (length c)
hi : n ≤ blocksFun c i
j : Fin (length c)
ji : ¬j = i
⊢ False

tactic: calc
  (∑ k, c.blocksFun k) ≤ c.blocksFun i := by simp only [c.sum_blocksFun, hi]
  _ < ∑ k, c.blocksFun k :=
    Finset.single_lt_sum ji (Finset.mem_univ _) (Finset.mem_univ _) (c.one_le_blocksFun j)
      fun _ _ _ => zero_le _
state_before: n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
i : Fin (length c)
hi : n ≤ blocksFun c i
j : Fin (length c)
ji : ¬j = i
⊢ ∑ k : Fin (length c), blocksFun c k < ∑ k : Fin (length c), blocksFun c k

tactic: simp only [c.sum_blocksFun, hi]
state_before: n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
i : Fin (length c)
hi : n ≤ blocksFun c i
j : Fin (length c)
ji : ¬j = i
⊢ ∑ k : Fin (length c), blocksFun c k ≤ blocksFun c i