Documentation

PolyFun.PFunctor.Dynamical.Responder.Presentation

Witness-preserving responder presentations #

A PresentationHom preserves the totalized one-step semantics of a responder together with its dependent witness. This module owns the generic identity, composition, terminal-semantics, and displayed-reindexing principles; lens-specific specializations live in Responder.Lens.

The terminology is structural. A Display.Coalgebra (Display.responder S) R.out I supplies, for every responder state and current witness in I, the displayed response and next-state witness required by S. toDisplayedBehavior coinduces that local data into an inhabitant of Display.M (Display.responder S) (R.behavior state), and a PresentationHom maps between two such state-and-witness presentations while commuting with their complete one-step data.

Neither S nor I is restricted to propositions. Applications may interpret them as preconditions, postconditions, and invariants, in which case these objects can witness a verification result. They may instead carry traces, resources, logical relations, or other Type-valued annotations. The public names therefore say displayed or witness-preserving, not verified.

def PFunctor.Responder.displayedTotalStep {RPoly : PFunctor.{uA₃, uB}} (S : RPoly.Display) {State : Type uC₂} (R : Responder State RPoly) (I : State → Type uD₂) (displayedR : S.responder.Coalgebra (DynSystem.out R) I) :
(state : State) × I state → ↑(IPFunctor.sigmaPFunctor S.responder.mStep) ((state : State) × I state)

