@@ -473,6 +473,10 @@ by { cases x, simpa using h, refl, }
473
473
@[simp] lemma unbot_coe (x : α) (h : (x : with_bot α) ≠ ⊥ := coe_ne_bot _) :
474
474
(x : with_bot α).unbot h = x := rfl
475
475
476
+ @[priority 10 ]
477
+ instance has_le [has_le α] : has_le (with_bot α) :=
478
+ { le := λ o₁ o₂ : option α, ∀ a ∈ o₁, ∃ b ∈ o₂, a ≤ b }
479
+
476
480
@[priority 10 ]
477
481
instance has_lt [has_lt α] : has_lt (with_bot α) :=
478
482
{ lt := λ o₁ o₂ : option α, ∃ b ∈ o₂, ∀ a ∈ o₁, a < b }
@@ -493,10 +497,10 @@ instance : can_lift (with_bot α) α :=
493
497
prf := λ x hx, ⟨option.get $ option.ne_none_iff_is_some.1 hx, option.some_get _⟩ }
494
498
495
499
instance [preorder α] : preorder (with_bot α) :=
496
- { le := λ o₁ o₂ : option α, ∀ a ∈ o₁, ∃ b ∈ o₂, a ≤ b ,
500
+ { le := (≤) ,
497
501
lt := (<),
498
502
lt_iff_le_not_le := by intros; cases a; cases b;
499
- simp [lt_iff_le_not_le]; simp [(<)];
503
+ simp [lt_iff_le_not_le]; simp [(≤), ( <)];
500
504
split; refl,
501
505
le_refl := λ o a ha, ⟨a, ha, le_refl _⟩,
502
506
le_trans := λ o₁ o₂ o₃ h₁ h₂ a ha,
@@ -518,20 +522,20 @@ instance order_bot [partial_order α] : order_bot (with_bot α) :=
518
522
{ bot_le := λ a a' h, option.no_confusion h,
519
523
..with_bot.partial_order, ..with_bot.has_bot }
520
524
521
- @[simp, norm_cast] theorem coe_le_coe [preorder α] {a b : α} :
525
+ @[simp, norm_cast] theorem coe_le_coe [has_le α] {a b : α} :
522
526
(a : with_bot α) ≤ b ↔ a ≤ b :=
523
527
⟨λ h, by rcases h a rfl with ⟨_, ⟨⟩, h⟩; exact h,
524
528
λ h a' e, option.some_inj.1 e ▸ ⟨b, rfl, h⟩⟩
525
529
526
- @[simp] theorem some_le_some [preorder α] {a b : α} :
530
+ @[simp] theorem some_le_some [has_le α] {a b : α} :
527
531
@has_le.le (with_bot α) _ (some a) (some b) ↔ a ≤ b := coe_le_coe
528
532
529
- theorem coe_le [preorder α] {a b : α} :
533
+ theorem coe_le [has_le α] {a b : α} :
530
534
∀ {o : option α}, b ∈ o → ((a : with_bot α) ≤ o ↔ a ≤ b)
531
535
| _ rfl := coe_le_coe
532
536
533
537
@[norm_cast]
534
- lemma coe_lt_coe [preorder α] {a b : α} : (a : with_bot α) < b ↔ a < b := some_lt_some
538
+ lemma coe_lt_coe [has_lt α] {a b : α} : (a : with_bot α) < b ↔ a < b := some_lt_some
535
539
536
540
lemma le_coe_get_or_else [preorder α] : ∀ (a : with_bot α) (b : α), a ≤ a.get_or_else b
537
541
| (some a) b := le_refl a
@@ -543,7 +547,7 @@ lemma get_or_else_bot_le_iff [order_bot α] {a : with_bot α} {b : α} :
543
547
a.get_or_else ⊥ ≤ b ↔ a ≤ b :=
544
548
by cases a; simp [none_eq_bot, some_eq_coe]
545
549
546
- instance decidable_le [preorder α] [@decidable_rel α (≤)] : @decidable_rel (with_bot α) (≤)
550
+ instance decidable_le [has_le α] [@decidable_rel α (≤)] : @decidable_rel (with_bot α) (≤)
547
551
| none x := is_true $ λ a h, option.no_confusion h
548
552
| (some x) (some y) :=
549
553
if h : x ≤ y
@@ -756,12 +760,12 @@ instance order_top [partial_order α] : order_top (with_top α) :=
756
760
{ le_top := λ a a' h, option.no_confusion h,
757
761
..with_top.partial_order, .. with_top.has_top }
758
762
759
- @[simp, norm_cast] theorem coe_le_coe [preorder α] {a b : α} :
763
+ @[simp, norm_cast] theorem coe_le_coe [has_le α] {a b : α} :
760
764
(a : with_top α) ≤ b ↔ a ≤ b :=
761
765
⟨λ h, by rcases h b rfl with ⟨_, ⟨⟩, h⟩; exact h,
762
766
λ h a' e, option.some_inj.1 e ▸ ⟨a, rfl, h⟩⟩
763
767
764
- theorem le_coe [preorder α] {a b : α} :
768
+ theorem le_coe [has_le α] {a b : α} :
765
769
∀ {o : option α}, a ∈ o →
766
770
(@has_le.le (with_top α) _ o b ↔ a ≤ b)
767
771
| _ rfl := coe_le_coe
@@ -779,9 +783,9 @@ theorem lt_iff_exists_coe [partial_order α] : ∀{a b : with_top α}, a < b ↔
779
783
| none b := by simp [none_eq_top]
780
784
781
785
@[norm_cast]
782
- lemma coe_lt_coe [preorder α] {a b : α} : (a : with_top α) < b ↔ a < b := some_lt_some
786
+ lemma coe_lt_coe [has_lt α] {a b : α} : (a : with_top α) < b ↔ a < b := some_lt_some
783
787
784
- lemma coe_lt_top [preorder α] (a : α) : (a : with_top α) < ⊤ := some_lt_none a
788
+ lemma coe_lt_top [has_lt α] (a : α) : (a : with_top α) < ⊤ := some_lt_none a
785
789
786
790
theorem coe_lt_iff [preorder α] {a : α} : ∀{x : with_top α}, ↑a < x ↔ (∀b:α, x = ↑b → a < b)
787
791
| (some b) := by simp [some_eq_coe, coe_eq_coe, coe_lt_coe]
@@ -790,7 +794,7 @@ theorem coe_lt_iff [preorder α] {a : α} : ∀{x : with_top α}, ↑a < x ↔ (
790
794
lemma not_top_le_coe [preorder α] (a : α) : ¬ (⊤:with_top α) ≤ ↑a :=
791
795
λ h, (lt_irrefl ⊤ (lt_of_le_of_lt h (coe_lt_top a))).elim
792
796
793
- instance decidable_le [preorder α] [@decidable_rel α (≤)] : @decidable_rel (with_top α) (≤) :=
797
+ instance decidable_le [has_le α] [@decidable_rel α (≤)] : @decidable_rel (with_top α) (≤) :=
794
798
λ x y, @with_bot.decidable_le (order_dual α) _ _ y x
795
799
796
800
instance decidable_lt [has_lt α] [@decidable_rel α (<)] : @decidable_rel (with_top α) (<) :=
0 commit comments