Skip to content

Commit 5d96ec0

Browse files
committed
fix problems caused by earlier PRs' changes
1 parent 4282ffa commit 5d96ec0

File tree

2 files changed

+31
-33
lines changed

2 files changed

+31
-33
lines changed

src/Std/Data/Iterators/Lemmas/Consumers/Loop.lean

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ theorem Iter.forIn_eq_forIn_toIterM {α β : Type w} [Iterator α Id β]
3030
ForIn.forIn it init f = letI : MonadLift Id m := ⟨pure⟩; ForIn.forIn it.toIterM init f := by
3131
rfl
3232

33-
theorem Iter.forIn_of_step {α β : Type w} [Iterator α Id β]
33+
theorem Iter.forIn_eq_match_step {α β : Type w} [Iterator α Id β]
3434
[Finite α Id] {m : Type w → Type w''} [Monad m] [LawfulMonad m]
3535
[IteratorLoop α Id m] [LawfulIteratorLoop α Id m]
3636
{γ : Type w} {it : Iter (α := α) β} {init : γ}
@@ -43,10 +43,10 @@ theorem Iter.forIn_of_step {α β : Type w} [Iterator α Id β]
4343
| .done c => return c
4444
| .skip it' _ => ForIn.forIn it' init f
4545
| .done _ => return init) := by
46-
rw [Iter.forIn_eq_forIn_toIterM, @IterM.forIn_of_step, Iter.step]
46+
rw [Iter.forIn_eq_forIn_toIterM, @IterM.forIn_eq_match_step, Iter.step]
4747
simp only [liftM, monadLift, pure_bind]
4848
generalize it.toIterM.step = step
49-
cases step.casesHelper
49+
cases step using PlausibleIterStep.casesOn
5050
· apply bind_congr
5151
intro forInStep
5252
rfl
@@ -61,13 +61,11 @@ theorem Iter.forIn_toList {α β : Type w} [Iterator α Id β]
6161
{f : β → γ → m (ForInStep γ)} :
6262
ForIn.forIn it.toList init f = ForIn.forIn it init f := by
6363
rw [List.forIn_eq_foldlM]
64-
revert init
65-
induction it using Iter.induct with case step it ihy ihs =>
66-
intro init
67-
rw [forIn_of_step, Iter.toList_of_step]
64+
induction it using Iter.inductSteps generalizing init with case step it ihy ihs =>
65+
rw [forIn_eq_match_step, Iter.toList_eq_match_step]
6866
simp only [map_eq_pure_bind]
6967
generalize it.step = step
70-
cases step.casesHelper
68+
cases step using PlausibleIterStep.casesOn
7169
· rename_i it' out h
7270
simp only [List.foldlM_cons, bind_pure_comp, map_bind]
7371
apply bind_congr
@@ -95,17 +93,17 @@ theorem Iter.forIn_yield_eq_foldM {α β γ δ : Type w} [Iterator α Id β]
9593
it.foldM (fun b c => g c b <$> f c b) init := by
9694
simp [Iter.foldM_eq_forIn]
9795

98-
theorem Iter.foldM_of_step {α β γ : Type w} [Iterator α Id β] [Finite α Id]
96+
theorem Iter.foldM_eq_match_step {α β γ : Type w} [Iterator α Id β] [Finite α Id]
9997
{m : Type w → Type w'} [Monad m] [LawfulMonad m] [IteratorLoop α Id m]
10098
[LawfulIteratorLoop α Id m] {f : γ → β → m γ} {init : γ} {it : Iter (α := α) β} :
10199
it.foldM (init := init) f = (do
102100
match it.step with
103101
| .yield it' out _ => it'.foldM (init := ← f init out) f
104102
| .skip it' _ => it'.foldM (init := init) f
105103
| .done _ => return init) := by
106-
rw [Iter.foldM_eq_forIn, Iter.forIn_of_step]
104+
rw [Iter.foldM_eq_forIn, Iter.forIn_eq_match_step]
107105
generalize it.step = step
108-
cases step.casesHelper <;> simp [foldM_eq_forIn]
106+
cases step using PlausibleIterStep.casesOn <;> simp [foldM_eq_forIn]
109107

110108
theorem Iter.foldlM_toList {α β γ : Type w} [Iterator α Id β] [Finite α Id] {m : Type w → Type w'}
111109
[Monad m] [LawfulMonad m] [IteratorLoop α Id m] [LawfulIteratorLoop α Id m]
@@ -148,17 +146,17 @@ theorem Iter.forIn_yield_eq_fold {α β γ : Type w} [Iterator α Id β]
148146
it.fold (fun b c => f c b) init := by
149147
simp [Iter.fold_eq_forIn]
150148

151-
theorem Iter.fold_of_step {α β γ : Type w} [Iterator α Id β] [Finite α Id]
149+
theorem Iter.fold_eq_match_step {α β γ : Type w} [Iterator α Id β] [Finite α Id]
152150
[IteratorLoop α Id Id] [LawfulIteratorLoop α Id Id]
153151
{f : γ → β → γ} {init : γ} {it : Iter (α := α) β} :
154152
it.fold (init := init) f = (match it.step with
155153
| .yield it' out _ => it'.fold (init := f init out) f
156154
| .skip it' _ => it'.fold (init := init) f
157155
| .done _ => init) := by
158-
rw [fold_eq_foldM, foldM_of_step]
156+
rw [fold_eq_foldM, foldM_eq_match_step]
159157
simp only [fold_eq_foldM]
160158
generalize it.step = step
161-
cases step.casesHelper <;> simp
159+
cases step using PlausibleIterStep.casesOn <;> simp
162160

163161
theorem Iter.foldl_toList {α β γ : Type w} [Iterator α Id β] [Finite α Id]
164162
[IteratorLoop α Id Id] [LawfulIteratorLoop α Id Id]

src/Std/Data/Iterators/Lemmas/Consumers/Monadic/Loop.lean

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Std.Data.Iterators.Lemmas.Consumers.Monadic.Collect
1212

1313
namespace 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

3636
theorem 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

9595
theorem 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

130130
theorem 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

179179
theorem 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

Comments
 (0)