Skip to content

Commit 69f3b8d

Browse files
feat(Data/ENat): more lemma about WithBot ENat (#36817)
In this PR, we add some lemma about WithBot ENat found useful in dimension shifting. Co-authored-by: Yimin Fu <fakegreenall@foxmail.com>
1 parent 40bda1e commit 69f3b8d

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Mathlib/Algebra/Order/Monoid/WithTop.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,8 @@ protected theorem le_add_self [AddCommMagma α] [LE α] [CanonicallyOrderedAdd
6464
· rw [← WithBot.coe_add, WithBot.coe_le_coe]
6565
exact le_add_self
6666

67+
lemma lt_zero_iff_eq_bot {α : Type*} [AddMonoid α] [Preorder α] [CanonicallyOrderedAdd α]
68+
(a : WithBot α) : a < 0 ↔ a = ⊥ := by
69+
induction a <;> simp
70+
6771
end WithBot

Mathlib/Data/ENat/Basic.lean

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,11 @@ theorem succ_def (m : ℕ∞) : Order.succ m = m + 1 :=
279279
theorem add_one_le_iff (hm : m ≠ ⊤) : m + 1 ≤ n ↔ m < n :=
280280
Order.add_one_le_iff_of_not_isMax (not_isMax_iff_ne_top.mpr hm)
281281

282+
theorem add_one_le_iff' (hn : n ≠ ⊤) : m + 1 ≤ n ↔ m < n := by
283+
rcases eq_or_ne m ⊤ with rfl | hm
284+
· simpa
285+
· exact add_one_le_iff hm
286+
282287
theorem one_le_iff_ne_zero : 1 ≤ n ↔ n ≠ 0 :=
283288
Order.one_le_iff_pos.trans pos_iff_ne_zero
284289

@@ -607,6 +612,9 @@ end ENat
607612

608613
namespace ENat.WithBot
609614

615+
@[simp]
616+
lemma coe_eq_natCast (n : ℕ) : (n : ℕ∞) = (n : WithBot ℕ∞) := rfl
617+
610618
lemma lt_add_one_iff {n : WithBot ℕ∞} {m : ℕ} : n < m + 1 ↔ n ≤ m := by
611619
rw [← WithBot.coe_one, ← ENat.coe_one, WithBot.coe_natCast, ← Nat.cast_add, ← WithBot.coe_natCast]
612620
cases n
@@ -621,6 +629,17 @@ lemma add_one_le_iff {n : ℕ} {m : WithBot ℕ∞} : n + 1 ≤ m ↔ n < m := b
621629
· rw [WithBot.coe_le_coe, ENat.coe_add, ENat.coe_one, ENat.add_one_le_iff (ENat.coe_ne_top n),
622630
← WithBot.coe_lt_coe, WithBot.coe_natCast]
623631

632+
lemma add_one_le_natCast_iff {n : WithBot ℕ∞} {m : ℕ} : n + 1 ≤ m ↔ n < m := by
633+
induction n with
634+
| bot => simp
635+
| coe n =>
636+
norm_cast
637+
simp [add_one_le_iff']
638+
639+
@[simp]
640+
lemma add_one_le_zero_iff (n : WithBot ℕ∞) : n + 10 ↔ n = ⊥ :=
641+
add_one_le_natCast_iff.trans (WithBot.lt_zero_iff_eq_bot n)
642+
624643
@[simp]
625644
lemma add_natCast_cancel {a b : WithBot ℕ∞} {c : ℕ} : a + c = b + c ↔ a = b :=
626645
(IsAddRightRegular.all c).withTop.withBot.eq_iff

0 commit comments

Comments
 (0)