Skip to content

Commit 72ca3c2

Browse files
committed
refactor: add and reuse helper lemmas
1 parent 91c75ab commit 72ca3c2

1 file changed

Lines changed: 24 additions & 22 deletions

File tree

Mathlib/SetTheory/Ordinal/FixedPointApproximants.lean

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ theorem le_lfpApprox {a : Ordinal} : x ≤ lfpApprox f x a := by
9494
apply le_sSup
9595
simp only [exists_prop, Set.union_singleton, Set.mem_insert_iff, Set.mem_setOf_eq, true_or]
9696

97+
theorem f_lfpApprox_le_lfpApprox_of_lt {a b : Ordinal} (h : a < b) :
98+
f (lfpApprox f x a) ≤ lfpApprox f x b := by
99+
nth_rw 2 [lfpApprox]
100+
exact le_sSup <| Or.inl ⟨a, h, rfl⟩
101+
97102
theorem lfpApprox_add_one (h : x ≤ f x) (a : Ordinal) :
98103
lfpApprox f x (a + 1) = f (lfpApprox f x a) := by
99104
apply le_antisymm
@@ -108,15 +113,9 @@ theorem lfpApprox_add_one (h : x ≤ f x) (a : Ordinal) :
108113
exact le_lfpApprox f x
109114
· intro a' h
110115
apply f.2; apply lfpApprox_monotone; exact h
111-
· conv => right; rw [lfpApprox]
112-
apply le_sSup
113-
simp only [lt_add_one_iff, exists_prop]
114-
rw [Set.mem_union]
115-
apply Or.inl
116-
simp only [Set.mem_setOf_eq]
117-
use a
118-
119-
theorem lfpApprox_limit {a : Ordinal} (ha : Order.IsSuccLimit a) :
116+
· exact f_lfpApprox_le_lfpApprox_of_lt f x (lt_add_one a)
117+
118+
theorem lfpApprox_of_isSuccLimit {a : Ordinal} (ha : Order.IsSuccLimit a) :
120119
lfpApprox f x a = ⨆ b : Set.Iio a, lfpApprox f x b := by
121120
refine le_antisymm ?_ (iSup_le fun b => lfpApprox_monotone f x b.2.le)
122121
rw [lfpApprox]
@@ -126,9 +125,8 @@ theorem lfpApprox_limit {a : Ordinal} (ha : Order.IsSuccLimit a) :
126125
· exact (lfpApprox_zero f x).symm.trans_le
127126
(le_iSup (fun b : Set.Iio a => lfpApprox f x b) ⟨0, ha.bot_lt⟩)
128127
· intro b hb
129-
trans lfpApprox f x (⟨b + 1, ha.succ_lt hb⟩ : Set.Iio a)
130-
· nth_rw 2 [lfpApprox]
131-
exact le_sSup <| Or.inl ⟨b, lt_add_one b, rfl⟩
128+
trans lfpApprox f x (b+1)
129+
· exact f_lfpApprox_le_lfpApprox_of_lt f x (lt_add_one b)
132130
· exact (le_iSup (fun c : Set.Iio a => lfpApprox f x c) ⟨b + 1, ha.succ_lt hb⟩)
133131

134132
theorem lfpApprox_mono_left : Monotone (lfpApprox : (α →o α) → _) := by
@@ -163,7 +161,7 @@ theorem lfpApprox_mono_mid : Monotone (lfpApprox f) := by
163161
· exact f.monotone (ih i' h_i')
164162

