Context-Free Grammars
|
|
- Clarence Small
- 5 years ago
- Views:
Transcription
1 Context-Free Grmmrs
2 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. 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. Describe 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 best explined by exmple...
4 Arithmetic Expressions Suppose we wnt to describe ll legl rithmetic expressions using ddition, subtrction, multipliction, nd division. Here is one possible 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 describe ll legl rithmetic expressions using ddition, subtrction, multipliction, nd division. Here is one possible 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 objects: A set of nonterminl symbols (lso clled vribles), A set of terminl symbols (the lphbet of the CFG) A set of production rules sying how ech nonterminl cn be replced by string of terminls nd nonterminls, nd A strt symbol (which must be nonterminl) tht begins the derivtion. By convention, it's the nonterminl tht's first in the list. E int E E Op E E (E) Op + Op - Op * Op /
7 Some CFG Nottion In tody's slides, cpitl letters in Bold Red Uppercse will represent nonterminls. i.e. A, B, C, D Lowercse letters in blue monospce will represent terminls. i.e. t, u, v, w Lowercse Greek letters in gry itlics will represent rbitrry strings of terminls nd nonterminls. i.e. α, γ, ω You don't need to use these conventions on your own; just mke sure whtever you do is redble.
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 derivtion is sequence of steps where in ech step single nonterminl is replced by one of its productions. 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 lphbet Σ nd strt symbol S, then the lnguge of G is the set L(G) = { ω Σ* S * ω } Tht is, L( G) is the set of strings derivble from the strt symbol. Note tht ω must be 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 *b
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 Ab A 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 (b c*)
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 X X b C C Cc ε
17 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. Problem Set 8 Exercise: Insted, show how to convert DFA/NFA into CFG.
18 The Lnguge of Grmmr Consider the following CFG G: S Sb ε Wht strings cn this generte? b b b b L(G) = { n b n n N }
19 All Lnguges Regulr Lnguges CFLs
20 Why the Extr Power? Why do CFGs hve more power thn regulr expressions? Intuition: Derivtions of strings hve unbounded memory. S Sb ε S b b b b
21 Time-Out for Announcements!
22 Problem Set Seven Problem Set Six ws due t the strt of tody's lecture. Wnt to use lte dys? Submit up to Mondy t 3:00PM. Problem Set Seven goes out now. It's due next Fridy. Build some nifty regulr expressions! Ply round with the Myhill-Nerode theorem nd the limits of regulr lnguges!
23 StreetCode Acdemy StreetCode Acdemy, bsed in Est Plo Alto, is currently looking for folks to join their teching tem. This is n mzing progrm tht hs rel impct on its students. It hs community support nd buy-in nd hs been profiled in number of plces. Interested in lerning more or pplying? Use this link!
24 WiCS Industry Mentorship Stnford WiCS (Women in Computer Science) is running n industry mentorship progrm. Sign up to get pired with mentor in industry. Meet cool folks nd be prt of lrger community! The progrm is open to people of ll genders nd bckgrounds. Interested? Sign up using this link.
25 Midterm II The second midterm exm is this upcoming Mondy. Plese feel free to sk us questions on Pizz over the weekend or to stop by our weekend office hours. We're hppy to help out! You cn do this! Best of luck on the exm!
26 Midterm Thoughts Some questions will be looking for intuition nd the feel of things. Think Midterm 1, Q1.i. To prep for these, sk questions like wht does n equivlence clss look like?, wht kinds of functions cn I mke?, or wht does biprtite grph look like? Some questions will be looking for proof setup nd proofwriting. Think Midterm 1, Q3 nd Q4. Q3 on the prctice midterm is n excellent testbed for these ides. These questions require you to be good t setting up nd executing proofs. To prep for questions like these, mke sure you hve good methodology for solving problems. Your gol is to not freeze up when you see something new. Set timer when working through the extr prctice problems tht re mrked s old midterm questions it's gret prctice. Consider putting sequence of steps on your notes sheet, like Step One: Set up the proof. Keep writing out wht to ssume nd wht to prove, nd repet this until there's nothing left to do.
27 Need Help? Some of the TAs hve grciously volunteered to hold extr office hours over the weekend. Check the OH clendr for detils. Ask questions on Pizz even conceptul questions! We're hppy to help out.
28 Your Questions
29 There's lot of resons to be nxious this weekend... Wht's your fvorite wy to destress? I I love love hosting hosting people people for for dinner dinner nd nd spending spending few few hours hours cooking cooking something something nice. nice. Oh, Oh, nd nd bking bking bred. bred. Tht Tht helps helps too! too! There's There's lso lso so so mny mny beutiful beutiful plces plces round round here here to to go go hiking. hiking. For For beutiful beutiful stroll, stroll, hed hed down down to to Point Point Lobos Lobos ner ner Crmel. Crmel. For For beutiful beutiful scenery, scenery, check check out out Cstle Cstle Rock. Rock. For For steep steep climb climb with with gret gret view view of of the the whole whole By By Are, Are, visit visit Montr Montr ner ner Pcific. Pcific. For For hike hike tht tht ends ends t t bech, bech, do do the the Mtt Mtt Dvis Dvis / Steep Steep Rvine Rvine tril tril t t Mt. Mt. Tm. Tm. Oh, Oh, nd nd biking biking to to nd nd from from work. work.
30 Considering wht hppened on Tuesdy, how do I use my CS skills to positively impct policy? There There is is huge huge need need for for CS CS folks folks in in public public policy. policy. There There re re surprisingly surprisingly few few federl federl lws lws on on the the books books involving involving computer computer security security nd nd the the most most importnt importnt one one (the (the CFAA) CFAA) ws ws written written in in Serch Serch round round nd nd red red some some court court decisions decisions bout bout it it to to see see just just how how vguely-worded vguely-worded it it is. is. And And remember remember SOPA SOPA nd nd PIPA? PIPA? There's There's lso lso generl generl lck lck of of understnding understnding by by mny mny politicins politicins bout bout cybersecurity. cybersecurity. In In the the first first debte debte both both cndidtes cndidtes seemed seemed pretty pretty out out of of touch touch with with wht's wht's possible. possible. Look Look t t SIG SIG Fellowships Fellowships through through the the Hs Hs center center for for wys wys to to get get involved involved in in government. government. Consider Consider going going to to lw lw school school not not enough enough CS CS folks folks go go down down tht tht route. route. You You could could lso lso consider consider tking tking job job t t 18F 18F nd nd building building softwre softwre for for the the US US government government or or joining joining the the USDS USDS nd nd help help mke mke government government gencies gencies run run more more smoothly. smoothly.
31 Wht's your workout routine? I I bike bike to to work? work?
32 Bck to CS103!
33 Designing CFGs Like designing DFAs, NFAs, nd regulr expressions, designing CFGs is crft. When thinking bout CFGs: Think recursively: Build up bigger structures from smller ones. Hve construction pln: Know in wht order you will build up the string. Store informtion in nonterminls: Hve ech nonterminl correspond to some useful piece of informtion.
34 Designing CFGs Let Σ = {, b} nd let L = {w Σ* w is plindrome } We cn design CFG for L by thinking inductively: Bse cse: ε,, nd b re plindromes. If ω is plindrome, then ω nd bωb re plindromes. S ε b S bsb
35 Designing CFGs Let Σ = {(, )} nd let L = {w Σ* w is string of blnced prentheses } Some smple strings in L: ((())) (())() (()())(()()) ((((()))(()))) ε ()()
36 Designing CFGs Let Σ = {(, )} nd let L = {w Σ* w is string of blnced prentheses } Let's think bout this recursively. Bse cse: the empty string is string of blnced prentheses. Recursive step: Look t the closing prenthesis tht mtches the first open prenthesis. (( ( ) ( ( ) ) )( ( ) ))(())(( ( ) ))
37 Designing CFGs Let Σ = {(, )} nd let L = {w Σ* w is string of blnced prentheses } Let's think bout this recursively. Bse cse: the empty string is string of blnced prentheses. Recursive step: Look t the closing prenthesis tht mtches the first open prenthesis. Removing the first prenthesis nd its mtching prenthesis forms two new strings of blnced prentheses. S (S)S ε
38 Designing CFGs: A Cvet Let Σ = {, b} nd let L = {w Σ* w hs the sme number of 's nd b's } Is this CFG for L? S Sb bs ε Cn you derive the string bb?
39 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 be tricky mke sure to test your grmmrs! You'll design your own CFG for this lnguge on PS8.
40 CFG Cvets II Is the following grmmr CFG for the lnguge { n b n n N }? S Sb Wht strings cn you derive? Answer: None! Wht is the lnguge of the grmmr? Answer: Ø When designing CFGs, mke sure your recursion ctully termintes!
41 CFG Cvets III When designing CFGs, remember tht ech nonterminl cn be 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
42 Finding Build Order Let Σ = {, } nd let L = { n n n N }. To build CFG for L, we need to be more clever with how we construct the string. If we build the strings of 's independently of one nother, then we cn't enforce tht they hve the sme length. Ide: Build both strings of 's t the sme time. Here's one possible grmmr bsed on tht ide: S S S S S S
43 Function Prototypes Let Σ = {void, int, double, nme, (, ),,, ;}. Let's write CFG for C-style function prototypes! Exmples: void nme(int nme, double nme); int nme(); int nme(double nme); int nme(int, int nme, int); void nme(void);
44 Function Prototypes Here's one possible grmmr: S Ret nme (Args); Ret Type void Type int double Args ε void ArgList ArgList OneArg ArgList, OneArg OneArg Type Type nme Fun question to think bout: wht chnges would you need to mke to support pointer types?
45 Summry of CFG Design Tips Look for recursive structures where they exist: they cn help guide you towrd solution. Keep the build order in mind often, you'll build two totlly different prts of the string concurrently. Usully, those prts re built in opposite directions: one's built left-to-right, the other right-to-left. Use different nonterminls to represent different structures.
46 Applictions of Context-Free Grmmrs
47 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...
48 Grmmrs in Compilers One of the key steps in compiler is figuring out wht progrm mens. This is usully done by 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 bison utomticlly generte prsers from these grmmrs. Curious to lern more? Tke CS143!
49 Nturl Lnguge Processing By building context-free grmmrs for ctul lnguges nd pplying sttisticl inference, it's possible for computer to recover the likely mening of sentence. In fct, CFGs were first clled phrse-structure grmmrs nd were introduced by 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!
50 Next Time Turing Mchines Wht does computer with unbounded memory look like? How do you progrm them? Good luck on the exm!
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 informationContext-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 informationContext-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 informationContext-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 informationContext-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 informationSome 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 informationHomework. 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 informationLING/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 informationFig.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 informationDefinition 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 informationCSE 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 informationCS 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 informationDr. 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 informationECE 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 informationCompilers 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 informationCS143 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 informationIn 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 informationCSCI 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 informationASTs, 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 informationCS321 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 informationCS 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 informationCMPSC 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 informationTheory 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 informationUNIVERSITY 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 informationSection 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 informationCS 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 informationQuiz2 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 informationMidterm 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 informationUnit #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ΕΠΛ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 informationLanguages. 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 informationMidterm 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 informationCS201 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 information10/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 informationCMSC 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 informationCS 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 informationEliminating 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 informationAssignment 4. Due 09/18/17
Assignment 4. ue 09/18/17 1. ). Write regulr expressions tht define the strings recognized by the following finite utomt: b d b b b c c b) Write FA tht recognizes the tokens defined by the following regulr
More informationLecture 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 informationMATH 25 CLASS 5 NOTES, SEP
MATH 25 CLASS 5 NOTES, SEP 30 2011 Contents 1. A brief diversion: reltively prime numbers 1 2. Lest common multiples 3 3. Finding ll solutions to x + by = c 4 Quick links to definitions/theorems Euclid
More informationCS 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 informationLecture 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 informationSection 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 informationSolving 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 informationMid-term exam. Scores. Fall term 2012 KAIST EE209 Programming Structures for EE. Thursday Oct 25, Student's name: Student ID:
Fll term 2012 KAIST EE209 Progrmming Structures for EE Mid-term exm Thursdy Oct 25, 2012 Student's nme: Student ID: The exm is closed book nd notes. Red the questions crefully nd focus your nswers on wht
More informationFall 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 informationCOMP 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 informationSubtracting 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 informationToday. 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 informationUnit 5 Vocabulary. A function is a special relationship where each input has a single output.
MODULE 3 Terms Definition Picture/Exmple/Nottion 1 Function Nottion Function nottion is n efficient nd effective wy to write functions of ll types. This nottion llows you to identify the input vlue with
More informationAnnouncements. 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 informationTopic 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 informationsuch that the S i cover S, or equivalently S
MATH 55 Triple Integrls Fll 16 1. Definition Given solid in spce, prtition of consists of finite set of solis = { 1,, n } such tht the i cover, or equivlently n i. Furthermore, for ech i, intersects i
More information10.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 informationthis 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 informationINTRODUCTION 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 informationCS412/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 informationSIMPLIFYING ALGEBRA PASSPORT.
SIMPLIFYING ALGEBRA PASSPORT www.mthletics.com.u This booklet is ll bout turning complex problems into something simple. You will be ble to do something like this! ( 9- # + 4 ' ) ' ( 9- + 7-) ' ' Give
More informationReducing 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 informationCSCE 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 informationEngineer To Engineer Note
Engineer To Engineer Note EE-186 Technicl Notes on using Anlog Devices' DSP components nd development tools Contct our technicl support by phone: (800) ANALOG-D or e-mil: dsp.support@nlog.com Or visit
More informationImproper Integrals. October 4, 2017
Improper Integrls October 4, 7 Introduction We hve seen how to clculte definite integrl when the it is rel number. However, there re times when we re interested to compute the integrl sy for emple 3. Here
More informationCSc 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 informationSolving 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 informationOperator 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 informationIntegration. 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 informationMath 464 Fall 2012 Notes on Marginal and Conditional Densities October 18, 2012
Mth 464 Fll 2012 Notes on Mrginl nd Conditionl Densities klin@mth.rizon.edu October 18, 2012 Mrginl densities. Suppose you hve 3 continuous rndom vribles X, Y, nd Z, with joint density f(x,y,z. The mrginl
More informationΕΠΛ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 informationIntroduction to Integration
Introduction to Integrtion Definite integrls of piecewise constnt functions A constnt function is function of the form Integrtion is two things t the sme time: A form of summtion. The opposite of differentition.
More information9.1 apply the distance and midpoint formulas
9.1 pply the distnce nd midpoint formuls DISTANCE FORMULA MIDPOINT FORMULA To find the midpoint between two points x, y nd x y 1 1,, we Exmple 1: Find the distnce between the two points. Then, find the
More informationSample 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 informationFall 2017 Midterm Exam 1 October 19, You may not use any books, notes, or electronic devices during this exam.
15-112 Fll 2017 Midterm Exm 1 October 19, 2017 Nme: Andrew ID: Recittion Section: You my not use ny books, notes, or electronic devices during this exm. You my not sk questions bout the exm except for
More informationMA1008. Calculus and Linear Algebra for Engineers. Course Notes for Section B. Stephen Wills. Department of Mathematics. University College Cork
MA1008 Clculus nd Liner Algebr for Engineers Course Notes for Section B Stephen Wills Deprtment of Mthemtics University College Cork s.wills@ucc.ie http://euclid.ucc.ie/pges/stff/wills/teching/m1008/ma1008.html
More information4452 Mathematical Modeling Lecture 4: Lagrange Multipliers
Mth Modeling Lecture 4: Lgrnge Multipliers Pge 4452 Mthemticl Modeling Lecture 4: Lgrnge Multipliers Lgrnge multipliers re high powered mthemticl technique to find the mximum nd minimum of multidimensionl
More informationControl-Flow Analysis and Loop Detection
! Control-Flow Anlysis nd Loop Detection!Lst time! PRE!Tody! Control-flow nlysis! Loops! Identifying loops using domintors! Reducibility! Using loop identifiction to identify induction vribles CS553 Lecture
More informationSpring 2018 Midterm Exam 1 March 1, You may not use any books, notes, or electronic devices during this exam.
15-112 Spring 2018 Midterm Exm 1 Mrch 1, 2018 Nme: Andrew ID: Recittion Section: You my not use ny books, notes, or electronic devices during this exm. You my not sk questions bout the exm except for lnguge
More informationScanner 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 informationCompiler 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 information12-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 informationImplementing 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 informationIntegration. October 25, 2016
Integrtion October 5, 6 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 hve
More informationFunctor (1A) Young Won Lim 10/5/17
Copyright (c) 2016-2017 Young W. Lim. Permission is grnted to copy, distribute nd/or modify this document under the terms of the GNU Free Documenttion License, Version 1.2 or ny lter version published
More informationa < a+ x < a+2 x < < a+n x = b, n A i n f(x i ) x. i=1 i=1
Mth 33 Volume Stewrt 5.2 Geometry of integrls. In this section, we will lern how to compute volumes using integrls defined by slice nlysis. First, we recll from Clculus I how to compute res. Given the
More informationAnnouncements. 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 informationEpson Projector Content Manager Operation Guide
Epson Projector Content Mnger Opertion Guide Contents 2 Introduction to the Epson Projector Content Mnger Softwre 3 Epson Projector Content Mnger Fetures... 4 Setting Up the Softwre for the First Time
More informationThe 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 informationIf 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 informationPYTHON PROGRAMMING. The History of Python. Features of Python. This Course
The History of Python PYTHON PROGRAMMING Dr Christin Hill 7 9 November 2016 Invented by Guido vn Rossum* t the Centrum Wiskunde & Informtic in Amsterdm in the erly 1990s Nmed fter Monty Python s Flying
More informationCS311H: 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 informationShould 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 informationProblem Set 2 Fall 16 Due: Wednesday, September 21th, in class, before class begins.
Problem Set 2 Fll 16 Due: Wednesdy, September 21th, in clss, before clss begins. 1. LL Prsing For the following sub-problems, consider the following context-free grmmr: S T$ (1) T A (2) T bbb (3) A T (4)
More informationCSEP 573 Artificial Intelligence Winter 2016
CSEP 573 Artificil Intelligence Winter 2016 Luke Zettlemoyer Problem Spces nd Serch slides from Dn Klein, Sturt Russell, Andrew Moore, Dn Weld, Pieter Abbeel, Ali Frhdi Outline Agents tht Pln Ahed Serch
More informationScanner Termination. Multi Character Lookahead
If d.doublevlue() represents vlid integer, (int) d.doublevlue() will crete the pproprite integer vlue. If string representtion of n integer begins with ~ we cn strip the ~, convert to double nd then negte
More informationSOME EXAMPLES OF SUBDIVISION OF SMALL CATEGORIES
SOME EXAMPLES OF SUBDIVISION OF SMALL CATEGORIES MARCELLO DELGADO Abstrct. The purpose of this pper is to build up the bsic conceptul frmework nd underlying motivtions tht will llow us to understnd ctegoricl
More informationTO 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 informationFunctor (1A) Young Won Lim 8/2/17
Copyright (c) 2016-2017 Young W. Lim. Permission is grnted to copy, distribute nd/or modify this document under the terms of the GNU Free Documenttion License, Version 1.2 or ny lter version published
More informationQuestions About Numbers. Number Systems and Arithmetic. Introduction to Binary Numbers. Negative Numbers?
Questions About Numbers Number Systems nd Arithmetic or Computers go to elementry school How do you represent negtive numbers? frctions? relly lrge numbers? relly smll numbers? How do you do rithmetic?
More informationAnswer Key Lesson 6: Workshop: Angles and Lines
nswer Key esson 6: tudent Guide ngles nd ines Questions 1 3 (G p. 406) 1. 120 ; 360 2. hey re the sme. 3. 360 Here re four different ptterns tht re used to mke quilts. Work with your group. se your Power
More informationReducing Costs with Duck Typing. Structural
Reducing Costs with Duck Typing Structurl 1 Duck Typing In computer progrmming with object-oriented progrmming lnguges, duck typing is lyer of progrmming lnguge nd design rules on top of typing. Typing
More informationacronyms possibly used in this test: CFG :acontext free grammar CFSM :acharacteristic finite state machine DFA :adeterministic finite automata
EE573 Fll 2002, Exm open book, if question seems mbiguous, sk me to clrify the question. If my nswer doesn t stisfy you, plese stte your ssumptions. cronyms possibly used in this test: CFG :context free
More information