Skip to content

Commit ad52a35

Browse files
committed
clean up the fixpoint combinator
1 parent 3341915 commit ad52a35

File tree

10 files changed

+130
-142
lines changed

10 files changed

+130
-142
lines changed

src/Init/Data/Iterators/Basic.lean

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -703,18 +703,6 @@ def IterM.TerminationMeasures.Finite.Rel
703703
TerminationMeasures.Finite α m → TerminationMeasures.Finite α m → Prop :=
704704
Relation.TransGen <| InvImage IterM.IsPlausibleSuccessorOf IterM.TerminationMeasures.Finite.it
705705

706-
/--
707-
The relation of plausible successors on `IterM.TerminationMeasures.Finite`. It is well-founded
708-
if there is a `Finite` instance.
709-
-/
710-
@[expose]
711-
def IterM.TerminationMeasures.Finite.RelExtrinsic
712-
{α : Type w} {m : Type w → Type w'} {β : Type w}
713-
(R : IterM (α := α) m β → IterM (α := α) m β → Prop)
714-
[Iterator α m β] :
715-
TerminationMeasures.Finite α m → TerminationMeasures.Finite α m → Prop :=
716-
Relation.TransGen <| InvImage R IterM.TerminationMeasures.Finite.it
717-
718706
instance {α : Type w} {m : Type w → Type w'} {β : Type w} [Iterator α m β]
719707
[Finite α m] : WellFoundedRelation (IterM.TerminationMeasures.Finite α m) where
720708
rel := IterM.TerminationMeasures.Finite.Rel

src/Init/Data/Iterators/Consumers/Collect.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Traverses the given iterator and stores the emitted values in an array.
4343
4444
This function is deprecated. Instead of `it.allowNontermination.toArray`, use `it.toArray`.
4545
-/
46-
@[always_inline, inline, deprecated Iter.toArray (since := "2025-10-23")]
46+
@[always_inline, inline, deprecated Iter.toArray (since := "2025-12-04")]
4747
def Iter.Partial.toArray {α : Type w} {β : Type w}
4848
[Iterator α Id β] [IteratorCollect α Id Id] (it : Iter.Partial (α := α) β) : Array β :=
4949
it.it.toArray
@@ -78,7 +78,7 @@ lists are prepend-only, this `toListRev` is usually more efficient that `toList`
7878
7979
This function is deprecated. Instead of `it.allowNontermination.toListRev`, use `it.toListRev`.
8080
-/
81-
@[always_inline, inline, deprecated Iter.toListRev (since := "2025-10-23")]
81+
@[always_inline, inline, deprecated Iter.toListRev (since := "2025-12-04")]
8282
def Iter.Partial.toListRev {α : Type w} {β : Type w}
8383
[Iterator α Id β] (it : Iter.Partial (α := α) β) : List β :=
8484
it.it.toListRev
@@ -113,7 +113,7 @@ lists are prepend-only, `toListRev` is usually more efficient that `toList`.
113113
114114
This function is deprecated. Instead of `it.allowNontermination.toList`, use `it.toList`.
115115
-/
116-
@[always_inline, deprecated Iter.toList (since := "2025-10-23")]
116+
@[always_inline, deprecated Iter.toList (since := "2025-12-04")]
117117
def Iter.Partial.toList {α : Type w} {β : Type w}
118118
[Iterator α Id β] [IteratorCollect α Id Id] (it : Iter.Partial (α := α) β) : List β :=
119119
it.it.toList

src/Init/Data/Iterators/Consumers/Loop.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ It is equivalent to `it.toList.foldlM`.
117117
118118
This function is deprecated. Instead of `it.allowNontermination.foldM`, use `it.foldM`.
119119
-/
120-
@[always_inline, inline]
120+
@[always_inline, inline, deprecated Iter.foldM (since := "2025-12-04")]
121121
def Iter.Partial.foldM {m : Type x → Type x'} [Monad m]
122122
{α : Type w} {β : Type w} {γ : Type x} [Iterator α Id β]
123123
[IteratorLoop α Id m] (f : γ → β → m γ)
@@ -160,7 +160,7 @@ It is equivalent to `it.toList.foldl`.
160160
161161
This function is deprecated. Instead of `it.allowNontermination.fold`, use `it.fold`.
162162
-/
163-
@[always_inline, inline]
163+
@[always_inline, inline, deprecated Iter.fold (since := "2025-12-04")]
164164
def Iter.Partial.fold {α : Type w} {β : Type w} {γ : Type x} [Iterator α Id β]
165165
[IteratorLoop α Id Id] (f : γ → β → γ)
166166
(init : γ) (it : Iter.Partial (α := α) β) : γ :=
@@ -375,7 +375,7 @@ Almost! 5
375375
some 10
376376
```
377377
-/
378-
@[inline, deprecated Iter.findSomeM? (since := "2025-10-21")]
378+
@[inline, deprecated Iter.findSomeM? (since := "2025-12-04")]
379379
def Iter.Partial.findSomeM? {α β : Type w} {γ : Type x} {m : Type x → Type w'} [Monad m]
380380
[Iterator α Id β] [IteratorLoop α Id m] (it : Iter.Partial (α := α) β)
381381
(f : β → m (Option γ)) :
@@ -449,7 +449,7 @@ Examples:
449449
* `[7, 6, 5, 8, 1, 2, 6].iter.allowNontermination.findSome? (fun x => if x < 5 then some (10 * x) else none) = some 10`
450450
* `[7, 6, 5, 8, 1, 2, 6].iter.allowNontermination.findSome? (fun x => if x < 1 then some (10 * x) else none) = none`
451451
-/
452-
@[inline, deprecated Iter.findSome? (since := "2025-10-21")]
452+
@[inline, deprecated Iter.findSome? (since := "2025-12-04")]
453453
def Iter.Partial.findSome? {α β : Type w} {γ : Type x} [Iterator α Id β]
454454
[IteratorLoop α Id Id] (it : Iter.Partial (α := α) β) (f : β → Option γ) :
455455
Option γ :=
@@ -534,7 +534,7 @@ Almost! 5
534534
some 1
535535
```
536536
-/
537-
@[inline, deprecated Iter.findM? (since := "2025-10-21")]
537+
@[inline, deprecated Iter.findM? (since := "2025-12-04")]
538538
def Iter.Partial.findM? {α β : Type w} {m : Type w → Type w'} [Monad m] [Iterator α Id β]
539539
[IteratorLoop α Id m] (it : Iter.Partial (α := α) β) (f : β → m (ULift Bool)) :
540540
m (Option β) :=
@@ -605,7 +605,7 @@ Examples:
605605
* `[7, 6, 5, 8, 1, 2, 6].iter.allowNontermination.find? (· < 5) = some 1`
606606
* `[7, 6, 5, 8, 1, 2, 6].iter.allowNontermination.find? (· < 1) = none`
607607
-/
608-
@[inline, deprecated Iter.find? (since := "2025-10-21")]
608+
@[inline, deprecated Iter.find? (since := "2025-12-04")]
609609
def Iter.Partial.find? {α β : Type w} [Iterator α Id β] [IteratorLoop α Id Id]
610610
(it : Iter.Partial (α := α) β) (f : β → Bool) : Option β :=
611611
it.it.find? f

src/Init/Data/Iterators/Consumers/Monadic/Collect.lean

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ prelude
99
public import Init.Data.Iterators.Consumers.Monadic.Partial
1010
public import Init.Data.Iterators.Consumers.Monadic.Total
1111
public import Init.Data.Iterators.Internal.LawfulMonadLiftFunction
12-
public import Init.Internal.ExtrinsicTermination
12+
public import Init.WFExtrinsicFix
1313

1414
@[expose] public section
1515

@@ -82,44 +82,14 @@ where
8282
@[always_inline]
8383
go it (acc : Array γ) : n (Array γ) :=
8484
letI : MonadLift m n := ⟨lift (α := _)⟩
85-
extrinsicFix₂ (C₂ := fun _ _ => n (Array γ)) (InvImage TerminationMeasures.Finite.Rel (·.1.finitelyManySteps!))
85+
WellFounded.extrinsicFix₂ (C₂ := fun _ _ => n (Array γ)) (InvImage TerminationMeasures.Finite.Rel (·.1.finitelyManySteps!))
8686
(fun (it : IterM (α := α) m β) acc recur => do
8787
match (← it.step).inflate with
8888
| .yield it' out h =>
8989
recur it' (acc.push (← f out)) (by exact TerminationMeasures.Finite.rel_of_yield ‹_›)
9090
| .skip it' h => recur it' acc (by exact TerminationMeasures.Finite.rel_of_skip ‹_›)
9191
| .done _ => return acc) it acc
9292

93-
-- @[always_inline, no_expose]
94-
-- def IterM.DefaultConsumers.toArrayMapped {α β : Type w} {m : Type w → Type w'}
95-
-- {n : Type w → Type w''} [Monad n] [MonadAttach n] [Iterator α m β]
96-
-- (lift : ⦃α : Type w⦄ → m α → n α) {γ : Type w} (f : β → n γ)
97-
-- (it : IterM (α := α) m β) : n (Array γ) :=
98-
-- letI : MonadLift m n := ⟨lift (α := _)⟩
99-
-- go it #[]
100-
-- where
101-
-- @[always_inline]
102-
-- go it (acc : Array γ) : n (Array γ) :=
103-
-- letI : MonadLift m n := ⟨lift (α := _)⟩
104-
-- extrinsicFix₂ (C₂ := fun _ _ => n (Array γ))
105-
-- (fun x' x => (∃ out, x.1.IsPlausibleStepE (.yield x'.1 out) ∧ ∃ fx, MonadAttach.CanReturn (f out) fx ∧ x'.2 = x.2.push fx) ∨ (∃ h, MonadAttach.CanReturn (m := n) x.1.step (.deflate <| .skip x'.1 h) ∧ x'.2 = x.2))
106-
-- (fun (it : IterM (α := α) m β) acc recur => do
107-
-- let ⟨step, hs⟩ ← MonadAttach.attach (m := n) it.step
108-
-- match hs' : step.inflate with
109-
-- | .yield it' out h =>
110-
-- let fx ← MonadAttach.attach (f out)
111-
-- recur it' (acc.push fx.val) (by
112-
-- apply Or.inl
113-
-- have : step = .deflate (.yield it' out h) := by simp [← hs']
114-
-- rw [this] at hs
115-
-- exact ⟨out, h, hs, fx.val, fx.property, rfl⟩)
116-
-- | .skip it' h => recur it' acc (by
117-
-- apply Or.inr
118-
-- have : step = .deflate (.skip it' h) := by simp [← hs']
119-
-- rw [this] at hs
120-
-- exact ⟨h, hs, rfl⟩)
121-
-- | .done h => return acc) it acc
122-
12393
/--
12494
This is the default implementation of the `IteratorCollect` class.
12595
It simply iterates through the iterator using `IterM.step`, incrementally building up the desired
@@ -208,7 +178,7 @@ def IterM.toListRev {α : Type w} {m : Type w → Type w'} [Monad m] {β : Type
208178
where
209179
@[always_inline, inline]
210180
go (it : IterM m β) acc :=
211-
extrinsicFix₂ (InvImage TerminationMeasures.Finite.Rel (·.1.finitelyManySteps!))
181+
WellFounded.extrinsicFix₂ (InvImage TerminationMeasures.Finite.Rel (·.1.finitelyManySteps!))
212182
(fun it acc recur => do
213183
match (← it.step).inflate with
214184
| .yield it' out h => recur it' (out :: acc) (TerminationMeasures.Finite.rel_of_yield h)

src/Init/Data/Iterators/Consumers/Monadic/Loop.lean

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module
88
prelude
99
public import Init.Data.Iterators.Consumers.Monadic.Partial
1010
public import Init.Data.Iterators.Internal.LawfulMonadLiftFunction
11-
public import Init.Internal.ExtrinsicTermination
11+
public import Init.WFExtrinsicFix
1212
public import Init.Data.Iterators.Consumers.Monadic.Total
1313

1414
public 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]
123123
def 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
145144
termination_by IteratorLoop.WithWF.mk it init (hwf := wf)
@@ -284,7 +283,7 @@ function. Therefore, it may *not* be equivalent to `it.toList.foldlM`.
284283
285284
This 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")]
288287
def 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
327326
This 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")]
330329
def 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
364363
This 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")]
367366
def 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
409408
This 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")]
412411
def 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
456455
This 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")]
459458
def 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
505504
This 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")]
508507
def 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
554553
This 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")]
557556
def 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
637636
some 10
638637
```
639638
-/
640-
@[inline, deprecated IterM.findSomeM? (since := "2025-10-21")]
639+
@[inline, deprecated IterM.findSomeM? (since := "2025-12-04")]
641640
def 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")]
713712
def 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
794793
some 1
795794
```
796795
-/
797-
@[inline, deprecated IterM.findM? (since := "2025-10-21")]
796+
@[inline, deprecated IterM.findM? (since := "2025-12-04")]
798797
def 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")]
870869
def 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 β) :=

src/Init/Data/Iterators/Lemmas/Consumers/Monadic/Collect.lean

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public import Init.Data.Iterators.Lemmas.Monadic.Basic
1111
public import Init.Data.Iterators.Consumers.Monadic.Collect
1212
import all Init.Data.Iterators.Consumers.Monadic.Collect
1313
import all Init.Data.Iterators.Consumers.Monadic.Total
14-
import all Init.Internal.ExtrinsicTermination
14+
import all Init.WFExtrinsicFix
1515

1616
public section
1717

@@ -30,7 +30,7 @@ private theorem IterM.DefaultConsumers.toArrayMapped.go_eq [Monad n]
3030
| .skip it' => go lift f it' acc
3131
| .done => return acc) := by
3232
letI : MonadLift m n := ⟨lift (δ := _)⟩
33-
rw [toArrayMapped.go, extrinsicFix₂_eq]
33+
rw [toArrayMapped.go, WellFounded.extrinsicFix₂_eq_apply]
3434
· simp only
3535
apply bind_congr; intro step
3636
cases step.inflate using PlausibleIterStep.casesOn
@@ -42,35 +42,6 @@ private theorem IterM.DefaultConsumers.toArrayMapped.go_eq [Monad n]
4242
apply InvImage.wf
4343
exact WellFoundedRelation.wf
4444

45-
-- private theorem IterM.DefaultConsumers.toArrayMapped.go_eq [Monad n] [MonadAttach n]
46-
-- [Iterator α m β] [LawfulMonad n] [Finite α m] {acc : Array γ} :
47-
-- letI : MonadLift m n := ⟨lift (δ := _)⟩
48-
-- go lift f it acc (m := m) = (do
49-
-- match (← it.step).inflate.val with
50-
-- | .yield it' out => go lift f it' (acc.push (← f out))
51-
-- | .skip it' => go lift f it' acc
52-
-- | .done => return acc) := by
53-
-- letI : MonadLift m n := ⟨lift (δ := _)⟩
54-
-- rw [toArrayMapped.go, extrinsicFix₂_eq]
55-
-- · simp only
56-
-- simp only [← MonadAttach.map_val_attach (x := liftM it.step), map_eq_pure_bind, bind_assoc]
57-
-- apply bind_congr; rintro ⟨step, hs⟩
58-
-- simp only [pure_bind]
59-
-- cases step.inflate using PlausibleIterStep.casesOn
60-
-- · simp only [← MonadAttach.map_val_attach (x := f _), map_eq_pure_bind, bind_assoc]
61-
-- apply bind_congr; intro fx
62-
-- simp [go]
63-
-- · simp [go]
64-
-- · simp
65-
-- · apply Subrelation.wf (r := InvImage WellFoundedRelation.rel (·.1.finitelyManySteps))
66-
-- · intro x' x h
67-
-- apply Relation.TransGen.single
68-
-- match h with
69-
-- | Or.inl ⟨out, h, h'⟩ => exact ⟨_, rfl, h⟩
70-
-- | Or.inr ⟨h, h'⟩ => exact ⟨_, rfl, h⟩
71-
-- · apply InvImage.wf
72-
-- exact WellFoundedRelation.wf
73-
7445
private theorem IterM.DefaultConsumers.toArrayMapped.go.aux₁ [Monad n] [LawfulMonad n]
7546
[Iterator α m β] [Finite α m] {b : γ} {bs : Array γ} :
7647
IterM.DefaultConsumers.toArrayMapped.go lift f it (#[b] ++ bs) (m := m) =
@@ -195,7 +166,7 @@ private theorem IterM.toListRev.go_eq [Monad m] [LawfulMonad m] [Iterator α m
195166
| .yield it' out => go it' (out :: bs)
196167
| .skip it' => go it' bs
197168
| .done => return bs) := by
198-
rw [go, extrinsicFix₂_eq]
169+
rw [go, WellFounded.extrinsicFix₂_eq_apply]
199170
· apply bind_congr; intro step
200171
cases step.inflate using PlausibleIterStep.casesOn <;> simp [go]
201172
· simp only [show (IterM.finitelyManySteps! = IterM.finitelyManySteps) by rfl]

0 commit comments

Comments
 (0)