theorem
Std.Iterators.IterM.step_filterMapWithPostcondition
{α β β' : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
{it : IterM m β}
{f : β → PostconditionT n (Option β')}
[Monad n]
[LawfulMonad n]
[MonadLiftT m n]
:
(filterMapWithPostcondition f it).step = do
let __do_lift ← liftM it.step
match __do_lift.inflate with
| ⟨IterStep.yield it' out, h⟩ => do
let __do_lift ← (f out).operation
match __do_lift with
| ⟨none, h'⟩ => pure (Shrink.deflate (PlausibleIterStep.skip (filterMapWithPostcondition f it') ⋯))
| ⟨some out', h'⟩ => pure (Shrink.deflate (PlausibleIterStep.yield (filterMapWithPostcondition f it') out' ⋯))
| ⟨IterStep.skip it', h⟩ => pure (Shrink.deflate (PlausibleIterStep.skip (filterMapWithPostcondition f it') ⋯))
| ⟨IterStep.done, h⟩ => pure (Shrink.deflate (PlausibleIterStep.done ⋯))
theorem
Std.Iterators.IterM.step_filterWithPostcondition
{α β : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
{it : IterM m β}
{f : β → PostconditionT n (ULift Bool)}
[Monad n]
[LawfulMonad n]
[MonadLiftT m n]
:
(filterWithPostcondition f it).step = do
let __do_lift ← liftM it.step
match __do_lift.inflate with
| ⟨IterStep.yield it' out, h⟩ => do
let __do_lift ← (f out).operation
match __do_lift with
| ⟨{ down := false }, h'⟩ => pure (Shrink.deflate (PlausibleIterStep.skip (filterWithPostcondition f it') ⋯))
| ⟨{ down := true }, h'⟩ =>
pure (Shrink.deflate (PlausibleIterStep.yield (filterWithPostcondition f it') out ⋯))
| ⟨IterStep.skip it', h⟩ => pure (Shrink.deflate (PlausibleIterStep.skip (filterWithPostcondition f it') ⋯))
| ⟨IterStep.done, h⟩ => pure (Shrink.deflate (PlausibleIterStep.done ⋯))
theorem
Std.Iterators.IterM.step_mapWithPostcondition
{α β : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
{it : IterM m β}
{γ : Type w}
{f : β → PostconditionT n γ}
[Monad n]
[LawfulMonad n]
[MonadLiftT m n]
:
(mapWithPostcondition f it).step = do
let __do_lift ← liftM it.step
match __do_lift.inflate with
| ⟨IterStep.yield it' out, h⟩ => do
let out' ← (f out).operation
pure (Shrink.deflate (PlausibleIterStep.yield (mapWithPostcondition f it') out'.val ⋯))
| ⟨IterStep.skip it', h⟩ => pure (Shrink.deflate (PlausibleIterStep.skip (mapWithPostcondition f it') ⋯))
| ⟨IterStep.done, h⟩ => pure (Shrink.deflate (PlausibleIterStep.done ⋯))
theorem
Std.Iterators.IterM.step_filterMapM
{α β β' : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
{it : IterM m β}
{f : β → n (Option β')}
[Monad n]
[LawfulMonad n]
[MonadLiftT m n]
:
(filterMapM f it).step = do
let __do_lift ← liftM it.step
match __do_lift.inflate with
| ⟨IterStep.yield it' out, h⟩ => do
let __do_lift ← f out
match __do_lift with
| none => pure (Shrink.deflate (PlausibleIterStep.skip (filterMapM f it') ⋯))
| some out' => pure (Shrink.deflate (PlausibleIterStep.yield (filterMapM f it') out' ⋯))
| ⟨IterStep.skip it', h⟩ => pure (Shrink.deflate (PlausibleIterStep.skip (filterMapM f it') ⋯))
| ⟨IterStep.done, h⟩ => pure (Shrink.deflate (PlausibleIterStep.done ⋯))
theorem
Std.Iterators.IterM.step_filterM
{α β : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
{it : IterM m β}
{f : β → n (ULift Bool)}
[Monad n]
[LawfulMonad n]
[MonadLiftT m n]
:
(filterM f it).step = do
let __do_lift ← liftM it.step
match __do_lift.inflate with
| ⟨IterStep.yield it' out, h⟩ => do
let __do_lift ← f out
match __do_lift with
| { down := false } => pure (Shrink.deflate (PlausibleIterStep.skip (filterM f it') ⋯))
| { down := true } => pure (Shrink.deflate (PlausibleIterStep.yield (filterM f it') out ⋯))
| ⟨IterStep.skip it', h⟩ => pure (Shrink.deflate (PlausibleIterStep.skip (filterM f it') ⋯))
| ⟨IterStep.done, h⟩ => pure (Shrink.deflate (PlausibleIterStep.done ⋯))
theorem
Std.Iterators.IterM.step_mapM
{α β : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
{it : IterM m β}
{γ : Type w}
{f : β → n γ}
[Monad n]
[LawfulMonad n]
[MonadLiftT m n]
:
(mapM f it).step = do
let __do_lift ← liftM it.step
match __do_lift.inflate with
| ⟨IterStep.yield it' out, h⟩ => do
let out' ← f out
pure (Shrink.deflate (PlausibleIterStep.yield (mapM f it') out' ⋯))
| ⟨IterStep.skip it', h⟩ => pure (Shrink.deflate (PlausibleIterStep.skip (mapM f it') ⋯))
| ⟨IterStep.done, h⟩ => pure (Shrink.deflate (PlausibleIterStep.done ⋯))
theorem
Std.Iterators.IterM.step_filterMap
{α β β' : Type w}
{m : Type w → Type w'}
[Iterator α m β]
{it : IterM m β}
[Monad m]
[LawfulMonad m]
{f : β → Option β'}
:
(filterMap f it).step = do
let __do_lift ← it.step
match __do_lift.inflate with
| ⟨IterStep.yield it' out, h⟩ =>
match h' : f out with
| none => pure (Shrink.deflate (PlausibleIterStep.skip (filterMap f it') ⋯))
| some out' => pure (Shrink.deflate (PlausibleIterStep.yield (filterMap f it') out' ⋯))
| ⟨IterStep.skip it', h⟩ => pure (Shrink.deflate (PlausibleIterStep.skip (filterMap f it') ⋯))
| ⟨IterStep.done, h⟩ => pure (Shrink.deflate (PlausibleIterStep.done ⋯))
theorem
Std.Iterators.IterM.step_map
{α β β' : Type w}
{m : Type w → Type w'}
[Iterator α m β]
{it : IterM m β}
[Monad m]
[LawfulMonad m]
{f : β → β'}
:
(map f it).step = do
let __do_lift ← it.step
match __do_lift.inflate with
| ⟨IterStep.yield it' out, h⟩ =>
let out' := f out;
pure (Shrink.deflate (PlausibleIterStep.yield (map f it') out' ⋯))
| ⟨IterStep.skip it', h⟩ => pure (Shrink.deflate (PlausibleIterStep.skip (map f it') ⋯))
| ⟨IterStep.done, h⟩ => pure (Shrink.deflate (PlausibleIterStep.done ⋯))
theorem
Std.Iterators.IterM.step_filter
{α β : Type w}
{m : Type w → Type w'}
[Iterator α m β]
{it : IterM m β}
[Monad m]
[LawfulMonad m]
{f : β → Bool}
:
(filter f it).step = do
let __do_lift ← it.step
match __do_lift.inflate with
| ⟨IterStep.yield it' out, h⟩ =>
if h' : f out = true then pure (Shrink.deflate (PlausibleIterStep.yield (filter f it') out ⋯))
else pure (Shrink.deflate (PlausibleIterStep.skip (filter f it') ⋯))
| ⟨IterStep.skip it', h⟩ => pure (Shrink.deflate (PlausibleIterStep.skip (filter f it') ⋯))
| ⟨IterStep.done, h⟩ => pure (Shrink.deflate (PlausibleIterStep.done ⋯))
instance
Std.Iterators.instLawfulIteratorCollectMapOfLawfulMonadOfLawfulMonadLiftFunction
{α β γ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
{o : Type w → Type x}
[Monad m]
[Monad n]
[Monad o]
[LawfulMonad n]
[LawfulMonad o]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m o]
[LawfulIteratorCollect α m o]
{lift : ⦃δ : Type w⦄ → m δ → n δ}
{f : β → PostconditionT n γ}
[Internal.LawfulMonadLiftFunction lift]
:
LawfulIteratorCollect (Map α m n lift f) n o
theorem
Std.Iterators.IterM.InternalConsumers.toList_filterMap
{α β γ : Type w}
{m : Type w → Type w'}
[Monad m]
[LawfulMonad m]
[Iterator α m β]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
[Finite α m]
{f : β → Option γ}
(it : IterM m β)
:
theorem
Std.Iterators.IterM.toList_map_eq_toList_mapM
{α β γ : Type w}
{m : Type w → Type w'}
[Monad m]
[LawfulMonad m]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
{f : β → γ}
{it : IterM m β}
:
theorem
Std.Iterators.IterM.toList_mapM_eq_toList_filterMapM
{α β γ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[MonadLiftT m n]
[LawfulMonadLiftT m n]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m n]
[LawfulIteratorCollect α m n]
{f : β → n γ}
{it : IterM m β}
:
theorem
Std.Iterators.IterM.toList_map_eq_toList_filterMapM
{α β γ : Type w}
{m : Type w → Type w'}
[Monad m]
[LawfulMonad m]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
{f : β → γ}
{it : IterM m β}
:
@[simp]
theorem
Std.Iterators.IterM.toList_filterMapM_filterMapM
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
{o : Type w → Type w'''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[Monad o]
[LawfulMonad o]
[MonadLiftT m n]
[MonadLiftT n o]
[LawfulMonadLiftT m n]
[LawfulMonadLiftT n o]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
{f : β → n (Option γ)}
{g : γ → o (Option δ)}
{it : IterM m β}
:
(filterMapM g (filterMapM f it)).toList = (filterMapM
(fun (b : β) => do
let __do_lift ← liftM (f b)
match __do_lift with
| none => pure none
| some fb => g fb)
it).toList
@[simp]
theorem
Std.Iterators.IterM.toList_filterMapM_mapM
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
{o : Type w → Type w'''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[Monad o]
[LawfulMonad o]
[MonadLiftT m n]
[MonadLiftT n o]
[LawfulMonadLiftT m n]
[LawfulMonadLiftT n o]
[Iterator α m β]
[Finite α m]
{f : β → n γ}
{g : γ → o (Option δ)}
{it : IterM m β}
:
(filterMapM g (mapM f it)).toList = (filterMapM
(fun (b : β) => do
let __do_lift ← liftM (f b)
g __do_lift)
it).toList
@[simp]
theorem
Std.Iterators.IterM.toList_filterMapM_map
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[MonadLiftT m n]
[LawfulMonadLiftT m n]
[Iterator α m β]
[Finite α m]
{f : β → γ}
{g : γ → n (Option δ)}
{it : IterM m β}
:
@[simp]
theorem
Std.Iterators.IterM.toList_mapM_filterMapM
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
{o : Type w → Type w'''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[Monad o]
[LawfulMonad o]
[MonadLiftT m n]
[MonadLiftT n o]
[LawfulMonadLiftT m n]
[LawfulMonadLiftT n o]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
{f : β → n (Option γ)}
{g : γ → o δ}
{it : IterM m β}
:
@[simp]
theorem
Std.Iterators.IterM.toList_mapM_mapM
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
{o : Type w → Type w'''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[Monad o]
[LawfulMonad o]
[MonadLiftT m n]
[MonadLiftT n o]
[LawfulMonadLiftT m n]
[LawfulMonadLiftT n o]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m o]
[LawfulIteratorCollect α m o]
{f : β → n γ}
{g : γ → o δ}
{it : IterM m β}
:
@[simp]
theorem
Std.Iterators.IterM.toList_mapM_map
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[MonadLiftT m n]
[LawfulMonadLiftT m n]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m n]
[LawfulIteratorCollect α m n]
{f : β → γ}
{g : γ → n δ}
{it : IterM m β}
:
theorem
Std.Iterators.IterM.toList_filterMap
{α β γ : Type w}
{m : Type w → Type w'}
[Monad m]
[LawfulMonad m]
[Iterator α m β]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
[Finite α m]
{f : β → Option γ}
(it : IterM m β)
:
theorem
Std.Iterators.IterM.toList_map
{α β β' : Type w}
{m : Type w → Type w'}
[Monad m]
[LawfulMonad m]
[Iterator α m β]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
[Finite α m]
{f : β → β'}
(it : IterM m β)
:
theorem
Std.Iterators.IterM.toList_filter
{α : Type w}
{m : Type w → Type w'}
[Monad m]
[LawfulMonad m]
{β : Type w}
[Iterator α m β]
[Finite α m]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
{f : β → Bool}
{it : IterM m β}
:
theorem
Std.Iterators.IterM.toListRev_map_eq_toListRev_mapM
{α β γ : Type w}
{m : Type w → Type w'}
[Monad m]
[LawfulMonad m]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
{f : β → γ}
{it : IterM m β}
:
theorem
Std.Iterators.IterM.toListRev_mapM_eq_toListRev_filterMapM
{α β γ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[MonadLiftT m n]
[LawfulMonadLiftT m n]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m n]
[LawfulIteratorCollect α m n]
{f : β → n γ}
{it : IterM m β}
:
theorem
Std.Iterators.IterM.toListRev_map_eq_toListRev_filterMapM
{α β γ : Type w}
{m : Type w → Type w'}
[Monad m]
[LawfulMonad m]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
{f : β → γ}
{it : IterM m β}
:
theorem
Std.Iterators.IterM.toListRev_filterMap
{α β γ : Type w}
{m : Type w → Type w'}
[Monad m]
[LawfulMonad m]
[Iterator α m β]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
[Finite α m]
{f : β → Option γ}
(it : IterM m β)
:
theorem
Std.Iterators.IterM.toListRev_map
{α β γ : Type w}
{m : Type w → Type w'}
[Monad m]
[LawfulMonad m]
[Iterator α m β]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
[Finite α m]
{f : β → γ}
(it : IterM m β)
:
theorem
Std.Iterators.IterM.toListRev_filter
{α β : Type w}
{m : Type w → Type w'}
[Monad m]
[LawfulMonad m]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
{f : β → Bool}
{it : IterM m β}
:
@[simp]
theorem
Std.Iterators.IterM.toListRev_filterMapM_filterMapM
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
{o : Type w → Type w'''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[Monad o]
[LawfulMonad o]
[MonadLiftT m n]
[MonadLiftT n o]
[LawfulMonadLiftT m n]
[LawfulMonadLiftT n o]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
{f : β → n (Option γ)}
{g : γ → o (Option δ)}
{it : IterM m β}
:
(filterMapM g (filterMapM f it)).toListRev = (filterMapM
(fun (b : β) => do
let __do_lift ← liftM (f b)
match __do_lift with
| none => pure none
| some fb => g fb)
it).toListRev
@[simp]
theorem
Std.Iterators.IterM.toListRev_filterMapM_mapM
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
{o : Type w → Type w'''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[Monad o]
[LawfulMonad o]
[MonadLiftT m n]
[MonadLiftT n o]
[LawfulMonadLiftT m n]
[LawfulMonadLiftT n o]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
{f : β → n γ}
{g : γ → o (Option δ)}
{it : IterM m β}
:
(filterMapM g (mapM f it)).toListRev = (filterMapM
(fun (b : β) => do
let __do_lift ← liftM (f b)
g __do_lift)
it).toListRev
@[simp]
theorem
Std.Iterators.IterM.toListRev_filterMapM_map
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[MonadLiftT m n]
[LawfulMonadLiftT m n]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
{f : β → γ}
{g : γ → n (Option δ)}
{it : IterM m β}
:
@[simp]
theorem
Std.Iterators.IterM.toListRev_mapM_filterMapM
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
{o : Type w → Type w'''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[Monad o]
[LawfulMonad o]
[MonadLiftT m n]
[MonadLiftT n o]
[LawfulMonadLiftT m n]
[LawfulMonadLiftT n o]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
{f : β → n (Option γ)}
{g : γ → o δ}
{it : IterM m β}
:
@[simp]
theorem
Std.Iterators.IterM.toListRev_mapM_mapM
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
{o : Type w → Type w'''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[Monad o]
[LawfulMonad o]
[MonadLiftT m n]
[MonadLiftT n o]
[LawfulMonadLiftT m n]
[LawfulMonadLiftT n o]
[Iterator α m β]
[Finite α m]
{f : β → n γ}
{g : γ → o δ}
{it : IterM m β}
:
@[simp]
theorem
Std.Iterators.IterM.toListRev_mapM_map
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[MonadLiftT m n]
[LawfulMonadLiftT m n]
[Iterator α m β]
[Finite α m]
{f : β → γ}
{g : γ → n δ}
{it : IterM m β}
:
theorem
Std.Iterators.IterM.toArray_map_eq_toArray_mapM
{α β γ : Type w}
{m : Type w → Type w'}
[Monad m]
[LawfulMonad m]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
{f : β → γ}
{it : IterM m β}
:
theorem
Std.Iterators.IterM.toArray_mapM_eq_toArray_filterMapM
{α β γ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[MonadLiftT m n]
[LawfulMonadLiftT m n]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m n]
[LawfulIteratorCollect α m n]
{f : β → n γ}
{it : IterM m β}
:
theorem
Std.Iterators.IterM.toArray_map_eq_toArray_filterMapM
{α β γ : Type w}
{m : Type w → Type w'}
[Monad m]
[LawfulMonad m]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
{f : β → γ}
{it : IterM m β}
:
theorem
Std.Iterators.IterM.toArray_filterMap
{α β γ : Type w}
{m : Type w → Type w'}
[Monad m]
[LawfulMonad m]
[Iterator α m β]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
[Finite α m]
{f : β → Option γ}
(it : IterM m β)
:
theorem
Std.Iterators.IterM.toArray_map
{α β γ : Type w}
{m : Type w → Type w'}
[Monad m]
[LawfulMonad m]
[Iterator α m β]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
[Finite α m]
{f : β → γ}
(it : IterM m β)
:
theorem
Std.Iterators.IterM.toArray_filter
{α : Type w}
{m : Type w → Type w'}
[Monad m]
[LawfulMonad m]
{β : Type w}
[Iterator α m β]
[Finite α m]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
{f : β → Bool}
{it : IterM m β}
:
@[simp]
theorem
Std.Iterators.IterM.toArray_filterMapM_filterMapM
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
{o : Type w → Type w'''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[Monad o]
[LawfulMonad o]
[MonadLiftT m n]
[MonadLiftT n o]
[LawfulMonadLiftT m n]
[LawfulMonadLiftT n o]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
{f : β → n (Option γ)}
{g : γ → o (Option δ)}
{it : IterM m β}
:
(filterMapM g (filterMapM f it)).toArray = (filterMapM
(fun (b : β) => do
let __do_lift ← liftM (f b)
match __do_lift with
| none => pure none
| some fb => g fb)
it).toArray
@[simp]
theorem
Std.Iterators.IterM.toArray_filterMapM_mapM
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
{o : Type w → Type w'''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[Monad o]
[LawfulMonad o]
[MonadLiftT m n]
[MonadLiftT n o]
[LawfulMonadLiftT m n]
[LawfulMonadLiftT n o]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
{f : β → n γ}
{g : γ → o (Option δ)}
{it : IterM m β}
:
(filterMapM g (mapM f it)).toArray = (filterMapM
(fun (b : β) => do
let __do_lift ← liftM (f b)
g __do_lift)
it).toArray
@[simp]
theorem
Std.Iterators.IterM.toArray_filterMapM_map
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[MonadLiftT m n]
[LawfulMonadLiftT m n]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
{f : β → γ}
{g : γ → n (Option δ)}
{it : IterM m β}
:
@[simp]
theorem
Std.Iterators.IterM.toArray_mapM_filterMapM
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
{o : Type w → Type w'''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[Monad o]
[LawfulMonad o]
[MonadLiftT m n]
[MonadLiftT n o]
[LawfulMonadLiftT m n]
[LawfulMonadLiftT n o]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m m]
[LawfulIteratorCollect α m m]
{f : β → n (Option γ)}
{g : γ → o δ}
{it : IterM m β}
:
@[simp]
theorem
Std.Iterators.IterM.toArray_mapM_mapM
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
{o : Type w → Type w'''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[Monad o]
[LawfulMonad o]
[MonadLiftT m n]
[MonadLiftT n o]
[LawfulMonadLiftT m n]
[LawfulMonadLiftT n o]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m o]
[LawfulIteratorCollect α m o]
{f : β → n γ}
{g : γ → o δ}
{it : IterM m β}
:
@[simp]
theorem
Std.Iterators.IterM.toArray_mapM_map
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Monad m]
[LawfulMonad m]
[Monad n]
[LawfulMonad n]
[MonadLiftT m n]
[LawfulMonadLiftT m n]
[Iterator α m β]
[Finite α m]
[IteratorCollect α m n]
[LawfulIteratorCollect α m n]
{f : β → γ}
{g : γ → n δ}
{it : IterM m β}
:
theorem
Std.Iterators.IterM.foldM_filterMapM
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
{o : Type w → Type w'''}
[Iterator α m β]
[Finite α m]
[Monad m]
[Monad n]
[Monad o]
[LawfulMonad m]
[LawfulMonad n]
[LawfulMonad o]
[IteratorLoop α m n]
[IteratorLoop α m o]
[LawfulIteratorLoop α m n]
[LawfulIteratorLoop α m o]
[MonadLiftT m n]
[MonadLiftT n o]
[LawfulMonadLiftT m n]
[LawfulMonadLiftT n o]
{f : β → n (Option γ)}
{g : δ → γ → o δ}
{init : δ}
{it : IterM m β}
:
theorem
Std.Iterators.IterM.foldM_mapM
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
{o : Type w → Type w'''}
[Iterator α m β]
[Finite α m]
[Monad m]
[Monad n]
[Monad o]
[LawfulMonad m]
[LawfulMonad n]
[LawfulMonad o]
[IteratorLoop α m n]
[IteratorLoop α m o]
[LawfulIteratorLoop α m n]
[LawfulIteratorLoop α m o]
[MonadLiftT m n]
[MonadLiftT n o]
[LawfulMonadLiftT m n]
[LawfulMonadLiftT n o]
{f : β → n γ}
{g : δ → γ → o δ}
{init : δ}
{it : IterM m β}
:
theorem
Std.Iterators.IterM.foldM_filterMap
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
[Finite α m]
[Monad m]
[Monad n]
[LawfulMonad m]
[LawfulMonad n]
[IteratorLoop α m m]
[IteratorLoop α m n]
[LawfulIteratorLoop α m m]
[LawfulIteratorLoop α m n]
[MonadLiftT m n]
[LawfulMonadLiftT m n]
{f : β → Option γ}
{g : δ → γ → n δ}
{init : δ}
{it : IterM m β}
:
theorem
Std.Iterators.IterM.foldM_map
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
[Finite α m]
[Monad m]
[Monad n]
[LawfulMonad m]
[LawfulMonad n]
[IteratorLoop α m m]
[IteratorLoop α m n]
[LawfulIteratorLoop α m m]
[LawfulIteratorLoop α m n]
[MonadLiftT m n]
[LawfulMonadLiftT m n]
{f : β → γ}
{g : δ → γ → n δ}
{init : δ}
{it : IterM m β}
:
theorem
Std.Iterators.IterM.fold_filterMapM
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
[Finite α m]
[Monad m]
[Monad n]
[LawfulMonad m]
[LawfulMonad n]
[IteratorLoop α m m]
[IteratorLoop α m n]
[LawfulIteratorLoop α m m]
[LawfulIteratorLoop α m n]
[MonadLiftT m n]
[LawfulMonadLiftT m n]
{f : β → n (Option γ)}
{g : δ → γ → δ}
{init : δ}
{it : IterM m β}
:
theorem
Std.Iterators.IterM.fold_mapM
{α β γ δ : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
[Finite α m]
[Monad m]
[Monad n]
[LawfulMonad m]
[LawfulMonad n]
[IteratorLoop α m m]
[IteratorLoop α m n]
[LawfulIteratorLoop α m m]
[LawfulIteratorLoop α m n]
[MonadLiftT m n]
[LawfulMonadLiftT m n]
{f : β → n γ}
{g : δ → γ → δ}
{init : δ}
{it : IterM m β}
:
theorem
Std.Iterators.IterM.fold_filterMap
{α β γ δ : Type w}
{m : Type w → Type w'}
[Iterator α m β]
[Finite α m]
[Monad m]
[LawfulMonad m]
[IteratorLoop α m m]
[LawfulIteratorLoop α m m]
{f : β → Option γ}
{g : δ → γ → δ}
{init : δ}
{it : IterM m β}
:
theorem
Std.Iterators.IterM.fold_map
{α β γ δ : Type w}
{m : Type w → Type w'}
[Iterator α m β]
[Finite α m]
[Monad m]
[LawfulMonad m]
[IteratorLoop α m m]
[LawfulIteratorLoop α m m]
{f : β → γ}
{g : δ → γ → δ}
{init : δ}
{it : IterM m β}
:
theorem
Std.Iterators.IterM.anyM_filterMapM
{α β β' : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
[Finite α m]
[Monad m]
[Monad n]
[MonadLiftT m n]
[LawfulMonad m]
[LawfulMonad n]
{it : IterM m β}
{f : β → n (Option β')}
{p : β' → n (ULift Bool)}
:
theorem
Std.Iterators.IterM.anyM_mapM
{α β β' : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
[Finite α m]
[Monad m]
[Monad n]
[MonadLiftT m n]
[LawfulMonad m]
[LawfulMonad n]
{it : IterM m β}
{f : β → n β'}
{p : β' → n (ULift Bool)}
:
theorem
Std.Iterators.IterM.anyM_filterM
{α β : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
[Finite α m]
[Monad m]
[Monad n]
[MonadLiftT m n]
[LawfulMonad m]
[LawfulMonad n]
{it : IterM m β}
{f p : β → n (ULift Bool)}
:
theorem
Std.Iterators.IterM.anyM_filterMap
{α β β' : Type w}
{m : Type w → Type w'}
[Iterator α m β]
[Finite α m]
[Monad m]
[IteratorLoop α m m]
[LawfulMonad m]
[LawfulIteratorLoop α m m]
{it : IterM m β}
{f : β → Option β'}
{p : β' → m (ULift Bool)}
:
theorem
Std.Iterators.IterM.anyM_map
{α β β' : Type w}
{m : Type w → Type w'}
[Iterator α m β]
[Finite α m]
[Monad m]
[IteratorLoop α m m]
[LawfulMonad m]
[LawfulIteratorLoop α m m]
{it : IterM m β}
{f : β → β'}
{p : β' → m (ULift Bool)}
:
theorem
Std.Iterators.IterM.anyM_filter
{α β : Type w}
{m : Type w → Type w'}
[Iterator α m β]
[Finite α m]
[Monad m]
[IteratorLoop α m m]
[LawfulMonad m]
[LawfulIteratorLoop α m m]
{it : IterM m β}
{f : β → Bool}
{p : β → m (ULift Bool)}
:
theorem
Std.Iterators.IterM.any_filterMapM
{α β β' : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
[Finite α m]
[Monad m]
[Monad n]
[MonadLiftT m n]
[IteratorLoop α m m]
[LawfulMonad m]
[LawfulMonad n]
[LawfulMonadLiftT m n]
[LawfulIteratorLoop α m m]
{it : IterM m β}
{f : β → n (Option β')}
{p : β' → Bool}
:
theorem
Std.Iterators.IterM.any_mapM
{α β β' : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
[Finite α m]
[Monad m]
[Monad n]
[MonadLiftT m n]
[IteratorLoop α m m]
[LawfulMonad m]
[LawfulMonad n]
[LawfulMonadLiftT m n]
[LawfulIteratorLoop α m m]
{it : IterM m β}
{f : β → n β'}
{p : β' → Bool}
:
theorem
Std.Iterators.IterM.any_filterM
{α β : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
[Finite α m]
[Monad m]
[Monad n]
[MonadLiftT m n]
[IteratorLoop α m m]
[LawfulMonad m]
[LawfulMonad n]
[LawfulMonadLiftT m n]
[LawfulIteratorLoop α m m]
{it : IterM m β}
{f : β → n (ULift Bool)}
{p : β → Bool}
:
theorem
Std.Iterators.IterM.any_filterMap
{α β β' : Type w}
{m : Type w → Type w'}
[Iterator α m β]
[Finite α m]
[Monad m]
[IteratorLoop α m m]
[LawfulMonad m]
[LawfulIteratorLoop α m m]
{it : IterM m β}
{f : β → Option β'}
{p : β' → Bool}
:
theorem
Std.Iterators.IterM.any_map
{α β β' : Type w}
{m : Type w → Type w'}
[Iterator α m β]
[Finite α m]
[Monad m]
[IteratorLoop α m m]
[LawfulMonad m]
[LawfulIteratorLoop α m m]
{it : IterM m β}
{f : β → β'}
{p : β' → Bool}
:
theorem
Std.Iterators.IterM.allM_filterMapM
{α β β' : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
[Finite α m]
[Monad m]
[Monad n]
[MonadLiftT m n]
[LawfulMonad m]
[LawfulMonad n]
[LawfulMonadLiftT m n]
{it : IterM m β}
{f : β → n (Option β')}
{p : β' → n (ULift Bool)}
:
theorem
Std.Iterators.IterM.allM_mapM
{α β β' : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
[Finite α m]
[Monad m]
[Monad n]
[MonadLiftT m n]
[LawfulMonad m]
[LawfulMonad n]
[LawfulMonadLiftT m n]
{it : IterM m β}
{f : β → n β'}
{p : β' → n (ULift Bool)}
:
theorem
Std.Iterators.IterM.allM_filterM
{α β : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
[Finite α m]
[Monad m]
[Monad n]
[MonadLiftT m n]
[LawfulMonad m]
[LawfulMonad n]
[LawfulMonadLiftT m n]
{it : IterM m β}
{f p : β → n (ULift Bool)}
:
theorem
Std.Iterators.IterM.allM_filterMap
{α β β' : Type w}
{m : Type w → Type w'}
[Iterator α m β]
[Finite α m]
[Monad m]
[IteratorLoop α m m]
[LawfulMonad m]
[LawfulIteratorLoop α m m]
{it : IterM m β}
{f : β → Option β'}
{p : β' → m (ULift Bool)}
:
theorem
Std.Iterators.IterM.allM_map
{α β β' : Type w}
{m : Type w → Type w'}
[Iterator α m β]
[Finite α m]
[Monad m]
[IteratorLoop α m m]
[LawfulMonad m]
[LawfulIteratorLoop α m m]
{it : IterM m β}
{f : β → β'}
{p : β' → m (ULift Bool)}
:
theorem
Std.Iterators.IterM.allM_filter
{α β : Type w}
{m : Type w → Type w'}
[Iterator α m β]
[Finite α m]
[Monad m]
[IteratorLoop α m m]
[LawfulMonad m]
[LawfulIteratorLoop α m m]
{it : IterM m β}
{f : β → Bool}
{p : β → m (ULift Bool)}
:
theorem
Std.Iterators.IterM.all_filterMapM
{α β β' : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
[Finite α m]
[Monad m]
[Monad n]
[MonadLiftT m n]
[IteratorLoop α m m]
[LawfulMonad m]
[LawfulMonad n]
[LawfulMonadLiftT m n]
[LawfulIteratorLoop α m m]
{it : IterM m β}
{f : β → n (Option β')}
{p : β' → Bool}
:
theorem
Std.Iterators.IterM.all_mapM
{α β β' : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
[Finite α m]
[Monad m]
[Monad n]
[MonadLiftT m n]
[IteratorLoop α m m]
[LawfulMonad m]
[LawfulMonad n]
[LawfulMonadLiftT m n]
[LawfulIteratorLoop α m m]
{it : IterM m β}
{f : β → n β'}
{p : β' → Bool}
:
theorem
Std.Iterators.IterM.all_filterM
{α β : Type w}
{m : Type w → Type w'}
{n : Type w → Type w''}
[Iterator α m β]
[Finite α m]
[Monad m]
[Monad n]
[MonadLiftT m n]
[IteratorLoop α m m]
[LawfulMonad m]
[LawfulMonad n]
[LawfulMonadLiftT m n]
[LawfulIteratorLoop α m m]
{it : IterM m β}
{f : β → n (ULift Bool)}
{p : β → Bool}
:
theorem
Std.Iterators.IterM.all_filterMap
{α β β' : Type w}
{m : Type w → Type w'}
[Iterator α m β]
[Finite α m]
[Monad m]
[IteratorLoop α m m]
[LawfulMonad m]
[LawfulIteratorLoop α m m]
{it : IterM m β}
{f : β → Option β'}
{p : β' → Bool}
:
theorem
Std.Iterators.IterM.all_map
{α β β' : Type w}
{m : Type w → Type w'}
[Iterator α m β]
[Finite α m]
[Monad m]
[IteratorLoop α m m]
[LawfulMonad m]
[LawfulIteratorLoop α m m]
{it : IterM m β}
{f : β → β'}
{p : β' → Bool}
: