AlgebraicJulia / Catlab.jl

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

Coproduct with looseACSetTransformations #908

Open kris-brown opened 4 months ago

kris-brown commented 4 months ago

@slwu89 has found a bug in the coproduct dispatch:

X = @acset LabeledSet{Symbol} begin
    X=4
    label=[:a,:b,:c,:d]
end

Y = @acset LabeledSet{Int} begin
    X=3
    label=1:3
end

g = (Label=FinFunction(Dict([l=>l for l in X[:,:label]])),)
h = (Label=FinFunction(Dict([l=>Symbol(l) for l in Y[:,:label]])),)
coproduct(X,Y, type_components=[g,h])

Dispatch is not working, as it should eventually turn into the following (which does work, if you directly type it in):

colimit(Tuple{LabeledSet{Symbol},LooseACSetTransformation},
        DiscreteDiagram([X,Y]);
        type_components=[g,h])
kris-brown commented 4 months ago

I'd guess it would be hard to straightforwardly infer the LabeledSet{Symbol} argument from the input data, so I'm not sure if there's a good solution to this problem, but at least there could be a better error message.

slwu89 commented 4 months ago

Adding the definition of LabeledSet here that I used, for completeness

@present SetSch(FreeSchema) begin
    X::Ob
end
@present LabeledSetSch <: SetSch begin
    Label::AttrType
    label::Attr(X,Label)
end
@acset_type LabeledSet(LabeledSetSch, unique_index=[:label])