Skip to content

Commit 332fc33

Browse files
committed
fix: improve the Lean.Grind.OrderedAdd instance (leanprover-community#35563)
This PR makes changes the entry point of the `grind` class `Lean.Grind.OrderedAdd` to be `IsOrderedCancelAddMonoid`, rather than the more granular type classes `AddRightMono` and `AddRightReflectLE`. Note that the doc-strings of these type classes explicitly say not to use them. This should improve `grind` performance. See [#general > grind failure/performance issue: timing out on slow instance](https://leanprover.zulipchat.com/#narrow/channel/113488-general/topic/grind.20failure.2Fperformance.20issue.3A.20timing.20out.20on.20slow.20instance/with/574912682)
1 parent f250304 commit 332fc33

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

Mathlib/Algebra/Order/Monoid/Defs.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ class IsOrderedCancelMonoid (α : Type*) [CommMonoid α] [PartialOrder α] exten
6666
protected le_of_mul_le_mul_right : ∀ a b c : α, b * a ≤ c * a → b ≤ c := fun a b c h ↦ by
6767
rw [mul_comm _ a, mul_comm _ a] at h; exact le_of_mul_le_mul_left a b c h
6868

69+
instance [AddCommMonoid α] [PartialOrder α] [IsOrderedCancelAddMonoid α] :
70+
Lean.Grind.OrderedAdd α where
71+
add_le_left_iff {a b} c := ⟨
72+
fun h ↦ IsOrderedAddMonoid.add_le_add_left a b h c,
73+
IsOrderedCancelAddMonoid.le_of_add_le_add_right c a b⟩
74+
6975
section IsOrderedCancelMonoid
7076
variable [CommMonoid α] [PartialOrder α] [IsOrderedCancelMonoid α]
7177

Mathlib/Algebra/Order/Monoid/Unbundled/Defs.lean

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,6 @@ abbrev AddRightReflectLE [Add M] [LE M] : Prop :=
257257

258258
attribute [to_additive existing] MulLeftReflectLE MulRightReflectLE
259259

260-
instance [Add M] [Preorder M] [i₁ : AddRightMono M] [i₂ : AddRightReflectLE M] :
261-
Lean.Grind.OrderedAdd M where
262-
add_le_left_iff := fun c => ⟨i₁.elim c, i₂.elim c⟩
263-
264260
theorem rel_iff_cov [CovariantClass M N μ r] [ContravariantClass M N μ r] (m : M) {a b : N} :
265261
r (μ m a) (μ m b) ↔ r a b :=
266262
⟨ContravariantClass.elim _, CovariantClass.elim _⟩

Mathlib/MeasureTheory/Function/L1Space/Integrable.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,14 +675,14 @@ lemma Integrable.measure_ge_lt_top {f : α → β} [Lattice β] [HasSolidNorm β
675675
μ {a : α | ε ≤ f a} < ∞ :=
676676
lt_of_le_of_lt (measure_mono fun x hx => norm_le_norm_of_abs_le_abs <|
677677
(abs_of_nonneg ε_pos.le).symm ▸ hx.trans (le_abs_self (f x)))
678-
(hf.measure_norm_ge_lt_top (by simp; grind))
678+
(hf.measure_norm_ge_lt_top (by positivity [ε_pos.ne']))
679679

680680
/-- If `f` is integrable, then for any `c < 0` the set `{x | f x ≤ c}` has finite
681681
measure. -/
682682
lemma Integrable.measure_le_lt_top {f : α → β} [Lattice β] [HasSolidNorm β] [AddLeftMono β]
683683
(hf : Integrable f μ) {c : β} (c_neg : c < 0) :
684684
μ {a : α | f a ≤ c} < ∞ := by
685-
have : 0 < ‖c‖ := by simp; grind
685+
have : 0 < ‖c‖ := by positivity [c_neg.ne]
686686
refine lt_of_le_of_lt (measure_mono fun x hx => ?_) (hf.measure_norm_ge_lt_top this)
687687
have : -c ≤ -f x := by simp; grind
688688
exact norm_le_norm_of_abs_le_abs <| abs_of_nonpos c_neg.le ▸ this.trans (neg_le_abs _)

0 commit comments

Comments
 (0)