The exercises and answer for programming language class

Size: px
Start display at page:

Download "The exercises and answer for programming language class"

Transcription

1 The exercises and answer for programming language class Neversay: March 14, 2006 Abstract There are exercises and its answer in detail. Please read it carefully. This exercise practice includes: 2.4: Determine whether or not the given statement therminateing by apply the rule or axiom you learn in natrual semantics. 2.7: Define the natrual semantics(ns) of repeat-construct in language While, and prove the equivalence of two sentences. 2.8: Define the natrual semantics(ns) of for-construct in language While, and evaluate some statement by using derivation tree. 2.17: Define the structural operational semantics(sos) of repeatconstruct in language While. 2.18: Define the structural operational semantics(sos) of for-construct in language While. Homework 2: Define the NS and SOS of (for)-construct in language While. If you have any question about this article, please call TA for help. 1

2 [ass ns ] [skip ns ] [comp ns ] [if tt [if ff ns ] [while tt [while ff < x := a, s > s[x A[ α ]s] < skip, s > s < S 1, s > s, < S 2, s > s < S 1 ; S 2, s > s < S 1, s > s < if b then S 1 else S 2, s > s if B[ b ]s = tt < S 2, s > s < if b then S 1 else S 2, s > s if B[ b ]s = ff < S, s > s, < while b do S, s > s < while b do S, s > s if B[ b ]s = tt < while b do S, s > s if B[ b ]s = ff 1 Exercise Question Consider the following statements: Table 1: Natural semantics for While 1. while (x = 1) do (y := y x; x := x 1) 2. while 1 x do (y := y x; x := x 1) 3. while true do skip For each statement determine whether or not it always terminates and whether or not it always loops. Try to argue for your answers using the axioms and rules of Table Answer 1. while (x = 1) do (y := y x; x := x 1) It terminates when only x 1 otherwise it loops. 2. while 1 x do (y := y x; x := x 1) It always terminates. 3. while true do skip It always loops because the derivation tree show that:... < skip, s > s, < while true do skip, s > s < skip, s > s, < while true do skip, s > s < while true do skip, s > s [while tt because B[ true ]s == tt 2

3 2 Exercise Question 1.Extend the language While with the statement repeat S until b and define the relation for it. (The semantic of the repeat-construct is not allowed to rely on the existence of a while-construct in the language.) 2. Prove that repeat S until b and S; if b then skip else (repeat S until b) are semantically equivalent. 2.2 Answer 1. [repeat tt < S, s > s < repeat S until b, s > s if B[ b ]s = tt [repeat ff < S, s > s, < repeat S until b, s > s < repeat S until b, s > s if B[ b ]s = ff 2. We must prove that repeat S until b S; if b then skip else repeat S until b a. First we prove part 1 : repeat S until b S; if b then skip else (repeat S until b) 1. case [repeat tt < S, s > s < repeat S until b, s > s if B[ b ]s = tt by axiom < skip, s > s, because B[ b ]s = tt, then < skip, s > s < if b then skip else (repeat S until b), s > s if B[ b ]s = tt by applying to [if tt, and then < S, s > s, < if b then skip else (repeat S until b), s > s < S; if b then skip else (repeat S until b), s > s by applying to [comp ns ] we got the prove. 2. case [repeat ff < S, s > s, < repeat S until b, s > s < repeat S until b, s > s if B[ b ]s = ff 3

4 < (repeat S until b), s > s < if b then skip else (repeat S until b), s > s if B[ b ]s = ff by applying [if ff ns ] because B[ b ]s = ff < S, s > s, < if b then skip else (repeat S until b), s > s < S; if b then skip else (repeat S until b), s > s by applying [comp ns ] and then we got the prove. By combining of case 1 and 2 we complete the part 1 of this prove. b. Now we prove part 2 : repeat S until b S; if b then skip else (repeat S until b) 1. case : [if tt. we assume s where B[ b ]s = tt First, we extract sentence we want to prove by applying [comp ns ]: < S, s > s, < if b then skip else (repeat S until b), s > s < S; if b then skip else (repeat S until b), s > s And we are going to extract < skip, s > s from if b then skip else (repeat S until b): < skip, s > s < if b then skip else (repeat S until b), s > s if B[ b ]s = tt and by axiom < skip, s > s, we know s = s. (equation 1) And then we prove by combining equation 1 and definition of [repeat tt : < S, s > s < repeat S until b, s > s = s because B[ b ]s = tt 2. case : [if ff ns ]. we assume s where B[ b ]s = ff First, we extract sentence we want to prove by applying [comp ns ]: < S, s > s, < if b then skip else (repeat S until b), s > s < S; if b then skip else (repeat S until b), s > s And we are going to extract < repeat S until b, s > s from if b then skip else (repeat S until b): < (repeat S until b), s > s < if b then skip else (repeat S until b), s > s if B[ b ]s = ff and we have: 4

5 [repeat ff < S, s > s, < repeat S until b, s > s < repeat S until b, s > s because B[ b ]s = ff, so we complete this prove. 3 Exercise Question Another iterative construct is : for x := a 1 to a 2 do S 1. Extend the language While with this statement and define the relation for it. 2. Evaluate the statement y := 1; for z := 1 to x do (y := y x; x := x 1) from a state where x has the value 5. Hint: You may need to assume that you have an inverse to N, so that there is a numeral for each number that may arise during the computation. (The semantics for the for-construct is not allowed to rely on the existence of a while-coonstruct.) 3.2 Answer 1. [for tt < x := a 1, s 0 > s 1, < S, s 1 > s 2, < for x := a 3 to a 2 do S, s 2 > s 3 < for x := a 1 to a 2 do S, s 0 > s 3 where a 3 = N 1 [ A[ a 1 ]s ] if B[ (x = a 2 ) ]s 1 = tt [forns ff < x := a 1, s 0 > s 1 ] < for x := a 1 to a 2 do S, s 0 > s 1 if B[ (x = a 2 ) ]s 1 = ff Please note that the state of x always increases by 1 after evaluating S. 2. We evaluate this by using derivation tree: We encode the state variable s x,y,z which corresponding to the value of x, y, and z in s. For example, s 1,2,3 means x=1,y=2,z=3 in this state enviorment. For saving space, we use S replace (y := y x; x := x 1). < y := 1, s 5,0,0 > s 5,1,0, < for z := 1 to x do S, s 5,1,0 > s 3,20,3 < y := 1; for z := 1 to x do S, s 5,0,0 > s 3,20,3 by [comp ns ]. And now we derivate the tree by [for tt : < z := 1, s 5,1,0 > s 5,1,1, < S, s 5,1,1 > s 4,5,1, < for z := 2 to x do S, s 4,5,1 > s 3,20,3 < for z := 1 to x do S, s 5,1,0 > s 3,20,3 where 2 = N 1 [ A[ 1 ]s 4,5,1 + 1 ] if B[ (z = x) ]s 5,1,1 = tt 5

6 [ass sos ] [skip sos ] [comp 1 sos] [comp 2 sos] [if tt sos] [if ff sos] < x := a, s > s[x A[ α ]s] < skip, s > s < S 1, s > < S 1, s > < S 1 ; S 2, s > < S 1 ; S 2, s > < S 1, s > s < S 1 ; S 2, s > < S 2, s > < if b then S 1 else S 2, s > < S 1, s > if B[ b ]s = tt < if b then S 1 else S 2, s > < S 2, s > if B[ b ]s = ff [while sos ] < while b do S, s > < if b then (S; while b do S) else skip, s > Table 2: Structural Operational Semantics for While For now we know how to extract < (y := y x; x := x 1), s 5,1,1 > s 4,5,1 by [comp ns ]: < y := y x, s 5,1,1 > s 5,5,1, < x := x 1, s 5,5,1 > s 4,5,1 < y := y x; x := x 1, s 5,1,1 > s 4,5,1 For simplizing our derivation process, we will not explain tree like this any more. And now we focus on the tree of [for]: < z := 2, s 4,5,1 > s 4,5,2, < S, s 4,5,2 > s 3,20,2, < for z := 3 to x do S, s 3,20,2 > s 3,20,3 < for z := 2 to x do S, s 4,5,1 > s 3,20,3 where 3 = N 1 [ A[ 2 ]s 3,20,2 + 1 ] if B[ (z = x) ]s 4,5,2 = tt < z := 3, s 3,20,2 > s 3,20,3 < for z := 3 to x do S, s 3,20,2 > s 3,20,3 if B[ (z = x) ]s 3,20,3 = ff 4 Exercise Question Extend While with the construct repeat S until b and specify a structural operational semantics for it. (The semantics for the repeat-construct is not allowed to rely on the existence of a while-construct.) 4.2 Answer It is a piece of cake: [repeat sos ] < repeat S until b, s > < S; if b then skip else (repeat S until b), s > 6

7 5 Exercise Question 1. Extend While with the construct for x := a 1 to a 2 do S and specify the structural operational semantics for it. Hint: You may need to assume that you have an inverse to N, so that there is a numeral for each number that may arise during the computation. (The semantics for the for-construct is not allowed to rely on the existence of a while-coonstruct.) 2. Evaluate the statement y := 1; for z := 1 to x do (y := y x; x := x 1) from a state where x has the value Answer 1. The answer for for-construct is simple: [for sos ] < x := a 1, s > s < for x := a 1 to a 2 do S, s > < if (x = a 2 ) then (S; for x := a 3 to a 2 do S) else skip, s > where a 3 = N 1 [ A[ a 1 ]s + 1 ] 2. We place S with (y := y x; x := x 1) for shorting the shape of evaluation. < y := 1; for z := 1 to x do S, s 5,0,0 > < for z := 1 to x do S, s 5,1,0 > < if (z = x) then (S; for z := 2 to x do S) else skip, s 5,1,1 > < (y := y x; x := x 1); for z := 2 to x do S, s 5,1,1 > < x := x 1; for z := 2 to x do S, s 5,5,1 > < for z := 2 to x do S, s 4,5,1 >... < for z := 3 to x do S, s 3,20,2 > < if (z = x) then (S; for z := 1 to x do S) else skip, s 3,20,3 > < skip, s 3,20,3 > s 3,20,3 6 Homework 2 Extend the language While with the statement for x := a 1 to a 2 step S s do S where S s is the step statement and always executes after S. And define the relation and for it. Hint: You may need to assume that you have an inverse to N, so that there is a numeral for each number that may arise during the computation. (The semantics for the for-construct is not allowed to rely on the existence of a while-coonstruct.) 7

Exercises on Semantics of Programming Languages

Exercises on Semantics of Programming Languages Technische Universität Wien SS 2014 Fakultät für Informatik Repetition sheet Assist. Prof. Florian Zuleger Tuesday, 8 April 2014 Assist. Prof. Georg Weissenbacher Univ. Prof. Agata Ciabattoni Moritz Sinn,

More information

Lecture 5 - Axiomatic semantics

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

More information

Formal Syntax and Semantics of Programming Languages

Formal Syntax and Semantics of Programming Languages Formal Syntax and Semantics of Programming Languages Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson http://www.daimi.au.dk/~bra8130/wiley_book/wiley.html axioms

More information

Formal Semantics of Programming Languages

Formal Semantics of Programming Languages Formal Semantics of Programming Languages Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson http://www.daimi.au.dk/~bra8130/wiley_book/wiley.html Benefits of formal

More information

Formal Semantics of Programming Languages

Formal Semantics of Programming Languages Formal Semantics of Programming Languages Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson http://www.daimi.au.dk/~bra8130/wiley_book/wiley.html Benefits of formal

More information

Formal Syntax and Semantics of Programming Languages

Formal Syntax and Semantics of Programming Languages Formal Syntax and Semantics of Programming Languages Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson http://www.daimi.au.dk/~bra8130/wiley_book/wiley.html The While

More information

Formal Semantics of Programming Languages

Formal Semantics of Programming Languages Formal Semantics of Programming Languages Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson http://www.daimi.au.dk/~bra8130/wiley_book/wiley.html Benefits of formal

More information

Semantics with Applications 3. More on Operational Semantics

Semantics with Applications 3. More on Operational Semantics Semantics with Applications 3. More on Operational Semantics Hanne Riis Nielson, Flemming Nielson (thanks to Henrik Pilegaard) [SwA] Hanne Riis Nielson, Flemming Nielson Semantics with Applications: An

More information

COMP Logic for Computer Scientists. Lecture 23

COMP Logic for Computer Scientists. Lecture 23 COMP 1002 Logic for Computer cientists Lecture 23 B 5 2 J Admin stuff Assignment 3 extension Because of the power outage, assignment 3 now due on Tuesday, March 14 (also 7pm) Assignment 4 to be posted

More information

Lesson 19: The Graph of a Linear Equation in Two Variables is a Line

Lesson 19: The Graph of a Linear Equation in Two Variables is a Line Lesson 19: The Graph of a Linear Equation in Two Variables is a Line Classwork Exercises Theorem: The graph of a linear equation y = mx + b is a non-vertical line with slope m and passing through (0, b),

More information

Fall Compiler Principles Lecture 6: Intermediate Representation. Roman Manevich Ben-Gurion University of the Negev

Fall Compiler Principles Lecture 6: Intermediate Representation. Roman Manevich Ben-Gurion University of the Negev Fall 2015-2016 Compiler Principles Lecture 6: Intermediate Representation Roman Manevich Ben-Gurion University of the Negev Tentative syllabus Front End Intermediate Representation Optimizations Code Generation

More information

Introduction to Denotational Semantics. Class Likes/Dislikes Survey. Dueling Semantics. Denotational Semantics Learning Goals. You re On Jeopardy!

Introduction to Denotational Semantics. Class Likes/Dislikes Survey. Dueling Semantics. Denotational Semantics Learning Goals. You re On Jeopardy! Introduction to Denotational Semantics Class Likes/Dislikes Survey would change [the bijection question] to be one that still tested students' recollection of set theory but that didn't take as much time

More information

Lesson 10. Homework Problem Set Sample Solutions. then Print True else Print False End if. False False True False False False

Lesson 10. Homework Problem Set Sample Solutions. then Print True else Print False End if. False False True False False False Homework Problem Set Sample Solutions 1. Perform the instructions in the following programming code as if you were a computer and your paper were the computer screen. Declare xx integer For all xx from

More information

Chapter 10 Language Translation

Chapter 10 Language Translation Chapter 10 Language Translation A program written in any of those high-level languages must be translated into machine language before execution, by a special piece of software, the compilers. Compared

More information

Subtraction Understand Subtraction on a Number Line Using a number line let s demonstrate the subtraction process using the problem 7 5.

Subtraction Understand Subtraction on a Number Line Using a number line let s demonstrate the subtraction process using the problem 7 5. Objective 1 Subtraction Understand Subtraction on a Number Line Using a number line let s demonstrate the subtraction process using the problem 7 5. -7-6 -5-4 -3-2 -1 0 1 2 3 4 5 6 7 Using the number line

More information

Contents. MATH 32B-2 (18W) (L) G. Liu / (TA) A. Zhou Calculus of Several Variables. 1 Homework 1 - Solutions 3. 2 Homework 2 - Solutions 13

Contents. MATH 32B-2 (18W) (L) G. Liu / (TA) A. Zhou Calculus of Several Variables. 1 Homework 1 - Solutions 3. 2 Homework 2 - Solutions 13 MATH 32B-2 (8) (L) G. Liu / (TA) A. Zhou Calculus of Several Variables Contents Homework - Solutions 3 2 Homework 2 - Solutions 3 3 Homework 3 - Solutions 9 MATH 32B-2 (8) (L) G. Liu / (TA) A. Zhou Calculus

More information

ECE 2300 Digital Logic & Computer Organization. More Finite State Machines

ECE 2300 Digital Logic & Computer Organization. More Finite State Machines ECE 2300 Digital Logic & Computer Organization Spring 2018 More Finite State Machines Lecture 9: 1 Announcements Prelab 3(B) due tomorrow Lab 4 to be released tonight You re not required to change partner(s)

More information

Introduction to Axiomatic Semantics

Introduction to Axiomatic Semantics Introduction to Axiomatic Semantics Meeting 10, CSCI 5535, Spring 2009 Announcements Homework 3 due tonight Homework 2 is graded 13 (mean), 14 (median), out of 21 total, but Graduate class: final project

More information

Introduction to Denotational Semantics. Brutus Is An Honorable Man. Class Likes/Dislikes Survey. Dueling Semantics

Introduction to Denotational Semantics. Brutus Is An Honorable Man. Class Likes/Dislikes Survey. Dueling Semantics Brutus Is An Honorable Man HW2 will not be due today. Homework X+1 will never be due until after I have returned Homework X to you. Normally this is never an issue, but I was sick yesterday and was hosting

More information

CSE 505, Fall 2008, Midterm Examination 29 October Please do not turn the page until everyone is ready.

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

More information

More on Operational Semantics

More on Operational Semantics More on Operational Semantics (Slides modified from those created by Xinyu Feng) 1 / 23 Outline Various formulations Extensions Going wrong Local variable declaration Heap Big-step operational semantics

More information

Formal semantics of loosely typed languages. Joep Verkoelen Vincent Driessen

Formal semantics of loosely typed languages. Joep Verkoelen Vincent Driessen Formal semantics of loosely typed languages Joep Verkoelen Vincent Driessen June, 2004 ii Contents 1 Introduction 3 2 Syntax 5 2.1 Formalities.............................. 5 2.2 Example language LooselyWhile.................

More information

S.W.B.A.T: Identify the independent and dependent variable in sentence. Write a function rule for a table and a situation.

S.W.B.A.T: Identify the independent and dependent variable in sentence. Write a function rule for a table and a situation. Lesson 31 Date: Mr. Jones S.W.B.A.T: Identify the independent and dependent variable in sentence. Write a function rule for a table and a situation. DO NOW 1. If ( ), find f(3). 2. If f(x) = 2x -1, what

More information

Lesson 3: Solving for Unknown Angles using Equations

Lesson 3: Solving for Unknown Angles using Equations Classwork Opening Exercise Two lines meet at the common vertex of two rays; the measurement of. Set up and solve an equation to find the value of and. Example 1 Set up and solve an equation to find the

More information

Lab - 8 Awk Programming

Lab - 8 Awk Programming Lab - 8 Awk Programming AWK is another interpreted programming language which has powerful text processing capabilities. It can solve complex text processing tasks with a few lines of code. Listed below

More information

More on Syntax. Agenda for the Day. Administrative Stuff. More on Syntax In-Class Exercise Using parse trees

More on Syntax. Agenda for the Day. Administrative Stuff. More on Syntax In-Class Exercise Using parse trees More on Syntax Judy Stafford Comp 80 Meeting February, 00 Agenda for the Day Administrative Stuff Moodle Classlist at without waiting list More on Syntax InClass Exercise Using parse trees Last time Syntax

More information

CS 506, Sect 002 Homework 5 Dr. David Nassimi Foundations of CS Due: Week 11, Mon. Apr. 7 Spring 2014

CS 506, Sect 002 Homework 5 Dr. David Nassimi Foundations of CS Due: Week 11, Mon. Apr. 7 Spring 2014 CS 506, Sect 002 Homework 5 Dr. David Nassimi Foundations of CS Due: Week 11, Mon. Apr. 7 Spring 2014 Study: Chapter 4 Analysis of Algorithms, Recursive Algorithms, and Recurrence Equations 1. Prove the

More information

Lesson 13: Exploring Factored Form

Lesson 13: Exploring Factored Form Opening Activity Below is a graph of the equation y = 6(x 3)(x + 2). It is also the graph of: y = 3(2x 6)(x + 2) y = 2(3x 9)(x + 2) y = 2(x 3)(3x + 6) y = 3(x 3)(2x + 4) y = (3x 9)(2x + 4) y = (2x 6)(3x

More information

Homework 1. Problem 1. The following code fragment processes an array and produces two values in registers $v0 and $v1:

Homework 1. Problem 1. The following code fragment processes an array and produces two values in registers $v0 and $v1: Homework 1 Problem 1 The following code fragment processes an array and produces two values in registers $v0 and $v1: add $v0, $zero, $zero add $v1, $zero, $zero add $t6, $zero, $zero sll $a2, $a1, 2 add

More information

Solution Guide for Chapter 12

Solution Guide for Chapter 12 Solution Guide for Chapter 1 Here are the solutions for the Doing the Math exercises in Kiss My Math! DTM from p. 170-1. Start with x. Add, then multiply by 4. So, starting with x, when we add, we ll get:

More information

Problem Set 4 Solutions

Problem Set 4 Solutions Design and Analysis of Algorithms March 5, 205 Massachusetts Institute of Technology 6.046J/8.40J Profs. Erik Demaine, Srini Devadas, and Nancy Lynch Problem Set 4 Solutions Problem Set 4 Solutions This

More information

Sorting Algorithms. CSE21 Winter 2017, Day 2 (B00), Day 1-2 (A00) January 11, 2017

Sorting Algorithms. CSE21 Winter 2017, Day 2 (B00), Day 1-2 (A00) January 11, 2017 Sorting Algorithms CSE21 Winter 2017, Day 2 (B00), Day 1-2 (A00) January 11, 2017 Sorting (or Ordering) Section 3.1 in Rosen vs. * Assume elements of the set to be sorted have some underlying order Why

More information

Triangle Congruence Packet #3

Triangle Congruence Packet #3 Triangle Congruence Packet #3 Name Teacher 1 Warm-Up Day 1: Identifying Congruent Triangles Five Ways to Prove Triangles Congruent In previous lessons, you learned that congruent triangles have all corresponding

More information

Chapter 2: Transformations. Chapter 2 Transformations Page 1

Chapter 2: Transformations. Chapter 2 Transformations Page 1 Chapter 2: Transformations Chapter 2 Transformations Page 1 Unit 2: Vocabulary 1) transformation 2) pre-image 3) image 4) map(ping) 5) rigid motion (isometry) 6) orientation 7) line reflection 8) line

More information

University of Toronto Faculty of Applied Science and Engineering Edward S. Rogers Sr. Department of Electrical and Computer Engineering

University of Toronto Faculty of Applied Science and Engineering Edward S. Rogers Sr. Department of Electrical and Computer Engineering University of Toronto Faculty of Applied Science and Engineering Edward S. Rogers Sr. Department of Electrical and Computer Engineering Final Examination ECE 241F - Digital Systems Examiners: S. Brown,

More information

Name & Recitation Section:

Name & Recitation Section: Name & Recitation Section: Due Wednesday, Jan 5 at 2:10 PM in 34-101. Please print out your code files (homework 1.py, rps.py, loops.py, and any code you wrote for optional problems), staple them to the

More information

Propositional Calculus. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Propositional Calculus. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus

More information

CSC173 Lambda Calculus Lambda Calculus Evaluation (10 min) Evaluate this expression (β-reduce with normal-order evaluation):

CSC173 Lambda Calculus Lambda Calculus Evaluation (10 min) Evaluate this expression (β-reduce with normal-order evaluation): CSC173 Lambda Calculus 014 Please write your name on the bluebook. You may use two sides of handwritten notes. There are 90 possible points and 75 is a perfect score. Stay cool and please write neatly.

More information

Lesson 19: The Graph of a Linear Equation in Two Variables Is a Line

Lesson 19: The Graph of a Linear Equation in Two Variables Is a Line The Graph of a Linear Equation in Two Variables Is a Line Classwork Exercises THEOREM: The graph of a linear equation yy = mmmm + bb is a non-vertical line with slope mm and passing through (0, bb), where

More information

Meeting13:Denotations

Meeting13:Denotations Meeting13:Denotations Announcements Homework 3 due next week Friday at 6:00pm Homework2Comments Time: 29.2 hours avg Difficulty: 5.4 avg Issues Length? (Part 2 out Wed instead of Mon) Misunderstanding

More information

COMP 105 Homework: Type Systems

COMP 105 Homework: Type Systems Due Tuesday, March 29, at 11:59 PM (updated) The purpose of this assignment is to help you learn about type systems. Setup Make a clone of the book code: git clone linux.cs.tufts.edu:/comp/105/build-prove-compare

More information

An Annotated Language

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

More information

A loopy introduction to dependence analysis

A loopy introduction to dependence analysis A loopy introduction to dependence analysis Lindsey Kuper JP Verkamp 1 Pipelining is supposed to work like this IF ID EX MEM WB IF EX MEM ID WB IF ID EX MEM WB c 1 c 2 c 3 c 4 c 5 c 6 c 7 source: Allen

More information

Classwork. Opening Exercise. Example 1. Which prism will hold more 1 in. 1 in. 1 in. cubes? 12 in. 6 in. 4 in. 5 in. 10 in. 8 in.

Classwork. Opening Exercise. Example 1. Which prism will hold more 1 in. 1 in. 1 in. cubes? 12 in. 6 in. 4 in. 5 in. 10 in. 8 in. Classwork Opening Exercise Which prism will hold more 1 in. 1 in. 1 in. cubes? 6 in. 12 in. 10 in. 4 in. 8 in. 5 in. How many more cubes will the prism hold? Example 1 A box with the same dimensions as

More information

Exercise Set Decide whether each matrix below is an elementary matrix. (a) (b) (c) (d) Answer:

Exercise Set Decide whether each matrix below is an elementary matrix. (a) (b) (c) (d) Answer: Understand the relationships between statements that are equivalent to the invertibility of a square matrix (Theorem 1.5.3). Use the inversion algorithm to find the inverse of an invertible matrix. Express

More information

EXAM. CS331 Compiler Design Spring Please read all instructions, including these, carefully

EXAM. CS331 Compiler Design Spring Please read all instructions, including these, carefully EXAM Please read all instructions, including these, carefully There are 7 questions on the exam, with multiple parts. You have 3 hours to work on the exam. The exam is open book, open notes. Please write

More information

Errata for Theories of Programming Languages

Errata for Theories of Programming Languages Errata for Theories of Programming Languages The following are corrections of the errors and obscurities in Theories of Programming Languages that I am currently aware of. Thanks go to Alexander Garthwaite,

More information

02157 Functional Programming Interpreters for two simple languages including exercises

02157 Functional Programming Interpreters for two simple languages including exercises Interpreters for two simple languages including exercises nsen 1 DTU Informatics, Technical University of Denmark Purpose To show the power of a functional programming language, we present a prototype

More information

λ calculus Function application Untyped λ-calculus - Basic Idea Terms, Variables, Syntax β reduction Advanced Formal Methods

λ calculus Function application Untyped λ-calculus - Basic Idea Terms, Variables, Syntax β reduction Advanced Formal Methods Course 2D1453, 2006-07 Advanced Formal Methods Lecture 2: Lambda calculus Mads Dam KTH/CSC Some material from B. Pierce: TAPL + some from G. Klein, NICTA Alonzo Church, 1903-1995 Church-Turing thesis First

More information

Notes for Recitation 8

Notes for Recitation 8 6.04/8.06J Mathematics for Computer Science October 5, 00 Tom Leighton and Marten van Dijk Notes for Recitation 8 Build-up error Recall a graph is connected iff there is a path between every pair of its

More information

Review 1. Richard Koch. April 23, 2005

Review 1. Richard Koch. April 23, 2005 Review Richard Koch April 3, 5 Curves From the chapter on curves, you should know. the formula for arc length in section.;. the definition of T (s), κ(s), N(s), B(s) in section.4. 3. the fact that κ =

More information

Lesson 5: Investigating Quadratic Functions in the Standard Form, ff(xx) = aaxx 2 + bbxx + cc

Lesson 5: Investigating Quadratic Functions in the Standard Form, ff(xx) = aaxx 2 + bbxx + cc : Investigating Quadratic Functions in the Standard Form, ff(xx) = aaxx 22 + bbxx + cc Opening Exercise 1. Marshall had the equation y = (x 2) 2 + 4 and knew that he could easily find the vertex. Sarah

More information

Compilers Course Lecture 4: Context Free Grammars

Compilers Course Lecture 4: Context Free Grammars Compilers Course Lecture 4: Context Free Grammars Example: attempt to define simple arithmetic expressions using named regular expressions: num = [0-9]+ sum = expr "+" expr expr = "(" sum ")" num Appears

More information

Equations of Lines - 3.4

Equations of Lines - 3.4 Equations of Lines - 3.4 Fall 2013 - Math 1010 y = mx + b (y y 1 ) = m(x x 1 ) Ax + By = C (Math 1010) M 1010 3.4 1 / 11 Roadmap Discussion/Activity: Graphs and linear equations. Form: The Point-Slope

More information

Spring 2013 CSE Qualifying Exam Core Subjects. March 23, 2013

Spring 2013 CSE Qualifying Exam Core Subjects. March 23, 2013 Spring 2013 CSE Qualifying Exam Core Subjects March 23, 2013 1 Architecture 1. ROB trace - single issue (a) Non-pipelined functional units Assume the following: Nine ROB slots. 1 integer Execution unit,

More information

Coefficient Constant Equivalent expressions Equation. 3 A mathematical sentence containing an equal sign

Coefficient Constant Equivalent expressions Equation. 3 A mathematical sentence containing an equal sign 8.4.0 Lesson Date Algebra Vocabulary and Generating Equivalent s Student Objectives I can identify how many terms an expression has and what the coefficients, constants, and like terms of that expression

More information

Solutions to Problem 1 of Homework 3 (10 (+6) Points)

Solutions to Problem 1 of Homework 3 (10 (+6) Points) Solutions to Problem 1 of Homework 3 (10 (+6) Points) Sometimes, computing extra information can lead to more efficient divide-and-conquer algorithms. As an example, we will improve on the solution to

More information

Find the area and perimeter of these shapes: Draw another shape with area a smaller perimeter. a larger perimeter.

Find the area and perimeter of these shapes: Draw another shape with area a smaller perimeter. a larger perimeter. Find the area and perimeter of these shapes: Draw another shape with area a smaller perimeter. Draw another shape with area a larger perimeter. but with but with Page 1 Perimeter 10cm 2cm 5cm An equilateral

More information

The semantics of a programming language is concerned with the meaning of programs, that is, how programs behave when executed on computers.

The semantics of a programming language is concerned with the meaning of programs, that is, how programs behave when executed on computers. Semantics The semantics of a programming language is concerned with the meaning of programs, that is, how programs behave when executed on computers. The semantics of a programming language assigns a precise

More information

Graphs and Algorithms 2016

Graphs and Algorithms 2016 Graphs and Algorithms 2016 Teachers: Nikhil Bansal and Jesper Nederlof TA: Shashwat Garg (Office Hours: Thursday: Pick??) Webpage: www.win.tue.nl/~nikhil/courses/2wo08 (for up to date information, links

More information

ECE/CS 552: Introduction to Computer Architecture ASSIGNMENT #1 Due Date: At the beginning of lecture, September 22 nd, 2010

ECE/CS 552: Introduction to Computer Architecture ASSIGNMENT #1 Due Date: At the beginning of lecture, September 22 nd, 2010 ECE/CS 552: Introduction to Computer Architecture ASSIGNMENT #1 Due Date: At the beginning of lecture, September 22 nd, 2010 This homework is to be done individually. Total 9 Questions, 100 points 1. (8

More information

Hoare logic. A proof system for separation logic. Introduction. Separation logic

Hoare logic. A proof system for separation logic. Introduction. Separation logic Introduction Hoare logic Lecture 6: Examples in separation logic In the previous lecture, we saw how reasoning about pointers in Hoare logic was problematic, which motivated introducing separation logic.

More information

3. According to universal addressing, what is the address of vertex d? 4. According to universal addressing, what is the address of vertex f?

3. According to universal addressing, what is the address of vertex d? 4. According to universal addressing, what is the address of vertex f? 1. Prove: A full m-ary tree with i internal vertices contains n = mi + 1 vertices. 2. For a full m-ary tree with n vertices, i internal vertices, and l leaves, prove: (i) i = (n 1)/m and l = [(m 1)n +

More information

CS 151 Midterm. Instructions: Student ID. (Last Name) (First Name) Signature

CS 151 Midterm. Instructions: Student ID. (Last Name) (First Name) Signature CS 151 Midterm Name Student ID Signature :, (Last Name) (First Name) : : Instructions: 1. Please verify that your paper contains 11 pages including this cover. 2. Write down your Student-Id on the top

More information

CS264: Homework #4. Due by midnight on Wednesday, October 22, 2014

CS264: Homework #4. Due by midnight on Wednesday, October 22, 2014 CS264: Homework #4 Due by midnight on Wednesday, October 22, 2014 Instructions: (1) Form a group of 1-3 students. You should turn in only one write-up for your entire group. (2) Turn in your solutions

More information

CS 6110 S14 Lecture 38 Abstract Interpretation 30 April 2014

CS 6110 S14 Lecture 38 Abstract Interpretation 30 April 2014 CS 6110 S14 Lecture 38 Abstract Interpretation 30 April 2014 1 Introduction to Abstract Interpretation At this point in the course, we have looked at several aspects of programming languages: operational

More information

4 Basis, Subbasis, Subspace

4 Basis, Subbasis, Subspace 4 Basis, Subbasis, Subspace Our main goal in this chapter is to develop some tools that make it easier to construct examples of topological spaces. By Definition 3.12 in order to define a topology on a

More information

Guidelines for Writing Mathematical Proofs

Guidelines for Writing Mathematical Proofs Appendix A Guidelines for Writing Mathematical Proofs One of the most important forms of mathematical writing is writing mathematical proofs. The writing of mathematical proofs is an acquired skill and

More information

ASSIGNMENT 2. COMP-202A, Fall 2013, All Sections. Due: October 20 th, 2013 (23:59)

ASSIGNMENT 2. COMP-202A, Fall 2013, All Sections. Due: October 20 th, 2013 (23:59) ASSIGNMENT 2 COMP-202A, Fall 2013, All Sections Due: October 20 th, 2013 (23:59) Please read the entire PDF before starting. You must do this assignment individually and, unless otherwise specified, you

More information

CS422 - Programming Language Design

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

More information

5 Exercise Formal Specification winter term 2010/11

5 Exercise Formal Specification winter term 2010/11 5 Exercise Formal Specification winter term 2010/11 Dipl.-Wirt.-Inf. Ulrich Wolffgang Department of Information Systems, University of Münster January 12, 2011 Agenda Exercise 12 Exercise 13 Next exercise

More information

CS2104 Prog. Lang. Concepts

CS2104 Prog. Lang. Concepts CS2104 Prog. Lang. Concepts Operational Semantics Abhik Roychoudhury Department of Computer Science National University of Singapore Organization An imperative language IMP Formalizing the syntax of IMP

More information

Math Homework 3

Math Homework 3 Math 0 - Homework 3 Due: Friday Feb. in class. Write on your paper the lab section you have registered for.. Staple the sheets together.. Solve exercise 8. of the textbook : Consider the following data:

More information

ECE468 Computer Organization & Architecture. The Design Process & ALU Design

ECE468 Computer Organization & Architecture. The Design Process & ALU Design ECE6 Computer Organization & Architecture The Design Process & Design The Design Process "To Design Is To Represent" Design activity yields description/representation of an object -- Traditional craftsman

More information

Algebra 2 Honors Lesson 10 Translating Functions

Algebra 2 Honors Lesson 10 Translating Functions Algebra 2 Honors Lesson 10 Translating Functions Objectives: The students will be able to translate a base function horizontally and vertically. Students will be able to describe the translation of f(x)

More information

Meeting14:Denotations

Meeting14:Denotations Meeting14:Denotations Announcements Homework 3 due next week Friday at 6:00pm Reminder: 5-minute feedback discussion with Sean is part of the assignment ("interview light") Talk (with me, with the class

More information

Fall Compiler Principles Lecture 5: Intermediate Representation. Roman Manevich Ben-Gurion University of the Negev

Fall Compiler Principles Lecture 5: Intermediate Representation. Roman Manevich Ben-Gurion University of the Negev Fall 2016-2017 Compiler Principles Lecture 5: Intermediate Representation Roman Manevich Ben-Gurion University of the Negev Tentative syllabus Front End Intermediate Representation Optimizations Code Generation

More information

Section 8.3 Vector, Parametric, and Symmetric Equations of a Line in

Section 8.3 Vector, Parametric, and Symmetric Equations of a Line in Section 8.3 Vector, Parametric, and Symmetric Equations of a Line in R 3 In Section 8.1, we discussed vector and parametric equations of a line in. In this section, we will continue our discussion, but,

More information

CSE P 501 Exam 8/5/04

CSE P 501 Exam 8/5/04 Name There are 7 questions worth a total of 65 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. You may refer to the following references: Course

More information

Big-step Operational Semantics (aka Natural Semantics)

Big-step Operational Semantics (aka Natural Semantics) x = 1 let x = 1 in... x(1).!x(1) x.set(1) Programming Language Theory Big-step Operational Semantics (aka Natural Semantics) Ralf Lämmel A big-step operational semantics for While 2 This slide is derived

More information

Introduction to Axiomatic Semantics (1/2)

Introduction to Axiomatic Semantics (1/2) #1 Introduction to Axiomatic Semantics (1/2) How s The Homework Going? Remember: just do the counterexample guided abstraction refinement part of DPLL(T). If you notice any other errors, those are good

More information

Handout 9: Imperative Programs and State

Handout 9: Imperative Programs and State 06-02552 Princ. of Progr. Languages (and Extended ) The University of Birmingham Spring Semester 2016-17 School of Computer Science c Uday Reddy2016-17 Handout 9: Imperative Programs and State Imperative

More information

CSE505, Fall 2012, Midterm Examination October 30, 2012

CSE505, Fall 2012, Midterm Examination October 30, 2012 CSE505, Fall 2012, Midterm Examination October 30, 2012 Rules: The exam is closed-book, closed-notes, except for one side of one 8.5x11in piece of paper. Please stop promptly at Noon. You can rip apart

More information

Structures of Expressions

Structures of Expressions SECONDARY MATH TWO An Integrated Approach MODULE 2 Structures of Expressions The Scott Hendrickson, Joleigh Honey, Barbara Kuehl, Travis Lemon, Janet Sutorius 2017 Original work 2013 in partnership with

More information

A linked list grows as data is added to it. In a linked list each item is packaged into a node.

A linked list grows as data is added to it. In a linked list each item is packaged into a node. Lesson 4 Data Structures What is a data structure? A data structure is a particular way of organizing data in a computer. A data structure that we have already encountered is the array. An array stores

More information

Computability and Complexity Sample Exam Questions

Computability and Complexity Sample Exam Questions Computability and Complexity Sample Exam Questions Wolfgang Schreiner Wolfgang.Schreiner@risc.jku.at Family Name: Given Name: Matriculation Number: Study Code: Total: 100 Points. 51 Points: GEN4 64 Points:

More information

February 2017 (1/20) 2 Piecewise Polynomial Interpolation 2.2 (Natural) Cubic Splines. MA378/531 Numerical Analysis II ( NA2 )

February 2017 (1/20) 2 Piecewise Polynomial Interpolation 2.2 (Natural) Cubic Splines. MA378/531 Numerical Analysis II ( NA2 ) f f f f f (/2).9.8.7.6.5.4.3.2. S Knots.7.6.5.4.3.2. 5 5.2.8.6.4.2 S Knots.2 5 5.9.8.7.6.5.4.3.2..9.8.7.6.5.4.3.2. S Knots 5 5 S Knots 5 5 5 5.35.3.25.2.5..5 5 5.6.5.4.3.2. 5 5 4 x 3 3.5 3 2.5 2.5.5 5

More information

Homework #2. If (your ID number s last two digits % 6) = 0: 6, 12, 18

Homework #2. If (your ID number s last two digits % 6) = 0: 6, 12, 18 2005/Sep/19 1 Homework #2 Chapter 1: Exercises 7, 9 with modifications: for Exercise 7.a: 20 and 32 are changed as your ID number s last two digits and 60. for Exercise 9: 47x25 are change as 47x(your

More information

ASSIGNMENT 4 SOLUTIONS

ASSIGNMENT 4 SOLUTIONS MATH 71 ASSIGNMENT SOLUTIONS 1. If F : X X is a function, define f (x) to be (f f)(x), and inductively define f k (x) (f f k 1 )(x) for each integer k. (So f (x) (f f )(x) f(f(f(x))) for instance.) We

More information

COMP 208 Computers in Engineering

COMP 208 Computers in Engineering COMP 208 Computers in Engineering Lecture 14 Jun Wang School of Computer Science McGill University Fall 2007 COMP 208 - Lecture 14 1 Review: basics of C C is case sensitive 2 types of comments: /* */,

More information

Section 13.5: Equations of Lines and Planes. 1 Objectives. 2 Assignments. 3 Lecture Notes

Section 13.5: Equations of Lines and Planes. 1 Objectives. 2 Assignments. 3 Lecture Notes Section 13.5: Equations of Lines and Planes 1 Objectives 1. Find vector, symmetric, or parametric equations for a line in space given two points on the line, given a point on the line and a vector parallel

More information

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #3: Of Integers and Endians (pt. 2)

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #3: Of Integers and Endians (pt. 2) ECE2049: Embedded Computing in Engineering Design C Term Spring 2018 Lecture #3: Of Integers and Endians (pt. 2) Reading for Today: Davies Ch 2, MSP430 User's Guide Ch 6.1, 6.3 Reading for Next Class:

More information

CSE 167: Introduction to Computer Graphics Lecture #4: Coordinate Systems

CSE 167: Introduction to Computer Graphics Lecture #4: Coordinate Systems CSE 167: Introduction to Computer Graphics Lecture #4: Coordinate Systems Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2017 Announcements Friday: homework 1 due at 2pm Upload

More information

Introduction to Axiomatic Semantics (1/2)

Introduction to Axiomatic Semantics (1/2) #1 Introduction to Axiomatic Semantics (1/2) How s The Homework Going? Remember that you can t just define a meaning function in terms of itself you must use some fixed point machinery. #2 #3 Observations

More information

1. M,M sequential composition: try tactic M; if it succeeds try tactic M. sequential composition (, )

1. M,M sequential composition: try tactic M; if it succeeds try tactic M. sequential composition (, ) Dipl.-Inf. Achim D. Brucker Dr. Burkhart Wolff Computer-supported Modeling and Reasoning http://www.infsec.ethz.ch/ education/permanent/csmr/ (rev. 16802) Submission date: FOL with Equality: Equational

More information

and how to label right triangles:

and how to label right triangles: Grade 9 IGCSE A1: Chapter 6 Trigonometry Items you need at some point in the unit of study: Graph Paper Exercise 2&3: Solving Right Triangles using Trigonometry Trigonometry is a branch of mathematics

More information

Homework 02. A, 8 letters, each letter is 7 bit, which makes 8*7=56bit, there will be 2^56= different combination of keys.

Homework 02. A, 8 letters, each letter is 7 bit, which makes 8*7=56bit, there will be 2^56= different combination of keys. Homework 02 ECE443/518, Falll 2018 By: Boyang Wang 1, We now consider the relation between passwords and key size. For this purpose, we consider a cryptosystem where the user enters a key in the form of

More information

Homework Assignment /645 Fall Instructions and Score Sheet (hand in with answers)

Homework Assignment /645 Fall Instructions and Score Sheet (hand in with answers) Homework Assignment 4 600.445/645 Fall 2018 Instructions and Score Sheet (hand in with answers Name Email Other contact information (optional Signature (required I have followed the rules in completing

More information

Assignment 3 Solutions, COMP 251B

Assignment 3 Solutions, COMP 251B Assignment 3 Solutions, COMP 251B Dipinder S. Rekhi March 24, 2005 1 Exercise 12.1-5 Binary search tree can be thought of as a sorted structure that is created using comparisons only. This weakly implies

More information

Type Checking. Outline. General properties of type systems. Types in programming languages. Notation for type rules.

Type Checking. Outline. General properties of type systems. Types in programming languages. Notation for type rules. Outline Type Checking General properties of type systems Types in programming languages Notation for type rules Logical rules of inference Common type rules 2 Static Checking Refers to the compile-time

More information