l3lab/ntp-mathlib huggingface dataset:
/-- A direct sum of flat `R`-modules is flat. -/
instance directSum (ι : Type v) (M : ι → Type w) [(i : ι) → AddCommGroup (M i)]
    [(i : ι) → Module R (M i)] [F : (i : ι) → (Flat R (M i))] : Flat R (⨁ i, M i) := by
  classical
  rw [iff_rTensor_injective]
  intro I hI
  rw [← Equiv.comp_injective _ (TensorProduct.lid R (⨁ i, M i)).toEquiv]
  

Proof state:
R : Type u
inst✝² : CommRing R
ι : Type v
M : ι → Type w
inst✝¹ : (i : ι) → AddCommGroup (M i)
inst✝ : (i : ι) → Module R (M i)
F : ∀ (i : ι), Flat R (M i)
I : Ideal R
hI : Ideal.FG I
⊢ Injective
    (⇑(LinearEquiv.toEquiv (TensorProduct.lid R (⨁ (i : ι), M i))) ∘ ⇑(rTensor (⨁ (i : ι), M i) (Submodule.subtype I)))

Next tactic:
set η₁ := TensorProduct.lid R (⨁ i, M i)
/-- A direct sum of flat `R`-modules is flat. -/
instance directSum (ι : Type v) (M : ι → Type w) [(i : ι) → AddCommGroup (M i)]
    [(i : ι) → Module R (M i)] [F : (i : ι) → (Flat R (M i))] : Flat R (⨁ i, M i) := by
  classical
  rw [iff_rTensor_injective]
  intro I hI
  rw [← Equiv.comp_injective _ (TensorProduct.lid R (⨁ i, M i)).toEquiv]
  set η₁ := TensorProduct.lid R (⨁ i, M i)
  

Proof state:
R : Type u
inst✝² : CommRing R
ι : Type v
M : ι → Type w
inst✝¹ : (i : ι) → AddCommGroup (M i)
inst✝ : (i : ι) → Module R (M i)
F : ∀ (i : ι), Flat R (M i)
I : Ideal R
hI : Ideal.FG I
η₁ : (R ⊗[R] ⨁ (i : ι), M i) ≃ₗ[R] ⨁ (i : ι), M i := TensorProduct.lid R (⨁ (i : ι), M i)
⊢ Injective (⇑(LinearEquiv.toEquiv η₁) ∘ ⇑(rTensor (⨁ (i : ι), M i) (Submodule.subtype I)))

Next tactic:
set η := (fun i ↦ TensorProduct.lid R (M i))
/-- A direct sum of flat `R`-modules is flat. -/
instance directSum (ι : Type v) (M : ι → Type w) [(i : ι) → AddCommGroup (M i)]
    [(i : ι) → Module R (M i)] [F : (i : ι) → (Flat R (M i))] : Flat R (⨁ i, M i) := by
  classical
  rw [iff_rTensor_injective]
  intro I hI
  rw [← Equiv.comp_injective _ (TensorProduct.lid R (⨁ i, M i)).toEquiv]
  set η₁ := TensorProduct.lid R (⨁ i, M i)
  set η := (fun i ↦ TensorProduct.lid R (M i))
  

Proof state:
R : Type u
inst✝² : CommRing R
ι : Type v
M : ι → Type w
inst✝¹ : (i : ι) → AddCommGroup (M i)
inst✝ : (i : ι) → Module R (M i)
F : ∀ (i : ι), Flat R (M i)
I : Ideal R
hI : Ideal.FG I
η₁ : (R ⊗[R] ⨁ (i : ι), M i) ≃ₗ[R] ⨁ (i : ι), M i := TensorProduct.lid R (⨁ (i : ι), M i)
η : (i : ι) → R ⊗[R] M i ≃ₗ[R] M i := fun i => TensorProduct.lid R (M i)
⊢ Injective (⇑(LinearEquiv.toEquiv η₁) ∘ ⇑(rTensor (⨁ (i : ι), M i) (Submodule.subtype I)))

Next tactic:
set φ := (fun i ↦ rTensor (M i) I.subtype)
/-- A direct sum of flat `R`-modules is flat. -/
instance directSum (ι : Type v) (M : ι → Type w) [(i : ι) → AddCommGroup (M i)]
    [(i : ι) → Module R (M i)] [F : (i : ι) → (Flat R (M i))] : Flat R (⨁ i, M i) := by
  classical
  rw [iff_rTensor_injective]
  intro I hI
  rw [← Equiv.comp_injective _ (TensorProduct.lid R (⨁ i, M i)).toEquiv]
  set η₁ := TensorProduct.lid R (⨁ i, M i)
  set η := (fun i ↦ TensorProduct.lid R (M i))
  set φ := (fun i ↦ rTensor (M i) I.subtype)
  

