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

Commit faf5e5c

Browse files
committed
feat(order/bounded_lattice): unbot and untop (#8885)
`unbot` sends non-`⊥` elements of `with_bot α` to the corresponding element of `α`. `untop` does the analogous thing for `with_top`.
1 parent f3101e8 commit faf5e5c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/order/bounded_lattice.lean

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,14 @@ option.rec h₁ h₂
493493
theorem coe_eq_coe {a b : α} : (a : with_bot α) = b ↔ a = b :=
494494
by rw [← option.some.inj_eq a b]; refl
495495

496+
/-- Deconstruct a `x : with_bot α` to the underlying value in `α`, given a proof that `x ≠ ⊥`. -/
497+
def unbot : Π (x : with_bot α), x ≠ ⊥ → α
498+
| ⊥ h := absurd rfl h
499+
| (some x) h := x
500+
501+
@[simp] lemma unbot_coe (x : α) (h : (x : with_bot α) ≠ ⊥ := coe_ne_bot _) :
502+
(x : with_bot α).unbot h = x := rfl
503+
496504
@[priority 10]
497505
instance has_lt [has_lt α] : has_lt (with_bot α) :=
498506
{ lt := λ o₁ o₂ : option α, ∃ b ∈ o₂, ∀ a ∈ o₁, a < b }
@@ -720,6 +728,13 @@ by rw [← option.some.inj_eq a b]; refl
720728
@[simp] theorem top_ne_coe {a : α} : ⊤ ≠ (a : with_top α) .
721729
@[simp] theorem coe_ne_top {a : α} : (a : with_top α) ≠ ⊤ .
722730

731+
/-- Deconstruct a `x : with_top α` to the underlying value in `α`, given a proof that `x ≠ ⊤`. -/
732+
def untop : Π (x : with_top α), x ≠ ⊤ → α :=
733+
with_bot.unbot
734+
735+
@[simp] lemma untop_coe (x : α) (h : (x : with_top α) ≠ ⊤ := coe_ne_top) :
736+
(x : with_top α).untop h = x := rfl
737+
723738
@[priority 10]
724739
instance has_lt [has_lt α] : has_lt (with_top α) :=
725740
{ lt := λ o₁ o₂ : option α, ∃ b ∈ o₁, ∀ a ∈ o₂, b < a }

0 commit comments

Comments
 (0)