# Register now to access 7 million high quality study materials (What's Course Hero?) Course Hero is the premier provider of high quality online educational resources. With millions of study documents, online tutors, digital flashcards and free courseware, Course Hero is helping students learn more efficiently and effectively. Whether you're interested in exploring new subjects or mastering key topics for your next exam, Course Hero has the tools you need to achieve your goals.

2 Pages

### lec17

Course: CS 322, Fall 2009
School: Washington
Rating:

Word Count: 1641

#### Document Preview

322 CSE - Introduction to Formal Methods in Computer Science Closure Properties of Context-Free Languages Dave Bacon Department of Computer Science &amp; Engineering, University of Washington Previously we showed how regular operations were closed under certain operations: union, intersection, the operation, concatenation, etc. Do similar results hold for CFLs? Well it will turn out for some of these...

Register Now

#### Unformatted Document Excerpt

Coursehero >> Washington >> Washington >> CS 322

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
322 CSE - Introduction to Formal Methods in Computer Science Closure Properties of Context-Free Languages Dave Bacon Department of Computer Science & Engineering, University of Washington Previously we showed how regular operations were closed under certain operations: union, intersection, the operation, concatenation, etc. Do similar results hold for CFLs? Well it will turn out for some of these operations, CFLs are indeed closed. Lets see how we can get at a few of these by introduction the a notion called substitution. Let be some alphabet. Suppose that for every symbol a , we choose a language La . Now La can be a language over any alphabet, it doesn't have to be over the alphabet . The alphabets of La do not have to match for different as. By choosing such a set of languages we have in effect defined a function on . We call this a substitution. Lets call this function s, so that s(a) is the language La . If w is a string from such that w = a1 a2 . . . an , where ai , then we define s(w) as the language of all strings x1 x2 xn such that xi s(ai ). Extending this even more we can define s(L) as the union of all s(w) for all strings w in L. Example: Let s(0) = {an bn cn |n 1} and s(1) = {aaa, bbb, ccc}. Let w = 01. Then s(01) = {an bn cn |n 1} {aaa, bbb, ccc} which is just s(01) = {an bn cn s3 |n 1, s {a, b, c}}. If L = L(0 ) is the language of all strings made up of no 1s, then s(L) = (s(0)) . This is s(L) = {an1 bn1 cn1 an2 bn2 cn2 . . . ank bnk cnk |k 0, 1 i k, ni 1} Okay having defined substitution we can now turn to our main result. We claim that if L is a context-free language over an alphabet , and s is a substitution on such that s(a) is a context-free language for all a , then s(L) is a context-free language. The basic idea behind how this work is that we can take the CFG for L and replace the terminals in this CFG with the start variables of relevant substitutions. In other words if the CFG for L has a terminal a, then we replace this terminal by the start symbol for s(a) in all rules of the CFG. Let's be a little more formal about this. Let G = (V, , R, S) be a CFG for the language L and Ga = (Va , a , Ra , Sa ) be a CFG for the languages s(a), where a . Since we can call variables whatever we like, let us assume that all of the variables in V and Va , a are different. That is V and Va , a are all disjoint. Okay so now we will construct a new grammar G = (V , , R , S ) for s(L). This new grammar will have 1. V = 2. = a a Va a V 3. R is made up of the union of all rules from every Ra , unioned with all rules from R, but with each terminal a replaced by Sa everywhere that a occurs in R. 4. S = S. Okay so now a formal proof would proceed by showing that a string is in L(G ) if and only if w is in s(L). If w is in s(L), then there is some string x = a1 a2 . . . an in L and strings xi in s(ai ) such that w = x1 x2 . . . xn . Then we can see that G will generate this string. The portion of G that comes from the rules of G with Sa substitute for each a which generate a string Sa1 Sa2 . . . San . Then the part of the derivation for each Sai xi proceeds from the second part of the derivation. If w is in L(G ), then the parse tree for w must be a tree which has an upper structure made up entirely of derivations from G with the old terminals replaced by trees made up entirely of derivations from the relevant Ga . This implies that if w is in L(G ) we can find Sa1 Sa2 . . . San in the derivation of the top part of the tree and then proceeding downwards each of these must derive a string in s(ai ). Okay so now lets apply this substitution theorem to show how CFLs are closed under union, concatenation and . Union: Let L1 and L2 be CFLs. Then L1 L2 be the language s(L) where L is the language {1, 2} and s is the substitution defined by s(1) = L1 and s(2) = L2 . By the theorem s(L) is a CFL. Concatenation: Let L1 and L2 be CFLs. Then L1 L2 is the language s(L) where L is the language {12} and s is the substitution defined by s(1) = L1 and s(2) = L2 . By the theorem s(L) is a CFL. The operation: Let L1 be a CFL. L Then is the language L where L is the language {0} and the substitution 1 s is defined by s(0) = L1 . It is interesting to think about the above and ask the question of whether CFLs are closed under intersection. After you think about it for a while you'll conclude that you can't use a construction like the one above, if this were true. Which is good, because it turns out that it is not true! CFLs are not closed under intersection (we will see an example of this later.) 2 I. A DIFFERENT EXAMPLE In class we talked about the following problem If L is a language, and a is a symbol, then L/a i, the quotient of L and a, is the set of strings w such that wa is in L. For example if L = {a, aab, baa}, then L/a = {, ba}. Prove that is L is a CFL then L/a is CFL. Hint: it might help to have the CFG for L in Chomsky normal form. How to solve this problem? We want to show that if L is a CFL then L/a is a CFG. Now since L is a CFG, there must exists some CFG G = (V, , R, S) such that L(G) = L. In order to show that L/a is a CFL, we will show how to convert this CFG, G into a new grammar, call it G1 = (V1 , , R1 , S1 ), such that this grammar has the language L/a, i.e. L(G1 ) = L/a. First of all we may assume, without loss of generality, that the grammar G has rules expressed in Chomsky normal form (if it isn't we can always convert this to a grammar in this form, which is why we can assume this without loss of generality.) To understand how to construct G1 , lets think about derivations using G. Since G is in Chomsky normal form, the parse tree for our derivation will be a binary tree, with the exception that for the variables which turn into terminals, these variables will only have single children. From the definition of L/a we see that we would like to be able to construct a grammar which allows similar derivations with the property that when the rightmost character in the parse tree is derived, if it is an a we would like to strip this a from the string for our new grammar. Thus it seems that need a way to keep track of the rightmost variable in our derivation. We will do this by adding to our grammar a variable for every variable in V but with this variable indicating that the variable is currently the rightmost string. Formally, let let Ai denote all of the variables in V (1 i |V |). Then we will define a new set of variables Ai for our grammar G1 . In particular we let V1 = V {Ai |1 i |V |}. To be clear, our new grammar has ...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science Turing MachinesDave BaconDepartment of Computer Science &amp; Engineering, University of WashingtonToday we finally make it up to.computers! Well at least to the model which best captures w
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science DecidabilityDave BaconDepartment of Computer Science &amp; Engineering, University of WashingtonIn the last lecture we introduced the Turing machine. We talked about how it worked, and show
Washington - CS - 322
CSE 322: Formal Models in Computer ScienceMidterm TopicsThe midterm will be Friday, May 9th in class. It will be 50 minutes in length and will be closed book. The midterm will cover everything covered in class up to and including the first half o
Washington - CS - 322
CSE 322: Formal Models in Computer ScienceFinal TopicsThe nal will be Monday, June 9 from 2:30-4:20 in EEB 045. It will be 110 minutes in length and will be closed book. It will cover everything in the class with slightly more coming from the mat
Washington - CS - 322
CSE322: Formal Models in Computer Science Partial Solutions to Sample FinalSpring 2006This handout has (partial) solutions to some of the problems in the sample final exam that was handed out in class on Friday, May 26. I have not given solutions
Washington - CS - 322
1 CSE 322: Formal Models in Computer Science April 2, 2008 HandoutN,S,W,ENNN,EQQQ Fremont Troll o QQQ y QQQ QQQ QQQ N,S,W N QQQ Q@ E G Queen Anne Ave o Villa Sophia o W iRRR y RRR RRR N S RRR W R Space Needle o yNWGas Works Park o
Washington - CS - 322
CSE 322 Introduction to Formal Models in Computer ScienceDefining from In the definition of DFAs, the transition function explicitly describes, for each character a , the name of the state reached on a when started at state q. This is precisely
Washington - CS - 322
Washington - CS - 322
CSE 322: Formal Models in Computer Science Website: http:/www.cs.washington.edu/322 Lecture Times: MWF 1:30-2:30 in EE 045 (in the dungeon of EE.) Instructor: Dave Bacon Office: CSE 460 Email: dabacon@cs.washington.edu Phone: 206-221-6503 Office hour
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Winter 2005 Course InformationInstructor: TAs:Anna R. Karlin Neva Cherniavsky Ning ChenPGA 594 PGA 378 PGA 310karlin@cs.washington.edu nchernia@cs.washington.edu ning@cs.washington.edu543-9344 685-
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #0 January 3, 2005 Due: Wednesday, January 5Reading Assignment: Kleinberg and Tardos, Chapters 1 and 4 Questions: 1. For each of the following topics, indicate your level of comfort on a scale o
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #1 January 5, 2005 Due: Wednesday, January 12Reading Assignment: Kleinberg and Tardos, Chapters 1 and 4 Problems:1. Gale and Shapley published their paper on the stable marriage problem in 196
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #2 January 12, 2005 Due: Wednesday, January 19 Reading Assignment: K&amp;T, Section 5.1, 5.2, 5.4, 5.6, 5.7, 5.9 Questions: 1. (Kleinberg and Tardos, Chapter 4, Problem 5) Let's consider a long, quiet
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #4 January 27, 2005 Due: Wednesday, February 2Reading Assignment: Kleinberg and Tardos, Network Flow, handout on linear programming, section 11.6 in new book. Problems:1. Let G = (V, E) be a g
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #5 February 2, 2005 Due: Wednesday, February 9Reading Assignment: Kleinberg and Tardos, Network Flow, handout on linear programming Problems: 1. Your friends have written a very fast piece of ma
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #6 Due: Wednesday, February 16Reading Assignment: Linear programming handouts, chapter on randomized algorithms, other randomized algorithms handouts (we'll send out mail about them.) Problems:
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #7 Due: Wednesday, Feb 23Problems:1. QuickSelect is the following simple algorithm for finding the k-th smallest element in an unsorted set S. QuickSelect(S, k): (a) Pick a pivot element p uni
Washington - CS - 521
Name:1 2 3 4 total/ 9 /10 /16 /39 /74CSE 521 Final ExamMarch 15, 2004 Instructions: You have 1 hour and 50 minutes to complete the exam. The exam is closed book, closed notes. Please do not turn the page until you are instructed to do so.
Washington - CS - 421
Measuring efficiency: The RAM modelnRAM = Random Access Machine Time # of instructions executed in an ideal assembly languagennComplexity and Representative ProblemsWinter 2005 Paul Beameneach simple operation (+,*,-,=,if,call) takes on
Washington - CS - 421
Undirected Graph G = (V,E)1 2 3 11 10Graph TraversalWinter 2005 Paul Beame12 4 5 6 7 8 13 9Directed Graph G = (V,E)1 2 3 11 12 4 5 6 7 8 13 9n n nGraph TraversalLearn the basic structure of a graph Walk from a fixed starting vertex s to
Washington - CS - 421
Greedy AlgorithmsnHard to define exactly but can give general propertiesn nGreedy AlgorithmsWinter 2005 Paul BeamenSolution is built in small steps Decisions on how to build the solution are made to maximize some criterion without looking t
Washington - CS - 421
Dynamic ProgrammingnDynamic ProgrammingnGive a solution of a problem using smaller sub-problems where all the possible sub-problems are determined in advance Useful when the same sub-problems show up again and again in the solutionDynamic Pro
Washington - CS - 421
Bipartite MatchingnnGiven: A bipartite graph G=(V,E)ME is a matching in G iff no two edges in M share a vertexnNetwork FlowWinter 2005 Paul BeameGoal: Find a matching M in G of maximum possible sizeBipartite MatchingBipartite Matchin
Washington - CS - 421
Dealing with NP-completenessWinter 2005 Paul BeameWhat to do if the problem you want to solve is NP-hardnYou might have phrased your problem too generallyne.g., in practice, the graphs that actually arise are far from arbitrary n maybe they
Washington - CSE - 590
Washington - CSEP - 590
Homeland Security / Cyber Security Autumn 2005N.B. CONTINUALLY IN FLUX Version 24: November 22 Course Requirements: Red Team Exercise (~25%): You are a member of a 5-6 person team of engineers and policy professionals that has been hired by the Depa
Washington - CSEP - 590
Homeland Security / Cyber Security Autumn 2005N.B. CONTINUALLY IN FLUX Version 24: November 22 Course Requirements: Red Team Exercise (~25%): You are a member of a 5-6 person team of engineers and policy professionals that has been hired by the Depa
Washington - CSEP - 590
CSE P 590TU: Homeland Security / Cyber Security Course Grade Histogram for UW Students4.0 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0X X X X X X X X X XX X X X X X X X X XX X X X X X X X X X X X X X X X X X X X X X X X X
Washington - CSEP - 590
Red Team ReportHemavathy Alaganandam Parvez Anandam Jameel Alsalam Yi-Kai Liu Pravin Mittal Elena Rodriguez-Vieitez Santeri VoutilainenUniversity of Washington CSE P 590TU UC Berkeley PP 190/290-009 UCSD CSE 291 (C00) Christine Hartmann-Siantar P
Washington - CSEP - 590
Buffer Overflows: Implications for Civilian CybersecurityAndrew Hoskinsahoskins@microsoft.comMark O. Ihimoyanmark.ihimoyan@microsoft.comAdeel Rasul Iqbalaiqbal@uclink.berkeley.eduKeunwoo Leeklee@cs.washington.eduThanh Nhut Nguyenttnguye
Washington - CSEP - 590
Homeland Security / Cyber Security Autumn 2005 Course Project (&quot;White Paper&quot;) Assignment, and Topic SuggestionsVersion 5: November 2 White Paper (~55%): Teams of 3-5 students will provide a comprehensive report describing a particular threat, assess