ProPed. Tool for Symbolic Verification of Probablistic Recursive Programs. University of Missouri Columbia, Missouri, USA

Size: px
Start display at page:

Download "ProPed. Tool for Symbolic Verification of Probablistic Recursive Programs. University of Missouri Columbia, Missouri, USA"

Transcription

1 ProPed Tool for Symbolic Verification of Probablistic Recursive Programs Rohit Chadha 1 Umang Mathur 2 Stefan Schwoon 3 1 Computer Science Department University of Missouri Columbia, Missouri, USA 2 Department of Computer Science and Engineering Indian Institute of Tchnology - Bombay Mumbai 3 LSV, ENS Cachan France January 23, 2014 Rohit Chadha, Umang Mathur, Stefan Schwoon 1 of 17

2 ProPed: Symbolic Verification + Probablistic + Recursion Figure: Comparison with existing state-of-the-art tools Rohit Chadha, Umang Mathur, Stefan Schwoon 2 of 17

3 ProPed: Symbolic Verification + Probablistic + Recursion Figure: Comparison with existing state-of-the-art tools Moped: Recursion and symbolic program verification but no probability Rohit Chadha, Umang Mathur, Stefan Schwoon 2 of 17

4 ProPed: Symbolic Verification + Probablistic + Recursion Figure: Comparison with existing state-of-the-art tools Moped: Recursion and symbolic program verification but no probability PRISM: Symbolic program analysis and probability but no recursion Rohit Chadha, Umang Mathur, Stefan Schwoon 2 of 17

5 ProPed: Symbolic Verification + Probablistic + Recursion Figure: Comparison with existing state-of-the-art tools Moped: Recursion and symbolic program verification but no probability PRISM: Symbolic program analysis and probability but no recursion PReMo: Recursion and probability but explicit state model checking Rohit Chadha, Umang Mathur, Stefan Schwoon 2 of 17

6 ProPed: Symbolic Verification + Probablistic + Recursion Figure: Comparison with existing state-of-the-art tools Moped: Recursion and symbolic program verification but no probability PRISM: Symbolic program analysis and probability but no recursion PReMo: Recursion and probability but explicit state model checking ProPed = Moped PRISM PReMo Rohit Chadha, Umang Mathur, Stefan Schwoon 2 of 17

7 ProPed: Symbolic Verification + Probablistic + Recursion Figure: Comparison with existing state-of-the-art tools Moped: Recursion and symbolic program verification but no probability PRISM: Symbolic program analysis and probability but no recursion PReMo: Recursion and probability but explicit state model checking ProPed = Moped PRISM PReMo ProPed is a MTBDD-based tool that analyzes probabilistic recursive programs Rohit Chadha, Umang Mathur, Stefan Schwoon 2 of 17

8 Probabilistic Recursive Programs Analysis of Probabilistic Recursive Programs: Modeling the program Rohit Chadha, Umang Mathur, Stefan Schwoon 3 of 17

9 Probabilistic Recursive Programs Analysis of Probabilistic Recursive Programs: Modeling the program Reachability Analysis and Property Checking Rohit Chadha, Umang Mathur, Stefan Schwoon 3 of 17

10 Probabilistic Recursive Programs Analysis of Probabilistic Recursive Programs: Modeling the program Reachability Analysis and Property Checking Calculating Information Leakage Rohit Chadha, Umang Mathur, Stefan Schwoon 3 of 17

11 Example program procedure p; p0: if? then p1: call s; p2: if? then wp 0.2 -> call p; wp 0.8 -> skip; end if; else p3: call p; P4: return end if procedure s; s0: if? then return; end if; s1: call p; s2: return; procedure main ; m0: call s; m1: return; S = {p 0,..., p 4, s 0,..., s 2, m 0, m 1 }, initial state = m 0 Rohit Chadha, Umang Mathur, Stefan Schwoon 4 of 17

12 Example program procedure p; p0: if? then p1: call s; p2: if? then wp 0.2 -> call p; wp 0.8 -> skip; end if; else p3: call p; P4: return end if procedure s; s0: if? then return; end if; s1: call p; s2: return; procedure main ; m0: call s; m1: return; S = {p 0,..., p 4, s 0,..., s 2, m 0, m 1 }, initial state = m 0 m1 ε m0 s0 m1 p1 s2 m1 s0 p2 s2 m1 s1 m1 p0 s2 m1 p3 s2 m1 p0 p4 s2 m1 Rohit Chadha, Umang Mathur, Stefan Schwoon 4 of 17

13 Analysis of Recursive Programs is not Straightforward Potentially infinite state space! Rohit Chadha, Umang Mathur, Stefan Schwoon 5 of 17

14 Analysis of Recursive Programs is not Straightforward Potentially infinite state space! Simple unrolling/inlining is not applicable Rohit Chadha, Umang Mathur, Stefan Schwoon 5 of 17

15 Analysis of Recursive Programs is not Straightforward Potentially infinite state space! Simple unrolling/inlining is not applicable Cannot be analyzed by naively searching all reachable states Rohit Chadha, Umang Mathur, Stefan Schwoon 5 of 17

16 Analysis of Recursive Programs is not Straightforward Potentially infinite state space! Simple unrolling/inlining is not applicable Cannot be analyzed by naively searching all reachable states Some finite representation is required Rohit Chadha, Umang Mathur, Stefan Schwoon 5 of 17

17 Computation Model for Probabilistic Recursive Programs Control flow: Sequential (probabilistic) program Procedures Mutual procedure calls (possibly recursive) Rohit Chadha, Umang Mathur, Stefan Schwoon 6 of 17

