HW 1 Reminder. Principles of Programming Languages. Lets try another proof. Induction. Induction on Derivations. CSE 230: Winter 2007

Size: px
Start display at page:

Download "HW 1 Reminder. Principles of Programming Languages. Lets try another proof. Induction. Induction on Derivations. CSE 230: Winter 2007"

Transcription

1 CSE 230: Winter 2007 Principles of Programming Languages Lecture 4: Induction, Small-Step Semantics HW 1 Reminder Due next Tue Instructions about turning in code to follow Send me mail if you have issues Ranjit Jhala UC San Diego Induction Most important technique for formal semantics, type systems in PL Several flavors mathematical induction (simplest) well-founded induction (most general) structural induction (most widely used in PL) On structure of expressions On structure of derivations (proofs) Lets try another proof Prove that IMP is deterministic (unique evaluations) 1. e Aexp. σ Σ. n, n N. <e, σ> n < e, σ > n n = n 2. b Bexp. σ Σ. t, t B. < b, σ > t < b, σ > t t = t 3. c Comm. σ, σ,σ Σ. < c, σ > σ < c, σ > σ σ = σ Q: Can we directly use induction? On what? For commands, cannot use induction on structure of cmd while eval does not depend only on eval of strict subexp <b, σ> true <c;while b do c, σ> σ <while b do c, σ > σ Induction on structure of Derivations Key idea: The (ind) hypothesis gives not only a c Comm but also the existence of a derivation of < c, σ > σ Derivation trees also defined inductively, like expression trees. A derivation is built of subderivations: <x, σ i+1 > 5 - i 5 i 5 < x+1, σ i+1 > 6 - i < x:=x+1, σ i+1 > σ i <W, σ i > σ 0 < x 5, σ i+1 > true < x:=x+1;w, σ i+1 > σ 0 <while x 5 do x:=x+1, σ i+1 > σ 0 We adapt structural induction principle to structure of derivations Induction on Derivations To prove that for all derivations D of a judgment, property P(D) holds: H 1 H n For each derivation rule of the form C Assume property P holds for derivation of H i (i =1,,n) : Prove property P holds for derivation obtained from derivations of H i using given rule 1

2 Example: Induction on Derivations (I) Prove evaluation of commands is deterministic: <c,σ > σ and <c, σ > σ σ = σ Pick arbitrary c, σ, σ and D :: <c, σ> σ To prove: <c, σ > σ σ = σ Proof by induction on the structure of the derivation D Case: the last rule used in D was the one for skip : D :: So, c = skip, and σ =σ <skip, σ > σ Thus, <c,σ> σ uses rule for skip, so σ =σ This is a Base case in the induction Example: Induction on Derivations (II) Case: last rule used in D was for sequencing D :: D 1 :: <c 1,σ > σ 1 D 2 :: <c 2, σ 1 > σ < c 1 ;c 2,σ > σ Pick arbitrary σ σ st s.t. D :: <c 1 ;c 2,σ σ > σ σ By inversion, D uses rule for sequencing w/ subderiv D 1 ::<c 1,σ> σ 1 and D 2 ::<c 2,σ 1 > σ By ind hyp on D 1 (with D 1 ): σ 1 = σ 1 Now D 2 :: <c 2, σ 1 > σ By induction hypothesis on D 2 (with D 2 ): σ = σ This is a simple inductive case Example: Induction on Derivations (III) Case: last rule used in D was for while true D 1 ::<b,σ> true D 2 ::<c; while b do c, σ> σ D :: <while b do c, σ> σ Pick arbitrary σ s.t. D ::<while b do c, σ> σ By inversion, determinism of bool expressions, D also uses the rule while-true with sub-derivations: D 1 ::<b,σ> true D 2 ::< c;while b do c, σ > σ By ind hypothesis on sub-derivation D 2 (with D 2 ): σ = σ Induction on Derivation: Notes To prove x A. P(x) with A inductively-defined, P(x) rule-defined Pick arbitrary x A and D :: P(x) can do induction on both facts x A induction on structure of x D :: P(x) induction on structure of derivation D Induction on derivation often more powerful Induction Haiku(?) Applying Big-Step Semantics: Equivalence Many choices for induction, Find right one by trial-and-error, and Practice helps. 2

3 Equivalence Two expressions are equivalent if they yield the same value from all states e 1 e 1 iff σ Σ. n Z. <e 1,σ> n iff <e 2,σ> n Equivalence Two commands are equivalent if they yield the same state from all states c 1 c 2 iff σ, σ Σ. <c 1,σ> σ iff<c 2,σ> σ Notes on Equivalence Equivalence is like validity Must hold in all states is a valid statement ( 2=1+1 is valid) 2 1+x? NO!Depends on state s value of x, Not true in all states Equivalence (for IMP) is undecidable Otherwise, could solve the halting problem How? Notes on Equivalence Equivalence justifies code transformations: compiler optimizations code instrumentation Semantics is basis for proving equivalence Find sufficient conditions for equivalence Translation Validation (for gcc!) skip;c c x:= e 1 ; x:=e 2 x:=e 2 Q: Does this hold for Java program? 3

4 while b do c if b then (c; while b do c) else skip If e 1 e 2 then x:=e 1 x:=e 2 Conditional Equivalence while true do skip while true do x:=x+1 If c is while (x=y) do if x y then x:=x-y else y:=y-x then (x:=221;y:=527;c) (x:=17;y:=17) Proving an Equivalence Prove: skip;c c for all c Assume that D :: < skip;c, σ> σ By inversion (twice) we have that: <skip, σ> σ D 1 :: <c, σ> σ D :: <skip;c, σ> σ Thus, we have D 1 :: <c, σ> σ The other direction is similar. Proving an Inequivalence Prove that x:=y x:=z Suffices to show a witness store σ in which the two commands yield different results Let σ(y)=0 and σ(z)=1. Then < x:=y, σ > σ[x a 0] and < x:=z, σ > σ[x a 1] 4

5 Big-Step Operational Semantics Big-Step Operational Semantics: <e,σ> n Means e evaluates to n in state σ In one, big step, all the way to a result Cannot describe non-terminating commands There is no σ such that < c, σ> σ Have no explanation of how c runs or fails! Cannot describe intermediate states E.g. interleaved execution (on parallel machine) E.g. low-level execution Operational Semantics: Big vs. Small Small-Step Operational Semantics: e e describe a single step in the evaluation many stepsmay be needed for result Relation defined by rules n is the sum of n 1 and n 2 n is the product of n 1 and n 2 n 1 +n 2 n n 1 *n 2 n e 1 e 1 e 1 +e 2 e 1 +e 2 e 2 e 2 n 1 +e 2 n 1 +e 2 Fixed evaluation order: E.g. (3+4) e 1 e 1 e 1 *e 2 e 1 *e 2 e 2 e 2 n 1 *e 2 n 1 *e 2 Contextual Semantics Small-step semantics, specified in two parts What evaluation rules to apply? What is an atomic reduction step? Wherecan we apply them? Where to apply next atomic reduction step? Small-Step Op. Semantics for IMP Execution step is a rewrite of the program We define a relation: <c, σ> <c, σ > c obtained from c through an atomic rewrite step e.g.: <x:=2+8, σ > <x:=10, σ> <skip, σ[xa10]> Termination: command rewritten to a terminal command from which we cannot make further progress For IMP the terminal command is skip For every other command we can make progress Some commands never reduce to skip i.e. do not terminate! while true do skip What is an Atomic Reduction? Need to define: What is an atomic reduction step? Granularity is choice of semantics designer e.g., choice between an addition of arbitrary integers, or an addition of 32-bit integers How to select the next reduction step? when several are possible? determines order of evaluation issue 5

6 Redexes Expressions, commands reducible in atomic step For brevity, we combine expr and command redexes Defined by a grammar: r ::= x n 1 + n 2 x := n skip; c if true then c 1 else c 2 if false then c 1 else c 2 while b do c Note: (1+3)+2 is not a redex, but 1+3 is Local Reduction Rules for IMP One per redex: <r, σ> <e, σ > Redex r in state σ can be replaced, in one step, with expression e, in state σ <x, σ> <σ(x), σ> <n 1 +n 2, σ> <n, σ> if n =n 1 + n 2 <n 1 =n 2, σ> <true, σ > if n 1 = n 2 <x:=n, σ> <skip, σ[x a n]> <skip;c, σ> <c, σ> <if true then c 1 else c 2, σ> <c 1, σ> <if false then c 1 else c 2, σ> <c 2, σ> <while b do c, σ> <if b then (c;while b do c) else skip, σ> Quick recap A redex can be reduced in one step E.g. 2+8 Local reduction rules reduce redexes E.g. < 2+8,σ> <10,σ> Next: global reduction rules Consider: <while false do x:=1+(2+8), σ> Should we reduce (2+8) in this case? Contexts Context = expr or command with one marker Sometimes called a hole Given a context H, H[e] obtained by replacing marker with e H is x := 1 + H[2+8] is x:=1+(2+8) H[10] is x:=1+10 H is while false do x := 1 + H[2+8] is while false do x :=1+(2+8) Evaluation Contexts Context in which hole indicates next place for evaluation. identifies next redex, (like program counter) H ::= H + e n + H x := H if H then c 1 else c 2 H; c Eval contexts determine redex Consider e 1 +e 2 and its decomposition as H[r] If e 1 is n 1 and e 2 is n 2 then H = and r = n 1 +n 2 If e 1 is n 1 and e 2 is not n 2 then H = n 1 + H 2 where e 2 = H 2 [r] i.e. recursively find hole in e 2 If e 1 is not n 1 and e 2 is not n 2 then H = H 1 + e 2 where e 1 = H 1 [r] i.e. recursively find hole in e 1 In each case the decomposition is unique 6

7 Global Reduction Rule Key idea of contextual semantics: Decompose current expression/command into: r : next redex H : evaluation context (i.e. the remaining program) Reduce redex r to expression e Plug e back into original context, yielding H[e] Formalized as a small step rule: If <r, σ> <e,σ > then <H[r],σ> <H[e],σ > Global Reduction Rule: Example Consider command x := 1+(2+8) Split into an evaluation context H and a redex r Get H = x := 1+ r = 2+8 H[r] = x := 1+(2+8) (original command) Have <2+8, σ> <10, σ> (local reduction rule) Define global reduction <H[2+8], σ > <H[10], σ > or, equivalently < x := 1+(2+8), σ > < x := 1+10, σ> Contextual Semantics: Example Consider the small-step evaluation of x := 1; x := x + 1 in the initial state [x a 0] State Context Redex <x:=1;x:=x+1, [xa 0]> ;x:=x+1 x := 1 <skip;x:=x+1, [xa 1]> skip;x:= x+1 <x := x + 1, [xa 1]> x:= +1 x <x := 1 + 1, [xa 1]> x:= <x := 2, [xa 1]> x := 2 <skip, [xa 2]> Unique Decomposition Theorem If c is not skip then there exist unique H and r such that c = H[r] Determinism and Progress For example: c = c 1 ;c 2 either c 1 = skip and then c = H[skip;c 2 ] with H = or c 1 skip and then c 1 = H 1 [r] so c = c 1 ;c 2 = H 1 [r];c 2 = H[r] where H = H 1 ;c 2 For example: c = if b then c 1 else c 2 either b = true or b = false and then c = H[r] with H = or b is not a value and b = H [r]; so c = if b then c 1 else c 2 = if H [r] then c 1 else c 2 = H[r] where H = if H then c 1 else c 2 Normal vs Short-Circuit Boolean Operators Normalevaluation of Define the contexts, redexes, and local rules: H ::=... H Æ b 2 p 1 Æ H r ::=... p 1 Æ p 2 < p 1 Æp 2, σ> <p,σ> where p 1 = p 1 Æ p 2 Short-circuit evaluation of Define the contexts, redexes, and local rules: H ::=... H Æ b 2 r ::=... p 1 Æ p 2 <true Æ b 2, σ> <b 2,σ> <false Æ b 2, σ> <false,σ> Contextual Semantics: Notes Think of as representing the program counter Advancement rules for are tricky At each step, entire command is decomposed So contextual semantics inefficient to implement Allows mix of local, global reduction rules IMP has only local reduction rules: redex is reduced 7

8 Some Further Topics Treating errors in operational semantics with an explicit error result, as in (3/0) error, with an error expression, as in (3 + error), with stuck computations, there is no r such that (3/0) r Treatment of overflow (see homework) Summary of Operational Semantics Precise specification of program behavior: order of evaluation (or that it doesn t matter) error conditions (sometimes implicitly, by rule applicability) Simple and abstract no low-level details e.g. stack, memory management, data layout Often not compositional (as for while) Basis for proofs about languages (deterministic) reasoning about particular programs (equivalence) Point of reference for other semantics 8

Programming Languages

Programming Languages CSE 230: Winter 2010 Principles of Programming Languages Lecture 3: Induction, Equivalence Ranjit Jhala UC San Diego Operational Semantics of IMP Evaluation judgement for commands Ternary relation on expression,

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

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

Proof Techniques for Operational Semantics. Questions? Why Bother? Mathematical Induction Well-Founded Induction Structural Induction

Proof Techniques for Operational Semantics. Questions? Why Bother? Mathematical Induction Well-Founded Induction Structural Induction Proof Techniques for Operational Semantics Announcements Homework 1 feedback/grades posted Homework 2 due tonight at 11:55pm Meeting 10, CSCI 5535, Spring 2010 2 Plan Questions? Why Bother? Mathematical

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 2 Thursday, January 30, 2014 1 Expressing Program Properties Now that we have defined our small-step operational

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

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

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

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

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

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

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

CS 4110 Programming Languages and Logics Lecture #2: Introduction to Semantics. 1 Arithmetic Expressions

CS 4110 Programming Languages and Logics Lecture #2: Introduction to Semantics. 1 Arithmetic Expressions CS 4110 Programming Languages and Logics Lecture #2: Introduction to Semantics What is the meaning of a program? When we write a program, we represent it using sequences of characters. But these strings

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

From Concurrent Programs to Simulating Sequential Programs: Correctness of a Transformation

From Concurrent Programs to Simulating Sequential Programs: Correctness of a Transformation From Concurrent s to Simulating Sequential s: Correctness of a Transformation VPT 2017 Allan Blanchard, Frédéric Loulergue, Nikolai Kosmatov April 29 th, 2017 Table of Contents 1 From Concurrent s to Simulating

More information

Structural Induction

Structural Induction Structural Induction Jason Filippou CMSC250 @ UMCP 07-05-2016 Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 1 / 26 Outline 1 Recursively defined structures 2 Proofs Binary Trees Jason

More information

Operational Semantics

Operational Semantics University of Science and Technology of China (USTC) 07/19/2011 Transition Semantics Program configurations: γ Γ def = Commands Σ Transitions between configurations: Γ ˆΓ where ˆΓ def = Γ {abort} Σ The

More information

CS 4110 Programming Languages & Logics. Lecture 2 Introduction to Semantics

CS 4110 Programming Languages & Logics. Lecture 2 Introduction to Semantics CS 4110 Programming Languages & Logics Lecture 2 Introduction to Semantics 29 August 2012 Announcements 2 Wednesday Lecture Moved to Thurston 203 Foster Office Hours Today 11a-12pm in Gates 432 Mota Office

