====== Principles for Software Composition ====== {{:magistraleinformatica:psc:psc.png?250 | }} **PSC 2023/24 (375AA, 9 CFU)** Lecturer: **Roberto Bruni**\\ [[http://www.di.unipi.it/~bruni|web]] - [[mailto:bruni@di.unipi.it|email]] - [[https://teams.microsoft.com/l/team/19%3AsDmxJu95LqR3omiYtTochKhmTMOcUJc61yv3GaPoDbI1%40thread.tacv2/conversations?groupId=ba0310d9-0944-4015-8a31-8e3bbeae73dc&tenantId=c7456b31-a220-47f5-be52-473828670aa1|Microsoft Teams channel]] Office hours: By appointment (preferably on **Tuesday 14:00-16:00**) ---- ==== 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, "[[http://www.springer.com/978-3-319-42898-7|Models of Computation]]", Springer Texts in Computer Science, 2017. Other readings: * Graham Hutton, "[[http://www.cs.nott.ac.uk/~pszgmh/pih.html|Programming in Haskell]]", 2nd edition, Cambridge University Press (2016). Chapters: 1-8, 14, 15. * Joe Armstrong, [[https://pragprog.com/titles/jaerlang2/programming-erlang-2nd-edition/|Programming Erlang]], 2nd edition. The Pragmatic Bookshelf (2013). Chapters: 1-5, 8, 10-12. * Caleb Doxsey, [[http://shop.oreilly.com/product/0636920046516.do|Introducing Go]], O'Reilly Media (2016). Chapters: 1-4, 6-7, 10. * Robin Milner, "[[https://books.google.it/books/about/Communication_and_Concurrency.html?id=QPyyQgAACAAJ&redir_esc=y|Communication and Concurrency]]", Prentice Hall (1989). Chapters: 1-7, 10. * Luca Aceto, et al, "[[https://www.cambridge.org/core/books/reactive-systems/9B91FFD3996FC77D7AF0C309F8EE4CF7#|Reactive Systems]]", Cambridge University Press (2011). Chapters: 1-7. * Jane Hillston, [[http://www.dcs.ed.ac.uk/pepa/book.pdf|A Compositional Approach to Performance Modelling]], Cambridge University Press (1996). Chapters 1-3. External resources: * [[https://www.haskell.org/|Haskell]] * [[http://www.erlang.org/|Erlang]] * [[http://golang.org/|Google Go]] * [[http://caal.cs.aau.dk/|CAAL]] * [[http://www.dcs.ed.ac.uk/pepa/|PEPA]] ---- ==== Exam ==== The evaluation will be solely based on oral exams, which can involve the assignment of written exercises. Registration to exams (mandatory): [[https://esami.unipi.it/esami/|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 ==== * as the course starts:\\ Each student must subscribe the [[https://teams.microsoft.com/l/team/19%3AsDmxJu95LqR3omiYtTochKhmTMOcUJc61yv3GaPoDbI1%40thread.tacv2/conversations?groupId=ba0310d9-0944-4015-8a31-8e3bbeae73dc&tenantId=c7456b31-a220-47f5-be52-473828670aa1|Microsoft Teams channel]] of the course and then fill the form [[https://forms.office.com/e/j1WFMAGeKt|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: [[https://forms.office.com/e/Pv9yJ9Aqdj|Familiar subjects]] ---- ==== Lectures (1st part) ==== ^ N ^ Date ^^ Time ^ Room ^ Lecture notes ^ Links ^ | 1 | Tue | 20/02 | 16:00-18:00 | C1 | 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// | {{ :magistraleinformatica:psc:2024-02-20_-_01_-_intro.pdf |Lecture 01}}\\ {{ :magistraleinformatica:psc:2024-02-20_-_02_-_semantics.pdf |Lecture 02}} | | 2 | Thu | 22/02 | 16:00-18:00 | M1 | 02 - Preliminaries (ctd):\\ //denotational semantics, compositionality principle, normalisation, determinacy, consistency, equivalence, congruence//\\ \\ 03 - Unification:\\ //inference process, signatures, substitutions, most general than relation, unification problem// | {{ :magistraleinformatica:psc:2024-02-20_-_02_-_semantics.pdf |Lecture 02}}\\ {{ :magistraleinformatica:psc:2024-02-22_-_03_-_unification.pdf |Lecture 03}} | | 3 | Fri | 23/02 | 14:00-16:00 | C1 | 03 - Unification (ctd):\\ //unification problem, most general unifiers, unification algorithm//\\ \\ 04 - Logical systems:\\ //logical systems, derivations, theorems, logic programs, goal-oriented derivations// | {{ :magistraleinformatica:psc:2024-02-22_-_03_-_unification.pdf |Lecture 03}}\\ {{ :magistraleinformatica:psc:2024-02-23_-_04_-_logic.pdf |Lecture 04}} | | 4 | Tue | 27/02 | 16:00-18:00 | C1 | Exercises:\\ //unification, goal-oriented derivations//\\ \\ 05 - Induction:\\ //precedence relation, infinite descending chains, well-founded relations, well-founded induction, mathematical induction, proof of induction principle, structural induction, termination of arithmetic expressions, determinacy of arithmetic expressions// | {{ :magistraleinformatica:psc:01_-_inference_-_2024.pdf |Exercises 01}}\\ {{ :magistraleinformatica:psc:2024-02-27_-_05a_-_induction.pdf |Lecture 05a}}\\ {{ :magistraleinformatica:psc:2024-02-29_-_05b_-_more_induction.pdf |Lecture 05b}} | | 5 | Thu | 29/02 | 16:00-18:00 | X3 | Exercises:\\ //induction//\\ \\ 05 - Induction (ctd.):\\ //many-sorted signatures, arithmetic and boolean expressions, structural induction over many-sorted signatures, termination of boolean expressions, memories, update operation, operational semantics of commands// | {{ :magistraleinformatica:psc:2024-02-29_-_05b_-_more_induction.pdf |Lecture 05b}}\\ | | 6 | Fri | 01/03 | 14:00-16:00 | C1 | 05 - Induction (ctd.):\\ //divergence, rule for divergence, limits of structural induction, induction on derivations, rule induction, determinacy of commands// | {{ :magistraleinformatica:psc:2024-03-01_-_05c_-_rule_induction.pdf |Lecture 05c}} | | 7 | Tue | 05/03 | 16:00-18:00 | C1 | 06 - Equivalence:\\ //operational equivalence, concrete equivalences, parametric equivalences, equivalence and divergence//\\ \\ 07 - Induction and recursion:\\ //well-founded recursion, lexicographic precedence relation, Ackermann function, denotational semantics of arithmetic expressions, fixpoint equations// | {{ :magistraleinformatica:psc:2024-03-05_-_06_-_equivalence.pdf |Lecture 06}}\\ {{ :magistraleinformatica:psc:2024-03-05_-_07_-_recursion.pdf |Lecture 07}} | | 8 | Thu | 07/03 | 16:00-18:00 | X3 | 07 - Induction and recursion (ctd):\\ //consistency of operational and denotational semantics for arithmetic expressions//\\ \\ 08 - Partial orders and fixpoints (ctd.):\\ //partial orders, Hasse diagrams, chains, least element, minimal element, bottom element, upper bounds, least upper bound, limits, complete partial orders, powerset completeness, prefix independence, CPO of partial functions, monotonicity// | {{ :magistraleinformatica:psc:2024-03-05_-_07_-_recursion.pdf |Lecture 07}}\\ {{ :magistraleinformatica:psc:2024-03-07_-_08a_-_cpo.pdf |Lecture 08a}}\\ {{ :magistraleinformatica:psc:2024-03-07_-_08b_-_kleene.pdf |Lecture 08b}} | | 9 | Fri | 08/03 | 14:00-16:00 | C1 | Exercises:\\ //induction, termination, determinacy, divergence//\\ \\ 08 - Partial orders and fixpoints (ctd.):\\ //continuity, Kleene's fixpoint theorem, McCarthy's 91 function// | {{ :magistraleinformatica:psc:02_-_properties_-_2024.pdf |Exercises 02}}\\ {{ :magistraleinformatica:psc:2024-03-07_-_08b_-_kleene.pdf |Lecture 08b}}\\ | | - | Tue | 12/03 | - | - | **Canceled** (Teacher's travel constraints) | - | | - | Thu | 14/03 | - | - | **Canceled** (Teacher's travel constraints) | - | | - | Fri | 15/03 | - | - | **Canceled** (Teacher's travel constraints) | - | | 10 | Tue | 19/03 | 16:00-18:00 | C1 | Exercises:\\ //well-founded recursion, posets, semantics//\\ \\ 08 - Partial orders and fixpoints (ctd.):\\ //recursive definitions of partial functions as logical systems, immediate consequences operator, set of theorems as fixpoint// | {{ :magistraleinformatica:psc:03_-_poset_-_2024.pdf |Exercises 03}}\\ {{ :magistraleinformatica:psc:2024-03-19_-_08c_-_ico.pdf |Lecture 08c}} | | 11 | Thu | 21/03 | 16:00-18:00 | X3 | 09 - Denotational semantics:\\ //lambda-notation, free variables, capture-avoiding substitutions, alpha-conversion, beta rule, conditionals, denotational semantics of commands, fixpoint computation//\\ \\ 10 - Consistency:\\ //denotational equivalence, congruence, compositionality principle, consistency of commands, correctness, completeness// | {{ :magistraleinformatica:psc:2024-03-19_-_09_-_denotational_imp.pdf |Lecture 09}}\\ {{ :magistraleinformatica:psc:2024-03-21_-_10_-_consistency_imp.pdf |Lecture 10}} | | 12 | Fri | 22/03 | 14:00-16:00 | C1 | 11 - Haskell:\\ //an overview//\\ \\ Haskell ghci:\\ //basics, tuples, lists, list comprehension, guards, pattern matching, lambda, partial application, zip, exercises// | [[https://www.haskell.org/|Haskell]]\\ {{ :magistraleinformatica:psc:2024-03-22_-_11_-_haskell.pdf |Lecture 11}}\\ {{ :magistraleinformatica:psc:ghci-session1-2024.txt.zip |ghci session 01}} | | 13 | Tue | 26/03 | 16:00-18:00 | C1 | Haskell ghci (ctd):\\ //recursive definitions, tail recursion, let-in, where, map, filter, fixpoint operator, folds, application, function composition, exercises// | [[https://www.haskell.org/|Haskell]]\\ {{ :magistraleinformatica:psc:ghci-session2-2024.txt.zip |ghci session 02}} | | 14 | Thu | 28/03 | 16:00-18:00 | X3 | Haskell ghci (ctd.):\\ //data types, type classes, recursive data structures, derived instances, exercises// | [[https://www.haskell.org/|Haskell]]\\ {{ :magistraleinformatica:psc:ghci-session3-2024.txt.zip |ghci session 03}} | | 15 | Thu | 04/04 | 16:00-18:00 | X3 | Exercises:\\ //Haskell//\\ \\ 12 - HOFL:\\ //syntax, pre-terms, types, types judgements, type system, type checking, type inference, principal type// | {{ :magistraleinformatica:psc:04_-_haskell_-_2024.pdf |Exercises 04}}\\ {{ :magistraleinformatica:psc:2024-04-04_-_12a_-_hofl_types.pdf |Lecture 12a}} | | 16 | Fri | 05/04 | 14:00-16:00 | C1 | 12 - HOFL (ctd.):\\ //canonical forms, operational semantics, lazy vs eager evaluation//\\ \\ 13 - Domain theory:\\ //Integers with bottom, cartesian product, projections// | {{ :magistraleinformatica:psc:2024-04-04_-_12b_-_hofl_operational.pdf |Lecture 12b}}\\ {{ :magistraleinformatica:psc:2024-04-05_-_13a_-_cartesian_domains.pdf |Lecture 13a}} | | - | Tue | 09/04 | - | - | **Canceled** (Teacher's travel constraints) | - | | 17 | Thu | 11/04 | 16:00-18:00 | X3 | 13 - Domain theory (ctd.):\\ //switching lemma, functional domains, lifting, let notation//\\ \\ 14 - Denotational semantics of HOFL:\\ //definition and examples, type consistency// | {{ :magistraleinformatica:psc:2024-04-11_-_13b_-_functional_domains.pdf |Lecture 13b}}\\ {{ :magistraleinformatica:psc:2024-04-11_-_13c_-_continuity_theorems.pdf |Lecture 13c}}\\ {{ :magistraleinformatica:psc:2024-04-12_-_14_-_hofl_denotational.pdf |Lecture 14}} | | 18 | Fri | 12/04 | 14:00-16:00 | C1 | 13 - Domain theory (ctd.):\\ //continuity theorems, apply, fix, curry, uncurry//\\ \\ 14 - Denotational semantics of HOFL (ctd.):\\ //substitution lemma, compositionality and other properties//\\ \\ 15 - Consistency of HOFL:\\ //Counterexample to completeness, correctness of the operational semantics// | {{ :magistraleinformatica:psc:2024-04-11_-_13c_-_continuity_theorems.pdf |Lecture 13c}}\\ {{ :magistraleinformatica:psc:2024-04-12_-_14_-_hofl_denotational.pdf |Lecture 14}}\\ {{ :magistraleinformatica:psc:2024-04-12_-_15_-_consistency_hofl.pdf |Lecture 15}} | | 19 | Tue | 16/04 | 16:00-18:00 | C1 | 15 - Consistency of HOFL (ctd.):\\ //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 semantics//\\ \\ 16 - Erlang:\\ //an overview//\\ \\ Exercises:\\ //HOFL, domains// | {{ :magistraleinformatica:psc:2024-04-12_-_15_-_consistency_hofl.pdf |Lecture 15}}\\ {{ :magistraleinformatica:psc:2024-04-16_-_16_-_erlang.pdf |Lecture 16}}\\ {{ :magistraleinformatica:psc:05_-_hofl_-_2024.pdf |Exercises 05}} | ==== Lectures (2nd part) ==== ^ N ^ Date ^^ Time ^ Room ^ Lecture notes ^ Links ^ | 20 | Thu | 18/04 | 16:00-18:00 | X3 | Erlang 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//\\ \\ 17 - CCS:\\ //Syntax, operational semantics// | [[http://www.erlang.org/|Erlang]]\\ {{ :magistraleinformatica:psc:erl_2024.zip |erl session}}\\ {{ :magistraleinformatica:psc:2024-04-18_-_17a_-_ccs.pdf |Lecture 17a}} | | 21 | Fri | 19/04 | 14:00-16:00 | C1 | 17 - CCS (ctd.):\\ //value passing, finitely branching processes, guarded processes//\\ \\ 18 - Bisimulation:\\ //abstract semantics, graph isomorphism, trace equivalence, bisimulation game, strong bisimulation// | {{ :magistraleinformatica:psc:2024-04-18_-_17a_-_ccs.pdf |Lecture 17a}}\\ {{ :magistraleinformatica:psc:2024-04-19_-_17b_-_ccs_guarded.pdf |Lecture 17b}}\\ {{ :magistraleinformatica:psc:2024-04-19_-_18a_-_ccs_abstract.pdf |Lecture 18a}}\\ {{ :magistraleinformatica:psc:2024-04-19_-_18b_-_ccs_bisimulation.pdf |Lecture 18b}} | | 22 | Tue | 23/04 | 16:00-18:00 | C1 | 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// | {{ :magistraleinformatica:psc:2024-04-19_-_18b_-_ccs_bisimulation.pdf |Lecture 18b}}\\ {{ :magistraleinformatica:psc:2024-04-23_-_18c_-_ccs_bis_as_fix.pdf |Lecture 18c}} | | 23 | Fri | 26/04 | 14:00-16:00 | C1 | 18 - Bisimulation (ctd.):\\ //strong bisimilarity as a fixpoint, Phi operator, Phi is monotone, Phi is continuous (on finitely branching processes), Knaster-Tarski's fixpoint theorem//\\ \\ 19 - Hennessy-Milner logic:\\ //modalities, HML syntax, formula satisfaction, converse of a formula, HML equivalence//\\ \\ 20 - Weak Semantics:\\ //weak transitions, weak bisimulation, weak bisimilarity, weak bisimilarity is not a congruence, weak observational congruence, Milner's tau-laws// | {{ :magistraleinformatica:psc:2024-04-23_-_18c_-_ccs_bis_as_fix.pdf |Lecture 18c}}\\ {{ :magistraleinformatica:psc:2024-04-26_-_19_-_hml.pdf |Lecture 19}}\\ {{ :magistraleinformatica:psc:2024-04-26_-_20_-_weak.pdf |Lecture 20}} | | 24 | Tue | 30/04 | 16:00-18:00 | C1 | 21 - CCS at work:\\ //modelling imperative programs with CCS, playing with CCS (using CAAL), modelling and verification of mutual exclusion algorithms with CCS and CAAL//\\ \\ CAAL session (copy the text and paste it in the Edit panel) | Lecture 21\\ [[http://caal.cs.aau.dk/|CAAL]]\\ CAAL session | | 25 | Thu | 02/05 | 16:00-18:00 | X3 | Exercises:\\ //Erlang, CCS//\\ \\ 22 - 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 | Fri | 03/05 | 14:00-16:00 | C1 | 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 | | | | | 23 - GoogleGo:\\ //an overview//\\ \\ GoogleGo 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\\ [[http://golang.org/|Google Go]]\\ go session | | 28 | | | | | 24 - Pi-calculus:\\ //name mobility, free names, bound names, syntax and operational semantics, scope extrusion, early and late bisimilarities, weak semantics// | Lecture 24 | | 29 | | | | | Exercises:\\ //logics, GoogleGo, pi-calculus//\\ \\ 25 - 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 | | | | | 25 - Measure theory and Markov chains (ctd):\\ //finite path probability, negative exponential distribution, CTMC, embedded DTMC, infinitesimal generator matrix, CTMC stationary distribution//\\ \\ 26 - 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 | | | | | 27 - PEPA:\\ //motivation, basic ideas, PEPA workflow, PEPA syntax, cooperation combinator, bounded capacity, apparent rate, PEPA operational semantics, performance analysis, reward structures// | Lecture 27\\ [[http://www.dcs.ed.ac.uk/pepa/|PEPA]] | | 32 | | | | | Exercises:\\ //Markov chains, probabilistic systems, PEPA// | Exercises 08 | | 33 | | | | | Mini-projects discussion | | | End | | | | | | | ==== Past courses ==== * [[magistraleinformatica:psc:2022-23:|A.A. 2022/23]] * [[magistraleinformatica:psc:2021-22:|A.A. 2021/22]] * [[magistraleinformatica:psc:2020-21:|A.A. 2020/21]] * [[magistraleinformatica:psc:2019-20:|A.A. 2019/20]] * [[magistraleinformatica:psc:2018-19:|A.A. 2018/19]] * [[magistraleinformatica:psc:2017-18:|A.A. 2017/18]] * [[magistraleinformatica:mod:|MOD (A.A. 2016/17)]] * [[magistraleinformatica:mod:2015-16:|MOD (A.A. 2015/16)]] * [[magistraleinformatica:mod:2014-15:|MOD (A.A. 2014/15)]] * [[magistraleinformatica:mod:2013-14:|MOD (A.A. 2013/14)]] ----