Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Mathlib/LinearAlgebra/Dimension/Free.lean
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ theorem rank_mul_rank (A : Type v) [AddCommMonoid A]
convert! lift_rank_mul_lift_rank F K A <;> rw [lift_id]

/-- Tower law: if `A` is a `K`-module and `K` is an extension of `F` then
$\operatorname{rank}_F(A) = \operatorname{rank}_F(K) * \operatorname{rank}_K(A)$. -/
$\operatorname{rank}_F(A) = \operatorname{rank}_F(K) * \operatorname{rank}_K(A)$.
See `Module.finrank_mul_finrank'` for a variant over a tower of domains that assumes the rings are
module-finite rather than the modules being free. -/
theorem Module.finrank_mul_finrank : finrank F K * finrank K A = finrank F A := by
simp_rw [finrank]
rw [← toNat_lift.{w} (Module.rank F K), ← toNat_lift.{v} (Module.rank K A), ← toNat_mul,
Expand Down
22 changes: 19 additions & 3 deletions Mathlib/RingTheory/Algebraic/Integral.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ Authors: Johan Commelin
-/
module

public import Mathlib.Algebra.Ring.Hom.InjSurj
public import Mathlib.LinearAlgebra.Dimension.Localization
public import Mathlib.RingTheory.Algebraic.Basic
public import Mathlib.RingTheory.IntegralClosure.IsIntegralClosure.Basic
public import Mathlib.RingTheory.Localization.BaseChange

import Mathlib.RingTheory.Polynomial.Subring
public import Mathlib.RingTheory.Polynomial.Subring

/-!
# Algebraic elements and integral elements
Expand Down Expand Up @@ -561,6 +560,23 @@ theorem rank_fractionRing [IsDomain S] :
Module.rank (FractionRing R) (FractionRing S) = Module.rank R S :=
rank_of_isFractionRing ..

attribute [local instance] FractionRing.liftAlgebra in
/-- Tower law for `Module.finrank` in a tower of domains `R → S → B` that is module-finite at each
step. This is a variant of `Module.finrank_mul_finrank` that assumes the rings are domains (and
module-finite) instead of the modules being free. -/
theorem _root_.Module.finrank_mul_finrank' (T : Type*) [CommRing T] [IsDomain T] [Algebra S T]
[Algebra R T] [IsScalarTower R S T]
[FaithfulSMul S T] [Module.Finite R S] [Module.Finite S T] :

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can replace the finiteness assumptions with [Algebra.IsAlgebraic S T] (since algebraic is transitive).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I haven't golfed this yet, but you can remove a lot of the assumptions from finrank_of_isFractionRing!

theorem _root_.Module.rank_eq_zero_of_not_faithfulSMul
    {R S : Type*} [Semiring R] [AddCommMonoid S] [Module R S]
    (h : ¬ FaithfulSMul R S) : Module.rank R S = 0 := by
  contrapose! h
  rw [← Cardinal.one_le_iff_ne_zero, Module.one_le_rank_iff] at h
  obtain ⟨f, hf⟩ := h
  refine ⟨fun {x y} h ↦ hf ?_⟩
  have := f.map_smul x 1
  have := f.map_smul y 1
  simp_all

theorem _root_.Module.finrank_eq_zero_of_not_faithfulSMul
    {R S : Type*} [Semiring R] [AddCommMonoid S] [Module R S]
    (h : ¬ FaithfulSMul R S) : Module.finrank R S = 0 :=
  Module.finrank_eq_zero_of_rank_eq_zero (Module.rank_eq_zero_of_not_faithfulSMul h)

theorem _root_.Transcendental.linearIndependent_pow
    {R S : Type*} [CommRing R] [CommRing S] [Algebra R S] {x : S}
    (h : Transcendental R x) : LinearIndependent R (x ^ ·) := by
  sorry

theorem _root_.Module.finrank_eq_zero_of_not_isAlgebraic
    {R S : Type*} [CommRing R] [Nontrivial R] [CommRing S] [Algebra R S]
    (h : ¬ Algebra.IsAlgebraic R S) : Module.finrank R S = 0 := by
  rw [Algebra.isAlgebraic_def, not_forall] at h
  obtain ⟨x, hx : Transcendental R x⟩ := h
  exact Cardinal.toNat_apply_of_aleph0_le hx.linearIndependent_pow.aleph0_le_rank

theorem _root_.Algebra.IsAlgebraic.finrank_of_isFractionRing' (R R' S S' : Type*)
    [CommRing R] [CommRing R'] [CommRing S] [CommRing S']
    [Algebra R S] [Algebra R R'] [Algebra S S'] [Algebra R' S'] [Algebra R S']
    [IsScalarTower R R' S'] [IsScalarTower R S S']
    [IsFractionRing R R'] [IsFractionRing S S']
    [NoZeroDivisors S] : Module.finrank R' S' = Module.finrank R S := by
  rcases iff_iff_and_or_not_and_not.mp (IsFractionRing.nontrivial_iff_nontrivial R R')
    with ⟨_, _⟩ | ⟨_, _⟩; swap
  · rw [not_nontrivial_iff_subsingleton] at *
    simp
  by_cases hfs : FaithfulSMul R S; swap
  · rw [Module.finrank_eq_zero_of_not_faithfulSMul hfs]
    replace hfs : ¬ FaithfulSMul R' S' := by
      contrapose! hfs
      rw [faithfulSMul_iff_algebraMap_injective] at *
      have : Function.Injective (algebraMap S S') := FaithfulSMul.algebraMap_injective S S'
      apply Function.Injective.of_comp (f := algebraMap S S')
      rw [← RingHom.coe_comp, ← IsScalarTower.algebraMap_eq,
        IsScalarTower.algebraMap_eq R R' S']
      apply hfs.comp
      exact FaithfulSMul.algebraMap_injective R R'
    rw [Module.finrank_eq_zero_of_not_faithfulSMul hfs]
  · have : NoZeroDivisors R := NoZeroDivisors.of_faithfulSMul R S
    have : NoZeroDivisors R' := IsLocalization.noZeroDivisors R⁰
    by_cases halg : Algebra.IsAlgebraic R S
    · apply finrank_of_isFractionRing
    · rw [Module.finrank_eq_zero_of_not_isAlgebraic halg]
      replace halg : ¬ Algebra.IsAlgebraic R' S' := by
        contrapose! halg
        have : Algebra.IsAlgebraic R R' := IsLocalization.isAlgebraic R' R⁰
        have : Algebra.IsAlgebraic R S' := Algebra.IsAlgebraic.trans R R' S'
        apply Algebra.IsAlgebraic.tower_bot_of_injective (R := R) (S := S) (A := S')
        exact FaithfulSMul.algebraMap_injective S S'
      rw [Module.finrank_eq_zero_of_not_isAlgebraic halg]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(although actually there might just be a more direct proof with localizations)

Module.finrank R S * Module.finrank S T = Module.finrank R T := by
have : FaithfulSMul R T := .trans R S T
have : IsDomain R := (FaithfulSMul.algebraMap_injective R T).isDomain
have : IsDomain S := (FaithfulSMul.algebraMap_injective S T).isDomain
have : Module.Finite R T := Module.Finite.trans S T
rw [← finrank_of_isFractionRing R (FractionRing R) S (FractionRing S),
← finrank_of_isFractionRing S (FractionRing S) T (FractionRing T),
← finrank_of_isFractionRing R (FractionRing R) T (FractionRing T),
Module.finrank_mul_finrank (FractionRing R) (FractionRing S) (FractionRing T)]

end Algebra.IsAlgebraic

section Polynomial
Expand Down
Loading