O mputational gic L Complexity Analysis by Graph Rewriting Martin - - PowerPoint PPT Presentation

o
SMART_READER_LITE
LIVE PREVIEW

O mputational gic L Complexity Analysis by Graph Rewriting Martin - - PowerPoint PPT Presentation

C O mputational gic L Complexity Analysis by Graph Rewriting Martin Avanzini and Georg Moser Computational Logic Faculty of Computer Science, University of Innsbruck FLOPS 2010 MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting


slide-1
SLIDE 1

O

L C

mputational

gic

Complexity Analysis by Graph Rewriting

Martin Avanzini and Georg Moser

Computational Logic Faculty of Computer Science, University of Innsbruck

FLOPS 2010

slide-2
SLIDE 2

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 2/17

slide-3
SLIDE 3

Term Rewriting

First Order Functional Program

➀ d(c) = 0 ➂ d(x + y) = d(x) + d(y) ➁ d(x × y) = d(x) × y + x × d(y) ➃ d(x − y) = d(x) − d(y) data Exp = Zero | Const c | Times Exp Exp e1 × e2 | Plus Exp Exp e1 + e2 | Minus Exp Exp e1 − e2

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 3/17

slide-4
SLIDE 4

Term Rewriting

First Order Functional Program

➀ d(c) = 0 ➂ d(x + y) = d(x) + d(y) ➁ d(x × y) = d(x) × y + x × d(y) ➃ d(x − y) = d(x) − d(y)

Underlying Computation

d(c + (c × c))

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 3/17

slide-5
SLIDE 5

Term Rewriting

First Order Functional Program

➀ d(c) = 0 ➂ d(x + y) = d(x) + d(y) ➁ d(x × y) = d(x) × y + x × d(y) ➃ d(x − y) = d(x) − d(y)

Underlying Computation

d(c + (c × c))

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 3/17

slide-6
SLIDE 6

Term Rewriting

First Order Functional Program

➀ d(c) = 0 ➂ d(x + y) = d(x) + d(y) ➁ d(x × y) = d(x) × y + x × d(y) ➃ d(x − y) = d(x) − d(y)

Underlying Computation

d(c + (c × c)) = d(c) + d( c × c )

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 3/17

slide-7
SLIDE 7

Term Rewriting

First Order Functional Program

➀ d(c) = 0 ➂ d(x + y) = d(x) + d(y) ➁ d(x × y) = d(x) × y + x × d(y) ➃ d(x − y) = d(x) − d(y)

Underlying Computation

d(c + (c × c)) = d(c) + d( c × c ) = 0 + d(c × c)

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 3/17

slide-8
SLIDE 8

Term Rewriting

First Order Functional Program

➀ d(c) = 0 ➂ d(x + y) = d(x) + d(y) ➁ d(x × y) = d(x) × y + x × d(y) ➃ d(x − y) = d(x) − d(y)

Underlying Computation

d(c + (c × c)) = d(c) + d( c × c ) = 0 + d(c × c) = 0 + d(c) × c + c × d(c)

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 3/17

slide-9
SLIDE 9

Term Rewriting

First Order Functional Program

➀ d(c) = 0 ➂ d(x + y) = d(x) + d(y) ➁ d(x × y) = d(x) × y + x × d(y) ➃ d(x − y) = d(x) − d(y)

Underlying Computation

d(c + (c × c)) = d(c) + d( c × c ) = 0 + d(c × c) = 0 + d(c) × c + c × d(c) = 0 + 0 × c + c × d(c)

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 3/17

slide-10
SLIDE 10

Term Rewriting

First Order Functional Program

➀ d(c) = 0 ➂ d(x + y) = d(x) + d(y) ➁ d(x × y) = d(x) × y + x × d(y) ➃ d(x − y) = d(x) − d(y)

Underlying Computation

d(c + (c × c)) = d(c) + d( c × c ) = 0 + d(c × c) = 0 + d(c) × c + c × d(c) = 0 + 0 × c + c × d(c) = 0 + 0 × c + c × 0

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 3/17

slide-11
SLIDE 11

Term Rewriting

First Order Functional Program

➀ d(c) = 0 ➂ d(x + y) = d(x) + d(y) ➁ d(x × y) = d(x) × y + x × d(y) ➃ d(x − y) = d(x) − d(y)

Underlying Computation

d(c + (c × c)) = d(c) + d( c × c ) = 0 + d(c × c) = 0 + d(c) × c + c × d(c) = 0 + 0 × c + c × d(c) = 0 + 0 × c + c × 0

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 3/17

slide-12
SLIDE 12

Term Rewriting

First Order Functional Program ≈ Term Rewrite System (TRS)

➀ d(c) → 0 ➂ d(x + y) → d(x) + d(y) ➁ d(x × y) → d(x) × y + x × d(y) ➃ d(x − y) → d(x) − d(y)

Underlying Computation ≈ Rewriting

d(c + (c × c)) − →R d(c) + d( c × c ) − →R 0 + d(c × c) − →R 0 + d(c) × c + c × d(c) − →R 0 + 0 × c + c × d(c) − →R 0 + 0 × c + c × 0

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 3/17

slide-13
SLIDE 13

Term Rewriting

First Order Functional Program ≈ Term Rewrite System (TRS)

➀ d(c) → 0 ➂ d(x + y) → d(x) + d(y) ➁ d(x × y) → d(x) × y + x × d(y) ➃ d(x − y) → d(x) − d(y)

Underlying Computation ≈ Rewriting

d(c + (c × c)) − →!

R 0 + 0 × c + c × 0

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 3/17

slide-14
SLIDE 14

Term Rewriting

First Order Functional Program ≈ Term Rewrite System (TRS)

➀ d(c) → 0 ➂ d(x + y) → d(x) + d(y) ➁ d(x × y) → d(x) × y + x × d(y) ➃ d(x − y) → d(x) − d(y)

Underlying Computation ≈ Rewriting

d(c + (c × c)) − →!

R 0 + 0 × c + c × 0 ◮ above TRS computes differentiation of arithmetical expressions

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 3/17

slide-15
SLIDE 15

Term Rewriting

First Order Functional Program ≈ Term Rewrite System (TRS)

➀ d(c) → 0 ➂ d(x + y) → d(x) + d(y) ➁ d(x × y) → d(x) × y + x × d(y) ➃ d(x − y) → d(x) − d(y)

Underlying Computation ≈ Rewriting

d(c + (c × c)) − →!

R 0 + 0 × c + c × 0 ◮ above TRS computes differentiation of arithmetical expressions

Runtime Complexity

number of reduction steps as function in the size of the initial terms

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 3/17

slide-16
SLIDE 16

Term Rewriting

Complexity

◮ innermost runtime complexity

number of eager evaluation steps as function in the size of the initial terms

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 4/17

slide-17
SLIDE 17

Term Rewriting

Complexity

◮ innermost runtime complexity

number of eager evaluation steps as function in the size of the initial terms rci

R(n) = max{dl(t, i

− →R) | size(t) n }

  • i

− →R ⊆ − →R is restriction to eager evaluation

◮ derivation length

dl(t, i − →R) = max{ℓ | ∃(t1, . . . , tℓ). t

i

− →R t1

i

− →R . . .

i

− →R tℓ}

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 4/17

slide-18
SLIDE 18

Term Rewriting

Complexity

◮ innermost runtime complexity

number of eager evaluation steps as function in the size of the initial terms rci

R(n) = max{dl(t, i

− →R) | size(t) n and arguments values}

  • i

− →R ⊆ − →R is restriction to eager evaluation

  • measure complexity of direct function calls

◮ derivation length

dl(t, i − →R) = max{ℓ | ∃(t1, . . . , tℓ). t

i

− →R t1

i

− →R . . .

i

− →R tℓ}

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 4/17

slide-19
SLIDE 19

Term Rewriting

Complexity Analysis

Example

➀ d(c) → 0 ➂ d(x + y) → d(x) + d(y) ➁ d(x × y) → d(x) × y + x × d(y) ➃ d(x − y) → d(x) − d(y)

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 5/17

slide-20
SLIDE 20

Term Rewriting

Complexity Analysis

Example

➀ d(c) → 0 ➂ d(x + y) → d(x) + d(y) ➁ d(x × y) → d(x) × y + x × d(y) ➃ d(x − y) → d(x) − d(y)

◮ runtime complexity of above TRS is linear

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 5/17

slide-21
SLIDE 21

Term Rewriting

Complexity Analysis

Example

➀ d(c) → 0 ➂ d(x + y) → d(x) + d(y) ➁ d(x × y) → d(x) × y + x × d(y) ➃ d(x − y) → d(x) − d(y)

◮ runtime complexity of above TRS is linear ◮ this can be automatically verified

$ tct -a rc -p -s "wdp (matrix :kind triangular)" dif.trs YES(?,O(n^1)) ’Weak Dependency Pairs’

  • Answer:

YES(?,O(n^1)) Input Problem: runtime-complexity with respect to Rules: { D(c) -> 0() , D(*(x, y)) -> +(*(y, D(x)), *(x, D(y))) , D(+(x, y)) -> +(D(x), D(y)) , D(-(x, y)) -> -(D(x), D(y))} Proof Details: ... MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 5/17

slide-22
SLIDE 22

Term Rewriting

Complexity Analysis

Example

➀ d(c) → 0 ➂ d(x + y) → d(x) + d(y) ➁ d(x × y) → d(x) × y + x × d(y) ➃ d(x − y) → d(x) − d(y)

◮ runtime complexity of above TRS is linear ◮ this can be automatically verified

$ tct -a rc -p -s "wdp (matrix :kind triangular)" dif.trs YES(?,O(n^1)) ’Weak Dependency Pairs’

  • Answer:

YES(?,O(n^1)) Input Problem: runtime-complexity with respect to Rules: { D(c) -> 0() , D(*(x, y)) -> +(*(y, D(x)), *(x, D(y))) , D(+(x, y)) -> +(D(x), D(y)) , D(-(x, y)) -> -(D(x), D(y))} Proof Details: ...

is this proof really meaningful?

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 5/17

slide-23
SLIDE 23

Term Rewriting

Complexity Analysis

Example

➀ d(c) → 0 ➂ d(x + y) → d(x) + d(y) ➁ d(x × y) → d(x) × y + x × d(y) ➃ d(x − y) → d(x) − d(y)

◮ runtime complexity of above TRS is linear ◮ this can be automatically verified

$ tct -a rc -p -s "wdp (matrix :kind triangular)" dif.trs YES(?,O(n^1)) ’Weak Dependency Pairs’

  • Answer:

YES(?,O(n^1)) Input Problem: runtime-complexity with respect to Rules: { D(c) -> 0() , D(*(x, y)) -> +(*(y, D(x)), *(x, D(y))) , D(+(x, y)) -> +(D(x), D(y)) , D(-(x, y)) -> -(D(x), D(y))} Proof Details: ...

is this proof really a certificate for polytime computability?

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 5/17

slide-24
SLIDE 24

Main Result

Yes

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 6/17

slide-25
SLIDE 25

Main Result

Theorem

If the (innermost) runtime-complexity of R is polynomially bounded, then each function f computed by R is polytime computable.

rci

R(n) nk ⇒ f ∈ TIME(O(n5·(k+1)))

f computed by R

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 6/17

slide-26
SLIDE 26

Main Result

Theorem

If the (innermost) runtime-complexity of R is polynomially bounded, then each function f computed by R is polytime computable.

rci

R(n) nk ⇒ f ∈ FP

f computed by R

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 6/17

slide-27
SLIDE 27

Main Result

Theorem

If the (innermost) runtime-complexity of R is polynomially bounded, then each function f computed by R is polytime computable.

rci

R(n) nk ⇒ f ∈ FP

f computed by R

Example

➀ d(c) → 0 ➂ d(x + y) → d(x) + d(y) ➁ d(x × y) → d(x) × y + x × d(y) ➃ d(x − y) → d(x) − d(y)

1 polynomial runtime complexity can be automatically verified 2 polytime computability of above given function can be verified

automatically

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 6/17

slide-28
SLIDE 28

Main Result

Theorem

If the (innermost) runtime-complexity of R is polynomially bounded, then each function f computed by R is polytime computable.

rci

R(n) nk ⇒ f ∈ FP

f computed by R

Proof Idea

◮ implement rewriting efficiently

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 6/17

slide-29
SLIDE 29

Main Result

Difficulty

a single rewrite step may copy arbitrarily large terms

❘ terms may grow exponential in the length of derivations

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 7/17

slide-30
SLIDE 30

Main Result

Difficulty

a single rewrite step may copy arbitrarily large terms

❘ terms may grow exponential in the length of derivations

Example

➀ d(c) → 0 ➂ d(x + y) → d(x) + d(y) ➁ d(x × y) → d(x) × y + x × d(y) ➃ d(x − y) → d(x) − d(y)

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 7/17

slide-31
SLIDE 31

Main Result

Difficulty

a single rewrite step may copy arbitrarily large terms

❘ terms may grow exponential in the length of derivations

Example

➀ d(c) → 0 ➂ d(x + y) → d(x) + d(y) ➁ d(x × y) → d(x) × y + x × d(y) ➃ d(x − y) → d(x) − d(y) d(c) = 0

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 7/17

slide-32
SLIDE 32

Main Result

Difficulty

a single rewrite step may copy arbitrarily large terms

❘ terms may grow exponential in the length of derivations

Example

➀ d(c) → 0 ➂ d(x + y) → d(x) + d(y) ➁ d(x × y) → d(x) × y + x × d(y) ➃ d(x − y) → d(x) − d(y) d(c) = 0 d(c × c) = 0 × c + c × 0

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 7/17

slide-33
SLIDE 33

Main Result

Difficulty

a single rewrite step may copy arbitrarily large terms

❘ terms may grow exponential in the length of derivations

Example

➀ d(c) → 0 ➂ d(x + y) → d(x) + d(y) ➁ d(x × y) → d(x) × y + x × d(y) ➃ d(x − y) → d(x) − d(y) d(c) = 0 d(c × c) = 0 × c + c × 0 d((c × c) × c) = (0 × c + c × 0) × c + (c × c) × 0

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 7/17

slide-34
SLIDE 34

Main Result

Difficulty

a single rewrite step may copy arbitrarily large terms

❘ terms may grow exponential in the length of derivations

Example

➀ d(c) → 0 ➂ d(x + y) → d(x) + d(y) ➁ d(x × y) → d(x) × y + x × d(y) ➃ d(x − y) → d(x) − d(y) d(c) = 0 d(c × c) = 0 × c + c × 0 d((c × c) × c) = (0 × c + c × 0) × c + (c × c) × 0 d((c × c) × (c × c)) = ((0 × c + c × 0) × c + (c × c) × 0) × (c × c) + (c × c) × ((0 × c + c × 0) × c + (c × c) × 0)

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 7/17

slide-35
SLIDE 35

Main Result

Proof Outline

f (s1, . . . , sn) t

ℓ R

term rewriting f (s1, . . . , sn) t

p(ℓ) M

Turing machine

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 8/17

slide-36
SLIDE 36

Main Result

Proof Outline

f (s1, . . . , sn) t

ℓ R

term rewriting · ·

ℓ G

graph rewriting f (s1, . . . , sn) t

p(ℓ) M

Turing machine

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 8/17

slide-37
SLIDE 37

Outline

Graph Rewriting in a Nutshell Adequacy of Graph Rewriting Conclusion

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 9/17

slide-38
SLIDE 38

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 10/17

slide-39
SLIDE 39

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

◮ term rewriting on graphs ◮ copying sharing ◮ structural equality pointer equality

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 10/17

slide-40
SLIDE 40

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

◮ term rewriting on graphs ◮ copying sharing ◮ structural equality pointer equality

Example

term t = d(x + x) × d(x + x) represented by × d d + x

◮ variables always represented by unique node

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 10/17

slide-41
SLIDE 41

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

◮ term rewriting on graphs ◮ copying sharing ◮ structural equality pointer equality

Example

term t = d(x + x) × d(x + x) represented by × d d + + x

  • ×

d d + x

  • ×

d + x

◮ variables always represented by unique node

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 10/17

slide-42
SLIDE 42

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

◮ term rewriting on graphs ◮ copying sharing ◮ structural equality pointer equality

Example

term t = d(x + x) × d(x + x) represented by × d d + + x

  • ×

d d + x unshared shared

  • ×

d + x

◮ variables always represented by unique node

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 10/17

slide-43
SLIDE 43

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Example

applying rule s(x) + y → s(x + y) on s(s(0) + s(0)) . . .

Term Rewriting

− →R s(s(0) + s(0)) s(s(0 + s(0)))

Graph Rewriting

s + s s s s + s = ⇒G

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 11/17

slide-44
SLIDE 44

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)

term rewriting graph rewriting

  • 1. identifying matching subterm

s(s(0) + s(0))|1 = σ(s(x) + y) σ =

  • x → 0

y → s(0)

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17

slide-45
SLIDE 45

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)

term rewriting graph rewriting

  • 1. identifying matching subterm
  • 1. finding term graph morphism

s(s(0) + s(0))|1 = σ(s(x) + y) σ =

  • x → 0

y → s(0) + s x y + s s s

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17

slide-46
SLIDE 46

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)

term rewriting graph rewriting

  • 1. identifying matching subterm
  • 1. finding term graph morphism

s(s(0) + s(0))|1 = σ(s(x) + y) σ =

  • x → 0

y → s(0) + s x y + s s s

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17

slide-47
SLIDE 47

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)

term rewriting graph rewriting

  • 1. identifying matching subterm
  • 1. finding term graph morphism

s(s(0) + s(0))|1 = σ(s(x) + y) σ =

  • x → 0

y → s(0) + s x y + s s s

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17

slide-48
SLIDE 48

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)

term rewriting graph rewriting

  • 1. identifying matching subterm
  • 1. finding term graph morphism

s(s(0) + s(0))|1 = σ(s(x) + y) σ =

  • x → 0

y → s(0) + s x y + s s s

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17

slide-49
SLIDE 49

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)

term rewriting graph rewriting

  • 1. identifying matching subterm
  • 1. finding term graph morphism

s(s(0) + s(0))|1 = σ(s(x) + y) σ =

  • x → 0

y → s(0) + s x y + s s s

  • 2. replace matched subterm

s(s(s(0) + 0))

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17

slide-50
SLIDE 50

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)

term rewriting graph rewriting

  • 1. identifying matching subterm
  • 1. finding term graph morphism

s(s(0) + s(0))|1 = σ(s(x) + y) σ =

  • x → 0

y → s(0) + s x y + s s s

  • 2. replace matched subterm

s(σ(s(x) + y))

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17

slide-51
SLIDE 51

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)

term rewriting graph rewriting

  • 1. identifying matching subterm
  • 1. finding term graph morphism

s(s(0) + s(0))|1 = σ(s(x) + y) σ =

  • x → 0

y → s(0) + s x y + s s s

  • 2. replace matched subterm

s(σ(s(x) + y)) − →R s(σ(s(x + y)))

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17

slide-52
SLIDE 52

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)

term rewriting graph rewriting

  • 1. identifying matching subterm
  • 1. finding term graph morphism

s(s(0) + s(0))|1 = σ(s(x) + y) σ =

  • x → 0

y → s(0) + s x y + s s s

  • 2. replace matched subterm

s(σ(s(x) + y)) − →R s(s(0 + s(0)))

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17

slide-53
SLIDE 53

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)

term rewriting graph rewriting

  • 1. identifying matching subterm
  • 1. finding term graph morphism

s(s(0) + s(0))|1 = σ(s(x) + y) σ =

  • x → 0

y → s(0) + s x y + s s s

  • 2. replace matched subterm
  • 2. replace matched subgraph

s(σ(s(x) + y)) − →R s(s(0 + s(0))) + s s s

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17

slide-54
SLIDE 54

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)

term rewriting graph rewriting

  • 1. identifying matching subterm
  • 1. finding term graph morphism

s(s(0) + s(0))|1 = σ(s(x) + y) σ =

  • x → 0

y → s(0) + s x y + s s s

  • 2. replace matched subterm
  • 2a. add copy of right-hand side

s(σ(s(x) + y)) − →R s(s(0 + s(0))) + s s s s + x y

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17

slide-55
SLIDE 55

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)

term rewriting graph rewriting

  • 1. identifying matching subterm
  • 1. finding term graph morphism

s(s(0) + s(0))|1 = σ(s(x) + y) σ =

  • x → 0

y → s(0) + s x y + s s s

  • 2. replace matched subterm
  • 2a. add copy of right-hand side

s(σ(s(x) + y)) − →R s(s(0 + s(0))) + s s s s + x y

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17

slide-56
SLIDE 56

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)

term rewriting graph rewriting

  • 1. identifying matching subterm
  • 1. finding term graph morphism

s(s(0) + s(0))|1 = σ(s(x) + y) σ =

  • x → 0

y → s(0) + s x y + s s s

  • 2. replace matched subterm
  • 2a. add copy of right-hand side

s(σ(s(x) + y)) − →R s(s(0 + s(0))) + s s s s + x y

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17

slide-57
SLIDE 57

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)

term rewriting graph rewriting

  • 1. identifying matching subterm
  • 1. finding term graph morphism

s(s(0) + s(0))|1 = σ(s(x) + y) σ =

  • x → 0

y → s(0) + s x y + s s s

  • 2. replace matched subterm
  • 2b. redirect edges

s(σ(s(x) + y)) − →R s(s(0 + s(0))) + s s s s + x y

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17

slide-58
SLIDE 58

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)

term rewriting graph rewriting

  • 1. identifying matching subterm
  • 1. finding term graph morphism

s(s(0) + s(0))|1 = σ(s(x) + y) σ =

  • x → 0

y → s(0) + s x y + s s s

  • 2. replace matched subterm
  • 2b. redirect edges

s(σ(s(x) + y)) − →R s(s(0 + s(0))) + s s s s + y

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17

slide-59
SLIDE 59

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)

term rewriting graph rewriting

  • 1. identifying matching subterm
  • 1. finding term graph morphism

s(s(0) + s(0))|1 = σ(s(x) + y) σ =

  • x → 0

y → s(0) + s x y + s s s

  • 2. replace matched subterm
  • 2b. redirect edges

s(σ(s(x) + y)) − →R s(s(0 + s(0))) + s s s s + y

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17

slide-60
SLIDE 60

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)

term rewriting graph rewriting

  • 1. identifying matching subterm
  • 1. finding term graph morphism

s(s(0) + s(0))|1 = σ(s(x) + y) σ =

  • x → 0

y → s(0) + s x y + s s s

  • 2. replace matched subterm
  • 2b. redirect edges

s(σ(s(x) + y)) − →R s(s(0 + s(0))) + s s s s +

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17

slide-61
SLIDE 61

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)

term rewriting graph rewriting

  • 1. identifying matching subterm
  • 1. finding term graph morphism

s(s(0) + s(0))|1 = σ(s(x) + y) σ =

  • x → 0

y → s(0) + s x y + s s s

  • 2. replace matched subterm
  • 2c. remove inaccessible nodes

s(σ(s(x) + y)) − →R s(s(0 + s(0))) + s s s s +

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17

slide-62
SLIDE 62

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)

term rewriting graph rewriting

  • 1. identifying matching subterm
  • 1. finding term graph morphism

s(s(0) + s(0))|1 = σ(s(x) + y) σ =

  • x → 0

y → s(0) + s x y + s s s

  • 2. replace matched subterm
  • 2c. remove inaccessible nodes

s(σ(s(x) + y)) − →R s(s(0 + s(0))) s s s +

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17

slide-63
SLIDE 63

Graph Rewriting in a Nutshell

Graph Rewriting in a Nutshell

Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)

term rewriting graph rewriting

  • 1. identifying matching subterm
  • 1. finding term graph morphism

s(s(0) + s(0))|1 = σ(s(x) + y) σ =

  • x → 0

y → s(0) + s x y + s s s

  • 2. replace matched subterm
  • 2c. remove inaccessible nodes

s(σ(s(x) + y)) − →R s(s(0 + s(0))) s s s + s

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17

slide-64
SLIDE 64

Adequacy of Graph Rewriting

Adequacy of Graph Rewriting

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 13/17

slide-65
SLIDE 65

Adequacy of Graph Rewriting

Adequacy of Graph Rewriting for Term Rewriting

s t

ℓ R

term rewriting S T

ℓ G

graph rewriting s t

p(ℓ) M

Turing machine

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 13/17

slide-66
SLIDE 66

Adequacy of Graph Rewriting

Adequacy of Graph Rewriting for Term Rewriting

s t

ℓ R

term rewriting S T

ℓ G

graph rewriting s t

p(ℓ) M

Turing machine

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 13/17

slide-67
SLIDE 67

Adequacy of Graph Rewriting

Simulating Graph Rewrite System

Definition

◮ simulating graph rewrite system G(R) of TRS R

G(R) : =

  • △(l) → △(r) | (l → r) ∈ R
  • ◮ △(s) is minimally sharing graph representing s

Example

x + x → d(x)

+ x

d x

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 14/17

slide-68
SLIDE 68

Adequacy of Graph Rewriting

Simulating Graph Rewrite System

Problems

x + x → d(x)

+ x

d x

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 15/17

slide-69
SLIDE 69

Adequacy of Graph Rewriting

Simulating Graph Rewrite System

Problems

x + x → d(x)

+ x

d x

  • (0 + 0) + (0 + 0)
  • ×
  • (0 + 0) + (0 + 0)

→R

  • (0 + 0) + (0 + 0)
  • ×
  • (0 + 0) + d(0)
  • MA& GM (ICS @ UIBK)

Complexity Analysis of Graph Rewriting 15/17

slide-70
SLIDE 70

Adequacy of Graph Rewriting

Simulating Graph Rewrite System

Problems

x + x → d(x)

+ x

d x

  • (0 + 0) + (0 + 0)
  • ×
  • (0 + 0) + (0 + 0)

→R

  • (0 + 0) + (0 + 0)
  • ×
  • (0 + 0) + d(0)
  • ×

+ +

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 15/17

slide-71
SLIDE 71

Adequacy of Graph Rewriting

Simulating Graph Rewrite System

Problems

x + x → d(x)

+ x

d x

  • (0 + 0) + (0 + 0)
  • ×
  • (0 + 0) + (0 + 0)

→R

  • (0 + 0) + (0 + 0)
  • ×
  • (0 + 0) + d(0)
  • ×

+ + + x

d x

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 15/17

slide-72
SLIDE 72

Adequacy of Graph Rewriting

Simulating Graph Rewrite System

Problems

x + x → d(x)

+ x

d x

  • (0 + 0) + (0 + 0)
  • ×
  • (0 + 0) + (0 + 0)

→R

  • (0 + 0) + (0 + 0)
  • ×
  • (0 + 0) + d(0)
  • ×

+ + + x

d x

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 15/17

slide-73
SLIDE 73

Adequacy of Graph Rewriting

Simulating Graph Rewrite System

Problems

x + x → d(x)

+ x

d x

  • (0 + 0) + (0 + 0)
  • ×
  • (0 + 0) + (0 + 0)

→R

  • (0 + 0) + (0 + 0)
  • ×
  • (0 + 0) + d(0)
  • ×

+ + + x

d x

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 15/17

slide-74
SLIDE 74

Adequacy of Graph Rewriting

Simulating Graph Rewrite System

Problems

x + x → d(x)

+ x

d x

  • (0 + 0) + (0 + 0)
  • ×
  • (0 + 0) + (0 + 0)

→R

  • (0 + 0) + (0 + 0)
  • ×
  • (0 + 0) + d(0)
  • ×

+ + + x

d x no redex

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 15/17

slide-75
SLIDE 75

Adequacy of Graph Rewriting

Simulating Graph Rewrite System

