Logic-Flow Analysis of Higher-Order Programs

Size: px
Start display at page:

Download "Logic-Flow Analysis of Higher-Order Programs"

Transcription

1 Logic-Flow Analysis of Higher-Order Programs Matt Might POPL 2007

2 Why? Tim Sweeney, POPL 2006 Static array-bounds checking. Example... a[i]... Will 0 i < a.length always hold?

3 3 Why? Tim Sweeney, POPL 2006 Static array-bounds checking. Example... a[i]... Will 0 i < a.length always hold? Wait... Hasn t this been done already? (Range analysis, etc.)

4 Why? Tim Sweeney, POPL 2006 Static array-bounds checking. Example... a[i]... Will 0 i < a.length always hold? Wait... Hasn t this been done already? (Range analysis, etc.) Yeah, but not for permutation/vertex array code.

5 5 Why? Tim Sweeney, POPL 2006 Static array-bounds checking. Example... a[i]... Will 0 i < a.length always hold? Wait... Hasn t this been done already? (Range analysis, etc.) Yeah, but not for permutation/vertex array code. Not the big idea LFA is not about array-bounds checking.

6 6 The Idea Theorem Proving Flow Analysis

7 The Idea Theorem Proving Flow Analysis

8 8 The Idea Theorem Proving Flow Analysis

9 9 How? Abstract interpretation Mechanical (flow): ς ς ς Propositional (logic): Π Π Π

10 10 How? Abstract interpretation Mechanical (flow): ς ς Propositional (logic): Π Π ς Π

11 Higher-order flow analysis fails Example... a[i]... Will 0 i < a.length always hold?

12 Higher-order flow analysis fails Example... a[i]... Will 0 i < a.length always hold? Flow analysis results a is an array.

13 13 Higher-order flow analysis fails Example... a[i]... Will 0 i < a.length always hold? Flow analysis results a is an array from line 10 or line 30.

14 Higher-order flow analysis fails Example... a[i]... Will 0 i < a.length always hold? Flow analysis results a is an array from line 10 or line 30. i is an integer.

15 15 Higher-order flow analysis fails Example... a[i]... Will 0 i < a.length always hold? Flow analysis results a is an array from line 10 or line 30. i is a non-negative integer.

16 16 Higher-order flow analysis fails Example... a[i]... Will 0 i < a.length always hold? Flow analysis results a is an array from line 10 or line 30. i is a non-negative integer. a.length is a positive integer.

17 Higher-order flow analysis fails Example... a[i]... Will 0 i < a.length always hold? Flow analysis results a is an array from line 10 or line 30. i is a non-negative integer. a.length is a positive integer. Insufficiently rich information Frequently can t show i < a.length.

18 18 First attempt: Enrich flow values with relations Example... a[i]... Will 0 i < a.length always hold?

19 19 First attempt: Enrich flow values with relations Example... a[i]... Will 0 i < a.length always hold? Hypothetical results a is an array from line 10 or line 30. i is a non-negative integer. a.length is a positive integer.

20 20 First attempt: Enrich flow values with relations Example... a[i]... Will 0 i < a.length always hold? Hypothetical results a is an array from line 10 or line 30. i is in {x : 0 x < a.length}. a.length is a positive integer.

21 First attempt: Enrich flow values with relations Example... a[i]... Will 0 i < a.length always hold? Hypothetical results a is an array from line 10 or line 30. i is in {x : 0 x < a.length}. a.length is a positive integer. Problems 1. What does a.length mean where a is out of scope? 2. How did this set get there in the first place?

22 First attempt: Enrich flow values with relations Example... a[i]... Will 0 i < a.length always hold? Hypothetical results a is an array from line 10 or line 30. i is in {x : 0 x < a.length}. a.length is a positive integer. Problems 1. What does a.length mean where a is out of scope? 2. How did this set get there in the first place?

23 23 Problem 1: Meaning of variables Ambiguity problem Need environment-independent identities for values.

24 Problem 1: Meaning of variables Ambiguity problem Need environment-independent identities for values. Solutions Constants. E.g. 5 means 5 anywhere.

25 25 Problem 1: Meaning of variables Ambiguity problem Need environment-independent identities for values. Solutions Constants. E.g. 5 means 5 anywhere. Heap locations. E.g. Heap location 10 offset 3.

26 26 Problem 1: Meaning of variables Ambiguity problem Need environment-independent identities for values. Solutions Constants. E.g. 5 means 5 anywhere. Heap locations. E.g. Heap location 10 offset 3. Bindings. [Shivers 1988]

27 Bindings Definition A binding is a variable-time pairing, e.g. (x, 3).

28 28 Bindings Definition A binding is a variable-time pairing, e.g. (x, 3). Example (Variable v. binding) Value of variable x depends on environment. Value of x bound at time 3: Same in any environment/state.

29 29 Bindings Definition A binding is a variable-time pairing, e.g. (x, 3). Example (Variable v. binding) Value of variable x depends on environment. Value of x bound at time 3: Same in any environment/state. Example (Abstract bindings) 0CFA: All values of x bound at any time. 1CFA: All values of x bound at a time while calling foo.

30 30 Strategy Build binding-sensitive flow analysis.

31 31 Strategy Build binding-sensitive flow analysis. Build binding-sensitive logic.

32 32 Strategy Build binding-sensitive flow analysis. Build binding-sensitive logic. Build binding-sensitive propositional abstract interpretation.

33 33 Strategy Build binding-sensitive flow analysis. Build binding-sensitive logic. Build binding-sensitive propositional abstract interpretation. Weave.

34 34 Tool 1: Continuation-passing style (CPS) Contract Calls never return. Continuations are passed to receive the result. Example Direct-style identity function: (define (id x) x) Example CPS identity function: (define (id x return) (return x))

35 35 CPS simplifies In CPS, fun call, fun return, conditional branch, sequencing, iteration, exception throw, coroutine switch, continuation invocation...

36 36 CPS simplifies In CPS, fun call, fun return, conditional branch, sequencing, iteration, exception throw, coroutine switch, continuation invocation......all become call to λ

37 37 CPS simplifies In CPS, fun call, fun return, conditional branch, sequencing, iteration, exception throw, coroutine switch, continuation invocation... Machine state without CPS...all become call to λ ς State = CALL Env Store Stack Time

38 38 CPS simplifies In CPS, fun call, fun return, conditional branch, sequencing, iteration, exception throw, coroutine switch, continuation invocation... Machine state without CPS...all become call to λ ς State = CALL Env Store Stack Time

39 39 CPS simplifies In CPS, fun call, fun return, conditional branch, sequencing, iteration, exception throw, coroutine switch, continuation invocation... Machine state with CPS...all become call to λ ς State = CALL Env Store Time

40 40 Tool 2: Machine-based abstract interpretation Idea Abstract machine states component-wise. Machine state A An A A call site. environment for variable lookup. heap. time. More formally ς State = CALL Env Store Time

