Semantics Connection to Traversal Graphs. Strategy: From C1 to T o1:C1 o2:C2 e go down e iff C1. )*.<=) T go down e iff C1 EI* EC C3 (EA*(EI* EC EA*)*

Slides:



Advertisements
Similar presentations
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Advertisements

DS.GR.14 Graph Matching Input: 2 digraphs G1 = (V1,E1), G2 = (V2,E2) Questions to ask: 1.Are G1 and G2 isomorphic? 2.Is G1 isomorphic to a subgraph of.
WSPD Applications.
Chapter 1 Object-Oriented Concepts. A class consists of variables called fields together with functions called methods that act on those fields.
Longest Common Subsequence
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
Depth-First Search1 Part-H2 Depth-First Search DB A C E.
Determinization of Büchi Automata
CSC401 – Analysis of Algorithms Lecture Notes 14 Graph Biconnectivity
 Dr. Vered Gafni 1 LTL Decidability Enables consistency check, but also base for verification.
. Hidden Markov Model Lecture #6. 2 Reminder: Finite State Markov Chain An integer time stochastic process, consisting of a domain D of m states {1,…,m}
Implementation of Graph Decomposition and Recursive Closures Graph Decomposition and Recursive Closures was published in 2003 by Professor Chen. The project.
Anagh Lal Monday, April 14, Chapter 9 – Tree Decomposition Methods Anagh Lal CSCE Advanced Constraint Processing.
. Hidden Markov Model Lecture #6 Background Readings: Chapters 3.1, 3.2 in the text book, Biological Sequence Analysis, Durbin et al., 2001.
3 -1 Chapter 3 The Greedy Method 3 -2 The greedy method Suppose that a problem can be solved by a sequence of decisions. The greedy method has that each.
Connected Components, Directed Graphs, Topological Sort COMP171.
. Hidden Markov Model Lecture #6 Background Readings: Chapters 3.1, 3.2 in the text book, Biological Sequence Analysis, Durbin et al., 2001.
Midterm Fall 2000 solutions. Question 1 From sentence to class dictionary abstraction In this case like from object graph to class graph abstraction because.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Validating Streaming XML Documents Luc Segoufin & Victor Vianu Presented by Harel Paz.
Connected Components, Directed Graphs, Topological Sort Lecture 25 COMP171 Fall 2006.
Technion 1 (Yet another) decision procedure for Equality Logic Ofer Strichman and Orly Meir Technion.
Connected Components, Directed graphs, Topological sort COMP171 Fall 2005.
Data Structures, Spring 2006 © L. Joskowicz 1 Data Structures – LECTURE 14 Strongly connected components Definition and motivation Algorithm Chapter 22.5.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
CSE 373, Copyright S. Tanimoto, 2002 Up-trees - 1 Up-Trees Review of the UNION-FIND ADT Straight implementation with Up-Trees Path compression Worst-case.
Data Flow Analysis Compiler Design Nov. 8, 2005.
Hidden Markov Model Continues …. Finite State Markov Chain A discrete time stochastic process, consisting of a domain D of m states {1,…,m} and 1.An m.
Minimum Spanning Trees. Subgraph A graph G is a subgraph of graph H if –The vertices of G are a subset of the vertices of H, and –The edges of G are a.
Path testing Path testing is a “design structural testing” in that it is based on detailed design & the source code of the program to be tested. The methodology.
Graph Algorithms Using Depth First Search Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms.
© The McGraw-Hill Companies, Inc., Chapter 3 The Greedy Method.
Basics of automata theory
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
(CSC 102) Lecture 29 Discrete Structures. Graphs.
CSc 453 Final Code Generation Saumya Debray The University of Arizona Tucson.
Lecture 05: Theory of Automata:08 Kleene’s Theorem and NFA.
A correction The definition of knot in page 147 is not correct. The correct definition is: A knot in a directed graph is a subgraph with the property that.
CSG 7111 Structure and Interpretation of an Aspect Language for Datatype Karl Lieberherr.
Chapter 10 Graph Theory Eulerian Cycle and the property of graph theory 10.3 The important property of graph theory and its representation 10.4.
Translating Traversals to AspectJ. Outline Motivation Demeter Process for Traversals AspectJ Translation Process.
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
R-customizers Goal: define relation between graph and its customizers, study domains of adaptive programs, merging of interface class graphs.
 2004 SDU 1 Lecture5-Strongly Connected Components.
Process Algebra (2IF45) Basic Process Algebra Dr. Suzana Andova.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
Chapter 11. Chapter Summary  Introduction to trees (11.1)  Application of trees (11.2)  Tree traversal (11.3)  Spanning trees (11.4)
Jesse proposal1 Jesse’s proposal Karl Lieberherr.
Computing smallest and largest repetition factorization in O(n log n) time Hiroe Inoue, Yoshiaki Matsuoka, Yuto Nakashima, Shunsuke Inenaga, Hideo Bannai,
IOI/ACM ICPC Training 4 June 2005.
Viewgraphs for Semantics
Structure and Interpretation of an Aspect Language for Datatype
Chapter 2 Finite Automata
Two issues in lexical analysis
Depth-First Search.
Graph Algorithms Using Depth First Search
Biconnectivity SEA PVD ORD FCO SNA MIA 11/16/2018 2:31 AM
A Short Introduction to Adaptive Programming (AP) with collaborations and adapters Northeastern Team 11/16/2018 DJ.
Spanning Trees Longin Jan Latecki Temple University based on slides by
Graphs Chapter 13.
Alternating tree Automata and Parity games
Lectures on Graph Algorithms: searching, testing and sorting
CS 583 Analysis of Algorithms
Midterm Review CSU 670 Spring 2004.
Connected Components, Directed Graphs, Topological Sort
APPCs revisited 2/25/2019 APPCs revisited.
Spanning Trees Longin Jan Latecki Temple University based on slides by
Biconnectivity SEA PVD ORD FCO SNA MIA 5/6/2019 5:08 PM Biconnectivity
Biconnectivity SEA PVD ORD FCO SNA MIA 5/23/ :21 PM
INTRODUCTION A graph G=(V,E) consists of a finite non empty set of vertices V , and a finite set of edges E which connect pairs of vertices .
Presentation transcript:

Semantics Connection to Traversal Graphs

Strategy: From C1 to T o1:C1 o2:C2 e go down e iff C1. )*.<=) T go down e iff C1 EI* EC C3 (EA*(EI* EC EA*)* EI*) T declared type of o2 is C3=>C2

