C O mputational gic L Closing the Gap Between Runtime Complexity and Polytime Computability Martin Avanzini and Georg Moser Computational Logic Faculty of Computer Science, University of Innsbruck RTA ’10
Complexity Analysis of Term Rewrite Systems Runtime Complexity Analysis Simple “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) RC = CC 2/15
Complexity Analysis of Term Rewrite Systems Runtime Complexity Analysis Simple “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 ) Computation d(c × c) MA & GM (ICS @ UIBK) RC = CC 2/15
Complexity Analysis of Term Rewrite Systems Runtime Complexity Analysis Simple “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 ) Computation d(c × c) = d(c) × c + c × d(c) MA & GM (ICS @ UIBK) RC = CC 2/15
Complexity Analysis of Term Rewrite Systems Runtime Complexity Analysis Simple “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 ) Computation d(c × c) = 0 × c + c × d(c) MA & GM (ICS @ UIBK) RC = CC 2/15
Complexity Analysis of Term Rewrite Systems Runtime Complexity Analysis Simple “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 ) Computation d(c × c) = 0 × c + c × 0 MA & GM (ICS @ UIBK) RC = CC 2/15
Complexity Analysis of Term Rewrite Systems Runtime Complexity Analysis Simple “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 ) Computation ≈ Rewriting → ! d(c × c) − R 0 × c + c × 0 MA & GM (ICS @ UIBK) RC = CC 2/15
Complexity Analysis of Term Rewrite Systems Runtime Complexity Analysis Simple “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 ) Computation ≈ Rewriting → ! d(c × c) − R 0 × c + c × 0 Runtime Complexity “number of reduction steps as function in the size of the initial terms” MA & GM (ICS @ UIBK) RC = CC 2/15
Complexity Analysis of Term Rewrite Systems Runtime Complexity Analysis Simple “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 ) Computation ≈ Rewriting → ! d(c × c) − R 0 × c + c × 0 Runtime Complexity “number of reduction steps as function in the size of the initial terms” ◮ initial terms are argument normalised MA & GM (ICS @ UIBK) RC = CC 2/15
Complexity Analysis of Term Rewrite Systems Computation and Complexity let C collect all constructor symbols and let V al abbreviate T ( C , V ) Definition (Computation) Let R denote a confluent and terminating TRS. R computes a function f : V al k → V al if ∃ function symbol f → ! f ( v 1 , . . . , v k ) = w ⇐ ⇒ f( v 1 , . . . , v k ) − R w MA & GM (ICS @ UIBK) RC = CC 3/15
Complexity Analysis of Term Rewrite Systems Computation and Complexity let C collect all constructor symbols and let V al abbreviate T ( C , V ) Definition (Computation) Let R denote a confluent and terminating TRS. R computes a relation R ⊆ V al k × V al if ∃ function symbol f → ! ( v 1 , . . . , v k , w ) ∈ R ⇐ ⇒ f( v 1 , . . . , v k ) − R w and w accepting MA & GM (ICS @ UIBK) RC = CC 3/15
Complexity Analysis of Term Rewrite Systems Computation and Complexity let C collect all constructor symbols and let V al abbreviate T ( C , V ) Definition (Computation) Let R denote a confluent and terminating TRS. R computes a relation R ⊆ V al k × V al if ∃ function symbol f → ! ( v 1 , . . . , v k , w ) ∈ R ⇐ ⇒ f( v 1 , . . . , v k ) − R w and w accepting Definition (Runtime Complexity) rc R ( n ) = max { dl( t , − → R ) | | t | � n } where dl( t , − → R ) = max { ℓ | ∃ ( t 1 , . . . , t ℓ ) . t − → R t 1 − → R . . . − → R t ℓ } MA & GM (ICS @ UIBK) RC = CC 3/15
Complexity Analysis of Term Rewrite Systems Computation and Complexity let C collect all constructor symbols and let V al abbreviate T ( C , V ) Definition (Computation) Let R denote a confluent and terminating TRS. R computes a relation R ⊆ V al k × V al if ∃ function symbol f → ! ( v 1 , . . . , v k , w ) ∈ R ⇐ ⇒ f( v 1 , . . . , v k ) − R w and w accepting Definition (Runtime Complexity) rc R ( n ) = max { dl( t , − → R ) | | t | � n and arguments from V al } where dl( t , − → R ) = max { ℓ | ∃ ( t 1 , . . . , t ℓ ) . t − → R t 1 − → R . . . − → R t ℓ } MA & GM (ICS @ UIBK) RC = CC 3/15
Complexity Analysis of Term Rewrite Systems Automated 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) RC = CC 4/15
Complexity Analysis of Term Rewrite Systems Automated 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 ) ◮ derivational complexity of above TRS is at least exponential MA & GM (ICS @ UIBK) RC = CC 4/15
Complexity Analysis of Term Rewrite Systems Automated 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 ) ◮ derivational complexity of above TRS is at least exponential ◮ runtime complexity of above TRS is linear $ tct -a rc -p 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) RC = CC 4/15
Complexity Analysis of Term Rewrite Systems Automated 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 ) ◮ derivational complexity of above TRS is at least exponential ◮ runtime complexity of above TRS is linear Our Question $ tct -a rc -p dif.trs YES(?,O(n^1)) what can we infer about ’Weak Dependency Pairs’ ----------------------- the computational complexity Answer: YES(?,O(n^1)) Input Problem: runtime-complexity with respect to from this proof? 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) RC = CC 4/15
Complexity Analysis of Term Rewrite Systems Automated 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 ) ◮ derivational complexity of above TRS is at least exponential ◮ runtime complexity of above TRS is linear Our Question $ tct -a rc -p dif.trs YES(?,O(n^1)) In particular, does it certify ’Weak Dependency Pairs’ ----------------------- polytime computability Answer: YES(?,O(n^1)) Input Problem: runtime-complexity with respect to of the functions defined? 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) RC = CC 4/15
Main Result Yes MA & GM (ICS @ UIBK) RC = CC 5/15
Main Result runtime complexity is a reasonable cost model for rewriting MA & GM (ICS @ UIBK) RC = CC 5/15
Main Result runtime complexity is a reasonable cost model for rewriting 1 runtime complexity naturally expresses the cost of computation MA & GM (ICS @ UIBK) RC = CC 5/15
Main Result runtime complexity is a reasonable cost model for rewriting 1 runtime complexity naturally expresses the cost of computation 2 polynomially related to actual cost of an implementation on a Turing machine MA & GM (ICS @ UIBK) RC = CC 5/15
Main Result Theorem For any term s with dl R ( s ) � ℓ ℓ = Ω( | s | ) 1 some normal-form is computable in deterministic time O(log( ℓ ) 3 ℓ 7 ) MA & GM (ICS @ UIBK) RC = CC 6/15
Main Result Theorem For any term s with dl R ( s ) � ℓ ℓ = Ω( | s | ) 1 some normal-form is computable in deterministic time O(log( ℓ ) 3 ℓ 7 ) t 7 t 6 · · t 5 s t 3 t 4 · t 2 t 1 MA & GM (ICS @ UIBK) RC = CC 6/15
Main Result Theorem For any term s with dl R ( s ) � ℓ ℓ = Ω( | s | ) 1 some normal-form is computable in deterministic time O(log( ℓ ) 3 ℓ 7 ) t 7 t 6 · · t 5 s t 3 t 4 · t 2 computed NF depends on employed strategy t 1 MA & GM (ICS @ UIBK) RC = CC 6/15
Recommend
More recommend