107
Analyzing Runtime Complexity via Innermost Runtime Complexity Florian Frohn 1 urgen Giesl 1 1 RWTH Aachen University, Germany May 11, 2017

Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Analyzing Runtime Complexity via Innermost RuntimeComplexity

Florian Frohn1 Jurgen Giesl1

1RWTH Aachen University, Germany

May 11, 2017

Page 2: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Consider the following MAUDE program...

Example

mod BASIC-NAT is...rl p l u s 0 Y => Y .rl p l u s s (X) Y => s ( p l u s X Y) .rl t i m e s 0 Y => 0 .

crl t i m e s s (X) Y => p l u s Z Y i f t i m e s X Y => Z .endm

Page 3: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

...which can be seen as a Conditional TRS...

Example

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(z , y) ⇐ times(x , y) ≈ z

Goal: Prove upper bound on worst case complexity

Page 4: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

...which can be seen as a Conditional TRS...

Example

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(z , y) ⇐ times(x , y) ≈ z

Goal: Prove upper bound on worst case complexity

Page 5: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

...which can be transformed to a standard TRS.

Transformation by Cynthia Kop, Aart Middeldorp, and Thomas Sternagel

“Complexity of Conditional Term Rewriting”, LMCS ’17

Leading Example Rtimes

plus(0, y ,>, x2) → yplus(s(x), y , x1,>) → s(plus(x , y ,>,>))times(0, y ,>, x2) → 0

times(s(x), y , x1,>) → times12(s(x), y , x1, times(x , y ,>,>))times12(s(x), y , x1, z) → plus(z , y ,>,>)

Let’s analyze it using leading tools!

TcT: timeout (60 s)

AProVE: full rewriting not supported

But: O(n3) for innermost rewriting – can we exploit that?

Page 6: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

...which can be transformed to a standard TRS.

Transformation by Cynthia Kop, Aart Middeldorp, and Thomas Sternagel

“Complexity of Conditional Term Rewriting”, LMCS ’17

Leading Example Rtimes

plus(0, y ,>, x2) → yplus(s(x), y , x1,>) → s(plus(x , y ,>,>))times(0, y ,>, x2) → 0

times(s(x), y , x1,>) → times12(s(x), y , x1, times(x , y ,>,>))times12(s(x), y , x1, z) → plus(z , y ,>,>)

Let’s analyze it using leading tools!

TcT: timeout (60 s)

AProVE: full rewriting not supported

But: O(n3) for innermost rewriting – can we exploit that?

Page 7: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

...which can be transformed to a standard TRS.

Transformation by Cynthia Kop, Aart Middeldorp, and Thomas Sternagel

“Complexity of Conditional Term Rewriting”, LMCS ’17

Leading Example Rtimes

plus(0, y ,>, x2) → yplus(s(x), y , x1,>) → s(plus(x , y ,>,>))times(0, y ,>, x2) → 0

times(s(x), y , x1,>) → times12(s(x), y , x1, times(x , y ,>,>))times12(s(x), y , x1, z) → plus(z , y ,>,>)

Let’s analyze it using leading tools!

TcT: timeout (60 s)

AProVE: full rewriting not supported

But: O(n3) for innermost rewriting – can we exploit that?

Page 8: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

...which can be transformed to a standard TRS.

Transformation by Cynthia Kop, Aart Middeldorp, and Thomas Sternagel

“Complexity of Conditional Term Rewriting”, LMCS ’17

Leading Example Rtimes

plus(0, y ,>, x2) → yplus(s(x), y , x1,>) → s(plus(x , y ,>,>))times(0, y ,>, x2) → 0

times(s(x), y , x1,>) → times12(s(x), y , x1, times(x , y ,>,>))times12(s(x), y , x1, z) → plus(z , y ,>,>)

Let’s analyze it using leading tools!

TcT: timeout (60 s)

AProVE: full rewriting not supported

But: O(n3) for innermost rewriting – can we exploit that?

Page 9: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

...which can be transformed to a standard TRS.

Transformation by Cynthia Kop, Aart Middeldorp, and Thomas Sternagel

“Complexity of Conditional Term Rewriting”, LMCS ’17

Leading Example Rtimes

plus(0, y ,>, x2) → yplus(s(x), y , x1,>) → s(plus(x , y ,>,>))times(0, y ,>, x2) → 0

times(s(x), y , x1,>) → times12(s(x), y , x1, times(x , y ,>,>))times12(s(x), y , x1, z) → plus(z , y ,>,>)

Let’s analyze it using leading tools!

TcT: timeout (60 s)

AProVE: full rewriting not supported

But: O(n3) for innermost rewriting – can we exploit that?

Page 10: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

...which can be transformed to a standard TRS.

Transformation by Cynthia Kop, Aart Middeldorp, and Thomas Sternagel

“Complexity of Conditional Term Rewriting”, LMCS ’17

Leading Example Rtimes

plus(0, y ,>, x2) → yplus(s(x), y , x1,>) → s(plus(x , y ,>,>))times(0, y ,>, x2) → 0

times(s(x), y , x1,>) → times12(s(x), y , x1, times(x , y ,>,>))times12(s(x), y , x1, z) → plus(z , y ,>,>)

Let’s analyze it using leading tools!

TcT: timeout (60 s)

AProVE: full rewriting not supported

But: O(n3) for innermost rewriting – can we exploit that?

Page 11: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

...which can be transformed to a standard TRS.

Transformation by Cynthia Kop, Aart Middeldorp, and Thomas Sternagel

“Complexity of Conditional Term Rewriting”, LMCS ’17

Leading Example Rtimes

plus(0, y ,>, x2) → yplus(s(x), y , x1,>) → s(plus(x , y ,>,>))times(0, y ,>, x2) → 0

times(s(x), y , x1,>) → times12(s(x), y , x1, times(x , y ,>,>))times12(s(x), y , x1, z) → plus(z , y ,>,>)

Let’s analyze it using leading tools!

TcT: timeout (60 s)

AProVE: full rewriting not supported

But: O(n3) for innermost rewriting – can we exploit that?

Page 12: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

...which can be transformed to a standard TRS.

Transformation by Cynthia Kop, Aart Middeldorp, and Thomas Sternagel

“Complexity of Conditional Term Rewriting”, LMCS ’17

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))

times(0, y ,>, x2) → 0times(s(x), y , x1,>) → times12(s(x), y , x1, times(x , y ,>,>))times12(s(x), y , x1, z) → plus(z , y)

Let’s analyze it using leading tools!

TcT: timeout (60 s)

AProVE: full rewriting not supported

But: O(n3) for innermost rewriting – can we exploit that?

Page 13: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

...which can be transformed to a standard TRS.

Transformation by Cynthia Kop, Aart Middeldorp, and Thomas Sternagel

“Complexity of Conditional Term Rewriting”, LMCS ’17

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))

times(0, y ,>, x2) → 0times(s(x), y , x1,>) → plus(times(x , y ,>,>), y)

Let’s analyze it using leading tools!

TcT: timeout (60 s)

AProVE: full rewriting not supported

But: O(n3) for innermost rewriting – can we exploit that?

Page 14: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

...which can be transformed to a standard TRS.

Transformation by Cynthia Kop, Aart Middeldorp, and Thomas Sternagel

“Complexity of Conditional Term Rewriting”, LMCS ’17

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Let’s analyze it using leading tools!

TcT: timeout (60 s)

AProVE: full rewriting not supported

But: O(n3) for innermost rewriting – can we exploit that?

Page 15: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Outline

1 Preliminariesrc and ircNDG Rewriting

2 Handling Constructor Systems

3 Handling Non-Constructor Systems

4 Experimental Results, Conclusion

Page 16: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

rc and irc

rc maps n ∈ N to the length of the longest rewrite sequence s.t.

(A) size of start term bounded by n

(B) start term basic

irc: similar, but just considers innermost sequences

Example

plus(0, s(0))

3

plus(0,plus(0, s(0))) 8

Page 17: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

rc and irc

rc maps n ∈ N to the length of the longest rewrite sequence s.t.

(A) size of start term bounded by n

(B) start term basic

irc: similar, but just considers innermost sequences

Example

plus(0, s(0))

3

plus(0,plus(0, s(0))) 8

Page 18: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

rc and irc

rc maps n ∈ N to the length of the longest rewrite sequence s.t.

(A) size of start term bounded by n

(B) start term basic

irc: similar, but just considers innermost sequences

Example

plus(0, s(0))

3

plus(0,plus(0, s(0))) 8

Page 19: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

rc and irc

rc maps n ∈ N to the length of the longest rewrite sequence s.t.

(A) size of start term bounded by n

(B) start term basic

irc: similar, but just considers innermost sequences

Example

plus(0, s(0)) 3

plus(0,plus(0, s(0))) 8

Page 20: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

rc and irc

rc maps n ∈ N to the length of the longest rewrite sequence s.t.

(A) size of start term bounded by n

(B) start term basic

irc: similar, but just considers innermost sequences

Example

plus(0, s(0)) 3

plus(0,plus(0, s(0)))

8

Page 21: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

rc and irc

rc maps n ∈ N to the length of the longest rewrite sequence s.t.

(A) size of start term bounded by n

(B) start term basic

irc: similar, but just considers innermost sequences

Example

plus(0, s(0)) 3

plus(0,plus(0, s(0))) 8

Page 22: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

rc and irc

rc maps n ∈ N to the length of the longest rewrite sequence s.t.

(A) size of start term bounded by n

(B) start term basic

irc: similar, but just considers innermost sequences

Example

plus(0, s(0)) 3

plus(0,plus(0, s(0))) 8

Page 23: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Outline

1 Preliminariesrc and ircNDG Rewriting

2 Handling Constructor Systems

3 Handling Non-Constructor Systems

4 Experimental Results, Conclusion

Page 24: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

NDG Rewriting

By Jaco van de Pol and Hans Zantema:

“Generalized innermost rewriting” (RTA ’05)

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Goal: Implement rewriting efficiently

Idea: No duplication of nested defined symbols

Example

times(s(0),plus(0, 0))→ plus(times(0,plus(0, 0)),plus(0, 0)) 8

plus(s(0),plus(0, 0))→ s(plus(0,plus(0, 0))) 3

Page 25: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

NDG Rewriting

By Jaco van de Pol and Hans Zantema:

“Generalized innermost rewriting” (RTA ’05)

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Goal: Implement rewriting efficiently

Idea: No duplication of nested defined symbols

Example

times(s(0),plus(0, 0))→ plus(times(0,plus(0, 0)),plus(0, 0)) 8

plus(s(0),plus(0, 0))→ s(plus(0,plus(0, 0))) 3

Page 26: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

NDG Rewriting

By Jaco van de Pol and Hans Zantema:

“Generalized innermost rewriting” (RTA ’05)

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)Goal: Implement rewriting efficiently

Idea: No duplication of nested defined symbols

Example

times(s(0),plus(0, 0))→ plus(times(0,plus(0, 0)),plus(0, 0)) 8

plus(s(0),plus(0, 0))→ s(plus(0,plus(0, 0))) 3

Page 27: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

NDG Rewriting

By Jaco van de Pol and Hans Zantema:

“Generalized innermost rewriting” (RTA ’05)

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)Goal: Implement rewriting efficiently

Idea: No duplication of nested defined symbols

Example

times(s(0),plus(0, 0))→ plus(times(0,plus(0, 0)),plus(0, 0))

8

plus(s(0),plus(0, 0))→ s(plus(0,plus(0, 0))) 3

Page 28: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

NDG Rewriting

By Jaco van de Pol and Hans Zantema:

“Generalized innermost rewriting” (RTA ’05)

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)Goal: Implement rewriting efficiently

Idea: No duplication of nested defined symbols

Example

times(s(0),plus(0, 0))→ plus(times(0,plus(0, 0)),plus(0, 0)) 8

plus(s(0),plus(0, 0))→ s(plus(0,plus(0, 0))) 3

Page 29: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

NDG Rewriting

By Jaco van de Pol and Hans Zantema:

“Generalized innermost rewriting” (RTA ’05)

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)Goal: Implement rewriting efficiently

Idea: No duplication of nested defined symbols

Example

times(s(0),plus(0, 0))→ plus(times(0,plus(0, 0)),plus(0, 0)) 8

plus(s(0),plus(0, 0))→ s(plus(0,plus(0, 0)))

3

Page 30: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

NDG Rewriting

By Jaco van de Pol and Hans Zantema:

“Generalized innermost rewriting” (RTA ’05)

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)Goal: Implement rewriting efficiently

Idea: No duplication of nested defined symbols

Example

times(s(0),plus(0, 0))→ plus(times(0,plus(0, 0)),plus(0, 0)) 8

plus(s(0),plus(0, 0))→ s(plus(0,plus(0, 0))) 3

Page 31: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

NDG Rewriting is cheap!

Theorem (Pol et. al, RTA ’05)

NDG rewriting is at least as efficientas innermost rewriting.

Reminder: rc

rc maps n to the length of the longestrewrite sequence s.t.

(A) size of start term bounded by n

(B) start term basic

y all sequences ndg =⇒ innermost is the worst case

y all sequences starting with basic terms ndg =⇒ rc = irc

y Goal: Prove that all sequences starting with basic terms are ndg

Use irc techniques to analyze rc

Page 32: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

NDG Rewriting is cheap!

Theorem (Pol et. al, RTA ’05)

NDG rewriting is at least as efficientas innermost rewriting.

Reminder: rc

rc maps n to the length of the longestrewrite sequence s.t.

(A) size of start term bounded by n

(B) start term basic

y all sequences ndg =⇒ innermost is the worst case

y all sequences starting with basic terms ndg =⇒ rc = irc

y Goal: Prove that all sequences starting with basic terms are ndg

Use irc techniques to analyze rc

Page 33: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

NDG Rewriting is cheap!

Theorem (Pol et. al, RTA ’05)

NDG rewriting is at least as efficientas innermost rewriting.

Reminder: rc

rc maps n to the length of the longestrewrite sequence s.t.

(A) size of start term bounded by n

(B) start term basic

y all sequences ndg =⇒ innermost is the worst case

y all sequences starting with basic terms ndg =⇒ rc = irc

y Goal: Prove that all sequences starting with basic terms are ndg

Use irc techniques to analyze rc

Page 34: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

NDG Rewriting is cheap!

Theorem (Pol et. al, RTA ’05)

NDG rewriting is at least as efficientas innermost rewriting.

Reminder: rc

