Hostname: page-component-5db58dd55d-xnzfm Total loading time: 0 Render date: 2026-05-26T07:45:00.702Z 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.

Information

Type
Articles
Copyright
Copyright © Cambridge University Press 2012
Submit a response

Discussions

No Discussions have been published for this article.