Skip to content

Commit

Permalink
subobjects of varacsets, removing directory numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
Kris Brown committed Jan 23, 2025
1 parent 69f163b commit 18846b6
Show file tree
Hide file tree
Showing 194 changed files with 281 additions and 226 deletions.
15 changes: 0 additions & 15 deletions src/03_basic_sets/module.jl

This file was deleted.

44 changes: 0 additions & 44 deletions src/04_categorical_algebra/01_cats/module.jl

This file was deleted.

36 changes: 0 additions & 36 deletions src/04_categorical_algebra/03_pointwise/module.jl

This file was deleted.

18 changes: 0 additions & 18 deletions src/04_categorical_algebra/module.jl

This file was deleted.

8 changes: 4 additions & 4 deletions src/Catlab.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ module Catlab

using Reexport

include("01_theories/module.jl")
include("theories/module.jl")
include("ACSetsGATsInterop.jl") # depends on Theories but is not a theory
include("02_graphs/Graphs.jl")
include("03_basic_sets/module.jl")
include("04_categorical_algebra/module.jl")
include("graphs/Graphs.jl")
include("basic_sets/module.jl")
include("categorical_algebra/module.jl")
include("wiring_diagrams/WiringDiagrams.jl")
include("graphics/Graphics.jl")
include("programs/Programs.jl")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions src/basic_sets/module.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module BasicSets

using Reexport

include("sets/module.jl")
@reexport using .Sets

include("finsets/module.jl")
@reexport using .FinSets

include("setfunctions/module.jl")
@reexport using .SetFunctions

include("finfunctions/module.jl")
@reexport using .FinFunctions

end # module
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
44 changes: 44 additions & 0 deletions src/categorical_algebra/cats/module.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module Cats

using Reexport

include("paths/Paths.jl") # [DEPS]
@reexport using .Paths

include("categories/module.jl") #
@reexport using .Categories

include("fincats/module.jl") # 2
@reexport using .FinCats

include("functors/module.jl") # 2
@reexport using .Functors

include("freediagrams/module.jl") # 3
@reexport using .FreeDiagrams

include("finfunctors/module.jl") # 2, 5
@reexport using .FinFunctors

include("cat_of_cat/CatOfCat.jl") # 2
@reexport using .CatOfCat

include("natural_transformations/module.jl")
@reexport using .Transformations

include("limits_colimits/module.jl") # 4,5
@reexport using .LimitsColimits

include("commutative_diagrams/CommutativeDiagrams.jl")
@reexport using .CommutativeDiagrams

include("diagrams/module.jl") # 5
@reexport using .Diagrams

include("slice/module.jl")
@reexport using .SliceCategories

include("subobjects/Subobjects.jl") # Limits
@reexport using .Subobjects

end # module
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions src/categorical_algebra/module.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module CategoricalAlgebra

using Reexport

include("cats/module.jl")
@reexport using .Cats

include("setcats/module.jl") # depends on Cats
@reexport using .SetCats

include("pointwise/module.jl") # depends on Cats, SetCats
@reexport using .Pointwise

include("misc/module.jl") # doesn't depend on the other three

@reexport using .Misc

end # module
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,9 @@ end

# WARNING that this means :cat is a reserved name for schema entities.
"""Move components as first argument"""
ACSetTransformation(X::ACSet, Y::ACSet; cat=nothing, components...) =
function ACSetTransformation(X::ACSet, Y::ACSet; cat=nothing, components...)
ACSetTransformation((; components...), X, Y; cat)

# ACSetTransformation(components, X::StructACSet{S}, Y::StructACSet{S}) where {S} =
# _ACSetTransformation(Val{S},components,X,Y,Val{true})

# ACSetTransformation(components, X::DynamicACSet, Y::DynamicACSet) =
# runtime(_ACSetTransformation, X.schema, components, X,Y,false)
end

function _ACSetTransformation(components, X::StructACSet{S}, Y::StructACSet{S}
) where S
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,13 @@ FinDomFunctor(acs::ACSet; cat=nothing) =
###########################################


# Set-valued FinDomFunctors as ACSets.
""" Set-valued FinDomFunctors as ACSets. """
function (::Type{ACS})(F::FinDomFunctor) where ACS <: ACSet
getvalue(F) isa ACSetFunctor && return getvalue(F).acset
X = if ACS isa UnionAll
pres = presentation(dom(F))
ACS{(strip_attrvars(eltype(ob_map(F, c))) for c in generators(pres, :AttrType))...}()
else
ACS()
end
X = ACS()
copy_parts!(X, F)
return X
end
strip_attrvars(T) = T
strip_attrvars(::Type{Union{AttrVar, T}}) where T = T

