COSE 215: Theory of Computation. Undecidability (2) Hakjoo Oh 2016 Spring

Size: px
Start display at page:

Download "COSE 215: Theory of Computation. Undecidability (2) Hakjoo Oh 2016 Spring"

Transcription

1 COSE 215: Theory of Computation Undecidability (2) Hakjoo Oh 2016 Spring

2 Contents Real Examples of undecidable problems Halting problem Program verification Properties of CFGs Post Correspondence Problem (PCP) How to deal with undecidable problems?

3 Halting Problem

4 Program Verification

5 Program Verification

6 Properties of CFGs Is a given CFG ambiguous? For CFGs G 1 and G 2,isL(G 1 ) \ L(G 2 )=;? Is L(G 1 )=L(G 2 )? Is L(G 1 )=L(R) for some regular expression R? Is L(G 1 )=T for some alphabet T?

7 Post Correspondence Problem Is there a list of dominos (repetitions permitted) such that reading off top yields the string obtained by reading off bottom? Possible: { b a ca abc,,, } ca ab a c Impossible: { abc ab, ca a, acc ba }

8 Programming Technologies Program Analysis Program Synthesis

9 27 int i; 28 for (i = 0; i <= 12; i++) txtbuf[i] = 0; junk = (char *)malloc(sizeof(char) * BUFLEN); 31 binbuf = (char *)malloc(sizeof(char)); if ((junk!= NULL) && (binbuf!= NULL)) { 34 isc_buffer_init(binbuf, junk, BUFLEN); 35 dns_name_init(dns_name, NULL); 36 dns_name_setbuffer(dns_name, binbuf); 37 result = dns_name_fromtext(dns_name, txtbuf, NULL, 0, NULL); 38 free(junk); 39 free(binbuf); Current Technology for Safe SW Manual, ad-hoc, postmortem: code review, testing, simulation, debugging, etc

10 Program Analysis Technology Technology for Software MRI prog.c prog.c

11 Aims to detect memory errors in C programs e.g., buffer-overrun, memory leak, null-dereference, etc Features (vs. testing) Full automation Find bugs early All bugs found

12 16 static char *curfinal = "HDACB FE"; keysym = read_from_input (); curfinal: buffer of size if ((((KeySym)(keysym) >= 0xFF91) keysym: && ((KeySym)(keysym) any integer <= 0xFF94))) 21 { 22 unparseputc((char)(keysym-0xff91 +'P'), pty); 23 key = 1; 24 } 25 else if (keysym >= 0) 26 { 27 if (keysym < 16) keysym: [0,15] 28 { 29 if (read_from_input()) 30 { 31 if (keysym >= 10) return; 32 curfinal[keysym] = 1; safe 33 } 34 else 35 { 36 curfinal[keysym] = 2; buffer-overrun 37 } 38 } 39 if (keysym < 10) 40 { 41 unparseputc(curfinal[keysym], pty); 42 } safe Sparrow automatically pinpoints the buffer-overrun bug curfinal:[10,10] keysym: [10,15] 43 }

13 Static Program Analysis Predict SW behavior statically and automatically static: before execution, before sell / embed automatic: sw is analyzed by sw ( static analyzers ) Applications bug-finding. e.g., find runtime failures of programs security. e.g., is this app malicious or benign? verification. e.g., does the program meet its specification? compiler optimization, e.g., automatic parallelization

14 14

15 How Program Analysis Works sound unsound vs.

16 How Program Analysis Works imprecise precise vs.

17 Program Synthesis Technology Currently, programs are written solely by programmers programming is often repetitive, tedious, and errorprone end-users are not capable of fully leveraging computational devices In the future, most programs will be written by programs

18 Program Synthesis Technology

19 ex) Regular Expressions

20 Synthesizing Regular Expressions ((0 + 1)(0 + 1)(0 + 1))* 0, 1 3

21 Synthesizing Regular Expressions * ( + )+ ( )+ ( * ) ( + ) 0+( )

22 Performance 3 ((0 + 1)(0 + 1)(0 + 1))* (1 (0 + 1)* 0)* (0 + 1(0 + 1))* ((0 + 1)* 01)* (1 + 01*0)* (0 + 1)(0 + 1)0(0 + 1)* ((0 + 1) + (0 + 1)1)* n 3 m 00*00(11)* (0 + 1)* 0101 (0 + 1)* 1.273

23 an help autoand structured uding problem eneration, and These tasks a wide variety ains including programming, d geometry. For s the output of technique for roof problems ple problem.. We have deworld applicahere are many ch IP can and ear future. Any t of high-level sts is a strong xample, the If service ( s end users to d programs usis an excellent on of IP. IFTTT gers (such as ) with actions message) over s Facebook. In e used to learn An Excel 2013 feature that automates repetitive string transformations using examples. Once the user performs one instance of the desired transformation (row 2, col. B) and proceeds to transforming another instance (row 3, col. B), Flash Fill learns a program Concatenate(ToLower(Substring(v,WordToken,1)), " ", ToLower(SubString(v,WordToken,2))), which extracts the first two words in input string v (col. A), converts them to lowercase, and concatenates them separated by a space character, to automate the repetitive task. FlashFill in Microsoft Excel

