Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Petri and Catlab APIs #252

Merged
merged 3 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
julia-version: ['1.0', '1.3', '1.4']
julia-version: ['1.3', '1.4']
os: [ubuntu-latest]

steps:
Expand Down
6 changes: 5 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SemanticModels"
uuid = "f5ac2a72-33c7-5caf-b863-f02fefdcf428"
authors = ["James Fairbanks <[email protected]>", "Micah Halter <[email protected]>"]
version = "0.3.0"
version = "0.4.0"

[deps]
Catlab = "134e5e36-593f-5add-ad60-77f754baafbe"
Expand All @@ -10,6 +10,10 @@ MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
Petri = "4259d249-1051-49fa-8328-3f8ab9391c33"

[compat]
Catlab = "^0.7.0"
LightGraphs = "^1.3.3"
MacroTools = "^0.5.5"
Petri = "^1.0.0"
julia = "1.0"

[extras]
Expand Down
2 changes: 1 addition & 1 deletion src/CategoryTheory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
module CategoryTheory

using SemanticModels
import Catlab.Doctrines: dom, codom
import Catlab.Theories: dom, codom
import Base: append!, push!, deleteat!, delete!

export ⊔, AbstractMorph, FinSetMorph, dom, codom, verify, func, Decorated, decorations, undecorate, AbstractSpan, leftob, rightob, apexob, Span, left, right, DoublePushout, AbstractCospan, Cospan, pushout
Expand Down
4 changes: 2 additions & 2 deletions src/OpenPetris.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import SemanticModels.PetriModels: PetriModel
import SemanticModels.OpenModels: OpenModel
using ModelingToolkit
import ModelingToolkit: Constant
using Catlab.Doctrines
import Catlab.Doctrines: ⊗, compose, otimes
using Catlab.Theories
import Catlab.Theories: ⊗, compose, otimes

export OpenPetri, eye, ⊕

Expand Down
22 changes: 11 additions & 11 deletions src/PetriCospans.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module PetriCospans

using Catlab
using Catlab.Doctrines
using Catlab.Theories
using Catlab.WiringDiagrams
# using Catlab.Programs
import Base: (==), length, show
Expand All @@ -10,7 +10,7 @@ using ..PetriModels
using ..CategoryTheory
import ..CategoryTheory: undecorate, ⊔

import Catlab.Doctrines:
import Catlab.Theories:
Ob, Hom, dom, codom, compose, ⋅, ∘, id, oplus, otimes, ⊗, ⊕, munit, mzero, braid,
dagger, dunit, dcounit, mcopy, Δ, delete, ◊, mmerge, ∇, create, □,
plus, zero, coplus, cozero, meet, top, join, bottom
Expand All @@ -25,11 +25,11 @@ export Epidemiology, FreeEpidemiology, spontaneous, exposure, death,
death(A)::Hom(A, munit()) ⊣ A::Ob
end

spontaneous(A::Ports, B::Ports) = singleton_diagram(Epidemiology.Hom, Box(:→, A, B))
exposure(A::Ports, B::Ports, C::Ports) = singleton_diagram(Epidemiology.Hom, Box(:exposure, A⊗B, C⊗B))
death(A::Ports) = singleton_diagram(Epidemiology.Hom, Box(:𝗫, A, Ports([])))
mcopy(A::Ports{Epidemiology.Hom}, Symbol) = implicit_mcopy(A, 2)
mmerge(A::Ports{Epidemiology.Hom}, Symbol) = implicit_mmerge(A, 2)
spontaneous(A::Ports, B::Ports) = singleton_diagram(Box(:→, A, B))
exposure(A::Ports, B::Ports, C::Ports) = singleton_diagram(Box(:exposure, A⊗B, C⊗B))
death(A::Ports) = singleton_diagram(Box(:𝗫, A, Ports([])))
mcopy(A::Ports{Epidemiology}, Symbol) = implicit_mcopy(A, 2)
mmerge(A::Ports{Epidemiology}, Symbol) = implicit_mmerge(A, 2)


@syntax FreeEpidemiology(ObExpr, HomExpr) Epidemiology begin
Expand All @@ -41,8 +41,8 @@ mmerge(A::Ports{Epidemiology.Hom}, Symbol) = implicit_mmerge(A, 2)
copair(f::Hom, g::Hom) = (f ⊗ g) → ∇(codom(f))
proj1(A::Ob, B::Ob) = id(A) ⊗ ◊(B)
proj2(A::Ob, B::Ob) = ◊(A) ⊗ id(B)
incl1(A::Ob, B::Ob) = id(A) ⊗ □(B)
incl2(A::Ob, B::Ob) = □(A) ⊗ id(B)
coproj1(A::Ob, B::Ob) = id(A) ⊗ □(B)
coproj2(A::Ob, B::Ob) = □(A) ⊗ id(B)
otimes(A::Ob, B::Ob) = associate_unit(new(A,B), munit)
otimes(f::Hom, g::Hom) = associate(new(f,g))
end
Expand Down Expand Up @@ -221,8 +221,8 @@ end
proj1(A::FinSet,B::FinSet) = otimes(id(A), delete(B))
proj2(A::FinSet,B::FinSet) = otimes(delete(A), id(B))

incl1(A::FinSet,B::FinSet) = otimes(id(A), create(B))
incl2(A::FinSet,B::FinSet) = otimes(create(A), id(B))
coproj1(A::FinSet,B::FinSet) = otimes(id(A), create(B))
coproj2(A::FinSet,B::FinSet) = otimes(create(A), id(B))

spontaneous(A::FinSet, B::FinSet) = begin
M, N = length(A), length(B)
Expand Down
4 changes: 2 additions & 2 deletions src/RelOlogModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module RelOlogModels
using Catlab
using Catlab.Syntax
using Catlab.WiringDiagrams
using Catlab.Doctrines
import Catlab.Doctrines.⊗
using Catlab.Theories
import Catlab.Theories.⊗

using SemanticModels
import SemanticModels: model
Expand Down
2 changes: 1 addition & 1 deletion src/WiringDiagrams.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module WiringDiagrams

using Catlab.WiringDiagrams
using Catlab.Doctrines
using Catlab.Theories
using Catlab.Graphics
using Catlab.Graphics.Graphviz
using MacroTools
Expand Down
6 changes: 3 additions & 3 deletions test/epidemics.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module TestEpidemics
using Catlab
using Catlab.Doctrines
using Catlab.Theories
using Catlab.Graphics
using Catlab.WiringDiagrams
using Catlab.Programs
Expand All @@ -18,7 +18,7 @@ import SemanticModels.PetriCospans: otimes_ipm, compose_pushout

println("Done Importing SemanticModels")

import Catlab.Doctrines:
import Catlab.Theories:
Ob, Hom, dom, codom, compose, ⋅, ∘, id, oplus, otimes, ⊗, ⊕, munit, mzero, braid,
dagger, dunit, dcounit, mcopy, Δ, delete, ◊, mmerge, ∇, create, □,
plus, zero, coplus, cozero, meet, top, join, bottom
Expand Down Expand Up @@ -199,7 +199,7 @@ Pseird = PetriModel(
([3],[2]), # onset
([2],[4]), # recovery
([2],[5]), # death
], missing, missing))
]))
inputs = FinSetMorph(1:5, [1,2,3])
outputs = FinSetMorph(1:5, [1,2,3])
Fcityd = PetriCospan(Cospan(Decorated(inputs, Pseird),
Expand Down
6 changes: 3 additions & 3 deletions test/petricospans.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module TestPetriCospans

using Catlab
using Catlab.Doctrines
using Catlab.Theories
using Catlab.WiringDiagrams
using Catlab.Programs
import Base.Multimedia: display
Expand All @@ -14,7 +14,7 @@ using SemanticModels.PetriModels
using SemanticModels.PetriCospans
import SemanticModels.PetriCospans: otimes_ipm, compose_pushout

import Catlab.Doctrines:
import Catlab.Theories:
Ob, Hom, dom, codom, compose, ⋅, ∘, id, oplus, otimes, ⊗, ⊕, munit, mzero, braid,
dagger, dunit, dcounit, mcopy, Δ, delete, ◊, mmerge, ∇, create, □,
plus, zero, coplus, cozero, meet, top, join, bottom
Expand All @@ -28,7 +28,7 @@ Cospan(f,g), Cospan(f′, g′)
pushout(Span(g,f′))


spon = PetriModel(Petri.Model([1,2], [([1], [2])], missing, missing))
spon = PetriModel(Petri.Model([1,2], [([1], [2])]))
f = Decorated(FinSetMorph(1:2, [2]), [spon])
g = Decorated(FinSetMorph(1:2, [1]), [spon])
s = Span(g,f)
Expand Down