-
Notifications
You must be signed in to change notification settings - Fork 297
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 : α → β} : | ||
f <$> x = none ↔ x = none := | ||
by { cases x; simp only [map_none, map_some, eq_self_iff_true] } | ||
|
||
@[simp] lemma map_eq_none' {x : option α} {f : α → β} : | ||
x.map f = none ↔ x = none := | ||
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 := | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There's already an |
||
by { cases x; simp only [map_none', map_some', h, mem_def] } | ||
|
||
@[simp] theorem map_id' : option.map (@id α) = id := map_id | ||
|
||
@[simp] lemma map_map (h : β → γ) (g : α → β) (x : option α) : | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like below? Or is there a reason not to?
There was a problem hiding this comment.
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.