Skip to content

Commit

Permalink
chore(ring_theory/ideal/operations): generalise some typeclasses (#15200
Browse files Browse the repository at this point in the history
)

Using the generalisation linter mostly.

Some more changes are possible surrounding map / comap, but they involve more restructuring, and I want to explore the right definitions of map and comap separately.

All changes here are of the form: dropping commutativity, changing domain to no_zero_divisors (i.e. not assuming nontriviality), or dropping subtraction (ring to semiring).
  • Loading branch information
alexjbest committed Jul 15, 2022
1 parent 9c8bc91 commit f6e9ec3
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/ring_theory/ideal/operations.lean
Expand Up @@ -286,14 +286,21 @@ end submodule

namespace ideal

section add

variables {R : Type u} [semiring R]

@[simp] lemma add_eq_sup {I J : ideal R} : I + J = I ⊔ J := rfl
@[simp] lemma zero_eq_bot : (0 : ideal R) = ⊥ := rfl

end add

section mul_and_radical
variables {R : Type u} {ι : Type*} [comm_semiring R]
variables {I J K L : ideal R}

instance : has_mul (ideal R) := ⟨(•)⟩

@[simp] lemma add_eq_sup : I + J = I ⊔ J := rfl
@[simp] lemma zero_eq_bot : (0 : ideal R) = ⊥ := rfl
@[simp] lemma one_eq_top : (1 : ideal R) = ⊤ :=
by erw [submodule.one_eq_range, linear_map.range_id]

Expand Down Expand Up @@ -557,14 +564,14 @@ lemma pow_le_self {n : ℕ} (hn : n ≠ 0) : I^n ≤ I :=
calc I^n ≤ I ^ 1 : pow_le_pow (nat.pos_of_ne_zero hn)
... = I : pow_one _

lemma mul_eq_bot {R : Type*} [comm_ring R] [is_domain R] {I J : ideal R} :
lemma mul_eq_bot {R : Type*} [comm_semiring R] [no_zero_divisors R] {I J : ideal R} :
I * J = ⊥ ↔ I = ⊥ ∨ J = ⊥ :=
⟨λ hij, or_iff_not_imp_left.mpr (λ I_ne_bot, J.eq_bot_iff.mpr (λ j hj,
let ⟨i, hi, ne0⟩ := I.ne_bot_iff.mp I_ne_bot in
or.resolve_left (mul_eq_zero.mp ((I * J).eq_bot_iff.mp hij _ (mul_mem_mul hi hj))) ne0)),
λ h, by cases h; rw [← ideal.mul_bot, h, ideal.mul_comm]⟩

instance {R : Type*} [comm_ring R] [is_domain R] : no_zero_divisors (ideal R) :=
instance {R : Type*} [comm_semiring R] [no_zero_divisors R] : no_zero_divisors (ideal R) :=
{ eq_zero_or_eq_zero_of_mul_eq_zero := λ I J, mul_eq_bot.1 }

/-- A product of ideals in an integral domain is zero if and only if one of the terms is zero. -/
Expand Down Expand Up @@ -661,7 +668,7 @@ have is_prime m, from ⟨by rintro rfl; rw radical_top at hrm; exact hrm trivial
(m.mul_mem_left _ hxym))⟩⟩,
hrm $ this.radical.symm ▸ (Inf_le ⟨him, this⟩ : Inf {J : ideal R | I ≤ J ∧ is_prime J} ≤ m) hr

@[simp] lemma radical_bot_of_is_domain {R : Type u} [comm_ring R] [is_domain R] :
@[simp] lemma radical_bot_of_is_domain {R : Type u} [comm_semiring R] [no_zero_divisors R] :
radical (⊥ : ideal R) = ⊥ :=
eq_bot_iff.2 (λ x hx, hx.rec_on (λ n hn, pow_eq_zero hn))

Expand Down Expand Up @@ -736,7 +743,7 @@ theorem is_prime.inf_le' {s : finset ι} {f : ι → ideal R} {P : ideal R} (hp
⟨λ h, (hp.prod_le hsne).1 $ le_trans prod_le_inf h,
λ ⟨i, his, hip⟩, le_trans (finset.inf_le his) hip⟩

theorem subset_union {R : Type u} [comm_ring R] {I J K : ideal R} :
theorem subset_union {R : Type u} [ring R] {I J K : ideal R} :
(I : set R) ⊆ J ∪ K ↔ I ≤ J ∨ I ≤ K :=
⟨λ h, or_iff_not_imp_left.2 $ λ hij s hsi,
let ⟨r, hri, hrj⟩ := set.not_subset.1 hij in classical.by_contradiction $ λ hsk,
Expand Down Expand Up @@ -1387,7 +1394,7 @@ end is_primary

end ideal

lemma associates.mk_ne_zero' {R : Type*} [comm_ring R] {r : R} :
lemma associates.mk_ne_zero' {R : Type*} [comm_semiring R] {r : R} :
(associates.mk (ideal.span {r} : ideal R)) ≠ 0 ↔ (r ≠ 0):=
by rw [associates.mk_ne_zero, ideal.zero_eq_bot, ne.def, ideal.span_singleton_eq_bot]

Expand Down

0 comments on commit f6e9ec3

Please sign in to comment.