Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/1292597.1292606acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
Article

Pattern matching coverage checking with dependent types using set approximations

Published: 02 October 2007 Publication History

Abstract

Definition of functions by pattern matching has proved to be a key feature of functional programming languages. These definitions allow a clear, easy to read, concise expression of functions. Proof assistants - like the the Coq proof assistant - and some programming languages - like the Epigram or Agda systems - introduce types that can depend on values. These dependent types allow to refine the definition of a type by the use of values. This results in a more precise specification of data types and functions. For example, it is possible, in such a system, to define the type of the lists of a given length n. The user can then express the fact that the head function - computing the first element of a list - can only be applied to non empty lists. This refinement reduces the number of run times error and allows to integrate program design and program verification.In presence of dependent types, some cases in a definition by pattern matching can become useless. For example, the case of the empty list is useless in the definition of the function head: the type of this function is specified to prevent the user to apply it to an empty list. For the sake of clarity and expressivity, we do not want the user to have to handle these useless cases. Especially, if the user is using dependent types for programming, handling such useless cases breaks, by introducing pieces of proof, the natural flow of the program. But forgetting a useful case can break the consistency of the system. This creates the need for a method to safely detect and remove useless cases in a definition by pattern matching.Alas, this problem - even restricted to algebraic data types - is undecidable in presence of dependent types. We introduce a new method to detect useless cases based on the computation of over-approximations of the inhabitants of inductive data types and contexts. Not only, this method is proved correct but can also produce - in a systematic way - a complete matching in Coq, ensuring that the logical power of the sysem remains unchanged. Moreover, it is modular over the kind of approximated sets used. We give two example implementations of such approximated sets: one is based on truncated terms, the other one on relations linking the number of occurrences of each constructor.

References

[1]
Agda The Agda programming language. http://www.cs.chalmers.se/~catarina/agda/
[2]
Alfa ALFA. The Alfa proof editor. http://www.cs.chalmers.se/~hallgren/Alfa/
[3]
Cayenne Lennart Augustsson. Cayenne - Hotter than Haskell, 1999.http://www.cs.chalmers.se/~augustss/cayenne/
[4]
PatternMatchingCompilation Lennart Augustsson. Compiling pattern matching. Proc. of a conference on Functional programming languages and computer architecture, pages 368--381, New York, NY, USA, 1985. Springer-Verlag New York, Inc. ISBN 3-387-15975-4.
[5]
Marc Bezem and Jan Springintveld. A simple proof of the undecidability of inhabitation in lambda. J. Funct. Program., 6 (5): 757--761, 1996.
[6]
Coq. The Coq proof assistant. http://coq.inria.fr
[7]
TCoquand. Pattern matching with dependent types, 1992. Proceedings of the Workshop on Logical Frameworks.
[8]
Patrick Cousot and Radhia Cousot. Static determination of dynamic properties pf programs. In Dunod, editor, Proceedings of the 2nd International Symposium on Programming, pages 106--130, 1976.
[9]
Epigram, making dependent types matter. http://www.e-pig.org
[10]
Haskell. Haskell, a Purely Functional Language. http://www.haskell.org
[11]
The {LEGO} proof assistant. http://www.dcs.ed.ac.uk/home/lego/
[12]
Conor McBride and James McKinna. The view from the left. J. Funct. Program., 14(1): 69--111, 2004. ISSN 0956--7968.
[13]
R. Milner. A theory of type polymorphismn programming. Journal of Computer and System Sciences, 17, 1978.
[14]
The Ocaml Language. http://www.ocaml.org.
[15]
Nicolas Oury. Egalites et filtrages avec types dependants dans le Calcul des Constructions Inductives. PhD thesis, Universite Paris-Sud, September 2006. http://www.lri.fr/~noury/
[16]
New Polka. http://www.irisa.fr/prive/bjeannet/newpolka.html.
[17]
Emil~L. Post. A variant of a recursively unsolvable problem. Bulletin of the American Mathematical Society, 52, 1946.
[18]
CSchurmann and FPfenning. A coverage checking algorithm for LF. In Proceedings of the 16th International Conference on Theorem Proving in Higher Order Logics (TPHOLs 2003), 2003.
[19]
The Coq Development Team. The Coq proof assistant reference manual-chapter 4. Technical Report 0255, INRIA, Fevrier 2002.
[20]
The Twelf project. http://www.cs.cmu.edu/~twelf/.
[21]
Daria Walukiewicz-Chrzaszcz and Jacek Chrzaszcz. Consistency and completeness of rewriting in the calculus of constructions. In Proceedings of IJCAR 2006, 2006.
[22]
Hongwei. Xi. Dependently typed pattern matching, 2003. citeseer.ist.psu.edu/xi03dependently.html.
[23]
Hongwei Xi. Dependent Types in Practical Programming. PhD thesis, Carnegie Mellon University, December 1998.

Cited By

View all
  • (2020)Lower your guards: a compositional pattern-match coverage checkerProceedings of the ACM on Programming Languages10.1145/34089894:ICFP(1-30)Online publication date: 3-Aug-2020
  • (2020)Elaborating dependent (co)pattern matching: No pattern left behindJournal of Functional Programming10.1017/S095679681900018230Online publication date: 21-Jan-2020
  • (2018)Elaborating dependent (co)pattern matchingProceedings of the ACM on Programming Languages10.1145/32367702:ICFP(1-30)Online publication date: 30-Jul-2018
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
PLPV '07: Proceedings of the 2007 workshop on Programming languages meets program verification
October 2007
76 pages
ISBN:9781595936776
DOI:10.1145/1292597
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 02 October 2007

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. coverage checking
  2. pattern matching
  3. set approximation

Qualifiers

  • Article

Conference

ICFP07
Sponsor:

Acceptance Rates

PLPV '07 Paper Acceptance Rate 6 of 8 submissions, 75%;
Overall Acceptance Rate 18 of 25 submissions, 72%

Upcoming Conference

POPL '25

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)2
  • Downloads (Last 6 weeks)0
Reflects downloads up to 16 Oct 2024

Other Metrics

Citations

Cited By

View all
  • (2020)Lower your guards: a compositional pattern-match coverage checkerProceedings of the ACM on Programming Languages10.1145/34089894:ICFP(1-30)Online publication date: 3-Aug-2020
  • (2020)Elaborating dependent (co)pattern matching: No pattern left behindJournal of Functional Programming10.1017/S095679681900018230Online publication date: 21-Jan-2020
  • (2018)Elaborating dependent (co)pattern matchingProceedings of the ACM on Programming Languages10.1145/32367702:ICFP(1-30)Online publication date: 30-Jul-2018
  • (2017)GADTs and Exhaustiveness: Looking for the ImpossibleElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.241.2241(23-35)Online publication date: 7-Feb-2017
  • (2009)A New Elimination Rule for the Calculus of Inductive ConstructionsTypes for Proofs and Programs10.1007/978-3-642-02444-3_3(32-48)Online publication date: 7-Jun-2009

View Options

Get Access

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media