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

Option seq/bind lemmas #334

Closed
wants to merge 5 commits into from
Closed

Option seq/bind lemmas #334

wants to merge 5 commits into from

Conversation

joehendrix
Copy link
Contributor

This adds a few simplification theorems to simplify Option seq and bind expressions.

It builds on the commits from #330.

@digama0
Copy link
Member

digama0 commented Oct 30, 2023

My preference is to merge #330 and rebase this on top, as the author of #330 is a new contributor and we shouldn't be poaching their work without (github) attribution.

@joehendrix
Copy link
Contributor Author

I don't agree with labeling this as "poaching", but I am merging in their request now.

Co-authored-by: Mario Carneiro <di.gama@gmail.com>
Comment on lines +100 to +106
@[simp] theorem none_bind (f : α → Option β) : Option.bind none f = none := rfl
@[simp] theorem some_bind (x : α) (f : α → Option β): Option.bind (some x) f = f x := rfl

@[simp] theorem bind_none (x : Option α)
: Option.bind x (fun _ => (none : Option β)) = none := by
cases x <;> rfl
@[simp] theorem bind_some (x : Option α) : Option.bind x some = x := by cases x <;> rfl
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
@[simp] theorem none_bind (f : α → Option β) : Option.bind none f = none := rfl
@[simp] theorem some_bind (x : α) (f : α → Option β): Option.bind (some x) f = f x := rfl
@[simp] theorem bind_none (x : Option α)
: Option.bind x (fun _ => (none : Option β)) = none := by
cases x <;> rfl
@[simp] theorem bind_some (x : Option α) : Option.bind x some = x := by cases x <;> rfl
@[simp] theorem none_bind (f : α → Option β) : none.bind f = none := rfl
@[simp] theorem some_bind (x : α) (f : α → Option β): (some x).bind f = f x := rfl
@[simp] theorem bind_none (x : Option α)
: x.bind (fun _ => (none : Option β)) = none := by
cases x <;> rfl
@[simp] theorem bind_some (x : Option α) : x.bind some = x := by cases x <;> rfl

@fgdorais fgdorais added the awaiting-author Waiting for PR author to address issues label Nov 5, 2023
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the merge-conflict This PR has merge conflicts with the `main` branch which must be resolved by the author. label Jan 4, 2024
@joehendrix joehendrix closed this Jan 9, 2024
@joehendrix joehendrix deleted the option-lemmas branch April 4, 2024 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-author Waiting for PR author to address issues merge-conflict This PR has merge conflicts with the `main` branch which must be resolved by the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants