Skip to content

Commit cf11736

Browse files
committed
implement goodMapping using hypergraphs
1 parent 7024751 commit cf11736

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed

src/Cartographer/GoodHypergraphCategory.idr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import Cartographer.Hypergraph as HG
1616
import Cartographer.HypergraphCategory
1717
import Cartographer.HypergraphStrictMonoidalCategory
1818

19+
%access public export
20+
1921
data GoodHypergraph : {s : Type} -> {ai, ao : s -> List o} -> (g : Hypergraph s ai ao k l) -> Type where
2022
Singleton : (edge : s) -> GoodHypergraph (singleton edge)
2123
Permutation : (p : Perm k l) -> GoodHypergraph (permutation p)

src/PetriGraph.idr

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import Basic.Category
55
import Basic.Functor
66
import Product.ProductCategory
77
import Permutations.Permutations
8+
import Permutations.SwapDown
89
import Cartographer.Hypergraph
10+
import Cartographer.GoodHypergraphCategory
911
import Cartographer.HypergraphStrictMonoidalCategory
1012
import MonoidalCategory.StrictMonoidalCategory
1113

@@ -79,26 +81,34 @@ Codomain m (Mor i) = snd $ index i m
7981
PetriPath : Nat -> Nat -> Type
8082
PetriPath places k = Tree (Fin places) (Fin k)
8183

82-
everything : (spec : PetriSpec k) -> (path : PetriPath (Places spec) k)
83-
-> Maybe (mor (cat (hypergraphSMC (Fin k)
84-
(\m => fst $ index m (Edges spec))
85-
(\m => snd $ index m (Edges spec))))
84+
goodMapping : (spec : PetriSpec k) -> (path : PetriPath (Places spec) k)
85+
-> Maybe (mor (cat (goodHypergraphSMC (Fin k)
86+
(\m => fst $ index m (Edges spec))
87+
(\m => snd $ index m (Edges spec))))
8688
(Domain (Edges spec) path)
8789
(Codomain (Edges spec) path))
88-
everything s (Tensor lt rt) = [| everything s lt `add` everything s rt |]
89-
everything s (Sequence lt rt) {k} = do
90-
lt' <- everything s lt
91-
rt' <- everything s rt
92-
case decEq (Domain (Edges s) rt) (Codomain (Edges s) lt) of
93-
Yes p => let rt'' = replace
94-
{P = (\newDom => Hypergraph (Fin k)
90+
goodMapping s (Tensor x y) = do
91+
x' <- goodMapping s x
92+
y' <- goodMapping s y
93+
pure $ Element (getWitness x' `add` getWitness y') (VComp (getProof x') (getProof y'))
94+
goodMapping s (Sequence x y) {k} = do
95+
x' <- goodMapping s x
96+
y' <- goodMapping s y
97+
case decEq (Domain (Edges s) y) (Codomain (Edges s) x) of
98+
Yes p => let y'' = replace
99+
{P = (\newDom => Subset (Hypergraph (Fin k)
95100
(\m => fst $ index m (Edges s))
96101
(\m => snd $ index m (Edges s))
97102
newDom
98-
(Codomain (Edges s) rt))
103+
(Codomain (Edges s) y))
104+
GoodHypergraph)
99105
}
100-
p rt' in pure (compose lt' rt'')
106+
p y'
107+
in pure $ Element (Hypergraph.compose (getWitness x') (getWitness y'')) (HComp (getProof x') (getProof y''))
101108
No _ => Nothing
102-
everything _ (Sym a b) = Just (permutation (swap [a] [b]))
103-
everything _ (Id o) = Just (Hypergraph.identity [o])
104-
everything _ (Mor m) = Just (Hypergraph.singleton m)
109+
110+
goodMapping s (Sym a b) = Just $ Element (permutation (swap [a] [b]))
111+
(GoodHypergraphCategory.Permutation (Ins (Ins Nil HereS) (ThereS HereS)))
112+
goodMapping s (Id x) = Just $ Element (Hypergraph.identity [x])
113+
(GoodHypergraphCategory.Permutation (Ins Nil HereS))
114+
goodMapping s (Mor x) = Just $ Element (Hypergraph.singleton x) (Singleton x)

0 commit comments

Comments
 (0)