Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

36
Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03

Transcript of Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Page 1: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Introduction to

Graph Grammars

Fulvio D’AntonioLEKS, IASI-CNRRome, 14-10-03

Page 2: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Summary

Basic conceptsDouble pushout approachSingle pushout approachToolsReferences

Page 3: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Graph grammars

Algebraic approaches were developed at the Technical University of Berlin

The main idea was that of extending concatenation of strings to a “gluing” of graphs

The action of gluing two graphs is a construction, in the category of graphs and graph morphisms, called pushout

Graph grammars has been invented (in early seventies) in order to generalize (Chomsky) string grammars.

Page 4: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Graph grammars: definition

A graph grammar is a pair: GG = (G0,P)

G0 is called the starting graph and P is a set of production rules

L(GG) is the set of graphs that can be derived starting with G0 and applying the rules in P

Page 5: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

A graph…

Page 6: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Definition

A pair (V,E) of finite sets :E V V

E is a set of ordered pairs of vertexes.

Graphically we represent an edge (v1,v2) with an arrow starting in v1 and ending in v2

Page 7: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Another graph …

This is a multigraph

Page 8: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Another definition

A pair (V,E) where V is a finite set, E is a finite multiset with elements in VV

E.g. V= v1,v2,…., vn

E = (v1,v2),….,(v1,v2),…

Page 9: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Yet another graph …

This is a labelled multigraph: elements without a label are considered labelled

with the null symbol

a

b

A

A

Page 10: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Yet another definition

A pair (V,E) where:

V is a finite set of pairs and E is a finite set of triples.

Too complicated!

Page 11: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

A more elegant definition (algebraic style)

A graph is a tuple (V,E,s,t,lV,lE):

V and E are two finite sets (VE=)

s,t : E V are two mappings indicating the source and the target of an edge

lV: V V e lE: E E are two mappings from from V and E in two finite sets of labels

Page 12: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Example

A

A

B

B

E

Notes:

The edges are directed

Two vertexes with the same label

Multiple edges (even with the same label!) between two vertexes

Page 13: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Example 2:Pacman graph (PG)

Page 14: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Graph morphism: informally speaking

Given two graphs G and G’ we want to know if G’ “contains” G.

We can try to draw a correspondence between every vertex (edge) of G and a vertex (edge) of G’

This correspondence is a graph morphism (if it respects some properties!)

Page 15: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Example: G is contained in G’

A

AB

B

E

G’G

A

A

B1

3

2

1

3

2

This is a correct graph morphism

Page 16: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Example 2

A

AB

B

E

G’G

A B1

3

2

1

3

This is not a correct graph morphism

2

Page 17: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Example 3

A

AB

B

E

G’G

1,3

2,4

This is a correct non-injective graph morphism

E

E2

1

3

4

Page 18: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Graph morphism

a graph morphism is a pair (1,2), 1:V V’, 2: E E’

such as:1)labels are preserved i.e. lV(vi) = lV’(1(vi)) etc.

2)incidence is preserved i.e. 1(s(ei)) = s’(2(ei))) etc.

Given G =(V,E,s,t,lV,lE)

and G’=(V’,E’,s’,t’,lV’,lE’)

Page 19: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

What is a pushout?(Very very informal)

“Gluing” of two objects along a common substructure

Page 20: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Summary

Basic conceptsDouble pushout approachSingle pushout approachToolsReferences

Page 21: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Graph grammars:Double pushout approach

The format of a production rule is:

p : L l K r R

L,K,R are graphs and l,r are two (total) morphisms matching K, respectively,in L and R

Page 22: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Example

movePacman :

L K R

Page 23: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Derivation

Given: a graph G,a production p:L l K

r R and a graph morphism :L G

1)The context graph is obtained “deleting” from G all elements images of elements in L but not of elements in K (pushout complement)

2)The final graph is obtained “adding” to context graph all elements which don’t have a pre-image in K(pushout)

Page 24: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Example

movePacman :

The graph G

The match

L K R

Page 25: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

The context graph

The match

Page 26: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

The final graph H

The match

G ,p H

G * ,p Gn (reflexive symmetric and

transitive closure)

Page 27: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Other rules in Pacman game

MoveGhost:

Kill:

Page 28: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Summary

Basic conceptsDouble pushout approachSingle pushout approachToolsReferences

Page 29: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Single pushout approach

The format of a production rule is:p : L r R

r is a partial graph morphism

A single derivation step is modelled by a single-pushout diagram

Page 30: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Example

L R

1

2

3

4

1

2

3

4

r is a partial morphism

r

Page 31: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Difference between the two approaches

Double-pushout approach requires two further conditions for a step derivation (dangling and identification condition)

Single-pushout doesn’t requires such conditions

Single pushout rules can model more situations than double pushout rules

Page 32: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Summary

Basic conceptsDouble pushout approachSingle pushout approachToolsReferences

Page 33: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Progres

PROGRES is an integrated environment for a very high level programming language which has a formally defined semantics based on "PROgrammed Graph REwriting Systems"

AggAGG is a rule based visual language supporting single pushout approach to graph transformation. It aims at the specification and prototypical implementation of applications with complex graph-structured data.

Page 34: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Fujaba

Atom3

Grace and Graceland

Other tools

Page 35: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

Standards

GXL (Graph Exchange Language)

GTXL (Graph Transformation Exchange Language)

Page 36: Introduction to Graph Grammars Fulvio D’Antonio LEKS, IASI-CNR Rome, 14-10-03.

ReferencesPeople:G.Rozenberg,A.Schurr, R.Heckel, G.Taentzer, P.Bottoni, F.Parisi-Presicce, A.Corradini, H.Ehrig, H.G.Kreowsky.

Theory:G. Rozenberg, editor. Handbook of Graph Grammars and Computing by Graph Transformation, Volume 1-3: Foundations. World Scientific, 1997. Corradini, A., Montanari, U., Rossi, F., Ehrig, H., Heckel, R., Löwe, M. Algebraic Approaches to Graph Transformation Part I: Basic Concepts and Double Pushout Approach Corradini, A. Concurrent Graph and Term Graph Rewriting Proc. CONCUR'96, LNCS

Tools:Progres homepage: http://www-i3.informatik.rwth-aachen.de/research/projects/progres/main.htmlAgg homepage:http://tfs.cs.tu-berlin.de/agg/Graceland homepage:http://www.informatik.uni-bremen.de/theorie/GRACEland/GRACEland.htmlFujaba homepage:http://www.fujaba.de/Atom3:http://atom3.cs.mcgill.ca/

Standard:GXL: http://www.gupro.de/GXL/