l3lab/ntp-mathlib huggingface dataset:
theorem tendstoUniformlyOn_diff_iUnionNotConvergentSeq (hε : 0 < ε)
    (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s)
    (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) :
    TendstoUniformlyOn f g atTop (s \ Egorov.iUnionNotConvergentSeq hε hf hg hsm hs hfg) := by
  rw [Metric.tendstoUniformlyOn_iff]
  intro δ hδ
  obtain ⟨N, hN⟩ := exists_nat_one_div_lt hδ
  rw [eventually_atTop]
  refine' ⟨Egorov.notConvergentSeqLTIndex (half_pos hε) hf hg hsm hs hfg N, fun n hn x hx => _⟩
  simp only [Set.mem_diff, Egorov.iUnionNotConvergentSeq, not_exists, Set.mem_iUnion,
    Set.mem_inter_iff, not_and, exists_and_left] at hx
  obtain ⟨hxs, hx⟩ := hx
  

Proof state:
case intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
inst✝³ : MetricSpace β
μ : Measure α
n✝ : ℕ
i j : ι
s : Set α
ε : ℝ
f : ι → α → β
g : α → β
inst✝² : SemilatticeSup ι
inst✝¹ : Nonempty ι
inst✝ : Countable ι
hε : 0 < ε
hf : ∀ (n : ι), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hsm : MeasurableSet s
hs : ↑↑μ s ≠ ⊤
hfg : ∀ᵐ (x : α) ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))
δ : ℝ
hδ : δ > 0
N : ℕ
hN : 1 / (↑N + 1) < δ
n : ι
hn : n ≥ notConvergentSeqLTIndex (_ : 0 < ε / 2) hf hg hsm hs hfg N
x : α
hxs : x ∈ s
hx :
  x ∈ s →
    ∀ (x_1 : ℕ),
      x ∉ notConvergentSeq (fun n => f n) g x_1 (notConvergentSeqLTIndex (_ : 0 < ε / 2) hf hg hsm hs hfg x_1)
⊢ dist (g x) (f n x) < δ

Next tactic:
specialize hx hxs N
theorem tendstoUniformlyOn_diff_iUnionNotConvergentSeq (hε : 0 < ε)
    (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s)
    (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) :
    TendstoUniformlyOn f g atTop (s \ Egorov.iUnionNotConvergentSeq hε hf hg hsm hs hfg) := by
  rw [Metric.tendstoUniformlyOn_iff]
  intro δ hδ
  obtain ⟨N, hN⟩ := exists_nat_one_div_lt hδ
  rw [eventually_atTop]
  refine' ⟨Egorov.notConvergentSeqLTIndex (half_pos hε) hf hg hsm hs hfg N, fun n hn x hx => _⟩
  simp only [Set.mem_diff, Egorov.iUnionNotConvergentSeq, not_exists, Set.mem_iUnion,
    Set.mem_inter_iff, not_and, exists_and_left] at hx
  obtain ⟨hxs, hx⟩ := hx
  specialize hx hxs N
  

Proof state:
case intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
inst✝³ : MetricSpace β
μ : Measure α
n✝ : ℕ
i j : ι
s : Set α
ε : ℝ
f : ι → α → β
g : α → β
inst✝² : SemilatticeSup ι
inst✝¹ : Nonempty ι
inst✝ : Countable ι
hε : 0 < ε
hf : ∀ (n : ι), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hsm : MeasurableSet s
hs : ↑↑μ s ≠ ⊤
hfg : ∀ᵐ (x : α) ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))
δ : ℝ
hδ : δ > 0
N : ℕ
hN : 1 / (↑N + 1) < δ
n : ι
hn : n ≥ notConvergentSeqLTIndex (_ : 0 < ε / 2) hf hg hsm hs hfg N
x : α
hxs : x ∈ s
hx : x ∉ notConvergentSeq (fun n => f n) g N (notConvergentSeqLTIndex (_ : 0 < ε / 2) hf hg hsm hs hfg N)
⊢ dist (g x) (f n x) < δ

