expressiveness and complexity of crosscut languages
Download
Skip this Video
Download Presentation
Expressiveness and Complexity of Crosscut Languages

Loading in 2 Seconds...

play fullscreen
1 / 60

Expressiveness and Complexity of Crosscut Languages - PowerPoint PPT Presentation


  • 71 Views
  • Uploaded on

Expressiveness and Complexity of Crosscut Languages. Karl Lieberherr, Jeffrey Palm and Ravi Sundaram Northeastern University FOAL 2005 presentation. Goal. Crosscut Languages are important in AOP Encapsulate crosscuts Delimit aspects

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Expressiveness and Complexity of Crosscut Languages' - hope-klein


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
expressiveness and complexity of crosscut languages

Expressiveness and Complexity of Crosscut Languages

Karl Lieberherr, Jeffrey Palm and Ravi Sundaram

Northeastern University

FOAL 2005 presentation

FOAL 2005

slide2
Goal
  • Crosscut Languages are important in AOP
    • Encapsulate crosscuts
    • Delimit aspects
  • Study them abstractly using expressions on graphs: lower bounds and upper bounds
  • Assumption: know entire call or class graph
  • Of interest to: AOSD language designers and tool builders

FOAL 2005

are algorithmic results of any use to aosd tool builders users
Are algorithmic results of any use to AOSD tool builders/users?
  • YES!
    • Positive results: Fast algorithms lead to faster tools.
    • Negative results: Indicate that we need to use different kinds of algorithms.

FOAL 2005

surprise
Surprise
  • Deciding pointcut satisfiability of an AspectJ pointcut using call, cflow and || and && on a Java program that only contains method calls (no conditionals) is NP-complete.
  • pointcut satisfiability: Is there an execution of the program so that the pointcut selects at least one join point.

FOAL 2005

insights
Insights
  • AspectJ pointcuts and Demeter traversals have same expressiveness: Integration.
  • Enhanced regular expressions on graphs and their instances are foundation for both.
  • Enhanced regular expression evaluation on instances may be exponentially faster if graph (meta information) is used.

FOAL 2005

some parc northeastern history about crosscut languages enhanced regular expressions ere
Some PARC-Northeastern History about Crosscut Languages:Enhanced Regular Expressions (ERE)

>From [email protected] Thu Aug 31 13:33:57 1995

>To [email protected]

(cc to Gregor, Crista, Boaz Patt-Shamir and Jens Palsberg et al.)

Subject: Re: Boolean and Regular

We seem to be converging, but I still think that enhanced regular expressions can express all of the operators. Here is the enhanced regular expression language from a while back:

Atomic expressions:

A The empty traversal at class A

lnk A link of type lnk ("any" is a special case of any link type)

For combining expressions, the usual regular expression crowd:

. concatenation

\cap intersection

\cup union

* repetition

not negation

FOAL 2005

my response
My response

From lieber Thu Aug 31 13:51:57 1995

From: Karl Lieberherr <lieber>

To: [email protected], [email protected]

Subject: Re: Boolean and Regular

Cc: [email protected], [email protected], [email protected],

[email protected], [email protected], [email protected],

[email protected], [email protected], [email protected]

Hi John:

yes, we agree. The operators of what I called Boolean algebra operators

are just as well counted as regular expression operators.

I like your integration; have to think more about how expressive it is.

-- Karl

CLAIM: ERE are a good foundation for crosscut languages.

Confirmed by de Moor / Suedholt / Krishnamurti etc.

FOAL 2005

enhanced regular expressions
Enhanced Regular Expressions
  • ERE = regular expressions (primitive, concatenation, union, star) with
    • complement/negation
    • nodes and edges (can eliminate need for edges by introducing a node for each edge)

FOAL 2005

same lamping message continued demeter in ere
Same Lamping message continued:Demeter in ERE

[A,B] A.any*.B

through edges any*.lnk.any*

bypassing edges not(any*.lnk.any*)

through vertices any*.A.any*

bypassing vertices not(any*.A.any*)

d1 join d2 [d1].[d2]

d1 merge d2 [d1] \cup [d2]

d1 intersect d2 [d1] \cap [d2]

not d1 not([d1])

