Skip to content

Commit 61dbfac

Browse files
author
Ioana
committed
today
1 parent 949132b commit 61dbfac

File tree

9 files changed

+219
-113
lines changed

9 files changed

+219
-113
lines changed

ast.ml

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,40 @@ type t = INIT of mixture
2626
| OBS of string*mixture
2727
| RULE of string*rule
2828

29+
let print_link = function
30+
| LNK_VALUE i -> Format.printf "!%d" i
31+
| FREE -> Format.printf "free"
32+
| LNK_ANY -> Format.printf "!_"
33+
| LNK_SOME -> Format.printf "!_"
34+
| LNK_TYPE (i,a) -> Format.printf "!%s.%s" i a
35+
36+
let print_port p =
37+
Format.printf "%s~[" p.port_nme;
38+
List.iter (fun intern -> Format.printf "%s " intern;) p.port_int;
39+
Format.printf "]";
40+
List.iter (fun p -> print_link p) p.port_lnk
41+
42+
let print_agent (name,plist) =
43+
Format.printf "%s(" name;
44+
List.iter (fun p -> print_port p) plist;
45+
Format.printf ") "
46+
47+
let print_rule r =
48+
List.iter (fun a -> print_agent a) r.lhs;
49+
if (r.bidirectional) then Format.printf " <-> "
50+
else Format.printf " -> ";
51+
List.iter (fun a -> print_agent a) r.rhs
52+
53+
let print = function
54+
| INIT mix -> Format.printf "\n init "; List.iter (fun a -> print_agent a) mix
55+
| OBS (name,mix) -> Format.printf "\n obs '%s' " name;
56+
List.iter (fun a -> print_agent a) mix
57+
| RULE (name,r) -> Format.printf "\n rule '%s' " name; print_rule r
58+
59+
let empty_rule = {lhs =[];rhs=[];bidirectional=false;}
60+
let empty = RULE ("empty",empty_rule)
61+
62+
2963
let add_free_to_port_lnk plinks = match plinks with
3064
| [] -> [FREE]
3165
| ls -> ls
@@ -71,15 +105,15 @@ let create_rhs_quarks agent_names mixture =
71105
let rec aux qs mixt count ag_nm =
72106
match mixt with
73107
| (name,plist)::mixt' ->
74-
if (List.mem (count,name) ag_nm) then
108+
if (((List.length ag_nm) >0)&&(List.mem (count,name) ag_nm)) then
75109
let qs' =
76110
List.fold_left
77111
(fun acc port -> (split_ports_quarks count port)@acc) [] plist in
78112
aux (qs'@qs) mixt' (count+1) ag_nm
79113
else
80-
let (qs',ag_nm',_) = create_quarks mixt' (List.length ag_nm) in
114+
let (qs',ag_nm',_) = create_quarks mixt (List.length ag_nm) in
81115
(qs'@qs, ag_nm'@ag_nm)
82-
| [] -> (qs, []) in
116+
| [] -> (qs, ag_nm) in
83117
aux [] mixture 0 agent_names
84118

85119
let match_il il il' = match (il,il') with
@@ -107,7 +141,7 @@ let partition_quarks lhs_quarks rhs_quarks =
107141
with _ ->
108142
(raise
109143
(ExceptionDefn.Syntax_Error
110-
("agent does not have the same ports in lhs and rhs")))) in
144+
("agent does not have the same ports in lhs and rhs1"))))in
111145
let new_quark = Rule.TestedMod ((n,p,il),(n',p',il')) in
112146
(new_quark::qlist',(remove_quark (n,p,il) rhs')))
113147
([],rhs_quarks) lhs_quarks in
@@ -119,22 +153,25 @@ let partition_quarks lhs_quarks rhs_quarks =
119153
(raise
120154
(ExceptionDefn.Syntax_Error
121155
("agent does not have the same ports
122-
in lhs and rhs")))) qlist in
156+
in lhs and rhs2")))) qlist in
123157
Rule.Modified q) rhs in
124158
(modified@qlist)
125159

126160
let create_prefix_map lhs rhs =
127161
let (lhs_quarks,lhs_agent_nm,_) = create_quarks lhs 0 in
128162
let (rhs_quarks,rhs_agent_nm) = create_rhs_quarks lhs_agent_nm rhs in
163+
let () = Format.printf "rhs_agent = ";
164+
List.iter (fun (c,n) -> Format.printf "(%d,%s) " c n) rhs_agent_nm in
129165
(partition_quarks lhs_quarks rhs_quarks,rhs_agent_nm)
130166

131167
let clean_rule = function
132168
| INIT mix ->
133-
let (quarks,agent_names) = create_prefix_map (add_free_to_mix mix) [] in
169+
let (quarks,agent_names) = create_prefix_map [] (add_free_to_mix mix) in
134170
let label = List.fold_left (fun acc (nme,_) -> acc^nme) "" mix in
135171
Rule.INIT (label,quarks,agent_names)
136172
| OBS (name,mix) ->
137-
let (quarks,agent_names) = create_prefix_map [] (add_free_to_mix mix) in
173+
let mix' = add_free_to_mix mix in
174+
let (quarks,agent_names) = create_prefix_map mix' mix' in
138175
Rule.OBS (name,quarks,agent_names)
139176
| RULE (name,r) ->
140177
let () = if (r.bidirectional) then
@@ -144,36 +181,3 @@ let clean_rule = function
144181
let rhs = add_free_to_mix r.rhs in
145182
let (quarks,agent_names) = create_prefix_map lhs rhs in
146183
Rule.RULE (name,quarks,agent_names)
147-
148-
let print_link = function
149-
| LNK_VALUE i -> Format.printf "!%d" i
150-
| FREE -> Format.printf "free"
151-
| LNK_ANY -> Format.printf "!_"
152-
| LNK_SOME -> Format.printf "!_"
153-
| LNK_TYPE (i,a) -> Format.printf "!%s.%s" i a
154-
155-
let print_port p =
156-
Format.printf "%s~[" p.port_nme;
157-
List.iter (fun intern -> Format.printf "%s " intern;) p.port_int;
158-
Format.printf "]";
159-
List.iter (fun p -> print_link p) p.port_lnk
160-
161-
let print_agent (name,plist) =
162-
Format.printf "%s(" name;
163-
List.iter (fun p -> print_port p) plist;
164-
Format.printf ") "
165-
166-
let print_rule r =
167-
List.iter (fun a -> print_agent a) r.lhs;
168-
if (r.bidirectional) then Format.printf " <-> "
169-
else Format.printf " -> ";
170-
List.iter (fun a -> print_agent a) r.rhs
171-
172-
let print = function
173-
| INIT mix -> Format.printf "\n init "; List.iter (fun a -> print_agent a) mix
174-
| OBS (name,mix) -> Format.printf "\n obs '%s' " name;
175-
List.iter (fun a -> print_agent a) mix
176-
| RULE (name,r) -> Format.printf "\n rule '%s' " name; print_rule r
177-
178-
let empty_rule = {lhs =[];rhs=[];bidirectional=false;}
179-
let empty = RULE ("empty",empty_rule)

event.ml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,24 @@ let nodes_of_json (node:Yojson.Basic.json) =
2222
match node with
2323
| `List [`Int id; `String "RULE"; `String label;
2424
(`Assoc ["quarks", `List l]) ]
25-
| `List [`Int id; `String "OBS"; `String label;
26-
(`Assoc ["quarks", `List l])]
2725
| `List [`Int id; `String "PERT"; `String label;
2826
(`Assoc ["quarks", `List l])]->
2927
let quarks_ls =
3028
List.map (fun q -> Quark.quarks_of_json q) l in
31-
{ event_id = id; event_label = label; quarks = quarks_ls; }
29+
let clean_quarks =
30+
List.filter (fun q -> Quark.positive_site q) quarks_ls in
31+
{ event_id = id; event_label = label; quarks = clean_quarks; }
32+
| `List [`Int id; `String "OBS"; `String label;
33+
(`Assoc ["quarks", `List l])] ->
34+
let quarks_ls =
35+
List.map (fun q -> Quark.quarks_of_json q) l in
36+
let clean_quarks =
37+
List.filter (fun q -> Quark.positive_site q) quarks_ls in
38+
let () = if ((Quark.exists_mod clean_quarks [0;1])
39+
&&(Quark.exists_testmod clean_quarks [0;1])) then
40+
(raise (ExceptionDefn.NotKappa_Poset
41+
("quarks of init event not valid"))) in
42+
{ event_id = id; event_label = label; quarks = clean_quarks; }
3243
| `List [`Int id; `String "INIT"; `List l;
3344
(`Assoc ["quarks", `List ql])] ->
3445
let init_label =
@@ -40,5 +51,11 @@ let nodes_of_json (node:Yojson.Basic.json) =
4051
("Not in the cflow format",x))) "" l in
4152
let quarks_ls =
4253
List.map (fun q -> Quark.quarks_of_json q) ql in
43-
{ event_id = id; event_label = init_label; quarks = quarks_ls; }
54+
let clean_quarks =
55+
List.filter (fun q -> Quark.positive_site q) quarks_ls in
56+
let () = if ((Quark.exists_test clean_quarks [0;1])
57+
&&(Quark.exists_testmod clean_quarks [0;1])) then
58+
(raise (ExceptionDefn.NotKappa_Poset
59+
("quarks of init event not valid"))) in
60+
{ event_id = id; event_label = init_label; quarks = clean_quarks; }
4461
| _ -> raise (Yojson.Basic.Util.Type_error ("Not in the cflow format",`Null))

notes/app_concret.tex

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
\subsection{The concretisation function}
22
\label{sec:app_concret}
33

4-
Let $s = (E,\seq,\cover,\prec,\dashv,\labl)$ be a linear extension of an augmented poset.
4+
Let $s = (E,\seq,\prec,\dashv,\labl)$ be a linear extension of an augmented poset.
55
In the algorithm proposed on~\autoref{sec:concret} we change~\autoref{eq:refine} so that instead of computing a new decoration for each new poset $s_2$ (\autoref{eq:dec}), we use the existing decoration $(s_1)^{\star}$ of $s_1$ and only refine the trace w.r.t. to the decorations for the new event $e$ added to the trace.
66

77
Also we change the interpretation of the refinement function $\mathtt{Ref}$: instead of a bijection between events and transitions in $\theta$, we use a bijection between events and transitions positions in $\theta$ (\autoref{eq:ith_trans}). The update of $\mathtt{Ref}_1$ to $\mathtt{Ref}_2$ is then straightforward.
@@ -11,8 +11,8 @@ \subsection{The concretisation function}
1111
&\quad\text{if }(E_s\setminus E_{s_1} = \emptyset)\text{ then return }\mathit{concretisations}_1\\
1212
&\quad e = \text{min}_{\sqsubset}(E_s\setminus E_{s_1})\\
1313
&\quad\mathit{concretisations}_2 = \emptyset \\
14-
&\quad\text{for each }(\theta_1,\mathtt{Ref}_1)\text{ in }\mathit{concretisations}_1\\
15-
&\quad\qquad s_2 = s\setminus\{s_1\cup\{e\}\}\\
14+
&\quad\text{for each }(s_1,\theta_1,\mathtt{Ref}_1)\text{ in }\mathit{concretisations}_1\\
15+
&\quad\qquad s_2 = s_{\{s_1\cup\{e\}\}}\\
1616
\label{eq:dec}
1717
&\quad\qquad\text{for each }(s_2)^{\star}\text{ in }\mathsf{decorate}(s_2)\\
1818
&\quad\qquad\qquad (s_1)^{\star} = \mathsf{decoration\_of\_trace}(\theta_1)\\
@@ -21,7 +21,7 @@ \subsection{The concretisation function}
2121
\label{eq:refine}
2222
&\quad\qquad\qquad\qquad \mathit{\theta_2} = \mathsf{refine}(\theta_1,\mathtt{Ref}_1,\labl(e),\mathit{spans})\\
2323
&\quad\qquad\qquad\qquad \mathtt{Ref}_2 = \mathtt{Ref}_1\cup\{e\leftrightarrow\mathsf{length}(\theta_2)\}\\
24-
&\quad\qquad\qquad\qquad \mathit{concretisations}_2 = \mathit{concretisations}_2 \cup (\mathit{\theta_2},\mathtt{Ref}_2)\\
24+
&\quad\qquad\qquad\qquad \mathit{concretisations}_2 = \mathit{concretisations}_2 \cup (s_2,\mathit{\theta_2},\mathtt{Ref}_2)\\
2525
&\quad\text{return }\mathit{concretisations}_2
2626
\end{align}
2727

@@ -46,9 +46,10 @@ \subsection{The concretisation function}
4646

4747
\begin{remark}
4848
\label{rm:simply}
49-
We make two simplifying assumptions. First, if an event uses an already introduced node than it appears in one of its decorations. All nodes in an event that are no part of any decorations are \emph{new} nodes that have \emph{fresh identifiers}, not used by any other node in the trace.
49+
We make two simplifying assumptions. First, if an event uses an already introduced node then it is accounted for in one of its decorations. All nodes that are no part of any decorations are \emph{new} nodes that have \emph{fresh identifiers}.
5050

51-
Secondly, we will assume that for any node there exists an event that introduces it. This assumption allows us to reason by induction on the linearisation of a poset.
51+
Secondly, we will assume that for any node there exists an event that introduces it. New nodes always appear in the lhs of rules.
52+
This assumption allows us to reason by induction on the linearisation of a poset.
5253
\end{remark}
5354

5455
The following example shows how much the simplfying assumptions help.
@@ -57,7 +58,7 @@ \subsection{The concretisation function}
5758
\begin{align*}
5859
r_1:A \Rightarrow A,B\qquad r_2:A \Rightarrow A,C \qquad r_3:A\Rightarrow D\qquad r_4:B,C,D\Rightarrow \varepsilon
5960
\end{align*}
60-
We can see that for such a poset we cannot construct the trace by induction on any linearisation. The constraint of node $A$ being the same node in both $e_1$ and $e_2$ only shows when event $e_3$ is considered.
61+
We can see that for such a poset we cannot construct the trace by induction on any linearisation. The constraint of node $A$ being the same node in both $e_1$ and $e_2$ only shows when event $e_3$ is considered. The second sumplying assumption of~\autoref{rm:simply} requires an introductory event for $A$.
6162
\end{example}
6263

6364
We give the algorithm for $\mathsf{refine}$ below. It consists of first updating the graph $L$ of a production $p$ to account for all decorations in $\mathit{spans}$ (\autoref{eq:idprod1} to~\autoref{eq:idprod2}). Then a new transition $t$ is obtained from $p$ (\autoref{eq:newt}).
@@ -118,7 +119,7 @@ \subsection{The concretisation function}
118119
\item otherwise, the only cases possible are either $e_1$ introduces node $n_1$ and $e_1\redl{+} e_2$ or the other way around. In both cases the two nodes are identified as the same node.
119120
\end{itemize}
120121
\item Similar to the case above, we use the constraint on decorating negative forks in~\autoref{def:constraints_poset} and the symplifying assumption~\autoref{rm:simply}.
121-
\item It follows that there exists $e_1,e_2\in s_2^{\star}$ such that $e_2\redl{+}_{\mathit{span}_2} e$ and $e\redl{-}_{\mathit{span}_2} e_1$. But then there exists a span ${\mathit{span}_3}$ such that $e_2\redl{+}_{\mathit{span}_3} e_1$ and the constraint on decorating positive forks in~\autoref{def:constraints_poset} is again not satisfied.
122+
\item It follows that there exists $e_1,e_2\in s_2^{\star}$ such that $e_2\redl{+}_{\mathit{span}_2} e$ and $e\redl{-}_{\mathit{span}_2} e_1$. But then there exists a span ${\mathit{span}_3}$ such that $e_2\redl{+}_{\mathit{span}_3} e_1$ and from the constraint on decorating positive forks in~\autoref{def:constraints_poset} the common nodes in $O_1$ and $O_2$ have the same id.
122123
\end{enumerate}
123124
\item Suppose that there exists $n\in L_I$ and $n\notin M_n$. From the symplifying assumption~\autoref{rm:simply} there exists an event $e_1$ which introduces node $n$. But $n\notin M_n$, implies that there exists an event $e_2$ which "consumes" $n$, i.e. $e_1\redl{+} e_2$ and $e_2\redl{-} e$. %we cannot use this last part $e_2\redl{-}_n e$ because we haven't yet proved that the concretisation of s2 doesn't introduce extra decorations.
124125
From $e_1\redl{+} e_2$ and $e_1\redl{+} e$ with node $n$ common to the two decorations, we have that the constraint on decorating positive forks in~\autoref{def:constraints_poset} is not satisfied.

notes/bio.bib

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,18 @@ @misc{RussInfluence
101101
year = {2016},
102102
publisher={ENS Lyon},
103103
url = {http://perso.ens-lyon.fr/russell.harmer/rbm.html}
104+
}
105+
@incollection{Ehrig:SPO,
106+
author = {Ehrig, H. and Heckel, R. and Korff, M. and L\"{o}we, M. and Ribeiro, L. and Wagner, A. and Corradini, A.},
107+
title = {Algebraic Approaches to Graph Transformation. Part II: Single Pushout Approach and Comparison with Double Pushout Approach},
108+
booktitle = {Handbook of Graph Grammars and Computing by Graph Transformation},
109+
editor = {Rozenberg, Grzegorz},
110+
year = {1997},
111+
isbn = {98-102288-48},
112+
pages = {247--312},
113+
numpages = {66},
114+
url = {http://dl.acm.org/citation.cfm?id=278918.278930},
115+
acmid = {278930},
116+
publisher = {World Scientific Publishing Co., Inc.},
117+
address = {River Edge, NJ, USA},
104118
}

notes/influence_stories.tex

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ \subsection{From posets to traces}
347347

348348
\begin{definition}[Concretisation of an augmented poset]
349349
\label{def:concret}
350-
Let $\underline s=(E,\cover,\prec,\dashv,\labl)$ be an augmented poset $s$.
350+
Let $\underline s=(E,\prec,\dashv,\labl)$ be an augmented poset $s$.
351351
A \emph{concretisation} of $s$ is a triple $(s,\theta,\mathtt{Ref}:E\leftrightarrow\theta)$ such that $\mathtt{Ref}$ is a refinement function and such that
352352
\begin{align*}
353353
%e_1\cover e_2 \iff& \mathtt{Ref}(e_1) <_{\theta}\mathtt{Ref}(e_2)\\
@@ -371,28 +371,37 @@ \subsection{From posets to traces}
371371

372372
\begin{definition}[Linear extensions of posets]
373373
\label{def:linears}
374-
A linear extension of a poset $s=(E,\tleq)$ is any total order that extends the partial order $\tleq$. We denote $\linear(s)$ the set of all possible linear extensions of $s$. A linear extension of a augmented poset $s=(E,\cover,\prec,\dashv)$ is any total order such that
374+
A linear extension of a poset $s=(E,\tleq)$ is any total order that extends the partial order $\tleq$.
375+
A linear extension of a augmented poset $s=(E,\prec,\dashv)$ is any total order $(E,\seq)$ such that
375376
\begin{align*}
376-
(E,\seq)\in\linear(s) \iff \forall e_1,e_2\in E, &e_1\leq e_2\implies e_1\seq e_2\\
377-
& e_1\dashv e_2\implies e_2\seq e_1.
377+
\forall e_1,e_2\in E, &e_1\leq e_2\implies e_1\seq e_2\\
378+
& e_1\neq e_2\text{ and }e_1\dashv e_2\implies e_2\seq e_1.
378379
\end{align*}
380+
We denote $\linear(s)$ the set of all possible linear extensions of $s$.
379381
\end{definition}
380382
Note that linearisations do not create cycles, as follows from the definition of augmented posets.
381383

384+
\begin{definition}{Restriction of a poset to a set of events}
385+
Let $s=(E,\prec,\dashv,\labl)$ be an augmented poset.
386+
Define $s|_{E'}=(E',\prec',\dashv',\labl')$ as a poset defined on $E'$ and where the relations $\prec'$,$\dashv'$ and the function $\labl'$ are the restriction of $\prec'$,$\dashv'$ and $\labl'$ respectively, to the set $E'$.
387+
\end{definition}
388+
389+
Note that $s|_E$ is not directed, but the rest of the properties of augmented posets still hold.
390+
382391
\paragraph{A candidate for the concretisation}
383-
Let $s = (E,\seq,\cover,\prec,\dashv,\labl)$ be a linear extension of an augmented poset. The function $\mathsf{concretise}(s,\emptyset,\emptyset)$ defined below returns a set of concretisations for $s$.
392+
Let $s = (E,\seq,\prec,\dashv,\labl)$ be a linear extension of an augmented poset. The function $\mathsf{concretise}(s,\emptyset,\emptyset)$ defined below returns a set of concretisations for $s$.
384393
\begin{align*}
385394
&\mathsf{concretise}(s,s_1,\mathit{concretisations}_1) = \\
386395
&\quad\text{if }(E_s\setminus E_{s_1} = \emptyset)\text{ then return }\mathit{concretisations}_1\\
387396
&\quad e = \text{min}_{\sqsubset}(E_s\setminus E_{s_1})\\
388397
&\quad\mathit{concretisations}_2 = \emptyset \\
389-
&\quad\text{for each }(s_1^{\star},\theta_1,\mathtt{Ref}_1)\text{ in }\mathit{concretisations}_1\\
390-
&\quad\qquad s_2 = s\setminus\{s_1\cup\{e\}\}\\
398+
&\quad\text{for each }(s_1,\theta_1,\mathtt{Ref}_1)\text{ in }\mathit{concretisations}_1\\
399+
&\quad\qquad s_2 = s|_{\{s_1\cup\{e\}\}}\\
391400
&\quad\qquad\text{for each }s_2^{\star}\text{ in }\mathsf{decorate}(s_2)\\
392-
%&\quad\qquad\qquad (s_1)^{\star} = \mathsf{decoration\_of\_trace}(\theta_1)\\
401+
&\quad\qquad\qquad (s_1)^{\star} = \mathsf{decoration\_of\_trace}(\theta_1)\\
393402
&\quad\qquad\qquad \text{ if }s_2^{\star}\subseteq s_1^{\star}\text{ and }\mathsf{valid}(s_2^{\star})\text{ then }\\
394403
&\quad\qquad\qquad\qquad (\mathit{\theta_2},\mathtt{Ref}_2) = \mathsf{refine}(\theta_1,\mathtt{Ref}_1,s_2^{\star})\\
395-
&\quad\qquad\qquad\qquad \mathit{concretisations}_2 = \mathit{concretisations}_2 \cup (s_2^{\star},\mathit{\theta_2},\mathtt{Ref}_2)\\
404+
&\quad\qquad\qquad\qquad \mathit{concretisations}_2 = \mathit{concretisations}_2 \cup (s_2,\mathit{\theta_2},\mathtt{Ref}_2)\\
396405
&\quad\text{return }\mathit{concretisations}_2
397406
\end{align*}
398407
where $\mathsf{decorate}$ returns a decoration of $s$ as in~\autoref{def:decorate_poset}, $\mathsf{decoration\_of\_trace}$ is an abstraction of a trace to its decorated poset, defined in the~\autoref{prop:constraints_poset}, $\mathsf{valid}$ is from~\autoref{def:constraints_poset} and lastly, $\mathsf{refine}$ is a function that extends a trace and a refinement to the new event $e$. We provide more details for $\mathsf{refine}$ in the appendix. Also in the appendix, we show that at each call of $\mathsf{concretise}$, the concretisations obtained so far are correct w.r.t.~\autoref{def:concret}.

0 commit comments

Comments
 (0)