@@ -73,6 +73,14 @@ theorem RangeIterator.mem_toList_iff_isPlausibleIndirectOutput
7373 simp only [ha.1 , ha.2 .1 , ha.2 .2 .1 ]
7474 simp [← ha.2 .2 .2 , h']
7575
76+ instance [UpwardEnumerable α]
77+ [SupportsLowerBound sl α] [SupportsUpperBound su α] [FinitelyEnumerableRange su α]
78+ [LawfulUpwardEnumerable α] [UpwardEnumerableRange sl α]
79+ [LawfulUpwardEnumerableUpperBound su α] [LawfulUpwardEnumerableLowerBound sl α] :
80+ LawfulPureIterator (Types.RangeIterator ⟨sl, su⟩ α) where
81+ mem_toList_iff_isPlausibleIndirectOutput :=
82+ RangeIterator.mem_toList_iff_isPlausibleIndirectOutput
83+
7684theorem mem_toList_iff_mem [UpwardEnumerable α]
7785 [SupportsUpperBound su α] [SupportsLowerBound sl α] [FinitelyEnumerableRange su α]
7886 [UpwardEnumerableRange sl α] [LawfulUpwardEnumerable α]
@@ -123,9 +131,22 @@ theorem forIn'_eq_forIn'_toList [UpwardEnumerable α]
123131 [UpwardEnumerableRange sl α] [LawfulUpwardEnumerable α]
124132 [LawfulUpwardEnumerableLowerBound sl α] [LawfulUpwardEnumerableUpperBound su α]
125133 {r : PRange ⟨sl, su⟩ α}
126- {γ : Type u} {init : γ} {m : Type u → Type w} [Monad m] {f : (a : α) → a ∈ r → γ → m (ForInStep γ)} :
134+ {γ : Type u} {init : γ} {m : Type u → Type w} [Monad m] [LawfulMonad m]
135+ {f : (a : α) → a ∈ r → γ → m (ForInStep γ)} :
127136 ForIn'.forIn' r init f =
128137 ForIn'.forIn' r.toList init (fun a ha acc => f a (mem_toList_iff_mem.mp ha) acc) := by
129- simp only [forIn'_eq_forIn'_iterInternal, toList_eq_toList_iterInternal]
138+ simp [forIn'_eq_forIn'_iterInternal, toList_eq_toList_iterInternal,
139+ Iter.forIn'_eq_forIn'_toList]
140+
141+ theorem forIn'_toList_eq_forIn' [UpwardEnumerable α]
142+ [SupportsUpperBound su α] [SupportsLowerBound sl α] [FinitelyEnumerableRange su α]
143+ [UpwardEnumerableRange sl α] [LawfulUpwardEnumerable α]
144+ [LawfulUpwardEnumerableLowerBound sl α] [LawfulUpwardEnumerableUpperBound su α]
145+ {r : PRange ⟨sl, su⟩ α}
146+ {γ : Type u} {init : γ} {m : Type u → Type w} [Monad m] [LawfulMonad m]
147+ {f : (a : α) → _ → γ → m (ForInStep γ)} :
148+ ForIn'.forIn' r.toList init f =
149+ ForIn'.forIn' r init (fun a ha acc => f a (mem_toList_iff_mem.mpr ha) acc) := by
150+ simp [forIn'_eq_forIn'_toList]
130151
131152end Std.PRange
0 commit comments