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
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
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 2/17
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 }
− →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
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}
− →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
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
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
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’
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
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’
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
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’
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
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 6/17
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
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
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
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
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
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
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
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
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
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
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
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
Graph Rewriting in a Nutshell Adequacy of Graph Rewriting Conclusion
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 9/17
Graph Rewriting in a Nutshell
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 10/17
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
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
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
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
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
Graph Rewriting in a Nutshell
Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)
term rewriting graph rewriting
s(s(0) + s(0))|1 = σ(s(x) + y) σ =
y → s(0)
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17
Graph Rewriting in a Nutshell
Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)
term rewriting graph rewriting
s(s(0) + s(0))|1 = σ(s(x) + y) σ =
y → s(0) + s x y + s s s
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17
Graph Rewriting in a Nutshell
Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)
term rewriting graph rewriting
s(s(0) + s(0))|1 = σ(s(x) + y) σ =
y → s(0) + s x y + s s s
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17
Graph Rewriting in a Nutshell
Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)
term rewriting graph rewriting
s(s(0) + s(0))|1 = σ(s(x) + y) σ =
y → s(0) + s x y + s s s
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17
Graph Rewriting in a Nutshell
Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)
term rewriting graph rewriting
s(s(0) + s(0))|1 = σ(s(x) + y) σ =
y → s(0) + s x y + s s s
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17
Graph Rewriting in a Nutshell
Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)
term rewriting graph rewriting
s(s(0) + s(0))|1 = σ(s(x) + y) σ =
y → s(0) + s x y + s s s
s(s(s(0) + 0))
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17
Graph Rewriting in a Nutshell
Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)
term rewriting graph rewriting
s(s(0) + s(0))|1 = σ(s(x) + y) σ =
y → s(0) + s x y + s s s
s(σ(s(x) + y))
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17
Graph Rewriting in a Nutshell
Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)
term rewriting graph rewriting
s(s(0) + s(0))|1 = σ(s(x) + y) σ =
y → s(0) + s x y + s s s
s(σ(s(x) + y)) − →R s(σ(s(x + y)))
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17
Graph Rewriting in a Nutshell
Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)
term rewriting graph rewriting
s(s(0) + s(0))|1 = σ(s(x) + y) σ =
y → s(0) + s x y + s s s
s(σ(s(x) + y)) − →R s(s(0 + s(0)))
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17
Graph Rewriting in a Nutshell
Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)
term rewriting graph rewriting
s(s(0) + s(0))|1 = σ(s(x) + y) σ =
y → s(0) + s x y + s s s
s(σ(s(x) + y)) − →R s(s(0 + s(0))) + s s s
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17
Graph Rewriting in a Nutshell
Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)
term rewriting graph rewriting
s(s(0) + s(0))|1 = σ(s(x) + y) σ =
y → s(0) + s x y + s s s
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
Graph Rewriting in a Nutshell
Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)
term rewriting graph rewriting
s(s(0) + s(0))|1 = σ(s(x) + y) σ =
y → s(0) + s x y + s s s
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
Graph Rewriting in a Nutshell
Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)
term rewriting graph rewriting
s(s(0) + s(0))|1 = σ(s(x) + y) σ =
y → s(0) + s x y + s s s
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
Graph Rewriting in a Nutshell
Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)
term rewriting graph rewriting
s(s(0) + s(0))|1 = σ(s(x) + y) σ =
y → s(0) + s x y + s s s
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
Graph Rewriting in a Nutshell
Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)
term rewriting graph rewriting
s(s(0) + s(0))|1 = σ(s(x) + y) σ =
y → s(0) + s x y + s s s
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
Graph Rewriting in a Nutshell
Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)
term rewriting graph rewriting
s(s(0) + s(0))|1 = σ(s(x) + y) σ =
y → s(0) + s x y + s s s
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
Graph Rewriting in a Nutshell
Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)
term rewriting graph rewriting
s(s(0) + s(0))|1 = σ(s(x) + y) σ =
y → s(0) + s x y + s s s
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
Graph Rewriting in a Nutshell
Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)
term rewriting graph rewriting
s(s(0) + s(0))|1 = σ(s(x) + y) σ =
y → s(0) + s x y + s s s
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
Graph Rewriting in a Nutshell
Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)
term rewriting graph rewriting
s(s(0) + s(0))|1 = σ(s(x) + y) σ =
y → s(0) + s x y + s s s
s(σ(s(x) + y)) − →R s(s(0 + s(0))) s s s +
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 12/17
Graph Rewriting in a Nutshell
Rewriting s(s(0) + s(0)) using rule s(x) + y → s(x + y)
term rewriting graph rewriting
s(s(0) + s(0))|1 = σ(s(x) + y) σ =
y → s(0) + s x y + s s s
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
Adequacy of Graph Rewriting
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 13/17
Adequacy of Graph 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
Adequacy of Graph 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
Adequacy of Graph Rewriting
Definition
◮ simulating graph rewrite system G(R) of TRS R
G(R) : =
Example
x + x → d(x)
+ x
d x
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 14/17
Adequacy of Graph Rewriting
Problems
x + x → d(x)
+ x
d x
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 15/17
Adequacy of Graph Rewriting
Problems
x + x → d(x)
+ x
d x
→R
Complexity Analysis of Graph Rewriting 15/17
Adequacy of Graph Rewriting
Problems
x + x → d(x)
+ x
d x
→R
+ +
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 15/17
Adequacy of Graph Rewriting
Problems
x + x → d(x)
+ x
d x
→R
+ + + x
d x
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 15/17
Adequacy of Graph Rewriting
Problems
x + x → d(x)
+ x
d x
→R
+ + + x
d x
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 15/17
Adequacy of Graph Rewriting
Problems
x + x → d(x)
+ x
d x
→R
+ + + x
d x
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 15/17
Adequacy of Graph Rewriting
Problems
x + x → d(x)
+ x
d x
→R
+ + + x
d x no redex
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 15/17
Adequacy of Graph Rewriting
Problems
x + x → d(x)
+ x
d x
→R
+ + + x
d x
Problem ➀
below redex maximal sharing required
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 15/17
Adequacy of Graph Rewriting
Problems
x + x → d(x)
+ x
d x
→R
+ + + x
d x
Problem ➀
below redex maximal sharing required
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 15/17
Adequacy of Graph Rewriting
Problems
x + x → d(x)
+ x
d x
→R
+ +
Problem ➀
below redex maximal sharing required = ⇒G(R) × + d
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 15/17
Adequacy of Graph Rewriting
Problems
x + x → d(x)
+ x
d x
→R
+ +
Problem ➀
below redex maximal sharing required = ⇒G(R) × + d
Problem ➁
both arguments
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 15/17
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
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
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
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
Adequacy of Graph Rewriting
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
Adequacy of Graph Rewriting
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
Adequacy of Graph Rewriting
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
Adequacy of Graph Rewriting
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
Adequacy of Graph Rewriting
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
Adequacy of Graph Rewriting
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
Adequacy of Graph Rewriting
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
Conclusion
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 18/17
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
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
http://cl-informatik.uibk.ac.at/research/software/tct
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 18/17
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
http://cl-informatik.uibk.ac.at/research/software/ttt2
http://cl-informatik.uibk.ac.at/research/software/tct
http://dfa.imn.htwk-leipzig.de/matchbox/poly
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 18/17
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
http://cl-informatik.uibk.ac.at/research/software/ttt2
http://cl-informatik.uibk.ac.at/research/software/tct
http://dfa.imn.htwk-leipzig.de/matchbox/poly
Future Work
◮ extension of results to full rewriting
just finished
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 18/17
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
http://cl-informatik.uibk.ac.at/research/software/ttt2
http://cl-informatik.uibk.ac.at/research/software/tct
http://dfa.imn.htwk-leipzig.de/matchbox/poly
Future Work
◮ extension of results to full rewriting
just finished
◮ complexity preserving translations of (pure) functional programs
MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 18/17