### Indice

# Principles for Software Composition

**PSC 2022/23 (375AA, 9 CFU)**

Lecturer: **Roberto Bruni**

web - email - Microsoft Teams channel

Office hours: **Tuesday 14:00-16:00 or by appointment**

### Objectives

The objective of the course is to present:

- different models of computation,
- their programming paradigms,
- their mathematical descriptions, both
*concrete*and*abstract*, - some intellectual tools/techniques for reasoning on models.

The course will cover the basic techniques for assigning meaning to programs with higher-order, concurrent and probabilistic features (e.g., domain theory, logical systems, well-founded induction, structural recursion, labelled transition systems, Markov chains, probabilistic reactive systems, stochastic process algebras) and for proving their fundamental properties, such as termination, normalisation, determinacy, behavioural equivalence and logical equivalence. Temporal and modal logics will also be studied for the specification and analysis of programs. In particular, some emphasis will be posed on modularity and compositionality, in the sense of guaranteeing some property of the whole by proving simpler properties of its parts.

### Prerequisites

There are no prerequisites, but the students are expected to have some familiarity with discrete mathematics, first-order logic, context-free grammars, and code fragments in imperative and functional style.

### Textbook(s)

Main text:

- Roberto Bruni, Ugo Montanari, “Models of Computation”, Springer Texts in Computer Science, 2017.

Other readings:

- Graham Hutton, “Programming in Haskell”, 2nd edition, Cambridge University Press (2016). Chapters: 1-8, 14, 15.
- Joe Armstrong, Programming Erlang, 2nd edition. The Pragmatic Bookshelf (2013). Chapters: 1-5, 8, 10-12.
- Caleb Doxsey, Introducing Go, O'Reilly Media (2016). Chapters: 1-4, 6-7, 10.
- Robin Milner, “Communication and Concurrency”, Prentice Hall (1989). Chapters: 1-7, 10.
- Luca Aceto, et al, “Reactive Systems”, Cambridge University Press (2011). Chapters: 1-7.
- Jane Hillston, A Compositional Approach to Performance Modelling, Cambridge University Press (1996). Chapters 1-3.

External resources:

### Exam

The evaluation will be solely based on oral exams, which can involve the assignment of written exercises.

Registration to exams (mandatory): Exams registration system

During the oral exam the student must demonstrate

- knowledge: his/her knowledge of the course material, and
- problem solving: the ability to solve some simple exercises, and
- understanding: the ability to discuss the reading matter thoughtfully and with propriety of expression.

### Oral Exams: schedule

See the channel **Exams** in the Microsoft Teams platform

### Announcements

- the lecture of
**monday May 8 11-13 is canceled** - the lecture of
**thursday April 20 14-16 (L1) is postponed to 16-18 (L1)** - the lecture of
**thursday April 6 14-16 is canceled** - as the course starts:

Each student must subscribe the Microsoft Teams channel of the course and then fill the form Students information to provide the following contact data and info about her/his background:**first name****last name**- enrolment number (numero di matricola), optional
**email****bachelor degree**(course of study and university)**MSc course**(if Computer Science, specify which curriculum)

- then, fill the (optional) form about your familiarity with some of the subjects of the course: Familiar subjects

### Lectures (1st part)

N | Date | Time | Room | Lecture notes | Links | |
---|---|---|---|---|---|---|

1 | Mon | 20/02 | 11:00-13:00 | L1 | 01 - Introduction to the course 02 - Preliminaries: from syntax to semantics, the role of formal semantics, SOS approach, small-step operational semantics, big-step operational semantics | Lecture 01 Lecture 02 |

2 | Tue | 21/02 | 16:00-18:00 | L1 | 02 - Preliminaries (ctd):denotational semantics, compositionality principle, normalisation, determinacy, consistency, equivalence, congruence03 - Unification: inference process, signatures, substitutions, unification problem, most general unifiers, unification algorithm04 - Logical systems: logical systems, derivations, theorems | Lecture 02 Lecture 03 Lecture 04 |

3 | Thu | 23/02 | 14:00-16:00 | L1 | 04 - Logical systems (ctd.):logic programs, goal-oriented derivations05 - Induction: precedence relation, infinite descending chains, well-founded relations, well-founded induction, mathematical induction, proof of induction principle | Lecture 04 Lecture 05a |

4 | Mon | 27/02 | 11:00-13:00 | L1 | Exercises:unification, goal-oriented derivations05 - Induction (ctd.): structural induction, termination of arithmetic expressions, determinacy of arithmetic expressions, many-sorted signatures, arithmetic and boolean expressions, structural induction over many-sorted signatures, termination of boolean expressions, memories, update operation, operational semantics of commands | Exercises 01 Lecture 05a Lecture 05b |

