Context-Free Grammars

Size: px
Start display at page:

Download "Context-Free Grammars"

Transcription

1 Context-Free Grmmrs

2 Descriing Lnguges We've seen two models for the regulr lnguges: Finite utomt ccept precisely the strings in the lnguge. Regulr expressions descrie precisely the strings in the lnguge. Finite utomt recognize strings in the lnguge. Perform computtion to determine whether specific string is in the lnguge. Regulr expressions mtch strings in the lnguge. Descrie the generl shpe of ll strings in the lnguge.

3 Context-Free Grmmrs A context-free grmmr (or CFG) is n entirely different formlism for defining clss of lnguges. Gol: Give procedure for listing off ll strings in the lnguge. CFGs re est explined y exmple...

4 Arithmetic Expressions Suppose we wnt to descrie ll legl rithmetic expressions using ddition, sutrction, multipliction, nd division. Here is one possile CFG: E int E E Op E E (E) Op + Op - Op * Op / E E Op E E Op (E) E Op (E Op E) E * (E Op E) int * (E Op E) int * (int Op E) int * (int Op int) int * (int + int)

5 Arithmetic Expressions Suppose we wnt to descrie ll legl rithmetic expressions using ddition, sutrction, multipliction, nd division. Here is one possile CFG: E int E E Op E E (E) Op + Op - Op * Op / E E Op E E Op int int Op int int / int

6 Context-Free Grmmrs Formlly, context-free grmmr is collection of four ojects: A set of nonterminl symols (lso clled vriles), A set of terminl symols (the lphet of the CFG) A set of production rules sying how ech nonterminl cn e replced y string of terminls nd nonterminls, nd A strt symol (which must e nonterminl) tht egins the derivtion. E int E E Op E E (E) Op + Op - Op * Op /

7 Some CFG Nottion Cpitl letters in Bold Red Uppercse will represent nonterminls. i.e. A, B, C, D Lowercse letters in lue monospce will represent terminls. i.e. t, u, v, w Lowercse Greek letters in gry itlics will represent ritrry strings of terminls nd nonterminls. i.e. α, γ, ω

8 A Nottionl Shorthnd E int E E Op E E (E) Op + Op - Op * Op /

9 A Nottionl Shorthnd E int E Op E (E) Op + - * /

10 Derivtions E E Op E int (E) Op + * - / E E Op E E Op (E) E Op (E Op E) E * (E Op E) int * (E Op E) int * (int Op E) int * (int Op int) int * (int + int) A sequence of steps where nonterminls re replced y the right-hnd side of production is clled derivtion. If string α derives string ω, we write α * ω. In the exmple on the left, we see E * int * (int + int).

11 The Lnguge of Grmmr If G is CFG with lphet Σ nd strt symol S, then the lnguge of G is the set L(G) = { ω Σ* S * ω } Tht is, L( G) is the set of strings derivle from the strt symol. Note: ω must e in Σ*, the set of strings mde from terminls. Strings involving nonterminls ren't in the lnguge.

12 Context-Free Lnguges A lnguge L is clled context-free lnguge (or CFL) if there is CFG G such tht L = L( G). Questions: Wht lnguges re context-free? How re context-free nd regulr lnguges relted?

13 From Regexes to CFGs CFGs consist purely of production rules of the form A ω. They do not hve the regulr expression opertors * or. However, we cn convert regulr expressions to CFGs s follows: S *

14 From Regexes to CFGs CFGs consist purely of production rules of the form A ω. They do not hve the regulr expression opertors * or. However, we cn convert regulr expressions to CFGs s follows: S A

15 From Regexes to CFGs CFGs consist purely of production rules of the form A ω. They do not hve the regulr expression opertors * or. However, we cn convert regulr expressions to CFGs s follows: S A A A ε

16 From Regexes to CFGs CFGs consist purely of production rules of the form A ω. They do not hve the regulr expression opertors * or. However, we cn convert regulr expressions to CFGs s follows: S ( c*)

17 From Regexes to CFGs CFGs consist purely of production rules of the form A ω. They do not hve the regulr expression opertors * or. However, we cn convert regulr expressions to CFGs s follows: S X X ( c*)

18 From Regexes to CFGs CFGs consist purely of production rules of the form A ω. They do not hve the regulr expression opertors * or. However, we cn convert regulr expressions to CFGs s follows: S X X c*

19 From Regexes to CFGs CFGs consist purely of production rules of the form A ω. They do not hve the regulr expression opertors * or. However, we cn convert regulr expressions to CFGs s follows: S X X c*

20 From Regexes to CFGs CFGs consist purely of production rules of the form A ω. They do not hve the regulr expression opertors * or. However, we cn convert regulr expressions to CFGs s follows: S X X C

21 From Regexes to CFGs CFGs consist purely of production rules of the form A ω. They do not hve the regulr expression opertors * or. However, we cn convert regulr expressions to CFGs s follows: S X X C C Cc ε

22 Regulr Lnguges nd CFLs Theorem: Every regulr lnguge is context-free. Proof Ide: Use the construction from the previous slides to convert regulr expression for L into CFG for L. Prolem Set Exercise: Insted, show how to convert DFA/NFA into CFG.

23 The Lnguge of Grmmr Consider the following CFG G: S S ε Wht strings cn this generte?

24 The Lnguge of Grmmr Consider the following CFG G: S S ε Wht strings cn this generte? S

25 The Lnguge of Grmmr Consider the following CFG G: S S ε Wht strings cn this generte? S

26 The Lnguge of Grmmr Consider the following CFG G: S S ε Wht strings cn this generte? S

27 The Lnguge of Grmmr Consider the following CFG G: S S ε Wht strings cn this generte? S

28 The Lnguge of Grmmr Consider the following CFG G: S S ε Wht strings cn this generte? S

29 The Lnguge of Grmmr Consider the following CFG G: S S ε Wht strings cn this generte? S

30 The Lnguge of Grmmr Consider the following CFG G: S S ε Wht strings cn this generte? S

31 The Lnguge of Grmmr Consider the following CFG G: S S ε Wht strings cn this generte? S

32 The Lnguge of Grmmr Consider the following CFG G: S S ε Wht strings cn this generte?

33 The Lnguge of Grmmr Consider the following CFG G: S S ε Wht strings cn this generte?

34 The Lnguge of Grmmr Consider the following CFG G: S S ε Wht strings cn this generte? L(G) = { n n n N }

35 All Lnguges Regulr Lnguges CFLs

36 Why the Extr Power? Why do CFGs hve more power thn regulr expressions? Intuition: Derivtions of strings hve unounded memory. S S ε

37 Why the Extr Power? Why do CFGs hve more power thn regulr expressions? Intuition: Derivtions of strings hve unounded memory. S S ε

38 Why the Extr Power? Why do CFGs hve more power thn regulr expressions? Intuition: Derivtions of strings hve unounded memory. S S ε S

39 Why the Extr Power? Why do CFGs hve more power thn regulr expressions? Intuition: Derivtions of strings hve unounded memory. S S ε S

40 Why the Extr Power? Why do CFGs hve more power thn regulr expressions? Intuition: Derivtions of strings hve unounded memory. S S ε S

41 Why the Extr Power? Why do CFGs hve more power thn regulr expressions? Intuition: Derivtions of strings hve unounded memory. S S ε S

42 Why the Extr Power? Why do CFGs hve more power thn regulr expressions? Intuition: Derivtions of strings hve unounded memory. S S ε S

43 Why the Extr Power? Why do CFGs hve more power thn regulr expressions? Intuition: Derivtions of strings hve unounded memory. S S ε S

44 Why the Extr Power? Why do CFGs hve more power thn regulr expressions? Intuition: Derivtions of strings hve unounded memory. S S ε S

45 Why the Extr Power? Why do CFGs hve more power thn regulr expressions? Intuition: Derivtions of strings hve unounded memory. S S ε S

46 Why the Extr Power? Why do CFGs hve more power thn regulr expressions? Intuition: Derivtions of strings hve unounded memory. S S ε

47 Why the Extr Power? Why do CFGs hve more power thn regulr expressions? Intuition: Derivtions of strings hve unounded memory. S S ε

48 Time-Out for Announcements!

49 Prolem Sets Prolem Set Six ws due t the strt of clss; feel free to turn it in y the strt of Mondy's lecture using lte dys. Prolem Set Seven goes out tody. It's due on Fridy of next week. Ply round with the limits of regulr lnguges! Explore context-free grmmrs! See the interply of utomt nd CFGs! As lwys, feel free to stop y office hours or sk questions on Pizz.

50 A Reminder: The Honor Code This is the point in the qurter where we strt to see lot of cheting cses. Plese tke the following to hert: It is not the end of the world if you cn't figure out ll the prolems on prolem set. Ech prolem set is worth something like 3% of your totl grde in this course. Skipping prolem set is not going to tnk your grde. If you know someone in this clss who is unhelthily stressed out, plese rech out to them. We ll need to look out for ech other nd tke cre of ech other. If you know someone who is relly hurting, e there for them. If you re feeling overwhelmed y this clss, plese come tlk to us. This clss is hrd, ut it's not supposed to mke you suffer. If things ren't going well, we'd e hppy to discuss your options. You re not your grdes. You re humn eing. I mentioned this erlier, ut it is not the end of the world if you get low grde, withdrw from this clss, or fil this clss. It does not reflect poorly on you. It does not mke you worthless. From experience, osessing over your grdes will mke you miserle in the long term. Plese don't mke the sme mistkes I mde.

51 Your Questions!

52 I m feeling overwhelmed right now with ll my clsses. Second wve of midterms hve lredy strted for me, nd I m finding it hrd to lnce studying for the midterms nd stying on top of the dy to dy mteril for ll my clsses. Any tips? I'm sorry to her tht. Tht cn e relly rough. There is I'm sorry to her tht. Tht cn e relly rough. There is no one size fits ll solution here. Your gol is to mke no one size fits ll solution here. Your gol is to mke sure tht not ll of the following re true: sure tht not ll of the following re true: you hve too mny things to do, you hve too mny things to do, you hve to do ll of them well, you hve to do ll of them well, you don't enjoy them, you don't enjoy them, you hve limited time to do them, nd you hve limited time to do them, nd this process repets. this process repets. Try ddressing ech of these independently. If you cn Try ddressing ech of these independently. If you cn ddress the root cuses of ech, you will proly end up ddress the root cuses of ech, you will proly end up lot hppier. lot hppier.

53 Three Questions Wht is something tht you now know tht, t the strt of the qurter, you knew you didn't know? Wht is something tht you now know tht, t the strt of the qurter, you didn't know you didn't know? Wht is something tht you don't know tht, t the strt of the qurter, you didn't know you didn't know?

54 I herd rumors tht there re plns to mke the CS deprtment more difficult to get into, ecuse there's so mny people trying to mjor in CS. Is this true? Also, wht re some of the plns out there to tckle the influx of so mny undergrds? I hven't herd nything like this it goes ginst so much of I hven't herd nything like this it goes ginst so much of wht mkes Stnford Stnford. We've hd lot of discussions wht mkes Stnford Stnford. We've hd lot of discussions out how to del with logisticl issues from lrge clss sizes nd out how to del with logisticl issues from lrge clss sizes nd re considering things like incresing the numer of offerings of re considering things like incresing the numer of offerings of ech clss, hving multiple people tech the sme clss ech ech clss, hving multiple people tech the sme clss ech qurter, hiring more stff, etc., ut nothing like this. qurter, hiring more stff, etc., ut nothing like this. We'd consider it huge filure on our prt if we mde it hrder We'd consider it huge filure on our prt if we mde it hrder to get into CS. Tht would undo so much of the work we've done to get into CS. Tht would undo so much of the work we've done in mking CS more ccessile nd interesting nd would totlly in mking CS more ccessile nd interesting nd would totlly poison the culture in the deprtment. poison the culture in the deprtment.

55 Bck to CS103!

56 Designing CFGs Like designing DFAs, NFAs, nd regulr expressions, designing CFGs is crft. When thinking out CFGs: Think recursively: Build up igger structures from smller ones. Hve construction pln: Know in wht order you will uild up the string. Store informtion in nonterminls: Hve ech nonterminl correspond to some useful piece of informtion.

57 Designing CFGs Let Σ = {, } nd let L = {w Σ* w is plindrome } We cn design CFG for L y thinking inductively: Bse cse: ε,, nd re plindromes. If ω is plindrome, then ω nd ω re plindromes. S ε S S

58 Designing CFGs Let Σ = {(, )} nd let L = {w Σ* w is string of lnced prentheses } Some smple strings in L: ((())) (())() (()())(()()) ((((()))(()))) ε ()()

59 Designing CFGs Let Σ = {(, )} nd let L = {w Σ* w is string of lnced prentheses } Let's think out this recursively. Bse cse: the empty string is string of lnced prentheses. Recursive step: Look t the closing prenthesis tht mtches the first open prenthesis. ((()(()))(()))(())((()))

60 Designing CFGs Let Σ = {(, )} nd let L = {w Σ* w is string of lnced prentheses } Let's think out this recursively. Bse cse: the empty string is string of lnced prentheses. Recursive step: Look t the closing prenthesis tht mtches the first open prenthesis. (( ( ) ( ( ) ) )( ( ) ))(())(( ( ) ))

61 Designing CFGs Let Σ = {(, )} nd let L = {w Σ* w is string of lnced prentheses } Let's think out this recursively. Bse cse: the empty string is string of lnced prentheses. Recursive step: Look t the closing prenthesis tht mtches the first open prenthesis. (( ( ) ( ( ) ) )( ( ) ))(())(( ( ) ))

62 Designing CFGs Let Σ = {(, )} nd let L = {w Σ* w is string of lnced prentheses } Let's think out this recursively. Bse cse: the empty string is string of lnced prentheses. Recursive step: Look t the closing prenthesis tht mtches the first open prenthesis. ( ( ) ( ( ) ) )( ( ) ) (())(( ( ) ))

63 Designing CFGs Let Σ = {(, )} nd let L = {w Σ* w is string of lnced prentheses } Let's think out this recursively. Bse cse: the empty string is string of lnced prentheses. Recursive step: Look t the closing prenthesis tht mtches the first open prenthesis. Removing the first prenthesis nd the mtching prenthesis forms two new strings of lnced prentheses. S (S)S ε

64 Designing CFGs: A Cvet Let Σ = {, } nd let L = {w Σ* w hs the sme numer of 's nd 's } Is this CFG for L? S S S ε Cn you derive the string?

65 Designing CFGs: A Cvet When designing CFG for lnguge, mke sure tht it genertes ll the strings in the lnguge nd never genertes string outside the lnguge. The first of these cn e tricky mke sure to test your grmmrs! You'll design your own CFG for this lnguge on the next prolem set.

66 CFG Cvets II Is the following grmmr CFG for the lnguge { n n n N }? S S Wht strings cn you derive? Answer: None! Wht is the lnguge of the grmmr? Answer: Ø When designing CFGs, mke sure your recursion ctully termintes!

67 CFG Cvets III When designing CFGs, rememer tht ech nonterminl cn e expnded out independently of the others. Let Σ = {, } nd let L = {n n n N }. Is the following CFG for L? S X X X X ε S X X X X X X X X

68 Finding Build Order Let Σ = {, } nd let L = { n n n N }. To uild CFG for L, we need to e more clever with how we construct the string. If we uild the strings of 's independently of one nother, then we cn't enforce tht they hve the sme length. Ide: Build oth strings of 's t the sme time. Here's one possile grmmr sed on tht ide: S S S S S S

69 Function Prototypes Let Σ = {void, int, doule, nme, (, ),,, ;}. Let's write CFG for C-style function prototypes! Exmples: void nme(int nme, doule nme); int nme(); int nme(doule nme); int nme(int, int nme, int); void nme(void);

70 Function Prototypes Here's one possile grmmr: S Ret nme (Args); Ret Type void Type int doule Args ε void ArgList ArgList OneArg ArgList, OneArg OneArg Type Type nme Fun question to think out: wht chnges would you need to mke to support pointer types?

71 Summry of CFG Design Tips Look for recursive structures where they exist: they cn help guide you towrd solution. Keep the uild order in mind often, you'll uild two totlly different prts of the string concurrently. Usully, those prts re uilt in opposite directions: one's uilt left-to-right, the other right-to-left. Use different nonterminls to represent different structures.

72 Applictions of Context-Free Grmmrs

73 CFGs for Progrmming Lnguges BLOCK STMT { STMTS } STMTS ε STMT STMTS STMT EXPR; if (EXPR) BLOCK while (EXPR) BLOCK do BLOCK while (EXPR); BLOCK EXPR identifier constnt EXPR + EXPR EXPR EXPR EXPR * EXPR...

74 Grmmrs in Compilers One of the key steps in compiler is figuring out wht progrm mens. This is usully done y defining grmmr showing the high-level structure of progrmming lnguge. There re certin clsses of grmmrs (LL(1) grmmrs, LR(1) grmmrs, LALR(1) grmmrs, etc.) for which it's esy to figure out how prticulr string ws derived. Tools like ycc or ison utomticlly generte prsers from these grmmrs. Curious to lern more? Tke CS143!

75 Nturl Lnguge Processing By uilding context-free grmmrs for ctul lnguges nd pplying sttisticl inference, it's possile for computer to recover the likely mening of sentence. In fct, CFGs were first clled phrse-structure grmmrs nd were introduced y Nom Chomsky in his seminl work Syntctic Structures. They were then dpted for use in the context of progrmming lnguges, where they were clled Bckus- Nur forms. Stnford's CoreNLP project is one plce to look for n exmple of this. Wnt to lern more? Tke CS124 or CS224N!

76 Next Time Turing Mchines Wht does computer with unounded memory look like? How do you progrm them?

Context-Free Grammars

Context-Free Grammars Context-Free Grmmrs Descriing Lnguges We've seen two models for the regulr lnguges: Finite utomt ccept precisely the strings in the lnguge. Regulr expressions descrie precisely the strings in the lnguge.

More information

Context-Free Grammars

Context-Free Grammars Context-Free Grmmrs Describing Lnguges We've seen two models for the regulr lnguges: Finite utomt ccept precisely the strings in the lnguge. Regulr expressions describe precisely the strings in the lnguge.

More information

Context-Free Grammars

Context-Free Grammars Context-Free Grammars Describing Languages We've seen two models for the regular languages: Finite automata accept precisely the strings in the language. Regular expressions describe precisely the strings

More information

Fig.25: the Role of LEX

Fig.25: the Role of LEX The Lnguge for Specifying Lexicl Anlyzer We shll now study how to uild lexicl nlyzer from specifiction of tokens in the form of list of regulr expressions The discussion centers round the design of n existing

More information

CS143 Handout 07 Summer 2011 June 24 th, 2011 Written Set 1: Lexical Analysis

CS143 Handout 07 Summer 2011 June 24 th, 2011 Written Set 1: Lexical Analysis CS143 Hndout 07 Summer 2011 June 24 th, 2011 Written Set 1: Lexicl Anlysis In this first written ssignment, you'll get the chnce to ply round with the vrious constructions tht come up when doing lexicl

More information

Dr. D.M. Akbar Hussain

Dr. D.M. Akbar Hussain Dr. D.M. Akr Hussin Lexicl Anlysis. Bsic Ide: Red the source code nd generte tokens, it is similr wht humns will do to red in; just tking on the input nd reking it down in pieces. Ech token is sequence

More information

CS 430 Spring Mike Lam, Professor. Parsing

CS 430 Spring Mike Lam, Professor. Parsing CS 430 Spring 2015 Mike Lm, Professor Prsing Syntx Anlysis We cn now formlly descrie lnguge's syntx Using regulr expressions nd BNF grmmrs How does tht help us? Syntx Anlysis We cn now formlly descrie

More information

Definition of Regular Expression

Definition of Regular Expression Definition of Regulr Expression After the definition of the string nd lnguges, we re redy to descrie regulr expressions, the nottion we shll use to define the clss of lnguges known s regulr sets. Recll

More information

Homework. Context Free Languages III. Languages. Plan for today. Context Free Languages. CFLs and Regular Languages. Homework #5 (due 10/22)

Homework. Context Free Languages III. Languages. Plan for today. Context Free Languages. CFLs and Regular Languages. Homework #5 (due 10/22) Homework Context Free Lnguges III Prse Trees nd Homework #5 (due 10/22) From textbook 6.4,b 6.5b 6.9b,c 6.13 6.22 Pln for tody Context Free Lnguges Next clss of lnguges in our quest! Lnguges Recll. Wht

More information

CSCI 3130: Formal Languages and Automata Theory Lecture 12 The Chinese University of Hong Kong, Fall 2011

CSCI 3130: Formal Languages and Automata Theory Lecture 12 The Chinese University of Hong Kong, Fall 2011 CSCI 3130: Forml Lnguges nd utomt Theory Lecture 12 The Chinese University of Hong Kong, Fll 2011 ndrej Bogdnov In progrmming lnguges, uilding prse trees is significnt tsk ecuse prse trees tell us the

More information

COMP 423 lecture 11 Jan. 28, 2008

COMP 423 lecture 11 Jan. 28, 2008 COMP 423 lecture 11 Jn. 28, 2008 Up to now, we hve looked t how some symols in n lphet occur more frequently thn others nd how we cn sve its y using code such tht the codewords for more frequently occuring

More information

CS321 Languages and Compiler Design I. Winter 2012 Lecture 5

CS321 Languages and Compiler Design I. Winter 2012 Lecture 5 CS321 Lnguges nd Compiler Design I Winter 2012 Lecture 5 1 FINITE AUTOMATA A non-deterministic finite utomton (NFA) consists of: An input lphet Σ, e.g. Σ =,. A set of sttes S, e.g. S = {1, 3, 5, 7, 11,

More information

Context-Free Grammars

Context-Free Grammars Context-Free Grammars Describing Languages We've seen two models for the regular languages: Finite automata accept precisely the strings in the language. Regular expressions describe precisely the strings

More information

CMPSC 470: Compiler Construction

CMPSC 470: Compiler Construction CMPSC 47: Compiler Construction Plese complete the following: Midterm (Type A) Nme Instruction: Mke sure you hve ll pges including this cover nd lnk pge t the end. Answer ech question in the spce provided.

More information

Some Thoughts on Grad School. Undergraduate Compilers Review and Intro to MJC. Structure of a Typical Compiler. Lexing and Parsing

Some Thoughts on Grad School. Undergraduate Compilers Review and Intro to MJC. Structure of a Typical Compiler. Lexing and Parsing Undergrdute Compilers Review nd Intro to MJC Announcements Miling list is in full swing Tody Some thoughts on grd school Finish prsing Semntic nlysis Visitor pttern for bstrct syntx trees Some Thoughts

More information

In the last lecture, we discussed how valid tokens may be specified by regular expressions.

In the last lecture, we discussed how valid tokens may be specified by regular expressions. LECTURE 5 Scnning SYNTAX ANALYSIS We know from our previous lectures tht the process of verifying the syntx of the progrm is performed in two stges: Scnning: Identifying nd verifying tokens in progrm.

More information

10.5 Graphing Quadratic Functions

10.5 Graphing Quadratic Functions 0.5 Grphing Qudrtic Functions Now tht we cn solve qudrtic equtions, we wnt to lern how to grph the function ssocited with the qudrtic eqution. We cll this the qudrtic function. Grphs of Qudrtic Functions

More information

Languages. L((a (b)(c))*) = { ε,a,bc,aa,abc,bca,... } εw = wε = w. εabba = abbaε = abba. (a (b)(c)) *

Languages. L((a (b)(c))*) = { ε,a,bc,aa,abc,bca,... } εw = wε = w. εabba = abbaε = abba. (a (b)(c)) * Pln for Tody nd Beginning Next week Interpreter nd Compiler Structure, or Softwre Architecture Overview of Progrmming Assignments The MeggyJv compiler we will e uilding. Regulr Expressions Finite Stte

More information

ASTs, Regex, Parsing, and Pretty Printing

ASTs, Regex, Parsing, and Pretty Printing ASTs, Regex, Prsing, nd Pretty Printing CS 2112 Fll 2016 1 Algeric Expressions To strt, consider integer rithmetic. Suppose we hve the following 1. The lphet we will use is the digits {0, 1, 2, 3, 4, 5,

More information

ECE 468/573 Midterm 1 September 28, 2012

ECE 468/573 Midterm 1 September 28, 2012 ECE 468/573 Midterm 1 September 28, 2012 Nme:! Purdue emil:! Plese sign the following: I ffirm tht the nswers given on this test re mine nd mine lone. I did not receive help from ny person or mteril (other

More information

CS 340, Fall 2014 Dec 11 th /13 th Final Exam Note: in all questions, the special symbol ɛ (epsilon) is used to indicate the empty string.

CS 340, Fall 2014 Dec 11 th /13 th Final Exam Note: in all questions, the special symbol ɛ (epsilon) is used to indicate the empty string. CS 340, Fll 2014 Dec 11 th /13 th Finl Exm Nme: Note: in ll questions, the specil symol ɛ (epsilon) is used to indicte the empty string. Question 1. [5 points] Consider the following regulr expression;

More information

CS 432 Fall Mike Lam, Professor a (bc)* Regular Expressions and Finite Automata

CS 432 Fall Mike Lam, Professor a (bc)* Regular Expressions and Finite Automata CS 432 Fll 2017 Mike Lm, Professor (c)* Regulr Expressions nd Finite Automt Compiltion Current focus "Bck end" Source code Tokens Syntx tree Mchine code chr dt[20]; int min() { flot x = 42.0; return 7;

More information

Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming

Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming Lecture 10 Evolutionry Computtion: Evolution strtegies nd genetic progrmming Evolution strtegies Genetic progrmming Summry Negnevitsky, Person Eduction, 2011 1 Evolution Strtegies Another pproch to simulting

More information

this grammar generates the following language: Because this symbol will also be used in a later step, it receives the

this grammar generates the following language: Because this symbol will also be used in a later step, it receives the LR() nlysis Drwcks of LR(). Look-hed symols s eplined efore, concerning LR(), it is possile to consult the net set to determine, in the reduction sttes, for which symols it would e possile to perform reductions.

More information

ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών

ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών ΕΠΛ323 - Θωρία και Πρακτική Μταγλωττιστών Lecture 3 Lexicl Anlysis Elis Athnsopoulos elisthn@cs.ucy.c.cy Recognition of Tokens if expressions nd reltionl opertors if è if then è then else è else relop

More information

Context-Free Grammars

Context-Free Grammars Context-Free Grammars Describing Languages We've seen two models for the regular languages: Automata accept precisely the strings in the language. Regular expressions describe precisely the strings in

More information

Compilers Spring 2013 PRACTICE Midterm Exam

Compilers Spring 2013 PRACTICE Midterm Exam Compilers Spring 2013 PRACTICE Midterm Exm This is full length prctice midterm exm. If you wnt to tke it t exm pce, give yourself 7 minutes to tke the entire test. Just like the rel exm, ech question hs

More information

Quiz2 45mins. Personal Number: Problem 1. (20pts) Here is an Table of Perl Regular Ex

Quiz2 45mins. Personal Number: Problem 1. (20pts) Here is an Table of Perl Regular Ex Long Quiz2 45mins Nme: Personl Numer: Prolem. (20pts) Here is n Tle of Perl Regulr Ex Chrcter Description. single chrcter \s whitespce chrcter (spce, t, newline) \S non-whitespce chrcter \d digit (0-9)

More information

Tries. Yufei Tao KAIST. April 9, Y. Tao, April 9, 2013 Tries

Tries. Yufei Tao KAIST. April 9, Y. Tao, April 9, 2013 Tries Tries Yufei To KAIST April 9, 2013 Y. To, April 9, 2013 Tries In this lecture, we will discuss the following exct mtching prolem on strings. Prolem Let S e set of strings, ech of which hs unique integer

More information

Today. CS 188: Artificial Intelligence Fall Recap: Search. Example: Pancake Problem. Example: Pancake Problem. General Tree Search.

Today. CS 188: Artificial Intelligence Fall Recap: Search. Example: Pancake Problem. Example: Pancake Problem. General Tree Search. CS 88: Artificil Intelligence Fll 00 Lecture : A* Serch 9//00 A* Serch rph Serch Tody Heuristic Design Dn Klein UC Berkeley Multiple slides from Sturt Russell or Andrew Moore Recp: Serch Exmple: Pncke

More information

CS 340, Fall 2016 Sep 29th Exam 1 Note: in all questions, the special symbol ɛ (epsilon) is used to indicate the empty string.

CS 340, Fall 2016 Sep 29th Exam 1 Note: in all questions, the special symbol ɛ (epsilon) is used to indicate the empty string. CS 340, Fll 2016 Sep 29th Exm 1 Nme: Note: in ll questions, the speil symol ɛ (epsilon) is used to indite the empty string. Question 1. [10 points] Speify regulr expression tht genertes the lnguge over

More information

Announcements. CS 188: Artificial Intelligence Fall Recap: Search. Today. Example: Pancake Problem. Example: Pancake Problem

Announcements. CS 188: Artificial Intelligence Fall Recap: Search. Today. Example: Pancake Problem. Example: Pancake Problem Announcements Project : erch It s live! Due 9/. trt erly nd sk questions. It s longer thn most! Need prtner? Come up fter clss or try Pizz ections: cn go to ny, ut hve priority in your own C 88: Artificil

More information

LING/C SC/PSYC 438/538. Lecture 21 Sandiway Fong

LING/C SC/PSYC 438/538. Lecture 21 Sandiway Fong LING/C SC/PSYC 438/538 Lecture 21 Sndiwy Fong Tody's Topics Homework 8 Review Optionl Homework 9 (mke up on Homework 7) Homework 8 Review Question1: write Prolog regulr grmmr for the following lnguge:

More information

CSE 401 Midterm Exam 11/5/10 Sample Solution

CSE 401 Midterm Exam 11/5/10 Sample Solution Question 1. egulr expressions (20 points) In the Ad Progrmming lnguge n integer constnt contins one or more digits, but it my lso contin embedded underscores. Any underscores must be preceded nd followed

More information

Topic 2: Lexing and Flexing

Topic 2: Lexing and Flexing Topic 2: Lexing nd Flexing COS 320 Compiling Techniques Princeton University Spring 2016 Lennrt Beringer 1 2 The Compiler Lexicl Anlysis Gol: rek strem of ASCII chrcters (source/input) into sequence of

More information

Operator Precedence. Java CUP. E E + T T T * P P P id id id. Does a+b*c mean (a+b)*c or

Operator Precedence. Java CUP. E E + T T T * P P P id id id. Does a+b*c mean (a+b)*c or Opertor Precedence Most progrmming lnguges hve opertor precedence rules tht stte the order in which opertors re pplied (in the sence of explicit prentheses). Thus in C nd Jv nd CSX, +*c mens compute *c,

More information

CS412/413. Introduction to Compilers Tim Teitelbaum. Lecture 4: Lexical Analyzers 28 Jan 08

CS412/413. Introduction to Compilers Tim Teitelbaum. Lecture 4: Lexical Analyzers 28 Jan 08 CS412/413 Introduction to Compilers Tim Teitelum Lecture 4: Lexicl Anlyzers 28 Jn 08 Outline DFA stte minimiztion Lexicl nlyzers Automting lexicl nlysis Jlex lexicl nlyzer genertor CS 412/413 Spring 2008

More information

CSCE 531, Spring 2017, Midterm Exam Answer Key

CSCE 531, Spring 2017, Midterm Exam Answer Key CCE 531, pring 2017, Midterm Exm Answer Key 1. (15 points) Using the method descried in the ook or in clss, convert the following regulr expression into n equivlent (nondeterministic) finite utomton: (

More information

Lexical Analysis: Constructing a Scanner from Regular Expressions

Lexical Analysis: Constructing a Scanner from Regular Expressions Lexicl Anlysis: Constructing Scnner from Regulr Expressions Gol Show how to construct FA to recognize ny RE This Lecture Convert RE to n nondeterministic finite utomton (NFA) Use Thompson s construction

More information

Compiler Construction D7011E

Compiler Construction D7011E Compiler Construction D7011E Lecture 3: Lexer genertors Viktor Leijon Slides lrgely y John Nordlnder with mteril generously provided y Mrk P. Jones. 1 Recp: Hndwritten Lexers: Don t require sophisticted

More information

ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών. Lecture 3b Lexical Analysis Elias Athanasopoulos

ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών. Lecture 3b Lexical Analysis Elias Athanasopoulos ΕΠΛ323 - Θωρία και Πρακτική Μταγλωττιστών Lecture 3 Lexicl Anlysis Elis Athnsopoulos elisthn@cs.ucy.c.cy RecogniNon of Tokens if expressions nd relnonl opertors if è if then è then else è else relop è

More information

CS311H: Discrete Mathematics. Graph Theory IV. A Non-planar Graph. Regions of a Planar Graph. Euler s Formula. Instructor: Işıl Dillig

CS311H: Discrete Mathematics. Graph Theory IV. A Non-planar Graph. Regions of a Planar Graph. Euler s Formula. Instructor: Işıl Dillig CS311H: Discrete Mthemtics Grph Theory IV Instructor: Işıl Dillig Instructor: Işıl Dillig, CS311H: Discrete Mthemtics Grph Theory IV 1/25 A Non-plnr Grph Regions of Plnr Grph The plnr representtion of

More information

Announcements. CS 188: Artificial Intelligence Fall Recap: Search. Today. General Tree Search. Uniform Cost. Lecture 3: A* Search 9/4/2007

Announcements. CS 188: Artificial Intelligence Fall Recap: Search. Today. General Tree Search. Uniform Cost. Lecture 3: A* Search 9/4/2007 CS 88: Artificil Intelligence Fll 2007 Lecture : A* Serch 9/4/2007 Dn Klein UC Berkeley Mny slides over the course dpted from either Sturt Russell or Andrew Moore Announcements Sections: New section 06:

More information

Reducing a DFA to a Minimal DFA

Reducing a DFA to a Minimal DFA Lexicl Anlysis - Prt 4 Reducing DFA to Miniml DFA Input: DFA IN Assume DFA IN never gets stuck (dd ded stte if necessry) Output: DFA MIN An equivlent DFA with the minimum numer of sttes. Hrry H. Porter,

More information

CS 236 Language and Computation. Alphabet. Definition. I.2.1. Formal Languages (10.1)

CS 236 Language and Computation. Alphabet. Definition. I.2.1. Formal Languages (10.1) C 236 Lnguge nd Computtion Course Notes Prt I: Grmmrs for Defining yntx (II) Chpter I.2: yntx nd Grmmrs (10, 12.1) Anton etzer (Bsed on ook drft y J. V. Tucker nd K. tephenson) Dept. of Computer cience,

More information

The Math Learning Center PO Box 12929, Salem, Oregon Math Learning Center

The Math Learning Center PO Box 12929, Salem, Oregon Math Learning Center Resource Overview Quntile Mesure: Skill or Concept: 80Q Multiply two frctions or frction nd whole numer. (QT N ) Excerpted from: The Mth Lerning Center PO Box 99, Slem, Oregon 9709 099 www.mthlerningcenter.org

More information

If you are at the university, either physically or via the VPN, you can download the chapters of this book as PDFs.

If you are at the university, either physically or via the VPN, you can download the chapters of this book as PDFs. Lecture 5 Wlks, Trils, Pths nd Connectedness Reding: Some of the mteril in this lecture comes from Section 1.2 of Dieter Jungnickel (2008), Grphs, Networks nd Algorithms, 3rd edition, which is ville online

More information

George Boole. IT 3123 Hardware and Software Concepts. Switching Algebra. Boolean Functions. Boolean Functions. Truth Tables

George Boole. IT 3123 Hardware and Software Concepts. Switching Algebra. Boolean Functions. Boolean Functions. Truth Tables George Boole IT 3123 Hrdwre nd Softwre Concepts My 28 Digitl Logic The Little Mn Computer 1815 1864 British mthemticin nd philosopher Mny contriutions to mthemtics. Boolen lger: n lger over finite sets

More information

UNIVERSITY OF EDINBURGH COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS INFORMATICS 1 COMPUTATION & LOGIC INSTRUCTIONS TO CANDIDATES

UNIVERSITY OF EDINBURGH COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS INFORMATICS 1 COMPUTATION & LOGIC INSTRUCTIONS TO CANDIDATES UNIVERSITY OF EDINBURGH COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS INFORMATICS COMPUTATION & LOGIC Sturdy st April 7 : to : INSTRUCTIONS TO CANDIDATES This is tke-home exercise. It will not

More information

LR Parsing, Part 2. Constructing Parse Tables. Need to Automatically Construct LR Parse Tables: Action and GOTO Table

LR Parsing, Part 2. Constructing Parse Tables. Need to Automatically Construct LR Parse Tables: Action and GOTO Table TDDD55 Compilers nd Interpreters TDDB44 Compiler Construction LR Prsing, Prt 2 Constructing Prse Tles Prse tle construction Grmmr conflict hndling Ctegories of LR Grmmrs nd Prsers Peter Fritzson, Christoph

More information

Midterm I Solutions CS164, Spring 2006

Midterm I Solutions CS164, Spring 2006 Midterm I Solutions CS164, Spring 2006 Februry 23, 2006 Plese red ll instructions (including these) crefully. Write your nme, login, SID, nd circle the section time. There re 8 pges in this exm nd 4 questions,

More information

TO REGULAR EXPRESSIONS

TO REGULAR EXPRESSIONS Suject :- Computer Science Course Nme :- Theory Of Computtion DA TO REGULAR EXPRESSIONS Report Sumitted y:- Ajy Singh Meen 07000505 jysmeen@cse.iit.c.in BASIC DEINITIONS DA:- A finite stte mchine where

More information

CSc 453. Compilers and Systems Software. 4 : Lexical Analysis II. Department of Computer Science University of Arizona

CSc 453. Compilers and Systems Software. 4 : Lexical Analysis II. Department of Computer Science University of Arizona CSc 453 Compilers nd Systems Softwre 4 : Lexicl Anlysis II Deprtment of Computer Science University of Arizon collerg@gmil.com Copyright c 2009 Christin Collerg Implementing Automt NFAs nd DFAs cn e hrd-coded

More information

Java CUP. Java CUP Specifications. User Code Additions. Package and Import Specifications

Java CUP. Java CUP Specifications. User Code Additions. Package and Import Specifications Jv CUP Jv CUP is prser-genertion tool, similr to Ycc. CUP uilds Jv prser for LALR(1) grmmrs from production rules nd ssocited Jv code frgments. When prticulr production is recognized, its ssocited code

More information

Stack Manipulation. Other Issues. How about larger constants? Frame Pointer. PowerPC. Alternative Architectures

Stack Manipulation. Other Issues. How about larger constants? Frame Pointer. PowerPC. Alternative Architectures Other Issues Stck Mnipultion support for procedures (Refer to section 3.6), stcks, frmes, recursion mnipulting strings nd pointers linkers, loders, memory lyout Interrupts, exceptions, system clls nd conventions

More information

Patterns and Algebra. My name. Series

Patterns and Algebra. My name. Series Student Techer Ptterns nd Alger My nme Series D Copyright 009 P Lerning. All rights reserved. First edition printed 009 in Austrli. A ctlogue record for this ook is ville from P Lerning Ltd. ISBN 978--9860--

More information

Implementing Automata. CSc 453. Compilers and Systems Software. 4 : Lexical Analysis II. Department of Computer Science University of Arizona

Implementing Automata. CSc 453. Compilers and Systems Software. 4 : Lexical Analysis II. Department of Computer Science University of Arizona Implementing utomt Sc 5 ompilers nd Systems Softwre : Lexicl nlysis II Deprtment of omputer Science University of rizon collerg@gmil.com opyright c 009 hristin ollerg NFs nd DFs cn e hrd-coded using this

More information

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

Lexical Analysis. Amitabha Sanyal. (www.cse.iitb.ac.in/ as) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay Lexicl Anlysis Amith Snyl (www.cse.iit.c.in/ s) Deprtment of Computer Science nd Engineering, Indin Institute of Technology, Bomy Septemer 27 College of Engineering, Pune Lexicl Anlysis: 2/6 Recp The input

More information

Section 3.1: Sequences and Series

Section 3.1: Sequences and Series Section.: Sequences d Series Sequences Let s strt out with the definition of sequence: sequence: ordered list of numbers, often with definite pttern Recll tht in set, order doesn t mtter so this is one

More information

10/12/17. Motivating Example. Lexical and Syntax Analysis (2) Recursive-Descent Parsing. Recursive-Descent Parsing. Recursive-Descent Parsing

10/12/17. Motivating Example. Lexical and Syntax Analysis (2) Recursive-Descent Parsing. Recursive-Descent Parsing. Recursive-Descent Parsing Motivting Exmple Lexicl nd yntx Anlysis (2) In Text: Chpter 4 Consider the grmmr -> cad A -> b Input string: w = cd How to build prse tree top-down? 2 Initilly crete tree contining single node (the strt

More information

SERIES. Patterns and Algebra OUT. Name

SERIES. Patterns and Algebra OUT. Name D Techer Student Book IN OUT 8 Nme Series D Contents Topic Section Ptterns Answers nd (pp. functions ) identifying ptterns nd nd functions_ creting ptterns_ skip equtions counting nd equivlence completing

More information

Unit #9 : Definite Integral Properties, Fundamental Theorem of Calculus

Unit #9 : Definite Integral Properties, Fundamental Theorem of Calculus Unit #9 : Definite Integrl Properties, Fundmentl Theorem of Clculus Gols: Identify properties of definite integrls Define odd nd even functions, nd reltionship to integrl vlues Introduce the Fundmentl

More information

Eliminating left recursion grammar transformation. The transformed expression grammar

Eliminating left recursion grammar transformation. The transformed expression grammar Eliminting left recursion grmmr trnsformtion Originl! rnsformed! 0 0! 0 α β α α α α α α α α β he two grmmrs generte the sme lnguge, but the one on the right genertes the rst, nd then string of s, using

More information

What are suffix trees?

What are suffix trees? Suffix Trees 1 Wht re suffix trees? Allow lgorithm designers to store very lrge mount of informtion out strings while still keeping within liner spce Allow users to serch for new strings in the originl

More information

Theory of Computation CSE 105

Theory of Computation CSE 105 $ $ $ Theory of Computtion CSE 105 Regulr Lnguges Study Guide nd Homework I Homework I: Solutions to the following problems should be turned in clss on July 1, 1999. Instructions: Write your nswers clerly

More information

12-B FRACTIONS AND DECIMALS

12-B FRACTIONS AND DECIMALS -B Frctions nd Decimls. () If ll four integers were negtive, their product would be positive, nd so could not equl one of them. If ll four integers were positive, their product would be much greter thn

More information

Midterm 2 Sample solution

Midterm 2 Sample solution Nme: Instructions Midterm 2 Smple solution CMSC 430 Introduction to Compilers Fll 2012 November 28, 2012 This exm contins 9 pges, including this one. Mke sure you hve ll the pges. Write your nme on the

More information

Lexical analysis, scanners. Construction of a scanner

Lexical analysis, scanners. Construction of a scanner Lexicl nlysis scnners (NB. Pges 4-5 re for those who need to refresh their knowledge of DFAs nd NFAs. These re not presented during the lectures) Construction of scnner Tools: stte utomt nd trnsition digrms.

More information

CS 321 Programming Languages and Compilers. Bottom Up Parsing

CS 321 Programming Languages and Compilers. Bottom Up Parsing CS 321 Progrmming nguges nd Compilers Bottom Up Prsing Bottom-up Prsing: Shift-reduce prsing Grmmr H: fi ; fi b Input: ;;b hs prse tree ; ; b 2 Dt for Shift-reduce Prser Input string: sequence of tokens

More information

2 Computing all Intersections of a Set of Segments Line Segment Intersection

2 Computing all Intersections of a Set of Segments Line Segment Intersection 15-451/651: Design & Anlysis of Algorithms Novemer 14, 2016 Lecture #21 Sweep-Line nd Segment Intersection lst chnged: Novemer 8, 2017 1 Preliminries The sweep-line prdigm is very powerful lgorithmic design

More information

Lecture T1: Pattern Matching

Lecture T1: Pattern Matching Introduction to Theoreticl CS Lecture T: Pttern Mtchin Two fundmentl questions. Wht cn computer do? Wht cn computer do with limited resources? Generl pproch. Don t tlk out specific mchines or prolems.

More information

CMSC 331 First Midterm Exam

CMSC 331 First Midterm Exam 0 00/ 1 20/ 2 05/ 3 15/ 4 15/ 5 15/ 6 20/ 7 30/ 8 30/ 150/ 331 First Midterm Exm 7 October 2003 CMC 331 First Midterm Exm Nme: mple Answers tudent ID#: You will hve seventy-five (75) minutes to complete

More information

Solving Problems by Searching. CS 486/686: Introduction to Artificial Intelligence Winter 2016

Solving Problems by Searching. CS 486/686: Introduction to Artificial Intelligence Winter 2016 Solving Prolems y Serching CS 486/686: Introduction to Artificil Intelligence Winter 2016 1 Introduction Serch ws one of the first topics studied in AI - Newell nd Simon (1961) Generl Prolem Solver Centrl

More information

Information Retrieval and Organisation

Information Retrieval and Organisation Informtion Retrievl nd Orgnistion Suffix Trees dpted from http://www.mth.tu.c.il/~himk/seminr02/suffixtrees.ppt Dell Zhng Birkeck, University of London Trie A tree representing set of strings { } eef d

More information

Sample Midterm Solutions COMS W4115 Programming Languages and Translators Monday, October 12, 2009

Sample Midterm Solutions COMS W4115 Programming Languages and Translators Monday, October 12, 2009 Deprtment of Computer cience Columbi University mple Midterm olutions COM W4115 Progrmming Lnguges nd Trnsltors Mondy, October 12, 2009 Closed book, no ids. ch question is worth 20 points. Question 5(c)

More information

Top-down vs Bottom-up. Bottom up parsing. Sentential form. Handles. Handles in expression example

Top-down vs Bottom-up. Bottom up parsing. Sentential form. Handles. Handles in expression example Bottom up prsing Generl e LR0) LR LR1) LLR o est exploit JvCUP, should understnd the theoreticl sis LR prsing); op-down vs Bottom-up Bottom-up more powerful thn top-down; Cn process more powerful grmmr

More information

CS 241 Week 4 Tutorial Solutions

CS 241 Week 4 Tutorial Solutions CS 4 Week 4 Tutoril Solutions Writing n Assemler, Prt & Regulr Lnguges Prt Winter 8 Assemling instrutions utomtilly. slt $d, $s, $t. Solution: $d, $s, nd $t ll fit in -it signed integers sine they re 5-it

More information

Section 10.4 Hyperbolas

Section 10.4 Hyperbolas 66 Section 10.4 Hyperbols Objective : Definition of hyperbol & hyperbols centered t (0, 0). The third type of conic we will study is the hyperbol. It is defined in the sme mnner tht we defined the prbol

More information

Lecture T4: Pattern Matching

Lecture T4: Pattern Matching Introduction to Theoreticl CS Lecture T4: Pttern Mtching Two fundmentl questions. Wht cn computer do? How fst cn it do it? Generl pproch. Don t tlk bout specific mchines or problems. Consider miniml bstrct

More information

Subtracting Fractions

Subtracting Fractions Lerning Enhncement Tem Model Answers: Adding nd Subtrcting Frctions Adding nd Subtrcting Frctions study guide. When the frctions both hve the sme denomintor (bottom) you cn do them using just simple dding

More information

CSCI 104. Rafael Ferreira da Silva. Slides adapted from: Mark Redekopp and David Kempe

CSCI 104. Rafael Ferreira da Silva. Slides adapted from: Mark Redekopp and David Kempe CSCI 0 fel Ferreir d Silv rfsilv@isi.edu Slides dpted from: Mrk edekopp nd Dvid Kempe LOG STUCTUED MEGE TEES Series Summtion eview Let n = + + + + k $ = #%& #. Wht is n? n = k+ - Wht is log () + log ()

More information

Slides for Data Mining by I. H. Witten and E. Frank

Slides for Data Mining by I. H. Witten and E. Frank Slides for Dt Mining y I. H. Witten nd E. Frnk Simplicity first Simple lgorithms often work very well! There re mny kinds of simple structure, eg: One ttriute does ll the work All ttriutes contriute eqully

More information

Fall 2018 Midterm 1 October 11, ˆ You may not ask questions about the exam except for language clarifications.

Fall 2018 Midterm 1 October 11, ˆ You may not ask questions about the exam except for language clarifications. 15-112 Fll 2018 Midterm 1 October 11, 2018 Nme: Andrew ID: Recittion Section: ˆ You my not use ny books, notes, extr pper, or electronic devices during this exm. There should be nothing on your desk or

More information

COMBINATORIAL PATTERN MATCHING

COMBINATORIAL PATTERN MATCHING COMBINATORIAL PATTERN MATCHING Genomic Repets Exmple of repets: ATGGTCTAGGTCCTAGTGGTC Motivtion to find them: Genomic rerrngements re often ssocited with repets Trce evolutionry secrets Mny tumors re chrcterized

More information

Integration. September 28, 2017

Integration. September 28, 2017 Integrtion September 8, 7 Introduction We hve lerned in previous chpter on how to do the differentition. It is conventionl in mthemtics tht we re supposed to lern bout the integrtion s well. As you my

More information

INTRODUCTION TO SIMPLICIAL COMPLEXES

INTRODUCTION TO SIMPLICIAL COMPLEXES INTRODUCTION TO SIMPLICIAL COMPLEXES CASEY KELLEHER AND ALESSANDRA PANTANO 0.1. Introduction. In this ctivity set we re going to introduce notion from Algebric Topology clled simplicil homology. The min

More information

Simplifying Algebra. Simplifying Algebra. Curriculum Ready.

Simplifying Algebra. Simplifying Algebra. Curriculum Ready. Simplifying Alger Curriculum Redy www.mthletics.com This ooklet is ll out turning complex prolems into something simple. You will e le to do something like this! ( 9- # + 4 ' ) ' ( 9- + 7-) ' ' Give this

More information

Regular Expressions and Automata using Miranda

Regular Expressions and Automata using Miranda Regulr Expressions nd Automt using Mirnd Simon Thompson Computing Lortory Univerisity of Kent t Cnterury My 1995 Contents 1 Introduction ::::::::::::::::::::::::::::::::: 1 2 Regulr Expressions :::::::::::::::::::::::::::::

More information

Finite Automata. Lecture 4 Sections Robb T. Koether. Hampden-Sydney College. Wed, Jan 21, 2015

Finite Automata. Lecture 4 Sections Robb T. Koether. Hampden-Sydney College. Wed, Jan 21, 2015 Finite Automt Lecture 4 Sections 3.6-3.7 Ro T. Koether Hmpden-Sydney College Wed, Jn 21, 2015 Ro T. Koether (Hmpden-Sydney College) Finite Automt Wed, Jn 21, 2015 1 / 23 1 Nondeterministic Finite Automt

More information

Algorithm Design (5) Text Search

Algorithm Design (5) Text Search Algorithm Design (5) Text Serch Tkshi Chikym School of Engineering The University of Tokyo Text Serch Find sustring tht mtches the given key string in text dt of lrge mount Key string: chr x[m] Text Dt:

More information

Deterministic. Finite Automata. And Regular Languages. Fall 2018 Costas Busch - RPI 1

Deterministic. Finite Automata. And Regular Languages. Fall 2018 Costas Busch - RPI 1 Deterministic Finite Automt And Regulr Lnguges Fll 2018 Costs Busch - RPI 1 Deterministic Finite Automton (DFA) Input Tpe String Finite Automton Output Accept or Reject Fll 2018 Costs Busch - RPI 2 Trnsition

More information

Very sad code. Abstraction, List, & Cons. CS61A Lecture 7. Happier Code. Goals. Constructors. Constructors 6/29/2011. Selectors.

Very sad code. Abstraction, List, & Cons. CS61A Lecture 7. Happier Code. Goals. Constructors. Constructors 6/29/2011. Selectors. 6/9/ Abstrction, List, & Cons CS6A Lecture 7-6-9 Colleen Lewis Very sd code (define (totl hnd) (if (empty? hnd) (+ (butlst (lst hnd)) (totl (butlst hnd))))) STk> (totl (h c d)) 7 STk> (totl (h ks d)) ;;;EEEK!

More information

AI Adjacent Fields. This slide deck courtesy of Dan Klein at UC Berkeley

AI Adjacent Fields. This slide deck courtesy of Dan Klein at UC Berkeley AI Adjcent Fields Philosophy: Logic, methods of resoning Mind s physicl system Foundtions of lerning, lnguge, rtionlity Mthemtics Forml representtion nd proof Algorithms, computtion, (un)decidility, (in)trctility

More information

Solving Problems by Searching. CS 486/686: Introduction to Artificial Intelligence

Solving Problems by Searching. CS 486/686: Introduction to Artificial Intelligence Solving Prolems y Serching CS 486/686: Introduction to Artificil Intelligence 1 Introduction Serch ws one of the first topics studied in AI - Newell nd Simon (1961) Generl Prolem Solver Centrl component

More information

Scanner Termination. Multi Character Lookahead. to its physical end. Most parsers require an end of file token. Lex and Jlex automatically create an

Scanner Termination. Multi Character Lookahead. to its physical end. Most parsers require an end of file token. Lex and Jlex automatically create an Scnner Termintion A scnner reds input chrcters nd prtitions them into tokens. Wht hppens when the end of the input file is reched? It my be useful to crete n Eof pseudo-chrcter when this occurs. In Jv,

More information

Typing with Weird Keyboards Notes

Typing with Weird Keyboards Notes Typing with Weird Keyords Notes Ykov Berchenko-Kogn August 25, 2012 Astrct Consider lnguge with n lphet consisting of just four letters,,,, nd. There is spelling rule tht sys tht whenever you see n next

More information

Should be done. Do Soon. Structure of a Typical Compiler. Plan for Today. Lab hours and Office hours. Quiz 1 is due tonight, was posted Tuesday night

Should be done. Do Soon. Structure of a Typical Compiler. Plan for Today. Lab hours and Office hours. Quiz 1 is due tonight, was posted Tuesday night Should e done L hours nd Office hours Sign up for the miling list t, strting to send importnt info to list http://groups.google.com/group/cs453-spring-2011 Red Ch 1 nd skim Ch 2 through 2.6, red 3.3 nd

More information

Example: 2:1 Multiplexer

Example: 2:1 Multiplexer Exmple: 2:1 Multiplexer Exmple #1 reg ; lwys @( or or s) egin if (s == 1') egin = ; else egin = ; 1 s B. Bs 114 Exmple: 2:1 Multiplexer Exmple #2 Normlly lwys include egin nd sttements even though they

More information

Lists in Lisp and Scheme

Lists in Lisp and Scheme Lists in Lisp nd Scheme Lists in Lisp nd Scheme Lists re Lisp s fundmentl dt structures, ut there re others Arrys, chrcters, strings, etc. Common Lisp hs moved on from eing merely LISt Processor However,

More information

CS201 Discussion 10 DRAWTREE + TRIES

CS201 Discussion 10 DRAWTREE + TRIES CS201 Discussion 10 DRAWTREE + TRIES DrwTree First instinct: recursion As very generic structure, we could tckle this problem s follows: drw(): Find the root drw(root) drw(root): Write the line for the

More information