The implicit complexity content of Quasi-interpretations G. - - PowerPoint PPT Presentation

the implicit complexity content of quasi interpretations
SMART_READER_LITE
LIVE PREVIEW

The implicit complexity content of Quasi-interpretations G. - - PowerPoint PPT Presentation

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


slide-1
SLIDE 1

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

slide-2
SLIDE 2

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

slide-3
SLIDE 3

Proof theoretical analysis of computation and complexity

Specification Proof of termination Program synthetesis

Appsem – 04/04 – p.3/21

slide-4
SLIDE 4

Proof theoretical analysis of computation and complexity

Specification 1st order functional programs Proof of termination Program synthetesis

Appsem – 04/04 – p.3/21

slide-5
SLIDE 5

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

slide-6
SLIDE 6

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

slide-7
SLIDE 7

1st order fct prog

Constructors :

  • , functions :

, variables :

.

(Terms)

✁ ☎ ✂ ✆✞✝ ✟ ✠ ✠ ✡ ☛ ☞ ✌ ✄ ✟✎✍ ☎✏ ✏ ✏ ☎ ✟✒✑ ✆ ☞

f

✄ ✟✎✍ ☎✏ ✏ ✏ ☎ ✟✒✑

(Patterns)

✓ ✝ ✔ ✠ ✠ ✡ ✌ ✄ ✔✕✍ ☎✏ ✏ ✏ ☎ ✔ ✑ ✆ ☞ ☛

(Rules)

✖ ✝ ✗ ✠ ✠ ✡

f

✄ ✔ ✍ ☎ ✘ ✘ ✘ ☎ ✔ ✑ ✆ ✙ ✟

Appsem – 04/04 – p.4/21

slide-8
SLIDE 8

1st order fct prog

Constructors :

  • , functions :

, variables :

.

(Terms)

✁ ☎ ✂ ✆✞✝ ✟ ✠ ✠ ✡ ☛ ☞ ✌ ✄ ✟✎✍ ☎✏ ✏ ✏ ☎ ✟✒✑ ✆ ☞

f

✄ ✟✎✍ ☎✏ ✏ ✏ ☎ ✟✒✑

(Patterns)

✓ ✝ ✔ ✠ ✠ ✡ ✌ ✄ ✔✕✍ ☎✏ ✏ ✏ ☎ ✔ ✑ ✆ ☞ ☛

(Rules)

✖ ✝ ✗ ✠ ✠ ✡

f

✄ ✔ ✍ ☎ ✘ ✘ ✘ ☎ ✔ ✑ ✆ ✙ ✟

concat

Nil

  • concat

Cons

✄ ✁ ☎ ✂ ✆ ☎

Cons

✄ ✁ ☎

concat

✄ ✂ ☎

Appsem – 04/04 – p.4/21

slide-9
SLIDE 9

Termination

Termination orderings : Polynomial interpretation (Lankford)

  • Multiset path ordering (MPO) (Dershowitz)

Lexicographic path ordering (LPO)

Appsem – 04/04 – p.5/21

slide-10
SLIDE 10

MPO (1/2)

✟ ✡
✟✂✁ ☎✏ ✏ ✏ ☎ ✟☎✄ ✆ ✆✞✝ ✟✠ ✡ ✄☞☛ ✁ ☎✏ ✏ ✏ ☎ ☛ ✝ ✆ ✡ ☛ ✌ ✍

is an ordering on

  • .
✎ ✏ ☎ ✟ ✑✒✝ ✟✠ ☛ ✓ ✟ ✆✔✝ ✟✠ ☛ ✕ ✏ ☎ ✟ ✓ ✆✞✝ ✟✠

g

✄☞☛ ✁ ☎✏ ✏ ✏ ☎ ☛ ✝ ✆

g

✟ ✆✞✝ ✟✠ ☛ ✕ ✏ ☎ ✟ ✓ ✆ ✝ ✟✠ ☛ ✖ ✟ ✁ ☎✏ ✏ ✏ ☎ ✟✗✄ ✘ ✆ ✝ ✝ ✟✠ ✖ ☛ ✁ ☎✏ ✏ ✏ ☎ ☛ ✄ ✘

f

✙ ✍

g

✟ ✆✔✝ ✟✠ ☛

Appsem – 04/04 – p.6/21

slide-11
SLIDE 11

MPO (2/2)

✡ ✖ ✟✂✁ ☎✏ ✏ ✏ ☎ ✟ ✄ ✘ ✆ ✝ ✝ ✟✠
✖ ☛ ✁ ☎✏ ✏ ✏ ☎ ☛ ✄ ✘

iff

✁ ✡
  • and there is a permutation

s.t.

✎ ✏ ✄ ☎

s.t.

✟ ✓ ✆✔✝ ✟✠ ☛✝✆ ✞ ✓ ✟ ✕ ✠ ✄ ☎ ☎ ✟☛✡ ✑ ✝ ✟✠ ☛✝✆ ✞ ✡ ✟

Appsem – 04/04 – p.7/21

slide-12
SLIDE 12

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

slide-13
SLIDE 13

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

slide-14
SLIDE 14

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

slide-15
SLIDE 15

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

slide-16
SLIDE 16

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

slide-17
SLIDE 17

Characterization of PTIME

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 PTIME of functions computable in polynomial time. (Marion et Moyen,

✁ ✁

) ICAR system implements this resource analysis method. (Moyen,

)

Appsem – 04/04 – p.11/21

slide-18
SLIDE 18

Characterization of PSPACE

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 PSPACE 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

slide-19
SLIDE 19

Length of the longest common subsequence

Appsem – 04/04 – p.13/21

slide-20
SLIDE 20

Length of the longest common subsequence

A B B A B A

Appsem – 04/04 – p.13/21

slide-21
SLIDE 21

Length of the longest common subsequence

A B B A B A B A B A

Appsem – 04/04 – p.13/21

slide-22
SLIDE 22

Length of the longest common subsequence

A B B A B A B A B A

Appsem – 04/04 – p.13/21

slide-23
SLIDE 23

Length of the longest common subsequence

A B B A B A B A B A

Appsem – 04/04 – p.13/21

slide-24
SLIDE 24

Length of the longest common subsequence

A B B A B A B A B A

lcs

  • ✁✄✂
☎ ✆ ✝ ✞

lcs

✂ ✟ ✆ ✝ ✞

lcs

  • i
✆ ✂

i

✆ ✆ ✝

lcs

✂ ✟ ✆✡✠ ☛

lcs

  • i
✆ ✂

j

✆ ✆ ✝

max

  • lcs

j

✆ ✆ ✂

lcs

  • i
✆ ✂ ✟ ✆ ✆

Appsem – 04/04 – p.13/21

slide-25
SLIDE 25

Explicit vs Implicit

lcs

  • ✁✄✂
☎ ✆ ✝ ✞

lcs

✂ ✟ ✆ ✝ ✞

lcs

  • i
✆ ✂

i

✆ ✆ ✝

lcs

✂ ✟ ✆✡✠ ☛

lcs

  • i
✆ ✂

j

✆ ✆ ✝

max

  • lcs

j

✆ ✆ ✂

lcs

  • i
✆ ✂ ✟ ✆ ✆

Explicit complexity : runtime is

Appsem – 04/04 – p.14/21

slide-26
SLIDE 26

Explicit vs Implicit

lcs

  • ✁✄✂
☎ ✆ ✝ ✞

lcs

✂ ✟ ✆ ✝ ✞

lcs

  • i
✆ ✂

i

✆ ✆ ✝

lcs

✂ ✟ ✆✡✠ ☛

lcs

  • i
✆ ✂

j

✆ ✆ ✝

max

  • lcs

j

✆ ✆ ✂

lcs

  • i
✆ ✂ ✟ ✆ ✆

Explicit complexity : runtime is

Appsem – 04/04 – p.14/21

slide-27
SLIDE 27

Explicit vs Implicit

lcs

  • ✁✄✂
☎ ✆ ✝ ✞

lcs

✂ ✟ ✆ ✝ ✞

lcs

  • i
✆ ✂

i

✆ ✆ ✝

lcs

✂ ✟ ✆✡✠ ☛

lcs

  • i
✆ ✂

