Skip to content
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

Closed
wants to merge 7 commits into from
Closed

add elementary lemmas about modules #15

wants to merge 7 commits into from

Conversation

langston-barrett
Copy link
Contributor

Some direct consequences of the module laws

Section Module_Lemmas.
Context `{Module R M}.

Lemma mon_unit_unique : forall i, ((forall x : M, x & i = x) -> i = mon_unit).
Copy link

@urkud urkud Nov 17, 2016

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.

Copy link
Contributor Author

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.
Copy link

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.

Copy link
Contributor Author

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

Copy link

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.
Copy link

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.

Copy link
Contributor Author

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}
.

Copy link

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".

Copy link

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.

@langston-barrett
Copy link
Contributor Author

@urkud I believe I've addressed all of your comments. Thanks again for the review, very helpful for a beginner like myself 😁

@langston-barrett
Copy link
Contributor Author

I welcome feedback on lemma names as well (the hardest part of Computer Science, right?)

@@ -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.
Copy link

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.

Copy link
Contributor Author

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.
Copy link

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.

Copy link
Contributor Author

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.
Copy link

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.

Copy link
Contributor Author

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.
Copy link

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.

Copy link
Contributor Author

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?

Copy link

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.
Copy link

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, thanks!

@langston-barrett
Copy link
Contributor Author

@urkud Thanks for the review!

@urkud
Copy link

urkud commented Dec 6, 2016

I've pushed the group theory fact mentioned in the review to urkud/math-classes@d41ec3da59c826783e3ad6499a56c90b4765b0d9.

@spitters
Copy link
Collaborator

spitters commented Jun 4, 2017

Is this PR still valid, or has it been superseded?
If you update, I'll pull the request.

@langston-barrett
Copy link
Contributor Author

@spitters I think it needs cleaning up before it can be merged. I'll comment here if and when I get around to it.

@langston-barrett
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants