skip to main content
10.1145/1863543.1863548acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Functional pearl: every bit counts

Published: 27 September 2010 Publication History

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.

Supplementary Material

MOV File (icfp-mon-1055-vytiniotis.mov)

References

[1]
}}Y. Bertot and P. Casteran. Interactive Theorem Proving and Program Development. Springer-Verlag, 2004.
[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.
[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.
[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.
[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.
[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.
[7]
}}ECMA. Standard {ECMA-335}: Common language infrastructure (CLI), 2006.
[8]
}}P. Elias. Universal codeword sets and representations of the integers. IEEE Transactions on Information Theory, 21(2):197--203, 1975.
[9]
}}K. Fisher, Y. Mandelbaum, and D. Walker. The next 700 data description languages. SIGPLAN Not., 41(1):2--15, 2006.
[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.
[11]
}}N. Ghani, P. Hancock, and D. Pattinson. Representations of stream processors using nested fixed points. Logical Methods in Computer Science, 5(3), 2009.
[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.
[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.
[14]
}}R. Hinze, J. Jeuring, and A. Löh. Comparing approaches to generic programming in Haskell. In Spring School on Datatype-Generic Programming, 2006.
[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.
[16]
}}A. J. Kennedy. Functional Pearl: Pickler Combinators. Journal of Functional Programming, 14(6):727--739, October 2004.
[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.
[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.
[19]
}}D. Salomon. A Concise Introduction to Data Compression. Undergraduate Topics in Computer Science. Springer, 2008.
[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.
[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.
[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.

Cited By

View all
  • (2019)Narcissus: correct-by-construction derivation of decoders and encoders from binary formatsProceedings of the ACM on Programming Languages10.1145/33416863:ICFP(1-29)Online publication date: 26-Jul-2019
  • (2016)Compact bit encoding schemes for simply-typed lambda-termsACM SIGPLAN Notices10.1145/3022670.295191851:9(146-157)Online publication date: 4-Sep-2016
  • (2016)Compact bit encoding schemes for simply-typed lambda-termsProceedings of the 21st ACM SIGPLAN International Conference on Functional Programming10.1145/2951913.2951918(146-157)Online publication date: 4-Sep-2016
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

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
  • 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
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: 27 September 2010

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. decoders
  2. encoders
  3. games

Qualifiers

  • Research-article

Conference

ICFP '10
Sponsor:

Acceptance Rates

Overall Acceptance Rate 333 of 1,064 submissions, 31%

Upcoming Conference

ICFP '25
ACM SIGPLAN International Conference on Functional Programming
October 12 - 18, 2025
Singapore , Singapore

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)5
  • Downloads (Last 6 weeks)1
Reflects downloads up to 17 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2019)Narcissus: correct-by-construction derivation of decoders and encoders from binary formatsProceedings of the ACM on Programming Languages10.1145/33416863:ICFP(1-29)Online publication date: 26-Jul-2019
  • (2016)Compact bit encoding schemes for simply-typed lambda-termsACM SIGPLAN Notices10.1145/3022670.295191851:9(146-157)Online publication date: 4-Sep-2016
  • (2016)Compact bit encoding schemes for simply-typed lambda-termsProceedings of the 21st ACM SIGPLAN International Conference on Functional Programming10.1145/2951913.2951918(146-157)Online publication date: 4-Sep-2016
  • (2016)A Size-Proportionate Bijective Encoding of Lambda Terms as Catalan Objects Endowed with Arithmetic OperationsPractical Aspects of Declarative Languages10.1007/978-3-319-28228-2_7(99-116)Online publication date: 9-Jan-2016
  • (2015)On a uniform representation of combinators, arithmetic, lambda terms and typesProceedings of the 17th International Symposium on Principles and Practice of Declarative Programming10.1145/2790449.2790526(244-255)Online publication date: 14-Jul-2015
  • (2012)Functional programs as compressed dataProceedings of the ACM SIGPLAN 2012 workshop on Partial evaluation and program manipulation10.1145/2103746.2103770(121-130)Online publication date: 23-Jan-2012
  • (2012)Computing with Free AlgebrasProceedings of the 2012 14th International Symposium on Symbolic and Numeric Algorithms for Scientific Computing10.1109/SYNASC.2012.19(15-22)Online publication date: 26-Sep-2012
  • (2012)Every bit countsJournal of Functional Programming10.1017/S095679681200026322:4-5(529-573)Online publication date: 1-Aug-2012
  • (2011)Testing an optimising compiler by generating random lambda termsProceedings of the 6th International Workshop on Automation of Software Test10.1145/1982595.1982615(91-97)Online publication date: 23-May-2011
  • (2013)Instant picklesACM SIGPLAN Notices10.1145/2544173.250954748:10(183-202)Online publication date: 29-Oct-2013
  • Show More Cited By

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

EPUB

View this article in ePub.

ePub

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media