FOAL 2005

using ere for aspectj
AspectJ

k (a primitive)

cflow(k)

&&

||

!

ERE

main any* k

main any* k any*

\cap

\cup

!

Using ERE for AspectJ

FOAL 2005

we continue the study of crosscut languages
We continue the study of crosscut languages
  • and show that AspectJ pointcuts are equivalent to Demeter strategies and vice versa if you abstract from the unimportant details.
  • we show the correspondence by direct translations in both directions (rather than using ERE).

FOAL 2005

examples first
Examples first
  • Show two programs and their graph abstractions

FOAL 2005

slide14

class Example { // AspectJ program

public static void main(String[] s) {x1(); nx1();}

static void x1() { x2(); nx2(); }

static void x2() { x3(); nx3(); }

static void x3() { target(); }

static void nx1() { x2(); nx2(); }

static void nx2() { x3(); nx3(); }

static void nx3() { target(); }

static void target() {}

}

aspect Aspect {

pointcut p1(): cflow(call (void x1()))

|| cflow(call (void nx2()))

|| cflow(call (void x3()));

pointcut p2() : cflow(call (void nx1()))

|| cflow(call (void x2()));

pointcut p3() : cflow(call (void x1()));

pointcut p4() : cflow(call (void nx3()));

pointcut all(): p1() && p2() && p3() && p4();

before(): all() && !within(Aspect) {

System.out.println(thisJoinPoint);

}

}

Meta graph=

Call graph

main

nx1

x1

x2

nx2

x3

nx3

main

x1

x2

x3

target

nx3

target

target

Instance tree

Call tree

Selected by all()

FOAL 2005

slide15