41 Tool 2: Machine-based abstract interpretation Idea Abstract machine states component-wise. Abstract machine state An abstract call site. An abstract environment for variable lookup. An abstract heap. An abstract time. More formally ς Ŝtate = ĈALL Ênv Ŝtore Time

42 Tool 2: Machine-based abstract interpretation Idea Abstract machine states component-wise. Abstract machine state An abstract call site. An abstract environment for variable lookup. An abstract heap. An abstract time. More formally ς Ŝtate = ĈALL Ênv Ŝtore Time

43 43 Binding-factored environment Definition An environment maps variables to values.

44 Binding-factored environment Definition An environment maps variables to values. Definition A binding-factored environment (β, ve) [Shivers 1988] maps: variables to their binding times. (β) and then, variables plus times (bindings) to values. (ve)

45 45 Tool 3: Restricted first-order logic for states Features Propositions are facts about concrete machine states. Ground terms are identities (bindings, locations, constants).

46 46 Tool 3: Restricted first-order logic for states Features Propositions are facts about concrete machine states. Ground terms are identities (bindings, locations, constants). Restrictions No existential quantifiers. Only outer-level universal quantifiers. Quantifiers range over abstract identities.

47 Example: Proposition Example Every value of x bound while calling foo is less than the length of every array bound to a.

48 48 Example: Proposition Example Every value of x bound while calling foo is less than the length of every array bound to a. In longhand: (forall x : (x, t foo ) (forall a : (a, ) (< x (alen a))))

49 49 Example: Proposition Example Every value of x bound while calling foo is less than the length of every array bound to a. In longhand: (forall x : (x, t foo ) (forall a : (a, ) (< x (alen a)))) Or, in convenient (but incomplete) shorthand: (< (x, t foo ) (alen (a, )))

50 50 Logic syntax Features S-Expressions. Just or, not. Relations encoded as functions.

51 51 Logic semantics Question How do we know when proposition φ is true for state ς?

52 52 Logic semantics Question How do we know when proposition φ is true for state ς? Answer When ς = φ holds.

53 53 Logic semantics Question How do we know when proposition φ is true for state ς? Answer When ς = φ holds. Means exactly what you think it means.

54 Filtered concretization Set of conrete states (State) 54

55 Filtered concretization ς Set of conrete states (State) {ς : ς ς } 55

56 Filtered concretization Π Set of conrete states (State) {ς : ς = Π} 56

57 Filtered concretization ς ς/π Π Set of conrete states (State) {ς : ς ς and ς = Π} 57

58 58 Deriving new propositions Example If ς = (= x y) and ς = (= y z), does ς = (= x z) hold?

59 59 Deriving new propositions Example If ς = (= x y) and ς = (= y z), does ς = (= x z) hold? Answer Yes, if {(= x y),(= y z)} (= x z) holds.

60 60 Deriving new propositions Example If ς = (= x y) and ς = (= y z), does ς = (= x z) hold? Answer Yes, if {(= x y),(= y z)} (= x z) holds. (Assm) ψ Π Π ψ ( Ant) Π {φ 1 } φ 3 Π {φ 2 } φ 3 Π {(or φ 1 φ 2 )} φ 3 (Subst) Π (= ι ι ) Π ψ[ι/x] Π ψ[ι /x] (Ant) Π φ Π Π Π φ (Cases) Π {φ 1 } φ 2 Π {(not φ 1 )} φ 2 Π φ 2 (Contr) Π {(not φ 1 )} φ 2 Π {(not φ 1 )} (not φ 2 ) Π φ 1 (Eq) Π (= ι ι) ( Cons) ( Intro) Π φ 1 Π (or φ 1 φ 2 ),(or φ 2 φ 1 ) Π ψ x free(ψ) Π (forall x : ι ψ) ( Swap) (Int) Π (forall x : ι φ) {φ} φ Π (forall x : ι (and φ φ )) Π (forall x 1, x 2 : ι 1, ι 2 ψ) Π (forall x 2, x 1 : ι 2, ι 1 ψ)

61 61 Trusting the theorem prover Summary = : What a proposition means. : What a proposition implies.

62 62 Trusting the theorem prover Summary = : What a proposition means. : What a proposition implies. Question How can we trust an external theorem prover?

63 63 Trusting the theorem prover Summary = : What a proposition means. : What a proposition implies. Question How can we trust an external theorem prover? Theorem (Syntactic soundness) If Π φ holds, then Π = φ holds.

64 All together now 64

65 65 Woven state Example (Machine, ς) call site (f x k) local env f t foo k t foo x t foo global env (f, t foo ) (k, t foo ) (x, t foo ) positive (z, t bar ) positive Example (Assumptions, Π) (forall x : (x, t foo ) (forall z : (z, t bar ) (< x z))) time t f

66 66 Woven state Example (Machine, ς) call site (f x k) local env f t foo k t foo x t foo global env (f, t foo ) (k, t foo ) (x, t foo ) positive (z, t bar ) positive Example (Assumptions, Π) (forall x : (x, t foo ) (forall z : (z, t bar ) (< x z))) time t f

67 67 Woven transition relation Old machine state New machine state ( ς,π) => ( ς,π ) Old assumption base New assumption base

68 68 Example: Transition Example call site (f x k) time t f

69 69 Example: Transition Example call site (f x k) local env f t foo time t f

70 70 Example: Transition Example call site (f x k) local env f t foo global env (f, t foo ) a closure over (λ (a q)...) time t f

71 Example: Transition Example call site (f x k) local env f t foo x t foo global env (f, t foo ) a closure over (λ (a q)...) time t f

72 Example: Transition Example call site (f x k) local env f t foo x t foo global env (f, t foo ) a closure over (λ (a q)...) time t f New fact? (forall x,a : (x, t foo ),(a, t f ) (= x a))

73 It depends. 73

74 Chaining equal values Candidate for Π φ = (forall x,a : (x, t foo ),(a, t f ) (= x a)) Prerequisites Can add it if Π φ. Chicken and egg How can φ be in there already?

75 75 ΓCFA: Abstract counting Idea Keep count of concrete counterparts to abstract identities.

76 76 ΓCFA: Abstract counting Idea Keep count of concrete counterparts to abstract identities. Mechanism Add counter to every abstract machine state. Counter maps each binding to times allocated. Stop counting after 1.

77 ΓCFA: Abstract counting Idea Keep count of concrete counterparts to abstract identities. Mechanism Add counter to every abstract machine state. Counter maps each binding to times allocated. Stop counting after 1. Theorem If {binding 1 } = {binding 2 }, then binding 1 = binding 2.

78 78 Chaining equal values Candidate for Π φ = (forall x,a : (x, t foo ),(a, t f ) (= x a)) Prerequisites Can add it if Π φ. Or, if count of (x, t foo ) is 1 and count of (a, t f ) is 0.

