Node-local contexts and schemas #
This file isolates the node-local metadata layer of the Interaction
framework.
Spec.Node.Context is the semantic notion:
for each move space X, it gives the type of node-local information available
at a node whose next move lives in X.
Spec.Node.Schema is the structured, telescope-style front-end for building
such contexts in stages. This follows the use of contexts and
telescopes in dependent type theory, where later entries may depend on
earlier ones, and it also echoes the schema / instance split common in
database theory.
References informing this terminology:
- de Bruijn (1991), telescopes in dependent type theory;
- Castellan–Clairambault–Dybjer (2020), contexts and types in context via categories with families;
- Spivak (2012), schemas as structured descriptions whose instances carry data.
The rest of the interaction core consumes realized node contexts, not schemas:
Spec.Decoration Γ specdecorates a protocol tree by concrete values in contextΓ;Spec.SyntaxOverandSpec.InteractionOverdefine syntax and execution over those realized contexts.Spec.ShapeOveris the functorial refinement ofSpec.SyntaxOver, used when node objects support generic continuation reindexing.Spec.Node.ContextHomrecords structure-preserving maps between realized contexts, so forgetting or repackaging metadata can be expressed explicitly.Spec.Node.Schema.SchemaMapis the corresponding notion at the schema level: a semantic map between realized contexts presented with their schema sources and targets.Spec.Node.Schema.Prefixrecords syntactic schema-prefix inclusions, which induce canonical forgetful maps on realized contexts.
Worked example:
if we previously thought of node metadata in two stages,
first a tag Tag X and then dependent data Data X tag,
the corresponding schema is
(Spec.Node.Schema.singleton Tag).extend Data.
Its realized context is Spec.Node.Context.extend Tag Data,
so a single decoration by that context packages the old staged view into one
semantic object.
Context is the realized family of node-local information.
If Γ : Node.Context, then for every move space X, the type Γ X describes
what metadata is available at a node whose next move lies in X.
This is the semantic object consumed by the rest of the interaction core.
Contexts may be written directly, or assembled in stages via Node.Schema.
Instances For
ContextHom Γ Δ is a nodewise map from context Γ to context Δ.
At each move space X, it turns a Γ X-value into a Δ X-value. This is the
right notion of morphism for realized node contexts, and it is what
Spec.Decoration.map consumes.
Instances For
Identity morphism on a realized node context.
Instances For
Composition of realized node-context morphisms.
Instances For
The empty node context, carrying no information at any node.
This is the neutral context used by the plain Shape / Interaction
specializations.
Instances For
Extend a realized node context by one dependent field.
If Γ is the current context and A X γ is a new field whose type may depend
on the existing context value γ : Γ X, then Γ.extend A is the enlarged
context containing both pieces of data.
The new field is allowed to live in a different universe from the existing
context. This keeps Context.extend flexible even though Schema itself uses
one fixed universe parameter for its staged fields.
Instances For
Forget the most recently added field of an extended node context.
This is the canonical projection from Context.extend Γ A back to its base
context Γ.
Instances For
Map one extended node context to another by:
- mapping the base context with
f, and - mapping the new dependent field with
g.
Instances For
Schema Γ is a telescope whose realized node context is Γ.
Schemas are the structured front-end for building node-local contexts:
nilis the empty telescope;singleton Ais a one-field schema with no prior dependencies;snoc S Aappends a new field whose type may depend on the earlier realized context carried byS.
The semantic object used elsewhere in the interaction core is still the
realized context Γ; a schema is simply a readable way to assemble such
contexts stage by stage, while keeping the dependency structure visible.
For example, a two-stage schema consisting of:
- a first field
Tag X, and then - a second field
Data X tagdepending on that tag
is written as (Schema.singleton Tag).extend Data,
and realizes to the context Context.extend Tag Data.
- nil : Schema Context.empty
The empty schema.
- singleton
(A : Type u → Type v)
: Schema A
A one-field schema whose realized context is exactly
A. - snoc
{Γ : Context}
(S : Schema Γ)
(A : (X : Type u) → Γ X → Type v)
: Schema (Context.extend Γ A)
Extend an existing schema by one further dependent field.
Instances For
Extend a node schema by one further dependent field.
This is the functional wrapper around the snoc constructor, useful when a
schema is being built incrementally.
Instances For
Interpret a node schema as its realized node context.
This uses the active name toContext rather than a noun like context
because a schema is a descriptive telescope, while a context is the semantic
family it determines.
Instances For
SchemaMap S T is a semantic morphism from schema S to schema T.
Unlike Schema.Prefix, this is not a syntactic extension relation. It is
simply a map between the realized node contexts of S and T, presented with
the schema source and target so that later constructions can speak directly in
schema-level terms.
So:
Schema.Prefixexpresses a particular syntactic way one schema sits inside another;SchemaMapexpresses an arbitrary semantic transformation between their realized contexts.
Instances For
Identity schema morphism.
Instances For
Treat a realized context morphism as a schema morphism between any schemas presenting those contexts.
Instances For
Extend a schema morphism by one further dependent field.
If f : SchemaMap S T maps the base contexts and g maps the newly added
field over each base value, then SchemaMap.extend f g is the induced schema
morphism between the corresponding one-step schema extensions.
Instances For
Prefix S T means that S is a syntactic prefix of the schema T.
Each snoc step adds one new field on the right, so a prefix determines a
canonical forgetful map from the realized context of T back to the realized
context of S.
This is intentionally a syntactic notion, not merely a semantic one: two schemas may realize equivalent node contexts without one being a prefix of the other.
- refl
{Γ : Context}
(S : Schema Γ)
: S.Prefix S
Every schema is a prefix of itself.
- snoc
{Γ Δ : Context}
{S : Schema Γ}
{T : Schema Δ}
(p : S.Prefix T)
(A : (X : Type u) → Δ X → Type v)
: S.Prefix (T.extend A)
If
Sis a prefix ofT, then it is also a prefix of any one-field extension ofT.
Instances For
The realized context morphism induced by a schema prefix.
This forgets exactly the fields appended after the prefix S.