rc maps n to the length of the longestrewrite sequence s.t.

(A) size of start term bounded by n

(B) start term basic

y all sequences ndg =⇒ innermost is the worst case

y all sequences starting with basic terms ndg =⇒ rc = irc

y Goal: Prove that all sequences starting with basic terms are ndg

Use irc techniques to analyze rc

Page 35: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

NDG Rewriting is cheap!

Theorem (Pol et. al, RTA ’05)

NDG rewriting is at least as efficientas innermost rewriting.

Reminder: rc

rc maps n to the length of the longestrewrite sequence s.t.

(A) size of start term bounded by n

(B) start term basic

y all sequences ndg =⇒ innermost is the worst case

y all sequences starting with basic terms ndg =⇒ rc = irc

y Goal: Prove that all sequences starting with basic terms are ndg

Use irc techniques to analyze rc

Page 36: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

NDG Rewriting is cheap!

Theorem (Pol et. al, RTA ’05)

NDG rewriting is at least as efficientas innermost rewriting.

Reminder: rc

rc maps n to the length of the longestrewrite sequence s.t.

(A) size of start term bounded by n

(B) start term basic

y all sequences ndg =⇒ innermost is the worst case

y all sequences starting with basic terms ndg =⇒ rc = irc

y Goal: Prove that all sequences starting with basic terms are ndg

Use irc techniques to analyze rc

Page 37: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Outline

1 Preliminariesrc and ircNDG Rewriting

2 Handling Constructor Systems

3 Handling Non-Constructor Systems

4 Experimental Results, Conclusion

Page 38: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

“Proving” ndg-ness by hand

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

times(...)nesting below plus’ first argument

duplication of times’ second argument

plus(...)no (further) nesting

no duplication

plus(�, y) and times(s(x),�) don’t “overlap”

Page 39: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

“Proving” ndg-ness by hand

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

times(...)

nesting below plus’ first argument

duplication of times’ second argument

plus(...)no (further) nesting

no duplication

plus(�, y) and times(s(x),�) don’t “overlap”

Page 40: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

“Proving” ndg-ness by hand

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

times(...)nesting below plus’ first argument

duplication of times’ second argument

plus(...)no (further) nesting

no duplication

plus(�, y) and times(s(x),�) don’t “overlap”

Page 41: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

“Proving” ndg-ness by hand

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

times(...)nesting below plus’ first argument plus(times(x , y), y)

duplication of times’ second argument

plus(...)no (further) nesting

no duplication

plus(�, y) and times(s(x),�) don’t “overlap”

Page 42: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

“Proving” ndg-ness by hand

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

times(...)nesting below plus’ first argument plus(�, y)

duplication of times’ second argument

plus(...)no (further) nesting

no duplication

plus(�, y) and times(s(x),�) don’t “overlap”

Page 43: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

“Proving” ndg-ness by hand

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

times(...)nesting below plus’ first argument plus(�, y)

duplication of times’ second argument

plus(...)no (further) nesting

no duplication

plus(�, y) and times(s(x),�) don’t “overlap”

Page 44: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

“Proving” ndg-ness by hand

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

times(...)nesting below plus’ first argument plus(�, y)

duplication of times’ second argument times(s(x), y)

plus(...)no (further) nesting

no duplication

plus(�, y) and times(s(x),�) don’t “overlap”

Page 45: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

“Proving” ndg-ness by hand

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

times(...)nesting below plus’ first argument plus(�, y)

duplication of times’ second argument times(s(x),�)

plus(...)no (further) nesting

no duplication

plus(�, y) and times(s(x),�) don’t “overlap”

Page 46: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

“Proving” ndg-ness by hand

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

times(...)nesting below plus’ first argument plus(�, y)

duplication of times’ second argument times(s(x),�)

plus(...)

no (further) nesting

no duplication

plus(�, y) and times(s(x),�) don’t “overlap”

Page 47: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

“Proving” ndg-ness by hand

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

times(...)nesting below plus’ first argument plus(�, y)

duplication of times’ second argument times(s(x),�)

plus(...)

no (further) nesting

no duplication

plus(�, y) and times(s(x),�) don’t “overlap”

Page 48: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

“Proving” ndg-ness by hand

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

times(...)nesting below plus’ first argument plus(�, y)

duplication of times’ second argument times(s(x),�)

plus(...)

no (further) nesting

plus(�, y)

no duplication

plus(�, y) and times(s(x),�) don’t “overlap”

Page 49: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

“Proving” ndg-ness by hand

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

times(...)nesting below plus’ first argument plus(�, y)

duplication of times’ second argument times(s(x),�)

plus(...)no (further) nesting

no duplication

plus(�, y) and times(s(x),�) don’t “overlap”

Page 50: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

“Proving” ndg-ness by hand

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

times(...)nesting below plus’ first argument plus(�, y)

duplication of times’ second argument times(s(x),�)

plus(...)no (further) nesting

