l3lab/ntp-mathlib huggingface dataset:
/-- The composition made of blocks all of size `1`. -/
def ones (n : ℕ) : Composition n :=
  ⟨replicate n (1 : ℕ), fun {i} hi => by 

Proof state:
n✝ : ℕ
c : Composition n✝
n i : ℕ
hi : i ∈ replicate n 1
⊢ 0 < i

Next tactic:
simp [List.eq_of_mem_replicate hi]
/-- The composition made of blocks all of size `1`. -/
def ones (n : ℕ) : Composition n :=
  ⟨replicate n (1 : ℕ), fun {i} hi => by simp [List.eq_of_mem_replicate hi], by 

Proof state:
n✝ : ℕ
c : Composition n✝
n : ℕ
⊢ sum (replicate n 1) = n

Next tactic:
simp
@[simp]
theorem ones_blocksFun (n : ℕ) (i : Fin (ones n).length) : (ones n).blocksFun i = 1 := by
  

Proof state:
n✝ : ℕ
c : Composition n✝
n : ℕ
i : Fin (length (ones n))
⊢ blocksFun (ones n) i = 1

Next tactic:
simp only [blocksFun, ones, blocks, i.2, List.get_replicate]
@[simp]
theorem ones_sizeUpTo (n : ℕ) (i : ℕ) : (ones n).sizeUpTo i = min i n := by
  

Proof state:
n✝ : ℕ
c : Composition n✝
n i : ℕ
⊢ sizeUpTo (ones n) i = min i n

Next tactic:
simp [sizeUpTo, ones_blocks, take_replicate]
@[simp]
theorem ones_embedding (i : Fin (ones n).length) (h : 0 < (ones n).blocksFun i) :
    (ones n).embedding i ⟨0, h⟩ = ⟨i, lt_of_lt_of_le i.2 (ones n).length_le⟩ := by
  

Proof state:
n : ℕ
c : Composition n
i : Fin (length (ones n))
h : 0 < blocksFun (ones n) i
⊢ (embedding (ones n) i) { val := 0, isLt := h } = { val := ↑i, isLt := (_ : ↑i < n) }

Next tactic:
ext
@[simp]
theorem ones_embedding (i : Fin (ones n).length) (h : 0 < (ones n).blocksFun i) :
    (ones n).embedding i ⟨0, h⟩ = ⟨i, lt_of_lt_of_le i.2 (ones n).length_le⟩ := by
  ext
  

Proof state:
case h
n : ℕ
c : Composition n
i : Fin (length (ones n))
h : 0 < blocksFun (ones n) i
⊢ ↑((embedding (ones n) i) { val := 0, isLt := h }) = ↑{ val := ↑i, isLt := (_ : ↑i < n) }

Next tactic:
simpa using i.2.le
theorem eq_ones_iff {c : Composition n} : c = ones n ↔ ∀ i ∈ c.blocks, i = 1 := by
  

Proof state:
n : ℕ
c✝ c : Composition n
⊢ c = ones n ↔ ∀ i ∈ c.blocks, i = 1

Next tactic:
constructor
theorem eq_ones_iff {c : Composition n} : c = ones n ↔ ∀ i ∈ c.blocks, i = 1 := by
  constructor
  · 

Proof state:
case mp
n : ℕ
c✝ c : Composition n
⊢ c = ones n → ∀ i ∈ c.blocks, i = 1

Next tactic:
rintro rfl
theorem eq_ones_iff {c : Composition n} : c = ones n ↔ ∀ i ∈ c.blocks, i = 1 := by
  constructor
  · rintro rfl
    

Proof state:
case mp
n : ℕ
c : Composition n
⊢ ∀ i ∈ (ones n).blocks, i = 1

Next tactic:
exact fun i => eq_of_mem_replicate
theorem eq_ones_iff {c : Composition n} : c = ones n ↔ ∀ i ∈ c.blocks, i = 1 := by
  constructor
  · rintro rfl
    exact fun i => eq_of_mem_replicate
  · 

Proof state:
case mpr
n : ℕ
c✝ c : Composition n
⊢ (∀ i ∈ c.blocks, i = 1) → c = ones n

