l3lab/ntp-mathlib huggingface dataset:
theorem mem_boundaries_iff_exists_blocks_sum_take_eq {j : Fin (n + 1)} :
    j ∈ c.boundaries ↔ ∃ i < c.boundaries.card, (c.blocks.take i).sum = j := by
  constructor
  · intro hj
    rcases (c.boundaries.orderIsoOfFin rfl).surjective ⟨j, hj⟩ with ⟨i, hi⟩
    rw [Subtype.ext_iff, Subtype.coe_mk] at hi
    refine' ⟨i.1, i.2, _⟩
    dsimp at hi
    rw [← hi, c.blocks_partial_sum i.2]
    rfl
  · 

Proof state:
case mpr
n : ℕ
c : CompositionAsSet n
j : Fin (n + 1)
⊢ (∃ i < Finset.card c.boundaries, sum (take i (blocks c)) = ↑j) → j ∈ c.boundaries

Next tactic:
rintro ⟨i, hi, H⟩
theorem mem_boundaries_iff_exists_blocks_sum_take_eq {j : Fin (n + 1)} :
    j ∈ c.boundaries ↔ ∃ i < c.boundaries.card, (c.blocks.take i).sum = j := by
  constructor
  · intro hj
    rcases (c.boundaries.orderIsoOfFin rfl).surjective ⟨j, hj⟩ with ⟨i, hi⟩
    rw [Subtype.ext_iff, Subtype.coe_mk] at hi
    refine' ⟨i.1, i.2, _⟩
    dsimp at hi
    rw [← hi, c.blocks_partial_sum i.2]
    rfl
  · rintro ⟨i, hi, H⟩
    

Proof state:
case mpr.intro.intro
n : ℕ
c : CompositionAsSet n
j : Fin (n + 1)
i : ℕ
hi : i < Finset.card c.boundaries
H : sum (take i (blocks c)) = ↑j
⊢ j ∈ c.boundaries

Next tactic:
convert (c.boundaries.orderIsoOfFin rfl ⟨i, hi⟩).2
theorem mem_boundaries_iff_exists_blocks_sum_take_eq {j : Fin (n + 1)} :
    j ∈ c.boundaries ↔ ∃ i < c.boundaries.card, (c.blocks.take i).sum = j := by
  constructor
  · intro hj
    rcases (c.boundaries.orderIsoOfFin rfl).surjective ⟨j, hj⟩ with ⟨i, hi⟩
    rw [Subtype.ext_iff, Subtype.coe_mk] at hi
    refine' ⟨i.1, i.2, _⟩
    dsimp at hi
    rw [← hi, c.blocks_partial_sum i.2]
    rfl
  · rintro ⟨i, hi, H⟩
    convert (c.boundaries.orderIsoOfFin rfl ⟨i, hi⟩).2
    

Proof state:
case h.e'_4
n : ℕ
c : CompositionAsSet n
j : Fin (n + 1)
i : ℕ
hi : i < Finset.card c.boundaries
H : sum (take i (blocks c)) = ↑j
⊢ j =
    ↑((Finset.orderIsoOfFin c.boundaries (_ : Finset.card c.boundaries = Finset.card c.boundaries))
        { val := i, isLt := hi })

Next tactic:
have : c.boundary ⟨i, hi⟩ = j := by rwa [Fin.ext_iff, ← c.blocks_partial_sum hi]
theorem mem_boundaries_iff_exists_blocks_sum_take_eq {j : Fin (n + 1)} :
    j ∈ c.boundaries ↔ ∃ i < c.boundaries.card, (c.blocks.take i).sum = j := by
  constructor
  · intro hj
    rcases (c.boundaries.orderIsoOfFin rfl).surjective ⟨j, hj⟩ with ⟨i, hi⟩
    rw [Subtype.ext_iff, Subtype.coe_mk] at hi
    refine' ⟨i.1, i.2, _⟩
    dsimp at hi
    rw [← hi, c.blocks_partial_sum i.2]
    rfl
  · rintro ⟨i, hi, H⟩
    convert (c.boundaries.orderIsoOfFin rfl ⟨i, hi⟩).2
    have : c.boundary ⟨i, hi⟩ = j := by 

