Semantic Analysis. CSCI 3136 Principles of Programming Languages. Faculty of Computer Science Dalhousie University. Winter Reading: Chapter 4

Save this PDF as:
 WORD  PNG  TXT  JPG

Size: px
Start display at page:

Download "Semantic Analysis. CSCI 3136 Principles of Programming Languages. Faculty of Computer Science Dalhousie University. Winter Reading: Chapter 4"

Transcription

1 Semnti nlysis SI 16 Priniples of Progrmming Lnguges Fulty of omputer Siene Dlhousie University Winter 2012 Reding: hpter 4

2 Motivtion Soure progrm (hrter strem) Snner (lexil nlysis) Front end Prse tree Prser (syntti nlysis) Token strem k end Modified intermedite form Modified trget lnguge Semnti nlysis nd ode genertion Mhine-independent ode improvement Trget ode genertion Mhine-speifi ode improvement strt syntx tree or other intermedite form Trget lnguge (e.g., ssemly) Symol tle Semnti nlysis

3 Syntx nd Semntis Syntx Desries form of vlid progrm n e desried y ontext-free grmmr Semntis Desries mening of progrm nnot e e desried y ontext-free grmmr Some onstrints tht my pper syntti re enfored y semnti nlysis: E.g., use of identifier only fter its delrtion Semnti nlysis

4 Semnti nlysis Enfores semnti rules uilds intermedite representtion (e.g., strt syntx tree) Fills symol tle Psses results to intermedite ode genertor Two pprohes Interleved with syntti nlysis s seprte phse Forml mehnism: ttriutes grmmrs Semnti nlysis

5 Enforing Semnti Rules Stti semnti rules Enfored y ompiler t ompile time Exmple: Do not use undelred vrile Dynmi semnti rules ompiler genertes ode for enforement t run time Exmples: division y zero, rry index out of ounds Some ompilers llow these heks to e disled Semnti nlysis

6 ttriute Grmmrs n ttriute grmmr is n ugmented ontext-free grmmr: Eh symol in prodution hs numer of ttriutes. Eh prodution is ugmented with semnti rules tht opy ttriute vlues etween symols, Evlute ttriute vlues using semnti funtions, Enfore onstrints on ttriute vlues. Semnti nlysis

7 ttriute Grmmrs: Exmple E E + T E E - T E T T T * F T T / F T F F -F F ( E ) F onst Semnti nlysis

8 ttriute Grmmrs: Exmple E E + T E E - T E T T T * F T T / F T F F -F F ( E ) E 1 E 2 + T E 1 E 2 - T E T T 1 T 2 * F T 1 T 2 / F T F F 1 -F 2 F ( E ) F onst F onst E 1.vl := sum(e 2.vl, T.vl) E 1.vl := differene(e 2.vl, T.vl) E.vl := T.vl T 1.vl := produt(t 2.vl, F.vl) T 1.vl := quotient(t 2.vl, F.vl) T.vl := F.vl F 1.vl := negte(f 2.vl) F.vl := E.vl F.vl := onst.vl Semnti nlysis

9 Synthesized ttriutes (ottom-up) The lnguge { n n n n 1} = {,,,... } is not ontext-free ut n e reognized y n ttriute grmmr. Synthesized ttriutes: ttriutes of LHS re omputed from ttriutes of RHS. S ondition:.ount =.ount =.ount.ount := ount := 2.ount + 1.ount := ount := 2.ount + 1.ount := ount := 2.ount + 1 Semnti nlysis

10 Synthesized ttriutes: Prse Tree Deortion (1) Input: Prse tree S Semnti nlysis

11 Synthesized ttriutes: Prse Tree Deortion (1) Input: Prse tree S = = Semnti nlysis

12 Synthesized ttriutes: Prse Tree Deortion (2) Input: Prse tree S Semnti nlysis

13 Synthesized ttriutes: Prse Tree Deortion (2) Input: Prse tree S Semnti nlysis

14 Inherited ttriutes (Top-Down) Inherited ttriutes: ttriutes flow from left to right (from LHS to RHS nd from symols of RHS to symols of RHS further to the right). S.inhount :=.ount;.inhount :=.ount.ount := ount := 2.ount + 1 ondition:.inhount = inhount := 1.inhount 1 ondition:.inhount := inhount := 1.inhount 1 Semnti nlysis

15 Inherited ttriutes: Prse Tree Deortion (1) Input: Prse tree S Semnti nlysis

16 Inherited ttriutes: Prse Tree Deortion (1) Input: Prse tree S = 1 1 = 1 Semnti nlysis

17 Inherited ttriutes: Prse Tree Deortion (2) Input: Prse tree S Semnti nlysis

18 Inherited ttriutes: Prse Tree Deortion (2) Input: Prse tree S = 1 Semnti nlysis

19 ttriute Flow nnottion or deortion of prse tree Proess of evluting ttriutes Synthesized ttriutes ttriutes of LHS of prodution re omputed from ttriutes of the symols in its RHS. ttriutes flow ottom-up in the prse tree. Inherited ttriutes ttriutes for symols in RHS re omputed from ttriutes of LHS nd symols in RHS preeding them. ttriutes flow top-down in the prse tree. Semnti nlysis

20 S-ttriuted nd L-ttriuted Grmmrs S-ttriuted grmmr ll ttriutes re synthesized. ttriutes flow ottom-up. L-ttriuted grmmr For eh prodution X Y 1 Y 2... Y k, X.syn depends on X.inh nd Y 1.inh, Y 1.syn, Y 2.inh, Y 2.syn,..., Y k.inh, Y k.syn. For ll 1 i k, Y i.inh depends on X.inh nd Y 1.inh, Y 1.syn, Y 2.inh, Y 2.syn,..., Y i 1.inh, Y i 1.syn. S-ttriuted grmmrs re speil se of L-ttriuted grmmrs. Semnti nlysis

21 LL(1) Prsing, Left-ssoitivity, nd L-ttriuted Grmmrs simple grmmr for rithmeti expressions using only ddition nd sutrtion = (10 ) + 5 = ( + 5) = 2 Semnti nlysis

22 LL(1) Prsing, Left-ssoitivity, nd L-ttriuted Grmmrs simple grmmr for rithmeti expressions using only ddition nd sutrtion E T E ET = (10 ) + 5 = ( + 5) = 2 T n + - E E T E T + 5 T - 10 Semnti nlysis

23 LL(1) Prsing, Left-ssoitivity, nd L-ttriuted Grmmrs simple grmmr for rithmeti expressions using only ddition nd sutrtion E T E ET = (10 ) + 5 = ( + 5) = 2 T n + - E E T E T + 5 T - 10 This grmmr ptures left-ssoitivity. Semnti nlysis

24 LL(1) Prsing, Left-ssoitivity, nd L-ttriuted Grmmrs simple grmmr for rithmeti expressions using only ddition nd sutrtion E T E ET = (10 ) + 5 = ( + 5) = 2 T n + - E 7 E 12 dd T 5 E 10 su T T This grmmr ptures left-ssoitivity. Semnti nlysis

25 LL(1) Prsing, Left-ssoitivity, nd L-ttriuted Grmmrs simple grmmr for rithmeti expressions using only ddition nd sutrtion E T E ET = (10 ) + 5 = ( + 5) = 2 T n + - E 7 E 12 dd T 5 Rule R PREDIT(R) E T su T E T E ET T n + - {n} {n} {n} {+} {-} This grmmr ptures left-ssoitivity. It is not LL(1). Semnti nlysis

26 LL(1) Prsing, Left-ssoitivity, nd L-ttriuted Grmmrs n LL(1) grmmr for the sme lnguge E T E $ E ɛ E 1 T E 2 T n + - Rule R E T E $ {n} E 2.op :=.fun(e E 1.op, T.vl); ɛ E 1.vl {$} := E 2.vl E T E {+,-} T n + - PREDIT(R) {n} {+} {-} Semnti nlysis

27 LL(1) Prsing, Left-ssoitivity, nd L-ttriuted Grmmrs n LL(1) grmmr for the sme lnguge E T E $ E ɛ E 1 T E 2 T n + - Rule R E T E $ {n} E 2.op :=.fun(e E 1.op, T.vl); ɛ E 1.vl {$} := E 2.vl E T E {+,-} T n + - PREDIT(R) {n} {+} {-} E T E $ 10 T E - T E + 5 ɛ Semnti nlysis

28 LL(1) Prsing, Left-ssoitivity, nd L-ttriuted Grmmrs n LL(1) grmmr for the sme lnguge E T E $ E ɛ E 1 T E 2 T n + - E.op := T.vl; E.vl := E.vl E.vl := E.op E 2.op :=.fun(e 1.op, T.vl); E 1.vl := E 2.vl T.vl := n.vl.fun := dd.fun := su E T E $ su T 7 E 12 - dd T 5 12 E ɛ Semnti nlysis

29 tion Routines tion routines re instrutions for d-ho trnsltion interleved with prsing. Prser genertors llow progrmmers to speify tion routines in the grmmr. tion routines n pper nywhere in rule (s long s the grmmr is LL(1)). Exmple E 1 T { E 2.op =.fun(e 1.op, T.vl) } E 2 { E 1.vl = E 2.vl } tion routines re supported, for exmple, in y nd ison. Semnti nlysis

CS241 Week 6 Tutorial Solutions

CS241 Week 6 Tutorial Solutions 241 Week 6 Tutoril olutions Lnguges: nning & ontext-free Grmmrs Winter 2018 1 nning Exerises 1. 0x0x0xd HEXINT 0x0 I x0xd 2. 0xend--- HEXINT 0xe I nd ER -- MINU - 3. 1234-120x INT 1234 INT -120 I x 4.

More information

Overview HC9. Parsing: Top-Down & LL(1) Context-Free Grammars (1) Introduction. CFGs (3) Context-Free Grammars (2) Vertalerbouw HC 9: Ch.

Overview HC9. Parsing: Top-Down & LL(1) Context-Free Grammars (1) Introduction. CFGs (3) Context-Free Grammars (2) Vertalerbouw HC 9: Ch. Overview H9 Vertlerouw H 9: Prsing: op-down & LL(1) do 3 mei 2001 56 heo Ruys h. 8 - Prsing 8.1 ontext-free Grmmrs 8.2 op-down Prsing 8.3 LL(1) Grmmrs See lso [ho, Sethi & Ullmn 1986] for more thorough

More information

Bottom-Up Parsing. Canonical Collection of LR(0) items. Part II

Bottom-Up Parsing. Canonical Collection of LR(0) items. Part II 2 ottom-up Prsing Prt II 1 Cnonil Colletion of LR(0) items CC_LR(0)_I items(g :ugmented_grmmr){ C = {CLOURE({ })} ; repet{ foreh(i C) foreh(grmmr symol X) if(goto(i,x) && GOTO(I,X) C) C = C {GOTO(I,X)};

More information

Normal Forms for Context-free Grammars

Normal Forms for Context-free Grammars Norml Forms for Context-free Grmmrs 1 Linz 6th, Section 6.2 wo Importnt Norml Forms, pges 171--178 2 Chomsky Norml Form All productions hve form: A BC nd A vrile vrile terminl 3 Exmples: S AS S AS S S

More information

The transformation to right derivation is called the canonical reduction sequence. Bottom-up analysis

The transformation to right derivation is called the canonical reduction sequence. Bottom-up analysis Bottom-up nlysis Shift-reduce prsing. Constructs the derivtion tree from ottom to top. Reduces the string to the strt symol. Produces reverse right derivtion. Exmple: G(E): 1. E E + T 2. T 3. T T * F 4.

More information

Nondeterministic Finite Automata

Nondeterministic Finite Automata Nondeterministi Finite utomt The Power of Guessing Tuesdy, Otoer 4, 2 Reding: Sipser.2 (first prt); Stoughton 3.3 3.5 S235 Lnguges nd utomt eprtment of omputer Siene Wellesley ollege Finite utomton (F)

More information

Prefix-Free Regular-Expression Matching

Prefix-Free Regular-Expression Matching Prefix-Free Regulr-Expression Mthing Yo-Su Hn, Yjun Wng nd Derik Wood Deprtment of Computer Siene HKUST Prefix-Free Regulr-Expression Mthing p.1/15 Pttern Mthing Given pttern P nd text T, find ll sustrings

More information

Homework 3 Solutions

Homework 3 Solutions CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 3 Solutions 1. Give NFAs with the specified numer of sttes recognizing ech of the following lnguges. In ll cses, the lphet is Σ = {,1}.

More information

Pre-Lie algebras, rooted trees and related algebraic structures

Pre-Lie algebras, rooted trees and related algebraic structures Pre-Lie lgers, rooted trees nd relted lgeri strutures Mrh 23, 2004 Definition 1 A pre-lie lger is vetor spe W with mp : W W W suh tht (x y) z x (y z) = (x z) y x (z y). (1) Exmple 2 All ssoitive lgers

More information

Project 6: Minigoals Towards Simplifying and Rewriting Expressions

Project 6: Minigoals Towards Simplifying and Rewriting Expressions MAT 51 Wldis Projet 6: Minigols Towrds Simplifying nd Rewriting Expressions The distriutive property nd like terms You hve proly lerned in previous lsses out dding like terms ut one prolem with the wy

More information

Matrices SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics (c) 1. Definition of a Matrix

Matrices SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics (c) 1. Definition of a Matrix tries Definition of tri mtri is regulr rry of numers enlosed inside rkets SCHOOL OF ENGINEERING & UIL ENVIRONEN Emple he following re ll mtries: ), ) 9, themtis ), d) tries Definition of tri Size of tri

More information

Chapter 4 Regular Grammar and Regular Sets. (Solutions / Hints)

Chapter 4 Regular Grammar and Regular Sets. (Solutions / Hints) C K Ngpl Forml Lnguges nd utomt Theory Chpter 4 Regulr Grmmr nd Regulr ets (olutions / Hints) ol. (),,,,,,,,,,,,,,,,,,,,,,,,,, (),, (c) c c, c c, c, c, c c, c, c, c, c, c, c, c c,c, c, c, c, c, c, c, c,

More information

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University CS415 Compilers Lexicl Anlysis nd These slides re sed on slides copyrighted y Keith Cooper, Ken Kennedy & Lind Torczon t Rice University First Progrmming Project Instruction Scheduling Project hs een posted

More information

Convert the NFA into DFA

Convert the NFA into DFA Convert the NF into F For ech NF we cn find F ccepting the sme lnguge. The numer of sttes of the F could e exponentil in the numer of sttes of the NF, ut in prctice this worst cse occurs rrely. lgorithm:

More information

ILLUSTRATING THE EXTENSION OF A SPECIAL PROPERTY OF CUBIC POLYNOMIALS TO NTH DEGREE POLYNOMIALS

ILLUSTRATING THE EXTENSION OF A SPECIAL PROPERTY OF CUBIC POLYNOMIALS TO NTH DEGREE POLYNOMIALS ILLUSTRATING THE EXTENSION OF A SPECIAL PROPERTY OF CUBIC POLYNOMIALS TO NTH DEGREE POLYNOMIALS Dvid Miller West Virgini University P.O. BOX 6310 30 Armstrong Hll Morgntown, WV 6506 millerd@mth.wvu.edu

More information

= state, a = reading and q j

