Hostname: page-component-586b7cd67f-r5fsc Total loading time: 0 Render date: 2024-11-26T04:43:14.206Z Has data issue: false hasContentIssue false

Every bit counts: The binary representation of typed data and programs

Published online by Cambridge University Press:  15 August 2012

ANDREW J. KENNEDY
Affiliation:
Microsoft Research, Cambridge, CB3 0FB, UK (e-mail: akenn@microsoft.com, dimitris@microsoft.com)
DIMITRIOS VYTINIOTIS
Affiliation:
Microsoft Research, Cambridge, CB3 0FB, UK (e-mail: akenn@microsoft.com, dimitris@microsoft.com)
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

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 in Haskell for structured, recursive, polymorphic and indexed types, building up to a representation of well-typed terms in the simply-typed λ-calculus with polymorphic constants. 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. Formal properties of the framework have been proved using the Coq proof assistant.

Type
Articles
Copyright
Copyright © Cambridge University Press 2012

References

Bertot, Y. & Casteran, P. (2004) Interactive Theorem Proving and Program Development. Springer-Verlag.CrossRefGoogle Scholar
Bird, R. & Gibbons, J. (2003) Arithmetic coding with folds and unfolds. In Advanced Functional Programming 4, Jeuring, J. & Peyton Jones, S. (eds), Lecture Notes in Computer Science, vol. 2638. Springer-Verlag, pp. 126.Google Scholar
Burtscher, M., Livshits, B., Sinha, G. & Zorn, B. (2010 June) JSZap: Compressing JavaScript code. In Proceedings of the USENIX Conference on Web Application Development. Berkeley, CA: USENIX Association.Google Scholar
Cameron, R. D. (1988) Source encoding using syntactic information source models. IEEE Trans. Inf. Theory 34 (4), 843850.CrossRefGoogle Scholar
Cheney, J. (2000) Statistical models for term compression. In DCC '00: Proceedings of the Conference on Data Compression. Washington, DC: IEEE Computer Society, p. 550.Google Scholar
Claessen, K. & Hughes, J. (2000) Quickcheck: A lightweight tool for random testing of Haskell programs. In ICFP '00: Proceedings of the 5th ACM SIGPLAN International Conference on Functional Programming. New York: ACM, pp. 268279.CrossRefGoogle Scholar
Contla, J. F. (1985) Compact coding of syntactically correct source programs. Softw. Pract. Exper. 15, 625636.CrossRefGoogle Scholar
Coutts, D., Leshchinskiy, R. & Stewart, D. (2007) Stream fusion: From lists to streams to nothing at all. In ICFP '07: Proceedings of the 12th ACM SIGPLAN International Conference on Functional Programming. New York: ACM, pp. 315326.CrossRefGoogle Scholar
Duan, J., Hurd, J., Li, G., Owens, S., Slind, K. & Zhang, J. (2005) Functional correctness proofs of encryption algorithms. In Logic for Programming, Artificial Intelligence and Reasoning (LPAR), LNCS, vol. 3835. Springer, pp. 519533.CrossRefGoogle Scholar
ECMA. (2006) Standard ECMA-335: Common Language Infrastructure (CLI). Geneva, Switzerland: ECMA International.Google Scholar
Elias, P. (1975) Universal codeword sets and representations of the integers. IEEE Trans. Inf. Theory 21 (2), 197203.CrossRefGoogle Scholar
Fisher, K., Mandelbaum, Y. & Walker, D. (2006) The next 700 data description languages. SIGPLAN Not. 41 (1), 215.CrossRefGoogle Scholar
Franz, M., Haldar, V., Krintz, C. & Stork, C. H. (2002) Tamper-Proof Annotations by Construction. Tech. Rep. 02-10. Department of Information and Computer Science, University of California, Irvine.Google Scholar
Ghani, N., Hancock, P. & Pattinson, D. (2009) Representations of stream processors using nested fixed points. Logical Methods Comput. Sci. 5 (3), 117.Google Scholar
Gibbons, J. (2007) Datatype-generic programming. In Datatype-Generic Programming, Backhouse, R., Gibbons, J., Hinze, R. & Jeuring, J. (eds), LNCS, vol. 4719. Berlin, Heidelberg: Springer, pp. 171.Google Scholar
Gonthier, G., Mahboubi, A. & Tassi, E. (2011) A Small Scale Reflection Extension for the Coq System. Tech. Rep. 6455. INRIA.Google Scholar
Haldar, V., Stork, C. H. & Franz, M. (2002) The source is the proof. In NSPW '02: Proceedings of the 2002 Workshop on New Security Paradigms. New York: ACM, pp. 6973.CrossRefGoogle Scholar
Hinze, R., Jeuring, J. & Löh, A. (2006) Comparing approaches to generic programming in Haskell. Spring Sch. Datatype-Generic Program, LNCS, vol. 4719, pp. 72–149.Google Scholar
Holdermans, S., Jeuring, J., Löh, A. & Rodriguez, A. (2006) Generic views on data types. In Proceedings of the 8th International Conference on Mathematics of Program Construction, MPC06, volume 4014 of LNCS. Springer, pp. 209234.Google Scholar
Kennedy, A. J. (2004) Functional pearl: Pickler combinators. J. Funct. Program. 14 (6), 727739.CrossRefGoogle Scholar
Knuth, D. E. (1992) Axioms and Hulls, LNCS, vol. 606. Springer-Verlag.CrossRefGoogle Scholar
MacKay, D. J. C. (2003) Information Theory, Inference and Learning Algorithms. Cambridge University Press.Google Scholar
Necula, G. C. & Lee, P. (1998) The design and implementation of a certifying compiler. In PLDI '98: Proceedings of the ACM SIGPLAN 1998 Conference on Programming Language Design and Implementation. New York: ACM, pp. 333344.CrossRefGoogle Scholar
Necula, G. C. & Rahul, S. P. (2001) Oracle-based checking of untrusted software. In POPL'01: Proceedings of the 28th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. New York: ACM, pp. 142154.CrossRefGoogle Scholar
Nielsen, L. & Henglein, F. (2011) Bit-coded regular expression parsing. In Proceedings of the 5th Int'l Conference on Language and Automata Theory and Applications (LATA), LNCS, vol. 6638. Springer, pp. 402413.CrossRefGoogle Scholar
Palka, M. H., Claessen, K., Russo, A. & Hughes, J. (2011) Testing an optimising compiler by generating random lambda terms. In Proceedings of the 6th International Workshop on Automation of Software Test (AST), AST '11. New York: ACM, pp. 9197.CrossRefGoogle Scholar
Rendel, T. & Ostermann, K. (2010) Invertible syntax descriptions: unifying parsing and pretty printing. SIGPLAN Not. 45, 112.CrossRefGoogle Scholar
Salomon, D. (2008) A Concise Introduction to Data Compression, Undergraduate Topics in Computer Science. Springer.CrossRefGoogle Scholar
Sørensen, M. H. & Urzyczyn, P. (2006) Lectures on the Curry-Howard Isomorphism (Studies in Logic and the Foundations of Mathematics, Volume 149). New York: Elsevier Science.Google Scholar
Sozeau, M. (2006) Subset coercions in Coq. In Selected Papers from the International Workshop on Types for Proofs and Programs (TYPES '06). Springer, pp. 237252.Google Scholar
Sulzmann, M., Chakravarty, M. & Peyton Jones, S. (2007) System F with type equality coercions. In ACM SIGPLAN International Workshop on Types in Language Design and Implementation (TLDI). ACM, pp. 5366.Google Scholar
Vytiniotis, D. & Kennedy, A. J. (2010) Functional pearl: Every bit counts. In ACM SIGPLAN International Conference on Functional Programming (ICFP). ACM, pp. 1526.CrossRefGoogle Scholar
Yakushev, A. R. & Jeuring, J. (2009) Enumerating well-typed terms generically. In Proceedings of the 5th Int'l Conference on Approaches and Applications of Inductive Programming (AAIP), LNCS, vol. 5812. Springer, pp. 4152.Google Scholar
Submit a response

Discussions

No Discussions have been published for this article.