Deterministic FA/ PDA Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 4 Updated by Marek Perkowski.

Slides:



Advertisements
Similar presentations
Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer.
Advertisements

Chapter 5 Pushdown Automata
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,
Pushdown Automata Chapter 12. Recognizing Context-Free Languages We need a device similar to an FSM except that it needs more power. The insight: Precisely.
CS21 Decidability and Tractability
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
Equivalence, DFA, NDFA Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 2 Updated and modified by.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
January 14, 2015CS21 Lecture 51 CS21 Decidability and Tractability Lecture 5 January 14, 2015.
CS 490: Automata and Language Theory Daniel Firpo Spring 2003.
Normal forms for Context-Free Grammars
Transparency No. P2C1-1 Formal Language and Automata Theory Part II Pushdown Automata and Context-Free Languages.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
1 Pushdown Automata PDAs. 2 Pushdown Automaton -- PDA Input String Stack States.
Finite State Machines Data Structures and Algorithms for Information Processing 1.
CS 3240: Languages and Computation Pushdown Automata & CF Grammars NOTE: THESE ARE ONLY PARTIAL SLIDES RELATED TO WEEKS 9 AND 10. PLEASE REFER TO THE TEXTBOOK.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 7 Mälardalen University 2010.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2010.
Pushdown Automata.
CS490 Presentation: Automata & Language Theory Thong Lam Ran Shi.
Pushdown Automata (PDA) Intro
Context-free Grammars Example : S   Shortened notation : S  aSaS   | aSa | bSb S  bSb Which strings can be generated from S ? [Section 6.1]
Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.
Pushdown Automata (PDAs)
Pushdown Automata Part I: PDAs Chapter Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2)
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 6 Mälardalen University 2010.
Pushdown Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
Complexity and Computability Theory I Lecture #11 Instructor: Rina Zviel-Girshin Lea Epstein.
Chapter 7 Pushdown Automata
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
PushDown Automata. What is a stack? A stack is a Last In First Out data structure where I only have access to the last element inserted in the stack.
CS 203: Introduction to Formal Languages and Automata
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 9 Mälardalen University 2006.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
Formal Languages, Automata and Models of Computation
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.
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
Grammar Set of variables Set of terminal symbols Start variable Set of Production rules.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2011.
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
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,
1 Chapter Pushdown Automata. 2 Section 12.2 Pushdown Automata A pushdown automaton (PDA) is a finite automaton with a stack that has stack operations.
Set, Alphabets, Strings, and Languages. The regular languages. Clouser properties of regular sets. Finite State Automata. Types of Finite State Automata.
MA/CSSE 474 Theory of Computation How many regular/non-regular languages are there? Closure properties of Regular Languages (if there is time) Pumping.
Week 14 - Friday.  What did we talk about last time?  Simplifying FSAs  Quotient automata.
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
Formal Languages, Automata and Models of Computation
Deterministic FA/ PDA Sequential Machine Theory Prof. K. J. Hintz
CSE 105 theory of computation
Pushdown Automata PDAs
PDAs Accept Context-Free Languages
Pushdown Automata PDAs
Pushdown Automata.
Pushdown Automata.
Equivalence, DFA, NDFA Sequential Machine Theory Prof. K. J. Hintz
Intro to Data Structures
… NPDAs continued.
Pushdown automata The Chinese University of Hong Kong Fall 2011
CSE 105 theory of computation
Presentation transcript:

Deterministic FA/ PDA Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 4 Updated by Marek Perkowski

Numerical Acceptor A Non-intuitive Concept of a Language Is One Which Can Accept Binary Arithmetic Values, e.g Moret, Theory of Computation Check all strings, from shortest that are accepted. What is their language? Our theory does not allow to create such machines automatically

Languages Accepted by FA The Class of Languages Accepted by a Deterministic or Nondeterministic FA Is Closed Under –Union –Concatenation –Kleene Star –Complementation –Intersection Something new, this generalized to Boolean algebra Give examples of pattern recognizing sequences for hear attack prediction on blind people canes

Union of Languages M1M1 M2M2 e e >

Concatenation of Languages M1M1 M2M2 ee > F2F2 F1F1 S1S1 S1S1

Kleene Star of Languages M1M1 F1F1 e > S1S1 e e q0q0

Difference of Languages L1L1 L2L2

Intersection of Languages L1L1 L2L2 L Intersection expressed by sums and differences only

Languages and FA Kleene’s Theorem –A Language Is Regular iff It Is Accepted by a Deterministic or Nondeterministic Finite Automata A Regular Language Is One Which Can Be Defined by a Regular Expression –Not all languages are regular Give examples of languages that are not regular

Context Free Languages Up Until Now we learned the following: But This Is a Limited Class of Languages There Are Other Context-Free Languages Which Cannot Be Recognized by a DFA There Are Other Types of Machines Which Can Accept the Context-Free Languages

A Non-Regular Language Since a Language, L, Is a Subset of the Set of All Strings, I*, Are There Some Strings Which Cannot Be Produced by a Regular Expression or Recognized by a DFA? Yes, e.g., We gave also other examples – palindromes (with deterministic and non-deterministic recognizers)

Is language a n b n Regular? Theorem 1 : Let L be an infinite regular language. Then there are strings x, y, and z such that y  e and x y n z  L for each n  0 –Proof based on pigeonhole principle If there are n + 1 pigeons and n pigeonholes, then at least two pigeons must be in the same hole –If a string has more characters than there are states in the language recognizer, then some state must be entered more than once 1 Lewis & Papadimitriou, Elements of the Theory of Computation

