1 Theory of Computation Introduction Text Book: Michael Sipser. Introduction to the Theory of Computation. 2nd ed. Boston, MA: Thomson Course Technology,

Slides:



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

Lecture 24 MAS 714 Hartmut Klauck
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Fall 2009.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
The Big Picture Chapter 3. We want to examine a given computational problem and see how difficult it is. Then we need to compare problems Problems appear.
CS21 Decidability and Tractability
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
CPSC 411, Fall 2008: Set 12 1 CPSC 411 Design and Analysis of Algorithms Set 12: Undecidability Prof. Jennifer Welch Fall 2008.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Fall 2008.
Normal forms for Context-Free Grammars
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.
 2004 SDU Introduction to the Theory of Computation My name: 冯好娣 My office: 计算中心 430
By: Er. Sukhwinder kaur.  Computation Computation  Algorithm Algorithm  Objectives Objectives  What do we study in Theory of Computation ? What do.
1 Introduction to Automata Theory Reading: Chapter 1.
1 Theory of Computation 計算理論 2 Instructor: 顏嗣鈞 Web: Time: 9:10-12:10 PM, Monday Place: BL 103.
CS490 Presentation: Automata & Language Theory Thong Lam Ran Shi.
1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd:
CS/IT 138 THEORY OF COMPUTATION Chapter 1 Introduction to the Theory of Computation.
AUTOMATA THEORY Reference Introduction to Automata Theory Languages and Computation Hopcraft, Ullman and Motwani.
1 Unit 1: Automata Theory and Formal Languages Readings 1, 2.2, 2.3.
1 Chapter 1 Automata: the Methods & the Madness Angkor Wat, Cambodia.
By: Er. Sukhwinder kaur.  What is Automata Theory? What is Automata Theory?  Alphabet and Strings Alphabet and Strings  Empty String Empty String 
TM Design Universal TM MA/CSSE 474 Theory of Computation.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
1 Chapter 1 Introduction to the Theory of Computation.
Mathematical Preliminaries (Hein 1.1 and 1.2) Sets are collections in which order of elements and duplication of elements do not matter. – {1,a,1,1} =
Theory of Computation, Feodor F. Dragan, Kent State University 1 TheoryofComputation Spring, 2015 (Feodor F. Dragan) Department of Computer Science Kent.
Pushdown Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
1 Theory of Computation 計算理論 2 Instructor: 顏嗣鈞 Web: Time: 2:20-5:10 PM, Tuesday Place: BL 112.
1 Theory of Computation 計算理論 2 Instructor: 顏嗣鈞 Web: Time: 9:10-12:10 PM, Monday Place: BL.
Specifying Languages Our aim is to be able to specify languages for use in the computer. The sketch of an FSA is easy for us to understand, but difficult.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
CS 203: Introduction to Formal Languages and Automata
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
Computability Review homework. Video. Variations. Definitions. Enumerators. Hilbert's Problem. Algorithms. Summary Homework: Give formal definition of.
Formal Languages and Grammars
Introduction to Automata Theory
CSCI 2670 Introduction to Theory of Computing October 13, 2005.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
Introduction Why do we study Theory of Computation ?
1 Formal Proofs. 2 Deductive Proofs From the given statement(s) to a conclusion statement (what we want to prove) Logical progression by direct implications.
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
Set, Alphabets, Strings, and Languages. The regular languages. Clouser properties of regular sets. Finite State Automata. Types of Finite State Automata.
Week 14 - Friday.  What did we talk about last time?  Simplifying FSAs  Quotient automata.
Theory of Computation. Introduction to The Course Lectures: Room ( Sun. & Tue.: 8 am – 9:30 am) Instructor: Dr. Ayman Srour (Ph.D. in Computer Science).
Introduction to Automata Theory
Theory of Computation. Introduction We study this course in order to answer the following questions: What are the fundamental capabilities and limitations.
Topic 3: Automata Theory 1. OutlineOutline Finite state machine, Regular expressions, DFA, NDFA, and their equivalence, Grammars and Chomsky hierarchy.
Why Study Automata Theory and Formal Languages?
Welcome to Automata Theory Course
Introduction to the Theory of Computation
Why do we study Theory of Computation ?
Lecture 1 Theory of Automata
CIS Automata and Formal Languages – Pei Wang
Course 1 Introduction to Formal Languages and Automata Theory (part 1)
Welcome to Automata Theory Course
Theory of Computation Theory of computation is mainly concerned with the study of how problems can be solved using algorithms.  Therefore, we can infer.
G. Pullaiah College of Engineering and Technology
Introduction to Automata Theory
Chapter 1 Introduction to the Theory of Computation
Lecture One: Automata Theory Amjad Ali
Formal Languages and Automata Theory BODDEDA HARITHA LAKSHMI,
Automata theory and formal languages COS 3112 – AUTOMATA THEORY PRELIM PERIOD WEEK 1 AND 2.
Presentation transcript:

