2,622 research outputs found
A Monadic, Functional Implementation of Real Numbers
Large scale real number computation is an essential ingredient in several
modern mathematical proofs. Because such lengthy computations cannot be
verified by hand, some mathematicians want to use software proof assistants to
verify the correctness of these proofs. This paper develops a new
implementation of the constructive real numbers and elementary functions for
such proofs by using the monad properties of the completion operation on metric
spaces. Bishop and Bridges's notion of regular sequences is generalized to,
what I call, regular functions which form the completion of any metric space.
Using the monad operations, continuous functions on length spaces (a common
subclass of metric spaces) are created by lifting continuous functions on the
original space. A prototype Haskell implementation has been created. I believe
that this approach yields a real number library that is reasonably efficient
for computation, and still simple enough to easily verify its correctness.Comment: This paper is to appear in an upcoming issue of Mathematical
Structures in Computer Science published by Cambridge University Press. For
more information and the latest source code for Few Digits, see
<http://r6.ca/FewDigits/
Memoizing a monadic mixin DSL
Modular extensibility is a highly desirable property of a domain-specific language (DSL): the ability to add new features without affecting the implementation of existing features. Functional mixins (also known as open recursion) are very suitable for this purpose.
We study the use of mixins in Haskell for a modular DSL for search heuristics used in systematic solvers for combinatorial problems, that generate optimized C++ code from a high-level specification. We show how to apply memoization techniques to tackle performance issues and code explosion due to the high recursion inherent to the semantics of combinatorial search.
As such heuristics are conventionally implemented as highly entangled imperative algorithms, our Haskell mixins are monadic. Memoization of monadic components causes further complications for us to deal with
Gradual Certified Programming in Coq
Expressive static typing disciplines are a powerful way to achieve
high-quality software. However, the adoption cost of such techniques should not
be under-estimated. Just like gradual typing allows for a smooth transition
from dynamically-typed to statically-typed programs, it seems desirable to
support a gradual path to certified programming. We explore gradual certified
programming in Coq, providing the possibility to postpone the proofs of
selected properties, and to check "at runtime" whether the properties actually
hold. Casts can be integrated with the implicit coercion mechanism of Coq to
support implicit cast insertion a la gradual typing. Additionally, when
extracting Coq functions to mainstream languages, our encoding of casts
supports lifting assumed properties into runtime checks. Much to our surprise,
it is not necessary to extend Coq in any way to support gradual certified
programming. A simple mix of type classes and axioms makes it possible to bring
gradual certified programming to Coq in a straightforward manner.Comment: DLS'15 final version, Proceedings of the ACM Dynamic Languages
Symposium (DLS 2015
Tracing monadic computations and representing effects
In functional programming, monads are supposed to encapsulate computations,
effectfully producing the final result, but keeping to themselves the means of
acquiring it. For various reasons, we sometimes want to reveal the internals of
a computation. To make that possible, in this paper we introduce monad
transformers that add the ability to automatically accumulate observations
about the course of execution as an effect. We discover that if we treat the
resulting trace as the actual result of the computation, we can find new
functionality in existing monads, notably when working with non-terminating
computations.Comment: In Proceedings MSFP 2012, arXiv:1202.240
Generating reversible circuits from higher-order functional programs
Boolean reversible circuits are boolean circuits made of reversible
elementary gates. Despite their constrained form, they can simulate any boolean
function. The synthesis and validation of a reversible circuit simulating a
given function is a difficult problem. In 1973, Bennett proposed to generate
reversible circuits from traces of execution of Turing machines. In this paper,
we propose a novel presentation of this approach, adapted to higher-order
programs. Starting with a PCF-like language, we use a monadic representation of
the trace of execution to turn a regular boolean program into a
circuit-generating code. We show that a circuit traced out of a program
computes the same boolean function as the original program. This technique has
been successfully applied to generate large oracles with the quantum
programming language Quipper.Comment: 21 pages. A shorter preprint has been accepted for publication in the
Proceedings of Reversible Computation 2016. The final publication is
available at http://link.springer.co
How functional programming mattered
In 1989 when functional programming was still considered a niche topic, Hughes wrote a visionary paper arguing convincingly ‘why functional programming matters’. More than two decades have passed. Has functional programming really mattered? Our answer is a resounding ‘Yes!’. Functional programming is now at the forefront of a new generation of programming technologies, and enjoying increasing popularity and influence. In this paper, we review the impact of functional programming, focusing on how it has changed the way we may construct programs, the way we may verify programs, and fundamentally the way we may think about programs
Type Generic Observing
Observing intermediate values helps to understand what is going on when your program runs.
Gill presented an observation method for lazy functional languages that
preserves the program's semantics.
However, users need to define for each type how its values are observed:
a laborious task and strictness of the program can easily be affected.
Here we define how any value can be observed based on the structure of its type
by applying generic programming frameworks.
Furthermore we present an extension to specify per observation point how much to observe of a value.
We discuss especially functional values and behaviour based on class membership
in generic programming frameworks
- …