-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(Submonoid/Membership): don't import
MonoidWithZero
See #10327 for the new copyright header
- Loading branch information
1 parent
305df19
commit c2f8a51
Showing
15 changed files
with
313 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/- | ||
Copyright (c) 2022 Christopher Hoskin. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Christopher Hoskin | ||
-/ | ||
import Mathlib.Algebra.Group.Basic | ||
import Mathlib.Algebra.Group.Commute.Defs | ||
import Mathlib.Algebra.Group.Hom.Defs | ||
import Mathlib.Data.Subtype | ||
import Mathlib.Tactic.MinImports | ||
|
||
/-! | ||
# Idempotents | ||
This file defines idempotents for an arbitrary multiplication and proves some basic results, | ||
including: | ||
* `IsIdempotentElem.mul_of_commute`: In a semigroup, the product of two commuting idempotents is | ||
an idempotent; | ||
* `IsIdempotentElem.pow_succ_eq`: In a monoid `a ^ (n+1) = a` for `a` an idempotent and `n` a | ||
natural number. | ||
## Tags | ||
projection, idempotent | ||
-/ | ||
|
||
assert_not_exists GroupWithZero | ||
|
||
variable {M N S : Type*} | ||
|
||
/-- An element `a` is said to be idempotent if `a * a = a`. -/ | ||
def IsIdempotentElem [Mul M] (a : M) : Prop := a * a = a | ||
|
||
namespace IsIdempotentElem | ||
section Mul | ||
variable [Mul M] {a : M} | ||
|
||
lemma of_isIdempotent [Std.IdempotentOp (α := M) (· * ·)] (a : M) : IsIdempotentElem a := | ||
Std.IdempotentOp.idempotent a | ||
|
||
lemma eq (ha : IsIdempotentElem a) : a * a = a := ha | ||
|
||
end Mul | ||
|
||
section Semigroup | ||
variable [Semigroup S] {a b : S} | ||
|
||
lemma mul_of_commute (hab : Commute a b) (ha : IsIdempotentElem a) (hb : IsIdempotentElem b) : | ||
IsIdempotentElem (a * b) := by rw [IsIdempotentElem, hab.symm.mul_mul_mul_comm, ha.eq, hb.eq] | ||
|
||
end Semigroup | ||
|
||
section CommSemigroup | ||
variable [CommSemigroup S] {a b : S} | ||
|
||
lemma mul (ha : IsIdempotentElem a) (hb : IsIdempotentElem b) : IsIdempotentElem (a * b) := | ||
ha.mul_of_commute (.all ..) hb | ||
|
||
end CommSemigroup | ||
|
||
section MulOneClass | ||
variable [MulOneClass M] {a : M} | ||
|
||
lemma one : IsIdempotentElem (1 : M) := mul_one _ | ||
|
||
instance : One {a : M // IsIdempotentElem a} where one := ⟨1, one⟩ | ||
|
||
@[simp, norm_cast] lemma coe_one : ↑(1 : {a : M // IsIdempotentElem a}) = (1 : M) := rfl | ||
|
||
end MulOneClass | ||
|
||
section Monoid | ||
variable [Monoid M] {a : M} | ||
|
||
lemma pow (n : ℕ) (h : IsIdempotentElem a) : IsIdempotentElem (a ^ n) := | ||
Nat.recOn n ((pow_zero a).symm ▸ one) fun n _ => | ||
show a ^ n.succ * a ^ n.succ = a ^ n.succ by | ||
conv_rhs => rw [← h.eq] -- Porting note: was `nth_rw 3 [← h.eq]` | ||
rw [← sq, ← sq, ← pow_mul, ← pow_mul'] | ||
|
||
lemma pow_succ_eq (n : ℕ) (h : IsIdempotentElem a) : a ^ (n + 1) = a := | ||
Nat.recOn n ((Nat.zero_add 1).symm ▸ pow_one a) fun n ih => by rw [pow_succ, ih, h.eq] | ||
|
||
end Monoid | ||
|
||
section CancelMonoid | ||
variable [CancelMonoid M] {a : M} | ||
|
||
@[simp] lemma iff_eq_one : IsIdempotentElem a ↔ a = 1 := by simp [IsIdempotentElem] | ||
|
||
end CancelMonoid | ||
|
||
lemma map {M N F} [Mul M] [Mul N] [FunLike F M N] [MulHomClass F M N] {e : M} | ||
(he : IsIdempotentElem e) (f : F) : IsIdempotentElem (f e) := by | ||
rw [IsIdempotentElem, ← map_mul, he.eq] | ||
|
||
end IsIdempotentElem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/- | ||
Copyright (c) 2022 Christopher Hoskin. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Christopher Hoskin | ||
-/ | ||
import Mathlib.Algebra.Group.Idempotent | ||
import Mathlib.Algebra.GroupWithZero.Defs | ||
|
||
/-! | ||
# Idempotents | ||
This file defines idempotents for an arbitrary multiplication and proves some basic results, | ||
including: | ||
* `IsIdempotentElem.mul_of_commute`: In a semigroup, the product of two commuting idempotents is | ||
an idempotent; | ||
* `IsIdempotentElem.one_sub_iff`: In a (non-associative) ring, `p` is an idempotent if and only if | ||
`1-p` is an idempotent. | ||
* `IsIdempotentElem.pow_succ_eq`: In a monoid `p ^ (n+1) = p` for `p` an idempotent and `n` a | ||
natural number. | ||
## Tags | ||
projection, idempotent | ||
-/ | ||
|
||
assert_not_exists Ring | ||
|
||
variable {M N S M₀ M₁ R G G₀ : Type*} | ||
variable [MulOneClass M₁] [CancelMonoidWithZero G₀] | ||
|
||
namespace IsIdempotentElem | ||
section MulZeroClass | ||
variable [MulZeroClass M₀] | ||
|
||
lemma zero : IsIdempotentElem (0 : M₀) := mul_zero _ | ||
|
||
instance : Zero { p : M₀ // IsIdempotentElem p } where zero := ⟨0, zero⟩ | ||
|
||
@[simp] lemma coe_zero : ↑(0 : { p : M₀ // IsIdempotentElem p }) = (0 : M₀) := rfl | ||
|
||
end MulZeroClass | ||
|
||
section CancelMonoidWithZero | ||
variable [CancelMonoidWithZero M₀] | ||
|
||
@[simp] | ||
lemma iff_eq_zero_or_one {p : G₀} : IsIdempotentElem p ↔ p = 0 ∨ p = 1 where | ||
mp h := or_iff_not_imp_left.mpr fun hp ↦ mul_left_cancel₀ hp (h.trans (mul_one p).symm) | ||
mpr h := h.elim (fun hp => hp.symm ▸ zero) fun hp => hp.symm ▸ one | ||
|
||
end CancelMonoidWithZero | ||
end IsIdempotentElem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/- | ||
Copyright (c) 2024 Junyan Xu. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Junyan Xu | ||
-/ | ||
import Mathlib.Algebra.Group.Submonoid.Membership | ||
import Mathlib.Algebra.GroupWithZero.Divisibility | ||
|
||
/-! | ||
# Submonoid of primal elements | ||
-/ | ||
|
||
/-- The submonoid of primal elements in a cancellative commutative monoid with zero. -/ | ||
def Submonoid.isPrimal (M₀ : Type*) [CancelCommMonoidWithZero M₀] : Submonoid M₀ where | ||
carrier := {a | IsPrimal a} | ||
mul_mem' := .mul | ||
one_mem' := isUnit_one.isPrimal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/- | ||
Copyright (c) 2022 Christopher Hoskin. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Christopher Hoskin | ||
-/ | ||
import Mathlib.Algebra.GroupWithZero.Idempotent | ||
import Mathlib.Algebra.Ring.Defs | ||
import Mathlib.Order.Notation | ||
|
||
/-! | ||
# Idempotents | ||
This file defines idempotents for an arbitrary multiplication and proves some basic results, | ||
including: | ||
* `IsIdempotentElem.mul_of_commute`: In a semigroup, the product of two commuting idempotents is | ||
an idempotent; | ||
* `IsIdempotentElem.one_sub_iff`: In a (non-associative) ring, `a` is an idempotent if and only if | ||
`1-a` is an idempotent. | ||
* `IsIdempotentElem.pow_succ_eq`: In a monoid `a ^ (n+1) = a` for `a` an idempotent and `n` a | ||
natural number. | ||
## Tags | ||
projection, idempotent | ||
-/ | ||
|
||
variable {R : Type*} | ||
|
||
namespace IsIdempotentElem | ||
section NonAssocRing | ||
variable [NonAssocRing R] {a : R} | ||
|
||
lemma one_sub (h : IsIdempotentElem a) : IsIdempotentElem (1 - a) := by | ||
rw [IsIdempotentElem, mul_sub, mul_one, sub_mul, one_mul, h.eq, sub_self, sub_zero] | ||
|
||
@[simp] | ||
lemma one_sub_iff : IsIdempotentElem (1 - a) ↔ IsIdempotentElem a := | ||
⟨fun h => sub_sub_cancel 1 a ▸ h.one_sub, IsIdempotentElem.one_sub⟩ | ||
|
||
@[simp] | ||
lemma mul_one_sub_self (h : IsIdempotentElem a) : a * (1 - a) = 0 := by | ||
rw [mul_sub, mul_one, h.eq, sub_self] | ||
|
||
@[simp] | ||
lemma one_sub_mul_self (h : IsIdempotentElem a) : (1 - a) * a = 0 := by | ||
rw [sub_mul, one_mul, h.eq, sub_self] | ||
|
||
instance : HasCompl {a : R // IsIdempotentElem a} where compl a := ⟨1 - a, a.prop.one_sub⟩ | ||
|
||
@[simp] lemma coe_compl (a : {a : R // IsIdempotentElem a}) : ↑aᶜ = (1 : R) - ↑a := rfl | ||
|
||
@[simp] lemma compl_compl (a : {a : R // IsIdempotentElem a}) : aᶜᶜ = a := by ext; simp | ||
@[simp] lemma zero_compl : (0 : {a : R // IsIdempotentElem a})ᶜ = 1 := by ext; simp | ||
@[simp] lemma one_compl : (1 : {a : R // IsIdempotentElem a})ᶜ = 0 := by ext; simp | ||
|
||
end NonAssocRing | ||
|
||
section Semiring | ||
variable [Semiring R] {a b : R} | ||
|
||
lemma of_mul_add (mul : a * b = 0) (add : a + b = 1) : IsIdempotentElem a ∧ IsIdempotentElem b := by | ||
simp_rw [IsIdempotentElem]; constructor | ||
· conv_rhs => rw [← mul_one a, ← add, mul_add, mul, add_zero] | ||
· conv_rhs => rw [← one_mul b, ← add, add_mul, mul, zero_add] | ||
|
||
end Semiring | ||
|
||
section Ring | ||
variable [Ring R] {a b : R} | ||
|
||
lemma add_sub_mul_of_commute (h : Commute a b) (hp : IsIdempotentElem a) (hq : IsIdempotentElem b) : | ||
IsIdempotentElem (a + b - a * b) := by | ||
convert (hp.one_sub.mul_of_commute ?_ hq.one_sub).one_sub using 1 | ||
· simp_rw [sub_mul, mul_sub, one_mul, mul_one, sub_sub, sub_sub_cancel, add_sub, add_comm] | ||
· simp_rw [commute_iff_eq, sub_mul, mul_sub, one_mul, mul_one, sub_sub, add_sub, add_comm, h.eq] | ||
|
||
end Ring | ||
|
||
section CommRing | ||
variable [CommRing R] {a b : R} | ||
|
||
lemma add_sub_mul (hp : IsIdempotentElem a) (hq : IsIdempotentElem b) : | ||
IsIdempotentElem (a + b - a * b) := add_sub_mul_of_commute (.all ..) hp hq | ||
|
||
end CommRing | ||
end IsIdempotentElem |
Oops, something went wrong.