-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from AlgebraicJulia/aw/docs
Initial documentation
- Loading branch information
Showing
11 changed files
with
207 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Library Reference | ||
|
||
```@autodocs | ||
Modules = [StructuredDecompositions, StructuredDecompositions.Decompositions, StructuredDecompositions.FunctorUtils, StructuredDecompositions.DecidingSheaves] | ||
Modules = [StructuredDecompositions, StructuredDecompositions.Decompositions, StructuredDecompositions.FunctorUtils, StructuredDecompositions.DecidingSheaves, StructuredDecompositions.JunctionTrees, StructuredDecompositions.NestedUWDs] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# [Deciding Sheaves] (@id DecidingSheaves) | ||
|
||
There are two functions that are used here. | ||
|
||
The first one called adhesion_filter will take an input Finset^{op}-valued structured decomposition and return a new structured decompostion replacing the span de in d by the span obtained by projecting the pullback of de. | ||
|
||
```julia | ||
function adhesion_filter(tup::Tuple, d::StructuredDecomposition) | ||
``` | ||
|
||
The second function is called decide_sheaf_tree_shape and solves a decision problem that is encoded by a sheaf. This function works by computing first on each of the bags, then computes composites on edges and projects back down to bags. | ||
|
||
```julia | ||
function decide_sheaf_tree_shape(f, d::StructuredDecomposition, solution_space_decomp::StructuredDecomposition = 𝐃(f, d, CoDecomposition)) | ||
``` | ||
|
||
## Graph Coloring Structure and Examples | ||
|
||
One of the many decision problems that can be solved using this system of functions is figuring out graph colorings. To put it simply, a graph coloring is an assignment of labels(colors) to each vertex of a graph so that no two adjacent vertices have the same label(color). | ||
|
||
We first define the structure of a coloring. | ||
|
||
```julia | ||
#an H-coloring is a hom onto H | ||
struct Coloring | ||
n #the target graph | ||
func #the function mapping opens to lists of homs from G to K_n | ||
end | ||
``` | ||
|
||
We then define how we are going to create and test colorings. | ||
|
||
```julia | ||
#construct an n-coloring | ||
K(n) = complete_graph(Graph, n) | ||
Coloring(n) = Coloring(n, g -> homomorphisms(g, K(n) )) | ||
#make it callable | ||
(c::Coloring)(X::Graph) = FinSet(c.func(X)) # given graph homos #f: G₁ → G₂ get morphism col(G₂) → col(G₁) by precomposition: take each λ₂ ∈ col(G₂) to hf ∈ col(G) | ||
function (c::Coloring)(f::ACSetTransformation) | ||
(G₁, G₂) = (dom(f), codom(f)) | ||
(cG₁, cG₂) = (c(G₁), c(G₂)) | ||
FinFunction( λ₂ -> compose(f,λ₂), cG₂, cG₁ ) #note the contravariance | ||
end | ||
|
||
skeletalColoring(n) = skeleton ∘ Coloring(n) | ||
|
||
colorability_test(n, the_test_case) = is_homomorphic(ob(colimit(the_test_case)), K(n)) == decide_sheaf_tree_shape(skeletalColoring(n), the_test_case)[1] | ||
``` | ||
|
||
We can consider the example of a ring with seven nodes as our graph. | ||
We first seperate the nodes into bags with adhesions and what our adhesions look like. | ||
|
||
```julia | ||
#bag 1 | ||
H₁ = @acset Graph begin | ||
V = 3 | ||
E = 2 | ||
src = [1, 2] | ||
tgt = [2, 3] | ||
end | ||
|
||
#adhesion 1,2 | ||
H₁₂ = @acset Graph begin | ||
V = 2 | ||
end | ||
|
||
#bag 2 | ||
H₂ = @acset Graph begin | ||
V = 4 | ||
E = 3 | ||
src = [1, 2, 3] | ||
tgt = [2, 3, 4] | ||
end | ||
|
||
Gₛ = @acset Graph begin | ||
V = 2 | ||
E = 1 | ||
src = [1] | ||
tgt = [2] | ||
end | ||
``` | ||
|
||
We can then construct our structured decomposition through transformations of these bags and adhesions. | ||
|
||
```julia | ||
#transformations | ||
Γₛ⁰ = Dict(1 => H₁, 2 => H₂, 3 => H₁₂) | ||
Γₛ = FinDomFunctor( | ||
Γₛ⁰, | ||
Dict( | ||
1 => ACSetTransformation(Γₛ⁰[3], Γₛ⁰[1], V=[1, 3]), | ||
2 => ACSetTransformation(Γₛ⁰[3], Γₛ⁰[2], V=[4, 1]), | ||
), | ||
∫(Gₛ) | ||
) | ||
|
||
my_decomp1 = StrDecomp(Gₛ, Γₛ) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# [Decompositions] (@id Decompositions) | ||
|
||
Structured decompositions are diagrams. They can be thought of as graphs whose vertices are labeled by the objects of some category and whose edges are labeld by spans in this category. | ||
|
||
```julia | ||
abstract type StructuredDecomposition{G, C, D} <: Diagram{id, C, D} end | ||
|
||
struct StrDecomp{G, C, D} <: StructuredDecomposition{G, C, D} | ||
decomp_shape ::G | ||
diagram ::D | ||
decomp_type ::DecompType | ||
domain ::C | ||
end | ||
``` | ||
|
||
A structured decomposition can be constructed by providing the graph representing the shap of the decomposition and the relevant diagram. The default constructor will set the decomposition type to Decomposition (viewing C-valued structured decompositions as diagrams into Span C). | ||
|
||
```julia | ||
StrDecomp(the_decomp_shape, the_diagram)=StrDecomp(the_decomp_shape, the_diagram, Decomposition) | ||
``` | ||
|
||
The function StrDecomp will construct a structured decomposition and check whether the decomposition shape makes sense. | ||
|
||
```julia | ||
StrDecomp(the_decomp_shape, the_diagram, the_decomp_type) | ||
``` | ||
|
||
The functions colimit and limit when called on a structured decomposition will take the colimit and limit of the diagram, respectively. | ||
|
||
```julia | ||
function colimit(d::StructuredDecomposition) colimit(FreeDiagram(d.diagram)) end | ||
function limit(d::StructuredDecomposition) limit(FreeDiagram(d.diagram)) end | ||
``` | ||
|
||
The construction of categories of structured decompositions consists of a functor 𝐃:Cat_{pullback} → Cat taking any category C to the category 𝐃C of C-valued structured decompositions. This allows the lifting of any functor F: C → E to a functor 𝐃f : 𝐃C → 𝐃E which maps C-valued structured decompositions to E-valued structured decompostions. | ||
|
||
```julia | ||
function 𝐃(f, d ::StructuredDecomposition, t::DecompType = d.decomp_type)::StructuredDecomposition | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# [Functor Utils] (@id FunctorUtils) | ||
|
||
Functor Utils only includes 4 functions and builds off of Decompositions. | ||
|
||
We first define the forgetful functors vs. | ||
|
||
```julia | ||
function vs(X::Graph) FinSet(length(vertices(X))) end | ||
function vs(f::ACSetTransformation) components(f)[1] end | ||
``` | ||
|
||
We also define the functor skeleton taking set to the skeleton of the set. | ||
|
||
```julia | ||
function skeleton(s::FinSet) FinSet(length(s)) end | ||
function skeleton(f::FinFunction) | ||
(dd, cc) = (dom(f), codom(f)) | ||
ℓ = isempty(dd) ? Int[] : [findfirst(item -> item == f(x), collect(cc)) for x ∈ collect(dd)] | ||
FinFunction(ℓ, skeleton(dd), skeleton(cc)) | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# [Junction Trees] (@id JunctionTrees) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# [Nested UWDs] (@id NestedUWDs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters