Key to Homework #2 1. What is the language of L-system G = ({a, b, c}, h, acb ), where the rewriting rule h is defined as follows: h (a) = aa h (b) = cb.

Slides:



Advertisements
Similar presentations
Deterministic Turing Machines
Advertisements

Variants of Turing machines
CS 461 – Oct. 21 Begin chapter 3 We need a better (more encompassing) model of computation. Ex. { 1 n 2 n 3 n } couldn’t be accepted by PDA. –How could.
Lecture # 8 Chapter # 4: Syntax Analysis. Practice Context Free Grammars a) CFG generating alternating sequence of 0’s and 1’s b) CFG in which no consecutive.
Turing Machines (At last!). Designing Universal Computational Devices Was Not The Only Contribution from Alan Turing… Enter the year 1940: The world is.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
Theory of Computation What types of things are computable? How can we demonstrate what things are computable?
start 0, 4, 8 1, 5, 9 2, 6 3, 7 2 0,4,8 2, 6 3, 7 1, 5, 9 to state 2 to state 3 to state 1 to state 0 to state 1 to state 3 to state 0 to state.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Fall 2004COMP 3351 Turing Machines. Fall 2004COMP 3352 The Language Hierarchy Regular Languages Context-Free Languages ? ?
1 The Chomsky Hierarchy. 2 Unrestricted Grammars: Rules have form String of variables and terminals String of variables and terminals.
1 1. Show the result of each of the following set operations in terms of set property. Write your sets as simple as possible. (a) L 0  L 4 (b) L 0  L.
Courtesy Costas Busch - RPI1 Turing Machines. Courtesy Costas Busch - RPI2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
56 Rumination on the Formal Definition of DPDA In the definition of DPDA, there are some parts that do not agree with our intuition. Let M = (Q, , ,
1 Homework #6 (Models of Computation, Spring, 2001) Due: Section 1; March 29 Section 2; March Let L be the language of the following grammar G 1.

104 Closure Properties of Regular Languages Regular languages are closed under many set operations. Let L 1 and L 2 be regular languages. (1) L 1  L 2.
Homework #9 Solutions.
79 Regular Expression Regular expressions over an alphabet  are defined recursively as follows. (1) Ø, which denotes the empty set, is a regular expression.
LING 388 Language and Computers Lecture 11 10/7/03 Sandiway FONG.
Costas Busch - RPI1 Turing Machines. Costas Busch - RPI2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Prof. Busch - LSU1 Turing Machines. Prof. Busch - LSU2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
CS5371 Theory of Computation Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)
Chapter 9 Turing Machine (TMs).
Problem of the DAY Create a regular context-free grammar that generates L= {w  {a,b}* : the number of a’s in w is not divisible by 3} Hint: start by designing.
1 Introduction to Parsing Lecture 5. 2 Outline Regular languages revisited Parser overview Context-free grammars (CFG’s) Derivations.
Languages & Strings String Operations Language Definitions.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
1 Homework #7 (Models of Computation, Spring, 2001) Due: Section 1; April 16 (Monday) Section 2; April 17 (Tuesday) 2. Covert the following context-free.
1 Section 14.2 A Hierarchy of Languages Context-Sensitive Languages A context-sensitive grammar has productions of the form xAz  xyz, where A is a nonterminal.
Languages, Grammars, and Regular Expressions Chuck Cusack Based partly on Chapter 11 of “Discrete Mathematics and its Applications,” 5 th edition, by Kenneth.
Regular Grammars Chapter 7. Regular Grammars A regular grammar G is a quadruple (V, , R, S), where: ● V is the rule alphabet, which contains nonterminals.
Regular Grammars Chapter 7 1. Regular Grammars A regular grammar G is a quadruple (V, , R, S), where: ● V is the rule alphabet, which contains nonterminals.
1 Course Overview PART I: overview material 1Introduction 2Language processors (tombstone diagrams, bootstrapping) 3Architecture of a compiler PART II:
Decidable languages Section 4.1 CSC 4170 Theory of Computation.
1 Simplification of Context-Free Grammars Some useful substitution rules. Removing useless productions. Removing -productions. Removing unit-productions.
1 1. Let A ={r, p, i } and B = { w, o, r, l, d }. What does each of the following (a), (b) and (c) denote? Briefly explain in plain English. (a) A * B.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
1 Chapter 6 Simplification of CFGs and Normal Forms.
Sahar Mosleh California State University San MarcosPage 1 Finite State Machine.
1 Section 13.1 Turing Machines A Turing machine (TM) is a simple computer that has an infinite amount of storage in the form of cells on an infinite tape.
1 Turing Machines and Equivalent Models Section 13.1 Turing Machines.
CSCI 3130: Formal languages and automata theory Tutorial 7 Chin.
98 Nondeterministic Automata vs Deterministic Automata We learned that NFA is a convenient model for showing the relationships among regular grammars,
1 Turing Machines - Chap 8 Turing Machines Recursive and Recursively Enumerable Languages.
1 Introduction to Turing Machines
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 12 Mälardalen University 2007.
Unrestricted Grammars
1 1. Eliminate all  -transitions from the following FA without changing the number of states and the language accepted by the automaton. You should also.
Transparency No. 1 Formal Language and Automata Theory Homework 6.
Turing Machines. The next level of Machine… PDAs improved on FSAs by adding memory. We make the memory more flexible to do more complicated tasks.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Lecture 14: Theory of Automata:2014 Finite Automata with Output.
Mealy Machines Finite State Machines with Outputs given on the transitions.
Chapter 5 Recursive and recursively enumerable functions Phrase-structure grammars.
CS6800 Advance Theory of Computation Spring 2016 Nasser Alsaedi
1 Key to Homework #3 (Models of Computation, Spring, 2001) Finite state control with a 4-way read/write head Figure (a)Figure (b) (over)
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS
TMs for {a2n | n  0} {a2n | n  0}
Busch Complexity Lectures: Turing Machines
Deterministic Turing Machines
Theorem 29 Given any PDA, there is another PDA that accepts exactly the same language with the additional property that whenever a path leads to ACCEPT,
Turing Machines 2nd 2017 Lecture 9.
Chapter 9 TURING MACHINES.
Constructing Complex Turing Machines
Chapter 7 Regular Grammars
Midterm (Models of Computation, Fall, 2000)
Variants of Turing machines
Presentation transcript:

