30 research outputs found
Arrays and References in Resource Aware ML
This article introduces a technique to accurately perform static prediction of resource usage for ML-like functional programs with references and arrays. Previous research successfully integrated the potential method of amortized analysis with a standard type system to automatically derive parametric resource bounds. The analysis is naturally compositional and the resource consumption of functions can be abstracted using potential-annotated types. The soundness theorem of the analysis guarantees that the derived bounds are correct with respect to the resource usage defined by a cost semantics. Type inference can be efficiently automated using off-the-shelf LP solvers, even if the derived bounds are polynomials. However, side effects and aliasing of heap references make it notoriously difficult to derive bounds that depend on mutable structures, such as arrays and references. As a result, existing automatic amortized analysis systems for ML-like programs cannot derive bounds for programs whose resource consumption depends on data in such structures. This article extends the potential method to handle mutable structures with minimal changes to the type rules while preserving the stated advantages of amortized analysis. To do so, we introduce a swap operation for references and arrays that users can use to make programs suitable for automatic analysis. We prove the soundness of the analysis introducing a potential-annotated memory typing, which gathers all unique locations reachable from a reference. Apart from the design of the system, the main contribution is the proof of soundness for the extended analysis system
Generic bidirectional typing for dependent type theories
Bidirectional typing is a discipline in which the typing judgment is
decomposed explicitly into inference and checking modes, allowing to control
the flow of type information in typing rules and to specify algorithmically how
they should be used. Bidirectional typing has been fruitfully studied and
bidirectional systems have been developed for many type theories. However, the
formal development of bidirectional typing has until now been kept confined to
specific theories, with general guidelines remaining informal. In this work, we
give a generic account of bidirectional typing for a general class of dependent
type theories. This is done by first giving a general definition of type
theories (or equivalently, a logical framework), for which we define
declarative and bidirectional type systems. We then show, in a
theory-independent fashion, that the two systems are equivalent. This
equivalence is then explored to establish the decidability of typing for weak
normalizing theories, yielding a generic type-checking algorithm that has been
implemented in a prototype and used in practice with many theories
General Recursion via Coinductive Types
A fertile field of research in theoretical computer science investigates the
representation of general recursive functions in intensional type theories.
Among the most successful approaches are: the use of wellfounded relations,
implementation of operational semantics, formalization of domain theory, and
inductive definition of domain predicates. Here, a different solution is
proposed: exploiting coinductive types to model infinite computations. To every
type A we associate a type of partial elements Partial(A), coinductively
generated by two constructors: the first, return(a) just returns an element
a:A; the second, step(x), adds a computation step to a recursive element
x:Partial(A). We show how this simple device is sufficient to formalize all
recursive functions between two given types. It allows the definition of fixed
points of finitary, that is, continuous, operators. We will compare this
approach to different ones from the literature. Finally, we mention that the
formalization, with appropriate structural maps, defines a strong monad.Comment: 28 page
Efficient Type Checking for Path Polymorphism
A type system combining type application, constants as types, union types (associative, commutative and idempotent) and recursive types has recently been proposed for statically typing path polymorphism, the ability to define functions that can operate uniformly over
recursively specified applicative data structures. A typical pattern such functions resort to is dataterm{x}{y} which decomposes a compound, in other words any applicative tree structure, into its parts. We study type-checking for this type system in two stages. First we propose algorithms for checking type equivalence and subtyping based on coinductive characterizations of those relations. We then formulate a syntax-directed presentation and prove its equivalence with the original one. This yields a type-checking algorithm which unfortunately has exponential time complexity in the worst case. A second algorithm is then proposed, based on automata techniques, which yields a polynomial-time type-checking algorithm
Modular Inference of Linear Types for Multiplicity-Annotated Arrows
Bernardy et al. [2018] proposed a linear type system as a
core type system of Linear Haskell. In the system, linearity is represented by
annotated arrow types , where denotes the multiplicity of the
argument. Thanks to this representation, existing non-linear code typechecks as
it is, and newly written linear code can be used with existing non-linear code
in many cases. However, little is known about the type inference of
. Although the Linear Haskell implementation is equipped with
type inference, its algorithm has not been formalized, and the implementation
often fails to infer principal types, especially for higher-order functions. In
this paper, based on OutsideIn(X) [Vytiniotis et al., 2011], we propose an
inference system for a rank 1 qualified-typed variant of , which
infers principal types. A technical challenge in this new setting is to deal
with ambiguous types inferred by naive qualified typing. We address this
ambiguity issue through quantifier elimination and demonstrate the
effectiveness of the approach with examples.Comment: The full version of our paper to appear in ESOP 202
PCC '06 / 5th International Workshop on Proof, Computation, Complexity, Ilmenau, July 24 - 25, 2006.
The Best of Both Worlds:Linear Functional Programming without Compromise
We present a linear functional calculus with both the safety guarantees
expressible with linear types and the rich language of combinators and
composition provided by functional programming. Unlike previous combinations of
linear typing and functional programming, we compromise neither the linear side
(for example, our linear values are first-class citizens of the language) nor
the functional side (for example, we do not require duplicate definitions of
compositions for linear and unrestricted functions). To do so, we must
generalize abstraction and application to encompass both linear and
unrestricted functions. We capture the typing of the generalized constructs
with a novel use of qualified types. Our system maintains the metatheoretic
properties of the theory of qualified types, including principal types and
decidable type inference. Finally, we give a formal basis for our claims of
expressiveness, by showing that evaluation respects linearity, and that our
language is a conservative extension of existing functional calculi.Comment: Extended versio