Space-Efficient Manifest Contracts. Michael Greenberg Princeton University POPL 2015

Size: px
Start display at page:

Download "Space-Efficient Manifest Contracts. Michael Greenberg Princeton University POPL 2015"

Transcription

1 Space-Efficient Manifest Contracts Michael Greenberg Princeton University POPL 2015

2 (First-order) contracts Specifications Written in code Checked at runtime 2

3 (First-order) contracts Specifications Written in code Checked at runtime assert(n 0) 2

4 (First-order) contracts Specifications Written in code Checked at runtime assert(n 0) sqrt : {x:float x 0} Float 2

5 Higher-order contracts ({x:int x 0} {x:int x 0}) {y:int y 0} You give a function f on Nats, I return a Nat 3 even-odd rule Findler and Felleisen 2002

6 Higher-order contracts ({x:int x 0} {x:int x 0}) {y:int y 0} You give a function f on Nats, I return a Nat 3 even-odd rule Findler and Felleisen 2002

7 Higher-order contracts ({x:int x 0} {x:int x 0}) {y:int y 0} You give a function f on Nats, I return a Nat If you don t get a Nat, oops you blame me 3 even-odd rule Findler and Felleisen 2002

8 Higher-order contracts ({x:int x 0} {x:int x 0}) {y:int y 0} You give a function f on Nats, I return a Nat If you don t get a Nat, oops you blame me If f is called with a negative number, oops you blame me 3 even-odd rule Findler and Felleisen 2002

9 Higher-order contracts ({x:int x 0} {x:int x 0}) {y:int y 0} You give a function f on Nats, I return a Nat If you don t get a Nat, oops you blame me If f is called with a negative number, oops you blame me If f returns a negative, oops I blame you 3 even-odd rule Findler and Felleisen 2002

10 Checking contracts at runtime Nat 7 4

11 Checking contracts at runtime Nat 7 7 4

12 Checking contracts at runtime Nat 7 7 Nat -1 4

13 Checking contracts at runtime Nat 7 7 Nat -1 blame 4

14 Checking contracts at runtime Nat 7 7 Nat -1 blame Pos Pos pred 4

15 Checking contracts at runtime Nat 7 7 Nat -1 blame ( Pos ) Pos pred 1 4

16 Checking contracts at runtime Nat 7 7 Nat -1 blame ( ) Pos pred 1 Pos Pos ( ( 1)) pred Pos 4

17 Checking contracts at runtime Nat 7 7 Nat -1 blame ( ) Pos pred 1 Pos Pos ( ( 1)) pred Pos blame 4

18 Bad space behavior ( ) Nat Nat f v Nat (f( Nat v)) 5

19 Bad space behavior ( ) Nat Nat f v Nat (f( Nat v)) My paper: a solution! 5

20 Function proxies Set... min : {l:α set not (empty) l}α List... head : {l:α list not (null l)}α 6

21 Function proxies Set... min : {l:α set not (empty) l}α List... head : {l:α list not (null l)}α 6

22 Function proxies Set empty = null min = ( not empty α ) head List... head = ( not null α ) fun x. 7

23 Tail calls let odd = let even = (λn:int. if (n==0) then false else even (n-1)) (λn:int. if (n==0) then true else odd (n-1)) 8

24 Tail calls let odd = let even = (λn:int. if (n==0) then false else even (n-1)) (λn:int. if (n==0) then true else odd (n-1)) 8

25 Tail calls let odd = let even = (λn:int. if (n==0) then false else even (n-1)) (λn:int. if (n==0) then true else odd (n-1)) 8

26 What tail calls? let odd = let even = (λn:int. even (n-1)) (λn:int. odd (n-1)) even ( 3) 9

27 What tail calls? let odd = let even = (λn:int. even (n-1)) (λn:int. odd (n-1)) even ( 3) odd ( 2) 9

28 What tail calls? let odd = let even = (λn:int. even (n-1)) (λn:int. odd (n-1)) even ( 3) odd ( 2) even ( 1) 9

29 What tail calls? let odd = let even = (λn:int. even (n-1)) (λn:int. odd (n-1)) even ( 3) odd ( 2) even ( 1) odd ( 0) 9

30 What tail calls? let odd = let even = (λn:int. even (n-1)) (λn:int. odd (n-1)) even ( 3) odd ( 2) even ( 1) odd ( 0) false 9

31 What tail calls? let odd = let even = (λn:int. even (n-1)) (λn:int. odd (n-1)) even ( 3) Contracts break tail calls! odd ( 2) even ( 1) odd ( 0) false 9

32 Bad space behavior Functional Programming - Tail Calls = Bad News Contracts change asymptotic space behavior Big barrier to adoption 10

33 Space-efficient manifest contracts a semantics for manifest contracts checks consume constant space behave just like classic contracts 11

34 Westward the Course of Empire Takes Its Way Emanuel Leutze

35 Contracts Made Manifest Greenberg, Pierce, and Weirich POPL 2010 no Are contracts types? yes Latent Manifest 13

36 Casts <T1 T2> l e I know e has type T1 Treat it as type T2 If I m wrong, blame l 14

37 Casts <T1 T2> l e B ::= Bool... T ::= {x:b e} T1T2 15

38 Casts between refinements <{x:int true} {x:int x 0}> l 7 * 7 16

39 Casts between refinements <{x:int true} {x:int x 0}> l 7 * 7 <{x:int true} {x:int x 0}> l -1 * blame l 16

40 Casts between functions <T1 T2 U1 U2> l f...is a value a/k/a function proxy. 17

41 Casts between functions (<T1 T2 U1 U2> l f) v <T2 U2> l (f (<U1 T1> l v)) 18

42 19

43 (<{x:int true}{x:int true} {x:int x 0}{x:Int x 0}> l λx:{x:int true}. x-1) 0 19

44 (<{x:int true}{x:int true} {x:int x 0}{x:Int x 0}> l λx:{x:int true}. x-1) 0 <{x:int true} {x:int x 0}> l (λx:{x:int true}. x-1 (<{x:int x 0} {x:int true}> l 0)) * 19

45 (<{x:int true}{x:int true} {x:int x 0}{x:Int x 0}> l λx:{x:int true}. x-1) 0 <{x:int true} {x:int x 0}> l (λx:{x:int true}. x-1 (<{x:int x 0} {x:int true}> l 0)) * <{x:int true} {x:int x 0}> l (λx:{x:int true}. x-1 0) * 19

