73 research outputs found
Forty hours of declarative programming: Teaching Prolog at the Junior College Utrecht
This paper documents our experience using declarative languages to give
secondary school students a first taste of Computer Science. The course aims to
teach students a bit about programming in Prolog, but also exposes them to
important Computer Science concepts, such as unification or searching
strategies. Using Haskell's Snap Framework in combination with our own
NanoProlog library, we have developed a web application to teach this course.Comment: In Proceedings TFPIE 2012, arXiv:1301.465
A correct-by-construction conversion from lambda calculus to combinatory logic
This pearl defines a translation from well-typed lambda terms to combinatory logic, where both the preservation of types and the correctness of the translation are enforced statically
A functional specification of effects
This dissertation is about effects and type theory.
Functional programming languages such as Haskell illustrate how to encapsulate side effects using monads. Haskell compilers provide a handful of primitive effectful functions. Programmers can construct larger computations using the monadic return and bind operations.
These primitive effectful functions, however, have no associated deļ¬nition. At best, their semantics are speciļ¬ed separately on paper. This can make it difļ¬cult to test, debug, verify, or even predict the behaviour of effectful computations.
This dissertation provides pure, functional speciļ¬cations in Haskell of several different effects. Using these speciļ¬cations, programmers can test and debug effectful programs. This is particularly useful in tandem with automatic testing tools such as QuickCheck.
The speciļ¬cations in Haskell are not total. This makes them unsuitable for the formal veriļ¬cation of effectful functions. This dissertation overcomes this limitation, by presenting total functional speciļ¬cations in Agda, a programming language with dependent types.
There have been alternative approaches to incorporating effects in a dependently typed programming language. Most notably, recent work on Hoare Type Theory proposes to extend type theory with axioms that postulate the existence of primitive effectful functions. This dissertation shows how the functional speciļ¬cations implement these axioms, unifying the two approaches.
The results presented in this dissertation may be used to write and verify effectful programs in the framework of type theory
A functional specification of effects
This dissertation is about effects and type theory.
Functional programming languages such as Haskell illustrate how to encapsulate side effects using monads. Haskell compilers provide a handful of primitive effectful functions. Programmers can construct larger computations using the monadic return and bind operations.
These primitive effectful functions, however, have no associated deļ¬nition. At best, their semantics are speciļ¬ed separately on paper. This can make it difļ¬cult to test, debug, verify, or even predict the behaviour of effectful computations.
This dissertation provides pure, functional speciļ¬cations in Haskell of several different effects. Using these speciļ¬cations, programmers can test and debug effectful programs. This is particularly useful in tandem with automatic testing tools such as QuickCheck.
The speciļ¬cations in Haskell are not total. This makes them unsuitable for the formal veriļ¬cation of effectful functions. This dissertation overcomes this limitation, by presenting total functional speciļ¬cations in Agda, a programming language with dependent types.
There have been alternative approaches to incorporating effects in a dependently typed programming language. Most notably, recent work on Hoare Type Theory proposes to extend type theory with axioms that postulate the existence of primitive effectful functions. This dissertation shows how the functional speciļ¬cations implement these axioms, unifying the two approaches.
The results presented in this dissertation may be used to write and verify effectful programs in the framework of type theory
A completely unique account of enumeration
How can we enumerate the inhabitants of an algebraic datatype? This paper explores a datatype generic solution that works for all regular types and indexed families. The enumerators presented here are provably both complete and uniqueāthey will eventually produce every value exactly onceāand fairāthey avoid bias when composing enumerators. Finally, these enumerators memoise previously enumerated values whenever possible, thereby avoiding repeatedly recomputing recursive results
FP2: Fully in-Place Functional Programming
As functional programmers we always face a dilemma: should we write purely functional code, or sacrifice purity for efficiency and resort to in-place updates? This paper identifies precisely when we can have the best of both worlds: a wide class of purely functional programs can be executed safely using in-place updates without requiring allocation, provided their arguments are not shared elsewhere. We describe a linear fully in-place (FIP) calculus where we prove that we can always execute such functions in a way that requires no (de)allocation and uses constant stack space. Of course, such a calculus is only relevant if we can express interesting algorithms; we provide numerous examples of in-place functions on datastructures such as splay trees or finger trees, together with in-place versions of merge sort and quick sort. We also show how we can generically derive a map function over any polynomial data type that is fully in-place. Finally, we have implemented the rules of the FIP calculus in the Koka language. Using the Perceus reference counting garbage collection, this implementation dynamically executes FIP functions in-place whenever possibl
Translation certification for smart contracts
Compiler correctness is an old problem, but with the emergence of smart contracts on blockchains that problem presents itself in a new light. Smart contracts are self-contained pieces of software that control (valuable) assets in an adversarial environment; once committed to the blockchain, these smart contracts cannot be modified. Smart contracts are typically developed in a high-level contract language and compiled to low-level virtual machine code before being committed to the blockchain. For a smart contract user to trust a given piece of low-level code on the blockchain, they must convince themselves that (a) they are in possession of the matching source code and (b) that the compiler has correctly translated the source code to the given low-level code. Classic approaches to compiler correctness tackle the second point. We argue that translation certification also squarely addresses the first. We describe the proof architecture of a translation certification framework and demonstrate how we can model the compilation pipeline as a sequence of translation relations. We give a detailed account of such relations for most passes of the Plutus Tx compiler, which we formalised in Coq. This approach facilitates a modular verification methodology and is robust in the face of an evolving compiler implementation
A Hoare logic for the state monad: Proof pearl
This pearl examines how to verify functional programs written using the state monad. It uses Coq\u27s Program framework to provide strong specifications for the standard operations that the state monad supports, such as return and bind. By exploiting the monadic structure of such programs during the verification process, it becomes easier to prove that they satisfy their specification
- ā¦