-
Notifications
You must be signed in to change notification settings - Fork 43
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
add elementary lemmas about modules #15
Conversation
Section Module_Lemmas. | ||
Context `{Module R M}. | ||
|
||
Lemma mon_unit_unique : forall i, ((forall x : M, x & i = x) -> i = mon_unit). |
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 seems that this lemma does not need a module structure. You just need M to be a group.
By the way, the following order of quantifiers is enough: ∀x i : M, x & i = x → i = mon_unit.
Lemma mon_unit_unique : ∀ x i, x & i = x → i = mon_unit.
Proof.
intros x i Hyp.
apply (left_cancellation (&) x).
now rewrite right_identity.
Qed.
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.
@urkud Thanks for the tips!
now rewrite left_identity in Hunit. | ||
Qed. | ||
|
||
Lemma mult_rzero : forall x : M, sm 0 x = mon_unit. |
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.
Why not use ⋅ notation? It is more readable.
Disclaimer: I'm neither a coq exprert, nor an experienced math-classes user.
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.
I don't know how to type it effectively :'( I should've copy-pasted before making a PR
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.
I use ~/.XCompose under Linux to type these chars.
Lemma mult_rzero : forall x : M, sm 0 x = mon_unit. | ||
intros. | ||
(* add mon_unit to the left side *) | ||
rewrite <- right_identity. |
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.
You may use the following for the proof
intros.
apply (mon_unit_unique (0 · x) (0 · x)).
rewrite <- distribute_r.
now rewrite left_identity.
if mon_unit_unique
is what I propose above.
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.
I'm getting an error while trying that proof, and it's one I've seen before and had trouble interpreting:
Ltac call to "now" failed.
Error:
Tactic failure: setoid rewrite failed: Unable to satisfy the following constraints:
UNDEFINED EVARS:
?X289==[R M Re Rplus Rmult Rzero Rone Rnegate Me Mop Munit Mnegate sm H x
|- relation M] (internal placeholder) {?r}
?X290==[R M Re Rplus Rmult Rzero Rone Rnegate Me Mop Munit Mnegate sm H x
|- relation M] (internal placeholder) {?r0}
?X291==[R M Re Rplus Rmult Rzero Rone Rnegate Me Mop Munit Mnegate sm H x
(do_subrelation:=do_subrelation)
|- Proper
(equiv ==>
?X290@{__:=R; __:=M; __:=Re; __:=Rplus; __:=Rmult; __:=Rzero;
__:=Rone; __:=Rnegate; __:=Me; __:=Mop; __:=Munit;
__:=Mnegate; __:=sm; __:=H; __:=x} ==>
?X289@{__:=R; __:=M; __:=Re; __:=Rplus; __:=Rmult; __:=Rzero;
__:=Rone; __:=Rnegate; __:=Me; __:=Mop; __:=Munit;
__:=Mnegate; __:=sm; __:=H; __:=x}) scalar_mult]
(internal placeholder) {?p}
?X292==[R M Re Rplus Rmult Rzero Rone Rnegate Me Mop Munit Mnegate sm H x
|- ProperProxy
?X290@{__:=R; __:=M; __:=Re; __:=Rplus; __:=Rmult; __:=Rzero;
__:=Rone; __:=Rnegate; __:=Me; __:=Mop; __:=Munit;
__:=Mnegate; __:=sm; __:=H; __:=x} x]
(internal placeholder) {?p0}
?X295==[R M Re Rplus Rmult Rzero Rone Rnegate Me Mop Munit Mnegate sm H x
|- relation M] (internal placeholder) {?r1}
?X296==[R M Re Rplus Rmult Rzero Rone Rnegate Me Mop Munit Mnegate sm H x
(do_subrelation:=do_subrelation)
|- Proper
(?X289@{__:=R; __:=M; __:=Re; __:=Rplus; __:=Rmult; __:=Rzero;
__:=Rone; __:=Rnegate; __:=Me; __:=Mop; __:=Munit;
__:=Mnegate; __:=sm; __:=H; __:=x} ==>
?X295@{__:=R; __:=M; __:=Re; __:=Rplus; __:=Rmult; __:=Rzero;
__:=Rone; __:=Rnegate; __:=Me; __:=Mop; __:=Munit;
__:=Mnegate; __:=sm; __:=H; __:=x} ==>
flip impl) equiv] (internal placeholder) {?p1}
?X297==[R M Re Rplus Rmult Rzero Rone Rnegate Me Mop Munit Mnegate sm H x
|- ProperProxy
?X295@{__:=R; __:=M; __:=Re; __:=Rplus; __:=Rmult; __:=Rzero;
__:=Rone; __:=Rnegate; __:=Me; __:=Mop; __:=Munit;
__:=Mnegate; __:=sm; __:=H; __:=x}
(0 · x)] (internal placeholder) {?p2}
.
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.
Sorry, I've copied the last two lines from lines 26, 27 of your commit without checking. I thought that I get an error because I didn't apply your patch about "Proper".
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.
This works:
apply scalar_mult_proper ; [apply right_identity|reflexivity].
I have no idea why it fails to rewrite. And why it rewrites in your proof.
@urkud I believe I've addressed all of your comments. Thanks again for the review, very helpful for a beginner like myself 😁 |
This proof requires a change of notation: the condition `Proper sm` must use the `·` notation. See coq-community/corn#35 for discussion. Additional context: http://stackoverflow.com/questions/40624302/what-does-the-error-message-setoid-rewrite-failed-undefined-evars-mean/40668305#40668305
I welcome feedback on lemma names as well (the hardest part of Computer Science, right?) |
define ring tactic on modules
@@ -43,6 +43,12 @@ Proof. | |||
now rewrite associativity, left_inverse, left_identity. | |||
Qed. | |||
|
|||
Lemma mon_unit_unique : forall x i, x & i = x -> i = mon_unit. |
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 seems that other lemmas in this project use a different syntax:
Lemma mon_unit_unique x i : x & i = x → i = mon_unit.
Proof.
intro.
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.
Yep, good eye!
@@ -0,0 +1,60 @@ | |||
From MathClasses.interfaces Require Import vectorspace canonical_names. | |||
From MathClasses.theory Require Import groups rings. |
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.
I get the following warning:
*** Warning: in file theory/modules.v,
required library groups matches several files in path
(found groups.v in varieties, . and theory; used the latter)
I have no warning with this form:
From MathClasses
Require Import interfaces.vectorspace interfaces.canonical_names theory.groups theory.rings.
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.
Thanks, fixed!
(* So we can use the `ring` tactic when we need to *) | ||
Add Ring my_ring : (stdlib_ring_theory R). | ||
|
||
Lemma mult_rzero : forall x : M, 0 · x = mon_unit. |
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.
This and mult_munit
are particular cases of the following fact: a SemiGroup_Morphism
of two groups preserves mon_unit
.
I'm going to submit a pull request for theory/groups.v
with this fact included.
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.
Great, please comment here when that is done!
now rewrite left_identity, right_inverse. | ||
Qed. | ||
|
||
Lemma multiplication_by_negative_1_is_negation : forall x : M, (-1) · x = - x. |
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.
Cf. negate_mult_distr_l
and negate_nult_distr_r
in rings.v
.
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.
Those lemmas are about ring multiplication, and do not apply to sm
as far as I can tell. Am I mistaken? Why do you mention them?
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.
I meant that you can use similar names. Sorry for bad wording.
reflexivity. | ||
Qed. | ||
|
||
Lemma double_negation : forall x, - (- x) = x. |
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.
This is a particular case of groups.negate_involutive
(or rings.negate_involutive
). Doesn't need module structure.
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.
Removed, thanks!
@urkud Thanks for the review! |
I've pushed the group theory fact mentioned in the review to urkud/math-classes@d41ec3da59c826783e3ad6499a56c90b4765b0d9. |
Is this PR still valid, or has it been superseded? |
@spitters I think it needs cleaning up before it can be merged. I'll comment here if and when I get around to it. |
I don't think I'm going to get around to fixing this. I'm making an issue to include my fixes to the laws for inner product spaces in case anyone wants to take that up. |
Some direct consequences of the module laws