Zulip Chat Archive

Stream: Is there code for X?

Topic: For a Dedekind domain, UFD implies PID


Raphael Douglas Giles (Oct 29 2025 at 14:30):

For Dedekind domains, being a UFD and being a PID are equivalent. This doesn't seem to be in mathlib yet as far as I can tell. Does anyone have this lying around in a ForMathlib folder somewhere?

Riccardo Brasca (Oct 29 2025 at 14:41):

Not sure if someone has this, but it should be quite easy, we have everything is needed, in particular the fact that it is enough to prove that prime ideals are principal.

Kenny Lau (Oct 29 2025 at 14:59):

import Mathlib.RingTheory.DedekindDomain.Dvr
import Mathlib.RingTheory.PrincipalIdealDomainOfPrime

theorem PID_of_UFD_of_dedekind (R : Type*) [CommRing R]
    [IsDedekindDomain R] [UniqueFactorizationMonoid R] :
    IsPrincipalIdealRing R := by
  refine .of_prime fun P hp  ?_
  by_cases hp₀ : P = 
  · rw [hp₀]
    infer_instance
  obtain x, hx₁, hx₂ := hp.exists_mem_prime_of_ne_bot hp₀
  suffices Ideal.span {x} = P by
    rw [ this]
    infer_instance
  have h₁ : (Ideal.span {x}).IsPrime := (Ideal.span_singleton_prime hx₂.ne_zero).mpr hx₂
  have h₂ := h₁.isMaximal (by simpa using hx₂.ne_zero)
  exact h₂.eq_of_le hp.ne_top <| (Ideal.span_singleton_le_iff_mem _).mpr hx₁

#min_imports

Kenny Lau (Oct 29 2025 at 14:59):

@Riccardo Brasca which file would this go to?

Riccardo Brasca (Oct 29 2025 at 15:00):

What does find_home! says?

Riccardo Brasca (Oct 29 2025 at 15:00):

Now I am curious to see if I can find a better proof :)

Riccardo Brasca (Oct 29 2025 at 15:00):

it seems longer than I thought

Kenny Lau (Oct 29 2025 at 15:01):

Riccardo Brasca said:

What does find_home! says?

Mathlib

Kenny Lau (Oct 29 2025 at 15:02):

i guess i can make a new file within DedekindDomain/

Riccardo Brasca (Oct 29 2025 at 15:07):

import Mathlib

variable {R : Type*} [CommRing R] [IsDedekindDomain R] [UniqueFactorizationMonoid R]

open Ideal

lemma foo : IsPrincipalIdealRing R := by
  refine IsPrincipalIdealRing.of_prime (fun p hp  ?_)
  by_cases h0 : p = 
  · exact h0  bot_isPrincipal
  obtain x, hxmem, hxprime := hp.exists_mem_prime_of_ne_bot h0
  refine x, (IsMaximal.eq_of_le ?_ hp.ne_top (span_le.2 (by simp [hxmem]))).symm
  refine Ring.DimensionLEOne.maximalOfPrime (by simpa using hxprime.ne_zero)
    ((span_singleton_prime hxprime.ne_zero).2 hxprime)

Riccardo Brasca (Oct 29 2025 at 15:07):

But find_home! still says mathlib, so a new file is probably a good idea.

Riccardo Brasca (Oct 29 2025 at 15:08):

Anyway we can improve IsPrincipalIdealRing.of_prime doing the bot case

Riccardo Brasca (Oct 29 2025 at 15:11):

I realize it's literally the same proof, sorry I couldn't resist writing one myself.

Kenny Lau (Oct 29 2025 at 15:12):

import Mathlib

theorem PID_of_UFD_of_dedekind (R : Type*) [CommRing R]
    [IsDedekindDomain R] [UniqueFactorizationMonoid R] :
    IsPrincipalIdealRing R := by
  refine .of_prime fun P hp  (eq_or_ne P ).elim (·  inferInstance) fun hp₀  ?_
  obtain x, hx₁, hx₂ := hp.exists_mem_prime_of_ne_bot hp₀
  have := (Ideal.span_singleton_prime hx₂.ne_zero).mpr hx₂
  exact (Ring.DimensionLeOne.prime_le_prime_iff_eq (by simp [hx₂.ne_zero])).mp
    ((Ideal.span_singleton_le_iff_mem _).mpr hx₁)  inferInstance

I tried to do trivial (and vertical) golfing on my proof

Riccardo Brasca (Oct 29 2025 at 15:13):

If you open a PR please modify the statement of IsPrincipalIdealRing.of_prime.

Kenny Lau (Oct 29 2025 at 15:35):

@Riccardo Brasca #31061


Last updated: Dec 20 2025 at 21:32 UTC