Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chair of Software Engineering 1 Concurrent Object-Oriented Programming Arnaud Bailly, Bertrand Meyer and Volkan Arslan.

Similar presentations


Presentation on theme: "Chair of Software Engineering 1 Concurrent Object-Oriented Programming Arnaud Bailly, Bertrand Meyer and Volkan Arslan."— Presentation transcript:

1 Chair of Software Engineering 1 Concurrent Object-Oriented Programming Arnaud Bailly, Bertrand Meyer and Volkan Arslan

2 Chair of Software Engineering 2 Lecture 6: Tutorial on Formal Logics for Computation and Concurrency.

3 Chair of Software Engineering 3 Formal Logics  Have a syntax defining (legal) terms.  Allow reasoning by providing:  Axioms defining equality on terms, and/or  A semantics defining the meaning of terms accompanied by a semantic equivalence.  Soundness/Completeness properties may relate the two approaches.

4 Chair of Software Engineering 4 Example: Integer Calculus  Syntax in (Enhanced) Backus-Naur Form.  Digit ::= 0 | 1 | … |9  Integer ::= |  Term ::=  Equality is symmetric, transitive, reflexive.  Operators can be associative, commutative, distributive.  Allows axiomatic reasoning, by tautology.  How to define “reasonable” equality? + | - | *

5 Chair of Software Engineering 5 Formalisms are Useful for…  Understanding (precise definitions).  Documentation.  Static analysis:  protocol verification,  code optimization (e.g. partial evaluation),  code validation.  Code generation.  Test case generation.  Execution monitoring.

6 Chair of Software Engineering 6 Functions and Functional Programming  Mathematical function:  taking (positional) parameters,  potentially calling other functions,  returning a result.  The result depends only on.  Calls with same parameters yield same result.  A function defines an input-output relation.  Functional programming:  Functions are 1 st -class entities,  Extensional equivalence with termination.  Programs are more concrete than functions!

7 Chair of Software Engineering 7 Lambda-Calculus [Church 1934]  Calculus of (sequential) functional programs.  Two constructions (operators):  lambda-abstraction,  function application.  Infinite but enumerable set of variables.  Lambda acts as a binding operator.  The scope of a lambda abstraction extends as far to the right as possible.

8 Chair of Software Engineering 8 Syntactical Aspects (1)  Occurrences of a variable under a lambda are bound.  Other occurrences are free.

9 Chair of Software Engineering 9 Syntactical Aspects (2)  The substitution of by in is noted :  Alpha-conversion (renaming) is defined as:  We shall assume from now that all terms are considered modulo alpha-conversion.

10 Chair of Software Engineering 10 Operational Semantics  Given as a set of rewriting rules.  Only 1 rule, Beta-reduction:  Defines a transition relation.  Repeatedly convert and reduce a term to have its semantics given by transitive closure.  A reducible part of a term is called a redex.  Functional application associates to the left.  Values are non-reducible terms (terminated computations).

11 Chair of Software Engineering 11 Encoding Booleans (1)

12 Chair of Software Engineering 12 Encoding Booleans (2)

13 Chair of Software Engineering 13 Encoding Pairs (or lists, records…)  A encloses two items and.  There exists two projection functions and.  and.  where ?

14 Chair of Software Engineering 14 Encoding Naturals (1) A natural just applies times a given function to an argument

15 Chair of Software Engineering 15 Encoding Naturals (2)

16 Chair of Software Engineering 16 What Can You Do?  Reason exactly about naturals.  Encode objects! (almost with what we have seen)  Write any sequential program (Church-Turing)  Haskell, ML, Lisp, Scheme, etc.  Prove properties?

17 Chair of Software Engineering 17 Imperative Programming  Problem: encoding a state.  Similar to semantic function for lambda terms.  Operational semantics:  give a function from states to states.  Repeat it as long as possible.  Computation finished when:  semantic function not applicable, or  Function yields always the same state (fixpoint).  The result is contained in variable Result.  In practice: becomes where associates variables to values.

18 Chair of Software Engineering 18 Example of State Encoding function fact (int n) is int result := 1; while n > 1 do result := result * n; n := n – 1; od; return result; end; function fact (int n) is return fact_rec (n, 1) function fact_rec (int n, int result) is if (n > 1) then return fact_rec (n - 1, n * result); else return result; end

19 Chair of Software Engineering 19 Modeling Concurrency  The choice operator can be used for expansion: x := 1 y := 1 Cobegin x := y + 1 || y := x + 1 Coend

20 Chair of Software Engineering 20 Non-Determinism in Lambda

21 Chair of Software Engineering 21 Encoding Non-Determinism?  It does not work!  Because of one property named either diamond, Church-Rosser, or confluence.  In short: the order of reductions does not matter.

22 Chair of Software Engineering 22 Example  Although a lambda-term can have more than one redex:  One can hardly say this models concurrency!

23 Chair of Software Engineering 23 Calculi for Concurrency  Have (internal) non-deterministic operators:  CCS,  CSP,  Pi-Calculus,  Ambients…  Next Time!


Download ppt "Chair of Software Engineering 1 Concurrent Object-Oriented Programming Arnaud Bailly, Bertrand Meyer and Volkan Arslan."

Similar presentations


Ads by Google