1 Theory of Computation Introduction Text Book: Michael Sipser. Introduction to the Theory of Computation. 2nd ed. Boston, MA: Thomson Course Technology, ISBN:

2 What is Automata Theory? Study of abstract computing devices, or “machines” Automation = an abstract computing device Note: A “device” need not even be a physical hardware! A fundamental question in computer science: Find out what different models of machines can do and cannot do The theory of computation Computability vs. Complexity

3 An Abstract Machine To make a more solid definition of algorithm we need to define an abstract (general) machine which can perform any algorithm that can be executed by any computer. Then, We need to show that indeed this machine can run any algorithm that can be executed by any other computer. Then, 1. We can associate the notion of algorithm with this abstract machine. 2. We can study this machine to find the limitations of computations. (Problems with no computation available to solve.)

4 A simple «computer» BATTERY SWITCH off on start f f input: switch output: light bulb actions: f for “flip switch” states: on, off bulb is on if and only if there was an odd number of flips

5 Another computer BATTERY off start 1 inputs: switches 1 and 2 actions: 1 for “flip switch 1” actions: 2 for “flip switch 2” states: on, off off on bulb is on if and only if both switches were flipped an odd number of times

6 A design problem 4 BATTERY ? Can you design a circuit where the light is on if and only if all the switches were flipped exactly the same number of times?

7 A design problem Such devices are difficult to reason about, because they can be designed in an infinite number of ways By representing them as abstract computational devices, or automata, we will learn how to answer such questions They can describe the operation of any “small computer”, like the control component of an alarm clock or a microwave They are also used in lexical analyzers to recognize well formed expressions in programming lang ab1 is a legal name of a variable in C 5u= is not

8 Different kinds of automata This was only one example of a computational device, and there are others We will look at different devices, and look at the following questions: What can a given type of device compute, and what are its limitations? Is one type of device more powerful than another?

9 Some devices we will see finite automataDevices with a finite amount of memory. Used to model “small” computers. push-down automata Devices with infinite memory that can be accessed in a restricted way. Used to model parsers, etc. Turing MachinesDevices with infinite memory. Used to model any computer. Time-bounded Turing Machines Infinite memory, but bounded running time. Used to model any computer program that runs in a “reasonable” amount of time.

10 Computation

11 Theory of Computation A very fundamental and traditional branch of Theory of Computation seeks: 1. A more tangible definition for the intuitive notion of algorithm which results in a more concrete definition for computation. 2. Finding the boundaries (limitations) of computation. We want to answer fundamental questions: What can we do in a reasonable amount of time? What can we do in a reasonable amount of space? What can we do at all?

12 Course Outlines Introduction: Mathematical preliminaries: sets, relations, functions,sequences, graphs, trees, proof by induction, definition by induction (recursion). Basics of formal languages: alphabet, word, sentence, concatenation,union, iteration [= Kleene star], language, infinity of languages, finite representations of languages