46 (<{x:int true}{x:int true} {x:int x 0}{x:Int x 0}> l λx:{x:int true}. x-1) 0 <{x:int true} {x:int x 0}> l (λx:{x:int true}. x-1 (<{x:int x 0} {x:int true}> l 0)) * <{x:int true} {x:int x 0}> l (λx:{x:int true}. x-1 0) * <{x:int true} {x:int x 0}> l -1 * blame l 19

47 (<{x:int true}{x:int true} {x:int x 0}{x:Int x 0}> l λx:{x:int true}. x-1) 0 <{x:int true} {x:int x 0}> l (λx:{x:int true}. x-1 (<{x:int x 0} {x:int true}> l 0)) * <{x:int true} {x:int x 0}> l (λx:{x:int true}. x-1 0) * <{x:int true} {x:int x 0}> l -1 * blame l 19

48 Pop quiz When we execute <(NatNat)Nat (PosPos)Pos> l will we check Nat or Pos in the domain s domain? 20

49 Insight #1: use coercions <T1 T2> l 21

50 Coercions between predicates <{x:int true} {x:int x 0}> l 7 * 7 <{x:int true} {x:int x 0}> l -1 * blame l 22

51 Coercions between predicates <{x:int true} {x:int x 0}> l 7 * 7 <{x:int true} {x:int x 0}> l -1 * blame l Totally ignored! 22

52 Coercions between predicates <{x:int true} {x:int x 0}> l 7 * 7 <{x:int true} {x:int x 0}> l -1 * blame l Nat 23

53 Coercions between functions (<{x:int true}{x:int true} {x:int x 0}{x:Int x 0}> l f) v <{x:int true} {x:int x 0}> l (f (<{x:int x 0} {x:int true}> l v)) 24

54 Coercions between functions (<{x:int true}{x:int true} {x:int x 0}{x:Int x 0}> l f) v <{x:int true} {x:int x 0}> l (f (<{x:int x 0} {x:int true}> l v)) Nat 24

55 Coercions between functions (<{x:int true}{x:int true} {x:int x 0}{x:Int x 0}> l f) v <{x:int true} {x:int x 0}> l (f (<{x:int x 0} {x:int true}> l v)) Nat Int 24

56 Coercions between functions (<{x:int true}{x:int true} {x:int x 0}{x:Int x 0}> l f) v <{x:int true} {x:int x 0}> l (f (<{x:int x 0} {x:int true}> l v)) Int Nat 25

57 Coercions between functions <T1 T2 U1 U2> l <U1 T1> l <T2 U2> l 26

58 Coercions between functions <T1 T2 U1 U2> l <U1 T1> l <T2 U2> l 26

59 Coercions between functions <T1 T2 U1 U2> l <U1 T1> l <T2 U2> l 26

60 Makeup exam When we execute <(NatNat)Nat (PosPos)Pos> l will we check Nat or Pos in the domain s domain? 27

61 Makeup exam When we execute <(NatNat)Nat (PosPos)Pos> l ( ) Nat Pos Pos will we check Nat or Pos in the domain s domain? 27

62 Bodies in Urban Spaces Willi Dorner / Studio 70

63 Insight #2: avoid redundant checks Nat Even Nat 6 29

64 Insight #2: avoid redundant checks Nat Even Nat 6 Nat Even 6 29

65 Insight #2: avoid redundant checks Nat Even Nat 6 Nat Even 6 Nat 6 29

66 Insight #2: avoid redundant checks Nat Even Nat 6 Nat Even 6 Nat

67 Insight #2: avoid redundant checks Nat Even Nat 6 Nat Even 6 Nat 6 6 Nat Even Nat 7 29

68 Insight #2: avoid redundant checks Nat Even Nat 6 Nat Even 6 Nat 6 6 Nat Even Nat 7 Nat Even 7 29

69 Insight #2: avoid redundant checks Nat Even Nat 6 Nat Even 6 Nat 6 6 Nat Even Nat 7 Nat Even 7 blame 29

70 Insight #2: avoid redundant checks Nat Even Nat 6 Nat Even 6 Nat 6 6 Nat Even Nat 7 Nat Even 7 blame Nat Even Nat -1 29

71 Insight #2: avoid redundant checks Nat Even Nat 6 Nat Even 6 Nat 6 6 Nat Even Nat 7 Nat Even 7 blame Nat Even Nat -1 blame 29

72 Insight #2: avoid redundant checks Never fails! Nat Even Nat 6 Nat Even 6 Nat 6 6 Nat Even Nat 7 Nat Even 7 blame Nat Even Nat -1 blame 29

73 Eliminating redundant checks let odd = let even = (λn:int. even (n-1)) (λn:int. odd (n-1)) even ( 3) 30

74 Eliminating redundant checks let odd = let even = (λn:int. even (n-1)) (λn:int. odd (n-1)) even ( 3) odd ( 2) 30

75 Eliminating redundant checks let odd = let even = (λn:int. even (n-1)) (λn:int. odd (n-1)) even ( 3) odd ( 2) even ( 1) 30

76 Eliminating redundant checks let odd = let even = (λn:int. even (n-1)) (λn:int. odd (n-1)) even ( 3) odd ( 2) even ( 1) odd ( 0) 30

77 Eliminating redundant checks let odd = let even = (λn:int. even (n-1)) (λn:int. odd (n-1)) even ( 3) odd ( 2) Redundant! even ( 1) odd ( 0) 30

78 Eliminating redundant checks let odd = let even = (λn:int. even (n-1)) (λn:int. odd (n-1)) even ( 3) odd ( 2) even ( 1) odd ( 0) 30

79 Eliminating redundant checks let odd = let even = (λn:int. even (n-1)) (λn:int. odd (n-1)) even ( 3) odd ( 2) even ( 1) odd ( 0) false 30

80 Eliminating redundant checks let odd = let even = (λn:int. even (n-1)) (λn:int. odd (n-1)) even ( 3) odd ( 2) even ( 1) Redundant! odd ( 0) false 30

81 Eliminating redundant checks let odd = let even = (λn:int. even (n-1)) (λn:int. odd (n-1)) even ( 3) odd ( 2) even ( 1) odd ( 0) false 30

82 Redundant checks Same color same check Formally: decidable pre-order on refinement types Is this enough? 31

83 How many checks? Finitely many because of simple types!

84 How many checks? Types: Finitely many because of simple types!

85 Bounds Types: Finitely many types Appear once, at most What s the worst that can happen?

86 Bounds Types: Finitely many types Appear once, at most What s the worst that can happen?

87 Bounds Types: Finitely many types Appear once, at most What s the worst that can happen?

88 Bounds Types: Finitely many types Appear once, at most What s the worst that can happen?

89 Bounds Types: Finitely many types Appear once, at most What s the worst that can happen?

90 Eliminating redundant checks How do we merge lists of checks? e Invariant: the checks on the stack have no redundancy. We ll merge the new checks in, dropping redundant checks. 34

91 Eliminating redundant checks How do we merge lists of checks? ( ) e e Invariant: the checks on the stack have no redundancy. We ll merge the new checks in, dropping redundant checks. 34

92 Merging, in detail How do we merge lists of checks? e + =? 35

93 Merging, in detail How do we merge lists of checks? ( ) e e + =? 35

94 Merging, in detail How do we merge lists of checks? ( ) e e + =? new 35

95 Merging, in detail How do we merge lists of checks? ( ) e e + =? new old 35

96 Merging, in detail How do we merge lists of checks? ( ) e e + = 36

97 Merging, in detail How do we merge lists of checks? ( ) e e + = 36

98 Merging, in detail How do we merge lists of checks? ( ) e e + = 36

99 Merging, in detail How do we merge lists of checks? ( ) e e + = 36

100 Merging, in detail How do we merge lists of checks? ( ) e e + = 36

101 Merging, in detail How do we merge lists of checks? ( ) e e + = 36

102 Merging, in detail How do we merge lists of checks? ( ) e e + = 36

103 Merging, in detail How do we merge lists of checks? ( ) e e + = 36

104 Merging, in detail How do we merge lists of checks? Go from new to old Drop redundant checks ( ) e e on the old coercion new old + =

105 Merging function proxies ( ( f ))vv 38

106 Merging function proxies ( ( f ))vv 38

107 Merging function proxies ( ( f ))vv (( f) v) 38

108 Merging function proxies ( ( f ))vv (( f) v) 38

109 Merging function proxies ( ( f ))vv (( f) v) (f ( v) ) 38

110 Merging function proxies new ( ( f ))vv old (( f) v) (f ( v) ) 38

111 Merging function checks Domain: new to old Codomain: old to new new old + = 39

112 Merging function checks Domain: new to old Codomain: old to new new old + = + 39

113 Merging function checks Domain: new to old Codomain: old to new new old + =

114 Merging function checks Domain: new to old Codomain: old to new new old + = 40

115 Merging function checks new Go from right to left old Domain: new to old Codomain: old to new + = Drop redundant checks Contravariance 40

116 Proofs Soundness Congruence lemma Classic semantics and space-efficient semantics behave identically e 1 e 2 + ht 1 )T 2 i l e 1 ht 1 )T 2 i l e 2 E E result E e E 41

117 Congruence lemma e e e e e 42

118 Congruence lemma e1 e1 Our step: check ( ) ( ) e1 e1 e 43

119 Congruence lemma e1 e1 Our step: check ( ) ( ) e1 e1 e1 e1 e 44

120 Outlook Types: + = Use coercions, not casts Merge redundant checks 45

121 Outlook Can we scale to dependency? Types: + = Simple types finite number Dependent types infinite number 46

122 Outlook Can we scale to dependency and effects? keep lowest check + = Idea: partial orders/lattices 5 47 x: x

123 Space-Efficient Manifest Contracts Michael Greenberg Princeton University POPL 2015

1. f(x) = x2 + x 12 x 2 4 Let s run through the steps.

1. f(x) = x2 + x 12 x 2 4 Let s run through the steps. Math 121 (Lesieutre); 4.3; September 6, 2017 The steps for graphing a rational function: 1. Factor the numerator and denominator, and write the function in lowest terms. 2. Set the numerator equal to zero

More information

Lecture Notes on Bidirectional Type Checking

Lecture Notes on Bidirectional Type Checking Lecture Notes on Bidirectional Type Checking 15-312: Foundations of Programming Languages Frank Pfenning Lecture 17 October 21, 2004 At the beginning of this class we were quite careful to guarantee that

More information

Lecture 7. Analysis of algorithms: Amortized Analysis. January Lecture 7

Lecture 7. Analysis of algorithms: Amortized Analysis. January Lecture 7 Analysis of algorithms: Amortized Analysis January 2014 What is amortized analysis? Amortized analysis: set of techniques (Aggregate method, Accounting method, Potential method) for proving upper (worst-case)

More information

About this lecture. Three Methods for the Same Purpose (1) Aggregate Method (2) Accounting Method (3) Potential Method.

About this lecture. Three Methods for the Same Purpose (1) Aggregate Method (2) Accounting Method (3) Potential Method. About this lecture Given a data structure, amortized analysis studies in a sequence of operations, the average time to perform an operation Introduce amortized cost of an operation Three Methods for the

More information

On the Optimality of a Family of Binary Trees Techical Report TR

On the Optimality of a Family of Binary Trees Techical Report TR On the Optimality of a Family of Binary Trees Techical Report TR-011101-1 Dana Vrajitoru and William Knight Indiana University South Bend Department of Computer and Information Sciences Abstract In this

More information

CS473-Algorithms I. Lecture 12. Amortized Analysis. Cevdet Aykanat - Bilkent University Computer Engineering Department

CS473-Algorithms I. Lecture 12. Amortized Analysis. Cevdet Aykanat - Bilkent University Computer Engineering Department CS473-Algorithms I Lecture 12 Amortized Analysis 1 Amortized Analysis Key point: The time required to perform a sequence of data structure operations is averaged over all operations performed Amortized

More information

x-intercepts, asymptotes, and end behavior together

x-intercepts, asymptotes, and end behavior together MA 2231 Lecture 27 - Sketching Rational Function Graphs Wednesday, April 11, 2018 Objectives: Explore middle behavior around x-intercepts, and the general shapes for rational functions. x-intercepts, asymptotes,

More information