Proof state:
R : Type u
inst✝² : CommRing R
ι : Type v
M : ι → Type w
inst✝¹ : (i : ι) → AddCommGroup (M i)
inst✝ : (i : ι) → Module R (M i)
F : ∀ (i : ι), Flat R (M i)
I : Ideal R
hI : Ideal.FG I
η₁ : (R ⊗[R] ⨁ (i : ι), M i) ≃ₗ[R] ⨁ (i : ι), M i := TensorProduct.lid R (⨁ (i : ι), M i)
η : (i : ι) → R ⊗[R] M i ≃ₗ[R] M i := fun i => TensorProduct.lid R (M i)
φ : (i : ι) → ↥I ⊗[R] M i →ₗ[R] R ⊗[R] M i := fun i => rTensor (M i) (Submodule.subtype I)
⊢ Injective (⇑(LinearEquiv.toEquiv η₁) ∘ ⇑(rTensor (⨁ (i : ι), M i) (Submodule.subtype I)))

Next tactic:
set π := (fun i ↦ component R ι (fun j ↦ M j) i)
/-- A direct sum of flat `R`-modules is flat. -/
instance directSum (ι : Type v) (M : ι → Type w) [(i : ι) → AddCommGroup (M i)]
    [(i : ι) → Module R (M i)] [F : (i : ι) → (Flat R (M i))] : Flat R (⨁ i, M i) := by
  classical
  rw [iff_rTensor_injective]
  intro I hI
  rw [← Equiv.comp_injective _ (TensorProduct.lid R (⨁ i, M i)).toEquiv]
  set η₁ := TensorProduct.lid R (⨁ i, M i)
  set η := (fun i ↦ TensorProduct.lid R (M i))
  set φ := (fun i ↦ rTensor (M i) I.subtype)
  set π := (fun i ↦ component R ι (fun j ↦ M j) i)
  

Proof state:
R : Type u
inst✝² : CommRing R
ι : Type v
M : ι → Type w
inst✝¹ : (i : ι) → AddCommGroup (M i)
inst✝ : (i : ι) → Module R (M i)
F : ∀ (i : ι), Flat R (M i)
I : Ideal R
hI : Ideal.FG I
η₁ : (R ⊗[R] ⨁ (i : ι), M i) ≃ₗ[R] ⨁ (i : ι), M i := TensorProduct.lid R (⨁ (i : ι), M i)
η : (i : ι) → R ⊗[R] M i ≃ₗ[R] M i := fun i => TensorProduct.lid R (M i)
φ : (i : ι) → ↥I ⊗[R] M i →ₗ[R] R ⊗[R] M i := fun i => rTensor (M i) (Submodule.subtype I)
π : (i : ι) → (⨁ (i : ι), M i) →ₗ[R] M i := fun i => component R ι (fun j => M j) i
⊢ Injective (⇑(LinearEquiv.toEquiv η₁) ∘ ⇑(rTensor (⨁ (i : ι), M i) (Submodule.subtype I)))