One witness-preserving responder step on the total state-and-witness presentation. The result packages the ordinary behavior, current displayed postcondition data, next responder state, and preserved next-state witness.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    theorem PFunctor.Responder.displayedTotalStepObj_ext {RPoly : PFunctor.{uA₃, uB}} (S : RPoly.Display) {α : Type uC₄} (left right : ↑(IPFunctor.sigmaPFunctor S.responder.mStep) α) (hBehavior : left.fst.fst = right.fst.fst) (hPostcondition : left.fst.snd ≍ right.fst.snd) (hContinuation : left.snd ≍ right.snd) :
    left = right

    Extensionality for a totalized displayed responder step. Separating the ordinary behavior, displayed postcondition, and continuation components keeps dependent Sigma/HEq plumbing out of presentation and coherence proofs.

    theorem PFunctor.Responder.toM_toDisplayedBehavior_eq_corec {RPoly : PFunctor.{uA₃, uB}} (S : RPoly.Display) {State : Type uC₂} (R : Responder State RPoly) (I : State → Type uD₂) (displayedR : S.responder.Coalgebra (DynSystem.out R) I) (state : State) (witness : I state) :
    (toDisplayedBehavior S R I displayedR state witness).toM = M.corec (displayedTotalStep S R I displayedR) ⟨state, witness⟩

    Sigma-erasing a displayed behavior is the ordinary behavior of its total state-and-witness presentation.

    structure PFunctor.Responder.PresentationHom {RPoly : PFunctor.{uA₃, uB}} (S : RPoly.Display) {SourceState : Type uC₁} (source : Responder SourceState RPoly) (SourceWitness : SourceState → Type uD₁) (displayedSource : S.responder.Coalgebra (DynSystem.out source) SourceWitness) {TargetState : Type uC₂} (target : Responder TargetState RPoly) (TargetWitness : TargetState → Type uD₂) (displayedTarget : S.responder.Coalgebra (DynSystem.out target) TargetWitness) :
    Type (max (max (max uC₁ uC₂) uD₁) uD₂)

    A homomorphism between witness-preserving responder presentations. The state and witness maps remain split so the latter visibly respects its dependent state index; an arbitrary homomorphism of total sigma coalgebras would erase that useful presentation structure. The sole law says that mapping a source state and witness commutes with the complete totalized witness-preserving step. Because answers, postconditions, next states, and next witnesses are packaged together, the law requires neither HEq nor exposed casts.

    Instances For
      def PFunctor.Responder.PresentationHom.totalMap {RPoly : PFunctor.{uA₃, uB}} {S : RPoly.Display} {SourceState : Type uC₁} {source : Responder SourceState RPoly} {SourceWitness : SourceState → Type uD₁} {displayedSource : S.responder.Coalgebra (DynSystem.out source) SourceWitness} {TargetState : Type uC₂} {target : Responder TargetState RPoly} {TargetWitness : TargetState → Type uD₂} {displayedTarget : S.responder.Coalgebra (DynSystem.out target) TargetWitness} (f : PresentationHom S source SourceWitness displayedSource target TargetWitness displayedTarget) :
      (state : SourceState) × SourceWitness state → (state : TargetState) × TargetWitness state

      The induced map on total state-and-witness sigma types.

      Equations
      Instances For
        def PFunctor.Responder.PresentationHom.transportToWitness {State₁ : Type uC₁} {Witness₁ : State₁ → Type uD₁} {State₂ : Type uC₂} {Witness₂ : State₂ → Type uD₂} {toState₁ toState₂ : State₁ → State₂} (h : toState₁ = toState₂) :
        ((state : State₁) → Witness₁ state → Witness₂ (toState₁ state)) → (state : State₁) → Witness₁ state → Witness₂ (toState₂ state)

        Transport a dependent witness map along equality of its state map.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          theorem PFunctor.Responder.PresentationHom.ext {RPoly : PFunctor.{uA₃, uB}} {S : RPoly.Display} {SourceState : Type uC₁} {source : Responder SourceState RPoly} {SourceWitness : SourceState → Type uD₁} {displayedSource : S.responder.Coalgebra (DynSystem.out source) SourceWitness} {TargetState : Type uC₂} {target : Responder TargetState RPoly} {TargetWitness : TargetState → Type uD₂} {displayedTarget : S.responder.Coalgebra (DynSystem.out target) TargetWitness} (f g : PresentationHom S source SourceWitness displayedSource target TargetWitness displayedTarget) (hState : f.toState = g.toState) (hWitness : transportToWitness hState f.toWitness = g.toWitness) :
          f = g

          Presentation homomorphisms are determined by their state and dependent witness maps; preservation proofs are propositionally irrelevant.

          def PFunctor.Responder.PresentationHom.id {RPoly : PFunctor.{uA₃, uB}} {S : RPoly.Display} {SourceState : Type uC₁} {source : Responder SourceState RPoly} {SourceWitness : SourceState → Type uD₁} {displayedSource : S.responder.Coalgebra (DynSystem.out source) SourceWitness} :
          PresentationHom S source SourceWitness displayedSource source SourceWitness displayedSource

          Identity homomorphism of a displayed responder presentation.

          Equations
          Instances For
            def PFunctor.Responder.PresentationHom.comp {RPoly : PFunctor.{uA₃, uB}} {S : RPoly.Display} {SourceState : Type uC₁} {source : Responder SourceState RPoly} {SourceWitness : SourceState → Type uD₁} {displayedSource : S.responder.Coalgebra (DynSystem.out source) SourceWitness} {MiddleState : Type uC₂} {middle : Responder MiddleState RPoly} {MiddleWitness : MiddleState → Type uD₂} {displayedMiddle : S.responder.Coalgebra (DynSystem.out middle) MiddleWitness} {FinalState : Type uC₄} {final : Responder FinalState RPoly} {FinalWitness : FinalState → Type uD₄} {displayedFinal : S.responder.Coalgebra (DynSystem.out final) FinalWitness} (second : PresentationHom S middle MiddleWitness displayedMiddle final FinalWitness displayedFinal) (first : PresentationHom S source SourceWitness displayedSource middle MiddleWitness displayedMiddle) :
            PresentationHom S source SourceWitness displayedSource final FinalWitness displayedFinal

            Composition of displayed presentation homomorphisms.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              @[simp]
              theorem PFunctor.Responder.PresentationHom.id_toState {RPoly : PFunctor.{uA₃, uB}} {S : RPoly.Display} {SourceState : Type uC₁} {source : Responder SourceState RPoly} {SourceWitness : SourceState → Type uD₁} {displayedSource : S.responder.Coalgebra (DynSystem.out source) SourceWitness} (state : SourceState) :
              id.toState state = state
              @[simp]
              theorem PFunctor.Responder.PresentationHom.id_toWitness {RPoly : PFunctor.{uA₃, uB}} {S : RPoly.Display} {SourceState : Type uC₁} {source : Responder SourceState RPoly} {SourceWitness : SourceState → Type uD₁} {displayedSource : S.responder.Coalgebra (DynSystem.out source) SourceWitness} (state : SourceState) (witness : SourceWitness state) :
              id.toWitness state witness = witness
              @[simp]
              theorem PFunctor.Responder.PresentationHom.comp_toState {RPoly : PFunctor.{uA₃, uB}} {S : RPoly.Display} {SourceState : Type uC₁} {source : Responder SourceState RPoly} {SourceWitness : SourceState → Type uD₁} {displayedSource : S.responder.Coalgebra (DynSystem.out source) SourceWitness} {MiddleState : Type uC₂} {middle : Responder MiddleState RPoly} {MiddleWitness : MiddleState → Type uD₂} {displayedMiddle : S.responder.Coalgebra (DynSystem.out middle) MiddleWitness} {FinalState : Type uC₄} {final : Responder FinalState RPoly} {FinalWitness : FinalState → Type uD₄} {displayedFinal : S.responder.Coalgebra (DynSystem.out final) FinalWitness} (second : PresentationHom S middle MiddleWitness displayedMiddle final FinalWitness displayedFinal) (first : PresentationHom S source SourceWitness displayedSource middle MiddleWitness displayedMiddle) (state : SourceState) :
              (second.comp first).toState state = second.toState (first.toState state)
              @[simp]
              theorem PFunctor.Responder.PresentationHom.comp_toWitness {RPoly : PFunctor.{uA₃, uB}} {S : RPoly.Display} {SourceState : Type uC₁} {source : Responder SourceState RPoly} {SourceWitness : SourceState → Type uD₁} {displayedSource : S.responder.Coalgebra (DynSystem.out source) SourceWitness} {MiddleState : Type uC₂} {middle : Responder MiddleState RPoly} {MiddleWitness : MiddleState → Type uD₂} {displayedMiddle : S.responder.Coalgebra (DynSystem.out middle) MiddleWitness} {FinalState : Type uC₄} {final : Responder FinalState RPoly} {FinalWitness : FinalState → Type uD₄} {displayedFinal : S.responder.Coalgebra (DynSystem.out final) FinalWitness} (second : PresentationHom S middle MiddleWitness displayedMiddle final FinalWitness displayedFinal) (first : PresentationHom S source SourceWitness displayedSource middle MiddleWitness displayedMiddle) (state : SourceState) (witness : SourceWitness state) :
              (second.comp first).toWitness state witness = second.toWitness (first.toState state) (first.toWitness state witness)
              @[simp]
              theorem PFunctor.Responder.PresentationHom.id_comp {RPoly : PFunctor.{uA₃, uB}} {S : RPoly.Display} {SourceState : Type uC₁} {source : Responder SourceState RPoly} {SourceWitness : SourceState → Type uD₁} {displayedSource : S.responder.Coalgebra (DynSystem.out source) SourceWitness} {TargetState : Type uC₂} {target : Responder TargetState RPoly} {TargetWitness : TargetState → Type uD₂} {displayedTarget : S.responder.Coalgebra (DynSystem.out target) TargetWitness} (f : PresentationHom S source SourceWitness displayedSource target TargetWitness displayedTarget) :
              id.comp f = f
              @[simp]
              theorem PFunctor.Responder.PresentationHom.comp_id {RPoly : PFunctor.{uA₃, uB}} {S : RPoly.Display} {SourceState : Type uC₁} {source : Responder SourceState RPoly} {SourceWitness : SourceState → Type uD₁} {displayedSource : S.responder.Coalgebra (DynSystem.out source) SourceWitness} {TargetState : Type uC₂} {target : Responder TargetState RPoly} {TargetWitness : TargetState → Type uD₂} {displayedTarget : S.responder.Coalgebra (DynSystem.out target) TargetWitness} (f : PresentationHom S source SourceWitness displayedSource target TargetWitness displayedTarget) :
              f.comp id = f
              theorem PFunctor.Responder.PresentationHom.comp_assoc {RPoly : PFunctor.{uA₃, uB}} {S : RPoly.Display} {SourceState : Type uC₁} {source : Responder SourceState RPoly} {SourceWitness : SourceState → Type uD₁} {displayedSource : S.responder.Coalgebra (DynSystem.out source) SourceWitness} {MiddleState : Type uC₂} {middle : Responder MiddleState RPoly} {MiddleWitness : MiddleState → Type uD₂} {displayedMiddle : S.responder.Coalgebra (DynSystem.out middle) MiddleWitness} {NextState : Type uC₄} {next : Responder NextState RPoly} {NextWitness : NextState → Type uD₄} {displayedNext : S.responder.Coalgebra (DynSystem.out next) NextWitness} {FinalState : Type uC₅} {final : Responder FinalState RPoly} {FinalWitness : FinalState → Type uD₅} {displayedFinal : S.responder.Coalgebra (DynSystem.out final) FinalWitness} (third : PresentationHom S next NextWitness displayedNext final FinalWitness displayedFinal) (second : PresentationHom S middle MiddleWitness displayedMiddle next NextWitness displayedNext) (first : PresentationHom S source SourceWitness displayedSource middle MiddleWitness displayedMiddle) :
              (third.comp second).comp first = third.comp (second.comp first)
              def PFunctor.Responder.PresentationHom.toTerminal {P : PFunctor.{uA₁, uB}} (S : P.Display) {State : Type uC₂} (R : Responder State P) (I : State → Type uD₂) (displayedR : S.responder.Coalgebra (DynSystem.out R) I) :

              Map any displayed responder presentation to its terminal state-free semantics. This is the reusable boundary between state-presented and state-free displayed behavior.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                theorem PFunctor.Responder.PresentationHom.behavior_eq {RPoly : PFunctor.{uA₃, uB}} {S : RPoly.Display} {SourceState : Type uC₁} {source : Responder SourceState RPoly} {SourceWitness : SourceState → Type uD₁} {displayedSource : S.responder.Coalgebra (DynSystem.out source) SourceWitness} {TargetState : Type uC₂} {target : Responder TargetState RPoly} {TargetWitness : TargetState → Type uD₂} {displayedTarget : S.responder.Coalgebra (DynSystem.out target) TargetWitness} (f : PresentationHom S source SourceWitness displayedSource target TargetWitness displayedTarget) (state : SourceState) (witness : SourceWitness state) :
                DynSystem.behavior target (f.toState state) = DynSystem.behavior source state

                The base behavior equality carried by a displayed presentation homomorphism.

                theorem PFunctor.Responder.PresentationHom.toDisplayedBehavior_naturality {RPoly : PFunctor.{uA₃, uB}} {S : RPoly.Display} {SourceState : Type uC₁} {source : Responder SourceState RPoly} {SourceWitness : SourceState → Type uD₁} {displayedSource : S.responder.Coalgebra (DynSystem.out source) SourceWitness} {TargetState : Type uC₂} {target : Responder TargetState RPoly} {TargetWitness : TargetState → Type uD₂} {displayedTarget : S.responder.Coalgebra (DynSystem.out target) TargetWitness} (f : PresentationHom S source SourceWitness displayedSource target TargetWitness displayedTarget) (state : SourceState) (witness : SourceWitness state) :
                Display.M.transport ⋯ (toDisplayedBehavior S target TargetWitness displayedTarget (f.toState state) (f.toWitness state witness)) = toDisplayedBehavior S source SourceWitness displayedSource state witness

                Displayed terminal semantics is natural under a displayed presentation homomorphism.

                def PFunctor.Responder.reindexPresentationHom {P : PFunctor.{uA₁, uB}} {Q : PFunctor.{uA₂, uB'}} {S : P.Display} {T : Q.Display} (f : Handler Q.FreeM P) (df : S.Handler T f) {State : Type uC₃} (R : Responder State Q) (I : State → Type uD₃) (displayedR : T.responder.Coalgebra (DynSystem.out R) I) :

                Presenting a reindexed displayed responder through terminal state-free semantics is a displayed presentation homomorphism.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  theorem PFunctor.Responder.reindexDisplayedBehavior_toDisplayedBehavior {P : PFunctor.{uA₁, uB}} {Q : PFunctor.{uA₂, uB'}} {S : P.Display} {T : Q.Display} (f : Handler Q.FreeM P) (df : S.Handler T f) {State : Type uC₃} (R : Responder State Q) (I : State → Type uD₃) (displayedR : T.responder.Coalgebra (DynSystem.out R) I) (state : State) (witness : I state) :
                  Display.M.transport ⋯ (reindexDisplayedBehavior S T f df (DynSystem.behavior R state) (toDisplayedBehavior T R I displayedR state witness)) = toDisplayedBehavior S (reindex f R) I (reindexCoalgebra S T f df R displayedR) state witness

                  State-free displayed reindexing agrees with reindexing the presenting displayed responder, after the ordinary presentation equality.