Skip to content

[Merged by Bors] - style: use cases x with | ... instead of cases x; case => ...#9321

Closed
digama0 wants to merge 2 commits intomasterfrom
cases_pipe
Closed

[Merged by Bors] - style: use cases x with | ... instead of cases x; case => ...#9321
digama0 wants to merge 2 commits intomasterfrom
cases_pipe

Conversation

@digama0
Copy link
Copy Markdown
Member

@digama0 digama0 commented Dec 28, 2023

This converts usages of the pattern

cases h
case inl h' => ...
case inr h' => ...

which derive from mathported code, to the "structured cases" syntax:

cases h with
| inl h' => ...
| inr h' => ...

The case where the subgoals are handled with · instead of case is more contentious (and much more numerous) so I left those alone. This pattern also appears with cases', induction, induction', and rcases. Furthermore, there is a similar transformation for by_cases:

by_cases h : cond
case pos => ...
case neg => ...

is replaced by:

if h : cond then
  ...
else
  ...

Open in Gitpod

@alexjbest
Copy link
Copy Markdown
Member

!bench

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Here are the benchmark results for commit 2581c17.
There were no significant changes against commit 6cab3d6.

@alexjbest
Copy link
Copy Markdown
Member

maintainer merge

@github-actions
Copy link
Copy Markdown

🚀 Pull request has been placed on the maintainer queue by alexjbest.

@alexjbest
Copy link
Copy Markdown
Member

Btw, to what extent was this automatically generated?

@digama0
Copy link
Copy Markdown
Member Author

digama0 commented Dec 29, 2023

Not at all, although I did think about ways this kind of thing might be automated in the future.

Copy link
Copy Markdown
Member

@jcommelin jcommelin left a comment

Choose a reason for hiding this comment

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

Thanks 🎉

bors merge

@ghost ghost added ready-to-merge This PR has been sent to bors. and removed awaiting-review labels Dec 29, 2023
mathlib-bors bot pushed a commit that referenced this pull request Dec 29, 2023
)

This converts usages of the pattern
```lean
cases h
case inl h' => ...
case inr h' => ...
```
which derive from mathported code, to the "structured `cases`" syntax:
```lean
cases h with
| inl h' => ...
| inr h' => ...
```
The case where the subgoals are handled with `·` instead of `case` is more contentious (and much more numerous) so I left those alone. This pattern also appears with `cases'`, `induction`, `induction'`, and `rcases`. Furthermore, there is a similar transformation for `by_cases`:
```lean
by_cases h : cond
case pos => ...
case neg => ...
```
is replaced by:
```lean
if h : cond then
  ...
else
  ...
```



Co-authored-by: Mario Carneiro <di.gama@gmail.com>
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Dec 29, 2023

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title style: use cases x with | ... instead of cases x; case => ... [Merged by Bors] - style: use cases x with | ... instead of cases x; case => ... Dec 29, 2023
@mathlib-bors mathlib-bors bot closed this Dec 29, 2023
@mathlib-bors mathlib-bors bot deleted the cases_pipe branch December 29, 2023 08:24
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants