C SC 473 Automata, Grammars & Languages Automata, Grammars and Languages Discourse 01 Introduction.

Slides:



Advertisements
Similar presentations
CS 345: Chapter 9 Algorithmic Universality and Its Robustness
Advertisements

8/25/2009 Sofya Raskhodnikova Intro to Theory of Computation L ECTURE 1 Theory of Computation Course information Overview of the area Finite Automata Sofya.
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
1 Section 14.1 Computability Some problems cannot be solved by any machine/algorithm. To prove such statements we need to effectively describe all possible.
CS21 Decidability and Tractability
Introduction to Computability Theory
FLAC Lecture 19 Turing Machines and Real Life * Reductions Mihai Budiu March 3, 2000.
CPSC 411, Fall 2008: Set 12 1 CPSC 411 Design and Analysis of Algorithms Set 12: Undecidability Prof. Jennifer Welch Fall 2008.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
1 The Chomsky Hierarchy. 2 Unrestricted Grammars: Rules have form String of variables and terminals String of variables and terminals.
Linear Bounded Automata LBAs
CS 490: Automata and Language Theory Daniel Firpo Spring 2003.
Finite State Machines Data Structures and Algorithms for Information Processing 1.
Theory of Computation and Formal Languages
Grammars, Languages and Finite-state automata Languages are described by grammars We need an algorithm that takes as input grammar sentence And gives a.
Theory of Computation. Computation Computation is a general term for any type of information processing that can be represented as an algorithm precisely.
Final Exam Review Cummulative Chapters 0, 1, 2, 3, 4, 5 and 7.
Design and Analysis of Algorithms
By: Er. Sukhwinder kaur.  Computation Computation  Algorithm Algorithm  Objectives Objectives  What do we study in Theory of Computation ? What do.
CS490 Presentation: Automata & Language Theory Thong Lam Ran Shi.
CSCI 2670 Introduction to Theory of Computing September 28, 2005.
CS/IT 138 THEORY OF COMPUTATION Chapter 1 Introduction to the Theory of Computation.
1 Unit 1: Automata Theory and Formal Languages Readings 1, 2.2, 2.3.
TM Design Universal TM MA/CSSE 474 Theory of Computation.
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.
Introduction to CS Theory Lecture 15 –Turing Machines Piotr Faliszewski
Copyright © Curt Hill Languages and Grammars This is not English Class. But there is a resemblance.
Theory of Computation, NTUEE Theory of Computation Lecture 04 Undecidability Part of the materials are from Courtesy of Prof. Peter J. Downey Department.
1 Theory of Computation 計算理論 2 Instructor: 顏嗣鈞 Web: Time: 9:10-12:10 PM, Monday Place: BL.
Theory of Computation In theoretical computer science and mathematics, the theory of computation is the branch that deals with how efficiently problems.
1 / 48 Formal a Language Theory and Describing Semantics Principles of Programming Languages 4.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
 2005 SDU Lecture13 Reducibility — A methodology for proving un- decidability.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
September1999 CMSC 203 / 0201 Fall 2002 Week #15 – 2/4/6 December 2002 Prof. Marie desJardins.
Capabilities of computing systems Numeric and symbolic Computations A look at Computability theory Turing Machines.
CSCI 2670 Introduction to Theory of Computing October 13, 2005.
1 Linear Bounded Automata LBAs. 2 Linear Bounded Automata (LBAs) are the same as Turing Machines with one difference: The input string tape space is the.
1 Course Overview Why this course “formal languages and automata theory?” What do computers really do? What are the practical benefits/application of formal.
1 Introduction to Turing Machines
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 12 Mälardalen University 2007.
1 The Chomsky Hierarchy. 2 Unrestricted Grammars: Productions String of variables and terminals String of variables and terminals.
1 Chapter 9 Undecidability  Turing Machines Coded as Binary Strings  Universal Turing machine  Diagonalizing over Turing Machines  Problems as Languages.
Undecidability and The Halting Problem
1 8.4 Extensions to the Basic TM Extended TM’s to be studied: Multitape Turing machine Nondeterministic Turing machine The above extensions make no increase.
CS 154 Formal Languages and Computability May 12 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
Chapter 9 Turing Machines What would happen if we change the stack in Pushdown Automata into some other storage device? Truing Machines, which maintains.
Turing Machines CS 130 Theory of Computation HMU Textbook: Chap 8.
The Church-Turing Thesis Chapter Are We Done? FSM  PDA  Turing machine Is this the end of the line? There are still problems we cannot solve:
Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.
Introduction to Automata Theory
CSE202: Introduction to Formal Languages and Automata Theory
8. Introduction to Turing Machines
Linear Bounded Automata LBAs
Turing Machines 2nd 2017 Lecture 9.
Introduction to Automata Theory
Summary.
CSE322 The Chomsky Hierarchy
Jaya Krishna, M.Tech, Assistant Professor
Jaya Krishna, M.Tech, Assistant Professor
CSCE 411 Design and Analysis of Algorithms
Decidable Languages Costas Busch - LSU.
8. Introduction to Turing Machines
Decidability and Undecidability
CS21 Decidability and Tractability
Decidability and Tractability
Subject Name: FORMAL LANGUAGES AND AUTOMATA THEORY
Automata, Grammars and Languages
The Chomsky Hierarchy Costas Busch - LSU.
Presentation transcript:

C SC 473 Automata, Grammars & Languages Automata, Grammars and Languages Discourse 01 Introduction

C SC 473 Automata, Grammars & Languages 2 Fundamental Questions Theory of Computation seeks to answer fundamental questions about computing What is computation? Ancient activity back as far as Babylonians, Egyptians Not precisely settled until circa 1936 What can be computed? Different ways of computing (C, Lisp, …) result in the same “effectively computable” functions from input to output? What cannot be computed? Not but can get arbitrarily close Are there precisely defined tasks (“problems”) that cannot be carried out? Yes/No decisions that cannot be computed? What can be computed efficiently? (Computational Complexity) Are there inherently difficult although computable problems?

C SC 473 Automata, Grammars & Languages 3 Basic Concepts: Automata, Grammars & Languages Language: a set of strings over some finite alphabet  Ex: Automaton (Machine): abstract (=simplified) model of a computing device. Used to “recognize” strings of a language L Ex: Grammar: finite set of string rewriting rules. Used to specify (derive) strings of a language Ex: a b a b Finite Automaton (Finite State Machine) Context-Free Grammar (CFG)

C SC 473 Automata, Grammars & Languages 4 Languages

C SC 473 Automata, Grammars & Languages 5 Types of Machines Logic circuit memoryless; values combined using gates zxy c s      Circuit size = 5 Circuit depth = 3

C SC 473 Automata, Grammars & Languages 6 Types of Machines (cont.) Finite-state automaton (FSA) bounded number of memory states step: input, current state determines next state & output a a a Mod 3 counter state/ouput (Moore) machine models programs with a finite number of bounded registers reducible to 0 registers b

C SC 473 Automata, Grammars & Languages 7 Pushdown Automaton (PDA) finite control and a single unbounded stack ,   $ models finite program + one unbounded stack of bounded registers $ top Types of Machines (cont.) b  #, $   a,   A b, A  

C SC 473 Automata, Grammars & Languages 8 Random access machine (RAM) finite program and an unbounded, addressable random access memory of ``registers” models general programs  unbounded # of bounded registers  Simple 1-addr instructions Example:  Types of Machines (cont.) b 

C SC 473 Automata, Grammars & Languages 9 Turing Machine (TM) finite control & tape of bounded cells unbounded in # to R Input left adjusted on tape at start with blank cell terminating current state, cell scanned determine next state & overprint symbol control writes over symbol in cell and moves head 1 cell L or R models simple ``sequential’’ memory; no addressability fixed amount of information (b bits) per cell Types of Machines (cont.)   Finite- state control b

C SC 473 Automata, Grammars & Languages 10 Theory of Computation Study of languages and functions that can be described by computation that is finite in space and time Grammar Theory Context-free grammars Right-linear grammars Unrestricted grammars Capabilities and limitations Application: programming language specification Automata Theory FA PDA Turing Machines Capabilities and limitations Characterizing “what is computable?” Application: parsing algorithms

C SC 473 Automata, Grammars & Languages 11 Theory of Computation (cont’d) Computational Complexity Theory Inherent difficulty of “problems” Time/space resources needed for computation “Intractable” problems Ranking of problems by difficulty (hierarchies) Application: algorithm design, algorithm improvement, analysis

C SC 473 Automata, Grammars & Languages 12 FSA Ex: Specifying/Recognizing C Identifiers Deterministic FA  ={a,…,z,A…,Z, _ }  ={0,…,9} State diagram (labeled digraph) Regular Expression Right-Linear Grammar    

C SC 473 Automata, Grammars & Languages 13 FSA Ex: C Floating Constants " A floating constant consists of an integer part, a decimal point, a fraction part, an e or E, an optionally signed integer exponent (and an optional type suffix … ). The integer and fraction parts both consist of a sequence of digits. Either the integer part or the fraction part (not both) may be missing; either the decimal point or the e and the exponent (not both) may be missing. …" --B. W. Kernighan and D.M. Ritchie, The C Programming Language, Prentice-Hall, 1978 (The type is determined by the suffix; F or f makes it a float, L or l makes it a long double; otherwise it is double.)