Proof state:
n : ℕ
c : CompositionAsSet n
j : Fin (n + 1)
i : ℕ
hi : i < Finset.card c.boundaries
H : sum (take i (blocks c)) = ↑j
⊢ (boundary c) { val := i, isLt := hi } = j

Next tactic:
rwa [Fin.ext_iff, ← c.blocks_partial_sum hi]
theorem mem_boundaries_iff_exists_blocks_sum_take_eq {j : Fin (n + 1)} :
    j ∈ c.boundaries ↔ ∃ i < c.boundaries.card, (c.blocks.take i).sum = j := by
  constructor
  · intro hj
    rcases (c.boundaries.orderIsoOfFin rfl).surjective ⟨j, hj⟩ with ⟨i, hi⟩
    rw [Subtype.ext_iff, Subtype.coe_mk] at hi
    refine' ⟨i.1, i.2, _⟩
    dsimp at hi
    rw [← hi, c.blocks_partial_sum i.2]
    rfl
  · rintro ⟨i, hi, H⟩
    convert (c.boundaries.orderIsoOfFin rfl ⟨i, hi⟩).2
    have : c.boundary ⟨i, hi⟩ = j := by rwa [Fin.ext_iff, ← c.blocks_partial_sum hi]
    

Proof state:
case h.e'_4
n : ℕ
c : CompositionAsSet n
j : Fin (n + 1)
i : ℕ
hi : i < Finset.card c.boundaries
H : sum (take i (blocks c)) = ↑j
this : (boundary c) { val := i, isLt := hi } = j
⊢ j =
    ↑((Finset.orderIsoOfFin c.boundaries (_ : Finset.card c.boundaries = Finset.card c.boundaries))
        { val := i, isLt := hi })

Next tactic:
exact this.symm
theorem blocks_sum : c.blocks.sum = n := by
  

Proof state:
n : ℕ
c : CompositionAsSet n
⊢ sum (blocks c) = n