24 Synthesizing Programs [] 7! [] [[1]] 7! [[]] [[1, 3, 5], [5, 3, 2]] 7! [[3, 5], [5, 3]] [[8, 4, 7, 2], [4, 6, 2, 9], [3, 4, 1, 0]] 7! [[8, 4, 7] [4, 6, 9], [3, 4, 1]] 2.2 Transforming trees dropmins x = map f x where f y = filter g y where g z = foldl h False y where h t w = t (w < z)

25 Summary Many real problems are unsolvable by algorithms They can be approximately but usefully solved

26 Announcement Last class: 6/7 (Tuesday) Final exam: 6/9 (Thursday) in class

COSE312: Compilers. Lecture 1 Overview of Compilers

COSE312: Compilers. Lecture 1 Overview of Compilers COSE312: Compilers Lecture 1 Overview of Compilers Hakjoo Oh 2017 Spring Hakjoo Oh COSE312 2017 Spring, Lecture 1 March 7, 2017 1 / 15 What is Compiler? Software systems that translate a program written

More information

Static Program Analysis Part 1 the TIP language

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

More information

The Turing Machine. Unsolvable Problems. Undecidability. The Church-Turing Thesis (1936) Decision Problem. Decision Problems

The Turing Machine. Unsolvable Problems. Undecidability. The Church-Turing Thesis (1936) Decision Problem. Decision Problems The Turing Machine Unsolvable Problems Motivating idea Build a theoretical a human computer Likened to a human with a paper and pencil that can solve problems in an algorithmic way The theoretical machine

More information

Advanced Programming Methods. Introduction in program analysis

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

More information

A Gentle Introduction to Program Analysis

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

More information

COS 320. Compiling Techniques

COS 320. Compiling Techniques Topic 5: Types COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer 1 Types: potential benefits (I) 2 For programmers: help to eliminate common programming mistakes, particularly

More information

CSE 403: Software Engineering, Fall courses.cs.washington.edu/courses/cse403/16au/ Static Analysis. Emina Torlak

CSE 403: Software Engineering, Fall courses.cs.washington.edu/courses/cse403/16au/ Static Analysis. Emina Torlak CSE 403: Software Engineering, Fall 2016 courses.cs.washington.edu/courses/cse403/16au/ Static Analysis Emina Torlak emina@cs.washington.edu Outline What is static analysis? How does it work? Free and

More information

Secure Software Development: Theory and Practice

Secure Software Development: Theory and Practice Secure Software Development: Theory and Practice Suman Jana MW 2:40-3:55pm 415 Schapiro [SCEP] *Some slides are borrowed from Dan Boneh and John Mitchell Software Security is a major problem! Why writing

More information

COMPILER DESIGN. For COMPUTER SCIENCE

COMPILER DESIGN. For COMPUTER SCIENCE COMPILER DESIGN For COMPUTER SCIENCE . COMPILER DESIGN SYLLABUS Lexical analysis, parsing, syntax-directed translation. Runtime environments. Intermediate code generation. ANALYSIS OF GATE PAPERS Exam

More information

Today Program Analysis for finding bugs, especially security bugs problem specification motivation approaches remaining issues

Today Program Analysis for finding bugs, especially security bugs problem specification motivation approaches remaining issues Finding Bugs Last time Run-time reordering transformations Today Program Analysis for finding bugs, especially security bugs problem specification motivation approaches remaining issues CS553 Lecture Finding

More information

R10 SET a) Construct a DFA that accepts an identifier of a C programming language. b) Differentiate between NFA and DFA?

R10 SET a) Construct a DFA that accepts an identifier of a C programming language. b) Differentiate between NFA and DFA? R1 SET - 1 1. a) Construct a DFA that accepts an identifier of a C programming language. b) Differentiate between NFA and DFA? 2. a) Design a DFA that accepts the language over = {, 1} of all strings that

More information

Theory Bridge Exam Example Questions Version of June 6, 2008

Theory Bridge Exam Example Questions Version of June 6, 2008 Theory Bridge Exam Example Questions Version of June 6, 2008 This is a collection of sample theory bridge exam questions. This is just to get some idea of the format of the bridge exam and the level of

More information

CSI33 Data Structures

CSI33 Data Structures Outline Department of Mathematics and Computer Science Bronx Community College October 24, 2018 Outline Outline 1 Chapter 8: A C++ Introduction For Python Programmers Expressions and Operator Precedence