18 Computation Model for Probabilistic Recursive Programs Control flow: Sequential (probabilistic) program Procedures Mutual procedure calls (possibly recursive) Data: Global Variables (finite memory) Local Variables in each procedure (one copy per call) Rohit Chadha, Umang Mathur, Stefan Schwoon 6 of 17

19 Pushdown Systems: Syntax and Semantics A pushdown system is a triple (P, Γ, δ), where P is a finite set of control locations (states) Γ is a finite stack alphabet δ (P Γ) (P Γ ) is a finite set of rules Rohit Chadha, Umang Mathur, Stefan Schwoon 7 of 17

20 Pushdown Systems: Syntax and Semantics A pushdown system is a triple (P, Γ, δ), where P is a finite set of control locations (states) Γ is a finite stack alphabet δ (P Γ) (P Γ ) is a finite set of rules A configuration is a pair pα, where p P and α Γ Semantics: A (possibly infinite) transition system with configurations as states and transitions given by If px qα δ, then pxβ qαβ for every β Γ Rohit Chadha, Umang Mathur, Stefan Schwoon 7 of 17

21 Pushdown Systems: Syntax and Semantics A pushdown system is a triple (P, Γ, δ), where P is a finite set of control locations (states) Γ is a finite stack alphabet δ (P Γ) (P Γ ) is a finite set of rules A configuration is a pair pα, where p P and α Γ Semantics: A (possibly infinite) transition system with configurations as states and transitions given by If px qα δ, then pxβ qαβ for every β Γ Normalization α 2 (each transition pushes atmost 2 symbols on the stack), termination only by empty stack. Rohit Chadha, Umang Mathur, Stefan Schwoon 7 of 17

22 Probabilistic Pushdown Systems: Syntax and Semantics A probabilistic pushdown system is a tuple P = (P, Γ, δ, P rob), where (P, Γ, δ) is a PDS P rob : δ (0, 1] such that for every pair px, we have P px qα P rob(px qα) = 1 px x qα to denote P rob(px qα) = x Rohit Chadha, Umang Mathur, Stefan Schwoon 8 of 17

23 Probabilistic Pushdown Systems: Syntax and Semantics A probabilistic pushdown system is a tuple P = (P, Γ, δ, P rob), where (P, Γ, δ) is a PDS P rob : δ (0, 1] such that for every pair px, we have P px qα P rob(px qα) = 1 px x qα to denote P rob(px qα) = x Semantics: A (possibly infinite) Markov chain with configurations as states and transition probabilities given by If px x qα δ, then pxβ x qαβ for every β Γ Rohit Chadha, Umang Mathur, Stefan Schwoon 8 of 17

24 From programs to pushdown systems State of a procedural program: (g, n, l, (n 1, l 1) (n k, l k )), where g is a valuation of the global variables, n is the value of the program counter, l is a valuation of local variables of the current active procedure, n i is a return address, and l i is a saved valuation of the local variables of a calling procedure Modeled as a configuration pxy 1 Y k where p = g X = (n, l) Y i = (n i, l i) Rohit Chadha, Umang Mathur, Stefan Schwoon 9 of 17

25 From programs to pushdown systems The following correspondence between a program and PDS holds: State p corresponds to valuations of global variables Γ corresponds to tuples of the form (program counter, local valuations) Configuration paw can be interpreted with globals in p, current procedure with local variables in A and suspended procedures in w Rule px qy corresponds to a sequential statement within a procedure Rule px qy Z corresponds to a call to some procedure Rule px qε corresponds to a return from some procedure Rohit Chadha, Umang Mathur, Stefan Schwoon 10 of 17

26 Probabilistic Verification Qualitative properties: Does a program property hold with probability 1? Rohit Chadha, Umang Mathur, Stefan Schwoon 11 of 17

27 Probabilistic Verification Qualitative properties: Does a program property hold with probability 1? Quantitative properties: What is the probability with which a certain property hold? Reachability of control states simple PCTL properties such as (l 1 l 2 l k ), where l i are labels in the program Rohit Chadha, Umang Mathur, Stefan Schwoon 11 of 17

28 Quantitative Verification: Formulating system of non-linear equations Define a variable [pxq] as the probability of starting at the configuration px and eventually reaching the configuration qε. Rohit Chadha, Umang Mathur, Stefan Schwoon 12 of 17

29 Quantitative Verification: Formulating system of non-linear equations Define a variable [pxq] as the probability of starting at the configuration px and eventually reaching the configuration qε. Theorem (J. Esparza, A. Kucĕra, R. Mayr) The [pxq]s are the least solution of the following system of equations: [pxq] = P px qε x x + P px ry x x.[ry q] + P px ry x x. P Z t P [ry t].[tzq] Rohit Chadha, Umang Mathur, Stefan Schwoon 12 of 17

30 Quantitative Verification: Formulating system of non-linear equations Define a variable [pxq] as the probability of starting at the configuration px and eventually reaching the configuration qε. Theorem (J. Esparza, A. Kucĕra, R. Mayr) The [pxq]s are the least solution of the following system of equations: [pxq] = P px qε x x + P px ry x x.[ry q] + P px ry x x. P Z t P [ry t].[tzq] The system is of the form x = P (x), and the sequence 0, P (0), P 2 (0) converges to the least solution. Rohit Chadha, Umang Mathur, Stefan Schwoon 12 of 17

31 Fixed-point Computation The variables [pxq] are just relations over the initial and final valuations of variables The statements of the program are also similar relations Stmt Stmt: x =!x x 0x2c x' 0x29 0x2b 0 1 Can be represented efficiently as MTBBDs (= BDDs + real values on the terminal nodes) Fixed point computation - Jacobi Iterative Method Use of CUDD library for MTBDD (ADD) manipulations. Rohit Chadha, Umang Mathur, Stefan Schwoon 13 of 17