Next tactic:
intro H
theorem eq_ones_iff {c : Composition n} : c = ones n ↔ ∀ i ∈ c.blocks, i = 1 := by
  constructor
  · rintro rfl
    exact fun i => eq_of_mem_replicate
  · intro H
    

Proof state:
case mpr
n : ℕ
c✝ c : Composition n
H : ∀ i ∈ c.blocks, i = 1
⊢ c = ones n

Next tactic:
ext1
theorem eq_ones_iff {c : Composition n} : c = ones n ↔ ∀ i ∈ c.blocks, i = 1 := by
  constructor
  · rintro rfl
    exact fun i => eq_of_mem_replicate
  · intro H
    ext1
    

Proof state:
case mpr.blocks
n : ℕ
c✝ c : Composition n
H : ∀ i ∈ c.blocks, i = 1
⊢ c.blocks = (ones n).blocks

Next tactic:
have A : c.blocks = replicate c.blocks.length 1 := eq_replicate_of_mem H
theorem eq_ones_iff {c : Composition n} : c = ones n ↔ ∀ i ∈ c.blocks, i = 1 := by
  constructor
  · rintro rfl
    exact fun i => eq_of_mem_replicate
  · intro H
    ext1
    have A : c.blocks = replicate c.blocks.length 1 := eq_replicate_of_mem H
    

Proof state:
case mpr.blocks
n : ℕ
c✝ c : Composition n
H : ∀ i ∈ c.blocks, i = 1
A : c.blocks = replicate (List.length c.blocks) 1
⊢ c.blocks = (ones n).blocks

Next tactic:
have : c.blocks.length = n := by
      conv_rhs => rw [← c.blocks_sum, A]
      simp
theorem eq_ones_iff {c : Composition n} : c = ones n ↔ ∀ i ∈ c.blocks, i = 1 := by
  constructor
  · rintro rfl
    exact fun i => eq_of_mem_replicate
  · intro H
    ext1
    have A : c.blocks = replicate c.blocks.length 1 := eq_replicate_of_mem H
    have : c.blocks.length = n := by
      

Proof state:
n : ℕ
c✝ c : Composition n
H : ∀ i ∈ c.blocks, i = 1
A : c.blocks = replicate (List.length c.blocks) 1
⊢ List.length c.blocks = n

Next tactic:
conv_rhs => rw [← c.blocks_sum, A]
theorem eq_ones_iff {c : Composition n} : c = ones n ↔ ∀ i ∈ c.blocks, i = 1 := by
  constructor
  · rintro rfl
    exact fun i => eq_of_mem_replicate
  · intro H
    ext1
    have A : c.blocks = replicate c.blocks.length 1 := eq_replicate_of_mem H
    have : c.blocks.length = n := by
      conv_rhs => 

Proof state:
n : ℕ
c✝ c : Composition n
H : ∀ i ∈ c.blocks, i = 1
A : c.blocks = replicate (List.length c.blocks) 1
| n

Next tactic:
rw [← c.blocks_sum, A]
theorem eq_ones_iff {c : Composition n} : c = ones n ↔ ∀ i ∈ c.blocks, i = 1 := by
  constructor
  · rintro rfl
    exact fun i => eq_of_mem_replicate
  · intro H
    ext1
    have A : c.blocks = replicate c.blocks.length 1 := eq_replicate_of_mem H
    have : c.blocks.length = n := by
      conv_rhs => rw [← c.blocks_sum, A]
      

Proof state:
n : ℕ
c✝ c : Composition n
H : ∀ i ∈ c.blocks, i = 1
A : c.blocks = replicate (List.length c.blocks) 1
⊢ List.length c.blocks = sum (replicate (List.length c.blocks) 1)

Next tactic:
simp
theorem eq_ones_iff {c : Composition n} : c = ones n ↔ ∀ i ∈ c.blocks, i = 1 := by
  constructor
  · rintro rfl
    exact fun i => eq_of_mem_replicate
  · intro H
    ext1
    have A : c.blocks = replicate c.blocks.length 1 := eq_replicate_of_mem H
    have : c.blocks.length = n := by
      conv_rhs => rw [← c.blocks_sum, A]
      simp
    

