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

Commit b2b39ed

Browse files
committed
chore(order/galois_connection): define with_bot.gi_get_or_else_bot (#4781)
This Galois insertion can be used to golf proofs about `polynomial.degree` vs `polynomial.nat_degree`.
1 parent 121c9a4 commit b2b39ed

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/data/option/basic.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ theorem get_of_mem {a : α} : ∀ {o : option α} (h : is_some o), a ∈ o → o
2828

2929
@[simp] lemma get_or_else_some (x y : α) : option.get_or_else (some x) y = x := rfl
3030

31+
@[simp] lemma get_or_else_coe (x y : α) : option.get_or_else ↑x y = x := rfl
32+
3133
lemma get_or_else_of_ne_none {x : option α} (hx : x ≠ none) (y : α) : some (x.get_or_else y) = x :=
3234
by cases x; [contradiction, rw get_or_else_some]
3335

src/order/bounded_lattice.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,12 @@ lemma le_coe_get_or_else [preorder α] : ∀ (a : with_bot α) (b : α), a ≤ a
488488
| (some a) b := le_refl a
489489
| none b := λ _ h, option.no_confusion h
490490

491+
@[simp] lemma get_or_else_bot (a : α) : option.get_or_else (⊥ : with_bot α) a = a := rfl
492+
493+
lemma get_or_else_bot_le_iff [order_bot α] {a : with_bot α} {b : α} :
494+
a.get_or_else ⊥ ≤ b ↔ a ≤ b :=
495+
by cases a; simp [none_eq_bot, some_eq_coe]
496+
491497
instance linear_order [linear_order α] : linear_order (with_bot α) :=
492498
{ le_total := λ o₁ o₂, begin
493499
cases o₁ with a, {exact or.inl bot_le},

src/order/galois_connection.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,3 +547,12 @@ def lift_complete_lattice [complete_lattice β] (gi : galois_coinsertion l u) :
547547
end lift
548548

549549
end galois_coinsertion
550+
551+
/-- If `α` is a partial order with bottom element (e.g., `ℕ`, `ℝ≥0`), then
552+
`λ o : with_bot α, o.get_or_else ⊥` and coercion form a Galois insertion. -/
553+
def with_bot.gi_get_or_else_bot [order_bot α] :
554+
galois_insertion (λ o : with_bot α, o.get_or_else ⊥) coe :=
555+
{ gc := λ a b, with_bot.get_or_else_bot_le_iff,
556+
le_l_u := λ a, le_rfl,
557+
choice := λ o ho, _,
558+
choice_eq := λ _ _, rfl }

0 commit comments

Comments
 (0)