Next tactic:
rw [Egorov.mem_notConvergentSeq_iff] at hx
theorem tendstoUniformlyOn_diff_iUnionNotConvergentSeq (hε : 0 < ε)
    (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s)
    (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) :
    TendstoUniformlyOn f g atTop (s \ Egorov.iUnionNotConvergentSeq hε hf hg hsm hs hfg) := by
  rw [Metric.tendstoUniformlyOn_iff]
  intro δ hδ
  obtain ⟨N, hN⟩ := exists_nat_one_div_lt hδ
  rw [eventually_atTop]
  refine' ⟨Egorov.notConvergentSeqLTIndex (half_pos hε) hf hg hsm hs hfg N, fun n hn x hx => _⟩
  simp only [Set.mem_diff, Egorov.iUnionNotConvergentSeq, not_exists, Set.mem_iUnion,
    Set.mem_inter_iff, not_and, exists_and_left] at hx
  obtain ⟨hxs, hx⟩ := hx
  specialize hx hxs N
  rw [Egorov.mem_notConvergentSeq_iff] at hx
  

Proof state:
case intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
inst✝³ : MetricSpace β
μ : Measure α
n✝ : ℕ
i j : ι
s : Set α
ε : ℝ
f : ι → α → β
g : α → β
inst✝² : SemilatticeSup ι
inst✝¹ : Nonempty ι
inst✝ : Countable ι
hε : 0 < ε
hf : ∀ (n : ι), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hsm : MeasurableSet s
hs : ↑↑μ s ≠ ⊤
hfg : ∀ᵐ (x : α) ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))
δ : ℝ
hδ : δ > 0
N : ℕ
hN : 1 / (↑N + 1) < δ
n : ι
hn : n ≥ notConvergentSeqLTIndex (_ : 0 < ε / 2) hf hg hsm hs hfg N
x : α
hxs : x ∈ s
hx : ¬∃ k ≥ notConvergentSeqLTIndex (_ : 0 < ε / 2) hf hg hsm hs hfg N, 1 / (↑N + 1) < dist (f k x) (g x)
⊢ dist (g x) (f n x) < δ

Next tactic:
push_neg at hx
theorem tendstoUniformlyOn_diff_iUnionNotConvergentSeq (hε : 0 < ε)
    (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s)
    (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) :
    TendstoUniformlyOn f g atTop (s \ Egorov.iUnionNotConvergentSeq hε hf hg hsm hs hfg) := by
  rw [Metric.tendstoUniformlyOn_iff]
  intro δ hδ
  obtain ⟨N, hN⟩ := exists_nat_one_div_lt hδ
  rw [eventually_atTop]
  refine' ⟨Egorov.notConvergentSeqLTIndex (half_pos hε) hf hg hsm hs hfg N, fun n hn x hx => _⟩
  simp only [Set.mem_diff, Egorov.iUnionNotConvergentSeq, not_exists, Set.mem_iUnion,
    Set.mem_inter_iff, not_and, exists_and_left] at hx
  obtain ⟨hxs, hx⟩ := hx
  specialize hx hxs N
  rw [Egorov.mem_notConvergentSeq_iff] at hx
  push_neg at hx
  

Proof state:
case intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
inst✝³ : MetricSpace β
μ : Measure α
n✝ : ℕ
i j : ι
s : Set α
ε : ℝ
f : ι → α → β
g : α → β
inst✝² : SemilatticeSup ι
inst✝¹ : Nonempty ι
inst✝ : Countable ι
hε : 0 < ε
hf : ∀ (n : ι), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hsm : MeasurableSet s
hs : ↑↑μ s ≠ ⊤
hfg : ∀ᵐ (x : α) ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))
δ : ℝ
hδ : δ > 0
N : ℕ
hN : 1 / (↑N + 1) < δ
n : ι
hn : n ≥ notConvergentSeqLTIndex (_ : 0 < ε / 2) hf hg hsm hs hfg N
x : α
hxs : x ∈ s
hx : ∀ k ≥ notConvergentSeqLTIndex (_ : 0 < ε / 2) hf hg hsm hs hfg N, dist (f k x) (g x) ≤ 1 / (↑N + 1)
⊢ dist (g x) (f n x) < δ

Next tactic:
rw [dist_comm]
theorem tendstoUniformlyOn_diff_iUnionNotConvergentSeq (hε : 0 < ε)
    (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s)
    (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) :
    TendstoUniformlyOn f g atTop (s \ Egorov.iUnionNotConvergentSeq hε hf hg hsm hs hfg) := by
  rw [Metric.tendstoUniformlyOn_iff]
  intro δ hδ
  obtain ⟨N, hN⟩ := exists_nat_one_div_lt hδ
  rw [eventually_atTop]
  refine' ⟨Egorov.notConvergentSeqLTIndex (half_pos hε) hf hg hsm hs hfg N, fun n hn x hx => _⟩
  simp only [Set.mem_diff, Egorov.iUnionNotConvergentSeq, not_exists, Set.mem_iUnion,
    Set.mem_inter_iff, not_and, exists_and_left] at hx
  obtain ⟨hxs, hx⟩ := hx
  specialize hx hxs N
  rw [Egorov.mem_notConvergentSeq_iff] at hx
  push_neg at hx
  rw [dist_comm]
  