32 Information Leakage Leakage measured in terms of min-entropy (G. Smith) For a given set of inputs S and outputs O, min-entropy leakage, L SO =, where log V (S O) V (S) S is a random variable on S and having distribution P S O is a random variable on O and having distribution P O V (S) = max s S P S[s] V (S O) = P o O P O[o].max s S P [s o] Computing the above metric is simply basic ADD manipulation! Rohit Chadha, Umang Mathur, Stefan Schwoon 14 of 17

33 Technical details about the tool Input language: Remopla with an additional pchoice construct define N 32 define DEFAULT_INT_BITS N unsigned int var1; bool g; module void f(unsigned int v, bool z){ } bool k; pchoice :: 0.2 -> label2: k = g && z; :: 0.8 -> var1 = var1 + v; choicep module void main(){ } var1 = 53; pchoice :: 0.3 -> label1: g = true; :: 0.7 -> f(var1,!g); choicep Figure: An input program for ProPed Parser and other libraries (CUDD, etc.,) : C Analysis (Fixed point computation) : C++ Rohit Chadha, Umang Mathur, Stefan Schwoon 15 of 17

34 More about MTBDDs main 0 0x x1942 0x193f 0x1940 0x1941 0x1938 0x193b 0x193e 0x1937 0x193a 0x193d 0x1935 0x1936 MTBDD = Multi Terminal Binary Decision Diagram Figure: An MTBDD CUDD : ADD (Algebraic Decision Diagram) interface Provides important Utilities: Cudd addtimes Cudd addplus Cudd addpermute Cudd addmatrixmultiply Cudd addcmpl, Cudd addxnor, Cudd addexistabstract, Cudd addmaxabstract, Rohit Chadha, Umang Mathur, Stefan Schwoon 16 of 17

35 Possible Improvements and Extensions Use faster iteration methods (Jacobi is too slow) such as Newton-Raphson iterations Repeated Reachability : Büchi Information leakage by energy characterization Rohit Chadha, Umang Mathur, Stefan Schwoon 17 of 17

Model checking pushdown systems

Model checking pushdown systems Model checking pushdown systems R. Ramanujam Institute of Mathematical Sciences, Chennai jam@imsc.res.in Update Meeting, IIT-Guwahati, 4 July 2006 p. 1 Sources of unboundedness Data manipulation: integers,

More information

Overview. Probabilistic Programming. Dijkstra s guarded command language: Syntax. Elementary pgcl ingredients. Lecture #4: Probabilistic GCL

Overview. Probabilistic Programming. Dijkstra s guarded command language: Syntax. Elementary pgcl ingredients. Lecture #4: Probabilistic GCL Overview Lecture #4: Probabilistic GCL 1 Joost-Pieter Katoen 2 3 Recursion RWTH Lecture Series on 2018 Joost-Pieter Katoen 1/31 Joost-Pieter Katoen 2/31 Dijkstra s guarded command language: Syntax Elementary

More information

Rewriting Models of Boolean Programs

Rewriting Models of Boolean Programs Rewriting Models of Boolean Programs Javier Esparza University of Stuttgart Joint work with Ahmed Bouajjani Automatic verification using model-checking Initiated in the early 80s in USA and France. 25

More information

Abstract Interpretation

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

More information

A BDD-Based Model Checker for Recursive Programs

A BDD-Based Model Checker for Recursive Programs A BDD-Based Model Checker for ecursive Programs Javier Esparza and Stefan Schwoon Technische Universität München Arcisstr. 21, 80290 München, Germany {esparza,schwoon}@in.tum.de Abstract. We present a

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

CSCI312 Principles of Programming Languages!

CSCI312 Principles of Programming Languages! CSCI312 Principles of Programming Languages!! Chapter 3 Regular Expression and Lexer Xu Liu Recap! Copyright 2006 The McGraw-Hill Companies, Inc. Clite: Lexical Syntax! Input: a stream of characters from

More information

Decidable Verification of Uninterpreted Programs

Decidable Verification of Uninterpreted Programs Decidable Verification of Uninterpreted Programs UMANG MATHUR, University of Illinois, Urbana Champaign, USA P. MADHUSUDAN, University of Illinois, Urbana Champaign, USA MAHESH VISWANATHAN, University

More information

3.7 Denotational Semantics

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

More information

Static Analysis by A. I. of Embedded Critical Software

Static Analysis by A. I. of Embedded Critical Software Static Analysis by Abstract Interpretation of Embedded Critical Software Julien Bertrane ENS, Julien.bertrane@ens.fr Patrick Cousot ENS & CIMS, Patrick.Cousot@ens.fr Radhia Cousot CNRS & ENS, Radhia.Cousot@ens.fr

More information

Virtual Machine Tutorial

Virtual Machine Tutorial Virtual Machine Tutorial CSA2201 Compiler Techniques Gordon Mangion Virtual Machine A software implementation of a computing environment in which an operating system or program can be installed and run.

More information

Lecture 6. Abstract Interpretation

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

More information

Compilation Lecture 3: Syntax Analysis: Top-Down parsing. Noam Rinetzky

Compilation Lecture 3: Syntax Analysis: Top-Down parsing. Noam Rinetzky Compilation 0368-3133 Lecture 3: Syntax Analysis: Top-Down parsing Noam Rinetzky 1 Recursive descent parsing Define a function for every nonterminal Every function work as follows Find applicable production

More information

