## Filters on coinductive streams, an application to eratosthenes’ sieve (2005)

Venue: | Typed Lambda Calculi and Applications, 7th International Conference, TLCA 2005 |

Citations: | 21 - 5 self |

### BibTeX

@INPROCEEDINGS{Bertot05filterson,

author = {Yves Bertot},

title = {Filters on coinductive streams, an application to eratosthenes’ sieve},

booktitle = {Typed Lambda Calculi and Applications, 7th International Conference, TLCA 2005},

year = {2005},

pages = {102--115},

publisher = {Springer-Verlag}

}

### Years of Citing Articles

### OpenURL

### Abstract

Our objective is to describe a formal proof of correctness for the following Haskell [13] program in a type theory-based proof verification system, such as the Coq system [10, 1]. sieve (p:rest) = p:sieve [r | r <- rest, r ‘rem ‘ p / = 0] primes = sieve [2..] This program is a functional implementation of Eratosthenes ’ sieve that consists in removing all multiples of previously found primes from the sequence of natural numbers. We want to prove that the expression primes is the stream containing all the prime numbers in increasing order. This work relies on co-inductive types [5, 11, 12] because the program manipulates infinite lists, also known as streams. It first uses the infinite list of natural numbers larger than 2, then the infinite list of numbers larger than 3 and containing no multiples of 2, then the infinite list of numbers larger than 4 and containing no multiples of prime numbers smaller than 4, and so on. This example was initially proposed as a challenge by G. Kahn and used as an illustration of a program and its proof of correctness in a

### Citations