Proof state:
case intro.intro
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
inst✝³ : MetricSpace β
μ : Measure α
n✝ : ℕ
i j : ι
s : Set α
ε : ℝ
f : ι → α → β
g : α → β
inst✝² : SemilatticeSup ι
inst✝¹ : Nonempty ι
inst✝ : Countable ι
hε : 0 < ε
hf : ∀ (n : ι), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hsm : MeasurableSet s
hs : ↑↑μ s ≠ ⊤
hfg : ∀ᵐ (x : α) ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))
δ : ℝ
hδ : δ > 0
N : ℕ
hN : 1 / (↑N + 1) < δ
n : ι
hn : n ≥ notConvergentSeqLTIndex (_ : 0 < ε / 2) hf hg hsm hs hfg N
x : α
hxs : x ∈ s
hx : ∀ k ≥ notConvergentSeqLTIndex (_ : 0 < ε / 2) hf hg hsm hs hfg N, dist (f k x) (g x) ≤ 1 / (↑N + 1)
⊢ dist (f n x) (g x) < δ

Next tactic:
exact lt_of_le_of_lt (hx n hn) hN
/-- Egorov's theorem for finite measure spaces. -/
theorem tendstoUniformlyOn_of_ae_tendsto' [IsFiniteMeasure μ] (hf : ∀ n, StronglyMeasurable (f n))
    (hg : StronglyMeasurable g) (hfg : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))) {ε : ℝ}
    (hε : 0 < ε) :
    ∃ t, MeasurableSet t ∧ μ t ≤ ENNReal.ofReal ε ∧ TendstoUniformlyOn f g atTop tᶜ := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
inst✝⁵ : MetricSpace β
μ : Measure α
inst✝⁴ : SemilatticeSup ι
inst✝³ : Nonempty ι
inst✝² : Countable ι
γ : Type u_4
inst✝¹ : TopologicalSpace γ
f : ι → α → β
g : α → β
s : Set α
inst✝ : IsFiniteMeasure μ
hf : ∀ (n : ι), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ
hε : 0 < ε
⊢ ∃ t, MeasurableSet t ∧ ↑↑μ t ≤ ENNReal.ofReal ε ∧ TendstoUniformlyOn f g atTop tᶜ

Next tactic:
have ⟨t, _, ht, htendsto⟩ := tendstoUniformlyOn_of_ae_tendsto hf hg MeasurableSet.univ
    (measure_ne_top μ Set.univ) (by filter_upwards [hfg] with _ htendsto _ using htendsto) hε
/-- Egorov's theorem for finite measure spaces. -/
theorem tendstoUniformlyOn_of_ae_tendsto' [IsFiniteMeasure μ] (hf : ∀ n, StronglyMeasurable (f n))
    (hg : StronglyMeasurable g) (hfg : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))) {ε : ℝ}
    (hε : 0 < ε) :
    ∃ t, MeasurableSet t ∧ μ t ≤ ENNReal.ofReal ε ∧ TendstoUniformlyOn f g atTop tᶜ := by
  have ⟨t, _, ht, htendsto⟩ := tendstoUniformlyOn_of_ae_tendsto hf hg MeasurableSet.univ
    (measure_ne_top μ Set.univ) (by 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
inst✝⁵ : MetricSpace β
μ : Measure α
inst✝⁴ : SemilatticeSup ι
inst✝³ : Nonempty ι
inst✝² : Countable ι
γ : Type u_4
inst✝¹ : TopologicalSpace γ
f : ι → α → β
g : α → β
s : Set α
inst✝ : IsFiniteMeasure μ
hf : ∀ (n : ι), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ
hε : 0 < ε
⊢ ∀ᵐ (x : α) ∂μ, x ∈ univ → Tendsto (fun n => f n x) atTop (𝓝 (g x))

Next tactic:
filter_upwards [hfg] with _ htendsto _ using htendsto
/-- Egorov's theorem for finite measure spaces. -/
theorem tendstoUniformlyOn_of_ae_tendsto' [IsFiniteMeasure μ] (hf : ∀ n, StronglyMeasurable (f n))
    (hg : StronglyMeasurable g) (hfg : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))) {ε : ℝ}
    (hε : 0 < ε) :
    ∃ t, MeasurableSet t ∧ μ t ≤ ENNReal.ofReal ε ∧ TendstoUniformlyOn f g atTop tᶜ := by
  have ⟨t, _, ht, htendsto⟩ := tendstoUniformlyOn_of_ae_tendsto hf hg MeasurableSet.univ
    (measure_ne_top μ Set.univ) (by filter_upwards [hfg] with _ htendsto _ using htendsto) hε
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
inst✝⁵ : MetricSpace β
μ : Measure α
inst✝⁴ : SemilatticeSup ι
inst✝³ : Nonempty ι
inst✝² : Countable ι
γ : Type u_4
inst✝¹ : TopologicalSpace γ
f : ι → α → β
g : α → β
s : Set α
inst✝ : IsFiniteMeasure μ
hf : ∀ (n : ι), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ
hε : 0 < ε
t : Set α
left✝ : t ⊆ univ
ht : MeasurableSet t
htendsto : ↑↑μ t ≤ ENNReal.ofReal ε ∧ TendstoUniformlyOn (fun n => f n) g atTop (univ \ t)
⊢ ∃ t, MeasurableSet t ∧ ↑↑μ t ≤ ENNReal.ofReal ε ∧ TendstoUniformlyOn f g atTop tᶜ

