ISBN: 3540654100
TITLE: Principles of Program Analysis
AUTHOR: Nielson, Flemming; Nielson, Hanne R.; Hankin, Chris
TOC:

1 Introduction 1
1.1 The Nature of Program Analysis 1
1.2 Setting the Scene 3
1.3 Data Flow Analysis 5
1.3.1 The Equational Approach 5
1.3.2 The Constraint Based Approach 8
1.4 Constraint Based Analysis 10
1.5 Abstract Interpretation 13
1.6 Type and Effect Systems 17
1.6.1 Annotated Type Systems 18
1.6.2 Effect Systems 22
1.7 Algorithms 25
1.8 Transformations 26
Concluding Remarks 29
Mini Projects 29
Exercises 31
2 Data Flow Analysis 33
2.1 Intraprocedural Analysis 33
2.1.1 Available Expressions Analysis 37
2.1.2 Reaching Definitions Analysis 41
2.1.3 Very Busy Expressions Analysis 44
2.1.4 Live Variables Analysis 47
2.1.5 Derived Data Flow Information 50
2.2 Theoretical Properties 52
2.2.1 Structural Operational Semantics 52
2.2.2 Correctness of Live Variables Analysis 57
2.3 Monotone Frameworks 63
2.3.1 Basic Definitions 65
2.3.2 The Examples Revisited 68
2.3.3 A Non-distributive Example 70
2.4 Equation Solving 72
2.4.1 The MFP Solution 72
2.4.2 The MOP Solution 76
2.5 Interprocedural Analysis 80
2.5.1 Structural Operational Semantics 83
2.5.2 Intraprocedural versus Interprocedural Analysis 86
2.5.3 Making Context Explicit 88
2.5.4 Call Strings as Context 93
2.5.5 Assumption Sets as Context 97
2.5.6 Flow-Sensitivity versus Flow-Insensitivity 99
2.6 Shape Analysis 102
2.6.1 Structural Operational Semantics 103
2.6.2 Shape Graphs 107
2.6.3 The Analysis 113
Concluding Remarks 126
Mini Projects 130
Exercises 133
3 Constraint Based Analysis 139
3.1 Abstract 0-CFA Analysis 139
3.1.1 The Analysis 141
3.1.2 Well-definedness of the Analysis 148
3.2 Theoretical Properties 151
3.2.1 Structural Operational Semantics 151
3.2.2 Semantic Correctness 156
3.2.3 Existence of Solutions 160
3.2.4 Coinduction versus Induction 163
3.3 Syntax Directed 0-CFA Analysis 166
3.3.1 Syntax Directed Specification 167
3.3.2 Preservation of Solutions 169
3.4 Constraint Based 0-CFA Analysis 171
3.4.1 Preservation of Solutions 173
3.4.2 Solving the Constraints 174
3.5 Adding Data Flow Analysis 180
3.5.1 Abstract Values as Powersets 180
3.5.2 Abstract Values as Complete Lattices 183
3.6 Adding Context Information 187
3.6.1 Uniform k-CFA Analysis 189
3.6.2 The Cartesian Product Algorithm 194
Concluding Remarks 196
Mini Projects 200
Exercises 203
4 Abstract Interpretation 209
4.1 A Mundane Approach to Correctness 209
4.1.1 Correctness Relations 212
4.1.2 Representation Functions 214
4.1.3 A Modest Generalisation 217
4.2 Approximation of Fixed Points 219
4.2.1 Widening Operators 222
4.2.2 Narrowing Operators 228
4.3 Galois Connections 231
4.3.1 Properties of Galois Connections 237
4.3.2 Galois Insertions 240
4.4 Systematic Design of Galois Connections 244
4.4.1 Component-wise Combinations 247
4.4.2 Other Combinations 251
4.5 Induced Operations 256
4.5.1 Inducing along the Abstraction Function 256
4.5.2 Application to Data Flow Analysis 260
4.5.3 Inducing along the Concretisation Function 265
Concluding Remarks 268
Mini Projects 272
Exercises 274
5 Type and Effect Systems 281
5.1 Control Flow Analysis 281
5.1.1 The Underlying Type System 282
5.1.2 The Analysis 285
5.2 Theoretical Properties 289
5.2.1 Natural Semantics 290
5.2.2 Semantic Correctness 292
5.2.3 Existence of Solutions 295
5.3 Inference Algorithms 298
5.3.1 An Algorithm for the Underlying Type System 298
5.3.2 An Algorithm for Control Flow Analysis 304
5.3.3 Syntactic Soundness and Completeness 310
5.3.4 Existence of Solutions 315
5.4 Effects 317
5.4.1 Side Effect Analysis 317
5.4.2 Exception Analysis 323
5.4.3 Region Inference 328
5.5 Behaviours 337
5.5.1 Communication Analysis 337
Concluding Remarks 347
Mini Projects 351
Exercises 357
6 Algorithms 363
6.1 Worklist Algorithms 363
6.1.1 The Structure of Worklist Algorithms 366
6.1.2 Iterating in LIFO and FIFO 370
6.2 Iterating in Reverse Postorder 372
6.2.1 The Round Robin Algorithm 376
6.3 Iterating Through Strong Components 379
Concluding Remarks 382
Mini Projects 385
Exercises 387
A Partially Ordered Sets 391
A.1 Basic Definitions 391
A.2 Construction of Complete Lattices 395
A.3 Chains 396
A.4 Fixed Points 400
Concluding Remarks 402
B Induction and Coinduction 403
B.1 Proof by Induction 403
B.2 Introducing Coinduction 405
B.3 Proof by Coinduction 409
Concluding Remarks 413
C Graphs and Regular Expressions 415
C.1 Graphs and Forests 415
C.2 Reverse Postorder 419
C.3 Regular Expressions 424
Concluding Remarks 425
Index of Notation 427
Index 431
Bibliography 437
END
