theorem
Std.Iterators.IterM.step_takeWhileWithPostcondition
{α : Type u_1}
{m : Type u_1 → Type u_2}
{β : Type u_1}
[Monad m]
[Iterator α m β]
{it : IterM m β}
{P : β → PostconditionT m (ULift Bool)}
:
(takeWhileWithPostcondition P it).step = do
let __do_lift ← it.step
match __do_lift with
| ⟨IterStep.yield it' out, h⟩ => do
let __do_lift ← (P out).operation
match __do_lift with
| ⟨{ down := true }, h'⟩ => pure (PlausibleIterStep.yield (takeWhileWithPostcondition P it') out ⋯)
| ⟨{ down := false }, h'⟩ => pure (PlausibleIterStep.done ⋯)
| ⟨IterStep.skip it', h⟩ => pure (PlausibleIterStep.skip (takeWhileWithPostcondition P it') ⋯)
| ⟨IterStep.done, h⟩ => pure (PlausibleIterStep.done ⋯)
theorem
Std.Iterators.IterM.step_takeWhileM
{α : Type u_1}
{m : Type u_1 → Type u_2}
{β : Type u_1}
[Monad m]
[LawfulMonad m]
[Iterator α m β]
{it : IterM m β}
{P : β → m (ULift Bool)}
:
(takeWhileM P it).step = do
let __do_lift ← it.step
match __do_lift with
| ⟨IterStep.yield it' out, h⟩ => do
let __do_lift ← P out
match __do_lift with
| { down := true } => pure (PlausibleIterStep.yield (takeWhileM P it') out ⋯)
| { down := false } => pure (PlausibleIterStep.done ⋯)
| ⟨IterStep.skip it', h⟩ => pure (PlausibleIterStep.skip (takeWhileM P it') ⋯)
| ⟨IterStep.done, h⟩ => pure (PlausibleIterStep.done ⋯)
theorem
Std.Iterators.IterM.step_takeWhile
{α : Type u_1}
{m : Type u_1 → Type u_2}
{β : Type u_1}
[Monad m]
[LawfulMonad m]
[Iterator α m β]
{it : IterM m β}
{P : β → Bool}
:
(takeWhile P it).step = do
let __do_lift ← it.step
match __do_lift with
| ⟨IterStep.yield it' out, h⟩ =>
match P out with
| true => pure (PlausibleIterStep.yield (takeWhile P it') out ⋯)
| false => pure (PlausibleIterStep.done ⋯)
| ⟨IterStep.skip it', h⟩ => pure (PlausibleIterStep.skip (takeWhile P it') ⋯)
| ⟨IterStep.done, h⟩ => pure (PlausibleIterStep.done ⋯)