Documentation

PolyFun.Interaction.Execution.ReactiveNetwork.Transport

Relabeling typed reactive networks #

A bijection changes the presentation of component identities, transporting the dependent component interfaces, private states, packets, routing, token holder, and FIFO schedules together. It does not alter effects or introduce new scheduler choices.

def Interaction.Execution.ReactiveNetwork.reindexDestination {Node Node' result : Type} {boundary : PortBoundary} (network : Network Node boundary result) (e : Node' ≃ Node) :
Destination network → (id : Node') × (network.ports (e id)).In.Packet ⊕ boundary.Out.Packet

Transport the recipient of a dependent packet along a bijection of identities.

Equations
Instances For
    def Interaction.Execution.ReactiveNetwork.Network.reindex {Node Node' result : Type} {boundary : PortBoundary} (network : Network Node boundary result) (e : Node' ≃ Node) :
    Network Node' boundary result

    Present the same diagram on a different type of stable component identities.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      @[simp]
      theorem Interaction.Execution.ReactiveNetwork.Network.reindex_environment {Node Node' result : Type} {boundary : PortBoundary} (network : Network Node boundary result) (e : Node' ≃ Node) :
      (network.reindex e).environment = e.symm network.environment

      The global environment follows the inverse bijection of component identities.

      def Interaction.Execution.ReactiveNetwork.State.reindex {Node Node' result S : Type} {boundary : PortBoundary} {network : Network Node boundary result} (e : Node' ≃ Node) (state : State network S) :
      State (network.reindex e) S

      Relabel a complete residual configuration, retaining traffic order and consumed fuel.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        def Interaction.Execution.ReactiveNetwork.State.castNetwork {Node result S : Type} {boundary : PortBoundary} {network network' : Network Node boundary result} (h : network = network') (state : State network S) :
        State network' S

        Equality of network data transports a residual configuration without executing a step.

        Equations
        Instances For
          def Interaction.Execution.ReactiveNetwork.castHandlers {Node result S : Type} {boundary : PortBoundary} {m : Type → Type} {network network' : Network Node boundary result} (h : network = network') (impl : (id : Node) → PFunctor.Handler (StateT S m) (network.effect id)) (id : Node) :
          PFunctor.Handler (StateT S m) (network'.effect id)

          Component handlers follow equality of the network's declared effect interfaces.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            @[simp]
            theorem Interaction.Execution.ReactiveNetwork.castHandlers_rfl {Node result S : Type} {boundary : PortBoundary} {m : Type → Type} {network : Network Node boundary result} (impl : (id : Node) → PFunctor.Handler (StateT S m) (network.effect id)) :
            castHandlers ⋯ impl = impl

            Transport along reflexive network equality leaves handlers unchanged.

            @[simp]
            theorem Interaction.Execution.ReactiveNetwork.outcome_reindex {Node Node' result S : Type} {boundary : PortBoundary} {network : Network Node boundary result} (e : Node' ≃ Node) (id : Node') (state : State network S) :
            outcome id (State.reindex e state) = outcome (e id) state

            Reading a relabeled node recovers the same return, abort, or unfinished observation.

            @[simp]
            theorem Interaction.Execution.ReactiveNetwork.outcome_castNetwork {Node result S : Type} {boundary : PortBoundary} {network network' : Network Node boundary result} (h : network = network') (id : Node) (state : State network S) :
            outcome id (State.castNetwork h state) = outcome id state

            Changing an equal presentation preserves the node's actual observation.

            theorem Interaction.Execution.ReactiveNetwork.initial_reindex {Node Node' result S : Type} {boundary : PortBoundary} {network : Network Node boundary result} (e : Node' ≃ Node) (service : S) :
            initial (network.reindex e) service = State.reindex e (initial network service)

            Initialization commutes with relabeling, including the initial token holder.

            theorem Interaction.Execution.ReactiveNetwork.dispatch_reindex {Node Node' result S : Type} {boundary : PortBoundary} {network : Network Node boundary result} [DecidableEq Node] [DecidableEq Node'] (e : Node' ≃ Node) (packet : Destination network) (state : State network S) :
            dispatch (reindexDestination network e packet) (State.reindex e state) = State.reindex e (dispatch packet state)

            Delivery respects dependent recipient types after relabeling.

            theorem Interaction.Execution.ReactiveNetwork.deliver_reindex {Node Node' result S : Type} {boundary : PortBoundary} {network : Network Node boundary result} [DecidableEq Node] [DecidableEq Node'] (e : Node' ≃ Node) (state : State network S) :

            FIFO queue delivery is independent of the names of its recipients.

            theorem Interaction.Execution.ReactiveNetwork.runToken_castNetwork {Node result S : Type} {boundary : PortBoundary} {network : Network Node boundary result} [DecidableEq Node] {m : Type → Type} [Monad m] [LawfulMonad m] {network' : Network Node boundary result} (h : network = network') (impl : (id : Node) → PFunctor.Handler (StateT S m) (network.effect id)) (fuel : ℕ) (state : State network S) :
            runToken (castHandlers h impl) fuel (State.castNetwork h state) = State.castNetwork h <$> runToken impl fuel state

            Token execution commutes with equality of network presentations.

            theorem Interaction.Execution.ReactiveNetwork.runFIFO_castNetwork {Node result S : Type} {boundary : PortBoundary} {network : Network Node boundary result} [DecidableEq Node] {m : Type → Type} [Monad m] [LawfulMonad m] {network' : Network Node boundary result} (h : network = network') (impl : (id : Node) → PFunctor.Handler (StateT S m) (network.effect id)) (schedule : List (Activation Node)) (state : State network S) :
            runFIFO (castHandlers h impl) schedule (State.castNetwork h state) = State.castNetwork h <$> runFIFO impl schedule state

            FIFO execution commutes with equality of network presentations, keeping the schedule.

            theorem Interaction.Execution.ReactiveNetwork.activate_reindex {Node Node' result S : Type} {boundary : PortBoundary} {network : Network Node boundary result} [DecidableEq Node] [DecidableEq Node'] {m : Type → Type} [Monad m] [LawfulMonad m] (impl : (id : Node) → PFunctor.Handler (StateT S m) (network.effect id)) (e : Node' ≃ Node) (discipline : Discipline) (id : Node') (state : State network S) :
            activate (fun (id : Node') => impl (e id)) discipline id (State.reindex e state) = State.reindex e <$> activate impl discipline (e id) state

            A local activation commutes with relabeling its component and effect handler.

            theorem Interaction.Execution.ReactiveNetwork.fifoStep_reindex {Node Node' result S : Type} {boundary : PortBoundary} {network : Network Node boundary result} [DecidableEq Node] [DecidableEq Node'] {m : Type → Type} [Monad m] [LawfulMonad m] (impl : (id : Node) → PFunctor.Handler (StateT S m) (network.effect id)) (e : Node' ≃ Node) (activation : Activation Node) (state : State network S) :
            fifoStep (fun (id : Node') => impl (e id)) (Activation.reindex e activation) (State.reindex e state) = State.reindex e <$> fifoStep impl activation state

            One scheduled FIFO operation commutes with relabeling.

            theorem Interaction.Execution.ReactiveNetwork.runFIFO_reindex {Node Node' result S : Type} {boundary : PortBoundary} {network : Network Node boundary result} [DecidableEq Node] [DecidableEq Node'] {m : Type → Type} [Monad m] [LawfulMonad m] (impl : (id : Node) → PFunctor.Handler (StateT S m) (network.effect id)) (e : Node' ≃ Node) (schedule : List (Activation Node)) (state : State network S) :
            runFIFO (fun (id : Node') => impl (e id)) (List.map (Activation.reindex e) schedule) (State.reindex e state) = State.reindex e <$> runFIFO impl schedule state

            Relabeling preserves every FIFO execution prefix, with all effects in their original order.

            theorem Interaction.Execution.ReactiveNetwork.runToken_reindex {Node Node' result S : Type} {boundary : PortBoundary} {network : Network Node boundary result} [DecidableEq Node] [DecidableEq Node'] {m : Type → Type} [Monad m] [LawfulMonad m] (impl : (id : Node) → PFunctor.Handler (StateT S m) (network.effect id)) (e : Node' ≃ Node) (fuel : ℕ) (state : State network S) :
            runToken (fun (id : Node') => impl (e id)) fuel (State.reindex e state) = State.reindex e <$> runToken impl fuel state

            Relabeling preserves token execution, including the identity selected by control transfer.

            theorem Interaction.Execution.ReactiveNetwork.runToken_reindex_cast {Node Node' result S : Type} {boundary : PortBoundary} {network : Network Node boundary result} [DecidableEq Node] [DecidableEq Node'] {m : Type → Type} [Monad m] [LawfulMonad m] {network' : Network Node' boundary result} (impl : (id : Node) → PFunctor.Handler (StateT S m) (network.effect id)) (e : Node' ≃ Node) (h : network.reindex e = network') (fuel : ℕ) (state : State network S) :
            runToken (castHandlers h fun (id : Node') => impl (e id)) fuel (State.castNetwork h (State.reindex e state)) = (fun (next : State network S) => State.castNetwork h (State.reindex e next)) <$> runToken impl fuel state

            A proved graph factorization transports complete token prefixes, including residual private states, shared service, queued traffic, control, and consumed fuel.

            theorem Interaction.Execution.ReactiveNetwork.runFIFO_reindex_cast {Node Node' result S : Type} {boundary : PortBoundary} {network : Network Node boundary result} [DecidableEq Node] [DecidableEq Node'] {m : Type → Type} [Monad m] [LawfulMonad m] {network' : Network Node' boundary result} (impl : (id : Node) → PFunctor.Handler (StateT S m) (network.effect id)) (e : Node' ≃ Node) (h : network.reindex e = network') (schedule : List (Activation Node)) (state : State network S) :
            runFIFO (castHandlers h fun (id : Node') => impl (e id)) (List.map (Activation.reindex e) schedule) (State.castNetwork h (State.reindex e state)) = (fun (next : State network S) => State.castNetwork h (State.reindex e next)) <$> runFIFO impl schedule state

            A proved graph factorization transports complete FIFO prefixes with exactly the same delivery positions and corresponding component activations.