88prelude
99public import Init.Data.Iterators.Consumers.Monadic.Partial
1010public import Init.Data.Iterators.Internal.LawfulMonadLiftFunction
11- public import Init.Internal.ExtrinsicTermination
11+ public import Init.WFExtrinsicFix
1212public import Init.Data.Iterators.Consumers.Monadic.Total
1313
1414public section
@@ -101,12 +101,12 @@ def IterM.DefaultConsumers.forIn' {m : Type w → Type w'} {α : Type w} {β : T
101101 [Iterator α m β]
102102 {n : Type x → Type x'} [Monad n]
103103 (lift : ∀ γ δ, (γ → n δ) → m γ → n δ) (γ : Type x)
104- (plausible_forInStep : β → γ → ForInStep γ → Prop )
104+ (PlausibleForInStep : β → γ → ForInStep γ → Prop )
105105 (it : IterM (α := α) m β) (init : γ)
106106 (P : β → Prop ) (hP : ∀ b, it.IsPlausibleIndirectOutput b → P b)
107- (f : (b : β) → P b → (c : γ) → n (Subtype (plausible_forInStep b c))) : n γ :=
107+ (f : (b : β) → P b → (c : γ) → n (Subtype (PlausibleForInStep b c))) : n γ :=
108108 haveI : Nonempty γ := ⟨init⟩
109- extrinsicFix₃ (C₃ := fun _ _ _ => n γ) (InvImage (IteratorLoop.rel α m plausible_forInStep ) (fun x => (x.1 , x.2 .1 )))
109+ WellFounded. extrinsicFix₃ (C₃ := fun _ _ _ => n γ) (InvImage (IteratorLoop.rel α m PlausibleForInStep ) (fun x => (x.1 , x.2 .1 )))
110110 (fun it acc (hP : ∀ b, it.IsPlausibleIndirectOutput b → P b) recur => (lift _ _ · it.step) fun s => do
111111 match s.inflate with
112112 | .yield it' out h =>
@@ -121,25 +121,24 @@ This is the loop implementation of the default instance `IteratorLoop.defaultImp
121121-/
122122@[specialize, expose]
123123def IterM.DefaultConsumers.forIn'.wf {m : Type w → Type w'} {α : Type w} {β : Type w}
124- [Iterator α m β]
125- {n : Type x → Type x'} [Monad n]
124+ [Iterator α m β] {n : Type x → Type x'} [Monad n]
126125 (lift : ∀ γ δ, (γ → n δ) → m γ → n δ) (γ : Type x)
127- (plausible_forInStep : β → γ → ForInStep γ → Prop )
128- (wf : IteratorLoop.WellFounded α m plausible_forInStep )
126+ (PlausibleForInStep : β → γ → ForInStep γ → Prop )
127+ (wf : IteratorLoop.WellFounded α m PlausibleForInStep )
129128 (it : IterM (α := α) m β) (init : γ)
130129 (P : β → Prop ) (hP : ∀ b, it.IsPlausibleIndirectOutput b → P b)
131- (f : (b : β) → P b → (c : γ) → n (Subtype (plausible_forInStep b c))) : n γ :=
130+ (f : (b : β) → P b → (c : γ) → n (Subtype (PlausibleForInStep b c))) : n γ :=
132131 haveI : WellFounded _ := wf
133132 (lift _ _ · it.step) fun s =>
134133 match s.inflate with
135134 | .yield it' out h => do
136135 match ← f out (hP _ <| .direct ⟨_, h⟩) init with
137136 | ⟨.yield c, _⟩ =>
138- IterM.DefaultConsumers.forIn'.wf lift _ plausible_forInStep wf it' c P
137+ IterM.DefaultConsumers.forIn'.wf lift _ PlausibleForInStep wf it' c P
139138 (fun _ h' => hP _ <| .indirect ⟨_, rfl, h⟩ h') f
140139 | ⟨.done c, _⟩ => return c
141140 | .skip it' h =>
142- IterM.DefaultConsumers.forIn'.wf lift _ plausible_forInStep wf it' init P
141+ IterM.DefaultConsumers.forIn'.wf lift _ PlausibleForInStep wf it' init P
143142 (fun _ h' => hP _ <| .indirect ⟨_, rfl, h⟩ h') f
144143 | .done _ => return init
145144termination_by IteratorLoop.WithWF.mk it init (hwf := wf)
@@ -284,7 +283,7 @@ function. Therefore, it may *not* be equivalent to `it.toList.foldlM`.
284283
285284This function is deprecated. Instead of `it.allowNontermination.foldM`, use `it.foldM`.
286285-/
287- @[always_inline, inline, deprecated IterM.foldM (since := "2025-10-21 ")]
286+ @[always_inline, inline, deprecated IterM.foldM (since := "2025-12-04 ")]
288287def IterM.Partial.foldM {m : Type w → Type w'} {n : Type w → Type w'} [Monad n]
289288 {α : Type w} {β : Type w} {γ : Type w} [Iterator α m β] [IteratorLoop α m n] [MonadLiftT m n]
290289 (f : γ → β → n γ) (init : γ) (it : IterM.Partial (α := α) m β) : n γ :=
@@ -326,7 +325,7 @@ It is equivalent to `it.toList.foldl`.
326325
327326This function is deprecated. Instead of `it.allowNontermination.fold`, use `it.fold`.
328327-/
329- @[always_inline, inline, deprecated IterM.Partial.fold (since := "2025-10-21 ")]
328+ @[always_inline, inline, deprecated IterM.Partial.fold (since := "2025-12-04 ")]
330329def IterM.Partial.fold {m : Type w → Type w'} {α : Type w} {β : Type w} {γ : Type w}
331330 [Monad m] [Iterator α m β] [IteratorLoop α m m] (f : γ → β → γ) (init : γ)
332331 (it : IterM.Partial (α := α) m β) : m γ :=
@@ -363,7 +362,7 @@ emitted values.
363362
364363This function is deprecated. Instead of `it.allowNontermination.drain`, use `it.drain`.
365364-/
366- @[always_inline, inline, deprecated IterM.drain (since := "2025-10-21 ")]
365+ @[always_inline, inline, deprecated IterM.drain (since := "2025-12-04 ")]
367366def IterM.Partial.drain {α : Type w} {m : Type w → Type w'} [Monad m] {β : Type w}
368367 [Iterator α m β] (it : IterM.Partial (α := α) m β) [IteratorLoop α m m] : m PUnit :=
369368 it.it.fold (γ := PUnit) (fun _ _ => .unit) .unit
@@ -408,7 +407,7 @@ examined in order of iteration.
408407
409408This function is deprecated. Instead of {lit}`it.allowNontermination.anyM`, use {lit}`it.anyM`.
410409-/
411- @[always_inline, inline, deprecated IterM.anyM (since := "2025-10-21 ")]
410+ @[always_inline, inline, deprecated IterM.anyM (since := "2025-12-04 ")]
412411def IterM.Partial.anyM {α β : Type w} {m : Type w → Type w'} [Monad m]
413412 [Iterator α m β] [IteratorLoop α m m] (p : β → m (ULift Bool))
414413 (it : IterM.Partial (α := α) m β) : m (ULift Bool) :=
@@ -455,7 +454,7 @@ examined in order of iteration.
455454
456455This function is deprecated. Instead of {lit}`it.allowNontermination.any`, use {lit}`it.any`.
457456-/
458- @[inline, deprecated IterM.any (since := "2025-10-21 ")]
457+ @[inline, deprecated IterM.any (since := "2025-12-04 ")]
459458def IterM.Partial.any {α β : Type w} {m : Type w → Type w'} [Monad m] [Iterator α m β]
460459 [IteratorLoop α m m] (p : β → Bool) (it : IterM.Partial (α := α) m β) : m (ULift Bool) := do
461460 it.it.any p
@@ -504,7 +503,7 @@ examined in order of iteration.
504503
505504This function is deprecated. Instead of {lit}`it.allowNontermination.allM`, use {lit}`it.allM`.
506505-/
507- @[always_inline, inline, deprecated IterM.allM (since := "2025-10-21 ")]
506+ @[always_inline, inline, deprecated IterM.allM (since := "2025-12-04 ")]
508507def IterM.Partial.allM {α β : Type w} {m : Type w → Type w'} [Monad m] [Iterator α m β]
509508 [IteratorLoop α m m] (p : β → m (ULift Bool)) (it : IterM.Partial (α := α) m β) :
510509 m (ULift Bool) := do
@@ -553,7 +552,7 @@ examined in order of iteration.
553552
554553This function is deprecated. Instead of {lit}`it.allowNontermination.allM`, use {lit}`it.allM`.
555554-/
556- @[inline, deprecated IterM.all (since := "2025-10-21 ")]
555+ @[inline, deprecated IterM.all (since := "2025-12-04 ")]
557556def IterM.Partial.all {α β : Type w} {m : Type w → Type w'} [Monad m] [Iterator α m β]
558557 [IteratorLoop α m m] (p : β → Bool) (it : IterM.Partial (α := α) m β) : m (ULift Bool) := do
559558 it.it.all p
@@ -637,7 +636,7 @@ Almost! 5
637636some 10
638637```
639638-/
640- @[inline, deprecated IterM.findSomeM? (since := "2025-10-21 ")]
639+ @[inline, deprecated IterM.findSomeM? (since := "2025-12-04 ")]
641640def IterM.Partial.findSomeM? {α β γ : Type w} {m : Type w → Type w'} [Monad m] [Iterator α m β]
642641 [IteratorLoop α m m] (it : IterM.Partial (α := α) m β) (f : β → m (Option γ)) :
643642 m (Option γ) :=
@@ -709,7 +708,7 @@ Examples:
709708 * `([7, 6, 5, 8, 1, 2, 6].iterM Id).allowNontermination.findSome? (fun x => if x < 5 then some (10 * x) else none) = pure (some 10)`
710709 * `([7, 6, 5, 8, 1, 2, 6].iterM Id).allowNontermination.findSome? (fun x => if x < 1 then some (10 * x) else none) = pure none`
711710 -/
712- @[inline, deprecated IterM.findSome? (since := "2025-10-21 ")]
711+ @[inline, deprecated IterM.findSome? (since := "2025-12-04 ")]
713712def IterM.Partial.findSome? {α β γ : Type w} {m : Type w → Type w'} [Monad m] [Iterator α m β]
714713 [IteratorLoop α m m] (it : IterM.Partial (α := α) m β) (f : β → Option γ) :
715714 m (Option γ) :=
@@ -794,7 +793,7 @@ Almost! 5
794793some 1
795794```
796795-/
797- @[inline, deprecated IterM.findM? (since := "2025-10-21 ")]
796+ @[inline, deprecated IterM.findM? (since := "2025-12-04 ")]
798797def IterM.Partial.findM? {α β : Type w} {m : Type w → Type w'} [Monad m] [Iterator α m β]
799798 [IteratorLoop α m m] (it : IterM.Partial (α := α) m β) (f : β → m (ULift Bool)) :
800799 m (Option β) :=
@@ -866,7 +865,7 @@ Examples:
866865* `([7, 6, 5, 8, 1, 2, 6].iterM Id).allowNontermination.find? (· < 5) = pure (some 1)`
867866* `([7, 6, 5, 8, 1, 2, 6].iterM Id).allowNontermination.find? (· < 1) = pure none`
868867 -/
869- @[inline, deprecated IterM.find? (since := "2025-10-21 ")]
868+ @[inline, deprecated IterM.find? (since := "2025-12-04 ")]
870869def IterM.Partial.find? {α β : Type w} {m : Type w → Type w'} [Monad m] [Iterator α m β]
871870 [IteratorLoop α m m] (it : IterM.Partial (α := α) m β) (f : β → Bool) :
872871 m (Option β) :=
0 commit comments