Documentation

Cslib.Foundations.Data.PFunctor.Free.W

Polynomial free monads with an empty result type #

When α is empty, a tree in P.FreeM α has only operation nodes. The equivalence PFunctor.FreeM.equivWOfIsEmpty identifies these trees with the W-type P.W.

def PFunctor.FreeM.toWOfIsEmpty {P : PFunctor.{uA, uB}} {α : Type u} [IsEmpty α] :
P.FreeM α → P.W

Regard a free polynomial tree with no return values as a W-type.

Equations
Instances For
    def PFunctor.W.toFreeM {P : PFunctor.{uA, uB}} {α : Type u} :
    P.W → P.FreeM α

    Regard a W-type as a free polynomial tree with no return nodes.

    Equations
    Instances For
      @[simp]
      theorem PFunctor.FreeM.toWOfIsEmpty_lift_bind {P : PFunctor.{uA, uB}} {α : Type u} [IsEmpty α] (a : P.A) (cont : P.B a → P.FreeM α) :
      ((lift a).bind cont).toWOfIsEmpty = W.mk (Obj.mk a fun (b : P.B a) => (cont b).toWOfIsEmpty)
      @[simp]
      theorem PFunctor.FreeM.toWOfIsEmpty_lift_bind' {P : PFunctor.{uA, uB}} {α : Type uB} [IsEmpty α] (a : P.A) (cont : P.B a → P.FreeM α) :
      (lift a >>= cont).toWOfIsEmpty = W.mk (Obj.mk a fun (b : P.B a) => (cont b).toWOfIsEmpty)
      @[simp]
      theorem PFunctor.W.toFreeM_mk {P : PFunctor.{uA, uB}} {α : Type u} (a : P.A) (cont : P.B a → P.W) :
      (mk (Obj.mk a cont)).toFreeM = (FreeM.lift a).bind fun (b : P.B a) => (cont b).toFreeM

      With an empty result type, the free polynomial monad is equivalent to its W-type.

      Equations
      Instances For