Next tactic:
refine' ⟨_, ht, _⟩
/-- Egorov's theorem for finite measure spaces. -/
theorem tendstoUniformlyOn_of_ae_tendsto' [IsFiniteMeasure μ] (hf : ∀ n, StronglyMeasurable (f n))
    (hg : StronglyMeasurable g) (hfg : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))) {ε : ℝ}
    (hε : 0 < ε) :
    ∃ t, MeasurableSet t ∧ μ t ≤ ENNReal.ofReal ε ∧ TendstoUniformlyOn f g atTop tᶜ := by
  have ⟨t, _, ht, htendsto⟩ := tendstoUniformlyOn_of_ae_tendsto hf hg MeasurableSet.univ
    (measure_ne_top μ Set.univ) (by filter_upwards [hfg] with _ htendsto _ using htendsto) hε
  refine' ⟨_, ht, _⟩
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
m : MeasurableSpace α
inst✝⁵ : MetricSpace β
μ : Measure α
inst✝⁴ : SemilatticeSup ι
inst✝³ : Nonempty ι
inst✝² : Countable ι
γ : Type u_4
inst✝¹ : TopologicalSpace γ
f : ι → α → β
g : α → β
s : Set α
inst✝ : IsFiniteMeasure μ
hf : ∀ (n : ι), StronglyMeasurable (f n)
hg : StronglyMeasurable g
hfg : ∀ᵐ (x : α) ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))
ε : ℝ
hε : 0 < ε
t : Set α
left✝ : t ⊆ univ
ht : MeasurableSet t
htendsto : ↑↑μ t ≤ ENNReal.ofReal ε ∧ TendstoUniformlyOn (fun n => f n) g atTop (univ \ t)
⊢ ↑↑μ t ≤ ENNReal.ofReal ε ∧ TendstoUniformlyOn f g atTop tᶜ

Next tactic:
rwa [Set.compl_eq_univ_diff]
/-- The map from `Matrix n n R` to bilinear forms on `n → R`.

