Skip to content

Commit

Permalink
Merge pull request #167 from AlgebraicJulia/fix_degenerate_duc
Browse files Browse the repository at this point in the history
Fix promotion of a gluing query with a conjunctive query
  • Loading branch information
epatters authored May 29, 2024
2 parents d7258ef + b8f6ea9 commit 3d0e938
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/DiagrammaticPrograms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,8 @@ promote_query_rule(::Type{<:GlueQuery{C}}, ::Type{<:Ob}) where {Ob,C<:FinCat{Ob}
GlueQuery{C}
promote_query_rule(::Type{<:GlucQuery{C}}, ::Type{<:Ob}) where {Ob,C<:FinCat{Ob}} =
GlucQuery{C}
promote_query_rule(::Type{<:GlueQuery{C}}, ::Type{<:ConjQuery{C}}) where C =
GlucQuery{C}
promote_query_rule(::Type{<:GlucQuery{C}}, ::Type{<:ConjQuery{C}}) where C =
GlucQuery{C}
promote_query_rule(::Type{<:GlucQuery{C}}, ::Type{<:GlueQuery{C}}) where C =
Expand All @@ -968,7 +970,7 @@ function convert_query(::C, ::Type{<:GlucQuery{C}}, d::ConjQuery{C}) where C
s = FreeCategory
p = Presentation(s)
add_generator!(p,Ob(s,Symbol("anon_ob")))
munit(Diagram{id}, TypeCat(ConjQuery{C}, Any), d;shape=FinCat(p))
munit(Diagram{id}, TypeCat(ConjQuery{C}, Any), d; shape=FinCat(p))
end
function convert_query(cat::C, ::Type{<:GlucQuery{C}}, d::GlueQuery{C}) where C
J = shape(d)
Expand All @@ -979,7 +981,7 @@ function convert_query(cat::C, ::Type{<:GlucQuery{C}}, d::GlueQuery{C}) where C
munit(Diagram{op}, cat, hom_map(d, h),
dom_shape=new_ob[dom(J,h)], codom_shape=new_ob[codom(J,h)])
end
Diagram{id}(FinDomFunctor(new_ob, new_hom, J))
Diagram{id}(FinDomFunctor(new_ob, new_hom, J, TypeCat(ConjQuery{C}, Any)))
end
function convert_query(cat::C, ::Type{<:GlucQuery{C}}, x::Ob) where
{Ob, C<:FinCat{Ob}}
Expand Down
11 changes: 6 additions & 5 deletions src/Migrations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ const GlueSchemaMigration{D<:FinCat,C<:FinCat} =
const GlucSchemaMigration{D<:FinCat,C<:FinCat} =
ContravariantMigration{<:FinDomFunctor{D,<:TypeCat{<:GlucQuery{C}}}}


# Contravariant migration
# Contravariant migration
#########################

function migrate(X::FinDomFunctor,M::ComplexDeltaMigration)
F = functor(M)
tgt_schema = dom(F)
Expand Down Expand Up @@ -360,12 +360,12 @@ function get_src_schema(F::Functor{<:Cat,<:TypeCat{<:Diagram}})
get_src_schema(diagram(ob_map(F,obs[1])))
end
get_src_schema(F::Functor{<:Cat,<:FinCat}) = codom(F)
#what the hell happened to the indentation

# Conjunctive migration
#----------------------

function migrate(X::FinDomFunctor, M::ConjSchemaMigration;
return_limits::Bool=false, tabular::Bool=false)
return_limits::Bool=false, tabular::Bool=false)
F = functor(M)
tgt_schema = dom(F)
homs = hom_generators(get_src_schema(F))
Expand Down Expand Up @@ -413,7 +413,8 @@ function migrate(X::FinDomFunctor, M::ConjSchemaMigration;
# Hand the Julia function form of the not-yet-defined components to compose
universal(compose(Ff, X, f_params), limits[c], limits[d])
end
Y = FinDomFunctor(mapvals(ob, limits), funcs, tgt_schema)
cod = isempty(limits) ? TypeCat(FinSet{Int}, FinDomFunction{Int}) : nothing
Y = FinDomFunctor(mapvals(ob, limits), funcs, tgt_schema, cod)
return_limits ? (Y, limits) : Y
end

Expand Down
9 changes: 8 additions & 1 deletion test/Migrations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ h′ = @acset Graph begin
end
@test h == h′

# Discrete graph on one vertex.
g = @migrate Graph set begin
V => @unit
E => @empty
end
@test g == Graph(1)

# Migrations with Code
######################

Expand Down Expand Up @@ -585,4 +592,4 @@ result = migrate(Split, data, M)
@test result == @acset Split begin end


end#module
end#module

0 comments on commit 3d0e938

Please sign in to comment.