Download as pdf or txt
Download as pdf or txt
You are on page 1of 45

Concepts and Semantics of

Programming Languages 1: A
Semantical Approach with OCaml and
Python Therese Hardin
Visit to download the full and correct content document:
https://ebookmass.com/product/concepts-and-semantics-of-programming-languages-
1-a-semantical-approach-with-ocaml-and-python-therese-hardin/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Concepts of Programming Languages (10th Edition)


Sebesta

https://ebookmass.com/product/concepts-of-programming-
languages-10th-edition-sebesta/

Python Programming and SQL: 10 Books in 1 - Supercharge


Your Career with Python Programming and SQL Andrew Reed

https://ebookmass.com/product/python-programming-and-
sql-10-books-in-1-supercharge-your-career-with-python-
programming-and-sql-andrew-reed/

Python & JavaScript Mastery: 2 Books In 1- Learn And


Master Two Powerful Programming Languages Alex Iversion

https://ebookmass.com/product/python-javascript-mastery-2-books-
in-1-learn-and-master-two-powerful-programming-languages-alex-
iversion/

Programming and Problem Solving with Python Ashok


Namdev Kamthane

https://ebookmass.com/product/programming-and-problem-solving-
with-python-ashok-namdev-kamthane/
Learning Scientific Programming with Python Hill

https://ebookmass.com/product/learning-scientific-programming-
with-python-hill/

Python Mini Reference 2022: A Quick Guide to the Modern


Python Programming Language for Busy Coders (A
Hitchhiker's Guide to the Modern Programming Languages
Book 3) Harry Yoon
https://ebookmass.com/product/python-mini-reference-2022-a-quick-
guide-to-the-modern-python-programming-language-for-busy-coders-
a-hitchhikers-guide-to-the-modern-programming-languages-
book-3-harry-yoon/

Mastering Functional Programming with Python Brett


Neutreon

https://ebookmass.com/product/mastering-functional-programming-
with-python-brett-neutreon/

Python Programming for Beginners: 2 Books in 1 - the


Ultimate Step-By-Step Guide to Learn Python Programming
Quickly With Practical Exercises Mark Reed

https://ebookmass.com/product/python-programming-for-
beginners-2-books-in-1-the-ultimate-step-by-step-guide-to-learn-
python-programming-quickly-with-practical-exercises-mark-reed/

Python Programming: Using Problem Solving Approach 1st


Edition Reema Thareja

https://ebookmass.com/product/python-programming-using-problem-
solving-approach-1st-edition-reema-thareja/
Concepts and Semantics of Programming Languages 1
Series Editor
Jean-Charles Pomerol

Concepts and Semantics of


Programming Languages 1

A Semantical Approach with


OCaml and Python

Thérèse Hardin
Mathieu Jaume
François Pessaux
Véronique Viguié Donzeau-Gouge
First published 2021 in Great Britain and the United States by ISTE Ltd and John Wiley & Sons, Inc.

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 and licenses issued by the
CLA. Enquiries concerning reproduction outside these terms should be sent to the publishers at the
undermentioned address:

ISTE Ltd John Wiley & Sons, Inc.


27-37 St George’s Road 111 River Street
London SW19 4EU Hoboken, NJ 07030
UK USA

www.iste.co.uk www.wiley.com

© ISTE Ltd 2021


The rights of Thérèse Hardin, Mathieu Jaume, François Pessaux and Véronique Viguié Donzeau-Gouge
to be identified as the authors of this work have been asserted by them in accordance with the Copyright,
Designs and Patents Act 1988.

Library of Congress Control Number: 2021930488

British Library Cataloguing-in-Publication Data


A CIP record for this book is available from the British Library
ISBN 978-1-78630-530-5
Contents

Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii

Chapter 1. From Hardware to Software . . . . . . . . . . . . . . . . . . . 1


1.1. Computers: a low-level view . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.1. Information processing . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.2. Memories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1.3. CPUs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1.4. Peripheral devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2. Computers: a high-level view . . . . . . . . . . . . . . . . . . . . . . . 8
1.2.1. Modeling computations . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.2.2. High-level languages . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.2.3. From source code to executable programs . . . . . . . . . . . . . . 10

Chapter 2. Introduction to Semantics of Programming Languages 15


2.1. Environment, memory and state . . . . . . . . . . . . . . . . . . . . . . 16
2.1.1. Evaluation environment . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.1.2. Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.1.3. State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.2. Evaluation of expressions . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.2.1. Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.2.2. Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.2.3. Evaluation semantics . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.3. Definition and assignment . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.3.1. Defining an identifier . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.3.2. Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.4. Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
vi Concepts and Semantics of Programming Languages 1

Chapter 3. Semantics of Functional Features . . . . . . . . . . . . . . . 35


3.1. Syntactic aspects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.1.1. Syntax of a functional kernel . . . . . . . . . . . . . . . . . . . . . . 35
3.1.2. Abstract syntax tree . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.1.3. Reasoning by induction over expressions . . . . . . . . . . . . . . . 39
3.1.4. Declaration of variables, bound and free variables . . . . . . . . . . 39
3.2. Execution semantics: evaluation functions . . . . . . . . . . . . . . . . 42
3.2.1. Evaluation errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.2.2. Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.2.3. Interpretation of operators . . . . . . . . . . . . . . . . . . . . . . . 45
3.2.4. Closures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.2.5. Evaluation of expressions . . . . . . . . . . . . . . . . . . . . . . . . 47
3.3. Execution semantics: operational semantics . . . . . . . . . . . . . . . 54
3.3.1. Simple expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.3.2. Call-by-value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.3.3. Recursive and mutually recursive functions . . . . . . . . . . . . . . 60
3.3.4. Call-by-name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
3.3.5. Call-by-value versus call-by-name . . . . . . . . . . . . . . . . . . . 62
3.4. Evaluation functions versus evaluation relations . . . . . . . . . . . . . 64
3.4.1. Status of the evaluation function . . . . . . . . . . . . . . . . . . . . 64
3.4.2. Induction over evaluation trees . . . . . . . . . . . . . . . . . . . . . 65
3.5. Semantic properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.5.1. Equivalent expressions . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.5.2. Equivalent environments . . . . . . . . . . . . . . . . . . . . . . . . 71
3.6. Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

Chapter 4. Semantics of Imperative Features . . . . . . . . . . . . . . . 77


4.1. Syntax of a kernel of an imperative language . . . . . . . . . . . . . . . 77
4.2. Evaluation of expressions . . . . . . . . . . . . . . . . . . . . . . . . . . 81
4.3. Evaluation of definitions . . . . . . . . . . . . . . . . . . . . . . . . . . 86
4.4. Operational semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
4.4.1. Big-step semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
4.4.2. Small-step semantics . . . . . . . . . . . . . . . . . . . . . . . . . . 93
4.4.3. Expressiveness of operational semantics . . . . . . . . . . . . . . . 95
4.5. Semantic properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
4.5.1. Equivalent programs . . . . . . . . . . . . . . . . . . . . . . . . . . 96
4.5.2. Program termination . . . . . . . . . . . . . . . . . . . . . . . . . . 98
4.5.3. Determinism of program execution . . . . . . . . . . . . . . . . . . 100
4.5.4. Big steps versus small steps . . . . . . . . . . . . . . . . . . . . . . 103
4.6. Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
4.6.1. Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
4.6.2. Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
4.7. Other approaches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Contents vii

4.7.1. Denotational semantics . . . . . . . . . . . . . . . . . . . . . . . . . 118


4.7.2. Axiomatic semantics, Hoare logic . . . . . . . . . . . . . . . . . . . 129
4.8. Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134

Chapter 5. Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137


5.1. Type checking: when and how? . . . . . . . . . . . . . . . . . . . . . . 139
5.1.1. When to verify types? . . . . . . . . . . . . . . . . . . . . . . . . . . 139
5.1.2. How to verify types? . . . . . . . . . . . . . . . . . . . . . . . . . . 140
5.2. Informal typing of a program Exp2 . . . . . . . . . . . . . . . . . . . . 141
5.2.1. A first example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
5.2.2. Typing a conditional expression . . . . . . . . . . . . . . . . . . . . 142
5.2.3. Typing without type constraints . . . . . . . . . . . . . . . . . . . . 142
5.2.4. Polymorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
5.3. Typing rules in Exp2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
5.3.1. Types, type schemes and typing environments . . . . . . . . . . . . 143
5.3.2. Generalization, substitution and instantiation . . . . . . . . . . . . . 146
5.3.3. Typing rules and typing trees . . . . . . . . . . . . . . . . . . . . . . 151
5.4. Type inference algorithm in Exp2 . . . . . . . . . . . . . . . . . . . . . 154
5.4.1. Principal type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
5.4.2. Sets of constraints and unification . . . . . . . . . . . . . . . . . . . 155
5.4.3. Type inference algorithm . . . . . . . . . . . . . . . . . . . . . . . . 159
5.5. Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
5.5.1. Properties of typechecking . . . . . . . . . . . . . . . . . . . . . . . 167
5.5.2. Properties of the inference algorithm . . . . . . . . . . . . . . . . . 167
5.6. Typechecking of imperative constructs . . . . . . . . . . . . . . . . . . 168
5.6.1. Type algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
5.6.2. Typing rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
5.6.3. Typing polymorphic definitions . . . . . . . . . . . . . . . . . . . . 171
5.7. Subtyping and overloading . . . . . . . . . . . . . . . . . . . . . . . . . 172
5.7.1. Subtyping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
5.7.2. Overloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

Chapter 6. Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179


6.1. Basic types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
6.1.1. Booleans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
6.1.2. Integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
6.1.3. Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
6.1.4. Floating point numbers . . . . . . . . . . . . . . . . . . . . . . . . . 187
6.2. Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
6.3. Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
6.4. Type definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
6.4.1. Type abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
6.4.2. Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
viii Concepts and Semantics of Programming Languages 1

6.4.3. Enumerated types . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200


6.4.4. Sum types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
6.5. Generalized conditional . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
6.5.1. C style switch/case . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
6.5.2. Pattern matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
6.6. Equality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
6.6.1. Physical equality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
6.6.2. Structural equality . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
6.6.3. Equality between functions . . . . . . . . . . . . . . . . . . . . . . . 220

Chapter 7. Pointers and Memory Management . . . . . . . . . . . . . . 223


7.1. Addresses and pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
7.2. Endianness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
7.3. Pointers and arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
7.4. Passing parameters by address . . . . . . . . . . . . . . . . . . . . . . . 226
7.5. References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
7.5.1. References in C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
7.5.2. References in Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
7.6. Memory management . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
7.6.1. Memory allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
7.6.2. Freeing memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
7.6.3. Automatic memory management . . . . . . . . . . . . . . . . . . . 239

Chapter 8. Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243


8.1. Errors: notification and propagation . . . . . . . . . . . . . . . . . . . . 243
8.1.1. Global variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
8.1.2. Record definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
8.1.3. Passing by address . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
8.1.4. Introducing exceptions . . . . . . . . . . . . . . . . . . . . . . . . . 246
8.2. A simple formalization: ML-style exceptions . . . . . . . . . . . . . . 247
8.2.1. Abstract syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
8.2.2. Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
8.2.3. Type algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
8.2.4. Operational semantics . . . . . . . . . . . . . . . . . . . . . . . . . . 248
8.2.5. Typing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
8.3. Exceptions in other languages . . . . . . . . . . . . . . . . . . . . . . . 250
8.3.1. Exceptions in OCaml . . . . . . . . . . . . . . . . . . . . . . . . . . 251
8.3.2. Exceptions in Python . . . . . . . . . . . . . . . . . . . . . . . . . . 251
8.3.3. Exceptions in Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
8.3.4. Exceptions in C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
Contents ix

Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257

Appendix: Solutions to the Exercises . . . . . . . . . . . . . . . . . . . . 259

List of Notations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287

Index of Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289

References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
Foreword

Computer programs have played an increasingly central role in our lives since the
1940s, and the quality of these programs has thus become a crucial question. Writing
a high-quality program – a program that performs the required task and is efficient,
robust, easy to modify, easy to extend, etc. – is an intellectually challenging task,
requiring the use of rigorous development methods. First and foremost, however, the
creation of such a program is dependent on an in-depth knowledge of the
programming language used, its syntax and, crucially, its semantics, i.e. what
happens when a program is executed.

The description of this semantics puts the most fundamental concepts into light,
including those of value, reference, exception or object. These concepts are the
foundations of programming language theory. Mastering these concepts is what sets
experienced programmers apart from beginners. Certain concepts – like that of value
– are common to all programming languages; others – such as the notion of functions
– operate differently in different languages; finally, other concepts – such as that of
objects – only exist in certain languages. Computer scientists often refer to
“programming paradigms” to consider sets of concepts shared by a family of
languages, which imply a certain programming style: imperative, functional,
object-oriented, logical, concurrent, etc. Nevertheless, an understanding of the
concepts themselves is essential, as several paradigms may be interwoven within the
same language.

Introductory texts on programming in any given language are not difficult to find,
and a number of published books address the fundamental concepts of language
semantics. Much rarer are those, like the present volume, which establish and
examine the links between concepts and their implementation in languages used by
programmers on a daily basis, such as C, C++, Ada, Java, OCaml and Python. The
authors provide a wealth of examples in these languages, illustrating and giving life
to the notions that they present. They propose general models, such as the kit
xii Concepts and Semantics of Programming Languages 1

presented in Volume 2, permitting a unified view of different notions; this makes it


easier for readers to understand the constructs used in popular programming
languages and facilitates comparison. This thorough and detailed work provides
readers with an understanding of these notions and, above all, an understanding of
the ways of using the latter to create high-quality programs, building a safer and
more reliable future in computing.

Gilles D OWEK
Research Director, Inria
Professor at the École normale supérieure, Paris-Saclay

Catherine D UBOIS
Professor at the École nationale supérieure
d’informatique pour l’industrie et l’entreprise
January 2021
Preface

This two-volume work relates to the field of programming. First and foremost, it
is intended to give readers a solid grounding in the bases of functional or imperative
programming, along with a thorough knowledge of the module and class mechanisms
involved. In our view, the semantics approach is most appropriate when studying
programming, as the impact of interlanguage syntax differences is limited. Practical
considerations, determined by the material characteristics of computers and/or
“smart” devices, will also be addressed. The same approach will be taken in both
volumes, using both mathematical formulas and memory state diagrams. With this
book, we hope to help readers understand the meaning of the constructs described in
the reference manuals of programming languages and to establish solid foundations
for reasoning and assessing the correctness of their own programs through critical
review. In short, our aim is to facilitate the development of safe and reliable
programs.

Volume 1 begins with a presentation of the computer, in Chapter 1, first at the


material level – as an assemblage of components – then as a tool for executing
programs. Chapter 2 is an intuitive, step-by-step introduction to language semantics,
intended to familiarize readers with this approach to programming. In Chapter 3, we
provide a detailed discussion on the subject, with a formal presentation of the
execution semantics of functional features. Chapter 4 continues with the same topic,
looking at the execution semantics of imperative features. In these two chapters, a
clear mathematical framework is used to support our presentation. Also, all of the
notions which we introduce in these chapters are implemented in both Python and
OCaml to assist readers learning about the semantic concepts in question for the first
time. Multiple exercises, with detailed solutions, are provided in both cases. Chapter
5, on the subject of typing, begins by addressing typing rules, which are used to
check programs; we then present the algorithm used to infer polymorphic types,
along with the associated mathematical notions, all implemented in both languages.
Finally, the extension of typing to imperative features is addressed. In Chapter 6, we
xiv Concepts and Semantics of Programming Languages 1

present the main data types and methods of pattern matching, using a range of
examples expressed in different programming languages. Chapter 7 focuses on
low-level programming features: endianness, pointers and memory management;
these notions are mostly presented using C and C++. Volume 1 ends with a
discussion of error processing using exceptions, their semantics is presented in
OCaml, and the exception management mechanisms used in Python, Java and C++
are also described (see Chapter 8).

Thus, Volume 1 is intended to give a broad overview of the functional and


imperative features of programming, from notions that can be modeled
mathematically to notions that are linked to the hardware configuration of computers
themselves. Volume 2 focuses on modular and object programming, building on the
foundations laid down in Volume 1 since modules, classes and objects are, in
essence, the means of organizing functional or imperative constructs. Volume 2 first
analyzes the needs of developers in terms of tools for software architecture. Based on
this study, an original semantic model, called a kit, is drawn up, jointly presenting all
the features of the modules and objects that can meet these needs. The semantics of
these kits are defined in a rather informal way, as research in this field has not yet led
to a mathematical model of this set of features, while remaining relatively simple.
From this model, we consider a set of emerging questions, the objective of which is
to guide the acquisition of a language. This approach is then exemplified by the study
of the module systems of Ada, OCaml and C. Finally, the same approach will be used
to deduce a semantic model of class and object features, which will serve to present
classes in Java, C++, OCaml and Python from a unified perspective.

This work is aimed at a relatively wide audience, from experienced developers –


who will find valuable additional information on language semantics – to beginners
who have only written short programs. For beginners, we recommend working on the
semantic concepts described in Volume 1 using the implementations in OCaml or
Python to ease assimilation. All readers may benefit from studying the reference
manual of a programming language, while comparing the presentations of constructs
given in the manual with those given here, guided by the questions mentioned in
Volume 2.

Note that we do not discuss the algorithmic aspect of data processing here.
However, choosing the algorithm and the data representation that fit the requirements
of the specification is an essential step in program development. Many excellent
works have been published on this subject, and we encourage readers to explore the
subject further. We also recommend using the standard libraries provided by the
chosen programming language. These libraries include tried and tested
implementations for many different algorithms, which may generally be assumed to
be correct.
1

From Hardware to Software

This first chapter provides a brief overview of the components found in all
computers, from mainframes to the processing chips in tablets, smartphones and
smart objects via desktop or laptop computers. Building on this hardware-centric
presentation, we shall then give a more abstract description of the actions carried out
by computers, leading to a uniform definition of the terms “program” and
“execution”, above and beyond the various characteristics of so-called electronic
devices.

1.1. Computers: a low-level view

Computer science is the science of rational processing of information by


computers. Computers have the capacity to carry out a variety of processes,
depending on the instructions given to them. Each item of information is an element
of knowledge that may be transmitted using a signal and encoded using a sequence of
symbols in conjunction with a set of rules used to decode them, i.e. to reconstruct the
signal from the sequence of symbols. Computers use binary encoding, involving two
symbols; these may be referred to as “true”/“false”, “0”/“1” or “high”/“low”; these
terms are interchangeable, and all represent the two stable states of the electrical
potential of digital electronic circuits.

