Theorem: CompositionAsSet.mem_boundaries_iff_exists_blocks_sum_take_eq
File: Mathlib/Combinatorics/Composition.lean

tactic: constructor
state_before: n : ℕ
c : CompositionAsSet n
j : Fin (n + 1)
⊢ j ∈ c.boundaries ↔ ∃ i, i < Finset.card c.boundaries ∧ sum (take i (blocks c)) = ↑j

tactic: intro hj
state_before: case mp
n : ℕ
c : CompositionAsSet n
j : Fin (n + 1)
⊢ j ∈ c.boundaries → ∃ i, i < Finset.card c.boundaries ∧ sum (take i (blocks c)) = ↑j

tactic: rcases(c.boundaries.orderIsoOfFin rfl).surjective ⟨j, hj⟩ with ⟨i, hi⟩
state_before: case mp
n : ℕ
c : CompositionAsSet n
j : Fin (n + 1)
hj : j ∈ c.boundaries
⊢ ∃ i, i < Finset.card c.boundaries ∧ sum (take i (blocks c)) = ↑j

tactic: rw [Subtype.ext_iff, Subtype.coe_mk] at hi
state_before: case mp.intro
n : ℕ
c : CompositionAsSet n
j : Fin (n + 1)
hj : j ∈ c.boundaries
i : Fin (Finset.card c.boundaries)
hi :
  ↑(Finset.orderIsoOfFin c.boundaries (_ : Finset.card c.boundaries = Finset.card c.boundaries)) i =
    { val := j, property := hj }
⊢ ∃ i, i < Finset.card c.boundaries ∧ sum (take i (blocks c)) = ↑j

tactic: refine' ⟨i.1, i.2, _⟩
state_before: case mp.intro
n : ℕ
c : CompositionAsSet n
j : Fin (n + 1)
hj : j ∈ c.boundaries
i : Fin (Finset.card c.boundaries)
hi :
  ↑(↑(Finset.orderIsoOfFin c.boundaries (_ : Finset.card c.boundaries = Finset.card c.boundaries)) i) =
    ↑{ val := j, property := hj }
⊢ ∃ i, i < Finset.card c.boundaries ∧ sum (take i (blocks c)) = ↑j

tactic: dsimp at hi
state_before: case mp.intro
n : ℕ
c : CompositionAsSet n
j : Fin (n + 1)
hj : j ∈ c.boundaries
i : Fin (Finset.card c.boundaries)
hi :
  ↑(↑(Finset.orderIsoOfFin c.boundaries (_ : Finset.card c.boundaries = Finset.card c.boundaries)) i) =
    ↑{ val := j, property := hj }
⊢ sum (take (↑i) (blocks c)) = ↑j

tactic: rw [← hi, c.blocks_partial_sum i.2]
state_before: case mp.intro
n : ℕ
c : CompositionAsSet n
j : Fin (n + 1)
hj : j ∈ c.boundaries
i : Fin (Finset.card c.boundaries)
hi : ↑(Finset.orderEmbOfFin c.boundaries (_ : Finset.card c.boundaries = Finset.card c.boundaries)) i = j
⊢ sum (take (↑i) (blocks c)) = ↑j

tactic: rfl
state_before: case mp.intro
n : ℕ
c : CompositionAsSet n
j : Fin (n + 1)
hj : j ∈ c.boundaries
i : Fin (Finset.card c.boundaries)
hi : ↑(Finset.orderEmbOfFin c.boundaries (_ : Finset.card c.boundaries = Finset.card c.boundaries)) i = j
⊢ ↑(↑(boundary c) { val := ↑i, isLt := (_ : ↑i < Finset.card c.boundaries) }) =
    ↑(↑(Finset.orderEmbOfFin c.boundaries (_ : Finset.card c.boundaries = Finset.card c.boundaries)) i)

tactic: rintro ⟨i, hi, H⟩
state_before: case mpr
n : ℕ
c : CompositionAsSet n
j : Fin (n + 1)
⊢ (∃ i, i < Finset.card c.boundaries ∧ sum (take i (blocks c)) = ↑j) → j ∈ c.boundaries

tactic: convert (c.boundaries.orderIsoOfFin rfl ⟨i, hi⟩).2
state_before: 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

tactic: have : c.boundary ⟨i, hi⟩ = j := by rwa [Fin.ext_iff, ← c.blocks_partial_sum hi]
state_before: 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 })

tactic: exact this.symm
state_before: 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 })

tactic: rwa [Fin.ext_iff, ← c.blocks_partial_sum hi]
state_before: 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