Equational reasoning. Equational reasoning. Equational reasoning. EDAN40: Functional Programming On Program Verification

Equational reasoning. Equational reasoning. Equational reasoning. EDAN40: Functional Programming On Program Verification Equational reasoning EDAN40: Functional Programming On Program Jacek Malec Dept. of Computer Science, Lund University, Sweden May18th, 2017 xy = yx x +(y + z) =(x + y)+z x(y + z) =xy + xz (x + y)z = xz

More information

Maximum Contiguous Subsequences

Maximum Contiguous Subsequences Chapter 8 Maximum Contiguous Subsequences In this chapter, we consider a well-know problem and apply the algorithm-design techniques that we have learned thus far to this problem. While applying these

More information

Lecture Notes on Type Checking

Lecture Notes on Type Checking Lecture Notes on Type Checking 15-312: Foundations of Programming Languages Frank Pfenning Lecture 17 October 23, 2003 At the beginning of this class we were quite careful to guarantee that every well-typed

More information

CS792 Notes Henkin Models, Soundness and Completeness

CS792 Notes Henkin Models, Soundness and Completeness CS792 Notes Henkin Models, Soundness and Completeness Arranged by Alexandra Stefan March 24, 2005 These notes are a summary of chapters 4.5.1-4.5.5 from [1]. 1 Review indexed family of sets: A s, where

More information

5 Deduction in First-Order Logic

5 Deduction in First-Order Logic 5 Deduction in First-Order Logic The system FOL C. Let C be a set of constant symbols. FOL C is a system of deduction for the language L # C. Axioms: The following are axioms of FOL C. (1) All tautologies.

More information

CIS 500 Software Foundations Fall October. CIS 500, 6 October 1

CIS 500 Software Foundations Fall October. CIS 500, 6 October 1 CIS 500 Software Foundations Fall 2004 6 October CIS 500, 6 October 1 Midterm 1 is next Wednesday Today s lecture will not be covered by the midterm. Next Monday, review class. Old exams and review questions

More information

A very simple model of a limit order book

A very simple model of a limit order book A very simple model of a limit order book Elena Yudovina Joint with Frank Kelly University of Cambridge Supported by NSF Graduate Research Fellowship YEQT V: 24-26 October 2011 1 Introduction 2 Other work

More information

CMSC 441: Design & Analysis of Algorithms

CMSC 441: Design & Analysis of Algorithms CMSC 441: Design & Analysis of Algorithms Hillol Kargupta http://www.cs.umbc.edu/~hillol/ hillol@cs.umbc.edu Today s Topics Amortized analysis April 19, 2011 CMSC 641 2 Amortized Analysis Aggregate Method

More information

X i = 124 MARTINGALES

X i = 124 MARTINGALES 124 MARTINGALES 5.4. Optimal Sampling Theorem (OST). First I stated it a little vaguely: Theorem 5.12. Suppose that (1) T is a stopping time (2) M n is a martingale wrt the filtration F n (3) certain other

More information

Copyright (C) 2001 David K. Levine This document is an open textbook; you can redistribute it and/or modify it under the terms of version 1 of the

Copyright (C) 2001 David K. Levine This document is an open textbook; you can redistribute it and/or modify it under the terms of version 1 of the Copyright (C) 2001 David K. Levine This document is an open textbook; you can redistribute it and/or modify it under the terms of version 1 of the open text license amendment to version 2 of the GNU General

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 3 Tuesday, February 2, 2016 1 Inductive proofs, continued Last lecture we considered inductively defined sets, and

More information

Unit 6: Amortized Analysis

Unit 6: Amortized Analysis : Amortized Analysis Course contents: Aggregate method Accounting method Potential method Reading: Chapter 17 Y.-W. Chang 1 Amortized Analysis Why Amortized Analysis? Find a tight bound of a sequence of

More information

Economic Development Finance

Economic Development Finance Economic Development Finance Gregory Smith & Company, LLC Northwest Economic Development Course 2014 1 Economic Development Finance Mr. Greg Smith, MBA 2 3 Agenda You can lead a lender to water Does it

More information

Lecture 4: Divide and Conquer

