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 2/17
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 0 | Const c | Times Exp Exp e 1 × e 2 | Plus Exp Exp e 1 + e 2 | Minus Exp Exp e 1 − e 2 MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 3/17
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
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
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
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
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
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
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
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
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
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
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
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
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
Term Rewriting Complexity ◮ innermost runtime complexity number of eager evaluation steps as function in the size of the initial terms rc i R ( n ) = max { dl( t , i − → R ) | size( t ) � n } i − → R ⊆ − → R is restriction to eager evaluation • ◮ derivation length dl( t , i i i i − → R ) = max { ℓ | ∃ ( t 1 , . . . , t ℓ ) . t − → R t 1 − → R . . . − → R t ℓ } MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 4/17
Term Rewriting Complexity ◮ innermost runtime complexity number of eager evaluation steps as function in the size of the initial terms rc i 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 i i i − → R ) = max { ℓ | ∃ ( t 1 , . . . , t ℓ ) . t − → R t 1 − → R . . . − → R t ℓ } MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 4/17
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
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
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
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 is this proof really $ tct -a rc -p -s "wdp (matrix :kind triangular)" dif.trs YES(?,O(n^1)) meaningful? ’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
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 is this proof really $ tct -a rc -p -s "wdp (matrix :kind triangular)" dif.trs YES(?,O(n^1)) a certificate for ’Weak Dependency Pairs’ polytime computability? ----------------------- 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
Main Result Yes MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 6/17
Main Result Theorem If the (innermost) runtime-complexity of R is polynomially bounded, then each function f computed by R is polytime computable. R ( n ) � n k ⇒ f ∈ TIME(O( n 5 · ( k +1) )) rc i f computed by R MA& GM (ICS @ UIBK) Complexity Analysis of Graph Rewriting 6/17
Recommend
More recommend