i-Neighbourhood Abstraction in Graph Transformation Arend Rensink University of Twente Based on work with: Jörg Bauer, Iovka Boneva, Dino Distefano, Marcus Kurban AHA, Berlin, July 2007
Abstraction in Graph Transformation2 Outline Setting – Graphs, rules, productions Abstraction – Quotients, neighbourhoods, shapes Logic – Modalities, preservation Framework – Extraction, transformation, normalization Conclusion – Future work
AHA, Berlin, July 2007Abstraction in Graph Transformation3 Setting System specification: Graph grammar – Graph transformation rules + start graph – May be generated from specification or programming language, or given directly Requirements: LTL properties – Propositions are predicates over graphs Verification: model checking – States = graphs, transitions = productions Problem: the usual – Very large or infinite state spaces – Genericity of analysis
AHA, Berlin, July 2007Abstraction in Graph Transformation4 Graph formalism Graphs in this presentation: – Directed, edge-labelled – Simple (no parallel identically labelled edges) – Flat (not hierarchical) Formally: G = (N,E) with – L universe of labels – N finite set of nodes – E N L N ? finite set of labelled edges ((v,a, ? ) is effectively a node label) Morphisms (partial/total) – Structure-preserving node mappings
AHA, Berlin, July 2007Abstraction in Graph Transformation5 LHS Rule formalism LHS is matched to host graph Matched elements outside morphism domain are deleted Elements outside morphism codomain are added NACs are forbidden 1:Customer 2:Cart RHS 1:Customer 2:Cart cart partial morphism NAC 1:Customer 3:Cart NAC 3:Customer 2:Cart
AHA, Berlin, July 2007Abstraction in Graph Transformation6 Single-graph view on rules Red dashed: NAC \ LHS Black: LHS Å RHS Green: RHS \ LHS
AHA, Berlin, July 2007Abstraction in Graph Transformation7 forbidden Graph Productions Production rule host graph matching Graph transition src(t)tgt(t) morph(t) result graph pushout NAC NACs (SPO = Single Pushout Approach) LHSRHS rule morphism (partial)
AHA, Berlin, July 2007Abstraction in Graph Transformation8 Outline Setting – Graphs, rules, productions Abstraction – Quotients, neighbourhoods, shapes Logic – Modalities, preservation Framework – Extraction, transformation, normalization Conclusion – Future work
AHA, Berlin, July 2007Abstraction in Graph Transformation9 Abstraction: Requirements Productions should be preserved G -p-> H implies (G) –p-> (H) No spurious productions X –p-> Y implies G –p-> H – for some G 2 -1 (X) and some H 2 -1 (Y) – for all G 2 -1 (X), for some H 2 -1 (Y) (i.e., rule applicability is reflected) Properties should be reflected – (G) ² implies G ² – Inductively carries over to LTL operators Method suitable for liveness properties (But few liveness properties hold on abstract model)
AHA, Berlin, July 2007Abstraction in Graph Transformation10 Abstraction: Idea Quotient the graph w.r.t. similarity: G/ » = (N/ », E/ », mult) with N/ » = { [v] » | v 2 N } E/ » = { ([v] », a, [w] » ) | (v,a,w) 2 E } mult: V |V| M for V 2 N/ » (bounded multiplicities: M = {0,1,…, }) Similarity should preserve structure: – v » w implies in(v) = in(w) with in(v) = { a | 9 v’: (v’,a,v) 2 E }, or in(v) = { (a,|V| M ) | V = {v’|(v’,a,v) 2 E} ; } – Analogous for out and node labels
AHA, Berlin, July 2007Abstraction in Graph Transformation11 Examples Similarity without edge multiplicities – all Objects similar Similarity with edge multiplicities – sharing information preserved ListCell Object next val
AHA, Berlin, July 2007Abstraction in Graph Transformation12 Abstraction: Neighbourhoods Family ( » i ) i of refining similarity relations Basis » 0 : node label equality v » i+1 w iff v » i w and for all U 2 N/ » i : – in M (v,U) = in M (w,U) – out M (v,U) = out M (w,U) where in M (v,U) = { (a,|V| M ) | V = {v’ 2 U|(v’,a,v) 2 E} ; } (and analogous for out M (v,U)) Intuition: (enriched) bisimilarity – More general: partition refinement
AHA, Berlin, July 2007Abstraction in Graph Transformation13 Example ListCell Object next val ListCell Object next val ListCell Object next val »0»0 »1»1 »2»2
AHA, Berlin, July 2007Abstraction in Graph Transformation14 Shapes Graph quotient has no edge multiplicities – Not suitable for canonical abstraction Shape: (G, ',mult n,mult in,mult out ) with – G: (quotiented) graph – ' µ N G £ N G : grouping relation – mult n : N G ! M: node multiplicity function – mult in : N G £ L £ (N G / ' ) ! M: incoming edge multiplicity function – mult out : analogous to mult in Edge multiplicities measured w.r.t. '
AHA, Berlin, July 2007Abstraction in Graph Transformation15 Shape of a graph S shapes G if there is a morphism s with – s a morphism from G to G S – for all v 2 N S : mult n (v) = |s -1 (v)| M – for all v = s(w), a 2 L and U 2 N S / ' S : mult in (v,a,U) = | {w’ 2 s -1 (U)|(w’,a,w) 2 E S } | M Shape constructed from G using two equivalences: S = G/ ´, ' (with ´ µ ' ) – Quotienting done w.r.t. ´ – Grouping relation derived from ' i-neighbourhood shape: S G i = G/ » i, » i-1
AHA, Berlin, July 2007Abstraction in Graph Transformation16 Canonical names i-neighbourhood shapes have a canonical representation – Unique up to isomorphism – Good for join & symmetry reduction i-Level canonical names (L finite): – Node names:CN 0 = 2 L (node labels) CN i+1 = CN i £ (CN i £ L ! M) 2 – Edge names: CE i = CN i £ L £ CN i – C i (G) = (name G i (N G ), name G i (E G ), mult) Theor: S G i S H i if and only if C i (G) = C i (H) Canonical name construction for G, also defined inductively
AHA, Berlin, July 2007Abstraction in Graph Transformation17 Outline Setting – Graphs, rules, productions Abstraction – Quotients, neighbourhoods, shapes Logic – Modalities, preservation Framework – Extraction, transformation, normalization Conclusion – Future work
AHA, Berlin, July 2007Abstraction in Graph Transformation18 Logic Modal fragment ML of FOL ::= True | p | : | Ç | i a i ¢ | h a h ¢ – p stands for a node label – i a i ¢ : there are (at least) outgoing a-edges of which the target satisfies ( 2 M) – Other operators standard Satisfaction for graphs straightforward – Predicate G, v ² (where v 2 N G ) – G,v ² i a i ¢ iff · | {v’|(v,a,v’) 2 E, G,v’ ² } | M ML[i]: modalities nested up to i deep
AHA, Berlin, July 2007Abstraction in Graph Transformation19 Example properties For the shopping example: – An item is owned by a shop or a customer: Item ) h owns h ¢ (Shop Ç Customer) – All items on a shop rack are shop-owned: Shop ) ]rack] ¢ ]contains] ¢ h owns h ¢ Shop – A customer has at most one cart: Customer ) : i cart i ¢ true For the list example: – There is no list with exactly 1 element: List ) : i next i ¢ : i next i ¢ True – Objects are not shared: Object ) : h val h ¢ true Not necessaryly the same shop!
AHA, Berlin, July 2007Abstraction in Graph Transformation20 Result: Property preservation Extend satisfaction to shapes – S,v ² i a i ¢ iff · U 2 X mult out (v,a,U) where X = { U 2 N S / ' | 8 v 2 U: S,v ² } Theorem: for all 2 ML[i], all G and all v 2 N G : G,v ² iff S G i, s(v) ² In words: All properties in i-nested modal logic are preserved and reflected by i-neighbourhood abstraction
AHA, Berlin, July 2007Abstraction in Graph Transformation21 Outline Setting – Graphs, rules, productions Abstraction – Quotients, neighbourhoods, shapes Logic – Modalities, preservation Framework – Extraction, transformation, normalization Conclusion – Future work
AHA, Berlin, July 2007Abstraction in Graph Transformation22 Framework Basic idea: build a LTS based on shapes – Define “shape transformation” Concepts: – p: LHS ! S is a pre-matching if p = s ± m for some shaping s: G ! S and matching m: LHS ! G – p is concrete if for all v 2 N LHS, mult n (p(v)) = 1 and [p(v)] ' = { p(v) } If p is concrete, construct S –p-> S’ – for all p = s ± m as above, G –p-> G’ such that S’ shapes G’
AHA, Berlin, July 2007Abstraction in Graph Transformation23 Extraction (Materialization) Given a pre-matching p: LHS ! S, the materialization of S is a family {T k } k – For all k, 9 a k : T k ! S (abstraction morphism) – For all k, 9 concrete c k : LHS ! T k – For all s: G ! S, 9 t: G ! T k with s = a k ± t (for some k) Construction of {T k } k for i-neighbourhood shapes – For all v 2 N LHS, copy p(v) and its i-radius neighbourhood – Guess the edges and multiplicities
AHA, Berlin, July 2007Abstraction in Graph Transformation24 GCGC GCGC GPGP GPGP Proposed construction LHSRHS GG’ SS’ s s’s’ TkTk T’ materialization normalization pre-matching concrete pre-matching transformation sksk pc m
AHA, Berlin, July 2007Abstraction in Graph Transformation25 Customer 1 Cart 1 cart Customer Cart Customer Cart transformationmaterialization Example CustomerCartCustomerCart cart Customer 1 Cart 1 cart Customer Cart LHSRHS S T0T0 s0s0 p cart Customer 1 Cart 1 Customer Cart Customer Cart T’ 0 cart Customer Cart Customer Cart S’ guessed multiplicities; 3 other possibilities normalization
AHA, Berlin, July 2007Abstraction in Graph Transformation26 Outline Setting – Graphs, rules, productions Abstraction – Quotients, neighbourhoods, shapes Logic – Modalities, preservation Framework – Extraction, transformation, normalization Conclusion
AHA, Berlin, July 2007Abstraction in Graph Transformation27 Evaluation: Neighbourhood shapes Pros – Powerful basic framework (arbitrary graphs) – Finite (canonical) abstraction – Unique representation up to isomorphism – Preservation and reflection of modal logic – Automatic transformation Cons – Modal logic limited (no cyclic structures) – Materialization expensive – Abstraction not property-driven
AHA, Berlin, July 2007Abstraction in Graph Transformation28 Future work Refined notion of neighbourhood – Regular language – Words up to bounded length ( ¼ radius) – Derived from properties & rules Integration with 3-valued logic Implementation in GROOVE
AHA, Berlin, July 2007Abstraction in Graph Transformation29 Legacy research Refine notion of neighbourhood – Bauer & Wilhelm (partner abstraction) – Distefano & Katoen (list abstraction) – Distefano (abstract graph transformation) Inspired by work by – Sagiv, Reps, Wilhelm et al. (shape analysis)