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

Added definition for cyclic' to AbGroups/Cyclic.v #2050

Merged
merged 4 commits into from
Aug 6, 2024

Conversation

ndcroos
Copy link
Contributor

@ndcroos ndcroos commented Aug 6, 2024

See #2022

theories/Algebra/AbGroups/Cyclic.v Outdated Show resolved Hide resolved
theories/Algebra/AbGroups/Cyclic.v Outdated Show resolved Hide resolved
@Alizter Alizter linked an issue Aug 6, 2024 that may be closed by this pull request
@Alizter
Copy link
Collaborator

Alizter commented Aug 6, 2024

Also I would add a comment dividing this definition from the top half of the file:

(** ** Alternative definition of cyclic group *)

(** The [n]-th cyclic ....

The format for comments is:

(* Comment that doesn't appear in documentation *)
(** Comment that appears in documentation *)
(** * Title *)
(** ** Header 1 *)
(** *** Header 2 *)

Copy link
Collaborator

@Alizter Alizter left a comment

Choose a reason for hiding this comment

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

Thanks, this looks good to me. I'll create an issue so that we remember to replace the old definition of cyclic at some point.

(** ** Alternative definition of cyclic group *)

(** The [n]-th cyclic group is the cokernel of [ab_mul n]. *)
Definition cyclic'@{u} (n : nat) : AbGroup@{u}
Copy link
Collaborator

@Alizter Alizter Aug 6, 2024

Choose a reason for hiding this comment

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

Actually, upon further thinking, this shouldn't take any universe variables. If you remove all references of u and the universe annotation on AbGroup and ab_cokernel you will see Coq complain about an unbound universe.

To fix this, at the top of the file before the (** * Cyclic groups *) title put

Local Set Universe Minimization ToSet.

This will tell Coq to try to minimize unbound universe variables to Set the lowest universe. Afterwards, the definition of cyclic'@{} should be accepted and you will see it lands in AbGroup@{Set} if you inspect it with About and Set Printing Universes.

Copy link
Contributor Author

@ndcroos ndcroos Aug 6, 2024

Choose a reason for hiding this comment

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

I have an issue with equiv_Z1_home that I can't resolve by removing universe variables

(** The universal property of [ab_Z1]. *)

I get the error: Universe instance length is 2 but should be 1. If I change the annotation to ab_Z1@{u}, I get another error.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK it looks like Local Set Universe Minimization ToSet messed some things up earlier up in the file. In that case, let's move it to after the "alternative def" title.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Other parts of the file don't work with minimization to set. I'm sure they aren't hard to fix, but to keep this PR focused, @ndcroos could just use:

Definition cyclic'@{} (n : nat) : AbGroup@{Set}
  := ab_cokernel (ab_mul@{Set} (A:=abgroup_Z) n).

Copy link
Contributor Author

@ndcroos ndcroos Aug 6, 2024

Choose a reason for hiding this comment

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

Using this definition, Coq complains here about an unbound universe.

(** ** Alternative definition of cyclic group *)

(** The [n]-th cyclic group is the cokernel of [ab_mul n]. *)
Definition cyclic'@{u} (n : nat) : AbGroup@{u}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Other parts of the file don't work with minimization to set. I'm sure they aren't hard to fix, but to keep this PR focused, @ndcroos could just use:

Definition cyclic'@{} (n : nat) : AbGroup@{Set}
  := ab_cokernel (ab_mul@{Set} (A:=abgroup_Z) n).

@@ -11,7 +11,7 @@ Local Open Scope mc_scope.
Local Open Scope mc_mult_scope.

(** The image of a group homomorphism between groups is a subgroup *)
Definition grp_image {A B : Group} (f : A $-> B) : Subgroup B.
Definition grp_image {A B : Group} (f : GroupHomomorphism A B) : Subgroup B.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why was this changed? It gets rid of one universe variable, but we don't generally try to avoid wild category notation just for that. (Moreover, I think with the next release of Coq those stray universe variables might go away.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

This was my suggestion from earlier, and yes, this will go away when Coq gets algebraic universes. I don't know if it will be the next release of Coq however. It still seems unfinished.

FTR @ndcroos the issue here is that the wildcat of groups should land in the unvierse Set+1 however Coq doesn't let you write that for the moment, meaning we have to introduce a new universe variable strictly larger.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, I missed that comment. But it seems weird to optimize that one result in Image.v to save a universe variable, but not the other results. And it's really orthogonal to this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

One difference here is that we are expecting no universe variables, whereas in other places it is one extra. Anyway, we can cleanup other universe issues some other time.

@jdchristensen
Copy link
Collaborator

I'll create an issue so that we remember to replace the old definition of cyclic at some point.

I've wondered whether defining the integers as the free group on one generator might be the best basic definition. You get a lot of properties for free... But now that Int is developed so thoroughly, it does make sense to focus on that definition.

@ndcroos
Copy link
Contributor Author

ndcroos commented Aug 6, 2024

I reverted the changes in grp_image in Image.v, and SixTerm.v.
The universe annotations are now removed for both the old and new versions of cyclic.

@ndcroos
Copy link
Contributor Author

ndcroos commented Aug 6, 2024

Thanks @Alizter and @jdchristensen for your helpful feedback.

@Alizter
Copy link
Collaborator

Alizter commented Aug 6, 2024

@ndcroos Thank you for the contribution. For #2022, I believe the next step (new PR) would be to define

Definition cyclic'_in {n} : abgroup_Z $-> cyclic' n := grp_quotient_map _. 

and then show

Definition ab_mul_cyclic'_in (n : nat) (x y : abgroup_Z)
  : ab_mul (@cyclic'_in n x) y = cyclic'_in (x * y).

(The @foo notation makes all implicit arguments of foo explicit.)

Copy link
Collaborator

@jdchristensen jdchristensen left a comment

Choose a reason for hiding this comment

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

Thanks for this!

@Alizter Alizter merged commit cdc0aaa into HoTT:master Aug 6, 2024
22 checks passed
@ndcroos ndcroos deleted the new_version_cyclic_group branch August 6, 2024 19:27
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