74 research outputs found
General Recursion via Coinductive Types
A fertile field of research in theoretical computer science investigates the
representation of general recursive functions in intensional type theories.
Among the most successful approaches are: the use of wellfounded relations,
implementation of operational semantics, formalization of domain theory, and
inductive definition of domain predicates. Here, a different solution is
proposed: exploiting coinductive types to model infinite computations. To every
type A we associate a type of partial elements Partial(A), coinductively
generated by two constructors: the first, return(a) just returns an element
a:A; the second, step(x), adds a computation step to a recursive element
x:Partial(A). We show how this simple device is sufficient to formalize all
recursive functions between two given types. It allows the definition of fixed
points of finitary, that is, continuous, operators. We will compare this
approach to different ones from the literature. Finally, we mention that the
formalization, with appropriate structural maps, defines a strong monad.Comment: 28 page
Termination Casts: A Flexible Approach to Termination with General Recursion
This paper proposes a type-and-effect system called Teqt, which distinguishes
terminating terms and total functions from possibly diverging terms and partial
functions, for a lambda calculus with general recursion and equality types. The
central idea is to include a primitive type-form "Terminates t", expressing
that term t is terminating; and then allow terms t to be coerced from possibly
diverging to total, using a proof of Terminates t. We call such coercions
termination casts, and show how to implement terminating recursion using them.
For the meta-theory of the system, we describe a translation from Teqt to a
logical theory of termination for general recursive, simply typed functions.
Every typing judgment of Teqt is translated to a theorem expressing the
appropriate termination property of the computational part of the Teqt term.Comment: In Proceedings PAR 2010, arXiv:1012.455
Recursive Definitions of Monadic Functions
Using standard domain-theoretic fixed-points, we present an approach for
defining recursive functions that are formulated in monadic style. The method
works both in the simple option monad and the state-exception monad of
Isabelle/HOL's imperative programming extension, which results in a convenient
definition principle for imperative programs, which were previously hard to
define.
For such monadic functions, the recursion equation can always be derived
without preconditions, even if the function is partial. The construction is
easy to automate, and convenient induction principles can be derived
automatically.Comment: In Proceedings PAR 2010, arXiv:1012.455
Step-Indexed Normalization for a Language with General Recursion
The Trellys project has produced several designs for practical dependently
typed languages. These languages are broken into two
fragments-a_logical_fragment where every term normalizes and which is
consistent when interpreted as a logic, and a_programmatic_fragment with
general recursion and other convenient but unsound features. In this paper, we
present a small example language in this style. Our design allows the
programmer to explicitly mention and pass information between the two
fragments. We show that this feature substantially complicates the metatheory
and present a new technique, combining the traditional Girard-Tait method with
step-indexed logical relations, which we use to show normalization for the
logical fragment.Comment: In Proceedings MSFP 2012, arXiv:1202.240
Normalization by Evaluation in the Delay Monad: A Case Study for Coinduction via Copatterns and Sized Types
In this paper, we present an Agda formalization of a normalizer for
simply-typed lambda terms. The normalizer consists of two coinductively defined
functions in the delay monad: One is a standard evaluator of lambda terms to
closures, the other a type-directed reifier from values to eta-long beta-normal
forms. Their composition, normalization-by-evaluation, is shown to be a total
function a posteriori, using a standard logical-relations argument.
The successful formalization serves as a proof-of-concept for coinductive
programming and reasoning using sized types and copatterns, a new and presently
experimental feature of Agda.Comment: In Proceedings MSFP 2014, arXiv:1406.153
Coinductive Big-Step Semantics for Concurrency
In a paper presented at SOS 2010, we developed a framework for big-step
semantics for interactive input-output in combination with divergence, based on
coinductive and mixed inductive-coinductive notions of resumptions, evaluation
and termination-sensitive weak bisimilarity. In contrast to standard
inductively defined big-step semantics, this framework handles divergence
properly; in particular, runs that produce some observable effects and then
diverge, are not "lost". Here we scale this approach for shared-variable
concurrency on a simple example language. We develop the metatheory of our
semantics in a constructive logic.Comment: In Proceedings PLACES 2013, arXiv:1312.221
Beating the Productivity Checker Using Embedded Languages
Some total languages, like Agda and Coq, allow the use of guarded corecursion
to construct infinite values and proofs. Guarded corecursion is a form of
recursion in which arbitrary recursive calls are allowed, as long as they are
guarded by a coinductive constructor. Guardedness ensures that programs are
productive, i.e. that every finite prefix of an infinite value can be computed
in finite time. However, many productive programs are not guarded, and it can
be nontrivial to put them in guarded form.
This paper gives a method for turning a productive program into a guarded
program. The method amounts to defining a problem-specific language as a data
type, writing the program in the problem-specific language, and writing a
guarded interpreter for this language.Comment: In Proceedings PAR 2010, arXiv:1012.455
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
Inductive and Coinductive Components of Corecursive Functions in Coq
In Constructive Type Theory, recursive and corecursive definitions are
subject to syntactic restrictions which guarantee termination for recursive
functions and productivity for corecursive functions. However, many terminating
and productive functions do not pass the syntactic tests. Bove proposed in her
thesis an elegant reformulation of the method of accessibility predicates that
widens the range of terminative recursive functions formalisable in
Constructive Type Theory. In this paper, we pursue the same goal for productive
corecursive functions. Notably, our method of formalisation of coinductive
definitions of productive functions in Coq requires not only the use of ad-hoc
predicates, but also a systematic algorithm that separates the inductive and
coinductive parts of functions.Comment: Dans Coalgebraic Methods in Computer Science (2008
Resumptions, Weak Bisimilarity and Big-Step Semantics for While with Interactive I/O: An Exercise in Mixed Induction-Coinduction
We look at the operational semantics of languages with interactive I/O
through the glasses of constructive type theory. Following on from our earlier
work on coinductive trace-based semantics for While, we define several big-step
semantics for While with interactive I/O, based on resumptions and
termination-sensitive weak bisimilarity. These require nesting inductive
definitions in coinductive definitions, which is interesting both
mathematically and from the point-of-view of implementation in a proof
assistant.
After first defining a basic semantics of statements in terms of resumptions
with explicit internal actions (delays), we introduce a semantics in terms of
delay-free resumptions that essentially removes finite sequences of delays on
the fly from those resumptions that are responsive. Finally, we also look at a
semantics in terms of delay-free resumptions supplemented with a silent
divergence option. This semantics hinges on decisions between convergence and
divergence and is only equivalent to the basic one classically.
We have fully formalized our development in Coq.Comment: In Proceedings SOS 2010, arXiv:1008.190
- …