-- Mathlib/Analysis/Analytic/Composition.lean
theorem compChangeOfVariables_sum {α : Type*} [AddCommMonoid α] (m M N : ℕ)
    (f : (Σ n : ℕ, Fin n → ℕ) → α) (g : (Σ n, Composition n) → α)
    (h : ∀ (e) (he : e ∈ compPartialSumSource m M N), f e = g (compChangeOfVariables m M N e he)) :
    ∑ e ∈ compPartialSumSource m M N, f e = ∑ e ∈ compPartialSumTarget m M N, g e

Proof state:
case hi.mk
α : Type u_6
inst✝ : AddCommMonoid α
m M N : ℕ
f : (n : ℕ) × (Fin n → ℕ) → α
g : (n : ℕ) × Composition n → α
h : ∀ (e : (n : ℕ) × (Fin n → ℕ)) (he : e ∈ compPartialSumSource m M N), f e = g (compChangeOfVariables m M N e he)
k : ℕ
blocks_fun : Fin k → ℕ
H✝ : ⟨k, blocks_fun⟩ ∈ compPartialSumSource m M N
H : (m ≤ k ∧ k < M) ∧ ∀ (a : Fin k), 1 ≤ blocks_fun a ∧ blocks_fun a < N
j : Fin (ofFn fun a => blocks_fun a).length
⊢ { blocks := ofFn fun a => blocks_fun a, blocks_pos := ⋯, blocks_sum := ⋯ }.blocksFun j < N

Tactic:
simp only [Composition.blocksFun, (H.right _).right, List.get_ofFn]

Result:
no goals

Proof state:
case i_inj.mk.mk.e_snd.h
α : Type u_6
inst✝ : AddCommMonoid α
m M N : ℕ
f : (n : ℕ) × (Fin n → ℕ) → α
g : (n : ℕ) × Composition n → α
h : ∀ (e : (n : ℕ) × (Fin n → ℕ)) (he : e ∈ compPartialSumSource m M N), f e = g (compChangeOfVariables m M N e he)
k : ℕ
blocks_fun : Fin k → ℕ
H : ⟨k, blocks_fun⟩ ∈ compPartialSumSource m M N
blocks_fun' : Fin k → ℕ
H' : ⟨k, blocks_fun'⟩ ∈ compPartialSumSource m M N
heq : compChangeOfVariables m M N ⟨k, blocks_fun⟩ H = compChangeOfVariables m M N ⟨k, blocks_fun'⟩ H'
i : Fin k
⊢ blocks_fun i = blocks_fun' i

