-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPreface.v
More file actions
177 lines (145 loc) · 8.27 KB
/
Preface.v
File metadata and controls
177 lines (145 loc) · 8.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
(** * Preface *)
(* ################################################################# *)
(** * Welcome *)
(** This electronic book is a survey of basic concepts in the
mathematical study of programs and programming languages. Topics
include advanced use of the Coq proof assistant, operational
semantics, Hoare logic, and static type systems. The exposition
is intended for a broad range of readers, from advanced
undergraduates to PhD students and researchers. No specific
background in logic or programming languages is assumed, though a
degree of mathematical maturity will be helpful.
As with all of the books in the _Software Foundations_ series,
this one is one hundred percent formalized and machine-checked:
the entire text is literally a script for Coq. It is intended to
be read alongside (or inside) an interactive session with Coq.
All the details in the text are fully formalized in Coq, and most
of the exercises are designed to be worked using Coq.
The files are organized into a sequence of core chapters, covering
about one half semester's worth of material and organized into a
coherent linear narrative, plus a number of "offshoot" chapters
covering additional topics. All the core chapters are suitable
for both upper-level undergraduate and graduate students.
The book builds on the material from _Logical Foundations_
(_Software Foundations_, volume 1). It can be used together with
that book for a one-semester course on the theory of programming
languages. Or, for classes where students who are already
familiar with some or all of the material in _Logical
Foundations_, there is plenty of additional material to fill most
of a semester from this book alone. *)
(* ################################################################# *)
(** * Overview *)
(** The book develops two main conceptual threads:
(1) formal techniques for _reasoning about the properties of
specific programs_ (e.g., the fact that a sorting function or
a compiler obeys some formal specification); and
(2) the use of _type systems_ for establishing well-behavedness
guarantees for _all_ programs in a given programming
language (e.g., the fact that well-typed Java programs cannot
be subverted at runtime).
Each of these is easily rich enough to fill a whole course in its
own right, and tackling both together naturally means that much
will be left unsaid. Nevertheless, we hope readers will find that
these themes illuminate and amplify each other and that bringing
them together creates a good foundation for digging into any of
them more deeply. Some suggestions for further reading can be
found in the [Postscript] chapter. Bibliographic information
for all cited works can be found in the file [Bib]. *)
(* ================================================================= *)
(** ** Program Verification *)
(** In the first part of the book, we introduce two broad topics of
critical importance in building reliable software (and hardware):
techniques for proving specific properties of particular
_programs_ and for proving general properties of whole programming
_languages_.
For both of these, the first thing we need is a way of
representing programs as mathematical objects, so we can talk
about them precisely, plus ways of describing their behavior in
terms of mathematical functions or relations. Our main tools for
these tasks are _abstract syntax_ and _operational semantics_, a
method of specifying programming languages by writing abstract
interpreters. At the beginning, we work with operational
semantics in the so-called "big-step" style, which leads to simple
and readable definitions when it is applicable. Later on, we
switch to a lower-level "small-step" style, which helps make some
useful distinctions (e.g., between different sorts of
nonterminating program behaviors) and which is applicable to a
broader range of language features, including concurrency.
The first programming language we consider in detail is _Imp_, a
tiny toy language capturing the core features of conventional
imperative programming: variables, assignment, conditionals, and
loops.
We study two different ways of reasoning about the properties of
Imp programs. First, we consider what it means to say that two
Imp programs are _equivalent_ in the intuitive sense that they
exhibit the same behavior when started in any initial memory
state. This notion of equivalence then becomes a criterion for
judging the correctness of _metaprograms_ -- programs that
manipulate other programs, such as compilers and optimizers. We
build a simple optimizer for Imp and prove that it is correct.
Second, we develop a methodology for proving that a given Imp
program satisfies some formal specifications of its behavior. We
introduce the notion of _Hoare triples_ -- Imp programs annotated
with pre- and post-conditions describing what they expect to be
true about the memory in which they are started and what they
promise to make true about the memory in which they terminate --
and the reasoning principles of _Hoare Logic_, a domain-specific
logic specialized for convenient compositional reasoning about
imperative programs, with concepts like "loop invariant" built in.
This part of the course is intended to give readers a taste of the
key ideas and mathematical tools used in a wide variety of
real-world software and hardware verification tasks. *)
(* ================================================================= *)
(** ** Type Systems *)
(** Our other major topic, covering approximately the second half of
the book, is _type systems_ -- powerful tools for establishing
properties of _all_ programs in a given language.
Type systems are the best established and most popular example of
a highly successful class of formal verification techniques known
as _lightweight formal methods_. These are reasoning techniques
of modest power -- modest enough that automatic checkers can be
built into compilers, linkers, or program analyzers and thus be
applied even by programmers unfamiliar with the underlying
theories. Other examples of lightweight formal methods include
hardware and software model checkers, contract checkers, and
run-time monitoring techniques.
This also completes a full circle with the beginning of the book:
the language whose properties we study in this part, the _simply
typed lambda-calculus_, is essentially a simplified model of the
core of Coq itself!
*)
(* ================================================================= *)
(** ** Further Reading *)
(** This text is intended to be self contained, but readers looking
for a deeper treatment of particular topics will find some
suggestions for further reading in the [Postscript]
chapter. *)
(* ################################################################# *)
(** * Practicalities *)
(* ================================================================= *)
(** ** Recommended Citation Format *)
(** If you want to refer to this volume in your own writing, please
do so as follows:
@book {$FIRSTAUTHOR:SF$VOLUMENUMBER,
author = {$AUTHORS},
title = "$VOLUMENAME",
series = "Software Foundations",
volume = "$VOLUMENUMBER",
year = "$VOLUMEYEAR",
publisher = "Electronic textbook",
note = {Version $VERSION, \URLhttp://softwarefoundations.cis.upenn.edu },
}
*)
(* ################################################################# *)
(** * Note for Instructors *)
(** If you plan to use these materials in your own course, you will
undoubtedly find things you'd like to change, improve, or add.
Your contributions are welcome! Please see the [Preface]
to _Logical Foundations_ for instructions. *)
(* ################################################################# *)
(** * Thanks *)
(** Development of the _Software Foundations_ series has been
supported, in part, by the National Science Foundation under the
NSF Expeditions grant 1521523, _The Science of Deep
Specification_. *)
(* 2020-09-09 21:08 *)