@@ -247,16 +247,17 @@ section LE
247247
248248variable [LE α] {x y : WithBot α}
249249
250- /-- The order on `WithBot α`, defined by `⊥ ≤ ⊥`, `⊥ ≤ ↑a` and `a ≤ b → ↑a ≤ ↑b`.
251-
252- Equivalently, `x ≤ y` can be defined as `∀ a : α, x = ↑a → ∃ b : α, y = ↑b ∧ a ≤ b`,
253- see `le_if_forall`. The definition as an inductive predicate is preferred since it
254- cannot be accidentally unfolded too far. -/
250+ /-- Auxiliary definition for the order on `WithBot`. -/
255251@[mk_iff le_def_aux]
256252protected inductive LE : WithBot α → WithBot α → Prop
257253 | protected bot_le (x : WithBot α) : WithBot.LE ⊥ x
258254 | protected coe_le_coe {a b : α} : a ≤ b → WithBot.LE a b
259255
256+ /-- The order on `WithBot α`, defined by `⊥ ≤ y` and `a ≤ b → ↑a ≤ ↑b`.
257+
258+ Equivalently, `x ≤ y` can be defined as `∀ a : α, x = ↑a → ∃ b : α, y = ↑b ∧ a ≤ b`,
259+ see `le_iff_forall`. The definition as an inductive predicate is preferred since it
260+ cannot be accidentally unfolded too far. -/
260261instance (priority := 10 ) instLE : LE (WithBot α) where le := WithBot.LE
261262
262263lemma le_def : x ≤ y ↔ x = ⊥ ∨ ∃ a b : α, a ≤ b ∧ x = a ∧ y = b := le_def_aux ..
@@ -303,28 +304,32 @@ section LT
303304
304305variable [LT α] {x y : WithBot α}
305306
307+ /-- Auxiliary definition for the order on `WithBot`. -/
308+ @[mk_iff lt_def_aux]
309+ protected inductive LT : WithBot α → WithBot α → Prop
310+ | protected bot_lt (b : α) : WithBot.LT ⊥ b
311+ | protected coe_lt_coe {a b : α} : a < b → WithBot.LT a b
312+
306313/-- The order on `WithBot α`, defined by `⊥ < ↑a` and `a < b → ↑a < ↑b`.
307314
308- Equivalently, `x ≤ y` can be defined as `∀ b : α, y = ↑v → ∃ a : α, x = ↑a ∧ a ≤ b`,
309- see `le_if_forall `. The definition as an inductive predicate is preferred since it
315+ Equivalently, `x < y` can be defined as `∃ b : α, y = ↑b ∧ ∀ a : α, x = ↑a → a < b`,
316+ see `lt_iff_exists `. The definition as an inductive predicate is preferred since it
310317cannot be accidentally unfolded too far. -/
311- instance (priority := 10 ) instLT : LT (WithBot α) where
312- lt
313- | ⊥, ⊥ => False
314- | (a : α), ⊥ => False
315- | ⊥, (b : α) => True
316- | (a : α), (b : α) => a < b
318+ instance (priority := 10 ) instLT : LT (WithBot α) where lt := WithBot.LT
319+
320+ lemma lt_def : x < y ↔ (x = ⊥ ∧ ∃ b : α, y = b) ∨ ∃ a b : α, a < b ∧ x = a ∧ y = b :=
321+ (lt_def_aux ..).trans <| by simp
317322
318- lemma lt_def : x < y ↔ ∃ b : α, y = ↑b ∧ ∀ a : α, x = ↑a → a < b := by
319- cases x <;> cases y <;> simp [LT.lt ]
323+ lemma lt_iff_exists : x < y ↔ ∃ b : α, y = ↑b ∧ ∀ a : α, x = ↑a → a < b := by
324+ cases x <;> cases y <;> simp [lt_def ]
320325
321326@[simp, norm_cast] lemma coe_lt_coe : (a : WithBot α) < b ↔ a < b := by simp [lt_def]
322327@[simp] lemma bot_lt_coe (a : α) : ⊥ < (a : WithBot α) := by simp [lt_def]
323328@[simp] protected lemma not_lt_bot (a : WithBot α) : ¬a < ⊥ := by simp [lt_def]
324329
325330lemma lt_iff_exists_coe : x < y ↔ ∃ b : α, y = b ∧ x < b := by cases y <;> simp
326331
327- lemma lt_coe_iff : x < b ↔ ∀ a : α, x = a → a < b := by simp [lt_def ]
332+ lemma lt_coe_iff : x < b ↔ ∀ a : α, x = a → a < b := by simp [lt_iff_exists ]
328333
329334/-- A version of `bot_lt_iff_ne_bot` for `WithBot` that only requires `LT α`, not
330335`PartialOrder α`. -/
@@ -827,7 +832,11 @@ section LE
827832
828833variable [LE α] {x y : WithTop α}
829834
830- /-- The order on `WithTop α`, defined by `⊤ ≤ ⊤`, `↑a ≤ ⊤` and `a ≤ b → ↑a ≤ ↑b`. -/
835+ /-- The order on `WithTop α`, defined by `x ≤ ⊤` and `a ≤ b → ↑a ≤ ↑b`.
836+
837+ Equivalently, `x ≤ y` can be defined as `∀ b : α, y = ↑b → ∃ a : α, x = ↑a ∧ a ≤ b`,
838+ see `le_iff_forall`. The definition as an inductive predicate is preferred since it
839+ cannot be accidentally unfolded too far. -/
831840instance (priority := 10 ) instLE : LE (WithTop α) where le a b := WithBot.LE (α := αᵒᵈ) b a
832841
833842lemma le_def : x ≤ y ↔ y = ⊤ ∨ ∃ a b : α, a ≤ b ∧ x = a ∧ y = b :=
@@ -896,25 +905,27 @@ section LT
896905
897906variable [LT α] {x y : WithTop α}
898907
899- /-- The order on `WithTop α`, defined by `↑a < ⊤` and `a < b → ↑a < ↑b`. -/
900- instance (priority := 10 ) instLT : LT (WithTop α) where
901- -- We match on `b, a` rather than `a, b` to keep the defeq with `WithBot.instLT (α := αᵒᵈ)`
902- lt a b := match b, a with
903- | ⊤, ⊤ => False
904- | (b : α), ⊤ => False
905- | ⊤, (a : α) => True
906- | (b : α), (a : α) => a < b
908+ /-- The order on `WithTop α`, defined by `↑a < ⊤` and `a < b → ↑a < ↑b`.
909+
910+ Equivalently, `x < y` can be defined as `∃ a : α, x = ↑a ∧ ∀ b : α, y = ↑b → a < b`,
911+ see `le_if_forall`. The definition as an inductive predicate is preferred since it
912+ cannot be accidentally unfolded too far. -/
913+ instance (priority := 10 ) instLT : LT (WithTop α) where lt a b := WithBot.LT (α := αᵒᵈ) b a
914+
915+ lemma lt_def : x < y ↔ (∃ a : α, x = ↑a) ∧ y = ⊤ ∨ ∃ a b : α, a < b ∧ x = ↑a ∧ y = ↑b :=
916+ WithBot.lt_def.trans <| or_congr and_comm <| exists_swap.trans <|
917+ exists₂_congr fun _ _ ↦ and_congr_right' and_comm
907918
908- lemma lt_def : x < y ↔ ∃ a : α, x = ↑a ∧ ∀ b : α, y = ↑b → a < b := by
909- cases x <;> cases y <;> simp [LT.lt ]
919+ lemma lt_iff_exists : x < y ↔ ∃ a : α, x = ↑a ∧ ∀ b : α, y = ↑b → a < b := by
920+ cases x <;> cases y <;> simp [lt_def ]
910921
911922@[simp, norm_cast] lemma coe_lt_coe : (a : WithTop α) < b ↔ a < b := by simp [lt_def]
912923@[simp] lemma coe_lt_top (a : α) : (a : WithTop α) < ⊤ := by simp [lt_def]
913924@[simp] protected lemma not_top_lt (a : WithTop α) : ¬⊤ < a := by simp [lt_def]
914925
915926lemma lt_iff_exists_coe : x < y ↔ ∃ a : α, x = a ∧ a < y := by cases x <;> simp
916927
917- lemma coe_lt_iff : a < y ↔ ∀ b : α, y = b → a < b := by simp [lt_def ]
928+ lemma coe_lt_iff : a < y ↔ ∀ b : α, y = b → a < b := by simp [lt_iff_exists ]
918929
919930/-- A version of `lt_top_iff_ne_top` for `WithTop` that only requires `LT α`, not
920931`PartialOrder α`. -/
0 commit comments