T HE STRONG INVARIANCE THESIS FOR A λ - CALCULUS LOLA WORKSHOP 2017 Yannick Forster 1 Fabian Kunze 1,2 Marc Roth 1,3 1 S AARLAND U NIVERSITY 2 M AX P LANCK I NSTITUTE FOR I NFORMATICS 3 C LUSTER OF E XCELLENCE (MMCI) saarland university computer science
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter T URING MACHINES saarland university computer science 2
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter T URING MACHINES ( PROS ) ◮ easy to imagine ◮ easy to explain ◮ de-facto the standard model of computation for computation theory and complexity theory saarland university computer science 3
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter T URING MACHINES ( CONS ) Notoriously hard to reason about (in a formally precise way): ◮ not compositional ◮ tedious encodings ◮ no nice abstractions for verification (e.g. no separation logic) ◮ Formalisation of Computability Theory is out of reach ◮ Formalisation of Complexity Theory is even further away saarland university computer science 4
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter E XEMPLARY RELATED WORK Ugo Dal Lago and Simone Martini The Weak Lambda Calculus as a Reasonable Machine Theoretical Computer Science, 2008 Beniamino Accattoli and Ugo Dal Lago (Leftmost-Outermost) Beta Reduction is Invariant, Indeed Logical Methods in Computer Science, 2016 saarland university computer science 5
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter E XEMPLARY RELATED WORK Ugo Dal Lago and Simone Martini The Weak Lambda Calculus as a Reasonable Machine Theoretical Computer Science, 2008 Beniamino Accattoli and Ugo Dal Lago (Leftmost-Outermost) Beta Reduction is Invariant, Indeed Logical Methods in Computer Science, 2016 Andrea Asperti and Wilmer Ricciotti A formalization of multi-tape Turing machines Theoretical Computer Science, 2015 saarland university computer science 5
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter A NOTHER MODEL OF COMPUTATION A certain flavour of λ -calculus called L ◮ compositional ◮ straightforward encodings of data types ◮ equational reasoning for verification ◮ Formalisation for Computability theory Yannick Forster and Gert Smolka Weak Call-by-Value Lambda Calculus as a Model of Computation in Coq ITP 2017 ◮ Reasonable with respect to time [Dal Lago, Martini (2008)] ◮ Reasonable with respect to space? saarland university computer science 6
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter T HE I NVARIANCE T HESIS (Strong) Invariance Thesis ‘Reasonable’ machines can simulate each other within a polynomially bounded overhead in time and a constant-factor overhead in space. saarland university computer science [Slot, van Emde Boas (1998)] 7
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter T HE I NVARIANCE T HESIS (Strong) Invariance Thesis ‘Reasonable’ machines can simulate each other within a polynomially bounded overhead in time and a constant-factor overhead in space. Ensures consistency w.r.t classes closed under poly-time/constant-space reductions. saarland university computer science [Slot, van Emde Boas (1998)] 7
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter C ONTRIBUTION ◮ Simple time and space measures for L ◮ substitution-based interpreter with constant-factor overhead in space ◮ heap-based interpreter with polynomially bounded overhead in time ◮ hybrid interpreter fulfilling the strong invariance thesis saarland university computer science 8
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter C ONTRIBUTION Theorem (Strong Invariance Thesis for L) L and Turing Machines can simulate each other within a polynomially bounded overhead in time and a constant-factor overhead in space for decision functions with non-sublinear running time . saarland university computer science 9
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter L: W EAK C ALL - BY -V ALUE λ -C ALCULUS s , t ::= x | λ x . s | s t s ≻ s ′ t ≻ t ′ st ≻ s ′ t st ≻ st ′ ( λ x . s )( λ y . t ) ≻ s [ x := λ y . t ] ◮ uniformly confluent (reductions to normal forms have the same length) ◮ data represented by abstractions (Scott encoding) saarland ◮ recursion using fixed-point combinator university computer science [Dal Lago, Martini (2008)] 10
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter T IME MEASURE If s = s 0 ≻ s 1 ≻ · · · ≻ s k then Time ( s ) := k i.e. the number of β -reduction steps saarland university computer science 11
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter S PACE MEASURE Space ( s ) := { s i | s ≻ ∗ s i } | s i | max i.e. size of the largest intermediate term of the reduction for | x | = de Bruijn index of x | st | = 1 + | s | + | t | | λ x . s | = 1 + | s | saarland university computer science 12
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter D EFINITION OF T URING MACHINE ◮ a finite type of states Q ◮ a transition function δ : Q × Σ n + 1 → Q × Σ n + 1 × { L , N , R } ◮ a start state s : Q ◮ a halting function Q → B Semantics: Loop δ until a halting state is reached. saarland university computer science [Asperti, Ricciotti (2015)], [Dal Lago, Martini (2008)] 13
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter D EFINITION OF T URING MACHINE ◮ a finite type of states Q ◮ a transition function δ : Q × Σ n + 1 → Q × Σ n + 1 × { L , N , R } ◮ a start state s : Q ◮ a halting function Q → B Semantics: Loop δ until a halting state is reached. Encode δ and halting function using Scott encodings (linear size, polynomial operations) and loop. saarland university computer science [Asperti, Ricciotti (2015)], [Dal Lago, Martini (2008)] 13
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter D EFINITION OF T URING MACHINE ◮ a finite type of states Q ◮ a transition function δ : Q × Σ n + 1 → Q × Σ n + 1 × { L , N , R } ◮ a start state s : Q ◮ a halting function Q → B Semantics: Loop δ until a halting state is reached. Encode δ and halting function using Scott encodings (linear size, polynomial operations) and loop. In Coq: Generation and verification of L-code from functional specification is automatic with our framework. saarland Time-complexity of the extract is semi-automatic. university Space-complexity has to be done by hand. computer science [Asperti, Ricciotti (2015)], [Dal Lago, Martini (2008)] 13
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter Theorem (Invariance thesis part I) L can simulate Turing machines with a polynomially bounded overhead in time and a constant-factor overhead in space. saarland university computer science 14
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter E XAMPLE : E VALUATING BY SUBSTITUTION Let I := λ x . x : ( λ xy . x x ) I (( λ xy . x x ) II ) saarland university computer science 15
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter E XAMPLE : E VALUATING BY SUBSTITUTION Let I := λ x . x : ( λ xy . x x ) I (( λ xy . x x ) II ) ≻ ( λ y . I I ) (( λ xy . x x ) II ) saarland university computer science 15
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter E XAMPLE : E VALUATING BY SUBSTITUTION Let I := λ x . x : ( λ xy . x x ) I (( λ xy . x x ) II ) ≻ ( λ y . I I ) (( λ xy . x x ) II ) ≻ ( λ y . I I ) (( λ y . II ) I ) saarland university computer science 15
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter E XAMPLE : E VALUATING BY SUBSTITUTION Let I := λ x . x : ( λ xy . x x ) I (( λ xy . x x ) II ) ≻ ( λ y . I I ) (( λ xy . x x ) II ) ≻ ( λ y . I I ) (( λ y . II ) I ) ≻ ( λ y . I I ) ( I I ) saarland university computer science 15
Introduction The calculus L Simulating TMs Simulating L with substitutions Simulating L with a heap Hybrid Interpreter E XAMPLE : E VALUATING BY SUBSTITUTION Let I := λ x . x : ( λ xy . x x ) I (( λ xy . x x ) II ) ≻ ( λ y . I I ) (( λ xy . x x ) II ) ≻ ( λ y . I I ) (( λ y . II ) I ) ≻ ( λ y . I I ) ( I I ) ≻ ( λ y . I I ) I saarland university computer science 15
Recommend
More recommend