444 research outputs found
Extensional equality preservation and verified generic programming
In verified generic programming, one cannot exploit the structure of concrete
data types but has to rely on well chosen sets of specifications or abstract
data types (ADTs). Functors and monads are at the core of many applications of
functional programming. This raises the question of what useful ADTs for
verified functors and monads could look like. The functorial map of many
important monads preserves extensional equality. For instance, if are extensionally equal, that is, , then and are also
extensionally equal. This suggests that preservation of extensional equality
could be a useful principle in verified generic programming. We explore this
possibility with a minimalist approach: we deal with (the lack of) extensional
equality in Martin-L\"of's intensional type theories without extending the
theories or using full-fledged setoids. Perhaps surprisingly, this minimal
approach turns out to be extremely useful. It allows one to derive simple
generic proofs of monadic laws but also verified, generic results in dynamical
systems and control theory. In turn, these results avoid tedious code
duplication and ad-hoc proofs. Thus, our work is a contribution towards
pragmatic, verified generic programming.Comment: Manuscript ID: JFP-2020-003
On the correctness of monadic backward induction
In control theory, to solve a finite-horizon sequential decision problem (SDP) commonly means to find a list of decision rules that result in an optimal expected total reward (or cost) when taking a given number of decision steps. SDPs are routinely solved using Bellman\u27s backward induction. Textbook authors (e.g. Bertsekas or Puterman) typically give more or less formal proofs to show that the backward induction algorithm is correct as solution method for deterministic and stochastic SDPs. Botta, Jansson and Ionescu propose a generic framework for finite horizon, monadic SDPs together with a monadic version of backward induction for solving such SDPs. In monadic SDPs, the monad captures a generic notion of uncertainty, while a generic measure function aggregates rewards. In the present paper, we define a notion of correctness for monadic SDPs and identify three conditions that allow us to prove a correctness result for monadic backward induction that is comparable to textbook correctness proofs for ordinary backward induction. The conditions that we impose are fairly general and can be cast in category-theoretical terms using the notion of Eilenberg-Moore algebra. They hold in familiar settings like those of deterministic or stochastic SDPs, but we also give examples in which they fail. Our results show that backward induction can safely be employed for a broader class of SDPs than usually treated in textbooks. However, they also rule out certain instances that were considered admissible in the context of Botta et al. \u27s generic framework. Our development is formalised in Idris as an extension of the Botta et al. framework and the sources are available as supplementary material
Semantic verification of dynamic programming
We prove that the generic framework for specifying and solving
finite-horizon, monadic sequential decision problems proposed in (Botta et
al.,2017) is semantically correct. By semantically correct we mean that, for a
problem specification and for any initial state compatible with ,
the verified optimal policies obtained with the framework maximize the
-measure of the -sums of the -rewards along all the possible
trajectories rooted in . In short, we prove that, given , the verified
computations encoded in the framework are the correct computations to do. The
main theorem is formulated as an equivalence between two value functions: the
first lies at the core of dynamic programming as originally formulated in
(Bellman,1957) and formalized by Botta et al. in Idris (Brady,2017), and the
second is a specification. The equivalence requires the two value functions to
be extensionally equal. Further, we identify and discuss three requirements
that measures of uncertainty have to fulfill for the main theorem to hold.
These turn out to be rather natural conditions that the expected-value measure
of stochastic uncertainty fulfills. The formal proof of the main theorem
crucially relies on a principle of preservation of extensional equality for
functors. We formulate and prove the semantic correctness of dynamic
programming as an extension of the Botta et al. Idris framework. However, the
theory can easily be implemented in Coq or Agda.Comment: Manuscript ID: JFP-2020-003
Datalog with Negation and Monotonicity
Positive Datalog has several nice properties that are lost when the language is extended with negation. One example is that fixpoints of positive Datalog programs are robust w.r.t. the order in which facts are inserted, which facilitates efficient evaluation of such programs in distributed environments. A natural question to ask, given a (stratified) Datalog program with negation, is whether an equivalent positive Datalog program exists.
In this context, it is known that positive Datalog can express only a strict subset of the monotone queries, yet the exact relationship between the positive and monotone fragments of semi-positive and stratified Datalog was previously left open. In this paper, we complete the picture by showing that monotone queries expressible in semi-positive Datalog exist which are not expressible in positive Datalog. To provide additional insight into this gap, we also characterize a large class of semi-positive Datalog programs for which the dichotomy `monotone if and only if rewritable to positive Datalog\u27 holds. Finally, we give best-effort techniques to reduce the amount of negation that is exhibited by a program, even if the program is not monotone
Programs as Data Structures in λSF-Calculus
© 2016 The Author(s) Lambda-SF-calculus can represent programs as closed normal forms. In turn, all closed normal forms are data structures, in the sense that their internal structure is accessible through queries defined in the calculus, even to the point of constructing the Goedel number of a program. Thus, program analysis and optimisation can be performed entirely within the calculus, without requiring any meta-level process of quotation to produce a data structure. Lambda-SF-calculus is a confluent, applicative rewriting system derived from lambda-calculus, and the combinatory SF-calculus. Its superior expressive power relative to lambda-calculus is demonstrated by the ability to decide if two programs are syntactically equal, or to determine if a program uses its input. Indeed, there is no homomorphism of applicative rewriting systems from lambda-SF-calculus to lambda-calculus. Program analysis and optimisation can be illustrated by considering the conversion of a programs to combinators. Traditionally, a program p is interpreted using fixpoint constructions that do not have normal forms, but combinatory techniques can be used to block reduction until the program arguments are given. That is, p is interpreted by a closed normal form M. Then factorisation (by F) adapts the traditional account of lambda-abstraction in combinatory logic to convert M to a combinator N that is equivalent to M in the following two senses. First, N is extensionally equivalent to M where extensional equivalence is defined in terms of eta-reduction. Second, the conversion is an intensional equivalence in that it does not lose any information, and so can be reversed by another definable conversion. Further, the standard optimisations of the conversion process are all definable within lambda-SF-calculus, even those involving free variable analysis. Proofs of all theorems in the paper have been verified using the Coq theorem prover
αCheck: a mechanized metatheory model-checker
The problem of mechanically formalizing and proving metatheoretic properties
of programming language calculi, type systems, operational semantics, and
related formal systems has received considerable attention recently. However,
the dual problem of searching for errors in such formalizations has attracted
comparatively little attention. In this article, we present Check, a
bounded model-checker for metatheoretic properties of formal systems specified
using nominal logic. In contrast to the current state of the art for metatheory
verification, our approach is fully automatic, does not require expertise in
theorem proving on the part of the user, and produces counterexamples in the
case that a flaw is detected. We present two implementations of this technique,
one based on negation-as-failure and one based on negation elimination, along
with experimental results showing that these techniques are fast enough to be
used interactively to debug systems as they are developed.Comment: Under consideration for publication in Theory and Practice of Logic
Programming (TPLP
Types, equations, dimensions and the Pi theorem
The languages of mathematical physics and modelling are endowed with a rich
"grammar of dimensions" that common abstractions of programming languages fail
to represent. We propose a dependently typed domain-specific language (embedded
in Idris) that captures this grammar. We apply it to explain basic notions of
dimensional analysis and Buckingham's Pi theorem. We hope that the language
makes mathematical physics more accessible to computer scientists and
functional programming more palatable to modelers and physicists.Comment: Submitted for publication in the "Journal of Functional Programming"
in August 202
On the Semantics of Intensionality and Intensional Recursion
Intensionality is a phenomenon that occurs in logic and computation. In the
most general sense, a function is intensional if it operates at a level finer
than (extensional) equality. This is a familiar setting for computer
scientists, who often study different programs or processes that are
interchangeable, i.e. extensionally equal, even though they are not implemented
in the same way, so intensionally distinct. Concomitant with intensionality is
the phenomenon of intensional recursion, which refers to the ability of a
program to have access to its own code. In computability theory, intensional
recursion is enabled by Kleene's Second Recursion Theorem. This thesis is
concerned with the crafting of a logical toolkit through which these phenomena
can be studied. Our main contribution is a framework in which mathematical and
computational constructions can be considered either extensionally, i.e. as
abstract values, or intensionally, i.e. as fine-grained descriptions of their
construction. Once this is achieved, it may be used to analyse intensional
recursion.Comment: DPhil thesis, Department of Computer Science & St John's College,
University of Oxfor
- …