Example 1 strategy: {A -> B B -> C} A B C X x x b c class graph ABC Strategy s t c BOpt Empty Object graph :A c2:C x1:X :R x2:X c1:C c3:C e1:Empty S R go down e iff C1. )*.<=) T

Are the two concepts equivalent? Traversals done by Mitch’s semantics. Traversals done by the Traversal Methods Algorithm.

Traversal methods algorithm Algorithm 2 Idea is to traverse an object graph while using the traversal graph as a road map. Maintain set of “tokens” placed on the traversal graph. May have several tokens: path leading to an object may be a prefix of several distinct paths in PathSet[SS,G,N,B].

Traversal methods algorithm –4. Let Q be the set of labels which appear both on edges outgoing from a node in T’  TG and on edges outgoing from this in the object graph. For each field name l  Q, let T l = {v|(u,l,v)  TG for some u  T’}. –5. Call this.l.Traverse(T l ) for all l  Q, ordered by “<“, the field ordering.

Main Theorem Let SS be a strategy, let G be a class graph, let N be a name map, and let B be a constraint map. Let TG be the traversal graph generated by Algorithm 1, and let T s and T f be the start and finish sets, respectively.

Main Theorem (cont.) Let O be an object tree and let o be an object in O. Let H be the sequence of nodes visited when o.Traverse is called with argument T s, guided by TG. Then traversing O from o guided by PathSet[SS,G,N,B] produces H.

Complexity of algorithm Algorithm 1: All steps run in time linear in the size of their input and output. Size of traversal graph: O(|S| 2 |G| d 0 ) where d 0 is the maximal number of edges outgoing from a node in the class graph. Algorithm 2: How many tokens? Size of argument T is bounded by the number of edges in strategy graph.

Explain directly in terms of paths in object graph

A simple view of traversals When a traversal reaches a target node in the object graph, the path traversed from the source, with suitable substitution of subclasses by superclasses, must be an expansion of an s-t path in the strategy graph. s is the source and t is the target of the strategy. Each each in the strategy graph corresponds to at least one edge in the object graph.

A simple view of traversals When a traversal reaches a final node in the object graph without being at a target, the path traversed from the source, with suitable substitution of subclasses by superclasses, must be a prefix of an expansion of an s-t path in the strategy graph. The prefix is the longest prefix such that there is still a possibility of success as determined by the class graph.

Example 1 strategy: {A -> B B -> C} A B C X x x b c class graph ABC Strategy s t c BOpt Empty Object graph OG : A X R X C OG’: A X B X C SG : A B C (CG: A X Bopt B X C) :A c2:C x1:X :R x2:X c1:C c3:C e1:Empty S R Only node paths shown for space reasons

Example 1A strategy: {A -> S S -> C} A B C X x x b c class graph ASC Strategy s t c BOpt Empty Object graph OG : A X R X OG’: A X B X SG : A B (CG: A X Bopt B X ) :A c2:C x1:X :R x2:X c1:C c3:C e1:Empty S R Only node paths shown for space reasons early termination

So far: Remarks about traversals Traversals are opportunistic: As long as there is a possibility for success (i.e., getting to the target), the branch is taken. In the TOPLAS 95 paper and my book (page 459): Notice that we let the set of paths guide the traversal as long as possible.

