@@ -129,13 +129,13 @@ theorem IterM.forIn_eq_foldM {α β : Type w} [Iterator α Id β]
129
129
theorem Iter.fold_eq_forIn {α β γ : Type w} [Iterator α Id β]
130
130
[Finite α Id] [IteratorLoop α Id Id] {f : γ → β → γ} {init : γ} {it : Iter (α := α) β} :
131
131
it.fold (init := init) f =
132
- ForIn.forIn (m := Id) it init (fun x acc => pure (ForInStep.yield (f acc x))) := by
132
+ ( ForIn.forIn (m := Id) it init (fun x acc => pure (ForInStep.yield (f acc x)))).run := by
133
133
rfl
134
134
135
135
theorem Iter.fold_eq_foldM {α β γ : Type w} [Iterator α Id β]
136
136
[Finite α Id] [IteratorLoop α Id Id] {f : γ → β → γ} {init : γ}
137
137
{it : Iter (α := α) β} :
138
- it.fold (init := init) f = it.foldM (m := Id) (init := init) (pure <| f · ·) := by
138
+ it.fold (init := init) f = ( it.foldM (m := Id) (init := init) (pure <| f · ·)).run := by
139
139
simp [foldM_eq_forIn, fold_eq_forIn]
140
140
141
141
theorem Iter.forIn_yield_eq_fold {α β γ : Type w} [Iterator α Id β]
@@ -144,7 +144,8 @@ theorem Iter.forIn_yield_eq_fold {α β γ : Type w} [Iterator α Id β]
144
144
{it : Iter (α := α) β} :
145
145
ForIn.forIn (m := Id) it init (fun c b => .yield (f c b)) =
146
146
it.fold (fun b c => f c b) init := by
147
- simp [Iter.fold_eq_forIn]
147
+ simp only [fold_eq_forIn]
148
+ rfl
148
149
149
150
theorem Iter.fold_eq_match_step {α β γ : Type w} [Iterator α Id β] [Finite α Id]
150
151
[IteratorLoop α Id Id] [LawfulIteratorLoop α Id Id]
@@ -163,6 +164,6 @@ theorem Iter.foldl_toList {α β γ : Type w} [Iterator α Id β] [Finite α Id]
163
164
[IteratorCollect α Id] [LawfulIteratorCollect α Id]
164
165
{f : γ → β → γ} {init : γ} {it : Iter (α := α) β} :
165
166
it.toList.foldl (init := init) f = it.fold (init := init) f := by
166
- simp [Iter. fold_eq_foldM, ← Iter.foldlM_toList, List.foldl_eq_foldlM ]
167
+ rw [ fold_eq_foldM, List.foldl_eq_foldlM, ← Iter.foldlM_toList]
167
168
168
169
end Std.Iterators
0 commit comments