Skip to content

[Merged by Bors] - refactor(Data/ZMod/IntUnitsPower): generalize ZMod 2 to work for Nat and Int too#7866

Closed
eric-wieser wants to merge 16 commits intomasterfrom
eric-wieser/zmod-pow-v2
Closed

[Merged by Bors] - refactor(Data/ZMod/IntUnitsPower): generalize ZMod 2 to work for Nat and Int too#7866
eric-wieser wants to merge 16 commits intomasterfrom
eric-wieser/zmod-pow-v2

Conversation

@eric-wieser
Copy link
Copy Markdown
Member

@eric-wieser eric-wieser commented Oct 23, 2023

Instead of providing instance : Pow ℤˣ (ZMod 2), this now provides instance [Module R (Additive ℤˣ)] : Pow ℤˣ R.
It turns out that this instance already exists for and , so all we need to do is create instance : Module (ZMod 2) (Additive ℤˣ) and we obtain new definitions that generalize over all three types.

As a result of the generalization, z₂pow has been renamed in lemmas to uzpow (units of ).

The motivation here is that I need $(-1) ^ i$ to make sense (and be lawful) for ZMod 2 (on clifford algebras) and (on exterior algebras).

Zulip thread


Open in Gitpod

@eric-wieser eric-wieser added awaiting-author A reviewer has asked the author a question or requested changes. awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. labels Oct 23, 2023
@eric-wieser eric-wieser changed the title refactor(Data/ZMod/IntUnitsPower): generalize ZMod 2 to work for Na… …t and Int too refactor(Data/ZMod/IntUnitsPower): generalize ZMod 2 to work for Nat and Int too Oct 23, 2023
@ghost ghost added blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) labels Oct 23, 2023
@ghost ghost removed merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) labels Oct 23, 2023
@ghost
Copy link
Copy Markdown

ghost commented Oct 23, 2023

@github-actions github-actions bot removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Oct 23, 2023
@eric-wieser eric-wieser added awaiting-review t-algebra Algebra (groups, rings, fields, etc) and removed awaiting-author A reviewer has asked the author a question or requested changes. labels Oct 24, 2023
Copy link
Copy Markdown
Contributor

@j-loreaux j-loreaux left a comment

Choose a reason for hiding this comment

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

This diff is very hard to follow. Would you mind trying to minimize it by ordering things the same way if possible? I don't think there is anything to complain about here, but it's hard to make sure I've checked everything.

@j-loreaux j-loreaux added awaiting-author A reviewer has asked the author a question or requested changes. and removed awaiting-review labels Nov 1, 2023
@eric-wieser
Copy link
Copy Markdown
Member Author

eric-wieser commented Nov 1, 2023

Would you mind trying to minimize it by ordering things the same way if possible?

This isn't really sensible because of the new typeclass assumptions. How about I split out a PR that does everything except the titular refactor?

@eric-wieser
Copy link
Copy Markdown
Member Author

Nevermind, the lemmas actually are in the same order, but the git diff isn't matching them up.

@eric-wieser
Copy link
Copy Markdown
Member Author

eric-wieser commented Nov 1, 2023

If you want a clear diff, I could rename the lemmas first? (edit: done in #8087)

@eric-wieser eric-wieser added awaiting-review and removed awaiting-author A reviewer has asked the author a question or requested changes. labels Nov 1, 2023
bors bot pushed a commit that referenced this pull request Nov 1, 2023
This reduces a diff in a future PR (#7866).
@eric-wieser
Copy link
Copy Markdown
Member Author

If you want a clear diff, I could rename the lemmas first? (edit: done in #8087)

Well, that was a waste of time; the diff is still hard to follow, just because the statements and proofs are changing too much!

@j-loreaux
Copy link
Copy Markdown
Contributor

Thanks for doing #8087. The diff was still a bit messy, but it was just readable enough to make sense of.

bors merge

@github-actions github-actions bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review labels Nov 4, 2023
bors bot pushed a commit that referenced this pull request Nov 4, 2023
…` and `Int` too (#7866)

Instead of providing `instance : Pow ℤˣ (ZMod 2)`, this now provides `instance [Module R (Additive ℤˣ)] : Pow ℤˣ R`.
It turns out that this instance already exists for `ℕ` and `ℤ`, so all we need to do is create `instance : Module (ZMod 2) (Additive ℤˣ)` and we obtain new definitions that generalize over all three types.

As a result of the generalization, `z₂pow` has been renamed in lemmas to `uzpow` (`u`nits of `ℤ`).

The motivation here is that I need $(-1) ^ i$ to make sense (and be lawful) for `ZMod 2` (on clifford algebras) and `ℕ` (on exterior algebras).

[Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/116395-maths/topic/Powers.20of.20.60.E2.84.A4.CB.A3.60.20by.20.60ZMod.202.60/near/397569279)
@bors
Copy link
Copy Markdown

bors bot commented Nov 4, 2023

Pull request successfully merged into master.

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot changed the title refactor(Data/ZMod/IntUnitsPower): generalize ZMod 2 to work for Nat and Int too [Merged by Bors] - refactor(Data/ZMod/IntUnitsPower): generalize ZMod 2 to work for Nat and Int too Nov 4, 2023
@bors bors bot closed this Nov 4, 2023
@bors bors bot deleted the eric-wieser/zmod-pow-v2 branch November 4, 2023 14:50
mathlib-bors bot pushed a commit that referenced this pull request Nov 14, 2023
Following #7866, `Int.negOnePow` is redefined as a map `ℤ → ℤˣ` rather than `ℤ → ℤ`.
mathlib-bors bot pushed a commit that referenced this pull request Nov 14, 2023
Following #7866, `Int.negOnePow` is redefined as a map `ℤ → ℤˣ` rather than `ℤ → ℤ`.



Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
alexkeizer pushed a commit that referenced this pull request Nov 17, 2023
Following #7866, `Int.negOnePow` is redefined as a map `ℤ → ℤˣ` rather than `ℤ → ℤ`.



Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
alexkeizer pushed a commit that referenced this pull request Nov 21, 2023
Following #7866, `Int.negOnePow` is redefined as a map `ℤ → ℤˣ` rather than `ℤ → ℤ`.



Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
grunweg pushed a commit that referenced this pull request Dec 15, 2023
Following #7866, `Int.negOnePow` is redefined as a map `ℤ → ℤˣ` rather than `ℤ → ℤ`.



Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge This PR has been sent to bors. t-algebra Algebra (groups, rings, fields, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants