Combining linear logic and size types for implicit complexity

Patrick Baillot, Alexis Ghyselen
2019 Theoretical Computer Science  
Several type systems have been proposed to statically control the time complexity of lambdacalculus programs and characterize complexity classes such as FPTIME or FEXPTIME. A first line of research stems from linear logic and restricted versions of its !-modality controlling duplication. A second approach relies on the idea of tracking the size increase between input and output, and together with a restricted recursion scheme, to deduce time complexity bounds. However both approaches suffer
more » ... limitations : either a limited intensional expressivity, or linearity restrictions. In the present work we incorporate both approaches into a common type system, in order to overcome their respective constraints. Our system is based on elementary linear logic combined with linear size types, called sEAL, and leads to characterizations of the complexity classes FPTIME and 2k-FEXPTIME, for k >= 0. complexity one can mention two important threads of work. The first one is issued from linear logic, which provides a decomposition of intuitionistic logic with a modality, !, accounting for duplication. By designing variants of linear logic with weak versions of the ! modality one obtains systems corresponding to different complexity classes, like light linear logic (LLL) for the class FP [15] and elementary linear logic (ELL) for the classes k-FEXPTIME, for k ≥ 0. [15, 2, 14]. These logical systems can be seen as type systems for some variants of lambda-calculi. A key feature of these systems, and the main ingredient for proving their complexity properties, is that they induce a stratification of the typed program into levels. We will thus refer to them as level-based systems. Their advantage is that they deal with a higher-order language, and that they are also compatible with polymorphism. Unfortunately from a programming point of view they have a critical drawback: only few and very specific programs are actually typable, because the restrictions imposed to recursion by typing are in fact very strong... A second thread of work relies on the idea of tracking the size increase between the input and the output of a program. This approach is well illustrated by Hofmann's Non-size-increasing (NSI) type system [19] : here the types carry information about the input/output size difference, and the recursion is restricted in such a way that typed programs admit polynomial time complexity. An important advantage with respect to LLL is that the system is algorithmically more expressive, that is to say that far more programs are typable. This has triggered a fertile research line on type-based complexity analysis using ideas of amortized cost analysis [20, 17, 16]. Some aspects of higher-order have been adressed [22] but note that this approach deals with complexity analysis and not with the characterization of complexity classes. In particular it does not suggest disciplines to program within a given complexity class. A similar idea is also explored by the line of work on quasi-interpretations [10, 4], with a slightly different angle : here the kind of dependence between input and output size can be more general but the analysis is more of a semantic nature and in particular no type system is provided to derive quasi-interpretations. The type system d T of [3] can be thought of as playing this role of describing the dependence between input and output size, and it allows to derive time complexity bounds, even though these are not limited to polynomial bounds. Altogether we will refer to these approaches as size-based systems. However they also have a limitation: characterizations of complexity classes have not been obtained for full-fledged higher-order languages, but only for linear higher-order languages, that is to say languages in which functional arguments have to be used at most once (as in [19, 4]). Problematic and methodology. So on the one hand level-based systems manage higherorder but have a poor expressivity, and on the other hand sized-based systems have a good expressivity but do not characterize complexity classes within a general higher-order language. . . On both sides some attempts have been made to repair these shortcomings but only with limited success: in [6] for instance LLL is extended to a language with recursive definitions, but the main expressivity problem remains; in [4] quasi-interpretations are defined for a higher-order language, but with a linearity condition on functional arguments. The goal of the present work is precisely to improve this situation by reconciliating the level-based and the size-based approaches. From a practical point of view we want to design a system which would bring together the advantages of the two approaches. From a fundamental point of view we want to understand how the levels and the input/output size dependencies are correlated, and for instance if one of these two characteristics subsumes the other one. One way to bridge these two approaches could be to start with a level-based system such as LLL, and try to extend it with more typing rules so as to integrate in it some size-based features. However a technical difficulty for that is that the complexity bounds for LLL and C S L 2 0 1 8 C S L 2 0 1 8 References 1 Martin Avanzini and Ugo Dal Lago. Automating sized-type inference for complexity analysis. PACMPL, 1(ICFP):43:1-43:29, 2017. 2 Patrick Baillot. On the expressivity of elementary linear logic: Characterizing ptime and an exponential time hierarchy. Information and Computation, 241:3-31, 2015. 3 Patrick Baillot, Gilles Barthe, and Ugo Dal Lago. Implicit computational complexity of subrecursive definitions and applications to cryptographic proofs (long version). Research report, ENS Lyon, 2015. URL: https://hal.archives-ouvertes.fr/hal-01197456. 4 Patrick Baillot and Ugo Dal Lago. Higher-order interpretations and program complexity. 6 Patrick Baillot, Marco Gaboardi, and Virgile Mogbil. A polytime functional language from light linear logic. In European Symposium on Programming, pages 104-124. Springer, 2010. 7 Patrick Baillot and Alexis Ghyselen. Combining linear logic and size types for implicit complexity (long version). hal-01687224, [Research Report], 2018. 8 Patrick Baillot and Kazushige Terui. A feasible algorithm for typing in elementary affine logic. In TLCA, volume 5, pages 55-70. Springer, 2005. 9 Stephen Bellantoni and Stephen Cook. A new recursion-theoretic characterization of the polytime functions. In
doi:10.1016/j.tcs.2019.09.032 fatcat:wbzm7ll2dbe55lenvkvzv2bnqu