Commit f5362da
committed
chore: replace single-subgoal
Replace uses of `cases'` that generate only one subgoal with `obtain` (or `rcases` if it is of the form `cases' h : f x`).
```python
#!/usr/bin/env python3
import re
keys = {}
with open("cases-uses", 'r') as f:
for l in f:
filename, line_n, col_n, rest = l.split(':', maxsplit=3)
i = int(line_n)-1
col_n = int(col_n)
head, sep, n_subgoals = rest.strip().rpartition(' ')
n_subgoals = int(n_subgoals)
assert head.endswith(']')
head, sep, newvars = head[:-1].rpartition(' [')
assert sep
newvars = newvars.split(', ')
if filename not in keys:
keys[filename] = {}
if i not in keys[filename]:
keys[filename][i] = {}
keys[filename][i].update({col_n: (head, newvars, n_subgoals)})
for (filename, d) in keys.items():
with open(filename, 'r') as f:
lines = f.readlines()
for (i, t) in d.items():
line = lines[i]
for (col_n, (head, newvars, n_subgoals)) in t.items():
cases_re = re.compile(rf"cases' (.*?) with " + " ".join(newvars))
def rf(m):
if n_subgoals == 1:
if ':' not in m[1]:
return f"obtain ⟨{', '.join(newvars)}⟩ := {m[1]}"
return f"rcases {m[1]} with ⟨{', '.join(newvars)}⟩"
return m[0]
line = cases_re.sub(rf, line, 1)
lines[i] = line
with open(filename, 'w') as f:
f.write("".join(lines))
```
The version of `cases-uses` used for this replacement was extracted from [this run](https://github.com/leanprover-community/mathlib4/actions/runs/13362153558/job/37313542212) and is available [here](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/The.20plan.20to.20remove.20cases'/near/500097792).cases' (leanprover-community#21976)1 parent ad8e0f1 commit f5362da
File tree
104 files changed
+225
-248
lines changed- Archive
- Imo
- MiuLanguage
- Wiedijk100Theorems
- Mathlib
- Algebra
- Lie/Weights
- Polynomial
- Analysis
- Analytic
- BoxIntegral/Box
- Calculus
- Complex/Polynomial
- Normed/Operator
- SpecialFunctions/Complex
- CategoryTheory
- Functor
- Limits
- Constructions
- Shapes
- Sites
- Computability
- Control
- Data
- Analysis
- Complex
- DFinsupp
- Fin
- List
- Perm
- PFunctor
- Multivariate
- Univariate
- PNat
- QPF/Multivariate
- Constructions
- Rat
- Cast
- Real
- Seq
- Set
- Sym
- Vector
- W
- FieldTheory
- IntermediateField/Adjoin
- IsAlgClosed
- RatFunc
- Geometry/Euclidean
- GroupTheory
- FreeGroup
- Perm
- Cycle
- MeasureTheory/Function
- LpSeminorm
- LpSpace
- ModelTheory
- Order
- Rel
- RingTheory
- Adjoin
- DedekindDomain
- Finiteness
- Ideal
- Localization
- Polynomial
- WittVector
- SetTheory
- Cardinal
- Game
- Ordinal
- ZFC
- Testing/Plausible
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
104 files changed
+225
-248
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
| 162 | + | |
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
| 213 | + | |
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
229 | | - | |
| 229 | + | |
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
| 220 | + | |
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
449 | | - | |
| 449 | + | |
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
453 | 453 | | |
454 | | - | |
| 454 | + | |
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
291 | | - | |
| 291 | + | |
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
124 | | - | |
125 | 123 | | |
126 | | - | |
| 124 | + | |
127 | 125 | | |
128 | 126 | | |
129 | 127 | | |
| |||
0 commit comments