A1 (=>.( )*.<=) E2 A1 A2 K1 B1 B2 D1 c1 D2 K2 E1 E2

Definition POSS(Class c1, Class t, Object o1) = those edges e outgoing from o1 s.t. there is an object graph O (consistent with the class graph C), containing the object o1 of class c1, an object o2 of a class that is a subclass of t, and a path in O from o1 to o2 such that the first edge in the path is e. POSS: possibility of success

Example A R B X S D 0..1 C T A -> T T -> D a1:A r1:Rs1:S :C :D class graph strategy object graph POSS(A,T,a1) = 1 edge POSS(R,T,r1) = 1 edge POSS(S,T,s1) = 0 edges object graph slice

Example A R B X S D 0..1 C T A -> T T -> D a1:A r1:R s1:S c1:C :D class graph strategy POSS(A,T,a1) = 1 edge POSS(R,T,r1) = 1 edge POSS(S,T,s1) = 1 edge POSS(T,D,t1) = 1 edge POSS(R,D,r2) = 1 edge t1:T r2:R c2:C d2:D s2:S object graph

Object Slice The object graph slice starting with o1 is the slice built by following the edges POSS(Class(o1), t, o1) starting at o1 and continuing until every path terminates (at an object of type t or if it terminates prematurely).

Path concept Path from A to B: –EI implies EA in opposite direction –(EC | EA | EI)* but not EA followed by EI –((EI* EC) | EA )* EI* Equivalent: ? –EA* (EI* EC EA*)* EI* –((EI* EC) | EA )* EI* EI: inheritance or is-a edges EA: subclass or alternation edges EC: construction or has-a edges

Agenda: Add to DJ Add WandVisitor as a new subclass to Visitor. In a WandVisitor visitor method activation is delayed until we are at a target. What are the semantics?

WandVisitor example // where has source A and target C void someMethod(TraversalGraph where) { where.traverse(this, new WandVisitor(“A”,”C”) { void before(A a){print(a);} void before(B b){print(b);} void before(C c){print(c);} }); } Which methods will be executed when a C-object is visited? Not all As and Bs visited since last visit to a C-object?

Visitor Methods for Construction Edges void cbefore_x(Source s, Target t); –-> Source,x,Target void cbefore(Source s, String partName, Target t); –-> Source, **, Target void cbefore_x(Source s); –-> Source, x, * void cbefore(Source s, String partName); // * –-> Source, **, *

Visitor Methods for Construction Edges void cbefore_x(Target t); // * –-> *,x,Target void cbefore(String partName, Target t); // * –-> *,**,Target void cbefore_x(); // * –-> *,x,* void cbefore(String partName); // * ; all edges –-> *,**,*

CEdgeInfo CEdgeInfo = [ String] [ String]. // derived / public, protected, private

SEdgeInfo SEdgeInfo = [ String] [ String].

Visitor has a method EdgeInfo getCEdgeInfo() that returns the EdgeInfo of the current construction edge being traversed.

Visitor Methods for Construction Edges void cbefore_x(Source s, Target t); –-> Source,x,Target void cbefore(Source s, Target t); –-> Source, *, Target void cbefore_x(Source s); –-> Source, x, * void cbefore(Source s); –-> Source, *, *

Visitor Methods for Construction Edges void cbefore_x(Target t); // * –-> *,x,Target void cbefore(String partName, Target t); // * –-> *,**,Target void cbefore_x(); // * –-> *,x,* void cbefore(String partName); // * ; all edges –-> *,**,*

Visitor Methods for Construction Edges void cbefore_x(Source s, EdgeInfo e); –-> Source, x, * void cbefore(Source s, EdgeInfo e); // * –-> Source, *, *

Visitor Methods for Construction Edges void cbefore_x(Target t, EdgeInfo e); // * –-> *,x,Target void cbefore(Target t, EdgeInfo); // * –-> *,**,Target void cbefore_x(EdgeInfo e); // * –-> *,x,* void cbefore(String partName); // * ; all edges –-> *,**,*

Visitor Methods for Strategy Edges void sbefore(Source s, Target t); // strategy

Programming with strategies check whether currently in scope of subtraversal // may be used in before, cbefore, rbefore, sbefore –// sg a substrategy of current strategy if (sg.contains(getSEdgeInfo())) { // currently in traversal determined by strategy sg –// tg a subgraph of current traversal graph if (tg.contains(getSEdgeInfo())) { // currently in traversal determined by tg

Programming with strategies check whether currently in scope of substrategy // sg a substrategy of current strategy // may be used in before, cbefore, rbefore, sbefore if (sg.contains(getSEdgeInfo())) { // currently in traversal determined by strategy sg check whether currently // tg a subgraph of current traversal graph // may only be used in cbefore if (tg.contains(getCEdgeInfo())) { // currently in traversal determined by tg