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(data/option/basic): lemmas on map of none and congr #5424

Closed
wants to merge 1 commit into from

Conversation

pechersky
Copy link
Collaborator


@bryangingechen bryangingechen added the awaiting-review The author would like community review of the PR label Dec 18, 2020
@@ -106,6 +106,18 @@ by cases x; simp
x.map f = some b ↔ ∃ a, x = some a ∧ f a = b :=
by cases x; simp

lemma map_eq_none {α β} {x : option α} {f : α → β} :
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
lemma map_eq_none {α β} {x : option α} {f : α → β} :
@[simp] lemma map_eq_none {α β} {x : option α} {f : α → β} :

like below? Or is there a reason not to?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

simp linter complains if both are simp afair.

@robertylewis robertylewis added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review The author would like community review of the PR labels Dec 19, 2020
by { cases x; simp only [map_none', map_some', eq_self_iff_true] }

lemma map_congr {f g : α → β} {x : option α} (h : ∀ a ∈ x, f a = g a) :
option.map f x = option.map g x :=
Copy link
Member

Choose a reason for hiding this comment

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

I think this lemma would be better if you left it without the x in the result (and maybe also the hypothesis. If you do that, then you can claim that map is injective

Copy link
Collaborator Author

@pechersky pechersky Dec 19, 2020

Choose a reason for hiding this comment

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

How would you phrase the hypothesis then? I've found this lemma useful for the cases when x is some complex expression, and f a = g a for all some a for that complex x, but not in the general case.

There's already an option.map_injective lemma.

@pechersky pechersky added awaiting-review The author would like community review of the PR and removed awaiting-author A reviewer has asked the author a question or requested changes labels Dec 20, 2020
@rwbarton
Copy link
Collaborator

LGTM.

bors merge

@github-actions github-actions bot added ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) and removed awaiting-review The author would like community review of the PR labels Dec 21, 2020
@bors
Copy link

bors bot commented Dec 21, 2020

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(data/option/basic): lemmas on map of none and congr [Merged by Bors] - feat(data/option/basic): lemmas on map of none and congr Dec 21, 2020
@bors bors bot closed this Dec 21, 2020
@bors bors bot deleted the pechersky/option-map-lemmas branch December 21, 2020 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants