Skip to content

Commit 7f14c97

Browse files
committed
chore(Order/Monotone/Basic): use to_dual (leanprover-community#35648)
This PR uses `to_dual` on a few lemmas about `Monotone`. I also turn some uses of `to_dual` into `to_dual none`, because these were made by me before `to_dual none` existed.
1 parent 02e8b79 commit 7f14c97

2 files changed

Lines changed: 21 additions & 32 deletions

File tree

Mathlib/Order/Monotone/Basic.lean

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -218,17 +218,13 @@ section WellFounded
218218

219219
variable [Preorder α] [Preorder β] {f : α → β}
220220

221+
@[to_dual]
221222
theorem StrictMono.wellFoundedLT [WellFoundedLT β] (hf : StrictMono f) : WellFoundedLT α :=
222-
Subrelation.isWellFounded (InvImage (· < ·) f) @hf
223+
Subrelation.isWellFounded (InvImage (· < ·) f) hf.imp
223224

225+
@[to_dual]
224226
theorem StrictAnti.wellFoundedLT [WellFoundedGT β] (hf : StrictAnti f) : WellFoundedLT α :=
225-
StrictMono.wellFoundedLT (β := βᵒᵈ) hf
226-
227-
theorem StrictMono.wellFoundedGT [WellFoundedGT β] (hf : StrictMono f) : WellFoundedGT α :=
228-
StrictMono.wellFoundedLT (α := αᵒᵈ) (β := βᵒᵈ) (fun _ _ h ↦ hf h)
229-
230-
theorem StrictAnti.wellFoundedGT [WellFoundedLT β] (hf : StrictAnti f) : WellFoundedGT α :=
231-
StrictMono.wellFoundedLT (α := αᵒᵈ) (fun _ _ h ↦ hf h)
227+
Subrelation.isWellFounded (InvImage (· > ·) f) hf.imp
232228

233229
end WellFounded
234230

@@ -252,27 +248,18 @@ section Preorder
252248

253249
variable [Preorder α] [Preorder β] {f g : α → β} {a : α}
254250

251+
@[to_dual]
255252
theorem StrictMono.isMax_of_apply (hf : StrictMono f) (ha : IsMax (f a)) : IsMax a :=
256253
of_not_not fun h ↦
257254
let ⟨_, hb⟩ := not_isMax_iff.1 h
258255
(hf hb).not_isMax ha
259256

260-
@[to_dual existing]
261-
theorem StrictMono.isMin_of_apply (hf : StrictMono f) (ha : IsMin (f a)) : IsMin a :=
262-
of_not_not fun h ↦
263-
let ⟨_, hb⟩ := not_isMin_iff.1 h
264-
(hf hb).not_isMin ha
265-
257+
@[to_dual]
266258
theorem StrictAnti.isMax_of_apply (hf : StrictAnti f) (ha : IsMin (f a)) : IsMax a :=
267259
of_not_not fun h ↦
268260
let ⟨_, hb⟩ := not_isMax_iff.1 h
269261
(hf hb).not_isMin ha
270262

271-
theorem StrictAnti.isMin_of_apply (hf : StrictAnti f) (ha : IsMax (f a)) : IsMin a :=
272-
of_not_not fun h ↦
273-
let ⟨_, hb⟩ := not_isMin_iff.1 h
274-
(hf hb).not_isMax ha
275-
276263
lemma StrictMono.add_le_nat {f : ℕ → ℕ} (hf : StrictMono f) (m n : ℕ) : m + f n ≤ f (m + n) := by
277264
rw [Nat.add_comm m, Nat.add_comm m]
278265
induction m with
@@ -346,11 +333,13 @@ variable [Preorder β] {f : α → β} {s : Set α}
346333

347334
open Ordering
348335

336+
@[to_dual self (reorder := a b, ha hb)]
349337
theorem StrictMonoOn.le_iff_le (hf : StrictMonoOn f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) :
350338
f a ≤ f b ↔ a ≤ b :=
351339
fun h ↦ le_of_not_gt fun h' ↦ (hf hb ha h').not_ge h, fun h ↦
352340
h.lt_or_eq_dec.elim (fun h' ↦ (hf ha hb h').le) fun h' ↦ h' ▸ le_rfl⟩
353341

342+
@[to_dual self (reorder := a b, ha hb)]
354343
theorem StrictAntiOn.le_iff_ge (hf : StrictAntiOn f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) :
355344
f a ≤ f b ↔ b ≤ a :=
356345
hf.dual_right.le_iff_le hb ha
@@ -365,23 +354,29 @@ theorem StrictAntiOn.eq_iff_eq (hf : StrictAntiOn f s) {a b : α} (ha : a ∈ s)
365354
f a = f b ↔ b = a :=
366355
(hf.dual_right.eq_iff_eq ha hb).trans eq_comm
367356

357+
@[to_dual self (reorder := a b, ha hb)]
368358
theorem StrictMonoOn.lt_iff_lt (hf : StrictMonoOn f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) :
369359
f a < f b ↔ a < b := by
370360
rw [lt_iff_le_not_ge, lt_iff_le_not_ge, hf.le_iff_le ha hb, hf.le_iff_le hb ha]
371361

362+
@[to_dual self (reorder := a b, ha hb)]
372363
theorem StrictAntiOn.lt_iff_gt (hf : StrictAntiOn f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) :
373364
f a < f b ↔ b < a :=
374365
hf.dual_right.lt_iff_lt hb ha
375366

