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

[Merged by Bors] - feat: add lemma List.prod_map_ite_eq #13023

Closed
wants to merge 13 commits into from

Conversation

BoltonBailey
Copy link
Collaborator

@BoltonBailey BoltonBailey commented May 19, 2024

Proves that the (product) sum of a list mapped through a function of the form if x = a then ... else ... is equal to the (product) sum over the list mapped through the else condition, (times) plus an additional factor about the number of times a appears.

Upstreamed from another project.


Open in Gitpod

@BoltonBailey BoltonBailey added awaiting-review t-algebra Algebra (groups, rings, fields, etc) labels May 19, 2024
@urkud
Copy link
Member

urkud commented May 26, 2024

Is it from an open source project? If yes, then please link. Also, what do you think about adding these generic lemmas?

namespace List

variable {α M : Type*} [CommMonoid M]

@[to_additive]
lemma prod_map_ite (p : α → Prop) [DecidablePred p] (f g : α → β) (l : List α) :
    (l.map fun a ↦ if p a then f a else g a).prod =
      ((l.filter fun a ↦ p a).map f) * ((l.filter fun a ↦ ¬p a).map g) := _

@[to_additive]
lemma prod_map_filter_mul_prod_map_filter_not (p : α → Prop) [DecidablePred p] (f : α → M) (l : List α) :
    -- See `Finset.prod_filter_mul_prod_filter_not`

@urkud urkud added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review labels May 26, 2024
@BoltonBailey
Copy link
Collaborator Author

Seems good, I have added these.

@BoltonBailey BoltonBailey added awaiting-review and removed awaiting-author A reviewer has asked the author a question or requested changes labels May 27, 2024
@Ruben-VandeVelde Ruben-VandeVelde added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review labels Jun 4, 2024
BoltonBailey and others added 4 commits June 4, 2024 11:25
Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com>
@BoltonBailey BoltonBailey added awaiting-review and removed awaiting-author A reviewer has asked the author a question or requested changes labels Jun 4, 2024
Copy link
Collaborator

@Ruben-VandeVelde Ruben-VandeVelde left a comment

Choose a reason for hiding this comment

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

maintainer merge

Copy link

github-actions bot commented Jul 5, 2024

🚀 Pull request has been placed on the maintainer queue by Ruben-VandeVelde.

@Ruben-VandeVelde Ruben-VandeVelde added awaiting-author A reviewer has asked the author a question or requested changes and removed maintainer-merge labels Jul 5, 2024
BoltonBailey and others added 2 commits July 5, 2024 10:46
Co-authored-by: Johan Commelin <johan@commelin.net>
@BoltonBailey BoltonBailey added awaiting-CI and removed awaiting-author A reviewer has asked the author a question or requested changes labels Jul 5, 2024
Copy link

github-actions bot commented Jul 5, 2024

PR summary 75218f0978

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ prod_map_filter_mul_prod_map_filter_not
+ prod_map_ite
+ prod_map_ite_eq

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

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

@fpvandoorn
Copy link
Member

bors merge

@github-actions github-actions bot added the ready-to-merge This PR has been sent to bors. label Jul 8, 2024
mathlib-bors bot pushed a commit that referenced this pull request Jul 8, 2024
Proves that the (product) sum of a list mapped through a function of the form `if x = a then ... else ...` is equal to the (product) sum over the list mapped through the else condition, (times) plus an additional factor about the number of times `a` appears.

Upstreamed from [another project](https://github.com/BoltonBailey/formal-snarks-project).
@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Jul 8, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat: add lemma List.prod_map_ite_eq [Merged by Bors] - feat: add lemma List.prod_map_ite_eq Jul 8, 2024
@mathlib-bors mathlib-bors bot closed this Jul 8, 2024
@mathlib-bors mathlib-bors bot deleted the BoltonBailey/prod_map_ite_eq branch July 8, 2024 17:05
@adomani adomani mentioned this pull request Aug 1, 2024
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.

5 participants