UC interfaces and open boundaries #
This file introduces the smallest structural layer for open concurrent systems.
The current concurrent semantic center, ProcessOver, describes closed
residual processes whose step protocols already live inside the system. For
UC-style openness, contextual plugging, and general interaction with an
environment, we also need a typed notion of:
- what traffic may enter a component,
- what traffic may leave it, and
- how such open boundaries compose.
The design here is intentionally minimal and purely structural.
Every definition is an abbrev over existing PFunctor / chart / lens
machinery, so the established theory is reused definitionally while
presenting names that read naturally in the interaction setting.
InterfaceisPFunctor: portsAand per-port messagesB a.Interface.Packet Iis one concrete boundary message on interfaceI.Interface.Hom I JisPFunctor.Chart I J(forward packet transport, covariant on both components).Interface.QueryHom I JisPFunctor.Lens I J(query retargeting with response pullback, contravariant on the fibre).Interface.Equiv I Jis the chart-level interface isomorphism.Interface.comp I Jis the composition monoidal product on polynomial functors (PFunctor.comp), modelling sequential dependence where one interface's response determines the next interface's port.Interface.compUnitis the composition unit (the identity polynomial functor: one port, one message).PortBoundaryis a directed pair of input and output interfaces.PortBoundary.swap,tensor,empty, andPortBoundary.Homare the basic operations for open composition.
The most important distinction in this file is:
Homacts on packets that have already been produced.QueryHomacts on one-step observations / queries that are still waiting for a response.
So Hom pushes traffic forward, while QueryHom retargets an interaction and
pulls the eventual response back.
The composition product is only functorial for QueryHom (lenses), not for
Hom (charts), because the fibre-level map must be contravariant.
This file also introduces the first equivalence layer:
Interface.Equivfor interface isomorphisms, andPortBoundary.Equivfor the corresponding variance-aware isomorphisms of directed open boundaries.
These structures are the starting point for expressing tensor unit,
associativity, and symmetry at the boundary level without hard-coding more
primitive operations into OpenTheory.
This file does not yet define open worlds, plugging, or runtime semantics. Those later layers should build on these typed boundary primitives rather than re-introducing their own packet/interface vocabulary.
References #
- Niu, Spivak (2024), Polynomial Functors: A Mathematical Theory of Interaction — the composition product, charts, lenses, and monoidal structures on polynomial functors used throughout this file
Interface is the interaction-facing name for PFunctor.
An interface packages:
- a type of ports
A, and - for each port
a : A, a type of messagesB a.
This is the same dependent-container structure already used throughout the
existing PFunctor world. The point of the new name is only to reflect the
intended reading: these are typed communication interfaces.
Instances For
Packet I is one concrete message on interface I.
It consists of:
- a chosen port
a : I.A, and - a message
m : I.B acarried on that port.
This is exactly PFunctor.Idx I, reused under a boundary-oriented name.
Instances For
Query I α is the continuation-bearing one-step query shape induced by the
interface I.
Unlike Packet I, which is just a concrete boundary message, Query I α
already stores a continuation returning values of type α.
So Query is the right bridge back to the existing PFunctor / oracle world:
it does not represent traffic that has already happened, but a one-step
interaction that is still waiting for a response.
This is exactly why the interface layer needs two different morphism notions:
Hom, for translating packets that already exist, andQueryHom, for retargeting a query while reinterpreting its eventual response.
At the PFunctor level, this is also the distinction between:
PFunctor.Chart, which transports concrete packets forward, andPFunctor.Lens, which transports continuation-bearing queries.
Instances For
Hom I J is the boundary-facing name for PFunctor.Chart I J.
A chart translates concrete packets forward from I to J:
toFunAmaps ports, andtoFunBmaps messages along the translated port.
In more operational terms, Hom answers the question:
if a packet actually appears on interface
I, how should it be viewed as a packet on interfaceJ?
So Hom is the structural notion of interface adaptation used for concrete
boundary traffic. When later layers need continuation-preserving interface
maps, they should use QueryHom instead.
Instances For
Equiv I J is the structural notion of interface isomorphism.
Unlike a plain Hom, which only translates packets forward, an
Interface.Equiv records an actual equivalence of ports together with an
equivalence of messages over each translated port.
This is intentionally based on the existing PFunctor.Equiv representation
rather than on chart isomorphisms. For the boundary layer, the stronger
structural equivalence is more convenient: the standard coproduct and tensor
coherence facts already live at this level, and packet/query translations can
be recovered from it when needed.
Instances For
QueryHom I J is the boundary-facing name for PFunctor.Lens I J.
A query hom translates continuation-bearing queries from I to J:
toFunAmaps the queried port, andtoFunBreinterprets a response on the translated port back as a response on the original port.
In more operational terms, QueryHom answers the question:
if a component wants to query interface
I, how should that query be retargeted to interfaceJ, and how should the eventual response be turned back into anI-response?
So charts are the right notion for concrete packets, while query homs are the
right notion for one-step interactive behavior. This is why the message map in
QueryHom goes in the opposite direction from Hom: queries move outward, but
their responses must be pulled back. The same underlying representation is
still PFunctor.Lens; the new name is only there to make the interaction-level
role of the abstraction immediately legible.
Instances For
The port component of an interface chart.
This is the interaction-facing name for PFunctor.Chart.toFunA.
Instances For
The message component of an interface chart.
For each source port a, onMsg translates a concrete message on a into a
message on the translated target port f.onPort a.
So onMsg moves in the same direction as the packet itself. This is the
interaction-facing name for PFunctor.Chart.toFunB.
Instances For
The identity interface translation.
Instances For
The port component of an interface query hom.
This is the interaction-facing name for PFunctor.Lens.toFunA.
Instances For
The message-response component of an interface query hom.
For each queried source port a, onMsg reinterprets a response on the
translated target port f.onPort a back as a response on the original port
a.
So onMsg moves in the opposite direction from the retargeted query: the query
goes out to J, and the response is pulled back to I. This is the
interaction-facing name for PFunctor.Lens.toFunB.
Instances For
The identity interface query hom.
Instances For
Translate one continuation-bearing query along an interface query hom.
If a query asks for a response on interface I, then mapQuery f retargets
that query to interface J and uses the query hom to reinterpret the eventual
response back on the original side.
So mapQuery is the query-level companion to Hom.mapPacket:
Hom.mapPacketchanges traffic that already exists;QueryHom.mapQuerychanges the interface against which a pending interaction is asked.
Instances For
The empty interface with no ports and therefore no packets.
Instances For
Disjoint sum of interfaces.
A packet on sum Σ Τ is either:
This is the structural operation used later for side-by-side composition of open boundaries.
This is just the ordinary coproduct of polynomial functors. To keep the representation definitionally simple, both sides share the same message universe. That is already the regime used by the current open-composition layer, so no extra universe-lifting machinery is needed here.
Instances For
Combine two interface query homs side by side.
The resulting query hom retargets left and right coproduct queries independently.
Instances For
The identity interface equivalence.
Instances For
Composition product of interfaces (the composition monoidal product on polynomial functors; see Niu–Spivak 2024).
A position of comp I J is a pair of:
- a port
a : I.Aon the outer interface, and - for each response
m : I.B aon that port, a port of the inner interface: a functionI.B a → J.A.
A direction at a composed position ⟨a, f⟩ is a dependent pair ⟨u, v⟩
where u : I.B a is a response on port a and v : J.B (f u) is a
response on the resulting inner port.
This models sequential dependence: one interface's response determines which port of the next interface is activated.
Instances For
Bifunctorial action of query homs on the composition product.
Given query homs f₁ : QueryHom I₁ J₁ and f₂ : QueryHom I₂ J₂, produces
a query hom on the composed interfaces.
There is no corresponding Hom.compMap because charts (covariant on both
components) are not functorial for the composition product; the composition
product requires contravariance on B, which only lenses provide.
Instances For
PortBoundary is a directed open boundary for a component or world.
Inis the interface of packets accepted from the outside.Outis the interface of packets emitted to the outside.
The direction matters: later plugging and contextual composition should not identify incoming and outgoing traffic.
Instances For
The empty open boundary: no inputs and no outputs.
Instances For
Swap the direction of a boundary.
This is the structural operation underlying plugging: the outputs expected by one side become inputs for the other, and vice versa.
Instances For
Side-by-side composition of open boundaries.
Inputs and outputs are combined by disjoint sum, so the resulting boundary exposes both components in parallel.
Instances For
PortBoundary.Hom Δ₁ Δ₂ is a structural adaptation from boundary Δ₁
to boundary Δ₂.
The variance matches the operational reading:
- inputs are contravariant: a consumer of
Δ₂.Incan be fed by packets fromΔ₁.Inonly if we know how to translateΔ₂-inputs back intoΔ₁-inputs; - outputs are covariant: packets produced on
Δ₁.Outare translated forward intoΔ₂.Out.
This is the boundary-level notion later used for interface adaptation and structural plugging.
Instances For
Combine two boundary adaptations side by side.
This is the boundary-level companion to PortBoundary.tensor: the left and
right adaptations act independently on the corresponding summands.
Instances For
Swap the direction of a boundary adaptation.
This is the structural boundary-level counterpart of PortBoundary.swap:
incoming and outgoing interface maps exchange roles.
Instances For
The identity boundary adaptation.
Instances For
Compose two boundary adaptations.
comp g f first adapts Δ₁ to Δ₂, then adapts Δ₂ to Δ₃.
Instances For
PortBoundary.Equiv Δ₁ Δ₂ is the variance-aware notion of boundary
isomorphism.
It is described directly in terms of interface equivalences:
onInis an equivalence fromΔ₂.IntoΔ₁.In, reflecting the contravariant role of inputs;onOutis an equivalence fromΔ₁.OuttoΔ₂.Out, reflecting the covariant role of outputs.
This is the right structure for expressing coherence laws of open composition: the exposed boundary may change shape, but only up to a canonical directed isomorphism.
Instances For
The forward boundary adaptation carried by a boundary equivalence.
Instances For
The inverse boundary adaptation carried by a boundary equivalence.
Instances For
The identity boundary equivalence.
Instances For
Reverse a boundary equivalence.
Instances For
Compose two boundary equivalences.
trans e₁ e₂ first changes the exposed boundary along e₁, then along e₂.
Instances For
Boundary equivalence is preserved under tensor.
Instances For
The forward boundary adaptation of tensorCongr is exactly the tensor of the
forward boundary adaptations on each factor.
Swapping the direction of boundaries preserves equivalence.
Instances For
The forward boundary adaptation of swapCongr is exactly the swapped forward
inverse boundary adaptation.
The empty boundary is a left tensor unit.
Instances For
The empty boundary is a right tensor unit.
Instances For
Tensor of boundaries is symmetric up to equivalence.
Instances For
Tensor of boundaries is associative up to equivalence.
Instances For
Swapping twice yields the original boundary, up to equivalence.