More on Graph Rewriting With Contextual Refinement Berthold - - PowerPoint PPT Presentation

more on graph rewriting with contextual refinement
SMART_READER_LITE
LIVE PREVIEW

More on Graph Rewriting With Contextual Refinement Berthold - - PowerPoint PPT Presentation

More on Graph Rewriting With Contextual Refinement Berthold Hoffmann, Universitt Bremen Workshop on Graph Computational Models 2014 York, 21. July 2014 1/18 Motivation GRGEN has been the starting point a very efficient graph rewriting


slide-1
SLIDE 1

More on Graph Rewriting With Contextual Refinement

Berthold Hoffmann, Universität Bremen

Workshop on Graph Computational Models 2014 York, 21. July 2014

1/18

slide-2
SLIDE 2

Motivation

GRGEN has been the starting point

◮ a very efficient graph rewriting tool ◮ with expressive rules:

◮ Attributes ◮ Subtyping (labels, attributes) ◮ Nested application conditions (with recursive

refinement)

◮ Recursive rule refinement

◮ Other graph rewriting tools support analysis and

verfification

◮ This provides an enormous “additional value”

◮ We want to support analysis of GRGEN rules

◮ We concentrate on rule refinement ◮ We translate refinement into simple rules

(which are used with a strategy)

2/18

slide-3
SLIDE 3

Outline of this Talk

Rewriting... ...of Graphs ...of Rules Rule Schemata Meta-Rules (Based on Contextual Hyperedge Replacement) Translation to Simple Rules Correctness Termination Conclusions Related and Future Work

3/18

slide-4
SLIDE 4

Refactoring Program Graphs

◮ If all subclasses of a class

  • verride the same method,

◮ Pull up one method, remove the

  • thers

C S C C C S B V E V V B B E E E E V E E

C S C C C S B V E V V B E E

4/18

slide-5
SLIDE 5

Refactoring Program Graphs

◮ If all subclasses of a class

  • verride the same method,

◮ Pull up one method, remove the

  • thers

◮ A simple rule has a fixed pattern C S C C C S B V E V V B B E E E E V E E

C S C C C S B V E V V B E E C C S C B V S B B E E E E E E V E E

4/18

slide-6
SLIDE 6

Refactoring Program Graphs

◮ If all subclasses of a class

  • verride the same method,

◮ Pull up one method, remove the

  • thers

◮ A simple rule has a fixed pattern ◮ A schema generates

a language of patterns

C S C C C S B V E V V B B E E E E V E E

C S C C C S B V E V V B E E C B S C

1 ... C k

C

...

B ... B B Bdy0

...

Bdy0 Bdy1

⇓∗

C C S C B V S B B E E E E E E V E E

4/18

slide-7
SLIDE 7

Graph Rewriting – the dual way

Pattern Body Replacement Source Union Target

Glue Clip

◮ All morphisms are monos

5/18

slide-8
SLIDE 8

Rule Rewriting

◮ Rule morphisms r → r′ are triples of commuting graph

morphisms P

r :

B R P′

r′ :

B′ R′

◮ Rule rewriting is defined by pushouts of rules and rule

morphisms p

δ:

b r s u t

6/18

slide-9
SLIDE 9

Pull Up Method – Schema and Meta-Rules

C B S C

1 ... C k

C

...

B ... B B Bdy0

...

Bdy0 Bdy1 B E

1

... E

n

Bdy0 Exp0

· · ·

Exp0 Exp0 E V Expi Exp0 E V E Exp0 Exp0 E E

1

... E

n

S Exp0

· · ·

Exp0 ◮ Method bodies are geneated by contextual rules

7/18

slide-10
SLIDE 10

Pull Up Method – Schema and Meta-Rules

C B S C

1 ... C k

C

...

B ... B B Bdy0

...

Bdy0 Bdy1 B E

1

... E

n

Bdy0 Exp0

· · ·

Exp0 Exp0 E V Expi Exp0 E V E Exp0 Exp0 E E

1

... E

n

S Exp0

· · ·

Exp0 ◮ Method bodies are geneated by contextual rules ◮ Meta-rules delete / copy a method body (up to its

context)

7/18

slide-11
SLIDE 11

Pull Up Method – Schema and Meta-Rules

C B S C

1 ... C k

C

...

B ... B B Bdy0

...

Bdy0 Bdy1 B E

1

... E

n

Bdy0 Exp0

· · ·

Exp0 Exp0 E V Expi Exp0 E V E Exp0 Exp0 E E

1

... E

n

S Exp0

· · ·

Exp0 ◮ Method bodies are geneated by contextual rules ◮ Meta-rules delete / copy a method body (up to its

context)

◮ Context nodes may be in the schema, or in the

source graph

7/18

slide-12
SLIDE 12

Pull Up Method – Schema and Meta-Rules

C B S C

1 ... C k

C

...

B ... B B Bdy0

...

Bdy0 Bdy1 B E

1

... E

n

Bdy0 Exp0

· · ·

Exp0 Exp0 E V Expi Exp0 E V E Exp0 Exp0 E E

1

... E

n

S Exp0

· · ·

Exp0 B E

1

... E

n

B

1

E

1

... E

n