13 Course Outlines PART I: Finite Automata and Regular Sets DFA,NFA,regular expressions and their equivalence Limitation of FAs; Closure properties of FAs, Optimization of FAs PART II: Pushdown Automata and Context Free Languages CFGs and CFLs; normal forms of CFG Limitation of CFG; PDAs and their variations, closure properties of CFLs Equivalence of pda and CFGs; deterministic PDAs parsing (Early or CYK's algorithms)

14 Course Outlines PART III: Turing Machines and Effective Computability Turing machine [& its variations] and Equivalence models Universal TMs Decidable and undecidable problems (Recursive sets and recursively enumerable sets) Problems reductions ; Some undecidable problems

15 Course Outlines PART III: Turing Machines and Effective Computability Turing machine [& its variations] and Equivalence models Universal TMs Decidable and undecidable problems (Recursive sets and recursively enumerable sets) Problems reductions ; Some undecidable problems

16 Goals Designing a new programming language for a specialized application Context Free Languages Dealing with string searching and pattern matching Finite Automata and regular expressions Confronted with a problem that seems to require more computer time than you can afford NP-Completeness «What are the fundemantal capabilities and limitations of computers?»

17 Goals Finite automata We will understand what kinds of things a device with finite memory can do, and what it cannot do Introduce simulation: the ability of one device to “imitate” another device Introduce nondeterminism: the ability of a device to make arbitrary choices Push-down automata These devices are related to grammars, which describe the structure of programming (and natural) languages

18 Goals Turing Machines This is a general model of a computer, capturing anything we could ever hope to compute Surprisingly, there are many things that we cannot compute, for example: It seems that you should be able to tell just by looking at the program, but it is impossible to do! Write a program that, given the code of another program in C, tells if this program ever outputs the word “ hello ”

19 Alan Turing ( ) Father of Modern Computer Science English mathematician Studied abstract machines called Turing machines even before computers existed Heard of the Turing test? (A pioneer of automata theory)

20 Turing Machine A conceptual model for general purpose computers proposed by Alan Turing in A Turing machine has an unlimited and unrestricted amount of memory. A Turing machine can do everything a real computer can do. Nevertheless there are problems that a Turing machine cannot solve. In a real sense, these problems are beyond the theoretical limits of computations.

21 Theory of Computation: A Historical Perspective 1930s Alan Turing studies Turing machines Decidability Halting problem s “Finite automata” machines studied Noam Chomsky proposes the “Chomsky Hierarchy” for formal languages 1969 Cook introduces “intractable” problems or “NP-Hard” problems Modern computer science: compilers, computational & complexity theory evolve

22 Languages & Grammars Or “words” Image source: Nowak et al. Nature, vol 417, 2002 Languages: “A language is a collection of sentences of finite length all constructed from a finite alphabet of symbols” Grammars: “A grammar can be regarded as a device that enumerates the sentences of a language” - nothing more, nothing less N. Chomsky, Information and Control, Vol 2, 1959

23 The Central Concepts of Automata Theory

24 Alphabet An alphabet is a finite, non-empty set of symbols We use the symbol ∑ (sigma) to denote an alphabet Examples: Binary: ∑ = {0,1} All lower case letters: ∑ = {a,b,c,..z} Alphanumeric: ∑ = {a-z, A-Z, 0-9} DNA molecule letters: ∑ = {a,c,g,t} …

25 Strings A string or word is a finite sequence of symbols chosen from ∑ Empty string is  (or “epsilon”) Length of a string w, denoted by “|w|”, is equal to the number of (non-  ) characters in the string E.g., x = |x| = 6 x = 01  0  1  00  |x| = ? xy = concatentation of two strings x and y

26 Powers of an alphabet Let ∑ be an alphabet. ∑ k = the set of all strings of length k ∑* = ∑ 0 U ∑ 1 U ∑ 2 U …(the set of all strings over  ∑ + = ∑ 1 U ∑ 2 U ∑ 3 U …

27 Languages L is a said to be a language over alphabet ∑, only if L  ∑*  this is because ∑* is the set of all strings (of all possible length including 0) over the given alphabet ∑ Examples: 1. Let L be the language of all strings consisting of n 0’s followed by n 1’s: L = { ,01,0011,000111,…} 2. Let L be the language of all strings of with equal number of 0’s and 1’s: L = { ,01,10,0011,1100,0101,1010,1001,…} Definition:Ø denotes the Empty language Let L = {  }; Is L=Ø? NO Canonical ordering of strings in the language

28 Examples of Practical Formal Languages Ex: Let D be the set of all ASCII codes.  a C program is simply a finite string over D satisfying all syntax rules of C.  C-language = def { x | x is a well-formed C program over D }.  PASCAL-language = {x | x is a well-formed PASCAL program over D }. Similarly, let ENG-DIC =The lexicon of all English words = { John, Mary, is, are, a, an, good, bad, boys, girl,..}  an English sentence is simply a string over ENG-DIC  ==> English = def {x | x is a legal English sentence over END-DIC} ==>  1.John is a good boy.  English.  2. |John is a good boy. | = ?

29 Issues About Formal Languages  Why need formal languages?  for specification (specifying programs, meanings etc.)  i.e., basic tools for communications b/t people and machines.  although FL does not provide all needed theoretical framework for subsequent (semantic processing...) processing, it indeed provides a necessary start, w/t which subsequent processing would be impossible -- first level of abstraction.  Many basic problems [about computation] can be investigated at this level.  How to specify(or represent) a language ?  Notes: All useful natural or programming languages contain infinite number of strings (or programs and sentences)

30 How to specify a language?  principles: 1. must be precise and no ambiguity among users of the language: 2. efficient for machine processing  tools:  1. traditional mathematical notations:  A = {x | |x| < 3 and x  {a,b}} = {e,a,b,aa,ab,ba,bb}  problem: in general not machine understandable.  2. via programs (or machines) :  P: a program; L(P) = def {x | P return 'ok' on input string x}  precise, no ambiguity, machine understandable.  hard to understand for human users !!  3. via grammars: (easy for human to understand)  Ex: noun := book | boy | John | Mary art := a | an | the ; prep := on | under | of |... adj := good | bad | smart |... NP := noun | art noun | NP PP |... PP := prep NP ==> 'the man on the bridge'

31 Operations on strings  string concatenations:  x,y: two strings ==> x·y is a new string with y appended to the tail of x. i.e., x·y is the function :  z : [0, len(x)+len(y) )   such that  z(n) = x(n) for 0  n < len(x) and  z(len(x)+n) = y(n) for 0  n < len(y).  Some properties of · : 1. ASSOC: (xy)z = x(yz) ; 2. Identity:  x = x  = x. 3. |xy| = |x| + |y|.  conventions and abbreviations:  S: for alphabet ; a,b,c: for symbols;  x,y,z: for strings; A,B,C: for languages;  x 5 for xxxxx; x 1 = x ; x 0 = .  #a(x) = def number of a's in x. ==> #a(aabbcca) = 3.

32 Operations on strings 1. usual set operations:  Union: A  B = {x | x  A or x  B } Ex: {a,ab} U { ab, aab} = {a,ab,aab}  intersection: A  B = {x | x  A and x  B }  complements in  *: ~A = def  * - A = { x | x not  A}  ex: ~{x | |x| is even } = {x | |x| is odd }. 2. Set concatenations: A·B = def {xy | x  A and y  B }.  Ex: {b,ba} {a,ab} = {ba,bab,baa,baab}. 3. Powers of A: A n ( n ³ 0) is defined inductively: A 0 = {  }; A n+1 = A·A n = A·A·...·A n A's

33 Operations on strings Ex: Let A = {ab,abb}. Then 1. A 0 = ? 2. A 1 = ?3. A 2 = ?4. |A 4 |=? 5. Hence {a,b,c} n = {x  {a,b,c}* | |x| = n } and A n = { x 1 x 2...x n | x 1,...,x n  A } 4. Asterate (or star) A* of A is the union of all finite powers of A: A* = def U k  0 A K = A 0 U A UA 2 U A 3 U... = {x 1 x 2...x n | n  0 and x i  A for 1  i  n } notes: 1. n can be 0 ==>   A*. ==>   {}*. 2. If A =  ==> A* =  * = the set of all finite strings over . 5. A + = def the set of all nonzero powers of A = def U k  1 A k = A U A 2 U A 3 U... = A A*.

34 The Membership Problem Given a string w  ∑*and a language L over ∑, decide whether or not w  L. Example: Let w = Q) Is w  the language of strings with equal number of 0s and 1s?

35 Finite Automata Some Applications Software for designing and checking the behavior of digital circuits Lexical analyzer of a typical compiler Software for scanning large bodies of text (e.g., web pages) for pattern finding Software for verifying systems of all types that have a finite number of states (e.g., stock market transaction, communication/network protocol)

36 Structural expressions Grammars Regular expressions E.g., unix style to capture city names such as “Palo Alto CA”: [A-Z][a-z]*([ ][A-Z][a-z]*)*[ ][A-Z][A-Z] Start with a letter A string of other letters (possibly empty) Other space delimited words (part of city name) Should end w/ 2-letter state code

37 Formal Proofs

38 Deductive Proofs From the given statement(s) to a conclusion statement (what we want to prove) Logical progression by direct implications Example for parsing a statement: “If y≥4, then 2 y ≥y 2.” (there are other ways of writing this). given conclusion

39 Example: Deductive proof Let Claim 1: If y≥4, then 2 y ≥y 2. Let x be any number which is obtained by adding the squares of 4 positive integers. Claim 2: Given x and assuming that Claim 1 is true, prove that 2 x ≥x 2 Proof: 1) Given: x = a 2 + b 2 + c 2 + d 2 2) Given: a≥1, b≥1, c≥1, d≥1 3)  a 2 ≥1, b 2 ≥1, c 2 ≥1, d 2 ≥1(by 2) 4)  x ≥ 4(by 1 & 3) 5)  2 x ≥ x 2 (by 4 and Claim 1) “implies” or “follows”

