Theorem: Composition.ne_single_iff
File: Mathlib/Combinatorics/Enumerative/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 c.length), c.blocksFun i < n
state_after: n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
⊢ ¬c ≠ single n hn ↔ ¬∀ (i : Fin c.length), c.blocksFun i < n

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

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

case mpr
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
⊢ (∃ i, n ≤ c.blocksFun i) → c = single n hn

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

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

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

tactic: simp
state_before: n✝ : ℕ
c : Composition n✝
n : ℕ
hn : 0 < n
⊢ n ≤ (single n hn).blocksFun ⟨0, ⋯⟩
state_after: no goals

tactic: rintro ⟨i, hi⟩
state_before: case mpr
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
⊢ (∃ i, n ≤ c.blocksFun i) → c = single n hn
state_after: case mpr.intro
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
i : Fin c.length
hi : n ≤ c.blocksFun 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 c.length
hi : n ≤ c.blocksFun i
⊢ c = single n hn
state_after: case mpr.intro
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
i : Fin c.length
hi : n ≤ c.blocksFun i
⊢ c.length = 1

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 c.length
hi : n ≤ c.blocksFun i
⊢ c.length = 1
state_after: case mpr.intro
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
i : Fin c.length
hi : n ≤ c.blocksFun i
this : ∀ (j : Fin c.length), j = i
⊢ c.length = 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 c.length
hi : n ≤ c.blocksFun i
this : ∀ (j : Fin c.length), j = i
⊢ c.length = 1
state_after: no goals

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

tactic: by_contra ji
state_before: n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
i : Fin c.length
hi : n ≤ c.blocksFun i
j : Fin c.length
⊢ j = i
state_after: n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
i : Fin c.length
hi : n ≤ c.blocksFun i
j : Fin c.length
ji : ¬j = i
⊢ False

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

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 c.length
hi : n ≤ c.blocksFun i
j : Fin c.length
ji : ¬j = i
⊢ ∑ k : Fin c.length, c.blocksFun k < ∑ k : Fin c.length, c.blocksFun k
state_after: no goals

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