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

Subobject classifier + Internal hom for C-Sets #786

Closed kris-brown closed 1 year ago

kris-brown commented 1 year ago

Combines subacset search with computation of representables.

Tested on DDS (with equations to make the repr finite), Grph, and ReflGrph.

A change to SigmaMigration was needed because the previous implementation threw away the diagram map data (how the input CSet is related to the output CSet). Maybe should return a proper DiagramHom, but for now it's just the result ACSet + a dictionary of the diagram map components.

Shoutout to @KevinArlin for helping me work out where the homs go in the subobject classifier + internal hom constructions!

kris-brown commented 1 year ago

For future reference, we had to change the definition of DiagramHom to not constrain one of its type parameters to be a FinTransformation in order for the Julia compiler to not freeze up when the following code (which seems like it should work) is run

@present ThInitial(FreeSchema) begin
  I::Ob
end
@acset_type Initial(ThInitial)
I = generators(ThInitial)[1]
G = path_graph(Graph,3)
dG = FinDomFunctor(G)

bang = FinFunctor(
  Dict(:E => :I, :V => :I),
  Dict(:src => id(I), :tgt => id(I)),
  SchGraph, ThInitial)
I1 =FinDomFunctor(apex(terminal(Initial)))
α = Dict(:V=>FinFunction([1,1,1]), :E=>FinFunction([1,1]))

DiagramHom{id}(bang, α, dG, I1)