Skip to content
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Mathlib/Algebra/Order/Monoid/WithTop.lean
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,8 @@ protected theorem le_add_self [AddCommMagma α] [LE α] [CanonicallyOrderedAdd
· 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 <;> simp

end WithBot
18 changes: 18 additions & 0 deletions Mathlib/Data/ENat/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,11 @@ theorem succ_def (m : ℕ∞) : Order.succ m = m + 1 :=
theorem add_one_le_iff (hm : m ≠ ⊤) : m + 1 ≤ n ↔ m < n :=
Order.add_one_le_iff_of_not_isMax (not_isMax_iff_ne_top.mpr hm)

theorem add_one_le_iff' (hn : n ≠ ⊤) : m + 1 ≤ n ↔ m < n := by
by_cases hm : m = ⊤
· simp_all
· exact add_one_le_iff hm

theorem one_le_iff_ne_zero : 1 ≤ n ↔ n ≠ 0 :=
Order.one_le_iff_pos.trans pos_iff_ne_zero

Expand Down Expand Up @@ -607,6 +612,9 @@ end ENat

namespace ENat.WithBot

@[simp]
lemma coe_eq_natCast (n : ℕ) : (n : ℕ∞) = (n : WithBot ℕ∞) := rfl

lemma lt_add_one_iff {n : WithBot ℕ∞} {m : ℕ} : n < m + 1 ↔ n ≤ m := by
rw [← WithBot.coe_one, ← ENat.coe_one, WithBot.coe_natCast, ← Nat.cast_add, ← WithBot.coe_natCast]
cases n
Expand All @@ -621,6 +629,16 @@ lemma add_one_le_iff {n : ℕ} {m : WithBot ℕ∞} : n + 1 ≤ m ↔ n < m := b
· rw [WithBot.coe_le_coe, ENat.coe_add, ENat.coe_one, ENat.add_one_le_iff (ENat.coe_ne_top n),
← WithBot.coe_lt_coe, WithBot.coe_natCast]

lemma add_one_le_natCast_iff {n : WithBot ℕ∞} {m : ℕ} : n + 1 ≤ m ↔ n < m := by
induction n with
| bot => simp
| coe n =>
norm_cast
simp [add_one_le_iff']

lemma add_one_le_zero_iff (n : WithBot ℕ∞) : n + 1 ≤ 0 ↔ n = ⊥ :=
add_one_le_natCast_iff.trans (WithBot.lt_zero_iff_eq_bot n)

@[simp]
lemma add_natCast_cancel {a b : WithBot ℕ∞} {c : ℕ} : a + c = b + c ↔ a = b :=
(IsAddRightRegular.all c).withTop.withBot.eq_iff
Expand Down
Loading