Proof state:
case mpr.blocks
n : ℕ
c✝ c : Composition n
H : ∀ i ∈ c.blocks, i = 1
A : c.blocks = replicate (List.length c.blocks) 1
this : List.length c.blocks = n
⊢ c.blocks = (ones n).blocks

Next tactic:
rw [A, this, ones_blocks]
theorem ne_ones_iff {c : Composition n} : c ≠ ones n ↔ ∃ i ∈ c.blocks, 1 < i := by
  

Proof state:
n : ℕ
c✝ c : Composition n
⊢ c ≠ ones n ↔ ∃ i ∈ c.blocks, 1 < i

Next tactic:
refine' (not_congr eq_ones_iff).trans _
theorem ne_ones_iff {c : Composition n} : c ≠ ones n ↔ ∃ i ∈ c.blocks, 1 < i := by
  refine' (not_congr eq_ones_iff).trans _
  

Proof state:
n : ℕ
c✝ c : Composition n
⊢ (¬∀ i ∈ c.blocks, i = 1) ↔ ∃ i ∈ c.blocks, 1 < i

Next tactic:
have : ∀ j ∈ c.blocks, j = 1 ↔ j ≤ 1 := fun j hj => by simp [le_antisymm_iff, c.one_le_blocks hj]
theorem ne_ones_iff {c : Composition n} : c ≠ ones n ↔ ∃ i ∈ c.blocks, 1 < i := by
  refine' (not_congr eq_ones_iff).trans _
  have : ∀ j ∈ c.blocks, j = 1 ↔ j ≤ 1 := fun j hj => by 

Proof state:
n : ℕ
c✝ c : Composition n
j : ℕ
hj : j ∈ c.blocks
⊢ j = 1 ↔ j ≤ 1

Next tactic:
simp [le_antisymm_iff, c.one_le_blocks hj]
theorem ne_ones_iff {c : Composition n} : c ≠ ones n ↔ ∃ i ∈ c.blocks, 1 < i := by
  refine' (not_congr eq_ones_iff).trans _
  have : ∀ j ∈ c.blocks, j = 1 ↔ j ≤ 1 := fun j hj => by simp [le_antisymm_iff, c.one_le_blocks hj]
  

Proof state:
n : ℕ
c✝ c : Composition n
this : ∀ j ∈ c.blocks, j = 1 ↔ j ≤ 1
⊢ (¬∀ i ∈ c.blocks, i = 1) ↔ ∃ i ∈ c.blocks, 1 < i

Next tactic:
simp (config := { contextual := true }) [this]
theorem eq_ones_iff_length {c : Composition n} : c = ones n ↔ c.length = n := by
  

Proof state:
n : ℕ
c✝ c : Composition n
⊢ c = ones n ↔ length c = n

Next tactic:
constructor
theorem eq_ones_iff_length {c : Composition n} : c = ones n ↔ c.length = n := by
  constructor
  · 

Proof state:
case mp
n : ℕ
c✝ c : Composition n
⊢ c = ones n → length c = n

Next tactic:
rintro rfl
theorem eq_ones_iff_length {c : Composition n} : c = ones n ↔ c.length = n := by
  constructor
  · rintro rfl
    

Proof state:
case mp
n : ℕ
c : Composition n
⊢ length (ones n) = n

Next tactic:
exact ones_length n
theorem eq_ones_iff_length {c : Composition n} : c = ones n ↔ c.length = n := by
  constructor
  · rintro rfl
    exact ones_length n
  · 

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

Next tactic:
contrapose
theorem eq_ones_iff_length {c : Composition n} : c = ones n ↔ c.length = n := by
  constructor
  · rintro rfl
    exact ones_length n
  · contrapose
    

Proof state:
case mpr
n : ℕ
c✝ c : Composition n
⊢ ¬c = ones n → ¬length c = n

Next tactic:
intro H length_n
theorem eq_ones_iff_length {c : Composition n} : c = ones n ↔ c.length = n := by
  constructor
  · rintro rfl
    exact ones_length n
  · contrapose
    intro H length_n
    