On Theorems, Lemmas and Corollaries We typically refer to: A major result as a “theorem” An intermediate result that we show to prove a larger result as a “lemma” A result that follows from an already proven result as a “corollary” 40 An example: Theorem: The height of an n-node binary tree is at least floor(lg n) Lemma: Level i of a perfect binary tree has 2 i nodes. Corollary: A perfect binary tree of height h has 2 h+1 -1 nodes.

41 Quantifiers “For all” or “For every” Universal proofs Notation * =? “There exists” Used in existential proofs Notation * =? Implication is denoted by => E.g., “IF A THEN B” can also be written as “A=>B” * I wasn’t able to locate the symbol for these notation in powerpoint. Sorry! Please follow the standard notation for these quantifiers. These will be presented in class.

42 Proving techniques By contradiction Start with the statement contradictory to the given statement E.g., To prove (A => B), we start with: (A and ~B) … and then show that could never happen What if you want to prove that “(A and B => C or D)”? By induction (3 steps) Basis, inductive hypothesis, inductive step By contrapositive statement If A then B ≡If ~B then ~A

43 Proving techniques… By counter-example Show an example that disproves the claim Note: There is no such thing called a “proof by example”! So when asked to prove a claim, an example that satisfied that claim is not a proof

44 Different ways of saying the same thing “If H then C”: i. H implies C ii. H => C iii. C if H iv. H only if C v. Whenever H holds, C follows

45 “If-and-Only-If” statements “A if and only if B” (A B) (if part) if B then A ( <= ) (only if part) A only if B ( => ) (same as “if A then B”) “If and only if” is abbreviated as “iff” i.e., “A iff B” Example: Theorem: Let x be a real number. Then floor of x = ceiling of x if and only if x is an integer. Proofs for iff have two parts One for the “if part” & another for the “only if part”