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] - style: use cases x with | ... instead of cases x; case => ... #9321

Closed
wants to merge 2 commits into from

Conversation

digama0
Copy link
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

@digama0 digama0 added the awaiting-review The author would like community review of the PR label Dec 28, 2023
@alexjbest
Copy link
Member

!bench

@leanprover-bot
Copy link
Collaborator

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

@alexjbest
Copy link
Member

maintainer merge

Copy link

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

@alexjbest
Copy link
Member

Btw, to what extent was this automatically generated?

@digama0
Copy link
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.

Archive/Arithcc.lean Outdated Show resolved Hide resolved
Copy link
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

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review The author would like community review of the PR 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

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.

None yet

6 participants