@@ -12,7 +12,7 @@ import Std.Data.Iterators.Lemmas.Consumers.Monadic.Collect
1212
1313namespace Std.Iterators
1414
15- theorem IterM.DefaultConsumers.forIn_of_step {α β : Type w} {m : Type w → Type w'}
15+ theorem IterM.DefaultConsumers.forIn_eq_match_step {α β : Type w} {m : Type w → Type w'}
1616 [Iterator α m β]
1717 {n : Type w → Type w''} [Monad n]
1818 {lift : ∀ γ, m γ → n γ} {γ : Type w}
@@ -31,7 +31,7 @@ theorem IterM.DefaultConsumers.forIn_of_step {α β : Type w} {m : Type w → Ty
3131 rw [forIn]
3232 apply bind_congr
3333 intro step
34- cases step.casesHelper <;> rfl
34+ cases step using PlausibleIterStep.casesOn <;> rfl
3535
3636theorem IterM.forIn_eq {α β : Type w} {m : Type w → Type w'} [Iterator α m β] [Finite α m]
3737 {n : Type w → Type w''} [Monad n] [IteratorLoop α m n] [hl : LawfulIteratorLoop α m n]
@@ -41,7 +41,7 @@ theorem IterM.forIn_eq {α β : Type w} {m : Type w → Type w'} [Iterator α m
4141 IteratorLoop.wellFounded_of_finite it init ((⟨·, .intro⟩) <$> f · ·) := by
4242 cases hl.lawful; rfl
4343
44- theorem IterM.forIn_of_step {α β : Type w} {m : Type w → Type w'} [Iterator α m β]
44+ theorem IterM.forIn_eq_match_step {α β : Type w} {m : Type w → Type w'} [Iterator α m β]
4545 [Finite α m] {n : Type w → Type w''} [Monad n] [LawfulMonad n]
4646 [IteratorLoop α m n] [LawfulIteratorLoop α m n]
4747 [MonadLiftT m n] {γ : Type w} {it : IterM (α := α) m β} {init : γ}
@@ -54,10 +54,10 @@ theorem IterM.forIn_of_step {α β : Type w} {m : Type w → Type w'} [Iterator
5454 | .done c => return c
5555 | .skip it' _ => ForIn.forIn it' init f
5656 | .done _ => return init) := by
57- rw [IterM.forIn_eq, DefaultConsumers.forIn_of_step ]
57+ rw [IterM.forIn_eq, DefaultConsumers.forIn_eq_match_step ]
5858 apply bind_congr
5959 intro step
60- cases step.casesHelper
60+ cases step using PlausibleIterStep.casesOn
6161 · simp only [map_eq_pure_bind, bind_assoc]
6262 apply bind_congr
6363 intro forInStep
@@ -79,18 +79,18 @@ theorem IterM.forIn_yield_eq_foldM {α β γ δ : Type w} {m : Type w → Type w
7979 it.foldM (fun b c => g c b <$> f c b) init := by
8080 simp [IterM.foldM_eq_forIn]
8181
82- theorem IterM.foldM_of_step {α β γ : Type w} {m : Type w → Type w'} [Iterator α m β] [Finite α m]
82+ theorem IterM.foldM_eq_match_step {α β γ : Type w} {m : Type w → Type w'} [Iterator α m β] [Finite α m]
8383 {n : Type w → Type w''} [Monad n] [LawfulMonad n] [IteratorLoop α m n] [LawfulIteratorLoop α m n]
8484 [MonadLiftT m n] {f : γ → β → n γ} {init : γ} {it : IterM (α := α) m β} :
8585 it.foldM (init := init) f = (do
8686 match ← it.step with
8787 | .yield it' out _ => it'.foldM (init := ← f init out) f
8888 | .skip it' _ => it'.foldM (init := init) f
8989 | .done _ => return init) := by
90- rw [IterM.foldM_eq_forIn, IterM.forIn_of_step ]
90+ rw [IterM.foldM_eq_forIn, IterM.forIn_eq_match_step ]
9191 apply bind_congr
9292 intro step
93- cases step.casesHelper <;> simp [foldM_eq_forIn]
93+ cases step using PlausibleIterStep.casesOn <;> simp [foldM_eq_forIn]
9494
9595theorem IterM.fold_eq_forIn {α β γ : Type w} {m : Type w → Type w'} [Iterator α m β]
9696 [Finite α m] [Monad m]
@@ -113,19 +113,19 @@ theorem IterM.forIn_pure_yield_eq_fold {α β γ : Type w} {m : Type w → Type
113113 it.fold (fun b c => f c b) init := by
114114 simp [IterM.fold_eq_forIn]
115115
116- theorem IterM.fold_of_step {α β γ : Type w} {m : Type w → Type w'} [Iterator α m β] [Finite α m]
116+ theorem IterM.fold_eq_match_step {α β γ : Type w} {m : Type w → Type w'} [Iterator α m β] [Finite α m]
117117 [Monad m] [LawfulMonad m] [IteratorLoop α m m] [LawfulIteratorLoop α m m]
118118 {f : γ → β → γ} {init : γ} {it : IterM (α := α) m β} :
119119 it.fold (init := init) f = (do
120120 match ← it.step with
121121 | .yield it' out _ => it'.fold (init := f init out) f
122122 | .skip it' _ => it'.fold (init := init) f
123123 | .done _ => return init) := by
124- rw [fold_eq_foldM, foldM_of_step ]
124+ rw [fold_eq_foldM, foldM_eq_match_step ]
125125 simp only [fold_eq_foldM]
126126 apply bind_congr
127127 intro step
128- cases step.casesHelper <;> simp
128+ cases step using PlausibleIterStep.casesOn <;> simp
129129
130130theorem IterM.toList_eq_fold {α β : Type w} {m : Type w → Type w'} [Iterator α m β]
131131 [Finite α m] [Monad m] [LawfulMonad m] [IteratorLoop α m m] [LawfulIteratorLoop α m m]
@@ -136,13 +136,13 @@ theorem IterM.toList_eq_fold {α β : Type w} {m : Type w → Type w'} [Iterator
136136 it.fold (init := l') (fun l out => l ++ [out]) by
137137 specialize h []
138138 simpa using h
139- induction it using IterM.induct with | step it ihy ihs =>
139+ induction it using IterM.inductSteps with | step it ihy ihs =>
140140 intro l'
141- rw [IterM.toList_of_step , IterM.fold_of_step ]
141+ rw [IterM.toList_eq_match_step , IterM.fold_eq_match_step ]
142142 simp only [map_eq_pure_bind, bind_assoc]
143143 apply bind_congr
144144 intro step
145- cases step.casesHelper
145+ cases step using PlausibleIterStep.casesOn
146146 · rename_i it' out h
147147 specialize ihy h (l' ++ [out])
148148 simpa using ihy
@@ -165,28 +165,28 @@ theorem IterM.drain_eq_forIn {α β : Type w} {m : Type w → Type w'} [Iterato
165165 it.drain = ForIn.forIn (m := m) it PUnit.unit (fun _ _ => pure (ForInStep.yield .unit)) := by
166166 simp [IterM.drain_eq_fold, IterM.fold_eq_forIn]
167167
168- theorem IterM.drain_of_step {α β : Type w} {m : Type w → Type w'} [Iterator α m β] [Finite α m]
168+ theorem IterM.drain_eq_match_step {α β : Type w} {m : Type w → Type w'} [Iterator α m β] [Finite α m]
169169 [Monad m] [LawfulMonad m] [IteratorLoop α m m] [LawfulIteratorLoop α m m]
170170 {it : IterM (α := α) m β} :
171171 it.drain = (do
172172 match ← it.step with
173173 | .yield it' _ _ => it'.drain
174174 | .skip it' _ => it'.drain
175175 | .done _ => return .unit) := by
176- rw [IterM.drain_eq_fold, IterM.fold_of_step ]
176+ rw [IterM.drain_eq_fold, IterM.fold_eq_match_step ]
177177 simp [IterM.drain_eq_fold]
178178
179179theorem IterM.drain_eq_map_toList {α β : Type w} {m : Type w → Type w'} [Iterator α m β]
180180 [Finite α m] [Monad m] [LawfulMonad m] [IteratorLoop α m m] [LawfulIteratorLoop α m m]
181181 [IteratorCollect α m] [LawfulIteratorCollect α m]
182182 {it : IterM (α := α) m β} :
183183 it.drain = (fun _ => .unit) <$> it.toList := by
184- induction it using IterM.induct with | step it ihy ihs =>
185- rw [IterM.drain_of_step , IterM.toList_of_step ]
184+ induction it using IterM.inductSteps with | step it ihy ihs =>
185+ rw [IterM.drain_eq_match_step , IterM.toList_eq_match_step ]
186186 simp only [map_eq_pure_bind, bind_assoc]
187187 apply bind_congr
188188 intro step
189- cases step.casesHelper
189+ cases step using PlausibleIterStep.casesOn
190190 · rename_i it' out h
191191 simp [ihy h]
192192 · rename_i it' h
0 commit comments