1 / 46

Deterministic FA/ PDA

Deterministic FA/ PDA. Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 4. Updated by Marek Perkowski. 0. 4. 5. 1. 0. 1. 1. 0. 0. 1. 1. 0. 3. 1. 2. Numerical Acceptor.

rosa
Download Presentation

Deterministic FA/ PDA

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

  3. 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

  4. M1 e > e M2 Union of Languages

  5. e e S1 M1 F1 S1 M2 F2 > Concatenation of Languages

  6. S1 M1 F1 Kleene Star of Languages e e e > q0

  7. Difference of Languages L1 L2

  8. Intersection of Languages L1 L L2 Intersection expressed by sums and differences only

  9. 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

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

  11. 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)

  12. Is language an bn Regular? • Theorem1: Let L be an infinite regular language. Then there are strings x, y, and z such that y e and x yn 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

  13. (Is language an bn 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 yn z  L with an bn as must go first, bs next

  14. an bn Regular? Case 1: y consists entirely of as x yn z  L Thus we proved that in first case the string that satisfies regular languages cannot be in language L

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

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

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

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

  19. 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.

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

  21. 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, R A finite set of rules, a subset of the crossproduct of the set of non-terminals and all strings,

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

  23. 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

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

  25. 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* G

  26. 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

  27. 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

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

  29. Pushdown Automata • All Context-Free Languages can Be Recognized by a PDA • { anbn } 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

  30. Pushdown Automata: formal definition A PDA is a Sextuple,

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

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

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

  34. 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 Boththe Current State and the Complete Contents of the Stack, x • This “State of the PDA” Is Called the “Configuration of the PDA”

  35. PDA Notation • The Input May Cause the PDA to Change From Configuration 1 to Configuration 2 Note: y is a word, xi are words

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

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

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

  39. Equivalent NPDA input FSM state 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 Top of stack New Top of stack

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

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

  42. 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)

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

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

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

  46. 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. • Can 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.

More Related