Problems

x + x → d(x)

+ x

d x

  • (0 + 0) + (0 + 0)
  • ×
  • (0 + 0) + (0 + 0)

→R

  • (0 + 0) + (0 + 0)
  • ×
  • (0 + 0) + d(0)
  • ×

+ + + x

d x

Problem ➀

below redex maximal sharing required

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 15/17

slide-76
SLIDE 76

Adequacy of Graph Rewriting

Simulating Graph Rewrite System

Problems

x + x → d(x)

+ x

d x

  • (0 + 0) + (0 + 0)
  • ×
  • (0 + 0) + (0 + 0)

→R

  • (0 + 0) + (0 + 0)
  • ×
  • (0 + 0) + d(0)
  • ×

+ + + x

d x

Problem ➀

below redex maximal sharing required

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 15/17

slide-77
SLIDE 77

Adequacy of Graph Rewriting

Simulating Graph Rewrite System

Problems

x + x → d(x)

+ x

d x

  • (0 + 0) + (0 + 0)
  • ×
  • (0 + 0) + (0 + 0)

→R

  • (0 + 0) + (0 + 0)
  • ×
  • (0 + 0) + d(0)
  • ×

+ +

Problem ➀

below redex maximal sharing required = ⇒G(R) × + d

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 15/17

slide-78
SLIDE 78

Adequacy of Graph Rewriting

Simulating Graph Rewrite System

Problems

x + x → d(x)

+ x

d x

  • (0 + 0) + (0 + 0)
  • ×
  • (0 + 0) + (0 + 0)

→R

  • (0 + 0) + (0 + 0)
  • ×
  • (0 + 0) + d(0)
  • ×

+ +

Problem ➀

below redex maximal sharing required = ⇒G(R) × + d

Problem ➁

both arguments

  • f +\× rewritten

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 15/17

slide-79
SLIDE 79

Adequacy of Graph Rewriting

Adequacy of Graph Rewriting

Theorem

suppose s is a term and S is a term graph representing s such that for redex position p in s

1 node corresponding to p is unshared 2 subgraph S ↾p is maximally shared

Then s − →R,p t ⇐ ⇒ S = ⇒G(R),p T where T represents t

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 16/17

slide-80
SLIDE 80

Adequacy of Graph Rewriting

Adequacy of Graph Rewriting

Theorem

suppose s is a term and S is a term graph representing s such that for redex position p in s

1 node corresponding to p is unshared 2 subgraph S ↾p is maximally shared

Then s − →R,p t ⇐ ⇒ S = ⇒G(R),p T where T represents t Idea

◮ recover condition ➋ by extending rewrite relation with sharing

= ⇒G : =

i

= ⇒G · ≥

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 16/17

slide-81
SLIDE 81

Adequacy of Graph Rewriting

Adequacy of Graph Rewriting

Theorem

suppose s is a term and S is a term graph representing s such that for redex position p in s

1 node corresponding to p is unshared 2 subgraph S ↾p is maximally shared

Then s − →R,p t ⇐ ⇒ S = ⇒G(R),p T where T represents t Idea

◮ condition ➊ is invariant on innermost G(R) reductions ◮ recover condition ➋ by extending rewrite relation with sharing

= ⇒G : =

i

= ⇒G · ≥

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 16/17

slide-82
SLIDE 82

Adequacy of Graph Rewriting

Adequacy of Graph Rewriting

Theorem

suppose s is a term and S is a term graph representing s such that for redex position p in s

1 node corresponding to p is unshared 2 subgraph S ↾p is maximally shared

Then s − →R,p t ⇐ ⇒ S = ⇒G(R),p T where T represents t

Theorem

s

i

− →ℓ

R t

⇐ ⇒ S

= ⇒ℓ

G(R) T

for suitable graph representations S and T of terms s and t

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 16/17

slide-83
SLIDE 83

Adequacy of Graph Rewriting

Main Result Revisited

Theorem

If the (innermost) runtime-complexity of R is polynomially bounded, then each function f computed by R is polytime computable.

rci

R(n) nk ⇒ f ∈ FP

f computed by R

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 17/17

slide-84
SLIDE 84

Adequacy of Graph Rewriting

Main Result Revisited

Theorem

If the (innermost) runtime-complexity of R is polynomially bounded, then each function f computed by R is polytime computable.

rci

R(n) nk ⇒ f ∈ FP

f computed by R

Proof Idea

1 employ innermost rewriting for computation of results

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 17/17

slide-85
SLIDE 85

Adequacy of Graph Rewriting

Main Result Revisited

Theorem

If the (innermost) runtime-complexity of R is polynomially bounded, then each function f computed by R is polytime computable.

rci

R(n) nk ⇒ f ∈ FP

f computed by R

Proof Idea

