28
DRAFT Roberto Bruni, Ugo Montanari Models of Computation – Monograph – April 11, 2016 Springer

Roberto Bruni, Ugo Montanarididawiki.cli.di.unipi.it/lib/exe/fetch.php/magistrale...DRAFT Mathematical reasoning may be regarded rather schematically as the exercise of a combination

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

  • DRAF

    TRoberto Bruni, Ugo Montanari

    Models of Computation

    – Monograph –

    April 11, 2016

    Springer

  • DRAF

    TMathematical reasoning may be regardedrather schematically as the exercise of acombination of two facilities, which we maycall intuition and ingenuity.Alan Turing1

    1 The purpose of ordinal logics (from Systems of Logic Based on Ordinals), Proceedings of theLondon Mathematical Society, series 2, vol. 45, 1939.

  • DRAF

    TContents

    Part I Preliminaries

    1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.1 Structure and Meaning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    1.1.1 Syntax, Types and Pragmatics . . . . . . . . . . . . . . . . . . . . . . . . . . 41.1.2 Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.1.3 Mathematical Models of Computation . . . . . . . . . . . . . . . . . . . 6

    1.2 A Taste of Semantics Methods: Numerical Expressions . . . . . . . . . . . 91.3 Applications of Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171.4 Key Topics and Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

    1.4.1 Induction and Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201.4.2 Semantic Domains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211.4.3 Bisimulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231.4.4 Temporal and Modal Logics . . . . . . . . . . . . . . . . . . . . . . . . . . . 251.4.5 Probabilistic Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

    1.5 Chapters Contents and Reading Guide . . . . . . . . . . . . . . . . . . . . . . . . . 261.6 Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

    2 Preliminaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332.1 Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

    2.1.1 Basic Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332.1.2 Signatures and Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342.1.3 Substitutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352.1.4 Unification Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

    2.2 Inference Rules and Logical Systems . . . . . . . . . . . . . . . . . . . . . . . . . . 372.3 Logic Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

    Part II IMP: a simple imperative language

    xv

  • DRAF

    T

    xvi Contents

    3 Operational Semantics of IMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533.1 Syntax of IMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

    3.1.1 Arithmetic Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543.1.2 Boolean Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543.1.3 Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553.1.4 Abstract Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

    3.2 Operational Semantics of IMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563.2.1 Memory State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563.2.2 Inference Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573.2.3 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

    3.3 Abstract Semantics: Equivalence of Expressions and Commands . . . 663.3.1 Examples: Simple Equivalence Proofs . . . . . . . . . . . . . . . . . . . 673.3.2 Examples: Parametric Equivalence Proofs . . . . . . . . . . . . . . . 693.3.3 Examples: Inequality Proofs . . . . . . . . . . . . . . . . . . . . . . . . . . . 713.3.4 Examples: Diverging Computations . . . . . . . . . . . . . . . . . . . . . 73

    Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

    4 Induction and Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 794.1 Noether Principle of Well-founded Induction . . . . . . . . . . . . . . . . . . . 79

    4.1.1 Well-founded Relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 794.1.2 Noether Induction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 854.1.3 Weak Mathematical Induction . . . . . . . . . . . . . . . . . . . . . . . . . 864.1.4 Strong Mathematical Induction . . . . . . . . . . . . . . . . . . . . . . . . . 874.1.5 Structural Induction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 874.1.6 Induction on Derivations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 904.1.7 Rule Induction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

    4.2 Well-founded Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

    5 Partial Orders and Fixpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1055.1 Orders and Continuous Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

    5.1.1 Orders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1065.1.2 Hasse Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1085.1.3 Chains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1115.1.4 Complete Partial Orders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113

    5.2 Continuity and Fixpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1165.2.1 Monotone and Continuous Functions . . . . . . . . . . . . . . . . . . . . 1165.2.2 Fixpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

    5.3 Immediate Consequence Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1225.3.1 The Operator bR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1225.3.2 Fixpoint of bR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

    Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126

  • DRAF

    T

    Contents xvii

    6 Denotational Semantics of IMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1296.1 l -Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

    6.1.1 l -Notation: Main Ideas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1306.1.2 Alpha-Conversion, Beta-Rule and Capture-Avoiding

    Substitution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1336.2 Denotational Semantics of IMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

    6.2.1 Denotational Semantics of Arithmetic Expressions: TheFunction A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136

    6.2.2 Denotational Semantics of Boolean Expressions: TheFunction B . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137

    6.2.3 Denotational Semantics of Commands: The Function C . . . . 1386.3 Equivalence Between Operational and Denotational Semantics . . . . 143

    6.3.1 Equivalence Proofs For Expressions . . . . . . . . . . . . . . . . . . . . 1436.3.2 Equivalence Proof for Commands . . . . . . . . . . . . . . . . . . . . . . 144

    6.4 Computational Induction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154

    Part III HOFL: a higher-order functional language

    7 Operational Semantics of HOFL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1597.1 Syntax of HOFL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159

    7.1.1 Typed Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1607.1.2 Typability and Typechecking . . . . . . . . . . . . . . . . . . . . . . . . . . 162

    7.2 Operational Semantics of HOFL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173

    8 Domain Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1778.1 The Flat Domain of Integer Numbers Z? . . . . . . . . . . . . . . . . . . . . . . . 1778.2 Cartesian Product of Two Domains . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1788.3 Functional Domains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1808.4 Lifting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1838.5 Function’s Continuity Theorems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1858.6 Apply, Curry and Fix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192

    9 HOFL Denotational Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1939.1 HOFL Semantic Domains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1939.2 HOFL Evaluation Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194

    9.2.1 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1949.2.2 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1949.2.3 Binary Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1959.2.4 Conditional . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1959.2.5 Pairing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1969.2.6 Projections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1969.2.7 Lambda Abstraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1979.2.8 Function Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

  • DRAF

    T

    xviii Contents

    9.2.9 Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1979.3 Continuity of Meta-language’s Functions . . . . . . . . . . . . . . . . . . . . . . . 1999.4 Substitution Lemma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202

    10 Equivalence between HOFL denotational and operational semantics . 20510.1 Completeness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20610.2 Equivalence (on Convergence) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20910.3 Operational and Denotational Equivalences of Terms . . . . . . . . . . . . . 21110.4 A Simpler Denotational Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213

    Part IV Concurrent Systems

    11 CCS, the Calculus for Communicating Systems . . . . . . . . . . . . . . . . . . . . 21911.1 Syntax of CCS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22411.2 Operational Semantics of CCS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225

    11.2.1 Action Prefix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22611.2.2 Restriction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22611.2.3 Relabelling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22611.2.4 Choice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22711.2.5 Parallel Composition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22711.2.6 Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22811.2.7 CCS with Value Passing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23111.2.8 Recursive Declarations and the Recursion Operator . . . . . . . . 232

    11.3 Abstract Semantics of CCS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23411.3.1 Graph Isomorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23411.3.2 Trace Equivalence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23611.3.3 Bisimilarity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237

    11.4 Compositionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24311.4.1 Bisimilarity is Preserved by Choice . . . . . . . . . . . . . . . . . . . . . 244

    11.5 A Logical View to Bisimilarity: Hennessy-Milner Logic . . . . . . . . . . 24511.6 Axioms for Strong Bisimilarity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24811.7 Weak Semantics of CCS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250

    11.7.1 Weak Bisimilarity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25011.7.2 Weak Observational Congruence . . . . . . . . . . . . . . . . . . . . . . . 25211.7.3 Dynamic Bisimilarity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253

    Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254

    12 Temporal Logic and µ-Calculus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25912.1 Temporal Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259

    12.1.1 Linear Temporal Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26012.1.2 Computation Tree Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262

    12.2 µ-Calculus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26412.3 Model Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268

  • DRAF

    T

    Contents xix

    13 p-Calculus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27113.1 Name Mobility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27113.2 Syntax of the p-calculus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27413.3 Operational Semantics of the p-calculus . . . . . . . . . . . . . . . . . . . . . . . 276

    13.3.1 Action Prefix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27713.3.2 Choice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27813.3.3 Name Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27813.3.4 Parallel Composition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27813.3.5 Restriction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27913.3.6 Scope Extrusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27913.3.7 Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27913.3.8 A Sample Derivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280

    13.4 Structural Equivalence of p-calculus . . . . . . . . . . . . . . . . . . . . . . . . . . 28113.4.1 Reduction semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281

    13.5 Abstract Semantics of the p-calculus . . . . . . . . . . . . . . . . . . . . . . . . . . 28213.5.1 Strong Early Ground Bisimulations . . . . . . . . . . . . . . . . . . . . . 28313.5.2 Strong Late Ground Bisimulations . . . . . . . . . . . . . . . . . . . . . . 28413.5.3 Strong Full Bisimilarities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28513.5.4 Weak Early and Late Ground Bisimulations . . . . . . . . . . . . . . 286

    Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287

    Part V Probabilistic Systems

    14 Measure Theory and Markov Chains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29114.1 Probabilistic and Stochastic Systems . . . . . . . . . . . . . . . . . . . . . . . . . . 29114.2 Measure Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292

    14.2.1 s -field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29214.2.2 Constructing a s -field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29314.2.3 Continuous Random Variables . . . . . . . . . . . . . . . . . . . . . . . . . 29514.2.4 Stochastic Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299

    14.3 Markov Chains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29914.3.1 Discrete and Continuous Time Markov Chain . . . . . . . . . . . . 30014.3.2 DTMC as LTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30114.3.3 DTMC Steady State Distribution . . . . . . . . . . . . . . . . . . . . . . . 30314.3.4 CTMC as LTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30514.3.5 Embedded DTMC of a CTMC . . . . . . . . . . . . . . . . . . . . . . . . . 30614.3.6 CTMC Bisimilarity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30614.3.7 DTMC Bisimilarity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308

    Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309

    15 Markov Chains with Actions and Non-determinism . . . . . . . . . . . . . . . . 31315.1 Discrete Markov Chains With Actions . . . . . . . . . . . . . . . . . . . . . . . . . 313

    15.1.1 Reactive DTMC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31415.1.2 DTMC With Non-determinism . . . . . . . . . . . . . . . . . . . . . . . . . 316

    Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319

  • DRAF

    T

    xx Contents

    16 PEPA - Performance Evaluation Process Algebra . . . . . . . . . . . . . . . . . . 32116.1 From Qualitative to Quantitative Analysis . . . . . . . . . . . . . . . . . . . . . . 32116.2 CSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322

    16.2.1 Syntax of CSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32216.2.2 Operational Semantics of CSP . . . . . . . . . . . . . . . . . . . . . . . . . 323

    16.3 PEPA. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32416.3.1 Syntax of PEPA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32416.3.2 Operational Semantics of PEPA . . . . . . . . . . . . . . . . . . . . . . . . 326

    Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331

    Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335

    Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337

    Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351

  • DRAF

    TAcronyms

    ⇠ operational equivalence in IMP (see Definition 3.3)⌘den denotational equivalence in HOFL (see Definition 10.4)⌘op operational equivalence in HOFL (see Definition 10.3)' CCS strong bisimilarity (see Definition 11.5)⇡ CCS weak bisimilarity (see Definition 11.16)⇠= CCS weak observational congruence (see Section 11.7.2)⇡d CCS dynamic bisimilarity (see Definition 11.17)�⇠E p-calculus early bisimilarity (see Definition 13.3)�⇠L p-calculus late bisimilarity (see Definition 13.4)⇠E p-calculus strong early full bisimilarity (see Section 13.5.3)⇠L p-calculus strong late full bisimilarity (see Section 13.5.3)•tE p-calculus weak early bisimilarity (see Section 13.5.4)•tL p-calculus weak late bisimilarity (see Section 13.5.4)A interpretation function for the denotational semantics of IMP arithmetic

    expressions (see Section 6.2.1)ack Ackermann function (see Example 4.18)Aexp set of IMP arithmetic expressions (see Chapter 3)B interpretation function for the denotational semantics of IMP boolean

    expressions (see Section 6.2.2)Bexp set of IMP boolean expressions (see Chapter 3)B set of booleansC interpretation function for the denotational semantics of IMP com-

    mands (see Section 6.2.3)CCS Calculus of Communicating Systems (see Chapter 11)Com set of IMP commands (see Chapter 3)CPO Complete Partial Order (see Definition 5.11)CPO? Complete Partial Order with bottom (see Definition 5.12)CSP Communicating Sequential Processes (see Section 16.2)CTL Computation Tree Logic (see Section 12.1.2)CTMC Continuous Time Markov Chain (see Definition 14.15)

    xxi

  • DRAF

    T

    xxii Acronyms

    DTMC Discrete Time Markov Chain (see Definition 14.14)Env set of HOFL environments (see Chapter 9)fix (least) fixpoint (see Definition 5.2.2)FIX (greatest) fixpointgcd greatest common divisorHML Hennessy-Milner modal Logic (see Section 11.5)HM-Logic Hennessy-Milner modal Logic (see Section 11.5)HOFL A Higher-Order Functional Language (see Chapter 7)IMP A simple IMPerative language (see Chapter 3)int integer type in HOFL (see Definition 7.2)Loc set of locations (see Chapter 3)LTL Linear Temporal Logic (see Section 12.1.1)LTS Labelled Transition System (see Definition 11.2)lub least upper bound (see Definition 5.7)N set of natural numbersP set of closed CCS processes (see Definition 11.1)PEPA Performance Evaluation Process Algebra (see Chapter 16)Pf set of partial functions on natural numbers (see Example 5.13)PI set of partial injective functions on natural numbers (see Problem 5.12)PO Partial Order (see Definition 5.1)PTS Probabilistic Transition System (see Section 14.3.2)R set of real numbersT set of HOFL types (see Definition 7.2)Tf set of total functions from N to N? (see Example 5.14)Var set of HOFL variables (see Chapter 7)Z set of integers

  • DRAF

    TPart III

    HOFL: a higher-order functional language

  • DRAF

    TThis part focuses on models for sequential computations that are associated to HOFL,a higher-order declarative language that follows the functional style. Chapter 7presents the syntax, typing and operational semantics of HOFL, while Chapter 9defines its denotational semantics. The two are related in Chapter 10. Chapter 8extends the theory presented in Chapter 5 to allow the construction of more complexdomains, as needed by the type-constructors available in HOFL.

  • DRAF

    TChapter 8Domain Theory

    Order, unity and continuity are human inventions just as truly ascatalogues and encyclopedias. (Bertrand Russell)

    Abstract As done for IMP we would like to introduce the denotational semanticsof HOFL, for which we need to develop a proper domain theory that is more so-phisticated than the one presented in Chapter 5. In order to define the denotationalsemantics of IMP we have shown that the semantic domain of commands, for whichwe need to apply fixpoint theorem, has the required properties. The situation is morecomplicated for HOFL, because HOFL provides constructors for infinitely manyterm types, so there are infinitely many domains to be considered. We will handlethis problem by showing, using structural induction, that the type constructors ofHOFL correspond to domains which are equipped with adequate CPO? structuresand that we can define useful continuous functions between them.

    8.1 The Flat Domain of Integer Numbers Z?

    The first domain we introduce is very simple: it consists of all the integers numberstogether with a distinguished bottom element. It relies on a flat order in the sense ofExample 5.5.

    Definition 8.1 (Z?). We define the CPO with bottom Z? = (Z[{?},v) as follows:• Z is the set of integer numbers;• ? is a distinguished bottom element that we add to the purpose;• 8x 2 Z[{?}. ? v x and x v x

    It is immediate to check that Z? is a CPO with bottom, where ? is the bottomelement and each chain has a lub because chains are all finite: they either contain 1or 2 different elements.

    Remark 8.1. Since in this chapter we present several different domains, each comingwith its proper order relation and bottom element, we find it useful to annotate themwith the name of the domain as a subscript to avoid ambiguities. For example, wecan write ?Z? to make explicit that we are referring to the bottom element of the

    177

  • DRAF

    T

    178 8 Domain Theory

    domain Z?. Also note that the subscript ? we attach to the name of the domain Z isjust a tag and it should not be confused with the name of the bottom element itself: itis the standard way to indicate that the domain Z is enriched with a bottom element(e.g., we could have used a different notation like Z to the same purpose).

    8.2 Cartesian Product of Two Domains

    Given two CPO?s we can combine them to obtain another CPO? whose elementsare pairs formed with one element from each CPO?.

    Definition 8.2. Let:D = (D,vD) E = (E,vE)

    be two CPO?s. Now we define their Cartesian product domain

    D ⇥E = (D⇥E,vD⇥E)

    1. whose elements are the pairs of elements from D and E; and2. whose order vD⇥E is defined as follows:1

    8d0,d1 2 D, 8e0,e1 2 E. (d0,e0) vD⇥E (d1,e1) , d0 vD d1 ^ e0 vE e1

    Proposition 8.1. (D⇥E,vD⇥E) is a partial order with bottom.

    Proof. We need to show that the relation vD⇥E is reflexive, antisymmetric andtransitive:

    reflexivity: since vD and vE are reflexive we have 8e 2 E. e vE e and 8d 2D. d vD d so by definition of vD⇥E we have

    8d 2 D 8e 2 E. (d,e) vD⇥E (d,e).

    antisymmetry: let us assume (d0,e0) vD⇥E (d1,e1) and (d1,e1) vD⇥E (d0,e0) soby definition of vD⇥E we have d0 vD d1 (using the first relation)and d1 vD d0 (by using the second relation) so it must be d0 = d1and similarly e0 = e1, hence (d0,e0) = (d1,e1).

    transitivity: let us assume (d0,e0) vD⇥E (d1,e1) and (d1,e1) vD⇥E (d2,e2). Bydefinition of vD⇥E we have d0 vD d1, d1 vD d2, e0 vE e1 ande1 vE e2. By transitivity of vD and vE we have d0 vD d2 ande0 vE e2. By definition of vD⇥E we get (d0,e0) vD⇥E (d2,e2).

    Finally, we show that the there is a bottom element. Let ?D⇥E = (?D,?E). In fact8d 2 D,e 2 E. ?D v d ^?E v e, thus (?D,?E) vD⇥E (d,e). ut

    It remains to show the completeness of D ⇥E .

    1 Note that the order is different from the lexicographic one considered in Example 4.9.

  • DRAF

    T

    8.2 Cartesian Product of Two Domains 179

    Theorem 8.1 (Completeness of D ⇥E ). The PO D ⇥E defined above is complete.

    Proof. We prove that for each chain (di,ei)i2N it holds:

    G

    i2N(di,ei) =

    G

    i2Ndi,G

    i2Nei

    !

    Obviously (F

    i2N di,F

    i2N ei) is an upper bound, indeed for each j 2 N we haved j vD

    Fi2N di and e j vE

    Fi2N ei so by definition of vD⇥E it holds (d j,e j) vD⇥E

    (F

    i2N di,F

    i2N ei).Moreover (

    Fi2N di,

    Fi2N ei) is also the least upper bound. Indeed, let (d,e) be an

    upper bound of {(di,ei)}i2N, sinceF

    i2N di is the lub of {di}i2N we haveF

    i2N di vD d,furthermore we have that

    Fi2N ei is the lub of {ei}i2N then

    Fi2N ei vE e. So by

    definition of vD⇥E we have (F

    i2N di,F

    i2N ei) vD⇥E (d,e). Thus (F

    i2N di,F

    i2N ei)is the least upper bound. ut

    We can now define suitable projection operators over D ⇥E .

    Definition 8.3 (Projection operators p1 and p2 ). Let (d,e) 2 D⇥E be a pair, wedefine the left and right projection functions p1 : D⇥E ! D and p2 : D⇥E ! E asfollows.

    p1 ((d,e))def= d and p2 ((d,e))

    def= e.

    Recall that in order to use a function in domain theory we have to show that itis continuous; this ensures that the function respects the domain structure (i.e., thefunction preserves the order and limits) and so we can calculate its fixpoints to solverecursive equations. So we have to prove that each function which we use on D ⇥Eis continuous. The proof that projections are monotone is immediate and left as anexercise (see Problem 8.1).

    Theorem 8.2 (Continuity of p1 and p2). Let p1 and p2 be the projection functionsin Definition 8.3 and let {(di,ei)}i2N be a chain of elements in D ⇥E , then:

    p1

    G

    i2N(di,ei)

    !=G

    i2Np1 ((di,ei)) p2

    G

    i2N(di,ei)

    !=G

    i2Np2 ((di,ei))

    Proof. Let us prove the first statement:

    p1

    G

    i2N(di,ei)

    != p1

    G

    i2Ndi,G

    i2Nei

    !!(by definition of limit in D⇥E)

    =G

    i2Ndi (by definition of projection)

    =G

    i2Np1 ((di,ei)) (by definition of projection).

    For the second statement the proof is completely analogous. ut

  • DRAF

    T

    180 8 Domain Theory

    8.3 Functional Domains

    Let (D,vD) and (E,vE) be two CPOs. In the following we denote by D ! Edef=

    { f | f : D ! E} the set of all functions from D to E (where the order relations are notimportant), while we denote by [D ! E] ✓ D ! E the set of all continuous functionsfrom D to E (i.e., [D ! E] contains just the functions that preserve order and limits).As for Cartesian product, we can define a suitable order on the set [D ! E] to get aCPO?. Note that as usual we require the continuity of the functions to preserve theapplicability of fixpoint theory.

    Definition 8.4. Let us consider the CPO?s:

    D = (D,vD) E = (E,vE)

    We define an order on the set of continuous functions from D to E as follows:

    [D ! E ] =�[D ! E] ,v[D!E]

    where:

    1. [D ! E] = { f | f : D ! E, f is continuous}2. f v[D!E] g , 8d 2 D. f (d) vE g(d)

    We leave as an exercise the proof that [D ! E ] is a PO with bottom, namelythat the relation v[D!E] is reflexive, antisymmetric, transitive and that the function?[D!E] : D ! E defined by letting, for any d 2 D:

    ?[D!E](d)def= ?E

    is continuous and that it is also the bottom element of [D ! E ] (see Problem 8.2).We show that the PO [D ! E ] is complete. In order to simplify the proof we

    introduce first the following lemmas.

    Lemma 8.1 (Switch Lemma). Let (E,vE) be a CPO whose elements are of theform en,m with n,m 2 N. If vE is such that:

    en,m vE en0,m0 if n n0 and m m0

    then, it holds:

    G

    n,m2Nen,m =

    G

    n2N

    G

    m2Nen,m

    !=G

    m2N

    G

    n2Nen,m

    !=G

    k2Nek,k

    Proof. The relation between the elements of E can be summarized as follows:

  • DRAF

    T

    8.3 Functional Domains 181

    ......

    ...... . .

    .

    v v v v

    en,0 v en,1 v en,2 v · · · v en,m v · · ·

    v v v v

    ......

    ... . .. ...

    v v v v

    e2,0 v e2,1 v e2,2 v · · · v e2,m v · · ·

    v v v v

    e1,0 v e1,1 v e1,2 v · · · v e1,m v · · ·

    v v v v

    e0,0 v e0,1 v e0,2 v · · · v e0,m v · · ·

    We show that all the following sets have the same upper bounds:

    {en,m}n,m2N

    (G

    m2Nen,m

    )

    n2N

    (G

    n2Nen,m

    )

    m2N

    {ek,k}k2N

    • Let us consider the first two sets. For any n 2 N, let en =F

    j2N en, j. This amountsto consider each row of the above diagram and compute the least upper bound forthe elements in the same row. Clearly, en1 v en2 when n1 n2 because for anyj 2 N an upper bound of en2, j is also an upper bound of en1, j.

    ......

    ......

    ...

    v v v v v

    en,0 v en,1 v en,2 v · · · v en,m v · · · v en =F

    m2N en,m

    v v v v v

    ......

    ......

    ...

    v v v v v

    e2,0 v e2,1 v e2,2 v · · · v e2,m v · · · v e2 =F

    m2N e2,m

    v v v v v

    e1,0 v e1,1 v e1,2 v · · · v e2,m v · · · v e1 =F

    m2N e1,m

    v v v v v

    e0,0 v e0,1 v e0,2 v · · · v e2,m v · · · v e0 =F

    m2N e0,m

    Let e be an upper bound of {ei}i2N, we want to show that e is an upper bound for{en,m}n,m2N. Take any n,m 2 N. Then

    en,m vG

    j2Nen, j = en v e

    since en,m is an element of the chain {en, j} j2N whose limit is en =F

    j2N en, j. Thuse is an upper bound for {en,m}n,m2N.

  • DRAF

    T

    182 8 Domain Theory

    Vice versa, let e be an upper bound of {ei, j}i, j2N and consider en =F

    m2N en,mfor some n. Since {en,m}m2N ✓ {ei, j}i, j2N, obviously e is an upper bound for{en,m}m2N and therefore en v e, because en is the lub of {en,m}m2N.

    • The correspondence between the sets of upper bounds of {en,m}n,m2N and{F

    n2N en,m}m2N can be proved analogously.• Finally, let us consider the sets {en,m}n,m2N and {ek,k}k2N and show that they have

    the same set of upper bounds.Taken any n,m 2 N the element, let k = max{n,m}. We have

    en,m v en,k v ek,k

    thus any upper bound of {ek,k}k2N is also an upper bound of {en,m}n,m2N.Vice versa, it is immediate to check that {ek,k}k2N is a subset of {en,m}n,m2N soany upper bound of {en,m}n,m2N is also an upper bound of {ek,k}k2N.

    We conclude by noting that the set of upper bounds {en,m}n,m2N has a leastelement. In fact, {

    Fm2N en,m}n2N is a chain, and it has a lub because E is a CPO. ut

    Lemma 8.2. Let { fn}n2N be a chain of functions2 in D ! E . Then the lubF

    n2N fnexists and it is defined as:

    G

    n2Nfn

    !(d) =

    G

    n2N( fn(d))

    Proof. The functionh def= ld.

    G

    n2N( fn(d))

    is clearly an upper bound for { fn}n2N since for every k 2 N and d 2 D we havefk(d) vE

    Fn2N fn(d).

    The function h is also the lub of { fn}n2N. In fact, given any other upper bound g,i.e., such that fn vD!E g for any n 2 N, we have that for any d 2 D the element g(d)is an upper bound of the chain { fn(d)}n2N and therefore

    Fn2N( fn(d)) vE g(d). ut

    Lemma 8.3. Let { fn}n2N be a chain of continuous functions in [D ! E ] and let{dn}n2N be a chain of D . Then, the function

    h def= ld.G

    n2N( fn(d))

    is continuous, namely

    h

    G

    m2Ndm

    !=G

    m2Nh(dm)

    Furthermore, h is the lub of { fn}n2N not only in D ! E as stated by Lemma 8.2, butalso in [D ! E ].2 Note that the fn are not necessarily continuous, because we select D ! E and not [D ! E ].

  • DRAF

    T

    8.4 Lifting 183

    Proof.

    h

    G

    m2Ndm

    !=G

    n2N

    fn

    G

    m2Ndm

    !!(by definition of h)

    =G

    n2N

    G

    m2N( fn (dm))

    !(by continuity of fn)

    =G

    m2N

    G

    n2N( fn (dm))

    !by Lemma 8.1 (switch lemma)

    =G

    m2Nh(dm) (by definition of h)

    The upper bounds of { fn}n2N in the PO D ! E are a larger set then those in [D ! E ],thus if h is the lub in D ! E , it is also the lub in [D ! E ]. ut

    Theorem 8.3 ([D ! E ] is a CPO?). The PO [D ! E ] is a CPO?

    Proof. The statement follows immediately from the previous lemmas. ut

    8.4 Lifting

    In IMP we introduced a lifting operator (see Definition 6.9) on functions f : S ! S?toderive a function f ⇤ : S? ! S? defined over the lifted domain S?, and thus able tohandle the argument ?S? . In the semantics of HOFL we need the same operator in amore general fashion: we need to apply the lifting operator to any domain, not just S .

    Definition 8.5 (Lifted domain). Let D = (D,vD) be a CPO and let ? be an elementnot in D. We define the lifted domain D? = (D?,vD?) as follows:

    • D?def= {?}]D = {(0,?)}[{1}⇥D

    • ?D?def= (0,?)

    • 8x 2 D?. ?D? vD? x• 8d1,d2 2 D. d1 vD d2 ) (1,d1) vD? (1,d2)

    We leave it as an exercise to show that D? is a CPO? (see Problem 8.3).We define a lifting function b·c : D ! D? by letting, for any d 2 D:

    bdc def= (1,d)

    As it was the case for S in the IMP semantics, when we add a bottom elementto a domain D we would like to extend the continuous functions in [D ! E] tocontinuous functions in [D? ! E]. The function defining the extension should itselfbe continuous.

  • DRAF

    T

    184 8 Domain Theory

    Definition 8.6 (Lifting). Let D be a CPO and let E be a CPO?. We define the liftingoperator (·)⇤ : [D ! E] ! [D? ! E] as follows:

    8 f 2 [D ! E] . f ⇤(x) def=⇢

    ?E if x = ?D?f (d) if x = bdc

    We need to prove that the definition is well-given and that the lifting operator iscontinuous.

    Theorem 8.4. Let D ,E be two CPOs.

    1. If f : D ! E is continuous, then f ⇤ is continuous.2. The operator (·)⇤ is continuous.

    Proof. We prove the two statements separately.

    1. We need to prove that if f 2 [D ! E], then f ⇤ 2 [D? ! E]. Let {xn}n2N be achain in D?. We have to prove f ⇤(

    Fn2N xn) =

    Fn2N f ⇤(xn).

    If 8n 2 N. xn = ?D? , then this is obvious.Otherwise, for some k 2 N there must exist a set of elements {dn+k}n2N in Dsuch that for all m � k we have xm = bdmc and also

    Fn2N xn =

    Fn2N xn+k =

    bF

    n2N dn+kc (by prefix independence of the limit, Lemma 5.1). Then:

    f ⇤ G

    n2Nxn

    != f ⇤

    $G

    n2Ndn+k

    %!by the above argument

    = f

    G

    n2Ndn+k

    !by definition of lifting

    =G

    n2Nf (dn+k) by continuity of f

    =G

    n2Nf ⇤(bdn+kc) by definition of lifting

    =G

    n2Nf ⇤(xn+k) by definition of xn+k

    =G

    n2Nf ⇤(xn) by Lemma 5.1

    2. We leave the proof that (·)⇤ is monotone as an exercise (see Problem 8.4).Let { fi}i2N be a chain of functions in [D ! E ]. We will prove that for all x 2 D?:

    G

    i2Nfi

    !⇤(x) =

    G

    i2Nf ⇤i

    !(x)

    if x = ?D? both sides of the equation simplify to ?E . So let us assume x = bdcfor some d 2 D we have:

  • DRAF

    T

    8.5 Function’s Continuity Theorems 185 G

    i2Nfi

    !⇤(bdc) =

    G

    i2Nfi

    !(d) by definition of lifting

    =G

    i2N( fi(d)) by def. of lub in a functional domain

    =G

    i2N( f ⇤i (bdc)) by definition of lifting

    =

    G

    i2Nf ⇤i

    !(bdc) by def. of lub in a functional domain

    ut

    8.5 Function’s Continuity Theorems

    In this section we show some theorems which allow to prove the continuity of somefunctions. We start proving that the composition of two continuous functions iscontinuous.

    Theorem 8.5 (Continuity of composition). Let f 2 [D ! E] and g 2 [E ! F ]. Theircomposition

    f ;g = g� f def= ld. g( f (d)) : D ! F

    is a continuous function, i.e., g� f 2 [D ! F ].

    Proof. The statement is just a rephrasing of Theorem 5.5. ut

    Now we consider a function whose outcome is a pair of values. So the functionhas a single CPO as domain but it returns a result over a product of CPOs.

    f : D ! E1 ⇥E2

    For this type of functions we introduce a theorem which allows to prove the continuityof f in a convenient way. We will consider f as the pairing of two simpler functionsg1 : D ! E1 and g2 : D ! E2, such that f (d) = (g1(d),g2(d)) for any d 2 D. Thenwe can prove the continuity of f from the continuity of g1 and g2 (and vice versa).

    Theorem 8.6. Let f : D ! E1 ⇥E2 be a function over CPOs and let

    g1def= f ;p1 : D ! E1 g2

    def= f ;p2 : D ! E2

    where f ;pi = lx. pi( f (x)) is the composition of f and pi for i = 1,2. Then: f iscontinuous if and only if g1 and g2 are continuous.

    Proof. Notice that we have

  • DRAF

    T

    186 8 Domain Theory

    8d 2 D. f (d) = (g1(d),g2(d))

    We prove the two implications separately.

    )) Since f is continuous, by Theorem 8.5 (continuity of composition) and The-orem 8.2 (continuity of projections), also g1 and g2 are continuous, becausethey are obtained as the composition of continuous functions.

    () We assume the continuity of g1 and g2 and we want to prove that f is continu-ous. Let {di}i2N be a chain in D. We want to prove:

    f

    G

    i2Ndi

    !=G

    i2Nf (di)

    So we have:

    f

    G

    i2Ndi

    !=

    g1

    G

    i2Ndi

    !,g2

    G

    i2Ndi

    !!(by definition of g1,g2)

    =

    G

    i2Ng1(di),

    G

    i2Ng2(di)

    !(by continuity of g1 and g2)

    =G

    i2N(g1(di),g2(di)) (by definition of lub of pairs)

    =G

    i2Nf (di) (by definition of g1,g2)

    ut

    Now let us consider the case of a function f : D1 ⇥D2 ! E over CPOs which takesa pair of arguments in D1 and D2 and then returns an element of E. The followingtheorem allows us to study the continuity of f by analysing each parameter separately.

    Theorem 8.7. Let f : D1 ⇥D2 ! E be a function over CPOs. Then f is continuousif and only if all the functions in the following two classes are continuous:

    1. 8d0 2 D1. fd0 : D2 ! E is defined as fd0def= ly. f (d0,y);

    2. 8d00 2 D2. fd00 : D1 ! E is defined as fd00def= lx. f (x,d00).

    Proof. We prove the two implications separately:

    )) If f is continuous then for all d0 2 D1,d00 2 D2 the functions fd0 and fd00 arecontinuous, since we are considering only certain chains (where one element ofthe pair is fixed). For example, let us fix d0 2 D1 and consider a chain {d00i }i2Nin D2. Then we prove that fd0 is continuous as follows:

  • DRAF

    T

    8.5 Function’s Continuity Theorems 187

    fd0

    G

    i2Nd00i

    != f

    d0,G

    i2Nd00i

    !(by definition of fd0 )

    = f

    G

    i2N(d0,d00i )

    !(by definition of lub)

    =G

    i2Nf (d0,d00i ) (by continuity of f )

    =G

    i2Nfd0(d00i ) (by definition of fd0 )

    Similarly, if we fix d00 2 D2 and take a chain {d0i}i2N in D1 we havefd00(

    Fi2N d0i) =

    Fi2N fd00(d0i).

    () In the opposite direction, assume that fd0 and fd00are continuous for all elementsd0 2 D1 and d00 2 D2. We want to prove that f is continuous. Take a chain{(d0k,d00k )}k2N. By definition of lub on pairs, we have

    G

    k2N(d0k,d

    00k ) =

    G

    i2Nd0i ,G

    j2Nd00j

    !

    Let d00 def=F

    j2N d00j . It follows:

  • DRAF

    T

    188 8 Domain Theory

    f

    G

    k2N(d0k,d

    00k )

    != f

    G

    i2Nd0i ,G

    j2Nd00j

    !(by definition of lub on pairs)

    = f

    G

    i2Nd0i ,d

    00

    !(by definition of d00)

    = fd00

    G

    i2Nd0i

    !(by definition of fd00 )

    =G

    i2Nfd00(d0i) (by continuity of fd00 )

    =G

    i2Nf (d0i ,d

    00) (by definition of fd00 )

    =G

    i2Nfd0i (d

    00) (by definition of fd0i )

    =G

    i2Nfd0i

    G

    j2Nd00j

    !(by definition of d00)

    =G

    i2N

    G

    j2Nfd0i (d

    00j ) (by continuity of fd0i )

    =G

    i2N

    G

    j2Nf (d0i ,d

    00j ) (by definition of fd0i )

    =G

    k2Nf (d0k,d

    00k ) (by Lemma 8.1 (switch lemma))

    ut

    8.6 Apply, Curry and Fix

    As done for IMP we will use the l -notation as meta-language for the denotationalsemantics of HOFL. In Section 8.2 we have already defined two new continuousfunctions for our meta-language (p1 and p2). In this section we introduce someadditional functions that will form the kernel of our meta-language.

    Definition 8.7 (Apply). Let D and E be two CPOs. We define a function apply :[D ! E]⇥D ! E as follows:

    apply( f ,d) def= f (d)

    The function apply represents the application of a function in our meta-language: ittakes a continuous function f : D ! E and an element d 2 D and then returns f (d) as

  • DRAF

    T

    8.6 Apply, Curry and Fix 189

    a result. We leave it as an exercise to prove that apply is monotone (see Problem 8.5).We prove that it is also continuous.

    Theorem 8.8 (Continuity of apply). Let apply : [D ! E]⇥D ! E be the functiondefined above and let {( fn,dn)}n2N be a chain in the CPO? [D ! E ]⇥D then:

    apply

    G

    n2N( fn,dn)

    !=G

    n2Napply( fn,dn)

    Proof. By Theorem 8.7 we can prove the continuity on each parameter separately.

    • Let us fix d 2 D and take a chain { fn}n2N in [D ! E]. We have:

    apply

    G

    n2Nfn

    !,d

    !=

    G

    n2Nfn

    !(d) (by definition)

    =G

    n2N( fn(d)) (by definition of lub of functions)

    =G

    n2Napply( fn,d) (by definition)

    • Now we fix f 2 [D ! E] and take a chain {dn}n2N in D. We have:

    apply

    f ,G

    n2Ndn

    != f

    G

    n2Ndn

    !(by definition)

    =G

    n2Nf (dn) (by continuity of f )

    =G

    n2Napply( f ,dn) (by definition)

    So apply is a continuous function. ut

    Currying is the name of a technique for transforming a function that takes a pair(or, more generally, a tuple) of arguments into a function that takes each argumentseparately but computes the same result.

    Definition 8.8 (Curry and un-curry). We define the function

    curry : (D⇥E ! F) ! (D ! E ! F)

    by letting, for any g : D⇥E ! F , d 2 D and e 2 E:

    curry g d e def= g(d,e)

    And we define the function

    un-curry : (D ! E ! F) ! (D⇥E ! F)

  • DRAF

    T

    190 8 Domain Theory

    by letting, for any h : D ! E ! F , d 2 D and e 2 E:

    un-curry h (d,e) def= h d e

    Theorem 8.9 (Continuity of curry). Let D,E,F be CPOs and g : D⇥E ! F be acontinuous function. Then (curryg) : D ! (E ! F) is a continuous function, namelygiven any chain {di}i2N in D:

    (curry g)

    G

    i2Ndi

    !=G

    i2N(curry g)(di).

    Proof. Let us note that since g is continuous, by Theorem 8.7, g is continuousseparately on each argument. Then let us take e 2 E we have:

    (curry g)

    G

    i2Ndi

    !(e) = g

    G

    i2Ndi

    !,e

    !(by definition of curry g)

    =G

    i2Ng(di,e) (by continuity of g)

    =G

    i2N((curry g)(di)(e)) (by definition of curry g)

    ut

    To define the denotational semantics of recursive definitions we need to provide afixpoint operator. So it seems useful to introduce fix in our meta-language.

    Definition 8.9 (Fix). Let D be a CPO?. We define fix : [D ! D] ! D as:

    fix def=G

    i2Nl f . f i(?D)

    Note that, since {l f . f i(?D)}i2N is a chain of functions and [D ! D] ! D iscomplete, we are guaranteed that the lub

    Fi2N l f . f i(?D) exists.

    Theorem 8.10 (Continuity of fix). The function fix : [D ! D] ! D is continuous,namely fix 2 [[D ! D] ! D].

    Proof. We know that [[D ! D] ! D] is complete, thus if for all i 2 N the functionl f . f i(?D) is continuous, then fix =

    Fi2N l f . f i(?D) is also continuous. We prove

    that 8i 2 N. l f . f i(?D) is continuous by mathematical induction on i.Base case: l f . f 0(?D) = l f . ?D is a constant, and thus continuous, function.Inductive case: Let us assume that g def= l f . f i(?D) is continuous, i.e., that given

    a chain { fn}n2N in [D ! D] we have g(F

    n2N fn) =F

    n2N g( fn),and let us prove that h def= l f . f i+1(?D) is continuous, namely thath(F

    n2N fn) =F

    n2N h( fn). In fact we have:

  • DRAF

    T

    8.6 Apply, Curry and Fix 191

    h

    G

    n2Nfn

    !=

    G

    n2Nfn

    !i+1(?D) (by def. of h)

    =

    G

    n2Nfn

    !0

    @ G

    n2Nfn

    !i(?D)

    1

    A (by def. of (·)i+1)

    =

    G

    n2Nfn

    ! g

    G

    n2Nfn

    !!(by def. of g)

    =

    G

    n2Nfn

    ! G

    n2Ng( fn)

    !(by ind. hyp.)

    =

    G

    n2Nfn

    ! G

    n2Nf in(?D)

    !(by def of g)

    =G

    n2N

    fn

    G

    m2Nf im(?D)

    !!(by def. of lub)

    =G

    n2N

    G

    m2Nfn�

    f im(?D)�

    (by cont. of fn)

    =G

    k2Nfk�

    f ik(?D)�

    (by Lemma 8.1)

    =G

    k2Nf i+1k (?D) (by def. of (·)i+1)

    =G

    n2Nh( fn) (by def. of h)

    ut

    Finally we introduce the let operator, whose role is that of binding a name x toa de-lifted expression. Note that the continuity of the let operator directly followsfrom the continuity of the lifting operator.

    Definition 8.10 (Let operator). Let E be a CPO? and lx. e a function in [D ! E].We define the let operator as follows, where d0 2 D?:

    let x ( d0. e def= (lx. e)D!E

    D?!E

    (d0

    D?

    )

    E

    =

    ⇢?E if d0 = ?D?e⇥d/x

    ⇤if d0 = bdc for some d 2 D

    Intuitively, taken d0 2 D?, if d0 = ? then let x ( d0. e returns ?E , otherwiseit means that d0 = bdc for some d 2 D and thus it returns e

    ⇥d/x⇤, as if lx. e was

    applied to d, i.e., d0 = bdc is de-lifted so that lx. e can be used.

  • DRAF

    T

    192 8 Domain Theory

    Problems

    8.1. Prove that the projection functions in Definition 8.3 are monotone.

    8.2. Prove that the domain [D ! E ] from Definition 8.4 is a CPO?.

    8.3. Prove that the lifted domain D? from Definition 8.5 is a CPO?.

    8.4. Complete the proof of Theorem 8.4 for what is concerned with the monotonicityof the lifting function (·)⇤.

    8.5. Prove that the function apply : [D ! E]⇥D ! E introduced in Definition 8.7 ismonotone.

    8.6. Let D be a CPO and f : D ! D be a continuous function. Prove that the set offixpoints of f is itself a CPO (under the order inherited from D).

    8.7. Let D and E be two CPO?s. A function f : D ! E is called strict if f (?D) = ?E .Prove that the set of strict functions from D to E is a CPO? under the usual order.

    8.8. Let D and E be two CPOs. Prove that the following two definitions of the orderbetween continuous functions f ,g : D ! E are equivalent.

    1. f v g , 8d 2 D. f (d) vE g(d).2. f � g , 8d1,d2 2 D. (d1 vD d2 ) f (d1) vE g(d2))

    8.9. Let D = (D,vD) and E = (E,vE) be two CPOs. Their sum D +E has:

    1. The set of elements

    {?D+E}[D]E = {?D+E}[ ({0}⇥D)[ ({1}⇥E)

    2. The order relation vD+E defined by letting:

    • (0,d1) vD+E (0,d2) if d1 vD d2;• (1,e1) vD+E (1,e2) if e1 vE e2;• 8x 2 {?D+E}[D]E. ?D+E vD+E x.

    Prove that D +E is a CPO?.

    8.10. Prove that un-curry is continuous and inverse to curry (see Definition 8.8).

    Part I PreliminariesIntroductionStructure and MeaningSyntax, Types and PragmaticsSemanticsMathematical Models of Computation

    A Taste of Semantics Methods: Numerical ExpressionsApplications of SemanticsKey Topics and TechniquesInduction and RecursionSemantic DomainsBisimulationTemporal and Modal LogicsProbabilistic Systems

    Chapters Contents and Reading GuideFurther ReadingReferences

    PreliminariesNotationBasic NotationSignatures and TermsSubstitutionsUnification Problem

    Inference Rules and Logical SystemsLogic ProgrammingProblems

    Part II IMP: a simple imperative languageOperational Semantics of IMPSyntax of IMPArithmetic ExpressionsBoolean ExpressionsCommandsAbstract Syntax

    Operational Semantics of IMPMemory StateInference RulesExamples

    Abstract Semantics: Equivalence of Expressions and CommandsExamples: Simple Equivalence ProofsExamples: Parametric Equivalence ProofsExamples: Inequality ProofsExamples: Diverging Computations

    Problems

    Induction and RecursionNoether Principle of Well-founded InductionWell-founded RelationsNoether InductionWeak Mathematical InductionStrong Mathematical InductionStructural InductionInduction on DerivationsRule Induction

    Well-founded RecursionProblems

    Partial Orders and FixpointsOrders and Continuous FunctionsOrdersHasse DiagramsChainsComplete Partial Orders

    Continuity and FixpointsMonotone and Continuous FunctionsFixpoints

    Immediate Consequence OperatorThe Operator R"0362RFixpoint of R"0362R

    Problems

    Denotational Semantics of IMP-Notation-Notation: Main IdeasAlpha-Conversion, Beta-Rule and Capture-Avoiding Substitution

    Denotational Semantics of IMPDenotational Semantics of Arithmetic Expressions: The Function ADenotational Semantics of Boolean Expressions: The Function BDenotational Semantics of Commands: The Function C

    Equivalence Between Operational and Denotational SemanticsEquivalence Proofs For ExpressionsEquivalence Proof for Commands

    Computational InductionProblems

    Part III HOFL: a higher-order functional languageOperational Semantics of HOFLSyntax of HOFLTyped TermsTypability and Typechecking

    Operational Semantics of HOFLProblems

    Domain TheoryThe Flat Domain of Integer Numbers ZCartesian Product of Two DomainsFunctional DomainsLiftingFunction's Continuity TheoremsApply, Curry and FixProblems

    HOFL Denotational SemanticsHOFL Semantic DomainsHOFL Evaluation FunctionConstantsVariablesBinary OperatorsConditionalPairingProjectionsLambda AbstractionFunction ApplicationRecursion

    Continuity of Meta-language's FunctionsSubstitution LemmaProblems

    Equivalence between HOFL denotational and operational semanticsCompletenessEquivalence (on Convergence)Operational and Denotational Equivalences of TermsA Simpler Denotational SemanticsProblems

    Part IV Concurrent SystemsCCS, the Calculus for Communicating SystemsSyntax of CCSOperational Semantics of CCSAction PrefixRestrictionRelabellingChoiceParallel CompositionRecursionCCS with Value PassingRecursive Declarations and the Recursion Operator

    Abstract Semantics of CCSGraph IsomorphismTrace EquivalenceBisimilarity

    CompositionalityBisimilarity is Preserved by Choice

    A Logical View to Bisimilarity: Hennessy-Milner LogicAxioms for Strong BisimilarityWeak Semantics of CCSWeak BisimilarityWeak Observational CongruenceDynamic Bisimilarity

    Problems

    Temporal Logic and -CalculusTemporal LogicLinear Temporal LogicComputation Tree Logic

    -CalculusModel CheckingProblems

    -CalculusName MobilitySyntax of the -calculusOperational Semantics of the -calculusAction PrefixChoiceName MatchingParallel CompositionRestrictionScope ExtrusionReplicationA Sample Derivation

    Structural Equivalence of -calculusReduction semantics

    Abstract Semantics of the -calculusStrong Early Ground BisimulationsStrong Late Ground BisimulationsStrong Full BisimilaritiesWeak Early and Late Ground Bisimulations

    Problems

    Part V Probabilistic SystemsMeasure Theory and Markov ChainsProbabilistic and Stochastic SystemsMeasure Theory-fieldConstructing a -fieldContinuous Random VariablesStochastic Processes

    Markov ChainsDiscrete and Continuous Time Markov ChainDTMC as LTSDTMC Steady State DistributionCTMC as LTSEmbedded DTMC of a CTMCCTMC BisimilarityDTMC Bisimilarity

    Problems

    Markov Chains with Actions and Non-determinismDiscrete Markov Chains With ActionsReactive DTMCDTMC With Non-determinism

    Problems

    PEPA - Performance Evaluation Process AlgebraFrom Qualitative to Quantitative AnalysisCSPSyntax of CSPOperational Semantics of CSP

    PEPASyntax of PEPAOperational Semantics of PEPA

    Problems

    GlossarySolutionsIndex