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

tactic: let d := c.toCompositionAsSet
state_before: n : ℕ
c : Composition n
⊢ CompositionAsSet.blocks (toCompositionAsSet c) = c.blocks

tactic: change d.blocks = c.blocks
state_before: n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
⊢ CompositionAsSet.blocks (toCompositionAsSet c) = c.blocks

tactic: have length_eq : d.blocks.length = c.blocks.length := by
  convert c.toCompositionAsSet_length
  simp [CompositionAsSet.blocks]
state_before: n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
⊢ CompositionAsSet.blocks d = c.blocks

tactic: suffices H : ∀ i ≤ d.blocks.length, (d.blocks.take i).sum = (c.blocks.take i).sum
state_before: 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

tactic: exact eq_of_sum_take_eq length_eq H
state_before: n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
length_eq : List.length (CompositionAsSet.blocks d) = List.length c.blocks
H :
  ∀ (i : ℕ),
    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 : ℕ),
    i ≤ List.length (CompositionAsSet.blocks d) → sum (take i (CompositionAsSet.blocks d)) = sum (take i c.blocks)

tactic: intro i hi
state_before: case H
n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
length_eq : List.length (CompositionAsSet.blocks d) = List.length c.blocks
⊢ ∀ (i : ℕ),
    i ≤ List.length (CompositionAsSet.blocks d) → sum (take i (CompositionAsSet.blocks d)) = sum (take i c.blocks)

tactic: have i_lt : i < d.boundaries.card := by
  simpa [CompositionAsSet.blocks, length_ofFn, Nat.succ_eq_add_one,
    d.card_boundaries_eq_succ_length] using Nat.lt_succ_iff.2 hi
state_before: 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)

tactic: have i_lt' : i < c.boundaries.card := i_lt
state_before: 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)

tactic: have i_lt'' : i < c.length + 1 := by rwa [c.card_boundaries_eq_succ_length] at i_lt'
state_before: 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)

tactic: have A :
  d.boundaries.orderEmbOfFin rfl ⟨i, i_lt⟩ =
    c.boundaries.orderEmbOfFin c.card_boundaries_eq_succ_length ⟨i, i_lt''⟩ :=
  rfl
state_before: 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)

tactic: have B : c.sizeUpTo i = c.boundary ⟨i, i_lt''⟩ := rfl
state_before: 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)

tactic: rw [d.blocks_partial_sum i_lt, CompositionAsSet.boundary, ← Composition.sizeUpTo, B, A,
  c.orderEmbOfFin_boundaries]
state_before: 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)

tactic: convert c.toCompositionAsSet_length
state_before: n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
⊢ List.length (CompositionAsSet.blocks d) = List.length c.blocks

tactic: simp [CompositionAsSet.blocks]
state_before: case h.e'_2
n : ℕ
c : Composition n
d : CompositionAsSet n := toCompositionAsSet c
⊢ List.length (CompositionAsSet.blocks d) = CompositionAsSet.length (toCompositionAsSet c)

tactic: simpa [CompositionAsSet.blocks, length_ofFn, Nat.succ_eq_add_one,
  d.card_boundaries_eq_succ_length] using Nat.lt_succ_iff.2 hi
state_before: 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

tactic: rwa [c.card_boundaries_eq_succ_length] at i_lt'
state_before: 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