-
Notifications
You must be signed in to change notification settings - Fork 298
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] - feat(data/equiv/mul_add): use @[simps]
#7213
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -108,6 +108,7 @@ def refl (M : Type*) [has_mul M] : M ≃* M := | |
{ map_mul' := λ _ _, rfl, | ||
..equiv.refl _} | ||
|
||
@[to_additive] | ||
instance : inhabited (M ≃* M) := ⟨refl M⟩ | ||
|
||
/-- The inverse of an isomorphism is an isomorphism. -/ | ||
|
@@ -343,7 +344,7 @@ def add_monoid_hom.to_add_equiv [add_zero_class M] [add_zero_class N] (f : M → | |
/-- Given a pair of monoid homomorphisms `f`, `g` such that `g.comp f = id` and `f.comp g = id`, | ||
returns an multiplicative equivalence with `to_fun = f` and `inv_fun = g`. This constructor is | ||
useful if the underlying type(s) have specialized `ext` lemmas for monoid homomorphisms. -/ | ||
@[to_additive] | ||
@[to_additive, simps {fully_applied := ff}] | ||
def monoid_hom.to_mul_equiv [mul_one_class M] [mul_one_class N] (f : M →* N) (g : N →* M) | ||
(h₁ : g.comp f = monoid_hom.id _) (h₂ : f.comp g = monoid_hom.id _) : | ||
M ≃* N := | ||
|
@@ -353,18 +354,11 @@ def monoid_hom.to_mul_equiv [mul_one_class M] [mul_one_class N] (f : M →* N) ( | |
right_inv := monoid_hom.congr_fun h₂, | ||
map_mul' := f.map_mul } | ||
|
||
@[simp, to_additive] | ||
lemma monoid_hom.coe_to_mul_equiv [mul_one_class M] [mul_one_class N] | ||
(f : M →* N) (g : N →* M) (h₁ h₂) : | ||
⇑(f.to_mul_equiv g h₁ h₂) = f := rfl | ||
|
||
/-- An additive equivalence of additive groups preserves subtraction. -/ | ||
lemma add_equiv.map_sub [add_group A] [add_group B] (h : A ≃+ B) (x y : A) : | ||
h (x - y) = h x - h y := | ||
h.to_add_monoid_hom.map_sub x y | ||
|
||
instance add_equiv.inhabited {M : Type*} [has_add M] : inhabited (M ≃+ M) := ⟨add_equiv.refl M⟩ | ||
|
||
/-- A group is isomorphic to its group of units. -/ | ||
@[to_additive to_add_units "An additive group is isomorphic to its group of additive units"] | ||
def to_units {G} [group G] : G ≃* units G := | ||
|
@@ -389,31 +383,27 @@ def map_equiv (h : M ≃* N) : units M ≃* units N := | |
.. map h.to_monoid_hom } | ||
|
||
/-- Left multiplication by a unit of a monoid is a permutation of the underlying type. -/ | ||
@[to_additive "Left addition of an additive unit is a permutation of the underlying type."] | ||
@[to_additive "Left addition of an additive unit is a permutation of the underlying type.", | ||
simps apply {fully_applied := ff}] | ||
def mul_left (u : units M) : equiv.perm M := | ||
{ to_fun := λx, u * x, | ||
inv_fun := λx, ↑u⁻¹ * x, | ||
left_inv := u.inv_mul_cancel_left, | ||
right_inv := u.mul_inv_cancel_left } | ||
|
||
@[simp, to_additive] | ||
lemma coe_mul_left (u : units M) : ⇑u.mul_left = (*) u := rfl | ||
|
||
@[simp, to_additive] | ||
lemma mul_left_symm (u : units M) : u.mul_left.symm = u⁻¹.mul_left := | ||
equiv.ext $ λ x, rfl | ||
|
||
/-- Right multiplication by a unit of a monoid is a permutation of the underlying type. -/ | ||
@[to_additive "Right addition of an additive unit is a permutation of the underlying type."] | ||
@[to_additive "Right addition of an additive unit is a permutation of the underlying type.", | ||
simps apply {fully_applied := ff}] | ||
def mul_right (u : units M) : equiv.perm M := | ||
{ to_fun := λx, x * u, | ||
inv_fun := λx, x * ↑u⁻¹, | ||
left_inv := λ x, mul_inv_cancel_right x u, | ||
right_inv := λ x, inv_mul_cancel_right x u } | ||
|
||
@[simp, to_additive] | ||
lemma coe_mul_right (u : units M) : ⇑u.mul_right = λ x : M, x * u := rfl | ||
|
||
@[simp, to_additive] | ||
lemma mul_right_symm (u : units M) : u.mul_right.symm = u⁻¹.mul_right := | ||
equiv.ext $ λ x, rfl | ||
|
@@ -460,7 +450,8 @@ attribute [nolint simp_nf] add_left_symm_apply add_right_symm_apply | |
variable (G) | ||
|
||
/-- Inversion on a `group` is a permutation of the underlying type. -/ | ||
@[to_additive "Negation on an `add_group` is a permutation of the underlying type."] | ||
@[to_additive "Negation on an `add_group` is a permutation of the underlying type.", | ||
simps apply {fully_applied := ff}] | ||
protected def inv : perm G := | ||
{ to_fun := λa, a⁻¹, | ||
inv_fun := λa, a⁻¹, | ||
|
@@ -469,9 +460,6 @@ protected def inv : perm G := | |
|
||
variable {G} | ||
|
||
@[simp, to_additive] | ||
lemma coe_inv : ⇑(equiv.inv G) = has_inv.inv := rfl | ||
|
||
@[simp, to_additive] | ||
lemma inv_symm : (equiv.inv G).symm = equiv.inv G := rfl | ||
|
||
|
@@ -482,30 +470,22 @@ variables [group_with_zero G] | |
|
||
/-- Left multiplication by a nonzero element in a `group_with_zero` is a permutation of the | ||
underlying type. -/ | ||
@[simps {fully_applied := ff}] | ||
protected def mul_left' (a : G) (ha : a ≠ 0) : perm G := | ||
{ to_fun := λ x, a * x, | ||
inv_fun := λ x, a⁻¹ * x, | ||
left_inv := λ x, by { dsimp, rw [← mul_assoc, inv_mul_cancel ha, one_mul] }, | ||
right_inv := λ x, by { dsimp, rw [← mul_assoc, mul_inv_cancel ha, one_mul] } } | ||
|
||
@[simp] lemma coe_mul_left' (a : G) (ha : a ≠ 0) : ⇑(equiv.mul_left' a ha) = (*) a := rfl | ||
|
||
@[simp] lemma mul_left'_symm_apply (a : G) (ha : a ≠ 0) : | ||
((equiv.mul_left' a ha).symm : G → G) = (*) a⁻¹ := rfl | ||
Comment on lines
-491
to
-494
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do the generated lemmas use |
||
|
||
/-- Right multiplication by a nonzero element in a `group_with_zero` is a permutation of the | ||
underlying type. -/ | ||
@[simps {fully_applied := ff}] | ||
protected def mul_right' (a : G) (ha : a ≠ 0) : perm G := | ||
{ to_fun := λ x, x * a, | ||
inv_fun := λ x, x * a⁻¹, | ||
left_inv := λ x, by { dsimp, rw [mul_assoc, mul_inv_cancel ha, mul_one] }, | ||
right_inv := λ x, by { dsimp, rw [mul_assoc, inv_mul_cancel ha, mul_one] } } | ||
|
||
@[simp] lemma coe_mul_right' (a : G) (ha : a ≠ 0) : ⇑(equiv.mul_right' a ha) = λ x, x * a := rfl | ||
|
||
@[simp] lemma mul_right'_symm_apply (a : G) (ha : a ≠ 0) : | ||
((equiv.mul_right' a ha).symm : G → G) = λ x, x * a⁻¹ := rfl | ||
|
||
end group_with_zero | ||
|
||
end equiv | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the new statement of
mk'_apply
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the same as the current
add_monoid_hom.coe_mk'
, i.e. an equality between functions. I tried to keep the generated lemmas as close to the existing ones, except for the name.It is currently not possible in the
@[simps]
framework to sometimes use a projection with one name_apply
and sometimes with a different name_coe
(though this would be easy to add).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_apply
feels like the wrong name here - I'm not sure we should be usingsimps
to save lines if it comes at the expense of generating an unusual name.