no duplication

plus(�, y) and times(s(x),�) don’t “overlap”

Page 51: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

“Proving” ndg-ness by hand

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

times(...)nesting below plus’ first argument plus(�, y)

duplication of times’ second argument times(s(x),�)

plus(...)no (further) nesting

no duplication

plus(�, y) and times(s(x),�) don’t “overlap”

Page 52: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

“Proving” ndg-ness by hand

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

times(...)nesting below plus’ first argument plus(�, y)

duplication of times’ second argument times(s(x),�)

plus(...)no (further) nesting

no duplication

plus(�, y) and times(s(x),�) don’t “overlap”

Reminderno duplication of defined symbols

y innermost rewriting is worst

y rc = irc

y irc techniques applicable for rc

Page 53: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Proving ndg-ness automatically

Representing sets of contexts

C matches D if

C [x ]σ = D

� in D below � in C

Overlapping contexts

C and D overlap if both match some E

Example

plus(x ,�) does not match plus(s(�), y)

Intuition: plus(�, y) represents “marked” terms

plus(times(x , z), y),plus(s(times(0, 0)), 0), . . .

Goal: compute sets of contexts Dup and DefDup and Def don’t overlap y rc = irc

Page 54: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Proving ndg-ness automatically

Representing sets of contexts

C matches D if

C [x ]σ = D

� in D below � in C

Overlapping contexts

C and D overlap if both match some E

Example

plus(x ,�) does not match plus(s(�), y)

Intuition: plus(�, y) represents “marked” terms

plus(times(x , z), y),plus(s(times(0, 0)), 0), . . .

Goal: compute sets of contexts Dup and DefDup and Def don’t overlap y rc = irc

Page 55: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Proving ndg-ness automatically

Representing sets of contexts

C matches D if

C [x ]σ = D

� in D below � in C

Overlapping contexts

C and D overlap if both match some E

Example

plus(x ,�) does not match plus(s(�), y)

Intuition: plus(�, y) represents “marked” terms

plus(times(x , z), y),plus(s(times(0, 0)), 0), . . .

Goal: compute sets of contexts Dup and DefDup and Def don’t overlap y rc = irc

Page 56: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Proving ndg-ness automatically

Representing sets of contexts

C matches D if

C [x ]σ = D

� in D below � in C

Overlapping contexts

C and D overlap if both match some E

Example

plus(x ,�) does not match plus(s(�), y)

Intuition: plus(�, y) represents “marked” terms

plus(times(x , z), y),plus(s(times(0, 0)), 0), . . .

Goal: compute sets of contexts Dup and DefDup and Def don’t overlap y rc = irc

Page 57: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Proving ndg-ness automatically

Representing sets of contexts

C matches D if

C [x ]σ = D

� in D below � in C

Overlapping contexts

C and D overlap if both match some E

Example

plus(�, y) matches plus(s(�), y)

Intuition: plus(�, y) represents “marked” terms

plus(times(x , z), y),plus(s(times(0, 0)), 0), . . .

Goal: compute sets of contexts Dup and DefDup and Def don’t overlap y rc = irc

Page 58: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Proving ndg-ness automatically

Representing sets of contexts

C matches D if

C [x ]σ = D

� in D below � in C

Overlapping contexts

C and D overlap if both match some E

Example

plus(�, y) matches plus(s(�), y)

Intuition: plus(�, y) represents “marked” terms

plus(times(x , z), y),plus(s(times(0, 0)), 0), . . .

Goal: compute sets of contexts Dup and DefDup and Def don’t overlap y rc = irc

Page 59: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Proving ndg-ness automatically

Representing sets of contexts

C matches D if

C [x ]σ = D

� in D below � in C

Overlapping contexts

C and D overlap if both match some E

Example

plus(�, y) matches plus(s(�), y)

Intuition: plus(�, y) represents “marked” termsplus(times(x , z), y),

plus(s(times(0, 0)), 0), . . .

Goal: compute sets of contexts Dup and DefDup and Def don’t overlap y rc = irc

Page 60: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Proving ndg-ness automatically

Representing sets of contexts

C matches D if

C [x ]σ = D

� in D below � in C

Overlapping contexts

C and D overlap if both match some E

Example

plus(�, y) matches plus(s(�), y)

Intuition: plus(�, y) represents “marked” termsplus(times(x , z), y),plus(s(times(0, 0)), 0), . . .

Goal: compute sets of contexts Dup and DefDup and Def don’t overlap y rc = irc

Page 61: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Proving ndg-ness automatically

Representing sets of contexts

C matches D if

C [x ]σ = D

� in D below � in C

Overlapping contexts

C and D overlap if both match some E

Example

plus(�, y) matches plus(s(�), y)

Intuition: plus(�, y) represents “marked” termsplus(times(x , z), y),plus(s(times(0, 0)), 0), . . .

Goal: compute sets of contexts Dup and Def

Dup and Def don’t overlap y rc = irc

