283 research outputs found
A foundation for synthesising programming language semantics
Programming or scripting languages used in real-world systems are seldom designed
with a formal semantics in mind from the outset. Therefore, the first step for developing well-founded analysis tools for these systems is to reverse-engineer a formal
semantics. This can take months or years of effort.
Could we automate this process, at least partially? Though desirable, automatically reverse-engineering semantics rules from an implementation is very challenging,
as found by Krishnamurthi, Lerner and Elberty. They propose automatically learning
desugaring translation rules, mapping the language whose semantics we seek to a simplified, core version, whose semantics are much easier to write. The present thesis
contains an analysis of their challenge, as well as the first steps towards a solution.
Scaling methods with the size of the language is very difficult due to state space
explosion, so this thesis proposes an incremental approach to learning the translation
rules. I present a formalisation that both clarifies the informal description of the challenge by Krishnamurthi et al, and re-formulates the problem, shifting the focus to the
conditions for incremental learning. The central definition of the new formalisation is
the desugaring extension problem, i.e. extending a set of established translation rules
by synthesising new ones.
In a synthesis algorithm, the choice of search space is important and non-trivial,
as it needs to strike a good balance between expressiveness and efficiency. The rest
of the thesis focuses on defining search spaces for translation rules via typing rules.
Two prerequisites are required for comparing search spaces. The first is a series of
benchmarks, a set of source and target languages equipped with intended translation
rules between them. The second is an enumerative synthesis algorithm for efficiently
enumerating typed programs. I show how algebraic enumeration techniques can be applied to enumerating well-typed translation rules, and discuss the properties expected
from a type system for ensuring that typed programs be efficiently enumerable.
The thesis presents and empirically evaluates two search spaces. A baseline search
space yields the first practical solution to the challenge. The second search space is
based on a natural heuristic for translation rules, limiting the usage of variables so that
they are used exactly once. I present a linear type system designed to efficiently enumerate translation rules, where this heuristic is enforced. Through informal analysis
and empirical comparison to the baseline, I then show that using linear types can speed
up the synthesis of translation rules by an order of magnitude
Erasure in dependently typed programming
It is important to reduce the cost of correctness in programming. Dependent types
and related techniques, such as type-driven programming, offer ways to do so.
Some parts of dependently typed programs constitute evidence of their typecorrectness
and, once checked, are unnecessary for execution. These parts can easily
become asymptotically larger than the remaining runtime-useful computation, which
can cause linear-time algorithms run in exponential time, or worse. It would be
unnacceptable, and contradict our goal of reducing the cost of correctness, to make
programs run slower by only describing them more precisely.
Current systems cannot erase such computation satisfactorily. By modelling
erasure indirectly through type universes or irrelevance, they impose the limitations
of these means to erasure. Some useless computation then cannot be erased and
idiomatic programs remain asymptotically sub-optimal.
This dissertation explains why we need erasure, that it is different from other
concepts like irrelevance, and proposes two ways of erasing non-computational data.
One is an untyped flow-based useless variable elimination, adapted for dependently
typed languages, currently implemented in the Idris 1 compiler.
The other is the main contribution of the dissertation: a dependently typed core
calculus with erasure annotations, full dependent pattern matching, and an algorithm
that infers erasure annotations from unannotated (or partially annotated) programs.
I show that erasure in well-typed programs is sound in that it commutes with
single-step reduction. Assuming the Church-Rosser property of reduction, I show
that properties such as Subject Reduction hold, which extends the soundness result
to multi-step reduction. I also show that the presented erasure inference is sound
and complete with respect to the typing rules; that this approach can be extended
with various forms of erasure polymorphism; that it works well with monadic I/O
and foreign functions; and that it is effective in that it not only removes the runtime
overhead caused by dependent typing in the presented examples, but can also shorten
compilation times."This work was supported by the University of St Andrews (School of Computer
Science)." -- Acknowledgement
Representing Guardedness in Call-By-Value
Like the notion of computation via (strong) monads serves to classify various flavours of impurity, including exceptions, non-determinism, probability, local and global store, the notion of guardedness classifies well-behavedness of cycles in various settings. In its most general form, the guardedness discipline applies to general symmetric monoidal categories and further specializes to Cartesian and co-Cartesian categories, where it governs guarded recursion and guarded iteration respectively. Here, even more specifically, we deal with the semantics of call-by-value guarded iteration. It was shown by Levy, Power and Thielecke that call-by-value languages can be generally interpreted in Freyd categories, but in order to represent effectful function spaces, such a category must canonically arise from a strong monad. We generalize this fact by showing that representing guarded effectful function spaces calls for certain parametrized monads (in the sense of Uustalu). This provides a description of guardedness as an intrinsic categorical property of programs, complementing the existing description of guardedness as a predicate on a category
A Curry-Howard Correspondence for Linear, Reversible Computation
In this paper, we present a linear and reversible programming language with inductives types and recursion. The semantics of the languages is based on pattern-matching; we show how ensuring syntactical exhaustivity and non-overlapping of clauses is enough to ensure reversibility. The language allows to represent any Primitive Recursive Function. We then give a Curry-Howard correspondence with the logic ?MALL: linear logic extended with least fixed points allowing inductive statements. The critical part of our work is to show how primitive recursion yields circular proofs that satisfy ?MALL validity criterion and how the language simulates the cut-elimination procedure of ?MALL
Planning problems as types, plans as programs : a dependent types infrastructure for verification and reasoning about automated plans in Agda
Historically, the Artificial Intelligence and programming language fields have had
a mutually beneficial relationship. Typically, theoretical results in the programming
language field have practical utility in the Artificial Intelligence field. One example
of this that has roots in both declarative languages and theorem proving is AI planning. In recent years, new programming languages have been developed that are
founded on dependent type theory. These languages are not only more expressive
than traditional programming languages but also have the ability to represent and
prove mathematical properties within the language. This thesis will explore how dependently typed languages can benefit the AI planning field. On one side this thesis
will show how AI planning languages can be enriched with more expressivity and
stronger verification guarantees. On the other, it will show that AI planning is an
ideal field to illustrate the practical utility of largely theoretical aspects of programming language theory. This thesis will accomplish this by implementing multiple
inference systems for plan validation in the dependently-typed programming language Agda. Importantly, these inference systems will be automated, and embody
the Curry-Howard correspondence where plans will not only be proof-terms but
also executable functions. This thesis will then show how the dependently-typed
implementations of the inference systems can be further utilised to add enriched
constraints over plan validation
CHAD for expressive total languages
We show how to apply forward and reverse mode Combinatory Homomorphic Automatic Differentiation (CHAD) (Vákár (2021). ESOP, 607–634; Vákár and Smeding (2022). ACM Transactions on Programming Languages and Systems 44 (3) 20:1–20:49.) to total functional programming languages with expressive type systems featuring the combination of • tuple types; • sum types; • inductive types; • coinductive types; • function types. We achieve this by analyzing the categorical semantics of such types in Σ-types (Grothendieck constructions) of suitable categories. Using a novel categorical logical relations technique for such expressive type systems, we give a correctness proof of CHAD in this setting by showing that it computes the usual mathematical derivative of the function that the original program implements. The result is a principled, purely functional and provably correct method for performing forward- and reverse-mode automatic differentiation (AD) on total functional programming languages with expressive type systems
Mathematical Foundations for a Compositional Account of the Bayesian Brain
This dissertation reports some first steps towards a compositional account of
active inference and the Bayesian brain. Specifically, we use the tools of
contemporary applied category theory to supply functorial semantics for
approximate inference. To do so, we define on the `syntactic' side the new
notion of Bayesian lens and show that Bayesian updating composes according to
the compositional lens pattern. Using Bayesian lenses, and inspired by
compositional game theory, we define fibrations of statistical games and
classify various problems of statistical inference as corresponding sections:
the chain rule of the relative entropy is formalized as a strict section, while
maximum likelihood estimation and the free energy give lax sections. In the
process, we introduce a new notion of `copy-composition'.
On the `semantic' side, we present a new formalization of general open
dynamical systems (particularly: deterministic, stochastic, and random; and
discrete- and continuous-time) as certain coalgebras of polynomial functors,
which we show collect into monoidal opindexed categories (or, alternatively,
into algebras for multicategories of generalized polynomial functors). We use
these opindexed categories to define monoidal bicategories of cilia: dynamical
systems which control lenses, and which supply the target for our functorial
semantics. Accordingly, we construct functors which explain the bidirectional
compositional structure of predictive coding neural circuits under the free
energy principle, thereby giving a formal mathematical underpinning to the
bidirectionality observed in the cortex. Along the way, we explain how to
compose rate-coded neural circuits using an algebra for a multicategory of
linear circuit diagrams, showing subsequently that this is subsumed by lenses
and polynomial functors.Comment: DPhil thesis; as submitted. Main change from v1: improved treatment
of statistical games. A number of errors also fixed, and some presentation
improved. Comments most welcom
- …