79 79 ΓCFA: Abstract garbage collection Idea Discard unreachable bindings.

80 80 ΓCFA: Abstract garbage collection Idea Discard unreachable bindings. Mechanism Start with bindings touched by current state. Take transitive closure. Can reset unreachable bindings counts to 0.

81 81 Chaining equal values Candidate for Π φ = (forall x,a : (x, t foo ),(a, t f ) (= x a)) Prerequisites Can add it if Π φ. Or, if count of (x, t foo ) is 1 and count of (a, t f ) is 0. Or, if count of (x, t foo ) is 1 and (a, t f ) is unreachable. (More in paper.)

82 82 Example: Invertible rebinding Example call site (f (+ x 1) k) local env f t foo x t f global env (f, t foo ) a closure over (λ (x q)...) time t f Updating assumption base Can replace (x, t f ) with (- (x, t f ) 1) in Π?

83 Example: Invertible rebinding Example call site (f (+ x 1) k) local env f t foo x t f global env (f, t foo ) a closure over (λ (x q)...) time t f Updating assumption base Can replace (x, t f ) with (- (x, t f ) 1) in Π? Yes, if (x, t f ) is unreachable and its count is 1. (E.g. tail recursion, for loops.) (More on this in the paper.) 83

84 84 Example: Conditional Example call site (if (< i (alen a))......)

85 85 Example: Conditional Example call site (if (< i (alen a))......) Case 1 Π can (dis)prove (< i (alen a)). Branch one way. ς true ς ς false

86 86 Example: Conditional Example call site (if (< i (alen a))......) Case 2 (< i (alen a)) has one counterpart. Branch both ways & assert. ς true (< i (alen a)) ς (not (< i (alen a))) ς false

87 87 Example: Conditional Example call site (if (< i (alen a))......) Case 3 None of the above. Branch both ways. Don t touch Π. ς ς true ς false

88 88 Walkthrough: Simple for loop Example for (i = 0; i < a.length; i++) print(a[i]) ; Example (CPS) (letrec ((loop (λ (i) (if (< i (alen a)) (print (aget a i) (λ () (loop (+ i 1))))...)))) (loop 0)) Parameters 0CFA contour set. (Bindings = Variables.)

89 89 Walkthrough: Simple for loop (letrec ((loop (λ (i) (if (< i (alen a)) (print (aget a i) (λ () (loop (+ i 1))))...)))) (loop 0)) Assumption base, Π (< 0 (alen a))

90 90 Walkthrough: Simple for loop (letrec ((loop (λ (i) (if (< i (alen a)) (print (aget a i) (λ () (loop (+ i 1))))...)))) (loop 0)) Assumption base, Π (< 0 (alen a))

91 91 Walkthrough: Simple for loop (letrec ((loop (λ (i) (if (< i (alen a)) (print (aget a i) (λ () (loop (+ i 1))))...)))) (loop 0)) Assumption base, Π (< 0 (alen a)), (= 0 i)

92 92 Walkthrough: Simple for loop (letrec ((loop (λ (i) (if (< i (alen a)) (print (aget a i) (λ () (loop (+ i 1))))...)))) (loop 0)) Assumption base, Π (< 0 (alen a)), (= 0 i)

93 93 Walkthrough: Simple for loop (letrec ((loop (λ (i) (if (< i (alen a)) (print (aget a i) (λ () (loop (+ i 1))))...)))) (loop 0)) Assumption base, Π (< 0 (alen a)), (= 0 i) Safe 0 i < (alen a) holds!

94 94 Walkthrough: Simple for loop (letrec ((loop (λ (i) (if (< i (alen a)) (print (aget a i) (λ () (loop (+ i 1))))...)))) (loop 0)) Assumption base, Π (< 0 (alen a)), (= 0 i)

95 95 Walkthrough: Simple for loop (letrec ((loop (λ (i) (if (< i (alen a)) (print (aget a i) (λ () (loop (+ i 1))))...)))) (loop 0)) Assumption base, Π (< 0 (alen a)), (= 0 i)

96 96 Walkthrough: Simple for loop (letrec ((loop (λ (i) (if (< i (alen a)) (print (aget a i) (λ () (loop (+ i 1))))...)))) (loop 0)) Assumption base, Π (< 0 (alen a)), (= 0 (- i 1))

97 97 Walkthrough: Simple for loop (letrec ((loop (λ (i) (if (< i (alen a)) (print (aget a i) (λ () (loop (+ i 1))))...)))) (loop 0)) Assumption base, Π (< 0 (alen a)), ( 0 i)

98 98 Walkthrough: Simple for loop (letrec ((loop (λ (i) (if (< i (alen a)) (print (aget a i) (λ () (loop (+ i 1))))...)))) (loop 0)) Assumption base, Π (< 0 (alen a)), ( 0 i), (< i (alen a)) Safe 0 i < (alen a) holds!

99 99 Walkthrough: Simple for loop (letrec ((loop (λ (i) (if (< i (alen a)) (print (aget a i) (λ () (loop (+ i 1))))...)))) (loop 0)) Assumption base, Π (< 0 (alen a)), ( 0 i), (< i (alen a))

100 100 Walkthrough: Simple for loop (letrec ((loop (λ (i) (if (< i (alen a)) (print (aget a i) (λ () (loop (+ i 1))))...)))) (loop 0)) Assumption base, Π (< 0 (alen a)), ( 0 i), (< i (alen a))

101 101 Walkthrough: Simple for loop (letrec ((loop (λ (i) (if (< i (alen a)) (print (aget a i) (λ () (loop (+ i 1))))...)))) (loop 0)) Assumption base, Π (< 0 (alen a)), ( 0 (- i 1)), (< (- i 1) (alen a))

102 102 Walkthrough: Simple for loop (letrec ((loop (λ (i) (if (< i (alen a)) (print (aget a i) (λ () (loop (+ i 1))))...)))) (loop 0)) Assumption base, Π (< 0 (alen a)), ( 0 i), (< (- i 1) (alen a)), (< i (alen a)) Safe 0 i < (alen a) holds!

103 103 Walkthrough: Simple for loop (letrec ((loop (λ (i) (if (< i (alen a)) (print (aget a i) (λ () (loop (+ i 1))))...)))) (loop 0)) Assumption base, Π (< 0 (alen a)), ( 0 i), (< i (alen a)) Finished State already visited.

104 104 More in the paper Formal treatment. Flow analysis as oracle inference rules. More rules for assumption base management. Rules for handling arrays. Three-page worked example for vertex arrays.

105 105 Related & inspiring work Cousot & Cousot. (Abstract interpretation)

106 106 Related & inspiring work Cousot & Cousot. (Abstract interpretation) Cousot & Cousot. (Invariant synthesis)

