File: Mathlib/RingTheory/Flat/EquationalCriterion.lean

full_name: Module.IsTrivialRelation
code: /-- The proposition that the relation $\sum_i f_i x_i = 0$ in $M$ is trivial.
That is, there exist a finite index type $\kappa$, elements
$(y_j)_{j \in \kappa}$ of $M$, and elements $(a_{ij})_{i \in \iota, j \in \kappa}$ of $R$
such that for all $i$,
$$x_i = \sum_j a_{ij} y_j$$
and for all $j$,
$$\sum_{i} f_i a_{ij} = 0.$$
By `Module.sum_smul_eq_zero_of_isTrivialRelation`, this condition implies $\sum_i f_i x_i = 0$. -/
abbrev IsTrivialRelation : Prop 
goal: Prop

full_name: Module.isTrivialRelation_iff_vanishesTrivially
code: /-- `Module.IsTrivialRelation` is equivalent to the predicate `TensorProduct.VanishesTrivially`
defined in `Mathlib/LinearAlgebra/TensorProduct/Vanishing.lean`. -/
theorem isTrivialRelation_iff_vanishesTrivially :
    IsTrivialRelation f x ↔ VanishesTrivially R f x 
goal: Module.IsTrivialRelation f x ↔ TensorProduct.VanishesTrivially R f x

full_name: Module.sum_smul_eq_zero_of_isTrivialRelation
code: /-- If the relation given by $(f_i)_{i \in \iota}$ and $(x_i)_{i \in \iota}$ is trivial, then
$\sum_{i} f_i x_i$ is actually equal to $0$. -/
theorem sum_smul_eq_zero_of_isTrivialRelation (h : IsTrivialRelation f x) :
    ∑ i, f i • x i = 0 
goal: ∑ i : ι, f i • x i = 0