= state, a = reading and q j 4 Finite Automt CHAPTER 2 Finite Automt (FA) (i) Derterministi Finite Automt (DFA) A DFA, M Q, q,, F, Where, Q = set of sttes (finite) q Q = the strt/initil stte = input lphet (finite) (use only those

More information

Refined interfaces for compositional verification

Refined interfaces for compositional verification Refined interfces for compositionl verifiction Frédéric Lng INRI Rhône-lpes http://www.inrilpes.fr/vsy Motivtion Enumertive verifiction of concurrent systems Prllel composition of synchronous processes

More information

Cyclic Inputs. Surface Generation (Part II) Ambiguity-preserving Generation. Ambiguity-preserving Generation. Ambiguity-preserving Generation

Cyclic Inputs. Surface Generation (Part II) Ambiguity-preserving Generation. Ambiguity-preserving Generation. Ambiguity-preserving Generation Cyli Inputs The set of strings tht grmmr reltes to yli input struture might e non-ontext-free Surfe Genertion (Prt II) Amiguity-preserving Genertion Amiguity-preserving Genertion Motivtion Motivtion ()

More information

CS 330 Formal Methods and Models

CS 330 Formal Methods and Models CS 0 Forml Methods nd Models Dn Richrds, George Mson University, Fll 2016 Quiz Solutions Quiz 1, Propositionl Logic Dte: Septemer 8 1. Prove q (q p) p q p () (4pts) with truth tle. p q p q p (q p) p q

More information

CS 330 Formal Methods and Models

CS 330 Formal Methods and Models CS 330 Forml Methods nd Models Dn Richrds, section 003, George Mson University, Fll 2017 Quiz Solutions Quiz 1, Propositionl Logic Dte: Septemer 7 1. Prove (p q) (p q), () (5pts) using truth tles. p q

More information

3 Regular expressions

3 Regular expressions 3 Regulr expressions Given n lphet Σ lnguge is set of words L Σ. So fr we were le to descrie lnguges either y using set theory (i.e. enumertion or comprehension) or y n utomton. In this section we shll

More information

CHAPTER 1 Regular Languages. Contents

CHAPTER 1 Regular Languages. Contents Finite Automt (FA or DFA) CHAPTE 1 egulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, euivlence of NFAs nd DFAs, closure under regulr

More information

NON-DETERMINISTIC FSA

NON-DETERMINISTIC FSA Tw o types of non-determinism: NON-DETERMINISTIC FS () Multiple strt-sttes; strt-sttes S Q. The lnguge L(M) ={x:x tkes M from some strt-stte to some finl-stte nd ll of x is proessed}. The string x = is

More information

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS CS 310 (sec 20) - Winter 2003 - Finl Exm (solutions) SOLUTIONS 1. (Logic) Use truth tles to prove the following logicl equivlences: () p q (p p) (q q) () p q (p q) (p q) () p q p q p p q q (q q) (p p)

More information

Chapter 4 State-Space Planning

Chapter 4 State-Space Planning Leture slides for Automted Plnning: Theory nd Prtie Chpter 4 Stte-Spe Plnning Dn S. Nu CMSC 722, AI Plnning University of Mrylnd, Spring 2008 1 Motivtion Nerly ll plnning proedures re serh proedures Different

More information

A Functorial Query Language

A Functorial Query Language A Funtoril Query Lnguge Ryn Wisnesky, Dvid Spivk Deprtment of Mthemtis Msshusetts Institute of Tehnology {wisnesky, dspivk}@mth.mit.edu Presented t Boston Hskell April 16, 2014 Outline Introdution to FQL.

More information

Automatic Verification of Pointer Programs Using Grammar-Based Shape Analysis

Automatic Verification of Pointer Programs Using Grammar-Based Shape Analysis Automti Verifition of Pointer Progrms Using Grmmr-Bsed Shpe Anlysis Oukseh Lee 1, Hongseok Yng 2, nd Kwngkeun Yi 3 1 Dept. of Computer Siene & Engineering, Hnyng University, Kore 2 ERC-ACI, Seoul Ntionl

More information

Learning Goals. Relational Query Languages. Formal Relational Query Languages. Formal Query Languages: Relational Algebra and Relational Calculus

Learning Goals. Relational Query Languages. Formal Relational Query Languages. Formal Query Languages: Relational Algebra and Relational Calculus Forml Query Lnguges: Reltionl Alger nd Reltionl Clculus Chpter 4 Lerning Gols Given dtse ( set of tles ) you will e le to express dtse query in Reltionl Alger (RA), involving the sic opertors (selection,

More information

Numbers and indices. 1.1 Fractions. GCSE C Example 1. Handy hint. Key point

Numbers and indices. 1.1 Fractions. GCSE C Example 1. Handy hint. Key point GCSE C Emple 7 Work out 9 Give your nswer in its simplest form Numers n inies Reiprote mens invert or turn upsie own The reiprol of is 9 9 Mke sure you only invert the frtion you re iviing y 7 You multiply

More information

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages 5//6 Grmmr Automt nd Lnguges Regulr Grmmr Context-free Grmmr Context-sensitive Grmmr Prof. Mohmed Hmd Softwre Engineering L. The University of Aizu Jpn Regulr Lnguges Context Free Lnguges Context Sensitive

More information

Reasoning and programming. Lecture 5: Invariants and Logic. Boolean expressions. Reasoning. Examples

Reasoning and programming. Lecture 5: Invariants and Logic. Boolean expressions. Reasoning. Examples Chir of Softwre Engineering Resoning nd progrmming Einführung in die Progrmmierung Introduction to Progrmming Prof. Dr. Bertrnd Meyer Octoer 2006 Ferury 2007 Lecture 5: Invrints nd Logic Logic is the sis

More information

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont. NFA DFA Exmple 3 CMSC 330: Orgniztion of Progrmming Lnguges NFA {B,D,E {A,E {C,D {E Finite Automt, con't. R = { {A,E, {B,D,E, {C,D, {E 2 Equivlence of DFAs nd NFAs Any string from {A to either {D or {CD

More information

INTRODUCTION TO AUTOMATA THEORY

INTRODUCTION TO AUTOMATA THEORY Chpter 3 INTRODUCTION TO AUTOMATA THEORY In this hpter we stuy the most si strt moel of omputtion. This moel els with mhines tht hve finite memory pity. Setion 3. els with mhines tht operte eterministilly

More information

Automata and Regular Languages

Automata and Regular Languages Chpter 9 Automt n Regulr Lnguges 9. Introution This hpter looks t mthemtil moels of omputtion n lnguges tht esrie them. The moel-lnguge reltionship hs multiple levels. We shll explore the simplest level,

More information

Context-Free Grammars and Languages

Context-Free Grammars and Languages Context-Free Grmmrs nd Lnguges (Bsed on Hopcroft, Motwni nd Ullmn (2007) & Cohen (1997)) Introduction Consider n exmple sentence: A smll ct ets the fish English grmmr hs rules for constructing sentences;

More information

Lexical Analysis Finite Automate

Lexical Analysis Finite Automate Lexicl Anlysis Finite Automte CMPSC 470 Lecture 04 Topics: Deterministic Finite Automt (DFA) Nondeterministic Finite Automt (NFA) Regulr Expression NFA DFA A. Finite Automt (FA) FA re grph, like trnsition

More information

STRAND J: TRANSFORMATIONS, VECTORS and MATRICES

STRAND J: TRANSFORMATIONS, VECTORS and MATRICES Mthemtics SKE: STRN J STRN J: TRNSFORMTIONS, VETORS nd MTRIES J3 Vectors Text ontents Section J3.1 Vectors nd Sclrs * J3. Vectors nd Geometry Mthemtics SKE: STRN J J3 Vectors J3.1 Vectors nd Sclrs Vectors

More information

Chapter 9 Definite Integrals

Chapter 9 Definite Integrals Chpter 9 Definite Integrls In the previous chpter we found how to tke n ntiderivtive nd investigted the indefinite integrl. In this chpter the connection etween ntiderivtives nd definite integrls is estlished

More information

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb. CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

More information

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2 CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

More information

Resources. Introduction: Binding. Resource Types. Resource Sharing. The type of a resource denotes its ability to perform different operations

Resources. Introduction: Binding. Resource Types. Resource Sharing. The type of a resource denotes its ability to perform different operations Introduction: Binding Prt of 4-lecture introduction Scheduling Resource inding Are nd performnce estimtion Control unit synthesis This lecture covers Resources nd resource types Resource shring nd inding

More information

Software Engineering using Formal Methods

Software Engineering using Formal Methods Softwre Engineering using Forml Methods Propositionl nd (Liner) Temporl Logic Wolfgng Ahrendt 13th Septemer 2016 SEFM: Liner Temporl Logic /GU 160913 1 / 60 Recpitultion: FormlistionFormlistion: Syntx,

More information

Formal languages, automata, and theory of computation

Formal languages, automata, and theory of computation Mälrdlen University TEN1 DVA337 2015 School of Innovtion, Design nd Engineering Forml lnguges, utomt, nd theory of computtion Thursdy, Novemer 5, 14:10-18:30 Techer: Dniel Hedin, phone 021-107052 The exm

More information

6.5 Improper integrals

6.5 Improper integrals Eerpt from "Clulus" 3 AoPS In. www.rtofprolemsolving.om 6.5. IMPROPER INTEGRALS 6.5 Improper integrls As we ve seen, we use the definite integrl R f to ompute the re of the region under the grph of y =

More information

Semantics of RTL and Validation of Synthesized RTL Designs using Formal Verification in Reconfigurable Computing Systems

Semantics of RTL and Validation of Synthesized RTL Designs using Formal Verification in Reconfigurable Computing Systems emntis of TL nd Vlidtion of ynthesized TL Designs using Forml Verifition in eonfigurle Computing ystems Phn C. Vinh nd Jonthn P. Bowen London outh Bnk University Centre for Applied Forml Methods, Institute

More information

The DOACROSS statement

The DOACROSS statement The DOACROSS sttement Is prllel loop similr to DOALL, ut it llows prouer-onsumer type of synhroniztion. Synhroniztion is llowe from lower to higher itertions sine it is ssume tht lower itertions re selete

More information

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018 CS 301 Lecture 04 Regulr Expressions Stephen Checkowy Jnury 29, 2018 1 / 35 Review from lst time NFA N = (Q, Σ, δ, q 0, F ) where δ Q Σ P (Q) mps stte nd n lphet symol (or ) to set of sttes We run n NFA

More information

1 Nondeterministic Finite Automata

1 Nondeterministic Finite Automata 1 Nondeterministic Finite Automt Suppose in life, whenever you hd choice, you could try oth possiilities nd live your life. At the end, you would go ck nd choose the one tht worked out the est. Then you

More information

Automatic Synthesis of New Behaviors from a Library of Available Behaviors

Automatic Synthesis of New Behaviors from a Library of Available Behaviors Automti Synthesis of New Behviors from Lirry of Aville Behviors Giuseppe De Giomo Università di Rom L Spienz, Rom, Itly degiomo@dis.unirom1.it Sestin Srdin RMIT University, Melourne, Austrli ssrdin@s.rmit.edu.u

More information

a b b a pop push read unread

a b b a pop push read unread A Finite Automton A Pushdown Automton 0000 000 red unred b b pop red unred push 2 An Exmple A Pushdown Automton Recll tht 0 n n not regulr. cn push symbols onto the stck cn pop them (red them bck) lter

More information

Functions. mjarrar Watch this lecture and download the slides

Functions. mjarrar Watch this lecture and download the slides 9/6/7 Mustf Jrrr: Leture Notes in Disrete Mthemtis. Birzeit University Plestine 05 Funtions 7.. Introdution to Funtions 7. One-to-One Onto Inverse funtions mjrrr 05 Wth this leture nd downlod the slides

More information

Precise and Efficient FIFO-Replacement Analysis Based on Static Phase Detection

Precise and Efficient FIFO-Replacement Analysis Based on Static Phase Detection Preise nd Effiient FIFO-Replement Anlysis Bsed on Stti Phse Detetion Dniel Grund Srlnd University, Srrüken, Germny Jn Reineke Srlnd University, Srrüken, Germny University of Cliforni, Berkeley, USA Astrt

More information

CS 267: Automated Verification. Lecture 8: Automata Theoretic Model Checking. Instructor: Tevfik Bultan

CS 267: Automated Verification. Lecture 8: Automata Theoretic Model Checking. Instructor: Tevfik Bultan CS 267: Automted Verifiction Lecture 8: Automt Theoretic Model Checking Instructor: Tevfik Bultn LTL Properties Büchi utomt [Vrdi nd Wolper LICS 86] Büchi utomt: Finite stte utomt tht ccept infinite strings

More information

CS375: Logic and Theory of Computing

CS375: Logic and Theory of Computing CS375: Logic nd Theory of Computing Fuhu (Frnk) Cheng Deprtment of Computer Science University of Kentucky 1 Tle of Contents: Week 1: Preliminries (set lger, reltions, functions) (red Chpters 1-4) Weeks

More information

for all x in [a,b], then the area of the region bounded by the graphs of f and g and the vertical lines x = a and x = b is b [ ( ) ( )] A= f x g x dx

for all x in [a,b], then the area of the region bounded by the graphs of f and g and the vertical lines x = a and x = b is b [ ( ) ( )] A= f x g x dx Applitions of Integrtion Are of Region Between Two Curves Ojetive: Fin the re of region etween two urves using integrtion. Fin the re of region etween interseting urves using integrtion. Desrie integrtion

More information

Previously on GLT. Basic technologies. Lexical analysis. Basic technologies ASF+SDF. Concepts of programming languages

Previously on GLT. Basic technologies. Lexical analysis. Basic technologies ASF+SDF. Concepts of programming languages Prevously on GLT Generc Lnguge Technology: Bsc technologes Pro.dr. Mrk vn den Brnd ASF+SDF syntx descrptons semntc descrptons: type checkng nlyss trnsormtons t so to s Concepts o progrmmng lnguges syntctc

More information

Geometry of the Circle - Chords and Angles. Geometry of the Circle. Chord and Angles. Curriculum Ready ACMMG: 272.

Geometry of the Circle - Chords and Angles. Geometry of the Circle. Chord and Angles. Curriculum Ready ACMMG: 272. Geometry of the irle - hords nd ngles Geometry of the irle hord nd ngles urriulum Redy MMG: 272 www.mthletis.om hords nd ngles HRS N NGLES The irle is si shpe nd so it n e found lmost nywhere. This setion

More information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Finite Automt Theory nd Forml Lnguges TMV027/DIT321 LP4 2018 Lecture 10 An Bove April 23rd 2018 Recp: Regulr Lnguges We cn convert between FA nd RE; Hence both FA nd RE ccept/generte regulr lnguges; More

More information

CS12N: The Coming Revolution in Computer Architecture Laboratory 2 Preparation

CS12N: The Coming Revolution in Computer Architecture Laboratory 2 Preparation CS2N: The Coming Revolution in Computer Architecture Lortory 2 Preprtion Ojectives:. Understnd the principle of sttic CMOS gte circuits 2. Build simple logic gtes from MOS trnsistors 3. Evlute these gtes

More information

8 factors of x. For our second example, let s raise a power to a power:

8 factors of x. For our second example, let s raise a power to a power: CH 5 THE FIVE LAWS OF EXPONENTS EXPONENTS WITH VARIABLES It s no time for chnge in tctics, in order to give us deeper understnding of eponents. For ech of the folloing five emples, e ill stretch nd squish,

More information

Data Structures LECTURE 10. Huffman coding. Example. Coding: problem definition

Data Structures LECTURE 10. Huffman coding. Example. Coding: problem definition Dt Strutures, Spring 24 L. Joskowiz Dt Strutures LEURE Humn oing Motivtion Uniquel eipherle oes Prei oes Humn oe onstrution Etensions n pplitions hpter 6.3 pp 385 392 in tetook Motivtion Suppose we wnt

More information

Non Right Angled Triangles

Non Right Angled Triangles Non Right ngled Tringles Non Right ngled Tringles urriulum Redy www.mthletis.om Non Right ngled Tringles NON RIGHT NGLED TRINGLES sin i, os i nd tn i re lso useful in non-right ngled tringles. This unit

More information

1.2 What is a vector? (Section 2.2) Two properties (attributes) of a vector are and.

1.2 What is a vector? (Section 2.2) Two properties (attributes) of a vector are and. Homework 1. Chpters 2. Bsis independent vectors nd their properties Show work except for fill-in-lnks-prolems (print.pdf from www.motiongenesis.com Textooks Resources). 1.1 Solving prolems wht engineers

More information

x = a To determine the volume of the solid, we use a definite integral to sum the volumes of the slices as we let!x " 0 :

x = a To determine the volume of the solid, we use a definite integral to sum the volumes of the slices as we let!x  0 : Clculus II MAT 146 Integrtion Applictions: Volumes of 3D Solids Our gol is to determine volumes of vrious shpes. Some of the shpes re the result of rotting curve out n xis nd other shpes re simply given

More information

Introduction to Electrical & Electronic Engineering ENGG1203

Introduction to Electrical & Electronic Engineering ENGG1203 Introduction to Electricl & Electronic Engineering ENGG23 2 nd Semester, 27-8 Dr. Hden Kwok-H So Deprtment of Electricl nd Electronic Engineering Astrction DIGITAL LOGIC 2 Digitl Astrction n Astrct ll

More information

1 From NFA to regular expression

1 From NFA to regular expression Note 1: How to convert DFA/NFA to regulr expression Version: 1.0 S/EE 374, Fll 2017 Septemer 11, 2017 In this note, we show tht ny DFA cn e converted into regulr expression. Our construction would work

More information

Section 4: Integration ECO4112F 2011

Section 4: Integration ECO4112F 2011 Reding: Ching Chpter Section : Integrtion ECOF Note: These notes do not fully cover the mteril in Ching, ut re ment to supplement your reding in Ching. Thus fr the optimistion you hve covered hs een sttic

More information

LIP. Laboratoire de l Informatique du Parallélisme. Ecole Normale Supérieure de Lyon

LIP. Laboratoire de l Informatique du Parallélisme. Ecole Normale Supérieure de Lyon LIP Lortoire de l Informtique du Prllélisme Eole Normle Supérieure de Lyon Institut IMAG Unité de reherhe ssoiée u CNRS n 1398 One-wy Cellulr Automt on Cyley Grphs Zsuzsnn Rok Mrs 1993 Reserh Report N

More information

CS 311 Homework 3 due 16:30, Thursday, 14 th October 2010

CS 311 Homework 3 due 16:30, Thursday, 14 th October 2010 CS 311 Homework 3 due 16:30, Thursdy, 14 th Octoer 2010 Homework must e sumitted on pper, in clss. Question 1. [15 pts.; 5 pts. ech] Drw stte digrms for NFAs recognizing the following lnguges:. L = {w

More information

CS 360 Exam 2 Fall 2014 Name

CS 360 Exam 2 Fall 2014 Name CS 360 Exm 2 Fll 2014 Nme 1. The lsses shown elow efine singly-linke list n stk. Write three ifferent O(n)-time versions of the reverse_print metho s speifie elow. Eh version of the metho shoul output

More information

Non-deterministic Finite Automata

Non-deterministic Finite Automata Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Rdoud University Nijmegen Non-deterministic Finite Automt H. Geuvers nd J. Rot Institute for Computing nd Informtion

More information

Harvard University Computer Science 121 Midterm October 23, 2012

Harvard University Computer Science 121 Midterm October 23, 2012 Hrvrd University Computer Science 121 Midterm Octoer 23, 2012 This is closed-ook exmintion. You my use ny result from lecture, Sipser, prolem sets, or section, s long s you quote it clerly. The lphet is

More information

1.3 SCALARS AND VECTORS

1.3 SCALARS AND VECTORS Bridge Course Phy I PUC 24 1.3 SCLRS ND VECTORS Introdution: Physis is the study of nturl phenomen. The study of ny nturl phenomenon involves mesurements. For exmple, the distne etween the plnet erth nd

More information

What s so hard about pointers? Reasoning about Pointer-based Data Structures. Traditional Alias Analysis. Language of Pointer Equalities

What s so hard about pointers? Reasoning about Pointer-based Data Structures. Traditional Alias Analysis. Language of Pointer Equalities Wht s so hrd out pointers? Resoning out Pointer-sed Dt Strutures Sott MPek CS 294-3 1/21/4 1 Indiret ess egs lising question Consider xiom for memory: i j sel(upd(m, i, v), j) = sel(m, j) need to e le

More information

Preview 11/1/2017. Greedy Algorithms. Coin Change. Coin Change. Coin Change. Coin Change. Greedy algorithms. Greedy Algorithms

Preview 11/1/2017. Greedy Algorithms. Coin Change. Coin Change. Coin Change. Coin Change. Greedy algorithms. Greedy Algorithms Preview Greed Algorithms Greed Algorithms Coin Chnge Huffmn Code Greed lgorithms end to e simple nd strightforwrd. Are often used to solve optimiztion prolems. Alws mke the choice tht looks est t the moment,

More information

AP Calculus BC Chapter 8: Integration Techniques, L Hopital s Rule and Improper Integrals

AP Calculus BC Chapter 8: Integration Techniques, L Hopital s Rule and Improper Integrals AP Clulus BC Chpter 8: Integrtion Tehniques, L Hopitl s Rule nd Improper Integrls 8. Bsi Integrtion Rules In this setion we will review vrious integrtion strtegies. Strtegies: I. Seprte the integrnd into

More information

Homework Solution - Set 5 Due: Friday 10/03/08

Homework Solution - Set 5 Due: Friday 10/03/08 CE 96 Introduction to the Theory of Computtion ll 2008 Homework olution - et 5 Due: ridy 10/0/08 1. Textook, Pge 86, Exercise 1.21. () 1 2 Add new strt stte nd finl stte. Mke originl finl stte non-finl.

More information

PART NUMBER 1 TD TD TD TD TD TD TD

PART NUMBER 1 TD TD TD TD TD TD TD TE N # RWING TREE # ITEM PRT NUMER 1 T-1039-401 2 T-1039-403 T-1039-44 T-1039-490 10 T-1039-432 12 T-1039-43 1 T-1039-433 2 1 2 03.3 2.0 1 12 12 1 9 1 9 0 21. 10 2.9 NOTES: (UNLESS OTHERWISE SPEIFIE) 1.

More information

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.) CS 373, Spring 29. Solutions to Mock midterm (sed on first midterm in CS 273, Fll 28.) Prolem : Short nswer (8 points) The nswers to these prolems should e short nd not complicted. () If n NF M ccepts

More information

THEORY OF FORMAL LANGUAGES EXERCISE BOOK. A Suite of Exercises with Solutions DRAFT COPY

THEORY OF FORMAL LANGUAGES EXERCISE BOOK. A Suite of Exercises with Solutions DRAFT COPY THEORY OF FORMAL LANGUAGES EXERCISE BOOK A Suite of Exerises with Solutions DRAFT COPY Lu Breveglieri ollortors Gimpolo Agost Alessndro Brenghi Ann Beletsk Stefno Crespi Reghizzi Bernrdo Dl Seno Vinenzo

More information

An introduction to groups

An introduction to groups n introdution to groups syllusref efereneene ore topi: Introdution to groups In this h hpter Groups The terminology of groups Properties of groups Further exmples of groups trnsformtions 66 Mths Quest

More information

input tape head moves current state

input tape head moves current state CPS 140 - Mthemticl Foundtions of CS Dr. Susn Rodger Section: Finite Automt (Ch. 2) (lecture notes) Things to do in clss tody (Jn. 13, 2004): ffl questions on homework 1 ffl finish chpter 1 ffl Red Chpter

More information

Course Overview. Shimon Schocken. Spring Course Overview 1 Elements of Computing Systems

Course Overview. Shimon Schocken. Spring Course Overview 1 Elements of Computing Systems IDC Herzliy Shimon Schocken Course Overview Shimon Schocken Spring 2005 Course Overview 1 Elements of Computing Systems Course gols Course ojectives: Understnd how HW+SW systems re uilt, nd how they work

More information

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck.

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck. Outline Automt Theory 101 Rlf Huuck Introduction Finite Automt Regulr Expressions ω-automt Session 1 2006 Rlf Huuck 1 Session 1 2006 Rlf Huuck 2 Acknowledgement Some slides re sed on Wolfgng Thoms excellent

More information

H (2a, a) (u 2a) 2 (E) Show that u v 4a. Explain why this implies that u v 4a, with equality if and only u a if u v 2a.

H (2a, a) (u 2a) 2 (E) Show that u v 4a. Explain why this implies that u v 4a, with equality if and only u a if u v 2a. Chpter Review 89 IGURE ol hord GH of the prol 4. G u v H (, ) (A) Use the distne formul to show tht u. (B) Show tht G nd H lie on the line m, where m ( )/( ). (C) Solve m for nd sustitute in 4, otining

More information

INF1383 -Bancos de Dados

INF1383 -Bancos de Dados 3//0 INF383 -ncos de Ddos Prof. Sérgio Lifschitz DI PUC-Rio Eng. Computção, Sistems de Informção e Ciênci d Computção LGER RELCIONL lguns slides sedos ou modificdos dos originis em Elmsri nd Nvthe, Fundmentls

More information

Domino Recognizability of Triangular Picture Languages

Domino Recognizability of Triangular Picture Languages Interntionl Journl of Computer Applictions (0975 8887) Volume 57 No.5 Novemer 0 Domino Recognizility of ringulr icture Lnguges V. Devi Rjselvi Reserch Scholr Sthym University Chenni 600 9. Klyni Hed of

More information

PAIR OF LINEAR EQUATIONS IN TWO VARIABLES

PAIR OF LINEAR EQUATIONS IN TWO VARIABLES PAIR OF LINEAR EQUATIONS IN TWO VARIABLES. Two liner equtions in the sme two vriles re lled pir of liner equtions in two vriles. The most generl form of pir of liner equtions is x + y + 0 x + y + 0 where,,,,,,

More information

Proportions: A ratio is the quotient of two numbers. For example, 2 3

Proportions: A ratio is the quotient of two numbers. For example, 2 3 Proportions: rtio is the quotient of two numers. For exmple, 2 3 is rtio of 2 n 3. n equlity of two rtios is proportion. For exmple, 3 7 = 15 is proportion. 45 If two sets of numers (none of whih is 0)

More information

8 Automata and formal languages. 8.1 Formal languages

8 Automata and formal languages. 8.1 Formal languages 8 Automt nd forml lnguges This exposition ws developed y Clemens Gröpl nd Knut Reinert. It is sed on the following references, ll of which re recommended reding: 1. Uwe Schöning: Theoretische Informtik

More information

1.3 Regular Expressions

1.3 Regular Expressions 56 1.3 Regulr xpressions These hve n importnt role in describing ptterns in serching for strings in mny pplictions (e.g. wk, grep, Perl,...) All regulr expressions of lphbet re 1.Ønd re regulr expressions,

More information

On Determinisation of History-Deterministic Automata.

On Determinisation of History-Deterministic Automata. On Deterministion of History-Deterministic Automt. Denis Kupererg Mich l Skrzypczk University of Wrsw YR-ICALP 2014 Copenhgen Introduction Deterministic utomt re centrl tool in utomt theory: Polynomil

More information

Golden Section Search Method - Theory

Golden Section Search Method - Theory Numericl Methods Golden Section Serch Method - Theory http://nm.mthforcollege.com For more detils on this topic Go to http://nm.mthforcollege.com Click on Keyword Click on Golden Section Serch Method You

More information

Nondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA

Nondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA Nondeterminism Nondeterministic Finite Automt Nondeterminism Subset Construction A nondeterministic finite utomton hs the bility to be in severl sttes t once. Trnsitions from stte on n input symbol cn

More information

Pythagoras theorem and surds

Pythagoras theorem and surds HPTER Mesurement nd Geometry Pythgors theorem nd surds In IE-EM Mthemtis Yer 8, you lernt out the remrkle reltionship etween the lengths of the sides of right-ngled tringle. This result is known s Pythgors

More information

Supplemental information. Supplementary_Fig_S1: Ribo-seq meta profiles at start and stop codons S. Typhimurium.

Supplemental information. Supplementary_Fig_S1: Ribo-seq meta profiles at start and stop codons S. Typhimurium. Supplementl informtion Pge 1 Supplementry_Fig_S1: Rio-seq met profiles t strt nd stop odons S. Typhimurium. 2 Supplementry_Fig_S2: Red length distriutions t Shine Dlgrno motifs. 3 Supplementry_Fig_S3:

More information

The Trapezoidal Rule

The Trapezoidal Rule _.qd // : PM Pge 9 SECTION. Numericl Integrtion 9 f Section. The re of the region cn e pproimted using four trpezoids. Figure. = f( ) f( ) n The re of the first trpezoid is f f n. Figure. = Numericl Integrtion

More information

Bayesian Networks of Dynamic Systems (Version du 28 Mars 2007)

Bayesian Networks of Dynamic Systems (Version du 28 Mars 2007) Hilittion à Diriger les Reherhes mention Informtique Université de Rennes 1 Byesin Networks of Dynmi Systems (Version du 28 Mrs 2007) Eri Fre Soutenue le 14 juin 2007, devnt le jury omposé de Président

More information

Finding all minimum-size DFA consistent with given examples: SAT-based approach

Finding all minimum-size DFA consistent with given examples: SAT-based approach Finding ll minimum-size DFA onsistent with given exmples: SAT-sed pproh Ily Zkirzynov 1,, Antoly Shlyto 1, nd Vldimir Ulyntsev 1 1 ITMO University, Sint Petersurg, Russi JetBrins Reserh, Sint Petersurg,

More information

Postprint.

Postprint. http://www.div-portl.org Postprint This is the ccepted version of pper presented t Eighth Workshop on Non-Clssicl Models of utomt nd pplictions(ncm 2016). Cittion for the originl pulished pper: ensch,

More information