ABSTRACT
Indexed data types allow us to specify and verify many interesting invariants about finite data in a general purpose programming language. In this paper we investigate the dual idea: indexed codata types, which allow us to describe data-dependencies about infinite data structures. Unlike finite data which is defined by constructors, we define infinite data by observations. Dual to pattern matching on indexed data which may refine the type indices, we define copattern matching on indexed codata where type indices guard observations we can make.
Our key technical contributions are three-fold: first, we extend Levy's call-by-push value language with support for indexed (co)data and deep (co)pattern matching; second, we provide a clean foundation for dependent (co)pattern matching using equality constraints; third, we describe a small-step semantics using a continuation-based abstract machine, define coverage for indexed (co)patterns, and prove type safety. This is an important step towards building a foundation where (co)data type definitions and dependent types can coexist.
- A. Abel and B. Pientka. Well-founded recursion with copatterns:a unified approach to termination and productivity. In 18th ACM International Conference on Functional Programming (ICFP ’13), pages 185–196. ACM Press, 2013. Google ScholarDigital Library
- A. Abel, B. Pientka, D. Thibodeau, and A. Setzer. Copatterns: Programming infinite structures by observations. In 40th ACM Symp. on Principles of Programming Languages (POPL’13), pages 27–38. ACM Press, 2013. Google ScholarDigital Library
- Agda team. The Agda Wiki, 2014.Google Scholar
- D. Baelde. Least and greatest fixed points in linear logic. ACM Transactions on Computational Logic, 13(1):2:1–2:44, 2012. Google ScholarDigital Library
- D. Baelde, Z. Snow, and D. Miller. Focused inductive theorem proving. In J. Giesl and R. Haehnle, editors, 5th International Joint Conference on Automated Reasoning (IJCAR’10), Lecture Notes in Artificial Intelligence (LNAI 6173), pages 278–292. Springer, 2010. Google ScholarDigital Library
- D. Baelde, K. Chaudhuri, A. Gacek, D. Miller, G. Nadathur, A. Tiu, and Y. Wang. Abella: A system for reasoning about relational specifications. Journal of Formalized Reasoning, 7(2):1–89, 2014.Google Scholar
- G. Betarte. Dependent Record Types and Formal Abstract Reasoning: Theory and practice. PhD thesis, Department of Computing Science, Chalmers University of Technology and University of Göteborg, 1998.Google Scholar
- E. Brady, C. McBride, and J. McKinna. Inductive families need not store their indices. In Types for Proofs and Programs (TYPES’03), Revised Selected Papers, Lecture Notes in Computer Science (LNCS 3085), pages 115–129, 2004.Google Scholar
- A. Cave and B. Pientka. Programming with binders and indexed datatypes. In 39th ACM Symposium on Principles of Programming Languages (POPL’12), pages 413–424. ACM Press, 2012. Google ScholarDigital Library
- J. Cheney and R. Hinze. First-class phantom types. Technical Report CUCIS TR2003-1901, Cornell University, 2003.Google Scholar
- R. Cockett and T. Fukushima. About charity. Technical report, Department of Computer Science, The University of Calgary, June 1992. Yellow Series Report No. 92/480/18. R. DeLine and M. Fähndrich. Typestates for objects. In 18th European Conference on Object-Oriented Programming (ECOOP 2004), Lecture Notes in Computer Science (LNCS 3086), pages 465–490. Springer, 2004.Google Scholar
- H. Goguen, C. McBride, and J. McKinna. Eliminating dependent pattern matching. In K. Futatsugi, J.-P. Jouannaud, and J. Meseguer, editors, Algebra, Meaning, and Computation, Essays Dedicated to Joseph A. Goguen on the Occasion of His 65th Birthday, Lecture Notes in Computer Science (LNCS 4060), pages 521–540. Springer, 2006.Google Scholar
- T. Hagino. A typed lambda calculus with categorical type constructors. In D. H. Pitt, A. Poigné, and D. E. Rydeheard, editors, Category Theory and Computer Science, Lecture Notes in Computer Science (LNCS 283), pages 140–157. Springer, 1987. Google ScholarDigital Library
- P. Hancock and A. Setzer. Interactive programs and weakly final coalgebras in dependent type theory. In L. Crosilla and P. Schuster, editors, From Sets and Types to Topology and Analysis. Towards Practicable Foundations for Constructive Mathematics, pages 115 – 134, Oxford, 2005. Clarendon Press.Google Scholar
- R. Harper, F. Honsell, and G. Plotkin. A framework for defining logics. Journal of the ACM, 40(1):143–184, January 1993. Google ScholarDigital Library
- N. R. Krishnaswami. Focusing on pattern matching. In 36th Annual ACM Symposium on Principles of Programming Languages (POPL’09), pages 366–378. ACM Press, 2009. Google ScholarDigital Library
- P. B. Levy. Call-by-push-value. PhD thesis, Queen Mary and Westfield College, University of London, 2001.Google Scholar
- D. R. Licata, N. Zeilberger, and R. Harper. Focusing on binding and computation. In F. Pfenning, editor, 23rd Symposium on Logic in Computer Science, pages 241–252. IEEE Computer Society Press, 2008. Google ScholarDigital Library
- C. McBride. Let’s see how things unfold: Reconciling the infinite with the intensional. In A. Kurz, M. Lenisa, and A. Tarlecki, editors, 3rd Int. Conf. on Algebra and Coalgebra in Computer Science (CALCO’09), Lecture Notes in Computer Science (LNCS 5728), pages 113–126. Springer, 2009. Google ScholarDigital Library
- R. Milner and M. Tofte. Co-induction in relational semantics. Theoretical Computer Science, 87(1):209 – 220, 1991. Google ScholarDigital Library
- U. Norell. Towards a practical programming language based on dependent type theory. PhD thesis, Department of Computer Science and Engineering, Chalmers University of Technology, Sept. 2007. Technical Report 33D. B. Pientka and J. Dunfield. Programming with proofs and explicit contexts. In ACM Symposium on Principles and Practice of Declarative Programming (PPDP’08), pages 163–173. ACM Press, 2008. Google ScholarDigital Library
- D. Thibodeau, A. Cave, and B. Pientka. Indexed codata (extended version). Technical report, School of Computer Science, McGill University, July 2016. Techincal Report. C. Tuckey. Pattern matching in Charity. Master’s thesis, The University of Calgary, July 1997.Google Scholar
- H. Xi. Applied type system. In Types for Proofs and Programs (TYPES’03), Revised Selected Papers, Lecture Notes in Computer Science (LNCS 3085), pages 394–408. Springer, 2004.Google Scholar
- H. Xi and F. Pfenning. Dependent types in practical programming. In 26th ACM Symposium on Principles of Programming Languages (POPL’99), pages 214–227. ACM Press, 1999. Google ScholarDigital Library
- H. Xi, C. Chen, and G. Chen. Guarded recursive datatype constructors. In 30th ACM Symposium on Principles of Programming Languages (POPL’03), pages 224–235. ACM Press, 2003.. N. Zeilberger. On the unity of duality. Annals of Pure and Applied Logic, 153(1-3):66–96, 2008a. N. Zeilberger. Focusing and higher-order abstract syntax. In 35th Annual ACM Symposium on Principles of Programming Languages (POPL’08), pages 359–369. ACM Press, 2008b. C. Zenger. Indexed types. Theoretical Computer Science, 187(1-2):147–165, 1997. Google ScholarDigital Library
Index Terms
- Indexed codata types
Recommendations
Copatterns: programming infinite structures by observations
POPL '13Inductive datatypes provide mechanisms to define finite data such as finite lists and trees via constructors and allow programmers to analyze and manipulate finite data via pattern matching. In this paper, we develop a dual approach for working with ...
Indexed codata types
ICFP '16Indexed data types allow us to specify and verify many interesting invariants about finite data in a general purpose programming language. In this paper we investigate the dual idea: indexed codata types, which allow us to describe data-dependencies ...
Programming with binders and indexed data-types
POPL '12: Proceedings of the 39th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languagesWe show how to combine a general purpose type system for an existing language with support for programming with binders and contexts by refining the type system of ML with a restricted form of dependent types where index objects are drawn from ...
Comments