@@ -12,7 +12,7 @@ import Std.Data.Iterators.Lemmas.Consumers.Monadic.Collect
12
12
13
13
namespace Std.Iterators
14
14
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'}
16
16
[Iterator α m β]
17
17
{n : Type w → Type w''} [Monad n]
18
18
{lift : ∀ γ, m γ → n γ} {γ : Type w}
@@ -31,7 +31,7 @@ theorem IterM.DefaultConsumers.forIn_of_step {α β : Type w} {m : Type w → Ty
31
31
rw [forIn]
32
32
apply bind_congr
33
33
intro step
34
- cases step.casesHelper <;> rfl
34
+ cases step using PlausibleIterStep.casesOn <;> rfl
35
35
36
36
theorem IterM.forIn_eq {α β : Type w} {m : Type w → Type w'} [Iterator α m β] [Finite α m]
37
37
{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
41
41
IteratorLoop.wellFounded_of_finite it init ((⟨·, .intro⟩) <$> f · ·) := by
42
42
cases hl.lawful; rfl
43
43
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 β]
45
45
[Finite α m] {n : Type w → Type w''} [Monad n] [LawfulMonad n]
46
46
[IteratorLoop α m n] [LawfulIteratorLoop α m n]
47
47
[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
54
54
| .done c => return c
55
55
| .skip it' _ => ForIn.forIn it' init f
56
56
| .done _ => return init) := by
57
- rw [IterM.forIn_eq, DefaultConsumers.forIn_of_step ]
57
+ rw [IterM.forIn_eq, DefaultConsumers.forIn_eq_match_step ]
58
58
apply bind_congr
59
59
intro step
60
- cases step.casesHelper
60
+ cases step using PlausibleIterStep.casesOn
61
61
· simp only [map_eq_pure_bind, bind_assoc]
62
62
apply bind_congr
63
63
intro forInStep
@@ -79,18 +79,18 @@ theorem IterM.forIn_yield_eq_foldM {α β γ δ : Type w} {m : Type w → Type w
79
79
it.foldM (fun b c => g c b <$> f c b) init := by
80
80
simp [IterM.foldM_eq_forIn]
81
81
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]
83
83
{n : Type w → Type w''} [Monad n] [LawfulMonad n] [IteratorLoop α m n] [LawfulIteratorLoop α m n]
84
84
[MonadLiftT m n] {f : γ → β → n γ} {init : γ} {it : IterM (α := α) m β} :
85
85
it.foldM (init := init) f = (do
86
86
match ← it.step with
87
87
| .yield it' out _ => it'.foldM (init := ← f init out) f
88
88
| .skip it' _ => it'.foldM (init := init) f
89
89
| .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 ]
91
91
apply bind_congr
92
92
intro step
93
- cases step.casesHelper <;> simp [foldM_eq_forIn]
93
+ cases step using PlausibleIterStep.casesOn <;> simp [foldM_eq_forIn]
94
94
95
95
theorem IterM.fold_eq_forIn {α β γ : Type w} {m : Type w → Type w'} [Iterator α m β]
96
96
[Finite α m] [Monad m]
@@ -113,19 +113,19 @@ theorem IterM.forIn_pure_yield_eq_fold {α β γ : Type w} {m : Type w → Type
113
113
it.fold (fun b c => f c b) init := by
114
114
simp [IterM.fold_eq_forIn]
115
115
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]
117
117
[Monad m] [LawfulMonad m] [IteratorLoop α m m] [LawfulIteratorLoop α m m]
118
118
{f : γ → β → γ} {init : γ} {it : IterM (α := α) m β} :
119
119
it.fold (init := init) f = (do
120
120
match ← it.step with
121
121
| .yield it' out _ => it'.fold (init := f init out) f
122
122
| .skip it' _ => it'.fold (init := init) f
123
123
| .done _ => return init) := by
124
- rw [fold_eq_foldM, foldM_of_step ]
124
+ rw [fold_eq_foldM, foldM_eq_match_step ]
125
125
simp only [fold_eq_foldM]
126
126
apply bind_congr
127
127
intro step
128
- cases step.casesHelper <;> simp
128
+ cases step using PlausibleIterStep.casesOn <;> simp
129
129
130
130
theorem IterM.toList_eq_fold {α β : Type w} {m : Type w → Type w'} [Iterator α m β]
131
131
[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
136
136
it.fold (init := l') (fun l out => l ++ [out]) by
137
137
specialize h []
138
138
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 =>
140
140
intro l'
141
- rw [IterM.toList_of_step , IterM.fold_of_step ]
141
+ rw [IterM.toList_eq_match_step , IterM.fold_eq_match_step ]
142
142
simp only [map_eq_pure_bind, bind_assoc]
143
143
apply bind_congr
144
144
intro step
145
- cases step.casesHelper
145
+ cases step using PlausibleIterStep.casesOn
146
146
· rename_i it' out h
147
147
specialize ihy h (l' ++ [out])
148
148
simpa using ihy
@@ -165,28 +165,28 @@ theorem IterM.drain_eq_forIn {α β : Type w} {m : Type w → Type w'} [Iterato
165
165
it.drain = ForIn.forIn (m := m) it PUnit.unit (fun _ _ => pure (ForInStep.yield .unit)) := by
166
166
simp [IterM.drain_eq_fold, IterM.fold_eq_forIn]
167
167
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]
169
169
[Monad m] [LawfulMonad m] [IteratorLoop α m m] [LawfulIteratorLoop α m m]
170
170
{it : IterM (α := α) m β} :
171
171
it.drain = (do
172
172
match ← it.step with
173
173
| .yield it' _ _ => it'.drain
174
174
| .skip it' _ => it'.drain
175
175
| .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 ]
177
177
simp [IterM.drain_eq_fold]
178
178
179
179
theorem IterM.drain_eq_map_toList {α β : Type w} {m : Type w → Type w'} [Iterator α m β]
180
180
[Finite α m] [Monad m] [LawfulMonad m] [IteratorLoop α m m] [LawfulIteratorLoop α m m]
181
181
[IteratorCollect α m] [LawfulIteratorCollect α m]
182
182
{it : IterM (α := α) m β} :
183
183
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 ]
186
186
simp only [map_eq_pure_bind, bind_assoc]
187
187
apply bind_congr
188
188
intro step
189
- cases step.casesHelper
189
+ cases step using PlausibleIterStep.casesOn
190
190
· rename_i it' out h
191
191
simp [ihy h]
192
192
· rename_i it' h
0 commit comments