Skip to content

Commit 0e2ee7f

Browse files
committed
chore: automatically replace cases' used to split Or (leanprover-community#16526)
Let `h : Or a b`. We replace `cases' h with ha hb` with `rcases h with ha | hb`. To get all uses of `cases'` apply the following diff and run `lake build -q > cases-targets`: ```diff diff --git a/Mathlib/Tactic/Cases.lean b/Mathlib/Tactic/Cases.lean index 34ad80c..944d54b992c 100644
1 parent 6edd1dd commit 0e2ee7f

File tree

198 files changed

+314
-313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+314
-313
lines changed

Mathlib/Algebra/Group/Int/Even.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ namespace Int
2222
variable {m n : ℤ}
2323

2424
@[simp] lemma emod_two_ne_one : ¬n % 2 = 1 ↔ n % 2 = 0 := by
25-
cases' emod_two_eq_zero_or_one n with h h <;> simp [h]
25+
rcases emod_two_eq_zero_or_one n with h | h <;> simp [h]
2626

2727
@[simp] lemma one_emod_two : (1 : Int) % 2 = 1 := rfl
2828

2929
-- `EuclideanDomain.mod_eq_zero` uses (2 ∣ n) as normal form
3030
@[local simp] lemma emod_two_ne_zero : ¬n % 2 = 0 ↔ n % 2 = 1 := by
31-
cases' emod_two_eq_zero_or_one n with h h <;> simp [h]
31+
rcases emod_two_eq_zero_or_one n with h | h <;> simp [h]
3232

3333
lemma even_iff : Even n ↔ n % 2 = 0 where
3434
mp := fun ⟨m, hm⟩ ↦ by simp [← Int.two_mul, hm]
@@ -49,8 +49,8 @@ instance : DecidablePred (IsSquare : ℤ → Prop) :=
4949
@[simp] lemma not_even_one : ¬Even (1 : ℤ) := by simp [even_iff]
5050

5151
@[parity_simps] lemma even_add : Even (m + n) ↔ (Even m ↔ Even n) := by
52-
cases' emod_two_eq_zero_or_one m with h₁ h₁ <;>
53-
cases' emod_two_eq_zero_or_one n with h₂ h₂ <;>
52+
rcases emod_two_eq_zero_or_one m with h₁ | h₁ <;>
53+
rcases emod_two_eq_zero_or_one n with h₂ | h₂ <;>
5454
simp [even_iff, h₁, h₂, Int.add_emod, one_add_one_eq_two, emod_self]
5555

5656
lemma two_not_dvd_two_mul_add_one (n : ℤ) : ¬22 * n + 1 := by simp [add_emod]
@@ -63,8 +63,8 @@ lemma even_sub : Even (m - n) ↔ (Even m ↔ Even n) := by simp [sub_eq_add_neg
6363
@[parity_simps] lemma even_sub_one : Even (n - 1) ↔ ¬Even n := by simp [even_sub]
6464

6565
@[parity_simps] lemma even_mul : Even (m * n) ↔ Even m ∨ Even n := by
66-
cases' emod_two_eq_zero_or_one m with h₁ h₁ <;>
67-
cases' emod_two_eq_zero_or_one n with h₂ h₂ <;>
66+
rcases emod_two_eq_zero_or_one m with h₁ | h₁ <;>
67+
rcases emod_two_eq_zero_or_one n with h₂ | h₂ <;>
6868
simp [even_iff, h₁, h₂, Int.mul_emod]
6969

7070
@[parity_simps] lemma even_pow {n : ℕ} : Even (m ^ n) ↔ Even m ∧ n ≠ 0 := by

Mathlib/Algebra/Homology/AlternatingConst.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def alternatingConstHomologyDataZero (X : C) (n : ℕ) (hn : n = 0) :
5858
.ofZeros _ (by simp [hn]) (by simp [hn])
5959

6060
instance (X : C) (n : ℕ) : (alternatingConst.obj X).HasHomology n := by
61-
cases' n.even_or_odd with h h
61+
rcases n.even_or_odd with h | h
6262
· cases' n with n
6363
· exact ⟨⟨alternatingConstHomologyDataZero X _ rfl⟩⟩
6464
· exact ⟨⟨alternatingConstHomologyDataEvenNEZero X _ h (by simp)⟩⟩
@@ -67,7 +67,7 @@ instance (X : C) (n : ℕ) : (alternatingConst.obj X).HasHomology n := by
6767
/-- The `n`-th homology of the alternating constant complex is `X` for `n ≠ 0`. -/
6868
lemma alternatingConst_exactAt (X : C) (n : ℕ) (hn : n ≠ 0) :
6969
(alternatingConst.obj X).ExactAt n := by
70-
cases' n.even_or_odd with h h
70+
rcases n.even_or_odd with h | h
7171
· exact ⟨(alternatingConstHomologyDataEvenNEZero X _ h hn), isZero_zero C⟩
7272
· exact ⟨(alternatingConstHomologyDataOdd X _ h), isZero_zero C⟩
7373

Mathlib/Algebra/Lie/Nilpotent.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ theorem nilpotencyLength_eq_one_iff [Nontrivial M] :
407407
theorem isTrivial_of_nilpotencyLength_le_one [IsNilpotent L M] (h : nilpotencyLength L M ≤ 1) :
408408
IsTrivial L M := by
409409
nontriviality M
410-
cases' Nat.le_one_iff_eq_zero_or_eq_one.mp h with h h
410+
rcases Nat.le_one_iff_eq_zero_or_eq_one.mp h with h | h
411411
· rw [nilpotencyLength_eq_zero_iff] at h; infer_instance
412412
· rwa [nilpotencyLength_eq_one_iff] at h
413413

Mathlib/Algebra/Lie/Solvable.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ theorem derivedSeriesOfIdeal_le {I J : LieIdeal R L} {k l : ℕ} (h₁ : I ≤ J
8585
revert l; induction' k with k ih <;> intro l h₂
8686
· rw [le_zero_iff] at h₂; rw [h₂, derivedSeriesOfIdeal_zero]; exact h₁
8787
· have h : l = k.succ ∨ l ≤ k := by rwa [le_iff_eq_or_lt, Nat.lt_succ_iff] at h₂
88-
cases' h with h h
88+
rcases h with h | h
8989
· rw [h, derivedSeriesOfIdeal_succ, derivedSeriesOfIdeal_succ]
9090
exact LieSubmodule.mono_lie (ih (le_refl k)) (ih (le_refl k))
9191
· rw [derivedSeriesOfIdeal_succ]; exact le_trans (LieSubmodule.lie_le_left _ _) (ih h)

Mathlib/Algebra/Lie/Weights/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ protected theorem weight_vector_multiplication (M₁ M₂ M₃ : Type*)
136136
-- Eliminate the binomial coefficients from the picture.
137137
suffices (f₁ ^ i * f₂ ^ j) (m₁ ⊗ₜ m₂) = 0 by rw [this]; apply smul_zero
138138
-- Finish off with appropriate case analysis.
139-
cases' Nat.le_or_le_of_add_eq_add_pred (Finset.mem_antidiagonal.mp hij) with hi hj
139+
rcases Nat.le_or_le_of_add_eq_add_pred (Finset.mem_antidiagonal.mp hij) with hi | hj
140140
· rw [(hf_comm.pow_pow i j).eq, LinearMap.mul_apply, LinearMap.pow_map_zero_of_le hi hf₁,
141141
LinearMap.map_zero]
142142
· rw [LinearMap.mul_apply, LinearMap.pow_map_zero_of_le hj hf₂, LinearMap.map_zero]

Mathlib/Algebra/Module/Torsion.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ theorem noZeroSMulDivisors_iff_torsion_eq_bot : NoZeroSMulDivisors R M ↔ torsi
760760
rw [eq_bot_iff]
761761
rintro x ⟨a, hax⟩
762762
change (a : R) • x = 0 at hax
763-
cases' eq_zero_or_eq_zero_of_smul_eq_zero hax with h0 h0
763+
rcases eq_zero_or_eq_zero_of_smul_eq_zero hax with h0 | h0
764764
· exfalso
765765
exact nonZeroDivisors.coe_ne_zero a h0
766766
· exact h0

Mathlib/Algebra/MvPolynomial/CommRing.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ theorem degreeOf_sub_lt {x : σ} {f g : MvPolynomial σ R} {k : ℕ} (h : 0 < k)
183183
by_contra! hc
184184
have h := support_sub σ f g hm
185185
simp only [mem_support_iff, Ne, coeff_sub, sub_eq_zero] at hm
186-
cases' Finset.mem_union.1 h with cf cg
186+
rcases Finset.mem_union.1 h with cf | cg
187187
· exact hm (hf m cf hc)
188188
· exact hm (hg m cg hc)
189189

Mathlib/Algebra/Order/BigOperators/Group/List.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ variable [OrderedCommMonoid M] [CanonicallyOrderedMul M] {l : List M}
188188

189189
@[to_additive] lemma monotone_prod_take (L : List M) : Monotone fun i => (L.take i).prod := by
190190
refine monotone_nat_of_le_succ fun n => ?_
191-
cases' lt_or_le n L.length with h h
191+
rcases lt_or_le n L.length with h | h
192192
· rw [prod_take_succ _ _ h]
193193
exact le_self_mul
194194
· simp [take_of_length_le h, take_of_length_le (le_trans h (Nat.le_succ _))]

Mathlib/Algebra/Order/CauSeq/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ protected theorem mul_pos {f g : CauSeq α abs} : Pos f → Pos g → Pos (f * g
604604
mul_le_mul h₁ h₂ (le_of_lt G0) (le_trans (le_of_lt F0) h₁)⟩
605605

606606
theorem trichotomy (f : CauSeq α abs) : Pos f ∨ LimZero f ∨ Pos (-f) := by
607-
cases' Classical.em (LimZero f) with h h <;> simp [*]
607+
rcases Classical.em (LimZero f) with h | h <;> simp [*]
608608
rcases abv_pos_of_not_limZero h with ⟨K, K0, hK⟩
609609
rcases exists_forall_ge_and hK (f.cauchy₃ K0) with ⟨i, hi⟩
610610
refine (le_total 0 (f i)).imp ?_ ?_ <;>

Mathlib/Algebra/Order/Field/Power.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ alias ⟨_, Odd.zpow_neg⟩ := Odd.zpow_neg_iff
125125
alias ⟨_, Odd.zpow_nonpos⟩ := Odd.zpow_nonpos_iff
126126

127127
theorem Even.zpow_abs {p : ℤ} (hp : Even p) (a : α) : |a| ^ p = a ^ p := by
128-
cases' abs_choice a with h h <;> simp only [h, hp.neg_zpow _]
128+
rcases abs_choice a with h | h <;> simp only [h, hp.neg_zpow _]
129129

130130
/-! ### Bernoulli's inequality -/
131131

0 commit comments

Comments
 (0)