1.1.1. Information processing

Schematically, a computer is made up of three families of components as follows:


– memories: store data (information) and executable code (the so-called von
Neumann architecture);
– one or more microprocessors, known as CPUs (central processing units), which
process information by applying elementary operations;

Concepts and Semantics of Programming Languages 1:


A Semantical Approach with OCaml and Python, First Edition. Thérèse Hardin,
Mathieu Jaume, François Pessaux and Véronique Viguié Donzeau-Gouge.
© ISTE Ltd 2021. Published by ISTE Ltd and John Wiley & Sons, Inc.
2 Concepts and Semantics of Programming Languages 1

– peripherals: these enable information to be exchanged between the


CPU/memory couple and the outside.

Information processing by a computer – in other terms, the execution of a


program – can be summarized as a sequence of three steps: fetching data, computing
the results and returning them. Each elementary processing operation corresponds to
a configuration of the logical circuits of the CPU, known as a logic function. If the
result of this function is solely dependent on input, and if no notion of “time” is
involved in the computations, then the function is said to be combinatorial;
otherwise, it is said to be sequential.

For example, a binary half-adder, as shown in Figure 1.1, is a circuit that


computes the sum of two binary digits (input), along with the possible carry value. It
thus implements a combinatorial logic function.

Bit 0 Sum
or
Bit 1

and Carry

Figure 1.1. Binary half-adder

The essential character of a combinatorial function is that, for the same input, the
function always produces the same output, no matter what the circumstances. This is
not true of sequential logic functions.

For example, a logic function that counts the number of times its input changes
relies on a notion of “time” (changes take place in time), and a persistent state between
two inputs is required in order to record the previous value of the counter. This state is
saved in a memory. For sequential functions, a same input value can result in different
output values, as every output depends not only on the input, but also on the state of
the memory at the moment of reading the new input.

1.1.2. Memories

Computers use memory to save programs and data. There are several different
technologies used in memory components, and a simplified presentation is as follows:
– RAM (Random Access Memory): RAM memory is both readable and writeable.
RAM components are generally fast, but also volatile: if electric power falls down,
their content is lost;
From Hardware to Software 3

– ROM (Read Only Memory): information stored in a ROM is written at the time
of manufacturing, and it is read-only. ROM is slower than RAM, but is non-volatile,
like, for example, a burned DVD;
– EPROM (Erasable Programmable Read Only Memory): this memory is
non-volatile, but can be written using a specific device, through exposure to ultra-
violet light, or by modifying the power voltage, etc. It is slower than RAM, for both
reading and writing. EPROM may be considered equivalent to a rewritable DVD.

Computers use the memory components of several technologies. Storage size


diminishes as access speed increases, as fast-access memory is more costly. A
distinction is generally made between four different types of memory:
– mass storage is measured in terabytes and is made either of mechanical disks
(with an access time of ∼ 10 ms) or – increasingly – of solid-state drive (SSD) blocks.
These blocks use an EEPROM variant (electrically erasable) with an access time of
∼ 0.1−0.3 ms, known as flash memory. Mass storage is non-volatile and is principally
used for the file system;
– RAM, which is external to the microprocessor. Recent home computers and
smartphones generally possess large RAM capacities (measured in gigabytes).
Embedded systems or consumer development electronic boards may have a much
lower RAM capacity. The access time is around 40–50 ηs;
– the cache is generally included in the CPU of modern machines. This is a small
RAM memory of a few kilobytes (or megabytes), with an access time of around
5−10 ηs. There are often multiple levels of cache, and access time decreases with size.
The cache is used to save frequently used and/or consecutive data and/or instructions,
reducing the need to access slower RAM by retaining information locally. Cache
management is complex: it is important to ensure consistency between the data in
the main memory and the cache, between different CPUs or different cores (full,
independent processing units within the same CPU) and to decide which data to
discard to free up space, etc.;
– registers are the fastest memory units and are located in the center of the
microprocessor itself. The microprocessor contains a limited number (a few dozen)
of these storage zones, used directly by CPU instructions. Access time is around one
processor cycle, i.e. around 1 ns.

1.1.3. CPUs

The CPU, as its name suggests, is the unit responsible for processing information,
via the execution of elementary instructions, which can be roughly grouped into five
categories:
– data transfer instructions (copy between registers or between memory and
registers);
4 Concepts and Semantics of Programming Languages 1

– arithmetic instructions (addition of two integer values contained in two registers,


multiplication by a constant, etc.);
– logical instructions (bit-wise and/or/not, shift, rotate, etc.);
– branching operations (conditional, non-conditional, to subroutines, etc.);
– other instructions (halt the processor, reset, interrupt requests, test-and-set,
compare-and-swap, etc.).

Instructions are coded by binary words in a format specific to each microprocessor.


A program of a few lines in a high-level programming language is translated into tens
or even hundreds of elementary instructions, which would be difficult, error prone
and time consuming to write out manually. This is illustrated in Figure 1.2, where a
“Hello World!” program written in C is shown alongside its counterpart in x86-64
instructions, generated by the gcc compiler.
. s e c t i o n __TEXT
. g l o b l _main
. a l i g n 4 , 0 x90
_main :
. cfi_startproc
## BB# 0 :
pushq %r b p
Ltmp0 :
. c f i _ d e f _ c f a _ o f f s e t 16
Ltmp1 :
. c f i _ o f f s e t %rbp , −16
movq %r s p , %r b p
# include < s t d i o . h> Ltmp2 :
i n t main () { . c f i _ d e f _ c f a _ r e g i s t e r %r b p
printf ( " Hello world ! \ n " ) ; subq $16 , %r s p
return (0) ; leaq L_ . s t r (% r i p ) , %r d i
} movl $0 , −4(%r b p )
movb $0 , %a l
callq _printf
xorl %ecx , %e c x
movl %eax , −8(%r b p )
movl %ecx , %e a x
addq $16 , %r s p
popq %r b p
retq
. cfi_endproc
. s e c t i o n __TEXT
L_ . s t r :
. a s c i z " Hello world ! \ n "

Figure 1.2. “Hello world!” in C and in x86-64 instructions

Put simply, a microprocessor is split into two parts: a control unit, which decodes
and sequences the instructions to execute, and one or more arithmetic and logic units
(ALUs) , which carry out the operations stipulated by the instructions. The CPU runs
permanently through a three-stage cycle:
Another random document with
no related content on Scribd:
„Jawel, Raffles!” herhaalde Marholm en keerde zich tot Baxter.

„Hij heeft u hier binnengebracht en u ook weer uit uw weinig


benijdenswaardige positie bevrijd. Zijn bedoeling was het, dat gij door
eigen aanschouwing de misdaden van dr. Braddon zoudt leeren
kennen.”

„En dat was, bij God, meer dan tijd,” sprak de inspecteur van politie
Baxter. „Deze mensch daar”—hij wees op den verpletterden
geneesheer-directeur—„is erger dan de gevreesde Jack the Ripper.”

Hij trad op den in zijn stoel sidderenden dr. Braddon toe, liet zijn hand
zwaar op diens schouder vallen, en sprak:

„In naam van de Engelsche wet neem ik u gevangen, dr. Braddon! en


beschuldig u van moord en zeer veel andere misdaden, waarmede ik het
gerecht in kennis zal stellen.”

Allereerst werd dr. Braddon zwaar geboeid uit de inrichting geleid,


daarop volgde de hoofdverpleger en eindelijk het geheele personeel.

De gevangenwagens boden niet voldoende plaats voor alle


gevangenen.

Spoedig daarop traden doktoren uit de ziekenhuizen het


krankzinnigengesticht binnen, om de verpleging der patiënten over te
nemen.

Afschuwelijke vertrekken werden gevonden, waarin zich de


ongelukkigen jarenlang moesten ophouden.

„Deze misdaden zijn zwaarder en verdienen grootere [31]straf,” sprak de


inspecteur van politie Baxter tot Marholm, „dan die van dieven en
moordenaars.”

Het Londensche publiek geraakte in koortsachtige opgewondenheid,


toen de couranten de eerste berichten brachten over den inval der
detectives in het krankzinnigengesticht en de gevangenneming van den
gekkendokter.

Duizenden vloeken werden uitgebraakt tegen dr. Braddon, maar ook


werd er hartelijk gelachen, toen het publiek uit de nieuwsbladen vernam,
hoe het nieuwste meesterstuk van John Raffles ook nu weer schitterend
was gelukt.

Lord Guildhall was gevlucht en had zijn onrechtmatig verkregen


vermogen, overeenkomstig den wensch van Raffles, aan de stad
Londen vermaakt.

Bijna iedere dag van onderzoek bracht nieuwe misdaden uit het
krankzinnigengesticht aan het licht en steeds weer was het die eene
naam, waarvan de geheele pers met lof gewaagde—de naam van den
genialen meesterdief John Raffles!

[Inhoud]

Het volgende deel (No. 27) zal bevatten:

LETTER R. 100. [32]

[Inhoud]

Verrassend! Boeiend!
In den Roman-Boekhandel voorheen A.
EICHLER te Amsterdam verschijnt in 14-
daagsche afleveringen:

