Overgraph Representation for Multi-Result Supercompilation Sergei - - PowerPoint PPT Presentation

overgraph representation for multi result supercompilation
SMART_READER_LITE
LIVE PREVIEW

Overgraph Representation for Multi-Result Supercompilation Sergei - - PowerPoint PPT Presentation

Overgraph Representation for Multi-Result Supercompilation Sergei Grechanik Keldysh Institute of Applied Mathematics Russian Academy of Sciences Meta 2012 1 General Idea of Multi-Resultness P1 P1 We use heuristics to guess the best path


slide-1
SLIDE 1

1

Overgraph Representation for Multi-Result Supercompilation

Sergei Grechanik

Keldysh Institute of Applied Mathematics Russian Academy of Sciences Meta 2012

slide-2
SLIDE 2

2

General Idea of Multi-Resultness

P1 SC(P1) P1

We use heuristics to guess the best path

SC(P1)

And get a single residual program

slide-3
SLIDE 3

3

General Idea of Multi-Resultness

P1 SC(P1) P1 SC(P1)

We take (almost)

every possible path

We get a set of residual programs And then we choose the best one (optionally)

slide-4
SLIDE 4

4

A problem Millions of residual programs

Overgraph – a compact representation for sets of graphs

A solution

slide-5
SLIDE 5

5

MRSC Toolkit Architecture Core Rules

Whistle Generalization Strategy Driving Rules Folding Strategy

...

Graph C Rewriting Steps Residualization R

slide-6
SLIDE 6

6

MRSC: Graphs of Configurations

C1 C2 C3 C4 C5 C6 C7 C2' C8

Root Current Node Incomplete Nodes Folding Edge

slide-7
SLIDE 7

7

MRSC: Graph Rewriting Steps

Complete AddChildNodes Fold Rebuild

1 2

slide-8
SLIDE 8

8

MRSC: Tree of Graphs

slide-9
SLIDE 9

9

MRSC: Tree of Graphs

Depth-First Traversal of the Tree of Graphs

slide-10
SLIDE 10

10

MRSC: Tree of Graphs

Depth-First Traversal of the Tree of Graphs

slide-11
SLIDE 11

11

MRSC: Tree of Graphs

Depth-First Traversal of the Tree of Graphs

slide-12
SLIDE 12

12

MRSC: Tree of Graphs

Depth-First Traversal of the Tree of Graphs

slide-13
SLIDE 13

13

MRSC: Tree of Graphs

Depth-First Traversal of the Tree of Graphs

Yield

slide-14
SLIDE 14

14

MRSC: Tree of Graphs

Depth-First Traversal of the Tree of Graphs

Yield Yield Yield Yield

slide-15
SLIDE 15

15

Combinatorial Explosion

Too many graphs

– Use some heuristics

– Share some parts of graphs

Shared

Spaghetti Stack (MRSC)

slide-16
SLIDE 16

16

Do Spaghetti Stacks Solve the Problem?

Not entirely

These subtrees are likely to be equal but they won't be shared

slide-17
SLIDE 17

17

Rules : Graph → [Step]

Rules transform graphs into rewriting steps

Add this node Add this node

But usually they don't need the whole graph, just a path from the root to the current node

slide-18
SLIDE 18

18

Rules : Path → [Step]

  • Let's try to restrict rules to work on paths

Add this node

  • We would need some new representation to

make use of this new property

  • We would lose an interesting ability to fold with cross

edges

slide-19
SLIDE 19

19

Overtree Representation

Let's combine all configuration trees into one big overtree

+ =

An overtree represents a set of trees data Tree = Tree (F Tree) data OTree = OTree [F OTree]

slide-20
SLIDE 20

20

Do Overtrees Solve the Problem?

  • They are a bit better, but still...

f(g(h(x))) f(g(x)) h(x) g(h(x)) f(x) f(x) g(x) g(x) h(x) Duplication

  • We've already lost cross edges
  • Are we going to lose folding edges completely?
slide-21
SLIDE 21

21

Overgraph

  • Let's just glue together nodes equivalent up to

renaming

f(g(h(x))) f(g(x)) h(x) g(h(x)) f(x) g(x)

  • Each configuration corresponds to no more

than one node

slide-22
SLIDE 22

22

Folding

We don't need special folding edges

f(x) f(g(y)) f(z) g(y)

...

f(x) f(g(y)) g(y)

...

slide-23
SLIDE 23

23

Advantages and Problems

  • Overgraphs are more compact
  • Overgraphs are cleaner

– One configuration ― one node – No special folding edges

  • Overgraphs contain more information
  • Each node can have multiple parents

– Can we use binary whistles? – How can we control generalization?

  • How to apply rules?
  • How to extract residual programs?
slide-24
SLIDE 24

24

Hyperedges

f g h ∘ ∘ f g ∘ h g h ∘ f g

Hyperedge

f g h → (f , g h) ∘ ∘ ∘

  • Hyperedges represent steps like driving and

generalization

  • Completion step can be represented as a hyperedge

with zero destination nodes

C1 → ()

C1 C2 incomplete nodes have

no outgoing hyperedges

  • We will call bundles of edges hyperedges
slide-25
SLIDE 25

25

Supercompilation with Overgraphs

1) Overgraph Construction

Add nodes and edges while possible

2) Overgraph Truncation

Remove useless nodes and edges

3) Residualization

slide-26
SLIDE 26

26

Overgraph Construction

  • Rule : Configuration → [Step]

Add this node

  • Rule : Overgraph → [Hyperedge]

In what order should we apply the rules?

G ⊆ H ⇒ r(G) ⊆ r(H)

r is monotone if for all graphs G and H: If all rules are monotone we can apply them in any order

