15 research outputs found
Proof-Relevant Resolution for Elaboration of Programming Languages
Proof-relevant resolution is a new variant of resolution in Horn-clause logic and its extensions. We propose proof-relevant resolution as a systematic approach to elaboration in programming languages that is close to formal specification and hence allows for analysis of semantics of the language. We demonstrate the approach on two case studies; we describe a novel, proof-relevant approach to type inference and term synthesis in dependently types languages and we show how proof-relevant resolution allows for analysis of inductive and coinductive soundness of type class resolution. We conclude by a discussion of overall contributions of our current work
Editing Syntax Trees on the Surface
Proceedings of the 18th Nordic Conference of Computational Linguistics
NODALIDA 2011.
Editors: Bolette Sandford Pedersen, Gunta Nešpore and Inguna Skadiņa.
NEALT Proceedings Series, Vol. 11 (2011), 138-145.
© 2011 The editors and contributors.
Published by
Northern European Association for Language
Technology (NEALT)
http://omilia.uio.no/nealt .
Electronically published at
Tartu University Library (Estonia)
http://hdl.handle.net/10062/16955
Static Type Inference for the Q language using Constraint Logic Programming
We describe an application of Prolog: a type inference tool for the Q functional language. Q is a terse vector processing language, a descendant of APL, which is getting more and more popular, especially in financial applications. Q is a dynamically typed language, much like Prolog. Extending Q with static typing improves both the readability of programs and programmer productivity, as type errors are discovered by the tool at compile time, rather than through debugging the program execution.
We map the task of type inference onto a constraint satisfaction problem and use constraint logic programming, in particular the Constraint Handling Rules extension of Prolog. We determine the possible type values for each program expression and detect inconsistencies. As most built-in function names of Q are overloaded, i.e. their meaning depends on the argument types, a quite complex system of constraints had to be implemented
Static Type Checking for the Q Functional Language in Prolog
We describe an application of Prolog: a type checking tool for the Q functional language. Q is a terse vector processing language, a descendant of APL, which is getting more and more popular, especially in financial applications. Q is a dynamically typed language, much like Prolog. Extending Q with static typing improves both the readability of programs and programmer productivity, as type errors are discovered by the tool at compile time, rather than through
debugging the program execution. We designed a type description syntax for Q and implemented a parser for both the Q language
and its type extension. We then implemented a type checking algorithm using constraints. As most built-in function names of Q are overloaded, i.e. their meaning depends on the argument types, a quite complex system of constraints had to be implemented. Prolog proved to be an ideal implementation language for the task at hand. We used Definite Clause Grammars for parsing and Constraint Handling Rules for the type checking algorithm. In the paper we describe the main problems solved and the experiences gained in the development of the type checking tool
Structural resolution for abstract compilation of object-oriented languages
We propose abstract compilation for precise static type analysis of
object-oriented languages based on coinductive logic programming. Source code
is translated to a logic program, then type-checking and inference problems
amount to queries to be solved with respect to the resulting logic program. We
exploit a coinductive semantics to deal with infinite terms and proofs produced
by recursive types and methods. Thanks to the recent notion of structural
resolution for coinductive logic programming, we are able to infer very precise
type information, including a class of irrational recursive types causing
non-termination for previously considered coinductive semantics. We also show
how to transform logic programs to make them satisfy the preconditions for the
operational semantics of structural resolution, and we prove this step does not
affect the semantics of the logic program.Comment: In Proceedings CoALP-Ty'16, arXiv:1709.0419
Proof-relevant Horn clauses for dependent type inference and term synthesis
This work has been supported by the EPSRC grant “Coalgebraic Logic Programming for Type Inference” EP/K031864/1-2, EU Horizon 2020 grant “RePhrase: Refactoring Parallel Heterogeneous Resource Aware Applications - a Software Engineering Approach” (ICT-644235), and by COST Action IC1202 (TACLe), supported by COST (European Cooperation in Science and Technology).First-order resolution has been used for type inference for many years, including in Hindley-Milner type inference, type-classes, and constrained data types. Dependent types are a new trend in functional languages. In this paper, we show that proof-relevant first-order resolution can play an important role in automating type inference and term synthesis for dependently typed languages. We propose a calculus that translates type inference and term synthesis problems in a dependently typed language to a logic program and a goal in the proof-relevant first-order Horn clause logic. The computed answer substitution and proof term then provide a solution to the given type inference and term synthesis problem. We prove the decidability and soundness of our method.PostprintPeer reviewe
HM(X) type inference is CLP(X) solving
10.1017/S0956796807006569Journal of Functional Programming182251-28
Recommended from our members
Extending Type Inference to Variational Programs
Through the use of conditional compilation and related tools, many software projects can be used to generate a huge
number of related programs. The problem of typing such variational software is difficult. The brute-force strategy
of generating all variants and typing each one individually is (1) usually infeasible for efficiency reasons and (2)
produces results that do not map well to the underlying variational program. Recent research has focused mainly
on efficiency and addressed only the problem of type checking. In this work we tackle the more general problem of
variational type inference and introduce variational types to represent the result of typing a variational program. We
introduce the variational lambda calculus (VLC) as a formal foundation for research on typing variational programs.
We define a type system for VLC in which VLC expressions are mapped to correspondingly variational types. We
show that the type system is correct by proving that the typing of expressions is preserved over the process of
variation elimination, which eventually results in a plain lambda calculus expression and its corresponding type.
We identify a set of equivalence rules for variational types and prove that the type unification problem modulo these
equivalence rules is unitary and decidable; we also present a sound and complete unification algorithm. Based on
the unification algorithm, the variational type inference algorithm is an extension of algorithm W. We show that
it is sound and complete and computes principal types. We also consider the extension of VLC with sum types, a
necessary feature for supporting variational data types, and demonstrate that the previous theoretical results also
hold under this extension. Finally, we characterize the complexity of variational type inference and demonstrate the
efficiency gains over the brute-force strategy.This is an author's peer-reviewed final manuscript, as accepted by the publisher. The published article is copyrighted by the Association for Computing Machinery and can be found at: http://toplas.acm.org/.Keywords: variational type inference, variational types, variational lambda calculu