107 107 Related & inspiring work Cousot & Cousot. (Abstract interpretation) Cousot & Cousot. (Invariant synthesis) Cousot & Cousot. (Widening & narrowing)

108 108 Related & inspiring work Cousot & Cousot. (Abstract interpretation) Cousot & Cousot. (Invariant synthesis) Cousot & Cousot. (Widening & narrowing) Cousot & Cousot. (Relational abstract domains)

109 109 Related & inspiring work Cousot & Cousot. (Abstract interpretation) Cousot & Cousot. (Invariant synthesis) Cousot & Cousot. (Widening & narrowing) Cousot & Cousot. (Relational abstract domains) Shivers. (Control-flow analysis w/ factored environment)

110 110 Related & inspiring work Cousot & Cousot. (Abstract interpretation) Cousot & Cousot. (Invariant synthesis) Cousot & Cousot. (Widening & narrowing) Cousot & Cousot. (Relational abstract domains) Shivers. (Control-flow analysis w/ factored environment) Hudak. (Abstract reference counting)

111 Related & inspiring work Cousot & Cousot. (Abstract interpretation) Cousot & Cousot. (Invariant synthesis) Cousot & Cousot. (Widening & narrowing) Cousot & Cousot. (Relational abstract domains) Shivers. (Control-flow analysis w/ factored environment) Hudak. (Abstract reference counting) Nanevski & Morrisett. (Soundness of theorem prover interaction)

112 Related & inspiring work Cousot & Cousot. (Abstract interpretation) Cousot & Cousot. (Invariant synthesis) Cousot & Cousot. (Widening & narrowing) Cousot & Cousot. (Relational abstract domains) Shivers. (Control-flow analysis w/ factored environment) Hudak. (Abstract reference counting) Nanevski & Morrisett. (Soundness of theorem prover interaction) Ball. (Predicate abstraction)

113 113 Related & inspiring work Cousot & Cousot. (Abstract interpretation) Cousot & Cousot. (Invariant synthesis) Cousot & Cousot. (Widening & narrowing) Cousot & Cousot. (Relational abstract domains) Shivers. (Control-flow analysis w/ factored environment) Hudak. (Abstract reference counting) Nanevski & Morrisett. (Soundness of theorem prover interaction) Ball. (Predicate abstraction)...

114 Related & future work CFA LFA ΓCFA

115 115 Related & future work CFA LFA ΓCFA

116 116 Related & future work CFA LFA ΓCFA ΘCFA

117 Conclusion HOFA + FOL = LFA

118 118 Conclusion HOFA + FOL = LFA Merci

119 119 Question What are some other applications of LFA? Answer Improving flow precision. Static checks of assert statements. Pre- and post-condition checks.

120 120 Question Do you have an implementation? Answer Half of one: Modified ACL/2 for theorem prover. Modified ΓCFA. Goal: Meet in the middle.

121 Question Does a backward version exist? Answer Not yet. Start by widening into constraint-solving form.

122 Question What is the complexity of LFA? Answer Exponential in theory. Usually much friendlier in pratice. It depends on......the contour set....the degree of widening to assumption base & abstract heap.

123 123 Question Do you support floats? Answer Patrick, not yet.

Formal Systems II: Applications

Formal Systems II: Applications Formal Systems II: Applications Functional Verification of Java Programs: Java Dynamic Logic Bernhard Beckert Mattias Ulbrich SS 2017 KIT INSTITUT FÜR THEORETISCHE INFORMATIK KIT University of the State

More information

Note that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m.

Note that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m. CS 6110 S18 Lecture 8 Structural Operational Semantics and IMP Today we introduce a very simple imperative language, IMP, along with two systems of rules for evaluation called small-step and big-step semantics.

More information

Programming Languages Third Edition

Programming Languages Third Edition Programming Languages Third Edition Chapter 12 Formal Semantics Objectives Become familiar with a sample small language for the purpose of semantic specification Understand operational semantics Understand

More information

CSE 413 Midterm, May 6, 2011 Sample Solution Page 1 of 8

