Higher-order Interpretations for Higher-order Complexity Emmanuel Hainry & Romain Péchoux LPAR, 11 may 2017 CNRS, INRIA, Université de Lorraine & LORIA, Nancy, France 1
Introduction
First-order computability and complexity • Computability is well understood: • Definitions, hierarchies (Turing degree) • Church-Turing’s thesis • Computational Complexity is well understood: • Definitions, classes • Various characterizations: • machine based characterizations • machine independent characterizations → Implicit Computational Complexity 2
Higher-order computability and complexity • 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
Higher-order computability and complexity • 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, ... • 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
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
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 = BFF i , the Basic Feasible Functionals at any order. 4
First-order interpretations
First-order interpretations of TRS • Defined in the 70s for showing TRS termination : • ∀ b of arity n , � b � : N n → ↑ N • ∀ l → r ∈ R , � l � > � r � additive: for any constructor symbol c , � c � ( X ) = X + k , ∈ N . Let PI add be the set of functions computed by TRS admitting an additive polynomial interpretation. Theorem (Bonfante et al.) PI add ≡ FPTIME 5
First-order interpretations of TRS Example double ( ǫ ) → ǫ double ( s ( x )) → s ( s ( double ( x )) 6
First-order interpretations of TRS Example double ( ǫ ) → ǫ double ( s ( x )) → s ( s ( double ( x )) � ǫ � = 0 , � s � ( X ) = X + 1 , � double � ( X ) = 3 X + 1 6
First-order interpretations of TRS Example double ( ǫ ) → ǫ double ( s ( x )) → s ( s ( double ( x )) � ǫ � = 0 , � s � ( X ) = X + 1 , � double � ( X ) = 3 X + 1 � double ǫ � = 1 > 0 = � ǫ � � double s ( x ) � = 3 X + 4 > 3 X + 3 = � s ( s ( double ( x )) � 6
First-order interpretations of TRS Example double ( ǫ ) → ǫ double ( s ( x )) → s ( s ( double ( x )) � ǫ � = 0 , � s � ( X ) = X + 1 , � double � ( X ) = 3 X + 1 � double ǫ � = 1 > 0 = � ǫ � � double s ( x ) � = 3 X + 4 > 3 X + 3 = � s ( s ( double ( x )) � Additivity ⇒ [ [ double ] ] : x �→ 2 x ∈ FPTIME 6
Higher-order interpretations of TRS: State of the art • Termination: • Van De Pol (1993) adapted interpretations for showing termination of higher-order TRS. 7
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 (BFF 2 ) and P ( R ). 7
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 (BFF 2 ) 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
Higher-order language
Higher Order Programming Language Definition (Functional Language) M := x | c | op | M 1 M 2 | λ x . M | case M of c 1 → M 1 | c 2 → M 2 | ... | c n → M n | letRec f = M + Inductive Typing 8
Example Example letRec map = λ g. λ x.case x of c y z → c (g y) (map g z) | nil → nil List ( α ) ::= nil | c α List ( α ) map: ( A → B ) → List ( A ) → List ( B ) 9
Semantics Four kinds of reductions: • β reduction: λ x . M N − → β M { N / x } • case reduction: case c j N j of c 1 → M 1 | ... | c n → M n − → case M j N j • letRec reduction: letRec f = M − → letRec M { letRec f = M / f } • Operator reduction (total functions over terms): op M → op [ [ op ] ]( M ) +Left-most outermost reduction strategy 10
Higher-order interpretations
Interpretations of types Definition • � b � = ¯ N = N ∪ {⊤} • � T → T ′ � = � T � → ↑ � T ′ � Definition • f : A → ↑ B a monotonic function from A to B . • 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 ) ) N → ↑ ¯ N ) → ↑ ¯ N → ↑ ¯ � map � is in (¯ N . 11
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
Interpretations of terms n ⊕ ¯ N = Λ X . ( n + X ) n ⊕ � T → T ′ � : Λ F . Λ X . ( n ⊕ � T ′ � F ( X )) Definition (Interpretations) � x � = X 1 ⊕ (Λ X 1 . . . . . Λ X n . � n � c � = i =1 X i ) � M N � = � M �� N � 13
Interpretations of terms n ⊕ ¯ N = Λ X . ( n + X ) n ⊕ � T → T ′ � : Λ F . Λ X . ( n ⊕ � T ′ � F ( X )) Definition (Interpretations) � x � = X 1 ⊕ (Λ X 1 . . . . . Λ X n . � n � c � = i =1 X i ) � M N � = � M �� N � � λ x . M � = 1 ⊕ (Λ � x � . � M � ) 13
Interpretations of terms n ⊕ ¯ N = Λ X . ( n + X ) n ⊕ � T → T ′ � : Λ F . Λ X . ( n ⊕ � T ′ � F ( X )) Definition (Interpretations) � x � = X 1 ⊕ (Λ X 1 . . . . . Λ X n . � n � c � = i =1 X i ) � M N � = � M �� N � � λ x . M � = 1 ⊕ (Λ � x � . � M � ) � case M of . . . c i → M i . . . � = 1 ⊕ ⊔ i { � M i � R i | � c i � R i ≤ � M � } 13
Interpretations of terms n ⊕ ¯ N = Λ X . ( n + X ) n ⊕ � T → T ′ � : Λ F . Λ X . ( n ⊕ � T ′ � F ( X )) Definition (Interpretations) � x � = X 1 ⊕ (Λ X 1 . . . . . Λ X n . � n � c � = i =1 X i ) � M N � = � M �� N � � λ x . M � = 1 ⊕ (Λ � x � . � M � ) � case M of . . . c i → M i . . . � = 1 ⊕ ⊔ i { � M i � R i | � c i � R i ≤ � M � } � letRec f = M � = ⊓{ F | F ≥ 1 ⊕ (Λ � f � . � M ) � F } 13
Interpretations of terms n ⊕ ¯ N = Λ X . ( n + X ) n ⊕ � T → T ′ � : Λ F . Λ X . ( n ⊕ � T ′ � F ( X )) Definition (Interpretations) � x � = X 1 ⊕ (Λ X 1 . . . . . Λ X n . � n � c � = i =1 X i ) � M N � = � M �� N � � λ x . M � = 1 ⊕ (Λ � x � . � M � ) � case M of . . . c i → M i . . . � = 1 ⊕ ⊔ i { � M i � R i | � c i � R i ≤ � M � } � letRec f = M � = ⊓{ F | F ≥ 1 ⊕ (Λ � f � . � M ) � F } � op M � ≥ �� op � ( M ) � 13
Properties of interpretations Theorem Any term M has an interpretation. Knaster-Tarski: lfp (Λ X . 1 ⊕ ((Λ � f � . � M � ) X )) 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
Example of Interpretation � letRec map = λ g .λ x . case x of c y z → c ( g y ) ( map g z ) | nil → nil � = . . . . . . = . . . = ⊓{ F | F ≥ 5 ⊕ (Λ G . Λ X . ⊔ { (( G Y ) ⊕ ( F G Z )) | X ≥ 1 ⊕ Y ⊕ Z }} with 1 (letRec), 2 (Lambda), 1 (Case), 2 (Cons c ), 2 (Cons nil ) 15
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
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
Recommend
More recommend