367+
@[to_dual self]
376368
theorem StrictMono.le_iff_le (hf : StrictMono f) {a b : α} : f a ≤ f b ↔ a ≤ b :=
377369
(hf.strictMonoOn Set.univ).le_iff_le trivial trivial
378370

371+
@[to_dual self]
379372
theorem StrictAnti.le_iff_ge (hf : StrictAnti f) {a b : α} : f a ≤ f b ↔ b ≤ a :=
380373
(hf.strictAntiOn Set.univ).le_iff_ge trivial trivial
381374

375+
@[to_dual self]
382376
theorem StrictMono.lt_iff_lt (hf : StrictMono f) {a b : α} : f a < f b ↔ a < b :=
383377
(hf.strictMonoOn Set.univ).lt_iff_lt trivial trivial
384378

379+
@[to_dual self]
385380
theorem StrictAnti.lt_iff_gt (hf : StrictAnti f) {a b : α} : f a < f b ↔ b < a :=
386381
(hf.strictAntiOn Set.univ).lt_iff_gt trivial trivial
387382

@@ -415,22 +410,16 @@ lemma StrictMonoOn.injOn (hf : StrictMonoOn f s) : s.InjOn f := fun x hx y hy hx
415410

416411
lemma StrictAntiOn.injOn (hf : StrictAntiOn f s) : s.InjOn f := hf.dual_left.injOn
417412

413+
@[to_dual]
418414
theorem StrictMono.maximal_of_maximal_image (hf : StrictMono f) {a} (hmax : ∀ p, p ≤ f a) (x : α) :
419415
x ≤ a :=
420416
hf.le_iff_le.mp (hmax (f x))
421417

422-
theorem StrictMono.minimal_of_minimal_image (hf : StrictMono f) {a} (hmin : ∀ p, f a ≤ p) (x : α) :
423-
a ≤ x :=
424-
hf.le_iff_le.mp (hmin (f x))
425-
418+
@[to_dual]
426419
theorem StrictAnti.minimal_of_maximal_image (hf : StrictAnti f) {a} (hmax : ∀ p, p ≤ f a) (x : α) :
427420
a ≤ x :=
428421
hf.le_iff_ge.mp (hmax (f x))
429422

430-
theorem StrictAnti.maximal_of_minimal_image (hf : StrictAnti f) {a} (hmin : ∀ p, f a ≤ p) (x : α) :
431-
x ≤ a :=
432-
hf.le_iff_ge.mp (hmin (f x))
433-
434423
end Preorder
435424

436425
section PartialOrder

Mathlib/Order/Monotone/Defs.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,23 +243,23 @@ section PartialOrder
243243

244244
variable [PartialOrder α] [Preorder β] {f : α → β} {s : Set α}
245245

246-
@[to_dual monotone_iff_forall_lt']
246+
@[to_dual none]
247247
theorem monotone_iff_forall_lt : Monotone f ↔ ∀ ⦃a b⦄, a < b → f a ≤ f b :=
248248
forall₂_congr fun _ _ ↦
249249
fun hf h ↦ hf h.le, fun hf h ↦ h.eq_or_lt.elim (fun H ↦ (congr_arg _ H).le) hf⟩
250250

251-
@[to_dual antitone_iff_forall_lt']
251+
@[to_dual none]
252252
theorem antitone_iff_forall_lt : Antitone f ↔ ∀ ⦃a b⦄, a < b → f b ≤ f a :=
253253
forall₂_congr fun _ _ ↦
254254
fun hf h ↦ hf h.le, fun hf h ↦ h.eq_or_lt.elim (fun H ↦ (congr_arg _ H).ge) hf⟩
255255

256-
@[to_dual monotoneOn_iff_forall_lt']
256+
@[to_dual none]
257257
theorem monotoneOn_iff_forall_lt :
258258
MonotoneOn f s ↔ ∀ ⦃a⦄ (_ : a ∈ s) ⦃b⦄ (_ : b ∈ s), a < b → f a ≤ f b :=
259259
fun hf _ ha _ hb h ↦ hf ha hb h.le,
260260
fun hf _ ha _ hb h ↦ h.eq_or_lt.elim (fun H ↦ (congr_arg _ H).le) (hf ha hb)⟩
261261

262-
@[to_dual antitoneOn_iff_forall_lt']
262+
@[to_dual none]
263263
theorem antitoneOn_iff_forall_lt :
264264
AntitoneOn f s ↔ ∀ ⦃a⦄ (_ : a ∈ s) ⦃b⦄ (_ : b ∈ s), a < b → f b ≤ f a :=
265265
fun hf _ ha _ hb h ↦ hf ha hb h.le,
@@ -341,7 +341,7 @@ theorem strictAnti_of_le_iff_le [Preorder α] [Preorder β] {f : α → β}
341341
(h : ∀ x y, x ≤ y ↔ f y ≤ f x) : StrictAnti f :=
342342
fun _ _ ↦ (lt_iff_lt_of_le_iff_le' (h _ _) (h _ _)).1
343343

344-
@[to_dual of_lt_imp_ne']
344+
@[to_dual none]
345345
theorem Function.Injective.of_lt_imp_ne [LinearOrder α] {f : α → β} (h : ∀ x y, x < y → f x ≠ f y) :
346346
Injective f := by
347347
grind [Injective]

0 commit comments

Comments
 (0)