Denotational semantics

Size: px
Start display at page:

Download "Denotational semantics"

Transcription

1 Denotational semantics Semantics and Application to Program Verification Antoine Miné École normale supérieure, Paris year Course 4 4 March 2016 Course 4 Denotational semantics Antoine Miné p. 1 / 58

2 Introduction Operational semantics (state and trace) (last two weeks) Defined as small execution steps, (transition relation) over low-level internal configurations. (states) Transitions are chained to ine maximal traces. Denotational semantics (today) Direct functions from programs to mathematical objects, ined by induction on the program syntax, ignoring intermediate steps and execution details. (denotations) (compositional) (no state) = Higher-level, more abstract, more modular. Tries to decouple a program meaning from its execution. Focus on the mathematical structures that represent programs. (founded by Strachey and Scott in the 70s: [Scott-Strachey71]) Assembly semantics vs. Functional programming semantics. often: semantics for practical verification vs. semantics for computer theorists Course 4 Denotational semantics Antoine Miné p. 2 / 58

3 Two very different programs Bubble sort in C int swapped; do { swapped = 0; for (int i=1; i<n; i++) { if (a[i-1] > a[i]) { swap(&a[i-1], &a[i]); swapped = 1; } } } while (swapped); Quick sort in OCaml let rec sort = function [] -> [] a::rest -> let lo, hi = List.partition (fun y -> y < x) rest in (sort (sort hi) different languages (C / OCaml) different algorithms (bubble sort / quick sort) different programming principles (loop / recursion) different data-types (array / list) Can we give them the same semantics? Course 4 Denotational semantics Antoine Miné p. 3 / 58

4 Denotation worlds imperative programs effect of a program: mutate a memory state natural denotation: input/output function domain D memory memory challenge: build a whole program denotation from denotations of atomic language constructs (modularity) functional programs effect of a program: return a value (without any side-effect) model a program of type a -> b as a function in D a D b challenge: choose D to allow polymorphic or untyped languages other paradigms: parallel, probabilistic, etc. = very rich theory of mathematical structures Scott domains, cartesian closed categories, coherent spaces, event structures, game semantics, etc. We will not present them in this overview! Course 4 Denotational semantics Antoine Miné p. 4 / 58

5 Course overview Imperative programs IMP: deterministic programs NIMP: handling non-determinism linking denotational and operational semantics Higher-order programs PCF : monomorphic typed programs linking denotational and operational semantics: full abstraction untyped λ calculus: recursive domain equations Practical session (room INFO 4) program the denotational semantics of a simple imperative (non-)deterministic language (IMP, NIMP) Course 4 Denotational semantics Antoine Miné p. 5 / 58

6 Deterministic imperative programs Deterministic imperative programs Course 4 Denotational semantics Antoine Miné p. 6 / 58

7 Deterministic imperative programs A simple imperative language: IMP IMP expressions expr ::= X (variable) c (constant) expr (unary operation) expr expr (binary operation) variables in a fixed set X V constants I = B Z: booleans B = { true, false } integers Z operations : integer operations: +,,, /, <, boolean operations:,, polymorphic operations: =, Course 4 Denotational semantics Antoine Miné p. 7 / 58

8 Deterministic imperative programs A simple imperative language: IMP Statements stat ::= skip (do nothing) X expr (assignment) stat; stat (sequence) if expr then stat else stat (conditional) while expr do stat (loop) (inspired from the presentation in [Benton96]) Course 4 Denotational semantics Antoine Miné p. 8 / 58

9 Deterministic imperative programs Expression semantics E expr : E I environments E = V I map variables in V to values in I E expr returns a value in I denotes partial functions (as opposed to ) necessary because some operations are unined 1 + true, 1 2 (type mismatch) 3/0 (invalid value) ined by structural induction on abstract syntax trees (next slide) when we use the notation X y, y is a syntactic object; X serves to distinguish between different semantic functions with different signatures, often varying with the kind of syntactic object y (expression, statement, etc.); X y z is the application of the function X y to the object z Course 4 Denotational semantics Antoine Miné p. 9 / 58

10 Deterministic imperative programs Expression semantics E expr : E I E c ρ E V ρ E e ρ E e ρ E e 1 + e 2 ρ E e 1 e 2 ρ E e 1 e 2 ρ E e 1 /e 2 ρ E e 1 e 2 ρ E e 1 e 2 ρ E e 1 < e 2 ρ E e 1 e 2 ρ E e 1 = e 2 ρ E e 1 e 2 ρ unined otherwise = c I = ρ(v ) I = v Z if v = E e ρ Z = v B if v = E e ρ B = v 1 + v 2 Z if v 1 = E e 1 ρ Z, v 2 = E e 2 ρ Z = v 1 v 2 Z if v 1 = E e 1 ρ Z, v 2 = E e 2 ρ Z = v 1 v 2 Z if v 1 = E e 1 ρ Z, v 2 = E e 2 ρ Z = v 1 /v 2 Z if v 1 = E e 1 ρ Z, v 2 = E e 2 ρ Z \ {0} = v 1 v 2 B if v 1 = E e 1 ρ B, v 2 = E e 2 ρ B = v 1 v 2 B if v 1 = E e 1 ρ B, v 2 = E e 2 ρ B = v 1 < v 2 B if v 1 = E e 1 ρ Z, v 2 = E e 2 ρ Z = v 1 v 2 B if v 1 = E e 1 ρ Z, v 2 = E e 2 ρ Z = v 1 = v 2 B if v 1 = E e 1 ρ I, v 2 = E e 2 ρ I = v 1 v 2 B if v 1 = E e 1 ρ I, v 2 = E e 2 ρ I Course 4 Denotational semantics Antoine Miné p. 10 / 58

11 Deterministic imperative programs Statement semantics S stat : E E maps an environment before the statement to an environment after the statement partial function due to errors in expressions non-termination also ined by structural induction Course 4 Denotational semantics Antoine Miné p. 11 / 58

12 Deterministic imperative programs Statement semantics S stat : E E skip: do nothing S skip ρ = ρ assignment: evaluate expression and mutate environment S X e ρ = ρ[x v] if E e ρ = v sequence: function composition S s 1 ; s 2 = S s 2 S s 1 conditional S if e then s 1 else s 2 ρ = S s 1 ρ S s 2 ρ unined if E e ρ = true if E e ρ = false otherwise f [x y] denotes the function that maps x to y, and any z x to f (z) Course 4 Denotational semantics Antoine Miné p. 12 / 58

13 Deterministic imperative programs Statement semantics: loops How do we handle loops? The semantics of loops must satisfy: S while e do s ρ = ρ S while e do s (S s ρ) unined if E e ρ = false if E e ρ = true otherwise This is a recursive inition; we must prove that: the equation has solution(s); in case there are several solutions, there is a single right one; = we use fixpoints of operators over partially ordered sets. Course 4 Denotational semantics Antoine Miné p. 13 / 58

14 Deterministic imperative programs Flat orders and partial functions Flat ordering (I, ) on I: I = I { } (pointed set) a b a = a = b (partial order) every chain is finite, and so has a lub = it is a pointed complete partial order (cpo) denotes the value unined ( is an information order) Similarly for E = E { }. Note that (E E) (E E ) = we will now use total functions only. Course 4 Denotational semantics Antoine Miné p. 14 / 58

15 Deterministic imperative programs Poset of continuous partial functions c Partial order structure on partial functions (E E, ) E E extends E E domain = co-domain = allows composition f E E extended with f ( ) = (strictness) = if S s x is unined, so is (S s S s )x such functions are monotonic and continuous (a b = f (a) f (b) and f ( X ) = { f (x) x X }) c = we restrict E E to continuous functions: E E point-wise order on functions f g x: f (x) g(x) E c E has a least element: = λx. by point-wise lub of chains, it is also complete = a cpo F = λx. { f (x) f F } Course 4 Denotational semantics Antoine Miné p. 15 / 58

16 Deterministic imperative programs Fixpoint semantics of loops To solve the semantic equation, we use a fixpoint of a functional. We use actually the least fixpoint. S while e do s = lfp F (most precise for the information order) where : F : (E E ) (E E ) ρ if E e ρ = false F (f )(ρ) = f (S s ρ) if E e ρ = true otherwise Theorem lfp F is well-ined remember our equation on S while e do s? it can be rewritten exactly as: S while e do s = F (S while e do s ) Course 4 Denotational semantics Antoine Miné p. 16 / 58

17 Deterministic imperative programs Fixpoint semantics of loops (proof sketch) Recall Kleene s theorem: Kleene s theorem A continuous function on a cpo has a least fixpoint To use the theorem we prove that S stat is continuous (and is well-ined) by induction on the syntax of stat: base cases: S skip and S X e are continuous S if e then s 1 else s 2 : by induction hypothesis, as S s 1 and S s 2 are continuous S s 1 ; s 2 : by induction hypotheses and because respects continuity c F is continuous in (E E ) c c (E E ) by induction hypotheses = lfp F exists by Kleene s theorem moreover, lfp F is continuous (simple consequence of Kleene s proof) = S while e do s is continuous Course 4 Denotational semantics Antoine Miné p. 17 / 58

18 Deterministic imperative programs Join semantics of loops Recall another fact about Kleene s fixpoints: lfp F = n N F n ( ) F 0 ( ) = is completely unined (no information) { ρ if E e ρ = false F 1 ( )(ρ) = otherwise environment if the loop is never entered (partial information) ρ if E e ρ = false F 2 ( )(ρ) = S s ρ else if E e (S s ρ) = false otherwise environment if the loop is iterated at most once F n ( )(ρ) environment if the loop is iterated at most n 1 times n N F n ( ) environment when exiting the loop whatever the number of iterations (total information) Course 4 Denotational semantics Antoine Miné p. 18 / 58

19 Deterministic imperative programs Error vs. non-termination In our semantics S stat ρ = can mean: either stat starting on input ρ loops for ever or it stops prematurely with an error Note : we could distinguish between the two cases by : adding an error value Ω, distinct from propagating it in the semantics, bypassing computations (no further computation after an error) Course 4 Denotational semantics Antoine Miné p. 19 / 58

20 Summary Deterministic imperative programs Rewriting the semantics using total functions on cpos with : c E expr : E I returns for an error or if its argument is c S stat : E E S skip ρ = ρ S e 1 ; e 2 = S e 2 S e 1 { S X e ρ if E e ρ = = ρ[x E e ρ] otherwise S s 1 ρ if E e ρ = true S if e then s 1 else s 2 ρ = S s 2 ρ if E e ρ = false otherwise S while e do s = lfp F ρ where F (f )(ρ) = f (S s ρ) if E e ρ = false if E e ρ = true otherwise Course 4 Denotational semantics Antoine Miné p. 20 / 58

21 Non-determinism Non-determinism Course 4 Denotational semantics Antoine Miné p. 21 / 58

22 Non-determinism Why non-determinism? It is useful to consider non-deterministic programs, to: model partially unknown environments abstract away unknown program parts abstract away too complex parts handle a set of programs as a single one Kinds of non-determinism data non-determinism: expr ::= random() control non-determinism: stat ::= either s 1 or s 2 (user input) (libraries) (rounding errors in floats) (parametric programs) but we can write either s 1 or s 2 as if random() = 0 then s 1 else s 2 Consequence on semantics and verification we want to verify all the possible executions = the semantics should express all the possible executions Course 4 Denotational semantics Antoine Miné p. 22 / 58

23 Non-determinism Modified language We extend IMP to NIMP, an imperative language with non-determinism. NIMP language expr ::= X (variable) c (constant) [c 1, c 2 ] (constant interval) expr (unary operation) expr expr (binary operation) NIMP has the same statements as IMP c 1 Z { }, c 2 Z {+ } [c 1, c 2 ] means: return a fresh random value between c 1 and c 2 each time the expression is evaluated Question: is [0, 1] = [0, 1] true or false? Course 4 Denotational semantics Antoine Miné p. 23 / 58

24 Non-determinism Expression semantics E expr : E P(I) E V ρ E c ρ E [c 1, c 2 ] ρ E e ρ E e ρ E e 1 + e 2 ρ E e 1 /e 2 ρ E e 1 < e 2 ρ... = {ρ(v )} = {c} = { c Z c 1 c c 2 } = { v v E e ρ Z } = { v v E e ρ B } = { v 1 + v 2 v 1 E e 1 ρ Z, v 2 E e 2 ρ Z } = { v 1 /v 2 v 1 E e 1 ρ Z, v 2 E e 2 ρ Z \ {0} } = { true v 1 E e 1 ρ, v 2 E e 2 ρ: v 1 Z, v 2 Z, v 1 < v 2 } { false v 1 E e 1 ρ, v 2 E e 2 ρ: v 1 Z, v 2 Z, v 1 v 2 } we output a set of values, to account for non-determinism we can have E e ρ = due to errors (no need for a special Ω nor element) Course 4 Denotational semantics Antoine Miné p. 24 / 58

25 Non-determinism Statement semantic domain Semantic domain: a statement can output a set of environments = use E P(E) to allow composition, extend it to P(E) P(E) non-termination and errors can be modeled by (no need for a special Ω nor element) Course 4 Denotational semantics Antoine Miné p. 25 / 58

26 Non-determinism Statement semantics S stat : P(E) P(E) S skip R = R S s 1 ; s 2 = S s 2 S s 1 S X e R = { ρ[x v] ρ R, v E e ρ } pick an environment ρ pick an expression value v in E e ρ generate an updated environment ρ[x v] S if e then s 1 else s 2 R = S s 1 { ρ R true E e ρ } S s 2 { ρ R false E e ρ } filter environments according to the value of e execute both branch independently join them with Course 4 Denotational semantics Antoine Miné p. 26 / 58

27 Non-determinism Statement semantics S while e do s R = { ρ lfp F false E e ρ } where F (X ) = R S s { ρ X true E e ρ } Justification: lfp F exists (P(E),,,,, E) forms a complete lattice all semantic functions and F are monotonic and continuous in fact, they are strict complete join morphisms S s ( i X i ) = i S s X i and S s = which we write as S s P(E) P(E) it is really the image function of a function in E P(E) S s X = { S s {x} x X } we can apply both Kleene s and Tarksi s fixpoint theorems Course 4 Denotational semantics Antoine Miné p. 27 / 58

28 Non-determinism Join semantics of loops S while e do s R = { ρ lfp F false E e ρ } where F (X ) = R S s { ρ X true E e ρ } (F applies a loop iteration to X and adds back the environments R before the loop) Recall that lfp F = n N F n ( ) F 0 ( ) = F 1 ( ) = R environments before entering the loop F 2 ( ) = R S s { ρ R true E e ρ } environments after zero or one loop iteration F n ( ) : environments after at most n 1 loop iterations (just before testing the condition to determine if we should iterate a n th time) n N F n ( ): loop invariant Course 4 Denotational semantics Antoine Miné p. 28 / 58

29 Non-determinism Angelic non-determinism and termination If stat is deterministic (no [c 1, c 2 ] in expressions) c the semantics is equivalent to our semantics on E E Justification: ({ E E E 1 },,, ) is isomorphic to (E,,, ) In general, we can have several outputs for S stat {ρ} E {Ω}: : the program never terminates at all {Ω}: the program never terminates correctly R E \ {Ω}: when the program terminates, it terminates correctly, in an environment in R = we cannot express that a program always terminates! This is called the Angelic semantics, useful for partial correctness. Course 4 Denotational semantics Antoine Miné p. 29 / 58

30 Non-determinism Note on non-determinism and termination Other (more complex) ways to mix non-termination and non-determinism exist Based on distinguishing and, and on different order relations {0, 1} {0, 1} {0, 1} {0} {0, 1, } {1} {0} {0, 1, } {1} {0} {1} {0, } {1, } {0, } {1, } { } { } powerset order mixed order Egli-Milner order angelic semantics natural semantics natural semantics (this is a complex subject, we will say no more) Course 4 Denotational semantics Antoine Miné p. 30 / 58

31 Link between operational and denotational semantics Link between operational and denotational semantics Course 4 Denotational semantics Antoine Miné p. 31 / 58

32 Link between operational and denotational semantics Motivation Are the operational and denotational semantics consistent with each other? Note that: systems are actually described operationally (previous courses) the denotational semantics is a more abstract representation (more suitable for some reasoning on the system) = the denotational semantics must be proven faithful (in some sense) to the operational model to be of any use Course 4 Denotational semantics Antoine Miné p. 32 / 58

33 Link between operational and denotational semantics Transition systems for our non-deterministic language Labelled syntax l stat l ::= l skip l l X expr l l if expr then l stat else l stat l l while l expr do l stat l l stat; l stat l l L: control labels statements are decorated with unique control labels l L program configurations in Σ = L E (lower-level than E: we must track program locations) transition relation τ Σ Σ models atomic execution steps Course 4 Denotational semantics Antoine Miné p. 33 / 58

34 Link between operational and denotational semantics Transition systems for our language τ is ined by induction on the syntax of statements (σ, σ ) τ is denoted as σ σ τ[ l1 skip l2 ] = { (l1, ρ) (l2, ρ) ρ E } τ[ l1 X e l2 ] = { (l1, ρ) (l2, ρ[x v]) ρ E, v E e ρ } τ[ l1 if e then l2 s 1 else l3 s 2 l4 ] = { (l1, ρ) (l2, ρ) ρ E, true E e ρ } { (l1, ρ) (l3, ρ) ρ E, false E e ρ } τ[ l2 s 1 l4 ] τ[ l3 s 2 l4 ] τ[ l1 while l2 e do l3 s l4 ] = { (l1, ρ) (l2, ρ) ρ E } { (l2, ρ) (l3, ρ) ρ E, true E e ρ } { (l2, ρ) (l4, ρ) ρ E, false E e ρ } τ[ l3 s l2 ] τ[ l1 s 1 ; l2 s 2 l3 ] = τ[ l1 s 1 l2 ] τ[ l2 s 2 l3 ] Defines the small-step semantics of a statement (the semantics of expressions is still in denotational form) Course 4 Denotational semantics Antoine Miné p. 34 / 58

35 Link between operational and denotational semantics Special states Given a labelled statement le s lx we ine: and its transition system, initial states: I note that σ σ = { (l e, ρ) ρ E } = σ / I blocking states: B = { σ Σ σ : Σ, σ σ } correct termination: OK = { (l x, ρ) ρ E } note that OK B error: ERR = B { (l, ρ) l l x, ρ E } B = ERR OK ERR OK = Course 4 Denotational semantics Antoine Miné p. 35 / 58

36 Link between operational and denotational semantics Reminder: maximal trace semantics Trace: in Σ starting in an initial state I following transitions can only end in a blocking state B (finite or infinite sequence of states) (traces are maximal) i.e.: t s = t s t s ω where finite traces: t s = { (σ 0,..., σ n ) n 0, σ 0 I, σ n B, i < n: σ i σ i+1 } infinite traces: t s ω = { (σ 0,...) σ 0 I, i N: σ i σ i+1 } Course 4 Denotational semantics Antoine Miné p. 36 / 58

37 Link between operational and denotational semantics From traces to big-step semantics Big-step semantics: abstraction of traces only remembers the input-output relations many variants exist: angelic semantics, in P(Σ Σ): A s = { (σ, σ ) (σ 0,..., σ n ) t s : σ = σ 0, σ = σ n } (only give information on the terminating behaviors; can only prove partial correctness) natural semantics, in P(Σ Σ ): N s = A s { (σ, ) (σ 0,...) t s ω : σ = σ 0 } (models the terminating and non-terminating behaviors; can prove total correctness) Exercise: compute the semantics of while X > 0 do X X [0, 1] Course 4 Denotational semantics Antoine Miné p. 37 / 58

38 Link between operational and denotational semantics From big-step to denotational semantics The angelic denotational and big-step semantics are isomorphic (isomorphism between relations and strict complete join morphisms) S s = α(a s ) where α(x ) = λr.{ ρ ρ R, ((l e, ρ), (l x, ρ )) X } (image of a relation) α 1 (Y ) = { ((l e, ρ), (l x, ρ )) ρ E, ρ Y ({ρ}) } Proof idea: by induction on the syntax of s = our operational and denotational semantics match Also, the denotational semantics is an abstraction of the natural semantics (it forgets about infinite computations) Thesis All semantics can be compared for equivalence or abstraction this can be made formal in the abstract interpretation theory (see [Cousot02]) Course 4 Denotational semantics Antoine Miné p. 38 / 58

39 Link between operational and denotational semantics Semantic diagram denotational world operational world S s denotational α big step A s natural N s traces t s transition system (small step) τ[s] statement Course 4 Denotational semantics Antoine Miné p. 39 / 58

40 Link between operational and denotational semantics Fixpoint formulation Recall that traces can be expressed as fixpoints: t s = (lfp F ) (I Σ ) ( (I Σ ) restricts to traces starting in I ) where F (X ) = B { (σ, σ 0,..., σ n) σ σ 0 (σ 0,..., σ n) X } t s ω = (gfp F ) (I Σ ) where F (X ) = { (σ, σ 0,...) σ σ 0 (σ 0,...) X } This also holds for the angelic denotational semantics: S s = α(lfp F ) (α converts relations to functions) where F (X ) = (B B) { (σ, σ ) σ : σ σ (σ, σ ) X } and many others: natural, denotational, big-step, denotational,... (again [Cousot02]) Thesis All semantics can be expressed through fixpoints Course 4 Denotational semantics Antoine Miné p. 40 / 58

41 Higher-order programs Higher-order programs Course 4 Denotational semantics Antoine Miné p. 41 / 58

42 Higher-order programs Monomorphic typed higher order language PCF language (introduced by Scott in 1969) type ::= int (integers) bool (booleans) type type (functions) term ::= X (variable X V) c (constant) λx type.term (abstraction) term term (application) Y type term (recursion) Ω type (failure) PCF (programming computable functions) is a λ calculus with: a monomorphic type system explicit type annotations X type, Y type, Ω type an explicit recursion combiner Y constants, including Z, B and a few built-in functions (arithmetic and comparisons in Z, if-then-else, etc.) (unlike ML) (unlike ML) (unlike untyped λ calculus) Course 4 Denotational semantics Antoine Miné p. 42 / 58

43 Higher-order programs Semantic domains What should be the domain of T term? Difficulty: term contains heterogeneous objects: constants, functions, second order functions, etc. Solution: use the type information each term m can be given a type typ(m) use one semantic domain D t per type t then T m : E D typ(m) where E = V ( t type D t ) Domain inition by induction on the syntax of types D int = Z D bool = B D t1 t 2 c = (D t1 D t2 ) Course 4 Denotational semantics Antoine Miné p. 43 / 58

44 Higher-order programs Order on semantic domains Order: all domains are cpos D int = Z, D bool = B use a flat ordering D t1 t 2 c = (D t1 D t2 ) with order f g f = (f, g x: f (x) g(x)) D t1 c D t2 is ordered point-wise each domain has its fresh minimal element (to distinguish Ω int int from λx int.ω int ) we restrict to continuous functions (to be able to take fixpoints) (see [Scott93]) Course 4 Denotational semantics Antoine Miné p. 44 / 58

45 Higher-order programs Denotational semantics Environments: Semantics: E = V ( t type D t ) T m : E D typ(m) T X ρ T c ρ T λx t.m ρ T m 1 m 2 ρ T Y t m ρ T Ω t ρ = ρ(x ) = c = λx.t m (ρ[x x]) = (T m 1 ρ)(t m 2 ρ) = lfp (T m ρ) = t program functions λ are mapped to mathematical functions λ program recursion Y is mapped to fixpoints lfp errors and non-termination are mapped to (typed) we should prove that T m is indeed continuous (by induction) so that lfp exists, and also that T m 1 is indeed a function (by soundness of typing) Course 4 Denotational semantics Antoine Miné p. 45 / 58

46 Higher-order programs Operational semantics Operational semantics: states are terms: Σ = term based on the λ calculus transitions correspond to reductions: (λx t.m 1 ) m 2 m 1 [X m 2 ] Ω t Ω t Y t m m (Y t m) plus c 1 c 2 (c 1 + c 2 ) if true m 1 m 2 m 1 if false m 1 m 2 m 2 m 1 m 1 m 1 m 2 m 1 m 2... (λ reduction) (failure) (iteration) (arithmetic) (if-then-else) (if-then-else) (context rule) big-step semantics m : maximal reductions m = m (PCF is deterministic) m m m : m m Course 4 Denotational semantics Antoine Miné p. 46 / 58

47 Higher-order programs Links between operational and denotational semantics How do we check that operational and denotational semantics match? check that they have the same view of semantically equal programs denotational way: we can use T m 1 = T m 2 we need an operational way to compare functions comparing the syntax is too fine grained, Example: (λx int.0) (λx int.minus 1 1), but they have the same denotation Observational equivalence: contexts c: terms with holes observe terms in all contexts c[m] term obtained by substituting m in hole ground is the set of terms of type int or bool term equivalence : m 1 m 2 ( c: c[m 1 ] = c[m 2 ] when c[m 1 ] ground) (don t look at a function s syntax, force its full evaluation and look at the value result) Course 4 Denotational semantics Antoine Miné p. 47 / 58

48 Higher-order programs Full abstraction Full abstraction: m 1, m 2 : m 1 m 2 T m 1 = T m 2 Unexpected result: for PCF, holds (adequacy), but not! (full abstraction concept introduced by Milner in 1975, proof by Plotkin 1977) Compare with: IMP, NIMP are fully abstract s 1, s 2 stat: S s 1 = S s 2 Intuitive explanation: c: A c[s 1 ] = A c[s 2 ] Domains such as D t1 t 2 contain many functions, most of them do not correspond to any program (this is expected: many functions are not computable). The problem is that, if m 1, m 2 have the form λx t 1 t 2.m, T m 1 = T m 2 imposes T m 1 f = T m 2 f for all f D t1 t 2, including many f that are not computable. It is actually possible to construct m 1, m 2 where T m 1 f T m 2 f only for some non-program functions f, so that m 1 m 2 actually holds Two solutions come to mind: enrich the language to express more functions in D t1 t 2 restrict D t1 t 2 to contain less non-program objects (next slide) Fruitful but complex research topic... Course 4 Denotational semantics Antoine Miné p. 48 / 58

49 Higher-order programs Full abstraction Example: the parallel or function por por(a)(b) = true false if a = true b = true if a = false b = false otherwise por can observe a and b concurrently, and return as soon as one returns true compare with sequential or, where b: or( )(b) = We have the following non-obvious result: por cannot be ined in PCF (por is a parallel construct, PCF is a sequential language) PCF+por is fully abstract (see [Ong95], [Winskel97] for references on the subject) Course 4 Denotational semantics Antoine Miné p. 49 / 58

50 Recursive domain equations Recursive domain equations Course 4 Denotational semantics Antoine Miné p. 50 / 58

51 Recursive domain equations Untyped higher order language λ calculus (with arithmetic) term ::= X (variable X V) c (constants) λx.term (abstraction) term term (application) Ω (failure) we can write truly polymorphic functions: e.g., λx.x (in PCF we would have to choose a type: int int or bool bool or (int int) (int int) or...) no need for a recursion combinator Y (we can ine Y = λf.(λx.f (X X ))(λx.f (X X )), not typable in PCF) operational semantics based on reduction, similarly to PCF denotational semantics also similar to PCF, but... Course 4 Denotational semantics Antoine Miné p. 51 / 58

52 Recursive domain equations Domain equations How to choose the domain of denotations T m? we need a unique domain D for all terms (no type information to help us) λx.x is a function = it should have denotation in (X Y) for some X, Y D λx.x is polymorphic; it accepts any term as argument = D X, Y We have a domain equation to solve: D (Z B (D D)) Problem: no solution in set theory (D D has a strictly larger cardinal than D) Course 4 Denotational semantics Antoine Miné p. 52 / 58

53 Recursive domain equations Inverse limits Given a fixpoint domain equation D = F (D) we construct an infinite sequence of domains: D 0 = { } D i+1 = F (D i ) We require the existence of continuous retractions: γ i : D i D i+1 c α i : D i+1 D i c (embedding) (projection) α i γ i = λx.x (D i a subset of D i+1 ) γ i α i λx.x (D i+1 can be approximated by D i ) α This is denoted: D 0 0 α D 1 1 Inverse limit: γ 0 γ 1 D = { (a 0, a 1,...) i: a i D i a i = α(a i+1 ) } (infinite sequences of elements; able to represent an element of any D i ) Course 4 Denotational semantics Antoine Miné p. 53 / 58

54 Recursive domain equations Inverse limits Inverse limits: Theorem D = { (a 0, a 1,...) i: a i D i a i = α(a i+1 ) } D is a cpo and F (D ) is isomorphic to D Application to λ calculus If we restrict ourself to continuous functions retractions can be computed for F (D) = (Z B (D c D)) (γ i (f ) = λx.f α i (x) = x if x Z B { } and α i (f ) = f ( ) if f D i c D i ) = we found our semantic domain! (pioneered by [Scott-Strachey71], see [Abramsky-Jung94] for a reference) Course 4 Denotational semantics Antoine Miné p. 54 / 58

55 Recursive domain equations Restrictions of function spaces The restriction to continuous functions seems merely technical but there are some valid justifications: all the denotations in IMP, NIMP, PCF were continuous (this appeared naturally, not as an a priori restriction) intuitively, computable functions should at least be monotonic recall that is an information order a function cannot give a more precise result with less information e.g.: if f (a) = for some a, then f ( ) = continuity is also reasonable given a problem on an infinite data set S computers can only process finite parts S i of S continuity ensures that the solution of S is contained in that of all S i e.g.: if 0 1 ω and i < ω: f (i) = 0, then f (ω) should also be 0 Course 4 Denotational semantics Antoine Miné p. 55 / 58

56 Recursive domain equations Domain equations for data-types Solution domains of recursive equations can also give the semantics of a variety of inductive or polymorphic data-types Examples: integer lists: D = ({empty} (Z D)) pairs: D = (Z (D D)) (allows arbitrary nested pairs, and also contains trees and lists) records: D = (Z (N D)) (fields are named by integer position) sum types: D = (Z ({1} D) ({2} D)) (we tag each case of the sum with an integer) Course 4 Denotational semantics Antoine Miné p. 56 / 58

57 Bibliography Recursive domain equations Courses and references on denotational semantics: [Benton96] P. N. Benton. Semantics of programming languages In University of Cambridge, [Winskel97] G. Winskel. Lecture notes on denotational semantics. In University of Cambridge, [Schmidt86] D. Schmidt. Denotational semantics. A methodology for language development. In Allyn and Bacon, [Abramsky-Jung94] S. Abramsky and A. Jung. Domain theory. In Handbook of Logic in Computer Science, Clarendon Press, Oxford, Course 4 Denotational semantics Antoine Miné p. 57 / 58

58 Bibliography Recursive domain equations Research articles and surveys: [Scott-Strachey71] D. Scott and C. Strachey. Toward a mathematical semantics for computer languages. In Oxford Programming Research Group Technical Monograph. PRG [Scott93] D. Scott. A type-theoretical alternative to ISWIM, CUCH, OWHY. In TCS, 121(1 2): , [Cousot02] P. Cousot. Constructive design of a hierarchy of semantics of a transition system by abstract interpretation. In TCS, 277(1 2):47 103, [Ong95] C.-H. L. Ong. Correspondence between operational and denotational semantics: the full abstraction problem for PCF In Oxford University, Course 4 Denotational semantics Antoine Miné p. 58 / 58

Operational Semantics

Operational Semantics Operational Semantics Semantics and applications to verification Xavier Rival École Normale Supérieure Xavier Rival Operational Semantics 1 / 50 Program of this first lecture Operational semantics Mathematical

More information

Abstract Interpretation II

Abstract Interpretation II Abstract Interpretation II Semantics and Application to Program Verification Antoine Miné École normale supérieure, Paris year 2015 2016 Course 11 13 May 2016 Course 11 Abstract Interpretation II Antoine

More information

CS422 - Programming Language Design

CS422 - Programming Language Design 1 CS422 - Programming Language Design Denotational Semantics Grigore Roşu Department of Computer Science University of Illinois at Urbana-Champaign 2 Denotational semantics, also known as fix-point semantics,

More information

Consistency of a Programming Logic for a Version of PCF Using Domain Theory

Consistency of a Programming Logic for a Version of PCF Using Domain Theory Consistency of a Programming Logic for a Version of PCF Using Domain Theory Andrés Sicard-Ramírez EAFIT University Logic and Computation Seminar EAFIT University 5 April, 3 May 2013 A Core Functional Programming

More information

1 Introduction. 2 Recap The Typed λ-calculus λ. 3 Simple Data Structures

1 Introduction. 2 Recap The Typed λ-calculus λ. 3 Simple Data Structures CS 6110 S18 Lecture 21 Products, Sums, and Other Datatypes 1 Introduction In this lecture, we add constructs to the typed λ-calculus that allow working with more complicated data structures, such as pairs,

More information

CS 6110 Lecture 21 The Fixed-Point Theorem 8 March 2013 Lecturer: Andrew Myers. 1 Complete partial orders (CPOs) 2 Least fixed points of functions

CS 6110 Lecture 21 The Fixed-Point Theorem 8 March 2013 Lecturer: Andrew Myers. 1 Complete partial orders (CPOs) 2 Least fixed points of functions CS 6110 Lecture 21 The Fixed-Point Theorem 8 March 2013 Lecturer: Andrew Myers We saw that the semantics of the while command are a fixed point. We also saw that intuitively, the semantics are the limit

More information

Domain theory and denotational semantics of functional programming

Domain theory and denotational semantics of functional programming Domain theory and denotational semantics of functional programming Martín Escardó School of Computer Science, Birmingham University MGS 2007, Nottingham, version of April 20, 2007 17:26 What is denotational

More information

Cours M.2-6 «Interprétation abstraite: applications à la vérification et à l analyse statique» Examen partiel. Patrick Cousot.

Cours M.2-6 «Interprétation abstraite: applications à la vérification et à l analyse statique» Examen partiel. Patrick Cousot. Master Parisien de Recherche en Informatique École normale supérieure Année scolaire 2010/2011 Cours M.2-6 «Interprétation abstraite: applications à la vérification et à l analyse statique» Examen partiel

More information

EDA045F: Program Analysis LECTURE 10: TYPES 1. Christoph Reichenbach

EDA045F: Program Analysis LECTURE 10: TYPES 1. Christoph Reichenbach EDA045F: Program Analysis LECTURE 10: TYPES 1 Christoph Reichenbach In the last lecture... Performance Counters Challenges in Dynamic Performance Analysis Taint Analysis Binary Instrumentation 2 / 44 Types

More information

Lecture Notes on Data Abstraction

Lecture Notes on Data Abstraction Lecture Notes on Data Abstraction 15-814: Types and Programming Languages Frank Pfenning Lecture 14 October 23, 2018 1 Introduction Since we have moved from the pure λ-calculus to functional programming

More information

Classical Program Logics: Hoare Logic, Weakest Liberal Preconditions

Classical Program Logics: Hoare Logic, Weakest Liberal Preconditions Chapter 1 Classical Program Logics: Hoare Logic, Weakest Liberal Preconditions 1.1 The IMP Language IMP is a programming language with an extensible syntax that was developed in the late 1960s. We will

More information

Formal Techniques for Software Engineering: Denotational Semantics

Formal Techniques for Software Engineering: Denotational Semantics Formal Techniques for Software Engineering: Denotational Semantics Rocco De Nicola IMT Institute for Advanced Studies, Lucca rocco.denicola@imtlucca.it May 2013 Lesson 4 R. De Nicola (IMT-Lucca) FoTSE@LMU

More information

MFPS LICS Special Session Honouring Dana Scott. Symmetric Scott. Andrew Pitts. Computer Laboratory MFPS/LICS /14

MFPS LICS Special Session Honouring Dana Scott. Symmetric Scott. Andrew Pitts. Computer Laboratory MFPS/LICS /14 MFPS/LICS 2013 1/14 MFPS LICS Special Session Honouring Dana Scott Symmetric Scott Andrew Pitts Computer Laboratory 80 years of Dana Scott MFPS/LICS 2013 2/14 automata theory set theory sheaves & logic

More information

Dynamic Noninterference Analysis Using Context Sensitive Static Analyses. Gurvan Le Guernic July 14, 2007

Dynamic Noninterference Analysis Using Context Sensitive Static Analyses. Gurvan Le Guernic July 14, 2007 Dynamic Noninterference Analysis Using Context Sensitive Static Analyses Gurvan Le Guernic July 14, 2007 1 Abstract This report proposes a dynamic noninterference analysis for sequential programs. This

More information

Axiomatic semantics. Semantics and Application to Program Verification. Antoine Miné. École normale supérieure, Paris year

Axiomatic semantics. Semantics and Application to Program Verification. Antoine Miné. École normale supérieure, Paris year Axiomatic semantics Semantics and Application to Program Verification Antoine Miné École normale supérieure, Paris year 2015 2016 Course 6 18 March 2016 Course 6 Axiomatic semantics Antoine Miné p. 1 /

More information

The Trace Partitioning Abstract Domain

The Trace Partitioning Abstract Domain The Trace Partitioning Abstract Domain XAVIER RIVAL and LAURENT MAUBORGNE École Normale Supérieure In order to achieve better precision of abstract interpretation based static analysis, we introduce a

More information

Static Program Analysis using Abstract Interpretation

Static Program Analysis using Abstract Interpretation Static Program Analysis using Abstract Interpretation Introduction Static Program Analysis Static program analysis consists of automatically discovering properties of a program that hold for all possible

More information

Safety Analysis versus Type Inference

Safety Analysis versus Type Inference Information and Computation, 118(1):128 141, 1995. Safety Analysis versus Type Inference Jens Palsberg palsberg@daimi.aau.dk Michael I. Schwartzbach mis@daimi.aau.dk Computer Science Department, Aarhus

More information

Typing λ-terms. Types. Typed λ-terms. Base Types. The Typing Relation. Advanced Formal Methods. Lecture 3: Simply Typed Lambda calculus

Typing λ-terms. Types. Typed λ-terms. Base Types. The Typing Relation. Advanced Formal Methods. Lecture 3: Simply Typed Lambda calculus Course 2D1453, 200607 Advanced Formal Methods Lecture 3: Simply Typed Lambda calculus Mads Dam KTH/CSC Some material from B. Pierce: TAPL + some from G. Klein, NICTA Typing λterms The uptyped λcalculus

More information

Denotational Semantics

Denotational Semantics Q Lecture Notes on Denotational Semantics for Part II of the Computer Science Tripos Dr Andrew M. Pitts Cambridge University Computer Laboratory c A. M. Pitts, 1997-9 First edition 1997. Revised 1998,

More information

CS156: The Calculus of Computation

CS156: The Calculus of Computation CS156: The Calculus of Computation Zohar Manna Winter 2010 It is reasonable to hope that the relationship between computation and mathematical logic will be as fruitful in the next century as that between

More information

Bi-inductive Structural Semantics

Bi-inductive Structural Semantics Bi-inductive Structural Semantics Patrick Cousot Département d informatique, École normale supérieure, 45 rue d Ulm, 75230 Paris cedex 05, France Radhia Cousot CNRS & École polytechnique, 91128 Palaiseau

More information

Discrete Fixpoint Approximation Methods in Program Static Analysis

Discrete Fixpoint Approximation Methods in Program Static Analysis Discrete Fixpoint Approximation Methods in Program Static Analysis P. Cousot Département de Mathématiques et Informatique École Normale Supérieure Paris

More information

Axiomatic Semantics. Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 CSE

Axiomatic Semantics. Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 CSE Axiomatic Semantics Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 CSE 6341 1 Outline Introduction What are axiomatic semantics? First-order logic & assertions about states Results (triples)

More information

Introduction to Axiomatic Semantics

Introduction to Axiomatic Semantics Introduction to Axiomatic Semantics Meeting 9, CSCI 5535, Spring 2009 Announcements Homework 3 is out, due Mon Feb 16 No domain theory! Homework 1 is graded Feedback attached 14.2 (mean), 13 (median),

More information

Temporal logics and explicit-state model checking. Pierre Wolper Université de Liège

Temporal logics and explicit-state model checking. Pierre Wolper Université de Liège Temporal logics and explicit-state model checking Pierre Wolper Université de Liège 1 Topics to be covered Introducing explicit-state model checking Finite automata on infinite words Temporal Logics and

More information

CSC 7101: Programming Language Structures 1. Axiomatic Semantics. Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11.

CSC 7101: Programming Language Structures 1. Axiomatic Semantics. Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11. Axiomatic Semantics Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 1 Overview We ll develop proof rules, such as: { I b } S { I } { I } while b do S end { I b } That allow us to verify

More information

Static Program Analysis

Static Program Analysis Static Program Analysis Xiangyu Zhang The slides are compiled from Alex Aiken s Michael D. Ernst s Sorin Lerner s A Scary Outline Type-based analysis Data-flow analysis Abstract interpretation Theorem

More information

«Specification and Abstraction of Semantics» 1. Souvenir, Souvenir. Neil D. Jones. Contents. A Tribute Workshop and Festival to Honor Neil D.

«Specification and Abstraction of Semantics» 1. Souvenir, Souvenir. Neil D. Jones. Contents. A Tribute Workshop and Festival to Honor Neil D. «Specification and Abstraction of Semantics» Patrick Cousot Radhia Cousot École normale supérieure CNRS & École polytechnique 45 rue d Ulm Route de Saclay 7530 Paris cedex 05, France 9118 Palaiseau Cedex,

More information

Denoting computation

Denoting computation A jog from Scott Domains to Hypercoherence Spaces 13/12/2006 Outline Motivation 1 Motivation 2 What Does Denotational Semantic Mean? Trivial examples Basic things to know 3 Scott domains di-domains 4 Event

More information

Categories, Proofs and Programs

Categories, Proofs and Programs Categories, Proofs and Programs Samson Abramsky and Nikos Tzevelekos Lecture 4: Curry-Howard Correspondence and Cartesian Closed Categories In A Nutshell Logic Computation 555555555555555555 5 Categories

More information

CSE 505, Fall 2005, Midterm Examination 8 November Please do not turn the page until everyone is ready.

CSE 505, Fall 2005, Midterm Examination 8 November Please do not turn the page until everyone is ready. CSE 505, Fall 2005, Midterm Examination 8 November 2005 Please do not turn the page until everyone is ready. Rules: The exam is closed-book, closed-note, except for one side of one 8.5x11in piece of paper.

More information

Denotational Semantics

Denotational Semantics Q Lecture Notes on Denotational Semantics Part II of the Computer Science Tripos 2010/11 Dr Marcelo Fiore Cambridge University Computer Laboratory c A. M. Pitts, G. Winskel, M. Fiore Contents Notes ii

More information

Towards a quantum calculus

Towards a quantum calculus QPL 2006 Preliminary Version Towards a quantum calculus (work in progress, extended abstract) Philippe Jorrand 1 Simon Perdrix 2 Leibniz Laboratory IMAG-INPG Grenoble, France Abstract The aim of this paper

More information

The non-logical symbols determine a specific F OL language and consists of the following sets. Σ = {Σ n } n<ω

The non-logical symbols determine a specific F OL language and consists of the following sets. Σ = {Σ n } n<ω 1 Preliminaries In this chapter we first give a summary of the basic notations, terminology and results which will be used in this thesis. The treatment here is reduced to a list of definitions. For the

More information

Reasoning About Imperative Programs. COS 441 Slides 10b

Reasoning About Imperative Programs. COS 441 Slides 10b Reasoning About Imperative Programs COS 441 Slides 10b Last time Hoare Logic: { P } C { Q } Agenda If P is true in the initial state s. And C in state s evaluates to s. Then Q must be true in s. Program

More information

COMP6463: λ-calculus

COMP6463: λ-calculus COMP6463: λ-calculus 1. Basics Michael Norrish Michael.Norrish@nicta.com.au Canberra Research Lab., NICTA Semester 2, 2015 Outline Introduction Lambda Calculus Terms Alpha Equivalence Substitution Dynamics

More information

Review. Principles of Programming Languages. Equality. The Diamond Property. The Church-Rosser Theorem. Corollaries. CSE 230: Winter 2007

Review. Principles of Programming Languages. Equality. The Diamond Property. The Church-Rosser Theorem. Corollaries. CSE 230: Winter 2007 CSE 230: Winter 2007 Principles of Programming Languages Lecture 12: The λ-calculus Ranjit Jhala UC San Diego Review The lambda calculus is a calculus of functions: e := x λx. e e 1 e 2 Several evaluation

More information

Programming Language Concepts, CS2104 Lecture 3

Programming Language Concepts, CS2104 Lecture 3 Programming Language Concepts, CS2104 Lecture 3 Statements, Kernel Language, Abstract Machine 31 Aug 2007 CS2104, Lecture 3 1 Reminder of last lecture Programming language definition: syntax, semantics

More information

Gerwin Klein, June Andronick, Ramana Kumar S2/2016

Gerwin Klein, June Andronick, Ramana Kumar S2/2016 COMP4161: Advanced Topics in Software Verification {} Gerwin Klein, June Andronick, Ramana Kumar S2/2016 data61.csiro.au Content Intro & motivation, getting started [1] Foundations & Principles Lambda

More information

arxiv: v1 [math.lo] 11 Jul 2016

arxiv: v1 [math.lo] 11 Jul 2016 arxiv:1607.02970v1 [math.lo] 11 Jul 2016 THE SEQUENTIAL FUNCTIONALS OF TYPE (ι ι) n ι FORM A DCPO FOR ALL n N DAG NORMANN Abstract. We prove that the sequential functionals of some fixed types at type

More information

Hoare Logic I. Introduction to Deductive Program Verification. Simple Imperative Programming Language. Hoare Logic. Meaning of Hoare Triples

Hoare Logic I. Introduction to Deductive Program Verification. Simple Imperative Programming Language. Hoare Logic. Meaning of Hoare Triples Hoare Logic I Introduction to Deductive Program Verification Işıl Dillig Program Spec Deductive verifier FOL formula Theorem prover valid contingent Example specs: safety (no crashes), absence of arithmetic

More information

What does the partial order "mean"?

What does the partial order mean? What does the partial order "mean"? Domain theory developed by Dana Scott and Gordon Plotkin in the late '60s use partial order to represent (informally): approximates carries more information than better

More information

Hoare Logic: Reasoning About Imperative Programs

Hoare Logic: Reasoning About Imperative Programs Hoare Logic: Reasoning About Imperative Programs COMP1600 / COMP6260 Dirk Pattinson Australian National University Semester 2, 2018 Programming Paradigms Functional. (Haskell, SML, OCaml,... ) main paradigm:

More information

Programming Languages

Programming Languages CSE 230: Winter 2010 Principles of Programming Languages Lecture 10: Programming in λ-calculusc l l Ranjit Jhala UC San Diego Review The lambda calculus is a calculus of functions: e := x λx. e e 1 e 2

More information

What happens to the value of the expression x + y every time we execute this loop? while x>0 do ( y := y+z ; x := x:= x z )

What happens to the value of the expression x + y every time we execute this loop? while x>0 do ( y := y+z ; x := x:= x z ) Starter Questions Feel free to discuss these with your neighbour: Consider two states s 1 and s 2 such that s 1, x := x + 1 s 2 If predicate P (x = y + 1) is true for s 2 then what does that tell us about

More information

Bi-inductive Structural Semantics

Bi-inductive Structural Semantics SOS 2007 Bi-inductive Structural Semantics (Extended Abstract) Patrick Cousot 1 Département d informatique, École normale supérieure, 45 rue d Ulm, 75230 Paris cedex 05, France Radhia Cousot 2 CNRS & École

More information

Partial model checking via abstract interpretation

Partial model checking via abstract interpretation Partial model checking via abstract interpretation N. De Francesco, G. Lettieri, L. Martini, G. Vaglini Università di Pisa, Dipartimento di Ingegneria dell Informazione, sez. Informatica, Via Diotisalvi

More information

Axiomatic Semantics: Verification Conditions. Review of Soundness and Completeness of Axiomatic Semantics. Announcements

Axiomatic Semantics: Verification Conditions. Review of Soundness and Completeness of Axiomatic Semantics. Announcements Axiomatic Semantics: Verification Conditions Meeting 12, CSCI 5535, Spring 2009 Announcements Homework 4 is due tonight Wed forum: papers on automated testing using symbolic execution 2 Questions? Review

More information

Program Analysis Part I : Sequential Programs

Program Analysis Part I : Sequential Programs Program Analysis Part I : Sequential Programs IN5170/IN9170 Models of concurrency Program Analysis, lecture 5 Fall 2018 26. 9. 2018 2 / 44 Program correctness Is my program correct? Central question for

More information

CS156: The Calculus of Computation Zohar Manna Autumn 2008

CS156: The Calculus of Computation Zohar Manna Autumn 2008 Page 3 of 52 Page 4 of 52 CS156: The Calculus of Computation Zohar Manna Autumn 2008 Lecturer: Zohar Manna (manna@cs.stanford.edu) Office Hours: MW 12:30-1:00 at Gates 481 TAs: Boyu Wang (wangboyu@stanford.edu)

More information

Minimal logic for computable functionals

Minimal logic for computable functionals Minimal logic for computable functionals Helmut Schwichtenberg Mathematisches Institut der Universität München Contents 1. Partial continuous functionals 2. Total and structure-total functionals 3. Terms;

More information

Mechanics of Static Analysis

Mechanics of Static Analysis Escuela 03 III / 1 Mechanics of Static Analysis David Schmidt Kansas State University www.cis.ksu.edu/~schmidt Escuela 03 III / 2 Outline 1. Small-step semantics: trace generation 2. State generation and

More information

Design of Distributed Systems Melinda Tóth, Zoltán Horváth

Design of Distributed Systems Melinda Tóth, Zoltán Horváth Design of Distributed Systems Melinda Tóth, Zoltán Horváth Design of Distributed Systems Melinda Tóth, Zoltán Horváth Publication date 2014 Copyright 2014 Melinda Tóth, Zoltán Horváth Supported by TÁMOP-412A/1-11/1-2011-0052

More information

Introduction to lambda calculus Part 6

Introduction to lambda calculus Part 6 Introduction to lambda calculus Part 6 Antti-Juhani Kaijanaho 2017-02-16 1 Untyped lambda calculus 2 Typed lambda calculi 2.1 Dynamically typed lambda calculus with integers 2.2 A model of Lisp 2.3 Simply

More information

Course Runtime Verification

Course Runtime Verification Course Martin Leucker (ISP) Volker Stolz (Høgskolen i Bergen, NO) INF5140 / V17 Chapters of the Course Chapter 1 Recall in More Depth Chapter 2 Specification Languages on Words Chapter 3 LTL on Finite

More information

Principles of Program Analysis: A Sampler of Approaches

Principles of Program Analysis: A Sampler of Approaches Principles of Program Analysis: A Sampler of Approaches Transparencies based on Chapter 1 of the book: Flemming Nielson, Hanne Riis Nielson and Chris Hankin: Principles of Program Analysis Springer Verlag

More information

Coinductive big-step semantics and Hoare logics for nontermination

Coinductive big-step semantics and Hoare logics for nontermination Coinductive big-step semantics and Hoare logics for nontermination Tarmo Uustalu, Inst of Cybernetics, Tallinn joint work with Keiko Nakata COST Rich Models Toolkit meeting, Madrid, 17 18 October 2013

More information

Preliminaries. Introduction to EF-games. Inexpressivity results for first-order logic. Normal forms for first-order logic

Preliminaries. Introduction to EF-games. Inexpressivity results for first-order logic. Normal forms for first-order logic Introduction to EF-games Inexpressivity results for first-order logic Normal forms for first-order logic Algorithms and complexity for specific classes of structures General complexity bounds Preliminaries

More information

CS1800: Mathematical Induction. Professor Kevin Gold

CS1800: Mathematical Induction. Professor Kevin Gold CS1800: Mathematical Induction Professor Kevin Gold Induction: Used to Prove Patterns Just Keep Going For an algorithm, we may want to prove that it just keeps working, no matter how big the input size

More information

Semantics and Verification of Software

Semantics and Verification of Software Semantics and Verification of Software Thomas Noll Software Modeling and Verification Group RWTH Aachen University http://moves.rwth-aachen.de/teaching/ss-15/sv-sw/ The Denotational Approach Denotational

More information

CS 6110 Lecture 35 Solving Domain Equations 19 April 2013 Lecturer: Andrew Myers

CS 6110 Lecture 35 Solving Domain Equations 19 April 2013 Lecturer: Andrew Myers CS 6110 Lecture 35 Solving Domain Equations 19 April 2013 Lecturer: Andrew Myers To develop a denotational semantics for a language with recursive types, or to give a denotational semantics for the untyped

More information

Linearity and Passivity

Linearity and Passivity Linearity and Passivity David A. 1 School of Computing University of Tasmania GPO Box 252-100 Hobart 7001 Australia Abstract A simple symmetric logic is proposed which captures both the notions of Linearity

More information

Formal Methods in Software Engineering

Formal Methods in Software Engineering Formal Methods in Software Engineering An Introduction to Model-Based Analyis and Testing Vesal Vojdani Department of Computer Science University of Tartu Fall 2014 Vesal Vojdani (University of Tartu)

More information

Introduction to Kleene Algebra Lecture 14 CS786 Spring 2004 March 15, 2004

Introduction to Kleene Algebra Lecture 14 CS786 Spring 2004 March 15, 2004 Introduction to Kleene Algebra Lecture 14 CS786 Spring 2004 March 15, 2004 KAT and Hoare Logic In this lecture and the next we show that KAT subsumes propositional Hoare logic (PHL). Thus the specialized

More information

A few bridges between operational and denotational semantics of programming languages

A few bridges between operational and denotational semantics of programming languages A few bridges between operational and denotational semantics of programming languages Soutenance d habilitation à diriger les recherches Tom Hirschowitz November 17, 2017 Hirschowitz Bridges between operational

More information

Denotational Semantics

Denotational Semantics Q Lecture Notes on Denotational Semantics for Part II of the Computer Science Tripos Andrew M. Pitts Cambridge University Computer Laboratory c A. M. Pitts, 1997-9 First edition 1997. Revised 1998, 1999.

More information

States and Actions: An Automata-theoretic Model of Objects

States and Actions: An Automata-theoretic Model of Objects States and Actions: An Automata-theoretic Model of Objects Uday S. Reddy 1 Brian P. Dunphy 2 1 University of Birmingham 2 University of Illinois at Urbana-Champaign Portland, Oct 2011 Uday S. Reddy (Univ

More information

An Abstract Domain to Infer Ordinal-Valued Ranking Functions

An Abstract Domain to Infer Ordinal-Valued Ranking Functions An Abstract Domain to Infer Ordinal-Valued Ranking Functions Caterina Urban and Antoine Miné ÉNS & CNRS & INRIA, Paris, France urban@di.ens.fr, mine@di.ens.fr Abstract. The traditional method for proving

More information

CSE 505, Fall 2009, Midterm Examination 5 November Please do not turn the page until everyone is ready.

CSE 505, Fall 2009, Midterm Examination 5 November Please do not turn the page until everyone is ready. CSE 505, Fall 2009, Midterm Examination 5 November 2009 Please do not turn the page until everyone is ready Rules: The exam is closed-book, closed-note, except for one side of one 85x11in piece of paper

More information

Chapter 4: Computation tree logic

Chapter 4: Computation tree logic INFOF412 Formal verification of computer systems Chapter 4: Computation tree logic Mickael Randour Formal Methods and Verification group Computer Science Department, ULB March 2017 1 CTL: a specification

More information

Safety Analysis versus Type Inference for Partial Types

Safety Analysis versus Type Inference for Partial Types Safety Analysis versus Type Inference for Partial Types Jens Palsberg palsberg@daimi.aau.dk Michael I. Schwartzbach mis@daimi.aau.dk Computer Science Department, Aarhus University Ny Munkegade, DK-8000

More information

G54FOP: Lecture 17 & 18 Denotational Semantics and Domain Theory III & IV

G54FOP: Lecture 17 & 18 Denotational Semantics and Domain Theory III & IV G54FOP: Lecture 17 & 18 Denotational Semantics and Domain Theory III & IV Henrik Nilsson University of Nottingham, UK G54FOP: Lecture 17 & 18 p.1/33 These Two Lectures Revisit attempt to define denotational

More information

Propositions and Proofs

Propositions and Proofs Chapter 2 Propositions and Proofs The goal of this chapter is to develop the two principal notions of logic, namely propositions and proofs There is no universal agreement about the proper foundations

More information

Complete Partial Orders, PCF, and Control

Complete Partial Orders, PCF, and Control Complete Partial Orders, PCF, and Control Andrew R. Plummer TIE Report Draft January 2010 Abstract We develop the theory of directed complete partial orders and complete partial orders. We review the syntax

More information

arxiv: v1 [cs.pl] 19 May 2016

arxiv: v1 [cs.pl] 19 May 2016 arxiv:1605.05858v1 [cs.pl] 19 May 2016 Domain Theory: An Introduction Robert Cartwright Rice University Rebecca Parsons ThoughtWorks, Inc. Moez AbdelGawad SRTA-City Hunan University This monograph is an

More information

Tutorial on Semantics Part I

Tutorial on Semantics Part I Tutorial on Semantics Part I Basic Concepts Prakash Panangaden 1 1 School of Computer Science McGill University on sabbatical leave at Department of Computer Science Oxford University Fields Institute,

More information

Recursion: Introduction and Correctness

Recursion: Introduction and Correctness Recursion: Introduction and Correctness CSE21 Winter 2017, Day 7 (B00), Day 4-5 (A00) January 25, 2017 http://vlsicad.ucsd.edu/courses/cse21-w17 Today s Plan From last time: intersecting sorted lists and

More information

Hoare Logic (I): Axiomatic Semantics and Program Correctness

Hoare Logic (I): Axiomatic Semantics and Program Correctness Hoare Logic (I): Axiomatic Semantics and Program Correctness (Based on [Apt and Olderog 1991; Gries 1981; Hoare 1969; Kleymann 1999; Sethi 199]) Yih-Kuen Tsay Dept. of Information Management National Taiwan

More information

AAA616: Program Analysis. Lecture 3 Denotational Semantics

AAA616: Program Analysis. Lecture 3 Denotational Semantics AAA616: Program Analysis Lecture 3 Denotational Semantics Hakjoo Oh 2018 Spring Hakjoo Oh AAA616 2018 Spring, Lecture 3 March 28, 2018 1 / 33 Denotational Semantics In denotational semantics, we are interested

More information

3 Propositional Logic

3 Propositional Logic 3 Propositional Logic 3.1 Syntax 3.2 Semantics 3.3 Equivalence and Normal Forms 3.4 Proof Procedures 3.5 Properties Propositional Logic (25th October 2007) 1 3.1 Syntax Definition 3.0 An alphabet Σ consists

More information

COSE312: Compilers. Lecture 14 Semantic Analysis (4)

COSE312: Compilers. Lecture 14 Semantic Analysis (4) COSE312: Compilers Lecture 14 Semantic Analysis (4) Hakjoo Oh 2017 Spring Hakjoo Oh COSE312 2017 Spring, Lecture 14 May 8, 2017 1 / 30 Denotational Semantics In denotational semantics, we are interested

More information

Model Theory MARIA MANZANO. University of Salamanca, Spain. Translated by RUY J. G. B. DE QUEIROZ

Model Theory MARIA MANZANO. University of Salamanca, Spain. Translated by RUY J. G. B. DE QUEIROZ Model Theory MARIA MANZANO University of Salamanca, Spain Translated by RUY J. G. B. DE QUEIROZ CLARENDON PRESS OXFORD 1999 Contents Glossary of symbols and abbreviations General introduction 1 xix 1 1.0

More information

Problem One: Order Relations i. What three properties does a binary relation have to have to be a partial order?

Problem One: Order Relations i. What three properties does a binary relation have to have to be a partial order? CS103 Handout 16 Fall 2011 November 4, 2011 Extra Practice Problems Many of you have expressed interest in additional practice problems to review the material from the first four weeks of CS103. This handout

More information

A Monad For Randomized Algorithms

A Monad For Randomized Algorithms A Monad For Randomized Algorithms Tyler Barker Tulane University 1 Domains XII August 26, 2015 1 Supported by AFOSR Tyler Barker Tulane University A Monad For Randomized Algorithms Domains XII August 26,

More information

Mathematical Foundations of Programming. Nicolai Kraus. Draft of February 15, 2018

Mathematical Foundations of Programming. Nicolai Kraus. Draft of February 15, 2018 Very short lecture notes: Mathematical Foundations of Programming University of Nottingham, Computer Science, module code G54FOP, Spring 2018 Nicolai Kraus Draft of February 15, 2018 What is this? This

More information

Automata-based Verification - III

Automata-based Verification - III CS3172: Advanced Algorithms Automata-based Verification - III Howard Barringer Room KB2.20/22: email: howard.barringer@manchester.ac.uk March 2005 Third Topic Infinite Word Automata Motivation Büchi Automata

More information

An Abstract Interpretation Framework for Semantics and Diagnosis of Lazy Functional-Logic Languages

An Abstract Interpretation Framework for Semantics and Diagnosis of Lazy Functional-Logic Languages Università degli Studi di Udine Dipartimento di Matematica e Informatica Dottorato di Ricerca in Informatica Ph.D. Thesis An Abstract Interpretation Framework for Semantics and Diagnosis of Lazy Functional-Logic

More information

Contextual equivalence

Contextual equivalence Techniques 16/22 ACS L16, lecture 2 4/10 Contextual equivalence Two phrases of a programming language are ( Morris style ) contextually equivalent ( = ctx ) if occurrences of the first phrase in any program

More information

b + O(n d ) where a 1, b > 1, then O(n d log n) if a = b d d ) if a < b d O(n log b a ) if a > b d

b + O(n d ) where a 1, b > 1, then O(n d log n) if a = b d d ) if a < b d O(n log b a ) if a > b d CS161, Lecture 4 Median, Selection, and the Substitution Method Scribe: Albert Chen and Juliana Cook (2015), Sam Kim (2016), Gregory Valiant (2017) Date: January 23, 2017 1 Introduction Last lecture, we

More information

Overall organisation and objectives. Semantics and Validation. Example of validation. Principle of course/tp relationship

Overall organisation and objectives. Semantics and Validation. Example of validation. Principle of course/tp relationship Overall organisation and objectives Semantics and Validation Eric Goubault Modelling and Analysis of Systems in Interaction lab. CEA-X-CNRS and X-Thalès chair 2nd of november 2011 How to give a formal

More information

CS Lecture 19: Logic To Truth through Proof. Prof. Clarkson Fall Today s music: Theme from Sherlock

CS Lecture 19: Logic To Truth through Proof. Prof. Clarkson Fall Today s music: Theme from Sherlock CS 3110 Lecture 19: Logic To Truth through Proof Prof. Clarkson Fall 2014 Today s music: Theme from Sherlock Review Current topic: How to reason about correctness of code Last week: informal arguments

More information

Halting and Equivalence of Program Schemes in Models of Arbitrary Theories

Halting and Equivalence of Program Schemes in Models of Arbitrary Theories Halting and Equivalence of Program Schemes in Models of Arbitrary Theories Dexter Kozen Cornell University, Ithaca, New York 14853-7501, USA, kozen@cs.cornell.edu, http://www.cs.cornell.edu/~kozen In Honor

More information

A Short Introduction to Hoare Logic

A Short Introduction to Hoare Logic A Short Introduction to Hoare Logic Supratik Chakraborty I.I.T. Bombay June 23, 2008 Supratik Chakraborty (I.I.T. Bombay) A Short Introduction to Hoare Logic June 23, 2008 1 / 34 Motivation Assertion checking

More information

Model Theory of Modal Logic Lecture 5. Valentin Goranko Technical University of Denmark

Model Theory of Modal Logic Lecture 5. Valentin Goranko Technical University of Denmark Model Theory of Modal Logic Lecture 5 Valentin Goranko Technical University of Denmark Third Indian School on Logic and its Applications Hyderabad, January 29, 2010 Model Theory of Modal Logic Lecture

More information

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata CISC 4090: Theory of Computation Chapter Regular Languages Xiaolan Zhang, adapted from slides by Prof. Werschulz Section.: Finite Automata Fordham University Department of Computer and Information Sciences

More information

Techniques. Contextual equivalence

Techniques. Contextual equivalence Techniques 16/22 Contextual equivalence Two phrases of a programming language are ( Morris style ) contextually equivalent ( = ctx )if occurrences of the first phrase in any program can be replaced by

More information

Quantum Functional Programming Language & Its Denotational Semantics

Quantum Functional Programming Language & Its Denotational Semantics Quantum Functional Programming Language & Its Denotational Semantics Ichiro Hasuo Dept. Computer Science University of Tokyo Naohiko Hoshino Research Inst. for Math. Sci. Kyoto University Talk based on:

More information

CMSC 451: Lecture 7 Greedy Algorithms for Scheduling Tuesday, Sep 19, 2017

CMSC 451: Lecture 7 Greedy Algorithms for Scheduling Tuesday, Sep 19, 2017 CMSC CMSC : Lecture Greedy Algorithms for Scheduling Tuesday, Sep 9, 0 Reading: Sects.. and. of KT. (Not covered in DPV.) Interval Scheduling: We continue our discussion of greedy algorithms with a number

More information

Logical Abstract Domains and Interpretations

Logical Abstract Domains and Interpretations Logical Abstract Domains and Interpretations Patrick Cousot 2,3, Radhia Cousot 3,1, and Laurent Mauborgne 3,4 1 Centre National de la Recherche Scientifique, Paris 2 Courant Institute of Mathematical Sciences,

More information