Next tactic:
have : c.blocks.take c.length = c.blocks := take_all_of_le (by simp [blocks])
theorem blocks_sum : c.blocks.sum = n := by
  have : c.blocks.take c.length = c.blocks := take_all_of_le (by 

Proof state:
n : ℕ
c : CompositionAsSet n
⊢ List.length (blocks c) ≤ length c

Next tactic:
simp [blocks]
theorem blocks_sum : c.blocks.sum = n := by
  have : c.blocks.take c.length = c.blocks := take_all_of_le (by simp [blocks])
  

Proof state:
n : ℕ
c : CompositionAsSet n
this : take (length c) (blocks c) = blocks c
⊢ sum (blocks c) = n

Next tactic:
rw [← this, c.blocks_partial_sum c.length_lt_card_boundaries, c.boundary_length]
theorem blocks_sum : c.blocks.sum = n := by
  have : c.blocks.take c.length = c.blocks := take_all_of_le (by simp [blocks])
  rw [← this, c.blocks_partial_sum c.length_lt_card_boundaries, c.boundary_length]
  

Proof state:
n : ℕ
c : CompositionAsSet n
this : take (length c) (blocks c) = blocks c
⊢ ↑(Fin.last n) = n

Next tactic:
rfl
/-- Associating a `Composition n` to a `CompositionAsSet n`, by registering the sizes of the
blocks as a list of positive integers. -/
def toComposition : Composition n where
  blocks := c.blocks
  blocks_pos := by 

Proof state:
n : ℕ
c : CompositionAsSet n
⊢ ∀ {i : ℕ}, i ∈ blocks c → 0 < i

Next tactic:
simp only [blocks, forall_mem_ofFn_iff, blocksFun_pos c, forall_true_iff]
@[simp]
theorem Composition.toCompositionAsSet_length (c : Composition n) :
    c.toCompositionAsSet.length = c.length := by
  

Proof state:
n : ℕ
c : Composition n
⊢ CompositionAsSet.length (toCompositionAsSet c) = length c

Next tactic:
simp [Composition.toCompositionAsSet, CompositionAsSet.length, c.card_boundaries_eq_succ_length]
@[simp]
theorem CompositionAsSet.toComposition_length (c : CompositionAsSet n) :
    c.toComposition.length = c.length := by
  

Proof state:
n : ℕ
c : CompositionAsSet n
⊢ Composition.length (toComposition c) = length c

Next tactic:
simp [CompositionAsSet.toComposition, Composition.length, Composition.blocks]
@[simp]
theorem Composition.toCompositionAsSet_blocks (c : Composition n) :
    c.toCompositionAsSet.blocks = c.blocks := by
  

Proof state:
n : ℕ
c : Composition n
⊢ CompositionAsSet.blocks (toCompositionAsSet c) = c.blocks

Next tactic:
let d := c.toCompositionAsSet
@[simp]
theorem Composition.toCompositionAsSet_blocks (c : Composition n) :
    c.toCompositionAsSet.blocks = c.blocks := by
  let d := c.toCompositionAsSet
  

Proof state:
n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
⊢ CompositionAsSet.blocks (toCompositionAsSet c) = c.blocks

Next tactic:
change d.blocks = c.blocks
@[simp]
theorem Composition.toCompositionAsSet_blocks (c : Composition n) :
    c.toCompositionAsSet.blocks = c.blocks := by
  let d := c.toCompositionAsSet
  change d.blocks = c.blocks
  

Proof state:
n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
⊢ CompositionAsSet.blocks d = c.blocks

Next tactic:
have length_eq : d.blocks.length = c.blocks.length := by
    convert c.toCompositionAsSet_length
    simp [CompositionAsSet.blocks]
@[simp]
theorem Composition.toCompositionAsSet_blocks (c : Composition n) :
    c.toCompositionAsSet.blocks = c.blocks := by
  let d := c.toCompositionAsSet
  change d.blocks = c.blocks
  have length_eq : d.blocks.length = c.blocks.length := by
    

Proof state:
n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
⊢ List.length (CompositionAsSet.blocks d) = List.length c.blocks

Next tactic:
convert c.toCompositionAsSet_length
@[simp]
theorem Composition.toCompositionAsSet_blocks (c : Composition n) :
    c.toCompositionAsSet.blocks = c.blocks := by
  let d := c.toCompositionAsSet
  change d.blocks = c.blocks
  have length_eq : d.blocks.length = c.blocks.length := by
    convert c.toCompositionAsSet_length
    

Proof state:
case h.e'_2
n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
⊢ List.length (CompositionAsSet.blocks d) = CompositionAsSet.length (toCompositionAsSet c)

Next tactic:
simp [CompositionAsSet.blocks]
@[simp]
theorem Composition.toCompositionAsSet_blocks (c : Composition n) :
    c.toCompositionAsSet.blocks = c.blocks := by
  let d := c.toCompositionAsSet
  change d.blocks = c.blocks
  have length_eq : d.blocks.length = c.blocks.length := by
    convert c.toCompositionAsSet_length
    simp [CompositionAsSet.blocks]
  

Proof state:
n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
length_eq : List.length (CompositionAsSet.blocks d) = List.length c.blocks
⊢ CompositionAsSet.blocks d = c.blocks

Next tactic:
suffices H : ∀ i ≤ d.blocks.length, (d.blocks.take i).sum = (c.blocks.take i).sum
@[simp]
theorem Composition.toCompositionAsSet_blocks (c : Composition n) :
    c.toCompositionAsSet.blocks = c.blocks := by
  let d := c.toCompositionAsSet
  change d.blocks = c.blocks
  have length_eq : d.blocks.length = c.blocks.length := by
    convert c.toCompositionAsSet_length
    simp [CompositionAsSet.blocks]
  suffices H : ∀ i ≤ d.blocks.length, (d.blocks.take i).sum = (c.blocks.take i).sum
  

Proof state:
n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
length_eq : List.length (CompositionAsSet.blocks d) = List.length c.blocks
H : ∀ i ≤ List.length (CompositionAsSet.blocks d), sum (take i (CompositionAsSet.blocks d)) = sum (take i c.blocks)
⊢ CompositionAsSet.blocks d = c.blocks
case H
n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
length_eq : List.length (CompositionAsSet.blocks d) = List.length c.blocks
⊢ ∀ i ≤ List.length (CompositionAsSet.blocks d), sum (take i (CompositionAsSet.blocks d)) = sum (take i c.blocks)

Next tactic:
exact eq_of_sum_take_eq length_eq H
@[simp]
theorem Composition.toCompositionAsSet_blocks (c : Composition n) :
    c.toCompositionAsSet.blocks = c.blocks := by
  let d := c.toCompositionAsSet
  change d.blocks = c.blocks
  have length_eq : d.blocks.length = c.blocks.length := by
    convert c.toCompositionAsSet_length
    simp [CompositionAsSet.blocks]
  suffices H : ∀ i ≤ d.blocks.length, (d.blocks.take i).sum = (c.blocks.take i).sum
  exact eq_of_sum_take_eq length_eq H
  

Proof state:
case H
n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
length_eq : List.length (CompositionAsSet.blocks d) = List.length c.blocks
⊢ ∀ i ≤ List.length (CompositionAsSet.blocks d), sum (take i (CompositionAsSet.blocks d)) = sum (take i c.blocks)

Next tactic:
intro i hi
@[simp]
theorem Composition.toCompositionAsSet_blocks (c : Composition n) :
    c.toCompositionAsSet.blocks = c.blocks := by
  let d := c.toCompositionAsSet
  change d.blocks = c.blocks
  have length_eq : d.blocks.length = c.blocks.length := by
    convert c.toCompositionAsSet_length
    simp [CompositionAsSet.blocks]
  suffices H : ∀ i ≤ d.blocks.length, (d.blocks.take i).sum = (c.blocks.take i).sum
  exact eq_of_sum_take_eq length_eq H
  intro i hi
  

Proof state:
case H
n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
length_eq : List.length (CompositionAsSet.blocks d) = List.length c.blocks
i : ℕ
hi : i ≤ List.length (CompositionAsSet.blocks d)
⊢ sum (take i (CompositionAsSet.blocks d)) = sum (take i c.blocks)

Next tactic:
have i_lt : i < d.boundaries.card := by
    -- porting note: relied on `convert` unfolding definitions, switched to using a `simpa`
    simpa [CompositionAsSet.blocks, length_ofFn, Nat.succ_eq_add_one,
      d.card_boundaries_eq_succ_length] using Nat.lt_succ_iff.2 hi
@[simp]
theorem Composition.toCompositionAsSet_blocks (c : Composition n) :
    c.toCompositionAsSet.blocks = c.blocks := by
  let d := c.toCompositionAsSet
  change d.blocks = c.blocks
  have length_eq : d.blocks.length = c.blocks.length := by
    convert c.toCompositionAsSet_length
    simp [CompositionAsSet.blocks]
  suffices H : ∀ i ≤ d.blocks.length, (d.blocks.take i).sum = (c.blocks.take i).sum
  exact eq_of_sum_take_eq length_eq H
  intro i hi
  have i_lt : i < d.boundaries.card := by
    -- porting note: relied on `convert` unfolding definitions, switched to using a `simpa`
    

Proof state:
n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
length_eq : List.length (CompositionAsSet.blocks d) = List.length c.blocks
i : ℕ
hi : i ≤ List.length (CompositionAsSet.blocks d)
⊢ i < Finset.card d.boundaries

Next tactic:
simpa [CompositionAsSet.blocks, length_ofFn, Nat.succ_eq_add_one,
      d.card_boundaries_eq_succ_length] using Nat.lt_succ_iff.2 hi
@[simp]
theorem Composition.toCompositionAsSet_blocks (c : Composition n) :
    c.toCompositionAsSet.blocks = c.blocks := by
  let d := c.toCompositionAsSet
  change d.blocks = c.blocks
  have length_eq : d.blocks.length = c.blocks.length := by
    convert c.toCompositionAsSet_length
    simp [CompositionAsSet.blocks]
  suffices H : ∀ i ≤ d.blocks.length, (d.blocks.take i).sum = (c.blocks.take i).sum
  exact eq_of_sum_take_eq length_eq H
  intro i hi
  have i_lt : i < d.boundaries.card := by
    -- porting note: relied on `convert` unfolding definitions, switched to using a `simpa`
    simpa [CompositionAsSet.blocks, length_ofFn, Nat.succ_eq_add_one,
      d.card_boundaries_eq_succ_length] using Nat.lt_succ_iff.2 hi
  

Proof state:
case H
n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
length_eq : List.length (CompositionAsSet.blocks d) = List.length c.blocks
i : ℕ
hi : i ≤ List.length (CompositionAsSet.blocks d)
i_lt : i < Finset.card d.boundaries
⊢ sum (take i (CompositionAsSet.blocks d)) = sum (take i c.blocks)

Next tactic:
have i_lt' : i < c.boundaries.card := i_lt
@[simp]
theorem Composition.toCompositionAsSet_blocks (c : Composition n) :
    c.toCompositionAsSet.blocks = c.blocks := by
  let d := c.toCompositionAsSet
  change d.blocks = c.blocks
  have length_eq : d.blocks.length = c.blocks.length := by
    convert c.toCompositionAsSet_length
    simp [CompositionAsSet.blocks]
  suffices H : ∀ i ≤ d.blocks.length, (d.blocks.take i).sum = (c.blocks.take i).sum
  exact eq_of_sum_take_eq length_eq H
  intro i hi
  have i_lt : i < d.boundaries.card := by
    -- porting note: relied on `convert` unfolding definitions, switched to using a `simpa`
    simpa [CompositionAsSet.blocks, length_ofFn, Nat.succ_eq_add_one,
      d.card_boundaries_eq_succ_length] using Nat.lt_succ_iff.2 hi
  have i_lt' : i < c.boundaries.card := i_lt
  

Proof state:
case H
n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
length_eq : List.length (CompositionAsSet.blocks d) = List.length c.blocks
i : ℕ
hi : i ≤ List.length (CompositionAsSet.blocks d)
i_lt : i < Finset.card d.boundaries
i_lt' : i < Finset.card (boundaries c)
⊢ sum (take i (CompositionAsSet.blocks d)) = sum (take i c.blocks)

Next tactic:
have i_lt'' : i < c.length + 1 := by rwa [c.card_boundaries_eq_succ_length] at i_lt'
@[simp]
theorem Composition.toCompositionAsSet_blocks (c : Composition n) :
    c.toCompositionAsSet.blocks = c.blocks := by
  let d := c.toCompositionAsSet
  change d.blocks = c.blocks
  have length_eq : d.blocks.length = c.blocks.length := by
    convert c.toCompositionAsSet_length
    simp [CompositionAsSet.blocks]
  suffices H : ∀ i ≤ d.blocks.length, (d.blocks.take i).sum = (c.blocks.take i).sum
  exact eq_of_sum_take_eq length_eq H
  intro i hi
  have i_lt : i < d.boundaries.card := by
    -- porting note: relied on `convert` unfolding definitions, switched to using a `simpa`
    simpa [CompositionAsSet.blocks, length_ofFn, Nat.succ_eq_add_one,
      d.card_boundaries_eq_succ_length] using Nat.lt_succ_iff.2 hi
  have i_lt' : i < c.boundaries.card := i_lt
  have i_lt'' : i < c.length + 1 := by 

Proof state:
n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
length_eq : List.length (CompositionAsSet.blocks d) = List.length c.blocks
i : ℕ
hi : i ≤ List.length (CompositionAsSet.blocks d)
i_lt : i < Finset.card d.boundaries
i_lt' : i < Finset.card (boundaries c)
⊢ i < length c + 1

Next tactic:
rwa [c.card_boundaries_eq_succ_length] at i_lt'
@[simp]
theorem Composition.toCompositionAsSet_blocks (c : Composition n) :
    c.toCompositionAsSet.blocks = c.blocks := by
  let d := c.toCompositionAsSet
  change d.blocks = c.blocks
  have length_eq : d.blocks.length = c.blocks.length := by
    convert c.toCompositionAsSet_length
    simp [CompositionAsSet.blocks]
  suffices H : ∀ i ≤ d.blocks.length, (d.blocks.take i).sum = (c.blocks.take i).sum
  exact eq_of_sum_take_eq length_eq H
  intro i hi
  have i_lt : i < d.boundaries.card := by
    -- porting note: relied on `convert` unfolding definitions, switched to using a `simpa`
    simpa [CompositionAsSet.blocks, length_ofFn, Nat.succ_eq_add_one,
      d.card_boundaries_eq_succ_length] using Nat.lt_succ_iff.2 hi
  have i_lt' : i < c.boundaries.card := i_lt
  have i_lt'' : i < c.length + 1 := by rwa [c.card_boundaries_eq_succ_length] at i_lt'
  

Proof state:
case H
n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
length_eq : List.length (CompositionAsSet.blocks d) = List.length c.blocks
i : ℕ
hi : i ≤ List.length (CompositionAsSet.blocks d)
i_lt : i < Finset.card d.boundaries
i_lt' : i < Finset.card (boundaries c)
i_lt'' : i < length c + 1
⊢ sum (take i (CompositionAsSet.blocks d)) = sum (take i c.blocks)

Next tactic:
have A :
    d.boundaries.orderEmbOfFin rfl ⟨i, i_lt⟩ =
      c.boundaries.orderEmbOfFin c.card_boundaries_eq_succ_length ⟨i, i_lt''⟩ :=
    rfl
@[simp]
theorem Composition.toCompositionAsSet_blocks (c : Composition n) :
    c.toCompositionAsSet.blocks = c.blocks := by
  let d := c.toCompositionAsSet
  change d.blocks = c.blocks
  have length_eq : d.blocks.length = c.blocks.length := by
    convert c.toCompositionAsSet_length
    simp [CompositionAsSet.blocks]
  suffices H : ∀ i ≤ d.blocks.length, (d.blocks.take i).sum = (c.blocks.take i).sum
  exact eq_of_sum_take_eq length_eq H
  intro i hi
  have i_lt : i < d.boundaries.card := by
    -- porting note: relied on `convert` unfolding definitions, switched to using a `simpa`
    simpa [CompositionAsSet.blocks, length_ofFn, Nat.succ_eq_add_one,
      d.card_boundaries_eq_succ_length] using Nat.lt_succ_iff.2 hi
  have i_lt' : i < c.boundaries.card := i_lt
  have i_lt'' : i < c.length + 1 := by rwa [c.card_boundaries_eq_succ_length] at i_lt'
  have A :
    d.boundaries.orderEmbOfFin rfl ⟨i, i_lt⟩ =
      c.boundaries.orderEmbOfFin c.card_boundaries_eq_succ_length ⟨i, i_lt''⟩ :=
    rfl
  

Proof state:
case H
n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
length_eq : List.length (CompositionAsSet.blocks d) = List.length c.blocks
i : ℕ
hi : i ≤ List.length (CompositionAsSet.blocks d)
i_lt : i < Finset.card d.boundaries
i_lt' : i < Finset.card (boundaries c)
i_lt'' : i < length c + 1
A :
  (Finset.orderEmbOfFin d.boundaries (_ : Finset.card d.boundaries = Finset.card d.boundaries))
      { val := i, isLt := i_lt } =
    (Finset.orderEmbOfFin (boundaries c) (_ : Finset.card (boundaries c) = length c + 1)) { val := i, isLt := i_lt'' }
⊢ sum (take i (CompositionAsSet.blocks d)) = sum (take i c.blocks)

Next tactic:
have B : c.sizeUpTo i = c.boundary ⟨i, i_lt''⟩ := rfl
@[simp]
theorem Composition.toCompositionAsSet_blocks (c : Composition n) :
    c.toCompositionAsSet.blocks = c.blocks := by
  let d := c.toCompositionAsSet
  change d.blocks = c.blocks
  have length_eq : d.blocks.length = c.blocks.length := by
    convert c.toCompositionAsSet_length
    simp [CompositionAsSet.blocks]
  suffices H : ∀ i ≤ d.blocks.length, (d.blocks.take i).sum = (c.blocks.take i).sum
  exact eq_of_sum_take_eq length_eq H
  intro i hi
  have i_lt : i < d.boundaries.card := by
    -- porting note: relied on `convert` unfolding definitions, switched to using a `simpa`
    simpa [CompositionAsSet.blocks, length_ofFn, Nat.succ_eq_add_one,
      d.card_boundaries_eq_succ_length] using Nat.lt_succ_iff.2 hi
  have i_lt' : i < c.boundaries.card := i_lt
  have i_lt'' : i < c.length + 1 := by rwa [c.card_boundaries_eq_succ_length] at i_lt'
  have A :
    d.boundaries.orderEmbOfFin rfl ⟨i, i_lt⟩ =
      c.boundaries.orderEmbOfFin c.card_boundaries_eq_succ_length ⟨i, i_lt''⟩ :=
    rfl
  have B : c.sizeUpTo i = c.boundary ⟨i, i_lt''⟩ := rfl
  

Proof state:
case H
n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
length_eq : List.length (CompositionAsSet.blocks d) = List.length c.blocks
i : ℕ
hi : i ≤ List.length (CompositionAsSet.blocks d)
i_lt : i < Finset.card d.boundaries
i_lt' : i < Finset.card (boundaries c)
i_lt'' : i < length c + 1
A :
  (Finset.orderEmbOfFin d.boundaries (_ : Finset.card d.boundaries = Finset.card d.boundaries))
      { val := i, isLt := i_lt } =
    (Finset.orderEmbOfFin (boundaries c) (_ : Finset.card (boundaries c) = length c + 1)) { val := i, isLt := i_lt'' }
B : sizeUpTo c i = ↑((boundary c) { val := i, isLt := i_lt'' })
⊢ sum (take i (CompositionAsSet.blocks d)) = sum (take i c.blocks)

Next tactic:
rw [d.blocks_partial_sum i_lt, CompositionAsSet.boundary, ← Composition.sizeUpTo, B, A,
    c.orderEmbOfFin_boundaries]
@[simp]
theorem CompositionAsSet.toComposition_boundaries (c : CompositionAsSet n) :
    c.toComposition.boundaries = c.boundaries := by
  

Proof state:
n : ℕ
c : CompositionAsSet n
⊢ Composition.boundaries (toComposition c) = c.boundaries

Next tactic:
ext j
@[simp]
theorem CompositionAsSet.toComposition_boundaries (c : CompositionAsSet n) :
    c.toComposition.boundaries = c.boundaries := by
  ext j
  

Proof state:
case a
n : ℕ
c : CompositionAsSet n
j : Fin (n + 1)
⊢ j ∈ Composition.boundaries (toComposition c) ↔ j ∈ c.boundaries

Next tactic:
simp only [c.mem_boundaries_iff_exists_blocks_sum_take_eq, Composition.boundaries, Finset.mem_map]
@[simp]
theorem CompositionAsSet.toComposition_boundaries (c : CompositionAsSet n) :
    c.toComposition.boundaries = c.boundaries := by
  ext j
  simp only [c.mem_boundaries_iff_exists_blocks_sum_take_eq, Composition.boundaries, Finset.mem_map]
  

Proof state:
case a
n : ℕ
c : CompositionAsSet n
j : Fin (n + 1)
⊢ (∃ a ∈ Finset.univ, (Composition.boundary (toComposition c)).toEmbedding a = j) ↔
    ∃ i < Finset.card c.boundaries, sum (take i (blocks c)) = ↑j

Next tactic:
constructor
@[simp]
theorem CompositionAsSet.toComposition_boundaries (c : CompositionAsSet n) :
    c.toComposition.boundaries = c.boundaries := by
  ext j
  simp only [c.mem_boundaries_iff_exists_blocks_sum_take_eq, Composition.boundaries, Finset.mem_map]
  constructor
  · 

Proof state:
case a.mp
n : ℕ
c : CompositionAsSet n
j : Fin (n + 1)
⊢ (∃ a ∈ Finset.univ, (Composition.boundary (toComposition c)).toEmbedding a = j) →
    ∃ i < Finset.card c.boundaries, sum (take i (blocks c)) = ↑j

Next tactic:
rintro ⟨i, _, hi⟩
@[simp]
theorem CompositionAsSet.toComposition_boundaries (c : CompositionAsSet n) :
    c.toComposition.boundaries = c.boundaries := by
  ext j
  simp only [c.mem_boundaries_iff_exists_blocks_sum_take_eq, Composition.boundaries, Finset.mem_map]
  constructor
  · rintro ⟨i, _, hi⟩
    

Proof state:
case a.mp.intro.intro
n : ℕ
c : CompositionAsSet n
j : Fin (n + 1)
i : Fin (Composition.length (toComposition c) + 1)
left✝ : i ∈ Finset.univ
hi : (Composition.boundary (toComposition c)).toEmbedding i = j
⊢ ∃ i < Finset.card c.boundaries, sum (take i (blocks c)) = ↑j

Next tactic:
refine' ⟨i.1, _, _⟩
@[simp]
theorem CompositionAsSet.toComposition_boundaries (c : CompositionAsSet n) :
    c.toComposition.boundaries = c.boundaries := by
  ext j
  simp only [c.mem_boundaries_iff_exists_blocks_sum_take_eq, Composition.boundaries, Finset.mem_map]
  constructor
  · rintro ⟨i, _, hi⟩
    refine' ⟨i.1, _, _⟩
    

Proof state:
case a.mp.intro.intro.refine'_1
n : ℕ
c : CompositionAsSet n
j : Fin (n + 1)
i : Fin (Composition.length (toComposition c) + 1)
left✝ : i ∈ Finset.univ
hi : (Composition.boundary (toComposition c)).toEmbedding i = j
⊢ ↑i < Finset.card c.boundaries
case a.mp.intro.intro.refine'_2
n : ℕ
c : CompositionAsSet n
j : Fin (n + 1)
i : Fin (Composition.length (toComposition c) + 1)
left✝ : i ∈ Finset.univ
hi : (Composition.boundary (toComposition c)).toEmbedding i = j
⊢ sum (take (↑i) (blocks c)) = ↑j

Next tactic:
simpa [c.card_boundaries_eq_succ_length] using i.2