Monoidal Bridge: DeepPackage ↔ PkgInterface SMC #
This file connects the concrete package operations (DeepPackage.par, link)
to the symmetric monoidal category on PkgInterface (from SemPkg.lean).
Main Results #
tensorAppendIso—toPkgInterface(I.append J) ≅ toPkgInterface(I) ⊗ toPkgInterface(J)unitIso—toPkgInterface(⟨[]⟩) ≅ 𝟙_diAppend_assoc/diAppend_empty_*— algebraic laws fordiAppendappendAssocIso— coherence iso fromList.append_assoctensorAppend_assoc_coherence— pentagon coherence (stated, see note)
Architecture #
The PkgInterface SMC (from SemPkg.lean) uses Sum-indexed families with
definitional coherence (funext + cases + rfl). The concrete DeepInterface
uses List-indexed families with diAppend = List.append as tensor.
The key difficulty: Fin (m + n) vs Fin m ⊕ Fin n. The tensorAppendIso
bridges this gap using castKl' (proof-irrelevant transport on Kleisli arrows)
with the roundtrip proofs handled by castKl'_castKl'_symm and
castKl'_dep_fn (dependent function transport).
Instances For
Instances For
Family Correspondence #
Type-level cast for operation families #
Tensor-Append Isomorphism #
Forward: handler for diAppend I J → handler for toPI I ⊗ toPI J.
Equations
- CatCrypt.Bridge.MonoidalBridge.appendToTensor I J h (Sum.inl i) = CatCrypt.Bridge.MonoidalBridge.castKl'✝ ⋯ (h ⟨↑i, ⋯⟩)
- CatCrypt.Bridge.MonoidalBridge.appendToTensor I J h (Sum.inr j) = CatCrypt.Bridge.MonoidalBridge.castKl'✝ ⋯ (h ⟨I.ops.length + ↑j, ⋯⟩)
Instances For
Inverse: handler for toPI I ⊗ toPI J → handler for diAppend I J.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The tensor-append isomorphism in the PkgInterface category.
This is the fundamental bridge between DeepInterface.append (list concat,
Fin-indexed) and PkgInterface.tensor (Sum-indexed).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Unit Correspondence #
The empty deep interface maps to the monoidal unit.
Equations
- One or more equations did not get rendered due to their size.
Instances For
diAppend is associative: (I ++ J) ++ K = I ++ (J ++ K) as DeepInterfaces.
Right unit: diAppend I ⟨[]⟩ = I.
Left unit: diAppend ⟨[]⟩ I = I.
The PkgInterface iso induced by associativity of diAppend.
Equations
Instances For
The PkgInterface iso from right-unit of diAppend.
Instances For
The PkgInterface iso from left-unit of diAppend.
Instances For
Coherence #
The associator pentagon: the two paths from toPI((I++J)++K) to
toPI I ⊗ (toPI J ⊗ toPI K) commute.
Note: The proof requires unfolding eqToHom (from appendAssocIso)
into explicit castKl' form. The approach is:
- Define
appendAssocIsoexplicitly viacastKl'(liketensorAppendIso) - Use
castKl'_trans+castKl'_dep_fn+ proof irrelevance Both paths computecastKl'at the sameFin.valindex with propositionally equal operation triples, so the casts agree by proof irrelevance.
Linking = Categorical Composition #
toSemPkg maps DeepPackage.link to composition in Category DeepInterface.
This is the fundamental functoriality theorem connecting the concrete package
operation to the categorical structure.
Note: toSemPkg is NOT a strict functor — it does not preserve identity exactly.
toSemPkg(DeepPackage.id I) returns fail on non-interface operations, while
𝟙 I = SemPkg.id I passes them through. Identity is only preserved on interface
operations (see toSemPkg_id_mem and evalImpl_link_id_left/right).
toSemPkg preserves linking at the handler level:
toSemPkg(link p₁ p₂).resolve = toSemPkg(p₁).resolve ∘ toSemPkg(p₂).resolve.
toSemPkg preserves linking as SemPkg.comp:
toSemPkg(link p₁ p₂) = toSemPkg(p₁).comp(toSemPkg(p₂)).
Requires p₁.imports = p₂.exports for the composition to be well-typed.
toSemPkg preserves linking as categorical composition ≫ in
Category DeepInterface (where f ≫ g = g.comp f):
toSemPkg(link p₁ p₂) = toSemPkg(p₂) ≫ eqToHom(h.symm) ≫ toSemPkg(p₁).
Unitor Coherence #
The unitor bridges: the two paths from toPI(I ++ ⟨[]⟩) to toPI(I) via
(1) the append-empty iso, or (2) tensor-append iso + unitIso + monoidal unitor,
are equal. Similarly for the left unitor.
Right unitor coherence: the two paths from toPI(I ++ ⟨[]⟩) to toPI(I) agree.
Path 1: toPI(I++⟨[]⟩) → toPI(I) ⊗ toPI(⟨[]⟩) → toPI(I) ⊗ 𝟙_ → toPI(I)
Path 2: toPI(I++⟨[]⟩) → toPI(I) directly via appendEmptyRightIso.
Left unitor coherence: the two paths from toPI(⟨[]⟩ ++ I) to toPI(I) agree.
Path 1: toPI(⟨[]⟩++I) → toPI(⟨[]⟩) ⊗ toPI(I) → 𝟙_ ⊗ toPI(I) → toPI(I)
Path 2: toPI(⟨[]⟩++I) → toPI(I) directly via appendEmptyLeftIso.
Braiding Bridge #
Braiding bridge: composing the tensor-append iso with braiding and the inverse tensor-append iso gives the concrete swap.
Equations
- One or more equations did not get rendered due to their size.