571 | A transformation system for developing recursive programs
- Burstall, Darlington
- 1977
(Show Context)
Citation Context ...ed to represent False. The main difference is that the function is decomposed into two recursive functions. However, we maintain that this code is equivalent, up to the unfolding/folding technique of =-=[3]-=- to the initialfilter. filter_i p_dec s = case s of SCons x s’ -> (case p_dec x of Left -> Pair x s’ Right -> filter_i p_dec s’) filter p_dec s = case filter_i p_dec s of Pair a b -> SCons a (filter p... |

472 |
Interactive Theorem Proving and Program Development. Coq’Art: The Calculus of Inductive Constructions
- Bertot, Castéran
- 2004
(Show Context)
Citation Context ...Yves Bertot October 27, 2004 Our objective is to describe a formal proof of correctness for the following Haskell [13] program in a type theory-based proof verification system, such as the Coq system =-=[10, 1]-=-. sieve (p:rest) = p:sieve [r | r <- rest, r ‘rem‘ p /= 0] primes = sieve [2..] This program is a functional implementation of Eratosthenes’ sieve that consists in removing all multiples of previously... |

168 |
Coroutines and Networks of Parallel Processes
- Kahn, MacQueen
- 1977
(Show Context)
Citation Context ...numbers smaller than 4, and so on. This example was initially proposed as a challenge by G. Kahn and used as an illustration of a program and its proof of correctness in a language for co-routines in =-=[14]-=-. The exact formulation of the program given here was found in A. J. T. Davie’s book on functional programming [7], who describes it as a re-phrasing of an initial program implemented in SASL by D. Tu... |

163 | Inductive Definitions in the System Coq: Rules and Properties
- Paulin-Mohring
- 1993
(Show Context)
Citation Context ...d through one of the constructors. However, there is no obligation that the process of constructing a term in a co-inductive type should be a finite process as is usually the case for inductive types =-=[17, 11]-=-. For instance, we can work in a context where some typeAis declared and use the type of streams of elements ofA. In this paper, we later intantiateAwith the typenat of natural numbers. CoInductive st... |

84 | Infinite objects in type theory
- Coquand
- 1993
(Show Context)
Citation Context ...und primes from the sequence of natural numbers. We want to prove that the expression primes is the stream containing all the prime numbers in increasing order. This work relies on co-inductive types =-=[5, 11, 12]-=- because the program manipulates infinite lists, also known as streams. It first uses the infinite list of natural numbers larger than 2, then the infinite list of numbers larger than 3 and containing... |

70 |
Codifying guarded definitions with recursive schemes
- Giménez
- 1994
(Show Context)
Citation Context ...und primes from the sequence of natural numbers. We want to prove that the expression primes is the stream containing all the prime numbers in increasing order. This work relies on co-inductive types =-=[5, 11, 12]-=- because the program manipulates infinite lists, also known as streams. It first uses the infinite list of natural numbers larger than 2, then the infinite list of numbers larger than 3 and containing... |

65 | et al. Report on the Programming Language Haskell - Hudak, Jones, et al. - 1992 |

53 |
Synthesis of ML programs in system Coq
- Paulin-Mohring, Werner
- 1993
(Show Context)
Citation Context ...lemme/Yves.Bertot/filters.tar.gz 3.3 Code extraction Once the sieve function is defined in the calculus of constructions, we can map it back to Haskell code using the extraction facility described in =-=[16, 18]-=-. The code we obtain for thesieve function is close to the one we initially intended to certify, except that it uses a re-defined type of streams, instead of using the built-in type of lists from Hask... |

47 |
A New Extraction for Coq
- Letouzey
- 2003
(Show Context)
Citation Context ...lemme/Yves.Bertot/filters.tar.gz 3.3 Code extraction Once the sieve function is defined in the calculus of constructions, we can map it back to Haskell code using the extraction facility described in =-=[16, 18]-=-. The code we obtain for thesieve function is close to the one we initially intended to certify, except that it uses a re-defined type of streams, instead of using the built-in type of lists from Hask... |

42 |
An Introduction to Functional Programming Systems using Haskell
- Davie
- 1992
(Show Context)
Citation Context ...ustration of a program and its proof of correctness in a language for co-routines in [14]. The exact formulation of the program given here was found in A. J. T. Davie’s book on functional programming =-=[7]-=-, who describes it as a re-phrasing of an initial program implemented in SASL by D. Turner [19]. A proof of Eratosthenes’ sieve in type theory was already studied by F. Leclerc and C. PaulinMohring in... |

14 |
An application of co-inductive types in Coq: Verification of the alternating bit protocol
- Giménez
- 1996
(Show Context)
Citation Context ...und primes from the sequence of natural numbers. We want to prove that the expression primes is the stream containing all the prime numbers in increasing order. This work relies on co-inductive types =-=[5, 11, 12]-=- because the program manipulates infinite lists, also known as streams. It first uses the infinite list of natural numbers larger than 2, then the infinite list of numbers larger than 3 and containing... |

14 |
Programming with streams in Coq — a case study: the sieve of Eratosthenes
- Leclerc, Paulin-Mohring
- 1993
(Show Context)
Citation Context ...describes it as a re-phrasing of an initial program implemented in SASL by D. Turner [19]. A proof of Eratosthenes’ sieve in type theory was already studied by F. Leclerc and C. PaulinMohring in 1993 =-=[15]-=-, but their program has a different structure and does not exhibit the filter problem that is central here. Another program computing the stream of prime numbers is given as example in [8]. The techni... |

11 |
An axiomatization of linear temporal logic in the calculus of inductive constructions
- Coupet-Grimal
(Show Context)
Citation Context ...s must be “guardedby-constructors” [11]. In their usual form, filters do not respect this syntactic criterion. We propose to combine insights coming from reasoning techniques on linear temporal logic =-=[4, 6]-=- and on general recursion, essentially the techique advocated by A. Bove [2] in the context of Martin-Löf type theory. We transpose this technique to the Calculus of Inductive Constructions, the under... |

10 | Simple general recursion in type theory
- Bove
(Show Context)
Citation Context ...spect this syntactic criterion. We propose to combine insights coming from reasoning techniques on linear temporal logic [4, 6] and on general recursion, essentially the techique advocated by A. Bove =-=[2]-=- in the context of Martin-Löf type theory. We transpose this technique to the Calculus of Inductive Constructions, the underlying theory for the Coq system, with some added difficulties coming from th... |

7 |
Version 5.8
- Dowek, Felty, et al.
- 1993
(Show Context)
Citation Context ...Yves Bertot October 27, 2004 Our objective is to describe a formal proof of correctness for the following Haskell [13] program in a type theory-based proof verification system, such as the Coq system =-=[10, 1]-=-. sieve (p:rest) = p:sieve [r | r <- rest, r ‘rem‘ p /= 0] primes = sieve [2..] This program is a functional implementation of Eratosthenes’ sieve that consists in removing all multiples of previously... |

5 |
Reasoning about parametrized automata
- Castéran, Rouillard
- 2000
(Show Context)
Citation Context ...s must be “guardedby-constructors” [11]. In their usual form, filters do not respect this syntactic criterion. We propose to combine insights coming from reasoning techniques on linear temporal logic =-=[4, 6]-=- and on general recursion, essentially the techique advocated by A. Bove [2] in the context of Martin-Löf type theory. We transpose this technique to the Calculus of Inductive Constructions, the under... |