C SC 473 Automata, Grammars & Languages 14 FSA Ex: C Floats (cont’d) Note: type suffixes f,F,l,L omitted “Either the integer part or the fraction part (not both) may be missing; either the decimal point or the e and the exponent (not both) may be missing ”

C SC 473 Automata, Grammars & Languages 15 CFG Ex: A Calculator Language Syntactic Classes Numerals 3 40 Digits Expressions 3*9 40-3*3 Commands 3*9= 40-3*3= Context-Free Grammar 20*30-12= 7 89  = C  E= E  N  E+N  E-N  E  N N  ND N  D D  0...  9 rules R terminals  = , ,0,…,9  variables =  N,D,E,C  start variable = C grammar Note: no division & no decimal point

C SC 473 Automata, Grammars & Languages 16 Calculator Language (cont’d) Syntax Trees—exhibit “phrase structure” Numerals N Expressions E Commands C N D 3 N D 4 N D 0 N D 3 N D 6 N D 5 E N 3 E N 9 C =    E 4 E N 3 C =    E N - N 0  3  3*9= 40-3*3= Is this the parse you expected?

C SC 473 Automata, Grammars & Languages 17 TM Ex: An “Algorithmically Unsolvable” Problem Q: Is there an algorithm for deciding if a given program P halts on a given input x? A: No. There is no program that works correctly for all P,x For the proof, we will need a simple programming language‡: NatC— a simplified C One data type: nat = {0,1,2, …}. All variables of type nat All programs have one nat input and one nat output ‡We will later on use Turing Machines to model a “simple programming language”. NatC is simpler to describe. Halting Decider P x

C SC 473 Automata, Grammars & Languages 18 Unsolvable Problem (cont’d) Observations: A standard C compiler can be modified to accept only NatC programs as “legal” Every NatC program P computes a function from natural numbers to natural numbers. Note: may not be defined for some inputs, i.e., it is a partial function nat P(nat x) { if (x=3) return(6); else { while(x=x) do x=x+1; return x; } Ex: P does not halt for some inputs

C SC 473 Automata, Grammars & Languages 19 Unsolvable Problem (cont’d) Enumeration A systematic list of all NatC programs For program i is called the program’s index program  index: write out program as bit sequence in ASCII; interpret the bit sequence as a binary integer—its index  A program is just a string of characters!!! index  program: given i  0, convert to binary. Divide into 8- bit blocks. If such division is impossible (e.g., 3 bits) or if some block is not an ASCII code, or if the string is not a legal program, will be the default “junk” program {nat x; read(x); while(x=x) do x=x+1;write(x)} which is undefined (“diverges”  ) for every legal input. Conclusions about enumeration  Given n can compute with NatC program  Given P can compute index n such that with NatC.

C SC 473 Automata, Grammars & Languages 20 Unsolvable Problem (cont’d) Unsolvability Result: Does halt on input n ? Question cannot be settled by an algorithm. Theorem: Define the function h: nat  nat by h (x) = if P x halts on input x then 1 else 0 Then h is not computable by any NatC program. Proof: Proof by contradiction. Suppose (contrary to what is to be proved) that h is computable by a program called halt. halt has input variable x, and output variable y. By assumption (i.e., that it exists) it has the following behavior: f halt (x) = if P x halts on input x then 1 else 0

C SC 473 Automata, Grammars & Languages 21 Unsolvable Problem (cont’d) Modify halt to a NatC function nat halt(nat x) Construct the following NatC program: Consequences If halt is a legal program, so is “ diagonal” Therefore, diagonal has some index e in the enumeration: u P e = diagonal nat diagonal(nat n) { nat y; if halt(n)=0 y:=1; else { y:=1; while (y!=0) do y:=y+1;} return y; }

C SC 473 Automata, Grammars & Languages 22 Unsolvable Problem (cont’d) How does diagonal behave on its own index e ? f diagonal (e)=1  f halt (e ) = 0  P e does not halt on e  diagonal does not halt on e f diagonal (e)= undefined  f halt (e ) = 1  P e halts on e  diagonal halts on e  diagonal halts on e  diagonal does not halt on e Contradiction!!!  program diagonal cannot exist Q.E.D. The “Halting Problem” is unsolvable Undecidable, recursively undecidable, algorithmically undecidable, unsolvable—all synonyms