j

✆ ✆ ✝

max

  • lcs

j

✆ ✆ ✂

lcs

  • i
✆ ✂ ✟ ✆ ✆

Explicit complexity : runtime is

lcs terminates by MPO and admits a QI :

lcs

✄ ✡

. Implicit complexity is polynomial.

Appsem – 04/04 – p.14/21

slide-28
SLIDE 28

Memoisation

Appsem – 04/04 – p.15/21

slide-29
SLIDE 29

Memoisation

  • ✁✂
✄ ☎ ☎✝✆ ✞ ✞ ✟

Appsem – 04/04 – p.15/21

slide-30
SLIDE 30

Memoisation

✂ ✄ ☎✝✆ ✞ ✞ ✟
  • ✁✂
✄ ☎ ☎✝✆ ✞ ✟
  • ✁✂
✄ ☎ ☎✝✆ ✞ ✞ ✟

Appsem – 04/04 – p.15/21

slide-31
SLIDE 31

Memoisation

  • ✁✂
✄✁ ✆ ✞ ✞ ✟
  • ✁✂
✄ ☎✝✆ ✞ ✟
✂ ✄ ☎✝✆ ✞ ✞ ✟
  • ✁✂
✄ ☎ ☎✝✆ ✞ ✟
  • ✁✂
✄ ☎ ☎✝✆ ✞ ✞ ✟

Appsem – 04/04 – p.15/21

slide-32
SLIDE 32

Memoisation

  • ✁✂
✄✁ ✆ ✞ ✞ ✟
  • ✁✂
✄ ☎✝✆ ✞ ✟
  • ✁✂
✄ ☎✝✆ ✞ ✟
✂ ✄ ☎ ☎ ✆
✂ ✄ ☎✝✆ ✞ ✞ ✟
  • ✁✂
✄ ☎ ☎✝✆ ✞ ✟
  • ✁✂
✄ ☎ ☎✝✆ ✞ ✞ ✟

Appsem – 04/04 – p.15/21

slide-33
SLIDE 33

Memoisation

  • ✁✂
✄✁ ✆ ✞ ✟
  • ✁✂
✄ ☎✝✆
  • ✁✂
✄✁ ✆ ✞ ✟
  • ✁✂
✄ ☎✝✆
  • ✁✂
✄✁ ✆ ✞ ✞ ✟
  • ✁✂
✄ ☎✝✆ ✞ ✟
  • ✁✂
✄ ☎✝✆ ✞ ✟
✂ ✄ ☎ ☎ ✆
✂ ✄ ☎✝✆ ✞ ✞ ✟
  • ✁✂
✄ ☎ ☎✝✆ ✞ ✟
  • ✁✂
✄ ☎ ☎✝✆ ✞ ✞ ✟

Appsem – 04/04 – p.15/21

slide-34
SLIDE 34

Memoisation

  • ✁✂
✄✁ ✆ ✞ ✟
  • ✁✂
✄ ☎✝✆
  • ✁✂
✄✁ ✆ ✞ ✞ ✟
  • ✁✂
✄ ☎✝✆ ✞ ✟
  • ✁✂
✄ ☎✝✆ ✞ ✟
✂ ✄ ☎ ☎ ✆
✂ ✄ ☎✝✆ ✞ ✞ ✟
  • ✁✂
✄ ☎ ☎✝✆ ✞ ✟
  • ✁✂
✄ ☎ ☎✝✆ ✞ ✞ ✟

Appsem – 04/04 – p.15/21

slide-35
SLIDE 35

Memoisation

  • ✁✂
✄✁ ✆ ✞ ✟
  • ✁✂
✄ ☎✝✆
  • ✁✂
✄✁ ✆ ✞ ✞ ✟
  • ✁✂
✄ ☎✝✆ ✞ ✟
  • ✁✂
✄ ☎✝✆ ✞ ✟
✂ ✄ ☎ ☎ ✆
✂ ✄ ☎✝✆ ✞ ✞ ✟
  • ✁✂
✄ ☎ ☎✝✆ ✞ ✟
  • ✁✂
✄ ☎ ☎✝✆ ✞ ✞ ✟