More information

Grainless Semantics without Critical Regions

Grainless Semantics without Critical Regions Grainless Semantics without Critical Regions John C. Reynolds Department of Computer Science Carnegie Mellon University April 11, 2007 (corrected April 27, 2007) (Work in progress, jointly with Ruy Ley-Wild)

More information

Operational Semantics

Operational Semantics University of Science and Technology of China (USTC) 10/24/2011 Transition Semantics Program configurations: γ Γ def = Commands Σ Transitions between configurations: Γ ˆΓ where ˆΓ def = Γ {abort} Σ The

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

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

The Traveling Salesman Problem. Time Complexity under Nondeterminism. A Nondeterministic Algorithm for tsp (d)

The Traveling Salesman Problem. Time Complexity under Nondeterminism. A Nondeterministic Algorithm for tsp (d) The Traveling Salesman Problem We are given n cities 1, 2,..., n and integer distances d ij between any two cities i and j. Assume d ij = d ji for convenience. The traveling salesman problem (tsp) asks

More information

A Formally Verified Interpreter for a Shell-like Programming Language

A Formally Verified Interpreter for a Shell-like Programming Language A Formally Verified Interpreter for a Shell-like Programming Language Claude Marché Nicolas Jeannerod Ralf Treinen VSTTE, July 22, 2017 Nicolas Jeannerod VSTTE 17 July 22, 2017 1 / 36 General goal The

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

CSE 21 Winter 2016 Homework 6 Due: Wednesday, May 11, 2016 at 11:59pm. Instructions

CSE 21 Winter 2016 Homework 6 Due: Wednesday, May 11, 2016 at 11:59pm. Instructions CSE 1 Winter 016 Homework 6 Due: Wednesday, May 11, 016 at 11:59pm Instructions Homework should be done in groups of one to three people. You are free to change group members at any time throughout the

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

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

IEOR E4004: Introduction to OR: Deterministic Models