5 | Tue | 28/02 | 16:00-18:00 | L1 | 05 - Induction (ctd.):divergence, rule for divergence, limits of structural induction, induction on derivations, rule induction, determinacy of commands | Lecture 05b Lecture 05c |

6 | Thu | 02/03 | 14:00-16:00 | L1 | 06 - Equivalence:operational equivalence, concrete equivalences, parametric equivalences, equivalence and divergence07 - Induction and recursion: well-founded recursion, lexicographic precedence relation, Ackermann function, denotational semantics of arithmetic expressions, fixpoint equations | Lecture 06 Lecture 07 |

7 | Mon | 06/03 | 11:00-13:00 | L1 | Exercises:induction, termination, determinacy, divergence07 - Induction and recursion (ctd.): consistency of operational and denotational semantics for arithmetic expressions08 - Partial orders and fixpoints: partial orders, Hasse diagrams, chains, least element, minimal element, bottom element, upper bounds, least upper bound, limits, complete partial orders, powerset completeness, prefix independence | Exercises 02 Lecture 07 Lecture 08a |

8 | Tue | 07/03 | 16:00-18:00 | L1 | 08 - Partial orders and fixpoints (ctd.):CPO of partial functions, monotonicity, continuity, Kleene's fixpoint theorem | Lecture 08b |

9 | Thu | 09/03 | 14:00-16:00 | L1 | 08 - Partial orders and fixpoints (ctd.):McCarthy's 91 function, recursive definitions of partial functions as logical systems, immediate consequences operator, set of theorems as fixpoint09 - Denotational semantics: lambda-notation, free variables, capture-avoiding substitutions, alpha-conversion, beta rule, conditionals, denotational semantics of commands, fixpoint computation | Lecture 08c Lecture 09 |

10 | Mon | 13/03 | 11:00-13:00 | L1 | 10 - Consistency:denotational equivalence, congruence, compositionality principle, consistency of commands, correctness, completenessExercises: posets, semantics, well-founded recursion, posets, semantics | Lecture 10 Exercises 03 |

11 | Tue | 14/03 | 16:00-18:00 | L1 | 11 - Haskell:an overviewHaskell ghci: basics, tuples, lists, list comprehension, guards, pattern matching, lambda, partial application, zip, exercises | Haskell Lecture 11 ghci session 01 |

12 | Thu | 16/03 | 14:00-16:00 | L1 | Haskell ghci (ctd):recursive definitions, tail recursion, let-in, where, map, filter, fixpoint operator, folds, exercises | Haskell ghci session 02 |

13 | Mon | 20/03 | 11:00-13:00 | L1 | Haskell ghci (ctd.):folds, application, function composition, data types, type classes, recursive data structures, derived instances, exercises | Haskell ghci session 03 |

14 | Tue | 21/03 | 16:00-18:00 | L1 | 12 - HOFL:syntax, pre-terms, types, types judgements, type system, type checking, type inference, principal type | Lecture 12a |

15 | Thu | 23/03 | 14:00-16:00 | L1 | Exercises:Haskell12 - HOFL (ctd.): canonical forms, operational semantics, lazy vs eager evaluation | Exercises 04 Lecture 12b |

16 | Mon | 27/03 | 11:00-13:00 | L1 | 13 - Domain theory:Integers with bottom, cartesian product, projections, switching lemma, functional domains | Lecture 13a Lecture 13b |

17 | Tue | 28/03 | 16:00-18:00 | L1 | 13 - Domain theory (ctd.):lifting, let notation, continuity theorems, apply, fix14 - Denotational semantics of HOFL: definition and examples, type consistency | Lecture 13c Lecture 14 |

18 | Thu | 30/03 | 14:00-16:00 | L1 | 13 - Domain theory (ctd.):curry, uncurry14 - Denotational semantics of HOFL (ctd.): substitution lemma, compositionality and other properties15 - Consistency of HOFL: Counterexample to completeness, correctness of the operational semantics, operational convergence, denotational convergence, operational convergence implies denotational convergence (and vice versa), operational and denotational equivalence, correspondence for type int, unlifted semantics, lifted vs unlifted semanticsExercises: HOFL, domains | Lecture 13c Lecture 14 Lecture 15 Exercises 05 |

19 | Mon | 03/04 | 11:00-13:00 | L1 | Exercises:HOFL, domainsErlang erl: numbers, atoms, tuples, lists, terms, variables, term comparison, pattern matching, list comprehension, modules, functions, guards, higher order, recursion, pids, spawn, self, send, receive, examples | Exercises 05 Lecture 16 Erlang erl session |

20 | Tue | 04/04 | 16:00-18:00 | L1 | 17 - CCS:Syntax, operational semantics, value passing | Lecture 17a |

- | Thu | 06/04 | 14:00-16:00 | L1 | Canceled |

### Lectures (2nd part)