BUFFALO BILL,
Amerika’s grootste Meester-verkenner.

Elke aflevering bevat een afgerond verhaal.

Buffalo Bill vertelt daarin op eenvoudige, doch pakkende,


aandoenlijke wijze van zijn avonturen met struikroovers,
roodhuiden, bandieten, enz.

SPANNENDE LECTUUR, VOL


SENSATIE-WEKKENDE TOONEELTJES.

ELKE AFLEVERING KOST SLECHTS 10


CENT [33]

[Inhoud]

Belooning: 1000 pond sterling.

Wie kent Wie heeft


hem? hem
gezien?

Dat vraagt
men in Dat vraagt
Scotland heel Londen!
Yard!

Lord Lister genaamd John C. Raffles, de


geniaalste aller dieven

brengt alle gemoederen in beweging, is de schrik van woekeraars en


geldschieters; ontrooft hun door zijn listen hunne bezittingen, waarmede
hij belaagde onschuld beschermt en behoeftigen ondersteunt.

Man van eer in alle opzichten

spant hij wet en gerecht menigen strik en heeft steeds de voorvechters


van edele levensbeschouwing op zijn hand, nl. allen, die ervan overtuigd
zijn, dat:

Ongestraft veel misstanden, door de wet beschermd,


blijven voortwoekeren.
Men leze, hoe alles in het werk wordt gesteld, Lord Lister, genaamd
John C. Raffles, den geniaalsten aller dieven, te vatten!

[Inhoud]

Vertaling:
WARRANT OF
ARREST. Bevel tot aanhouding.

Be it known unto all men by these Wij verzoeken de aanhouding van


presents that we hereby charge and den man, wiens beschrijving hier
warrant the apprehension of the man volgt:
described as under:

DESCRIPTION: Beschrijving:

Name: Lord Edward Naam: Lord Edward


Lister, alias John Lister, genaamd
C. Raffles. John C. Raffles.
Age: 32 to 35 years. Leeftijd: 32–35 jaar.
Height: 5 feet nine inches. Lengte: ongeveer 1,76
Weight: 176 pounds. meter.
Figure: Tall. Gewicht: 80 kilo.
C o m p l e x i o n : Dark. Gestalte: slank.
Hair: Black. G e l a a t s k l e u r : donker.
Beard: A slight Haar: zwart.
moustache. Baardgroei: kleine snor.
Eyes: Black. Oogen: zwart.
Language: English, French, Spreekt Engelsch,
German, Russian, Fransch,
etc. Duitsch,
Russisch enz.
enz.

S p e c i a l n o t e s : The man poses Bijzondere kenteekenen:


as a gentleman of great distinction. Het optreden van den man kenmerkt
Adopts a new role every other day. zich door bijzonder goede manieren.
Wears an eyeglass. Always Telkens een ander uiterlijk. Draagt
een monocle. Is in gezelschap van
accompanied by a young man— een jongeman, wiens naam
name unknown. onbekend.

Charged with robbery. Moet worden aangehouden als dief.


Voor zijn aanhouding betalen wij een
A reward of 1000 pounds sterling will prijs van 1000 pond sterling.
be paid for the arrest of this man.

Headquarters—Scotland Yard. Het Hoofdbureau van Politie


Scotland Yard.
L o n d o n , 1st October 1908.
L o n d e n , 1. Oktober 1908.
Police Inspector,
H o r n y. Inspecteur van Politie
(get.) H o r n y .

[Inhoud]

Roman-Boekhandel voorheen A. Eichler

Singel 236—Amsterdam.
Inhoudsopgave

I. HET KRIJGSPLAN VAN RAFFLES. 1


II. RAFFLES BIJ DEN KONING DER GEKKEN. 5
III. TWEE HEEREN DIENEN. 8
IV. IN HET KRANKZINNIGENGESTICHT. 11
V. RAFFLES IN HET GESTICHT. 16
VI. DE INVAL IN HET KRANKZINNIGENGESTICHT. 27
Colofon
Beschikbaarheid

Dit eBoek is voor kosteloos gebruik door iedereen overal, met vrijwel
geen beperkingen van welke soort dan ook. U mag het kopiëren,
weggeven of hergebruiken onder de voorwaarden van de Project
Gutenberg Licentie in dit eBoek of on-line op www.gutenberg.org ↗️.

Dit eBoek is geproduceerd door het on-line gedistribueerd correctieteam


op www.pgdp.net ↗️.

De oorspronkelijke Duitse titel is: Polizeiinspektor Baxter im Irrenhause.

Metadata

Titel: Lord Lister No. 26: Inspecteur Baxter in het