Page 62: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Proving ndg-ness automatically

Representing sets of contexts

C matches D if

C [x ]σ = D

� in D below � in C

Overlapping contexts

C and D overlap if both match some E

Example

plus(�, y) matches plus(s(�), y)

Intuition: plus(�, y) represents “marked” termsplus(times(x , z), y),plus(s(times(0, 0)), 0), . . .

Goal: compute sets of contexts Dup and DefDup and Def don’t overlap y rc = irc

Page 63: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Proving ndg-ness automatically

Representing sets of contexts

C matches D if

C [x ]σ = D

� in D below � in C

Overlapping contexts

C and D overlap if both match some E

Example

plus(�, y) matches plus(s(�), y)

Intuition: plus(�, y) represents “marked” termsplus(times(x , z), y),plus(s(times(0, 0)), 0), . . .

Goal: compute sets of contexts Dup and DefDup and Def don’t overlap y rc = irc

Page 64: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The easy one: Computing Dup

Algorithm

collect left-hand sides of rules with non-linear right-hand sidesreplace occurrences of duplicated variables in left-hand sides with �

Example

Dup = {times(s(x),�)}

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Page 65: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The easy one: Computing Dup

Algorithm

collect left-hand sides of rules with non-linear right-hand sides

replace occurrences of duplicated variables in left-hand sides with �

Example

Dup = {times(s(x),�)}

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Page 66: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The easy one: Computing Dup

Algorithm

collect left-hand sides of rules with non-linear right-hand sides

replace occurrences of duplicated variables in left-hand sides with �

Example

Dup = {times(s(x),�)}

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Page 67: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The easy one: Computing Dup

Algorithm

collect left-hand sides of rules with non-linear right-hand sidesreplace occurrences of duplicated variables in left-hand sides with �

Example

Dup = {times(s(x),�)}

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Page 68: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The easy one: Computing Dup

Algorithm

collect left-hand sides of rules with non-linear right-hand sidesreplace occurrences of duplicated variables in left-hand sides with �

Example

Dup = {times(s(x),�)}

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Page 69: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The easy one: Computing Dup

Algorithm

collect left-hand sides of rules with non-linear right-hand sidesreplace occurrences of duplicated variables in left-hand sides with �

Example

Dup = {times(s(x),�)}

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Page 70: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The easy one: Computing Dup

Algorithm

collect left-hand sides of rules with non-linear right-hand sidesreplace occurrences of duplicated variables in left-hand sides with �

Example

Dup = {times(s(x),�)}

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

ReminderDup and Def don’t overlap

y no duplication of defined symbols

y rc = irc

y irc techniques applicable for rc

Page 71: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Initialization

collect right-hand sides with nested defined symbols

replace nested defined symbols with � y C

add bCc to Def

Example

Def = {}

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Page 72: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Initialization

collect right-hand sides with nested defined symbols

replace nested defined symbols with � y C

add bCc to Def

Example

Def = {}

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Page 73: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Initialization

collect right-hand sides with nested defined symbols

replace nested defined symbols with � y C

add bCc to Def

Example

Def = {}

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Page 74: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Initialization

collect right-hand sides with nested defined symbols

replace nested defined symbols with � y C

add bCc to Def

Example

Def = {}

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Page 75: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Initialization

collect right-hand sides with nested defined symbols

replace nested defined symbols with � y C

add bCc to Def

Example

Def = {}

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Page 76: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Initialization

collect right-hand sides with nested defined symbols

replace nested defined symbols with � y C

add bCc to Def

Example

Def = {

plus(�, y)

}

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Page 77: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Initialization

collect right-hand sides with nested defined symbols

replace nested defined symbols with � y C

add bCc to Def

Example

Def = {

plus(�, y)

}

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Page 78: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Initialization

collect right-hand sides with nested defined symbols

replace nested defined symbols with � y C

add bCc to Def

Example

Def = {bplus(�, y)c}

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Page 79: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Initialization

collect right-hand sides with nested defined symbols

replace nested defined symbols with � y C

add bCc to Def

Example

Def = {plus(�, y)}

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Page 80: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Idea: capture that nested defined symbols may be matched by variables

Fixed Point Step

pick a rule `→ r

replace some x in ` with �

if `[�] overlaps with D ∈ Def

pick a subterm f(...x ...) of r

add bf(...�...)c to Def

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Example

Def = {plus(�, y)}

`[�] = plus(s(�), y)

Dup = {times(s(x),�)} and Def = {plus(�, y)} don’t overlap y rc = irc!

Page 81: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Idea: capture that nested defined symbols may be matched by variables

Fixed Point Step

pick a rule `→ r

replace some x in ` with �

if `[�] overlaps with D ∈ Def

pick a subterm f(...x ...) of r

add bf(...�...)c to Def

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Example

Def = {plus(�, y)}

`[�] = plus(s(�), y)

Dup = {times(s(x),�)} and Def = {plus(�, y)} don’t overlap y rc = irc!

