source
theorem Std.Iterators.Flatten.IsPlausibleStep.outerYield_flatMapM_pure {α β α₂ γ : Type w} {m : Type w → Type w'} [Monad m] [LawfulMonad m] [Iterator α Id β] [Iterator α₂ m γ] {f : β → m (IterM m γ)} {it₁ it₁' : Iter β} {it₂' : IterM m γ} {b : β} (h : it₁.IsPlausibleStep (IterStep.yield it₁' b)) :
(Iter.flatMapAfterM f it₁ none).IsPlausibleStep (IterStep.skip (Iter.flatMapAfterM f it₁' (some it₂')))
source
theorem Std.Iterators.Flatten.IsPlausibleStep.outerSkip_flatMapM_pure {α β α₂ γ : Type w} {m : Type w → Type w'} [Monad m] [LawfulMonad m] [Iterator α Id β] [Iterator α₂ m γ] {f : β → m (IterM m γ)} {it₁ it₁' : Iter β} (h : it₁.IsPlausibleStep (IterStep.skip it₁')) :
(Iter.flatMapAfterM f it₁ none).IsPlausibleStep (IterStep.skip (Iter.flatMapAfterM f it₁' none))
source
theorem Std.Iterators.Flatten.IsPlausibleStep.outerDone_flatMapM_pure {α β α₂ γ : Type w} {m : Type w → Type w'} [Monad m] [LawfulMonad m] [Iterator α Id β] [Iterator α₂ m γ] {f : β → m (IterM m γ)} {it₁ : Iter β} (h : it₁.IsPlausibleStep IterStep.done) :
(Iter.flatMapAfterM f it₁ none).IsPlausibleStep IterStep.done
source
theorem Std.Iterators.Flatten.IsPlausibleStep.innerYield_flatMapM_pure {α β α₂ γ : Type w} {m : Type w → Type w'} [Monad m] [LawfulMonad m] [Iterator α Id β] [Iterator α₂ m γ] {f : β → m (IterM m γ)} {it₁ : Iter β} {it₂ it₂' : IterM m γ} {b : γ} (h : it₂.IsPlausibleStep (IterStep.yield it₂' b)) :
(Iter.flatMapAfterM f it₁ (some it₂)).IsPlausibleStep (IterStep.yield (Iter.flatMapAfterM f it₁ (some it₂')) b)
source
theorem Std.Iterators.Flatten.IsPlausibleStep.innerSkip_flatMapM_pure {α β α₂ γ : Type w} {m : Type w → Type w'} [Monad m] [LawfulMonad m] [Iterator α Id β] [Iterator α₂ m γ] {f : β → m (IterM m γ)} {it₁ : Iter β} {it₂ it₂' : IterM m γ} (h : it₂.IsPlausibleStep (IterStep.skip it₂')) :
(Iter.flatMapAfterM f it₁ (some it₂)).IsPlausibleStep (IterStep.skip (Iter.flatMapAfterM f it₁ (some it₂')))
source
theorem Std.Iterators.Flatten.IsPlausibleStep.innerDone_flatMapM_pure {α β α₂ γ : Type w} {m : Type w → Type w'} [Monad m] [LawfulMonad m] [Iterator α Id β] [Iterator α₂ m γ] {f : β → m (IterM m γ)} {it₁ : Iter β} {it₂ : IterM m γ} (h : it₂.IsPlausibleStep IterStep.done) :
(Iter.flatMapAfterM f it₁ (some it₂)).IsPlausibleStep (IterStep.skip (Iter.flatMapAfterM f it₁ none))
source
theorem Std.Iterators.Flatten.IsPlausibleStep.outerYield_flatMap_pure {α β α₂ γ : Type w} [Iterator α Id β] [Iterator α₂ Id γ] {f : β → Iter γ} {it₁ it₁' : Iter β} {b : β} (h : it₁.IsPlausibleStep (IterStep.yield it₁' b)) :
(Iter.flatMapAfter f it₁ none).IsPlausibleStep (IterStep.skip (Iter.flatMapAfter f it₁' (some (f b))))
source
theorem Std.Iterators.Flatten.IsPlausibleStep.outerSkip_flatMap_pure {α β α₂ γ : Type w} [Iterator α Id β] [Iterator α₂ Id γ] {f : β → Iter γ} {it₁ it₁' : Iter β} (h : it₁.IsPlausibleStep (IterStep.skip it₁')) :
(Iter.flatMapAfter f it₁ none).IsPlausibleStep (IterStep.skip (Iter.flatMapAfter f it₁' none))
source
theorem Std.Iterators.Flatten.IsPlausibleStep.outerDone_flatMap_pure {α β α₂ γ : Type w} [Iterator α Id β] [Iterator α₂ Id γ] {f : β → Iter γ} {it₁ : Iter β} (h : it₁.IsPlausibleStep IterStep.done) :
(Iter.flatMapAfter f it₁ none).IsPlausibleStep IterStep.done
source
theorem Std.Iterators.Flatten.IsPlausibleStep.innerYield_flatMap_pure {α β α₂ γ : Type w} [Iterator α Id β] [Iterator α₂ Id γ] {f : β → Iter γ} {it₁ : Iter β} {it₂ it₂' : Iter γ} {b : γ} (h : it₂.IsPlausibleStep (IterStep.yield it₂' b)) :
(Iter.flatMapAfter f it₁ (some it₂)).IsPlausibleStep (IterStep.yield (Iter.flatMapAfter f it₁ (some it₂')) b)
source
theorem Std.Iterators.Flatten.IsPlausibleStep.innerSkip_flatMap_pure {α β α₂ γ : Type w} [Iterator α Id β] [Iterator α₂ Id γ] {f : β → Iter γ} {it₁ : Iter β} {it₂ it₂' : Iter γ} (h : it₂.IsPlausibleStep (IterStep.skip it₂')) :
(Iter.flatMapAfter f it₁ (some it₂)).IsPlausibleStep (IterStep.skip (Iter.flatMapAfter f it₁ (some it₂')))
source
theorem Std.Iterators.Flatten.IsPlausibleStep.innerDone_flatMap_pure {α β α₂ γ : Type w} [Iterator α Id β] [Iterator α₂ Id γ] {f : β → Iter γ} {it₁ : Iter β} {it₂ : Iter γ} (h : it₂.IsPlausibleStep IterStep.done) :
(Iter.flatMapAfter f it₁ (some it₂)).IsPlausibleStep (IterStep.skip (Iter.flatMapAfter f it₁ none))
source
theorem Std.Iterators.Iter.step_flatMapAfterM {α β α₂ γ : Type w} {m : Type w → Type w'} [Monad m] [LawfulMonad m] [Iterator α Id β] [Iterator α₂ m γ] {f : β → m (IterM m γ)} {it₁ : Iter β} {it₂ : Option (IterM m γ)} :
(flatMapAfterM f it₁ it₂).step = match it₂ with | none => match it₁.step with | ⟨IterStep.yield it₁' b, h⟩ => do let __do_lift ← f b pure (Shrink.deflate (PlausibleIterStep.skip (flatMapAfterM f it₁' (some __do_lift)) ⋯)) | ⟨IterStep.skip it₁', h⟩ => pure (Shrink.deflate (PlausibleIterStep.skip (flatMapAfterM f it₁' none) ⋯)) | ⟨IterStep.done, h⟩ => pure (Shrink.deflate (PlausibleIterStep.done ⋯)) | some it₂ => do let __do_lift ← it₂.step match __do_lift.inflate with | ⟨IterStep.yield it₂' out, h⟩ => pure (Shrink.deflate (PlausibleIterStep.yield (flatMapAfterM f it₁ (some it₂')) out ⋯)) | ⟨IterStep.skip it₂', h⟩ => pure (Shrink.deflate (PlausibleIterStep.skip (flatMapAfterM f it₁ (some it₂')) ⋯)) | ⟨IterStep.done, h⟩ => pure (Shrink.deflate (PlausibleIterStep.skip (flatMapAfterM f it₁ none) ⋯))
source
theorem Std.Iterators.Iter.step_flatMapM {α β α₂ γ : Type w} {m : Type w → Type w'} [Monad m] [LawfulMonad m] [Iterator α Id β] [Iterator α₂ m γ] {f : β → m (IterM m γ)} {it₁ : Iter β} :
(flatMapM f it₁).step = match it₁.step with | ⟨IterStep.yield it₁' b, h⟩ => do let __do_lift ← f b pure (Shrink.deflate (PlausibleIterStep.skip (flatMapAfterM f it₁' (some __do_lift)) ⋯)) | ⟨IterStep.skip it₁', h⟩ => pure (Shrink.deflate (PlausibleIterStep.skip (flatMapAfterM f it₁' none) ⋯)) | ⟨IterStep.done, h⟩ => pure (Shrink.deflate (PlausibleIterStep.done ⋯))
source
theorem Std.Iterators.Iter.step_flatMapAfter {α β α₂ γ : Type w} [Iterator α Id β] [Iterator α₂ Id γ] {f : β → Iter γ} {it₁ : Iter β} {it₂ : Option (Iter γ)} :
(flatMapAfter f it₁ it₂).step = match it₂ with | none => match it₁.step with | ⟨IterStep.yield it₁' b, h⟩ => PlausibleIterStep.skip (flatMapAfter f it₁' (some (f b))) ⋯ | ⟨IterStep.skip it₁', h⟩ => PlausibleIterStep.skip (flatMapAfter f it₁' none) ⋯ | ⟨IterStep.done, h⟩ => PlausibleIterStep.done ⋯ | some it₂ => match it₂.step with | ⟨IterStep.yield it₂' out, h⟩ => PlausibleIterStep.yield (flatMapAfter f it₁ (some it₂')) out ⋯ | ⟨IterStep.skip it₂', h⟩ => PlausibleIterStep.skip (flatMapAfter f it₁ (some it₂')) ⋯ | ⟨IterStep.done, h⟩ => PlausibleIterStep.skip (flatMapAfter f it₁ none) ⋯
source
theorem Std.Iterators.Iter.step_flatMap {α β α₂ γ : Type w} [Iterator α Id β] [Iterator α₂ Id γ] {f : β → Iter γ} {it₁ : Iter β} :
(flatMap f it₁).step = match it₁.step with | ⟨IterStep.yield it₁' b, h⟩ => PlausibleIterStep.skip (flatMapAfter f it₁' (some (f b))) ⋯ | ⟨IterStep.skip it₁', h⟩ => PlausibleIterStep.skip (flatMapAfter f it₁' none) ⋯ | ⟨IterStep.done, h⟩ => PlausibleIterStep.done ⋯
source
theorem Std.Iterators.Iter.toList_flatMapAfterM {α α₂ β γ : Type w} {m : Type w → Type w'} [Monad m] [LawfulMonad m] [Iterator α Id β] [Iterator α₂ m γ] [Finite α Id] [Finite α₂ m] [IteratorCollect α Id m] [IteratorCollect α₂ m m] [LawfulIteratorCollect α Id m] [LawfulIteratorCollect α₂ m m] {f : β → m (IterM m γ)} {it₁ : Iter β} {it₂ : Option (IterM m γ)} :
(flatMapAfterM f it₁ it₂).toList = match it₂ with | none => List.flatten <$> (mapM (fun (b : β) => do let __do_lift ← f b __do_lift.toList) it₁).toList | some it₂ => do let __do_lift ← it₂.toList let __do_lift_1 ← List.flatten <$> (mapM (fun (b : β) => do let __do_lift ← f b __do_lift.toList) it₁).toList pure (__do_lift ++ __do_lift_1)
source
theorem Std.Iterators.Iter.toArray_flatMapAfterM {α α₂ β γ : Type w} {m : Type w → Type w'} [Monad m] [LawfulMonad m] [Iterator α Id β] [Iterator α₂ m γ] [Finite α Id] [Finite α₂ m] [IteratorCollect α Id m] [IteratorCollect α₂ m m] [LawfulIteratorCollect α Id m] [LawfulIteratorCollect α₂ m m] {f : β → m (IterM m γ)} {it₁ : Iter β} {it₂ : Option (IterM m γ)} :
(flatMapAfterM f it₁ it₂).toArray = match it₂ with | none => Array.flatten <$> (mapM (fun (b : β) => do let __do_lift ← f b __do_lift.toArray) it₁).toArray | some it₂ => do let __do_lift ← it₂.toArray let __do_lift_1 ← Array.flatten <$> (mapM (fun (b : β) => do let __do_lift ← f b __do_lift.toArray) it₁).toArray pure (__do_lift ++ __do_lift_1)
source
theorem Std.Iterators.Iter.toList_flatMapM {α α₂ β γ : Type w} {m : Type w → Type w'} [Monad m] [LawfulMonad m] [Iterator α Id β] [Iterator α₂ m γ] [Finite α Id] [Finite α₂ m] [IteratorCollect α Id m] [IteratorCollect α₂ m m] [LawfulIteratorCollect α Id m] [LawfulIteratorCollect α₂ m m] {f : β → m (IterM m γ)} {it₁ : Iter β} :
(flatMapM f it₁).toList = List.flatten <$> (mapM (fun (b : β) => do let __do_lift ← f b __do_lift.toList) it₁).toList
source
theorem Std.Iterators.Iter.toArray_flatMapM {α α₂ β γ : Type w} {m : Type w → Type w'} [Monad m] [LawfulMonad m] [Iterator α Id β] [Iterator α₂ m γ] [Finite α Id] [Finite α₂ m] [IteratorCollect α Id m] [IteratorCollect α₂ m m] [LawfulIteratorCollect α Id m] [LawfulIteratorCollect α₂ m m] {f : β → m (IterM m γ)} {it₁ : Iter β} :
(flatMapM f it₁).toArray = Array.flatten <$> (mapM (fun (b : β) => do let __do_lift ← f b __do_lift.toArray) it₁).toArray
source
theorem Std.Iterators.Iter.toList_flatMapAfter {α α₂ β γ : Type w} [Iterator α Id β] [Iterator α₂ Id γ] [Finite α Id] [Finite α₂ Id] [IteratorCollect α Id Id] [IteratorCollect α₂ Id Id] [LawfulIteratorCollect α Id Id] [LawfulIteratorCollect α₂ Id Id] {f : β → Iter γ} {it₁ : Iter β} {it₂ : Option (Iter γ)} :
(flatMapAfter f it₁ it₂).toList = match it₂ with | none => (map (fun (b : β) => (f b).toList) it₁).toList.flatten | some it₂ => it₂.toList ++ (map (fun (b : β) => (f b).toList) it₁).toList.flatten
source
theorem Std.Iterators.Iter.toArray_flatMapAfter {α α₂ β γ : Type w} [Iterator α Id β] [Iterator α₂ Id γ] [Finite α Id] [Finite α₂ Id] [IteratorCollect α Id Id] [IteratorCollect α₂ Id Id] [LawfulIteratorCollect α Id Id] [LawfulIteratorCollect α₂ Id Id] {f : β → Iter γ} {it₁ : Iter β} {it₂ : Option (Iter γ)} :
(flatMapAfter f it₁ it₂).toArray = match it₂ with | none => (map (fun (b : β) => (f b).toArray) it₁).toArray.flatten | some it₂ => it₂.toArray ++ (map (fun (b : β) => (f b).toArray) it₁).toArray.flatten
source
theorem Std.Iterators.Iter.toList_flatMap {α α₂ β γ : Type w} [Iterator α Id β] [Iterator α₂ Id γ] [Finite α Id] [Finite α₂ Id] [Iterator α Id β] [Iterator α₂ Id γ] [Finite α Id] [Finite α₂ Id] [IteratorCollect α Id Id] [IteratorCollect α₂ Id Id] [LawfulIteratorCollect α Id Id] [LawfulIteratorCollect α₂ Id Id] {f : β → Iter γ} {it₁ : Iter β} :
(flatMap f it₁).toList = (map (fun (b : β) => (f b).toList) it₁).toList.flatten
source
theorem Std.Iterators.Iter.toArray_flatMap {α α₂ β γ : Type w} [Iterator α Id β] [Iterator α₂ Id γ] [Finite α Id] [Finite α₂ Id] [Iterator α Id β] [Iterator α₂ Id γ] [Finite α Id] [Finite α₂ Id] [IteratorCollect α Id Id] [IteratorCollect α₂ Id Id] [LawfulIteratorCollect α Id Id] [LawfulIteratorCollect α₂ Id Id] {f : β → Iter γ} {it₁ : Iter β} :
(flatMap f it₁).toArray = (map (fun (b : β) => (f b).toArray) it₁).toArray.flatten