Polynomial-Time What-If Analysis for Prefix-Manipulating MPLS Networks

Polynomial-Time What-If Analysis for Prefix-Manipulating MPLS Networks Polynomial-Time What-If Analysis for Prefix-Manipulating MPLS Networks Stefan Schmid University of Vienna, Austria and Segment Routing!... Jiri Srba Aalborg University, Denmark Polynomial-Time What-If

More information

Lexical and Syntax Analysis. Top-Down Parsing

Lexical and Syntax Analysis. Top-Down Parsing Lexical and Syntax Analysis Top-Down Parsing Easy for humans to write and understand String of characters Lexemes identified String of tokens Easy for programs to transform Data structure Syntax A syntax

More information

Chapter 13. Recursion. Copyright 2016 Pearson, Inc. All rights reserved.

Chapter 13. Recursion. Copyright 2016 Pearson, Inc. All rights reserved. Chapter 13 Recursion Copyright 2016 Pearson, Inc. All rights reserved. Learning Objectives Recursive void Functions Tracing recursive calls Infinite recursion, overflows Recursive Functions that Return

More information

Parsing. source code. while (k<=n) {sum = sum+k; k=k+1;}

Parsing. source code. while (k<=n) {sum = sum+k; k=k+1;} Compiler Construction Grammars Parsing source code scanner tokens regular expressions lexical analysis Lennart Andersson parser context free grammar Revision 2012 01 23 2012 parse tree AST builder (implicit)

More information

Pushdown Automata. A PDA is an FA together with a stack.

Pushdown Automata. A PDA is an FA together with a stack. Pushdown Automata A PDA is an FA together with a stack. Stacks A stack stores information on the last-in firstout principle. Items are added on top by pushing; items are removed from the top by popping.

More information

MIT Specifying Languages with Regular Expressions and Context-Free Grammars

MIT Specifying Languages with Regular Expressions and Context-Free Grammars MIT 6.035 Specifying Languages with Regular essions and Context-Free Grammars Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology Language Definition Problem How to precisely

More information

Approximating the Shuffle of Context-free Languages to Find Bugs in Concurrent Recursive Programs

Approximating the Shuffle of Context-free Languages to Find Bugs in Concurrent Recursive Programs IT 11 062 Examensarbete 30 hp Augusti 2011 Approximating the Shuffle of Context-free Languages to Find Bugs in Concurrent Recursive Programs Jari Stenman Institutionen för informationsteknologi Department

More information

Lexical and Syntax Analysis

Lexical and Syntax Analysis Lexical and Syntax Analysis (of Programming Languages) Top-Down Parsing Lexical and Syntax Analysis (of Programming Languages) Top-Down Parsing Easy for humans to write and understand String of characters

More information

Lecture 24 Notes Search in Graphs

Lecture 24 Notes Search in Graphs Lecture 24 Notes Search in Graphs 15-122: Principles of Imperative Computation (Spring 2016) Frank Pfenning, André Platzer, Rob Simmons, Penny Anderson 1 Introduction In this lecture, we will discuss the

More information

CS 403: Scanning and Parsing

CS 403: Scanning and Parsing CS 403: Scanning and Parsing Stefan D. Bruda Fall 2017 THE COMPILATION PROCESS Character stream Scanner (lexical analysis) Token stream Parser (syntax analysis) Parse tree Semantic analysis Abstract syntax

More information

Context Free Languages and Pushdown Automata

Context Free Languages and Pushdown Automata Context Free Languages and Pushdown Automata COMP2600 Formal Methods for Software Engineering Ranald Clouston Australian National University Semester 2, 2013 COMP 2600 Context Free Languages and Pushdown

More information

Probabilistic Model Checking. Mohammad Roohitavaf

Probabilistic Model Checking. Mohammad Roohitavaf Probabilistic Model Checking Mohammad Roohitavaf Index! Introduction! Probabilistic Systems! Probabilistic Logics! PRISM! Performance Evaluation! Model Checking and Performance Evaluation! Challenges Introduction!

More information

Part II: Atomicity for Software Model Checking. Analysis of concurrent programs is difficult (1) Transaction. The theory of movers (Lipton 75)

