Documentation

VCVio.Interaction.UC.OpenSyntax.Expr

Quotiented free model of open composition #

This module defines Expr, the initial (quotiented) free model of OpenTheory.

Expr Atom Δ is the quotient of the raw syntax tree Raw Atom Δ by the equivalence relation Raw.Equiv, which identifies raw expressions that should be equal according to the OpenTheory equations (functoriality of map, naturality of par, wire, and plug).

The quotient construction yields a lawful OpenTheory instance by construction: each law holds because it is a constructor of Raw.Equiv.

Main definitions #

Expr Atom Δ is the free open-system expression of boundary Δ, generated by primitive atoms Atom.

This is the quotient of Raw Atom Δ by the OpenTheory equations. Unlike the raw syntax tree, Expr satisfies map_id, map_comp, and the naturality laws, so it forms a lawful OpenTheory.

For pattern matching on the underlying syntax, project to Raw via Expr.liftOn or work with Raw directly.

Instances For
    def Interaction.UC.OpenSyntax.Expr.mk {Atom : PortBoundaryType u} {Δ : PortBoundary} (e : Raw Atom Δ) :
    Expr Atom Δ

    Project a raw expression into the quotiented Expr.

    Instances For
      def Interaction.UC.OpenSyntax.Expr.atom {Atom : PortBoundaryType u} {Δ : PortBoundary} (a : Atom Δ) :
      Expr Atom Δ

      Inject a primitive open component.

      Instances For
        def Interaction.UC.OpenSyntax.Expr.map {Atom : PortBoundaryType u} {Δ₁ Δ₂ : PortBoundary} (f : Δ₁.Hom Δ₂) (e : Expr Atom Δ₁) :
        Expr Atom Δ₂

        Adapt the exposed boundary along a structural morphism.

        Instances For
          def Interaction.UC.OpenSyntax.Expr.par {Atom : PortBoundaryType u} {Δ₁ Δ₂ : PortBoundary} (e₁ : Expr Atom Δ₁) (e₂ : Expr Atom Δ₂) :
          Expr Atom (Δ₁.tensor Δ₂)

          Place two open systems side by side.

          Instances For
            def Interaction.UC.OpenSyntax.Expr.wire {Atom : PortBoundaryType u} {Δ₁ Γ Δ₂ : PortBoundary} (e₁ : Expr Atom (Δ₁.tensor Γ)) (e₂ : Expr Atom (Γ.swap.tensor Δ₂)) :
            Expr Atom (Δ₁.tensor Δ₂)

            Connect one shared boundary between two open systems.

            Instances For

              The identity wire (coevaluation) on boundary Γ.

              Instances For
                def Interaction.UC.OpenSyntax.Expr.plug {Atom : PortBoundaryType u} {Δ : PortBoundary} (e : Expr Atom Δ) (k : Expr Atom Δ.swap) :

                Close an open system against a matching context. Derived from wire and map, mirroring Raw.plug.

                Instances For

                  The monoidal unit (closed system with no boundary). Derived from idWire and map, mirroring Raw.unit.

                  Instances For
                    def Interaction.UC.OpenSyntax.Expr.interpret {Atom : PortBoundaryType u} {Δ : PortBoundary} (e : Expr Atom Δ) (T : OpenTheory) [hT : T.CompactClosed] (interp : {Δ : PortBoundary} → Atom ΔT.Obj Δ) :
                    T.Obj Δ

                    Interpret a quotiented expression in a compact closed target theory.

                    Well-defined on the quotient because Raw.Equiv.interpret_eq shows that equivalent raw expressions interpret the same way in any compact closed theory.

                    Instances For
                      @[simp]
                      theorem Interaction.UC.OpenSyntax.Expr.interpret_mk {Atom : PortBoundaryType u} {Δ : PortBoundary} (r : Raw Atom Δ) (T : OpenTheory) [T.CompactClosed] (interp : {Δ : PortBoundary} → Atom ΔT.Obj Δ) :
                      ((mk r).interpret T fun {Δ : PortBoundary} => interp) = r.interpret T (fun {Δ : PortBoundary} => interp) OpenTheory.CompactClosed.idWire
                      @[simp]
                      theorem Interaction.UC.OpenSyntax.Expr.interpret_atom {Atom : PortBoundaryType u} {Δ : PortBoundary} (a : Atom Δ) (T : OpenTheory) [T.CompactClosed] (interp : {Δ : PortBoundary} → Atom ΔT.Obj Δ) :
                      ((atom a).interpret T fun {Δ : PortBoundary} => interp) = interp a
                      @[simp]
                      theorem Interaction.UC.OpenSyntax.Expr.interpret_map {Atom : PortBoundaryType u} {Δ₁ Δ₂ : PortBoundary} (f : Δ₁.Hom Δ₂) (e : Expr Atom Δ₁) (T : OpenTheory) [T.CompactClosed] (interp : {Δ : PortBoundary} → Atom ΔT.Obj Δ) :
                      ((map f e).interpret T fun {Δ : PortBoundary} => interp) = T.map f (e.interpret T fun {Δ : PortBoundary} => interp)
                      @[simp]
                      theorem Interaction.UC.OpenSyntax.Expr.interpret_par {Atom : PortBoundaryType u} {Δ₁ Δ₂ : PortBoundary} (e₁ : Expr Atom Δ₁) (e₂ : Expr Atom Δ₂) (T : OpenTheory) [T.CompactClosed] (interp : {Δ : PortBoundary} → Atom ΔT.Obj Δ) :
                      ((e₁.par e₂).interpret T fun {Δ : PortBoundary} => interp) = T.par (e₁.interpret T fun {Δ : PortBoundary} => interp) (e₂.interpret T fun {Δ : PortBoundary} => interp)
                      @[simp]
                      theorem Interaction.UC.OpenSyntax.Expr.interpret_wire {Atom : PortBoundaryType u} {Δ₁ Γ Δ₂ : PortBoundary} (e₁ : Expr Atom (Δ₁.tensor Γ)) (e₂ : Expr Atom (Γ.swap.tensor Δ₂)) (T : OpenTheory) [T.CompactClosed] (interp : {Δ : PortBoundary} → Atom ΔT.Obj Δ) :
                      ((e₁.wire e₂).interpret T fun {Δ : PortBoundary} => interp) = T.wire (e₁.interpret T fun {Δ : PortBoundary} => interp) (e₂.interpret T fun {Δ : PortBoundary} => interp)
                      @[simp]
                      theorem Interaction.UC.OpenSyntax.Expr.interpret_idWire {Atom : PortBoundaryType u} (Γ : PortBoundary) (T : OpenTheory) [T.CompactClosed] (interp : {Δ : PortBoundary} → Atom ΔT.Obj Δ) :
                      @[simp]
                      theorem Interaction.UC.OpenSyntax.Expr.interpret_plug {Atom : PortBoundaryType u} {Δ : PortBoundary} (e : Expr Atom Δ) (k : Expr Atom Δ.swap) (T : OpenTheory) [T.CompactClosed] (interp : {Δ : PortBoundary} → Atom ΔT.Obj Δ) :
                      ((e.plug k).interpret T fun {Δ : PortBoundary} => interp) = T.plug (e.interpret T fun {Δ : PortBoundary} => interp) (k.interpret T fun {Δ : PortBoundary} => interp)
                      @[simp]
                      theorem Interaction.UC.OpenSyntax.Expr.interpret_unit {Atom : PortBoundaryType u} (T : OpenTheory) [T.CompactClosed] (interp : {Δ : PortBoundary} → Atom ΔT.Obj Δ) :
                      @[reducible, inline]

                      The free lawful OpenTheory whose objects are quotiented expressions over Atom.

                      Instances For
                        @[implicit_reducible]
                        @[implicit_reducible]
                        def Interaction.UC.OpenSyntax.Expr.toInterp {Atom : PortBoundaryType u} {Δ : PortBoundary} (e : Expr Atom Δ) :
                        Interp Atom Δ

                        Embed a quotiented expression into the tagless-final representation.

                        Well-defined on the quotient because equivalent raw expressions interpret the same way in every compact closed theory (which is exactly what Interp.ext requires).

                        Instances For
                          @[simp]
                          theorem Interaction.UC.OpenSyntax.Expr.toInterp_mk {Atom : PortBoundaryType u} {Δ : PortBoundary} (r : Raw Atom Δ) :
                          (mk r).toInterp = { run := fun (T : OpenTheory) (hCC : T.CompactClosed) (interp : {Δ : PortBoundary} → Atom ΔT.Obj Δ) => r.interpret T (fun {Δ : PortBoundary} => interp) OpenTheory.CompactClosed.idWire }
                          @[simp]
                          theorem Interaction.UC.OpenSyntax.Expr.toInterp_map {Atom : PortBoundaryType u} {Δ₁ Δ₂ : PortBoundary} (f : Δ₁.Hom Δ₂) (e : Expr Atom Δ₁) :
                          @[simp]
                          theorem Interaction.UC.OpenSyntax.Expr.toInterp_par {Atom : PortBoundaryType u} {Δ₁ Δ₂ : PortBoundary} (e₁ : Expr Atom Δ₁) (e₂ : Expr Atom Δ₂) :
                          (e₁.par e₂).toInterp = e₁.toInterp.par e₂.toInterp
                          @[simp]
                          theorem Interaction.UC.OpenSyntax.Expr.toInterp_wire {Atom : PortBoundaryType u} {Δ₁ Γ Δ₂ : PortBoundary} (e₁ : Expr Atom (Δ₁.tensor Γ)) (e₂ : Expr Atom (Γ.swap.tensor Δ₂)) :
                          (e₁.wire e₂).toInterp = e₁.toInterp.wire e₂.toInterp
                          @[simp]
                          theorem Interaction.UC.OpenSyntax.Expr.toInterp_plug {Atom : PortBoundaryType u} {Δ : PortBoundary} (e : Expr Atom Δ) (k : Expr Atom Δ.swap) :