Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…2015) * refactor(algebra/associated): move `is_unit` def to `algebra/group` I think it makes sense to have it near `units`. * Add a docstring to `units`, mention `is_unit` there. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
177c06f
commit 8563695
Showing
4 changed files
with
83 additions
and
51 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
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,69 @@ | ||
/- | ||
Copyright (c) 2018 Johannes Hölzl. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Johannes Hölzl, Jens Wagemaker | ||
Contents of this file was cherry-picked from `algebra/associated` by Yury Kudryashov. | ||
I copied the original copyright header from there. | ||
-/ | ||
import algebra.group.units_hom | ||
|
||
/-! | ||
# `is_unit` predicate | ||
In this file we define the `is_unit` predicate on a `monoid`, and | ||
prove a few basic properties. For the bundled version see `units`. See | ||
also `prime`, `associated`, and `irreducible` in `algebra/associated`. | ||
-/ | ||
|
||
variables {M : Type*} {N : Type*} | ||
|
||
/-- An element `a : M` of a monoid is a unit if it has a two-sided inverse. | ||
The actual definition says that `a` is equal to some `u : units M`, where | ||
`units M` is a bundled version of `is_unit`. -/ | ||
def is_unit [monoid M] (a : M) : Prop := ∃ u : units M, a = u | ||
|
||
@[simp] lemma is_unit_unit [monoid M] (u : units M) : is_unit (u : M) := ⟨u, rfl⟩ | ||
|
||
lemma is_unit.map [monoid M] [monoid N] (f : M →* N) {x : M} (h : is_unit x) : is_unit (f x) := | ||
by rcases h with ⟨y, rfl⟩; exact is_unit_unit (units.map f y) | ||
|
||
lemma is_unit.map' [monoid M] [monoid N] (f : M → N) {x : M} (h : is_unit x) [is_monoid_hom f] : | ||
is_unit (f x) := | ||
h.map (monoid_hom.of f) | ||
|
||
@[simp] theorem is_unit_one [monoid M] : is_unit (1:M) := ⟨1, rfl⟩ | ||
|
||
theorem is_unit_of_mul_one [comm_monoid M] (a b : M) (h : a * b = 1) : is_unit a := | ||
⟨units.mk_of_mul_eq_one a b h, rfl⟩ | ||
|
||
theorem is_unit_iff_exists_inv [comm_monoid M] {a : M} : is_unit a ↔ ∃ b, a * b = 1 := | ||
⟨by rintro ⟨⟨a, b, hab, _⟩, rfl⟩; exact ⟨b, hab⟩, | ||
λ ⟨b, hab⟩, is_unit_of_mul_one _ b hab⟩ | ||
|
||
theorem is_unit_iff_exists_inv' [comm_monoid M] {a : M} : is_unit a ↔ ∃ b, b * a = 1 := | ||
by simp [is_unit_iff_exists_inv, mul_comm] | ||
|
||
/-- Multiplication by a `u : units M` doesn't affect `is_unit`. -/ | ||
@[simp] theorem units.is_unit_mul_units [monoid M] (a : M) (u : units M) : | ||
is_unit (a * u) ↔ is_unit a := | ||
iff.intro | ||
(assume ⟨v, hv⟩, | ||
have is_unit (a * ↑u * ↑u⁻¹), by existsi v * u⁻¹; rw [hv, units.coe_mul], | ||
by rwa [mul_assoc, units.mul_inv, mul_one] at this) | ||
(assume ⟨v, hv⟩, hv.symm ▸ ⟨v * u, (units.coe_mul v u).symm⟩) | ||
|
||
theorem is_unit_of_mul_is_unit_left [comm_monoid M] {x y : M} | ||
(hu : is_unit (x * y)) : is_unit x := | ||
let ⟨z, hz⟩ := is_unit_iff_exists_inv.1 hu in | ||
is_unit_iff_exists_inv.2 ⟨y * z, by rwa ← mul_assoc⟩ | ||
|
||
theorem is_unit_of_mul_is_unit_right [comm_monoid M] {x y : M} | ||
(hu : is_unit (x * y)) : is_unit y := | ||
@is_unit_of_mul_is_unit_left _ _ y x $ by rwa mul_comm | ||
|
||
@[simp] theorem is_unit_nat {n : ℕ} : is_unit n ↔ n = 1 := | ||
iff.intro | ||
(assume ⟨u, hu⟩, match n, u, hu, nat.units_eq_one u with _, _, rfl, rfl := rfl end) | ||
(assume h, h.symm ▸ ⟨1, rfl⟩) |
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
Aww, this PR removed the best doc string in mathlib.