Documentation

PolyFun.PFunctor.Free.Displayed.Cursor

Restricting displayed data along free-program cursors #

A displayed algebra can be restricted to a cursor residual when each node value exposes the displayed value at a selected child. This capability is explicit: an arbitrary Displayed.Algebra need not permit such a projection.

The generic restriction algorithm follows Cursor.Spine once. Node decorations and dependent over-decorations supply their canonical child projections as thin specializations.

structure PFunctor.FreeM.Displayed.Algebra.ChildProjection {P : PFunctor.{uA, uB}} {α : Type v} (D : Algebra P α) :
Type (max (max uA uB) w)

Capability for selecting one recursive child from a displayed node value.

  • project (a : P.A) (children : P.B a → Sort w) : D.node a children → (b : P.B a) → children b

    Project the displayed value stored at child b.

Instances For
    structure PFunctor.FreeM.Displayed.Over.Algebra.ChildProjection {P : PFunctor.{uA, uB}} {α : Type v} {D : Displayed.Algebra P α} (base : D.ChildProjection) (R : Algebra D) :
    Type (max (max (max uA uB) w) w₂)

    Dependent child projection for a displayed-over algebra.

    • project (a : P.A) (children : P.B a → Sort w) (overChildren : (b : P.B a) → children b → Sort w₂) (d : D.node a children) : R.node a children overChildren d → (b : P.B a) → overChildren b (base.project a children d b)

      Project the over-value lying above the selected base child.

    Instances For
      def PFunctor.FreeM.Displayed.restrictSpine {P : PFunctor.{uA, uB}} {α : Type v} {D : Algebra P α} (projection : D.ChildProjection) {program residual : P.FreeM α} :
      Cursor.Spine program residual → Displayed D program → Displayed D residual

      Restrict displayed data along an indexed cursor spine.

      Equations
      Instances For
        @[simp]
        theorem PFunctor.FreeM.Displayed.restrictSpine_root {P : PFunctor.{uA, uB}} {α : Type v} {D : Algebra P α} (projection : D.ChildProjection) (program : P.FreeM α) (d : Displayed D program) :
        restrictSpine projection (Cursor.Spine.root program) d = d
        @[simp]
        theorem PFunctor.FreeM.Displayed.restrictSpine_down {P : PFunctor.{uA, uB}} {α : Type v} {D : Algebra P α} (projection : D.ChildProjection) {a : P.A} {next : P.B a → P.FreeM α} {residual : P.FreeM α} (answer : P.B a) (tail : Cursor.Spine (next answer) residual) (d : Displayed D (liftBind a next)) :
        restrictSpine projection (Cursor.Spine.down answer tail) d = restrictSpine projection tail (projection.project a (fun (b : P.B a) => Displayed D (next b)) d answer)
        theorem PFunctor.FreeM.Displayed.restrictSpine_comp {P : PFunctor.{uA, uB}} {α : Type v} {D : Algebra P α} (projection : D.ChildProjection) {program middle residual : P.FreeM α} (first : Cursor.Spine program middle) (second : Cursor.Spine middle residual) (d : Displayed D program) :
        restrictSpine projection (first.comp second) d = restrictSpine projection second (restrictSpine projection first d)
        def PFunctor.FreeM.Displayed.restrict {P : PFunctor.{uA, uB}} {α : Type v} {D : Algebra P α} (projection : D.ChildProjection) {program : P.FreeM α} (cursor : program.Cursor) (d : Displayed D program) :

        Restrict displayed data to the residual selected by a cursor.

        Equations
        Instances For
          @[simp]
          theorem PFunctor.FreeM.Displayed.restrict_root {P : PFunctor.{uA, uB}} {α : Type v} {D : Algebra P α} (projection : D.ChildProjection) (program : P.FreeM α) (d : Displayed D program) :
          restrict projection (Cursor.root program) d = d
          @[simp]
          theorem PFunctor.FreeM.Displayed.restrict_down {P : PFunctor.{uA, uB}} {α : Type v} {D : Algebra P α} (projection : D.ChildProjection) {a : P.A} {next : P.B a → P.FreeM α} (answer : P.B a) (tail : (next answer).Cursor) (d : Displayed D (liftBind a next)) :
          restrict projection (Cursor.down answer tail) d = restrict projection tail (projection.project a (fun (b : P.B a) => Displayed D (next b)) d answer)
          theorem PFunctor.FreeM.Displayed.restrict_comp {P : PFunctor.{uA, uB}} {α : Type v} {D : Algebra P α} (projection : D.ChildProjection) {program : P.FreeM α} (first : program.Cursor) (second : first.residual.Cursor) (d : Displayed D program) :
          restrict projection (first.comp second) d = restrict projection second (restrict projection first d)
          def PFunctor.FreeM.Displayed.Over.restrictSpine {P : PFunctor.{uA, uB}} {α : Type v} {D : Displayed.Algebra P α} {R : Algebra D} (base : D.ChildProjection) (projection : Algebra.ChildProjection base R) {program residual : P.FreeM α} (spine : Cursor.Spine program residual) (d : Displayed D program) :
          Over R program d → Over R residual (Displayed.restrictSpine base spine d)

          Restrict displayed-over data along an indexed cursor spine.

          Equations
          Instances For
            @[simp]
            theorem PFunctor.FreeM.Displayed.Over.restrictSpine_root {P : PFunctor.{uA, uB}} {α : Type v} {D : Displayed.Algebra P α} {R : Algebra D} (base : D.ChildProjection) (projection : Algebra.ChildProjection base R) (program : P.FreeM α) (d : Displayed D program) (r : Over R program d) :
            restrictSpine base projection (Cursor.Spine.root program) d r = r
            @[simp]
            theorem PFunctor.FreeM.Displayed.Over.restrictSpine_down {P : PFunctor.{uA, uB}} {α : Type v} {D : Displayed.Algebra P α} {R : Algebra D} (base : D.ChildProjection) (projection : Algebra.ChildProjection base R) {a : P.A} {next : P.B a → P.FreeM α} {residual : P.FreeM α} (answer : P.B a) (tail : Cursor.Spine (next answer) residual) (d : Displayed D (liftBind a next)) (r : Over R (liftBind a next) d) :
            restrictSpine base projection (Cursor.Spine.down answer tail) d r = restrictSpine base projection tail (base.project a (fun (b : P.B a) => Displayed D (next b)) d answer) (projection.project a (fun (b : P.B a) => Displayed D (next b)) (fun (b : P.B a) (d : Displayed D (next b)) => Over R (next b) d) d r answer)
            theorem PFunctor.FreeM.Displayed.Over.restrictSpine_comp {P : PFunctor.{uA, uB}} {α : Type v} {D : Displayed.Algebra P α} {R : Algebra D} (base : D.ChildProjection) (projection : Algebra.ChildProjection base R) {program middle residual : P.FreeM α} (first : Cursor.Spine program middle) (second : Cursor.Spine middle residual) (d : Displayed D program) (r : Over R program d) :
            restrictSpine base projection (first.comp second) d r ≍ restrictSpine base projection second (Displayed.restrictSpine base first d) (restrictSpine base projection first d r)
            def PFunctor.FreeM.Displayed.Over.restrict {P : PFunctor.{uA, uB}} {α : Type v} {D : Displayed.Algebra P α} {R : Algebra D} (base : D.ChildProjection) (projection : Algebra.ChildProjection base R) {program : P.FreeM α} (cursor : program.Cursor) (d : Displayed D program) (r : Over R program d) :
            Over R cursor.residual (Displayed.restrict base cursor d)

            Restrict displayed-over data to the residual selected by a cursor.

            Equations
            Instances For
              @[simp]
              theorem PFunctor.FreeM.Displayed.Over.restrict_root {P : PFunctor.{uA, uB}} {α : Type v} {D : Displayed.Algebra P α} {R : Algebra D} (base : D.ChildProjection) (projection : Algebra.ChildProjection base R) (program : P.FreeM α) (d : Displayed D program) (r : Over R program d) :
              restrict base projection (Cursor.root program) d r = r
              @[simp]
              theorem PFunctor.FreeM.Displayed.Over.restrict_down {P : PFunctor.{uA, uB}} {α : Type v} {D : Displayed.Algebra P α} {R : Algebra D} (base : D.ChildProjection) (projection : Algebra.ChildProjection base R) {a : P.A} {next : P.B a → P.FreeM α} (answer : P.B a) (tail : (next answer).Cursor) (d : Displayed D (liftBind a next)) (r : Over R (liftBind a next) d) :
              restrict base projection (Cursor.down answer tail) d r = restrict base projection tail (base.project a (fun (b : P.B a) => Displayed D (next b)) d answer) (projection.project a (fun (b : P.B a) => Displayed D (next b)) (fun (b : P.B a) (d : Displayed D (next b)) => Over R (next b) d) d r answer)
              theorem PFunctor.FreeM.Displayed.Over.restrict_comp {P : PFunctor.{uA, uB}} {α : Type v} {D : Displayed.Algebra P α} {R : Algebra D} (base : D.ChildProjection) (projection : Algebra.ChildProjection base R) {program : P.FreeM α} (first : program.Cursor) (second : first.residual.Cursor) (d : Displayed D program) (r : Over R program d) :
              restrict base projection (first.comp second) d r ≍ restrict base projection second (Displayed.restrict base first d) (restrict base projection first d r)

              Node decorations expose the decoration stored at every child.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                def PFunctor.FreeM.Displayed.Decoration.restrict {P : PFunctor.{uA, uB}} {α : Type v} {Γ : P.A → Type w₂} {program : P.FreeM α} (cursor : program.Cursor) (d : Decoration Γ program) :

                Restrict a node decoration to a cursor residual.

                Equations
                Instances For
                  @[simp]
                  theorem PFunctor.FreeM.Displayed.Decoration.restrict_root {P : PFunctor.{uA, uB}} {α : Type v} {Γ : P.A → Type w₂} (program : P.FreeM α) (d : Decoration Γ program) :
                  restrict (Cursor.root program) d = d
                  @[simp]
                  theorem PFunctor.FreeM.Displayed.Decoration.restrict_down {P : PFunctor.{uA, uB}} {α : Type v} {Γ : P.A → Type w₂} {a : P.A} {next : P.B a → P.FreeM α} (answer : P.B a) (tail : (next answer).Cursor) (d : Decoration Γ (liftBind a next)) :
                  restrict (Cursor.down answer tail) d = restrict tail (d.2 answer)
                  theorem PFunctor.FreeM.Displayed.Decoration.restrict_comp {P : PFunctor.{uA, uB}} {α : Type v} {Γ : P.A → Type w₂} {program : P.FreeM α} (first : program.Cursor) (second : first.residual.Cursor) (d : Decoration Γ program) :
                  restrict (first.comp second) d = restrict second (restrict first d)
                  theorem PFunctor.FreeM.Displayed.Decoration.restrict_map {P : PFunctor.{uA, uB}} {α : Type v} {Γ : P.A → Type w₂} {Δ : P.A → Type w₃} (f : (a : P.A) → Γ a → Δ a) {program : P.FreeM α} (cursor : program.Cursor) (d : Decoration Γ program) :
                  restrict cursor (map f program d) = map f cursor.residual (restrict cursor d)

                  Dependent node decorations expose the over-decoration at every child.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    def PFunctor.FreeM.Displayed.Decoration.Over.restrict {P : PFunctor.{uA, uB}} {α : Type v} {Γ : P.A → Type w₂} {A : (a : P.A) → Γ a → Type w₃} {program : P.FreeM α} (cursor : program.Cursor) (d : Decoration Γ program) (r : Over Γ A program d) :
                    Over Γ A cursor.residual (Decoration.restrict cursor d)

                    Restrict a dependent decoration to a cursor residual.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      @[simp]
                      theorem PFunctor.FreeM.Displayed.Decoration.Over.restrict_root {P : PFunctor.{uA, uB}} {α : Type v} {Γ : P.A → Type w₂} {A : (a : P.A) → Γ a → Type w₃} (program : P.FreeM α) (d : Decoration Γ program) (r : Over Γ A program d) :
                      restrict (Cursor.root program) d r = r
                      @[simp]
                      theorem PFunctor.FreeM.Displayed.Decoration.Over.restrict_down {P : PFunctor.{uA, uB}} {α : Type v} {Γ : P.A → Type w₂} {A : (a : P.A) → Γ a → Type w₃} {a : P.A} {next : P.B a → P.FreeM α} (answer : P.B a) (tail : (next answer).Cursor) (d : Decoration Γ (liftBind a next)) (r : Over Γ A (liftBind a next) d) :
                      restrict (Cursor.down answer tail) d r = restrict tail (d.2 answer) (r.2 answer)
                      theorem PFunctor.FreeM.Displayed.Decoration.Over.restrict_comp {P : PFunctor.{uA, uB}} {α : Type v} {Γ : P.A → Type w₂} {A : (a : P.A) → Γ a → Type w₃} {program : P.FreeM α} (first : program.Cursor) (second : first.residual.Cursor) (d : Decoration Γ program) (r : Over Γ A program d) :
                      restrict (first.comp second) d r ≍ restrict second (Decoration.restrict first d) (restrict first d r)
                      theorem PFunctor.FreeM.Displayed.Decoration.Over.restrict_map {P : PFunctor.{uA, uB}} {α : Type v} {Γ : P.A → Type w₂} {A : (a : P.A) → Γ a → Type w₃} {B : (a : P.A) → Γ a → Type w₄} (f : (a : P.A) → (γ : Γ a) → A a γ → B a γ) {program : P.FreeM α} (cursor : program.Cursor) (d : Decoration Γ program) (r : Over Γ A program d) :
                      restrict cursor d (map f program d r) = map f cursor.residual (Decoration.restrict cursor d) (restrict cursor d r)
                      theorem PFunctor.FreeM.Displayed.Decoration.Over.restrict_mapBase {P : PFunctor.{uA, uB}} {α : Type v} {Γ : P.A → Type w₂} {A : (a : P.A) → Γ a → Type w₃} {Δ : P.A → Type w₄} {B : (a : P.A) → Δ a → Type w₅} (f : (a : P.A) → Γ a → Δ a) (g : (a : P.A) → (γ : Γ a) → A a γ → B a (f a γ)) {program : P.FreeM α} (cursor : program.Cursor) (d : Decoration Γ program) (r : Over Γ A program d) :
                      restrict cursor (Decoration.map f program d) (mapBase f g program d r) ≍ mapBase f g cursor.residual (Decoration.restrict cursor d) (restrict cursor d r)
                      theorem PFunctor.FreeM.Displayed.Decoration.restrict_ofOver {P : PFunctor.{uA, uB}} {α : Type v} {Γ : P.A → Type w₂} {A : (a : P.A) → Γ a → Type w₃} {program : P.FreeM α} (cursor : program.Cursor) (d : Decoration Γ program) (r : Over Γ A program d) :
                      restrict cursor (ofOver program d r) = ofOver cursor.residual (restrict cursor d) (Over.restrict cursor d r)
                      theorem PFunctor.FreeM.Displayed.Decoration.toOver_restrict {P : PFunctor.{uA, uB}} {α : Type v} {Γ : P.A → Type w₂} {A : (a : P.A) → Γ a → Type w₃} {program : P.FreeM α} (cursor : program.Cursor) (d : Decoration (Context.extend Γ A) program) :
                      toOver cursor.residual (restrict cursor d) = ⟨restrict cursor (toOver program d).fst, Over.restrict cursor (toOver program d).fst (toOver program d).snd⟩