ring_theory.flat ⟷ Mathlib.RingTheory.Flat.Basic

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -3,7 +3,7 @@ Copyright (c) 2020 Johan Commelin. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Johan Commelin
 -/
-import Mathbin.RingTheory.Noetherian
+import RingTheory.Noetherian
 
 #align_import ring_theory.flat from "leanprover-community/mathlib"@"c085f3044fe585c575e322bfab45b3633c48d820"
 
Diff
@@ -2,14 +2,11 @@
 Copyright (c) 2020 Johan Commelin. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Johan Commelin
-
-! This file was ported from Lean 3 source module ring_theory.flat
-! leanprover-community/mathlib commit c085f3044fe585c575e322bfab45b3633c48d820
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.RingTheory.Noetherian
 
+#align_import ring_theory.flat from "leanprover-community/mathlib"@"c085f3044fe585c575e322bfab45b3633c48d820"
+
 /-!
 # Flat modules
 
Diff
@@ -60,7 +60,7 @@ open Function (Injective)
 
 open LinearMap (lsmul)
 
-open TensorProduct
+open scoped TensorProduct
 
 #print Module.Flat /-
 /-- An `R`-module `M` is flat if for all finitely generated ideals `I` of `R`,
Diff
@@ -66,7 +66,7 @@ open TensorProduct
 /-- An `R`-module `M` is flat if for all finitely generated ideals `I` of `R`,
 the canonical map `I βŠ— M β†’β‚— M` is injective. -/
 class Flat (R : Type u) (M : Type v) [CommRing R] [AddCommGroup M] [Module R M] : Prop where
-  out : βˆ€ ⦃I : Ideal R⦄ (hI : I.Fg), Injective (TensorProduct.lift ((lsmul R M).comp I.Subtype))
+  out : βˆ€ ⦃I : Ideal R⦄ (hI : I.FG), Injective (TensorProduct.lift ((lsmul R M).comp I.Subtype))
 #align module.flat Module.Flat
 -/
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Johan Commelin
 
 ! This file was ported from Lean 3 source module ring_theory.flat
-! leanprover-community/mathlib commit 62c0a4ef1441edb463095ea02a06e87f3dfe135c
+! leanprover-community/mathlib commit c085f3044fe585c575e322bfab45b3633c48d820
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -13,6 +13,9 @@ import Mathbin.RingTheory.Noetherian
 /-!
 # Flat modules
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 A module `M` over a commutative ring `R` is *flat*
 if for all finitely generated ideals `I` of `R`,
 the canonical map `I βŠ— M β†’β‚— M` is injective.
Diff
@@ -59,16 +59,19 @@ open LinearMap (lsmul)
 
 open TensorProduct
 
+#print Module.Flat /-
 /-- An `R`-module `M` is flat if for all finitely generated ideals `I` of `R`,
 the canonical map `I βŠ— M β†’β‚— M` is injective. -/
 class Flat (R : Type u) (M : Type v) [CommRing R] [AddCommGroup M] [Module R M] : Prop where
   out : βˆ€ ⦃I : Ideal R⦄ (hI : I.Fg), Injective (TensorProduct.lift ((lsmul R M).comp I.Subtype))
 #align module.flat Module.Flat
+-/
 
 namespace Flat
 
 open TensorProduct LinearMap _Root_.Submodule
 
+#print Module.Flat.self /-
 instance self (R : Type u) [CommRing R] : Flat R R :=
   ⟨by
     intro I hI
@@ -78,6 +81,7 @@ instance self (R : Type u) [CommRing R] : Flat R R :=
     simp only [Function.comp_apply, LinearEquiv.coe_toEquiv, rid_symm_apply, comp_apply, mul_one,
       lift.tmul, subtype_apply, Algebra.id.smul_eq_mul, lsmul_apply]⟩
 #align module.flat.self Module.Flat.self
+-/
 
 end Flat
 

Changes in mathlib4

mathlib3
mathlib4
chore: superfluous parentheses part 2 (#12131)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -158,9 +158,9 @@ instance directSum (ΞΉ : Type v) (M : ΞΉ β†’ Type w) [(i : ΞΉ) β†’ AddCommGroup
   letI : βˆ€ i, AddCommGroup (I βŠ—[R] M i) := inferInstance
   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 Ξ· := 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)
