Stump's Programming Language Foundations is a short concise text that covers semantics, equally weighting operational and denotational semantics for several different programming paradigms: imperative, concurrent, and functional. Programming Language Foundations provides: an even coverage of denotational, operational an axiomatic semantics; extensions to concurrent and non-deterministic versions; operational semantics for untyped lambda calculus; functional programming; type systems; and coverage of emerging topics and modern research directions.

Preface 1

**I Central Topics 7**

**1 Semantics of First-Order Arithmetic 9**

1.1 Syntax of FO(**Z**) terms 10

1.2 Informal semantics of FO(**Z**) terms 10

1.3 Syntax of FO(**Z**) formulas 11

1.4 Some alternative logical languages for arithmetic 12

1.5 Informal semantics of FO(**Z**) formulas 13

1.6 Formal semantics of FO(**Z**) terms 14

1.6.1 Examples 17

1.7 Formal semantics of FO(**Z**) formulas 18

1.7.1 Examples 18

1.8 Compositionality 19

1.9 Validity and satisfiability 19

1.10 Interlude: proof by natural-number induction 20

1.11 Proof by structural induction 27

1.12 Conclusion 28

1.13 Basic exercises 29

1.14 Intermediate exercises 30

**2 Denotational Semantics of W****HILE ****33**

2.1 Syntax and informal semantics of WHILE 33

2.2 Beginning of the formal semantics for WHILE 34

2.3 Problem with the semantics of while-commands 35

2.4 Domains 37

2.5 Continuous functions 42

2.6 The least fixed-point theorem 46

2.7 Completing the formal semantics of commands 48

2.8 Connection to practice: static analysis using abstract interpretation 54

2.9 Conclusion 59

2.10 Basic exercises 60

2.11 Intermediate exercises 62

**3 Axiomatic Semantics of W****HILE ****65**

3.1 Denotational equivalence 66

3.2 Partial correctness assertions 68

3.3 Interlude: rules and derivations 71

3.4 Hoare Logic rules 76

3.5 Example derivations in Hoare Logic 82

3.6 Soundness of Hoare Logic and induction on the structure of derivations 87

3.7 Conclusion 92

3.8 Exercises 92

**4 Operational Semantics of W****HILE ****95**

4.1 Big-step semantics of WHILE 95

4.2 Small-step semantics of WHILE 97

4.3 Relating the two operational semantics 101

4.4 Conclusion 120

4.5 Basic exercises 120

4.6 Intermediate exercises 122

**5 Untyped Lambda Calculus 125**

5.1 Abstract syntax of untyped lambda calculus 125

5.2 Operational semantics: full *b*-reduction 127

5.3 Defining full *b*-reduction with contexts 132

5.4 Specifying other reduction orders with contexts 134

5.5 Big-step call-by-value operational semantics 137

5.6 Relating big-step and small-step operational semantics 138

5.7 Conclusion 142

5.8 Basic Exercises 143

5.9 Intermediate Exercises 147

5.10 More Challenging Exercises 147

**6 Programming in Untyped Lambda Calculus 149**

6.1 The Church encoding for datatypes 149

6.2 The Scott encoding for datatypes 156

6.3 Other datatypes: lists 158

6.4 Non-recursive operations on Scott-encoded data 158

6.5 Recursive equations and the fix operator 160

6.6 Another recursive example: multiplication 162

6.7 Conclusion 162

6.8 Basic exercises 163

6.9 Intermediate exercises 164

**7 Simple Type Theory 167**

7.1 Abstract syntax of simple type theory 167

7.2 Semantics of types 168

7.3 Type-assignment rules 169

7.4 Semantic soundness for type-assignment rules 169

7.5 Applying semantic soundness to prove normalization 171

7.6 Type preservation 173

7.7 The Curry-Howard isomorphism 176

7.8 Algorithmic typing 183

7.9 Algorithmic typing via constraint generation 186

7.10 Subtyping 190

7.11 Conclusion 199

7.12 Basic Exercises 200

7.13 Intermediate Exercises 202

**II Extra Topics 205**

**8 Nondeterminism and Concurrency 207**

8.1 Guarded commands 207

8.2 Operational semantics of guarded commands 208

8.3 Concurrent WHILE 215

8.4 Operational semantics of concurrent WHILE 216

8.5 Milner’s Calculus of Communicating Systems 219

8.6 Operational semantics of CCS 220

8.7 Conclusion 226

8.8 Basic exercises 226

8.9 Intermediate exercises 228

**9 More on Untyped Lambda Calculus 231**

9.1 Confluence of untyped lambda calculus 231

9.2 Combinators 259

9.3 Conclusion 266

9.4 Basic exercises 266

9.5 Intermediate exercises 267

**10 Polymorphic Type Theory 269**

10.1 Type-assignment version of System F 269

10.2 Annotated terms for System F 271

10.3 Semantics of annotated System F 272

10.4 Programming with Church-encoded data 274

10.5 Higher-kind polymorphism and System F*w * 276

10.6 Conclusion 283

10.7 Exercises 283

**11 Functional Programming 285**

11.1 Call-by-value functional programming 286

11.2 Connection to practice: eager FP in OCaml

11.3 Lazy programming with call-by-name evaluation 300

11.4 Connection to practice: lazy FP in Haskell 304

11.5 Conclusion 310

11.6 Basic Exercises 310

11.7 Intermediate exercises 312

**Mathematical Background 315**

**Bibliography 321**

**Index 325**