Nominal Game Semantics
Total Page:16
File Type:pdf, Size:1020Kb
Full text available at: http://dx.doi.org/10.1561/2500000017 Nominal Game Semantics Andrzej S. Murawski University of Warwick Nikos Tzevelekos Queen Mary University of London Boston — Delft Full text available at: http://dx.doi.org/10.1561/2500000017 Foundations and Trends R in Programming Languages Published, sold and distributed by: now Publishers Inc. PO Box 1024 Hanover, MA 02339 United States Tel. +1-781-985-4510 www.nowpublishers.com [email protected] Outside North America: now Publishers Inc. PO Box 179 2600 AD Delft The Netherlands Tel. +31-6-51115274 The preferred citation for this publication is A. S. Murawski and N. Tzevelekos. Nominal Game Semantics. Foundations and Trends R in Programming Languages, vol. 2, no. 4, pp. 191–269, 2015. R This Foundations and Trends issue was typeset in LATEX using a class file designed by Neal Parikh. Printed on acid-free paper. ISBN: 978-1-68083-107-8 c 2016 A. S. Murawski and N. Tzevelekos All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, mechanical, photocopying, recording or otherwise, without prior written permission of the publishers. Photocopying. In the USA: This journal is registered at the Copyright Clearance Cen- ter, Inc., 222 Rosewood Drive, Danvers, MA 01923. Authorization to photocopy items for internal or personal use, or the internal or personal use of specific clients, is granted by now Publishers Inc for users registered with the Copyright Clearance Center (CCC). The ‘services’ for users can be found on the internet at: www.copyright.com For those organizations that have been granted a photocopy license, a separate system of payment has been arranged. Authorization does not extend to other kinds of copy- ing, such as that for general distribution, for advertising or promotional purposes, for creating new collective works, or for resale. In the rest of the world: Permission to pho- tocopy must be obtained from the copyright owner. Please apply to now Publishers Inc., PO Box 1024, Hanover, MA 02339, USA; Tel. +1 781 871 0245; www.nowpublishers.com; [email protected] now Publishers Inc. has an exclusive license to publish this material worldwide. Permission to use this content must be obtained from the copyright license holder. Please apply to now Publishers, PO Box 179, 2600 AD Delft, The Netherlands, www.nowpublishers.com; e-mail: [email protected] Full text available at: http://dx.doi.org/10.1561/2500000017 Foundations and Trends R in Programming Languages Volume 2, Issue 4, 2015 Editorial Board Editor-in-Chief Mooly Sagiv Tel Aviv University Israel Editors Martín Abadi Robert Harper Ganesan Ramalingam Google & CMU Microsoft Research UC Santa Cruz Tim Harris Mooly Sagiv Anindya Banerjee Oracle Tel Aviv University IMDEA Fritz Henglein Davide Sangiorgi Patrick Cousot University of Copenhagen University of Bologna ENS Paris & NYU Rupak Majumdar David Schmidt Oege De Moor MPI-SWS & UCLA Kansas State University University of Oxford Kenneth McMillan Peter Sewell Matthias Felleisen Microsoft Research University of Cambridge Northeastern University J. Eliot B. Moss Scott Stoller John Field UMass, Amherst Stony Brook University Google Andrew C. Myers Peter Stuckey Cormac Flanagan Cornell University University of Melbourne UC Santa Cruz Hanne Riis Nielson Jan Vitek Philippa Gardner TU Denmark Purdue University Imperial College Peter O’Hearn Philip Wadler Andrew Gordon UCL University of Edinburgh Microsoft Research & Benjamin C. Pierce David Walker University of Edinburgh UPenn Princeton University Dan Grossman Andrew Pitts Stephanie Weirich University of Washington University of Cambridge UPenn Full text available at: http://dx.doi.org/10.1561/2500000017 Editorial Scope Topics Foundations and Trends R in Programming Languages publishes survey and tutorial articles in the following topics: • Abstract interpretation • Programming languages for concurrency • Compilation and interpretation techniques • Programming languages for • Domain specific languages parallelism • Formal semantics, including • Program synthesis lambda calculi, process calculi, and process algebra • Program transformations and optimizations • Language paradigms • Mechanical proof checking • Program verification • Memory management • Runtime techniques for • Partial evaluation programming languages • Program logic • Software model checking • Programming language • Static and dynamic program implementation analysis • Programming language security • Type theory and type systems Information for Librarians Foundations and Trends R in Programming Languages, 2015, Volume 2, 4 issues. ISSN paper version 2325-1107. ISSN online version 2325-1131. Also available as a combined paper and online subscription. Full text available at: http://dx.doi.org/10.1561/2500000017 Foundations and Trends R in Programming Languages Vol. 2, No. 4 (2015) 191–269 c 2016 A. S. Murawski and N. Tzevelekos DOI: 10.1561/2500000017 Nominal Game Semantics Andrzej S. Murawski Nikos Tzevelekos University of Warwick Queen Mary University of London Full text available at: http://dx.doi.org/10.1561/2500000017 Contents 1 Introduction 2 2 Elements of Nominal Set Theory 6 3 GroundML 10 3.1 Syntax............................ 10 3.2 Operationalsemantics. 12 4 ToyML: A First-Order Language with Integer References 18 4.1 Typesandterms....................... 18 4.2 Concretegames ....................... 19 4.3 Interpretation of ToyML terms . 22 5 Game Model 32 5.1 Moves,arenas,plays,strategies . 32 5.2 Fullabstraction ....................... 58 5.3 Chapter Appendix: deferred proofs . 68 6 Conclusions 71 6.1 Other paradigms: higher-order references . 71 6.2 From references to Java objects . 73 6.3 Algorithmicgamesemantics. 74 ii Full text available at: http://dx.doi.org/10.1561/2500000017 iii 6.4 Operationalgamesemantics . 75 References 76 Full text available at: http://dx.doi.org/10.1561/2500000017 Abstract These tutorial notes present nominal game semantics, a denotational technique for modelling higher-order programs. A. S. Murawski and N. Tzevelekos. Nominal Game Semantics. Foundations and Trends R in Programming Languages, vol. 2, no. 4, pp. 191–269, 2015. DOI: 10.1561/2500000017. Full text available at: http://dx.doi.org/10.1561/2500000017 1 Introduction Game semantics is a branch of denotational semantics that uses the metaphor of game playing to model computation. The game models of PCF [5, 21, 35] constructed in the 1990s have led to an unprecedented series of full abstraction results for a range of functional/imperative programming languages. A result of this kind characterises contextual equivalence between terms semantically, i.e. equality of denotations co- incides with the fact that terms can be used interchangeably in any context. As such, full abstraction results can be said to capture the computational essence of programs. The fully abstract game models from the 1990s covered a plethora of computational effects, contributing to a general picture referred to as Abramsky’s cube [8]: by selectively weakening the combinatorial con- ditions on plays of the games, one was able to increase the expressivity of the games and capture desired computational effects. Although those works successfully constructed models of state [7, 6, 4, 9], the techniques used to interpret reference types did not make them fully compatible with what constitutes the norm in languages such as ML or Java. In particular, references were modelled through a form of indirection originating in the work of Reynolds [39], namely 2 Full text available at: http://dx.doi.org/10.1561/2500000017 3 by assuming that ref θ = (θ → unit) × (unit → θ). The approach led to identification of references with pairs of arbitrary reading (unit → θ) and writing (θ → unit) functions. While this view is elegant and cer- tainly comprises the range of behaviours corresponding to references, it does not enforce a relationship between reading and writing, as wit- nessed by the presence of the product type. This causes a significant strengthening of the semantic universe used for modelling references and, consequently, many desirable equivalences are not satisfied in the model. For example, the interpretation of (x := 0; x := 1) is different from that of x := 1 and, similarly, for x := !x and (). We list the inter- pretations below using the terminology of [6]. x := 0; x := 1 run write(0) ok write(1) ok done x := 1 run write(1) ok done x := !x run read i write(i) ok done () run done Thus, for the first term, the semantic translation treats both updates as observable events and therefore both are recorded in the game play.1 This immediately distinguishes semantically the first term from the second one, for which only a single update is recorded. On the other hand, the translation of the third term is more verbose, registering calls to both the read and write methods of x, even though the computa- tional content of the term is in fact that of the skip command () in the modelled language. To prove full abstraction in this setting, it is then necessary to enrich the syntax with terms that will populate the whole semantic space of references. Such terms are often referred to as bad variables, because they are objects of reference type equipped with potentially unrelated reading and writing methods. These terms, if used by the context, can distinguish the pairs of terms discussed above. For instance, a context that instantiates x to a bad variable with divergent reading and writing capabilities will be able