Page 82: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Idea: capture that nested defined symbols may be matched by variables

Fixed Point Step

pick a rule `→ r

replace some x in ` with �

if `[�] overlaps with D ∈ Def

pick a subterm f(...x ...) of r

add bf(...�...)c to Def

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Example

Def = {plus(�, y)}

`[�] = plus(s(�), y)

Dup = {times(s(x),�)} and Def = {plus(�, y)} don’t overlap y rc = irc!

Page 83: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Idea: capture that nested defined symbols may be matched by variables

Fixed Point Step

pick a rule `→ r

replace some x in ` with �

if `[�] overlaps with D ∈ Def

pick a subterm f(...x ...) of r

add bf(...�...)c to Def

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Example

Def = {plus(�, y)}

`[�] = plus(s(�), y)

Dup = {times(s(x),�)} and Def = {plus(�, y)} don’t overlap y rc = irc!

Page 84: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Idea: capture that nested defined symbols may be matched by variables

Fixed Point Step

pick a rule `→ r

replace some x in ` with �

if `[�] overlaps with D ∈ Def

pick a subterm f(...x ...) of r

add bf(...�...)c to Def

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Example

Def = {plus(�, y)}

`[�] = plus(s(�), y)

Dup = {times(s(x),�)} and Def = {plus(�, y)} don’t overlap y rc = irc!

Page 85: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Idea: capture that nested defined symbols may be matched by variables

Fixed Point Step

pick a rule `→ r

replace some x in ` with �

if `[�] overlaps with D ∈ Def

pick a subterm f(...x ...) of r

add bf(...�...)c to Def

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Example

Def = {plus(�, y)}`[�] = plus(s(�), y)

Dup = {times(s(x),�)} and Def = {plus(�, y)} don’t overlap y rc = irc!

Page 86: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Idea: capture that nested defined symbols may be matched by variables

Fixed Point Step

pick a rule `→ r

replace some x in ` with �

if `[�] overlaps with D ∈ Def

pick a subterm f(...x ...) of r

add bf(...�...)c to Def

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Example

Def = {plus(�, y)}`[�] = plus(s(�), y)

Dup = {times(s(x),�)} and Def = {plus(�, y)} don’t overlap y rc = irc!

Page 87: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Idea: capture that nested defined symbols may be matched by variables

Fixed Point Step

pick a rule `→ r

replace some x in ` with �

if `[�] overlaps with D ∈ Def

pick a subterm f(...x ...) of r

add bf(...�...)c to Def

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Example

Def = {plus(�, y)}`[�] = plus(s(�), y)

Dup = {times(s(x),�)} and Def = {plus(�, y)} don’t overlap y rc = irc!

Page 88: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Idea: capture that nested defined symbols may be matched by variables

Fixed Point Step

pick a rule `→ r

replace some x in ` with �

if `[�] overlaps with D ∈ Def

pick a subterm f(...x ...) of r

add bf(...�...)c to Def

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Example

Def = {plus(�, y)}`[�] = plus(s(�), y)

Dup = {times(s(x),�)} and Def = {plus(�, y)} don’t overlap y rc = irc!

Page 89: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Idea: capture that nested defined symbols may be matched by variables

Fixed Point Step

pick a rule `→ r

replace some x in ` with �

if `[�] overlaps with D ∈ Def

pick a subterm f(...x ...) of r

add bf(...�...)c to Def

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Example

Def = {plus(�, y)}`[�] = plus(s(�), y)

Dup = {times(s(x),�)} and Def = {plus(�, y)} don’t overlap y rc = irc!

Page 90: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Idea: capture that nested defined symbols may be matched by variables

Fixed Point Step

pick a rule `→ r

replace some x in ` with �

if `[�] overlaps with D ∈ Def

pick a subterm f(...x ...) of r

add bf(...�...)c to Def

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Example

Def = {plus(�, y), bplus(�, y)c}`[�] = plus(s(�), y)

Dup = {times(s(x),�)} and Def = {plus(�, y)} don’t overlap y rc = irc!

Page 91: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Idea: capture that nested defined symbols may be matched by variables

Fixed Point Step

pick a rule `→ r

replace some x in ` with �

if `[�] overlaps with D ∈ Def

pick a subterm f(...x ...) of r

add bf(...�...)c to Def

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Example

Def = {plus(�, y),plus(�, y)}`[�] = plus(s(�), y)

Dup = {times(s(x),�)} and Def = {plus(�, y)} don’t overlap y rc = irc!

Page 92: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Idea: capture that nested defined symbols may be matched by variables

Fixed Point Step

pick a rule `→ r

replace some x in ` with �

if `[�] overlaps with D ∈ Def

pick a subterm f(...x ...) of r

add bf(...�...)c to Def

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Example

Def = {plus(�, y)}`[�] = plus(s(�), y)

Dup = {times(s(x),�)} and Def = {plus(�, y)} don’t overlap y rc = irc!