Key to Homework #2 1. What is the language of L-system G = ({a, b, c}, h, acb ), where the rewriting rule h is defined as follows: h (a) = aa h (b) = cb h (c) = a Answer: Applying h iteratively on acb, we get the following: acb  aaacb  aaaaaaacb  aaaaaaaaaaaaaaacb ... The number of a’s increases with the following pattern; 1, 2+1, 4+2+1, ,..., and so on. If we apply h i times, we get string a 1 a 2 a 4....a i cb. Since i = 2 i+1 – 1, we can express the language of the L-system as follows. { a r cd | r = 2 i+1 – 1, i  0 } 2. Construct a syntax diagram which defines the language of the following context-free grammar. S  aSbB | A A  bSa | ba | ab B  bB |  SB a b A B b S B Answer: S b a a A b

4. Suppose that in the Pascal Syntax Flow Graph (see your handout) digit are defined as the following syntax flow graphs. Write a context-free grammar that generates all unsigned numbers defined by the Pascal syntax flow graph “unsigned number” in the handout. We know that digit unsigned integer For convenience, define + - sign . e |. | e |  |  1 | 2  + | - |  digit 1 2 unsigned integer.edigit + - unsigned number We use lower case letter instead of capital E, to show that it is terminal symbol. Answer: * Let denote nonterminals, and be the start symbol of the grammar.

3. What does the following Turing Machine (TM) do? Explain in detail referring to the states. Assume that the input is a string in { 0, 1 } +. (Hint: Trace the machine operation with a simple example.) (1,1,R) (0,0,R) (B,B,L) (0,0,R) (1,1,R) (B,B,L) (1,0,L) (0,1,R) start (1,B,L) (0,B,L) (0,1,L) (1,0,L) (0,0,L) (1,1,L) (B,0,N) (B,1,N) Given a binary number on the tape, the Turing machine increments and shifts it as follows: (1)In state 0, the head move all the way to the right until it the blank next to the last symbol, and back up one cell to the left and enters state 1. (2)Moving to the left changes all 1’s to 0, until it reads 0. The machine changes this 0 to 1, enters state 2 and moves all the way to the right until it hits a blank, and then back up in state 3. Above procedures (1) and (2) increment the binary number on the tape by one. (There is an exceptional case; if the number is all 1’s, the increment will be stuck at state 1, and will not work.) (3) If the machine reads symbol 0 (symbol 1), it replaces the symbol with blank and moves to the left entering state 4 (respectively, state 5). (4) Changing states between 4 and 5, the machine shifts the binary string to the left by one cell. Answer:

5. Construct a TM which, given a string x  {a, b} +, rearrange the symbols in x such that all a’s come fist then b’s follow. For example, if the input is abbaaba, then the result will be aaaabbb. When the work is complete the TM should be in an accepting state and the tape should only contain rearranged string. For your answer, you should first informally explain your idea in detail and then show the transition graph of the TM. An idea: Shifting the input string to the right, if there is a symbol b before an a, stop shifting and move that b to the end of the string. This operation repeats until it sees no b to the left of an a.(See the illustration in Figure (a).) In Figure (b), the machine enters in state 3 if it sees an a after reading b ’s. a a b a b b a a b a a a b b a a b b a a a b a a b b b a a a a a b b b b accept Figure (a). Shifting the string and transposing b’s. Figure (b). State transition graph (b, B, R) (a, B, R) (a, a, R) (a, a, R), (b, b, R) (b, a, R) (b, b, R) 5 (B, b, N) (a, a, R) (B, b, L) 4 (a, a, L), (b, b, L) (B, B, R) start Put b at the end. Go for next iteration. This is an a out of order (B, a, N)