class Main { // Java Program with DJ

X1 x1; Nx1 nx1;

public static void main(String[] s) {

ClassGraph cg = new ClassGraph(); Main m = new Main();

String strategy =

"intersect(" + // union is expressed by concatenation of edges

"{Main -> X1 X1 -> Target " +

"Main ->Nx2 Nx2 -> Target " +

"Main -> X3 X3 -> Target}," +

"{Main -> Nx1 Nx1 -> Target " +

"Main -> X2 X2 -> Target}," +

"{Main -> X1 X1 -> Target}," +

"{Main -> Nx3 Nx3 -> Target})“;

cg.traverse(m, // m is the complete tree with 8 leaves

strategy,

new Visitor(){

public void start (){System.out.println(" start traversal");}

public void finish (){System.out.println(" finish traversal");}

void before (Target host){System.out.print(host + \' \');}

void before (Nx3 host) {System.out.print(host + \' \');}

void before (X2 host) {System.out.print(host + \' \');}

void before (X1 host) {System.out.print(host + \' \');}

});}

}

class X1 { X2 x2; Nx2 nx2; } class Nx1 { X2 x2; Nx2 nx2; }

class X2 { X3 x3; Nx3 nx3; } class Nx2 { X3 x3; Nx3 nx3; }

class X3 { Target t; } class Nx3 { Target t; }

class Target {}

Meta graph=

Class graph

Main

Nx1

X1

X2

Nx2

X3

Nx3

Main

X1

X2

X3

Target

Nx3

Target

Target

Instance tree

Object tree

Selected by strategy

FOAL 2005

regular expressions on graphs

ALL PROBLEMS

ARE POLYNOMIAL

Regular Expressions on Graphs
  • Questions: Given graph G and reg. exp. r:
    • Is there a path in G satisfying r? (SAT)
    • Do all paths in G that satisfy r contain n in G? (ALWAYS)
  • Questions: Given graph G and reg. exps r1 and r2:
    • Is the set of paths in G satisfying r1 a subset of the set of paths satisfying r2? (IMPL)
  • What has this to do with AOSD?

Generalizes regular expressions on strings:

sentences must be node paths in graphs. Work by Tarjan and Mendelzon/Wood.

FOAL 2005

enhanced regular expressions on graphs
Enhanced Regular Expressions on Graphs

ALL PROBLEMS

BECOME NP-COMPLETE

  • Questions: Given G and enh. reg. exp. r:
    • Is there a path in G satisfying r? (SAT)
    • Do all paths in G that satisfy r contain n in G? (ALWAYS)
  • Questions: Given G and enh. reg. exps. r1 and r2:
    • Is the set of paths in G satisfying r1 a subset of the set of paths satisfying r2? (IMPL)
  • Ok, related to Demeter but how does AspectJ come in?

FOAL 2005

crosscut language saj
Crosscut Language SAJ

S ::= a set of nodes

k | set of nodes having label k

flow(S) | set of nodes reachable from S

S | S | union

S & S | intersection

!Scomplement

base language

FOAL 2005

crosscut language sd
Crosscut language SD

D ::= a set of paths

[A,B] | paths from A to B

D . D | concatenation of paths

D | D | union of paths

D & D | intersection of paths

!Dcomplement of paths

base language

FOAL 2005

crosscut language
Graph

Path set

Defines set of instance trees

Instance trees

Subtree or its leaves

Conform to a graph (expansion)

Crosscut Language

FOAL 2005

instance trees
Instance trees

Meaning of a crosscut language expression

  • Without meta graph
    • Cannot look ahead: before we enter a join point we want to know whether it is selected based on information on the path back to the root: target node semantics.
  • With meta graph
    • Can look ahead in meta graph: before we enter a join point we want to know whether it is selected based on information on the path back to the root and if there is a possibility for success based on meta information: may use path set semantics. Include inner nodes, not just target nodes.
    • Of course, we can always restrict semantics to target nodes.
    • May give exponential speedup.

FOAL 2005

instance trees1
AspectJ

Execution tree

Traversed anyway by Java virtual machine

Can cut exponentially the size of the tree where we pay attention to events

Demeter

Object tree

Traverse only what is needed

Can cut exponentially the tree to be traversed

Instance trees

FOAL 2005

exponential improvement
Exponential improvement
  • There is a sequence of crosscut expression/ meta graph/ instance triples (Qn; Dn; Pn) such that Pn conforms to Dn, |Qn| = O(n), |Dn| = O(n), and |Pn| = o(2n), and so that the naive evaluation will pay attention to o(2n) nodes in Pn while the meta-information-based evaluation will pay attention to O(n) nodes in Pn.

FOAL 2005

expressions on graphs expressions on instances
Expressions on GraphsExpressions on Instances
  • Questions: Given graph G and r: Exists J sat G:
    • Is there a path in J satisfying r? (SAT)
    • For a given node m in G: Do all paths in J that satisfy r contain a node n in J with Label(n) = m? (ALWAYS)
  • Questions: Given G and r1 and r2: Exists J sat G:
    • Is the set of paths in J satisfying r1 a subset of the set of paths satisfying r2? (IMPL)

push down to instances

FOAL 2005

connections between saj and sd
SAJ

selects set of nodes in tree (but there is a unique path from root to each node)

set expression flavor

SD

selects set of paths in tree

regular expression flavor

Connections between SAJ and SD

FOAL 2005

equivalence of node sets and path sets
Equivalence of node sets and path sets

In a rooted tree, such as an instance tree, there is a one-to-one correspondence between nodes, and, paths from the root, because there is a unique path from the root to each node.

We say a set of paths P is equivalent to a set of nodes N if for each n in N there is a path p in P that starts at the root and ends at n and similarly for each p in P it is the case that p starts at the root and ends in a node n in N.

FOAL 2005

theorem 1
Theorem 1
  • A selector expression in SD (SAJ) can be transformed into an expression in SAJ (SD) in polynomial-time, such that for all meta graphs and instance trees the set of paths (nodes) selected by the SD (SAJ) selector is equivalent to the set of nodes (paths) selected by the SAJ (SD) selector.

Motivation for theorem: SD and SAJ have identical complexity results.

FOAL 2005

proof t sd to saj
SD

T([A,B])

T(D1.D2)

T(D1 | D2)

T(D1 & D2)

!D

SAJ

flow(A) & B

flow(T(D1)) & T(D2)

T(D1) | T(D2)

T(D1) & T(D2)

!T(D)

Proof: T: SD to SAJ

FOAL 2005

proof t saj to sd for a graph g
SAJ

T(k)

T(flow(S))

T(S1 | S2)

T(S1 & S2)

T(!S)

SD

[Start(G),k]

| [(Start(G),k].[k,Alph(G)]

T(S1) | T(S2)

T(S1) & T(S2)

!T(S)

Proof: T: SAJ to SDfor a graph G

Start(G): distinguished root of graph

Alph(G): set of node labels of G

Union over all k in S and all elements of Alph(G)

FOAL 2005

slide30

class Example { // AspectJ program

public static void main(String[] s) {x1(); nx1();}

static void x1() {if (false) x2(); nx2(); }

static void x2() { if (false) x3(); nx3(); }

static void x3() { if (false)target(); }

static void nx1() {if (false) x2(); nx2(); }

static void nx2() {if (false) x3(); nx3(); }

static void nx3() {if (false)target(); }

static void target() {}

}

aspect Aspect {

pointcut p1(): cflow(call (void x1()))

|| cflow(call (void nx2()))

|| cflow(call (void x3()));

pointcut p2() : cflow(call (void nx1()))

|| cflow(call (void x2()));

pointcut p3() : cflow(call (void x1()));

pointcut p4() : cflow(call (void nx3()));

pointcut all(): p1() && p2() && p3() && p4();

before(): all() && !within(Aspect) {

System.out.println(thisJoinPoint);

}

}

Meta graph

main

nx1

x1

x2

nx2

x3

nx3

main

x1

x2

x3

target

nx3

target

target

Instance tree

Selected by all()

FOAL 2005

APPROXIMATION

computational properties
Computational Properties
  • Select-Sat: Given a selector p and a meta graph G, is there an instance tree for G for which p selects a non-empty set of nodes.
  • X/Y/Z
    • X is a problem, e.g., Select-Sat
    • Z is a language, e.g. SAJ or SD
    • Y is one of -,&,! representing a version of Z.
      • X/-/Z base language of Z.
      • X/&/Z is base language of Z plus intersection.
      • X/!/Z is base language of Z plus negation.

FOAL 2005

approximation and computational properties
Approximation and Computational Properties
  • Not Select-Sat: Given a selector p and a meta graph G, for all instance trees for G selector p selects an empty set of nodes, i.e. p is useless.
  • If Not Select-Sat(p,G)/*/SAJ holds then also for the original Java program the selector p (pointcut) is useless.

FOAL 2005

same results for 5 problems
Same results for 5 problems
  • We don’t know yet how to unify all the proofs.
  • So we prove the results separately.

FOAL 2005

results problem1
Results (Problem)
  • Results(Select-Sat)
  • Results(Not Select-Impl)
  • Results(Select-First)
  • Results(Not Select-Always)
  • Results(Not Select-Never)

FOAL 2005

implementation
Implementation

SD

  • AP Library
  • DJ
  • DAJ

FOAL 2005

future work
Future Work
  • Complexity of more expressive crosscut languages, e.g., sequences.

FOAL 2005

conclusions
Conclusions
  • AspectJ pointcuts and traversal strategies are equivalent and founded on enhanced regular expressions and graphs as discussed in 1995.
  • Surprising NP-completeness.
  • Exponential improvement is possible if meta information is used.
  • Several useful algorithms in paper.

FOAL 2005

select sat
Select-Sat
  • Select-Sat/&/SAJ is NP-complete
  • This is unexpected because we have only primitive pointcuts (e.g., call), cflow, union and intersection. Looks like Satisfiability of a monotone Boolean expression which is polynomial.

FOAL 2005

an idea by gregor
An idea by Gregor
  • add a new primitive pointcut to AspectJ: traversal(D).
  • cflow(call (void class(traversal({A->B})). foo())) && this(B)
    • in the cflow of a call to void foo() of a class between A and B and the currently executing object is of class B.

FOAL 2005

combining saj and sd
Combining SAJ and SD
  • Extend SD with [A,*]: all nodes reachable from A
  • Replace in SAJ: flow(S) by nodes(D)
  • Can simulate flow(S): use [X,*] for each X in S and take the union.

FOAL 2005

crosscut language saj sd
Crosscut Language SAJ/SD

S ::= a set of nodes

k | set of nodes having label k

nodes(D) | set of nodes selected by D in SD

S | S | union

S & S | intersection

!Scomplement

SAJ/SD seems interesting. Have both capabilities of AspectJ pointcuts

and Demeter traversals.

This is basically what Gregor Kiczales suggested a few years ago:he called it

traversal(D), instead of nodes(D).

FOAL 2005

crosscut language sd1
Crosscut language SD

D ::= a set of paths

[A,B] | paths from A to B

D . D | concatenation of paths

D | D | union of paths

D & D | intersection of paths

!Dcomplement of paths

FOAL 2005

sat is there a path in g satisfying r1
SAT: is there a path in G satisfying r?

results identical for class graphs

FOAL 2005

abbreviations
Abbreviations

FOAL 2005

polynomial translations
Polynomial Translations
  • We want to know which languages are fundamental. We conjecture that all languages can be translated in polynomial time into ERE. Maybe we also need ESG?
  • The translations must preserve the meaning:
    • same set of nodes or
    • same set of paths or
    • set of paths corresponding to a set of nodes or
    • set of nodes corresponding to a set of paths.

FOAL 2005

motivation for polynomial translations
Motivation for polynomial translations
  • If a large number of languages can be translated efficiently to ERE, we only need an efficient implementation for ERE.
  • Currently the AP Library uses SG with intersection. If we would add complement, the AP Library would use ESG.

FOAL 2005

polynomial translations any mistakes

translate row to column

N: no, unless P=NP; NN: no Y: yes

Polynomial Translations ( any mistakes?)

FOAL 2005

crosscut language sd k
Crosscut language SDk

D ::= a set of paths

[A,B]k | paths from A to B of length = k

[A,B]k bypassing {A1,…} ignore {A1,…}

D . D | concatenation of paths

D | D | union of paths

D & D | intersection of paths

!Dcomplement of paths

base language:SDB

see work on poly lingual systems

FOAL 2005

crosscut language sd2
Crosscut language SD

D ::= a set of paths

[A,B] | paths from A to B

[A,B] bypassing {A1,…} ignore {A1,…}

D . D | concatenation of paths

D | D | union of paths

D & D | intersection of paths

!Dcomplement of paths

base language:SDB

FOAL 2005

discussion
Discussion
  • some results are trivial: an RE sentence is trivially an ERE sentence.
  • an ERE sentence can not be translated in polynomial time to an RE sentence because negation cannot be simulated by union et al.
  • An SAJ sentence cannot be translated to an SDB sentence in polynomial time because otherwise P=NP (consider SAT).

FOAL 2005

assignments
Assignments
  • We want to fill in all 64 entries and have a proof for them. This is a good opportunity for a beginning PhD student.
  • Yuantai: please can you do the upper triangle.
  • Jingsong: please can you do the lower triangle.

FOAL 2005

slide55
Puntingam: non regular process types
  • Some context-free, context-sensitive
  • FSM with counters: the same?
    • Reussner

FOAL 2005

mario
Mario
  • Given G and sequence of reg. exps. r1, r2. r1 and r2 are over the same alphabet.
    • Is there a pair of paths in G satisfying r1 and r2? Node selected by r1 < Node selected by r2.
    • After having visited a node satisfying r1, how can we find all nodes satisfying r2?
    • Instance-level dependencies between r1 and r2?

FOAL 2005

instance tree
Instance Tree

J is called an instance tree of graph G, if J is a tree, Root(J)=Start(G) and for each edge e=(u,v) in E(J), there is an edge e’ = (u’, v’) in G so that Label(u)=Label(u’) and Label(v)=Label(v’). J is a rooted tree with edges directed away from the root. (think of Label = Class)

FOAL 2005

quality of model
Quality of model
  • Meta graph defines set of instances
    • Precisely
      • Class graph
    • Too many
      • Call graph
      • Pcflow: what traversals do: use meta information

FOAL 2005

first
FIRST
  • Given a reg. exp. r, a graph G, compute for each node n in G the set of outgoing edges from n that are part of a path p from Start(G) through n to a node so that p satisfies r.
  • Polynomial for regular expressions and NP-complete for enhanced regular expressions.

see TOPLAS 2004 paper

FOAL 2005

ad