CSE 413 Midterm, May 6, 2011 Sample Solution Page 1 of 8 Question 1. (12 points) For each of the following, what value is printed? (Assume that each group of statements is executed independently in a newly reset Scheme environment.) (a) (define x 1) (define

More information

A Gentle Introduction to Program Analysis

A Gentle Introduction to Program Analysis A Gentle Introduction to Program Analysis Işıl Dillig University of Texas, Austin January 21, 2014 Programming Languages Mentoring Workshop 1 / 24 What is Program Analysis? Very broad topic, but generally

More information

Runtime Checking for Program Verification Systems

Runtime Checking for Program Verification Systems Runtime Checking for Program Verification Systems Karen Zee, Viktor Kuncak, and Martin Rinard MIT CSAIL Tuesday, March 13, 2007 Workshop on Runtime Verification 1 Background Jahob program verification

More information

Fundamentals of Software Engineering

Fundamentals of Software Engineering Fundamentals of Software Engineering Reasoning about Programs - Selected Features Ina Schaefer Institute for Software Systems Engineering TU Braunschweig, Germany Slides by Wolfgang Ahrendt, Richard Bubel,

More information

Static Analysis of Dynamically Typed Languages made Easy

Static Analysis of Dynamically Typed Languages made Easy Static Analysis of Dynamically Typed Languages made Easy Yin Wang School of Informatics and Computing Indiana University Overview Work done as two internships at Google (2009 summer and 2010 summer) Motivation:

More information

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming Closures Mooly Sagiv Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming t ::= x x. t t t Call-by-value big-step Operational Semantics terms variable v ::= values abstraction x.

More information

Advanced Programming Methods. Introduction in program analysis

Advanced Programming Methods. Introduction in program analysis Advanced Programming Methods Introduction in program analysis What is Program Analysis? Very broad topic, but generally speaking, automated analysis of program behavior Program analysis is about developing

More information

Lecture 10 Design by Contract

Lecture 10 Design by Contract CS 5959 Writing Solid Code Fall 2015 Nov-23 Lecture 10 Design by Contract Zvonimir Rakamarić University of Utah Design by Contract Also called assume-guarantee reasoning Developers annotate software components

More information

Induction and Semantics in Dafny

Induction and Semantics in Dafny 15-414 Lecture 11 1 Instructor: Matt Fredrikson Induction and Semantics in Dafny TA: Ryan Wagner Encoding the syntax of Imp Recall the abstract syntax of Imp: a AExp ::= n Z x Var a 1 + a 2 b BExp ::=

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Operational Semantics CMSC 330 Summer 2018 1 Formal Semantics of a Prog. Lang. Mathematical description of the meaning of programs written in that language

More information

Scope, Functions, and Storage Management

Scope, Functions, and Storage Management Scope, Functions, and Storage Management Implementing Functions and Blocks cs3723 1 Simplified Machine Model (Compare To List Abstract Machine) Registers Code Data Program Counter (current instruction)

More information

Abstracting Definitional Interpreters

Abstracting Definitional Interpreters Abstracting Definitional Interpreters David Darais University of Maryland Nicholas Labich University of Maryland Phúc C. Nguyễn University of Maryland David Van Horn University of Maryland Does my program

More information

Compiler Theory. (Semantic Analysis and Run-Time Environments)

Compiler Theory. (Semantic Analysis and Run-Time Environments) Compiler Theory (Semantic Analysis and Run-Time Environments) 005 Semantic Actions A compiler must do more than recognise whether a sentence belongs to the language of a grammar it must do something useful

More information

Introduction to dependent types in Coq

Introduction to dependent types in Coq October 24, 2008 basic use of the Coq system In Coq, you can play with simple values and functions. The basic command is called Check, to verify if an expression is well-formed and learn what is its type.

More information

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 2. true / false ML can be compiled. 3. true / false FORTRAN can reasonably be considered

More information

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 19 Tuesday, April 3, 2018 1 Introduction to axiomatic semantics The idea in axiomatic semantics is to give specifications

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 4 Thomas Wies New York University Review Last week Control Structures Selection Loops Adding Invariants Outline Subprograms Calling Sequences Parameter

More information

Organization of Programming Languages CS3200/5200N. Lecture 11

Organization of Programming Languages CS3200/5200N. Lecture 11 Organization of Programming Languages CS3200/5200N Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.edu Functional vs. Imperative The design of the imperative languages

More information

CS 161 Computer Security

CS 161 Computer Security Wagner Spring 2014 CS 161 Computer Security 1/27 Reasoning About Code Often functions make certain assumptions about their arguments, and it is the caller s responsibility to make sure those assumptions

More information

! Those values must be stored somewhere! Therefore, variables must somehow be bound. ! How?

! Those values must be stored somewhere! Therefore, variables must somehow be bound. ! How? A Binding Question! Variables are bound (dynamically) to values Subprogram Activation! Those values must be stored somewhere! Therefore, variables must somehow be bound to memory locations! How? Function

More information

Model Checking with Abstract State Matching

Model Checking with Abstract State Matching Model Checking with Abstract State Matching Corina Păsăreanu QSS, NASA Ames Research Center Joint work with Saswat Anand (Georgia Institute of Technology) Radek Pelánek (Masaryk University) Willem Visser

More information

Lecture 6. Abstract Interpretation

Lecture 6. Abstract Interpretation Lecture 6. Abstract Interpretation Wei Le 2014.10 Outline Motivation History What it is: an intuitive understanding An example Steps of abstract interpretation Galois connection Narrowing and Widening

More information

3.7 Denotational Semantics

3.7 Denotational Semantics 3.7 Denotational Semantics Denotational semantics, also known as fixed-point semantics, associates to each programming language construct a well-defined and rigorously understood mathematical object. These

More information

In Our Last Exciting Episode

In Our Last Exciting Episode In Our Last Exciting Episode #1 Lessons From Model Checking To find bugs, we need specifications What are some good specifications? To convert a program into a model, we need predicates/invariants and

More information

Abstract Interpretation

Abstract Interpretation Abstract Interpretation Ranjit Jhala, UC San Diego April 22, 2013 Fundamental Challenge of Program Analysis How to infer (loop) invariants? Fundamental Challenge of Program Analysis Key issue for any analysis

More information

CSCI-GA Scripting Languages

CSCI-GA Scripting Languages CSCI-GA.3033.003 Scripting Languages 12/02/2013 OCaml 1 Acknowledgement The material on these slides is based on notes provided by Dexter Kozen. 2 About OCaml A functional programming language All computation

More information

Integration of SMT Solvers with ITPs There and Back Again

Integration of SMT Solvers with ITPs There and Back Again Integration of SMT Solvers with ITPs There and Back Again Sascha Böhme and University of Sheffield 7 May 2010 1 2 Features: SMT-LIB vs. Yices Translation Techniques Caveats 3 4 Motivation Motivation System

More information

Software Security: Vulnerability Analysis

Software Security: Vulnerability Analysis Computer Security Course. Software Security: Vulnerability Analysis Program Verification Program Verification How to prove a program free of buffer overflows? Precondition Postcondition Loop invariants

More information

Verifying Centaur s Floating Point Adder

Verifying Centaur s Floating Point Adder Verifying Centaur s Floating Point Adder Sol Swords sswords@cs.utexas.edu April 23, 2008 Sol Swords () Verifying Centaur s Floating Point Adder April 23, 2008 1 / 21 Problem Given: Verilog RTL for the

More information

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming Closures Mooly Sagiv Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming Summary 1. Predictive Parsing 2. Large Step Operational Semantics (Natural) 3. Small Step Operational Semantics

More information

Flow Analysis. Data-flow analysis, Control-flow analysis, Abstract interpretation, AAM

Flow Analysis. Data-flow analysis, Control-flow analysis, Abstract interpretation, AAM Flow Analysis Data-flow analysis, Control-flow analysis, Abstract interpretation, AAM Helpful Reading: Sections 1.1-1.5, 2.1 Data-flow analysis (DFA) A framework for statically proving facts about program

More information

Functional Programming. Pure Functional Programming

Functional Programming. Pure Functional Programming Functional Programming Pure Functional Programming Computation is largely performed by applying functions to values. The value of an expression depends only on the values of its sub-expressions (if any).

More information

Summer 2017 Discussion 10: July 25, Introduction. 2 Primitives and Define

Summer 2017 Discussion 10: July 25, Introduction. 2 Primitives and Define CS 6A Scheme Summer 207 Discussion 0: July 25, 207 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,

More information

axiomatic semantics involving logical rules for deriving relations between preconditions and postconditions.

axiomatic semantics involving logical rules for deriving relations between preconditions and postconditions. CS 6110 S18 Lecture 18 Denotational Semantics 1 What is Denotational Semantics? So far we have looked at operational semantics involving rules for state transitions, definitional semantics involving translations

More information

Lecture 5 - Axiomatic semantics

Lecture 5 - Axiomatic semantics Program Verification March 2014 Lecture 5 - Axiomatic semantics Lecturer: Noam Rinetzky Scribes by: Nir Hemed 1.1 Axiomatic semantics The development of the theory is contributed to Robert Floyd, C.A.R

More information

CS 4110 Programming Languages & Logics

CS 4110 Programming Languages & Logics CS 4110 Programming Languages & Logics Lecture 38 Typed Assembly Language 30 November 2012 Schedule 2 Monday Typed Assembly Language Wednesday Polymorphism Stack Types Today Compilation Course Review Certi

More information

INF 212 ANALYSIS OF PROG. LANGS FUNCTION COMPOSITION. Instructors: Crista Lopes Copyright Instructors.

INF 212 ANALYSIS OF PROG. LANGS FUNCTION COMPOSITION. Instructors: Crista Lopes Copyright Instructors. INF 212 ANALYSIS OF PROG. LANGS FUNCTION COMPOSITION Instructors: Crista Lopes Copyright Instructors. Topics Recursion Higher-order functions Continuation-Passing Style Monads (take 1) Identity Monad Maybe

More information

! Use of formal notations. ! in software system descriptions. ! for a broad range of effects. ! and varying levels of use. !

! Use of formal notations. ! in software system descriptions. ! for a broad range of effects. ! and varying levels of use. ! What Are Formal Methods? David S. Rosenblum ICS 221 Winter 2001! Use of formal notations! first-order logic, state machines, etc.! in software system descriptions! system models, constraints, specifications,

More information

CS558 Programming Languages. Winter 2013 Lecture 3

CS558 Programming Languages. Winter 2013 Lecture 3 CS558 Programming Languages Winter 2013 Lecture 3 1 NAMES AND BINDING One essential part of being a high-level language is having convenient names for things: variables constants types functions etc. classes

More information

R13 SET Discuss how producer-consumer problem and Dining philosopher s problem are solved using concurrency in ADA.

R13 SET Discuss how producer-consumer problem and Dining philosopher s problem are solved using concurrency in ADA. R13 SET - 1 III B. Tech I Semester Regular Examinations, November - 2015 1 a) What constitutes a programming environment? [3M] b) What mixed-mode assignments are allowed in C and Java? [4M] c) What is

