forked from leanprover-community/mathlib4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWithTop.lean
More file actions
73 lines (57 loc) · 2 KB
/
WithTop.lean
File metadata and controls
73 lines (57 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/-
Copyright (c) 2016 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro, Johannes Hölzl
-/
module
public import Mathlib.Algebra.Order.Monoid.Unbundled.WithTop
public import Mathlib.Algebra.Order.Monoid.Canonical.Defs
/-! # Adjoining top/bottom elements to ordered monoids.
-/
@[expose] public section
universe u
variable {α : Type u}
open Function
namespace WithTop
instance isOrderedAddMonoid [AddCommMonoid α] [PartialOrder α] [IsOrderedAddMonoid α] :
IsOrderedAddMonoid (WithTop α) where
add_le_add_left _ _ := add_le_add_left
instance canonicallyOrderedAdd [Add α] [Preorder α] [CanonicallyOrderedAdd α] :
CanonicallyOrderedAdd (WithTop α) where
le_self_add
| ⊤, _ => le_rfl
| (a : α), ⊤ => le_top
| (a : α), (b : α) => WithTop.coe_le_coe.2 le_self_add
le_add_self
| ⊤, ⊤ | ⊤, (b : α) => le_rfl
| (a : α), ⊤ => le_top
| (a : α), (b : α) => WithTop.coe_le_coe.2 le_add_self
end WithTop
namespace WithBot
instance isOrderedAddMonoid [AddCommMonoid α] [PartialOrder α] [IsOrderedAddMonoid α] :
IsOrderedAddMonoid (WithBot α) :=
{ add_le_add_left := fun _ _ h c => add_le_add_left h c }
protected theorem le_self_add [Add α] [LE α] [CanonicallyOrderedAdd α]
{x : WithBot α} (hx : x ≠ ⊥) (y : WithBot α) :
y ≤ y + x := by
induction x
· simp at hx
induction y
· simp
· rw [← WithBot.coe_add, WithBot.coe_le_coe]
exact le_self_add
protected theorem le_add_self [AddCommMagma α] [LE α] [CanonicallyOrderedAdd α]
{x : WithBot α} (hx : x ≠ ⊥) (y : WithBot α) :
y ≤ x + y := by
induction x
· simp at hx
induction y
· simp
· rw [← WithBot.coe_add, WithBot.coe_le_coe]
exact le_add_self
lemma lt_zero_iff_eq_bot {α : Type*} [AddMonoid α] [Preorder α] [CanonicallyOrderedAdd α]
(a : WithBot α) : a < 0 ↔ a = ⊥ := by
induction a with
| bot => simp
| coe => simp
end WithBot