The implicit complexity content of Quasi-interpretations G. Bonfante, J-Y Marion and J-Y Moyen Ecole des Mines - INPL - Loria Appsem – 04/04 – p.1/21
Motivations Control program resources: time, memory, stack size. Static analysis provides a “resource certificate” A resource certificate can be attached to a program (see PCC) A resource certificate can give hints to run a program satisfying some computational property. Resource controls at runtime slowdown a program and is problematic in case of attack Appsem – 04/04 – p.2/21
Proof theoretical analysis of computation and complexity Specification Proof of termination Program synthetesis Appsem – 04/04 – p.3/21
Proof theoretical analysis of computation and complexity Specification 1st order functional programs Proof of termination Program synthetesis Appsem – 04/04 – p.3/21
Proof theoretical analysis of computation and complexity Specification 1st order functional programs Proof of termination Complexity analysis Program synthetesis Appsem – 04/04 – p.3/21
Proof theoretical analysis of computation and complexity Specification 1st order functional programs Proof of termination Complexity analysis Program synthetesis with transformation and guaranted complexity Appsem – 04/04 – p.3/21
✔ ✟ ✑ ✔ ☎ ✏ ✏ ☎✏ ✄ ☞ ✌ ✡ ✠ ✠ ✔ ✝ ✆ ☛ ✑ ✔ ☎ ✘ ✘ ✘ ☎ ✍ ✄ ✙ ✆ ✡ ✠ ✠ ✗ ✝ ✖ ✓ ☎ ✏ ☞ � ✁ ✂ ✄ � ☎ ✁ ☎ ✂ ✟ ✠ ✠ ✡ ✏ ☛ ✌ ☞ ☎✏ ☎✏ ✏ ✏ ☎ ✄ ✄ ✆ 1st order fct prog Constructors : , functions : , variables : . ✆✞✝ ✟✎✍ ✟✒✑ ✟✎✍ ✟✒✑ (Terms) f (Patterns) ✔✕✍ (Rules) f Appsem – 04/04 – p.4/21
✆ ☎ ✠ ✠ ✗ ✝ ✖ ✆ ☛ ☞ ✑ ✂ ✔ ☎ ✏ ✏ ☎✏ � ✄ ✌ ✡ ✄ ✠ ✟ � ✙ ✆ � ☎ ✁ ✄ ☎ ✙ ✔ ✆ ✑ ✔ ☎ ✘ ✘ ✘ ☎ ✍ ✡ ✠ ✄ ☎ ✡ ✠ ✠ ✟ ✂ ✂ ☎ ✁ � ☞ ✄ ☎ � ✂ ✆ ✁ ✆ � ☛ ✌ ✔ ✄ ✝ ✓ ✆ ✙ ☎ ✏ ✏ ☎✏ ✄ ✄ ✁ ☞ ✆ ☎ ☎ ✏ ✏ ☎✏ ✄ ✄ 1st order fct prog Constructors : , functions : , variables : . ✆✞✝ ✟✎✍ ✟✒✑ ✟✎✍ ✟✒✑ (Terms) f (Patterns) ✔✕✍ (Rules) f Nil concat Cons Cons concat concat Appsem – 04/04 – p.4/21
� Termination Termination orderings : Polynomial interpretation (Lankford) Multiset path ordering (MPO) (Dershowitz) Lexicographic path ordering (LPO) Appsem – 04/04 – p.5/21
Appsem – 04/04 – p.6/21 ☛ ✖ ☛ ✟✠ ✝ ✆ ✓ ✟ ☎ ✏ ✕ ✟✠ ✁ ✟ ✍ ✌ � ✆ ✝ ☛ ☎ ✏ ✟ ✟ ☎✏ ✁ ✏ ☛ ✟✠ ✟ ✍ ✙ ✘ ✄ ☛ ☎ ✏ ☎✏ ✏ ✁ ☛ ✖ ✟✠ ✝ ✝ ✆ ✘ ☎ ✏ ☎✏ ✏ ☛ ✝ � ✁ ✍ ✌ ✏ ✡ ✆ ✏ ✎ ☛ ☎ ✏ ✏ ☎✏ ✁ ☎ ✡ ☎✏ ✏ ✆ ✟✠ ✟✠ ✡ ✓ ✟ ☎ ✏ ✕ ☛ � ☎ ✟ ✄ ✓ ☛ ✟✠ ✟ ✟✠ g f g MPO (1/2) ✄ ☞☛ ✑✒✝ ✆✔✝ ✆✞✝ ✆✔✝ ✆✞✝ ✟ ✗✄ ✄ ☞☛ . ✟ ☎✄ g ✆✞✝ is an ordering on ✟ ✂✁
� ☎ ✁ ✡ ✡ ✞ ✂ ✟✠ ✎ ✏ ✄ ✝ ✘ ✟ ✓ ✑ ✟✠ ☎ ✞ ✓ ✟ ✕ ✠ ✡ ✄ ☎ ✝ ✖ ✟ ☎✏ ✏ ✏ ☎ ✟ ✄ ✘ ✆ ✝ ☛ ✟✠ � ✡ ✖ ☛ ✁ ☎✏ ✏ ✏ ☎ ✄ MPO (2/2) ✟ ✂✁ iff and there is a permutation s.t. s.t. ✆✔✝ ☛ ✝✆ ✟ ☛✡ ☛ ✝✆ Appsem – 04/04 – p.7/21
✄ ✟✠ ✂ ✂ ✂ ✎ ✏ ✡ ☎ ✙ ✟ ✓ � ✟ ✡ ✞ ✓ ✟ ✕ ✠ ✄ ☎ ☎ ✡ ✑ ✝ � ✁ ✞ ✝ ✖ � ☎✏ ✏ ✏ ☎ ✟ ✄ ✘ ✆ ✝ ✟✠ ✟✠ � ✡ ✖ ☛ ✁ ☎✏ ✏ ✏ ☎ ☛ ✄ ✘ ✟✠ MPO (2/2) ✟ ✂✁ iff and there is a permutation s.t. s.t. ✆✔✝ ☛ ✝✆ ✟ ☛✡ ☛ ✝✆ A program terminates by MPO if for each rule , we have . ✆✔✝ Appsem – 04/04 – p.7/21
Extensional characterization of MPO A MPO function is a function computed by a program which terminates by MPO. The set of MPO functions is exactly the set of primitive recursive functions. (Cichon (90), Hofbauer (92)) Appsem – 04/04 – p.8/21
✆ ☛ � ✆ ✄ ☛ ☎ ☎ ✆ ☎ ☎ ✏ ☎ ✄ Intentionnality The “good” algorithms which computes in ✁✄✂ steps is not definable by primitive recursive schema (Colson (89)) . However, it terminates by MPO. Appsem – 04/04 – p.9/21
☎ ☛ � ✆ ✄ ☛ ☎ ☎ ✆ ☎ ✆ ✏ ☎ ✄ Intentionnality The “good” algorithms which computes in ✁✄✂ steps is not definable by primitive recursive schema (Colson (89)) . However, it terminates by MPO. On the other hand, quicksort does not terminate by MPO but the sort function is a PR function. The goal is to capture “good” programs within a resource bound. Appsem – 04/04 – p.9/21
✓ ✏ ✁ ✂ � ✄ ✁ ✂ ✙ ✂ ✆ ✂ ☎ ✟ ✆ ✄ ☎ ☎ ✄ ☎✏ ✏ ✄ ✏ ✏ ☎✏ ✄ ✁ ✟ ✂ ✄ ✏ ✁ ✂ ✡ ✄ ✆ ✄ ☎ ✏ ✏ ☎✏ ✂ ✁ ✂ ✄ ✄ ✁ ✂ ✄ ✄ ✂ ✄ ✂ ✁ � ✄ ✁ ✁ ✁ � ✌ ✄ ✁ ☎ ☎ ✄ ✄ ✁ ✂ ✂ ✓ ✡ ☎ ✆ ✄ ☎ ☎ ✏ ✏ ☎✏ ✁ ☎ Quasi-interpretations (Marion et Moyen, Bonfante, ) A quasi-interprétation of is a function satisfying: is bounded by a polynomial. ✆✞✝ for all . is increasing (not-strictly). ✟ ✂✁ ✟ ☎✄ ✟ ☎✄ Program with quasi-interpretation if for each rule , we have . Appsem – 04/04 – p.10/21
✁ � ✁ � ✁ � ✁ ✁ Characterization of P TIME The set of functions which are computed by a program 1. which terminates by MPO 2. which admits a quasi-interpretation is exactly the set P TIME of functions computable in polynomial time. (Marion et Moyen, ) I CAR system implements this resource analysis method. (Moyen, ) Appsem – 04/04 – p.11/21
� ✁ � ✁ ✁ � ✁ � Characterization of P SPACE The set of functions which are computed by a program 1. which terminates by LPO 2. which admits a quasi-interpretation is exactly the set P SPACE of functions computable in polynomial space. (Bonfante, Marion et Moyen, ) A upper bound on memory can be produced from termina- tion proof (Amadio et al. ). Appsem – 04/04 – p.12/21
Length of the longest common subsequence Appsem – 04/04 – p.13/21
Length of the longest common subsequence A B B A B A Appsem – 04/04 – p.13/21
Length of the longest common subsequence A B B A B A B A B A Appsem – 04/04 – p.13/21
Length of the longest common subsequence A B B A B A B A B A Appsem – 04/04 – p.13/21
Length of the longest common subsequence A B B A B A B A B A Appsem – 04/04 – p.13/21
✁ � ✁ ✆ ✂ ✁ � ✟ ✆ ✆ ✝ � � ✂ ✂ ✟ ✝ ☛ ✆ � ✆ � ✁ ✆ ✂ � � � ✆ ✆ ✆ ✟ ✂ ✆ ✁ � � ✂ ✆ � ☎ � ✆ ✝ ✞ ✟ � ☎ ✂ ✟ ✆ ✝ ✞ ✟ Length of the longest common subsequence A B B A B A B A B A lcs ✁✄✂ lcs i i ✆✡✠ lcs lcs i j j i lcs max lcs lcs Appsem – 04/04 – p.13/21
� � ✂ ✟ ✆ ☛ ✟ � ✂ ✆ ✁ ✆ ✂ ✁ ✟ � ✆ ✆ ✝ � � � � ✁ ✂ ✂ � ✟ ✁ ✆ ✆ ✝ � ✆ ☎ ✆ ✝ ✞ ✄ � ☎ ✂ ✟ ✆ ✞ ✝ � � ✄ � ✁ ✆ ✂ � � ✟ ✆ ✆ ✆ Explicit vs Implicit lcs ✁✄✂ lcs i i ✆✡✠ lcs lcs i j j i lcs max lcs lcs Explicit complexity : runtime is Appsem – 04/04 – p.14/21
� � ✂ ✟ ✆ ☛ ✟ � ✂ ✆ ✁ ✆ ✂ ✁ ✟ � ✆ ✆ ✝ � � � � ✁ ✂ ✂ � ✟ ✁ ✆ ✆ ✝ � ✆ ☎ ✆ ✝ ✞ ✄ � ☎ ✂ ✟ ✆ ✞ ✝ � � ✄ � ✁ ✆ ✂ � � ✟ ✆ ✆ ✆ Explicit vs Implicit lcs ✁✄✂ lcs i i ✆✡✠ lcs lcs i j j i lcs max lcs lcs Explicit complexity : runtime is Appsem – 04/04 – p.14/21
� ✝ ☛ ✄ � � � ✁ ✆ ✂ ✄ � ✟ ✆ ✆ ✆ ✟ � ✆ � ✁ ✂ ✟ � ✟ ✆ ✆ ✂ ✂ � ✆ ✆ ✂ ✁ ✞ � ✁ ☎ ✆ ✝ ✞ � � ☎ ✂ ✟ ✆ ✝ � ✁ � ✡ � ✁ ✆ ✂ ✄ � ✟ ✆ ✆ ✝ ✂ � � Explicit vs Implicit lcs ✁✄✂ lcs i i ✆✡✠ lcs lcs i j j i lcs max lcs lcs Explicit complexity : runtime is lcs terminates by MPO and admits a QI : . lcs Implicit complexity is polynomial. Appsem – 04/04 – p.14/21
Memoisation Appsem – 04/04 – p.15/21
� ✁✂ ✄ ☎ ✞ ✞ ✟ Memoisation ☎✝✆ Appsem – 04/04 – p.15/21
☎ ✄ ✄ ✁✂ � ✟ ✞ ✞ � ✁✂ ✞ � ✟ ✞ ✞ ✟ ✄ ✂ ✁ ☎ Memoisation ☎✝✆ ☎✝✆ ☎✝✆ Appsem – 04/04 – p.15/21
Recommend
More recommend