full_name: Module.Flat.tfae_equational_criterion
code: /-- **Equational criterion for flatness** [Stacks 00HK](https://stacks.math.columbia.edu/tag/00HK),
combined form.

Let $M$ be a module over a commutative ring $R$. The following are equivalent:
* $M$ is flat.
* For all ideals $I \subseteq R$, the map $I \otimes M \to M$ is injective.
* Every $\sum_i f_i \otimes x_i$ that vanishes in $R \otimes M$ vanishes trivially.
* Every relation $\sum_i f_i x_i = 0$ in $M$ is trivial.
* For all finite index types $\iota$, all elements $f \in R^{\iota}$, and all homomorphisms
$x \colon R^{\iota} \to M$ such that $x(f) = 0$, there exist a finite index type $\kappa$ and module
homomorphisms $a \colon R^{\iota} \to R^{\kappa}$ and $y \colon R^{\kappa} \to M$ such
that $x = y \circ a$ and $a(f) = 0$.
* For all finite free modules $N$, all elements $f \in N$, and all homomorphisms $x \colon N \to M$
such that $x(f) = 0$, there exist a finite index type $\kappa$ and module homomorphisms
$a \colon N \to R^{\kappa}$ and $y \colon R^{\kappa} \to M$ such that $x = y \circ a$ and
$a(f) = 0$. -/
theorem tfae_equational_criterion : List.TFAE [
    Flat R M,
    ∀ (I : Ideal R), Function.Injective ⇑(rTensor M (Submodule.subtype I)),
    ∀ {ι : Type u} [Fintype ι] {f : ι → R} {x : ι → M}, ∑ i, f i ⊗ₜ x i = (0 : R ⊗[R] M) →
      VanishesTrivially R f x,
    ∀ {ι : Type u} [Fintype ι] {f : ι → R} {x : ι → M}, ∑ i, f i • x i = 0 → IsTrivialRelation f x,
    ∀ {ι : Type u} [Fintype ι] {f : ι →₀ R} {x : (ι →₀ R) →ₗ[R] M}, x f = 0 →
      ∃ (κ : Type u) (_ : Fintype κ) (a : (ι →₀ R) →ₗ[R] (κ →₀ R)) (y : (κ →₀ R) →ₗ[R] M),
        x = y ∘ₗ a ∧ a f = 0,
    ∀ {N : Type u} [AddCommGroup N] [Module R N] [Free R N] [Finite R N] {f : N} {x : N →ₗ[R] M},
      x f = 0 →
        ∃ (κ : Type u) (_ : Fintype κ) (a : N →ₗ[R] (κ →₀ R)) (y : (κ →₀ R) →ₗ[R] M),
          x = y ∘ₗ a ∧ a f = 0] 
goal: [Module.Flat R M, ∀ (I : Ideal R), Function.Injective ⇑(LinearMap.rTensor M (Submodule.subtype I)),
    ∀ {ι : Type u} [inst : Fintype ι] {f : ι → R} {x : ι → M},
      ∑ i : ι, f i ⊗ₜ[R] x i = 0 → TensorProduct.VanishesTrivially R f x,
    ∀ {ι : Type u} [inst : Fintype ι] {f : ι → R} {x : ι → M}, ∑ i : ι, f i • x i = 0 → Module.IsTrivialRelation f x,
    ∀ {ι : Type u} [inst : Fintype ι] {f : ι →₀ R} {x : (ι →₀ R) →ₗ[R] M}, x f = 0 → ∃ κ x_1 a y, x = y ∘ₗ a ∧ a f = 0,
    ∀ {N : Type u} [inst : AddCommGroup N] [inst_1 : Module R N] [inst_2 : Module.Free R N] [inst_3 : Module.Finite R N]
      {f : N} {x : N →ₗ[R] M}, x f = 0 → ∃ κ x_1 a y, x = y ∘ₗ a ∧ a f = 0].TFAE

full_name: Module.Flat.iff_forall_isTrivialRelation
code: /-- **Equational criterion for flatness** [Stacks 00HK](https://stacks.math.columbia.edu/tag/00HK).

A module $M$ is flat if and only if every relation $\sum_i f_i x_i = 0$ in $M$ is trivial. -/
theorem iff_forall_isTrivialRelation : Flat R M ↔ ∀ {ι : Type u} [Fintype ι] {f : ι → R}
    {x : ι → M}, ∑ i, f i • x i = 0 → IsTrivialRelation f x 
goal: Module.Flat R M ↔
  ∀ {ι : Type u} [inst : Fintype ι] {f : ι → R} {x : ι → M}, ∑ i : ι, f i • x i = 0 → Module.IsTrivialRelation f x

full_name: Module.Flat.isTrivialRelation_of_sum_smul_eq_zero
code: /-- **Equational criterion for flatness**
[Stacks 00HK](https://stacks.math.columbia.edu/tag/00HK), forward direction.

If $M$ is flat, then every relation $\sum_i f_i x_i = 0$ in $M$ is trivial. -/
theorem isTrivialRelation_of_sum_smul_eq_zero [Flat R M] {ι : Type u} [Fintype ι] {f : ι → R}
    {x : ι → M} (h : ∑ i, f i • x i = 0) : IsTrivialRelation f x 
goal: Module.IsTrivialRelation f x

full_name: Module.Flat.of_forall_isTrivialRelation
code: /-- **Equational criterion for flatness**
[Stacks 00HK](https://stacks.math.columbia.edu/tag/00HK), backward direction.

If every relation $\sum_i f_i x_i = 0$ in $M$ is trivial, then $M$ is flat. -/
theorem of_forall_isTrivialRelation (hfx : ∀ {ι : Type u} [Fintype ι] {f : ι → R} {x : ι → M},
    ∑ i, f i • x i = 0 → IsTrivialRelation f x) : Flat R M 
goal: Module.Flat R M

full_name: Module.Flat.iff_forall_exists_factorization
code: /-- **Equational criterion for flatness**
[Stacks 00HK](https://stacks.math.columbia.edu/tag/00HK), alternate form.

A module $M$ is flat if and only if for all finite free modules $R^\iota$,
all $f \in R^{\iota}$, and all homomorphisms $x \colon R^{\iota} \to M$ such that $x(f) = 0$, there
exist a finite free module $R^\kappa$ and homomorphisms $a \colon R^{\iota} \to R^{\kappa}$ and
$y \colon R^{\kappa} \to M$ such that $x = y \circ a$ and $a(f) = 0$. -/
theorem iff_forall_exists_factorization : Flat R M ↔
    ∀ {ι : Type u} [Fintype ι] {f : ι →₀ R} {x : (ι →₀ R) →ₗ[R] M}, x f = 0 →
      ∃ (κ : Type u) (_ : Fintype κ) (a : (ι →₀ R) →ₗ[R] (κ →₀ R)) (y : (κ →₀ R) →ₗ[R] M),
        x = y ∘ₗ a ∧ a f = 0 
goal: Module.Flat R M ↔
  ∀ {ι : Type u} [inst : Fintype ι] {f : ι →₀ R} {x : (ι →₀ R) →ₗ[R] M}, x f = 0 → ∃ κ x_1 a y, x = y ∘ₗ a ∧ a f = 0

full_name: Module.Flat.exists_factorization_of_apply_eq_zero
code: /-- **Equational criterion for flatness**
[Stacks 00HK](https://stacks.math.columbia.edu/tag/00HK), forward direction, alternate form.

Let $M$ be a flat module. Let $R^\iota$ be a finite free module, let $f \in R^{\iota}$ be an
element, and let $x \colon R^{\iota} \to M$ be a homomorphism such that $x(f) = 0$. Then there
exist a finite free module $R^\kappa$ and homomorphisms $a \colon R^{\iota} \to R^{\kappa}$ and
$y \colon R^{\kappa} \to M$ such that $x = y \circ a$ and $a(f) = 0$. -/
theorem exists_factorization_of_apply_eq_zero [Flat R M] {ι : Type u} [_root_.Finite ι]
    {f : ι →₀ R} {x : (ι →₀ R) →ₗ[R] M} (h : x f = 0) :
    ∃ (κ : Type u) (_ : Fintype κ) (a : (ι →₀ R) →ₗ[R] (κ →₀ R)) (y : (κ →₀ R) →ₗ[R] M),
      x = y ∘ₗ a ∧ a f = 0 
goal: ∃ κ x_1 a y, x = y ∘ₗ a ∧ a f = 0

full_name: Module.Flat.of_forall_exists_factorization
code: /-- **Equational criterion for flatness**
[Stacks 00HK](https://stacks.math.columbia.edu/tag/00HK), backward direction, alternate form.

Let $M$ be a module over a commutative ring $R$. Suppose that for all finite free modules $R^\iota$,
all $f \in R^{\iota}$, and all homomorphisms $x \colon R^{\iota} \to M$ such that $x(f) = 0$, there
exist a finite free module $R^\kappa$ and homomorphisms $a \colon R^{\iota} \to R^{\kappa}$ and
$y \colon R^{\kappa} \to M$ such that $x = y \circ a$ and $a(f) = 0$. Then $M$ is flat. -/
theorem of_forall_exists_factorization (h : ∀ {ι : Type u} [Fintype ι] {f : ι →₀ R}
    {x : (ι →₀ R) →ₗ[R] M}, x f = 0 →
      ∃ (κ : Type u) (_ : Fintype κ) (a : (ι →₀ R) →ₗ[R] (κ →₀ R)) (y : (κ →₀ R) →ₗ[R] M),
      x = y ∘ₗ a ∧ a f = 0) : Flat R M 
goal: Module.Flat R M

full_name: Module.Flat.exists_factorization_of_apply_eq_zero_of_free
code: /-- **Equational criterion for flatness** [Stacks 00HK](https://stacks.math.columbia.edu/tag/00HK),
forward direction, second alternate form.

Let $M$ be a flat module over a commutative ring $R$. Let $N$ be a finite free module over $R$,
let $f \in N$, and let $x \colon N \to M$ be a homomorphism such that $x(f) = 0$. Then there exist a
finite index type $\kappa$ and module homomorphisms $a \colon N \to R^{\kappa}$ and
$y \colon R^{\kappa} \to M$ such that $x = y \circ a$ and $a(f) = 0$. -/
theorem exists_factorization_of_apply_eq_zero_of_free [Flat R M] {N : Type u}
    [AddCommGroup N] [Module R N] [Free R N] [Finite R N] {f : N} {x : N →ₗ[R] M} (h : x f = 0) :
    ∃ (κ : Type u) (_ : Fintype κ) (a : N →ₗ[R] (κ →₀ R)) (y : (κ →₀ R) →ₗ[R] M),
      x = y ∘ₗ a ∧ a f = 0 
goal: ∃ κ x_1 a y, x = y ∘ₗ a ∧ a f = 0

full_name: Module.Flat.exists_factorization_of_comp_eq_zero_of_free
code: /-- Let $M$ be a flat module. Let $K$ and $N$ be finite $R$-modules with $N$
free, and let $f \colon K \to N$ and $x \colon N \to M$ be homomorphisms such that
$x \circ f = 0$. Then there exist a finite index type $\kappa$ and module homomorphisms
$a \colon N \to R^{\kappa}$ and $y \colon R^{\kappa} \to M$ such that $x = y \circ a$ and
$a \circ f = 0$. -/
theorem exists_factorization_of_comp_eq_zero_of_free [Flat R M] {K N : Type u}
    [AddCommGroup K] [Module R K] [Finite R K] [AddCommGroup N] [Module R N] [Free R N] [Finite R N]
    {f : K →ₗ[R] N} {x : N →ₗ[R] M} (h : x ∘ₗ f = 0) :
    ∃ (κ : Type u) (_ : Fintype κ) (a : N →ₗ[R] (κ →₀ R)) (y : (κ →₀ R) →ₗ[R] M),
      x = y ∘ₗ a ∧ a ∘ₗ f = 0 
goal: ∃ κ x_1 a y, x = y ∘ₗ a ∧ a ∘ₗ f = 0

full_name: Module.Flat.exists_factorization_of_isFinitelyPresented
code: /-- Every homomorphism from a finitely presented module to a flat module factors through a finite
free module. -/
theorem exists_factorization_of_isFinitelyPresented [Flat R M] {P : Type u} [AddCommGroup P]
    [Module R P] [FinitePresentation R P] (h₁ : P →ₗ[R] M) :
      ∃ (κ : Type u) (_ : Fintype κ) (h₂ : P →ₗ[R] (κ →₀ R)) (h₃ : (κ →₀ R) →ₗ[R] M),
        h₁ = h₃ ∘ₗ h₂ 
goal: ∃ κ x h₂ h₃, h₁ = h₃ ∘ₗ h₂