More information

Computer Science 21b (Spring Term, 2015) Structure and Interpretation of Computer Programs. Lexical addressing

Computer Science 21b (Spring Term, 2015) Structure and Interpretation of Computer Programs. Lexical addressing Computer Science 21b (Spring Term, 2015) Structure and Interpretation of Computer Programs Lexical addressing The difference between a interpreter and a compiler is really two points on a spectrum of possible

More information

CS4215 Programming Language Implementation. Martin Henz

CS4215 Programming Language Implementation. Martin Henz CS4215 Programming Language Implementation Martin Henz Thursday 26 January, 2012 2 Chapter 4 The Language simpl In this chapter, we are exting the language epl in order to provide a more powerful programming

More information

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS 1 THE FORMALIZATION OF MATHEMATICS by Harvey M. Friedman Ohio State University Department of Mathematics friedman@math.ohio-state.edu www.math.ohio-state.edu/~friedman/ May 21, 1997 Can mathematics be

More information

Testing, Debugging, and Verification

Testing, Debugging, and Verification Testing, Debugging, and Verification Formal Specification, Part II Srinivas Pinisetty 23 November 2017 Introduction Today: Introduction to Dafny: An imperative language with integrated support for formal

More information

Modal Logic: Implications for Design of a Language for Distributed Computation p.1/53

Modal Logic: Implications for Design of a Language for Distributed Computation p.1/53 Modal Logic: Implications for Design of a Language for Distributed Computation Jonathan Moody (with Frank Pfenning) Department of Computer Science Carnegie Mellon University Modal Logic: Implications for

More information

CS 4110 Programming Languages & Logics. Lecture 35 Typed Assembly Language

CS 4110 Programming Languages & Logics. Lecture 35 Typed Assembly Language CS 4110 Programming Languages & Logics Lecture 35 Typed Assembly Language 1 December 2014 Announcements 2 Foster Office Hours today 4-5pm Optional Homework 10 out Final practice problems out this week

More information

HOL DEFINING HIGHER ORDER LOGIC LAST TIME ON HOL CONTENT. Slide 3. Slide 1. Slide 4. Slide 2 WHAT IS HIGHER ORDER LOGIC? 2 LAST TIME ON HOL 1

HOL DEFINING HIGHER ORDER LOGIC LAST TIME ON HOL CONTENT. Slide 3. Slide 1. Slide 4. Slide 2 WHAT IS HIGHER ORDER LOGIC? 2 LAST TIME ON HOL 1 LAST TIME ON HOL Proof rules for propositional and predicate logic Safe and unsafe rules NICTA Advanced Course Forward Proof Slide 1 Theorem Proving Principles, Techniques, Applications Slide 3 The Epsilon

More information

Higher-Order Intensional Type Analysis. Stephanie Weirich Cornell University

Higher-Order Intensional Type Analysis. Stephanie Weirich Cornell University Higher-Order Intensional Type Analysis Stephanie Weirich Cornell University Reflection A style of programming that supports the run-time discovery of program information. What does this code do? How is

More information

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen COP4020 Programming Languages Functional Programming Prof. Robert van Engelen Overview What is functional programming? Historical origins of functional programming Functional programming today Concepts

More information

VS 3 : SMT Solvers for Program Verification

VS 3 : SMT Solvers for Program Verification VS 3 : SMT Solvers for Program Verification Saurabh Srivastava 1,, Sumit Gulwani 2, and Jeffrey S. Foster 1 1 University of Maryland, College Park, {saurabhs,jfoster}@cs.umd.edu 2 Microsoft Research, Redmond,

More information

CSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341)

CSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341) CSE 413 Languages & Implementation Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341) 1 Goals Representing programs as data Racket structs as a better way to represent

More information

Predicate Refinement Heuristics in Program Verification with CEGAR

Predicate Refinement Heuristics in Program Verification with CEGAR Predicate Refinement Heuristics in Program Verification with CEGAR Tachio Terauchi (JAIST) Part of this is joint work with Hiroshi Unno (U. Tsukuba) 1 Predicate Abstraction with CEGAR Iteratively generate

More information

Whereweare. CS-XXX: Graduate Programming Languages. Lecture 7 Lambda Calculus. Adding data structures. Data + Code. What about functions

Whereweare. CS-XXX: Graduate Programming Languages. Lecture 7 Lambda Calculus. Adding data structures. Data + Code. What about functions Whereweare CS-XXX: Graduate Programming Languages Lecture 7 Lambda Calculus Done: Syntax, semantics, and equivalence For a language with little more than loops and global variables Now: Didn t IMP leave

More information

Overview. CS389L: Automated Logical Reasoning. Lecture 6: First Order Logic Syntax and Semantics. Constants in First-Order Logic.

Overview. CS389L: Automated Logical Reasoning. Lecture 6: First Order Logic Syntax and Semantics. Constants in First-Order Logic. Overview CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics Işıl Dillig So far: Automated reasoning in propositional logic. Propositional logic is simple and easy to

More information

Formally Certified Satisfiability Solving

Formally Certified Satisfiability Solving SAT/SMT Proof Checking Verifying SAT Solver Code Future Work Computer Science, The University of Iowa, USA April 23, 2012 Seoul National University SAT/SMT Proof Checking Verifying SAT Solver Code Future

More information