slide-27
SLIDE 27

27

Rules

  • We can also write rules in this form:

precondition hyperedges to add

  • Examples:

¬ UnaryWhistle(c) c → drive(c) always c → generalize(c) min_depth(c) < 42 c → drive(c)

This precondition is monotone

slide-28
SLIDE 28

28

Binary Whistles

¬ d G : BinaryWhistle(c,d) ∃ ∈ c → drive(c)

NOT monotone

∃ path p from root to c : ∀ d p : ¬BinaryWhistle(c,d) ∈ c → drive(c)

OK This green path won't disappear

slide-29
SLIDE 29

29

Overgraph Truncation

This incomplete node is useless

We should remove all incident hyperedges

slide-30
SLIDE 30

30

Residualization

Overgraph Set of graphs Building a full set of graphs should be avoided!

We will represent residual programs as trees with

back edges

(i.e. no subprogram sharing)

slide-31
SLIDE 31

31

Naive Residualization Algorithm

1 4 3 2 5 6 1 4 3 2 5 6 4 5 6 2

Convert Overgraph into an Overtree and then convert it into a set of trees

slide-32
SLIDE 32

32

Naive Residualization Algorithm

1 4 3 2 5 6 1 4 3 2 5 6 4 5 6 2

Convert Overgraph into an Overtree and then convert it into a set of trees

slide-33
SLIDE 33

33

Suboptimality

1 4 3 2 5 6 1 4 3 2 5 6 4 5 6

Absolutely identical subtrees

Idea: Cache intermediate results

slide-34
SLIDE 34

34

More Formal Definition

R n h | n ∈ h = [Fold(n)] R n h | otherwise = [n → (r1 ... rk) | n → (d1 ... dk) ∈ G, ri ∈ R di (n:h)] R : Node → [Node] → [Tree]

1 4 3 2

h = [4, 2, 1] n = 2

2 4 2' 1

slide-35
SLIDE 35

35

More Formal Definition

R n h | n ∈ h = [Fold(n)] R n h | otherwise = [n → (r1 ... rk) | n → (d1 ... dk) ∈ G, ri ∈ R di (n:h)] R : Node → [Node] → [Tree]

1 3 2

h = [2, 1] n = 4

4

R 2 [4, 2, 1]

slide-36
SLIDE 36

36

History Structure

R : Node → [Node] → [Tree]

N

Predecessors Successors Both

History Won't be in a history Can be in a history but cannot be folded against These can influence folding

slide-37
SLIDE 37

37

Enhanced Residualization

  • Removing pure predecessors from history

won't change the result

R n h = R n (h ∩ succs(n))

  • Let's rewrite residualization algorithm this way:

R n h | n ∈ h = [Fold(n)] R n h | otherwise = [n → (r1 ... rk) | n → (d1 ... dk) ∈ G, ri ∈ R di (n:h ∩ succs(di))]

  • Now we can just apply memoization
slide-38
SLIDE 38

38

Evaluation of Residualization Algorithms

  • Caching improves performance

add mul fict idle evenBad nrev 2 4 6 8 10 12 14

Improvement (times)

  • But the algorithms produce trees with back edges

Turned out it is not very useful for most tasks

slide-39
SLIDE 39

39

Example: Counter Systems

  • The task is to find the minimal proof of a

counter system's safety

  • A proof is a graph, not a tree with back edges
  • MRSC uses cross edges to simulate graphs
  • But overgraphs may be still useful because

they enable truncation

slide-40
SLIDE 40

40

Experiment with Counter Systems Rules Core

Branch & Bound

Branch & Bound Overgraph Construction

Truncation Rules Core

VS

slide-41
SLIDE 41

41

Experimental Results

Synapse MSI MOSI MESI MOESI Illinois Berkley Firefly Xerox Java ReaderWriter DataRace

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Improvement (times)

(in terms of the number of visited nodes)

slide-42
SLIDE 42

42

Why overgraphs were useful?

  • We could compute sets of successors
  • We could truncate an overgraph

An overgraph contains a lot of information about relations between configurations This is even more important than its compactness

slide-43
SLIDE 43

43

Further Work

  • Experiments with subgraph-producing

residualization algorithms

– need graph-based language – tree-producing algorithm seems unsuitable for

real-world tasks

  • Searching for heuristics (whistles etc) useful

for overgraph representation

  • Applying overgraphs to higher-level

supercompilation

slide-44
SLIDE 44

44

Conclusions

We suggested the Overgraph representation

  • An Overgraph is a very compact

representation

  • Rules, Whistles and Residualization were

generalized to Overgraphs

  • The implementation has shown its usefulness

– Caching residualization algorithm – Truncation for counter systems

  • Overgraph contains a lot of information, so it is

possible to analyze multiple graphs at once

slide-45
SLIDE 45

45

Please return to the previous slide

slide-46
SLIDE 46

46

Correctness

  • It is possible that not all of the trees extracted

from an overgraph represent correct programs

  • Usually it is not a problem for single-level

supercompilation

a b id id

a = b b = a a = a

a b c

slide-47
SLIDE 47

47

Language used in experiments

  • The language is essentially based on trees

with back edges

Y (λ f → ...) f

  • Higher order
  • Explicit fixed point combinator
  • No let-expressions
slide-48
SLIDE 48

48

Overgraph vs E-PEG

  • Essentially the same idea applied to different

domains

  • We work with functional languages, so we

have a clear recursion rather than incomprehensible cycles

  • We don't have symmetric equalities
  • We decided to residualize to trees, they

naturally “residualize” to graphs

– Should we do the same?

slide-49
SLIDE 49

49

There are no more slides