krankzinnigengesticht
Auteur: Theo von Blankensee [Pseudoniem van Info ↗️
Mathias Blank (1881–1928)]
Auteur: Kurt Matull (1872–1930?) Info ↗️
Aanmaakdatum 2023-12-23 13:46:12 UTC
bestand:
Taal: Nederlands (Spelling De Vries-Te Winkel)
Oorspronkelijke [1911]
uitgiftedatum:
Trefwoorden: Detective and mystery stories -- Periodicals
Dime novels -- Periodicals

Codering

Dit boek is weergegeven in oorspronkelijke schrijfwijze. Afgebroken


woorden aan het einde van de regel zijn stilzwijgend hersteld. Kennelijke
zetfouten in het origineel zijn verbeterd. Deze verbeteringen zijn
aangegeven in de colofon aan het einde van dit boek.
Documentgeschiedenis

2023-12-18 Begonnen.

Verbeteringen

De volgende verbeteringen zijn aangebracht in de tekst:

Bladzijde Bron Verbetering Bewerkingsafstand


1, 33 [Niet in bron] . 1
2 , [Verwijderd] 1
2 teruggesturd teruggestuurd 1
2 onder langs onderlangs 1
Passim. [Niet in bron] „ 1
3, 3 millionair millionnair 1
3 milioenen millioenen 1
7 Zij Zijn 1
7, 14 adsistent assistent 1
7, 14, 14,
22 [Niet in bron] ” 1
9 sousterrain souterrain 1
11 KRANKZINNIGEN
GESTICHT KRANKZINNIGENGESTICHT 1
13, 18 ’ ” 1
14, 14 [Niet in bron] „„ 2
16 afschuwd afschuw 1
17 verlpegers verplegers 2
18 Bailay Bailey 1
18 ? . 1
19 toegeeigend toegeëigend 1/0
22 hijde hijgde 1
23 nu nu nu 3
24 overschillige onverschillige 1
24 ” [Verwijderd] 1
27, 27,
27 telephoon telefoon 2
27 telephoneerde telefoneerde 2
28 patient patiënt 1/0
28 telephoonhoorn telefoonhoorn 2
29 [Niet in bron] , 1
30 Jacq Jack 1
33 Sinclair Raffles 7
33 Scotland-Yard Scotland Yard 1
33 Inspekteur Inspecteur 1
*** END OF THE PROJECT GUTENBERG EBOOK LORD LISTER
NO. 0026: INSPECTEUR BAXTER IN HET
KRANKZINNIGENGESTICHT ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright
in these works, so the Foundation (and you!) can copy and
distribute it in the United States without permission and without
paying copyright royalties. Special rules, set forth in the General
Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree to
abide by all the terms of this agreement, you must cease using
and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project
Gutenberg™ works in compliance with the terms of this
agreement for keeping the Project Gutenberg™ name
associated with the work. You can easily comply with the terms
of this agreement by keeping this work in the same format with
its attached full Project Gutenberg™ License when you share it
without charge with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.

1.E. Unless you have removed all references to Project


Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:

This eBook is for the use of anyone anywhere in the


United States and most other parts of the world at no
cost and with almost no restrictions whatsoever. You may
copy it, give it away or re-use it under the terms of the
Project Gutenberg License included with this eBook or
online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the
country where you are located before using this eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is


derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of the
copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is


posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.
1.E.5. Do not copy, display, perform, distribute or redistribute
this electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the
Project Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must, at
no additional cost, fee or expense to the user, provide a copy, a
means of exporting a copy, or a means of obtaining a copy upon
request, of the work in its original “Plain Vanilla ASCII” or other
form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™
works unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or


providing access to or distributing Project Gutenberg™
electronic works provided that:

• You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt that
s/he does not agree to the terms of the full Project Gutenberg™
License. You must require such a user to return or destroy all
copies of the works possessed in a physical medium and
discontinue all use of and all access to other copies of Project
Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project


Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite
these efforts, Project Gutenberg™ electronic works, and the
medium on which they may be stored, may contain “Defects,”
such as, but not limited to, incomplete, inaccurate or corrupt
data, transcription errors, a copyright or other intellectual
property infringement, a defective or damaged disk or other
medium, a computer virus, or computer codes that damage or
cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES -


Except for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU
AGREE THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE,
STRICT LIABILITY, BREACH OF WARRANTY OR BREACH
OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE
TRADEMARK OWNER, AND ANY DISTRIBUTOR UNDER
THIS AGREEMENT WILL NOT BE LIABLE TO YOU FOR
ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE
OR INCIDENTAL DAMAGES EVEN IF YOU GIVE NOTICE OF
THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If


you discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person or
entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR
ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you do
or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.

Section 2. Information about the Mission of


Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status by
the Internal Revenue Service. The Foundation’s EIN or federal
tax identification number is 64-6221541. Contributions to the
Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form

You might also like