ebook img

Semantics with Applications: An Appetizer PDF

284 Pages·2007·2.3 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Semantics with Applications: An Appetizer

www.dbebooks.com - Free Books & magazines Undergraduate Topics in Computer Science Undergraduate Topics in Computer Science (UTiCS) delivers high-quality instructional content for undergraduates studying in all areas of computing and information science. From core foundational and theoretical material to final-year topics and applications, UTiCS books take a fresh, concise, and modern approach and are ideal for self-study or for a one- or two-semester course. The texts are all authored by established experts in their fields, reviewed by an international advisory board, and contain numerous examples and problems. Many include fully worked solutions. Also in this series Iain Craig Object-Oriented Programming Languages: Interpretation 978-1-84628-773-2 Max Bramer Principles of Data Mining 978-1-84628-765-7 Hanne Riis Nielson and Flemming Nielson Semantics with Applications: An Appetizer Hanne Riis Nielson, PhD Flemming Nielson, PhD, DSc The Technical University of Denmark The Technical University of Denmark Denmark Denmark Series editor Ian Mackie École Polytechnique, France and King’s College London, UK Advisory board Samson Abramsky, University of Oxford, UK Chris Hankin, Imperial College London, UK Dexter Kozen, Cornell University, USA Andrew Pitts, University of Cambridge, UK Hanne Riis Nielson, Technical University of Denmark, Denmark Steven Skiena, Stony Brook University, USA Iain Stewart, University of Durham, UK David Zhang, The Hong Kong Polytechnic University, Hong Kong British Library Cataloguing in Publication Data A catalogue record for this book is available from the British Library Library of Congress Control Number: 2006939147 Undergraduate Topics in Computer Science ISSN 1863-7310 ISBN-10: 1-84628-691-3 e-ISBN-10: 1-84628-692-1 ISBN-13: 978-1-84628-691-9 e-ISBN-13: 978-1-84628-692-6 Printed on acid-free paper © Springer-Verlag London Limited 2007 Apart from any fair dealing for the purposes of research or private study, or criticism or review, as permitted under the Copyright, Designs and Patents Act 1988, this publication may only be reproduced, stored or transmitted, in any form or by any means, with the prior permission in writing of the publishers, or in the case of reprographic reproduction in accordance with the terms of licences issued by the Copyright Licensing Agency. Enquiries concerning reproduction outside those terms should be sent to the publishers. The use of registered names, trademarks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant laws and regulations and therefore free for general use. The publisher makes no representation, express or implied, with regard to the accuracy of the information contained in this book and cannot accept any legal responsibility or liability for any errors or omissions that may be made. 9 8 7 6 5 4 3 2 1 Springer Science+Business Media springer.com Preface This book is written out of a tradition that places special emphasis on the following three approaches to semantics: – operational semantics, – denotational semantics, and – axiomatic semantics. It is therefore beyond the scope of this introductory book to cover other ap- proaches such as algebraic semantics, game semantics, and evolving algebras. We strongly believe that semantics has an important role to play in the fu- turedevelopmentofsoftwaresystemsanddomain-specificlanguages(andhence is not confined to the enormous task of specifying “real life” languages such as C++, Java or C#). We have therefore found the need for an introductory book that – presents the fundamental ideas behind these approaches, – stressestheirrelationship byformulatingandprovingtherelevanttheorems, and – illustrates the applications of semantics in computer science. This is an ambitious goal for an introductory book, and to achieve it, the bulk of the technical development concentrates on a rather small core language of while-programs for which the three approaches are developed to roughly the same level of sophistication; this should enable students to get a better grasp of similarities and differences among the three approaches. In our choice of applications, we have selected some of the historically important application areas as well as some of the more promising candidates for future applications: vi Preface Chapter 1 Chapter 2 (cid:1) (cid:2) (cid:1) (cid:2) (cid:1) (cid:2) (cid:1) (cid:2) (cid:1) (cid:2) Chapter 3 Chapter 4 Chapter 5 (cid:1) (cid:2) (cid:1) (cid:2) (cid:1) (cid:2) (cid:1) (cid:2) (cid:1) (cid:2) Chapter 6 Chapter 7 Chapter 9 (cid:1) (cid:1) (cid:1) (cid:1) (cid:1) Chapter 10 Chapter 8 Chapter 11 – the use of semantics for validating prototype implementations of program- ming languages; – the use of semantics for verifying program analyses that are part of more advanced implementations of programming languages; – the use of semantics for verifying security analyses; and – the use of semantics for verifying useful program properties, including infor- mation about execution time. Clearly this only serves as an appetizer to the fascinating area of “Semantics with Applications”; some pointers for further reading are given in Chapter 11. Overview. As is illustrated in the dependency diagram, Chapters 1, 2, 5, 9, and 11 form the core of the book. Chapter 1 introduces the example language While of while-programs that is used throughout the book. In Chapter 2 we cover two approaches to operational semantics, the natural semantics of Preface vii G. Kahn and the structural operational semantics of G. D. Plotkin. Chapter 5 develops the denotational semantics of D. Scott and C. Strachey, including simple fixed point theory. Chapter 9 introduces program verification based on operational and denotational semantics and goes on to present the axiomatic approach due to C. A. R. Hoare. Finally, Chapter 11 contains suggestions for further reading. Chapters 2, 5, and 9 are devoted to the language While and cover specification as well as theory; there is quite a bit of attention to the proof techniques needed for proving the relevant theorems. Chapters 3, 6, and 10 consider extensions of the approach by incorporat- ing new descriptive techniques or new language constructs; in the interest of breadth of coverage, the emphasis is on specification rather than theory. To be specific, Chapter 3 considers extensions with abortion, non-determinism, par- allelism, block constructs, dynamic and static procedures, and non-recursive andrecursiveprocedures.InChapter6weconsiderstaticproceduresthatmay ormaynotberecursiveandweshowhowtohandleexceptions;thatis,certain kindsofjumps.Finally,inSection10.1weconsidernon-recursiveandrecursive procedures and show how to deal with total correctness properties. Chapters4,7,8,and10covertheapplicationsofoperational,denotational, andaxiomaticsemanticstothelanguageWhileasdevelopedinChapters2,5, and9.InChapter4weshowhowtoprovethecorrectnessofasimplecompiler using the operational semantics. In Chapter 7 we show how to specify and prove the correctness of a program analysis for “Detection of Signs” using the denotational semantics. Furthermore, in Chapter 8 we specify and prove the correctness of a security analysis once more using the denotational semantics. Finally, in Section 10.2 we extend the axiomatic approach so as to obtain information about execution time. AppendixAreviewsthemathematicalnotationonwhichthisbookisbased. It is mostly standard notation, but some may find our use of (cid:1)→ and (cid:3) non- standard. We use D (cid:1)→ E for the set of partial functions from D to E; this is because we find that the D (cid:2) E notation is too easily overlooked. Also, we use R (cid:3) S for the composition of binary relations R and S. When dealing with axiomatic semantics we use formulae { P } S { Q } for partial correctness assertions but { P } S { ⇓ Q } for total correctness assertions, hoping that the explicit occurrence of ⇓ (for termination) may prevent the student from confusing the two systems. AppendixBcontainssomefairlydetailedresultsforcalculatingthenumber of iterations of a functional before it stabilises and produces the least fixed point.Thisappliestothefunctionalsarisingintheprogramanalysesdeveloped in Chapters 7 and 8. viii Preface Notes for the instructor. Thereadershouldpreferablybeacquaintedwiththe BNF style of specifying the syntax of programming languages and should be familiar with most of the mathematical concepts surveyed in Appendix A. Weprovidetwokindsofexercises.Onekindhelpsthestudentinunderstand- ingthedefinitions,results,andtechniquesusedinthetext.Inparticular,there areexercisesthataskthestudenttoproveauxiliaryresultsneededforthemain results but then the proof techniques will be minor variations of those already explainedinthetext.Wehavemarkedthoseexerciseswhoseresultsareneeded later by “Essential”. The other kind of exercises are more challenging in that they extend the development, for example by relating it to other approaches. Weuseastartomarkthemoredifficultoftheseexercises.Exercisesmarkedby two stars are rather lengthy and may require insight not otherwise presented in the book. It will not be necessary for students to attempt all the exercises, but we do recommend that they read them and try to understand what the exercises are about. For a list of misprints and supplementary material, please consult the webpage http://www.imm.dtu.dk/∼riis/SWA/swa.html. Acknowledgments. This book grew out of our previous book Semantics with Applications: A Formal Introduction [18] that was published by Wiley in 1992 andanote,Semantics with Applications: Model-Based Program Analysis,writ- ten in 1996. Over the years,we have obtained many comments from colleagues and students, and since we are constantly reminded that the material is still in demand, we have taken this opportunity to rework the book. This includes using shorter chapters and a different choice of security-related analyses. The present version has benefitted from the comments of Henning Makholm. Kongens Lyngby, Denmark, January 2007 Hanne Riis Nielson Flemming Nielson Contents List of Tables ................................................... xi 1. Introduction................................................ 1 1.1 Semantic Description Methods ............................. 1 1.2 The Example Language While............................. 7 1.3 Semantics of Expressions .................................. 9 1.4 Properties of the Semantics ................................ 16 2. Operational Semantics...................................... 19 2.1 Natural Semantics........................................ 20 2.2 Structural Operational Semantics........................... 33 2.3 An Equivalence Result .................................... 41 3. More on Operational Semantics ............................ 47 3.1 Non-sequential Language Constructs........................ 47 3.2 Blocks and Procedures .................................... 54 4. Provably Correct Implementation .......................... 67 4.1 The Abstract Machine .................................... 67 4.2 Specification of the Translation............................. 75 4.3 Correctness.............................................. 78 4.4 An Alternative Proof Technique ............................ 88 5. Denotational Semantics..................................... 91 5.1 Direct Style Semantics: Specification ........................ 92 5.2 Fixed Point Theory....................................... 99 5.3 Direct Style Semantics: Existence...........................115 x Contents 5.4 An Equivalence Result ....................................121 6. More on Denotational Semantics ...........................127 6.1 Environments and Stores ..................................127 6.2 Continuations............................................138 7. Program Analysis ..........................................145 7.1 Detection of Signs Analysis: Specification....................149 7.2 Detection of Signs Analysis: Existence.......................161 7.3 Safety of the Analysis.....................................166 7.4 Program Transformation ..................................171 8. More on Program Analysis .................................175 8.1 Data Flow Frameworks....................................177 8.2 Security Analysis.........................................183 8.3 Safety of the Analysis.....................................193 9. Axiomatic Program Verification ............................205 9.1 Direct Proofs of Program Correctness .......................205 9.2 Partial Correctness Assertions..............................212 9.3 Soundness and Completeness...............................220 10. More on Axiomatic Program Verification ...................229 10.1 Total Correctness Assertions ...............................229 10.2 Assertions for Execution Time .............................239 11. Further Reading............................................247 A. Review of Notation.........................................251 B. Implementation of Program Analysis .......................255 B.1 The General and Monotone Frameworks.....................257 B.2 The Completely Additive Framework .......................259 B.3 Iterative Program Schemes ................................262 Bibliography....................................................267 Index...........................................................269

Description:
Semantics will have an important role to play in the future development of software systems and domain specific languages, and there is a real need for an introductory book that presents the fundamental ideas behind these approaches; stresses their relationship by formulating and proving the relevan
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.