Documentation

PolyFun.Interaction.Basic.Interaction

Generic local execution laws over interaction trees #

This file introduces the execution-side counterpart to SyntaxOver.

InteractionOver is a local operational law for agent-indexed node objects. It says how a whole profile of local objects, one for each agent, is combined at a single protocol node in order to choose the next move and continue the interaction. The node-local information seen by those objects is packaged as a realized node context.

Role-based prover/verifier runners are specializations of this notion, obtained by choosing suitable node contexts and syntax objects.

Just as SyntaxOver reindexes contravariantly along node-context morphisms, InteractionOver.comap transports a local execution law along the same kind of context change.

Naming note: InteractionOver keeps the suffix form for the same reason as ShapeOver: it is the generalized execution notion over node-local data, while Interaction names the plain specialization with trivial node data.

structure Interaction.InteractionOver {P : PFunctor.{uA, uB}} {Q : PFunctor.{uA₂, uB₂}} (l : P.Lens Q) (Agent : Type a) (Γ : P.A → Type vΓ) (syn : SyntaxOver l Agent Γ) (m : Type (max uB₂ a w) → Type (max uB₂ a w)) :
Type (max (max (max (max (a + 1) uA) (uB₂ + 1)) vΓ) (w + 1))

InteractionOver l Agent Γ syn m is a one-step operational law for a lens-executed polynomial interaction.

At each control node, every agent supplies a local syntax object. The interaction law chooses one runtime direction and passes each agent's matching continuation to the recursive runner.

  • interact {pos : P.A} {γ : Γ pos} {Cont : Agent → Q.B (l.toFunA pos) → Type w} {Result : Type (max uB₂ a w)} : ((agent : Agent) → syn.Node agent pos γ (Cont agent)) → ((d : Q.B (l.toFunA pos)) → ((agent : Agent) → Cont agent d) → m Result) → m Result

    The one-step operational law: given each agent's local node object at a control node, choose a runtime direction and pass each agent's matching continuation to the recursive runner in m.

Instances For
    def Interaction.InteractionOver.comap {P : PFunctor.{uA, uB}} {Q : PFunctor.{uA₂, uB₂}} {Agent : Type a} {Γ : P.A → Type vΓ} {l : P.Lens Q} {Δ : P.A → Type vΔ} {syn : SyntaxOver l Agent Δ} {m : Type (max uB₂ a w) → Type (max uB₂ a w)} (f : (pos : P.A) → Γ pos → Δ pos) (I : InteractionOver l Agent Δ syn m) :
    InteractionOver l Agent Γ (SyntaxOver.comap f syn) m

    Reindex a local execution law contravariantly along a node metadata map.

    If f : Γ → Δ, then an execution law for Δ-metadata can be reused on Γ-metadata by first viewing local syntax through SyntaxOver.comap f.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      @[simp]
      theorem Interaction.InteractionOver.comap_id {P : PFunctor.{uA, uB}} {Q : PFunctor.{uA₂, uB₂}} {Agent : Type a} {Γ : P.A → Type vΓ} {l : P.Lens Q} {syn : SyntaxOver l Agent Γ} {m : Type (max uB₂ a w) → Type (max uB₂ a w)} (I : InteractionOver l Agent Γ syn m) :
      comap (fun (x : P.A) (γ : Γ x) => γ) I = I
      theorem Interaction.InteractionOver.comap_comp {P : PFunctor.{uA, uB}} {Q : PFunctor.{uA₂, uB₂}} {Agent : Type a} {Γ : P.A → Type vΓ} {l : P.Lens Q} {Δ : P.A → Type vΔ} {Λ : P.A → Type vΛ} {syn : SyntaxOver l Agent Λ} {m : Type (max uB₂ a w) → Type (max uB₂ a w)} (I : InteractionOver l Agent Λ syn m) (g : (pos : P.A) → Δ pos → Λ pos) (f : (pos : P.A) → Γ pos → Δ pos) :
      comap f (comap g I) = comap (fun (pos : P.A) => g pos ∘ f pos) I
      def Interaction.InteractionOver.run {P : PFunctor.{uA, uB}} {Q : PFunctor.{uA₂, uB₂}} {α : Type t} {Agent : Type a} {Γ : P.A → Type vΓ} {l : P.Lens Q} {syn : SyntaxOver l Agent Γ} {m : Type (max uB₂ a w) → Type (max uB₂ a w)} [Monad m] {spec : P.FreeM α} (ctxs : PFunctor.FreeM.Displayed.Decoration Γ spec) {Out : Agent → PFunctor.FreeM.PathAlong l spec → Type w} {Result : PFunctor.FreeM.PathAlong l spec → Type (max a w)} (profile : (agent : Agent) → StrategyOver syn agent spec ctxs (Out agent)) (collect : (path : PFunctor.FreeM.PathAlong l spec) → ((agent : Agent) → Out agent path) → Result path) (I : InteractionOver l Agent Γ syn m) :
      m ((path : PFunctor.FreeM.PathAlong l spec) × Result path)

      Run a whole lens-executed protocol from a profile of local participant objects, producing the runtime path and an output collected from all agents at that same path.

      Equations
      Instances For
        def Interaction.InteractionOver.runTypeTree {Agent : Type u} {Γ : TypeTree.Node.Context} {syn : SyntaxOver (PFunctor.Lens.id TypeTree.basePFunctor) Agent Γ} {m : Type u → Type u} [Monad m] {spec : TypeTree} (ctxs : PFunctor.FreeM.Displayed.Decoration Γ spec) {Out : Agent → PFunctor.FreeM.Path spec → Type u} {Result : PFunctor.FreeM.Path spec → Type u} (profile : (agent : Agent) → StrategyOver syn agent spec ctxs (Out agent)) (collect : (tr : PFunctor.FreeM.Path spec) → ((agent : Agent) → Out agent tr) → Result tr) (I : InteractionOver (PFunctor.Lens.id TypeTree.basePFunctor) Agent Γ syn m) :
        m ((tr : PFunctor.FreeM.Path spec) × Result tr)

        Execute a plain TypeTree tree using an identity-lens generic local one-step law.

        The local execution structure is the generic InteractionOver; this facade only keeps the plain-tree path recursion definitionally clean for computation lemmas.

        Equations
        Instances For