Zulip Chat Archive
Stream: Is there code for X?
Topic: NoZeroDivisors iff IsDomain or Subsingleton
Xavier Xarles (Jan 02 2024 at 20:00):
I need this elementary lemma (I have a proof, but surely too long).
import Mathlib.Algebra.Ring.Basic
lemma NoZeroDivisors_iff_IsDomain_or_Subsingleton (L : Type*) [Ring L]:
NoZeroDivisors L ↔ (IsDomain L ∨ Subsingleton L) := by sorry
Eric Rodriguez (Jan 02 2024 at 20:10):
lemma NoZeroDivisors_iff_IsDomain_or_Subsingleton (L : Type*) [Ring L]: NoZeroDivisors L ↔ (IsDomain L ∨ Subsingleton L) := by
refine ⟨fun t ↦ ?_, fun h ↦ h.elim (fun _ ↦ inferInstance) (fun _ ↦ sorry)⟩
rw [or_iff_not_imp_right, not_subsingleton_iff_nontrivial]
exact fun _ ↦ t.to_isDomain
where the sorry
is that Subsingleton rings are NZDs, I couldn't seem to find that quickly oddly
Xavier Xarles (Jan 02 2024 at 20:22):
That was the same place I was stuck. Of course one can prove it, but it seems it should be more elementary...
Eric Rodriguez (Jan 02 2024 at 20:28):
doesn't seem to exist oddly
Antoine Chambert-Loir (Jan 02 2024 at 20:54):
Can be golfed, but everything is more or less there
import Mathlib.Tactic
import Mathlib.Algebra.Ring.Defs
import Mathlib.Algebra.GroupWithZero.Defs
lemma NoZeroDivisors_iff_IsDomain_or_Subsingleton (L : Type*) [Ring L]:
NoZeroDivisors L ↔ (IsDomain L ∨ Subsingleton L) := by
constructor
· intro nzd
by_cases nt : Nontrivial L
· left
exact IsDomain.mk
· simp only [not_nontrivial_iff_subsingleton] at nt
exact Or.inr nt
· intro h
cases' h with isd ss
· exact IsDomain.to_noZeroDivisors L
· apply NoZeroDivisors.mk
intro a _ _
left
exact Subsingleton.eq_zero a
Antoine Chambert-Loir (Jan 02 2024 at 21:03):
lemma NoZeroDivisors_iff_IsDomain_or_Subsingleton (L : Type*) [Ring L]: NoZeroDivisors L ↔ (IsDomain L ∨ Subsingleton L) := by
refine ⟨fun t ↦ ?_, fun h ↦ h.elim (fun _ ↦ inferInstance) (fun _ ↦ NoZeroDivisors.mk (fun _ => Or.inl (Subsingleton.eq_zero _)))⟩
rw [or_iff_not_imp_right, not_subsingleton_iff_nontrivial]
exact fun _ ↦ t.to_isDomain
Eric Wieser (Jan 02 2024 at 21:43):
This lemma might help:
lemma isDomain_iff_noZeroDivisors_and_nontrivial (L : Type*) [Ring L]:
IsDomain L ↔ (NoZeroDivisors L ∧ Nontrivial L) :=
⟨fun _ => ⟨inferInstance, inferInstance⟩, fun ⟨_, _⟩ => {}⟩
Antoine Chambert-Loir (Jan 02 2024 at 22:03):
What seems to be missing is the instance that a trivial ring has no zero divisors
instance (L : Type*) [Ring L] [Subsingleton L] : NoZeroDivisors L :=
NoZeroDivisors.mk (fun _ => Or.inl (Subsingleton.eq_zero _))
Antoine Chambert-Loir (Jan 02 2024 at 22:27):
Funnily, trying to apply lazily your lemma led me to
example (L : Type*) [Ring L]:
NoZeroDivisors L ↔ (IsDomain L ∨ Subsingleton L) := by
classical
rw [isDomain_iff_noZeroDivisors_and_nontrivial, ← not_nontrivial_iff_subsingleton]
generalize NoZeroDivisors L = p
generalize Nontrivial L = q
sorry -- p ↔ (p ∧ q) ∨ ¬q does not hold
Eric Wieser (Jan 02 2024 at 22:31):
That instance looks like a performance issue to me, but maybe I'm wrong
Eric Wieser (Jan 02 2024 at 22:31):
It should certainly be a lemma if nothing else
Antoine Chambert-Loir (Jan 03 2024 at 08:29):
There's probably very little chance that this lemma has to be found automatically by the TypeClass inference system.
Xavier Xarles (Jan 03 2024 at 10:56):
Do you think it is a good idea to do a PR with some of these?
Xavier Xarles (Jan 03 2024 at 12:18):
Done #9407
But there is a problem with the cache.
Yaël Dillies (Jan 03 2024 at 12:21):
For the cache, see https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/The.20cache.20doesn't.20work
Antoine Chambert-Loir (Jan 03 2024 at 12:23):
While we're at it, it would probably be a good thing to give the proofs for all properties of rings (modules, spaces…) which are introduced in mathlib when they hold for the trivial ring (module, space…).
Yaël Dillies (Jan 03 2024 at 12:25):
Not necessarily, since that would create diamonds. NoZeroDivisors
is alright because it's Prop-valued.
Antoine Chambert-Loir (Jan 03 2024 at 12:25):
(For example, docs#isNoetherian_of_subsingleton exists, but not isArtinian_of_subsingleton
, nor the fact that the zero module is noetherian…)
Antoine Chambert-Loir (Jan 03 2024 at 12:26):
Not necessarily as instances. Just the theorems when they hold.
Junyan Xu (Jan 03 2024 at 16:27):
We already have docs#isArtinian_of_finite though
Last updated: May 02 2025 at 03:31 UTC