Bdy1 Exp1 · · · Exp1 Exp1 E V E Exp1 Exp1 E V E E E Exp1 Exp1 E E

1

... E

n

S E

1

E

1

... E

n

Exp1

· · ·

Exp1

· · ·

◮ Method bodies are geneated by contextual rules ◮ Meta-rules delete / copy a method body (up to its

context)

◮ Context nodes may be in the schema, or in the

source graph

7/18

slide-13
SLIDE 13

A Refinement of Pull up Method

C B S C C C B B E E E Exp0 Exp1 Exp1 E V E E E Exp1 C B S C C C B B E E E E V E Exp0 Exp1

◮ Context node V does not occur in the source schema ◮ With the context-free meta-rule, we “delay” matching

to the source graph

8/18

slide-14
SLIDE 14

Schema Refinement

◮ A schema is a rule s: (P → B ← R)

where meta-variables appear only in the body B

◮ A meta rule is a rule rewrite rule δ: (p → b ← r)

where the body rule δB : (B

p → Bb ← Rb) is contextual ◮ A finite set ∆ of meta-rules generates rules (instances)

∆(s) = {r | s ∗ ⇒

∆ r, r is meta-variable-free}

∆ shall also contain “less contextual variations”

◮ Rewriting with refinement: S ◦

s,∆ T if S ⇒r T for some

r ∈ ∆(s) Assumption

◮ ∆ generates a non-empty set of rules

9/18

slide-15
SLIDE 15

Incremental Rules for Pull-Up Method

C B S C

1 ... C k

C

...

B ... B B Bdy0

...

Bdy0 Bdy1 Exp1 E V E E E Exp1 Exp1 E V E E E Exp1 C B S C

1 ... C k

C

...

B ... B B Bdy0 Bdy0 Bdy1 Exp1 E V E E E Exp1 Exp Exp1 E V E E E Exp1 Exp

10/18

slide-16
SLIDE 16

Translation to Simple Rules

Incremental Rules

◮ Schemata: Turn meta-variables into variables of the

replacement (with their attachments)

◮ Meta-rules: Turn meta-variables into variables of the

pattern and replacement Residual Rewriting (◦ ⇒)

◮ Matches of incremental meta-rules must overlap only

in variables and their attachments

◮ Incremental meta-rules have priority over incremental

schemata: S ◦ ⇒

˜ s S′ !

˜ ∆

T

11/18

slide-17
SLIDE 17

Correctness

◮ Refinement

corresponds to compositions of incremental rules

◮ If r is

meta-variable-free, ˜ r = r by construction

◮ Rewriting with a

composed incremental rule corresponds to residual rewrite sequences with incremental rules s ˜ s t ˜ t = ˜ s ◦m, ¯

m ˜

δ1 r ˜ r = ˜ s ◦ ˜ δ1 · · · ◦ ˜ δn

δ1 m ∆ ∗

S S′ T

˜ r ˜ s

  • ˜

12/18

slide-18
SLIDE 18

C B S C C C B B E E E Exp0 Exp1 Exp1 E V E E E Exp1 C B S C C C B B E E E E V E Exp0 Exp1 C B S C C C B B E E E Exp0 Exp1

← − ↓

E E Exp1

d

  • d

Exp1 E V E E E Exp1 Exp

=

C B S C C C B B E E E E V E Exp0 Exp1

13/18

slide-19
SLIDE 19

Termination of Residual Rewriting

◮ A meta-rule (p ֒

→ b ← ֓ r) refines its pattern

◮ if it adds terminal nodes or edges to Bp, or ◮ if Bb does not contain meta-variables

Theorem

For a schema s and a set ∆ of pattern-refining meta-rules, residual rewriting of incremental rules terminates

◮ The replicative meta-rules for Pull Up Method refine

their patterns

14/18

slide-20
SLIDE 20

Summary

◮ Rules with contextual refinement

◮ match, ◮ delete, ◮ replicate, and ◮ transform

subgraphs of arbitrary size and varying shape

◮ They are entirely rule-based ◮ They translate to simple graph rewrite rules

used with

◮ residual matches and ◮ priority to meta-rules 15/18

slide-21
SLIDE 21

Related Work

Rules with variables

◮ Substitutive transformation (Plump-Habel:96) ◮ HR-shaped (hierarchical) graph transformation

(Hoffmann:01)

◮ ASR-shaped graph transformation (Drewes et al:07) ◮ NCE rewriting (Janssen:83) can be modeled by

refinement Analysis of graph rewrite systems

◮ Verification: Augur, Raven (Duisburg) ◮ State space exploration: Groove (Twente) ◮ Termination: ?? (Duisburg) ◮ Local confluence (critical pair analysis)

◮ AGG (TU Berlin) ◮ GP2 (York, work in progress) 16/18

slide-22
SLIDE 22

Future Work

Next steps

◮ Combination with nested application conditions and

attributes (This should be straight-forward)

◮ What about recursively refined conditions?

(Habel-Radke) Our Overall Aim

◮ Critical pair analysis

◮ Impossible in general! ◮ Possible for graph rewriting preserving unambiguous

shapes?

17/18

slide-23
SLIDE 23

Thank You!

18/18