Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - feat(field_theory/cardinality): cardinality of fields & localizations #12285

Closed
wants to merge 15 commits into from
65 changes: 65 additions & 0 deletions src/field_theory/cardinality.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/-
Copyright (c) 2022 Eric Rodriguez. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Rodriguez
-/
import ring_theory.localization.cardinality
import algebra.is_prime_pow
import field_theory.finite.galois_field
import data.equiv.transfer_instance
import algebra.ring.ulift
import data.mv_polynomial.cardinal
import data.rat.denumerable

/-!
# Cardinality of Fields

In this file we show all the possible cardinalities of fields. All infinite cardinals can harbour
a field structure, and so can all types with prime power cardinalities, and this is sharp.

## Main statements

* `fintype.nonempty_field_iff`: A `fintype` can be given a field structure iff its cardinality is a
prime power.
* `infinite.nonempty_field` : Any infinite type can be endowed a field structure.

-/

local notation `‖` x `‖` := fintype.card x

open_locale cardinal non_zero_divisors

universe u

/-- A `fintype` can be given a field structure iff its cardinality is a prime power. -/
lemma fintype.nonempty_field_iff {α} [fintype α] :
nonempty (field α) ↔ is_prime_pow (‖α‖) :=
begin
ericrbg marked this conversation as resolved.
Show resolved Hide resolved
split,
swap,
{ rintros ⟨p, n, hp, hn, hα⟩,
haveI := fact.mk (nat.prime_iff.mpr hp),
exact ⟨(fintype.equiv_of_card_eq ((galois_field.card p n hn.ne').trans hα)).symm.field⟩ },
rintro ⟨h⟩,
casesI char_p.exists α with p _,
haveI hp := fact.mk (char_p.char_is_prime α p),
let b := is_noetherian.finset_basis (zmod p) α,
rw [module.card_fintype b, zmod.card, is_prime_pow_pow_iff],
{ exact hp.1.is_prime_pow },
rw ←finite_dimensional.finrank_eq_card_basis b,
exact finite_dimensional.finrank_pos.ne'
end

/-- Any infinite type can be endowed a field structure. -/
lemma infinite.nonempty_field {α : Type u} [infinite α] : nonempty (field α) :=
begin
letI K := fraction_ring (mv_polynomial α $ ulift.{u} ℚ),
suffices : #α = #K,
{ obtain ⟨e⟩ := cardinal.eq.1 this,
exact ⟨e.field⟩ },
rw ←is_localization.cardinal_mk K (le_refl (mv_polynomial α $ ulift.{u} ℚ)⁰),
apply le_antisymm,
{ refine ⟨⟨λ a, mv_polynomial.monomial (finsupp.single a 1) (1 : ulift.{u} ℚ), λ x y h, _⟩⟩,
simpa [mv_polynomial.monomial_eq_monomial_iff, finsupp.single_eq_single_iff] using h },
{ simpa using @mv_polynomial.cardinal_mk_le_max α (ulift.{u} ℚ) _ }
end
72 changes: 72 additions & 0 deletions src/ring_theory/localization/cardinality.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/-
Copyright (c) 2022 Eric Rodriguez. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Rodriguez
-/
import ring_theory.localization.basic
import set_theory.cardinal_ordinal
import ring_theory.integral_domain

/-!
# Cardinality of localizations

In this file, we establish the cardinality of localizations. In most cases, a localization has
cardinality equal to the base ring (even in the finite case!); however, this can be muddled by
zero-divisors.

## Main statements

* `is_localization.cardinal_mk`: All infinite localizations of rings at submonoids smaller than the
non-zero divisors have the same cardinality as the base ring.
* `is_localization.card`: All localizations of finite integral domains at submonoids not containing
zero have the same cardinality as the base domain.

## Implementation details

Note that in `is_localization.card`, the second `fintype` is not an instance, and is instead
provided by `is_localization.fintype' S L`.

-/


open_locale cardinal non_zero_divisors

universes u v

namespace is_localization

/-- All infinite localizations of rings at submonoids smaller than the non-zero divisors have the
same cardinality as the base ring. -/
lemma cardinal_mk {R : Type u} [comm_ring R] {S : submonoid R} (L : Type u) [comm_ring L]
[algebra R L] [infinite R] [is_localization S L] (hS : S ≤ R⁰) : #R = #L :=
begin
classical,
apply (cardinal.mk_le_of_injective (is_localization.injective L hS)).antisymm,
erw [←cardinal.mul_eq_self $ cardinal.omega_le_mk R],
let f : R × R → L := λ aa, is_localization.mk' _ aa.1 (if h : aa.2 ∈ S then ⟨aa.2, h⟩ else 1),
refine @cardinal.mk_le_of_surjective _ _ f (λ a, _),
obtain ⟨x, y, h⟩ := is_localization.mk'_surjective S a,
use (x, y),
dsimp [f],
rwa [dif_pos $ show ↑y ∈ S, from y.2, set_like.eta]
end

/-- All finite localizations of integral domains at submonoids not containing zero have the same
cardinality as the base domain. -/
lemma card {R : Type u} [comm_ring R] {S : submonoid R} {L : Type v} [comm_ring L] [algebra R L]
Copy link
Member

Choose a reason for hiding this comment

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

Can you generalize localization_map_bijective_of_field to integral domains and then prove this lemma directly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think this is true, right? the Z -> Q algebra map is clearly not bijective

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I meant for finite integral domains. So the literal statement you proved, just with a different formulation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, I see! Yes, I'll do that. I think the real missing glue is a way to automagically turn a finite ID into a field, so I'll add that

Copy link
Member

Choose a reason for hiding this comment

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

Or something like is_field_of_is_domain_of_fintype.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hmm, do you think I should split some stuff now with all these changes?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it's probably a good idea to open a smaller PR that only talk about fields and integral domains, without cardinality involved.

About cardinality, essentially the same proof shows that this is also the list of a cardinalities of integral domains.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added a couple of these leafs. I'll extend the proof to integral domains too!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, I realised that it's not so obvious to state this for integral domains, as integral domains are bundled. You'd have to have a spec lemma, and so on...

Copy link
Member

Choose a reason for hiding this comment

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

I see... don't bother too much about that

[fintype R] [is_domain R] [is_localization S L] (hS : ↑0 ∉ S) :
fintype.card R = @fintype.card L (fintype' S L) :=
begin
casesI subsingleton_or_nontrivial R,
{ haveI := unique R L S,
haveI := unique_of_subsingleton (0 : R),
simp },
letI := fintype' S L,
refine fintype.card_of_bijective
(localization_map_bijective_of_field hS ⟨nontrivial.exists_pair_ne, mul_comm, λ a ha, _⟩),
classical,
letI hG := group_with_zero_of_fintype R,
exact ⟨a⁻¹, mul_inv_cancel ha⟩
end

end is_localization