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

feat(Logic/Equiv/Basic): sumSigmaDistrib, finSigmaFinEquiv #19618

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Timeroot
Copy link
Collaborator

Upstreamed from the EquationalTheories project.

Open in Gitpod

Copy link

github-actions bot commented Nov 30, 2024

PR summary 9fcfebfbc1

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ finSigmaFinEquiv
+ finSigmaFinEquiv_apply
+ finSigmaFinEquiv_one
+ sumSigmaDistrib
+ uniqueSigma
+ uniqueSigma_apply
+ uniqueSigma_symm_apply

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@Timeroot Timeroot added the t-data Data (lists, quotients, numbers, etc) label Dec 2, 2024
@quangvdao
Copy link
Collaborator

I also defined finSigmaFinEquiv in another PR #19013, but this definition looks a lot neater than mine.

@Timeroot
Copy link
Collaborator Author

Timeroot commented Dec 3, 2024

I also defined finSigmaFinEquiv in another PR #19013, but this definition looks a lot neater than mine.

Oh haha! When I was writing mine (which was pretty much the exact same time as you writing yours) I checked loogle/mathlib but not the current PRs.

I guess it's a testament to Mathlib's naming convention, that two of us could write totally separate implementations of the same idea, that do the exact same thing, with the exact same name.

@@ -388,6 +388,17 @@ theorem finPiFinEquiv_single {m : ℕ} {n : Fin m → ℕ} [∀ i, NeZero (n i)]
rintro x hx
rw [Pi.single_eq_of_ne hx, Fin.val_zero', zero_mul]

/-- Equivalence between the Sigma type `(i : Fin m) × Fin (n i)` and `Fin (∑ i : Fin m, n i)`. -/
def finSigmaFinEquiv {m : ℕ} {n : Fin m → ℕ} : (i : Fin m) × Fin (n i) ≃ Fin (∑ i : Fin m, n i) :=
Copy link
Member

Choose a reason for hiding this comment

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

Could you please provide a few API lemmas that will help working with this defn?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added finSigmaFinEquiv_apply and finSigmaFinEquiv_one. I would add finSigmaFinEquiv_symm_apply but I don't think there's a particularly clean statement of the inverse equivalence (at least, not clean enough to be useful - I think the forward apply should be preferred)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that there's WIP in Batteries to provide a more cohesive framework for Fin equivalences: leanprover-community/batteries#1007.

My PR also defines auxiliary functions that explicitly identify the inverse equivalence #19013.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see, I guess one can write it in terms of these divSum and modSum you defined. Well, I guess we both have definitions of this equivalence. I'll leave mine like this (without a the _symm_apply lemma), I'm fine with either definition getting merged. #19695 just requires some definition of finSigmaFinEquiv.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm also fine with either definitions, and wonder if we could have the best of both worlds (explicit formulas from my PR, plus theorems that relate it to your PR).

@jcommelin jcommelin added the awaiting-author A reviewer has asked the author a question or requested changes label Dec 3, 2024
@jcommelin
Copy link
Member

Apart from one comment, LGTM

@Timeroot Timeroot removed the awaiting-author A reviewer has asked the author a question or requested changes label Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t-data Data (lists, quotients, numbers, etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants