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] - chore(algebra/ring/basic): generalize is_domain.to_cancel_monoid_with_zero to no_zero_divisors #11387

Closed
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
18 changes: 13 additions & 5 deletions src/algebra/ring/basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,18 @@ lemma is_regular_of_ne_zero' [ring α] [no_zero_divisors α] {k : α} (hk : k
is_right_regular_of_non_zero_divisor k
(λ x h, (no_zero_divisors.eq_zero_or_eq_zero_of_mul_eq_zero h).resolve_right hk)⟩

/-- A ring with no zero divisors is a cancel_monoid_with_zero.

Note this is not an instance as it forms a typeclass loop. -/
@[reducible]
def no_zero_divisors.to_cancel_monoid_with_zero [ring α] [no_zero_divisors α] :
cancel_monoid_with_zero α :=
{ mul_left_cancel_of_ne_zero := λ a b c ha,
@is_regular.left _ _ _ (is_regular_of_ne_zero' ha) _ _,
mul_right_cancel_of_ne_zero := λ a b c hb,
@is_regular.right _ _ _ (is_regular_of_ne_zero' hb) _ _,
.. (infer_instance : semiring α) }

/-- A domain is a nontrivial ring with no zero divisors, i.e. satisfying
the condition `a * b = 0 ↔ a = 0 ∨ b = 0`.

Expand All @@ -1046,11 +1058,7 @@ variables [ring α] [is_domain α]

@[priority 100] -- see Note [lower instance priority]
instance is_domain.to_cancel_monoid_with_zero : cancel_monoid_with_zero α :=
{ mul_left_cancel_of_ne_zero := λ a b c ha,
@is_regular.left _ _ _ (is_regular_of_ne_zero' ha) _ _,
mul_right_cancel_of_ne_zero := λ a b c hb,
@is_regular.right _ _ _ (is_regular_of_ne_zero' hb) _ _,
.. (infer_instance : semiring α) }
no_zero_divisors.to_cancel_monoid_with_zero

/-- Pullback an `is_domain` instance along an injective function. -/
protected theorem function.injective.is_domain [ring β] (f : β →+* α) (hf : injective f) :
Expand Down