N | Date | Time | Room | Lecture notes | Links | |
---|---|---|---|---|---|---|

21 | Thu | 13/04 | 14:00-16:00 | L1 | 17 - CCS (ctd.):finitely branching processes, guarded processes18 - Bisimulation: abstract semantics, graph isomorphism, trace equivalence, bisimulation game, strong bisimulation | Lecture 17b Lecture 18a Lecture 18b |

22 | Mon | 17/04 | 11:00-13:00 | L1 | 18 - Bisimulation (ctd.):strong bisimilarity, strong bisimilarity is an equivalence, strong bisimilarity is a bisimulation, strong bisimilarity is the coarsest strong bisimulation, strong bisimilarity is a congruence, some laws for strong bisimilarity, strong bisimilarity as a fixpoint, Phi operator, Phi is monotone, Phi is continuous (on finitely branching processes), Knaster-Tarski's fixpoint theorem | Lecture 18b Lecture 18c |

23 | Tue | 18/04 | 16:00-18:00 | L1 | 19 - Hennessy-Milner logic:modalities, HML syntax, formula satisfaction, converse of a formula, HML equivalence20 - Weak Semantics: weak transitions, weak bisimulation, weak bisimilarity, weak bisimilarity is not a congruence, weak observational congruence, Milner's tau-laws21 - CCS at work: modelling imperative programs with CCS, playing with CCS (using CAAL) | Lecture 19 Lecture 20 |

24 | Thu | 20/04 | 16:00-18:00 | L1 | 21 - CCS at work (ctd.):modelling imperative programs with CCS, playing with CCS (using CAAL), modelling and verification of mutual exclusion algorithms with CCS and CAALCAAL session (copy the text and paste it in the Edit panel) | Lecture 21 CAAL CAAL session |

25 | Mon | 24/04 | 11:00-13:00 | L1 | Exercises:Erlang, CCS22 - Temporal and modal logics: linear temporal logic (LTL), linear structures models, shifting, LTL satisfaction, equivalence of formulas, automata-like models | Exercises 06 Lecture 22a |

26 | Thu | 27/04 | 14:00-16:00 | L1 | 22 - Temporal and modal logics (ctd.):computational tree logic (CTL* and CTL), infinite trees, infinite paths, branching structure, CTL* satisfaction, equivalence of formulas, CTL formulas, expressiveness comparison, mu-calculus, positive normal form, least and greatest fixpoints, invariant properties, possibly properties, mu-calculus with labels | Lecture 22a Lecture 22b |

27 | Tue | 02/05 | 16:00-18:00 | L1 | 23 - GoogleGo:an overviewGoogleGo playground: Go principles, variable declaration, type conversion, multiple assignments, type inference, imports, packages and public names, named return values, naked return, multiple results, conditionals and loops, pointers, struct, receiver arguments and methods, interfaces, goroutines, bidirectional channels, channel types, send, receive, asynchronous communication with buffering, close, select, communicating communication means, range, handling multiple senders, concurrent prime sieve | Lecture 23 Google Go go session |

28 | Thu | 04/05 | 14:00-16:00 | L1 | 24 - Pi-calculus:name mobility, free names, bound names, syntax and operational semantics, scope extrusion, early and late bisimilarities, weak semantics | Lecture 24 |

- | Mon | 08/05 | 11:00-13:00 | L1 | canceled | |

29 | Tue | 09/05 | 16:00-18:00 | L1 | Exercises:logics, GoogleGo, pi-calculus25 - Measure theory and Markov chains: probability space, random variables, stochastic processes, homogeneous Markov chains, DTMC, DTMC as matrices, DTMC as PTS, next state probability, ergodic DTMC, steady state distribution | Exercises 07 Lecture 25a |

30 | Thu | 11/05 | 14:00-16:00 | L1 | 25 - Measure theory and Markov chains (ctd):finite path probability, negative exponential distribution, CTMC, embedded DTMC, infinitesimal generator matrix, CTMC stationary distribution26 - Probabilistic bisimilarities: bisimilarity revisited, reachability predicate, CTMC bisimilarity, DTMC bisimilarity, Markov chains with actions, probabilistic reactive systems, bisimilarity for reactive systems, Larsen-Skou logic | Lecture 25a Lecture 25b Lecture 26 |

31 | Mon | 15/05 | 11:00-13:00 | L1 | 27 - PEPA:motivation, basic ideas, PEPA workflow, PEPA syntax, cooperation combinator, bounded capacity, apparent rate, PEPA operational semantics, performance analysis, reward structures | Lecture 27 PEPA |

32 | Tue | 16/05 | 16:00-18:00 | L1 | Exercises:Markov chains, probabilistic systems, PEPA | Exercises 08 |

33 | Thu | 18/05 | 14:00-16:00 | L1 | Mini-projects discussion | |

End |