@@ -184,7 +184,7 @@ instance directSum (ΞΉ : Type v) (M : ΞΉ β†’ Type w) [(i : ΞΉ) β†’ AddCommGroup
   have f := LinearMap.congr_arg (f := (Ο€ i)) ha
   erw [LinearMap.congr_fun (h₁ i) a] at f
   rw [(map_zero (Ο€ i) : (Ο€ i) 0 = (0 : M i))] at f
-  have hβ‚‚ := (F i)
+  have hβ‚‚ := F i
   rw [iff_rTensor_injective] at hβ‚‚
   have h₃ := hβ‚‚ hI
   simp only [coe_comp, LinearEquiv.coe_coe, Function.comp_apply, AddEquivClass.map_eq_zero_iff,
style: replace '.-/' by '. -/' (#11938)

Purely automatic replacement. If this is in any way controversial; I'm happy to just close this PR.

Diff
@@ -112,12 +112,12 @@ theorem iff_rTensor_injective' :
 @[deprecated]
 alias lTensor_inj_iff_rTensor_inj := LinearMap.lTensor_inj_iff_rTensor_inj
 
-/-- The `lTensor`-variant of `iff_rTensor_injective`. .-/
+/-- The `lTensor`-variant of `iff_rTensor_injective`. . -/
 theorem iff_lTensor_injective :
     Module.Flat R M ↔ βˆ€ ⦃I : Ideal R⦄ (_ : I.FG), Function.Injective (lTensor M I.subtype) := by
   simpa [← comm_comp_rTensor_comp_comm_eq] using Module.Flat.iff_rTensor_injective R M
 
-/-- The `lTensor`-variant of `iff_rTensor_injective'`. .-/
+/-- The `lTensor`-variant of `iff_rTensor_injective'`. . -/
 theorem iff_lTensor_injective' :
     Module.Flat R M ↔ βˆ€ (I : Ideal R), Function.Injective (lTensor M I.subtype) := by
   simpa [← comm_comp_rTensor_comp_comm_eq] using Module.Flat.iff_rTensor_injective' R M
@@ -228,7 +228,7 @@ theorem iff_characterModule_baer : Flat R M ↔ Module.Baer R (CharacterModule M
   simp_rw [iff_rTensor_injective', Baer, rTensor_injective_iff_lcomp_surjective,
     Surjective, DFunLike.ext_iff, Subtype.forall]; rfl
 
-/-- `CharacterModule M` is an injective module iff `M` is flat.-/
+/-- `CharacterModule M` is an injective module iff `M` is flat. -/
 theorem iff_characterModule_injective [Small.{v} R] :
     Flat R M ↔ Module.Injective R (CharacterModule M) :=
   iff_characterModule_baer.trans Module.Baer.iff_injective
feat(RingTheory/Flat/Basic): add lTensor_preserves_injective_linearMap (#11748)

also move lTensor_inj_iff_rTensor_inj to LinearMap

Diff
@@ -109,11 +109,8 @@ theorem iff_rTensor_injective' :
   rewrite [← rTensor_comp_apply] at hxβ‚€
   rw [(injective_iff_map_eq_zero _).mp (h hfg) y hxβ‚€, LinearMap.map_zero]
 
-/-- Given a linear map `f : N β†’ P`, `f βŠ— M` is injective if and only if `M βŠ— f` is injective. -/
-@[deprecated] lemma lTensor_inj_iff_rTensor_inj {N P : Type*} [AddCommGroup N] [AddCommGroup P]
-    [Module R N] [Module R P] (f : N β†’β‚—[R] P) :
-    Function.Injective (lTensor M f) ↔ Function.Injective (rTensor M f) := by
-  simp [← comm_comp_rTensor_comp_comm_eq]
+@[deprecated]
+alias lTensor_inj_iff_rTensor_inj := LinearMap.lTensor_inj_iff_rTensor_inj
 
 /-- The `lTensor`-variant of `iff_rTensor_injective`. .-/
 theorem iff_lTensor_injective :
@@ -239,10 +236,22 @@ theorem iff_characterModule_injective [Small.{v} R] :
 /--
 If `M` is a flat module, then `f βŠ— πŸ™ M` is injective for all injective linear maps `f`.
 -/
-theorem preserves_injective_linearMap {N' : Type*} [AddCommGroup N'] [Module R N'] [h : Flat R M]
-    (L : N β†’β‚—[R] N') (hL : Function.Injective L) : Function.Injective (L.rTensor M) :=
+theorem rTensor_preserves_injective_linearMap {N' : Type*} [AddCommGroup N'] [Module R N']
+    [h : Flat R M] (L : N β†’β‚—[R] N') (hL : Function.Injective L) :
+    Function.Injective (L.rTensor M) :=
   rTensor_injective_iff_lcomp_surjective.2 ((iff_characterModule_baer.1 h).extension_property _ hL)
 
+@[deprecated]
+alias preserves_injective_linearMap := rTensor_preserves_injective_linearMap
+
+/--
+If `M` is a flat module, then `πŸ™ M βŠ— f` is injective for all injective linear maps `f`.
+-/
+theorem lTensor_preserves_injective_linearMap {N' : Type*} [AddCommGroup N'] [Module R N']
+    [Flat R M] (L : N β†’β‚—[R] N') (hL : Function.Injective L) :
+    Function.Injective (L.lTensor M) :=
+  (L.lTensor_inj_iff_rTensor_inj M).2 (rTensor_preserves_injective_linearMap L hL)
+
 variable (R M) in
 /--
 M is flat if and only if `f βŠ— πŸ™ M` is injective whenever `f` is an injective linear map.
@@ -254,6 +263,16 @@ lemma iff_rTensor_preserves_injective_linearMap [Small.{v} R] :
   rw [iff_characterModule_injective,
     injective_characterModule_iff_rTensor_preserves_injective_linearMap]
 
+variable (R M) in
+/--
+M is flat if and only if `πŸ™ M βŠ— f` is injective whenever `f` is an injective linear map.
+-/
+lemma iff_lTensor_preserves_injective_linearMap [Small.{v} R] :
+    Flat R M ↔
+    βˆ€ ⦃N N' : Type v⦄ [AddCommGroup N] [AddCommGroup N'] [Module R N] [Module R N']
+      (L : N β†’β‚—[R] N'), Function.Injective L β†’ Function.Injective (L.lTensor M) := by
+  simp_rw [iff_rTensor_preserves_injective_linearMap, LinearMap.lTensor_inj_iff_rTensor_inj]
+
 end Flat
 
 end Module
chore: scope open Classical (#11199)

We remove all but one open Classicals, instead preferring to use open scoped Classical. The only real side-effect this led to is moving a couple declarations to use Exists.choose instead of Classical.choose.

The first few commits are explicitly labelled regex replaces for ease of review.

Diff
@@ -194,7 +194,7 @@ instance directSum (ΞΉ : Type v) (M : ΞΉ β†’ Type w) [(i : ΞΉ) β†’ AddCommGroup
     h₃, LinearMap.map_eq_zero_iff] at f
   simp [f]
 
-open Classical in
+open scoped Classical in
 /-- Free `R`-modules over discrete types are flat. -/
 instance finsupp (ΞΉ : Type v) : Flat R (ΞΉ β†’β‚€ R) :=
   of_linearEquiv R _ _ (finsuppLEquivDirectSum R R ΞΉ)
feat(RingTheory/Flat/Basic): a module is flat iff tensoring preserves injectivity of linear maps (#9120)

Co-authored-by: Junyan Xu <junyanxu.math@gmail.com>

Co-authored-by: Junyan Xu <junyanxu.math@gmail.com>

Diff
@@ -1,14 +1,17 @@
 /-
 Copyright (c) 2020 Johan Commelin. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
-Authors: Johan Commelin
+Authors: Johan Commelin, Jujian Zhang
 -/
+import Mathlib.RingTheory.Noetherian
 import Mathlib.Algebra.DirectSum.Module
 import Mathlib.Algebra.DirectSum.Finsupp
 import Mathlib.Algebra.Module.Projective
+import Mathlib.Algebra.Module.Injective
+import Mathlib.Algebra.Module.CharacterModule
 import Mathlib.LinearAlgebra.DirectSum.TensorProduct
 import Mathlib.LinearAlgebra.FreeModule.Basic
-import Mathlib.RingTheory.Finiteness
+import Mathlib.Algebra.Module.Projective
 
 #align_import ring_theory.flat from "leanprover-community/mathlib"@"62c0a4ef1441edb463095ea02a06e87f3dfe135c"
 
@@ -22,7 +25,6 @@ the canonical map `I βŠ— M β†’β‚— M` is injective.
 This is equivalent to the claim that for all injective `R`-linear maps `f : M₁ β†’ Mβ‚‚`
 the induced map `M₁ βŠ— M β†’ Mβ‚‚ βŠ— M` is injective.
 See <https://stacks.math.columbia.edu/tag/00HD>.
-This result is not yet formalised.
 
 ## Main declaration
 
@@ -35,22 +37,26 @@ This result is not yet formalised.
 * `Module.Flat.directSum`: arbitrary direct sums of flat modules are flat
 * `Module.Flat.of_free`: free modules are flat
 * `Module.Flat.of_projective`: projective modules are flat
+* `Module.Flat.preserves_injective_linearMap`: If `M` is a flat module then tensoring with `M`
+  preserves injectivity of linear maps. This lemma is fully universally polymorphic in all
+  arguments, i.e. `R`, `M` and linear maps `N β†’ N'` can all have different universe levels.
+* `Module.Flat.iff_rTensor_preserves_injective_linearMap`: a module is flat iff tensoring preserves
+  injectivity in the ring's universe (or higher).
+
+## Implementation notes
+In `Module.Flat.iff_rTensor_preserves_injective_linearMap`, we require that the universe level of
+the ring is lower than or equal to that of the module. This requirement is to make sure ideals of
+the ring can be lifted to the universe of the module. It is unclear if this lemma also holds
+when the module lives in a lower universe.
 
 ## TODO
 
-* Show that tensoring with a flat module preserves injective morphisms.
-  Show that this is equivalent to be flat.
-  See <https://stacks.math.columbia.edu/tag/00HD>.
-  To do this, it is probably a good idea to think about a suitable
-  categorical induction principle that should be applied to the category of `R`-modules,
-  and that will take care of the administrative side of the proof.
 * Show that flatness is stable under base change (aka extension of scalars)
-  For base change, it will be very useful to have a "characteristic predicate"
-  instead of relying on the construction `A βŠ— B`.
-  Indeed, such a predicate should allow us to treat both
+  Using the `IsBaseChange` predicate should allow us to treat both
   `A[X]` and `A βŠ— R[X]` as the base change of `R[X]` to `A`.
   (Similar examples exist with `Fin n β†’ R`, `R Γ— R`, `β„€[i] βŠ— ℝ`, etc...)
 * Generalize flatness to noncommutative rings.
+
 -/
 
 
@@ -58,21 +64,22 @@ universe u v w
 
 namespace Module
 
-open Function (Injective Surjective)
+open Function (Surjective)
 
-open LinearMap Submodule TensorProduct
+open LinearMap Submodule TensorProduct DirectSum
 
 variable (R : Type u) (M : Type v) [CommRing R] [AddCommGroup M] [Module R M]
 
 /-- An `R`-module `M` is flat if for all finitely generated ideals `I` of `R`,
 the canonical map `I βŠ— M β†’β‚— M` is injective. -/
-class Flat : Prop where
-  out : βˆ€ ⦃I : Ideal R⦄ (_ : I.FG), Injective (TensorProduct.lift ((lsmul R M).comp I.subtype))
+@[mk_iff] class Flat : Prop where
+  out : βˆ€ ⦃I : Ideal R⦄ (_ : I.FG),
+    Function.Injective (TensorProduct.lift ((lsmul R M).comp I.subtype))
 #align module.flat Module.Flat
 
 namespace Flat
 
-instance self : Flat R R :=
+instance self (R : Type u) [CommRing R] : Flat R R :=
   ⟨by
     intro I _
     rw [← Equiv.injective_comp (TensorProduct.rid R I).symm.toEquiv]
@@ -86,58 +93,37 @@ instance self : Flat R R :=
 tensor product of the inclusion `I β†’ R` and the identity `M β†’ M` is injective. See
 `iff_rTensor_injective'` to extend to all ideals `I`. --/
 lemma iff_rTensor_injective :
-    Flat R M ↔ βˆ€ ⦃I : Ideal R⦄ (_ : I.FG), Injective (rTensor M I.subtype) := by
-  have aux : βˆ€ I : Ideal R, (TensorProduct.lid R M).comp (rTensor M I.subtype) =
-      TensorProduct.lift ((lsmul R M).comp I.subtype) := by
-    intro I; apply TensorProduct.ext'; intro x y; simp
-  constructor
-  Β· intro F I hI
-    erw [← Equiv.comp_injective _ (TensorProduct.lid R M).toEquiv]
-    have h₁ := F.out hI
-    rw [← aux] at h₁
-    exact h₁
-  Β· intro h₁
-    constructor
-    intro I hI
-    rw [← aux]
-    simp [h₁ hI]
+    Flat R M ↔ βˆ€ ⦃I : Ideal R⦄ (_ : I.FG), Function.Injective (rTensor M I.subtype) := by
+  simp [flat_iff, ← lid_comp_rTensor]
 
 /-- An `R`-module `M` is flat iff for all ideals `I` of `R`, the tensor product of the
 inclusion `I β†’ R` and the identity `M β†’ M` is injective. See `iff_rTensor_injective` to
 restrict to finitely generated ideals `I`. --/
 theorem iff_rTensor_injective' :
-    Flat R M ↔ βˆ€ I : Ideal R, Injective (rTensor M I.subtype) := by
+    Flat R M ↔ βˆ€ I : Ideal R, Function.Injective (rTensor M I.subtype) := by
   rewrite [Flat.iff_rTensor_injective]
   refine ⟨fun h I => ?_, fun h I _ => h I⟩
   rewrite [injective_iff_map_eq_zero]
   intro x hxβ‚€
-  obtain ⟨J, hfg, hle, y, rfl⟩ := exists_fg_le_eq_rTensor_inclusion x
+  obtain ⟨J, hfg, hle, y, rfl⟩ := Submodule.exists_fg_le_eq_rTensor_inclusion x
   rewrite [← rTensor_comp_apply] at hxβ‚€
   rw [(injective_iff_map_eq_zero _).mp (h hfg) y hxβ‚€, LinearMap.map_zero]
 
 /-- Given a linear map `f : N β†’ P`, `f βŠ— M` is injective if and only if `M βŠ— f` is injective. -/
-lemma lTensor_inj_iff_rTensor_inj {N P : Type*} [AddCommGroup N] [AddCommGroup P] [Module R N]
-    [Module R P] (f : N β†’β‚—[R] P) :
-    Injective (lTensor M f) ↔ Injective (rTensor M f) := by
-  haveI h1 : rTensor M f βˆ˜β‚— TensorProduct.comm R M N =
-    TensorProduct.comm R M P βˆ˜β‚— lTensor M f := ext rfl
-  haveI h2 : ⇑(TensorProduct.comm R M P) ∘ ⇑(lTensor M f) =
-    (TensorProduct.comm R M P) βˆ˜β‚— (lTensor M f) := rfl
-  simp only [← EquivLike.injective_comp (TensorProduct.comm R M N),
-    ← EquivLike.comp_injective _ (TensorProduct.comm R M P), h2, ← h1]
-  trivial
+@[deprecated] lemma lTensor_inj_iff_rTensor_inj {N P : Type*} [AddCommGroup N] [AddCommGroup P]
+    [Module R N] [Module R P] (f : N β†’β‚—[R] P) :
+    Function.Injective (lTensor M f) ↔ Function.Injective (rTensor M f) := by
+  simp [← comm_comp_rTensor_comp_comm_eq]
 
 /-- The `lTensor`-variant of `iff_rTensor_injective`. .-/
 theorem iff_lTensor_injective :
-    Module.Flat R M ↔ βˆ€ ⦃I : Ideal R⦄ (_ : I.FG), Injective (lTensor M I.subtype) := by
-  simp only [lTensor_inj_iff_rTensor_inj]
-  exact Module.Flat.iff_rTensor_injective R M
+    Module.Flat R M ↔ βˆ€ ⦃I : Ideal R⦄ (_ : I.FG), Function.Injective (lTensor M I.subtype) := by
+  simpa [← comm_comp_rTensor_comp_comm_eq] using Module.Flat.iff_rTensor_injective R M
 
 /-- The `lTensor`-variant of `iff_rTensor_injective'`. .-/
 theorem iff_lTensor_injective' :
-    Module.Flat R M ↔ βˆ€ (I : Ideal R), Injective (lTensor M I.subtype) := by
-  simp only [lTensor_inj_iff_rTensor_inj]
-  exact Module.Flat.iff_rTensor_injective' R M
+    Module.Flat R M ↔ βˆ€ (I : Ideal R), Function.Injective (lTensor M I.subtype) := by
+  simpa [← comm_comp_rTensor_comp_comm_eq] using Module.Flat.iff_rTensor_injective' R M
 
 variable (N : Type w) [AddCommGroup N] [Module R N]
 
@@ -164,8 +150,6 @@ lemma of_linearEquiv [f : Flat R M] (e : N ≃ₗ[R] M) : Flat R N := by
   have h : e.symm.toLinearMap.comp e.toLinearMap = LinearMap.id := by simp
   exact of_retract _ _ _ e.toLinearMap e.symm.toLinearMap h
 
-open DirectSum
-
 /-- 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
@@ -194,7 +178,7 @@ instance directSum (ΞΉ : Type v) (M : ΞΉ β†’ Type w) [(i : ΞΉ) β†’ AddCommGroup
     apply TensorProduct.ext'
     intro a m
     simp only [ρ, ψ, Ο†, Ξ·, η₁, coe_comp, LinearEquiv.coe_coe, Function.comp_apply,
-      directSumRight_symm_lof_tmul, rTensor_tmul, coeSubtype, lid_tmul, map_smul]
+      directSumRight_symm_lof_tmul, rTensor_tmul, Submodule.coeSubtype, lid_tmul, map_smul]
     rw [DirectSum.component.of, DirectSum.component.of]
     by_cases hβ‚‚ : j = i
     Β· subst j; simp
@@ -210,9 +194,9 @@ instance directSum (ΞΉ : Type v) (M : ΞΉ β†’ Type w) [(i : ΞΉ) β†’ AddCommGroup
     h₃, LinearMap.map_eq_zero_iff] at f
   simp [f]
 
+open Classical in
 /-- Free `R`-modules over discrete types are flat. -/
 instance finsupp (ΞΉ : Type v) : Flat R (ΞΉ β†’β‚€ R) :=
-  haveI := Classical.decEq ΞΉ
   of_linearEquiv R _ _ (finsuppLEquivDirectSum R R ΞΉ)
 
 instance of_free [Free R M] : Flat R M := of_linearEquiv R _ _ (Free.repr R M)
@@ -229,6 +213,47 @@ instance of_projective [h : Projective R M] : Flat R M := by
   cases h with
     | _ e he => exact of_retract R _ _ _ _ he
 
+/--
+Define the character module of `M` to be `M β†’+ β„š β§Έ β„€`.
+The character module of `M` is an injective module if and only if
+ `L βŠ— πŸ™ M` is injective for any linear map `L` in the same universe as `M`.
+-/
+lemma injective_characterModule_iff_rTensor_preserves_injective_linearMap :
+    Module.Injective R (CharacterModule M) ↔
+    βˆ€ ⦃N N' : Type v⦄ [AddCommGroup N] [AddCommGroup N'] [Module R N] [Module R N']
+      (L : N β†’β‚—[R] N'), Function.Injective L β†’ Function.Injective (L.rTensor M) := by
+  simp_rw [injective_iff, rTensor_injective_iff_lcomp_surjective, Surjective, DFunLike.ext_iff]; rfl
+
+variable {R M N}
+
+/-- `CharacterModule M` is Baer iff `M` is flat. -/
+theorem iff_characterModule_baer : Flat R M ↔ Module.Baer R (CharacterModule M) := by
+  simp_rw [iff_rTensor_injective', Baer, rTensor_injective_iff_lcomp_surjective,
+    Surjective, DFunLike.ext_iff, Subtype.forall]; rfl
+
+/-- `CharacterModule M` is an injective module iff `M` is flat.-/
+theorem iff_characterModule_injective [Small.{v} R] :
+    Flat R M ↔ Module.Injective R (CharacterModule M) :=
+  iff_characterModule_baer.trans Module.Baer.iff_injective
+
+/--
+If `M` is a flat module, then `f βŠ— πŸ™ M` is injective for all injective linear maps `f`.
+-/
+theorem preserves_injective_linearMap {N' : Type*} [AddCommGroup N'] [Module R N'] [h : Flat R M]
+    (L : N β†’β‚—[R] N') (hL : Function.Injective L) : Function.Injective (L.rTensor M) :=
+  rTensor_injective_iff_lcomp_surjective.2 ((iff_characterModule_baer.1 h).extension_property _ hL)
+
+variable (R M) in
+/--
+M is flat if and only if `f βŠ— πŸ™ M` is injective whenever `f` is an injective linear map.
+-/
+lemma iff_rTensor_preserves_injective_linearMap [Small.{v} R] :
+    Flat R M ↔
+    βˆ€ ⦃N N' : Type v⦄ [AddCommGroup N] [AddCommGroup N'] [Module R N] [Module R N']
+      (L : N β†’β‚—[R] N'), Function.Injective L β†’ Function.Injective (L.rTensor M) := by
+  rw [iff_characterModule_injective,
+    injective_characterModule_iff_rTensor_preserves_injective_linearMap]
+
 end Flat
 
 end Module
chore: more backporting of simp changes from #10995 (#11001)

Co-authored-by: Patrick Massot <patrickmassot@free.fr> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -193,8 +193,8 @@ instance directSum (ΞΉ : Type v) (M : ΞΉ β†’ Type w) [(i : ΞΉ) β†’ AddCommGroup
     intro j
     apply TensorProduct.ext'
     intro a m
-    simp only [coe_comp, LinearEquiv.coe_coe, Function.comp_apply, directSumRight_symm_lof_tmul,
-      rTensor_tmul, coeSubtype, lid_tmul, map_smul]
+    simp only [ρ, ψ, Ο†, Ξ·, η₁, coe_comp, LinearEquiv.coe_coe, Function.comp_apply,
+      directSumRight_symm_lof_tmul, rTensor_tmul, coeSubtype, lid_tmul, map_smul]
     rw [DirectSum.component.of, DirectSum.component.of]
     by_cases hβ‚‚ : j = i
     Β· subst j; simp
chore: generalize more DirectSum results to avoid negation (#10965)

Generalize Basis.tensorProduct and instance Module.Free.tensor to CommSemiring and AddCommMonoid, as a follow-up to #10828.

Plus style fixes:

  • tidy up LinearAlgebra.DirectSum.Finsupp.lean:
    • delete unused universe declaration
    • delete duplicate open TensorProduct
    • delete redundant noncomputable annotation and associated comment (due to noncomputable section in the same file)
    • use variable
  • delete "typeclass reminders" in "Module.Flat.iff_rTensor_injective'" (no longer needed)
  • whitespace fixes
  • simplify file structure (section/namespace/open/variable)

Co-authored-by: Richard Copley <rcopley@gmail.com>

Diff
@@ -51,7 +51,6 @@ This result is not yet formalised.
   `A[X]` and `A βŠ— R[X]` as the base change of `R[X]` to `A`.
   (Similar examples exist with `Fin n β†’ R`, `R Γ— R`, `β„€[i] βŠ— ℝ`, etc...)
 * Generalize flatness to noncommutative rings.
-
 -/
 
 
@@ -61,23 +60,19 @@ namespace Module
 
 open Function (Injective Surjective)
 
-open LinearMap (lsmul rTensor lTensor)
+open LinearMap Submodule TensorProduct
 
-open TensorProduct
+variable (R : Type u) (M : Type v) [CommRing R] [AddCommGroup M] [Module R M]
 
 /-- An `R`-module `M` is flat if for all finitely generated ideals `I` of `R`,
 the canonical map `I βŠ— M β†’β‚— M` is injective. -/
-class Flat (R : Type u) (M : Type v) [CommRing R] [AddCommGroup M] [Module R M] : Prop where
+class Flat : Prop where
   out : βˆ€ ⦃I : Ideal R⦄ (_ : I.FG), Injective (TensorProduct.lift ((lsmul R M).comp I.subtype))
 #align module.flat Module.Flat
 
 namespace Flat
 
-variable (R : Type u) [CommRing R]
-
-open LinearMap Submodule
-
-instance self (R : Type u) [CommRing R] : Flat R R :=
+instance self : Flat R R :=
   ⟨by
     intro I _
     rw [← Equiv.injective_comp (TensorProduct.rid R I).symm.toEquiv]
@@ -87,8 +82,6 @@ instance self (R : Type u) [CommRing R] : Flat R R :=
       lift.tmul, Submodule.subtype_apply, Algebra.id.smul_eq_mul, lsmul_apply]⟩
 #align module.flat.self Module.Flat.self
 
-variable (M : Type v) [AddCommGroup M] [Module R M]
-
 /-- An `R`-module `M` is flat iff for all finitely generated ideals `I` of `R`, the
 tensor product of the inclusion `I β†’ R` and the identity `M β†’ M` is injective. See
 `iff_rTensor_injective'` to extend to all ideals `I`. --/
@@ -116,13 +109,11 @@ theorem iff_rTensor_injective' :
     Flat R M ↔ βˆ€ I : Ideal R, Injective (rTensor M I.subtype) := by
   rewrite [Flat.iff_rTensor_injective]
   refine ⟨fun h I => ?_, fun h I _ => h I⟩
-  letI : AddCommGroup (I βŠ—[R] M) := inferInstance -- Type class reminder
   rewrite [injective_iff_map_eq_zero]
   intro x hxβ‚€
   obtain ⟨J, hfg, hle, y, rfl⟩ := exists_fg_le_eq_rTensor_inclusion x
   rewrite [← rTensor_comp_apply] at hxβ‚€
-  letI : AddCommGroup (J βŠ—[R] M) := inferInstance -- Type class reminder
-  rw [(injective_iff_map_eq_zero _).mp (h hfg) y hxβ‚€, _root_.map_zero]
+  rw [(injective_iff_map_eq_zero _).mp (h hfg) y hxβ‚€, LinearMap.map_zero]
 
 /-- Given a linear map `f : N β†’ P`, `f βŠ— M` is injective if and only if `M βŠ— f` is injective. -/
 lemma lTensor_inj_iff_rTensor_inj {N P : Type*} [AddCommGroup N] [AddCommGroup P] [Module R N]
@@ -173,18 +164,12 @@ lemma of_linearEquiv [f : Flat R M] (e : N ≃ₗ[R] M) : Flat R N := by
   have h : e.symm.toLinearMap.comp e.toLinearMap = LinearMap.id := by simp
   exact of_retract _ _ _ e.toLinearMap e.symm.toLinearMap h
 
-end Flat
-
-namespace Flat
-
-open DirectSum LinearMap Submodule
-
-variable (R : Type u) [CommRing R]
+open DirectSum
 
 /-- 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
+  haveI := Classical.decEq ΞΉ
   rw [iff_rTensor_injective]
   intro I hI
   -- This instance was added during PR #10828,
@@ -227,11 +212,9 @@ instance directSum (ΞΉ : Type v) (M : ΞΉ β†’ Type w) [(i : ΞΉ) β†’ AddCommGroup
 
 /-- Free `R`-modules over discrete types are flat. -/
 instance finsupp (ΞΉ : Type v) : Flat R (ΞΉ β†’β‚€ R) :=
-  let _ := Classical.decEq ΞΉ
+  haveI := Classical.decEq ΞΉ
   of_linearEquiv R _ _ (finsuppLEquivDirectSum R R ΞΉ)
 
-variable (M : Type v) [AddCommGroup M] [Module R M]
-
 instance of_free [Free R M] : Flat R M := of_linearEquiv R _ _ (Free.repr R M)
 
 /-- A projective module with a discrete type of generator is flat -/
feat: generalize direct sum results to avoid negation (#10828)

Three files are modified, where the hypotheses are relaxed from Ring or CommRing to Semiring or CommSemiring, and AddCommGroup to AddCommMonoid. Besides this, no definition is changed, and for one proof in RingTheory.Flat.Basic, I needed to add an instance (letI…) in the proof. (Everything pertains to direct sums of modules.)

Co-authored-by: Antoine Chambert-Loir <antoine.chambert-loir@math.univ-paris-diderot.fr> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -187,6 +187,9 @@ instance directSum (ΞΉ : Type v) (M : ΞΉ β†’ Type w) [(i : ΞΉ) β†’ AddCommGroup
   classical
   rw [iff_rTensor_injective]
   intro I hI
+  -- This instance was added during PR #10828,
+  -- see https://leanprover.zulipchat.com/#narrow/stream/144837-PR-reviews/topic/.2310828.20-.20generalizing.20CommRing.20to.20CommSemiring.20etc.2E/near/422684923
+  letI : βˆ€ i, AddCommGroup (I βŠ—[R] M i) := inferInstance
   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))
chore: remove terminal, terminal refines (#10762)

I replaced a few "terminal" refine/refine's with exact.

The strategy was very simple-minded: essentially any refine whose following line had smaller indentation got replaced by exact and then I cleaned up the mess.

This PR certainly leaves some further terminal refines, but maybe the current change is beneficial.

Diff
@@ -102,7 +102,7 @@ lemma iff_rTensor_injective :
     erw [← Equiv.comp_injective _ (TensorProduct.lid R M).toEquiv]
     have h₁ := F.out hI
     rw [← aux] at h₁
-    refine h₁
+    exact h₁
   Β· intro h₁
     constructor
     intro I hI
chore: remove stream-of-consciousness uses of have, replace and suffices (#10640)

No changes to tactic file, it's just boring fixes throughout the library.

This follows on from #6964.

Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -155,8 +155,8 @@ lemma of_retract [f : Flat R M] (i : N β†’β‚—[R] M) (r : M β†’β‚—[R] N) (h : r.c
     Flat R N := by
   rw [iff_rTensor_injective] at *
   intro I hI
-  have h₁ : Function.Injective (lTensor R i)
-  Β· apply Function.RightInverse.injective (g := (lTensor R r))
+  have h₁ : Function.Injective (lTensor R i) := by
+    apply Function.RightInverse.injective (g := (lTensor R r))
     intro x
     rw [← LinearMap.comp_apply, ← lTensor_comp, h]
     simp
@@ -199,8 +199,8 @@ instance directSum (ΞΉ : Type v) (M : ΞΉ β†’ Type w) [(i : ΞΉ) β†’ AddCommGroup
   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
+  have h₁ : βˆ€ (i : ΞΉ), (Ο€ i).comp ((η₁.comp ρ).comp ψ) = (Ξ· i).comp ((Ο† i).comp (Ο„ i)) := by
+    intro i
     apply DirectSum.linearMap_ext
     intro j
     apply TensorProduct.ext'
chore(RingTheory/Flat): remove finished TODOs (#10221)
Diff
@@ -44,10 +44,6 @@ This result is not yet formalised.
   To do this, it is probably a good idea to think about a suitable
   categorical induction principle that should be applied to the category of `R`-modules,
   and that will take care of the administrative side of the proof.
-* Define flat `R`-algebras
-* Define flat ring homomorphisms
-  - Show that the identity is flat
-  - Show that composition of flat morphisms is flat
 * Show that flatness is stable under base change (aka extension of scalars)
   For base change, it will be very useful to have a "characteristic predicate"
   instead of relying on the construction `A βŠ— B`.
feat(RingTheory/Flat): definition of flat ring homomorphism and stability under composition (#10148)

Adds the definition of flat algebras, flat ring homomorphisms and shows that flatness is stable under composition.

Diff
@@ -128,6 +128,30 @@ theorem iff_rTensor_injective' :
   letI : AddCommGroup (J βŠ—[R] M) := inferInstance -- Type class reminder
   rw [(injective_iff_map_eq_zero _).mp (h hfg) y hxβ‚€, _root_.map_zero]
 
+/-- Given a linear map `f : N β†’ P`, `f βŠ— M` is injective if and only if `M βŠ— f` is injective. -/
+lemma lTensor_inj_iff_rTensor_inj {N P : Type*} [AddCommGroup N] [AddCommGroup P] [Module R N]
+    [Module R P] (f : N β†’β‚—[R] P) :
+    Injective (lTensor M f) ↔ Injective (rTensor M f) := by
+  haveI h1 : rTensor M f βˆ˜β‚— TensorProduct.comm R M N =
+    TensorProduct.comm R M P βˆ˜β‚— lTensor M f := ext rfl
+  haveI h2 : ⇑(TensorProduct.comm R M P) ∘ ⇑(lTensor M f) =
+    (TensorProduct.comm R M P) βˆ˜β‚— (lTensor M f) := rfl
+  simp only [← EquivLike.injective_comp (TensorProduct.comm R M N),
+    ← EquivLike.comp_injective _ (TensorProduct.comm R M P), h2, ← h1]
+  trivial
+
+/-- The `lTensor`-variant of `iff_rTensor_injective`. .-/
+theorem iff_lTensor_injective :
+    Module.Flat R M ↔ βˆ€ ⦃I : Ideal R⦄ (_ : I.FG), Injective (lTensor M I.subtype) := by
+  simp only [lTensor_inj_iff_rTensor_inj]
+  exact Module.Flat.iff_rTensor_injective R M
+
+/-- The `lTensor`-variant of `iff_rTensor_injective'`. .-/
+theorem iff_lTensor_injective' :
+    Module.Flat R M ↔ βˆ€ (I : Ideal R), Injective (lTensor M I.subtype) := by
+  simp only [lTensor_inj_iff_rTensor_inj]
+  exact Module.Flat.iff_rTensor_injective' R M
+
 variable (N : Type w) [AddCommGroup N] [Module R N]
 
 /-- A retract of a flat `R`-module is flat. -/
chore: reduce imports (#9830)

This uses the improved shake script from #9772 to reduce imports across mathlib. The corresponding noshake.json file has been added to #9772.

Co-authored-by: Mario Carneiro <di.gama@gmail.com>

Diff
@@ -3,12 +3,12 @@ Copyright (c) 2020 Johan Commelin. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Johan Commelin
 -/
-import Mathlib.RingTheory.Noetherian
 import Mathlib.Algebra.DirectSum.Module
 import Mathlib.Algebra.DirectSum.Finsupp
+import Mathlib.Algebra.Module.Projective
 import Mathlib.LinearAlgebra.DirectSum.TensorProduct
 import Mathlib.LinearAlgebra.FreeModule.Basic
-import Mathlib.Algebra.Module.Projective
+import Mathlib.RingTheory.Finiteness
 
 #align_import ring_theory.flat from "leanprover-community/mathlib"@"62c0a4ef1441edb463095ea02a06e87f3dfe135c"
 
chore: space after ← (#8178)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -141,7 +141,7 @@ lemma of_retract [f : Flat R M] (i : N β†’β‚—[R] M) (r : M β†’β‚—[R] N) (h : r.c
     rw [← LinearMap.comp_apply, ← lTensor_comp, h]
     simp
   rw [← Function.Injective.of_comp_iff h₁ (rTensor N I.subtype), ← LinearMap.coe_comp]
-  rw [LinearMap.lTensor_comp_rTensor, ←LinearMap.rTensor_comp_lTensor]
+  rw [LinearMap.lTensor_comp_rTensor, ← LinearMap.rTensor_comp_lTensor]
   rw [LinearMap.coe_comp, Function.Injective.of_comp_iff (f hI)]
   apply Function.RightInverse.injective (g := lTensor _ r)
   intro x
Extend RingTheory.Flat.iff_rTensor_injective to all ideals (#8494)

Extend RingTheory.Flat.iff_rTensor_injective to all ideals

Using an elementary argument after Dummit and Foote (2004, Ex. 10.25)

Diff
@@ -93,11 +93,14 @@ instance self (R : Type u) [CommRing R] : Flat R R :=
 
 variable (M : Type v) [AddCommGroup M] [Module R M]
 
+/-- An `R`-module `M` is flat iff for all finitely generated ideals `I` of `R`, the
+tensor product of the inclusion `I β†’ R` and the identity `M β†’ M` is injective. See
+`iff_rTensor_injective'` to extend to all ideals `I`. --/
 lemma iff_rTensor_injective :
-    Flat R M ↔ (βˆ€ ⦃I : Ideal R⦄ (_ : I.FG), Injective (rTensor M I.subtype)) := by
-  have aux : βˆ€ (I : Ideal R), ((TensorProduct.lid R M).comp (rTensor M I.subtype)) =
-    (TensorProduct.lift ((lsmul R M).comp I.subtype))
-  Β· intro I; apply TensorProduct.ext'; intro x y; simp
+    Flat R M ↔ βˆ€ ⦃I : Ideal R⦄ (_ : I.FG), Injective (rTensor M I.subtype) := by
+  have aux : βˆ€ I : Ideal R, (TensorProduct.lid R M).comp (rTensor M I.subtype) =
+      TensorProduct.lift ((lsmul R M).comp I.subtype) := by
+    intro I; apply TensorProduct.ext'; intro x y; simp
   constructor
   Β· intro F I hI
     erw [← Equiv.comp_injective _ (TensorProduct.lid R M).toEquiv]
@@ -110,6 +113,21 @@ lemma iff_rTensor_injective :
     rw [← aux]
     simp [h₁ hI]
 
+/-- An `R`-module `M` is flat iff for all ideals `I` of `R`, the tensor product of the
+inclusion `I β†’ R` and the identity `M β†’ M` is injective. See `iff_rTensor_injective` to
+restrict to finitely generated ideals `I`. --/
+theorem iff_rTensor_injective' :
+    Flat R M ↔ βˆ€ I : Ideal R, Injective (rTensor M I.subtype) := by
+  rewrite [Flat.iff_rTensor_injective]
+  refine ⟨fun h I => ?_, fun h I _ => h I⟩
+  letI : AddCommGroup (I βŠ—[R] M) := inferInstance -- Type class reminder
+  rewrite [injective_iff_map_eq_zero]
+  intro x hxβ‚€
+  obtain ⟨J, hfg, hle, y, rfl⟩ := exists_fg_le_eq_rTensor_inclusion x
+  rewrite [← rTensor_comp_apply] at hxβ‚€
+  letI : AddCommGroup (J βŠ—[R] M) := inferInstance -- Type class reminder
+  rw [(injective_iff_map_eq_zero _).mp (h hfg) y hxβ‚€, _root_.map_zero]
+
 variable (N : Type w) [AddCommGroup N] [Module R N]
 
 /-- A retract of a flat `R`-module is flat. -/
style: add missing spaces around colons (#8293)

This is not exhaustive

Diff
@@ -174,7 +174,7 @@ instance directSum (ΞΉ : Type v) (M : ΞΉ β†’ Type w) [(i : ΞΉ) β†’ AddCommGroup
     Β· subst j; simp
     Β· simp [hβ‚‚]
   intro a ha; rw [DirectSum.ext_iff R]; intro i
-  have f := LinearMap.congr_arg (f:= (Ο€ i)) ha
+  have f := LinearMap.congr_arg (f := (Ο€ i)) ha
   erw [LinearMap.congr_fun (h₁ i) a] at f
   rw [(map_zero (Ο€ i) : (Ο€ i) 0 = (0 : M i))] at f
   have hβ‚‚ := (F i)
feat(RingTheory/Flat): free and projective modules over a CommRing are flat (#7567)

Prove that flat modules are stable under retracts, isomorphisms and direct sums. Use this to deduce that free and projective modules are flat.

Co-authored-by: Robin Carlier <robin.carlier@ens-lyon.fr> Co-authored-by: Andrew Yang <36414270+erdOne@users.noreply.github.com> Co-authored-by: Johan Commelin <johan@commelin.net>

Diff
@@ -4,6 +4,11 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Johan Commelin
 -/
 import Mathlib.RingTheory.Noetherian
+import Mathlib.Algebra.DirectSum.Module
+import Mathlib.Algebra.DirectSum.Finsupp
+import Mathlib.LinearAlgebra.DirectSum.TensorProduct
+import Mathlib.LinearAlgebra.FreeModule.Basic
+import Mathlib.Algebra.Module.Projective
 
 #align_import ring_theory.flat from "leanprover-community/mathlib"@"62c0a4ef1441edb463095ea02a06e87f3dfe135c"
 
@@ -23,6 +28,14 @@ This result is not yet formalised.
 
 * `Module.Flat`: the predicate asserting that an `R`-module `M` is flat.
 
+## Main theorems
+
+* `Module.Flat.of_retract`: retracts of flat modules are flat
+* `Module.Flat.of_linearEquiv`: modules linearly equivalent to a flat modules are flat
+* `Module.Flat.directSum`: arbitrary direct sums of flat modules are flat
+* `Module.Flat.of_free`: free modules are flat
+* `Module.Flat.of_projective`: projective modules are flat
+
 ## TODO
 
 * Show that tensoring with a flat module preserves injective morphisms.
@@ -46,13 +59,13 @@ This result is not yet formalised.
 -/
 
 
-universe u v
+universe u v w
 
 namespace Module
 
-open Function (Injective)
+open Function (Injective Surjective)
 
-open LinearMap (lsmul)
+open LinearMap (lsmul rTensor lTensor)
 
 open TensorProduct
 
@@ -64,7 +77,9 @@ class Flat (R : Type u) (M : Type v) [CommRing R] [AddCommGroup M] [Module R M]
 
 namespace Flat
 
-open TensorProduct LinearMap Submodule
+variable (R : Type u) [CommRing R]
+
+open LinearMap Submodule
 
 instance self (R : Type u) [CommRing R] : Flat R R :=
   ⟨by
@@ -76,6 +91,120 @@ instance self (R : Type u) [CommRing R] : Flat R R :=
       lift.tmul, Submodule.subtype_apply, Algebra.id.smul_eq_mul, lsmul_apply]⟩
 #align module.flat.self Module.Flat.self
 
+variable (M : Type v) [AddCommGroup M] [Module R M]
+
+lemma iff_rTensor_injective :
+    Flat R M ↔ (βˆ€ ⦃I : Ideal R⦄ (_ : I.FG), Injective (rTensor M I.subtype)) := by
+  have aux : βˆ€ (I : Ideal R), ((TensorProduct.lid R M).comp (rTensor M I.subtype)) =
+    (TensorProduct.lift ((lsmul R M).comp I.subtype))
+  Β· intro I; apply TensorProduct.ext'; intro x y; simp
+  constructor
+  Β· intro F I hI
+    erw [← Equiv.comp_injective _ (TensorProduct.lid R M).toEquiv]
+    have h₁ := F.out hI
+    rw [← aux] at h₁
+    refine h₁
+  Β· intro h₁
+    constructor
+    intro I hI
+    rw [← aux]
+    simp [h₁ hI]
+
+variable (N : Type w) [AddCommGroup N] [Module R N]
+
+/-- A retract of a flat `R`-module is flat. -/
+lemma of_retract [f : Flat R M] (i : N β†’β‚—[R] M) (r : M β†’β‚—[R] N) (h : r.comp i = LinearMap.id) :
+    Flat R N := by
+  rw [iff_rTensor_injective] at *
+  intro I hI
+  have h₁ : Function.Injective (lTensor R i)
+  Β· apply Function.RightInverse.injective (g := (lTensor R r))
+    intro x
+    rw [← LinearMap.comp_apply, ← lTensor_comp, h]
+    simp
+  rw [← Function.Injective.of_comp_iff h₁ (rTensor N I.subtype), ← LinearMap.coe_comp]
+  rw [LinearMap.lTensor_comp_rTensor, ←LinearMap.rTensor_comp_lTensor]
+  rw [LinearMap.coe_comp, Function.Injective.of_comp_iff (f hI)]
+  apply Function.RightInverse.injective (g := lTensor _ r)
+  intro x
+  rw [← LinearMap.comp_apply, ← lTensor_comp, h]
+  simp
+
+/-- A `R`-module linearly equivalent to a flat `R`-module is flat. -/
+lemma of_linearEquiv [f : Flat R M] (e : N ≃ₗ[R] M) : Flat R N := by
+  have h : e.symm.toLinearMap.comp e.toLinearMap = LinearMap.id := by simp
+  exact of_retract _ _ _ e.toLinearMap e.symm.toLinearMap h
+
+end Flat
+
+namespace Flat
+
+open DirectSum LinearMap Submodule
+
+variable (R : Type u) [CommRing R]
+
+/-- 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
+    apply DirectSum.linearMap_ext
+    intro j
+    apply TensorProduct.ext'
+    intro a m
+    simp only [coe_comp, LinearEquiv.coe_coe, Function.comp_apply, directSumRight_symm_lof_tmul,
+      rTensor_tmul, coeSubtype, lid_tmul, map_smul]
+    rw [DirectSum.component.of, DirectSum.component.of]
+    by_cases hβ‚‚ : j = i
+    Β· subst j; simp
+    Β· simp [hβ‚‚]
+  intro a ha; rw [DirectSum.ext_iff R]; intro i
+  have f := LinearMap.congr_arg (f:= (Ο€ i)) ha
+  erw [LinearMap.congr_fun (h₁ i) a] at f
+  rw [(map_zero (Ο€ i) : (Ο€ i) 0 = (0 : M i))] at f
+  have hβ‚‚ := (F i)
+  rw [iff_rTensor_injective] at hβ‚‚
+  have h₃ := hβ‚‚ hI
+  simp only [coe_comp, LinearEquiv.coe_coe, Function.comp_apply, AddEquivClass.map_eq_zero_iff,
+    h₃, LinearMap.map_eq_zero_iff] at f
+  simp [f]
+
+/-- Free `R`-modules over discrete types are flat. -/
+instance finsupp (ΞΉ : Type v) : Flat R (ΞΉ β†’β‚€ R) :=
+  let _ := Classical.decEq ΞΉ
+  of_linearEquiv R _ _ (finsuppLEquivDirectSum R R ΞΉ)
+
+variable (M : Type v) [AddCommGroup M] [Module R M]
+
+instance of_free [Free R M] : Flat R M := of_linearEquiv R _ _ (Free.repr R M)
+
+/-- A projective module with a discrete type of generator is flat -/
+lemma of_projective_surjective (ΞΉ : Type w) [Projective R M] (p : (ΞΉ β†’β‚€ R) β†’β‚—[R] M)
+    (hp : Surjective p) : Flat R M := by
+  have h := Module.projective_lifting_property p (LinearMap.id) hp
+  cases h with
+    | _ e he => exact of_retract R _ _ _ _ he
+
+instance of_projective [h : Projective R M] : Flat R M := by
+  rw [Module.projective_def'] at h
+  cases h with
+    | _ e he => exact of_retract R _ _ _ _ he
+
 end Flat
 
 end Module
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,14 +2,11 @@
 Copyright (c) 2020 Johan Commelin. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Johan Commelin
-
-! This file was ported from Lean 3 source module ring_theory.flat
-! leanprover-community/mathlib commit 62c0a4ef1441edb463095ea02a06e87f3dfe135c
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.RingTheory.Noetherian
 
+#align_import ring_theory.flat from "leanprover-community/mathlib"@"62c0a4ef1441edb463095ea02a06e87f3dfe135c"
+
 /-!
 # Flat modules
 
chore: reenable eta, bump to nightly 2023-05-16 (#3414)

Now that leanprover/lean4#2210 has been merged, this PR:

  • removes all the set_option synthInstance.etaExperiment true commands (and some etaExperiment% term elaborators)
  • removes many but not quite all set_option maxHeartbeats commands
  • makes various other changes required to cope with leanprover/lean4#2210.

Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Matthew Ballard <matt@mrb.email>

Diff
@@ -69,7 +69,6 @@ namespace Flat
 
 open TensorProduct LinearMap Submodule
 
-set_option synthInstance.etaExperiment true in
 instance self (R : Type u) [CommRing R] : Flat R R :=
   ⟨by
     intro I _
Diff
@@ -62,7 +62,7 @@ open TensorProduct
 /-- An `R`-module `M` is flat if for all finitely generated ideals `I` of `R`,
 the canonical map `I βŠ— M β†’β‚— M` is injective. -/
 class Flat (R : Type u) (M : Type v) [CommRing R] [AddCommGroup M] [Module R M] : Prop where
-  out : βˆ€ ⦃I : Ideal R⦄ (_ : I.Fg), Injective (TensorProduct.lift ((lsmul R M).comp I.subtype))
+  out : βˆ€ ⦃I : Ideal R⦄ (_ : I.FG), Injective (TensorProduct.lift ((lsmul R M).comp I.subtype))
 #align module.flat Module.Flat
 
 namespace Flat
chore: use etaExperiment rather than hacking with instances (#3668)

This is to fix timeouts in https://github.com/leanprover-community/mathlib4/pull/3552.

See discussion at https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/!4.233552.20.28LinearAlgebra.2EMatrix.2EToLin.29.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -69,6 +69,7 @@ namespace Flat
 
 open TensorProduct LinearMap Submodule
 
+set_option synthInstance.etaExperiment true in
 instance self (R : Type u) [CommRing R] : Flat R R :=
   ⟨by
     intro I _
feat: port RingTheory.Flat (#3009)

Co-authored-by: Parcly Taxel <reddeloostw@gmail.com>

Dependencies 8 + 463

464 files ported (98.3%)
190801 lines ported (98.4%)
Show graph

The unported dependencies are