k-2PDA Cook, Jones (00)

Appsem – 04/04 – p.15/21

slide-36
SLIDE 36

Memoisation

  • ✁✂
✄✁ ✆ ✞ ✟
  • ✁✂
✄ ☎✝✆
  • ✁✂
✄✁ ✆ ✞ ✞ ✟
  • ✁✂
✄ ☎✝✆ ✞ ✟
  • ✁✂
✄ ☎✝✆ ✞ ✟
✂ ✄ ☎ ☎ ✆
✂ ✄ ☎✝✆ ✞ ✞ ✟
  • ✁✂
✄ ☎ ☎✝✆ ✞ ✟
  • ✁✂
✄ ☎ ☎✝✆ ✞ ✞ ✟

k-2PDA Cook, Jones (00) Cache is mintained minimal because of MPO (Marion,

✁ ✁

).

Appsem – 04/04 – p.15/21

slide-37
SLIDE 37

CBV with cache

✁ ✂ ☎
☎ ✆ ☎ ☛ ✝ ✙ ☎ ✆ ☎ ✁ ✝ ✌ ✞
☎ ✆✠✟☛✡ ✍ ☎ ✟ ✟ ✝ ✙ ☎ ✆✠✟ ☎ ✁ ✟ ✝ ✂ ☎
☎ ✆✠☞ ☎ ✌ ✄ ✌ ✟ ✆ ✝ ✙ ☎ ✆ ✑ ☎ ✌ ✄ ✌ ✁ ✆ ✝

f

✞ ✁ ✂ ☎
☎ ✆✍✟☛✡ ✍ ☎ ✟ ✟ ✝ ✙ ☎ ✆✍✟ ☎ ✁ ✟ ✝ ✄

f

✄ ✌ ✁ ✆ ☎ ✁ ✆ ✞ ✆ ✑ ✂ ☎
☎ ✆✠☞ ☎

f

✄ ✌ ✟ ✆ ✝ ✙ ☎ ✆ ✑ ☎ ✁ ✝

f

✞ ✁ ✂ ☎
☎ ✆✠✟☛✡ ✍ ☎ ✟ ✟ ✝ ✙ ☎ ✆✠✟ ☎ ✁ ✟ ✝

f

✄ ✌ ✔ ✆ ✙ ✂ ✞ ✂ ✔ ✟
✡ ✁ ✟ ✂ ☎
✄ ☎ ✆ ✑ ☎ ✂ ✝ ✙ ☎ ✆ ☎ ✁ ✝ ✂ ☎
☎ ✆✠☞ ☎

f

✄ ✌ ✟ ✆ ✝ ✙ ☎ ✆ ✄

f

✄ ✌ ✁ ✆ ☎ ✁ ✆ ☎ ✁ ✝

Appsem – 04/04 – p.16/21

slide-38
SLIDE 38

Finding QI

Finding quasi-interpretations is undecidable. NP-hard when considering max-plus quasi-interpretations (Amadio 2003) Open : Finding heuristics to synthesis QI

Appsem – 04/04 – p.17/21

slide-39
SLIDE 39

In-place computation

A function

  • computes in place if

f

✄ ☛ ✆ ☞ ✄ ☞ ☛ ☞ ✆✞✝

. Compilation without malloc (M. Hofmann,

  • ).

A program which admits a linear quasi-interpretation

☎ ✆ ✆

computes in place.

Appsem – 04/04 – p.18/21

slide-40
SLIDE 40

Conclusions

Appsem – 04/04 – p.19/21

slide-41
SLIDE 41

Fight : Functions vs Algorithms

About functions Calculability Logical characterization of complexity classes Extensional characterization of complexity classes About Algorithms Studying algorithms : Colson, Gurevich, Moschovakis Implicit computational complexity classes Intentional characterization of complexity classes including “good” algorithms (Amadio & al, Jones, Hofmann, Bonfante, Marion and Moyen)

Appsem – 04/04 – p.20/21

slide-42
SLIDE 42

On-going research

Source 1st order functional programs Compilation Resource analysis Prf of termination & Quasi-int. Virtual Machine Byte code + Resource Certificate

Appsem – 04/04 – p.21/21