Page 93: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

The hard one: Computing Def

Idea: capture that nested defined symbols may be matched by variables

Fixed Point Step

pick a rule `→ r

replace some x in ` with �

if `[�] overlaps with D ∈ Def

pick a subterm f(...x ...) of r

add bf(...�...)c to Def

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

Example

Def = {plus(�, y)}`[�] = plus(s(�), y)

Dup = {times(s(x),�)} and Def = {plus(�, y)} don’t overlap y rc = irc!

Page 94: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Outline

1 Preliminariesrc and ircNDG Rewriting

2 Handling Constructor Systems

3 Handling Non-Constructor Systems

4 Experimental Results, Conclusion

Page 95: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Handling Non-Constructor Systems

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

plus(x ,plus(y , z)) → plus(plus(x , y), z)

nested defined symbols only below plus’s first argument

y plus(x ,plus(y , z)) not reachable from basic terms!

information which defined symbols can be nested often crucial

y similar fixed point algorithm

Page 96: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Handling Non-Constructor Systems

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)plus(x ,plus(y , z)) → plus(plus(x , y), z)

nested defined symbols only below plus’s first argument

y plus(x ,plus(y , z)) not reachable from basic terms!

information which defined symbols can be nested often crucial

y similar fixed point algorithm

Page 97: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Handling Non-Constructor Systems

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)plus(x ,plus(y , z)) → plus(plus(x , y), z)

nested defined symbols only below plus’s first argument

y plus(x ,plus(y , z)) not reachable from basic terms!

information which defined symbols can be nested often crucial

y similar fixed point algorithm

Page 98: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Handling Non-Constructor Systems

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)plus(x ,plus(y , z)) → plus(plus(x , y), z)

nested defined symbols only below plus’s first argument

y plus(x ,plus(y , z)) not reachable from basic terms!

information which defined symbols can be nested often crucial

y similar fixed point algorithm

Page 99: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Handling Non-Constructor Systems

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

plus(x ,plus(y , z)) → plus(plus(x , y), z)

nested defined symbols only below plus’s first argument

y plus(x ,plus(y , z)) not reachable from basic terms!

information which defined symbols can be nested often crucial

y similar fixed point algorithm

Page 100: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Handling Non-Constructor Systems

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

plus(x ,plus(y , z)) → plus(plus(x , y), z)

nested defined symbols only below plus’s first argument

y plus(x ,plus(y , z)) not reachable from basic terms!

information which defined symbols can be nested often crucial

y similar fixed point algorithm

Page 101: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Handling Non-Constructor Systems

Leading Example Rtimes

plus(0, y) → yplus(s(x), y) → s(plus(x , y))times(0, y) → 0

times(s(x), y) → plus(times(x , y), y)

plus(x ,plus(y , z)) → plus(plus(x , y), z)

nested defined symbols only below plus’s first argument

y plus(x ,plus(y , z)) not reachable from basic terms!

information which defined symbols can be nested often crucial

y similar fixed point algorithm

Page 102: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Experimental Results, Conclusion

Experiments on the TPDB:

TcT AProVE TcT preproc AProVE & TcT

209 270 299 308

powerful sufficient criterion for rc = irc

easy to automate

y future irc techniques applicable for rc

significant improvement of the state of the art

Page 103: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Experimental Results, Conclusion

Experiments on the TPDB:

TcT AProVE TcT preproc AProVE & TcT

209 270 299 308

powerful sufficient criterion for rc = irc

easy to automate

y future irc techniques applicable for rc

significant improvement of the state of the art

Page 104: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Experimental Results, Conclusion

Experiments on the TPDB:

TcT AProVE TcT preproc AProVE & TcT

209 270 299 308

powerful sufficient criterion for rc = irc

easy to automate

y future irc techniques applicable for rc

significant improvement of the state of the art

Page 105: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Experimental Results, Conclusion

Experiments on the TPDB:

TcT AProVE TcT preproc AProVE & TcT

209 270 299 308

powerful sufficient criterion for rc = irc

easy to automate

y future irc techniques applicable for rc

significant improvement of the state of the art

Page 106: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Experimental Results, Conclusion

Experiments on the TPDB:

TcT AProVE TcT preproc AProVE & TcT AProVE++

209 270 299 308 324

powerful sufficient criterion for rc = irc

easy to automate

y future irc techniques applicable for rc

significant improvement of the state of the art

Page 107: Analyzing Runtime Complexity via Innermost …...NDG Rewriting is cheap! Theorem (Pol et. al, RTA ’05) NDG rewriting is at least as e cient as innermost rewriting. Reminder: rc rc

Experimental Results, Conclusion

Experiments on the TPDB:

TcT AProVE TcT preproc AProVE & TcT AProVE++

209 270 299 308 324

powerful sufficient criterion for rc = irc

easy to automate

y future irc techniques applicable for rc

significant improvement of the state of the art