1 employ innermost graph rewriting for computation of results

adequacy theorem

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 17/17

slide-86
SLIDE 86

Adequacy of Graph Rewriting

Main Result Revisited

Theorem

If the (innermost) runtime-complexity of R is polynomially bounded, then each function f computed by R is polytime computable.

rci

R(n) nk ⇒ f ∈ FP

f computed by R

Proof Idea

1 employ innermost graph rewriting for computation of results

adequacy theorem

2 graphs grow only polynomial in size

S

= ⇒ℓ

G T ⇒ |T| |S| + ℓ∆

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 17/17

slide-87
SLIDE 87

Adequacy of Graph Rewriting

Main Result Revisited

Theorem

If the (innermost) runtime-complexity of R is polynomially bounded, then each function f computed by R is polytime computable.

rci

R(n) nk ⇒ f ∈ FP

f computed by R

Proof Idea

1 employ innermost graph rewriting for computation of results

adequacy theorem

2 graphs grow only polynomial in size

S

= ⇒ℓ

G T ⇒ |T| |S| + ℓ∆ 3 each step computable in polynomial time

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 17/17

slide-88
SLIDE 88

Adequacy of Graph Rewriting

Main Result Revisited

Theorem

If the (innermost) runtime-complexity of R is polynomially bounded, then each function f computed by R is polytime computable.

rci

R(n) nk ⇒ f ∈ FP

f computed by R

Proof Idea

1 employ innermost graph rewriting for computation of results

adequacy theorem

2 graphs grow only polynomial in size

S

= ⇒ℓ

G T ⇒ |T| |S| + ℓ∆ 3 each step computable in polynomial time in size of starting term

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 17/17

slide-89
SLIDE 89

Adequacy of Graph Rewriting

Main Result Revisited

Theorem

If the (innermost) runtime-complexity of R is polynomially bounded, then each function f computed by R is polytime computable.

rci

R(n) nk ⇒ f ∈ FP

f computed by R

Proof Idea

1 employ innermost graph rewriting for computation of results

adequacy theorem

2 graphs grow only polynomial in size

S

= ⇒ℓ

G T ⇒ |T| |S| + ℓ∆ 3 each step computable in polynomial time in size of starting term 4 overall polynomial number of steps required

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 17/17

slide-90
SLIDE 90

Conclusion

Conclusion

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 18/17

slide-91
SLIDE 91

Conclusion

Conclusion

◮ notion of runtime-complexity is a reason cost model for rewriting 1 cost of computation naturally expressed 2 polynomially related to actual cost on Turing machines

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 18/17

slide-92
SLIDE 92

Conclusion

Conclusion

◮ notion of runtime-complexity is a reason cost model for rewriting 1 cost of computation naturally expressed 2 polynomially related to actual cost on Turing machines ◮ runtime-complexity analysis gives rise automation

  • TCT

http://cl-informatik.uibk.ac.at/research/software/tct

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 18/17

slide-93
SLIDE 93

Conclusion

Conclusion

◮ notion of runtime-complexity is a reason cost model for rewriting 1 cost of computation naturally expressed 2 polynomially related to actual cost on Turing machines ◮ runtime-complexity analysis gives rise automation

  • CaT

http://cl-informatik.uibk.ac.at/research/software/ttt2

  • TCT

http://cl-informatik.uibk.ac.at/research/software/tct

  • Matchbox/Poly

http://dfa.imn.htwk-leipzig.de/matchbox/poly

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 18/17

slide-94
SLIDE 94

Conclusion

Conclusion

◮ notion of runtime-complexity is a reason cost model for rewriting 1 cost of computation naturally expressed 2 polynomially related to actual cost on Turing machines ◮ runtime-complexity analysis gives rise automation

  • CaT

http://cl-informatik.uibk.ac.at/research/software/ttt2

  • TCT

http://cl-informatik.uibk.ac.at/research/software/tct

  • Matchbox/Poly

http://dfa.imn.htwk-leipzig.de/matchbox/poly

Future Work

◮ extension of results to full rewriting

just finished

  • classification of nondeterministic computation possible

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 18/17

slide-95
SLIDE 95

Conclusion

Conclusion

◮ notion of runtime-complexity is a reason cost model for rewriting 1 cost of computation naturally expressed 2 polynomially related to actual cost on Turing machines ◮ runtime-complexity analysis gives rise automation

  • CaT

http://cl-informatik.uibk.ac.at/research/software/ttt2

  • TCT

http://cl-informatik.uibk.ac.at/research/software/tct

  • Matchbox/Poly

http://dfa.imn.htwk-leipzig.de/matchbox/poly

Future Work

◮ extension of results to full rewriting

just finished

  • classification of nondeterministic computation possible

◮ complexity preserving translations of (pure) functional programs

MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 18/17