165163
/-- The approximations of the least fixed point stabilize at a fixed point of `f` -/
166-
theorem lfpApprox_eq_of_mem_fixedPoints {a b : Ordinal} (h_init : x ≤ f x) (h_ab : a ≤ b)
164+
theorem lfpApprox_eq_of_mem_fixedPoints {a b : Ordinal} (h_ab : a ≤ b)
167165
(h : lfpApprox f x a ∈ fixedPoints f) : lfpApprox f x b = lfpApprox f x a := by
168166
rw [mem_fixedPoints_iff] at h
169167
induction b using WellFoundedLT.induction with | ind b IH
@@ -175,9 +173,7 @@ theorem lfpApprox_eq_of_mem_fixedPoints {a b : Ordinal} (h_init : x ≤ f x) (h_
175173
apply And.intro (le_lfpApprox f x)
176174
intro a' ha'b
177175
by_cases! haa : a' < a
178-
· rw [← lfpApprox_add_one f x h_init]
179-
apply lfpApprox_monotone
180-
simpa
176+
· exact f_lfpApprox_le_lfpApprox_of_lt f x haa
181177
· rw [IH a' ha'b haa, h]
182178
· exact lfpApprox_monotone f x h_ab
183179

@@ -202,9 +198,11 @@ lemma lfpApprox_mem_fixedPoints_of_eq {a b c : Ordinal}
202198
have lfpApprox_mem_fixedPoint :
203199
lfpApprox f x a ∈ fixedPoints f := by
204200
rw [mem_fixedPoints_iff, ← lfpApprox_add_one f x h_init]
205-
exact Monotone.eq_of_ge_of_le (lfpApprox_monotone f x)
206-
h_fab (SuccOrder.le_succ a) (SuccOrder.succ_le_of_lt h_ab)
207-
rw [lfpApprox_eq_of_mem_fixedPoints f x h_init]
201+
apply le_antisymm
202+
· rw [lfpApprox_add_one f x h_init]
203+
simpa [h_fab] using f_lfpApprox_le_lfpApprox_of_lt f x h_ab
204+
· exact lfpApprox_monotone f x (SuccOrder.le_succ a)
205+
rw [lfpApprox_eq_of_mem_fixedPoints f x]
208206
· exact lfpApprox_mem_fixedPoint
209207
· exact h_ac
210208
· exact lfpApprox_mem_fixedPoint
@@ -282,9 +280,13 @@ theorem gfpApprox_add_one (h : f x ≤ x) (a : Ordinal) :
282280
gfpApprox f x (a + 1) = f (gfpApprox f x a) :=
283281
lfpApprox_add_one f.dual x h a
284282

283+
theorem gfpApprox_le_f_gfpApprox_of_lt {a b : Ordinal} (h : a < b) :
284+
gfpApprox f x b ≤ f (gfpApprox f x a) :=
285+
f_lfpApprox_le_lfpApprox_of_lt f.dual x h
286+
285287
theorem gfpApprox_limit {a : Ordinal} (ha : Order.IsSuccLimit a) :
286288
gfpApprox f x a = ⨅ b : Set.Iio a, gfpApprox f x b :=
287-
lfpApprox_limit f.dual x ha
289+
lfpApprox_of_isSuccLimit f.dual x ha
288290

289291
theorem gfpApprox_mono_left : Monotone (gfpApprox : (α →o α) → _) := by
290292
intro f g h
@@ -295,9 +297,9 @@ theorem gfpApprox_mono_mid : Monotone (gfpApprox f) :=
295297
fun _ _ h => lfpApprox_mono_mid f.dual h
296298

297299
/-- The approximations of the greatest fixed point stabilize at a fixed point of `f` -/
298-
theorem gfpApprox_eq_of_mem_fixedPoints {a b : Ordinal} (h_init : f x ≤ x) (h_ab : a ≤ b)
300+
theorem gfpApprox_eq_of_mem_fixedPoints {a b : Ordinal} (h_ab : a ≤ b)
299301
(h : gfpApprox f x a ∈ fixedPoints f) : gfpApprox f x b = gfpApprox f x a :=
300-
lfpApprox_eq_of_mem_fixedPoints f.dual x h_init h_ab h
302+
lfpApprox_eq_of_mem_fixedPoints f.dual x h_ab h
301303

302304
/-- There are distinct indices smaller than the successor of the domain's cardinality
303305
yielding the same value -/

0 commit comments

Comments
 (0)