Skip to content

Commit 3c3631e

Browse files
committed
feat: generalize WithBot.wellFounded_lt (#5425)
1 parent 0171e87 commit 3c3631e

File tree

1 file changed

+23
-32
lines changed

1 file changed

+23
-32
lines changed

Mathlib/Order/WithBot.lean

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -490,24 +490,16 @@ theorem coe_max [LinearOrder α] (x y : α) : ((max x y : α) : WithBot α) = ma
490490
rfl
491491
#align with_bot.coe_max WithBot.coe_max
492492

493-
theorem wellFounded_lt [Preorder α] (h : @WellFounded α (· < ·)) :
493+
theorem wellFounded_lt [LT α] (h : @WellFounded α (· < ·)) :
494494
@WellFounded (WithBot α) (· < ·) :=
495-
have acc_bot : Acc ((· < ·) : WithBot α → WithBot α → Prop) ⊥ :=
496-
Acc.intro _ fun _ ha => (not_le_of_gt ha bot_le).elim
497-
fun a =>
498-
Option.recOn a acc_bot fun a =>
499-
Acc.intro _ fun b =>
500-
Option.recOn b (fun _ => acc_bot) fun b =>
501-
WellFounded.induction h b
502-
(show
503-
∀ b : α,
504-
(∀ c, c < b → (c : WithBot α) < a → Acc
505-
((· < ·) : WithBot α → WithBot α → Prop) c) →
506-
(b : WithBot α) < a → Acc ((· < ·) : WithBot α → WithBot α → Prop) b
507-
from fun _ ih hba =>
508-
Acc.intro _ fun c =>
509-
Option.recOn c (fun _ => acc_bot) fun _ hc => ih _
510-
(some_lt_some.1 hc) (lt_trans hc hba))⟩
495+
have not_lt_bot : ∀ a : WithBot α, ¬ a < ⊥ := (fun.)
496+
have acc_bot := ⟨_, by simp [not_lt_bot]⟩
497+
.intro fun
498+
| ⊥ => acc_bot
499+
| (a : α) => (h.1 a).rec fun a _ ih =>
500+
.intro _ fun
501+
| ⊥, _ => acc_bot
502+
| (b : α), hlt => ih _ (some_lt_some.1 hlt)
511503
#align with_bot.well_founded_lt WithBot.wellFounded_lt
512504

513505
instance denselyOrdered [LT α] [DenselyOrdered α] [NoMinOrder α] : DenselyOrdered (WithBot α) :=
@@ -1246,25 +1238,24 @@ theorem coe_max [LinearOrder α] (x y : α) : (↑(max x y) : WithTop α) = max
12461238
rfl
12471239
#align with_top.coe_max WithTop.coe_max
12481240

1249-
theorem wellFounded_lt [Preorder α] (h : @WellFounded α (· < ·)) :
1241+
theorem wellFounded_lt [LT α] (h : @WellFounded α (· < ·)) :
12501242
@WellFounded (WithTop α) (· < ·) :=
1251-
have acc_some : ∀ a : α, Acc ((· < ·) : WithTop α → WithTop α → Prop) (some a) := fun a =>
1252-
Acc.intro _
1253-
(WellFounded.induction h a
1254-
(show
1255-
∀ b, (∀ c, c < b → ∀ d : WithTop α, d < some c → Acc (· < ·) d) →
1256-
∀ y : WithTop α, y < some b → Acc (· < ·) y
1257-
from fun _ ih c =>
1258-
Option.recOn c (fun hc => (not_lt_of_ge le_top hc).elim) fun _ hc =>
1259-
Acc.intro _ (ih _ (some_lt_some.1 hc))))
1260-
fun a =>
1261-
Option.recOn a (Acc.intro _ fun y => Option.recOn y
1262-
(fun h => (lt_irrefl _ h).elim) fun _ _ => acc_some _) acc_some⟩
1243+
have not_top_lt : ∀ a : WithTop α, ¬ ⊤ < a := (fun.)
1244+
have acc_some (a : α) : Acc ((· < ·) : WithTop α → WithTop α → Prop) a :=
1245+
(h.1 a).rec fun _ _ ih =>
1246+
.intro _ fun
1247+
| (b : α), hlt => ih _ (some_lt_some.1 hlt)
1248+
| ⊤, hlt => nomatch not_top_lt _ hlt
1249+
.intro fun
1250+
| (a : α) => acc_some a
1251+
| ⊤ => .intro _ fun
1252+
| (b : α), _ => acc_some b
1253+
| ⊤, hlt => nomatch not_top_lt _ hlt
12631254
#align with_top.well_founded_lt WithTop.wellFounded_lt
12641255

12651256
open OrderDual
12661257

1267-
theorem wellFounded_gt [Preorder α] (h : @WellFounded α (· > ·)) :
1258+
theorem wellFounded_gt [LT α] (h : @WellFounded α (· > ·)) :
12681259
@WellFounded (WithTop α) (· > ·) :=
12691260
fun a => by
12701261
-- ideally, use rel_hom_class.acc, but that is defined later
@@ -1279,7 +1270,7 @@ theorem wellFounded_gt [Preorder α] (h : @WellFounded α (· > ·)) :
12791270
exact ⟨_, fun a' h => IH (WithTop.toDual a') (toDual_lt_toDual.mpr h) _ rfl⟩⟩
12801271
#align with_top.well_founded_gt WithTop.wellFounded_gt
12811272

1282-
theorem _root_.WithBot.wellFounded_gt [Preorder α] (h : @WellFounded α (· > ·)) :
1273+
theorem _root_.WithBot.wellFounded_gt [LT α] (h : @WellFounded α (· > ·)) :
12831274
@WellFounded (WithBot α) (· > ·) :=
12841275
fun a => by
12851276
-- ideally, use rel_hom_class.acc, but that is defined later

0 commit comments

Comments
 (0)