-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kris Brown
committed
Oct 20, 2023
1 parent
5bbd879
commit d2cbdbd
Showing
29 changed files
with
643 additions
and
112 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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using DataStructures, StructEquality | ||
|
||
export PushoutInt | ||
|
||
using GATlab | ||
|
||
"""Data required to specify a pushout. No fancy caching.""" | ||
@struct_hash_equal struct PushoutInt | ||
ob::Int | ||
i1::Vector{Int} | ||
i2::Vector{Int} | ||
end | ||
|
||
using .ThPushout | ||
|
||
@instance ThPushout{Int, Vector{Int}, PushoutInt} [model::FinSetC] begin | ||
@import Ob, Hom, id, compose, dom, codom | ||
function pushout(sp::Span; context) | ||
B, C = context[:d], context[:c] | ||
d = DataStructures.IntDisjointSets(B+C) | ||
[union!(d, sp.left[a], sp.right[a]+B) for a in 1:sp.apex] | ||
roots = DataStructures.find_root!.(Ref(d), 1:length(d)) | ||
rootindex = sort(collect(Set(values(roots)))) | ||
toindex = [findfirst(==(r),rootindex) for r in roots] | ||
PushoutInt(DataStructures.num_groups(d), | ||
[toindex[roots[b]] for b in 1:B], | ||
[toindex[roots[c+B]] for c in 1:C] | ||
) | ||
end | ||
cospan(p::PushoutInt) = Cospan(p.ob, p.i1, p.i2) | ||
function universal(p::PushoutInt, csp::Cospan; context) | ||
map(1:p.ob) do i | ||
for (proj, csp_map) in [(p.i1, csp.left), (p.i2, csp.right)] | ||
for (j, i′) in enumerate(proj) | ||
if i′ == i return csp_map[j] end | ||
end | ||
end | ||
error("Pushout is jointly surjective") | ||
end | ||
end | ||
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,10 @@ | ||
module NonStdModels | ||
|
||
using ...Syntax | ||
using ...Models | ||
using ...Stdlib | ||
using ..NonStdTheories | ||
|
||
include("Pushouts.jl") | ||
|
||
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,15 @@ | ||
module NonStdlib | ||
|
||
using Reexport | ||
|
||
include("theories/module.jl") | ||
include("models/module.jl") | ||
# include("theorymaps/module.jl") | ||
# include("derivedmodels/module.jl") | ||
|
||
@reexport using .NonStdTheories | ||
@reexport using .NonStdModels | ||
# @reexport using .StdTheoryMaps | ||
# @reexport using .StdDerivedModels | ||
|
||
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,52 @@ | ||
""" | ||
A theory of a category with pushouts highlights two features of | ||
GATs which require syntactic sugar. The first is an operation | ||
with a (dependent) record type as its output. | ||
The second is the type of equality witnesses for any given | ||
AlgSort. This allows us to define functions which are only | ||
valid when certain *derived terms* from the arguments are | ||
equal. (E.g. when to apply universal property of a pushout). | ||
""" | ||
|
||
export ThPushout | ||
|
||
@theory ThSpanCospan <: ThCategory begin | ||
struct Span(dom::Ob, codom::Ob) | ||
apex::Ob | ||
left::(apex→dom) | ||
right::(apex→codom) | ||
end | ||
|
||
struct Cospan(dom::Ob, codom::Ob) | ||
apex::Ob | ||
left::(dom→apex) | ||
right::(codom→apex) | ||
end | ||
end | ||
|
||
"""A category with pushouts""" | ||
@theory ThPushout <: ThSpanCospan begin | ||
Pushout(s)::TYPE ⊣ [(d,c)::Ob, s::Span(d,c)] | ||
pushout(s)::Pushout(s) ⊣ [(d,c)::Ob, s::Span(d,c)] # compute representative | ||
cospan(p::Pushout(s))::Cospan(d,c) ⊣ [(d,c)::Ob, s::Span(d,c)] # extract result | ||
apex(p::Pushout(s)) := cospan(p).apex ⊣ [(d,c)::Ob, s::Span(d,c)] | ||
ι₁(p::Pushout(s)) := cospan(p).left ⊣ [(d,c)::Ob, s::Span(d,c)] | ||
ι₂(p::Pushout(s)) := cospan(p).right ⊣ [(d,c)::Ob, s::Span(d,c)] | ||
|
||
(pushout_commutes := (s.left)⋅ι₁(p) == (s.right)⋅ι₂(p) | ||
⊣ [(d,c)::Ob, s::Span(d,c), p::Pushout(s)]) | ||
|
||
(universal(p, csp, eq) :: (apex(p) → csp.apex) | ||
⊣ [(d,c)::Ob, sp::Span(d,c), csp::Cospan(d,c), p::Pushout(sp), | ||
eq::(sp.left⋅csp.left == sp.right⋅csp.right)]) | ||
|
||
((ι₁(p) ⋅ universal(p, csp, eq) == csp.left) | ||
⊣ [(d,c)::Ob, sp::Span(d,c), csp::Cospan(d,c), p::Pushout(sp), | ||
eq::(sp.left⋅csp.left == sp.right⋅csp.right)]) | ||
|
||
((ι₂(p) ⋅ universal(p, csp, eq) == csp.right) | ||
⊣ [(d,c)::Ob, sp::Span(d,c), csp::Cospan(d,c), p::Pushout(sp), | ||
eq::(sp.left⋅csp.left == sp.right⋅csp.right)]) | ||
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,10 @@ | ||
module NonStdTheories | ||
|
||
using ...Syntax | ||
using ...Stdlib | ||
|
||
using Reexport | ||
|
||
include("Pushouts.jl") | ||
|
||
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
Oops, something went wrong.