Skip to content

Commit

Permalink
initial Set refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Kris Brown committed Oct 24, 2024
1 parent 764b4c0 commit 2e8b3d0
Show file tree
Hide file tree
Showing 42 changed files with 4,334 additions and 3,271 deletions.
5 changes: 1 addition & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "Catlab"
uuid = "134e5e36-593f-5add-ad60-77f754baafbe"
license = "MIT"
authors = ["Evan Patterson <[email protected]>"]
version = "0.16.18"
version = "0.17.1"

[deps]
ACSets = "227ef7b5-1206-438b-ac65-934d6da304b8"
Expand Down Expand Up @@ -37,12 +37,9 @@ SCS = "c946c3f1-0d1f-5ce8-9dea-7daa1f7e2d13"
TikzPictures = "37f6aa50-8035-52d0-81c2-5a1d08754b2d"

[extensions]
CatlabConvexExt = "Convex"
CatlabDataFramesExt = "DataFrames"
CatlabGraphsExt = "Graphs"
CatlabGraphvizExt = "Graphviz_jll"
CatlabMetaGraphsExt = "MetaGraphs"
CatlabSCSExt = "SCS"
CatlabTikzPicturesExt = "TikzPictures"

[compat]
Expand Down
12 changes: 6 additions & 6 deletions src/Catlab.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ include("theories/Theories.jl")
include("categorical_algebra/ACSetsGATsInterop.jl")
include("graphs/Graphs.jl")
include("categorical_algebra/CategoricalAlgebra.jl")
include("wiring_diagrams/WiringDiagrams.jl")
include("graphics/Graphics.jl")
include("programs/Programs.jl")
# include("wiring_diagrams/WiringDiagrams.jl")
# include("graphics/Graphics.jl")
# include("programs/Programs.jl")

@reexport using .Theories
@reexport using .Graphs
@reexport using .CategoricalAlgebra
@reexport using .WiringDiagrams
@reexport using .Graphics
@reexport using .Programs
# @reexport using .WiringDiagrams
# @reexport using .Graphics
# @reexport using .Programs

end
86 changes: 56 additions & 30 deletions src/categorical_algebra/CategoricalAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,71 @@ module CategoricalAlgebra

using Reexport

include("Categories.jl")
include("FinCats.jl")
include("FreeDiagrams.jl")
include("Limits.jl")
include("Subobjects.jl")
include("Sets.jl")
include("FinSets.jl")
include("Permutations.jl")
include("Matrices.jl")
include("FinRelations.jl")
include("Diagrams.jl")
include("CSets.jl")
include("HomSearch.jl")

include("Matrices.jl") # (no deps, not reexported)
include("Permutations.jl") # (no deps)
include("Categories.jl") # (no deps)
include("FreeDiagrams.jl") # FinCats


include("FinRelations.jl") # Matrices


include("Limits.jl") # FreeDiagrams


include("FinCats.jl") # Categories, FreeDiagrams
include("Subobjects.jl") # LimitsOld


include("Sets.jl") # Categories
include("SetFunctions.jl") # Sets
include("FinSets.jl") # Sets
include("FinFunctions.jl") # SetFunctions

include("SetCLimits.jl") #
include("FinCLimits.jl") # Limits

include("Subsets.jl") # Subobjects, FinSets



# include("Diagrams.jl") # Categories, Limits, FinCats, FinSets

# include("CSets.jl")

# include("HomSearch.jl")
include("GraphCategories.jl")
include("CommutativeDiagrams.jl")
include("CatElements.jl")
include("Chase.jl")
include("FunctorialDataMigrations.jl")
include("StructuredCospans.jl")
include("SliceCategories.jl")
# include("CommutativeDiagrams.jl")
# include("CatElements.jl")
# include("Chase.jl")
# include("FunctorialDataMigrations.jl")
# include("StructuredCospans.jl")
# include("SliceCategories.jl")

@reexport using .Permutations
@reexport using .Categories

@reexport using .FinCats
@reexport using .FreeDiagrams
@reexport using .Limits
@reexport using .Subobjects

@reexport using .Sets
@reexport using .SetFunctions
@reexport using .FinSets
@reexport using .Permutations
@reexport using .CSets
@reexport using .HomSearch
@reexport using .CatElements

@reexport using .Diagrams
@reexport using .CommutativeDiagrams
@reexport using .Chase
@reexport using .FunctorialDataMigrations
@reexport using .StructuredCospans
@reexport using .SliceCategories
@reexport using .FinFunctions
@reexport using .Subsets

# @reexport using .CSets
# @reexport using .HomSearch
# @reexport using .CatElements

# @reexport using .Diagrams
# @reexport using .CommutativeDiagrams
# @reexport using .Chase
# @reexport using .FunctorialDataMigrations
# @reexport using .StructuredCospans
# @reexport using .SliceCategories

end
40 changes: 40 additions & 0 deletions src/categorical_algebra/DiscreteCats.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
""" This depends on FinSets, so must come afterwards """
module DiscreteCats

export DiscreteCat

import ..Categories: ob, hom, dom, codom, compose, id, ob_map, hom_map

""" Discrete category on a finite set.
The only morphisms in a discrete category are the identities, which are here
identified with the objects.
"""
@struct_hash_equal struct DiscreteCat{Ob,Any} <: FinCat{Ob,Ob}
set::FinSet
end
DiscreteCat(n::Integer) = DiscreteCat(FinSet(n))

FinCat(s::Union{FinSet,Integer}) = DiscreteCat(s)

ob_generators(C::DiscreteCat) = C.set
hom_generators(::DiscreteCat) = ()
ob_generator(C::DiscreteCat, x) = x C.set ? x : error("$x$(C.set)")
ob_generator_name(C::DiscreteCat, x) = x
hom(C::DiscreteCat, x) = ob_generator(C, x)

is_discrete(::DiscreteCat) = true
graph(C::DiscreteCat{Int,FinSetInt}) = Graph(length(C.set))

dom(C::DiscreteCat{T}, f) where T = f::T
codom(C::DiscreteCat{T}, f) where T = f::T
id(C::DiscreteCat{T}, x) where T = x::T
compose(C::DiscreteCat{T}, f, g) where T = (f::T == g::T) ? f :
error("Nontrivial composite in discrete category: $f != $g")

hom_map(F::FinDomFunctor{<:DiscreteCat}, x) = id(codom(F), ob_map(F, x))

Base.show(io::IO, C::DiscreteCat{Int,FinSetInt}) =
print(io, "FinCat($(length(C.set)))")

end # module
Loading

0 comments on commit 2e8b3d0

Please sign in to comment.