CS152: Programming Languages. Lecture 7 Lambda Calculus. Dan Grossman Spring 2011

CS152: Programming Languages. Lecture 7 Lambda Calculus. Dan Grossman Spring 2011 CS152: Programming Languages Lecture 7 Lambda Calculus Dan Grossman Spring 2011 Where we are Done: Syntax, semantics, and equivalence For a language with little more than loops and global variables Now:

More information

Finite Model Generation for Isabelle/HOL Using a SAT Solver

Finite Model Generation for Isabelle/HOL Using a SAT Solver Finite Model Generation for / Using a SAT Solver Tjark Weber webertj@in.tum.de Technische Universität München Winterhütte, März 2004 Finite Model Generation for / p.1/21 is a generic proof assistant: Highly

More information

Deductive Methods, Bounded Model Checking

Deductive Methods, Bounded Model Checking Deductive Methods, Bounded Model Checking http://d3s.mff.cuni.cz Pavel Parízek CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Deductive methods Pavel Parízek Deductive Methods, Bounded

More information

Program Verification (6EC version only)

Program Verification (6EC version only) Program Verification (6EC version only) Erik Poll Digital Security Radboud University Nijmegen Overview Program Verification using Verification Condition Generators JML a formal specification language

More information

Formal Semantics. Prof. Clarkson Fall Today s music: Down to Earth by Peter Gabriel from the WALL-E soundtrack

Formal Semantics. Prof. Clarkson Fall Today s music: Down to Earth by Peter Gabriel from the WALL-E soundtrack Formal Semantics Prof. Clarkson Fall 2015 Today s music: Down to Earth by Peter Gabriel from the WALL-E soundtrack Review Previously in 3110: simple interpreter for expression language: abstract syntax

More information

Type Theory meets Effects. Greg Morrisett

Type Theory meets Effects. Greg Morrisett Type Theory meets Effects Greg Morrisett A Famous Phrase: Well typed programs won t go wrong. 1. Describe abstract machine: M ::= 2. Give transition relation: M 1 M 2

More information

Reminder of the last lecture. Aliasing Issues: Call by reference, Pointer programs. Introducing Aliasing Issues. Home Work from previous lecture

Reminder of the last lecture. Aliasing Issues: Call by reference, Pointer programs. Introducing Aliasing Issues. Home Work from previous lecture Reminder of the last lecture Aliasing Issues: Call by reference, Pointer programs Claude Marché Cours MPRI 2-36-1 Preuve de Programme 18 janvier 2017 Additional features of the specification language Abstract

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 3 Thomas Wies New York University Review Last week Names and Bindings Lifetimes and Allocation Garbage Collection Scope Outline Control Flow Sequencing

More information

CSCE 314 Programming Languages. Type System

CSCE 314 Programming Languages. Type System CSCE 314 Programming Languages Type System Dr. Hyunyoung Lee 1 Names Names refer to different kinds of entities in programs, such as variables, functions, classes, templates, modules,.... Names can be

More information

Testing, Debugging, Program Verification

Testing, Debugging, Program Verification Testing, Debugging, Program Verification Automated Test Case Generation, Part II Wolfgang Ahrendt & Vladimir Klebanov & Moa Johansson 12 December 2012 TDV: ATCG II /GU 2011-12-12 1 / 17 Recap Specification-/Model-Based

More information

Calculus of Inductive Constructions

Calculus of Inductive Constructions Calculus of Inductive Constructions Software Formal Verification Maria João Frade Departmento de Informática Universidade do Minho 2008/2009 Maria João Frade (DI-UM) Calculus of Inductive Constructions

More information

Comp 311: Sample Midterm Examination

Comp 311: Sample Midterm Examination Comp 311: Sample Midterm Examination October 29, 2007 Name: Id #: Instructions 1. The examination is closed book. If you forget the name for a Scheme operation, make up a name for it and write a brief

More information

Static Program Analysis Part 1 the TIP language

Static Program Analysis Part 1 the TIP language Static Program Analysis Part 1 the TIP language http://cs.au.dk/~amoeller/spa/ Anders Møller & Michael I. Schwartzbach Computer Science, Aarhus University Questions about programs Does the program terminate

More information

Verified Characteristic Formulae for CakeML. Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, Michael Norrish April 27, 2017

Verified Characteristic Formulae for CakeML. Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, Michael Norrish April 27, 2017 Verified Characteristic Formulae for CakeML Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, Michael Norrish April 27, 2017 Goal: write programs in a high-level (ML-style) language, prove them correct interactively,

More information

CMSC 330: Organization of Programming Languages. Operational Semantics

CMSC 330: Organization of Programming Languages. Operational Semantics CMSC 330: Organization of Programming Languages Operational Semantics Notes about Project 4, Parts 1 & 2 Still due today (7/2) Will not be graded until 7/11 (along with Part 3) You are strongly encouraged

More information

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming CMSC 330: Organization of Programming Languages OCaml Imperative Programming CMSC330 Fall 2017 1 So Far, Only Functional Programming We haven t given you any way so far to change something in memory All

More information

Topic 16: Issues in compiling functional and object-oriented languages

Topic 16: Issues in compiling functional and object-oriented languages Topic 16: Issues in compiling functional and object-oriented languages COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer 1 Compiling functional and OO languages General structure

More information

Comp 411 Principles of Programming Languages Lecture 7 Meta-interpreters. Corky Cartwright January 26, 2018

Comp 411 Principles of Programming Languages Lecture 7 Meta-interpreters. Corky Cartwright January 26, 2018 Comp 411 Principles of Programming Languages Lecture 7 Meta-interpreters Corky Cartwright January 26, 2018 Denotational Semantics The primary alternative to syntactic semantics is denotational semantics.

More information

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming CMSC 330: Organization of Programming Languages OCaml Imperative Programming CMSC330 Spring 2018 1 So Far, Only Functional Programming We haven t given you any way so far to change something in memory

More information

Verifying Java Programs Verifying Java Programs with KeY

Verifying Java Programs Verifying Java Programs with KeY Verifying Java Programs Verifying Java Programs with KeY Wolfgang Schreiner Wolfgang.Schreiner@risc.jku.at Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria http://www.risc.jku.at

More information

Lecture Notes on Aggregate Data Structures

Lecture Notes on Aggregate Data Structures Lecture Notes on Aggregate Data Structures 15-312: Foundations of Programming Languages Frank Pfenning Lecture 8 September 23, 2004 In this lecture we discuss various language extensions which make MinML

More information

CS-XXX: Graduate Programming Languages. Lecture 9 Simply Typed Lambda Calculus. Dan Grossman 2012

CS-XXX: Graduate Programming Languages. Lecture 9 Simply Typed Lambda Calculus. Dan Grossman 2012 CS-XXX: Graduate Programming Languages Lecture 9 Simply Typed Lambda Calculus Dan Grossman 2012 Types Major new topic worthy of several lectures: Type systems Continue to use (CBV) Lambda Caluclus as our