More information

CSCE 548 Building Secure Software Software Analysis Basics

CSCE 548 Building Secure Software Software Analysis Basics CSCE 548 Building Secure Software Software Analysis Basics Professor Lisa Luo Spring 2018 Previous Class Ø Android Background Ø Two Android Security Problems: 1. Android App Repackaging o Very easy to

More information

CS 430 Spring Mike Lam, Professor. Data Types and Type Checking

CS 430 Spring Mike Lam, Professor. Data Types and Type Checking CS 430 Spring 2015 Mike Lam, Professor Data Types and Type Checking Type Systems Type system Rules about valid types, type compatibility, and how data values can be used Benefits of a robust type system

More information

COP4020 Programming Languages. Syntax Prof. Robert van Engelen

COP4020 Programming Languages. Syntax Prof. Robert van Engelen COP4020 Programming Languages Syntax Prof. Robert van Engelen Overview Tokens and regular expressions Syntax and context-free grammars Grammar derivations More about parse trees Top-down and bottom-up

More information

Static Analysis: Overview, Syntactic Analysis and Abstract Interpretation TDDC90: Software Security

Static Analysis: Overview, Syntactic Analysis and Abstract Interpretation TDDC90: Software Security Static Analysis: Overview, Syntactic Analysis and Abstract Interpretation TDDC90: Software Security Ahmed Rezine IDA, Linköpings Universitet Hösttermin 2014 Outline Overview Syntactic Analysis Abstract

More information

Static Analysis methods and tools An industrial study. Pär Emanuelsson Ericsson AB and LiU Prof Ulf Nilsson LiU

