Theory of Computation CSCI 3434, Spring 2010

Size: px
Start display at page:

Download "Theory of Computation CSCI 3434, Spring 2010"

Transcription

1 Homework 3: Solutions Theory of Computation CSCI 3434, Spring This was listed as a question to make it clear that you would lose points if you did not answer these questions or work with another student in the class. Some of the content in these solutions was taken from wikipedia. 2. Construct CFGs for the following languages over Σ = {0, 1}: a. L = odd-length strings whose first, middle, and last characters are all the same S 0A0 1B1 0 1 A 0A0 0A1 1A0 1A1 0 B 0B0 0B1 1B0 1B1 1 The string is built from the outside in. Initially, first and last characters are set alike. Then, if there s more than one character, any pairs of characters can be added, but it ends with the same character as the first and last given for the middle character. b. L = {0 m 1 n m n} S 0S1 A B 0 1 A 0A 0 B 1B 1 S builds equal numbers of 0 s and 1 s, then ends with an additional 0 or 1 to prevent having the same number. To get more than one additional 0 or 1, A adds unlimited 0 s and B adds unlimited 1 s. c. L = {x x x R (x is not a palindrome)} S 0S0 1S1 A A 0B1 1B B 0B0 0B1 1B0 1B1 1 0 ε The string is built from the outside in. The variable A, which must be used in a derivation of a final string, ensures that the string is not a palindrome 3. Describe the languages generated by: a. S ASA A ε A 00 ε L = {x x is a string of 0's of even length, including length zero} = (00)*

2 b. S 0S1 SS ε L = {x x has the same number of 0 s and 1 s, and every prefix has at least as many 0 s as 1 s } This is equivalent to the language of well-formed parentheses, with 0={ and 1=}. c. S T0T T TT 0T1 1T0 0 ε L = {x x has more 0 s than 1's} 4. Construct PDAs for the following languages over Σ = {0, 1}: a. L = {x x x R (x is not a palindrome)} 0, ε : push 0 1, ε : push 1 0, 0 : pop a, a : pop 1, 1 : pop A ε, a : pop B a, b {0,1} 0, 1 : pop C 0, 1 : pop EBN D a, b : pop State A reads the first half of the string, including the middle character for oddlength strings. State B reads the 2 nd half of the string while the portion read so far is palindromic with the end of the 1 st half. State C is entered when the string has been confirmed not to be a palindrome. If the end of string is encountered at the same time as the stack bottom, then the guess for when to transition out of state A was correct, and if already in state C, the string can be accepted. b. L = strings containing as many 1s as 0s 0, A : push 0 A {0, BOT} 1, B : push 1 B {1, BOT} 0, 1 : pop EBN

3 At any point, the stack contains only 0s or only 1s. A 0 is popped when a 1 is read, and vice versa, ensuring there are the same number of 1s as 0s. c. L = {0 m 1 m+n 0 n m, n 0} 1, BOT : push 1 (m=0) 0, ε : push 1, ε : push 1 1, BOT : push 1 EBN (m=n=0) EBN (n=0) EBN 0, 1 : pop 0, 1 : pop Initially, 0s are pushed onto the stack until a 1 is seen. Then an equal number of 1s can pop (m ) 0s, at which point any remaining 1s are pushed. These are balanced by final 0s, which pop the 1s. There are additional transitions (indicated) to account for m and/or n equal to 0. d. L = {0 n x x n } 0, ε : push 0 EOS, ε : NoOp a, 0 : pop a {0,1} EOS, ε : NoOp Since the length of x must be no more than the initial string of 0s, we may as well include all initial 0s in this portion of the string, forcing x to begin with a 1. We push all the initial 0s onto the stack, and pop them off for any character in x. We accept if we reach the end of the input string without first prematurely hitting the bottom of the stack. 5. Prove the following languages are not CFL: a. L = {0 m 1 n 2 p m = n+p} this is actually CF. Think of a PDA that pushes 0s, then pops 1s then pops 2s. b. L = {0 m 1 n 2 p m n+p} this is actually also CF. Think of a similar PDA as the one in 5a, but that only accepts if the stack isn t empty at EOS (more 0s) or if the stack becomes empty before reading all 1s and 2s (fewer 0s).

4 c. L = {0 m 1 n 2 p m < n < p} This is CF. Sketch of proof (see 6.2 for format of a complete proof): Consider the string x = 0 k 1 k+1 2 k +2 = uvwyz. The 2 locations to pump (v and y) cannot span all 3 regions (0s, 1s, and 2s), so cannot include both 0s and 2s. Anywhere v and y could be, either pumping up will yield too many 0s or 1s for the number of 2s (if no 2s pumped), or pumping down will yield not enough 1s or 2s for the number of 0s (if no 0s pumped) 6. Ex. 3.6, parts 1 and 2 on pp Prove your answers. Which of the following languages are context-free? 1. L 10 = {a i b j a j b i i,j 0 } Context free. It can be generated by the context free grammar: S asb A ε A baa 2. L 11 = {a i b j a i b j i,j 0 } This is not context free. Use the pumping lemma to justify this. Proof: Assume L 11 is context-free. Let k be the constant from the pumping lemma. Consider the string x = a k b k+1 a k b k +1. Think of x as comprised of 4 groups of characters: a group of a s followed by a group of b s followed by another group of a s followed by another group of b s. Then uvwyz = x with vy 1, vwy k, and uv i wy i z L i N. So v and y are either entirely within one group or within two consecutive groups. Consider u v 2 w y 2 z. If v or y contain both an a and a b, then we end up with more than 4 groups, and u v 2 w y 2 z is not in L 11. So both v and y must contain only one type of character. If u v 2 w y 2 z adds additional a s to one group of a s, it cannot also add to the other group of a s, so u v 2 w y 2 z is not in L 11. Similarly, if u v 2 w y 2 z adds additional b s to one group of b s, it cannot also add to the other group of b s, so u v 2 w y 2 z is not in L 11. We have considered all possibilities for v and y, and none would allow u v 2 w y 2 z to be in L 11. So we have a contradiction, and L 11 is not context-free. 7. Give a regular grammar that generates the same language as the following CFGs:

5 a. S as Sb ε Any number of a s can be placed before the growing point (S), and any number of b s can be placed after it. Thus, the language is a*b*. An equivalent regular grammar is: S as A ε A ba ε b. S SSS a ab An equivalent regular grammar is: S aa aba a ab A ab abb B aa aba a ab c. S AB A aaa bab a b B ab bb ε This grammar gives a palindrome of length at least one, followed by a*b*. The key thing to notice is that any string of length at least one begins with a palindrome of length at least one, since the first character is a palindrome regardless of whether there s a longer palindromic prefix. This makes the language (a,b) +. An equivalent regular grammar is: S as bs a b 8. Recall that there are CFLs that can only be generated by an ambiguous CFG and CFLs that can only be generated by a nondeterministic PDA. How does the set of inherently ambiguous CFLs relate to the set of nondeterministic CFLs (are they equal, disjoint, overlapping, or is one contained in the other)? The set of inherently ambiguous CFLs is a proper subset of the set of nondeterministic CFLs. This can be seen because any CFG created from a DPDA using the method shown in class will be unambiguous: the leftmost character of every substring can have been generated by only one nonterminal, since the machine for the grammar was deterministic. As discussed in class, the language of palindromes is a nondeterministic CFL (the middle of the word must be "guessed" by a PDA), but it is not inherently ambiguous (each word can be generated by only one sequence of rules S 0S0 1S1 0 1 ε ). This implies that ambiguous languages and deterministic languages are not equal, so ambiguous CFLs nondeterministic CFLs. NOTE that a nondeterministic CFL cannot be generated by a deterministic PDA. Any CFL can be generated by a nondeterministic PDA, but here we are interested only in those that can only be generated by a nondeterministic PDA (and cannot be generated by a deterministic PDA).

6 9. Ex. 3.7 on p. 87. Even if A and B are both context-free, A B may not be. Prove this by giving an example of two context-free languages whose intersection is not context-free. Consider the two CFLs A and B where A = {a m b n c n m, n 0}, generated by the CFG: S as A ε A ba c ε and B = {a m b m c n m, n 0}, generated by the CFG: S Sc A ε A aa b ε The intersection is A B = {a n b n c n n 0} As shown in class this language is not a CFL. 10. Describe these conventions for CFGs (you will need to use a book or google): a. Chomsky normal form Grammars in Chomsky Normal Form (CNF) contain only production rules of the forms A BC or A a or S ε with A, B, C, and S nonterminals, S the start symbol, a a terminal symbol, neither B nor C can be S. This form simplifies parsing, and there are common algorithms (such as CYK) that can efficiently parse a string to determine if it is in the language described by a CFG in CNF. All CFGs can be written in CNF. b. Backus-Naur form BNF is a format for CFGs (a metasyntax), which places both nonterminals and some terminals (those generated by some rule outside the grammar, for example by regular expressions) inside angle brackets (allowing meaningful symbol names). Literals within the grammar are placed in quotes. Rules are written with a nonterminal on the left, followed by ::=, followed by the productions for the rule, separated by. Terminals are identifiable because they never appear on the left of any rule. c. Greibach normal form Grammars in Greibech Normal Form contain only production rules of the form A a X or S ε with A and S nonterminals, S the start symbol, X a (possibly empty) sequence of nonterminals, S X, a is a terminal symbol. This grammar prevents left-recursions, which can simplify parsing. All CFGs can be written in GNF. 11. Prove that any CFL can be generated by a CFG in Chomsky normal form.

7 idea: Given any CFG G, construct G' in CNF with L(G) = L(G ) by replacing rules not in CNF with additional rules (and nonterminals) as follows: add new start symbol with only rule going to previous start symbol (this will be fixed later) remove A ε (new S ε can stay) by adding new rules for each rule with A on right-hand-side (RHS). iterate this step (doing this can create new A ε rules) similarly, remove rules A B by adding new rules for any rule with B on LHS. iterate this step. replace long rules with a chain of shorter rules, replacing terminals on RHS with new nonterminals with rule sending this new nonterminal to the terminal symbol it replaced. 12. In class we showed that L(CFG) L(PDA), that the language generated by any CFG could be generated by a PDA. Complete the proof that L(CFG) = L(PDA). To complete this proof, we need to show that L(PDA) L(CFG). The proof is by construction; for an arbitrary PDA M we generate a CFG G that generates exactly the strings recognized by M. Given a PDA M = (Σ, Γ, Q, q 0, q F, δ). We require that M empties its stack before accepting, but we can simply add a pre-accept state to do this. We require M to have a single accept state, which we can achieve with an ε -transition from all accept states to a new single accept state (or pre-accept state). M is also required to either push or pop (not both) a single stack symbol at every transition. This requires splitting states for all NoOp transitions to push and then pop an arbitrary symbol). We construct G as follows. We include a nonterminal A pq for all pairs of states p, q Q. The productions from A pq are all strings that cause M to transition from p to q with empty stacks (from state p with an empty stack, reading a substring causes a sequence of transitions that push and pop characters onto the stack, ending with a pop that empties the stack going to state q). G's start symbol is

8 A q0 q F, corresponding to starting at the start state with an empty stack and ending at the final state with an empty stack. The above constraints on M allow us to say some things about its processing between p and q with an empty stack in both states: 1. The move out of p is a push 2. The move into q is a pop 3. Either the symbol popped for q is (a) the same as the one pushed in p (in which case the stack was never empty between p and q) (b) different from the one pushed in p (in which case the stack was empty at some point between p and q) G can simulate case (a) with a rule A pq a A rs b with a, b Σ, the symbols read out of p and into q, respectively; and r and s the states after p and before q, respectively. We effectively define the symbol pushed in state p as the new bottom of the stack, since it is never removed until state q (so it is not removed anywhere between r and s). a or b or both can be ε. case (b) is simply: A pq A pr A rq with r the state where the stack becomes empty. Through successive application of these two types of rules the grammar builds a string accepted by M from both ends (A rs is not needed where there is only one state between p and q, so the grammar eventually finishes). Therefore L(G) = L(M), and L(PDA) L(CFG). 13. What does this TM do? Annotate it appropriately.

9 0 : 0R 1 : 1R 0 : 0L 0 : 1L : 0L 1 : 1R 1 : 0L A B C E 1 : 0L F : R 1 : 1L D 0 : 1L : 1R 1 : 1R 1 : 0L I G 0 : 1L H This TM multiplies an input binary number by 3. Idea: Multiply by 2 and add the original number to the result Multiply by 2 by appending a 0. Add the original number to the doubled number: starting from the right, in each position put the sum of the digit there and the digit to the left. State A: move to the end of the string A B transition: append a 0, thereby doubling the input string State B: no bit is being carried State F: a carried bit must be remembered State I: multiplication completed B loop: Add 0 to char to right, so no need to change anything. States B, C, D, E, F, G, H: Add original number to get a multiple of 3. B, D, D Loop: Simple add of a 1 to the number before it. B C: Read 1 to add to character to right. C D: 1 to be added to 0; do it. D B: move past added 1 to see next character to be added. C E F: 1 to be added to 1; do it and move to carry states. State F: reads next character to add to the character to the right (carrying a 1) B, C, E, F Loop: Add with one carry F, G, H Loop: Allows for multiple carries

10 F B: Add 0 to char to right, no need to change char to right, but change this 0 to 1 and get out of carry state. F G: Read 1 to add to character to right. G H: character to right must be 0 (see all entries to this loop), change it to 1. H F: Change added 1 to 0 to propagate carry. NOTE: Question 14 appeared only on the challenge version. 14. Prove your answers. In question 9 above you showed that context-free languages are not closed under union. Are context-free languages closed under: NOTE that there is a mistake in this question. Question 9 showed that context-free languages are not closed under intersection. Context Free languages are closed under union. a. concatenation? Yes. Consider CFGs for two CFLs, L 1 and L 2. Place a subscript on the nonterminals for both L 1 and L 2 to avoid ambiguity. Then for L = L 1 L 2, create a new rule S S 1 S 2, with S the start symbol for L. Include all rules for L1 and L2. Since all rules in L are context-free (either S S 1 S 2 is context-free, as are all rules from L 1 and L 2 ), L is context-free. b. complementation? No. This is a result of the union and intersection closure properties. Let L c indicate the complement of L. Assume that CFLs are closed under complementation. Then if L 1 and L 2 are context-free, so are L 1 c and L2 c. Then (L1 c L2 c ) must be context-free, and so must (L 1 c L2 c ) c = L1 L 2 by De Morgan's theorems. However, we know L 1 and L 2 is not necessarily context-free, a contradiction, so context-free languages are not closed under complementation. c. Kleene closure? Yes. To obtain L* create a new start symbol S with rules S SS ε, with S the start symbol for L, with S the start symbol for L, and include all the rules for L. The new grammar is context-free (The added rules for S are context-free as are the rules for L) and generates L*.

Automata and Computability. Solutions to Exercises

Automata and Computability. Solutions to Exercises Automata and Computability Solutions to Exercises Fall 25 Alexis Maciel Department of Computer Science Clarkson University Copyright c 25 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata

More information

Pushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, 2014. School of Informatics University of Edinburgh als@inf.ed.ac.

Pushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, 2014. School of Informatics University of Edinburgh als@inf.ed.ac. Pushdown automata Informatics 2A: Lecture 9 Alex Simpson School of Informatics University of Edinburgh als@inf.ed.ac.uk 3 October, 2014 1 / 17 Recap of lecture 8 Context-free languages are defined by context-free

More information

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Samarjit Chakraborty Computer Engineering and Networks Laboratory Swiss Federal Institute of Technology (ETH) Zürich March

More information

ÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK. 15 april 2003. Master Edition

ÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK. 15 april 2003. Master Edition ÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK 5 april 23 Master Edition CONTEXT FREE LANGUAGES & PUSH-DOWN AUTOMATA CONTEXT-FREE GRAMMARS, CFG Problems Sudkamp Problem. (3.2.) Which language generates the grammar

More information

(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems.

(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems. 3130CIT: Theory of Computation Turing machines and undecidability (IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems. An undecidable problem

More information

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010. Class 4 Nancy Lynch

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010. Class 4 Nancy Lynch 6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010 Class 4 Nancy Lynch Today Two more models of computation: Nondeterministic Finite Automata (NFAs)

More information

Pushdown Automata. place the input head on the leftmost input symbol. while symbol read = b and pile contains discs advance head remove disc from pile

Pushdown Automata. place the input head on the leftmost input symbol. while symbol read = b and pile contains discs advance head remove disc from pile Pushdown Automata In the last section we found that restricting the computational power of computing devices produced solvable decision problems for the class of sets accepted by finite automata. But along

More information

C H A P T E R Regular Expressions regular expression

C H A P T E R Regular Expressions regular expression 7 CHAPTER Regular Expressions Most programmers and other power-users of computer systems have used tools that match text patterns. You may have used a Web search engine with a pattern like travel cancun

More information

CS103B Handout 17 Winter 2007 February 26, 2007 Languages and Regular Expressions

CS103B Handout 17 Winter 2007 February 26, 2007 Languages and Regular Expressions CS103B Handout 17 Winter 2007 February 26, 2007 Languages and Regular Expressions Theory of Formal Languages In the English language, we distinguish between three different identities: letter, word, sentence.

More information

Honors Class (Foundations of) Informatics. Tom Verhoeff. Department of Mathematics & Computer Science Software Engineering & Technology

Honors Class (Foundations of) Informatics. Tom Verhoeff. Department of Mathematics & Computer Science Software Engineering & Technology Honors Class (Foundations of) Informatics Tom Verhoeff Department of Mathematics & Computer Science Software Engineering & Technology www.win.tue.nl/~wstomv/edu/hci c 2011, T. Verhoeff @ TUE.NL 1/20 Information

More information

Automata and Formal Languages

Automata and Formal Languages Automata and Formal Languages Winter 2009-2010 Yacov Hel-Or 1 What this course is all about This course is about mathematical models of computation We ll study different machine models (finite automata,

More information

Reading 13 : Finite State Automata and Regular Expressions

Reading 13 : Finite State Automata and Regular Expressions CS/Math 24: Introduction to Discrete Mathematics Fall 25 Reading 3 : Finite State Automata and Regular Expressions Instructors: Beck Hasti, Gautam Prakriya In this reading we study a mathematical model

More information

Chapter 7 Uncomputability

Chapter 7 Uncomputability Chapter 7 Uncomputability 190 7.1 Introduction Undecidability of concrete problems. First undecidable problem obtained by diagonalisation. Other undecidable problems obtained by means of the reduction

More information

CMPSCI 250: Introduction to Computation. Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013

CMPSCI 250: Introduction to Computation. Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013 CMPSCI 250: Introduction to Computation Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013 Regular Expressions and Their Languages Alphabets, Strings and Languages

More information

Regular Expressions and Automata using Haskell

Regular Expressions and Automata using Haskell Regular Expressions and Automata using Haskell Simon Thompson Computing Laboratory University of Kent at Canterbury January 2000 Contents 1 Introduction 2 2 Regular Expressions 2 3 Matching regular expressions

More information

The Halting Problem is Undecidable

The Halting Problem is Undecidable 185 Corollary G = { M, w w L(M) } is not Turing-recognizable. Proof. = ERR, where ERR is the easy to decide language: ERR = { x { 0, 1 }* x does not have a prefix that is a valid code for a Turing machine

More information

Turing Machines, Part I

Turing Machines, Part I Turing Machines, Part I Languages The $64,000 Question What is a language? What is a class of languages? Computer Science Theory 2 1 Now our picture looks like Context Free Languages Deterministic Context

More information

Formal Grammars and Languages

Formal Grammars and Languages Formal Grammars and Languages Tao Jiang Department of Computer Science McMaster University Hamilton, Ontario L8S 4K1, Canada Bala Ravikumar Department of Computer Science University of Rhode Island Kingston,

More information

Scanner. tokens scanner parser IR. source code. errors

Scanner. tokens scanner parser IR. source code. errors Scanner source code tokens scanner parser IR errors maps characters into tokens the basic unit of syntax x = x + y; becomes = + ; character string value for a token is a lexeme

More information

Fast nondeterministic recognition of context-free languages using two queues

Fast nondeterministic recognition of context-free languages using two queues Fast nondeterministic recognition of context-free languages using two queues Burton Rosenberg University of Miami Abstract We show how to accept a context-free language nondeterministically in O( n log

More information

Regular Languages and Finite Automata

Regular Languages and Finite Automata Regular Languages and Finite Automata 1 Introduction Hing Leung Department of Computer Science New Mexico State University Sep 16, 2010 In 1943, McCulloch and Pitts [4] published a pioneering work on a

More information

CS5236 Advanced Automata Theory

CS5236 Advanced Automata Theory CS5236 Advanced Automata Theory Frank Stephan Semester I, Academic Year 2012-2013 Advanced Automata Theory is a lecture which will first review the basics of formal languages and automata theory and then

More information

3515ICT Theory of Computation Turing Machines

3515ICT Theory of Computation Turing Machines Griffith University 3515ICT Theory of Computation Turing Machines (Based loosely on slides by Harald Søndergaard of The University of Melbourne) 9-0 Overview Turing machines: a general model of computation

More information

6.080/6.089 GITCS Feb 12, 2008. Lecture 3

6.080/6.089 GITCS Feb 12, 2008. Lecture 3 6.8/6.89 GITCS Feb 2, 28 Lecturer: Scott Aaronson Lecture 3 Scribe: Adam Rogal Administrivia. Scribe notes The purpose of scribe notes is to transcribe our lectures. Although I have formal notes of my

More information

COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing

COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing The scanner (or lexical analyzer) of a compiler processes the source program, recognizing

More information

1 Approximating Set Cover

1 Approximating Set Cover CS 05: Algorithms (Grad) Feb 2-24, 2005 Approximating Set Cover. Definition An Instance (X, F ) of the set-covering problem consists of a finite set X and a family F of subset of X, such that every elemennt

More information

Model 2.4 Faculty member + student

Model 2.4 Faculty member + student Model 2.4 Faculty member + student Course syllabus for Formal languages and Automata Theory. Faculty member information: Name of faculty member responsible for the course Office Hours Office Number Email

More information

CPS 140 - Mathematical Foundations of CS Dr. S. Rodger Section: Properties of Context-Free Languages èhandoutè Section 3.5 Which of the following languages are CFL? æ L=fa n b n c j j 0 énçjg æ L=fa n

More information

CS 103X: Discrete Structures Homework Assignment 3 Solutions

CS 103X: Discrete Structures Homework Assignment 3 Solutions CS 103X: Discrete Structures Homework Assignment 3 s Exercise 1 (20 points). On well-ordering and induction: (a) Prove the induction principle from the well-ordering principle. (b) Prove the well-ordering

More information

Regular Languages and Finite State Machines

Regular Languages and Finite State Machines Regular Languages and Finite State Machines Plan for the Day: Mathematical preliminaries - some review One application formal definition of finite automata Examples 1 Sets A set is an unordered collection

More information

Push-down Automata and Context-free Grammars

Push-down Automata and Context-free Grammars 14 Push-down Automata and Context-free Grammars This chapter details the design of push-down automata (PDA) for various languages, the conversion of CFGs to PDAs, and vice versa. In particular, after formally

More information

MATH10040 Chapter 2: Prime and relatively prime numbers

MATH10040 Chapter 2: Prime and relatively prime numbers MATH10040 Chapter 2: Prime and relatively prime numbers Recall the basic definition: 1. Prime numbers Definition 1.1. Recall that a positive integer is said to be prime if it has precisely two positive

More information

INCIDENCE-BETWEENNESS GEOMETRY

INCIDENCE-BETWEENNESS GEOMETRY INCIDENCE-BETWEENNESS GEOMETRY MATH 410, CSUSM. SPRING 2008. PROFESSOR AITKEN This document covers the geometry that can be developed with just the axioms related to incidence and betweenness. The full

More information

CS154. Turing Machines. Turing Machine. Turing Machines versus DFAs FINITE STATE CONTROL AI N P U T INFINITE TAPE. read write move.

CS154. Turing Machines. Turing Machine. Turing Machines versus DFAs FINITE STATE CONTROL AI N P U T INFINITE TAPE. read write move. CS54 Turing Machines Turing Machine q 0 AI N P U T IN TAPE read write move read write move Language = {0} q This Turing machine recognizes the language {0} Turing Machines versus DFAs TM can both write

More information

a 11 x 1 + a 12 x 2 + + a 1n x n = b 1 a 21 x 1 + a 22 x 2 + + a 2n x n = b 2.

a 11 x 1 + a 12 x 2 + + a 1n x n = b 1 a 21 x 1 + a 22 x 2 + + a 2n x n = b 2. Chapter 1 LINEAR EQUATIONS 1.1 Introduction to linear equations A linear equation in n unknowns x 1, x,, x n is an equation of the form a 1 x 1 + a x + + a n x n = b, where a 1, a,..., a n, b are given

More information

Philadelphia University Faculty of Information Technology Department of Computer Science First Semester, 2007/2008.

Philadelphia University Faculty of Information Technology Department of Computer Science First Semester, 2007/2008. Philadelphia University Faculty of Information Technology Department of Computer Science First Semester, 2007/2008 Course Syllabus Course Title: Theory of Computation Course Level: 3 Lecture Time: Course

More information

Automata on Infinite Words and Trees

Automata on Infinite Words and Trees Automata on Infinite Words and Trees Course notes for the course Automata on Infinite Words and Trees given by Dr. Meghyn Bienvenu at Universität Bremen in the 2009-2010 winter semester Last modified:

More information

1 Definition of a Turing machine

1 Definition of a Turing machine Introduction to Algorithms Notes on Turing Machines CS 4820, Spring 2012 April 2-16, 2012 1 Definition of a Turing machine Turing machines are an abstract model of computation. They provide a precise,

More information

2110711 THEORY of COMPUTATION

2110711 THEORY of COMPUTATION 2110711 THEORY of COMPUTATION ATHASIT SURARERKS ELITE Athasit Surarerks ELITE Engineering Laboratory in Theoretical Enumerable System Computer Engineering, Faculty of Engineering Chulalongkorn University

More information

SRM UNIVERSITY FACULTY OF ENGINEERING & TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF SOFTWARE ENGINEERING COURSE PLAN

SRM UNIVERSITY FACULTY OF ENGINEERING & TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF SOFTWARE ENGINEERING COURSE PLAN Course Code : CS0355 SRM UNIVERSITY FACULTY OF ENGINEERING & TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF SOFTWARE ENGINEERING COURSE PLAN Course Title : THEORY OF COMPUTATION Semester : VI Course : June

More information

CPSC 121: Models of Computation Assignment #4, due Wednesday, July 22nd, 2009 at 14:00

CPSC 121: Models of Computation Assignment #4, due Wednesday, July 22nd, 2009 at 14:00 CPSC 2: Models of Computation ssignment #4, due Wednesday, July 22nd, 29 at 4: Submission Instructions Type or write your assignment on clean sheets of paper with question numbers prominently labeled.

More information

Lecture summary for Theory of Computation

Lecture summary for Theory of Computation Lecture summary for Theory of Computation Sandeep Sen 1 January 8, 2015 1 Department of Computer Science and Engineering, IIT Delhi, New Delhi 110016, India. E- mail:ssen@cse.iitd.ernet.in Contents 1 The

More information

Fundamentele Informatica II

Fundamentele Informatica II Fundamentele Informatica II Answer to selected exercises 1 John C Martin: Introduction to Languages and the Theory of Computation M.M. Bonsangue (and J. Kleijn) Fall 2011 Let L be a language. It is clear

More information

NP-Completeness and Cook s Theorem

NP-Completeness and Cook s Theorem NP-Completeness and Cook s Theorem Lecture notes for COM3412 Logic and Computation 15th January 2002 1 NP decision problems The decision problem D L for a formal language L Σ is the computational task:

More information

Base Conversion written by Cathy Saxton

Base Conversion written by Cathy Saxton Base Conversion written by Cathy Saxton 1. Base 10 In base 10, the digits, from right to left, specify the 1 s, 10 s, 100 s, 1000 s, etc. These are powers of 10 (10 x ): 10 0 = 1, 10 1 = 10, 10 2 = 100,

More information

Compiler Construction

Compiler Construction Compiler Construction Regular expressions Scanning Görel Hedin Reviderad 2013 01 23.a 2013 Compiler Construction 2013 F02-1 Compiler overview source code lexical analysis tokens intermediate code generation

More information

CSE 135: Introduction to Theory of Computation Decidability and Recognizability

CSE 135: Introduction to Theory of Computation Decidability and Recognizability CSE 135: Introduction to Theory of Computation Decidability and Recognizability Sungjin Im University of California, Merced 04-28, 30-2014 High-Level Descriptions of Computation Instead of giving a Turing

More information

Lecture 2: Universality

Lecture 2: Universality CS 710: Complexity Theory 1/21/2010 Lecture 2: Universality Instructor: Dieter van Melkebeek Scribe: Tyson Williams In this lecture, we introduce the notion of a universal machine, develop efficient universal

More information

Lecture 2: Regular Languages [Fa 14]

Lecture 2: Regular Languages [Fa 14] Caveat lector: This is the first edition of this lecture note. Please send bug reports and suggestions to jeffe@illinois.edu. But the Lord came down to see the city and the tower the people were building.

More information

How To Compare A Markov Algorithm To A Turing Machine

How To Compare A Markov Algorithm To A Turing Machine Markov Algorithm CHEN Yuanmi December 18, 2007 1 Abstract Markov Algorithm can be understood as a priority string rewriting system. In this short paper we give the definition of Markov algorithm and also

More information

6.3 Conditional Probability and Independence

6.3 Conditional Probability and Independence 222 CHAPTER 6. PROBABILITY 6.3 Conditional Probability and Independence Conditional Probability Two cubical dice each have a triangle painted on one side, a circle painted on two sides and a square painted

More information

Mathematical Induction

Mathematical Induction Mathematical Induction (Handout March 8, 01) The Principle of Mathematical Induction provides a means to prove infinitely many statements all at once The principle is logical rather than strictly mathematical,

More information

Finite Automata and Regular Languages

Finite Automata and Regular Languages CHAPTER 3 Finite Automata and Regular Languages 3. Introduction 3.. States and Automata A finite-state machine or finite automaton (the noun comes from the Greek; the singular is automaton, the Greek-derived

More information

Continued Fractions and the Euclidean Algorithm

Continued Fractions and the Euclidean Algorithm Continued Fractions and the Euclidean Algorithm Lecture notes prepared for MATH 326, Spring 997 Department of Mathematics and Statistics University at Albany William F Hammond Table of Contents Introduction

More information

ASSIGNMENT ONE SOLUTIONS MATH 4805 / COMP 4805 / MATH 5605

ASSIGNMENT ONE SOLUTIONS MATH 4805 / COMP 4805 / MATH 5605 ASSIGNMENT ONE SOLUTIONS MATH 4805 / COMP 4805 / MATH 5605 (1) (a) (0 + 1) 010 (finite automata below). (b) First observe that the following regular expression generates the binary strings with an even

More information

14.1 Rent-or-buy problem

14.1 Rent-or-buy problem CS787: Advanced Algorithms Lecture 14: Online algorithms We now shift focus to a different kind of algorithmic problem where we need to perform some optimization without knowing the input in advance. Algorithms

More information

Computability Theory

Computability Theory CSC 438F/2404F Notes (S. Cook and T. Pitassi) Fall, 2014 Computability Theory This section is partly inspired by the material in A Course in Mathematical Logic by Bell and Machover, Chap 6, sections 1-10.

More information

Basic Parsing Algorithms Chart Parsing

Basic Parsing Algorithms Chart Parsing Basic Parsing Algorithms Chart Parsing Seminar Recent Advances in Parsing Technology WS 2011/2012 Anna Schmidt Talk Outline Chart Parsing Basics Chart Parsing Algorithms Earley Algorithm CKY Algorithm

More information

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 2. x n. a 11 a 12 a 1n b 1 a 21 a 22 a 2n b 2 a 31 a 32 a 3n b 3. a m1 a m2 a mn b m

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 2. x n. a 11 a 12 a 1n b 1 a 21 a 22 a 2n b 2 a 31 a 32 a 3n b 3. a m1 a m2 a mn b m MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS 1. SYSTEMS OF EQUATIONS AND MATRICES 1.1. Representation of a linear system. The general system of m equations in n unknowns can be written a 11 x 1 + a 12 x 2 +

More information

Notes on Complexity Theory Last updated: August, 2011. Lecture 1

Notes on Complexity Theory Last updated: August, 2011. Lecture 1 Notes on Complexity Theory Last updated: August, 2011 Jonathan Katz Lecture 1 1 Turing Machines I assume that most students have encountered Turing machines before. (Students who have not may want to look

More information

CS 3719 (Theory of Computation and Algorithms) Lecture 4

CS 3719 (Theory of Computation and Algorithms) Lecture 4 CS 3719 (Theory of Computation and Algorithms) Lecture 4 Antonina Kolokolova January 18, 2012 1 Undecidable languages 1.1 Church-Turing thesis Let s recap how it all started. In 1990, Hilbert stated a

More information

CAs and Turing Machines. The Basis for Universal Computation

CAs and Turing Machines. The Basis for Universal Computation CAs and Turing Machines The Basis for Universal Computation What We Mean By Universal When we claim universal computation we mean that the CA is capable of calculating anything that could possibly be calculated*.

More information

Lempel-Ziv Coding Adaptive Dictionary Compression Algorithm

Lempel-Ziv Coding Adaptive Dictionary Compression Algorithm Lempel-Ziv Coding Adaptive Dictionary Compression Algorithm 1. LZ77:Sliding Window Lempel-Ziv Algorithm [gzip, pkzip] Encode a string by finding the longest match anywhere within a window of past symbols

More information

THE TURING DEGREES AND THEIR LACK OF LINEAR ORDER

THE TURING DEGREES AND THEIR LACK OF LINEAR ORDER THE TURING DEGREES AND THEIR LACK OF LINEAR ORDER JASPER DEANTONIO Abstract. This paper is a study of the Turing Degrees, which are levels of incomputability naturally arising from sets of natural numbers.

More information

3. Mathematical Induction

3. Mathematical Induction 3. MATHEMATICAL INDUCTION 83 3. Mathematical Induction 3.1. First Principle of Mathematical Induction. Let P (n) be a predicate with domain of discourse (over) the natural numbers N = {0, 1,,...}. If (1)

More information

Increasing Interaction and Support in the Formal Languages and Automata Theory Course

Increasing Interaction and Support in the Formal Languages and Automata Theory Course Increasing Interaction and Support in the Formal Languages and Automata Theory Course Susan H. Rodger Duke University ITiCSE 2007 June 25, 2007 Supported by NSF Grant DUE 0442513. Outline Overview of JFLAP

More information

Homework until Test #2

Homework until Test #2 MATH31: Number Theory Homework until Test # Philipp BRAUN Section 3.1 page 43, 1. It has been conjectured that there are infinitely many primes of the form n. Exhibit five such primes. Solution. Five such

More information

Solution to Homework 2

Solution to Homework 2 Solution to Homework 2 Olena Bormashenko September 23, 2011 Section 1.4: 1(a)(b)(i)(k), 4, 5, 14; Section 1.5: 1(a)(b)(c)(d)(e)(n), 2(a)(c), 13, 16, 17, 18, 27 Section 1.4 1. Compute the following, if

More information

8 Divisibility and prime numbers

8 Divisibility and prime numbers 8 Divisibility and prime numbers 8.1 Divisibility In this short section we extend the concept of a multiple from the natural numbers to the integers. We also summarize several other terms that express

More information

4. FIRST STEPS IN THE THEORY 4.1. A

4. FIRST STEPS IN THE THEORY 4.1. A 4. FIRST STEPS IN THE THEORY 4.1. A Catalogue of All Groups: The Impossible Dream The fundamental problem of group theory is to systematically explore the landscape and to chart what lies out there. We

More information

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson Mathematics for Computer Science/Software Engineering Notes for the course MSM1F3 Dr. R. A. Wilson October 1996 Chapter 1 Logic Lecture no. 1. We introduce the concept of a proposition, which is a statement

More information

CSC4510 AUTOMATA 2.1 Finite Automata: Examples and D efinitions Definitions

CSC4510 AUTOMATA 2.1 Finite Automata: Examples and D efinitions Definitions CSC45 AUTOMATA 2. Finite Automata: Examples and Definitions Finite Automata: Examples and Definitions A finite automaton is a simple type of computer. Itsoutputislimitedto yes to or no. It has very primitive

More information

The Goldberg Rao Algorithm for the Maximum Flow Problem

The Goldberg Rao Algorithm for the Maximum Flow Problem The Goldberg Rao Algorithm for the Maximum Flow Problem COS 528 class notes October 18, 2006 Scribe: Dávid Papp Main idea: use of the blocking flow paradigm to achieve essentially O(min{m 2/3, n 1/2 }

More information

Ambiguity, closure properties, Overview of ambiguity, and Chomsky s standard form

Ambiguity, closure properties, Overview of ambiguity, and Chomsky s standard form Ambiguity, closure properties, and Chomsky s normal form Overview of ambiguity, and Chomsky s standard form The notion of ambiguity Convention: we assume that in every substitution, the leftmost remaining

More information

Quotient Rings and Field Extensions

Quotient Rings and Field Extensions Chapter 5 Quotient Rings and Field Extensions In this chapter we describe a method for producing field extension of a given field. If F is a field, then a field extension is a field K that contains F.

More information

SECTION 10-2 Mathematical Induction

SECTION 10-2 Mathematical Induction 73 0 Sequences and Series 6. Approximate e 0. using the first five terms of the series. Compare this approximation with your calculator evaluation of e 0.. 6. Approximate e 0.5 using the first five terms

More information

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS Systems of Equations and Matrices Representation of a linear system The general system of m equations in n unknowns can be written a x + a 2 x 2 + + a n x n b a

More information

Pigeonhole Principle Solutions

Pigeonhole Principle Solutions Pigeonhole Principle Solutions 1. Show that if we take n + 1 numbers from the set {1, 2,..., 2n}, then some pair of numbers will have no factors in common. Solution: Note that consecutive numbers (such

More information

Computational Models Lecture 8, Spring 2009

Computational Models Lecture 8, Spring 2009 Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown Univ. p. 1 Computational Models Lecture 8, Spring 2009 Encoding of TMs Universal Turing Machines The Halting/Acceptance

More information

Finite Automata. Reading: Chapter 2

Finite Automata. Reading: Chapter 2 Finite Automata Reading: Chapter 2 1 Finite Automaton (FA) Informally, a state diagram that comprehensively captures all possible states and transitions that a machine can take while responding to a stream

More information

Solutions for Practice problems on proofs

Solutions for Practice problems on proofs Solutions for Practice problems on proofs Definition: (even) An integer n Z is even if and only if n = 2m for some number m Z. Definition: (odd) An integer n Z is odd if and only if n = 2m + 1 for some

More information

SOLUTION Trial Test Grammar & Parsing Deficiency Course for the Master in Software Technology Programme Utrecht University

SOLUTION Trial Test Grammar & Parsing Deficiency Course for the Master in Software Technology Programme Utrecht University SOLUTION Trial Test Grammar & Parsing Deficiency Course for the Master in Software Technology Programme Utrecht University Year 2004/2005 1. (a) LM is a language that consists of sentences of L continued

More information

Bottom-Up Parsing. An Introductory Example

Bottom-Up Parsing. An Introductory Example Bottom-Up Parsing Bottom-up parsing is more general than top-down parsing Just as efficient Builds on ideas in top-down parsing Bottom-up is the preferred method in practice Reading: Section 4.5 An Introductory

More information

Turing Machines: An Introduction

Turing Machines: An Introduction CIT 596 Theory of Computation 1 We have seen several abstract models of computing devices: Deterministic Finite Automata, Nondeterministic Finite Automata, Nondeterministic Finite Automata with ɛ-transitions,

More information

Positional Numbering System

Positional Numbering System APPENDIX B Positional Numbering System A positional numbering system uses a set of symbols. The value that each symbol represents, however, depends on its face value and its place value, the value associated

More information

I. GROUPS: BASIC DEFINITIONS AND EXAMPLES

I. GROUPS: BASIC DEFINITIONS AND EXAMPLES I GROUPS: BASIC DEFINITIONS AND EXAMPLES Definition 1: An operation on a set G is a function : G G G Definition 2: A group is a set G which is equipped with an operation and a special element e G, called

More information

Graph Theory Problems and Solutions

Graph Theory Problems and Solutions raph Theory Problems and Solutions Tom Davis tomrdavis@earthlink.net http://www.geometer.org/mathcircles November, 005 Problems. Prove that the sum of the degrees of the vertices of any finite graph is

More information

Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy

Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy Kim S. Larsen Odense University Abstract For many years, regular expressions with back referencing have been used in a variety

More information

1.2 Solving a System of Linear Equations

1.2 Solving a System of Linear Equations 1.. SOLVING A SYSTEM OF LINEAR EQUATIONS 1. Solving a System of Linear Equations 1..1 Simple Systems - Basic De nitions As noticed above, the general form of a linear system of m equations in n variables

More information

Cartesian Products and Relations

Cartesian Products and Relations Cartesian Products and Relations Definition (Cartesian product) If A and B are sets, the Cartesian product of A and B is the set A B = {(a, b) :(a A) and (b B)}. The following points are worth special

More information

Models of Sequential Computation

Models of Sequential Computation Models of Sequential Computation 13 C H A P T E R Programming is often considered as an art, but it raises mostly practical questions like which language should I choose, which algorithm is adequate, and

More information

Increasing Interaction and Support in the Formal Languages and Automata Theory Course

Increasing Interaction and Support in the Formal Languages and Automata Theory Course Increasing Interaction and Support in the Formal Languages and Automata Theory Course [Extended Abstract] Susan H. Rodger rodger@cs.duke.edu Jinghui Lim Stephen Reading ABSTRACT The introduction of educational

More information

Computer Architecture Syllabus of Qualifying Examination

Computer Architecture Syllabus of Qualifying Examination Computer Architecture Syllabus of Qualifying Examination PhD in Engineering with a focus in Computer Science Reference course: CS 5200 Computer Architecture, College of EAS, UCCS Created by Prof. Xiaobo

More information

Preliminary Mathematics

Preliminary Mathematics Preliminary Mathematics The purpose of this document is to provide you with a refresher over some topics that will be essential for what we do in this class. We will begin with fractions, decimals, and

More information

Theory of Computation Class Notes 1

Theory of Computation Class Notes 1 Theory of Computation Class Notes 1 1 based on the books by Sudkamp and by Hopcroft, Motwani and Ullman ii Contents 1 Introduction 1 1.1 Sets.............................................. 1 1.2 Functions

More information

Automata Theory. Şubat 2006 Tuğrul Yılmaz Ankara Üniversitesi

Automata Theory. Şubat 2006 Tuğrul Yılmaz Ankara Üniversitesi Automata Theory Automata theory is the study of abstract computing devices. A. M. Turing studied an abstract machine that had all the capabilities of today s computers. Turing s goal was to describe the

More information

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook. Elementary Number Theory and Methods of Proof CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.edu/~cse215 1 Number theory Properties: 2 Properties of integers (whole

More information

Chapter 6: Episode discovery process

Chapter 6: Episode discovery process Chapter 6: Episode discovery process Algorithmic Methods of Data Mining, Fall 2005, Chapter 6: Episode discovery process 1 6. Episode discovery process The knowledge discovery process KDD process of analyzing

More information

NOTES ON LINEAR TRANSFORMATIONS

NOTES ON LINEAR TRANSFORMATIONS NOTES ON LINEAR TRANSFORMATIONS Definition 1. Let V and W be vector spaces. A function T : V W is a linear transformation from V to W if the following two properties hold. i T v + v = T v + T v for all

More information

Sample Induction Proofs

Sample Induction Proofs Math 3 Worksheet: Induction Proofs III, Sample Proofs A.J. Hildebrand Sample Induction Proofs Below are model solutions to some of the practice problems on the induction worksheets. The solutions given

More information