Lecture 4: Divide and Conquer Lecture 4: Divide and Conquer Divide and Conquer Merge sort is an example of a divide-and-conquer algorithm Recall the three steps (at each level to solve a divideand-conquer problem recursively Divide

More information

Lattice-Theoretic Framework for Data-Flow Analysis. Defining Available Expressions Analysis. Reality Check! Reaching Constants

Lattice-Theoretic Framework for Data-Flow Analysis. Defining Available Expressions Analysis. Reality Check! Reaching Constants Lattice-Theoretic Framework for Data-Flow Analysis Defining Available Expressions Analysis Last time Generalizing data-flow analysis Today Finish generalizing data-flow analysis Reaching Constants introduction

More information

Approximate Revenue Maximization with Multiple Items

Approximate Revenue Maximization with Multiple Items Approximate Revenue Maximization with Multiple Items Nir Shabbat - 05305311 December 5, 2012 Introduction The paper I read is called Approximate Revenue Maximization with Multiple Items by Sergiu Hart

More information

A new approach to backtesting and risk model selection

A new approach to backtesting and risk model selection A new approach to backtesting and risk model selection Jacopo Corbetta (École des Ponts - ParisTech) Joint work with: Ilaria Peri (University of Greenwich) June 18, 2016 Jacopo Corbetta Backtesting & Selection

More information

Forex Illusions - 6 Illusions You Need to See Through to Win

Forex Illusions - 6 Illusions You Need to See Through to Win Forex Illusions - 6 Illusions You Need to See Through to Win See the Reality & Forex Trading Success can Be Yours! The myth of Forex trading is one which the public believes and they lose and its a whopping

More information

P(z) =.0.2X2 + 22x - 400

P(z) =.0.2X2 + 22x - 400 Survey ofcalcu1us I (Math 121 Exam 3 November 13, 2002 Part I. Multiple Choice. (2 points each) P(z) =.0.2X2 + 22x - 400 1. Find the marginal profit at a production level of 50 clocks. numerical answer,

More information

Approximating the Transitive Closure of a Boolean Affine Relation

Approximating the Transitive Closure of a Boolean Affine Relation Approximating the Transitive Closure of a Boolean Affine Relation Paul Feautrier ENS de Lyon Paul.Feautrier@ens-lyon.fr January 22, 2012 1 / 18 Characterization Frakas Lemma Comparison to the ACI Method

More information

G5212: Game Theory. Mark Dean. Spring 2017

G5212: Game Theory. Mark Dean. Spring 2017 G5212: Game Theory Mark Dean Spring 2017 Modelling Dynamics Up until now, our games have lacked any sort of dynamic aspect We have assumed that all players make decisions at the same time Or at least no

More information

A semantics for concurrent permission logic. Stephen Brookes CMU

A semantics for concurrent permission logic. Stephen Brookes CMU A semantics for concurrent permission logic Stephen Brookes CMU Cambridge, March 2006 Traditional logic Owicki/Gries 76 Γ {p} c {q} Resource-sensitive partial correctness Γ specifies resources ri, protection

More information

A. For each interval, the probability that the true popula8on propor8on is between the upper and lower limit of the confidence interval is 95%.

A. For each interval, the probability that the true popula8on propor8on is between the upper and lower limit of the confidence interval is 95%. From the quiz: Suppose that simple random samples are repeatedly taken from a popula8on, and for each sample a 95% confidence interval for a propor8on is calculated. Which of the following statements is

More information

TEST 1 SOLUTIONS MATH 1002

TEST 1 SOLUTIONS MATH 1002 October 17, 2014 1 TEST 1 SOLUTIONS MATH 1002 1. Indicate whether each it below exists or does not exist. If the it exists then write what it is. No proofs are required. For example, 1 n exists and is

More information

February 23, An Application in Industrial Organization

February 23, An Application in Industrial Organization An Application in Industrial Organization February 23, 2015 One form of collusive behavior among firms is to restrict output in order to keep the price of the product high. This is a goal of the OPEC oil

More information

Chapter 12 Module 6. AMIS 310 Foundations of Accounting

Chapter 12 Module 6. AMIS 310 Foundations of Accounting Chapter 12, Module 6 Slide 1 CHAPTER 1 MODULE 1 AMIS 310 Foundations of Accounting Professor Marc Smith Hi everyone welcome back! Let s continue our problem from the website, it s example 3 and requirement

More information

Futures markets allow the possibility of forward pricing. Forward pricing or hedging allows decision makers pricing flexibility.

Futures markets allow the possibility of forward pricing. Forward pricing or hedging allows decision makers pricing flexibility. II) Forward Pricing and Risk Transfer Cash market participants are price takers. Futures markets allow the possibility of forward pricing. Forward pricing or hedging allows decision makers pricing flexibility.

More information

Proof Techniques for Operational Semantics

Proof Techniques for Operational Semantics Proof Techniques for Operational Semantics Wei Hu Memorial Lecture I will give a completely optional bonus survey lecture: A Recent History of PL in Context It will discuss what has been hot in various

More information

Microeconomics of Banking: Lecture 5

Microeconomics of Banking: Lecture 5 Microeconomics of Banking: Lecture 5 Prof. Ronaldo CARPIO Oct. 23, 2015 Administrative Stuff Homework 2 is due next week. Due to the change in material covered, I have decided to change the grading system

More information

MATH 10 INTRODUCTORY STATISTICS

MATH 10 INTRODUCTORY STATISTICS MATH 10 INTRODUCTORY STATISTICS Tommy Khoo Your friendly neighbourhood graduate student. Midterm Exam ٩(^ᴗ^)۶ In class, next week, Thursday, 26 April. 1 hour, 45 minutes. 5 questions of varying lengths.

More information

Chapter 8 Statistical Intervals for a Single Sample

Chapter 8 Statistical Intervals for a Single Sample Chapter 8 Statistical Intervals for a Single Sample Part 1: Confidence intervals (CI) for population mean µ Section 8-1: CI for µ when σ 2 known & drawing from normal distribution Section 8-1.2: Sample

More information

Lecture 14: Basic Fixpoint Theorems (cont.)

Lecture 14: Basic Fixpoint Theorems (cont.) Lecture 14: Basic Fixpoint Theorems (cont) Predicate Transformers Monotonicity and Continuity Existence of Fixpoints Computing Fixpoints Fixpoint Characterization of CTL Operators 1 2 E M Clarke and E

More information

Probability Basics. Part 1: What is Probability? INFO-1301, Quantitative Reasoning 1 University of Colorado Boulder. March 1, 2017 Prof.

Probability Basics. Part 1: What is Probability? INFO-1301, Quantitative Reasoning 1 University of Colorado Boulder. March 1, 2017 Prof. Probability Basics Part 1: What is Probability? INFO-1301, Quantitative Reasoning 1 University of Colorado Boulder March 1, 2017 Prof. Michael Paul Variables We can describe events like coin flips as variables

More information

Semantics with Applications 2b. Structural Operational Semantics

Semantics with Applications 2b. Structural Operational Semantics Semantics with Applications 2b. Structural Operational Semantics Hanne Riis Nielson, Flemming Nielson (thanks to Henrik Pilegaard) [SwA] Hanne Riis Nielson, Flemming Nielson Semantics with Applications:

More information

An Adaptive Learning Model in Coordination Games

An Adaptive Learning Model in Coordination Games Department of Economics An Adaptive Learning Model in Coordination Games Department of Economics Discussion Paper 13-14 Naoki Funai An Adaptive Learning Model in Coordination Games Naoki Funai June 17,

More information

Real Estate Private Equity Case Study 3 Opportunistic Pre-Sold Apartment Development: Waterfall Returns Schedule, Part 1: Tier 1 IRRs and Cash Flows

Real Estate Private Equity Case Study 3 Opportunistic Pre-Sold Apartment Development: Waterfall Returns Schedule, Part 1: Tier 1 IRRs and Cash Flows Real Estate Private Equity Case Study 3 Opportunistic Pre-Sold Apartment Development: Waterfall Returns Schedule, Part 1: Tier 1 IRRs and Cash Flows Welcome to the next lesson in this Real Estate Private

More information

Strong normalisation and the typed lambda calculus

Strong normalisation and the typed lambda calculus CHAPTER 9 Strong normalisation and the typed lambda calculus In the previous chapter we looked at some reduction rules for intuitionistic natural deduction proofs and we have seen that by applying these

More information

Lecture 16: Estimating Parameters (Confidence Interval Estimates of the Mean)

Lecture 16: Estimating Parameters (Confidence Interval Estimates of the Mean) Statistics 16_est_parameters.pdf Michael Hallstone, Ph.D. hallston@hawaii.edu Lecture 16: Estimating Parameters (Confidence Interval Estimates of the Mean) Some Common Sense Assumptions for Interval Estimates

More information

Infinitely Repeated Games

Infinitely Repeated Games February 10 Infinitely Repeated Games Recall the following theorem Theorem 72 If a game has a unique Nash equilibrium, then its finite repetition has a unique SPNE. Our intuition, however, is that long-term

More information

Prof. Thistleton MAT 505 Introduction to Probability Lecture 3

Prof. Thistleton MAT 505 Introduction to Probability Lecture 3 Sections from Text and MIT Video Lecture: Sections 2.1 through 2.5 http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-041-probabilistic-systemsanalysis-and-applied-probability-fall-2010/video-lectures/lecture-1-probability-models-and-axioms/

More information

Linear functions Increasing Linear Functions. Decreasing Linear Functions

Linear functions Increasing Linear Functions. Decreasing Linear Functions 3.5 Increasing, Decreasing, Max, and Min So far we have been describing graphs using quantitative information. That s just a fancy way to say that we ve been using numbers. Specifically, we have described

More information

Priority Queues Based on Braun Trees

Priority Queues Based on Braun Trees Priority Queues Based on Braun Trees Tobias Nipkow September 19, 2015 Abstract This theory implements priority queues via Braun trees. Insertion and deletion take logarithmic time and preserve the balanced

More information

Differentially Private, Bounded-Loss Prediction Markets. Bo Waggoner UPenn Microsoft with Rafael Frongillo Colorado

Differentially Private, Bounded-Loss Prediction Markets. Bo Waggoner UPenn Microsoft with Rafael Frongillo Colorado Differentially Private, Bounded-Loss Prediction Markets Bo Waggoner UPenn Microsoft with Rafael Frongillo Colorado WADE, June 2018 1 Outline A. Cost function based prediction markets B. Summary of results

More information

Max Registers, Counters and Monotone Circuits

Max Registers, Counters and Monotone Circuits James Aspnes 1 Hagit Attiya 2 Keren Censor 2 1 Yale 2 Technion Counters Model Collects Our goal: build a cheap counter for an asynchronous shared-memory system. Two operations: increment and read. Read

More information

> asympt( ln( n! ), n ); n 360n n

> asympt( ln( n! ), n ); n 360n n 8.4 Heap Sort (heapsort) We will now look at our first (n ln(n)) algorithm: heap sort. It will use a data structure that we have already seen: a binary heap. 8.4.1 Strategy and Run-time Analysis Given

More information

Swaps and Inversions

Swaps and Inversions Swaps and Inversions I explained in class why every permutation can be obtained as a product [composition] of swaps and that there are multiple ways to do this. In class, I also mentioned, without explaining

More information

Probability without Measure!

Probability without Measure! Probability without Measure! Mark Saroufim University of California San Diego msaroufi@cs.ucsd.edu February 18, 2014 Mark Saroufim (UCSD) It s only a Game! February 18, 2014 1 / 25 Overview 1 History of

More information

Final Exam YOUR NAME:. Your mail folder location (Economics, Booth PhD/MBA mailfolders, elsewhere)

Final Exam YOUR NAME:. Your mail folder location (Economics, Booth PhD/MBA mailfolders, elsewhere) Business 35904 John H. Cochrane Final Exam YOUR NAME:. Your mail folder location (Economics, Booth PhD/MBA mailfolders, elsewhere) INSTRUCTIONS DO NOT TURN OVER THIS PAGE UNTIL YOU ARE TOLD TO DO SO. Please

More information

Proof Techniques for Operational Semantics

Proof Techniques for Operational Semantics #1 Proof Techniques for Operational Semantics #2 Small-Step Contextual Semantics In small-step contextual semantics, derivations are not tree-structured A contextual semantics derivation is a sequence

More information

Law of Large Numbers, Central Limit Theorem

Law of Large Numbers, Central Limit Theorem November 14, 2017 November 15 18 Ribet in Providence on AMS business. No SLC office hour tomorrow. Thursday s class conducted by Teddy Zhu. November 21 Class on hypothesis testing and p-values December

More information

The mathematical definitions are given on screen.

The mathematical definitions are given on screen. Text Lecture 3.3 Coherent measures of risk and back- testing Dear all, welcome back. In this class we will discuss one of the main drawbacks of Value- at- Risk, that is to say the fact that the VaR, as

More information

CS 6110 S11 Lecture 8 Inductive Definitions and Least Fixpoints 11 February 2011

CS 6110 S11 Lecture 8 Inductive Definitions and Least Fixpoints 11 February 2011 CS 6110 S11 Lecture 8 Inductive Definitions and Least Fipoints 11 Februar 2011 1 Set Operators Recall from last time that a rule instance is of the form X 1 X 2... X n, (1) X where X and the X i are members

More information

Amath 546/Econ 589 Univariate GARCH Models: Advanced Topics

Amath 546/Econ 589 Univariate GARCH Models: Advanced Topics Amath 546/Econ 589 Univariate GARCH Models: Advanced Topics Eric Zivot April 29, 2013 Lecture Outline The Leverage Effect Asymmetric GARCH Models Forecasts from Asymmetric GARCH Models GARCH Models with

More information

Game Theory I. Author: Neil Bendle Marketing Metrics Reference: Chapter Neil Bendle and Management by the Numbers, Inc.

Game Theory I. Author: Neil Bendle Marketing Metrics Reference: Chapter Neil Bendle and Management by the Numbers, Inc. Game Theory I This module provides an introduction to game theory for managers and includes the following topics: matrix basics, zero and non-zero sum games, and dominant strategies. Author: Neil Bendle

More information

Opinion formation CS 224W. Cascades, Easley & Kleinberg Ch 19 1

Opinion formation CS 224W. Cascades, Easley & Kleinberg Ch 19 1 Opinion formation CS 224W Cascades, Easley & Kleinberg Ch 19 1 How Do We Model Diffusion? Decision based models (today!): Models of product adoption, decision making A node observes decisions of its neighbors

More information

3/7/13. Binomial Tree. Binomial Tree. Binomial Tree. Binomial Tree. Number of nodes with respect to k? N(B o ) = 1 N(B k ) = 2 N(B k-1 ) = 2 k

3/7/13. Binomial Tree. Binomial Tree. Binomial Tree. Binomial Tree. Number of nodes with respect to k? N(B o ) = 1 N(B k ) = 2 N(B k-1 ) = 2 k //1 Adapted from: Kevin Wayne B k B k B k : a binomial tree with the addition of a left child with another binomial tree Number of nodes with respect to k? N(B o ) = 1 N(B k ) = 2 N( ) = 2 k B 1 B 2 B

More information

Iterated Dominance and Nash Equilibrium

Iterated Dominance and Nash Equilibrium Chapter 11 Iterated Dominance and Nash Equilibrium In the previous chapter we examined simultaneous move games in which each player had a dominant strategy; the Prisoner s Dilemma game was one example.

More information

Week 3 Supplemental: The Odds......Never tell me them. Stat 305 Notes. Week 3 Supplemental Page 1 / 23

Week 3 Supplemental: The Odds......Never tell me them. Stat 305 Notes. Week 3 Supplemental Page 1 / 23 Week 3 Supplemental: The Odds......Never tell me them Stat 305 Notes. Week 3 Supplemental Page 1 / 23 Odds Odds are a lot like probability, but are calculated differently. Probability of event = Times

More information

PERSONAL FINANCE FINAL EXAM REVIEW. Click here to begin

PERSONAL FINANCE FINAL EXAM REVIEW. Click here to begin PERSONAL FINANCE FINAL EXAM REVIEW Click here to begin FINAL EXAM REVIEW Once you work through the questions, you will have a good ideas of what will be on the final next week. Click here if you are too

More information

STA 103: Final Exam. Print clearly on this exam. Only correct solutions that can be read will be given credit.

STA 103: Final Exam. Print clearly on this exam. Only correct solutions that can be read will be given credit. STA 103: Final Exam June 26, 2008 Name: } {{ } by writing my name i swear by the honor code Read all of the following information before starting the exam: Print clearly on this exam. Only correct solutions

More information

EDA045F: Program Analysis LECTURE 3: DATAFLOW ANALYSIS 2. Christoph Reichenbach

EDA045F: Program Analysis LECTURE 3: DATAFLOW ANALYSIS 2. Christoph Reichenbach EDA045F: Program Analysis LECTURE 3: DATAFLOW ANALYSIS 2 Christoph Reichenbach In the last lecture... Eliminating Nested Expressions (Three-Address Code) Control-Flow Graphs Static Single Assignment Form

More information

A Semantic Framework for Program Debugging

A Semantic Framework for Program Debugging A Semantic Framework for Program Debugging State Key Laboratory of Software Development Environment Beihang University July 3, 2013 Outline 1 Introduction 2 The Key Points 3 A Structural Operational Semantics

More information

In this lecture, we will use the semantics of our simple language of arithmetic expressions,

In this lecture, we will use the semantics of our simple language of arithmetic expressions, CS 4110 Programming Languages and Logics Lecture #3: Inductive definitions and proofs In this lecture, we will use the semantics of our simple language of arithmetic expressions, e ::= x n e 1 + e 2 e

More information

Review for Quiz #2 Revised: October 31, 2015

Review for Quiz #2 Revised: October 31, 2015 ECON-UB 233 Dave Backus @ NYU Review for Quiz #2 Revised: October 31, 2015 I ll focus again on the big picture to give you a sense of what we ve done and how it fits together. For each topic/result/concept,

More information

Outline for this Week

Outline for this Week Binomial Heaps Outline for this Week Binomial Heaps (Today) A simple, fexible, and versatile priority queue. Lazy Binomial Heaps (Today) A powerful building block for designing advanced data structures.

More information

Seven Trading Mistakes to Say Goodbye To. By Mark Kelly KNISPO Solutions Inc.

Seven Trading Mistakes to Say Goodbye To. By Mark Kelly KNISPO Solutions Inc. Seven Trading Mistakes to Say Goodbye To By Mark Kelly KNISPO Solutions Inc. www.knispo.com Bob Proctor asks people this question - What do you want, what do you really want? In regards to stock trading,

More information

Copyright 2005 Pearson Education, Inc. Slide 6-1

Copyright 2005 Pearson Education, Inc. Slide 6-1 Copyright 2005 Pearson Education, Inc. Slide 6-1 Chapter 6 Copyright 2005 Pearson Education, Inc. Measures of Center in a Distribution 6-A The mean is what we most commonly call the average value. It is

More information

Bilateral trading with incomplete information and Price convergence in a Small Market: The continuous support case

Bilateral trading with incomplete information and Price convergence in a Small Market: The continuous support case Bilateral trading with incomplete information and Price convergence in a Small Market: The continuous support case Kalyan Chatterjee Kaustav Das November 18, 2017 Abstract Chatterjee and Das (Chatterjee,K.,

More information

Lecture 2. Vladimir Asriyan and John Mondragon. September 14, UC Berkeley

Lecture 2. Vladimir Asriyan and John Mondragon. September 14, UC Berkeley Lecture 2 UC Berkeley September 14, 2011 Theory Writing a model requires making unrealistic simplifications. Two inherent questions (from Krugman): Theory Writing a model requires making unrealistic simplifications.

More information

3 The Model Existence Theorem

3 The Model Existence Theorem 3 The Model Existence Theorem Although we don t have compactness or a useful Completeness Theorem, Henkinstyle arguments can still be used in some contexts to build models. In this section we describe

More information

Self-organized criticality on the stock market

Self-organized criticality on the stock market Prague, January 5th, 2014. Some classical ecomomic theory In classical economic theory, the price of a commodity is determined by demand and supply. Let D(p) (resp. S(p)) be the total demand (resp. supply)

More information

E120: Principles of Engineering Economics Part 1: Concepts. (20 points)

E120: Principles of Engineering Economics Part 1: Concepts. (20 points) E120: Principles of Engineering Economics Final Exam December 14 th, 2004 Instructor: Professor Shmuel Oren Part 1: Concepts. (20 points) 1. Circle the only correct answer. 1.1 Which of the following statements

More information

1 Modelling borrowing constraints in Bewley models

1 Modelling borrowing constraints in Bewley models 1 Modelling borrowing constraints in Bewley models Consider the problem of a household who faces idiosyncratic productivity shocks, supplies labor inelastically and can save/borrow only through a risk-free

More information

1. Graph each of the following Rational Functions, by analyzing the function expression to first determine:

1. Graph each of the following Rational Functions, by analyzing the function expression to first determine: MHF4U_011: Advanced Functions, Grade 1, University Preparation Unit : Advanced Polynomial and Rational Functions Activity 7: Graphing rational functions part Formative Assignment Do NOT submit this to

More information

Introduction to Multi-Agent Programming

Introduction to Multi-Agent Programming Introduction to Multi-Agent Programming 10. Game Theory Strategic Reasoning and Acting Alexander Kleiner and Bernhard Nebel Strategic Game A strategic game G consists of a finite set N (the set of players)

More information

Fibonacci Heaps Y Y o o u u c c an an s s u u b b m miitt P P ro ro b blle e m m S S et et 3 3 iin n t t h h e e b b o o x x u u p p fro fro n n tt..

Fibonacci Heaps Y Y o o u u c c an an s s u u b b m miitt P P ro ro b blle e m m S S et et 3 3 iin n t t h h e e b b o o x x u u p p fro fro n n tt.. Fibonacci Heaps You You can can submit submit Problem Problem Set Set 3 in in the the box box up up front. front. Outline for Today Review from Last Time Quick refresher on binomial heaps and lazy binomial

More information

Large-Scale SVM Optimization: Taking a Machine Learning Perspective

Large-Scale SVM Optimization: Taking a Machine Learning Perspective Large-Scale SVM Optimization: Taking a Machine Learning Perspective Shai Shalev-Shwartz Toyota Technological Institute at Chicago Joint work with Nati Srebro Talk at NEC Labs, Princeton, August, 2008 Shai

More information

Invest now or temporarily hold your cash?

Invest now or temporarily hold your cash? Invest now or temporarily hold your cash? Mike Custer: Hello, and welcome to Vanguard s Investment Commentary Podcast series. I m Mike Custer. In this month s episode, which we re recording on November

More information

Quant Finance Interviews

Quant Finance Interviews Quant Finance Interviews Financial Engineering Interview Prep C O U R S E B Y W W W. Q C F I N A N C E. I N H T T P : / / Q C F I N A N C E. I N / F I N A N C I A L - E N G I N E E R I N G - I N T E R

More information

Forecast Horizons for Production Planning with Stochastic Demand

Forecast Horizons for Production Planning with Stochastic Demand Forecast Horizons for Production Planning with Stochastic Demand Alfredo Garcia and Robert L. Smith Department of Industrial and Operations Engineering Universityof Michigan, Ann Arbor MI 48109 December

More information

2 Deduction in Sentential Logic

2 Deduction in Sentential Logic 2 Deduction in Sentential Logic Though we have not yet introduced any formal notion of deductions (i.e., of derivations or proofs), we can easily give a formal method for showing that formulas are tautologies:

More information

FMCAD 2011 Effective Word-Level Interpolation for Software Verification

FMCAD 2011 Effective Word-Level Interpolation for Software Verification FMCAD 2011 Effective Word-Level Interpolation for Software Verification Alberto Griggio FBK-IRST Motivations Craig interpolation applied succesfully for Formal Verification of both hardware and software

More information

Retractable and Speculative Contracts

Retractable and Speculative Contracts Retractable and Speculative Contracts Ivan Lanese Computer Science Department University of Bologna/INRIA Italy Joint work with Franco Barbanera and Ugo de'liguoro Map of the talk What retractable/speculative

More information

Expected Utility Theory

Expected Utility Theory Expected Utility Theory Mark Dean Behavioral Economics Spring 27 Introduction Up until now, we have thought of subjects choosing between objects Used cars Hamburgers Monetary amounts However, often the

More information

Markov Decision Processes

Markov Decision Processes Markov Decision Processes Ryan P. Adams COS 324 Elements of Machine Learning Princeton University We now turn to a new aspect of machine learning, in which agents take actions and become active in their

More information

Other Regarding Preferences

Other Regarding Preferences Other Regarding Preferences Mark Dean Lecture Notes for Spring 015 Behavioral Economics - Brown University 1 Lecture 1 We are now going to introduce two models of other regarding preferences, and think

More information

Section B: Risk Measures. Value-at-Risk, Jorion

Section B: Risk Measures. Value-at-Risk, Jorion Section B: Risk Measures Value-at-Risk, Jorion One thing to always keep in mind when reading this text is that it is focused on the banking industry. It mainly focuses on market and credit risk. It also

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/ws-1718/sv-sw/ Recap: CCPOs and Continuous Functions

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 3 Tuesday, January 30, 2018 1 Inductive sets Induction is an important concept in the theory of programming language.

More information

SAMURAI SCROOGE: IMPORTANT CONCEPTS

SAMURAI SCROOGE: IMPORTANT CONCEPTS SAMURAI SCROOGE: IMPORTANT CONCEPTS CONTENTS 1. Trend vs. swing trading 2. Mechanical vs. discretionary trading 3. News 4. Drawdowns 5. Money management 6. Letting the system do the work 7. Trade journal

More information

The Assumption(s) of Normality

The Assumption(s) of Normality The Assumption(s) of Normality Copyright 2000, 2011, 2016, J. Toby Mordkoff This is very complicated, so I ll provide two versions. At a minimum, you should know the short one. It would be great if you

More information

COMP251: Amortized Analysis

COMP251: Amortized Analysis COMP251: Amortized Analysis Jérôme Waldispühl School of Computer Science McGill University Based on (Cormen et al., 2009) T n = 2 % T n 5 + n( What is the height of the recursion tree? log ( n log, n log

More information

CSCI 104 B-Trees (2-3, 2-3-4) and Red/Black Trees. Mark Redekopp David Kempe

CSCI 104 B-Trees (2-3, 2-3-4) and Red/Black Trees. Mark Redekopp David Kempe 1 CSCI 104 B-Trees (2-3, 2-3-4) and Red/Black Trees Mark Redekopp David Kempe 2 An example of B-Trees 2-3 TREES 3 Definition 2-3 Tree is a tree where Non-leaf nodes have 1 value & 2 children or 2 values

More information