Static Analysis methods and tools An industrial study. Pär Emanuelsson Ericsson AB and LiU Prof Ulf Nilsson LiU Static Analysis methods and tools An industrial study Pär Emanuelsson Ericsson AB and LiU Prof Ulf Nilsson LiU Outline Why static analysis What is it Underlying technology Some tools (Coverity, KlocWork,

More information

Floating-point lab deadline moved until Wednesday Today: characters, strings, scanf Characters, strings, scanf questions clicker questions

Floating-point lab deadline moved until Wednesday Today: characters, strings, scanf Characters, strings, scanf questions clicker questions Announcements Thursday Extras: CS Commons on Thursdays @ 4:00 pm but none next week No office hours next week Monday or Tuesday Reflections: when to use if/switch statements for/while statements Floating-point

More information

Static Analysis and Dataflow Analysis

Static Analysis and Dataflow Analysis Static Analysis and Dataflow Analysis Static Analysis Static analyses consider all possible behaviors of a program without running it. 2 Static Analysis Static analyses consider all possible behaviors

More information

Spring Semester 16, Dr. Punch. Exam #1 (2/18), form 1 A

Spring Semester 16, Dr. Punch. Exam #1 (2/18), form 1 A Spring Semester 16, Dr. Punch. Exam #1 (2/18), form 1 A Last name (printed): First name (printed): Directions: a) DO NOT OPEN YOUR EXAM BOOKLET UNTIL YOU HAVE BEEN TOLD TO BEGIN. b) You have 80 minutes

More information

Tracking Pointers with Path and Context Sensitivity for Bug Detection in C Programs. {livshits,

Tracking Pointers with Path and Context Sensitivity for Bug Detection in C Programs. {livshits, Tracking Pointers with Path and Context Sensitivity for Bug Detection in C Programs {livshits, lam}@cs.stanford.edu 2 Background Software systems are getting bigger Harder to develop Harder to modify Harder

More information

COP4020 Programming Languages. Syntax Prof. Robert van Engelen

COP4020 Programming Languages. Syntax Prof. Robert van Engelen COP4020 Programming Languages Syntax Prof. Robert van Engelen Overview n Tokens and regular expressions n Syntax and context-free grammars n Grammar derivations n More about parse trees n Top-down and

More information

Verification by Static Analysis

Verification by Static Analysis Verification by Static Analysis Intelligent Testing Conference Bristol, 17 th March 2014 Verification overview Software Verification is The process of evaluating software during or at the end of the development

More information

Machine-Learning-Guided Selectively Unsound Static Analysis

Machine-Learning-Guided Selectively Unsound Static Analysis Machine-Learning-Guided Selectively Unsound Static Analysis Kihong Heo Seoul National University Hakjoo Oh Korea University Kwangkeun Yi Seoul National University 26 May 2017 ICSE'17 @ Buenos Aires Goal

More information

Simple Overflow. #include <stdio.h> int main(void){ unsigned int num = 0xffffffff;

Simple Overflow. #include <stdio.h> int main(void){ unsigned int num = 0xffffffff; Simple Overflow 1 #include int main(void){ unsigned int num = 0xffffffff; printf("num is %d bits long\n", sizeof(num) * 8); printf("num = 0x%x\n", num); printf("num + 1 = 0x%x\n", num + 1); }

More information

Software Security: Vulnerability Analysis

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

More information

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

CSE P 501 Compilers. Parsing & Context-Free Grammars Hal Perkins Spring UW CSE P 501 Spring 2018 C-1

CSE P 501 Compilers. Parsing & Context-Free Grammars Hal Perkins Spring UW CSE P 501 Spring 2018 C-1 CSE P 501 Compilers Parsing & Context-Free Grammars Hal Perkins Spring 2018 UW CSE P 501 Spring 2018 C-1 Administrivia Project partner signup: please find a partner and fill out the signup form by noon

More information

22c:111 Programming Language Concepts. Fall Types I

22c:111 Programming Language Concepts. Fall Types I 22c:111 Programming Language Concepts Fall 2008 Types I Copyright 2007-08, The McGraw-Hill Company and Cesare Tinelli. These notes were originally developed by Allen Tucker, Robert Noonan and modified

More information

Language Security. Lecture 40

Language Security. Lecture 40 Language Security Lecture 40 (from notes by G. Necula) Prof. Hilfinger CS 164 Lecture 40 1 Lecture Outline Beyond compilers Looking at other issues in programming language design and tools C Arrays Exploiting

More information

C Programming Language: C ADTs, 2d Dynamic Allocation. Math 230 Assembly Language Programming (Computer Organization) Thursday Jan 31, 2008

C Programming Language: C ADTs, 2d Dynamic Allocation. Math 230 Assembly Language Programming (Computer Organization) Thursday Jan 31, 2008 C Programming Language: C ADTs, 2d Dynamic Allocation Math 230 Assembly Language Programming (Computer Organization) Thursday Jan 31, 2008 Overview Row major format 1 and 2-d dynamic allocation struct

More information

Array. Array Declaration:

Array. Array Declaration: Array Arrays are continuous memory locations having fixed size. Where we require storing multiple data elements under single name, there we can use arrays. Arrays are homogenous in nature. It means and

More information

COSE212: Programming Languages. Lecture 3 Functional Programming in OCaml

COSE212: Programming Languages. Lecture 3 Functional Programming in OCaml COSE212: Programming Languages Lecture 3 Functional Programming in OCaml Hakjoo Oh 2017 Fall Hakjoo Oh COSE212 2017 Fall, Lecture 3 September 18, 2017 1 / 44 Why learn ML? Learning ML is a good way of

More information

MA513: Formal Languages and Automata Theory Topic: Context-free Grammars (CFG) Lecture Number 18 Date: September 12, 2011

MA513: Formal Languages and Automata Theory Topic: Context-free Grammars (CFG) Lecture Number 18 Date: September 12, 2011 MA53: Formal Languages and Automata Theory Topic: Context-free Grammars (CFG) Lecture Number 8 Date: September 2, 20 xercise: Define a context-free grammar that represents (a simplification of) expressions

More information

Goal. Overflow Checking in Firefox. Sixgill. Sixgill (cont) Verifier Design Questions. Sixgill: Properties 4/8/2010

Goal. Overflow Checking in Firefox. Sixgill. Sixgill (cont) Verifier Design Questions. Sixgill: Properties 4/8/2010 Goal Overflow Checking in Firefox Brian Hackett Can we clean a code base of buffer overflows? Keep it clean? Must prove buffer accesses are in bounds Verification: prove a code base has a property Sixgill

More information

Static Analysis of C++ Projects with CodeSonar

Static Analysis of C++ Projects with CodeSonar Static Analysis of C++ Projects with CodeSonar John Plaice, Senior Scientist, GrammaTech jplaice@grammatech.com 25 July 2017, Meetup C++ de Montréal Abstract Static program analysis consists of the analysis

More information

CSE 3302 Programming Languages Lecture 2: Syntax

CSE 3302 Programming Languages Lecture 2: Syntax CSE 3302 Programming Languages Lecture 2: Syntax (based on slides by Chengkai Li) Leonidas Fegaras University of Texas at Arlington CSE 3302 L2 Spring 2011 1 How do we define a PL? Specifying a PL: Syntax:

More information

Combinational Devices and Boolean Algebra

Combinational Devices and Boolean Algebra Combinational Devices and Boolean Algebra Silvina Hanono Wachman M.I.T. L02-1 6004.mit.edu Home: Announcements, course staff Course information: Lecture and recitation times and locations Course materials

More information

Informatics Ingeniería en Electrónica y Automática Industrial

Informatics Ingeniería en Electrónica y Automática Industrial Informatics Ingeniería en Electrónica y Automática Industrial Operators and expressions in C Operators and expressions in C Numerical expressions and operators Arithmetical operators Relational and logical

More information

Introduction to Computer Science Midterm 3 Fall, Points

Introduction to Computer Science Midterm 3 Fall, Points Introduction to Computer Science Fall, 2001 100 Points Notes 1. Tear off this sheet and use it to keep your answers covered at all times. 2. Turn the exam over and write your name next to the staple. Do

More information

One-Slide Summary. Lecture Outline. Language Security

One-Slide Summary. Lecture Outline. Language Security Language Security Or: bringing a knife to a gun fight #1 One-Slide Summary A language s design principles and features have a strong influence on the security of programs written in that language. C s

More information

Gujarat Technological University Sankalchand Patel College of Engineering, Visnagar B.E. Semester VII (CE) July-Nov Compiler Design (170701)

Gujarat Technological University Sankalchand Patel College of Engineering, Visnagar B.E. Semester VII (CE) July-Nov Compiler Design (170701) Gujarat Technological University Sankalchand Patel College of Engineering, Visnagar B.E. Semester VII (CE) July-Nov 2014 Compiler Design (170701) Question Bank / Assignment Unit 1: INTRODUCTION TO COMPILING

More information

Continuation Passing Style. Continuation Passing Style

Continuation Passing Style. Continuation Passing Style 161 162 Agenda functional programming recap problem: regular expression matcher continuation passing style (CPS) movie regular expression matcher based on CPS correctness proof, verification change of

More information

Dynamic Dependency Monitoring to Secure Information Flow

Dynamic Dependency Monitoring to Secure Information Flow Dynamic Dependency Monitoring to Secure Information Flow Mark Thober Joint work with Paritosh Shroff and Scott F. Smith Department of Computer Science Johns Hopkins University CSF 07 1 Motivation Information

More information

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I BASIC COMPUTATION x public static void main(string [] args) Fundamentals of Computer Science I Outline Using Eclipse Data Types Variables Primitive and Class Data Types Expressions Declaration Assignment

More information

Automated Software Analysis Techniques For High Reliability: A Concolic Testing Approach. Moonzoo Kim

Automated Software Analysis Techniques For High Reliability: A Concolic Testing Approach. Moonzoo Kim Automated Software Analysis Techniques For High Reliability: A Concolic Testing Approach Moonzoo Kim Contents Automated Software Analysis Techniques Background Concolic testing process Example of concolic

More information

ESC101N: Fundamentals of Computing End-sem st semester

ESC101N: Fundamentals of Computing End-sem st semester ESC101N: Fundamentals of Computing End-sem 2010-11 1st semester Instructor: Arnab Bhattacharya 8:00-11:00am, 15th November, 2010 Instructions 1. Please write your name, roll number and section below. 2.

More information

Introduction A Tiny Example Language Type Analysis Static Analysis 2009

Introduction A Tiny Example Language Type Analysis Static Analysis 2009 Introduction A Tiny Example Language Type Analysis 2009 Michael I. Schwartzbach Computer Science, University of Aarhus 1 Questions About Programs Does the program terminate? How large can the heap become

More information

Automatic Software Verification

Automatic Software Verification Automatic Software Verification Instructor: Mooly Sagiv TA: Oded Padon Slides from Eran Yahav and the Noun Project, Wikipedia Course Requirements Summarize one lecture 10% one lecture notes 45% homework

More information

CS 3360 Design and Implementation of Programming Languages. Exam 1

CS 3360 Design and Implementation of Programming Languages. Exam 1 1 Spring 2017 (Thursday, March 9) Name: CS 3360 Design and Implementation of Programming Languages Exam 1 This test has 8 questions and pages numbered 1 through 7. Reminders This test is closed-notes and

More information

Chapter 2 :: Programming Language Syntax

Chapter 2 :: Programming Language Syntax Chapter 2 :: Programming Language Syntax Michael L. Scott kkman@sangji.ac.kr, 2015 1 Regular Expressions A regular expression is one of the following: A character The empty string, denoted by Two regular

More information

Fiji VM Safety Critical Java

Fiji VM Safety Critical Java Fiji VM Safety Critical Java Filip Pizlo, President Fiji Systems Inc. Introduction Java is a modern, portable programming language with wide-spread adoption. Goal: streamlining debugging and certification.

More information

14.1 Encoding for different models of computation

14.1 Encoding for different models of computation Lecture 14 Decidable languages In the previous lecture we discussed some examples of encoding schemes, through which various objects can be represented by strings over a given alphabet. We will begin this

More information

Outline. 1 Scanning Tokens. 2 Regular Expresssions. 3 Finite State Automata

Outline. 1 Scanning Tokens. 2 Regular Expresssions. 3 Finite State Automata Outline 1 2 Regular Expresssions Lexical Analysis 3 Finite State Automata 4 Non-deterministic (NFA) Versus Deterministic Finite State Automata (DFA) 5 Regular Expresssions to NFA 6 NFA to DFA 7 8 JavaCC:

More information

Automatic Generation of Program Specifications

Automatic Generation of Program Specifications Automatic Generation of Program Specifications Jeremy Nimmer MIT Lab for Computer Science http://pag.lcs.mit.edu/ Joint work with Michael Ernst Jeremy Nimmer, page 1 Synopsis Specifications are useful

More information

[0569] p 0318 garbage

[0569] p 0318 garbage A Pointer is a variable which contains the address of another variable. Declaration syntax: Pointer_type *pointer_name; This declaration will create a pointer of the pointer_name which will point to the

More information

Pointers. 1 Background. 1.1 Variables and Memory. 1.2 Motivating Pointers Massachusetts Institute of Technology

Pointers. 1 Background. 1.1 Variables and Memory. 1.2 Motivating Pointers Massachusetts Institute of Technology Introduction to C++ Massachusetts Institute of Technology ocw.mit.edu 6.096 Pointers 1 Background 1.1 Variables and Memory When you declare a variable, the computer associates the variable name with a

More information

Compiler Construction

Compiler Construction Compiler Construction Exercises 1 Review of some Topics in Formal Languages 1. (a) Prove that two words x, y commute (i.e., satisfy xy = yx) if and only if there exists a word w such that x = w m, y =

More information

Compiler Construction LECTURE # 3

Compiler Construction LECTURE # 3 Compiler Construction LECTURE # 3 The Course Course Code: CS-4141 Course Title: Compiler Construction Instructor: JAWAD AHMAD Email Address: jawadahmad@uoslahore.edu.pk Web Address: http://csandituoslahore.weebly.com/cc.html

More information

Programming Studio #9 ECE 190

Programming Studio #9 ECE 190 Programming Studio #9 ECE 190 Programming Studio #9 Concepts: Functions review 2D Arrays GDB Announcements EXAM 3 CONFLICT REQUESTS, ON COMPASS, DUE THIS MONDAY 5PM. NO EXTENSIONS, NO EXCEPTIONS. Functions

More information

Agenda. Peer Instruction Question 1. Peer Instruction Answer 1. Peer Instruction Question 2 6/22/2011

Agenda. Peer Instruction Question 1. Peer Instruction Answer 1. Peer Instruction Question 2 6/22/2011 CS 61C: Great Ideas in Computer Architecture (Machine Structures) Introduction to C (Part II) Instructors: Randy H. Katz David A. Patterson http://inst.eecs.berkeley.edu/~cs61c/sp11 Spring 2011 -- Lecture

More information

Lexical Analysis 1 / 52

Lexical Analysis 1 / 52 Lexical Analysis 1 / 52 Outline 1 Scanning Tokens 2 Regular Expresssions 3 Finite State Automata 4 Non-deterministic (NFA) Versus Deterministic Finite State Automata (DFA) 5 Regular Expresssions to NFA

More information

Program Verification. Aarti Gupta

Program Verification. Aarti Gupta Program Verification Aarti Gupta 1 Agenda Famous bugs Common bugs Testing (from lecture 6) Reasoning about programs Techniques for program verification 2 Famous Bugs The first bug: A moth in a relay (1945)

More information

Compilation 2012 Static Type Checking

Compilation 2012 Static Type Checking Compilation 2012 Jan Midtgaard Michael I. Schwartzbach Aarhus University The Type Checker The type checker has several tasks: determine the types of all expressions check that values and variables are

More information

programming languages need to be precise a regular expression is one of the following: tokens are the building blocks of programs

programming languages need to be precise a regular expression is one of the following: tokens are the building blocks of programs Chapter 2 :: Programming Language Syntax Programming Language Pragmatics Michael L. Scott Introduction programming languages need to be precise natural languages less so both form (syntax) and meaning

More information

Computer Science Foundation Exam

Computer Science Foundation Exam Computer Science Foundation Exam August 6, 017 Section I A DATA STRUCTURES SOLUTIONS NO books, notes, or calculators may be used, and you must work entirely on your own. Question # Max Pts Category Passing

More information

Algorithms and Programming I. Lecture#12 Spring 2015

Algorithms and Programming I. Lecture#12 Spring 2015 Algorithms and Programming I Lecture#12 Spring 2015 Think Python How to Think Like a Computer Scientist By :Allen Downey Installing Python Follow the instructions on installing Python and IDLE on your

More information

Lecture 9 Assertions and Error Handling CS240

Lecture 9 Assertions and Error Handling CS240 Lecture 9 Assertions and Error Handling CS240 The C preprocessor The C compiler performs Macro expansion and directive handling Preprocessing directive lines, including file inclusion and conditional compilation,

More information

Data Types and Variables in C language

Data Types and Variables in C language Data Types and Variables in C language Basic structure of C programming To write a C program, we first create functions and then put them together. A C program may contain one or more sections. They are

More information

Abstractions and small languages in synthesis CS294: Program Synthesis for Everyone

Abstractions and small languages in synthesis CS294: Program Synthesis for Everyone Abstractions and small languages in synthesis CS294: Program Synthesis for Everyone Ras Bodik Emina Torlak Division of Computer Science University of California, Berkeley Today Today: we describe why high-level

More information

QUESTIONS RELATED TO UNIT I, II And III

QUESTIONS RELATED TO UNIT I, II And III QUESTIONS RELATED TO UNIT I, II And III UNIT I 1. Define the role of input buffer in lexical analysis 2. Write regular expression to generate identifiers give examples. 3. Define the elements of production.

More information

Static Analysis in C/C++ code with Polyspace

Static Analysis in C/C++ code with Polyspace 1 Static Analysis in C/C++ code with Polyspace Yongchool Ryu Application Engineer gary.ryu@mathworks.com 2016 The MathWorks, Inc. 2 Agenda Efficient way to find problems in Software Category of Static

More information

Midterm Solutions COMS W4115 Programming Languages and Translators Wednesday, March 25, :10-5:25pm, 309 Havemeyer

Midterm Solutions COMS W4115 Programming Languages and Translators Wednesday, March 25, :10-5:25pm, 309 Havemeyer Department of Computer cience Columbia University Midterm olutions COM W4115 Programming Languages and Translators Wednesday, March 25, 2009 4:10-5:25pm, 309 Havemeyer Closed book, no aids. ach question

More information

9/21/17. Outline. Expression Evaluation and Control Flow. Arithmetic Expressions. Operators. Operators. Notation & Placement

9/21/17. Outline. Expression Evaluation and Control Flow. Arithmetic Expressions. Operators. Operators. Notation & Placement Outline Expression Evaluation and Control Flow In Text: Chapter 6 Notation Operator evaluation order Operand evaluation order Overloaded operators Type conversions Short-circuit evaluation of conditions

More information

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible) Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program

More information

Datatypes, Variables, and Operations

Datatypes, Variables, and Operations Datatypes, Variables, and Operations 1 Primitive Type Classification 2 Numerical Data Types Name Range Storage Size byte 2 7 to 2 7 1 (-128 to 127) 8-bit signed short 2 15 to 2 15 1 (-32768 to 32767) 16-bit

More information

Automation Framework for Large-Scale Regular Expression Matching on FPGA. Thilan Ganegedara, Yi-Hua E. Yang, Viktor K. Prasanna

Automation Framework for Large-Scale Regular Expression Matching on FPGA. Thilan Ganegedara, Yi-Hua E. Yang, Viktor K. Prasanna Automation Framework for Large-Scale Regular Expression Matching on FPGA Thilan Ganegedara, Yi-Hua E. Yang, Viktor K. Prasanna Ming-Hsieh Department of Electrical Engineering University of Southern California

More information

CS 449 Lecture 3. Variables in memory. Dr. Jack Lange. int x = 4;

CS 449 Lecture 3. Variables in memory. Dr. Jack Lange. int x = 4; CS 449 Lecture 3 Dr. Jack Lange int x = 4; Variables in memory X is a handle to 4 bytes of memory assigned by the compiler &x; à returns the memory locaeon What if we want to modify the value of x in another

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/ Today's learning goals Sipser Ch 3.2, 3.3 Define variants of TMs Enumerators Multi-tape TMs Nondeterministic TMs

More information

c. Typically results in an intractably large set of test cases even for small programs

c. Typically results in an intractably large set of test cases even for small programs Multiple-Choice Questions: 1. True or false? Generally, in practice, developers exhaustively test software. a. True b. False 2. True or false? All real software contains bugs. a. True b. False 3. Which

More information

Syntax Analysis. Amitabha Sanyal. (www.cse.iitb.ac.in/ as) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay

Syntax Analysis. Amitabha Sanyal. (www.cse.iitb.ac.in/ as) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay Syntax Analysis (www.cse.iitb.ac.in/ as) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay September 2007 College of Engineering, Pune Syntax Analysis: 2/124 Syntax

More information

Flow Control. CSC215 Lecture

Flow Control. CSC215 Lecture Flow Control CSC215 Lecture Outline Blocks and compound statements Conditional statements if - statement if-else - statement switch - statement? : opertator Nested conditional statements Repetitive statements

More information

Static Analysis Alert Audits Lexicon And Rules David Svoboda, CERT Lori Flynn, CERT Presenter: Will Snavely, CERT

Static Analysis Alert Audits Lexicon And Rules David Svoboda, CERT Lori Flynn, CERT Presenter: Will Snavely, CERT Static Analysis Alert Audits Lexicon And Rules David Svoboda, CERT Lori Flynn, CERT Presenter: Will Snavely, CERT Software Engineering Institute Carnegie Mellon University Pittsburgh, PA 15213 2016 Carnegie

More information

Review! * follows a pointer to its value! & gets the address of a variable! Pearce, Summer 2010 UCB! ! int x = 1000; Pearce, Summer 2010 UCB!

Review! * follows a pointer to its value! & gets the address of a variable! Pearce, Summer 2010 UCB! ! int x = 1000; Pearce, Summer 2010 UCB! CS61C L03 Introduction to C (pt 2) (1)! inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 3 Introduction to C (pt 2) 2010-06-23!!!Instructor Paul Pearce! The typical! development cycle!

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 3 Introduction to C (pt 2) 2010-06-23! C help session: Tonight 7:00-9:00pm @ 306 Soda!!!Instructor Paul Pearce! The typical! development

More information

Computer Science Foundation Exam

Computer Science Foundation Exam Computer Science Foundation Exam August 26, 2017 Section I A DATA STRUCTURES NO books, notes, or calculators may be used, and you must work entirely on your own. Name: UCFID: NID: Question # Max Pts Category

More information

Computer Science 217

Computer Science 217 Computer Science 217 Midterm Exam October 29, 2014 First Name: Last Name: ID: Class Time (Circle One): 1:00pm 3:00pm Instructions: Neatly print your names and ID number in the spaces provided above. Pick

More information

Test Automation. 20 December 2017

Test Automation. 20 December 2017 Test Automation 20 December 2017 The problem of test automation Testing has repetitive components, so automation is justified The problem is cost-benefit evaluation of automation [Kaner] Time for: test

More information

Lexical Analysis. Dragon Book Chapter 3 Formal Languages Regular Expressions Finite Automata Theory Lexical Analysis using Automata

Lexical Analysis. Dragon Book Chapter 3 Formal Languages Regular Expressions Finite Automata Theory Lexical Analysis using Automata Lexical Analysis Dragon Book Chapter 3 Formal Languages Regular Expressions Finite Automata Theory Lexical Analysis using Automata Phase Ordering of Front-Ends Lexical analysis (lexer) Break input string

More information

Topic 9: Type Checking

Topic 9: Type Checking Recommended Exercises and Readings Topic 9: Type Checking From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 13.17, 13.18, 13.19, 13.20, 13.21, 13.22 Readings: Chapter 13.5, 13.6 and

More information

Topic 9: Type Checking

Topic 9: Type Checking Topic 9: Type Checking 1 Recommended Exercises and Readings From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 13.17, 13.18, 13.19, 13.20, 13.21, 13.22 Readings: Chapter 13.5, 13.6

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Variable and Data Type I

Variable and Data Type I Islamic University Of Gaza Faculty of Engineering Computer Engineering Department Lab 2 Variable and Data Type I Eng. Ibraheem Lubbad September 24, 2016 Variable is reserved a location in memory to store

More information

Midterm II CS164, Spring 2006

Midterm II CS164, Spring 2006 Midterm II CS164, Spring 2006 April 11, 2006 Please read all instructions (including these) carefully. Write your name, login, SID, and circle the section time. There are 10 pages in this exam and 4 questions,

More information

CompSci 125 Lecture 11

CompSci 125 Lecture 11 CompSci 125 Lecture 11 switch case The? conditional operator do while for Announcements hw5 Due 10/4 p2 Due 10/5 switch case! The switch case Statement Consider a simple four-function calculator 16 buttons:

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Context Free Grammars and Parsing 1 Recall: Architecture of Compilers, Interpreters Source Parser Static Analyzer Intermediate Representation Front End Back

More information

CS711 Advanced Programming Languages Pointer Analysis Overview and Flow-Sensitive Analysis

CS711 Advanced Programming Languages Pointer Analysis Overview and Flow-Sensitive Analysis CS711 Advanced Programming Languages Pointer Analysis Overview and Flow-Sensitive Analysis Radu Rugina 8 Sep 2005 Pointer Analysis Informally: determine where pointers (or references) in the program may

More information

Week 9 Part 1. Kyle Dewey. Tuesday, August 28, 12

Week 9 Part 1. Kyle Dewey. Tuesday, August 28, 12 Week 9 Part 1 Kyle Dewey Overview Dynamic allocation continued Heap versus stack Memory-related bugs Exam #2 Dynamic Allocation Recall... Dynamic memory allocation allows us to request memory on the fly

More information

18-642: Code Style for Compilers

18-642: Code Style for Compilers 18-642: Code Style for Compilers 9/25/2017 1 Anti-Patterns: Coding Style: Language Use Code compiles with warnings Warnings are turned off or over-ridden Insufficient warning level set Language safety

More information