Tactic:
calc
  blocks_fun i = (compChangeOfVariables m M N _ H).2.blocksFun _ :=
    (compChangeOfVariables_blocksFun m M N H i).symm
  _ = (compChangeOfVariables m M N _ H').2.blocksFun _ := by
    apply Composition.blocksFun_congr <;>
    first | rw [heq] | rfl
  _ = blocks_fun' i := compChangeOfVariables_blocksFun m M N H' i

Result:
no goals

Proof state:
case i_surj
α : Type u_6
inst✝ : AddCommMonoid α
m M N : ℕ
f : (n : ℕ) × (Fin n → ℕ) → α
g : (n : ℕ) × Composition n → α
h : ∀ (e : (n : ℕ) × (Fin n → ℕ)) (he : e ∈ compPartialSumSource m M N), f e = g (compChangeOfVariables m M N e he)
i : (n : ℕ) × Composition n
hi : i ∈ compPartialSumTarget m M N
⊢ ∃ a, ∃ (ha : a ∈ compPartialSumSource m M N), compChangeOfVariables m M N a ha = i

Tactic:
apply compPartialSumTargetSet_image_compPartialSumSource m M N i

Result:
case i_surj
α : Type u_6
inst✝ : AddCommMonoid α
m M N : ℕ
f : (n : ℕ) × (Fin n → ℕ) → α
g : (n : ℕ) × Composition n → α
h : ∀ (e : (n : ℕ) × (Fin n → ℕ)) (he : e ∈ compPartialSumSource m M N), f e = g (compChangeOfVariables m M N e he)
i : (n : ℕ) × Composition n
hi : i ∈ compPartialSumTarget m M N
⊢ i ∈ compPartialSumTargetSet m M N

Proof state:
case hi.mk
α : Type u_6
inst✝ : AddCommMonoid α
m M N : ℕ
f : (n : ℕ) × (Fin n → ℕ) → α
g : (n : ℕ) × Composition n → α
h : ∀ (e : (n : ℕ) × (Fin n → ℕ)) (he : e ∈ compPartialSumSource m M N), f e = g (compChangeOfVariables m M N e he)
k : ℕ
blocks_fun : Fin k → ℕ
H✝ : ⟨k, blocks_fun⟩ ∈ compPartialSumSource m M N
H : (m ≤ k ∧ k < M) ∧ ∀ (a : Fin k), 1 ≤ blocks_fun a ∧ blocks_fun a < N
⊢ compChangeOfVariables m M N ⟨k, blocks_fun⟩ H✝ ∈ compPartialSumTarget m M N

Tactic:
simp only [mem_compPartialSumTarget_iff, Composition.length, Composition.blocks, H.left,
  map_ofFn, length_ofFn, true_and, compChangeOfVariables]

Result:
case hi.mk
α : Type u_6
inst✝ : AddCommMonoid α
m M N : ℕ
f : (n : ℕ) × (Fin n → ℕ) → α
g : (n : ℕ) × Composition n → α
h : ∀ (e : (n : ℕ) × (Fin n → ℕ)) (he : e ∈ compPartialSumSource m M N), f e = g (compChangeOfVariables m M N e he)
k : ℕ
blocks_fun : Fin k → ℕ
H✝ : ⟨k, blocks_fun⟩ ∈ compPartialSumSource m M N
H : (m ≤ k ∧ k < M) ∧ ∀ (a : Fin k), 1 ≤ blocks_fun a ∧ blocks_fun a < N
⊢ ∀ (j : Fin (ofFn fun a => blocks_fun a).length),
    { blocks := ofFn fun a => blocks_fun a, blocks_pos := ⋯, blocks_sum := ⋯ }.blocksFun j < N

Proof state:
α : Type u_6
inst✝ : AddCommMonoid α
m M N : ℕ
f : (n : ℕ) × (Fin n → ℕ) → α
g : (n : ℕ) × Composition n → α
h : ∀ (e : (n : ℕ) × (Fin n → ℕ)) (he : e ∈ compPartialSumSource m M N), f e = g (compChangeOfVariables m M N e he)
k : ℕ
blocks_fun : Fin k → ℕ
H : ⟨k, blocks_fun⟩ ∈ compPartialSumSource m M N
k' : ℕ
blocks_fun' : Fin k' → ℕ
H' : ⟨k', blocks_fun'⟩ ∈ compPartialSumSource m M N
heq : compChangeOfVariables m M N ⟨k, blocks_fun⟩ H = compChangeOfVariables m M N ⟨k', blocks_fun'⟩ H'
⊢ k = k'

Tactic:
have := (compChangeOfVariables_length m M N H).symm

Result:
α : Type u_6
inst✝ : AddCommMonoid α
m M N : ℕ
f : (n : ℕ) × (Fin n → ℕ) → α
g : (n : ℕ) × Composition n → α
h : ∀ (e : (n : ℕ) × (Fin n → ℕ)) (he : e ∈ compPartialSumSource m M N), f e = g (compChangeOfVariables m M N e he)
k : ℕ
blocks_fun : Fin k → ℕ
H : ⟨k, blocks_fun⟩ ∈ compPartialSumSource m M N
k' : ℕ
blocks_fun' : Fin k' → ℕ
H' : ⟨k', blocks_fun'⟩ ∈ compPartialSumSource m M N
heq : compChangeOfVariables m M N ⟨k, blocks_fun⟩ H = compChangeOfVariables m M N ⟨k', blocks_fun'⟩ H'
this : ⟨k, blocks_fun⟩.fst = (compChangeOfVariables m M N ⟨k, blocks_fun⟩ H).snd.length
⊢ k = k'

Proof state:
case hi
α : Type u_6
inst✝ : AddCommMonoid α
m M N : ℕ
f : (n : ℕ) × (Fin n → ℕ) → α
g : (n : ℕ) × Composition n → α
h : ∀ (e : (n : ℕ) × (Fin n → ℕ)) (he : e ∈ compPartialSumSource m M N), f e = g (compChangeOfVariables m M N e he)
k : ℕ
blocks_fun : Fin k → ℕ
H : ⟨k, blocks_fun⟩ ∈ compPartialSumSource m M N
blocks_fun' : Fin k → ℕ
H' : ⟨k, blocks_fun'⟩ ∈ compPartialSumSource m M N
heq : compChangeOfVariables m M N ⟨k, blocks_fun⟩ H = compChangeOfVariables m M N ⟨k, blocks_fun'⟩ H'
i : Fin k
⊢ ↑⟨↑i, ⋯⟩ = ↑⟨↑i, ⋯⟩

Tactic:
rfl

Result:
no goals

Proof state:
case i_inj.mk.mk
α : Type u_6
inst✝ : AddCommMonoid α
m M N : ℕ
f : (n : ℕ) × (Fin n → ℕ) → α
g : (n : ℕ) × Composition n → α
h : ∀ (e : (n : ℕ) × (Fin n → ℕ)) (he : e ∈ compPartialSumSource m M N), f e = g (compChangeOfVariables m M N e he)
k : ℕ
blocks_fun : Fin k → ℕ
H : ⟨k, blocks_fun⟩ ∈ compPartialSumSource m M N
blocks_fun' : Fin k → ℕ
H' : ⟨k, blocks_fun'⟩ ∈ compPartialSumSource m M N
heq : compChangeOfVariables m M N ⟨k, blocks_fun⟩ H = compChangeOfVariables m M N ⟨k, blocks_fun'⟩ H'
⊢ ⟨k, blocks_fun⟩ = ⟨k, blocks_fun'⟩

Tactic:
congr

Result:
case i_inj.mk.mk.e_snd
α : Type u_6
inst✝ : AddCommMonoid α
m M N : ℕ
f : (n : ℕ) × (Fin n → ℕ) → α
g : (n : ℕ) × Composition n → α
h : ∀ (e : (n : ℕ) × (Fin n → ℕ)) (he : e ∈ compPartialSumSource m M N), f e = g (compChangeOfVariables m M N e he)
k : ℕ
blocks_fun : Fin k → ℕ
H : ⟨k, blocks_fun⟩ ∈ compPartialSumSource m M N
blocks_fun' : Fin k → ℕ
H' : ⟨k, blocks_fun'⟩ ∈ compPartialSumSource m M N
heq : compChangeOfVariables m M N ⟨k, blocks_fun⟩ H = compChangeOfVariables m M N ⟨k, blocks_fun'⟩ H'
⊢ blocks_fun = blocks_fun'

Proof state:
case i_surj
α : Type u_6
inst✝ : AddCommMonoid α
m M N : ℕ
f : (n : ℕ) × (Fin n → ℕ) → α
g : (n : ℕ) × Composition n → α
h : ∀ (e : (n : ℕ) × (Fin n → ℕ)) (he : e ∈ compPartialSumSource m M N), f e = g (compChangeOfVariables m M N e he)
i : (n : ℕ) × Composition n
hi : i ∈ compPartialSumTarget m M N
⊢ i ∈ compPartialSumTargetSet m M N

Tactic:
simpa [compPartialSumTarget] using hi

Result:
no goals

Proof state:
case i_surj
α : Type u_6
inst✝ : AddCommMonoid α
m M N : ℕ
f : (n : ℕ) × (Fin n → ℕ) → α
g : (n : ℕ) × Composition n → α
h : ∀ (e : (n : ℕ) × (Fin n → ℕ)) (he : e ∈ compPartialSumSource m M N), f e = g (compChangeOfVariables m M N e he)
⊢ ∀ b ∈ compPartialSumTarget m M N, ∃ a, ∃ (ha : a ∈ compPartialSumSource m M N), compChangeOfVariables m M N a ha = b

Tactic:
intro i hi

Result:
case i_surj
α : Type u_6
inst✝ : AddCommMonoid α
m M N : ℕ
f : (n : ℕ) × (Fin n → ℕ) → α
g : (n : ℕ) × Composition n → α
h : ∀ (e : (n : ℕ) × (Fin n → ℕ)) (he : e ∈ compPartialSumSource m M N), f e = g (compChangeOfVariables m M N e he)
i : (n : ℕ) × Composition n
hi : i ∈ compPartialSumTarget m M N
⊢ ∃ a, ∃ (ha : a ∈ compPartialSumSource m M N), compChangeOfVariables m M N a ha = i