Part II: Atomicity for Software Model Checking. Analysis of concurrent programs is difficult (1) Transaction. The theory of movers (Lipton 75) Part II: Atomicity for Software Model Checking Class Account { int balance; static int MIN = 0, MAX = 00; bool synchronized deposit(int n) { int t = balance + n; if (t > MAX) return false; bool synchronized

More information

Intermediate Code Generation

Intermediate Code Generation Intermediate Code Generation In the analysis-synthesis model of a compiler, the front end analyzes a source program and creates an intermediate representation, from which the back end generates target

More information

Lecture 10: Nested Depth First Search, Counter- Example Generation Revisited, Bit-State Hashing, On-The-Fly Model Checking

Lecture 10: Nested Depth First Search, Counter- Example Generation Revisited, Bit-State Hashing, On-The-Fly Model Checking CS 267: Automated Verification Lecture 10: Nested Depth First Search, Counter- Example Generation Revisited, Bit-State Hashing, On-The-Fly Model Checking Instructor: Tevfik Bultan Buchi Automata Language

More information

Syntax Analysis Check syntax and construct abstract syntax tree

Syntax Analysis Check syntax and construct abstract syntax tree Syntax Analysis Check syntax and construct abstract syntax tree if == = ; b 0 a b Error reporting and recovery Model using context free grammars Recognize using Push down automata/table Driven Parsers

More information

CSX-lite Example. LL(1) Parse Tables. LL(1) Parser Driver. Example of LL(1) Parsing. An LL(1) parse table, T, is a twodimensional

CSX-lite Example. LL(1) Parse Tables. LL(1) Parser Driver. Example of LL(1) Parsing. An LL(1) parse table, T, is a twodimensional LL(1) Parse Tables CSX-lite Example An LL(1) parse table, T, is a twodimensional array. Entries in T are production numbers or blank (error) entries. T is indexed by: A, a non-terminal. A is the nonterminal

More information

Syntax Analysis Part I

Syntax Analysis Part I Syntax Analysis Part I Chapter 4: Context-Free Grammars Slides adapted from : Robert van Engelen, Florida State University Position of a Parser in the Compiler Model Source Program Lexical Analyzer Token,

More information

CS1622. Today. A Recursive Descent Parser. Preliminaries. Lecture 9 Parsing (4)

CS1622. Today. A Recursive Descent Parser. Preliminaries. Lecture 9 Parsing (4) CS1622 Lecture 9 Parsing (4) CS 1622 Lecture 9 1 Today Example of a recursive descent parser Predictive & LL(1) parsers Building parse tables CS 1622 Lecture 9 2 A Recursive Descent Parser. Preliminaries

More information

Compiler Construction

Compiler Construction Compiler Construction Lecture 2: Lexical Analysis I (Introduction) Thomas Noll Lehrstuhl für Informatik 2 (Software Modeling and Verification) noll@cs.rwth-aachen.de http://moves.rwth-aachen.de/teaching/ss-14/cc14/

More information

A Characterization of the Chomsky Hierarchy by String Turing Machines

A Characterization of the Chomsky Hierarchy by String Turing Machines A Characterization of the Chomsky Hierarchy by String Turing Machines Hans W. Lang University of Applied Sciences, Flensburg, Germany Abstract A string Turing machine is a variant of a Turing machine designed

More information

Certified Memory Usage Analysis

Certified Memory Usage Analysis Certified Memory Usage Analysis David Cachera, Thomas Jensen, David Pichardie, Gerardo Schneider IRISA, ENS Cachan Bretagne, France Context Embedded devices (smart cards, mobile phones) memory is limited

More information

Foundations. Yu Zhang. Acknowledgement: modified from Stanford CS242

Foundations. Yu Zhang. Acknowledgement: modified from Stanford CS242 Spring 2013 Foundations Yu Zhang Acknowledgement: modified from Stanford CS242 https://courseware.stanford.edu/pg/courses/317431/ Course web site: http://staff.ustc.edu.cn/~yuzhang/fpl Reading Concepts

More information

Configuration Sets for CSX- Lite. Parser Action Table

Configuration Sets for CSX- Lite. Parser Action Table Configuration Sets for CSX- Lite State s 6 s 7 Cofiguration Set Prog { Stmts } Eof Stmts Stmt Stmts State s s Cofiguration Set Prog { Stmts } Eof Prog { Stmts } Eof Stmts Stmt Stmts Stmts λ Stmt if ( Expr

More information

MIT Specifying Languages with Regular Expressions and Context-Free Grammars. Martin Rinard Massachusetts Institute of Technology

MIT Specifying Languages with Regular Expressions and Context-Free Grammars. Martin Rinard Massachusetts Institute of Technology MIT 6.035 Specifying Languages with Regular essions and Context-Free Grammars Martin Rinard Massachusetts Institute of Technology Language Definition Problem How to precisely define language Layered structure

More information

Syntax Analysis. Prof. James L. Frankel Harvard University. Version of 6:43 PM 6-Feb-2018 Copyright 2018, 2015 James L. Frankel. All rights reserved.

Syntax Analysis. Prof. James L. Frankel Harvard University. Version of 6:43 PM 6-Feb-2018 Copyright 2018, 2015 James L. Frankel. All rights reserved. Syntax Analysis Prof. James L. Frankel Harvard University Version of 6:43 PM 6-Feb-2018 Copyright 2018, 2015 James L. Frankel. All rights reserved. Context-Free Grammar (CFG) terminals non-terminals start

More information

THE COMPILATION PROCESS EXAMPLE OF TOKENS AND ATTRIBUTES

THE COMPILATION PROCESS EXAMPLE OF TOKENS AND ATTRIBUTES THE COMPILATION PROCESS Character stream CS 403: Scanning and Parsing Stefan D. Bruda Fall 207 Token stream Parse tree Abstract syntax tree Modified intermediate form Target language Modified target language

More information

Type assignment for intersections and unions in call-by-value languages

Type assignment for intersections and unions in call-by-value languages Type assignment for intersections and unions in call-by-value languages Joshua Dunfield and Frank Pfenning Triple Project Carnegie Mellon University 8 April 2003 FOSSACS 03, Warsaw, Poland Type assignment

More information

Model Checking Revision: Model Checking for Infinite Systems Revision: Traffic Light Controller (TLC) Revision: 1.12

Model Checking Revision: Model Checking for Infinite Systems Revision: Traffic Light Controller (TLC) Revision: 1.12 Model Checking mc Revision:.2 Model Checking for Infinite Systems mc 2 Revision:.2 check algorithmically temporal / sequential properties fixpoint algorithms with symbolic representations: systems are

More information

Automatic Test Generation from Interprocedural Specifications

Automatic Test Generation from Interprocedural Specifications Automatic Test Generation from Interprocedural Specifications Camille Constant 1, Bertrand Jeannet 2 and Thierry Jéron 1 1 IRISA/INRIA, Campus de Beaulieu, Rennes, France, constant, jeron@irisa.fr 2 INRIA

More information

Compiler Construction

Compiler Construction Compiler Construction Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ss-16/cc/ Conceptual Structure of a Compiler Source code x1 := y2

More information

Table-Driven Top-Down Parsers

Table-Driven Top-Down Parsers Table-Driven Top-Down Parsers Recursive descent parsers have many attractive features. They are actual pieces of code that can be read by programmers and extended. This makes it fairly easy to understand

More information

Today s class. Roots of equation Finish up incremental search Open methods. Numerical Methods, Fall 2011 Lecture 5. Prof. Jinbo Bi CSE, UConn

Today s class. Roots of equation Finish up incremental search Open methods. Numerical Methods, Fall 2011 Lecture 5. Prof. Jinbo Bi CSE, UConn Today s class Roots of equation Finish up incremental search Open methods 1 False Position Method Although the interval [a,b] where the root becomes iteratively closer with the false position method, unlike

More information

Compiler Construction: Parsing

Compiler Construction: Parsing Compiler Construction: Parsing Mandar Mitra Indian Statistical Institute M. Mitra (ISI) Parsing 1 / 33 Context-free grammars. Reference: Section 4.2 Formal way of specifying rules about the structure/syntax

More information

Software Model Checking. From Programs to Kripke Structures

Software Model Checking. From Programs to Kripke Structures Software Model Checking (in (in C or or Java) Java) Model Model Extraction 1: int x = 2; int y = 2; 2: while (y

More information

Compiler Design 1. Bottom-UP Parsing. Goutam Biswas. Lect 6

Compiler Design 1. Bottom-UP Parsing. Goutam Biswas. Lect 6 Compiler Design 1 Bottom-UP Parsing Compiler Design 2 The Process The parse tree is built starting from the leaf nodes labeled by the terminals (tokens). The parser tries to discover appropriate reductions,

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

Application: Programming Language Semantics

Application: Programming Language Semantics Chapter 8 Application: Programming Language Semantics Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 527 Introduction to Programming Language Semantics Programming Language

More information

Improving Pushdown System Model Checking

Improving Pushdown System Model Checking Improving Pushdown System Model Checking Akash Lal and Thomas Reps University of Wisconsin, Madison, Wisconsin 53706 {akash, reps}@cs.wisc.edu Abstract. In this paper, we reduce pushdown system (PDS) model

More information

PROGRAM ANALYSIS & SYNTHESIS

PROGRAM ANALYSIS & SYNTHESIS Lecture 02 Structural Operational Semantics (SOS) PROGRAM ANALYSIS & SYNTHESIS EranYahav 1 Previously static analysis over-approximation of program behavior abstract interpretation abstraction, transformers,

More information

Grammar Rules in Prolog!!

Grammar Rules in Prolog!! Grammar Rules in Prolog GR-1 Backus-Naur Form (BNF) BNF is a common grammar used to define programming languages» Developed in the late 1950 s Because grammars are used to describe a language they are

More information

Administrativia. PA2 assigned today. WA1 assigned today. Building a Parser II. CS164 3:30-5:00 TT 10 Evans. First midterm. Grammars.

Administrativia. PA2 assigned today. WA1 assigned today. Building a Parser II. CS164 3:30-5:00 TT 10 Evans. First midterm. Grammars. Administrativia Building a Parser II CS164 3:30-5:00 TT 10 Evans PA2 assigned today due in 12 days WA1 assigned today due in a week it s a practice for the exam First midterm Oct 5 will contain some project-inspired

More information

Binary Code Analysis: Concepts and Perspectives

Binary Code Analysis: Concepts and Perspectives Binary Code Analysis: Concepts and Perspectives Emmanuel Fleury LaBRI, Université de Bordeaux, France May 12, 2016 E. Fleury (LaBRI, France) Binary Code Analysis: Concepts

More information

Introduction to Lexing and Parsing

Introduction to Lexing and Parsing Introduction to Lexing and Parsing ECE 351: Compilers Jon Eyolfson University of Waterloo June 18, 2012 1 Riddle Me This, Riddle Me That What is a compiler? 1 Riddle Me This, Riddle Me That What is a compiler?

More information

Timo Latvala. January 28, 2004

Timo Latvala. January 28, 2004 Reactive Systems: Kripke Structures and Automata Timo Latvala January 28, 2004 Reactive Systems: Kripke Structures and Automata 3-1 Properties of systems invariants: the system never reaches a bad state

More information

LL(1) predictive parsing

LL(1) predictive parsing LL(1) predictive parsing Informatics 2A: Lecture 11 Mary Cryan School of Informatics University of Edinburgh mcryan@staffmail.ed.ac.uk 10 October 2018 1 / 15 Recap of Lecture 10 A pushdown automaton (PDA)

More information

Denotational Semantics. Domain Theory

Denotational Semantics. Domain Theory Denotational Semantics and Domain Theory 1 / 51 Outline Denotational Semantics Basic Domain Theory Introduction and history Primitive and lifted domains Sum and product domains Function domains Meaning

More information

Improved BDD-based Discrete Analysis of Timed Systems

Improved BDD-based Discrete Analysis of Timed Systems Improved BDD-based Discrete Analysis of Timed Systems Truong Khanh Nguyen 1, Jun Sun 2, Yang Liu 1, Jin Song Dong 1 and Yan Liu 1 1 School of Computing National University of Singapore 2 Information System

More information

CS 314 Principles of Programming Languages. Lecture 9

CS 314 Principles of Programming Languages. Lecture 9 CS 314 Principles of Programming Languages Lecture 9 Zheng Zhang Department of Computer Science Rutgers University Wednesday 5 th October, 2016 Zheng Zhang 1 CS@Rutgers University Class Information Homework

More information

Proving liveness. Alexey Gotsman IMDEA Software Institute

Proving liveness. Alexey Gotsman IMDEA Software Institute Proving liveness Alexey Gotsman IMDEA Software Institute Safety properties Ensure bad things don t happen: - the program will not commit a memory safety fault - it will not release a lock it does not hold

More information

Symbolic Evaluation/Execution

Symbolic Evaluation/Execution Symbolic Evaluation/Execution Reading Assignment *R.W. Floyd, "Assigning Meaning to Programs, Symposium on Applied Mathematics, 1967, pp. 19-32 (Appeared as volume 19 of Mathematical Aspects of Computer

More information

Softwaretechnik. Program verification. Albert-Ludwigs-Universität Freiburg. June 28, Softwaretechnik June 28, / 24

Softwaretechnik. Program verification. Albert-Ludwigs-Universität Freiburg. June 28, Softwaretechnik June 28, / 24 Softwaretechnik Program verification Albert-Ludwigs-Universität Freiburg June 28, 2012 Softwaretechnik June 28, 2012 1 / 24 Road Map Program verification Automatic program verification Programs with loops

More information

Reasoning About Exceptions Using Model Checking

Reasoning About Exceptions Using Model Checking Reasoning About Exceptions Using Model Checking Reid Simmons David Garlan Jeannette M. Wing George Fairbanks, Gil Tolle, Balaji Sarpeshkar, Joe Jiang Computer Science Department Carnegie Mellon University

More information

Compiler Construction 2016/2017 Syntax Analysis

Compiler Construction 2016/2017 Syntax Analysis Compiler Construction 2016/2017 Syntax Analysis Peter Thiemann November 2, 2016 Outline 1 Syntax Analysis Recursive top-down parsing Nonrecursive top-down parsing Bottom-up parsing Syntax Analysis tokens

More information

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology exam Compiler Construction in4020 July 5, 2007 14.00-15.30 This exam (8 pages) consists of 60 True/False

More information

Context-Free Languages & Grammars (CFLs & CFGs) Reading: Chapter 5

Context-Free Languages & Grammars (CFLs & CFGs) Reading: Chapter 5 Context-Free Languages & Grammars (CFLs & CFGs) Reading: Chapter 5 1 Not all languages are regular So what happens to the languages which are not regular? Can we still come up with a language recognizer?

More information

Flat (Draft) Pasqualino Titto Assini 27 th of May 2016

Flat (Draft) Pasqualino Titto Assini 27 th of May 2016 Flat (Draft) Pasqualino Titto Assini (tittoassini@gmail.com) 27 th of May 206 Contents What is Flat?...................................... Design Goals...................................... Design Non-Goals...................................

More information

Context-free grammars

Context-free grammars Context-free grammars Section 4.2 Formal way of specifying rules about the structure/syntax of a program terminals - tokens non-terminals - represent higher-level structures of a program start symbol,

More information

SEMANTIC ANALYSIS TYPES AND DECLARATIONS

SEMANTIC ANALYSIS TYPES AND DECLARATIONS SEMANTIC ANALYSIS CS 403: Type Checking Stefan D. Bruda Winter 2015 Parsing only verifies that the program consists of tokens arranged in a syntactically valid combination now we move to check whether

More information

Turing Machines. A transducer is a finite state machine (FST) whose output is a string and not just accept or reject.

Turing Machines. A transducer is a finite state machine (FST) whose output is a string and not just accept or reject. Turing Machines Transducers: A transducer is a finite state machine (FST) whose output is a string and not just accept or reject. Each transition of an FST is labeled with two symbols, one designating

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

Eliminating the Storage Tape in Reachability Constructions

Eliminating the Storage Tape in Reachability Constructions Eliminating the Storage Tape in Reachability Constructions Oscar H. Ibarra Department of Computer Science University of California Santa Barbara, CA 93106, USA Zhe Dang School of Electrical Engineering

More information

Compiler construction in4303 lecture 3

Compiler construction in4303 lecture 3 Compiler construction in4303 lecture 3 Top-down parsing Chapter 2.2-2.2.4 Overview syntax analysis: tokens AST program text lexical analysis language grammar parser generator tokens syntax analysis AST

More information

T Reactive Systems: Kripke Structures and Automata

T Reactive Systems: Kripke Structures and Automata Tik-79.186 Reactive Systems 1 T-79.186 Reactive Systems: Kripke Structures and Automata Spring 2005, Lecture 3 January 31, 2005 Tik-79.186 Reactive Systems 2 Properties of systems invariants: the system

More information

Part I: Multiple Choice Questions (40 points)

Part I: Multiple Choice Questions (40 points) Preparatory Course Grammars and Parsing Friday, November 11, 2005 (9:00-12:00 This exam consists of 10 multiple-choice questions (Part I and 3 open questions (Part II. The maximum number of points for

More information

Glynda, the good witch of the North

Glynda, the good witch of the North Strings and Languages It is always best to start at the beginning -- Glynda, the good witch of the North What is a Language? A language is a set of strings made of of symbols from a given alphabet. An

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

Theory of Computation

Theory of Computation Theory of Computation For Computer Science & Information Technology By www.thegateacademy.com Syllabus Syllabus for Theory of Computation Regular Expressions and Finite Automata, Context-Free Grammar s

More information

How do LL(1) Parsers Build Syntax Trees?

How do LL(1) Parsers Build Syntax Trees? How do LL(1) Parsers Build Syntax Trees? So far our LL(1) parser has acted like a recognizer. It verifies that input token are syntactically correct, but it produces no output. Building complete (concrete)

More information

Introduction to Computers & Programming

Introduction to Computers & Programming 16.070 Introduction to Computers & Programming Theory of computation 5: Reducibility, Turing machines Prof. Kristina Lundqvist Dept. of Aero/Astro, MIT States and transition function State control A finite

More information

Actually talking about Turing machines this time

Actually talking about Turing machines this time Actually talking about Turing machines this time 10/25/17 (Using slides adapted from the book) Administrivia HW due now (Pumping lemma for context-free languages) HW due Friday (Building TMs) Exam 2 out

More information

Compiler construction lecture 3

Compiler construction lecture 3 Compiler construction in4303 lecture 3 Top-down parsing Chapter 2.2-2.2.4 Overview syntax analysis: tokens AST language grammar parser generator program text lexical analysis tokens syntax analysis AST

More information

The Parallelization of Binary Decision Diagram operations for model checking

The Parallelization of Binary Decision Diagram operations for model checking The Parallelization of Binary Decision Diagram operations for model checking Tom van Dijk 24 April 2012 Master s thesis Department of Computer Science Graduation committee: Prof.dr. J.C. van de Pol Dr.

More information

Overview. Discrete Event Systems - Verification of Finite Automata. What can finite automata be used for? What can finite automata be used for?

Overview. Discrete Event Systems - Verification of Finite Automata. What can finite automata be used for? What can finite automata be used for? Computer Engineering and Networks Overview Discrete Event Systems - Verification of Finite Automata Lothar Thiele Introduction Binary Decision Diagrams Representation of Boolean Functions Comparing two

More information

Lexical Analysis. Introduction

Lexical Analysis. Introduction Lexical Analysis Introduction Copyright 2015, Pedro C. Diniz, all rights reserved. Students enrolled in the Compilers class at the University of Southern California have explicit permission to make copies

More information

TAFL 1 (ECS-403) Unit- V. 5.1 Turing Machine. 5.2 TM as computer of Integer Function

TAFL 1 (ECS-403) Unit- V. 5.1 Turing Machine. 5.2 TM as computer of Integer Function TAFL 1 (ECS-403) Unit- V 5.1 Turing Machine 5.2 TM as computer of Integer Function 5.2.1 Simulating Turing Machine by Computer 5.2.2 Simulating Computer by Turing Machine 5.3 Universal Turing Machine 5.4

More information

Lecture Notes on Ints

Lecture Notes on Ints Lecture Notes on Ints 15-122: Principles of Imperative Computation Frank Pfenning Lecture 2 August 26, 2010 1 Introduction Two fundamental types in almost any programming language are booleans and integers.

More information

Timed Automata From Theory to Implementation

Timed Automata From Theory to Implementation Timed Automata From Theory to Implementation Patricia Bouyer LSV CNRS & ENS de Cachan France Chennai january 2003 Timed Automata From Theory to Implementation p.1 Roadmap Timed automata, decidability issues

More information

From OCL to Propositional and First-order Logic: Part I

From OCL to Propositional and First-order Logic: Part I 22c181: Formal Methods in Software Engineering The University of Iowa Spring 2008 From OCL to Propositional and First-order Logic: Part I Copyright 2007-8 Reiner Hähnle and Cesare Tinelli. Notes originally

More information

Proof Pearl: The Termination Method of TERMINATOR

Proof Pearl: The Termination Method of TERMINATOR Proof Pearl: The Termination Method of TERMINATOR Joe Hurd Computing Laboratory University of Oxford University of Edinburgh Thursday 9 August 2007 Joe Hurd Proof Pearl: The Termination Method of TERMINATOR

More information

Talen en Compilers. Jurriaan Hage , period 2. November 13, Department of Information and Computing Sciences Utrecht University

Talen en Compilers. Jurriaan Hage , period 2. November 13, Department of Information and Computing Sciences Utrecht University Talen en Compilers 2017-2018, period 2 Jurriaan Hage Department of Information and Computing Sciences Utrecht University November 13, 2017 1. Introduction 1-1 This lecture Introduction Course overview

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

Reducing Concurrent Analysis Under a Context Bound to Sequential Analysis

Reducing Concurrent Analysis Under a Context Bound to Sequential Analysis Noname manuscript No. (will be inserted by the editor) Reducing Concurrent Analysis Under a Context Bound to Sequential Analysis Akash Lal Thomas Reps the date of receipt and acceptance should be inserted

More information

Abstract Syntax Trees & Top-Down Parsing

Abstract Syntax Trees & Top-Down Parsing Review of Parsing Abstract Syntax Trees & Top-Down Parsing Given a language L(G), a parser consumes a sequence of tokens s and produces a parse tree Issues: How do we recognize that s L(G)? A parse tree

More information

Lecture #13: Type Inference and Unification. Typing In the Language ML. Type Inference. Doing Type Inference

Lecture #13: Type Inference and Unification. Typing In the Language ML. Type Inference. Doing Type Inference Lecture #13: Type Inference and Unification Typing In the Language ML Examples from the language ML: fun map f [] = [] map f (a :: y) = (f a) :: (map f y) fun reduce f init [] = init reduce f init (a ::

More information

Compiler Design Concepts. Syntax Analysis

Compiler Design Concepts. Syntax Analysis Compiler Design Concepts Syntax Analysis Introduction First task is to break up the text into meaningful words called tokens. newval=oldval+12 id = id + num Token Stream Lexical Analysis Source Code (High

More information

Mosig M1 - PLSCD Written exam

Mosig M1 - PLSCD Written exam Mosig M1 - PLSCD 0809 - Written exam 1 Exercise I : Operational semantics - a debugger In this exercise we consider program execution with the help of a debugger. This execution will be defined on an intermediate

More information