skip to main content
research-article

Functional pearl: every bit counts

Published:27 September 2010Publication History
Skip Abstract Section

Abstract

We show how the binary encoding and decoding of typed data and typed programs can be understood, programmed, and verified with the help of question-answer games. The encoding of a value is determined by the yes/no answers to a sequence of questions about that value; conversely, decoding is the interpretation of binary data as answers to the same question scheme.

We introduce a general framework for writing and verifying game-based codecs. We present games for structured, recursive, polymorphic, and indexed types, building up to a representation of well-typed terms in the simply-typed λ-calculus. The framework makes novel use of isomorphisms between types in the definition of games. The definition of isomorphisms together with additional simple properties make it easy to prove that codecs derived from games never encode two distinct values using the same code, never decode two codes to the same value, and interpret any bit sequence as a valid code for a value or as a prefix of a valid code.

Skip Supplemental Material Section

Supplemental Material

icfp-mon-1055-vytiniotis.mov

References

  1. }}Y. Bertot and P. Casteran. Interactive Theorem Proving and Program Development. Springer-Verlag, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. }}R. Bird and J. Gibbons. Arithmetic coding with folds and unfolds. In J. Jeuring and S. Peyton Jones, editors, Advanced Functional Programming 4, volume 2638 of Lecture Notes in Computer Science, pages 1--26. Springer-Verlag, 2003.Google ScholarGoogle Scholar
  3. }}J. Cheney. Statistical models for term compression. In DCC '00: Proceedings of the Conference on Data Compression, page 550, Washington, DC, USA, 2000. IEEE Computer Society. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. }}K. Claessen and J. Hughes. Quickcheck: a lightweight tool for random testing of Haskell programs. In ICFP '00: Proceedings of the fifth ACM SIGPLAN International Conference on Functional Programming, pages 268--279, New York, NY, USA, 2000. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. }}D. Coutts, R. Leshchinskiy, and D. Stewart. Stream fusion: from lists to streams to nothing at all. In ICFP '07: Proceedings of the 12th ACM SIGPLAN International Conference on Functional Programming, pages 315--326, New York, NY, USA, 2007. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. }}J. Duan, J. Hurd, G. Li, S. Owens, K. Slind, and J. Zhang. Functional correctness proofs of encryption algorithms. In Logic for Programming, Artificial Intelligence and Reasoning (LPAR), volume 3835 of LNCS, pages 519--533. Springer, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. }}ECMA. Standard {ECMA-335}: Common language infrastructure (CLI), 2006.Google ScholarGoogle Scholar
  8. }}P. Elias. Universal codeword sets and representations of the integers. IEEE Transactions on Information Theory, 21(2):197--203, 1975.Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. }}K. Fisher, Y. Mandelbaum, and D. Walker. The next 700 data description languages. SIGPLAN Not., 41(1):2--15, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. }}M. Franz, V. Haldar, C. Krintz, and C. H. Stork. Tamper-proof annotations by construction. Technical Report 02-10, Dept of Information and Computer Science, University of California, Irvine, March 2002.Google ScholarGoogle Scholar
  11. }}N. Ghani, P. Hancock, and D. Pattinson. Representations of stream processors using nested fixed points. Logical Methods in Computer Science, 5(3), 2009.Google ScholarGoogle Scholar
  12. }}J. Gibbons. Datatype-generic programming. In R. Backhouse, J. Gibbons, R. Hinze, and J. euring, editors, Datatype-Generic Programming, volume 4719 of LNCS, chapter 1, pages 1--71. Springer, Berlin, Heidelberg, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. }}V. Haldar, C. H. Stork, and M. Franz. The source is the proof. In NSPW '02: Proceedings of the 2002 workshop on New security paradigms, pages 69--73, New York, NY, USA, 2002. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. }}R. Hinze, J. Jeuring, and A. Löh. Comparing approaches to generic programming in Haskell. In Spring School on Datatype-Generic Programming, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. }}S. Holdermans, J. Jeuring, A. Löh, and A. Rodriguez. Generic views on data types. In In T. Uustalu, editor, Proceedings of the 8th International Conference on Mathematics of Program Construction, MPC'06, volume 4014 of LNCS, pages 209--234. Springer, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. }}A. J. Kennedy. Functional Pearl: Pickler Combinators. Journal of Functional Programming, 14(6):727--739, October 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. }}G. C. Necula and P. Lee. The design and implementation of a certifying compiler. In PLDI '98: Proceedings of the ACM SIGPLAN 1998 Conference on Programming Language Design and Implementation, pages 333--344, New York, NY, USA, 1998. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. }}G. C. Necula and S. P. Rahul. Oracle-based checking of untrusted software. In POPL '01: Proceedings of the 28th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 142--154, New York, NY, USA, 2001. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. }}D. Salomon. A Concise Introduction to Data Compression. Undergraduate Topics in Computer Science. Springer, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. }}M. H. Sørensen and P. Urzyczyn. Lectures on the Curry-Howard Isomorphism, Volume 149 (Studies in Logic and the Foundations of Mathematics). Elsevier Science Inc., New York, NY, USA, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. }}M. Sozeau. Subset coercions in Coq. In Selected papers from the International Workshop on Types for Proofs and Programs (TYPES '06), pages 237--252. Springer, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. }}M. Sulzmann, M. Chakravarty, and S. Peyton Jones. System F with type equality coercions. In ACM Workshop on Types in Language Design and Implementation (TLDI). ACM, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Functional pearl: every bit counts

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        • Published in

          cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 45, Issue 9
          ICFP '10
          September 2010
          382 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/1932681
          Issue’s Table of Contents
          • cover image ACM Conferences
            ICFP '10: Proceedings of the 15th ACM SIGPLAN international conference on Functional programming
            September 2010
            398 pages
            ISBN:9781605587943
            DOI:10.1145/1863543

          Copyright © 2010 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 27 September 2010

          Check for updates

          Qualifiers

          • research-article

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader

        ePub

        View this article in ePub.

        View ePub
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!