Package Interfaces and Fam(KlSPComp) Morphisms #
A package interface specifies operation signatures via an index type ι with
domain and codomain families in KlSPComp.
A package implementation (PkgImpl) is a morphism in Fam(KlSPComp) from the
domain family to the codomain family. Fam composition is Kleisli sequencing
(bind at each operation), NOT oracle substitution. See SemPkg.lean for the
package category with substitution-style composition.
Linking vs composition: PkgImpl.link computes as SPComp.bind at each
operation index — this is a data pipeline (first-order), not oracle resolution
(second-order). Cryptographic package linking is oracle substitution, which is
modeled by the Category PkgInterface in SemPkg.lean.
Parallel composition (PkgImpl.par) dispatches operations by Sum index.
This IS the correct parallel composition and is shared with the package category.
Main definitions #
PkgInterface— operation signatures (index type, domains, codomains)PkgInterface.tensor— parallel combination (Sum on indices)PkgInterface.unit— empty interface (Empty index)PkgImpl— Fam(KlSPComp) morphism (Kleisli arrow at each operation)PkgImpl.ofImpls— construct from componentwise implementations (σ = id)PkgImpl.link— Kleisli-bind composition (NOT oracle substitution)PkgImpl.par— parallel composition via Fam tensorDeepInterface.toPkgInterface— bridge from deep-embedding interfaces
Semantic characterization #
link_map: linking at operationiisSPComp.bind (p₁.map i x) (p₂.map (p₁.σ i))par_map_inl: parallel at.inl idispatches top₁.map ipar_map_inr: parallel at.inr jdispatches top₂.map j
SMC structure #
Since PkgInterface.tensor/unit correspond definitionally to FamObj.tensorObj/unitObj,
the monoidal category laws apply directly to PkgImpl parallel composition.
The full SMC structure on PkgInterface (with substitution-style composition)
is in SemPkg.lean.
Package Interface #
A package interface specifies operation signatures.
Each operation is indexed by ι with domain type doms i and codomain type codoms i,
both living in KlSPComp (= Type, viewed as objects of the Kleisli category of SPComp).
- ι : Type
Index type for operations
- doms : self.ι → Core.KlSPComp
Domain type of each operation
- codoms : self.ι → Core.KlSPComp
Codomain type of each operation
Instances For
The domain family as a FamObj KlSPComp.
Instances For
The codomain family as a FamObj KlSPComp.
Instances For
Tensor and Unit #
The empty interface (no operations).
Equations
- CatCrypt.Category.PkgInterface.unit = { ι := Empty, doms := Empty.elim, codoms := Empty.elim }
Instances For
Correspondence with Fam's tensor and unit #
These are all rfl because both sides expand to the same ⟨ι₁ ⊕ ι₂, Sum.elim ...⟩
(resp. ⟨Empty, Empty.elim⟩). This definitional equality is the key insight:
packages inherit their SMC structure from Fam.lean with zero proof effort.
Package Implementation #
A package implementation for interface I is a morphism in Fam(KlSPComp)
from the domain family to the codomain family.
Concretely, this consists of:
- An equivalence
σ : I.ι ≃ I.ιpermuting operation indices - Implementations
map i : I.doms i → SPComp (I.codoms (σ i))for each operation
When σ = id (the common case), each operation i has a direct implementation
I.doms i → SPComp (I.codoms i).
Equations
- CatCrypt.Category.PkgImpl I = (I.domFam ⟶ I.codomFam)
Instances For
Construction #
Construct a package from componentwise implementations (with σ = id).
Equations
- CatCrypt.Category.PkgImpl.ofImpls I impls = { σ := Equiv.refl I.domFam.ι, map := impls }
Instances For
Linking = Fam Composition (Kleisli Sequencing) #
Note: This is Kleisli-bind composition (sequencing), not oracle substitution.
At each operation i, link computes as SPComp.bind (p₁.map i x) (p₂.map (p₁.σ i)),
i.e., run p₁, then feed the result into p₂. This models a data pipeline, not
cryptographic package linking (which is oracle resolution — see SemPkg.lean).
Linking two packages: composition in Fam(KlSPComp).
Equations
Instances For
Parallel Composition = Fam Tensor #
Parallel composition dispatches operations to the correct component:
Parallel composition of packages: tensor in Fam(KlSPComp).
Equations
- p₁.par p₂ = CategoryTheory.MonoidalCategoryStruct.tensorHom p₁ p₂
Instances For
SMC Laws for Parallel Composition #
The monoidal laws for parallel composition (tensor, associator, braiding) hold
for PkgImpl via the definitional equality between PkgInterface.tensor/unit
and FamObj.tensorObj/unitObj. These are inherited from Fam.lean.
The full symmetric monoidal category structure on PkgInterface — with
substitution-style composition (oracle resolution) rather than Fam's Kleisli
sequencing — is in SemPkg.lean.
Bridge: DeepInterface → PkgInterface #
Convert a DeepInterface (list-based, from the deep embedding) to a PkgInterface
(family-based, for the categorical framework) via Fin indexing.
Each position in the operation list becomes a Fin index.
Equations
Instances For
Append two deep interfaces (concatenate operation lists).
Instances For
The tensor of toPkgInterface corresponds to the append of DeepInterface:
(I.append J).toPkgInterface and I.toPkgInterface.tensor J.toPkgInterface
have the same operations, indexed by Fin (m + n) vs Fin m ⊕ Fin n respectively.
The equivalence finSumFinEquiv from Mathlib connects these index types,
with List.getElem_append_left/List.getElem_append_right showing the families match.