Skip to content

Commit bfbc3fb

Browse files
YaelDilliesyuanyi-350
authored andcommitted
refactor(Algebra/Order/Module): don't use elim as a field name (leanprover-community#29340)
This prevented us from defining further typeclasses by extending. Also move earlier an instance that somehow got stranded in `Data.Finsupp.Weight`.
1 parent d379e27 commit bfbc3fb

File tree

8 files changed

+119
-92
lines changed

8 files changed

+119
-92
lines changed

Mathlib/Algebra/Order/Module/Defs.lean

Lines changed: 100 additions & 70 deletions
Large diffs are not rendered by default.

Mathlib/Algebra/Order/Module/Field.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@ variable [Semifield 𝕜] [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜] [AddComm
2121
-- See note [lower instance priority]
2222
instance (priority := 100) PosSMulMono.toPosSMulReflectLE [MulAction 𝕜 G] [PosSMulMono 𝕜 G] :
2323
PosSMulReflectLE 𝕜 G where
24-
elim _a ha b₁ b₂ h := by
24+
le_of_smul_le_smul_left _a ha b₁ b₂ h := by
2525
simpa [ha.ne'] using smul_le_smul_of_nonneg_left h <| inv_nonneg.2 ha.le
2626

2727
-- See note [lower instance priority]
2828
instance (priority := 100) PosSMulStrictMono.toPosSMulReflectLT [MulActionWithZero 𝕜 G]
2929
[PosSMulStrictMono 𝕜 G] : PosSMulReflectLT 𝕜 G :=
30-
PosSMulReflectLT.of_pos fun a ha b₁ b₂ h ↦ by
31-
simpa [ha.ne'] using smul_lt_smul_of_pos_left h <| inv_pos.2 ha
30+
.of_pos fun a ha b₁ b₂ h ↦ by simpa [ha.ne'] using smul_lt_smul_of_pos_left h <| inv_pos.2 ha
3231

3332
end LinearOrderedSemifield
3433

Mathlib/Algebra/Order/Module/OrderedSMul.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ variable [Semiring R] [PartialOrder R] [AddCommMonoid M] [PartialOrder M]
5959
[SMulWithZero R M] [OrderedSMul R M]
6060

6161
instance OrderedSMul.toPosSMulStrictMono : PosSMulStrictMono R M where
62-
elim _a ha _b₁ _b₂ hb := OrderedSMul.smul_lt_smul_of_pos hb ha
62+
smul_lt_smul_of_pos_left _a ha _b₁ _b₂ hb := OrderedSMul.smul_lt_smul_of_pos hb ha
6363

6464
instance OrderedSMul.toPosSMulReflectLT : PosSMulReflectLT R M :=
65-
PosSMulReflectLT.of_pos fun _a ha _b₁ _b₂ h ↦ OrderedSMul.lt_of_smul_lt_smul_of_pos h ha
65+
.of_pos fun _a ha _b₁ _b₂ h ↦ OrderedSMul.lt_of_smul_lt_smul_of_pos h ha
6666

6767
instance OrderDual.instOrderedSMul : OrderedSMul R Mᵒᵈ where
6868
smul_lt_smul_of_pos := OrderedSMul.smul_lt_smul_of_pos (M := M)

Mathlib/Algebra/Order/Module/Rat.lean

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ import Mathlib.Data.Rat.Cast.Order
1414
variable {α : Type*}
1515

1616
instance PosSMulMono.nnrat_of_rat [Preorder α] [MulAction ℚ α] [PosSMulMono ℚ α] :
17-
PosSMulMono ℚ≥0 α where elim _q hq _a₁ _a₂ ha := smul_le_smul_of_nonneg_left (α := ℚ) ha hq
17+
PosSMulMono ℚ≥0 α where
18+
smul_le_smul_of_nonneg_left _q hq _a₁ _a₂ ha := smul_le_smul_of_nonneg_left (α := ℚ) ha hq
1819

1920
instance PosSMulStrictMono.nnrat_of_rat [Preorder α] [MulAction ℚ α] [PosSMulStrictMono ℚ α] :
20-
PosSMulStrictMono ℚ≥0 α where elim _q hq _a₁ _a₂ ha := smul_lt_smul_of_pos_left (α := ℚ) ha hq
21+
PosSMulStrictMono ℚ≥0 α where
22+
smul_lt_smul_of_pos_left _q hq _a₁ _a₂ ha := smul_lt_smul_of_pos_left (α := ℚ) ha hq
2123

2224
section LinearOrderedAddCommGroup
2325
variable [AddCommGroup α] [LinearOrder α] [IsOrderedAddMonoid α]
@@ -37,7 +39,7 @@ section LinearOrderedSemifield
3739
variable [Semifield α] [LinearOrder α] [IsStrictOrderedRing α]
3840

3941
instance LinearOrderedSemifield.toPosSMulStrictMono_rat : PosSMulStrictMono ℚ≥0 α where
40-
elim q hq a b hab := by
42+
smul_lt_smul_of_pos_left q hq a b hab := by
4143
rw [NNRat.smul_def, NNRat.smul_def]; exact mul_lt_mul_of_pos_left hab <| NNRat.cast_pos.2 hq
4244

4345
end LinearOrderedSemifield
@@ -46,7 +48,7 @@ section LinearOrderedField
4648
variable [Field α] [LinearOrder α] [IsStrictOrderedRing α]
4749

4850
instance LinearOrderedField.toPosSMulStrictMono_rat : PosSMulStrictMono ℚ α where
49-
elim q hq a b hab := by
51+
smul_lt_smul_of_pos_left q hq a b hab := by
5052
rw [Rat.smul_def, Rat.smul_def]; exact mul_lt_mul_of_pos_left hab <| Rat.cast_pos.2 hq
5153

5254
end LinearOrderedField

Mathlib/Algebra/Order/Star/Basic.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,14 @@ variable [Semiring R] [PartialOrder R] [StarRing R] [StarOrderedRing R]
359359
[StarModule R A] [IsScalarTower R A A] [SMulCommClass R A A]
360360

361361
instance : PosSMulMono R A where
362-
elim r hr a b hab := by
362+
smul_le_smul_of_nonneg_left r hr a b hab := by
363363
rw [StarOrderedRing.nonneg_iff] at hr
364364
rw [StarOrderedRing.le_iff] at hab ⊢
365365
obtain ⟨a, ha, rfl⟩ := hab
366366
exact ⟨r • a, smul_mem_closure_star_mul hr ha, smul_add ..⟩
367367

368368
instance : SMulPosMono R A where
369-
elim a ha r s hrs := by
369+
smul_le_smul_of_nonneg_right a ha r s hrs := by
370370
rw [StarOrderedRing.nonneg_iff] at ha
371371
rw [StarOrderedRing.le_iff] at hrs ⊢
372372
obtain ⟨r, hr, rfl⟩ := hrs
@@ -375,15 +375,15 @@ instance : SMulPosMono R A where
375375
variable [IsCancelAdd A] [NoZeroSMulDivisors R A]
376376

377377
instance : PosSMulStrictMono R A where
378-
elim r hr a b hab := by
378+
smul_lt_smul_of_pos_left r hr a b hab := by
379379
rw [StarOrderedRing.pos_iff] at hr
380380
rw [StarOrderedRing.lt_iff] at hab ⊢
381381
obtain ⟨a, ha₀, ha, rfl⟩ := hab
382382
obtain ⟨hr₀, hr⟩ := hr
383383
exact ⟨r • a, smul_ne_zero hr₀ ha₀, smul_mem_closure_star_mul hr ha, smul_add ..⟩
384384

385385
instance [IsCancelAdd R] : SMulPosStrictMono R A where
386-
elim a ha r s hrs := by
386+
smul_lt_smul_of_pos_right a ha r s hrs := by
387387
rw [StarOrderedRing.pos_iff] at ha
388388
rw [StarOrderedRing.lt_iff] at hrs ⊢
389389
obtain ⟨r, hr₀, hr, rfl⟩ := hrs

Mathlib/Data/ENNReal/Action.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ theorem toReal_smul (r : ℝ≥0) (s : ℝ≥0∞) : (r • s).toReal = r • s.
8888
rfl
8989

9090
instance : PosSMulStrictMono ℝ≥0 ℝ≥0where
91-
elim _r hr _a _b hab := ENNReal.mul_lt_mul_left' (coe_pos.2 hr).ne' coe_ne_top hab
91+
smul_lt_smul_of_pos_left _r hr _a _b hab :=
92+
ENNReal.mul_lt_mul_left' (coe_pos.2 hr).ne' coe_ne_top hab
9293

9394
instance : SMulPosMono ℝ≥0 ℝ≥0where
94-
elim _r _ _a _b hab := mul_le_mul_right' (coe_le_coe.2 hab) _
95+
smul_le_smul_of_nonneg_right _r _ _a _b hab := mul_le_mul_right' (coe_le_coe.2 hab) _
9596

9697
end Actions
9798

Mathlib/Data/Finsupp/Weight.lean

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,6 @@ variable [AddCommMonoid M] [PartialOrder M] [IsOrderedAddMonoid M] (w : σ → M
137137
{R : Type*} [CommSemiring R] [PartialOrder R] [IsOrderedRing R]
138138
[CanonicallyOrderedAdd R] [NoZeroDivisors R] [Module R M]
139139

140-
instance : SMulPosMono ℕ M :=
141-
fun b hb m m' h ↦ by
142-
rw [← Nat.add_sub_of_le h, add_smul]
143-
exact le_add_of_nonneg_right (nsmul_nonneg hb (m' - m))⟩
144-
145140
variable {w} in
146141
theorem le_weight_of_ne_zero (hw : ∀ s, 0 ≤ w s) {s : σ} {f : σ →₀ ℕ} (hs : f s ≠ 0) :
147142
w s ≤ weight w f := by

Mathlib/Data/NNReal/Defs.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,11 @@ example : NoMaxOrder ℝ≥0 := by infer_instance
393393

394394
instance instPosSMulStrictMono {α} [Preorder α] [MulAction ℝ α] [PosSMulStrictMono ℝ α] :
395395
PosSMulStrictMono ℝ≥0 α where
396-
elim _r hr _a₁ _a₂ ha := (smul_lt_smul_of_pos_left ha (coe_pos.2 hr):)
396+
smul_lt_smul_of_pos_left _r hr _a₁ _a₂ ha := (smul_lt_smul_of_pos_left ha (coe_pos.2 hr) :)
397397

398398
instance instSMulPosStrictMono {α} [Zero α] [Preorder α] [MulAction ℝ α] [SMulPosStrictMono ℝ α] :
399399
SMulPosStrictMono ℝ≥0 α where
400-
elim _a ha _r₁ _r₂ hr := (smul_lt_smul_of_pos_right (coe_lt_coe.2 hr) ha :)
400+
smul_lt_smul_of_pos_right _a ha _r₁ _r₂ hr := (smul_lt_smul_of_pos_right (coe_lt_coe.2 hr) ha :)
401401

402402
/-- If `a` is a nonnegative real number, then the closed interval `[0, a]` in `ℝ` is order
403403
isomorphic to the interval `Set.Iic a`. -/

0 commit comments

Comments
 (0)