Proof state:
case mpr
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : length c = n
⊢ False

Next tactic:
apply lt_irrefl n
theorem eq_ones_iff_length {c : Composition n} : c = ones n ↔ c.length = n := by
  constructor
  · rintro rfl
    exact ones_length n
  · contrapose
    intro H length_n
    apply lt_irrefl n
    

Proof state:
case mpr
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : length c = n
⊢ n < n

Next 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
theorem eq_ones_iff_length {c : Composition n} : c = ones n ↔ c.length = n := by
  constructor
  · rintro rfl
    exact ones_length n
  · contrapose
    intro H length_n
    apply lt_irrefl n
    calc
      n = ∑ i : Fin c.length, 1 := by 

Proof state:
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : length c = n
⊢ n = ∑ i : Fin (length c), 1

Next tactic:
simp [length_n]
theorem eq_ones_iff_length {c : Composition n} : c = ones n ↔ c.length = n := by
  constructor
  · rintro rfl
    exact ones_length n
  · contrapose
    intro H length_n
    apply lt_irrefl n
    calc
      n = ∑ i : Fin c.length, 1 := by simp [length_n]
      _ < ∑ i : Fin c.length, c.blocksFun i := by
        

Proof state:
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : length c = n
⊢ ∑ i : Fin (length c), 1 < ∑ i : Fin (length c), blocksFun c i

Next tactic:
{
        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⟩
        }
