A Monadic version of Mathlib's List.insertionSort #
This can be instantiated with Id to recover the original, or with TimeM or FreeM for
algorithmic analysis.
A monadic version of List.orderedInsert.
Equations
Instances For
@[simp]
theorem List.orderedInsertM_pure {α : Type} {m : Type → Type u_1} [Monad m] [LawfulMonad m] (r : α → α → Bool) (a : α) (xs : List α) :
orderedInsertM (fun (x y : α) => pure (r x y)) a xs = pure (orderedInsert (fun (x1 x2 : α) => r x1 x2 = true) a xs)
@[simp]
A monadic version of List.insertionSort.
Equations
- List.insertionSortM r [] = pure []
- List.insertionSortM r (b :: l) = do let __do_lift ← List.insertionSortM r l List.orderedInsertM r b __do_lift
Instances For
@[simp]
theorem List.insertionSortM_pure {α : Type} {m : Type → Type u_1} [Monad m] [LawfulMonad m] (xs : List α) (r : α → α → Bool) :
insertionSortM (fun (x y : α) => pure (r x y)) xs = pure (insertionSort (fun (x1 x2 : α) => r x1 x2 = true) xs)
@[simp]