More information

Functional Languages. CSE 307 Principles of Programming Languages Stony Brook University

Functional Languages. CSE 307 Principles of Programming Languages Stony Brook University Functional Languages CSE 307 Principles of Programming Languages Stony Brook University http://www.cs.stonybrook.edu/~cse307 1 Historical Origins 2 The imperative and functional models grew out of work

More information

An Annotated Language

An Annotated Language Hoare Logic An Annotated Language State and Semantics Expressions are interpreted as functions from states to the corresponding domain of interpretation Operators have the obvious interpretation Free of

More information

Theorem-prover based Testing with HOL-TestGen

Theorem-prover based Testing with HOL-TestGen Theorem-prover based Testing with HOL-TestGen Burkhart Wolff 1 1 Université Paris-Sud, LRI, Orsay, France wolff@lri.fr M2R: Test des Systemes Informatiques Orsay, 28 Jan 2010 Outline 1 Revision: Apparent

More information

Modular and Verified Automatic Program Repairs

Modular and Verified Automatic Program Repairs Modular and Verified Automatic Program Repairs from Francesco Logozzo and Thomas Ball at Microsoft Research, Redmond presenter name(s) removed for FERPA considerations Introduction Your programs will have

More information

Name, Scope, and Binding. Outline [1]

Name, Scope, and Binding. Outline [1] Name, Scope, and Binding In Text: Chapter 3 Outline [1] Variable Binding Storage bindings and lifetime Type bindings Type Checking Scope Lifetime vs. Scope Referencing Environments N. Meng, S. Arthur 2

More information

Mutable References. Chapter 1

Mutable References. Chapter 1 Chapter 1 Mutable References In the (typed or untyped) λ-calculus, or in pure functional languages, a variable is immutable in that once bound to a value as the result of a substitution, its contents never

More information

Meanings of syntax. Norman Ramsey Geoffrey Mainland. COMP 105 Programming Languages Tufts University. January 26, 2015

Meanings of syntax. Norman Ramsey Geoffrey Mainland. COMP 105 Programming Languages Tufts University. January 26, 2015 Meanings of syntax Norman Ramsey Geoffrey Mainland COMP 105 Programming Languages Tufts University January 26, 2015 (COMP 105) Meanings of syntax January 26, 2015 1 / 33 What is the meaning of a while

More information

Operational Semantics 1 / 13

Operational Semantics 1 / 13 Operational Semantics 1 / 13 Outline What is semantics? Operational Semantics What is semantics? 2 / 13 What is the meaning of a program? Recall: aspects of a language syntax: the structure of its programs

More information

CPSC 311, 2010W1 Midterm Exam #2

CPSC 311, 2010W1 Midterm Exam #2 CPSC 311, 2010W1 Midterm Exam #2 2010/11/02 Page 1 of 18 CPSC 311, 2010W1 Midterm Exam #2 Name: Q1: 20 Student ID: Q2: 20 Signature (required; indicates agreement with rules below): Q3: 20 Q4: 20 Q5: 20

More information

Verification Condition Generation

Verification Condition Generation Verification Condition Generation Jorge Sousa Pinto Departamento de Informática / Universidade do Minho jsp@di.uminho.pt www.di.uminho.pt/~jsp Outline (1) - From Hoare Logic to VCGen algorithms: an architecture

More information

Thursday, December 23, The attack model: Static Program Analysis

Thursday, December 23, The attack model: Static Program Analysis The attack model: Static Program Analysis How making SPA? DFA - Data Flow Analysis CFA - Control Flow Analysis Proving invariance: theorem proving Checking models: model checking Giaco & Ranzato DFA:

More information

Programming Languages: Application and Interpretation

Programming Languages: Application and Interpretation Programming Languages: Application and Interpretation Version 6.7 October 26, 2016 This is the documentation for the software accompanying the textbook Programming Languages: Application and Interpretation

More information

Types for References, Exceptions and Continuations. Review of Subtyping. Γ e:τ τ <:σ Γ e:σ. Annoucements. How s the midterm going?

Types for References, Exceptions and Continuations. Review of Subtyping. Γ e:τ τ <:σ Γ e:σ. Annoucements. How s the midterm going? Types for References, Exceptions and Continuations Annoucements How s the midterm going? Meeting 21, CSCI 5535, Spring 2009 2 One-Slide Summary Review of Subtyping If τ is a subtype of σ then any expression

More information

Operational Semantics of Cool

Operational Semantics of Cool Operational Semantics of Cool Key Concepts semantics: the meaning of a program, what does program do? how the code is executed? operational semantics: high level code generation steps of calculating values

More information

Contents. Program 1. Java s Integral Types in PVS (p.4 of 37)

Contents. Program 1. Java s Integral Types in PVS (p.4 of 37) Java s Integral Types in PVS Bart Jacobs bart@cs.kun.nl www.cs.kun.nl/ bart www.verificard.org. Dep. Computer Science, Univ. Nijmegen, NL Contents I. Example programs II. Integral types in Java (implementations)

More information

Pooya Saadatpanah, Michalis Famelis, Jan Gorzny, Nathan Robinson, Marsha Chechik, Rick Salay. September 30th, University of Toronto.

Pooya Saadatpanah, Michalis Famelis, Jan Gorzny, Nathan Robinson, Marsha Chechik, Rick Salay. September 30th, University of Toronto. Comparing the Pooya Michalis Jan Nathan Marsha Chechik, Rick Salay University of Toronto September 30th, 2012 MoDeVVa 12 1 / 32 in software modeling : pervasive in MDE Models with uncertainty: Represent

More information

Main Goal. Language-independent program verification framework. Derive program properties from operational semantics

Main Goal. Language-independent program verification framework. Derive program properties from operational semantics Main Goal Language-independent program verification framework Derive program properties from operational semantics Questions: Is it possible? Is it practical? Answers: Sound and complete proof system,

More information

Program Static Analysis. Overview

Program Static Analysis. Overview Program Static Analysis Overview Program static analysis Abstract interpretation Data flow analysis Intra-procedural Inter-procedural 2 1 What is static analysis? The analysis to understand computer software

More information

Computing Fundamentals 2 Introduction to CafeOBJ

Computing Fundamentals 2 Introduction to CafeOBJ Computing Fundamentals 2 Introduction to CafeOBJ Lecturer: Patrick Browne Lecture Room: K408 Lab Room: A308 Based on work by: Nakamura Masaki, João Pascoal Faria, Prof. Heinrich Hußmann. See notes on slides

More information

CSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009

CSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009 CSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009 Lecture notes for CS 6110 (Spring 09) taught by Andrew Myers at Cornell; edited by Amal Ahmed, Fall 09. 1 Static vs. dynamic scoping The scope of a variable

More information