This is an auxiliary definition for the equivalence `Matrix.toLinearMap₂'`. -/
def Matrix.toLinearMap₂'Aux (f : Matrix n m R) : (n → R₁) →ₛₗ[σ₁] (m → R₂) →ₛₗ[σ₂] R :=
  -- porting note: we don't seem to have `∑ i j` as valid notation yet
  mk₂'ₛₗ σ₁ σ₂ (fun (v : n → R₁) (w : m → R₂) => ∑ i, ∑ j, σ₁ (v i) * f i j * σ₂ (w j))
    (fun _ _ _ => by 

Proof state:
R : Type u_1
R₁ : Type u_2
R₂ : Type u_3
M : Type u_4
M₁ : Type u_5
M₂ : Type u_6
M₁' : Type u_7
M₂' : Type u_8
n : Type u_9
m : Type u_10
n' : Type u_11
m' : Type u_12
ι : Type u_13
inst✝⁴ : CommSemiring R
inst✝³ : CommSemiring R₁
inst✝² : CommSemiring R₂
inst✝¹ : Fintype n
inst✝ : Fintype m
σ₁ : R₁ →+* R
σ₂ : R₂ →+* R
f : Matrix n m R
x✝² x✝¹ : n → R₁
x✝ : m → R₂
⊢ (fun v w => ∑ i : n, ∑ j : m, σ₁ (v i) * f i j * σ₂ (w j)) (x✝² + x✝¹) x✝ =
    (fun v w => ∑ i : n, ∑ j : m, σ₁ (v i) * f i j * σ₂ (w j)) x✝² x✝ +
      (fun v w => ∑ i : n, ∑ j : m, σ₁ (v i) * f i j * σ₂ (w j)) x✝¹ x✝

Next tactic:
simp only [Pi.add_apply, map_add, add_mul, sum_add_distrib]
/-- The map from `Matrix n n R` to bilinear forms on `n → R`.

This is an auxiliary definition for the equivalence `Matrix.toLinearMap₂'`. -/
def Matrix.toLinearMap₂'Aux (f : Matrix n m R) : (n → R₁) →ₛₗ[σ₁] (m → R₂) →ₛₗ[σ₂] R :=
  -- porting note: we don't seem to have `∑ i j` as valid notation yet
  mk₂'ₛₗ σ₁ σ₂ (fun (v : n → R₁) (w : m → R₂) => ∑ i, ∑ j, σ₁ (v i) * f i j * σ₂ (w j))
    (fun _ _ _ => by simp only [Pi.add_apply, map_add, add_mul, sum_add_distrib])
    (fun _ _ _ => by 

Proof state:
R : Type u_1
R₁ : Type u_2
R₂ : Type u_3
M : Type u_4
M₁ : Type u_5
M₂ : Type u_6
M₁' : Type u_7
M₂' : Type u_8
n : Type u_9
m : Type u_10
n' : Type u_11
m' : Type u_12
ι : Type u_13
inst✝⁴ : CommSemiring R
inst✝³ : CommSemiring R₁
inst✝² : CommSemiring R₂
inst✝¹ : Fintype n
inst✝ : Fintype m
σ₁ : R₁ →+* R
σ₂ : R₂ →+* R
f : Matrix n m R
x✝² : R₁
x✝¹ : n → R₁
x✝ : m → R₂
⊢ (fun v w => ∑ i : n, ∑ j : m, σ₁ (v i) * f i j * σ₂ (w j)) (x✝² • x✝¹) x✝ =
    σ₁ x✝² • (fun v w => ∑ i : n, ∑ j : m, σ₁ (v i) * f i j * σ₂ (w j)) x✝¹ x✝

Next tactic:
simp only [Pi.smul_apply, smul_eq_mul, RingHom.map_mul, mul_assoc, mul_sum]
/-- The map from `Matrix n n R` to bilinear forms on `n → R`.

This is an auxiliary definition for the equivalence `Matrix.toLinearMap₂'`. -/
def Matrix.toLinearMap₂'Aux (f : Matrix n m R) : (n → R₁) →ₛₗ[σ₁] (m → R₂) →ₛₗ[σ₂] R :=
  -- porting note: we don't seem to have `∑ i j` as valid notation yet
  mk₂'ₛₗ σ₁ σ₂ (fun (v : n → R₁) (w : m → R₂) => ∑ i, ∑ j, σ₁ (v i) * f i j * σ₂ (w j))
    (fun _ _ _ => by simp only [Pi.add_apply, map_add, add_mul, sum_add_distrib])
    (fun _ _ _ => by simp only [Pi.smul_apply, smul_eq_mul, RingHom.map_mul, mul_assoc, mul_sum])
    (fun _ _ _ => by 

Proof state:
R : Type u_1
R₁ : Type u_2
R₂ : Type u_3
M : Type u_4
M₁ : Type u_5
M₂ : Type u_6
M₁' : Type u_7
M₂' : Type u_8
n : Type u_9
m : Type u_10
n' : Type u_11
m' : Type u_12
ι : Type u_13
inst✝⁴ : CommSemiring R
inst✝³ : CommSemiring R₁
inst✝² : CommSemiring R₂
inst✝¹ : Fintype n
inst✝ : Fintype m
σ₁ : R₁ →+* R
σ₂ : R₂ →+* R
f : Matrix n m R
x✝² : n → R₁
x✝¹ x✝ : m → R₂
⊢ (fun v w => ∑ i : n, ∑ j : m, σ₁ (v i) * f i j * σ₂ (w j)) x✝² (x✝¹ + x✝) =
    (fun v w => ∑ i : n, ∑ j : m, σ₁ (v i) * f i j * σ₂ (w j)) x✝² x✝¹ +
      (fun v w => ∑ i : n, ∑ j : m, σ₁ (v i) * f i j * σ₂ (w j)) x✝² x✝

Next tactic:
simp only [Pi.add_apply, map_add, mul_add, sum_add_distrib]
/-- The map from `Matrix n n R` to bilinear forms on `n → R`.

This is an auxiliary definition for the equivalence `Matrix.toLinearMap₂'`. -/
def Matrix.toLinearMap₂'Aux (f : Matrix n m R) : (n → R₁) →ₛₗ[σ₁] (m → R₂) →ₛₗ[σ₂] R :=
  -- porting note: we don't seem to have `∑ i j` as valid notation yet
  mk₂'ₛₗ σ₁ σ₂ (fun (v : n → R₁) (w : m → R₂) => ∑ i, ∑ j, σ₁ (v i) * f i j * σ₂ (w j))
    (fun _ _ _ => by simp only [Pi.add_apply, map_add, add_mul, sum_add_distrib])
    (fun _ _ _ => by simp only [Pi.smul_apply, smul_eq_mul, RingHom.map_mul, mul_assoc, mul_sum])
    (fun _ _ _ => by simp only [Pi.add_apply, map_add, mul_add, sum_add_distrib]) fun _ _ _ => by
    

Proof state:
R : Type u_1
R₁ : Type u_2
R₂ : Type u_3
M : Type u_4
M₁ : Type u_5
M₂ : Type u_6
M₁' : Type u_7
M₂' : Type u_8
n : Type u_9
m : Type u_10
n' : Type u_11
m' : Type u_12
ι : Type u_13
inst✝⁴ : CommSemiring R
inst✝³ : CommSemiring R₁
inst✝² : CommSemiring R₂
inst✝¹ : Fintype n
inst✝ : Fintype m
σ₁ : R₁ →+* R
σ₂ : R₂ →+* R
f : Matrix n m R
x✝² : R₂
x✝¹ : n → R₁
x✝ : m → R₂
⊢ (fun v w => ∑ i : n, ∑ j : m, σ₁ (v i) * f i j * σ₂ (w j)) x✝¹ (x✝² • x✝) =
    σ₂ x✝² • (fun v w => ∑ i : n, ∑ j : m, σ₁ (v i) * f i j * σ₂ (w j)) x✝¹ x✝

Next tactic:
simp only [Pi.smul_apply, smul_eq_mul, RingHom.map_mul, mul_assoc, mul_left_comm, mul_sum]
theorem Matrix.toLinearMap₂'Aux_stdBasis (f : Matrix n m R) (i : n) (j : m) :
    f.toLinearMap₂'Aux σ₁ σ₂ (LinearMap.stdBasis R₁ (fun _ => R₁) i 1)
      (LinearMap.stdBasis R₂ (fun _ => R₂) j 1) = f i j := by
  

Proof state:
R : Type u_1
R₁ : Type u_2
R₂ : Type u_3
M : Type u_4
M₁ : Type u_5
M₂ : Type u_6
M₁' : Type u_7
M₂' : Type u_8
n : Type u_9
m : Type u_10
n' : Type u_11
m' : Type u_12
ι : Type u_13
inst✝⁶ : CommSemiring R
inst✝⁵ : CommSemiring R₁
inst✝⁴ : CommSemiring R₂
inst✝³ : Fintype n
inst✝² : Fintype m
σ₁ : R₁ →+* R
σ₂ : R₂ →+* R
inst✝¹ : DecidableEq n
inst✝ : DecidableEq m
f : Matrix n m R
i : n
j : m
⊢ ((toLinearMap₂'Aux σ₁ σ₂ f) ((LinearMap.stdBasis R₁ (fun x => R₁) i) 1)) ((LinearMap.stdBasis R₂ (fun x => R₂) j) 1) =
    f i j

Next tactic:
rw [Matrix.toLinearMap₂'Aux, mk₂'ₛₗ_apply]
theorem Matrix.toLinearMap₂'Aux_stdBasis (f : Matrix n m R) (i : n) (j : m) :
    f.toLinearMap₂'Aux σ₁ σ₂ (LinearMap.stdBasis R₁ (fun _ => R₁) i 1)
      (LinearMap.stdBasis R₂ (fun _ => R₂) j 1) = f i j := by
  rw [Matrix.toLinearMap₂'Aux, mk₂'ₛₗ_apply]
  

Proof state:
R : Type u_1
R₁ : Type u_2
R₂ : Type u_3
M : Type u_4
M₁ : Type u_5
M₂ : Type u_6
M₁' : Type u_7
M₂' : Type u_8
n : Type u_9
m : Type u_10
n' : Type u_11
m' : Type u_12
ι : Type u_13
inst✝⁶ : CommSemiring R
inst✝⁵ : CommSemiring R₁
inst✝⁴ : CommSemiring R₂
inst✝³ : Fintype n
inst✝² : Fintype m
σ₁ : R₁ →+* R
σ₂ : R₂ →+* R
inst✝¹ : DecidableEq n
inst✝ : DecidableEq m
f : Matrix n m R
i : n
j : m
⊢ ∑ i_1 : n,
      ∑ j_1 : m,
        σ₁ ((LinearMap.stdBasis R₁ (fun x => R₁) i) 1 i_1) * f i_1 j_1 *
          σ₂ ((LinearMap.stdBasis R₂ (fun x => R₂) j) 1 j_1) =
    f i j

Next tactic:
have : (∑ i', ∑ j', (if i = i' then 1 else 0) * f i' j' * if j = j' then 1 else 0) = f i j := by
    simp_rw [mul_assoc, ← Finset.mul_sum]
    simp only [boole_mul, Finset.sum_ite_eq, Finset.mem_univ, if_true, mul_comm (f _ _)]
theorem Matrix.toLinearMap₂'Aux_stdBasis (f : Matrix n m R) (i : n) (j : m) :
    f.toLinearMap₂'Aux σ₁ σ₂ (LinearMap.stdBasis R₁ (fun _ => R₁) i 1)
      (LinearMap.stdBasis R₂ (fun _ => R₂) j 1) = f i j := by
  rw [Matrix.toLinearMap₂'Aux, mk₂'ₛₗ_apply]
  have : (∑ i', ∑ j', (if i = i' then 1 else 0) * f i' j' * if j = j' then 1 else 0) = f i j := by
    

Proof state:
R : Type u_1
R₁ : Type u_2
R₂ : Type u_3
M : Type u_4
M₁ : Type u_5
M₂ : Type u_6
M₁' : Type u_7
M₂' : Type u_8
n : Type u_9
m : Type u_10
n' : Type u_11
m' : Type u_12
ι : Type u_13
inst✝⁶ : CommSemiring R
inst✝⁵ : CommSemiring R₁
inst✝⁴ : CommSemiring R₂
inst✝³ : Fintype n
inst✝² : Fintype m
σ₁ : R₁ →+* R
σ₂ : R₂ →+* R
inst✝¹ : DecidableEq n
inst✝ : DecidableEq m
f : Matrix n m R
i : n
j : m
⊢ (∑ i' : n, ∑ j' : m, (if i = i' then 1 else 0) * f i' j' * if j = j' then 1 else 0) = f i j

Next tactic:
simp_rw [mul_assoc, ← Finset.mul_sum]
theorem Matrix.toLinearMap₂'Aux_stdBasis (f : Matrix n m R) (i : n) (j : m) :
    f.toLinearMap₂'Aux σ₁ σ₂ (LinearMap.stdBasis R₁ (fun _ => R₁) i 1)
      (LinearMap.stdBasis R₂ (fun _ => R₂) j 1) = f i j := by
  rw [Matrix.toLinearMap₂'Aux, mk₂'ₛₗ_apply]
  have : (∑ i', ∑ j', (if i = i' then 1 else 0) * f i' j' * if j = j' then 1 else 0) = f i j := by
    simp_rw [mul_assoc, ← Finset.mul_sum]
    

Proof state:
R : Type u_1
R₁ : Type u_2
R₂ : Type u_3
M : Type u_4
M₁ : Type u_5
M₂ : Type u_6
M₁' : Type u_7
M₂' : Type u_8
n : Type u_9
m : Type u_10
n' : Type u_11
m' : Type u_12
ι : Type u_13
inst✝⁶ : CommSemiring R
inst✝⁵ : CommSemiring R₁
inst✝⁴ : CommSemiring R₂
inst✝³ : Fintype n
inst✝² : Fintype m
σ₁ : R₁ →+* R
σ₂ : R₂ →+* R
inst✝¹ : DecidableEq n
inst✝ : DecidableEq m
f : Matrix n m R
i : n
j : m
⊢ (∑ x : n, (if i = x then 1 else 0) * ∑ x_1 : m, f x x_1 * if j = x_1 then 1 else 0) = f i j

Next tactic:
simp only [boole_mul, Finset.sum_ite_eq, Finset.mem_univ, if_true, mul_comm (f _ _)]
theorem Matrix.toLinearMap₂'Aux_stdBasis (f : Matrix n m R) (i : n) (j : m) :
    f.toLinearMap₂'Aux σ₁ σ₂ (LinearMap.stdBasis R₁ (fun _ => R₁) i 1)
      (LinearMap.stdBasis R₂ (fun _ => R₂) j 1) = f i j := by
  rw [Matrix.toLinearMap₂'Aux, mk₂'ₛₗ_apply]
  have : (∑ i', ∑ j', (if i = i' then 1 else 0) * f i' j' * if j = j' then 1 else 0) = f i j := by
    simp_rw [mul_assoc, ← Finset.mul_sum]
    simp only [boole_mul, Finset.sum_ite_eq, Finset.mem_univ, if_true, mul_comm (f _ _)]
  

Proof state:
R : Type u_1
R₁ : Type u_2
R₂ : Type u_3
M : Type u_4
M₁ : Type u_5
M₂ : Type u_6
M₁' : Type u_7
M₂' : Type u_8
n : Type u_9
m : Type u_10
n' : Type u_11
m' : Type u_12
ι : Type u_13
inst✝⁶ : CommSemiring R
inst✝⁵ : CommSemiring R₁
inst✝⁴ : CommSemiring R₂
inst✝³ : Fintype n
inst✝² : Fintype m
σ₁ : R₁ →+* R
σ₂ : R₂ →+* R
inst✝¹ : DecidableEq n
inst✝ : DecidableEq m
f : Matrix n m R
i : n
j : m
this : (∑ i' : n, ∑ j' : m, (if i = i' then 1 else 0) * f i' j' * if j = j' then 1 else 0) = f i j
⊢ ∑ i_1 : n,
      ∑ j_1 : m,
        σ₁ ((LinearMap.stdBasis R₁ (fun x => R₁) i) 1 i_1) * f i_1 j_1 *
          σ₂ ((LinearMap.stdBasis R₂ (fun x => R₂) j) 1 j_1) =
    f i j

Next tactic:
rw [← this]
theorem Matrix.toLinearMap₂'Aux_stdBasis (f : Matrix n m R) (i : n) (j : m) :
    f.toLinearMap₂'Aux σ₁ σ₂ (LinearMap.stdBasis R₁ (fun _ => R₁) i 1)
      (LinearMap.stdBasis R₂ (fun _ => R₂) j 1) = f i j := by
  rw [Matrix.toLinearMap₂'Aux, mk₂'ₛₗ_apply]
  have : (∑ i', ∑ j', (if i = i' then 1 else 0) * f i' j' * if j = j' then 1 else 0) = f i j := by
    simp_rw [mul_assoc, ← Finset.mul_sum]
    simp only [boole_mul, Finset.sum_ite_eq, Finset.mem_univ, if_true, mul_comm (f _ _)]
  rw [← this]
  

Proof state:
R : Type u_1
R₁ : Type u_2
R₂ : Type u_3
M : Type u_4
M₁ : Type u_5
M₂ : Type u_6
M₁' : Type u_7
M₂' : Type u_8
n : Type u_9
m : Type u_10
n' : Type u_11
m' : Type u_12
ι : Type u_13
inst✝⁶ : CommSemiring R
inst✝⁵ : CommSemiring R₁
inst✝⁴ : CommSemiring R₂
inst✝³ : Fintype n
inst✝² : Fintype m
σ₁ : R₁ →+* R
σ₂ : R₂ →+* R
inst✝¹ : DecidableEq n
inst✝ : DecidableEq m
f : Matrix n m R
i : n
j : m
this : (∑ i' : n, ∑ j' : m, (if i = i' then 1 else 0) * f i' j' * if j = j' then 1 else 0) = f i j
⊢ ∑ i_1 : n,
      ∑ j_1 : m,
        σ₁ ((LinearMap.stdBasis R₁ (fun x => R₁) i) 1 i_1) * f i_1 j_1 *
          σ₂ ((LinearMap.stdBasis R₂ (fun x => R₂) j) 1 j_1) =
    ∑ i' : n, ∑ j' : m, (if i = i' then 1 else 0) * f i' j' * if j = j' then 1 else 0

Next tactic:
exact Finset.sum_congr rfl fun _ _ => Finset.sum_congr rfl fun _ _ => by simp