Next tactic:
set ψ := (TensorProduct.directSumRight R {x // x ∈ I} (fun i ↦ M i)).symm.toLinearMap with psi_def
/-- A direct sum of flat `R`-modules is flat. -/
instance directSum (ι : Type v) (M : ι → Type w) [(i : ι) → AddCommGroup (M i)]
    [(i : ι) → Module R (M i)] [F : (i : ι) → (Flat R (M i))] : Flat R (⨁ i, M i) := by
  classical
  rw [iff_rTensor_injective]
  intro I hI
  rw [← Equiv.comp_injective _ (TensorProduct.lid R (⨁ i, M i)).toEquiv]
  set η₁ := TensorProduct.lid R (⨁ i, M i)
  set η := (fun i ↦ TensorProduct.lid R (M i))
  set φ := (fun i ↦ rTensor (M i) I.subtype)
  set π := (fun i ↦ component R ι (fun j ↦ M j) i)
  set ψ := (TensorProduct.directSumRight R {x // x ∈ I} (fun i ↦ M i)).symm.toLinearMap with psi_def
  

Proof state:
R : Type u
inst✝² : CommRing R
ι : Type v
M : ι → Type w
inst✝¹ : (i : ι) → AddCommGroup (M i)
inst✝ : (i : ι) → Module R (M i)
F : ∀ (i : ι), Flat R (M i)
I : Ideal R
hI : Ideal.FG I
η₁ : (R ⊗[R] ⨁ (i : ι), M i) ≃ₗ[R] ⨁ (i : ι), M i := TensorProduct.lid R (⨁ (i : ι), M i)
η : (i : ι) → R ⊗[R] M i ≃ₗ[R] M i := fun i => TensorProduct.lid R (M i)
φ : (i : ι) → ↥I ⊗[R] M i →ₗ[R] R ⊗[R] M i := fun i => rTensor (M i) (Submodule.subtype I)
π : (i : ι) → (⨁ (i : ι), M i) →ₗ[R] M i := fun i => component R ι (fun j => M j) i
ψ : (⨁ (i : ι), ↥I ⊗[R] M i) →ₗ[R] ↥I ⊗[R] ⨁ (i : ι), M i := ↑(LinearEquiv.symm (directSumRight R ↥I fun i => M i))
psi_def : ψ = ↑(LinearEquiv.symm (directSumRight R ↥I fun i => M i))
⊢ Injective (⇑(LinearEquiv.toEquiv η₁) ∘ ⇑(rTensor (⨁ (i : ι), M i) (Submodule.subtype I)))

Next tactic:
set ρ := rTensor (⨁ i, M i) I.subtype
/-- A direct sum of flat `R`-modules is flat. -/
instance directSum (ι : Type v) (M : ι → Type w) [(i : ι) → AddCommGroup (M i)]
    [(i : ι) → Module R (M i)] [F : (i : ι) → (Flat R (M i))] : Flat R (⨁ i, M i) := by
  classical
  rw [iff_rTensor_injective]
  intro I hI
  rw [← Equiv.comp_injective _ (TensorProduct.lid R (⨁ i, M i)).toEquiv]
  set η₁ := TensorProduct.lid R (⨁ i, M i)
  set η := (fun i ↦ TensorProduct.lid R (M i))
  set φ := (fun i ↦ rTensor (M i) I.subtype)
  set π := (fun i ↦ component R ι (fun j ↦ M j) i)
  set ψ := (TensorProduct.directSumRight R {x // x ∈ I} (fun i ↦ M i)).symm.toLinearMap with psi_def
  set ρ := rTensor (⨁ i, M i) I.subtype
  

Proof state:
R : Type u
inst✝² : CommRing R
ι : Type v
M : ι → Type w
inst✝¹ : (i : ι) → AddCommGroup (M i)
inst✝ : (i : ι) → Module R (M i)
F : ∀ (i : ι), Flat R (M i)
I : Ideal R
hI : Ideal.FG I
η₁ : (R ⊗[R] ⨁ (i : ι), M i) ≃ₗ[R] ⨁ (i : ι), M i := TensorProduct.lid R (⨁ (i : ι), M i)
η : (i : ι) → R ⊗[R] M i ≃ₗ[R] M i := fun i => TensorProduct.lid R (M i)
φ : (i : ι) → ↥I ⊗[R] M i →ₗ[R] R ⊗[R] M i := fun i => rTensor (M i) (Submodule.subtype I)
π : (i : ι) → (⨁ (i : ι), M i) →ₗ[R] M i := fun i => component R ι (fun j => M j) i
ψ : (⨁ (i : ι), ↥I ⊗[R] M i) →ₗ[R] ↥I ⊗[R] ⨁ (i : ι), M i := ↑(LinearEquiv.symm (directSumRight R ↥I fun i => M i))
psi_def : ψ = ↑(LinearEquiv.symm (directSumRight R ↥I fun i => M i))
ρ : (↥I ⊗[R] ⨁ (i : ι), M i) →ₗ[R] R ⊗[R] ⨁ (i : ι), M i := rTensor (⨁ (i : ι), M i) (Submodule.subtype I)
⊢ Injective (⇑(LinearEquiv.toEquiv η₁) ∘ ⇑ρ)

Next tactic:
set τ := (fun i ↦ component R ι (fun j ↦ ({x // x ∈ I} ⊗[R] (M j))) i)
/-- A direct sum of flat `R`-modules is flat. -/
instance directSum (ι : Type v) (M : ι → Type w) [(i : ι) → AddCommGroup (M i)]
    [(i : ι) → Module R (M i)] [F : (i : ι) → (Flat R (M i))] : Flat R (⨁ i, M i) := by
  classical
  rw [iff_rTensor_injective]
  intro I hI
  rw [← Equiv.comp_injective _ (TensorProduct.lid R (⨁ i, M i)).toEquiv]
  set η₁ := TensorProduct.lid R (⨁ i, M i)
  set η := (fun i ↦ TensorProduct.lid R (M i))
  set φ := (fun i ↦ rTensor (M i) I.subtype)
  set π := (fun i ↦ component R ι (fun j ↦ M j) i)
  set ψ := (TensorProduct.directSumRight R {x // x ∈ I} (fun i ↦ M i)).symm.toLinearMap with psi_def
  set ρ := rTensor (⨁ i, M i) I.subtype
  set τ := (fun i ↦ component R ι (fun j ↦ ({x // x ∈ I} ⊗[R] (M j))) i)
  

Proof state:
R : Type u
inst✝² : CommRing R
ι : Type v
M : ι → Type w
inst✝¹ : (i : ι) → AddCommGroup (M i)
inst✝ : (i : ι) → Module R (M i)
F : ∀ (i : ι), Flat R (M i)
I : Ideal R
hI : Ideal.FG I
η₁ : (R ⊗[R] ⨁ (i : ι), M i) ≃ₗ[R] ⨁ (i : ι), M i := TensorProduct.lid R (⨁ (i : ι), M i)
η : (i : ι) → R ⊗[R] M i ≃ₗ[R] M i := fun i => TensorProduct.lid R (M i)
φ : (i : ι) → ↥I ⊗[R] M i →ₗ[R] R ⊗[R] M i := fun i => rTensor (M i) (Submodule.subtype I)
π : (i : ι) → (⨁ (i : ι), M i) →ₗ[R] M i := fun i => component R ι (fun j => M j) i
ψ : (⨁ (i : ι), ↥I ⊗[R] M i) →ₗ[R] ↥I ⊗[R] ⨁ (i : ι), M i := ↑(LinearEquiv.symm (directSumRight R ↥I fun i => M i))
psi_def : ψ = ↑(LinearEquiv.symm (directSumRight R ↥I fun i => M i))
ρ : (↥I ⊗[R] ⨁ (i : ι), M i) →ₗ[R] R ⊗[R] ⨁ (i : ι), M i := rTensor (⨁ (i : ι), M i) (Submodule.subtype I)
τ : (i : ι) → (⨁ (i : ι), ↥I ⊗[R] M i) →ₗ[R] ↥I ⊗[R] M i := fun i => component R ι (fun j => ↥I ⊗[R] M j) i
⊢ Injective (⇑(LinearEquiv.toEquiv η₁) ∘ ⇑ρ)

Next tactic:
rw [← Equiv.injective_comp (TensorProduct.directSumRight _ _ _).symm.toEquiv]
/-- A direct sum of flat `R`-modules is flat. -/
instance directSum (ι : Type v) (M : ι → Type w) [(i : ι) → AddCommGroup (M i)]
    [(i : ι) → Module R (M i)] [F : (i : ι) → (Flat R (M i))] : Flat R (⨁ i, M i) := by
  classical
  rw [iff_rTensor_injective]
  intro I hI
  rw [← Equiv.comp_injective _ (TensorProduct.lid R (⨁ i, M i)).toEquiv]
  set η₁ := TensorProduct.lid R (⨁ i, M i)
  set η := (fun i ↦ TensorProduct.lid R (M i))
  set φ := (fun i ↦ rTensor (M i) I.subtype)
  set π := (fun i ↦ component R ι (fun j ↦ M j) i)
  set ψ := (TensorProduct.directSumRight R {x // x ∈ I} (fun i ↦ M i)).symm.toLinearMap with psi_def
  set ρ := rTensor (⨁ i, M i) I.subtype
  set τ := (fun i ↦ component R ι (fun j ↦ ({x // x ∈ I} ⊗[R] (M j))) i)
  rw [← Equiv.injective_comp (TensorProduct.directSumRight _ _ _).symm.toEquiv]
  

Proof state:
R : Type u
inst✝² : CommRing R
ι : Type v
M : ι → Type w
inst✝¹ : (i : ι) → AddCommGroup (M i)
inst✝ : (i : ι) → Module R (M i)
F : ∀ (i : ι), Flat R (M i)
I : Ideal R
hI : Ideal.FG I
η₁ : (R ⊗[R] ⨁ (i : ι), M i) ≃ₗ[R] ⨁ (i : ι), M i := TensorProduct.lid R (⨁ (i : ι), M i)
η : (i : ι) → R ⊗[R] M i ≃ₗ[R] M i := fun i => TensorProduct.lid R (M i)
φ : (i : ι) → ↥I ⊗[R] M i →ₗ[R] R ⊗[R] M i := fun i => rTensor (M i) (Submodule.subtype I)
π : (i : ι) → (⨁ (i : ι), M i) →ₗ[R] M i := fun i => component R ι (fun j => M j) i
ψ : (⨁ (i : ι), ↥I ⊗[R] M i) →ₗ[R] ↥I ⊗[R] ⨁ (i : ι), M i := ↑(LinearEquiv.symm (directSumRight R ↥I fun i => M i))
psi_def : ψ = ↑(LinearEquiv.symm (directSumRight R ↥I fun i => M i))
ρ : (↥I ⊗[R] ⨁ (i : ι), M i) →ₗ[R] R ⊗[R] ⨁ (i : ι), M i := rTensor (⨁ (i : ι), M i) (Submodule.subtype I)
τ : (i : ι) → (⨁ (i : ι), ↥I ⊗[R] M i) →ₗ[R] ↥I ⊗[R] M i := fun i => component R ι (fun j => ↥I ⊗[R] M j) i
⊢ Injective
    ((⇑(LinearEquiv.toEquiv η₁) ∘ ⇑ρ) ∘ ⇑(LinearEquiv.toEquiv (LinearEquiv.symm (directSumRight R ↥I fun i => M i))))

Next tactic:
rw [LinearEquiv.coe_toEquiv, ← LinearEquiv.coe_coe, ← LinearMap.coe_comp]
/-- A direct sum of flat `R`-modules is flat. -/
instance directSum (ι : Type v) (M : ι → Type w) [(i : ι) → AddCommGroup (M i)]
    [(i : ι) → Module R (M i)] [F : (i : ι) → (Flat R (M i))] : Flat R (⨁ i, M i) := by
  classical
  rw [iff_rTensor_injective]
  intro I hI
  rw [← Equiv.comp_injective _ (TensorProduct.lid R (⨁ i, M i)).toEquiv]
  set η₁ := TensorProduct.lid R (⨁ i, M i)
  set η := (fun i ↦ TensorProduct.lid R (M i))
  set φ := (fun i ↦ rTensor (M i) I.subtype)
  set π := (fun i ↦ component R ι (fun j ↦ M j) i)
  set ψ := (TensorProduct.directSumRight R {x // x ∈ I} (fun i ↦ M i)).symm.toLinearMap with psi_def
  set ρ := rTensor (⨁ i, M i) I.subtype
  set τ := (fun i ↦ component R ι (fun j ↦ ({x // x ∈ I} ⊗[R] (M j))) i)
  rw [← Equiv.injective_comp (TensorProduct.directSumRight _ _ _).symm.toEquiv]
  rw [LinearEquiv.coe_toEquiv, ← LinearEquiv.coe_coe, ← LinearMap.coe_comp]
  

Proof state:
R : Type u
inst✝² : CommRing R
ι : Type v
M : ι → Type w
inst✝¹ : (i : ι) → AddCommGroup (M i)
inst✝ : (i : ι) → Module R (M i)
F : ∀ (i : ι), Flat R (M i)
I : Ideal R
hI : Ideal.FG I
η₁ : (R ⊗[R] ⨁ (i : ι), M i) ≃ₗ[R] ⨁ (i : ι), M i := TensorProduct.lid R (⨁ (i : ι), M i)
η : (i : ι) → R ⊗[R] M i ≃ₗ[R] M i := fun i => TensorProduct.lid R (M i)
φ : (i : ι) → ↥I ⊗[R] M i →ₗ[R] R ⊗[R] M i := fun i => rTensor (M i) (Submodule.subtype I)
π : (i : ι) → (⨁ (i : ι), M i) →ₗ[R] M i := fun i => component R ι (fun j => M j) i
ψ : (⨁ (i : ι), ↥I ⊗[R] M i) →ₗ[R] ↥I ⊗[R] ⨁ (i : ι), M i := ↑(LinearEquiv.symm (directSumRight R ↥I fun i => M i))
psi_def : ψ = ↑(LinearEquiv.symm (directSumRight R ↥I fun i => M i))
ρ : (↥I ⊗[R] ⨁ (i : ι), M i) →ₗ[R] R ⊗[R] ⨁ (i : ι), M i := rTensor (⨁ (i : ι), M i) (Submodule.subtype I)
τ : (i : ι) → (⨁ (i : ι), ↥I ⊗[R] M i) →ₗ[R] ↥I ⊗[R] M i := fun i => component R ι (fun j => ↥I ⊗[R] M j) i
⊢ Injective (⇑(↑η₁ ∘ₗ ρ) ∘ ⇑(LinearEquiv.toEquiv (LinearEquiv.symm (directSumRight R ↥I fun i => M i))))

Next tactic:
rw [LinearEquiv.coe_toEquiv, ← LinearEquiv.coe_coe, ← LinearMap.coe_comp]
/-- A direct sum of flat `R`-modules is flat. -/
instance directSum (ι : Type v) (M : ι → Type w) [(i : ι) → AddCommGroup (M i)]
    [(i : ι) → Module R (M i)] [F : (i : ι) → (Flat R (M i))] : Flat R (⨁ i, M i) := by
  classical
  rw [iff_rTensor_injective]
  intro I hI
  rw [← Equiv.comp_injective _ (TensorProduct.lid R (⨁ i, M i)).toEquiv]
  set η₁ := TensorProduct.lid R (⨁ i, M i)
  set η := (fun i ↦ TensorProduct.lid R (M i))
  set φ := (fun i ↦ rTensor (M i) I.subtype)
  set π := (fun i ↦ component R ι (fun j ↦ M j) i)
  set ψ := (TensorProduct.directSumRight R {x // x ∈ I} (fun i ↦ M i)).symm.toLinearMap with psi_def
  set ρ := rTensor (⨁ i, M i) I.subtype
  set τ := (fun i ↦ component R ι (fun j ↦ ({x // x ∈ I} ⊗[R] (M j))) i)
  rw [← Equiv.injective_comp (TensorProduct.directSumRight _ _ _).symm.toEquiv]
  rw [LinearEquiv.coe_toEquiv, ← LinearEquiv.coe_coe, ← LinearMap.coe_comp]
  rw [LinearEquiv.coe_toEquiv, ← LinearEquiv.coe_coe, ← LinearMap.coe_comp]
  

Proof state:
R : Type u
inst✝² : CommRing R
ι : Type v
M : ι → Type w
inst✝¹ : (i : ι) → AddCommGroup (M i)
inst✝ : (i : ι) → Module R (M i)
F : ∀ (i : ι), Flat R (M i)
I : Ideal R
hI : Ideal.FG I
η₁ : (R ⊗[R] ⨁ (i : ι), M i) ≃ₗ[R] ⨁ (i : ι), M i := TensorProduct.lid R (⨁ (i : ι), M i)
η : (i : ι) → R ⊗[R] M i ≃ₗ[R] M i := fun i => TensorProduct.lid R (M i)
φ : (i : ι) → ↥I ⊗[R] M i →ₗ[R] R ⊗[R] M i := fun i => rTensor (M i) (Submodule.subtype I)
π : (i : ι) → (⨁ (i : ι), M i) →ₗ[R] M i := fun i => component R ι (fun j => M j) i
ψ : (⨁ (i : ι), ↥I ⊗[R] M i) →ₗ[R] ↥I ⊗[R] ⨁ (i : ι), M i := ↑(LinearEquiv.symm (directSumRight R ↥I fun i => M i))
psi_def : ψ = ↑(LinearEquiv.symm (directSumRight R ↥I fun i => M i))
ρ : (↥I ⊗[R] ⨁ (i : ι), M i) →ₗ[R] R ⊗[R] ⨁ (i : ι), M i := rTensor (⨁ (i : ι), M i) (Submodule.subtype I)
τ : (i : ι) → (⨁ (i : ι), ↥I ⊗[R] M i) →ₗ[R] ↥I ⊗[R] M i := fun i => component R ι (fun j => ↥I ⊗[R] M j) i
⊢ Injective ⇑((↑η₁ ∘ₗ ρ) ∘ₗ ↑(LinearEquiv.symm (directSumRight R ↥I fun i => M i)))

Next tactic:
rw [← psi_def, injective_iff_map_eq_zero ((η₁.comp ρ).comp ψ)]
/-- A direct sum of flat `R`-modules is flat. -/
instance directSum (ι : Type v) (M : ι → Type w) [(i : ι) → AddCommGroup (M i)]
    [(i : ι) → Module R (M i)] [F : (i : ι) → (Flat R (M i))] : Flat R (⨁ i, M i) := by
  classical
  rw [iff_rTensor_injective]
  intro I hI
  rw [← Equiv.comp_injective _ (TensorProduct.lid R (⨁ i, M i)).toEquiv]
  set η₁ := TensorProduct.lid R (⨁ i, M i)
  set η := (fun i ↦ TensorProduct.lid R (M i))
  set φ := (fun i ↦ rTensor (M i) I.subtype)
  set π := (fun i ↦ component R ι (fun j ↦ M j) i)
  set ψ := (TensorProduct.directSumRight R {x // x ∈ I} (fun i ↦ M i)).symm.toLinearMap with psi_def
  set ρ := rTensor (⨁ i, M i) I.subtype
  set τ := (fun i ↦ component R ι (fun j ↦ ({x // x ∈ I} ⊗[R] (M j))) i)
  rw [← Equiv.injective_comp (TensorProduct.directSumRight _ _ _).symm.toEquiv]
  rw [LinearEquiv.coe_toEquiv, ← LinearEquiv.coe_coe, ← LinearMap.coe_comp]
  rw [LinearEquiv.coe_toEquiv, ← LinearEquiv.coe_coe, ← LinearMap.coe_comp]
  rw [← psi_def, injective_iff_map_eq_zero ((η₁.comp ρ).comp ψ)]
  

Proof state:
R : Type u
inst✝² : CommRing R
ι : Type v
M : ι → Type w
inst✝¹ : (i : ι) → AddCommGroup (M i)
inst✝ : (i : ι) → Module R (M i)
F : ∀ (i : ι), Flat R (M i)
I : Ideal R
hI : Ideal.FG I
η₁ : (R ⊗[R] ⨁ (i : ι), M i) ≃ₗ[R] ⨁ (i : ι), M i := TensorProduct.lid R (⨁ (i : ι), M i)
η : (i : ι) → R ⊗[R] M i ≃ₗ[R] M i := fun i => TensorProduct.lid R (M i)
φ : (i : ι) → ↥I ⊗[R] M i →ₗ[R] R ⊗[R] M i := fun i => rTensor (M i) (Submodule.subtype I)
π : (i : ι) → (⨁ (i : ι), M i) →ₗ[R] M i := fun i => component R ι (fun j => M j) i
ψ : (⨁ (i : ι), ↥I ⊗[R] M i) →ₗ[R] ↥I ⊗[R] ⨁ (i : ι), M i := ↑(LinearEquiv.symm (directSumRight R ↥I fun i => M i))
psi_def : ψ = ↑(LinearEquiv.symm (directSumRight R ↥I fun i => M i))
ρ : (↥I ⊗[R] ⨁ (i : ι), M i) →ₗ[R] R ⊗[R] ⨁ (i : ι), M i := rTensor (⨁ (i : ι), M i) (Submodule.subtype I)
τ : (i : ι) → (⨁ (i : ι), ↥I ⊗[R] M i) →ₗ[R] ↥I ⊗[R] M i := fun i => component R ι (fun j => ↥I ⊗[R] M j) i
⊢ ∀ (a : ⨁ (i : ι), ↥I ⊗[R] M i), ((↑η₁ ∘ₗ ρ) ∘ₗ ψ) a = 0 → a = 0

Next tactic:
have h₁ : ∀ (i : ι), (π i).comp ((η₁.comp ρ).comp ψ) = (η i).comp ((φ i).comp (τ i))
/-- A direct sum of flat `R`-modules is flat. -/
instance directSum (ι : Type v) (M : ι → Type w) [(i : ι) → AddCommGroup (M i)]
    [(i : ι) → Module R (M i)] [F : (i : ι) → (Flat R (M i))] : Flat R (⨁ i, M i) := by
  classical
  rw [iff_rTensor_injective]
  intro I hI
  rw [← Equiv.comp_injective _ (TensorProduct.lid R (⨁ i, M i)).toEquiv]
  set η₁ := TensorProduct.lid R (⨁ i, M i)
  set η := (fun i ↦ TensorProduct.lid R (M i))
  set φ := (fun i ↦ rTensor (M i) I.subtype)
  set π := (fun i ↦ component R ι (fun j ↦ M j) i)
  set ψ := (TensorProduct.directSumRight R {x // x ∈ I} (fun i ↦ M i)).symm.toLinearMap with psi_def
  set ρ := rTensor (⨁ i, M i) I.subtype
  set τ := (fun i ↦ component R ι (fun j ↦ ({x // x ∈ I} ⊗[R] (M j))) i)
  rw [← Equiv.injective_comp (TensorProduct.directSumRight _ _ _).symm.toEquiv]
  rw [LinearEquiv.coe_toEquiv, ← LinearEquiv.coe_coe, ← LinearMap.coe_comp]
  rw [LinearEquiv.coe_toEquiv, ← LinearEquiv.coe_coe, ← LinearMap.coe_comp]
  rw [← psi_def, injective_iff_map_eq_zero ((η₁.comp ρ).comp ψ)]
  have h₁ : ∀ (i : ι), (π i).comp ((η₁.comp ρ).comp ψ) = (η i).comp ((φ i).comp (τ i))
  · 

Proof state:
case h₁
R : Type u
inst✝² : CommRing R
ι : Type v
M : ι → Type w
inst✝¹ : (i : ι) → AddCommGroup (M i)
inst✝ : (i : ι) → Module R (M i)
F : ∀ (i : ι), Flat R (M i)
I : Ideal R
hI : Ideal.FG I
η₁ : (R ⊗[R] ⨁ (i : ι), M i) ≃ₗ[R] ⨁ (i : ι), M i := TensorProduct.lid R (⨁ (i : ι), M i)
η : (i : ι) → R ⊗[R] M i ≃ₗ[R] M i := fun i => TensorProduct.lid R (M i)
φ : (i : ι) → ↥I ⊗[R] M i →ₗ[R] R ⊗[R] M i := fun i => rTensor (M i) (Submodule.subtype I)
π : (i : ι) → (⨁ (i : ι), M i) →ₗ[R] M i := fun i => component R ι (fun j => M j) i
ψ : (⨁ (i : ι), ↥I ⊗[R] M i) →ₗ[R] ↥I ⊗[R] ⨁ (i : ι), M i := ↑(LinearEquiv.symm (directSumRight R ↥I fun i => M i))
psi_def : ψ = ↑(LinearEquiv.symm (directSumRight R ↥I fun i => M i))
ρ : (↥I ⊗[R] ⨁ (i : ι), M i) →ₗ[R] R ⊗[R] ⨁ (i : ι), M i := rTensor (⨁ (i : ι), M i) (Submodule.subtype I)
τ : (i : ι) → (⨁ (i : ι), ↥I ⊗[R] M i) →ₗ[R] ↥I ⊗[R] M i := fun i => component R ι (fun j => ↥I ⊗[R] M j) i
⊢ ∀ (i : ι), π i ∘ₗ (↑η₁ ∘ₗ ρ) ∘ₗ ψ = ↑(η i) ∘ₗ φ i ∘ₗ τ i

Next tactic:
intro i
/-- A direct sum of flat `R`-modules is flat. -/
instance directSum (ι : Type v) (M : ι → Type w) [(i : ι) → AddCommGroup (M i)]
    [(i : ι) → Module R (M i)] [F : (i : ι) → (Flat R (M i))] : Flat R (⨁ i, M i) := by
  classical
  rw [iff_rTensor_injective]
  intro I hI
  rw [← Equiv.comp_injective _ (TensorProduct.lid R (⨁ i, M i)).toEquiv]
  set η₁ := TensorProduct.lid R (⨁ i, M i)
  set η := (fun i ↦ TensorProduct.lid R (M i))
  set φ := (fun i ↦ rTensor (M i) I.subtype)
  set π := (fun i ↦ component R ι (fun j ↦ M j) i)
  set ψ := (TensorProduct.directSumRight R {x // x ∈ I} (fun i ↦ M i)).symm.toLinearMap with psi_def
  set ρ := rTensor (⨁ i, M i) I.subtype
  set τ := (fun i ↦ component R ι (fun j ↦ ({x // x ∈ I} ⊗[R] (M j))) i)
  rw [← Equiv.injective_comp (TensorProduct.directSumRight _ _ _).symm.toEquiv]
  rw [LinearEquiv.coe_toEquiv, ← LinearEquiv.coe_coe, ← LinearMap.coe_comp]
  rw [LinearEquiv.coe_toEquiv, ← LinearEquiv.coe_coe, ← LinearMap.coe_comp]
  rw [← psi_def, injective_iff_map_eq_zero ((η₁.comp ρ).comp ψ)]
  have h₁ : ∀ (i : ι), (π i).comp ((η₁.comp ρ).comp ψ) = (η i).comp ((φ i).comp (τ i))
  · intro i
    

Proof state:
case h₁
R : Type u
inst✝² : CommRing R
ι : Type v
M : ι → Type w
inst✝¹ : (i : ι) → AddCommGroup (M i)
inst✝ : (i : ι) → Module R (M i)
F : ∀ (i : ι), Flat R (M i)
I : Ideal R
hI : Ideal.FG I
η₁ : (R ⊗[R] ⨁ (i : ι), M i) ≃ₗ[R] ⨁ (i : ι), M i := TensorProduct.lid R (⨁ (i : ι), M i)
η : (i : ι) → R ⊗[R] M i ≃ₗ[R] M i := fun i => TensorProduct.lid R (M i)
φ : (i : ι) → ↥I ⊗[R] M i →ₗ[R] R ⊗[R] M i := fun i => rTensor (M i) (Submodule.subtype I)
π : (i : ι) → (⨁ (i : ι), M i) →ₗ[R] M i := fun i => component R ι (fun j => M j) i
ψ : (⨁ (i : ι), ↥I ⊗[R] M i) →ₗ[R] ↥I ⊗[R] ⨁ (i : ι), M i := ↑(LinearEquiv.symm (directSumRight R ↥I fun i => M i))
psi_def : ψ = ↑(LinearEquiv.symm (directSumRight R ↥I fun i => M i))
ρ : (↥I ⊗[R] ⨁ (i : ι), M i) →ₗ[R] R ⊗[R] ⨁ (i : ι), M i := rTensor (⨁ (i : ι), M i) (Submodule.subtype I)
τ : (i : ι) → (⨁ (i : ι), ↥I ⊗[R] M i) →ₗ[R] ↥I ⊗[R] M i := fun i => component R ι (fun j => ↥I ⊗[R] M j) i
i : ι
⊢ π i ∘ₗ (↑η₁ ∘ₗ ρ) ∘ₗ ψ = ↑(η i) ∘ₗ φ i ∘ₗ τ i

Next tactic:
apply DirectSum.linearMap_ext