AlgebraicJulia / Catlab.jl

A framework for applied category theory in the Julia language
https://www.algebraicjulia.org
MIT License
613 stars 58 forks source link

For GLA, @program needs to know that copying is oplus #116

Open jpfairbanks opened 4 years ago

jpfairbanks commented 4 years ago

MWE:

@present Mat(FreeLinearMaps) begin
    X::Ob
    Y::Ob
    Z::Ob

    f::Hom(X,Y)
    g::Hom(Y,Z)
    h::Hom(Y⊕Z, V)
end

A = @program Mat (x::X,y::Y) begin
    v = h(f(x), g(y))
    return v
end
jpfairbanks commented 4 years ago

@mehalter do you think you could take a look at this? How should we handle this in general? Do we need to map Julia PL features onto the GAT term constructors in general? Should we use a mechanism like the @op macro when defining the doctrine to supply this information to the program macro?

epatters commented 4 years ago

Since this macro generates wiring diagrams, not morphism expressions, it does not depend on otimes in any important way. In fact, it only calls otimes once (on objects) and I think that call could be removed, thus solving this problem.

Support for additive monoidal categories needs to be added in two places:

  1. Wiring diagram instances: Catlab.WiringDiagrams.AlgebraicWiringDiagrams
  2. Conversion of wiring diagrams to morphism epressions: Catlab.WiringDiagrams.Expressions