""" Copy parts from a set-valued `FinDomFunctor` to an `ACSet`.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ struct BacktrackingState{
predicates::Predicates
image::Image # Negative of image for epic components or if finding an epimorphism
unassigned::Unassign # "# of unassigned elems in domain of a component
cat::ACSetCategory
end

function backtracking_search(f, X::ACSet, Y::ACSet;
Expand Down Expand Up @@ -299,7 +300,7 @@ function backtracking_search(f, X::ACSet, Y::ACSet;

state = BacktrackingState(assignment, assignment_depth,
inv_assignment, X, Y, loosefuns, pred_nt,
images, unassigned)
images, unassigned, cat)

# Make any initial assignments, failing immediately if inconsistent.
for (c, c_assignments) in pairs(initial)
Expand Down Expand Up @@ -341,7 +342,7 @@ function backtracking_search(f, state::BacktrackingState, depth::Int;
state.assignment, state.type_components, state.dom, state.codom)])
else
m = Dict(k=>!isnothing(v) for (k,v) in pairs(state.inv_assignment))
return f(postprocess_search_results(state.dom, state.codom, state.assignment, m))
return f(postprocess_search_results(state.dom, state.codom, state.assignment, m; cat=state.cat))
end
elseif mrv == 0
# An element has no allowable assignment, so we must backtrack.
Expand Down Expand Up @@ -522,7 +523,7 @@ representables.
This function takes a result assignment from backtracking search and returns an
iterator of the implicit set of homomorphisms that it specifies.
"""
function postprocess_search_results(dom, codom, assgn, monic)
function postprocess_search_results(dom, codom, assgn, monic; cat)
S = acset_schema(dom)
od = Dict{Symbol,Vector{Int}}(k=>(assgn[k]) for k in objects(S))

Expand All @@ -547,7 +548,7 @@ function postprocess_search_results(dom, codom, assgn, monic)
k => vec
end)
comps = merge(NamedTuple(od),NamedTuple(ad))
ACSetTransformation(comps, dom, codom)
ACSetTransformation(comps, dom, codom; cat)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ end

"""This would be much more efficient with canonical isomorph"""
function is_seen(cat, S::SubobjectIteratorState, f::ACSetTransformation)
for h in S.seen
if any-> force(compose[cat](σ,h); cat) == force(f; cat),
isomorphisms(dom(f),dom(h)))
return true
for h in S.seen
for σ in isomorphisms(dom(f),dom(h); cat)
σ = force(σ; cat) # TODO this should be done automatically in homsearch
force(compose[cat](σ,h); cat) == force(f; cat) && return true
end
end
return false
Expand Down Expand Up @@ -261,8 +261,8 @@ these are all returned.
If there are attributes, we ignore these and use variables in the apex of the
overlap.
"""
function maximum_common_subobject(Xs::Vector{T}; abstract=true) where T <: ACSet
it = partial_overlaps(Xs; abstract)
function maximum_common_subobject(Xs::Vector{T}; abstract=true, kw...) where T <: ACSet
it = partial_overlaps(Xs; abstract, kw...)
osize = -1
res = DefaultDict(()->[])
for overlap in it
Expand All @@ -275,7 +275,7 @@ function maximum_common_subobject(Xs::Vector{T}; abstract=true) where T <: ACSet
return res
end

maximum_common_subobject(Xs::T...; abstract=true) where T <: ACSet =
maximum_common_subobject(collect(Xs); abstract)
maximum_common_subobject(Xs::ACSet...; abstract=true, kw...) =
maximum_common_subobject(collect(Xs); abstract, kw...)

end # module
34 changes: 34 additions & 0 deletions src/categorical_algebra/pointwise/module.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module Pointwise
using Reexport

include("acsettransformations/ACSetTransformations.jl")
@reexport using .ACSetTransformations

include("csets/module.jl")
@reexport using .CSets

include("pointwisecats/module.jl")
@reexport using .PointwiseCats

include("limits_colimits/module.jl")
@reexport using .LimitsColimits

include("homsearch/module.jl")
@reexport using .HomSearch

include("catelements/CatElements.jl")
@reexport using .CatElements

include("subcsets/SubCSets.jl")
@reexport using .SubCSets

include("chase/Chase.jl")
@reexport using .Chase

include("datamigrations/module.jl")
@reexport using .FunctorialDataMigrations

include("structured_cospans/StructuredCospans.jl")
@reexport using .StructuredCospans

end # module
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ using ...CSets

function compose(f::ACSetTransformation, g::ACSetTransformation)
S = acset_schema(model)
f, g = coerce(f; cat=model), coerce(g; cat=model) # we shouldn't have to do this
𝒞, 𝒟 = Category(entity_cat(model)), t->Category(attr_cat(model,t))
ecomps = Dict(o => compose(𝒞, f[o], g[o]) for o in ob(S))
acomps = Dict(o => compose(𝒟(o), f[o], g[o]) for o in attrtypes(S))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ function infer_acset_cat(X::ACSet)::ACSetCategory
return ACSetCategory(cat(X))
end


function hasvar(X::ACSet,x)
function hasvar(X::ACSet, x)
s = acset_schema(X)
(x attrs(acset_schema(X),just_names=true) && hasvar(X,codom(s,x))) ||
xattrtypes(acset_schema(X)) && nparts(X,x)>0
end

hasvar(X::ACSet) = any(o->hasvar(X,o), attrtypes(acset_schema(X)))

function ACSetTransformation(comps, dom::ACSet, codom::ACSet;
Expand Down
Loading

0 comments on commit 18846b6

Please sign in to comment.