theorem eq_ones_iff_length {c : Composition n} : c = ones n ↔ c.length = n := by
  constructor
  · rintro rfl
    exact ones_length n
  · contrapose
    intro H length_n
    apply lt_irrefl n
    calc
      n = ∑ i : Fin c.length, 1 := by simp [length_n]
      _ < ∑ i : Fin c.length, c.blocksFun i := by
        {
        

Proof state:
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : length c = n
⊢ ∑ i : Fin (length c), 1 < ∑ i : Fin (length c), blocksFun c i

Next tactic:
obtain ⟨i, hi, i_blocks⟩ : ∃ i ∈ c.blocks, 1 < i := ne_ones_iff.1 H
theorem eq_ones_iff_length {c : Composition n} : c = ones n ↔ c.length = n := by
  constructor
  · rintro rfl
    exact ones_length n
  · contrapose
    intro H length_n
    apply lt_irrefl n
    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
        

Proof state:
case intro.intro
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : length c = n
i : ℕ
hi : i ∈ c.blocks
i_blocks : 1 < i
⊢ ∑ i : Fin (length c), 1 < ∑ i : Fin (length c), blocksFun c i

Next tactic:
rw [← ofFn_blocksFun, mem_ofFn c.blocksFun, Set.mem_range] at hi
theorem eq_ones_iff_length {c : Composition n} : c = ones n ↔ c.length = n := by
  constructor
  · rintro rfl
    exact ones_length n
  · contrapose
    intro H length_n
    apply lt_irrefl n
    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
        

Proof state:
case intro.intro
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : length c = n
i : ℕ
hi : ∃ y, blocksFun c y = i
i_blocks : 1 < i
⊢ ∑ i : Fin (length c), 1 < ∑ i : Fin (length c), blocksFun c i

Next tactic:
obtain ⟨j : Fin c.length, hj : c.blocksFun j = i⟩ := hi
theorem eq_ones_iff_length {c : Composition n} : c = ones n ↔ c.length = n := by
  constructor
  · rintro rfl
    exact ones_length n
  · contrapose
    intro H length_n
    apply lt_irrefl n
    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
        

Proof state:
case intro.intro.intro
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : length c = n
i : ℕ
i_blocks : 1 < i
j : Fin (length c)
hj : blocksFun c j = i
⊢ ∑ i : Fin (length c), 1 < ∑ i : Fin (length c), blocksFun c i

Next tactic:
rw [← hj] at i_blocks
theorem eq_ones_iff_length {c : Composition n} : c = ones n ↔ c.length = n := by
  constructor
  · rintro rfl
    exact ones_length n
  · contrapose
    intro H length_n
    apply lt_irrefl n
    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
        

Proof state:
case intro.intro.intro
n : ℕ
c✝ c : Composition n
H : ¬c = ones n
length_n : length c = n
i : ℕ
j : Fin (length c)
i_blocks : 1 < blocksFun c j
hj : blocksFun c j = i
⊢ ∑ i : Fin (length c), 1 < ∑ i : Fin (length c), blocksFun c i

Next tactic:
exact Finset.sum_lt_sum (fun i _ => one_le_blocksFun c i) ⟨j, Finset.mem_univ _, i_blocks⟩
theorem eq_ones_iff_le_length {c : Composition n} : c = ones n ↔ n ≤ c.length := by
  

Proof state:
n : ℕ
c✝ c : Composition n
⊢ c = ones n ↔ n ≤ length c

Next tactic:
simp [eq_ones_iff_length, le_antisymm_iff, c.length_le]
/-- The composition made of a single block of size `n`. -/
def single (n : ℕ) (h : 0 < n) : Composition n :=
  ⟨[n], by 

Proof state:
n✝ : ℕ
c : Composition n✝
n : ℕ
h : 0 < n
⊢ ∀ {i : ℕ}, i ∈ [n] → 0 < i

Next tactic:
simp [h]
/-- The composition made of a single block of size `n`. -/
def single (n : ℕ) (h : 0 < n) : Composition n :=
  ⟨[n], by simp [h], by 

Proof state:
n✝ : ℕ
c : Composition n✝
n : ℕ
h : 0 < n
⊢ sum [n] = n

Next tactic:
simp
@[simp]
theorem single_blocksFun {n : ℕ} (h : 0 < n) (i : Fin (single n h).length) :
    (single n h).blocksFun i = n := by 

Proof state:
n✝ : ℕ
c : Composition n✝
n : ℕ
h : 0 < n
i : Fin (length (single n h))
⊢ blocksFun (single n h) i = n

Next tactic:
simp [blocksFun, single, blocks, i.2]
@[simp]
theorem single_embedding {n : ℕ} (h : 0 < n) (i : Fin n) :
    ((single n h).embedding (0 : Fin 1)) i = i := by
  

Proof state:
n✝ : ℕ
c : Composition n✝
n : ℕ
h : 0 < n
i : Fin n
⊢ (embedding (single n h) 0) i = i

Next tactic:
ext
@[simp]
theorem single_embedding {n : ℕ} (h : 0 < n) (i : Fin n) :
    ((single n h).embedding (0 : Fin 1)) i = i := by
  ext
  

Proof state:
case h
n✝ : ℕ
c : Composition n✝
n : ℕ
h : 0 < n
i : Fin n
⊢ ↑((embedding (single n h) 0) i) = ↑i

Next tactic:
simp
theorem eq_single_iff_length {n : ℕ} (h : 0 < n) {c : Composition n} :
    c = single n h ↔ c.length = 1 := by
  

Proof state:
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
h : 0 < n
c : Composition n
⊢ c = single n h ↔ length c = 1

Next tactic:
constructor
theorem eq_single_iff_length {n : ℕ} (h : 0 < n) {c : Composition n} :
    c = single n h ↔ c.length = 1 := by
  constructor
  · 

Proof state:
case mp
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
h : 0 < n
c : Composition n
⊢ c = single n h → length c = 1

Next tactic:
intro H
theorem eq_single_iff_length {n : ℕ} (h : 0 < n) {c : Composition n} :
    c = single n h ↔ c.length = 1 := by
  constructor
  · intro H
    

Proof state:
case mp
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
h : 0 < n
c : Composition n
H : c = single n h
⊢ length c = 1

Next tactic:
rw [H]
theorem eq_single_iff_length {n : ℕ} (h : 0 < n) {c : Composition n} :
    c = single n h ↔ c.length = 1 := by
  constructor
  · intro H
    rw [H]
    

Proof state:
case mp
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
h : 0 < n
c : Composition n
H : c = single n h
⊢ length (single n h) = 1

Next tactic:
exact single_length h
theorem eq_single_iff_length {n : ℕ} (h : 0 < n) {c : Composition n} :
    c = single n h ↔ c.length = 1 := by
  constructor
  · intro H
    rw [H]
    exact single_length h
  · 

Proof state:
case mpr
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
h : 0 < n
c : Composition n
⊢ length c = 1 → c = single n h

Next tactic:
intro H
theorem eq_single_iff_length {n : ℕ} (h : 0 < n) {c : Composition n} :
    c = single n h ↔ c.length = 1 := by
  constructor
  · intro H
    rw [H]
    exact single_length h
  · intro H
    

Proof state:
case mpr
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
h : 0 < n
c : Composition n
H : length c = 1
⊢ c = single n h

Next tactic:
ext1
theorem eq_single_iff_length {n : ℕ} (h : 0 < n) {c : Composition n} :
    c = single n h ↔ c.length = 1 := by
  constructor
  · intro H
    rw [H]
    exact single_length h
  · intro H
    ext1
    

Proof state:
case mpr.blocks
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
h : 0 < n
c : Composition n
H : length c = 1
⊢ c.blocks = (single n h).blocks

Next tactic:
have A : c.blocks.length = 1 := H ▸ c.blocks_length
theorem eq_single_iff_length {n : ℕ} (h : 0 < n) {c : Composition n} :
    c = single n h ↔ c.length = 1 := by
  constructor
  · intro H
    rw [H]
    exact single_length h
  · intro H
    ext1
    have A : c.blocks.length = 1 := H ▸ c.blocks_length
    

Proof state:
case mpr.blocks
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
h : 0 < n
c : Composition n
H : length c = 1
A : List.length c.blocks = 1
⊢ c.blocks = (single n h).blocks

Next tactic:
have B : c.blocks.sum = n := c.blocks_sum
theorem eq_single_iff_length {n : ℕ} (h : 0 < n) {c : Composition n} :
    c = single n h ↔ c.length = 1 := by
  constructor
  · intro H
    rw [H]
    exact single_length h
  · intro H
    ext1
    have A : c.blocks.length = 1 := H ▸ c.blocks_length
    have B : c.blocks.sum = n := c.blocks_sum
    

Proof state:
case mpr.blocks
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
h : 0 < n
c : Composition n
H : length c = 1
A : List.length c.blocks = 1
B : sum c.blocks = n
⊢ c.blocks = (single n h).blocks

Next tactic:
rw [eq_cons_of_length_one A] at B ⊢
theorem eq_single_iff_length {n : ℕ} (h : 0 < n) {c : Composition n} :
    c = single n h ↔ c.length = 1 := by
  constructor
  · intro H
    rw [H]
    exact single_length h
  · intro H
    ext1
    have A : c.blocks.length = 1 := H ▸ c.blocks_length
    have B : c.blocks.sum = n := c.blocks_sum
    rw [eq_cons_of_length_one A] at B ⊢
    

Proof state:
case mpr.blocks
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
h : 0 < n
c : Composition n
H : length c = 1
A : List.length c.blocks = 1
B : sum [nthLe c.blocks 0 (_ : 0 < List.length c.blocks)] = n
⊢ [nthLe c.blocks 0 (_ : 0 < List.length c.blocks)] = (single n h).blocks

Next tactic:
simpa [single_blocks] using B
theorem ne_single_iff {n : ℕ} (hn : 0 < n) {c : Composition n} :
    c ≠ single n hn ↔ ∀ i, c.blocksFun i < n := by
  

Proof state:
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
⊢ c ≠ single n hn ↔ ∀ (i : Fin (length c)), blocksFun c i < n

Next tactic:
rw [← not_iff_not]
theorem ne_single_iff {n : ℕ} (hn : 0 < n) {c : Composition n} :
    c ≠ single n hn ↔ ∀ i, c.blocksFun i < n := by
  rw [← not_iff_not]
  

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

Next tactic:
push_neg
theorem ne_single_iff {n : ℕ} (hn : 0 < n) {c : Composition n} :
    c ≠ single n hn ↔ ∀ i, c.blocksFun i < n := by
  rw [← not_iff_not]
  push_neg
  

Proof state:
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
⊢ c = single n hn ↔ ∃ i, n ≤ blocksFun c i

Next tactic:
constructor
theorem ne_single_iff {n : ℕ} (hn : 0 < n) {c : Composition n} :
    c ≠ single n hn ↔ ∀ i, c.blocksFun i < n := by
  rw [← not_iff_not]
  push_neg
  constructor
  · 

Proof state:
case mp
n✝ : ℕ
c✝ : Composition n✝
n : ℕ
hn : 0 < n
c : Composition n
⊢ c = single n hn → ∃ i, n ≤ blocksFun c i

Next tactic:
rintro rfl
theorem ne_single_iff {n : ℕ} (hn : 0 < n) {c : Composition n} :
    c ≠ single n hn ↔ ∀ i, c.blocksFun i < n := by
  rw [← not_iff_not]
  push_neg
  constructor
  · rintro rfl
    

Proof state:
case mp
n✝ : ℕ
c : Composition n✝
n : ℕ
hn : 0 < n
⊢ ∃ i, n ≤ blocksFun (single n hn) i

Next tactic:
exact ⟨⟨0, by simp⟩, by simp⟩
theorem ne_single_iff {n : ℕ} (hn : 0 < n) {c : Composition n} :
    c ≠ single n hn ↔ ∀ i, c.blocksFun i < n := by
  rw [← not_iff_not]
  push_neg
  constructor
  · rintro rfl
    exact ⟨⟨0, by 

Proof state:
n✝ : ℕ
c : Composition n✝
n : ℕ
hn : 0 < n
⊢ 0 < length (single n hn)

Next tactic:
simp
theorem ne_single_iff {n : ℕ} (hn : 0 < n) {c : Composition n} :
    c ≠ single n hn ↔ ∀ i, c.blocksFun i < n := by
  rw [← not_iff_not]
  push_neg
  constructor
  · rintro rfl
    exact ⟨⟨0, by simp⟩, by 

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

Next tactic:
simp
theorem ne_single_iff {n : ℕ} (hn : 0 < n) {c : Composition n} :
    c ≠ single n hn ↔ ∀ i, c.blocksFun i < n := by
  rw [← not_iff_not]
  push_neg
  constructor
  · rintro rfl
    exact ⟨⟨0, by simp⟩, by simp⟩
  · 

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

Next tactic:
rintro ⟨i, hi⟩
theorem ne_single_iff {n : ℕ} (hn : 0 < n) {c : Composition n} :
    c ≠ single n hn ↔ ∀ i, c.blocksFun i < n := by
  rw [← not_iff_not]
  push_neg
  constructor
  · rintro rfl
    exact ⟨⟨0, by simp⟩, by simp⟩
  · rintro ⟨i, hi⟩
    

Proof state:
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

Next tactic:
rw [eq_single_iff_length]
theorem ne_single_iff {n : ℕ} (hn : 0 < n) {c : Composition n} :
    c ≠ single n hn ↔ ∀ i, c.blocksFun i < n := by
  rw [← not_iff_not]
  push_neg
  constructor
  · rintro rfl
    exact ⟨⟨0, by simp⟩, by simp⟩
  · rintro ⟨i, hi⟩
    rw [eq_single_iff_length]
    

Proof state:
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

Next 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 _
theorem ne_single_iff {n : ℕ} (hn : 0 < n) {c : Composition n} :
    c ≠ single n hn ↔ ∀ i, c.blocksFun i < n := by
  rw [← not_iff_not]
  push_neg
  constructor
  · rintro rfl
    exact ⟨⟨0, by simp⟩, by simp⟩
  · rintro ⟨i, hi⟩
    rw [eq_single_iff_length]
    have : ∀ j : Fin c.length, j = i := by
      

Proof state:
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

Next tactic:
intro j
theorem ne_single_iff {n : ℕ} (hn : 0 < n) {c : Composition n} :
    c ≠ single n hn ↔ ∀ i, c.blocksFun i < n := by
  rw [← not_iff_not]
  push_neg
  constructor
  · rintro rfl
    exact ⟨⟨0, by simp⟩, by simp⟩
  · rintro ⟨i, hi⟩
    rw [eq_single_iff_length]
    have : ∀ j : Fin c.length, j = i := by
      intro j
      

Proof state:
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

Next tactic:
by_contra ji