(Is language a n b n Regular? Language Is Infinite, Therefore Theorem Applies Is This Language Regular? If So, the Theorem Must Apply Three Cases to Study for all possible numbers of a’s and b’s in parts x,y,z of string from theorem  see next slides We match therefore x y n z  L with a n b n as must go first, bs next

a n b n Regular? Case 1: y consists entirely of as x y n z  L Thus we proved that in first case the string that satisfies regular languages cannot be in language L

a n b n Regular? Case 2: y consists entirely of bs Similar argument to Case 1 x y n z  L Thus we proved that in second case the string that satisfies regular languages cannot be in language L

a n b n Regular? Case 3: y contains both as and bs For n > 1, x y n z has an occurrence of b preceding an occurrence of a and therefore cannot be in L Assume x y n z  L For instance assume y=aab, then y 2 =aabaab Thus we proved that in third case the string that satisfies regular languages cannot be in language L

Intuitive explanation ab aa b b b b a a b To accept a longer a n I need to make loop Without loop I can do this only for limited value of n If I make loop in a-part, I will obtain strings that are not in L b b a a b a b b a b b If I make loop in b-part, I will obtain strings that are not in L a b b a b b or a This way I create strings with b before a that are not in L

Context Free Grammars: idea A More General Way to Describe and/or Generate Languages Context-Free –Replacement Rules Can Be Applied Independently of the Preceding or Following Elements. Give grammars for language from previous example and palindromes (deterministic and not). Picture grammars

Example of grammar Building blocks Examples of good houses Good houses have at least one window Good houses have door in first floor, may have more door. Good houses have roof or not. You cannot obviously build above roof.

Are they equivalent? 0,1, ,2 Of course not, the first has arbitrary sequence of zeros at the beginning. e 012 e

Context Free Grammar: definition A Quadruple, ( I, , R, s) where I An alphabet (note that now we assume that I is both terminal and nonterminal symbols)  A set of terminals, RA finite set of rules, a subset of the crossproduct of the set of non-terminals and all strings,

Context Free Grammar: definition cont s The start symbol, a non-terminal The set of non-terminals AND...

Context Free Grammar: definition cont For All Non-terminals, And Strings The Grammar, G, Maps the Non-Terminals to Strings for strings u, v, x, y, v’  I* and non-terminals

Context Free Grammar: definition of G-related u is G -related to v iff u = x A y v = x v’ y and

Context Free Grammar: the set of all possible relations The relation,, the * meaning the set of all possible relations, is –reflexive –transitive –has closure I*I* G

Context Free Language The Language Generated by the Context Free Grammar, G, Is the Set of Strings Which Map From the Start Symbol, s, Under the Reflexive, Transitive, and Closed Relation, Briefly. Language is a set of words over alphabet I that can be derived from initial symbol

Context Free Language A Context Free Language Is One Which Can Be Generated by a Context Free Grammar, and, The Context Free Grammar (CFG) Can Be Used to Generate Strings of the Language

A Derivation Example The Steps in Applying the Rules From the Start Symbol to Any String is called a Derivation in G, e.g., Terminal symbols. It is more convenient to denote non-terminal symbols by capital letters

Pushdown Automata All Context-Free Languages can Be Recognized by a PDA { a n b n } Is Context-Free, but Not Regular –Problem is the same number of as and bs PDA Assumes –An unlimited memory in the form of a stack, LIFO –The machine only has access to the top of the stack. LIFO means last in first out

Pushdown Automata: formal definition A PDA is a Sextuple,

Pushdown Relation where “top of stack” is replaced by “new top of stack.”

Pushdown Relation Example x s=p x s=q x s=p x s=q

PDA Properties One Can Have the Same State Before and After a Transition, but Have Different Stack Contents Which Makes It Non- Deterministic State Changes May Occur in the Absence of an Input, but Only If the Stack Is Not Empty. i.e., non-causal behavior.

PDA Properties: what is the state of PDA? The “State” of the PDA Is Determined Not Only by S, and Not Only by the Top-of- Stack, but Rather by Both the Current State and the Complete Contents of the Stack, x This “State of the PDA” Is Called the “Configuration of the PDA”

PDA Notation The Input May Cause the PDA to Change From Configuration 1 to Configuration 2 Note: y is a word, x i are words

PDA Recognizer A string w  I* is accepted by a PDA

PDA Example* A Machine to Recognize Strings of the Form wcw R * Lewis & Papadimitriou, pg. 114

PDA Example wcw R Can Be Represented by a Context Free Grammar, Please remember this grammar. We already showed how to build intuitively the stack machine for it.

Equivalent NPDA Top of stack New Top of stack FSM state input On stack Observe that with this approach we have much non-determinism but there is a mechanical transformation of grammar to rules of PDA operation

Is abccba Accepted? You should already know immediately that not T1 pushed S to empty stack S  aSa S  bSb S  c Please not that we pop a from input and stack

Is abccba Accepted? T3 added this Top of stack Top of input They are different

Is abccba Accepted? The machine halts with unread inputs since there is no transition rule to be executed. If there is no transition rule among our set of rules, like above, then machine halts (for the previous sequence of non-deterministic choices)

Is bacab Accepted? You should already know immediately that yes You should analyze by yourself each transition, as we have done in previous example. nondeter minism

Is bacab Accepted? At this point stack the same as input

Is bacab Accepted? The machine halts with no unread input and nothing on the stack, therefore, bacab  language wcw R. So in this case machine found sequence of rules to terminate with empty input and empty stack.

Typical Homework Typical homework is to write a grammar for some (usually non-deterministic) language (for instance, properly parenthesized simplified arithmetic expressions) and next use the method above to create a non-deterministic PushDown Automaton. cCan for this particular language (like palindromes with a non-used elsewhere terminal symbol c in their middle) be accepted by a deterministic machine? Give example of such language. Give example of a graphical language that generates houses using a context-free grammar that is not regular.