Specifying Graph Languages with Type Graphs
Andrea Corradini, Barbara K\"onig, Dennis Nolte

TL;DR
This paper explores formal methods for defining graph languages using type graphs, including logic and annotations, analyzing their decidability and closure properties to advance graph specification techniques.
Contribution
It introduces three novel formalisms for specifying graph languages with type graphs, extending the basic approach with logic and annotations, and analyzes their theoretical properties.
Findings
Decidability results for each formalism
Closure properties of the graph language classes
Relationships between restriction graphs and type graphs
Abstract
We investigate three formalisms to specify graph languages, i.e. sets of graphs, based on type graphs. First, we are interested in (pure) type graphs, where the corresponding language consists of all graphs that can be mapped homomorphically to a given type graph. In this context, we also study languages specified by restriction graphs and their relation to type graphs. Second, we extend this basic approach to a type graph logic and, third, to type graphs with annotations. We present decidability results and closure properties for each of the formalisms.
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsLogic, programming, and type systems · Formal Methods in Verification · Model-Driven Software Engineering Techniques
References
- [1]
Parosh Aziz Abdulla, Lukás Holík, Bengt Jonsson, Ondrej Lengál, Cong Quy Trinh, and Tomás Vojnar.
Verification of heap manipulating programs with ordered data by extended forest automata.
In Proc. of ATVA ’13, pages 224–239, 2013.
LNCS 8172.
- [2]
Christoph Blume, H.J. Sander Bruggink, Dominik Engelke, and Barbara König.
Efficient symbolic implementation of graph automata with applications to invariant checking.
In Proc. of ICGT ’12, pages 264–278. Springer, 2012.
LNCS 7562.
- [3]
Christoph Blume, H.J. Sander Bruggink, Martin Friedrich, and Barbara König.
Treewidth, pathwidth and cospan decompositions with applications to graph-accepting tree automata.
Journal of Visual Languages & Computing, 24(3):192–206, 2013.
- [4]
H.J. Sander Bruggink and Barbara König.
On the recognizability of arrow and graph languages.
In Proc. of ICGT ’08, pages 336–350. Springer, 2008.
LNCS 5214.
- [5]
Edmund M. Clarke, Orna Grumberg, Somesh Jha, Yuan Lu, and Helmut Veith.
Counterexample-guided abstraction refinement for symbolic model checking.
Journal of the ACM, 50(5):752–794, 2003.
- [6]
Andrea Corradini, Ugo Montanari, and Francesca Rossi.
Graph processes.
Fundamenta Informaticae, 26(3/4):241–265, 1996.
- [7]
Bruno Courcelle.
The monadic second-order logic of graphs I. Recognizable sets of finite graphs.
Information and Computation, 85:12–75, 1990.
- [8]
Bruno Courcelle and Joost Engelfriet.
Graph Structure and Monadic Second-Order Logic, A Language-Theoretic Approach.
Cambridge University Press, June 2012.
- [9]
Dino Distefano, Peter W. O’Hearn, and Hongseok Yang.
A local shape analysis based on separation logic.
In Proc. of TACAS ’06, pages 287–302. Springer, 2006.
LNCS 3920.
- [10]
Jörg Endrullis and Hans Zantema.
Proving non-termination by finite automata.
In RTA ’15, volume 36 of LIPIcs, pages 160–176. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, 2015.
- [11]
Annegret Habel.
Hyperedge Replacement: Grammars and Languages.
Springer-Verlag, 1992.
LNCS 643.
- [12]
Annegret Habel and Karl-Heinz Pennemann.
Nested constraints and application conditions for high-level structures.
In Formal Methods in Software and Systems Modeling. Essays Dedicated to Hartmut Ehrig, on the Occasion of His 60th Birthday, pages 294–308. Springer, 2005.
LNCS 3393.
- [13]
Reiko Heckel and Annika Wagner.
Ensuring consistency of conditional graph rewriting – a constructive approach.
In Proc. of the Joint COMPUGRAPH/SEMAGRAPH Workshop on Graph Rewriting and Computation, volume 2 of ENTCS, 1995.
- [14]
Stephen Lack and Paweł Sobociński.
Adhesive and quasiadhesive categories.
RAIRO – Theoretical Informatics and Applications, 39(3), 2005.
- [15]
Jaroslav Nešetřil and Claude Tardif.
Duality theorems for finite structures (characterising gaps and good characterisations).
Journal of Combinatorial Theory, Series B, 80:80–97, 2000.
- [16]
Peter W. O’Hearn.
Resources, concurrency and local reasoning.
Theoretical Computer Science, 375(1–3):271–307, May 2007.
Reynolds Festschrift.
- [17]
Fernando Orejas, Hartmut Ehrig, and Ulrike Prange.
A logic of graph constraints.
In Proc. of FASE ’08, pages 179–198. Springer, 2008.
LNCS 4961.
- [18]
Karl-Heinz Pennemann.
Development of Correct Graph Transformation Systems.
PhD thesis, Universität Oldenburg, May 2009.
- [19]
Arend Rensink.
Canonical graph shapes.
In Proc. of ESOP ’04, pages 401–415. Springer, 2004.
LNCS 2986.
- [20]
Arend Rensink.
Representing first-order logic using graphs.
In Proc. of ICGT ’04, pages 319–335. Springer, 2004.
LNCS 3256.
- [21]
Grzegorz Rozenberg, editor.
Handbook of Graph Grammars and Computing by Graph Transformation, Vol.1: Foundations.
World Scientific, 1997.
- [22]
Adrian Rutle, Alessandro Rossini, Yngve Lamo, and Uwe Wolter.
A diagrammatic formalisation of MOF-based modelling languages.
In Proc. of TOOLS EUROPE ’09, pages 37–56. Springer, 2009.
LNBIP 33.
- [23]
Mooly Sagiv, Thomas Reps, and Reinhard Wilhelm.
Parametric shape analysis via 3-valued logic.
TOPLAS (ACM Transactions on Programming Languages and Systems), 24(3):217–298, 2002.
- [24]
Dominik Steenken, Heike Wehrheim, and Daniel Wonisch.
Sound and complete abstract graph transformation.
In Proc. of SBMF ’11, pages 92–107. Springer, 2011.
LNCS 7021.
11institutetext: Università di Pisa, Italy
11email: [email protected] 22institutetext: Universität Duisburg-Essen, Germany
22email: {barbara_koenig,dennis.nolte}@uni-due.de
Specifying Graph Languages with Type Graphs
Andrea Corradini 11
Barbara König 22
Dennis Nolte 22
Abstract
We investigate three formalisms to specify graph languages, i.e. sets of graphs, based on type graphs. First, we are interested in (pure) type graphs, where the corresponding language consists of all graphs that can be mapped homomorphically to a given type graph. In this context, we also study languages specified by restriction graphs and their relation to type graphs. Second, we extend this basic approach to a type graph logic and, third, to type graphs with annotations. We present decidability results and closure properties for each of the formalisms.
1 Introduction
Formal languages in general and regular languages in particular play an important role in computer science. They can be used for pattern matching, parsing, verification and in many other domains. For instance, verification approaches such as reachability checking, counterexample-guided abstraction refinement [5] and non-termination analysis [10] could be directly adapted to graph transformation systems if one had a graph specification formalism with suitable closure properties, computable pre- and postconditions and inclusion checks. Inclusion checks are also important for checking when a fixpoint iteration sequence stabilizes.
While regular languages for words and trees are well-understood and can be used efficiently and successfully in applications, the situation is less satisfactory when it comes to graphs. Although the work of Courcelle [8] presents an accepted notion of recognizable graph languages, equivalent to regular languages, this is often not useful in practice, due to the sheer size of the resulting graph automata. Other formalisms, such as application conditions [20, 12] and first-order or second-order logics, feature more compact descriptions, but there are problems with expressiveness, undecidability issues or unsatisfactory closure properties.111A more detailed overview over related formalisms is given in the conclusion (Section 6).
Hence, we believe that it is important to study and compare specification formalisms (i.e., automata, grammars and logics) that allow to specify potentially infinite sets of graphs. In our opinion there is no one-fits-all solution, but we believe that specification mechanisms should be studied and compared more extensively.
In this paper we study specification formalisms based on type graphs, where a type graph represents all graphs that can be mapped homomorphically to , potentially taking into account some extra constraints. Type graphs are common in graph rewriting [6, 21]. Usually, one assumes that all items, i.e., rules and graphs to be rewritten, are typed, introducing constraints on the applicability of rules. Hence, type graphs are in a way seen as a form of labelling. This is different from our point of view, where graphs (and rules) are – a priori – untyped (but labeled) and type graphs are simply a means to represent sets of graphs.
There are various reasons for studying type graphs: first, they are reasonably simple with many positive decidability results and they have not yet been extensively studied from the perspective of specification formalisms. Second, other specification mechanisms – especially those used in connection with verification and abstract graph transformation [19, 23, 24] – are based on type graphs: abstract graphs are basically type graphs with extra annotations. Third, while not being as expressive as recognizable graph languages, they retain a nice intuition from regular languages: given a finite state automaton one can think of the language of as the set of all string graphs that can be mapped homomorphically to (respecting initial and final states).
We in fact study three different formalisms based on type graphs: first, pure type graphs , where the language consists simply of all graphs that can be mapped to . We also discuss the connection between type graph and restriction graph languages. Then, in order to obtain a language with better boolean closure properties, we study type graph logic, which consists of type graphs enriched with boolean connectives (negation, conjunction, disjunction). Finally, we consider annotated type graphs, where the annotations constrain the number of items mapped to a specific node or edge, somewhat similar to the proposals from abstract graph rewriting mentioned above.
In all three cases we are interested in closure properties and in decidability issues (such decidability of the membership, emptiness and inclusion problems) and in expressiveness. Proofs for all the results can be found in Appendix 0.A.
2 Preliminaries
We first introduce graphs and graph morphisms. In the context of this paper we use edge-labeled, directed graphs.
Definition 1 (Graph)
Let be a fixed set of edge labels. A -labeled graph is a tuple , where is a finite set of nodes, is a finite set of edges, assign to each edge a source and a target node, and is a labeling function.
We will denote, for a given graph , its components by , , , and , unless otherwise indicated.
Definition 2 (Graph morphism)
Let be two -labeled graphs. A graph morphism consists of two functions and , such that for each edge it holds that , and . If is both injective and surjective it is called an isomorphism.
We will often drop the subscripts and write instead of , . We will consider the category having -labeled graphs as objects and graph morphisms as arrows. The set of its objects will be denoted by . The categorical structure induces an obvious preorder on graphs, defined as follows.
Definition 3 (Homomorphism preorder)
Given graphs and , we write if there is a graph morphism from to in . The relation is obviously a preorder (i.e. it is reflexive and transitive) and we call it the homomorphism preorder on graphs. We write if does not hold. Graphs and are homomorphically equivalent, written , if both and hold.
We will revisit the concept of retracts and cores from [15]. Cores are a convenient way to minimize type graphs, as, according to [15], all graphs with have isomorphic cores.
Definition 4 (Retract and core)
A graph is called a retract of a graph if is a subgraph of and in addition there exists a morphism . A graph is called a core of , written , if it is a retract of and has itself no proper retracts.
Example 1
The graph is a retract of , where the morphism is indicated by the node numbering:
[TABLE]
Since the graph does not have a proper retract itself it is also the core of .
3 Languages Specified by Type or Restriction Graphs
In this section we introduce two classes of graph languages that are characterized by two somewhat dual properties. A type graph language contains all graphs that can be mapped homomorphically to a given type graph, while a restriction graph language includes all graphs that do not contain an homomorphic image of a given restriction graph. Next, we discuss for these two classes of languages some properties such as closure under set operators, decidability of emptiness and inclusion, and decidability of closure under rewriting via double-pushout rules. Finally we discuss the relationship between these two classes of graph languages.
Definition 5 (Type graph language)
A type graph is just a -labeled graph. The language is defined as:
[TABLE]
Example 2
The following type graph over the edge label set specifies a type graph language consisting of infinitely many graphs:
[TABLE]
The category has a final object, that we denote , consisting of one node (called flower node ✲) and one loop for each label in . Therefore . The graph for is depicted to the right.
Specifying graph languages using type graphs gives us the possibility to forbid certain graph structures by not including them into the type graph. For example, no graph in the language of Example 2 can contain a -loop or an -edge incident to the target of a -edge. However, it is not possible to force some structures to exist in all graphs of the language, since the morphism to the type graph need not be surjective. This point will be addressed with the notion of annotated type graph in Section 5.
Another way (possibly more explicit) to specify languages of graphs not including certain structures, is the following one.
Definition 6 (Restriction graph language)
A restriction graph is just a -labeled graph. The language is defined as:
[TABLE]
We will consider the relationship between the class of languages introduced in Definitions 5 and 6 in Section 3.3.
3.1 Closure and Decidability Properties
The type graph and restriction graph languages enjoy the following complementary closure properties with respect to set operators.
Proposition 1
Type graph languages are closed under intersection (by taking the product of type graphs) but not under union or complementation, while restriction graph languages are closed under union (by taking the coproduct of restriction graphs) but not under intersection or complementation.
Instead the two classes of languages enjoy similar decidability properties.
Proposition 2
For a graph language characterized by a type graph (i.e. ) or by a restriction graph (i.e. ) the following problems are decidable:
Membership, i.e. for each graph it is decidable if holds. 2. 2.
Emptiness, i.e. it is decidable if holds.
*Furthermore, language inclusion is decidable for both classes of languages: *
Given type graphs and it is decidable if holds. 2. 4.
Given restriction graphs and it is decidable if holds.
3.2 Closure under Double-Pushout Rewriting
In this subsection we are using the DPO approach with general, not necessarily injective, rules and matches. We discuss how we can show that a graph language is a closed under a given graph transformation rule \rho=(L\mathchoice{\xleftarrow{\varphi_{L}}}{\mathbin{{\textstyle\shortleftarrow}{\raisebox{0.99025pt}{\scriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\textstyle\relbar}}}{\mathbin{{\scriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\scriptstyle\relbar}}}{\mathbin{{\scriptscriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}}}I\mathbin{\mathchoice{\xrightarrow{\varphi_{R}}}{\scalebox{0.8}[1.0]{\textstyle\relbar}{\raisebox{0.99025pt}{\scriptstyle\varphi_{R}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{R}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{R}}}{\shortrightarrow}}}R), i.e., is an invariant for . This means that for all graphs , where can be rewritten to via , it holds that implies .
For both type graph languages and restriction graph languages, separately, we characterize a sufficient and necessary condition which shows that closure under rule application is decidable. The condition for restriction graph languages is related to a condition already discussed in [13].
Proposition 3 (Closure under DPO rewriting for restriction graphs)
A restriction graph language is closed under a rule \rho=(L\mathchoice{\xleftarrow{\varphi_{L}}}{\mathbin{{\textstyle\shortleftarrow}{\raisebox{0.99025pt}{\scriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\textstyle\relbar}}}{\mathbin{{\scriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\scriptstyle\relbar}}}{\mathbin{{\scriptscriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}}}I\mathbin{\mathchoice{\xrightarrow{\varphi_{R}}}{\scalebox{0.8}[1.0]{\textstyle\relbar}{\raisebox{0.99025pt}{\scriptstyle\varphi_{R}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{R}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{R}}}{\shortrightarrow}}}R) if and only if the following condition holds: for every pair of morphisms , which are jointly surjective, applying the rule with (co-)match backwards to yields a graph with a homomorphic image of , i.e., .
Proposition 4 (Closure under DPO rewriting for type graphs)
A type graph language is closed under a rule \rho=(L\mathchoice{\xleftarrow{\varphi_{L}}}{\mathbin{{\textstyle\shortleftarrow}{\raisebox{0.99025pt}{\scriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\textstyle\relbar}}}{\mathbin{{\scriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\scriptstyle\relbar}}}{\mathbin{{\scriptscriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}}}I\mathbin{\mathchoice{\xrightarrow{\varphi_{R}}}{\scalebox{0.8}[1.0]{\textstyle\relbar}{\raisebox{0.99025pt}{\scriptstyle\varphi_{R}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{R}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{R}}}{\shortrightarrow}}}R) if and only if for each morphism , there exists a morphism such that .
L$$I$$R$$\mathit{core}(T)$$\Leftrightarrow$$\mathcal{L}(T)* is closed under application of *\rho$$\forall t_{L}$$\varphi_{L}$$\varphi_{R}$$\exists t_{R}
We show that the only if part () of Proposition 4 cannot be weakened by considering morphisms to the type graph , instead of to . In fact, consider the following type graph and the rule :
[TABLE]
The type graph contains the flower node, i.e., it has as subgraph. This ensures that each graph , edge-labeled over , is in the language , and thus by rewriting any graph into a graph using it is guaranteed that . However there is a morphism , the one mapping the -labeled edge of to the left -labeled edge of , such that there exists no morphism satisfying .
3.3 Relating Type graph and Restriction Graph Languages
Both type graph and restriction graph languages specify collections of graphs by forbidding the presence of certain structures. This is more explicit with the use of restriction graphs, though. A natural question is how the two classes of languages are related. A partial answer to this is provided by the notion of duality pairs and by an important result concerning their existence, presented in [15].222Note that in [15] graphs are simple, but it can be easily seen that for our purposes the results can be transferred straightforwardly.
Definition 7 (Duality pair)
Given two graphs and , we call the dual of if for every graph it holds that if and only if . In this case the pair is called duality pair.
Clearly, we have that is a duality pair if and only if the restriction graph language coincides with the type graph language .
Example 3
Let be given. The following is a duality pair:
[TABLE]
Since node 1 of is not the source of a -labeled edge and node 2 is not the target of an -labeled edge, for every graph we have iff it does not contain a node which is both the target of an -labeled edge and the source of a -labeled edge. But it contains such a node if and only if .
One can identify the class of restriction graphs for which a corresponding type graph exists which defines the same graph language. Results from [15] state333We refer to Lemma 2.3, Lemma 2.5 and Theorem 3.1 in [15]. that given a core graph , a graph can be constructed such that is a duality pair if and only if is a tree.
Thus we have a precise characterisation of the intersection of the classes of type and restriction graph languages: belongs to the intersection if and only if it is of the form and is a tree. It is worth mentioning that the construction of from using the results from [15] contains two exponential blow-ups. This can be interpreted by saying that type graphs have limited expressiveness if used to forbid the presence of certain structures.
4 Type Graph Logic
In this section we investigate the possibility to define a language of graphs using a logical formula over type graphs. We start by defining the syntax and semantics of a type graph logic ().
Definition 8 (Syntax and semantics of )
A formula over a fixed set of edge labels is formed according to the following grammar:
[TABLE]
Each formula denotes a graph language defined by structural induction as follows:
[TABLE]
Clearly, due to the presence of boolean connectives, boolean closure properties come for free.
Example 4
Let the following formula over be given:
[TABLE]
The graph language consists of all graphs which do not consist exclusively of -edges or of -edges, i.e., which contain at least one -labeled edge and at least one -labeled edge, something that can not be expressed by pure type graphs.
We now present some positive results for graph languages over formulas with respect to decidability problems. Due to the conjunction and negation operator, the emptiness (or unsatisfiability) check is not as trivial as it is for pure type graphs. Note that thanks to the presence of boolean connectives, inclusion can be reduced to emptiness.
Proposition 5
For a graph language characterized by a formula , the following problems are decidable:
- •
Membership, i.e. for all graphs it is decidable if holds.
- •
Emptiness, i.e. it is decidable if holds.
- •
Language inclusion, i.e. given two formulas and it is decidable if holds.
Such a logic could alternatively also be defined based on restriction graphs. A related logic, for injective occurrences of restriction graphs, is studied in [17], where the authors also give a decidability result via inference rules.
5 Annotated Type Graphs
In this section we will improve the expressiveness of the type graphs themselves, rather than using an additional logic to do so. We will equip graphs with additional annotations. As explained in the introduction, this idea was already used similarly in abstract graph rewriting. In contrast to most other approaches, we will investigate the problem from a categorical point of view.
The idea we follow is to annotate each element of a type graph with pairs of multiplicities, denoting upper and lower bounds. We will define a category of multiply annotated graphs, where we consider elements of a lattice-ordered monoid (short -monoid) as multiplicities.
Definition 9 (Lattice-ordered monoid)
A lattice-ordered monoid (-monoid) consists of a set , a partial order and a binary operation such that
- •
is a lattice.
- •
is a monoid; we denote its unit by [math].
- •
It holds that and , where are the meet and join of .
We denote by the category having -monoids as objects and as arrows monoid homomorphisms which are monotone.
Example 5
Let and take (zero, one, , , many) with and addition as monoid operation with the proviso that if the sum is larger than . Clearly, for all and . From this we can infer distributivity and therefore forms an -monoid.
Furthermore, given a set and an -monoid , it is easy to check that also is an -monoid, where the elements are functions from to and the partial order and the monoidal operation are taken pointwise.
In the following we will sometimes denote an -monoid by its underlying set.
Definition 10 (Annotations and multiplicities for graphs)
Given a functor , an annotation based on for a graph is an element . We write , instead of , for the action of functor on a graph morphism . We assume that for each graph there is a standard annotation based on that we denote by , thus .
Given an -monoid we define the functor as follows:
- •
for every graph , ;
- •
for every graph morphism and , we have
with:
[TABLE]
Therefore an annotation based on a functor associates every item of a graph with a number (or the top value ). We will call such kind of annotations multiplicities. Furthermore, the action of the functor on a morphism transforms a multiplicity by summing up (in ) the values of all items of the source graph that are mapped to the same item of the target graph.
For a graph , its standard multiplicity is defined as the function which maps every node and edge of to 1.
Some of the results that we will present in the rest of the paper will hold for annotations based on a generic functor , some only for annotations based on functors , i.e. for multiplicities.
The type graphs which we are going to consider are enriched with a set of pairs of annotations. The motivation for considering multiple annotations rather than a single one is mainly to ensure closure under union. Each pair can be interpreted as establishing a lower and an upper bound to what a graph morphism can map to the graph.
Definition 11 (Multiply annotated graphs)
Given a functor , a multiply annotated graph (over ) is a graph equipped with a finite set of pairs of annotations , such that for all .
An arrow , also called a legal morphism, is a graph morphism such that for all there exists with and . We will write as an abbreviation of . In case of annotations based on , we will often call a pair a double multiplicity.
Multiply annotated graphs and legal morphisms form a category.
Lemma 1
The composition of two legal morphisms is a legal morphism.
Example 6
Consider the following multiply annotated graphs (over ) and , both having one double multiplicity.
[TABLE]
As evident from the picture, multiplicities are represented by writing the lower and upper bounds next to the corresponding graph elements. Note that there is a unique, obvious graph morphism , mapping both nodes of to the only node of . Concerning multiplicities, by adding the lower and upper bounds of the two nodes of , one gets the interval which is included in the interval of the node of , . Similarly, the double multiplicity of the edge of is included in . Therefore, since both and hold, we can conclude that is a legal morphism.
We are now ready to define how a graph language looks like.
Definition 12 (Graph languages of multiply annotated type graphs)
We say that a graph is represented by a multiply annotated type graph whenever there exists a legal morphism , i.e., there exists such that . We will write in this case. Whenever for a multiply annotated type graph we get .
An extended example can be found in Appendix 0.B.
5.1 Decidability Properties for Multiply Annotated Graphs
We now address some decidability problems for languages defined by multiply annotated graphs. We get positive results with respect to the membership and emptiness problems. However, for decidability of language inclusion we only get partial results.
For the membership problem we can simply enumerate all graph morphisms and check if there exists a legal morphism .
The emptiness check is somewhat more involved, since we have to take care of “illegal” annotations.
Proposition 6
For a graph language characterized by a multiply annotated type graph over the emptiness problem is decidable: iff or for each there exists an edge such that and or .
Language inclusion can be deduced from the existence of a legal morphism between the two multiply annotated type graphs.
Proposition 7
The existence of a legal morphism implies .
We would like to remark that this condition is sufficient but not necessary, and we present the following counterexample. Let the following two multiply annotated type graphs and over be given where :
[TABLE]
Clearly we have that the languages and are equal as both contain all discrete non-empty graphs. Thus , but there exists no legal morphism . In fact, the upper bound of the first node of would be violated if the node of is mapped by to it, while the lower bound would be violated if the node of is mapped to the other node.
5.2 Deciding Language Inclusion for Annotated Type Graphs
In this section we show that if we allow only bounded graph languages consisting of graphs up to a fixed pathwidth, the language inclusion problem becomes decidable for annotations based on . Pathwidth is a well-known concept from graph theory that intuitively measures how much a graph resembles a path.
The proof is based on the notion of recognizability, which will be described via automaton functors that were introduced in [4]. We start with the main result and explain step by step the arguments that will lead to decidability.
Proposition 8
The language inclusion problem is decidable for graph languages of bounded pathwidth characterized by multiply annotated type graphs over . That is, given and two multiply annotated type graphs and over , it is decidable whether , where has pathwidth .
Our automaton model, given by automaton functors, reads cospans (i.e., graphs with interfaces) instead of single graphs. Therefore in the following, the category under consideration will be , i.e. the category of cospans of graphs where the objects are discrete graphs and the arrows are cospans where both graph morphisms are injective. We will refer to the graph as the inner interface and to the graph as the outer interface of the graph . In addition we will sometimes abbreviate the cospan to the short representation c\colon J\mathrel{\raisebox{5.59721pt}{\scalebox{1.0}[-1.0]{\mbox{\looparrowright}}}}K.
According to [3] a graph has pathwidth iff it can be decomposed into cospans where each middle graph of a cospan has at most nodes. Hence it is easy to check that a path has pathwidth , while a clique of order has pathwidth .
Our main goal is to build an automaton which can read all graphs of our language step by step, similar to the idea of finite automata reading words in formal languages. Such an automaton can be constructed for an unbounded language, where the pathwidth is not restricted. However, we obtain a finite automaton only if we restrict the pathwidth. Then we can use well-known algorithms for finite automata to solve the language inclusion problem. Note that, if we would use tree automata instead of finite automata, our result could be generalized to graphs of bounded treewidth.
We will first introduce the notion of automaton functor (which is a categorical automaton model for so-called recognizable arrow languages) and which is inspired by Courcelle’s theory of recognizable graph languages [8].
Definition 13 (Automaton functor [4])
An automaton functor is a functor that maps every object (i.e., every discrete graph) to a finite set (the set of states of ) and every cospan c\colon J\mathrel{\raisebox{5.59721pt}{\scalebox{1.0}[-1.0]{\mbox{\looparrowright}}}}K to a relation (the transition relation of ). In addition there is a distinguished set of initial states and a distinguished set of final states . The language of is defined as follows:
A graph is contained in if and only if there exist states and which are related by , i.e. , where is the unique cospan with empty interfaces and middle graph .
Languages accepted by automaton functors are called recognizable.
We will now define an automaton functor for a type graph over .
Definition 14 (Counting cospan automaton)
Let be a multiply annotated type graph over . We define an automaton functor as follows:
- •
For each object of (thus is a finite discrete graph), is its finite set of states
- •
is the set of initial states with , where [math] is the constant [math]-function
- •
is the set of final states with
– Let c\colon J\mathbin{\mathchoice{\xrightarrow{\psi_{L}}}{\scalebox{0.8}[1.0]{\textstyle\relbar}{\raisebox{0.99025pt}{\scriptstyle\psi_{L}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle\psi_{L}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle\psi_{L}}}{\shortrightarrow}}}G\mathchoice{\xleftarrow{\psi_{R}}}{\mathbin{{\textstyle\shortleftarrow}{\raisebox{0.99025pt}{\scriptstyle\psi_{R}}}\scalebox{0.8}[1.0]{\textstyle\relbar}}}{\mathbin{{\scriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle\psi_{R}}}\scalebox{0.8}[1.0]{\scriptstyle\relbar}}}{\mathbin{{\scriptscriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle\psi_{R}}}\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}}}K be an arrow in the category with discrete interface graphs and where both graph morphisms and are injective. Two states and are in the relation if and only if there exists a morphism such that the diagram to the right commutes and for all the following equation holds:
J$$G$$K$$T$$c\colon J\mathrel{\raisebox{5.59721pt}{\scalebox{1.0}[-1.0]{\mbox{\looparrowright}}}}K$$f$$\psi_{L}$$\exists h$$\psi_{R}$$f^{\prime}
[TABLE]
The set consists of all elements of which are not targeted by the morphism , e.g. . Instead of and we just write and if is clear from the context.
The intuition behind this construction is to count for each item of , step by step, the number of elements that are being mapped from a graph (which is in the form of a cospan decomposition) to , and then check if the bounds of a pair of annotations of the multiply annotated type graph are satisfied. We give a short example before moving on to the results.
Example 7
Let the following multiply annotated type graph (over ) and the cospan with be given:
[TABLE]
We will now decompose the cospan into two cospans with in the following way:
\varnothing$$\mathit{A}$$\mathit{B}$$\varnothing$$c_{1}$$c_{2}$$c
We let our counting cospan automaton parse the cospan decomposition step by step now to show how the annotations for the type graph evolve during the process. According to our construction, every element in has multiplicity [math] in the initial state of the automaton. We then sum up the number of elements within the middle graphs of the cospans which are not part of the right interface. Therefore we get the following parsing process:
\varnothing$$\mathit{A}$$\mathit{B}$$\varnothing[0][0]A[0]B[0][1][0]A[1]B[0][1][2]A[1]B[1]f_{1}$$f_{2}$$f_{3}$$q_{1}$$q_{2}$$q_{3}
We visited three states and in the automaton with and . Since is supposed to be a functor we get that and therefore also holds. In addition we have and since the annotation function in satisfies we can infer that . Therefore we can conclude that holds as well.
We still need to prove that is indeed a functor. Intuitively this shows that acceptance of a graph by the automaton is not dependent on its specific decomposition.
Proposition 9
Let and be two arrows and let be the identity cospan.
The mapping is a functor:
** 2. 2.
**
The language accepted by the automaton is exactly the graph language .
Proposition 10
Let the multiply annotated type graph (over ) and the corresponding automaton functor for be given. Then holds, i.e. for a graph we have if and only if there exist states and such that , where .
Therefore we can construct an automaton for each graph language specified by a multiply annotated type graph , which accepts exactly the same language. In case of a bounded graph language this automaton will have only finitely many states. Furthermore we can restrict the label alphabet, i.e., the cospans by using only atomic cospans, adding a single node or edges (see [2]). Once these steps are performed, we obtain conventional non-deterministic finite automata over a finite alphabet and we can use standard techniques from automata theory to solve the language inclusion problem directly on the finite automata.
5.3 Closure Properties for Multiply Annotated Graphs
Extending the expressiveness of the type graphs by adding multiplicities gives us positive results in case of closure under union and intersection. Here we use constructions that rely on products and coproducts in the category of graphs.
Closure under intersection holds for the most general form of annotations. From , we can construct an annotated type graph , where contains all annotations which make both projections legal.
Proposition 11
The category of multiply annotated graphs is closed under intersection.
We can prove closure under union for the case of annotations based on the functor . Here we take the coproduct , where contains all annotations of , , transferred to via the injections . Intuitively, graph items not in the original domain of the annotations receive annotation . This can be generalized under some mild assumptions(see proof in the appendix).
Proposition 12
The category of multiply annotated graphs over functor is closed under union.
Closure under complement is still an open issue. If we restrict to graphs of bounded pathwidth, we have a (non-deterministic) automaton (functor), as described in Section 5.1, which could be determinized and complemented. However, this does not provide us with an annotated type graph for the complement. We conjecture that closure under complement does not hold.
6 Conclusion
Our results on decidability and closure properties for specification languages are summarized in the following table. In the case where the results hold only for bounded pathwidth, the checkmark is in brackets.
[TABLE]
One open question that remains is whether language inclusion for annotated type graphs is decidable if we do not restrict to bounded treewidth. Similarly, closure under complement is still open.
Furthermore, in order to be able to use these formalisms extensively in applications, it is necessary to provide a mechanism to compute weakest preconditions and strongest postconditions. This does not seem feasible for pure type graphs or the type graph logic. Hence, we are currently working on characterizing weakest preconditions and strongest postconditions in the setting of annotated type graphs. This requires a materialisation construction, similar to [23], which we plan to characterize abstractly, exploiting universal properties in category theory.
Note that our annotations are global, i.e., we count all items that are mapped to a specific item in the type graph. This holds also for edges, as opposed to UML multiplicities, which are local wrt. the classes which are related by an edge (i.e., an association). We plan to study the possibility to integrate this into our framework and investigate the corresponding decidability and closure properties.
Related work: As already mentioned there are many approaches for specifying graph languages. One can not say that one is superior to the other, usually there is a tradeoff between expressiveness and decidability properties, furthermore they differ in terms of closure properties.
Recognizable graph languages [7, 8], which are the counterpart to regular word languages, are closely related with monadic second-order graph logic. If one restricts recognizable graph languages to bounded treewidth (or pathwidth as we did), one obtains satisfactory decidability properties. On the other hand, the size of the resulting graph automata is often quite intimidating [2] and hence they are difficult to work with in practical applications. The use of nested application conditions [12], equivalent to first-order logic [20], has a long tradition in graph rewriting and they can be used to compute pre- and postconditions for rules [18]. However, satisfiability and implication are undecidable for first-order logic.
A notion of grammars that is equivalent to context-free (word) grammars are hyperedge replacement grammars [11]. Many aspects of the theory of context-free languages can be transferred to the graph setting.
In heap analysis the representation of pointer structures to be analyzed requires methods to specify sets of graphs. Hence both the TVLA approach by Sagiv, Reps and Wilhelm [23], as well as separation logic [16, 9] face this problem. In [23] heaps are represented by graphs, annotated with predicates from a three-valued logics (with truth values yes, no and maybe).
A further interesting approach are forest automata [1] that have many interesting properties, but are somewhat complex to handle.
In [22] the authors study an approach called Diagram Predicate Framework (DPF), in which type graphs have annotations based on generalized sketches. This formalism is intended for MOF-based modelling languages and allows more complex annotations than our framework.
Appendix 0.A Proofs
0.A.1 Languages Specified by Type or Restriction Graphs
Proposition 1.* Type graph languages are closed under intersection (by taking the product of type graphs) but not under union or complementation, while restriction graph languages are closed under union (by taking the coproduct of restriction graphs) but not under intersection or complementation. *
Proof
The product has the property that for any graph we have if and only if and . Hence, given two type graphs and , by the universal property of the product graph we get immediately the following equality: .
Dually, given two restriction graphs and , we show that . In fact, iff , iff (by the universal property of coproducts) and , iff and , iff .
For the negative results, we will show counterexamples using the following graphs over :
[TABLE]
We first show by contradiction that there is no type graph such that . In fact, the type graph language contains all graphs which do not have any -labeled edge, and contains all graphs which do not have any -labeled edge. Since , we would have and , which implies that contains at least one -labeled loop (thus ) and one -labeled loop (thus ). It follows that , but instead yielding a contradiction.
Now we show by contradiction that there is no restriction graph such that . In fact, if such an exists we would have , and thus by Proposition 2.4, and , and thus . But means that has no -edges, and that it has no -edges, thus must be discrete. This yields a contradiction, because any graph with no loops but with at least one edge belongs to but not to , because .
The lack of closure under complementation immediately follows from these negative results and the fact that union can be expressed using intersection and complementation, and dually. ∎
Proposition 2.*
For a graph language characterized by a type graph (i.e. ) or by a restriction graph (i.e. ) the following problems are decidable:*
Membership, i.e. for each graph it is decidable if holds. 2. 2.
Emptiness, i.e. it is decidable if holds.
*Furthermore, language inclusion is decidable for both classes of languages: *
Given type graphs and it is decidable if holds. 2. 4.
Given restriction graphs and it is decidable if holds.
Proof
To decide whether (or ) holds, we need to check for the existence of a morphism (or for the non-existence of a morphism ), which is obviously possible because graphs are finite. Nevertheless, note that this problem is NP-complete. For instance, searching for a morphism from any graph into the 3-clique is the same as deciding if the graph is 3-colorable. 2. 2.
The emptiness problem is pretty trivial. If for a type graph , then because it holds (recall that is the initial object of ).
If instead for a restriction graph , then if and only if . In fact, if then for all , and thus . Instead if then clearly , thus . 3. 3.
We show that iff , which is decidable.
: Assume holds. Since holds then also holds and therefore .
: Assume holds, and let . Therefore , and by transitivity , thus . 4. 4.
We show that iff .
: Assume that holds. Equivalently, , where we wrote for the complement language . Thus, since obviously , we obtain .
: Assume that holds and that , which means . If, by contradiction, , then we have and, by transitivity, , which is a contradiction.∎
Proposition 3.* A restriction graph language is closed under a rule \rho=(L\mathchoice{\xleftarrow{\varphi_{L}}}{\mathbin{{\textstyle\shortleftarrow}{\raisebox{0.99025pt}{\scriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\textstyle\relbar}}}{\mathbin{{\scriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\scriptstyle\relbar}}}{\mathbin{{\scriptscriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}}}I\mathbin{\mathchoice{\xrightarrow{\varphi_{R}}}{\scalebox{0.8}[1.0]{\textstyle\relbar}{\raisebox{0.99025pt}{\scriptstyle\varphi_{R}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{R}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{R}}}{\shortrightarrow}}}R) if and only if the following condition holds: for every pair of morphisms , which are jointly surjective, applying the rule with (co-)match backwards to yields a graph with a homomorphic image of , i.e., . *
Proof
: Assume that the condition holds. Now let with . Instead of showing that implies , we show that implies .
Since we have the following DPO diagram (below, on the left) for a rule \rho=(L\mathchoice{\xleftarrow{\varphi_{L}}}{\mathbin{{\textstyle\shortleftarrow}{\raisebox{0.99025pt}{\scriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\textstyle\relbar}}}{\mathbin{{\scriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\scriptstyle\relbar}}}{\mathbin{{\scriptscriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}}}I\mathbin{\mathchoice{\xrightarrow{\varphi_{R}}}{\scalebox{0.8}[1.0]{\textstyle\relbar}{\raisebox{0.99025pt}{\scriptstyle\varphi_{R}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{R}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{R}}}{\shortrightarrow}}}R)\in\mathcal{R}. Furthermore, since , there exists a morphism .
[TABLE]
Now take the joint image of and in , i.e., factor the morphisms , into and , where the arrows , are jointly epi. Since we are working in an adhesive category, the pushouts split into pushouts according to [14] (see diagram above, on the right). Now, is obtained from by applying rule backwards. Hence, the condition implies that there exists a morphism and this means that there is a morphism , which implies .
: Assume that is closed under rewriting via a rule . We show that the condition holds. Let , be a pair of morphisms which are jointly epi and assume that is obtained from by applying backwards.
Now, since and , we infer that , otherwise we would have a counterexample to closure under rewriting. Hence there exists a morphism . ∎
For the next result we need to recall the following lemma presented in [15].
Lemma 2 (Lemma 2.1 of [15])
Let be a graph and be its core. Then for each morphism there exists a morphism such that . Vice versa, for each morphism there exists a morphism such that .
Proposition 4.* A type graph language is closed under a rule \rho=(L\mathchoice{\xleftarrow{\varphi_{L}}}{\mathbin{{\textstyle\shortleftarrow}{\raisebox{0.99025pt}{\scriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\textstyle\relbar}}}{\mathbin{{\scriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\scriptstyle\relbar}}}{\mathbin{{\scriptscriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}}}I\mathbin{\mathchoice{\xrightarrow{\varphi_{R}}}{\scalebox{0.8}[1.0]{\textstyle\relbar}{\raisebox{0.99025pt}{\scriptstyle\varphi_{R}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{R}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{R}}}{\shortrightarrow}}}R) if and only if for each morphism , there exists a morphism such that .*
L$$I$$R$$\mathit{core}(T)$$\Leftrightarrow$$\mathcal{L}(T) is closed under application of \rho$$\rho$$\forall t_{L}$$\varphi_{L}$$\varphi_{R}$$\exists t_{R}
Proof
: Notice that if then there is no morphism and we are done. Otherwise, let , and let be defined as . Consider the following diagram, where the top span is the rule, and the two squares are built as pushouts ( is the pushout of ; is the pushout of ).
[TABLE] \textstyle{L\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces}$$\scriptstyle{t_{L}}$$\textstyle{I\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces}$$\scriptstyle{\varphi_{L}}$$\scriptstyle{\varphi_{R}}$$\scriptstyle{n}$$\textstyle{R\ignorespaces\ignorespaces\ignorespaces\ignorespaces}$$\scriptstyle{m}$$\textstyle{{A}\ignorespaces\ignorespaces\ignorespaces\ignorespaces}$$\textstyle{\@ensuremath{\mathit{core}(T)}\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces}$$\scriptstyle{f}$$\scriptstyle{id}$$\textstyle{B\ignorespaces\ignorespaces\ignorespaces\ignorespaces}$$\scriptstyle{g^{\prime}}$$\textstyle{\@ensuremath{\mathit{core}(T)}}
Arrow is uniquely determined because the left square is a pushout and . This arrow witnesses that (because ), and thus by assumption , because obviously . Therefore we know that , and thus that there is an arrow . In general, this arrow does not make the lower right triangle commute, but given that we also have arrow as the base of the right pushout, it follows that and hence . Therefore by Lemma 2, we know that there is an arrow such that (in particular, ). Therefore in the above diagram also the lower right triangle commutes, and arrow satisfies , as desired.
: Assume that by morphism , and that is rewritten to via rule \rho=(L\mathchoice{\xleftarrow{\varphi_{L}}}{\mathbin{{\textstyle\shortleftarrow}{\raisebox{0.99025pt}{\scriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\textstyle\relbar}}}{\mathbin{{\scriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\scriptstyle\relbar}}}{\mathbin{{\scriptscriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{L}}}\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}}}I\mathbin{\mathchoice{\xrightarrow{\varphi_{R}}}{\scalebox{0.8}[1.0]{\textstyle\relbar}{\raisebox{0.99025pt}{\scriptstyle\varphi_{R}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{R}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle\varphi_{R}}}{\shortrightarrow}}}R)\in\mathcal{R}. Also, let be any arrow from to . This gives us the diagram below, where the two squares are pushouts, and the left triangle commutes by taking for the composition .
L$$I$$R$$G$$C$$H$$\mathit{core}(T)$$m$$\varphi_{L}$$n$$\varphi_{R}$$m^{\prime}$$\psi_{L}$$\psi_{R}$$t\circ t_{G}$$t_{R}$$t_{H}
By assumption, since , there exists a morphism such that . This means that the square consisting of commutes, that is . Hence there exists a mediating morphism , which implies because . ∎
0.A.2 Type Graph Logic
Proposition 5.*
For a graph language characterized by a formula , the following problems are decidable:*
- •
Membership, i.e. for all graphs it is decidable if holds.
- •
Emptiness, i.e. it is decidable if holds.
- •
Language inclusion, i.e. given two formulas and it is decidable if holds.
Proof
Membership: The membership problem for graph languages over formulae is decidable since it is decidable for every type graph language . We simply build the syntax tree of the formula and search for morphisms at the leafs of the tree. Afterwards we pass the boolean results up to the root to decide whether holds.
Emptiness: In order to show whether holds, we transform into disjunctive normal form (DNF). It is sufficient to check whether all conjunctions of the form are unsatisfiable. We can assume that there is at most one positive type graph in every conjunction, since type graphs are closed under conjunction/intersection. Furthermore we can even assume that there is exactly one positive type graph, since we always add (the flower graph).
Now we have:
[TABLE]
Therefore, we need to check whether for each of the conjunctions in the DNF of , there exists a morphism for some .
Inclusion: The language inclusion problem can be reduced to the aforementioned emptiness problem. To solve the language inclusion we use the following equivalence:
[TABLE]
Since the emptiness problem is decidable we can conclude that the language inclusion problem is decidable as well. ∎
0.A.3 Annotated Type Graphs
Lemma 1.* The composition of two legal morphisms is a legal morphism. *
Proof
Let and be two legal morphisms in the category of multiply annotated graphs. Since is legal we get that for all there exists such that and hold. Furthermore is legal and therefore we get that for all there exists such that and hold as well. We define to be the composed morphism with and due to the fact that is a functor which preserves monotonicity, we get the following two inequalities:
[TABLE]
Since both and hold, the morphism is legal. ∎
Proposition 6.*
For a graph language characterized by a multiply annotated type graph over the emptiness problem is decidable: iff or for each there exists an edge such that and or . *
Proof
: Assume that , in this case is clearly empty as well. Assume that there is an annotation such that and ( or ) for some edge . Then no graph can satisfy these lower and upper bounds, since we are forced to map at least one edge to , but are not allowed to map any node to the source respectively target node. If this is true for all annotations, the language of the type graph must be empty.
: Now assume that and there exists one annotation such that for every edge with we have and ).
Now take and remove from all edges and nodes with , resulting in a graph . If a node is removed all incident edges are removed as well. Note that in such a case only edges with will be removed (due to the condition above).
Now define and . Due to the considerations above there exists a legal morphisms (embedding) T^{\prime}[\ell^{\prime},u^{\prime}]\mathrel{\raisebox{5.59721pt}{\scalebox{1.0}[-1.0]{\mbox{\looparrowright}}}}T[\ell,u], since the removed items had a lower bound of [math]. Furthermore each remaining item has an upper bound of at least , i.e., it represents at least one node or edge.
Now construct a graph from by proceeding as follows: for every node with add isolated nodes (zero isolated nodes if ). For every edge with put parallel edges between . There is a morphism obtained by mapping every item to the item from which it orginated.
Mapping to via will give us an annotation . This annotation will coincide will the lower bound in all cases, apart from the case where there is a node with . In this case , but this is covered by the upper bound which is at least .
Hence there is a legal graph morphism from to and – by composition – to . Hence and hence . ∎
Proposition 7.* The existence of a legal morphism implies . *
Proof
Every graph has a legal morphism . Whenever there exists a legal morphism between the two multiply annotated type graphs, we obtain the morphism with which is legal due to Lemma 1. Therefore holds and we can conclude that also holds. ∎
Proposition 9.* Let and be two arrows and let be the identity cospan.*
The mapping is a functor:
** 2. 2.
**
Proof
The identity relation consists of all pairs with . Let the two states be given with and . The pair is in the relation if and only if there exists a morphism such that, for all444We write as an abbreviation for . the equation holds and the following diagram commutes:
G$$G$$G$$T$$id_{G}\colon G\mathrel{\raisebox{5.59721pt}{\scalebox{1.0}[-1.0]{\mbox{\looparrowright}}}}G$$f_{1}$$id$$\exists h$$id$$f_{2}
Since the diagram commutes we obtain that since holds and for all the annotation functions and are equal due to the following equation:
[TABLE]
This is equivalent to and therefore for all the following equation holds:
[TABLE]
Therefore holds.
In the following part let c_{1}\colon J\mathbin{\mathchoice{\xrightarrow{g_{1}}}{\scalebox{0.8}[1.0]{\textstyle\relbar}{\raisebox{0.99025pt}{\scriptstyle g_{1}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle g_{1}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle g_{1}}}{\shortrightarrow}}}G\mathchoice{\xleftarrow{g_{2}}}{\mathbin{{\textstyle\shortleftarrow}{\raisebox{0.99025pt}{\scriptstyle g_{2}}}\scalebox{0.8}[1.0]{\textstyle\relbar}}}{\mathbin{{\scriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle g_{2}}}\scalebox{0.8}[1.0]{\scriptstyle\relbar}}}{\mathbin{{\scriptscriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle g_{2}}}\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}}}K and c_{2}\colon K\mathbin{\mathchoice{\xrightarrow{g_{1}^{\prime}}}{\scalebox{0.8}[1.0]{\textstyle\relbar}{\raisebox{0.99025pt}{\scriptstyle g_{1}^{\prime}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle g_{1}^{\prime}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle g_{1}^{\prime}}}{\shortrightarrow}}}H\mathchoice{\xleftarrow{g_{2}^{\prime}}}{\mathbin{{\textstyle\shortleftarrow}{\raisebox{0.99025pt}{\scriptstyle g_{2}^{\prime}}}\scalebox{0.8}[1.0]{\textstyle\relbar}}}{\mathbin{{\scriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle g_{2}^{\prime}}}\scalebox{0.8}[1.0]{\scriptstyle\relbar}}}{\mathbin{{\scriptscriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle g_{2}^{\prime}}}\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}}}L be given and let with c\colon J\mathbin{\mathchoice{\xrightarrow{g_{1};j_{1}}}{\scalebox{0.8}[1.0]{\textstyle\relbar}{\raisebox{0.99025pt}{\scriptstyle g_{1};j_{1}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle g_{1};j_{1}}}{\shortrightarrow}}{\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}{\raisebox{0.6458pt}{\scriptscriptstyle g_{1};j_{1}}}{\shortrightarrow}}}G^{\prime}\mathchoice{\xleftarrow{g_{2}^{\prime};j_{2}}}{\mathbin{{\textstyle\shortleftarrow}{\raisebox{0.99025pt}{\scriptstyle g_{2}^{\prime};j_{2}}}\scalebox{0.8}[1.0]{\textstyle\relbar}}}{\mathbin{{\scriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle g_{2}^{\prime};j_{2}}}\scalebox{0.8}[1.0]{\scriptstyle\relbar}}}{\mathbin{{\scriptscriptstyle\shortleftarrow}{\raisebox{0.6458pt}{\scriptscriptstyle g_{2}^{\prime};j_{2}}}\scalebox{0.8}[1.0]{\scriptscriptstyle\relbar}}}L be the composed morphism of and .
Let be given with and such that and . Then there exists a morphism such that holds for all and the following diagram commutes:
J$$G$$K$$H$$L$$G^{\prime}$$T$$c_{1}\colon J\mathrel{\raisebox{5.59721pt}{\scalebox{1.0}[-1.0]{\mbox{\looparrowright}}}}K$$c_{2}\colon K\mathrel{\raisebox{5.59721pt}{\scalebox{1.0}[-1.0]{\mbox{\looparrowright}}}}L$$f_{1}$$g_{1}$$g_{1}^{\prime}$$g_{2}^{\prime}$$j_{1}$$j_{2}$$\exists h$$g_{2}$$f_{3}
To prove that is satisfied from the above properties, we need to show that there exists a where such that and . Let . Then there must exist two morphisms , such that the following six properties hold:
[TABLE]
[TABLE]
We define to be and which already satisfy the following four properties:
[TABLE]
We define with respect to property , such that for all the equation holds. Due to property we get the following equation for , for which we need to prove that it holds for all elements :
[TABLE]
We prove the following equation instead for all , from which we can easily derive afterwards that also holds:
[TABLE]
Since the morphisms and are both injective and is the pushout object of and over the common graph we get that . Subtracting all elements that are being mapped into on both sides of the equation, we get that holds as well. Using this fact we can prove equation which holds for all :
[TABLE]
Using equation we conclude that property always holds for all :
[TABLE]
Therefore holds as well.
Let two pairs and be given with , and such that , and . Then in addition there exist two morphisms and such that for all the two equations and
both hold and the following diagram commutes:
J$$G$$K$$H$$L$$T$$c_{1}\colon J\mathrel{\raisebox{5.59721pt}{\scalebox{1.0}[-1.0]{\mbox{\looparrowright}}}}K$$c_{2}\colon K\mathrel{\raisebox{5.59721pt}{\scalebox{1.0}[-1.0]{\mbox{\looparrowright}}}}L$$f_{1}$$g_{1}$$g_{1}^{\prime}$$f_{2}$$g_{2}^{\prime}$$\exists h_{1}$$\exists h_{2}$$g_{2}$$f_{3}
To prove that is satisfied from the properties gained so far, we need to show that holds and that there exists a morphism such that the following diagram commutes:
J$$G$$K$$H$$L$$G^{\prime}$$T$$(PO)$$c_{1}\colon J\mathrel{\raisebox{5.59721pt}{\scalebox{1.0}[-1.0]{\mbox{\looparrowright}}}}K$$c_{2}\colon K\mathrel{\raisebox{5.59721pt}{\scalebox{1.0}[-1.0]{\mbox{\looparrowright}}}}L$$f_{1}$$g_{1}$$g_{1}^{\prime}$$j_{1}$$j_{2}$$g_{2}^{\prime}$$h_{1}$$\exists h$$h_{2}$$g_{2}$$f_{3}
The morphism exists and is unique due to the universal property of pushouts. From the two equations and we can derive the following equation which holds for all :
[TABLE]
Using the results of equation from the previous proof direction, we directly can conclude that also holds and therefore holds, which completes this proof. ∎
Proposition 10.* Let the multiply annotated type graph (over ) and the corresponding automaton functor for be given. Then holds, i.e. for a graph we have if and only if there exist states and such that , where . *
Proof
We will prove the following equality:
[TABLE]
””: Since holds, there exists a legal morphism and a pair of multiplicities such that holds. Let be and which are clearly in the relation , i.e. since for all the equation holds by definition and the following diagram commutes:
\varnothing$$G$$\varnothing$$T$$c\colon\varnothing\mathrel{\raisebox{5.59721pt}{\scalebox{1.0}[-1.0]{\mbox{\looparrowright}}}}\varnothing$$f_{1}$$g_{1}$$\varphi$$g_{2}$$f_{2}
””: There exists and with and such that holds. Therefore, there exists a pair of multiplicities with and we get that there exists a morphism such that the following diagram commutes:
\varnothing$$G$$\varnothing$$T$$c\colon\varnothing\mathrel{\raisebox{5.59721pt}{\scalebox{1.0}[-1.0]{\mbox{\looparrowright}}}}\varnothing$$f_{1}$$g_{1}$$\exists\varphi$$g_{2}$$f_{2}
For all the following equation holds:
[TABLE]
From we can infer that is a legal morphism due to the fact that holds as well, and therefore . ∎
Proposition 11.*
The category of multiply annotated graphs is closed under intersection. *
Proof
Let two multiply annotated type graphs and be given. Let be the usual product graph in the underlying category .
We now consider the multiply annotated type graph where the set of annotations is defined as follows:
[TABLE]
Therefore for each there exist and such that the following four properties hold:
[TABLE]
\textstyle{(T_{1}\times T_{2})[N]\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces}$$\scriptstyle{\pi_{1}}$$\scriptstyle{\pi_{2}}$$\textstyle{T_{1}[M_{1}]}$$\textstyle{T_{2}[M_{2}]}
We will now prove the following equality:
[TABLE]
: Let . Then there exist two legal morphisms and . Due to the universal property of pullbacks in the underlying category , there exists a unique graph morphism such that the following diagram commutes:
\textstyle{G[s_{G},s_{G}]\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces}$$\scriptstyle{\varphi_{1}}$$\scriptstyle{\varphi_{2}}$$\scriptstyle{\eta}$$\textstyle{(T_{1}\times T_{2})[N]\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces}$$\scriptstyle{\pi_{1}}$$\scriptstyle{\pi_{2}}$$\textstyle{T_{1}[M_{1}]}$$\textstyle{T_{2}[M_{2}]}
Since with is a legal morphism, there exist annotations and such that the following inequalities hold:
[TABLE]
Therefore the pair is one of the annotations in and we can conclude that holds.
: We now assume . Then there exists a legal morphism with an annotation pair such that . For each such pair we have two legal morphisms and , by construction. We obtain two morphisms with and with , which are legal due to Lemma 1. Therefore we can conclude that . ∎
In order to show closure under union for annotated type graphs over , we first have a look at the following lemma.
Lemma 3
*Assume that we are working with annotations over .
Let and be two legal graph morphisms where is injective. Let be one of the double multiplicities of the graph . Whenever , we can deduce that there exists a graph morphism with , i.e. the diagram commutes.
\textstyle{G[s_{G},s_{G}]\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces}$$\scriptstyle{\varphi}$$\scriptstyle{\zeta}$$\textstyle{A[M]\ignorespaces\ignorespaces\ignorespaces\ignorespaces}$$\scriptstyle{i}$$\textstyle{T[N]}
Proof
The morphisms exists if all elements of the form with are in the range of . For such an we have , since is the sum of the -annotations of all preimages of . Furthermore . But for all that are not in the range of , since the empty sum evaluates to [math]. But since , we can conclude that has a preimage under . ∎
In addition, we need the concept of reduction: the reduction operation shifts annotations over morphisms in the reverse direction.
Definition 15 (Reduction)
Let be an (annotation) functor. For a morphism and a monoid element we define the reduction of to as follows:
[TABLE]
In the case of concrete annotations, the reduction operator satisfies the following properties:
Lemma 4
Assume that we are working with annotations over . If is injective, we obtain the following equality for all :
[TABLE]
Furthermore, if is injective, it holds that for every .
Proof
Straightforward from the definition of concrete annotations. ∎
We are now ready to prove closure under union for the concrete case. Since we do work with abstract annotations in the proof, but need the results of the lemmas, one could generalize this result to a setting where the properties stated in Lemma 3 and Lemma 4 hold.
Proposition 12.* The category of multiply annotated graphs over functor is closed under union.*
Proof
Let two multiply annotated type graphs and be given. Let be the usual coproduct graph in the underlying category , together with the embedding morphisms and :
\textstyle{T_{1}[M_{1}]\ignorespaces\ignorespaces\ignorespaces\ignorespaces}$$\scriptstyle{i_{1}}$$\textstyle{T_{2}[M_{2}]\ignorespaces\ignorespaces\ignorespaces\ignorespaces}$$\scriptstyle{i_{2}}$$\textstyle{T_{1}\oplus T_{2}[N]}
We define the set of annotations for the multiply annotated type graph using the following two sets:
[TABLE]
Finally we define .
By this definition, we get that for all elements and for all there exists such that and . This makes a legal morphism since . The same holds for analogously. We will now prove the following equality:
[TABLE]
: Let . Then there exists at least one legal morphism or . We assume that . Let be the composed morphism of and with . Then is legal due to Lemma 1 and therefore holds. The proof for the case where works in the same way.
: We now assume . Then, there exists a legal morphism with an annotation such that . For each , we know that the pair belongs to or . Assume that . Then we know that there exists such that , . Hence . From Lemma 3 it follows that there exists a graph morphism with such that the following diagram commutes in the underlying category :
\textstyle{G[s_{G},s_{G}]\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces}$$\scriptstyle{\zeta_{1}}$$\scriptstyle{\eta}$$\textstyle{T_{1}[M_{1}]\ignorespaces\ignorespaces\ignorespaces\ignorespaces}$$\scriptstyle{i_{1}}$$\textstyle{T_{2}[M_{2}]\ignorespaces\ignorespaces\ignorespaces\ignorespaces}$$\scriptstyle{i_{2}}$$\textstyle{(T_{1}\oplus T_{2})[N]}
We need to prove that is a legal graph morphism in the category of multiply annotated graphs. We get that and since is injective, the following inequality holds due to the fact that is monotone and holds for every , whenever is injective (cf. Lemma 4):
[TABLE]
Therefore is a legal morphism and we can conclude that . For a legal morphism with a pair we get a similar proof which shows that . Summarizing, in all cases holds.
Appendix 0.B Extended Example: Annotated Type Graphs
In order to illustrate the use of annotated type graphs in applications, we model a client-server scenario with the following specification:
- •
There exists exactly one server.
- •
An arbitrary number of users can connect to the server, even using multiple connection sessions at the same time.
- •
There exists one user with special administrative rights.
- •
At least one user is always connected to the server.
- •
The server can host an arbitrary number of files from which at most one can be edited at the same time.
The above scenario can be modelled using an annotated type graph (see below). We will use the following edge labels: -labeled loops for administrative rights, -labeled edges for connections between users and the server and -labeled edges which are pointing to the file that is currently edited. We now extend the requirements of our specification:
- •
The user with the administrative rights is always connected to the server.
- •
There has to be at least one file on the server.
We use the annotated type graph , depicted below to model the extended scenario.
[TABLE]
Since the second scenario is more restrictive than the first, there exist graphs in , which do not fulfil the additional requirements of the extended specification.
For instance the graph shown to the right is such a model, which describes that there exists a user with administrative rights but he is not connected to the server. Instead there is another user which is currently connected. However, it holds that that , since we can easily find a legal graph morphism .
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1[1] Parosh Aziz Abdulla, Lukás Holík, Bengt Jonsson, Ondrej Lengál, Cong Quy Trinh, and Tomás Vojnar. Verification of heap manipulating programs with ordered data by extended forest automata. In Proc. of ATVA ’13 , pages 224–239, 2013. LNCS 8172.
- 2[2] Christoph Blume, H.J. Sander Bruggink, Dominik Engelke, and Barbara König. Efficient symbolic implementation of graph automata with applications to invariant checking. In Proc. of ICGT ’12 , pages 264–278. Springer, 2012. LNCS 7562.
- 3[3] Christoph Blume, H.J. Sander Bruggink, Martin Friedrich, and Barbara König. Treewidth, pathwidth and cospan decompositions with applications to graph-accepting tree automata. Journal of Visual Languages & Computing , 24(3):192–206, 2013.
- 4[4] H.J. Sander Bruggink and Barbara König. On the recognizability of arrow and graph languages. In Proc. of ICGT ’08 , pages 336–350. Springer, 2008. LNCS 5214.
- 5[5] Edmund M. Clarke, Orna Grumberg, Somesh Jha, Yuan Lu, and Helmut Veith. Counterexample-guided abstraction refinement for symbolic model checking. Journal of the ACM , 50(5):752–794, 2003.
- 6[6] Andrea Corradini, Ugo Montanari, and Francesca Rossi. Graph processes. Fundamenta Informaticae , 26(3/4):241–265, 1996.
- 7[7] Bruno Courcelle. The monadic second-order logic of graphs I. Recognizable sets of finite graphs. Information and Computation , 85:12–75, 1990.
- 8[8] Bruno Courcelle and Joost Engelfriet. Graph Structure and Monadic Second-Order Logic, A Language-Theoretic Approach . Cambridge University Press, June 2012.