IEOR E4004: Introduction to OR: Deterministic Models IEOR E4004: Introduction to OR: Deterministic Models 1 Dynamic Programming Following is a summary of the problems we discussed in class. (We do not include the discussion on the container problem or the

More information

Decidability and Recursive Languages

Decidability and Recursive Languages Decidability and Recursive Languages Let L (Σ { }) be a language, i.e., a set of strings of symbols with a finite length. For example, {0, 01, 10, 210, 1010,...}. Let M be a TM such that for any string

More information

Abstract stack machines for LL and LR parsing

Abstract stack machines for LL and LR parsing Abstract stack machines for LL and LR parsing Hayo Thielecke August 13, 2015 Contents Introduction Background and preliminaries Parsing machines LL machine LL(1) machine LR machine Parsing and (non-)deterministic

More information

Sublinear Time Algorithms Oct 19, Lecture 1

Sublinear Time Algorithms Oct 19, Lecture 1 0368.416701 Sublinear Time Algorithms Oct 19, 2009 Lecturer: Ronitt Rubinfeld Lecture 1 Scribe: Daniel Shahaf 1 Sublinear-time algorithms: motivation Twenty years ago, there was practically no investigation

More information

Lecture 2: The Simple Story of 2-SAT

Lecture 2: The Simple Story of 2-SAT 0510-7410: Topics in Algorithms - Random Satisfiability March 04, 2014 Lecture 2: The Simple Story of 2-SAT Lecturer: Benny Applebaum Scribe(s): Mor Baruch 1 Lecture Outline In this talk we will show that

More information

Calculational Design of Information Flow Monitors

Calculational Design of Information Flow Monitors Calculational Design of Information Flow Monitors Mounir Assaf David Naumann Stevens Institute of Technology, Hoboken, NJ November 9th, 2016 SoSySec Seminar, Rennes Mounir Assaf Calculational Design of

More information

Discrete Mathematics for CS Spring 2008 David Wagner Final Exam

Discrete Mathematics for CS Spring 2008 David Wagner Final Exam CS 70 Discrete Mathematics for CS Spring 2008 David Wagner Final Exam PRINT your name:, (last) SIGN your name: (first) PRINT your Unix account login: Your section time (e.g., Tue 3pm): Name of the person

More information

Yao s Minimax Principle

Yao s Minimax Principle Complexity of algorithms The complexity of an algorithm is usually measured with respect to the size of the input, where size may for example refer to the length of a binary word describing the input,

More information

Formal Techniques for Software Engineering: More on Denotational Semantics

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

More information

MAS115: R programming Lecture 3: Some more pseudo-code and Monte Carlo estimation Lab Class: for and if statements, input

MAS115: R programming Lecture 3: Some more pseudo-code and Monte Carlo estimation Lab Class: for and if statements, input MAS115: R programming Lecture 3: Some more pseudo-code and Monte Carlo estimation Lab Class: for and if statements, input The University of Sheffield School of Mathematics and Statistics Aims Introduce

More information

Recitation 1. Solving Recurrences. 1.1 Announcements. Welcome to 15210!

Recitation 1. Solving Recurrences. 1.1 Announcements. Welcome to 15210! Recitation 1 Solving Recurrences 1.1 Announcements Welcome to 1510! The course website is http://www.cs.cmu.edu/ 1510/. It contains the syllabus, schedule, library documentation, staff contact information,

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

Computational Independence

Computational Independence Computational Independence Björn Fay mail@bfay.de December 20, 2014 Abstract We will introduce different notions of independence, especially computational independence (or more precise independence by

More information

Conditional Rewriting

Conditional Rewriting Conditional Rewriting Bernhard Gramlich ISR 2009, Brasilia, Brazil, June 22-26, 2009 Bernhard Gramlich Conditional Rewriting ISR 2009, July 22-26, 2009 1 Outline Introduction Basics in Conditional Rewriting

More information

15-451/651: Design & Analysis of Algorithms November 9 & 11, 2015 Lecture #19 & #20 last changed: November 10, 2015

15-451/651: Design & Analysis of Algorithms November 9 & 11, 2015 Lecture #19 & #20 last changed: November 10, 2015 15-451/651: Design & Analysis of Algorithms November 9 & 11, 2015 Lecture #19 & #20 last changed: November 10, 2015 Last time we looked at algorithms for finding approximately-optimal solutions for NP-hard

More information

7-4. Compound Interest. Vocabulary. Interest Compounded Annually. Lesson. Mental Math

7-4. Compound Interest. Vocabulary. Interest Compounded Annually. Lesson. Mental Math Lesson 7-4 Compound Interest BIG IDEA If money grows at a constant interest rate r in a single time period, then after n time periods the value of the original investment has been multiplied by (1 + r)

More information

Comparing Goal-Oriented and Procedural Service Orchestration

Comparing Goal-Oriented and Procedural Service Orchestration Comparing Goal-Oriented and Procedural Service Orchestration M. Birna van Riemsdijk 1 Martin Wirsing 2 1 Technische Universiteit Delft, The Netherlands m.b.vanriemsdijk@tudelft.nl 2 Ludwig-Maximilians-Universität

More information

A CATEGORICAL FOUNDATION FOR STRUCTURED REVERSIBLE FLOWCHART LANGUAGES: SOUNDNESS AND ADEQUACY

A CATEGORICAL FOUNDATION FOR STRUCTURED REVERSIBLE FLOWCHART LANGUAGES: SOUNDNESS AND ADEQUACY Logical Methods in Computer Science Vol. 14(3:16)2018, pp. 1 38 https://lmcs.episciences.org/ Submitted Oct. 12, 2017 Published Sep. 05, 2018 A CATEGORICAL FOUNDATION FOR STRUCTURED REVERSIBLE FLOWCHART

More information

Online Algorithms SS 2013

Online Algorithms SS 2013 Faculty of Computer Science, Electrical Engineering and Mathematics Algorithms and Complexity research group Jun.-Prof. Dr. Alexander Skopalik Online Algorithms SS 2013 Summary of the lecture by Vanessa

More information

Semantic Array Dataflow Analysis

Semantic Array Dataflow Analysis Semantic Array Dataflow Analysis Paul Iannetta UCBL 1, CNRS, ENS de Lyon, Inria, LIP, F-69342, LYON Cedex 07, France Laure Gonnord UCBL 1, CNRS, ENS de Lyon, Inria, LIP, F-69342, LYON Cedex 07, France

More information

Developmental Math An Open Program Unit 12 Factoring First Edition

Developmental Math An Open Program Unit 12 Factoring First Edition Developmental Math An Open Program Unit 12 Factoring First Edition Lesson 1 Introduction to Factoring TOPICS 12.1.1 Greatest Common Factor 1 Find the greatest common factor (GCF) of monomials. 2 Factor

More information

Tableau Theorem Prover for Intuitionistic Propositional Logic

Tableau Theorem Prover for Intuitionistic Propositional Logic Tableau Theorem Prover for Intuitionistic Propositional Logic Portland State University CS 510 - Mathematical Logic and Programming Languages Motivation Tableau for Classical Logic If A is contradictory

More information

CTL Model Checking. Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula. Approach Model checking!

CTL Model Checking. Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula. Approach Model checking! CMSC 630 March 13, 2007 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula. Approach Model checking! Mathematically, M is a model of σ if s I = M

More information

Tableau Theorem Prover for Intuitionistic Propositional Logic

Tableau Theorem Prover for Intuitionistic Propositional Logic Tableau Theorem Prover for Intuitionistic Propositional Logic Portland State University CS 510 - Mathematical Logic and Programming Languages Motivation Tableau for Classical Logic If A is contradictory

More information

Expected Value and Variance

Expected Value and Variance Expected Value and Variance MATH 472 Financial Mathematics J Robert Buchanan 2018 Objectives In this lesson we will learn: the definition of expected value, how to calculate the expected value of a random

More information

MSU CSE Spring 2011 Exam 2-ANSWERS

MSU CSE Spring 2011 Exam 2-ANSWERS MSU CSE 260-001 Spring 2011 Exam 2-NSWERS Name: This is a closed book exam, with 9 problems on 5 pages totaling 100 points. Integer ivision/ Modulo rithmetic 1. We can add two numbers in base 2 by using

More information

Algebra homework 8 Homomorphisms, isomorphisms

Algebra homework 8 Homomorphisms, isomorphisms MATH-UA.343.005 T.A. Louis Guigo Algebra homework 8 Homomorphisms, isomorphisms For every n 1 we denote by S n the n-th symmetric group. Exercise 1. Consider the following permutations: ( ) ( 1 2 3 4 5

More information

Multistage Stochastic Programming

Multistage Stochastic Programming IE 495 Lecture 21 Multistage Stochastic Programming Prof. Jeff Linderoth April 16, 2003 April 16, 2002 Stochastic Programming Lecture 21 Slide 1 Outline HW Fixes Multistage Stochastic Programming Modeling

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

CH 39 CREATING THE EQUATION OF A LINE

CH 39 CREATING THE EQUATION OF A LINE 9 CH 9 CREATING THE EQUATION OF A LINE Introduction S ome chapters back we played around with straight lines. We graphed a few, and we learned how to find their intercepts and slopes. Now we re ready to

More information

MATH3075/3975 FINANCIAL MATHEMATICS TUTORIAL PROBLEMS

MATH3075/3975 FINANCIAL MATHEMATICS TUTORIAL PROBLEMS MATH307/37 FINANCIAL MATHEMATICS TUTORIAL PROBLEMS School of Mathematics and Statistics Semester, 04 Tutorial problems should be used to test your mathematical skills and understanding of the lecture material.

More information

Towards Smart Proof Search for Isabelle PSL and all that

Towards Smart Proof Search for Isabelle PSL and all that formerly known as NICTA Towards Smart Proof Search for Isabelle PSL and all that Yutaka Nagashima Trustworthy System Research Group March 2017 until last week www.csiro.au Example proof at Data61 Click

More information

CS 188: Artificial Intelligence. Outline

CS 188: Artificial Intelligence. Outline C 188: Artificial Intelligence Markov Decision Processes (MDPs) Pieter Abbeel UC Berkeley ome slides adapted from Dan Klein 1 Outline Markov Decision Processes (MDPs) Formalism Value iteration In essence

More information

15-451/651: Design & Analysis of Algorithms October 23, 2018 Lecture #16: Online Algorithms last changed: October 22, 2018

15-451/651: Design & Analysis of Algorithms October 23, 2018 Lecture #16: Online Algorithms last changed: October 22, 2018 15-451/651: Design & Analysis of Algorithms October 23, 2018 Lecture #16: Online Algorithms last changed: October 22, 2018 Today we ll be looking at finding approximately-optimal solutions for problems

More information

Lecture 5: Tuesday, January 27, Peterson s Algorithm satisfies the No Starvation property (Theorem 1)

Lecture 5: Tuesday, January 27, Peterson s Algorithm satisfies the No Starvation property (Theorem 1) Com S 611 Spring Semester 2015 Advanced Topics on Distributed and Concurrent Algorithms Lecture 5: Tuesday, January 27, 2015 Instructor: Soma Chaudhuri Scribe: Nik Kinkel 1 Introduction This lecture covers

More information

Math 101, Basic Algebra Author: Debra Griffin

Math 101, Basic Algebra Author: Debra Griffin Math 101, Basic Algebra Author: Debra Griffin Name Chapter 5 Factoring 5.1 Greatest Common Factor 2 GCF, factoring GCF, factoring common binomial factor 5.2 Factor by Grouping 5 5.3 Factoring Trinomials

More information

3 Arbitrage pricing theory in discrete time.

3 Arbitrage pricing theory in discrete time. 3 Arbitrage pricing theory in discrete time. Orientation. In the examples studied in Chapter 1, we worked with a single period model and Gaussian returns; in this Chapter, we shall drop these assumptions

More information

A Translation of Intersection and Union Types

A Translation of Intersection and Union Types A Translation of Intersection and Union Types for the λ µ-calculus Kentaro Kikuchi RIEC, Tohoku University kentaro@nue.riec.tohoku.ac.jp Takafumi Sakurai Department of Mathematics and Informatics, Chiba

More information

COMPUTER SCIENCE 20, SPRING 2014 Homework Problems Recursive Definitions, Structural Induction, States and Invariants

COMPUTER SCIENCE 20, SPRING 2014 Homework Problems Recursive Definitions, Structural Induction, States and Invariants COMPUTER SCIENCE 20, SPRING 2014 Homework Problems Recursive Definitions, Structural Induction, States and Invariants Due Wednesday March 12, 2014. CS 20 students should bring a hard copy to class. CSCI

More information

Semantics of an Intermediate Language for Program Transformation

Semantics of an Intermediate Language for Program Transformation Semantics of an Intermediate Language for Program Transformation Sigurd Schneider Master Thesis Proposal Talk Advisors: Prof. Dr. Sebastian Hack, Prof. Dr. Gert Smolka Saarland University Graduate School

More information

LECTURE 2: MULTIPERIOD MODELS AND TREES

LECTURE 2: MULTIPERIOD MODELS AND TREES LECTURE 2: MULTIPERIOD MODELS AND TREES 1. Introduction One-period models, which were the subject of Lecture 1, are of limited usefulness in the pricing and hedging of derivative securities. In real-world

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

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

Lecture 17: More on Markov Decision Processes. Reinforcement learning

Lecture 17: More on Markov Decision Processes. Reinforcement learning Lecture 17: More on Markov Decision Processes. Reinforcement learning Learning a model: maximum likelihood Learning a value function directly Monte Carlo Temporal-difference (TD) learning COMP-424, Lecture

More information

CS599: Algorithm Design in Strategic Settings Fall 2012 Lecture 6: Prior-Free Single-Parameter Mechanism Design (Continued)

CS599: Algorithm Design in Strategic Settings Fall 2012 Lecture 6: Prior-Free Single-Parameter Mechanism Design (Continued) CS599: Algorithm Design in Strategic Settings Fall 2012 Lecture 6: Prior-Free Single-Parameter Mechanism Design (Continued) Instructor: Shaddin Dughmi Administrivia Homework 1 due today. Homework 2 out

More information

From PSL to NBA: a Modular Symbolic Encoding

From PSL to NBA: a Modular Symbolic Encoding From PSL to NBA: a Modular Symbolic Encoding A. Cimatti 1 M. Roveri 1 S. Semprini 1 S. Tonetta 2 1 ITC-irst Trento, Italy {cimatti,roveri}@itc.it 2 University of Lugano, Lugano, Switzerland tonettas@lu.unisi.ch

More information

SAT and DPLL. Introduction. Preliminaries. Normal forms DPLL. Complexity. Espen H. Lian. DPLL Implementation. Bibliography.

SAT and DPLL. Introduction. Preliminaries. Normal forms DPLL. Complexity. Espen H. Lian. DPLL Implementation. Bibliography. SAT and Espen H. Lian Ifi, UiO Implementation May 4, 2010 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 1 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 2 / 59 Introduction Introduction SAT is the problem

More information

Instruction Selection: Preliminaries. Comp 412

Instruction Selection: Preliminaries. Comp 412 COMP 412 FALL 2018 Instruction Selection: Preliminaries Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights reserved. Students

More information

Dynamic Programming (DP) Massimo Paolucci University of Genova

Dynamic Programming (DP) Massimo Paolucci University of Genova Dynamic Programming (DP) Massimo Paolucci University of Genova DP cannot be applied to each kind of problem In particular, it is a solution method for problems defined over stages For each stage a subproblem

More information

Interpolation. 1 What is interpolation? 2 Why are we interested in this?

Interpolation. 1 What is interpolation? 2 Why are we interested in this? Interpolation 1 What is interpolation? For a certain function f (x we know only the values y 1 = f (x 1,,y n = f (x n For a point x different from x 1,,x n we would then like to approximate f ( x using

More information

MS-E2114 Investment Science Lecture 10: Options pricing in binomial lattices

MS-E2114 Investment Science Lecture 10: Options pricing in binomial lattices MS-E2114 Investment Science Lecture 10: Options pricing in binomial lattices A. Salo, T. Seeve Systems Analysis Laboratory Department of System Analysis and Mathematics Aalto University, School of Science

More information

91.420/543: Artificial Intelligence UMass Lowell CS Fall 2010

91.420/543: Artificial Intelligence UMass Lowell CS Fall 2010 91.420/543: Artificial Intelligence UMass Lowell CS Fall 2010 Lecture 17 & 18: Markov Decision Processes Oct 12 13, 2010 A subset of Lecture 9 slides from Dan Klein UC Berkeley Many slides over the course

More information

Math 167: Mathematical Game Theory Instructor: Alpár R. Mészáros

Math 167: Mathematical Game Theory Instructor: Alpár R. Mészáros Math 167: Mathematical Game Theory Instructor: Alpár R. Mészáros Midterm #1, February 3, 2017 Name (use a pen): Student ID (use a pen): Signature (use a pen): Rules: Duration of the exam: 50 minutes. By

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

SAT and DPLL. Espen H. Lian. May 4, Ifi, UiO. Espen H. Lian (Ifi, UiO) SAT and DPLL May 4, / 59

SAT and DPLL. Espen H. Lian. May 4, Ifi, UiO. Espen H. Lian (Ifi, UiO) SAT and DPLL May 4, / 59 SAT and DPLL Espen H. Lian Ifi, UiO May 4, 2010 Espen H. Lian (Ifi, UiO) SAT and DPLL May 4, 2010 1 / 59 Normal forms Normal forms DPLL Complexity DPLL Implementation Bibliography Espen H. Lian (Ifi, UiO)

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

X ln( +1 ) +1 [0 ] Γ( )

X ln( +1 ) +1 [0 ] Γ( ) Problem Set #1 Due: 11 September 2014 Instructor: David Laibson Economics 2010c Problem 1 (Growth Model): Recall the growth model that we discussed in class. We expressed the sequence problem as ( 0 )=

More information

Homework #4. CMSC351 - Spring 2013 PRINT Name : Due: Thu Apr 16 th at the start of class

Homework #4. CMSC351 - Spring 2013 PRINT Name : Due: Thu Apr 16 th at the start of class Homework #4 CMSC351 - Spring 2013 PRINT Name : Due: Thu Apr 16 th at the start of class o Grades depend on neatness and clarity. o Write your answers with enough detail about your approach and concepts

More information

Practice Second Midterm Exam II

Practice Second Midterm Exam II CS13 Handout 34 Fall 218 November 2, 218 Practice Second Midterm Exam II This exam is closed-book and closed-computer. You may have a double-sided, 8.5 11 sheet of notes with you when you take this exam.

More information

Partial Fractions. A rational function is a fraction in which both the numerator and denominator are polynomials. For example, f ( x) = 4, g( x) =

Partial Fractions. A rational function is a fraction in which both the numerator and denominator are polynomials. For example, f ( x) = 4, g( x) = Partial Fractions A rational function is a fraction in which both the numerator and denominator are polynomials. For example, f ( x) = 4, g( x) = 3 x 2 x + 5, and h( x) = x + 26 x 2 are rational functions.

More information

ACCUPLACER Elementary Algebra Assessment Preparation Guide

ACCUPLACER Elementary Algebra Assessment Preparation Guide ACCUPLACER Elementary Algebra Assessment Preparation Guide Please note that the guide is for reference only and that it does not represent an exact match with the assessment content. The Assessment Centre

More information

The two meanings of Factor

The two meanings of Factor Name Lesson #3 Date: Factoring Polynomials Using Common Factors Common Core Algebra 1 Factoring expressions is one of the gateway skills necessary for much of what we do in algebra for the rest of the

More information

CSE 417 Algorithms. Huffman Codes: An Optimal Data Compression Method

CSE 417 Algorithms. Huffman Codes: An Optimal Data Compression Method CSE 417 Algorithms Huffman Codes: An Optimal Data Compression Method 1 Compression Example 100k file, 6 letter alphabet: a 45% b 13% c 12% d 16% e 9% f 5% File Size: ASCII, 8 bits/char: 800kbits 2 3 >

More information

Lecture 37 Sections 11.1, 11.2, Mon, Mar 31, Hampden-Sydney College. Independent Samples: Comparing Means. Robb T. Koether.

Lecture 37 Sections 11.1, 11.2, Mon, Mar 31, Hampden-Sydney College. Independent Samples: Comparing Means. Robb T. Koether. : : Lecture 37 Sections 11.1, 11.2, 11.4 Hampden-Sydney College Mon, Mar 31, 2008 Outline : 1 2 3 4 5 : When two samples are taken from two different populations, they may be taken independently or not

More information

arxiv: v1 [math.lo] 24 Feb 2014

arxiv: v1 [math.lo] 24 Feb 2014 Residuated Basic Logic II. Interpolation, Decidability and Embedding Minghui Ma 1 and Zhe Lin 2 arxiv:1404.7401v1 [math.lo] 24 Feb 2014 1 Institute for Logic and Intelligence, Southwest University, Beibei

More information

A Consistent Semantics of Self-Adjusting Computation

A Consistent Semantics of Self-Adjusting Computation A Consistent Semantics of Self-Adjusting Computation Umut A. Acar 1 Matthias Blume 1 Jacob Donham 2 December 2006 CMU-CS-06-168 School of Computer Science Carnegie Mellon University Pittsburgh, PA 15213

More information

AVL Trees. The height of the left subtree can differ from the height of the right subtree by at most 1.

AVL Trees. The height of the left subtree can differ from the height of the right subtree by at most 1. AVL Trees In order to have a worst case running time for insert and delete operations to be O(log n), we must make it impossible for there to be a very long path in the binary search tree. The first balanced

More information

Matching of Meta-Expressions with Recursive Bindings

Matching of Meta-Expressions with Recursive Bindings Matching of Meta-Expressions with Recursive Bindings David Sabel Goethe-University Frankfurt am Main, Germany UNIF 2017, Oxford, UK Research supported by the Deutsche Forschungsgemeinschaft (DFG) under

More information

Section 5.3 Factor By Grouping

Section 5.3 Factor By Grouping Section 5.3 Factor By Grouping INTRODUCTION In the previous section you were introduced to factoring out a common monomial factor from a polynomial. For example, in the binomial 6x 2 + 15x, we can recognize

More information

MAC Learning Objectives. Learning Objectives (Cont.)

MAC Learning Objectives. Learning Objectives (Cont.) MAC 1140 Module 12 Introduction to Sequences, Counting, The Binomial Theorem, and Mathematical Induction Learning Objectives Upon completing this module, you should be able to 1. represent sequences. 2.

More information

Binary Decision Diagrams

Binary Decision Diagrams Binary Decision Diagrams Hao Zheng Department of Computer Science and Engineering University of South Florida Tampa, FL 33620 Email: zheng@cse.usf.edu Phone: (813)974-4757 Fax: (813)974-5456 Hao Zheng

More information

1 Graham Hutton, Programming in Haskell, 2nd ed., Cambridge. 2 Bryan O Sullivan, Don Stewart, and John Goerzen, Real World

1 Graham Hutton, Programming in Haskell, 2nd ed., Cambridge. 2 Bryan O Sullivan, Don Stewart, and John Goerzen, Real World Administrativia Legend: EDAF40/EDAN40: Functional Programming Introduction F1 F2 F3 F4 A1 Ö1 A2 EDAF40: 5hp, G2, programming focus EDAN40: 7,5hp, A, theory as well Fi: lectures for all Xi: lectures for

More information