Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit d89160b

Browse files
committed
feat(order/bounded_order): Strictly monotone functions preserve maximality (#13434)
Prove `f a = f ⊤ ↔ a = ⊤` and `f a = f ⊥ ↔ a = ⊥` for strictly monotone/antitone functions. Also fix `is_max.eq_top` and friends and delete `eq_top_of_maximal` (which accidentally survived the last refactor).
1 parent 5c75390 commit d89160b

File tree

3 files changed

+35
-10
lines changed

3 files changed

+35
-10
lines changed

src/logic/basic.lean

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,6 @@ def not.elim {α : Sort*} (H1 : ¬a) (H2 : a) : α := absurd H2 H1
294294

295295
@[reducible] theorem not.imp {a b : Prop} (H2 : ¬b) (H1 : a → b) : ¬a := mt H1 H2
296296

297-
lemma iff.not (h : a ↔ b) : ¬ a ↔ ¬ b := not_congr h
298-
299297
theorem not_not_of_not_imp : ¬(a → b) → ¬¬a :=
300298
mt not.elim
301299

@@ -399,6 +397,10 @@ theorem imp.swap : (a → b → c) ↔ (b → a → c) :=
399397
theorem imp_not_comm : (a → ¬b) ↔ (b → ¬a) :=
400398
imp.swap
401399

400+
lemma iff.not (h : a ↔ b) : ¬ a ↔ ¬ b := not_congr h
401+
lemma iff.not_left (h : a ↔ ¬ b) : ¬ a ↔ b := h.not.trans not_not
402+
lemma iff.not_right (h : ¬ a ↔ b) : a ↔ ¬ b := not_not.symm.trans h.not
403+
402404
/-! ### Declarations about `xor` -/
403405

404406
@[simp] theorem xor_true : xor true = not := funext $ λ a, by simp [xor]

src/order/bounded_order.lean

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ alias ne_top_of_lt ← has_lt.lt.ne_top
8888

8989
end preorder
9090

91-
variables [partial_order α] [order_top α] {a b : α}
91+
variables [partial_order α] [order_top α] [preorder β] {f : α → β} {a b : α}
9292

9393
@[simp] lemma is_max_iff_eq_top : is_max a ↔ a = ⊤ :=
9494
⟨λ h, h.eq_of_le le_top, λ h b _, h.symm ▸ le_top⟩
@@ -99,21 +99,25 @@ variables [partial_order α] [order_top α] {a b : α}
9999
lemma not_is_max_iff_ne_top : ¬ is_max a ↔ a ≠ ⊤ := is_max_iff_eq_top.not
100100
lemma not_is_top_iff_ne_top : ¬ is_top a ↔ a ≠ ⊤ := is_top_iff_eq_top.not
101101

102-
alias is_max_iff_eq_top ↔ _ is_max.eq_top
103-
alias is_top_iff_eq_top ↔ _ is_top.eq_top
102+
alias is_max_iff_eq_top ↔ is_max.eq_top _
103+
alias is_top_iff_eq_top ↔ is_top.eq_top _
104104

105105
@[simp] lemma top_le_iff : ⊤ ≤ a ↔ a = ⊤ := le_top.le_iff_eq.trans eq_comm
106106
lemma top_unique (h : ⊤ ≤ a) : a = ⊤ := le_top.antisymm h
107107
lemma eq_top_iff : a = ⊤ ↔ ⊤ ≤ a := top_le_iff.symm
108108
lemma eq_top_mono (h : a ≤ b) (h₂ : a = ⊤) : b = ⊤ := top_unique $ h₂ ▸ h
109109
lemma lt_top_iff_ne_top : a < ⊤ ↔ a ≠ ⊤ := le_top.lt_iff_ne
110+
@[simp] lemma not_lt_top_iff : ¬ a < ⊤ ↔ a = ⊤ := lt_top_iff_ne_top.not_left
110111
lemma eq_top_or_lt_top (a : α) : a = ⊤ ∨ a < ⊤ := le_top.eq_or_lt
111112
lemma ne.lt_top (h : a ≠ ⊤) : a < ⊤ := lt_top_iff_ne_top.mpr h
112113
lemma ne.lt_top' (h : ⊤ ≠ a) : a < ⊤ := h.symm.lt_top
113114
lemma ne_top_of_le_ne_top (hb : b ≠ ⊤) (hab : a ≤ b) : a ≠ ⊤ := (hab.trans_lt hb.lt_top).ne
114115

115-
lemma eq_top_of_maximal (h : ∀ b, ¬ a < b) : a = ⊤ :=
116-
or.elim (lt_or_eq_of_le le_top) (λ hlt, absurd hlt (h ⊤)) (λ he, he)
116+
lemma strict_mono.apply_eq_top_iff (hf : strict_mono f) : f a = f ⊤ ↔ a = ⊤ :=
117+
⟨λ h, not_lt_top_iff.1 $ λ ha, (hf ha).ne h, congr_arg _⟩
118+
119+
lemma strict_anti.apply_eq_top_iff (hf : strict_anti f) : f a = f ⊤ ↔ a = ⊤ :=
120+
⟨λ h, not_lt_top_iff.1 $ λ ha, (hf ha).ne' h, congr_arg _⟩
117121

118122
variables [nontrivial α]
119123

@@ -168,7 +172,7 @@ alias ne_bot_of_gt ← has_lt.lt.ne_bot
168172

169173
end preorder
170174

171-
variables [partial_order α] [order_bot α] {a b : α}
175+
variables [partial_order α] [order_bot α] [preorder β] {f : α → β} {a b : α}
172176

173177
@[simp] lemma is_min_iff_eq_bot : is_min a ↔ a = ⊥ :=
174178
⟨λ h, h.eq_of_ge bot_le, λ h b _, h.symm ▸ bot_le⟩
@@ -187,12 +191,19 @@ lemma bot_unique (h : a ≤ ⊥) : a = ⊥ := h.antisymm bot_le
187191
lemma eq_bot_iff : a = ⊥ ↔ a ≤ ⊥ := le_bot_iff.symm
188192
lemma eq_bot_mono (h : a ≤ b) (h₂ : b = ⊥) : a = ⊥ := bot_unique $ h₂ ▸ h
189193
lemma bot_lt_iff_ne_bot : ⊥ < a ↔ a ≠ ⊥ := bot_le.lt_iff_ne.trans ne_comm
194+
@[simp] lemma not_bot_lt_iff : ¬ ⊥ < a ↔ a = ⊥ := bot_lt_iff_ne_bot.not_left
190195
lemma eq_bot_or_bot_lt (a : α) : a = ⊥ ∨ ⊥ < a := bot_le.eq_or_gt
191196
lemma eq_bot_of_minimal (h : ∀ b, ¬ b < a) : a = ⊥ := (eq_bot_or_bot_lt a).resolve_right (h ⊥)
192197
lemma ne.bot_lt (h : a ≠ ⊥) : ⊥ < a := bot_lt_iff_ne_bot.mpr h
193198
lemma ne.bot_lt' (h : ⊥ ≠ a) : ⊥ < a := h.symm.bot_lt
194199
lemma ne_bot_of_le_ne_bot (hb : b ≠ ⊥) (hab : b ≤ a) : a ≠ ⊥ := (hb.bot_lt.trans_le hab).ne'
195200

201+
lemma strict_mono.apply_eq_bot_iff (hf : strict_mono f) : f a = f ⊥ ↔ a = ⊥ :=
202+
⟨λ h, not_bot_lt_iff.1 $ λ ha, (hf ha).ne' h, congr_arg _⟩
203+
204+
lemma strict_anti.apply_eq_bot_iff (hf : strict_anti f) : f a = f ⊥ ↔ a = ⊥ :=
205+
⟨λ h, not_bot_lt_iff.1 $ λ ha, (hf ha).ne h, congr_arg _⟩
206+
196207
variables [nontrivial α]
197208

198209
lemma not_is_max_bot : ¬ is_max (⊥ : α) :=

src/order/monotone.lean

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Jeremy Avigad, Mario Carneiro, Yaël Dillies
55
-/
66
import order.compare
7-
import order.order_dual
7+
import order.max
88
import order.rel_classes
99

1010
/-!
@@ -339,7 +339,19 @@ lemma injective_of_le_imp_le [partial_order α] [preorder β] (f : α → β)
339339
λ x y hxy, (h hxy.le).antisymm (h hxy.ge)
340340

341341
section preorder
342-
variables [preorder α] [preorder β] {f g : α → β}
342+
variables [preorder α] [preorder β] {f g : α → β} {a : α}
343+
344+
lemma strict_mono.is_max_of_apply (hf : strict_mono f) (ha : is_max (f a)) : is_max a :=
345+
of_not_not $ λ h, let ⟨b, hb⟩ := not_is_max_iff.1 h in (hf hb).not_is_max ha
346+
347+
lemma strict_mono.is_min_of_apply (hf : strict_mono f) (ha : is_min (f a)) : is_min a :=
348+
of_not_not $ λ h, let ⟨b, hb⟩ := not_is_min_iff.1 h in (hf hb).not_is_min ha
349+
350+
lemma strict_anti.is_max_of_apply (hf : strict_anti f) (ha : is_min (f a)) : is_max a :=
351+
of_not_not $ λ h, let ⟨b, hb⟩ := not_is_max_iff.1 h in (hf hb).not_is_min ha
352+
353+
lemma strict_anti.is_min_of_apply (hf : strict_anti f) (ha : is_max (f a)) : is_min a :=
354+
of_not_not $ λ h, let ⟨b, hb⟩ := not_is_min_iff.1 h in (hf hb).not_is_max ha
343355

344356
protected lemma strict_mono.ite' (hf : strict_mono f) (hg : strict_mono g) {p : α → Prop}
345357
[decidable_pred p] (hp : ∀ ⦃x y⦄, x < y → p y → p x)

0 commit comments

Comments
 (0)