Skip to content

Commit 2fbbcf1

Browse files
committed
feat: the successor as a function WithBot α → α (#20055)
This will be useful to do induction on a family of polynomials by the sum of the successor of their degree. From GrowthInGroups (LeanCamCombi) Co-authored-by: Andrew Yang
1 parent 92c2d0c commit 2fbbcf1

File tree

5 files changed

+112
-13
lines changed

5 files changed

+112
-13
lines changed

Mathlib.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ import Mathlib.Algebra.Order.Sub.Unbundled.Hom
775775
import Mathlib.Algebra.Order.Sub.WithTop
776776
import Mathlib.Algebra.Order.SuccPred
777777
import Mathlib.Algebra.Order.SuccPred.TypeTags
778+
import Mathlib.Algebra.Order.SuccPred.WithBot
778779
import Mathlib.Algebra.Order.Sum
779780
import Mathlib.Algebra.Order.ToIntervalMod
780781
import Mathlib.Algebra.Order.UpperLower
@@ -4175,6 +4176,7 @@ import Mathlib.Order.SuccPred.Limit
41754176
import Mathlib.Order.SuccPred.LinearLocallyFinite
41764177
import Mathlib.Order.SuccPred.Relation
41774178
import Mathlib.Order.SuccPred.Tree
4179+
import Mathlib.Order.SuccPred.WithBot
41784180
import Mathlib.Order.SupClosed
41794181
import Mathlib.Order.SupIndep
41804182
import Mathlib.Order.SymmDiff
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/-
2+
Copyright (c) 2024 Yaël Dillies, Andrew Yang. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Yaël Dillies, Andrew Yang
5+
-/
6+
import Mathlib.Algebra.Order.Monoid.Unbundled.WithTop
7+
import Mathlib.Algebra.Order.SuccPred
8+
import Mathlib.Order.SuccPred.WithBot
9+
10+
/-!
11+
# Algebraic properties of the successor function on `WithBot`
12+
-/
13+
14+
namespace WithBot
15+
variable {α : Type*} [Preorder α] [OrderBot α] [AddMonoidWithOne α] [SuccAddOrder α]
16+
17+
lemma succ_natCast (n : ℕ) : succ (n : WithBot α) = n + 1 := by
18+
rw [← WithBot.coe_natCast, succ_coe, Order.succ_eq_add_one]
19+
20+
@[simp] lemma succ_zero : succ (0 : WithBot α) = 1 := by simpa using succ_natCast 0
21+
22+
@[simp]
23+
lemma succ_one : succ (1 : WithBot α) = 2 := by simpa [one_add_one_eq_two] using succ_natCast 1
24+
25+
@[simp]
26+
lemma succ_ofNat (n : ℕ) [n.AtLeastTwo] :
27+
succ (no_index (OfNat.ofNat n) : WithBot α) = OfNat.ofNat n + 1 := succ_natCast n
28+
29+
end WithBot

Mathlib/Algebra/Polynomial/Splits.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ theorem splits_of_degree_le_one {f : K[X]} (hf : degree f ≤ 1) : Splits i f :=
7777
if hif : degree (f.map i) ≤ 0 then splits_of_map_eq_C i (degree_le_zero_iff.mp hif)
7878
else by
7979
push_neg at hif
80-
rw [← Order.succ_le_iff, ← WithBot.coe_zero, WithBot.succ_coe, Nat.succ_eq_succ] at hif
80+
rw [← Order.succ_le_iff, ← WithBot.coe_zero, WithBot.orderSucc_coe, Nat.succ_eq_succ] at hif
8181
exact splits_of_map_degree_eq_one i ((degree_map_le.trans hf).antisymm hif)
8282

8383
theorem splits_of_degree_eq_one {f : K[X]} (hf : degree f = 1) : Splits i f :=

Mathlib/Order/SuccPred/Basic.lean

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,13 +1063,11 @@ instance : PredOrder (WithTop α) where
10631063
· exact coe_le_coe.2 le_top
10641064
exact coe_le_coe.2 (le_pred_of_lt <| coe_lt_coe.1 h)
10651065

1066-
@[simp]
1067-
theorem pred_top : pred (⊤ : WithTop α) = ↑(⊤ : α) :=
1068-
rfl
1066+
/-- Not to be confused with `WithTop.pred_bot`, which is about `WithTop.pred`. -/
1067+
@[simp] lemma orderPred_top : pred (⊤ : WithTop α) = ↑(⊤ : α) := rfl
10691068

1070-
@[simp]
1071-
theorem pred_coe (a : α) : pred (↑a : WithTop α) = ↑(pred a) :=
1072-
rfl
1069+
/-- Not to be confused with `WithTop.pred_coe`, which is about `WithTop.pred`. -/
1070+
@[simp] lemma orderPred_coe (a : α) : pred (↑a : WithTop α) = ↑(pred a) := rfl
10731071

10741072
@[simp]
10751073
theorem pred_untop :
@@ -1125,13 +1123,11 @@ instance : SuccOrder (WithBot α) where
11251123
· exact coe_le_coe.2 bot_le
11261124
· exact coe_le_coe.2 (succ_le_of_lt <| coe_lt_coe.1 h)
11271125

1128-
@[simp]
1129-
theorem succ_bot : succ (⊥ : WithBot α) = ↑(⊥ : α) :=
1130-
rfl
1126+
/-- Not to be confused with `WithBot.succ_bot`, which is about `WithBot.succ`. -/
1127+
@[simp] lemma orderSucc_bot : succ (⊥ : WithBot α) = ↑(⊥ : α) := rfl
11311128

1132-
@[simp]
1133-
theorem succ_coe (a : α) : succ (↑a : WithBot α) = ↑(succ a) :=
1134-
rfl
1129+
/-- Not to be confused with `WithBot.succ_coe`, which is about `WithBot.succ`. -/
1130+
@[simp] lemma orderSucc_coe (a : α) : succ (↑a : WithBot α) = ↑(succ a) := rfl
11351131

11361132
@[simp]
11371133
theorem succ_unbot :
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/-
2+
Copyright (c) 2024 Yaël Dillies, Andrew Yang. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Yaël Dillies, Andrew Yang
5+
-/
6+
import Mathlib.Order.SuccPred.Basic
7+
8+
/-!
9+
# Successor function on `WithBot`
10+
11+
This file defines the successor of `a : WithBot α` as an element of `α`, and dually for `WithTop`.
12+
-/
13+
14+
namespace WithBot
15+
variable {α : Type*} [Preorder α] [OrderBot α] [SuccOrder α] {x y : WithBot α}
16+
17+
/-- The successor of `a : WithBot α` as an element of `α`. -/
18+
def succ (a : WithBot α) : α := a.recBotCoe ⊥ Order.succ
19+
20+
/-- Not to be confused with `WithBot.orderSucc_bot`, which is about `Order.succ`. -/
21+
@[simp] lemma succ_bot : succ (⊥ : WithBot α) = ⊥ := rfl
22+
23+
/-- Not to be confused with `WithBot.orderSucc_coe`, which is about `Order.succ`. -/
24+
@[simp] lemma succ_coe (a : α) : succ (a : WithBot α) = Order.succ a := rfl
25+
26+
lemma succ_eq_succ : ∀ a : WithBot α, succ a = Order.succ a
27+
| ⊥ => rfl
28+
| (a : α) => rfl
29+
30+
lemma succ_mono : Monotone (succ : WithBot α → α)
31+
| ⊥, _, _ => by simp
32+
| (a : α), ⊥, hab => by simp at hab
33+
| (a : α), (b : α), hab => Order.succ_le_succ (by simpa using hab)
34+
35+
lemma succ_strictMono [NoMaxOrder α] : StrictMono (succ : WithBot α → α)
36+
| ⊥, (b : α), hab => by simp
37+
| (a : α), (b : α), hab => Order.succ_lt_succ (by simpa using hab)
38+
39+
@[gcongr] lemma succ_le_succ (hxy : x ≤ y) : x.succ ≤ y.succ := succ_mono hxy
40+
@[gcongr] lemma succ_lt_succ [NoMaxOrder α] (hxy : x < y) : x.succ < y.succ := succ_strictMono hxy
41+
42+
end WithBot
43+
44+
namespace WithTop
45+
variable {α : Type*} [Preorder α] [OrderTop α] [PredOrder α] {x y : WithTop α}
46+
47+
/-- The predessor of `a : WithTop α` as an element of `α`. -/
48+
def pred (a : WithTop α) : α := a.recTopCoe ⊤ Order.pred
49+
50+
/-- Not to be confused with `WithTop.orderPred_top`, which is about `Order.pred`. -/
51+
@[simp] lemma pred_top : pred (⊤ : WithTop α) = ⊤ := rfl
52+
53+
/-- Not to be confused with `WithTop.orderPred_coe`, which is about `Order.pred`. -/
54+
@[simp] lemma pred_coe (a : α) : pred (a : WithTop α) = Order.pred a := rfl
55+
56+
lemma pred_eq_pred : ∀ a : WithTop α, pred a = Order.pred a
57+
| ⊤ => rfl
58+
| (a : α) => rfl
59+
60+
lemma pred_mono : Monotone (pred : WithTop α → α)
61+
| _, ⊤, _ => by simp
62+
| ⊤, (a : α), hab => by simp at hab
63+
| (a : α), (b : α), hab => Order.pred_le_pred (by simpa using hab)
64+
65+
lemma pred_strictMono [NoMinOrder α] : StrictMono (pred : WithTop α → α)
66+
| (b : α), ⊤, hab => by simp
67+
| (a : α), (b : α), hab => Order.pred_lt_pred (by simpa using hab)
68+
69+
@[gcongr] lemma pred_le_pred (hxy : x ≤ y) : x.pred ≤ y.pred := pred_mono hxy
70+
@[gcongr] lemma pred_lt_pred [NoMinOrder α] (hxy : x < y) : x.pred < y.pred := pred_strictMono hxy
71+
72+
end WithTop

0 commit comments

Comments
 (0)