Documentation

Init.Data.Iterators.Lemmas.Combinators.Monadic.FilterMap

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] :
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_liftliftM 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] :
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_liftliftM it.step match __do_lift.inflate with | IterStep.yield it' out, h => do let __do_liftf 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_liftliftM it.step match __do_lift.inflate with | IterStep.yield it' out, h => do let __do_liftf 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_liftliftM 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_liftit.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_liftit.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_liftit.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 β) :
(filterMap f it).toList = (fun (x : List β) => List.filterMap f x) <$> it.toList
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 β} :
(map f it).toList = (mapM (fun (b : β) => pure (f b)) it).toList
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 β} :
(mapM f it).toList = (filterMapM (fun (b : β) => some <$> f b) it).toList
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 β} :
(map f it).toList = (filterMapM (fun (b : β) => pure (some (f b))) it).toList
@[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_liftliftM (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_liftliftM (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 β} :
(filterMapM g (map f it)).toList = (filterMapM (fun (b : β) => g (f b)) it).toList
@[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 β} :
(mapM g (filterMapM f it)).toList = (filterMapM (fun (b : β) => do let __do_liftliftM (f b) match __do_lift with | none => pure none | some fb => some <$> g fb) it).toList
@[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 β} :
(mapM g (mapM f it)).toList = (mapM (fun (b : β) => do let __do_liftliftM (f b) g __do_lift) it).toList
@[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 β} :
(mapM g (map f it)).toList = (mapM (fun (b : β) => g (f b)) it).toList
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 β) :
(filterMap f it).toList = (fun (x : List β) => List.filterMap f x) <$> it.toList
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 β) :
(map f it).toList = (fun (x : List β) => List.map f x) <$> it.toList
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 β} :
(map f it).toListRev = (mapM (fun (b : β) => pure (f b)) it).toListRev
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 β} :
(mapM f it).toListRev = (filterMapM (fun (b : β) => some <$> f b) it).toListRev
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 β} :
(map f it).toListRev = (filterMapM (fun (b : β) => pure (some (f b))) it).toListRev
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 β) :
(filterMap f it).toListRev = (fun (x : List β) => List.filterMap f x) <$> it.toListRev
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 β) :
(map f it).toListRev = (fun (x : List β) => List.map f x) <$> it.toListRev
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_liftliftM (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_liftliftM (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 β} :
(filterMapM g (map f it)).toListRev = (filterMapM (fun (b : β) => g (f b)) it).toListRev
@[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 β} :
(mapM g (filterMapM f it)).toListRev = (filterMapM (fun (b : β) => do let __do_liftliftM (f b) match __do_lift with | none => pure none | some fb => some <$> g fb) it).toListRev
@[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 β} :
(mapM g (mapM f it)).toListRev = (mapM (fun (b : β) => do let __do_liftliftM (f b) g __do_lift) it).toListRev
@[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 β} :
(mapM g (map f it)).toListRev = (mapM (fun (b : β) => g (f b)) it).toListRev
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 β} :
(map f it).toArray = (mapM (fun (b : β) => pure (f b)) it).toArray
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 β} :
(mapM f it).toArray = (filterMapM (fun (b : β) => some <$> f b) it).toArray
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 β} :
(map f it).toArray = (filterMapM (fun (b : β) => pure (some (f b))) it).toArray
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 β) :
(filterMap f it).toArray = (fun (x : Array β) => Array.filterMap f x) <$> it.toArray
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 β) :
(map f it).toArray = (fun (x : Array β) => Array.map f x) <$> it.toArray
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 β} :
(filter f it).toArray = (fun (as : Array β) => Array.filter f as) <$> it.toArray
@[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_liftliftM (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_liftliftM (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 β} :
(filterMapM g (map f it)).toArray = (filterMapM (fun (b : β) => g (f b)) it).toArray
@[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 β} :
(mapM g (filterMapM f it)).toArray = (filterMapM (fun (b : β) => do let __do_liftliftM (f b) match __do_lift with | none => pure none | some fb => some <$> g fb) it).toArray
@[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 β} :
(mapM g (mapM f it)).toArray = (mapM (fun (b : β) => do let __do_liftliftM (f b) g __do_lift) it).toArray
@[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 β} :
(mapM g (map f it)).toArray = (mapM (fun (b : β) => g (f b)) it).toArray
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 β} :
foldM g init (filterMapM f it) = foldM (fun (d : δ) (b : β) => do let __discrliftM (f b) match __discr with | some c => g d c | x => pure d) init it
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 β} :
foldM g init (mapM f it) = foldM (fun (d : δ) (b : β) => do let cliftM (f b) g d c) init it
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 β} :
foldM g init (filterMap f it) = foldM (fun (d : δ) (b : β) => match f b with | some c => g d c | x => pure d) init it
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 β} :
foldM g init (map f it) = foldM (fun (d : δ) (b : β) => g d (f b)) init it
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 β} :
fold g init (filterMapM f it) = foldM (fun (d : δ) (b : β) => do let __discrf b match __discr with | some c => pure (g d c) | x => pure d) init it
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 β} :
fold g init (mapM f it) = foldM (fun (d : δ) (b : β) => do let cf b pure (g d c)) init it
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 β} :
fold g init (filterMap f it) = fold (fun (d : δ) (b : β) => match f b with | some c => g d c | x => d) init it
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 β} :
fold g init (map f it) = fold (fun (d : δ) (b : β) => g d (f b)) init it
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)} :
anyM p (filterMapM f it) = anyM (fun (x : β) => do let __do_liftf x match __do_lift with | some fx => p fx | none => pure { down := false }) (mapM pure it)
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)} :
anyM p (mapM f it) = anyM (fun (x : β) => do let __do_liftf x p __do_lift) (mapM pure it)
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)} :
anyM p (filterM f it) = anyM (fun (x : β) => do let __do_liftf x if __do_lift.down = true then p x else pure { down := false }) (mapM pure it)
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)} :
anyM p (filterMap f it) = anyM (fun (x : β) => match f x with | some fx => p fx | none => pure { down := false }) it
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)} :
anyM p (map f it) = anyM (fun (x : β) => p (f x)) it
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)} :
anyM p (filter f it) = anyM (fun (x : β) => if f x = true then p x else pure { down := false }) it
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} :
any p (filterMapM f it) = anyM (fun (x : β) => do let __do_liftf x match __do_lift with | some fx => pure { down := p fx } | none => pure { down := false }) (mapM pure it)
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} :
any p (mapM f it) = anyM (fun (x : β) => (fun (x : β') => { down := p x }) <$> f x) (mapM pure it)
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} :
any p (filterM f it) = anyM (fun (x : β) => do let __do_liftf x if __do_lift.down = true then pure { down := p x } else pure { down := false }) (mapM pure it)
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} :
any p (filterMap f it) = any (fun (x : β) => match f x with | some fx => p fx | none => false) it
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} :
any p (map f it) = any (fun (x : β) => p (f x)) it
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)} :
allM p (filterMapM f it) = allM (fun (x : β) => do let __do_liftf x match __do_lift with | some fx => p fx | none => pure { down := true }) (mapM pure it)
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)} :
allM p (mapM f it) = allM (fun (x : β) => do let __do_liftf x p __do_lift) (mapM pure it)
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)} :
allM p (filterM f it) = allM (fun (x : β) => do let __do_liftf x if __do_lift.down = true then p x else pure { down := true }) (mapM pure it)
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)} :
allM p (filterMap f it) = allM (fun (x : β) => match f x with | some fx => p fx | none => pure { down := true }) it
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)} :
allM p (map f it) = allM (fun (x : β) => p (f x)) it
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)} :
allM p (filter f it) = allM (fun (x : β) => if f x = true then p x else pure { down := true }) it
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} :
all p (filterMapM f it) = allM (fun (x : β) => do let __do_liftf x match __do_lift with | some fx => pure { down := p fx } | none => pure { down := true }) (mapM pure it)
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} :
all p (mapM f it) = allM (fun (x : β) => (fun (x : β') => { down := p x }) <$> f x) (mapM pure it)
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} :
all p (filterM f it) = allM (fun (x : β) => do let __do_liftf x if __do_lift.down = true then pure { down := p x } else pure { down := true }) (mapM pure it)
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} :
all p (filterMap f it) = all (fun (x : β) => match f x with | some fx => p fx | none => true) it
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} :
all p (map f it) = all (fun (x : β) => p (f x)) it