Higher-order Interpretations for Higher-order Complexity Emmanuel - - PowerPoint PPT Presentation

higher order interpretations for higher order complexity
SMART_READER_LITE
LIVE PREVIEW

Higher-order Interpretations for Higher-order Complexity Emmanuel - - PowerPoint PPT Presentation

Higher-order Interpretations for Higher-order Complexity Emmanuel Hainry & Romain Pchoux DICE-FOPARA, 22-23 april 2017 CNRS, INRIA, Universit de Lorraine & LORIA, Nancy, France 1 Introduction First-order computability and


slide-1
SLIDE 1

Higher-order Interpretations for Higher-order Complexity

Emmanuel Hainry & Romain Péchoux DICE-FOPARA, 22-23 april 2017

CNRS, INRIA, Université de Lorraine & LORIA, Nancy, France 1

slide-2
SLIDE 2

Introduction

slide-3
SLIDE 3

First-order computability and complexity

  • First-order computability is well understood:
  • Agreed upon definitions
  • Hierarchies layering the Turing degree of problems
  • Church-Turing’s thesis
  • First-order computational Complexity is well understood:
  • Agreed upon definitions
  • Classes and hierarchies layering the difficulty of problems
  • Various characterizations:
  • machine based characterizations
  • machine independent characterizations

→ Implicit Computational Complexity

2

slide-4
SLIDE 4

Higher-order computability and complexity

  • Higher-order computability is (well) understood:
  • Order 2 = computations over reals.
  • No Church-Turing’s thesis!
  • General Purpose Analog Computer by Shannon,
  • Blum-Shub-Smale model,
  • Computable Analysis (CA) by Weihrauch,
  • Oracle TM,
  • ...

3

slide-5
SLIDE 5

Higher-order computability and complexity

  • Higher-order computability is (well) understood:
  • Order 2 = computations over reals.
  • No Church-Turing’s thesis!
  • General Purpose Analog Computer by Shannon,
  • Blum-Shub-Smale model,
  • Computable Analysis (CA) by Weihrauch,
  • Oracle TM,
  • ...
  • Higher-order complexity is not well understood.
  • Polytime complexity on OTM = Basic Feasible

Functions (BFF) by Constable, Melhorn

  • Polytime complexity in CA = P(R) by Ko
  • No homogeneous theory for higher-order:

P(R) = BFF

3

slide-6
SLIDE 6

Objectives of this talk:

  • not developping a new complexity theory for higher-order,
  • adapting first-order tools for program complexity analysis,
  • validating the theory by capturing existing higher-order

complexity classes

4

slide-7
SLIDE 7

Objectives of this talk:

  • not developping a new complexity theory for higher-order,
  • adapting first-order tools for program complexity analysis,
  • validating the theory by capturing existing higher-order

complexity classes Framework:

  • tool = (polynomial) interpretations
  • target = BFFi, the Basic Feasible Functionals at any order.

4

slide-8
SLIDE 8

First-order interpretations

slide-9
SLIDE 9

First-order interpretations of TRS

  • Defined in the 70s for showing TRS termination:
  • ∀b of arity n, b : Nn →↑ N
  • ∀l → r ∈ R, l > r
  • Quasi-interpretation (QI) for complexity analysis:
  • ∀b of arity n, b : Nn →ր N
  • ∀l → r ∈ R, l ≥ r

Theorem (Bonfante et al. 2011) Let QIpoly

add be the set of functions computed by TRS admitting an

additive and polynomial QI.

  • QIpoly

add ∩ RPO ≡ FSPACE

  • QIpoly

add ∩ RPOprod ≡ FPTIME 5

slide-10
SLIDE 10

First-order interpretations of TRS

Example double(ǫ) → ǫ double(s(x)) → s(s(double(x))

6

slide-11
SLIDE 11

First-order interpretations of TRS

Example double(ǫ) → ǫ double(s(x)) → s(s(double(x)) ǫ = 0, s(X) = X + 1, double(X) = 3X + 1

6

slide-12
SLIDE 12

First-order interpretations of TRS

Example double(ǫ) → ǫ double(s(x)) → s(s(double(x)) ǫ = 0, s(X) = X + 1, double(X) = 3X + 1 double 0 = 1 > 0 = ǫ double s(x) = 3X + 4 > 3X + 3 = s(s(double(x))

6

slide-13
SLIDE 13

First-order interpretations of TRS

Example double(ǫ) → ǫ double(s(x)) → s(s(double(x)) ǫ = 0, s(X) = X + 1, double(X) = 3X + 1 double 0 = 1 > 0 = ǫ double s(x) = 3X + 4 > 3X + 3 = s(s(double(x)) Termination by RPOprod ⇒ [ [double] ] : x → 2x ∈ FPTIME

6

slide-14
SLIDE 14

Higher-order interpretations of TRS: State of the art

  • Termination:
  • Van De Pol (1993) adapted interpretations for showing

termination of higher-order TRS.

7

slide-15
SLIDE 15

Higher-order interpretations of TRS: State of the art

  • Termination:
  • Van De Pol (1993) adapted interpretations for showing

termination of higher-order TRS.

  • Complexity:
  • Férée et al. (2010) adapted interpretations to first-order

stream programs for characterizing BFF (BFF2) and P(R).

7

slide-16
SLIDE 16

Higher-order interpretations of TRS: State of the art

  • Termination:
  • Van De Pol (1993) adapted interpretations for showing

termination of higher-order TRS.

  • Complexity:
  • Férée et al. (2010) adapted interpretations to first-order

stream programs for characterizing BFF (BFF2) and P(R).

  • Baillot & Dal Lago (2016) adapted interpretations to

higher-order Simply Typed TRS for characterizing FPtime.

→ a first step towards a better expressivity

7

slide-17
SLIDE 17

Higher-order language

slide-18
SLIDE 18

Higher Order Programming Language

Definition (Functional Language) M := x | c |

  • p

| M1 M2 | λx.M | case M of c1 → M1|c2 → M2|...|cn → Mn | letRec f = M + Inductive Typing

8

slide-19
SLIDE 19

Example

Example letRec map = λg.λx.case x of c y z → c (g y) (map g z) | nil → nil List(A) :: = nil | c A List(A) map: (A → B) → List(A) → List(B)

9

slide-20
SLIDE 20

Semantics

Four kinds of reductions:

  • β reduction:

λx.M N − →β M{N/x}

  • case reduction:

case cpjNj

  • f c1 → M1|...|cn → Mn −

→case Mj Nj

  • letRec reduction:

letRec f = M − →letRec M{letRec f = M/f }

  • Operator reduction (total functions over terms):
  • pM →op [

[op] ](M) +Left-most outermost reduction strategy

10

slide-21
SLIDE 21

Higher-order interpretations

slide-22
SLIDE 22

Interpretations of types

Definition

  • b = ¯

N = N ∪ {⊤}

  • T → T ′ = T →↑ T ′

Definition

  • f : A →↑ B a strictly monotonic function from A to B:

∀x, y ∈ A, x <A y = ⇒ f (x) <B f (y).

  • x <¯

N y iff x < y or y = ⊤

  • f <A→↑B g iff ∀x ∈ A, f (x) <B g(x)

Example (map: (A → B) → List(A) → List(B)) map is in (¯ N →↑ ¯ N) →↑ ¯ N →↑ ¯ N.

11

slide-23
SLIDE 23

Lattices

⊥¯

N = 0

⊤¯

N = ⊤

⊥T→T ′ = ΛX T.⊥T ′ ⊤T→T ′ = ΛX T.⊤T ′ ⊔T→T ′(F, G) = ΛX T. ⊔T ′ (F(X), G(X)) ⊓T→T ′(F, G) = ΛX T. ⊓T ′ (F(X), G(X)) Lemma For any type T, (T, ≤, ⊔, ⊓, ⊤, ⊥) is a complete lattice.

12

slide-24
SLIDE 24

Interpretations of terms

n⊕¯

N = ΛX.(n + X)

n⊕T→T ′ : ΛF.ΛX.(n ⊕T ′ F(X)) Definition (Interpretations) x = X c = 1 ⊕ (ΛX1. . . . .ΛXn. n

i=1 Xi)

M N = MN

13

slide-25
SLIDE 25

Interpretations of terms

n⊕¯

N = ΛX.(n + X)

n⊕T→T ′ : ΛF.ΛX.(n ⊕T ′ F(X)) Definition (Interpretations) x = X c = 1 ⊕ (ΛX1. . . . .ΛXn. n

i=1 Xi)

M N = MN λx.M = 1 ⊕ (Λx.M)

13

slide-26
SLIDE 26

Interpretations of terms

n⊕¯

N = ΛX.(n + X)

n⊕T→T ′ : ΛF.ΛX.(n ⊕T ′ F(X)) Definition (Interpretations) x = X c = 1 ⊕ (ΛX1. . . . .ΛXn. n

i=1 Xi)

M N = MN λx.M = 1 ⊕ (Λx.M) case M of . . . ci → Mi . . . = 1 ⊕ ⊔i{MiRi | ciRi ≤ M}

13

slide-27
SLIDE 27

Interpretations of terms

n⊕¯

N = ΛX.(n + X)

n⊕T→T ′ : ΛF.ΛX.(n ⊕T ′ F(X)) Definition (Interpretations) x = X c = 1 ⊕ (ΛX1. . . . .ΛXn. n

i=1 Xi)

M N = MN λx.M = 1 ⊕ (Λx.M) case M of . . . ci → Mi . . . = 1 ⊕ ⊔i{MiRi | ciRi ≤ M} letRec f = M = ⊓{F | F ≥ 1⊕(Λf .M)F}

13

slide-28
SLIDE 28

Interpretations of terms

n⊕¯

N = ΛX.(n + X)

n⊕T→T ′ : ΛF.ΛX.(n ⊕T ′ F(X)) Definition (Interpretations) x = X c = 1 ⊕ (ΛX1. . . . .ΛXn. n

i=1 Xi)

M N = MN λx.M = 1 ⊕ (Λx.M) case M of . . . ci → Mi . . . = 1 ⊕ ⊔i{MiRi | ciRi ≤ M} letRec f = M = ⊓{F | F ≥ 1⊕(Λf .M)F}

  • p M ≥ op(M)

13

slide-29
SLIDE 29

Properties of interpretations

Theorem Any term M has an interpretation. Knaster-Tarski: lfp(ΛX.1 ⊕ ((Λf .M)X)) → monotonic function over a complete lattice Lemma If M − → N, then M ≥ N. If M − →α N, α = op, then M > N. Lemma If M :: B and M = ⊤ then M terminates in time O(M).

14

slide-30
SLIDE 30

Example of Interpretation

letRec map = λg.λx.case x of c y z → c (g y) (map g z)

15

slide-31
SLIDE 31

Example of Interpretation

letRec map = λg.λx.case x of c y z → c (g y) (map g z) = ⊓ {F | F ≥ 1 ⊕ (Λf .λg.λx.case x of c y z → c (g y) (f g z))F} (letRec)

15

slide-32
SLIDE 32

Example of Interpretation

letRec map = λg.λx.case x of c y z → c (g y) (map g z) = ⊓ {F | F ≥ 1 ⊕ (Λf .λg.λx.case x of c y z → c (g y) (f g z))F} (letRec) = ⊓{F | F ≥ 3 ⊕ ((Λf .Λg.Λx.case x of c y z → c (g y) (f g z))F)} (lambda × 2)

15

slide-33
SLIDE 33

Example of Interpretation

letRec map = λg.λx.case x of c y z → c (g y) (map g z) = ⊓ {F | F ≥ 1 ⊕ (Λf .λg.λx.case x of c y z → c (g y) (f g z))F} (letRec) = ⊓{F | F ≥ 3 ⊕ ((Λf .Λg.Λx.case x of c y z → c (g y) (f g z))F)} (lambda × 2) = ⊓{F | F ≥ 4 ⊕ (Λf .Λg.Λx. ⊔ {c (g y) (f g z) | x ≥ c y z}F)} (case)

15

slide-34
SLIDE 34

Example of Interpretation

letRec map = λg.λx.case x of c y z → c (g y) (map g z) = ⊓ {F | F ≥ 1 ⊕ (Λf .λg.λx.case x of c y z → c (g y) (f g z))F} (letRec) = ⊓{F | F ≥ 3 ⊕ ((Λf .Λg.Λx.case x of c y z → c (g y) (f g z))F)} (lambda × 2) = ⊓{F | F ≥ 4 ⊕ (Λf .Λg.Λx. ⊔ {c (g y) (f g z) | x ≥ c y z}F)} (case) = ⊓{F | F ≥ 4 ⊕ (Λf .Λg.Λx. ⊔ {1 ⊕ (g y) + (f g z)) | x ≥ 1 ⊕ y + z}F)} (cons × 2)

15

slide-35
SLIDE 35

Example of Interpretation

letRec map = λg.λx.case x of c y z → c (g y) (map g z) = ⊓ {F | F ≥ 1 ⊕ (Λf .λg.λx.case x of c y z → c (g y) (f g z))F} (letRec) = ⊓{F | F ≥ 3 ⊕ ((Λf .Λg.Λx.case x of c y z → c (g y) (f g z))F)} (lambda × 2) = ⊓{F | F ≥ 4 ⊕ (Λf .Λg.Λx. ⊔ {c (g y) (f g z) | x ≥ c y z}F)} (case) = ⊓{F | F ≥ 4 ⊕ (Λf .Λg.Λx. ⊔ {1 ⊕ (g y) + (f g z)) | x ≥ 1 ⊕ y + z}F)} (cons × 2) = ⊓{F | F ≥ 5 ⊕ (Λg.Λx. ⊔ {((g y) ⊕ (F g z)) | x ≥ 1 ⊕ y ⊕ z}}

15

slide-36
SLIDE 36

Relaxing interpretations

letRec map = λg.λx.case x of c y z → c (g y) (map g z) = ⊓{F | F ≥ 5 ⊕ (ΛG.ΛX. ⊔ {((G Y ) ⊕ (F G Z))| X ≥ 1 ⊕ Y ⊕ Z}}

16

slide-37
SLIDE 37

Relaxing interpretations

letRec map = λg.λx.case x of c y z → c (g y) (map g z) = ⊓{F | F ≥ 5 ⊕ (ΛG.ΛX. ⊔ {((G Y ) ⊕ (F G Z))| X ≥ 1 ⊕ Y ⊕ Z}} ≤ ⊓{F | F ≥ 5 ⊕ (ΛG.ΛX.((G (X − 1)) ⊕ (F G (X − 1))))} (constraint upper bound)

16

slide-38
SLIDE 38

Relaxing interpretations

letRec map = λg.λx.case x of c y z → c (g y) (map g z) = ⊓{F | F ≥ 5 ⊕ (ΛG.ΛX. ⊔ {((G Y ) ⊕ (F G Z))| X ≥ 1 ⊕ Y ⊕ Z}} ≤ ⊓{F | F ≥ 5 ⊕ (ΛG.ΛX.((G (X − 1)) ⊕ (F G (X − 1))))} (constraint upper bound) ≤ ΛG.ΛX.(5 + G X)) × X (min upper bound)

16

slide-39
SLIDE 39

A characterization of BFFi

slide-40
SLIDE 40

Order

Order 1 f : N → N Order 2 f : (N → N) → N Order n f : (((N → N) → N)... → N)

  • n

→ N Formally:

  • rder(b) = 0
  • rder(T → T ′) = max(order(T) + 1, order(T ′))

Example map is of order 2. apply : f , x → f (x) is of order 2. compose : f , g → (x → f (g(x))) is of order 2. isNorm : f →

  

1 if f is a norm

  • therwise

is of order 3.

17

slide-41
SLIDE 41

Order

Order 1 f : N → N Order 2 f : (N → N) → N Order n f : (((N → N) → N)... → N)

  • n

→ N Formally:

  • rder(b) = 0
  • rder(T → T ′) = max(order(T) + 1, order(T ′))

Example map is of order n. apply : f , x → f (x) is of order n. compose : f , g → (x → f (g(x))) is of order n. isNorm : f →

  

1 if f is a norm

  • therwise

is of order 3.

17

slide-42
SLIDE 42

Higher-order polynomial

P1 ::= c ∈ N|X0|P1 + P1|P1 × P1 Pi+1 ::= Pi|Pi+1 + Pi+1|Pi+1 × Pi+1|Xi(Pi+1) Definition Let FPi, i > 0, be the class of polynomial functionals at order i that consist in functionals computed by closed terms M such that:

  • order(M) = i
  • M is bounded by an order i polynomial (∃Pi, M ≤ Pi).

18

slide-43
SLIDE 43

Bounded Typed Loop Program (BTLP)

Definition (BTLP) A Bounded Typed Loop Program (BTLP) is a non-recursive and well-formed procedure defined by the following grammar:

(Procedures) ∋ P ::=v τ1×...×τn→N(v τ1

1 , . . . , v τn n )P∗VI∗ Return v N r End

(Declarations) ∋ V ::=var v N

1 , . . . , v N n ;

(Instructions) ∋ I ::=v N := E; | Loop v N

0 with v N 1 do I∗ EndLoop ;

(Expressions) ∋ E ::=1 | v N | v N

0 + v N 1 | v N 0 − v N 1 | v N 0 #v N 1 |

v τ1×...×τn→N(Aτ1

1 , . . . , Aτn n )

(Arguments) ∋ A ::=v | λv1, . . . , vn.v(v ′

1 . . . , v ′ m)

with v / ∈ {v1, . . . , vn}

BFFi is the class of order i functionals computable by a BTLP program.

19

slide-44
SLIDE 44

Results

Define the Safe Feasible Functionals at order i, SFFi by: SFF1 =BFF1, ∀i ≥ 1, SFFi+1 =BFFi+1↾SFFi Theorem (Hainry Péchoux) For any order i, FPi = SFFi. In particular, FP1 is FPtime and FP2 is BFF with FPtime oracles.

20

slide-45
SLIDE 45

Conclusion

slide-46
SLIDE 46

Conclusion

Results

  • An interpretation theory for higher-order functional languages
  • A characterization of well-known classes: BFFi

Issues and future work

  • BFFi is known to be restricted

→ see Férée’s phD manuscript (2014)

  • The interpretation synthesis problem is known to be very hard.
  • Interpretations for complexity analysis of real operators and

real-based languages.

  • Adapt the results to space: does it make sense?
  • Adapt ICC techniques to characterize P(R).

21