Download presentation
Presentation is loading. Please wait.
1
Theory of Automata Chapter 1
Dr. Abdus Salam Theory of Automata Chapter 1 by Dr. Abdus Salam Theory of Automata by
2
Grading Policy Assignments (10%) Quizzes/Tests (10%)
Due at the beginning of the class 10% penalty for each day of delay, up to 3 days Some programming component Quizzes/Tests (10%) Surprise Announced Mid-term exam (30%) Closed books, closed notes Final exam (50%) Dr. Abdus Salam Theory of Automata by
3
Recommended Book(s) Text Book(s): Reference Book(s):
Nasir S.F.B and P.K. Srimani, “A Textbook on Automata Theory”, Cambridge University Press, India, 2008 Sikander H. Khiyal, “Theory of Automata and Computation”, National Book Foundation, 2004 Reference Book(s): John E. Hopcroft, Rajeev Motvani, and Jeffrey D. Ullman, “Introduction to Automata theory, Languages and Computation”, Second Edition, Addison-Wesley, New York, 2001. Daniel I. A. Cohen, “Introduction to Computer Theory”, Second Edition. K.L.P. Mishra, N. Chandrasekaran, “Theory of Computer Science (Automata, Languages and Computation)”, Prentice-Hall of India, 2002. Dr. Abdus Salam Theory of Automata by
4
Computation Computation can be defined as finding a solution to a problem from given inputs by means of an algorithm. Model of Computation A formal or an abstract computer Types of Computation Models Serial Models Parallel Models Dr. Abdus Salam Theory of Automata by
5
Computation Devices In this study we consider a mathematical model of computing. Such a model strips the computational machinery down to the bare minimum, so that it’s easy to manipulate these theoretical machines (there are several such models, for different purposes, as you’ll soon see) mathematically to prove things about their capabilities. Dr. Abdus Salam Theory of Automata by
6
Background Theory of computation is the study of abstract computing devices, or “machines”. Allan Turing in the 1930’s. In the 1940’s and 1950’s, simpler kinds of machines, which we today call “finite automata”, were studied by a number of researchers. These automata, originally proposed to model brain function. Dr. Abdus Salam Theory of Automata by
7
Background In the late 1950’s, the linguist Noam Chomsky begun the study of formal “grammars”. In 1969, S. Cook extended Turing’s study of what could and what could not be computed. The later class of problems is called “intractable”, or NP-hard. Dr. Abdus Salam Theory of Automata by
8
What is a Language? Dr. Abdus Salam Theory of Automata by
9
Formal languages By formal we don't mean dressed up, we mean languages with a form defined by rules that say which strings are in the language and which are not. We are only interested in syntax here, not semantics. We are interested in the form of a string of symbols, not the meaning of the string. Semantic languages Syntactic languages Dr. Abdus Salam Theory of Automata by
10
Types of Formal Languages
Regular languages (type-3) Context-free languages (type-2) Context-sensitive languages (type-1) Phrase structure languages (type-0) Language Generators Language Recognition Dr. Abdus Salam Theory of Automata by
11
Phrase-Structure Languages Context –Sensitive Languages
Context-Free Languages Regular Languages Type-3 DFA NFA ε-NFA RE RG Dr. Abdus Salam Type-2 Language generating devices Language recognition devices PDA CFG Type-1 Theory of Automata by LBA CSG Type-0 TM PSG
12
Lets Play a Game! In this game I have a rule in mind. You guess strings of letters, using only the letters A and B. I’ll tell you whether each string follows the rule or not. Your job is to guess the rule. e.g., suppose you have done these experiments: accepted rejected ABBA BA GUES The Language Dr. Abdus Salam Theory of Automata by
13
Applications Finite state machines are a useful model for many important kinds of hardware and software. e.g. Software for designing digital circuits Lexical analyzer of a compiler Searching for keywords in a file or on the Web Software for verifying finite state systems, such as communication protocols Operating System (UNIX grep) Text Editors Markup Languages (HTML, XML) Natural Language Processing Dr. Abdus Salam Theory of Automata by
14
Dr. Abdus Salam Theory of Automata by Central concepts
15
Central Concepts Symbol
A symbol is a single object and is an abstract entity that has no meaning by itself. It can be alphabet, character or special character Dr. Abdus Salam Theory of Automata by
16
Central Concepts Alphabet
An alphabet is a finite, nonempty set of symbols, Σ (sigma) is used for an alphabet. For example {0, 1} is an alphabet with two symbols {a, b} is another alphabet with two symbols, and English alphabet is also an alphabet Σ = {0,1}, or Σ = the binary alphabet Σ = {a,b,…..z}, or Σ=the set of all lower-case letters Dr. Abdus Salam Theory of Automata by
17
Central Concepts String
A string is a finite sequence of symbols chosen from some alphabet. e.g is a string from the binary alphabet Σ = {0,1}. The number of symbols in a string is called the length of a string. e.g has length 5 and the number of symbols are 2. The standard notation for the length of a string w is |w|. e.g. |011| = 3 and | ε | = 0 Dr. Abdus Salam Theory of Automata by
18
Central Concepts Strings
The empty string (also called null string) is the string with length zero. That is, it has no symbols. It is denoted with ε (epsilon), that may be chosen from any alphabet whatsoever. Thus | ε | = 0. Powers of an Alphabet: If Σ is an alphabet, we define Σk to be the set of strings of length k, each of whose symbols is in Σ. e.g. Σ0 = {ε}. If Σ = {0,1}, then Σ1 = {0,1} Σ2 = {00,01,10,11} Σ3 = {000,001,010,011,100,101,110,111} The set of all strings over an alphabet is denoted as Σ*. For instance, {0,1}* = {ε,0,1,00,01,10,11,000,….}. Put another way, Σ* = Σ0 U Σ1 U Σ2 U Σ3 …. Σ+ = Σ1 U Σ2 U Σ3 …. Dr. Abdus Salam Theory of Automata by
19
Central Concepts Strings
Concatenation of Strings: Let x and y be strings. Then xy denotes the string obtained by concatenating x with y, that is, xy is the string obtained by appending the sequence os symbols of y to that of x. e.g. if x = aab and y = bbab, then xy = aabbbab. Note that xy ≠ yx. Dr. Abdus Salam Theory of Automata by
20
Central Concepts Languages
A language is a set of strings over an alphabet. Thus {a, ab, baa} is a language (over alphabet {a, b}). A set of strings all of which are chosen from some Σ*, where Σ is a particular alphabet, is called a language. If Σ is an alphabet, and L Σ* , then L is a language over Σ. An example is English, where the collection of legal English words is a set of strings over the alphabet that consists of all the letters. Dr. Abdus Salam Theory of Automata by
21
Examples of Languages The language of all strings consisting of n 0’s followed by n 1’s, for some n ≥ 0: {ε, 01, 0011, ,…..} The set of strings of 0’s and 1’s with an equal number of each: {ε, 01,10,0011,0101,1001,…..} The set of binary numbers whose value is a prime: {10, 11, 101,111,1011…..} Note: The only important constraint on what can be a language is that all alphabets are finite, although they can have an infinite number of strings. Dr. Abdus Salam Theory of Automata by
22
Graphs A graph, denoted by G = (V, E), consists of a finite set of vertices V and a set of pairs of vertices E called edges. An example of graph is shown below: Here V={1,2,3,4,5} and E={(n,m)|n+m=4, or n+m=7} Directed graph? Dr. Abdus Salam 1 3 2 4 5 Theory of Automata by
23
Trees A tree is a digraph with the following properties:
There is one vertex, called the root, that has no predecessors and from which there is path to every vertex. Each vertex other than root has exactly one predecessor. The successors of each vertex are ordered “from the left”. Dr. Abdus Salam Theory of Automata by
24
Set Notation It is common to describe a language using a “set-notation”: {w | something about w } It is read “the set of strings w such that (whatever is said about w to the right of the vertical bar)” Examples: { w | w consists of an equal number of 0’s and 1’s } { w | w is a binary integer that is prime } { w | w is a syntactically correct C++ program } Dr. Abdus Salam Theory of Automata by
25
Set-Notation as a way to Define Languages
It is also common to replace w by some expression with parameters and describe the strings in the language by stating conditions on the parameters. For example: { 0n1n | n ≥ 1} {0i1j | 0 ≤ i ≤ j } Dr. Abdus Salam Theory of Automata by
26
Some Special Languages
The empty set Ø is a language which has no strings. The set { ε } is a language which has one string, namely ε . Though ε has no symbols, this set has an object in it. So it is not empty. For any alphabet Σ, the set of all strings over Σ is denoted by Σ*. Thus a language over alphabet Σ is a subset of Σ*. Dr. Abdus Salam Theory of Automata by
27
Operations on Languages
Since languages are sets, all the set operations can be applied to languages. Thus the union, intersection and difference of two languages over an alphabet Σ are languages over Σ. The complement of a language L over an alphabet Σ is Σ* - L and it is also a language. Another operation on a language is concatenation. Let L1 and L2 be languages. Then the concatenation of L1 with L2 is denoted as L1L2 and it is defined as L1L2 = ( xy | x Є L1 and y Є L2} Dr. Abdus Salam Theory of Automata by
28
Theory of Automata Chapter 2
Dr. Abdus Salam by Dr. Abdus Salam Theory of Automata Chapter # 2
29
Finite Automata Definition of an Automaton
“An automaton is defined as a system where energy, materials and information are transformed, transmitted and used for performing some functions without direct participation of man.” Examples are Automatic machine tools, automatic packing machines, and automatic photo printing machines. Dr. Abdus Salam Theory of Automata Chapter # 2
30
Automaton I1 Automaton q1, q2, …..qn O1 I2 O2 I3 O3 Ip Oq
In Computer Science the term ‘automaton’ means “discrete automaton” and is defined in a more abstract way as shown in the figure: Dr. Abdus Salam I1 Automaton q1, q2, …..qn O1 I2 O2 Theory of Automata Chapter # 2 I3 O3 Ip Oq The model of a discrete automaton
31
Characteristics of Discrete Automaton
Input At each discrete instance of time t1, t2,…. Input values I1, I2,…. Each of which can take a finite number of fixed values from the input alphabet Σ, are applied to the input side of the model. Output O1, O2,…. Are the outputs of the model, each of which can take finite number of fixed values from an output O. States At any instant of time the automaton can be in one of the states q1, q2, q3…. State relation The next state of an automaton at any instant of time is determined by the present state and the present input. Output relation Output is related to either state only or to both the input and the state. It should be noted that at any instant of time the automaton is in some state. Dr. Abdus Salam Theory of Automata Chapter # 2
32
Example 1 A vending machine dispense piece of candy that cost Rs. 20 each. The machine accepts coins of Rs. 5 and Rs. 10 only and does not return change. As soon as the amount deposited equal or exceeds Rs. 20, the machine releases a piece of candy. Dr. Abdus Salam Theory of Automata Chapter # 2
33
Example 1 (contd:) Each circle represents a state of the machine
Rs. 15 deposited Rs. 5 deposited 10 Dr. Abdus Salam 5 5 Rs. 0 deposited 5 10 5 5 10 Rs. 20 or more deposited Rs. 10 deposited 10 Theory of Automata Chapter # 2 10 Each circle represents a state of the machine Unlabelled arrow indicates the initial state of the machine Double circle indicates that candy is released, called accepting state.
34
Example 1 (contd:) Next State Table Inputs State 5 10
Rs. 0 deposited Rs. 5 deposited Rs. 10 deposited Rs. 15 deposited Rs. 20 or more deposited Rs. 20 deposited Dr. Abdus Salam Theory of Automata Chapter # 2
35
Example 2 A story of man with wolf, goat and cabbage to cross the river. Dr. Abdus Salam G M MWGC - Φ WC-MG MWC-G G M C W C W C-MWG W-MCG Theory of Automata Chapter # 2 G G G G MGC-W MWG-C C W C W G M Φ - MWGC MG-WC G-MWC G M
36
Deterministic Finite Automata
A deterministic finite automaton is a simple language recognition device. It is called deterministic because their operation is completely determined by their input. Strings are fed into the device by means of an input tape, which is divided into squares, with one symbol inscribed in each tape square. Input tape Dr. Abdus Salam a b a a b b a b Reading head q0 Theory of Automata Chapter # 2 q1 q5 Finite control q2 q4 q3
37
Formal Definition of Deterministic Finite Automata (DFA)
A deterministic finite automaton is quintuple A= (Q, Σ, δ, s, F) where Q is a finite set of states, Σ is an alphabet, s Є Q is the initial state, F Q is the set of final states, and δ the transition function, is a function from Q X Σ to Q . If the symbol read from tape is σ Є Σ, then δ(q, σ) Є Q. Theory of Automata Chapter # 2 Dr. Abdus Salam
38
A DFA M = (Q, Σ, δ, s, F), where Q = {q0, q1} Σ = {a, b} s = q0
F = {q0} q σ δ(q,σ) q0 a b q1 Theory of Automata Chapter # 2 Dr. Abdus Salam
39
The Language of DFA M passes from state q0 to q1 or from q1 back to q0 when a b is read, but M essentially ignores a’s, always remaining in its current state when an a is read. Thus M accepts a string if and only if the number of b’s is even. Then L(M) is the set of all strings in {a,b}* that have an even number of b’s. L(M) = { w | w Є { a, b }* and w contains even number of b’s } Dr. Abdus Salam Theory of Automata Chapter # 2
40
Transition Diagram A transition diagram for a DFA M = (Q, Σ, δ, s, F) is a graph defined as follows: For each state in Q there is a node (vertex). For each state q in Q and each input symbol a in Σ, let δ(q, a) = p. Then the transition diagram has an arc (edge) from node q to node p, labeled a. There is an arrow into the start state q0, labeled start. Nodes corresponding to accepting states (those in F) are marked by a double circle. Dr. Abdus Salam a Theory of Automata Chapter # 2 a b q0 q1 b
41
How a DFA Processes Strings?
Let the input string is aabba. δ(q0, a) = q0 δ(q0, b) = q1 δ(q1, b) = q0 Since q0 belong to F therefore the string is accepted. Dr. Abdus Salam Theory of Automata Chapter # 2
42
Example-2 Let us design a DFA M that accepts the language L(M) = { w | w Є {0,1}* and w is of the form x01y for some strings x and y consisting of 0’s and 1’s only} Dr. Abdus Salam To decide whether 01 is a substring of the input, M needs to remember: 1. Has it already seen 01? If so, then it accepts every sequence of further inputs. 2. Has it never seen 01, but its most recent input was 0, so if it now sees a 1, it will have seen 01. 3. Has it never seen 01, but its last input was either nonexistent or it last saw a 1? Theory of Automata Chapter # 2
43
Example (continued) These three conditions can each be represented by three states q0, q1, q2. The transition functions are: δ(q0, 0) = q2 δ(q0, 1) = q0 δ(q2, 0) = q2 δ(q2, 1) = q1 δ(q1, 0) = q1 δ(q1, 1) = q1 Dr. Abdus Salam 1 0,1 1 q0 q2 q1 Theory of Automata Chapter # 2
44
Transition Tables A transition table is a conventional, tabular representation of a function like δ that takes two arguments and returns a value. The rows of the table correspond to the states, and the columns correspond to the inputs. 1 q0 q2 q0 *q1 q1 Transition table for the DFA Theory of Automata Chapter # 2 Dr. Abdus Salam
45
Quiz No. 1 Dr. Abdus Salam Consider the finite state automaton M shown on the white board. - What are the states of M? - What are the input symbols of M? - What is the initial state of M? - What are the accepting states of M? - Find δ(q0, ). - Find the next state table for M. - Describe informally the language accepted by the DFA. Theory of Automata Chapter # 2
46
Quiz No. 2 Design a DFA to accept the language:
L = { w | w Є {English language letters}* and w has “the” as a substring} - What are the states of M? - What are the input symbols of M? - What is the initial state of M? - What are the accepting states of M? - Find δ(q1, brothers). - Find the transition state table for M. - Draw the transition diagram. Dr. Abdus Salam Theory of Automata Chapter # 2
47
Extending the Transition Function to String
Design a DFA to accept the language: L = { w | w Є {0, 1}* and w has an even number of 0’s and even number of 1’s} Dr. Abdus Salam 1 *->q0 q2 q1 q3 q0 Theory of Automata Chapter # 2
48
Extending the Transition Function to String
Dr. Abdus Salam ^ Theory of Automata Chapter # 2 ^
49
Delta hat(q0, )=? δ(q0, ε) = q0. δ(q0, 1) = (δ(δ(q0, ε ), 1) = δ(q0,1)=q1. δ(q0, 11) = (δ(δ(q0, 1), 1) = δ(q1,1)=q0. δ(q0, 110) = (δ(δ(q0, 11), 0) = δ(q0,0)=q2. δ(q0, 1101) = (δ(δ(q0, 110), 1) = δ(q2,1)=q3. δ(q0, 11010) = (δ(δ(q0, 1101), 0) = δ(q3,0)=q1. δ(q0, ) = (δ(δ(q0, 11010), 1) = δ(q1,1)=q0. ^ Dr. Abdus Salam ^ ^ ^ ^ ^ ^ ^ ^ Theory of Automata Chapter # 2 ^ ^ ^ ^
50
Assignment No. 1 Construct deterministic finite automata accepting each of the following languages. Dr. Abdus Salam Theory of Automata Chapter # 2
51
Using theoretical computer simulators for Formal Languages and Automata Theory
Dr. Abdus Salam Multipurpose FLAT Software DEM (Deus ex Machina) JFLAP (Java Formal Languages & Automata Packages) JCT (Java Computability Toolkit) FSME (Finite State Machine Explorer) Theory of Automata Chapter # 2
52
Nondeterministic Finite Automata
OUTLINE Example of an NFA Difference between DFA and NFA Definition of nondeterministic finite automata Transition diagram an transition table Extended transition function The language of an NFA Proving that an NFA accepts a language Equivalence of DFA and NFA Dr. Abdus Salam Theory of Automata Chapter # 2
53
Example of an NFA A “nondeterministic” finite automata (NFA) has the power to be in several states at once. Nondeterminism is the ability to change states in a way that is only partially determined by the current state and input symbol. A transition diagram for NFA is shown below: Dr. Abdus Salam 0, 1 0, 1 Theory of Automata Chapter # 2 q0 q3 q4 1 1 q1 q2 0, 1
54
Example of an NFA An input sequence a1,a2,….,an is accepted by a NFA if there exists a sequence of transitions corresponding to the input sequence, that leads from the initial state to some final state. e.g is accepted by the NFA because there is a sequence of transition through the states q0, q0, q0, q3, q4, q4 labeled 0, 1, 0, 0, 1. This NFA accepts all strings with either two consecutive 0’s or two consecutive 1’s. DFA is a special case of NFA. Dr. Abdus Salam Theory of Automata Chapter # 2
55
The states an NFA during the processing of an input sequence
Dr. Abdus Salam 1 1 q0 q0 q0 q0 q0 q0 1 1 q3 q1 q3 q3 q1 Theory of Automata Chapter # 2 q4 1 q4
56
Formal Definition of NFA
An NFA is represented like a DFA: A = ( Q, Σ, δ, q0, F) Where: Q is a finite set of states. Σ is a finite set of input symbols. q0 , a member of Q, is the start state. F, a subset of Q, is the set of final (or accepting) states. δ, the transition function is a function that takes a state in Q and an input symbol in Σ as arguments and returns a subset of Q (δ:Qx Σ→2Q). Notice that the only difference between an NFA and DFA is in the type of value that δ returns: a set of states in the case of an NFA and a single state in the case of a DFA. Dr. Abdus Salam Theory of Automata Chapter # 2
57
The Transition Table for an NFA
Dr. Abdus Salam Input State 1 q0 {q0, q3 } {q0, q1 } q1 Ø { q2 } q2 q3 { q4 } q4 Theory of Automata Chapter # 2
58
The difference between DFA and NFA
The difference between DFA and NFA is in the type of δ. For the NFA, δ is a function that takes a state and input symbol as arguments (like the DFA’s transition function), but returns a set of zero, one, or more states (rather than returning exactly one state, as the DFA must). In DFA, for a given input string w and state q, there will be exactly one path labeled w starting at q. To determine if a string is accepted by DFA it suffices to check this one path. For NFA there may be many paths labeled w, and all must be checked to see whether one or more terminate at a final state. The NFA proliferation of states of the transitions diagram with input is Dr. Abdus Salam Theory of Automata Chapter # 2
59
The Extended Transition Function
^ The previous figure suggest that δ(q0, 010) = {q0, q3}. Formally, we define δ for an NFA’s transition function δ by: BASIS: δ(q, ε) = {q} That is, without reading any input symbols, we are only in the state we begin in. INDUCTION: Suppose w is of the form w = xa, where a is the final symbol of w and x is the rest of w. Then δ(q, w) = U δ(pi, a) ^ Dr. Abdus Salam ^ Theory of Automata Chapter # 2 k ^ i =1
60
Example (Extended Transition Function)
Let us use δ to consider the processing of input by the NFA. A summary of the steps is: δ (q0, ε) = {q0} δ (q0, 0) = {q0, q3} δ (q0, 01) = δ(δ(q0, 0), 1)) = δ({q0, q3},1) = δ(q0, 1) U δ(q3, 1) = {q0, q1} U Ø = {q0, q1} δ (q0, 010) = δ(δ(q0, 01), 0)) = δ({q0, q1},0) = δ(q0, 0) U δ(q1, 0) = {q0, q3} U Ø = {q0, q3} δ (q0, 0100) = δ(δ(q0, 010), 0)) = δ({q0, q3},0) = δ(q0, 0) U δ(q3, 0) = {q0, q3} U{q4} = {q0, q3, q4} δ (q0, 01001) = δ(δ(q0, 0100), 1)) = δ({q0, q3, q},1) = δ(q0, 1) U δ(q3, 1) U δ(q4, 1) = {q0, q1} U Ø U {q4} = {q0, q3, q4} As F = {q2, q4} thus {q0, q3, q4} ∩ {q2, q4} = {q4} string is accepted. ^ Dr. Abdus Salam ^ ^ ^ ^ ^ ^ ^ Theory of Automata Chapter # 2 ^ ^
61
The Language of an NFA An NFA accepts a string w if it is possible to make any sequence of choices of next state, while reading the characters of w, and go from the start state to any accepting state. The language of an NFA is the set of strings w such that δ(q0, w) contains at least one accepting state. If A = (Q, Σ, δ, q0, F) is an NFA, then L(A) = { w | δ(q0, w) ∩ F ≠ Ø } i.e. L(A) is the set of strings w in Σ* such that δ(q0, w) contains at least one accepting state. Dr. Abdus Salam ^ Theory of Automata Chapter # 2 ^ ^
62
An NFA Example Input State a b
Let M = (Q, Σ, δ, q0, F), where Q = {q0, q1, q2, q3}, Σ = {a, b}, F = {q3} and δ is given below: Draw the transition diagram for M. What is the language of M? Find δ(q0,aaa)=? ^ Input State a b q0 {q0, q1} {q0} q1 {q2} q2 {q3} q3 Ø Theory of Automata Chapter # 2 Dr. Abdus Salam
63
Equivalence of DFA and NFA
Every language that can be described by some NFA can also be described by some DFA We can prove this statement using subset construction Subset construction involve constructing an automaton in terms of the states and transitions of another automaton Dr. Abdus Salam Theory of Automata Chapter # 2
64
Subset Construction Given an NFA N = (QN, Σ, δN, q0, FN) we will construct a DFA D = (QD, Σ, δD, {q0}, FD) such that L(D) = L(N) Steps of the subset construction QD = { S | S QN} FD = {S QN} | S ∩ FN ≠ Ø } For every S QN and a Є Σ, δD(S, a) = U δN (p, a) Theory of Automata Chapter # 2 Dr. Abdus Salam
65
Example: Subset Construction
Convert the following NFA to a DFA Dr. Abdus Salam Theory of Automata Chapter # 2
66
The Complete Subset Construction
1 Ø ─> {q0} {q0, q1} {q0} {q1} {q2} *{q2} {q0,q1} {q0,q2} *{q0, q2} *{q1, q2} *{q0, q1, q2} {q0, q2} Dr. Abdus Salam Theory of Automata Chapter # 2
67
The DFA Constructed from NFA
Dr. Abdus Salam {q0} {q0, q1} {q0, q2} 1 Theory of Automata Chapter # 2 1
68
Assignment # 2 Write a program to convert an NFA to DFA.
Dr. Abdus Salam Theory of Automata Chapter # 2
69
Theorem 1 If D = (QD, Σ, δD, {q0}, FD) is the DFA constructed from NFA N = (QN, Σ, δN, {q0}, FN) by the subset construction, then L(D)=L(N). PROOF: We prove by induction on |w|, is that δD({q0}, w) = δN(q0, w) Dr. Abdus Salam ^ ^ Theory of Automata Chapter # 2
70
The inductive part of the definition of δ for NFA’s tell us
BASIS: Let |w| =0; that is, w = ε by the basis definition of δ for DFA’s and NFA’s, both δD({q0}, ε) and δN(q0, ε) are {q0}. INDUCTION: Let w be of length n + 1, and assume the statement for length n. Break w up as w = xa, where a is the final symbol of w. By the induction hypothesis, δD({q0}, x) = δN({q0}, x). Let both these sets of N’s states be {p1, p2,…,pk}. The inductive part of the definition of δ for NFA’s tell us δN(q0, w) = δ(q0, xa) δN(q0, x) = {p1, p2,…,pk} δN(q0, w) = UδN(pi, a) ………(1) The subset construction, on the other hand, tells us that δD({p1, p2,…,pk}, a) = UδN(pi, a) ……..(2) Now, let us use (2) and the fact that δD({q0}, x) = {p1, p2,…,pk} in the inductive part of the definition of δ for DFA’s: δD({q0}, w) = δD(δD({q0}, x), a) = δD({p1, p2,…,pk}, a = UδN(pi, a) Thus the above equations demonstrate that δD({q0}, w) = δN(q0, w). When we observe that D and N both accept w if and only if δD({q0}, w) or δN(q0, w), respectively, contain a state in FN, we have a complete proof that L(D) = L(N). Dr. Abdus Salam ^ ^ ^ ^ ^ Theory of Automata Chapter # 2 ^ ^ ^ ^ ^ ^ ^
71
Convert to a DFA the following NFA
1 →p {p, q} {p} q {r} r {s} Ø *s 1 ─> {p} {p, q} {p} {p, q, s} {p, r} {p, q, r, s} *{p, q, s} {p, r, s} *{p, q, r, s} *{p, r, s} {p, s} *{p, s} Dr. Abdus Salam Theory of Automata Chapter # 2
72
Which of the following strings are accepted by this nondeterministic finite automata?
Dr. Abdus Salam aa aba abb ab abab a b a b e a b b Theory of Automata Chapter # 2
73
Design an NFA to recognize the following set of strings
b c d ->q0 {q0,q1,q4,q7} {q0} q1 {} {q2} q2 {q3} *q3 q4 {q5} q5 {q6} *q6 q7 {q8} q8 {q9} q9 {q10} *q10 Exercise 2.4.1 a) abc, abd, and aacd. Assume the alphabet is {a, b, c, d} Theory of Automata Chapter # 2 Dr. Abdus Salam
74
Finite Automata with Epsilon-Transitions
The new “feature” is that a transition is allowed on ε, the empty string. It does not expand the class of languages that can be accepted by finite automata. It gives us some added “programming convenience”. NFA’s with ε-transitions are called ε-NFA’s Dr. Abdus Salam Theory of Automata Chapter # 2
75
A ε-NFA accepting decimal numbers
An optional + or – sing, A string of digits, A decimal point Another string of digits. Either this string, or the strings (2) can be empty. Dr. Abdus Salam Theory of Automata Chapter # 2
76
The Formal Notation for an ε-NFA
An ε-NFA is a quintuple (Q, Σ, δ, q0, F) where δ is a function from Q X Σ U {ε} to the power set of Q. The ε-NFA from the previous slide is represented formally as E = ({q0, q1,…,q5}, {.,+,-,0,1,2,…9}, δ, q0, {q5}) where the transition table for δ is Dr. Abdus Salam Theory of Automata Chapter # 2
77
Epsilon-Closures We ε-close a state q by following all transitions out of q that are labeled ε. When we get to other states by following ε, we follow the ε-transitions out of those states, and so on, eventually finding every state that can be reached from q along any path whose arcs are labeled ε. Formal Definition BASIS: State q is in ECLOSE(q). INDUCTION: If state p is in ECLOSE(q), and there is transition from state p to state r labeled ε, then r is in ECLOSE(q). Dr. Abdus Salam Theory of Automata Chapter # 2
78
Ε-Close Example For the automaton of previous slide, each state is its own ε-closure, with two exceptions: ECLOSE(q0) = {q0, q1} and ECLOSE(q3) = {q3, q5}. Another Example: Dr. Abdus Salam Theory of Automata Chapter # 2 ECLOSE(1) = {1, 2, 3, 4, 6}
79
Extended Transitions and Languages for ε-NFA’s
BASIS: δ(q, ε) = ECLOSE(q). INDUCTION: δ(q, xa) = U ECLOSE(p) p Є δ(δ(q, x), a) Example Lets compute δ(q0, 5.6) for ε-NFA of previous slide on the board. Dr. Abdus Salam Theory of Automata Chapter # 2
80
Eliminating ε-Transitions
Given an ε-NFA E = (QE, Σ, δE, q0, FE) We will construct a DFA D = (QD, Σ, δD, q0, FD) Such that L(D) = L(E) Details of the construction: QD = {S | S QE and S = ECLOSE(S)} qD = ECLOSE(q0) FD = { S | S Є QD and S ∩ FE ≠ Ø } δD(S, a) =U{ ECLOSE(p) | p Є δ(t, a) for some t Є S} Theory of Automata Chapter # 2 Dr. Abdus Salam
81
Eliminating ε-Transitions
Dr. Abdus Salam Theory of Automata Chapter # 2 δ(q0, ε) = ECLOSE(q0) = {q0, q1} δ({q0,q1}, +-) = ECLOSE(δ({q0, q1}, +-))
82
Dr. Abdus Salam Theory of Automata Chapter # 2
83
Transducers Finite automata with output Moore Machine Mealy Machine
Dr. Abdus Salam Theory of Automata Chapter # 2
84
Moore Machine A Moore machine is like a finite automata except the following differences. There are two alphabets (input alphabet & output alphabet) No accept states Not a language recognizer It is an output producer Each state produces a one-character output immediately upon the machines entry into that state. Dr. Abdus Salam Theory of Automata Chapter # 2
85
Moore Machine Formal definition
A Moore machine is a sixtuple M=(Q,Σ,∆,δ,Λ,q0) Q is a finite set of states Σ is an input alphabet ∆ is an output alphabet δ transitions from one state to another Λ is output table. Λ is a mapping from Q -> ∆ i.e. Λ(Q) = ∆ q0 is starting state Dr. Abdus Salam Theory of Automata Chapter # 2
86
Moore Machine Example Σ = {a, b} ∆ = {0, 1} Q={q0, q1, q2, q3}
Run the string abab through the machine which will produce the output Input States Output a b q0 1 q1 q3 q2 q0/1 a q1/0 b b a a b q3/1 a q2/0 Theory of Automata Chapter # 2 b Dr. Abdus Salam
87
Exercise Counting machine
Construct a Moore machine that produces a 1 for each occurrence of the substring aab found in the input string. Dr. Abdus Salam Theory of Automata Chapter # 2
88
Mealy Machine A Mealy machine produces output on a transition instead of on entry into a state. Transitions are labeled i/o. No accept states Not a language recognizer, it is an output producer. Its output will be the same length as its input. Dr. Abdus Salam Theory of Automata Chapter # 2
89
Mealy Machine Formal definition
A Mealy machine is a sixtuple M=(Q,Σ,∆,δ,Λ,q0) Q is a finite set of states Σ is an input alphabet ∆ is an output alphabet δ transitions from one state to another Λ is output table. Λ is a mapping from Q x Σ -> ∆ i.e. Λ(Q) = ∆ q0 is starting state Dr. Abdus Salam Theory of Automata Chapter # 2
90
Mealy Machine Example q0 q1/0 q3/0 q1 q3/1 q2/1 q2 q3 q0/1
Input States a b q0 q1/0 q3/0 q1 q3/1 q2/1 q2 q3 q0/1 Σ = {a, b} ∆ = {0, 1} Q={q0, q1, q2, q3} Run the string aaabb through the machine which will produce the output q0 a/0 q1 a/1 b/0 b/1 b/1 a/1 q2 q3 Theory of Automata Chapter # 2 b/1, a/0 Dr. Abdus Salam
91
Exercise Construct a Mealy machine that takes the 1’s complement of its binary input. Produce a Mealy machine that adds two integers using their binary expansions. Construct a Mealy machine that accept its input in a binary number and prints out the binary number that is one larger. Dr. Abdus Salam Theory of Automata Chapter # 2
92
Theory of Automata Chapter 3-Regular Expressions
by Dr. Abdus Salam
93
Regular Expressions The set of strings accepted by a finite automaton is referred to as the language accepted by the finite automaton. We might describe a finite automaton as a language recognizer whereas a regular expression is a language generator. For each finite automaton there is a regular expression that defines the same language. Dr. Abdus Salam Theory of Automata
94
Defining Languages L1 = {xn | n = 1, 2, 3, …}
L4 = {ε x xx xxx …} Let S = {x}. Then L4 = S* We can also write L4 = {x}* x* = ε x1 x2 x3… = xn The language L4 can also be defined by any of the expressions below: xx* x+ xx*x* x*xx* x+x* x*x+ Dr. Abdus Salam Theory of Automata
95
Examples The Language defined by the expression ab*a
Is the set of all strings of a’s and b’s that have at least two letters, that begin and end with a’s and that have nothing but b’s inside (if any thing at all). Language(ab*a)={aa aba abba abbba…} Dr. Abdus Salam Theory of Automata
96
More Examples a*b* Language(a*b*)={ε a b aa ab bb aaa aab…} Note a*b* ≠ (ab)* L2 = { xodd} can be defined as x(xx)* or (xx)*x 01* + 10* Denotes the language consisting of all strings that are either a single 0 followed by any number of 1’s or a single 1 followed by any number of 0’s. Dr. Abdus Salam Theory of Automata
97
Operations on languages
Union Concatenation Closure (or star, Kleene closure) Dr. Abdus Salam Theory of Automata
98
Languages and Regular Expression
S.No. Languages Regular Expression 1 {ε} ε 2 {0} 3 {001} i.e. {0}{0}{1} 001 4 {0,1} 0+1 5 {1, ε}{001} (1+ ε)001 6 {110}*{0,1} (110)*(0+1) 7 {1}*{10} 1*10 8 {10, 111, 11010} ( )* Theory of Automata Dr. Abdus Salam
99
Formal Definition of RE
A RE over the alphabet Σ, and the corresponding language are defined as follows: Every letter of Σ can be made into a regular expression; ε itself is a regular expression. If r1 and r2 are regular expressions, then so are: (r1) r1r2 r1 + r2 r1* Nothing else is a regular expression Dr. Abdus Salam Theory of Automata
100
Example Regex for: L = { w Є {0, 1}* | 0 and 1 alternate in w}
(01)* + (10)* + 0(10)* + 1(01)* Or, equivalently, (ε + 1)(01)*(ε + 0) Order of precedence for operators: Star Dot Plus Example: 01* + 1 is grouped (0(1)*) + 1 Dr. Abdus Salam Theory of Automata
101
Example-1 Write regular expression for the following languages:
The set of strings over alphabet {a, b, c} containing at least one a and at least one b. Ans: The simplest approach is to consider those strings in which the first a precedes the first b separately from those where the opposite occurs. The expression: c*a(a+c)*b(a+b+c)* + c*b(b+c)*a(a+b+c)* Dr. Abdus Salam Theory of Automata
102
Example-2 The language of all words that have at least two a’s can be described by the expression (a + b)*a (a + b)*a (a + b)* (some beginning) (the 1st important a) (some middle) (the 2nd important a) (some end) Dr. Abdus Salam Theory of Automata
103
Example-3 Even-Even = {ε aa bb aaaa aabb abab abba baab baba bbaa bbbb aaaaaa aaaabb aaabab} E = [aa+bb+(ab+ba)(aa+bb)*(ab+ba)]* type1 = aa type2 = bb type3 = (ab + ba)(aa + bb)*(ab + ba) E = [type1 + type2 + type3]* Dr. Abdus Salam Theory of Automata
104
Equivalence of FA’s and regex’s
We have already shown that DFA’s, NFA’s, and ε-NFA all are equivalent. To show FA’s equivalent to regex’s we need to establish that For every DFA A we can find (construct, in this case) a regex R, such that L(R) = L(A). For every regex R there is a ε-NFA A, such that L(A) = L(R). Dr. Abdus Salam Theory of Automata
105
Simplification Rules We will be needing the following simplification rules: (ε + R)* = R* R + RS* = RS* ØR = R Ø = Ø (Annihilation) Ø + R = R + Ø = R (Identity) Dr. Abdus Salam Theory of Automata
106
Convert DFA to regex Rij = Rij + Rik (Rkk )*Rkj
L(A) = {x0y | x Є {1}* and y Є {0,1} } Dr. Abdus Salam Theory of Automata
107
Convert DFA to regex (con’t)
Dr. Abdus Salam Theory of Automata
108
Convert DFA to regex (con’t)
Dr. Abdus Salam Theory of Automata
109
Convert DFA to regex (con’t)
Dr. Abdus Salam Theory of Automata
110
Observations There are n3 expressions for an n-state automaton
Each inductive step grows the expression 4-fold R(n) could have size 4n For all {i, j} < {1,….,n}, R(k) uses R(k-1) So we have to write n2 times the regex R(k-1) We need a more efficient approach: The State Elimination Technique Dr. Abdus Salam ij ij kk kk Theory of Automata
111
The State Elimination Technique
When state S is eliminated, all the paths that went through s no longer exist in the automaton. To not to change the language of automaton, add an arc from q to p. How to label that arc? Use a Regular Expression. The language of the automaton is the union over all paths from the start state to an accepting state of the language formed by concatenating the REs along the path. Dr. Abdus Salam Theory of Automata
112
The State Elimination Technique
What happens when we eliminate state s. For each accepting state q eliminate from the original automaton all states except q0 and q. To compensate, we introduce, for each predecessor qi of s and each successor pj of s, a RE that represents all the paths that start at qi and finally go to pj. The expression for these paths is QiS*Pj. Add this expression to the arc from qi to pj. Dr. Abdus Salam Theory of Automata
113
Constructing a RE from a FA
For each accepting state q, apply the previous reduction process to produce an equivalent automaton with RE labels on the arcs. Eliminate all states except q and the start state q0. If q ≠ q0, then we shall be left with a two-state automaton that looks like; The RE for the accepted strings can be described as (R+SU*T)*SU Dr. Abdus Salam Theory of Automata
114
The Strategy for Constructing a RE from a FA
If the start state is also an accepting state, then we are left with a one-state automaton that looks like; The RE denoting the strings that it accepts is R*. The desired RE is the sum (union) of all the expressions derived from the reduced automata for each accepting state, by rules (2) and (3). Dr. Abdus Salam Theory of Automata
115
Example 3.6 Dr. Abdus Salam First step is to convert it to an automaton with regular expression labels. Theory of Automata
116
Example (con’t) Lets eliminate state B.
State B has one predecessor, A, and one successor, C. Thus: Q1 = 1, P1 = 0 + 1, R11 = Ø (Since the arc from A to C does not exist) and S = Ø (because there is no loop at state B). The resultant expression is Ø + 1Ø*(0 + 1). To simplify; initial Ø may be ignored in a union. L(Ø*) = {Є} U L(Ø) U L(Ø) ……. Thus Ø + 1Ø*(0 + 1) is equivalent to 1(0 + 1). Dr. Abdus Salam Theory of Automata
117
Example (con’t) Lets eliminate state C and obtain AD.
The mechanics is similar to those performed to eliminate state B and the resulting automaton is shown as follows: Dr. Abdus Salam Theory of Automata The REs are R = 0 + 1, S = 1(0 + 1)(0 + 1), T = Ø, U = Ø. The generic expression (R + SU*T)*SU* thus simplifies in this case to R*S, or (0 + 1)*1(0 + 1)(0 + 1).
118
Example (con’t) with regex (0 + 1)*1(0 + 1)
We can eliminate D to obtain AC. Dr. Abdus Salam with regex (0 + 1)*1(0 + 1) The final expression is the sum of previous two regex’s: (0 + 1)*1(0 + 1)(0 + 1) + (0 + 1)*1(0 + 1) Theory of Automata
119
From regex’s to ε-NFA’s
Theorem 3.7: For every regex R we can construct an ε-NFA A, s.t. L(A) = L(R). Proof: By structural induction: Basis: Automata for ε, Ø, and a. Dr. Abdus Salam Theory of Automata
120
From regex’s to ε-NFA’s
Induction: Automata for R + S, RS, and R*. Dr. Abdus Salam Theory of Automata
121
Example 3.8 Let us convert the regular expression (0 + 1)*1(0 + 1)
Dr. Abdus Salam Theory of Automata
122
Example 3.8 (cont.) Dr. Abdus Salam Theory of Automata
123
Application of Regular Expressions
Regular Expression in UNIX Most real applications deal with the ASCII character set UNIX regular expression allow us to write character classes to represent large sets of characters. The rules are: The symbol . (dot) stands for “any character” The sequence [a1,a2…ak] stands for the regular expression a1 + a2 + … + ak A range of the form x-y mean all the characters form x to y in the ASCII sequence. e.g. digits can be expressed [0-9] Dr. Abdus Salam Theory of Automata
124
Application of Regular Expressions
There are special notations for several of the most common classes of characters. e.g. [:digit;] is the set of ten digits, the same as [0-9]. [:alpha:] stands for any alphabetic character, as does [A-Za-z] [:alnum:] stands for the digits and letters, as does {A-Za-z0-9] grep stands for “Global (search for) Regular Expression and Print” Lexical Analysis Finding Patterns in Text Dr. Abdus Salam Theory of Automata
125
Automata Theory Chapter 4 Properties of Regular Languages
by Dr. Abdus Salam
126
Algebraic Laws for Languages
Commutativity is the property of an operator that says we can switch the order of its operands and get the same result. L + M = M + L. The commutative law of union, says that we may take the union of two languages in either order. Associativity is the property of an operator that allows us to regroup the operands when the operator is applied twice. (L + M) + N = L + (M + N). The associative law for union, says that we may take the union of three languages either by taking the union of the first two initially, or taking the union of the last two initially. Dr. Abdus Salam Theory of Automata
127
Algebraic Laws for Languages
(LM)N = L(MN). The associative law for concatenation, says that we can concatenate three languages by concatenating either the first two or the last two initially. Missing from this list is the “law” LM = ML, which would say that concatenation is commutative. However, this law is false. Dr. Abdus Salam Theory of Automata
128
Algebraic Laws for regexp’s
Identity An identity for an operator is a value such that when the operator is applied to the identity and some other value, the result is the other value. e.g. 0 is the identity for addition. Annihilator An annihilator for an operator is a value such that when the operator is applied to the annihilator and some other value, the result is the annihilator. e.g. 0 is an annihilator for multiplication. Dr. Abdus Salam Theory of Automata
129
Algebraic Laws for regexp’s
There are three laws for regular expressions involving these concepts Ø + L = L + Ø = L. This law asserts that Ø is the identity for union. ЄL = LЄ = L. This law asserts that Є is the identity for concatenation. ØL = LØ = Ø. This law asserts that Ø id the annihilator for concatenation. Dr. Abdus Salam Theory of Automata
130
Distributive Laws A distributive law involves two operators, and asserts that one operator can be pushed down to be applied to each argument of the operator individually. L(G(E + F)) =L(EG + FG). This law, is the left distributive law of concatenation over union. e.g. L(( )11) = L( ) L((E + F)G) =L(EG + FG). This law, is the right distributive law of concatenation over union. Dr. Abdus Salam Theory of Automata
131
The Idempotent Law An operator is said to be idempotent if the result of applying it to two of the same values as arguments is that value. e.g = 0. L + L = L. This law, the idempotence law for union, states that if we take the union of two identical expressions, we can replace them by one copy of the expression Dr. Abdus Salam Theory of Automata
132
Laws Involving Closures
Dr. Abdus Salam (L*)* = L* Closing an expression that is already closed does not change the language. Ø* = ε The closure of Ø contains only the string ε. ε* = ε The only string that can be formed by concatenating any number of copies of the empty string is the empty string itself. L+ = LL*=L*L L+ is defined to be L+LL+LLL+…. L* = ε + L + LL + LLL + …. Theory of Automata
133
Properties of Regular Languages
Dr. Abdus Salam Pumping Lemma. Every regular language satisfies the pumping lemma. If somebody presents you with fake regular language, use a pumping lemma to show a contradiction. Closure properties. Building automata from components through operations, e.g. given L and M we can build an automaton for L ∩ M. Decision properties. Computational analysis of a automata, e.g. are two automata equivalent. Minimization techniques. We can save money since we can build smaller machines. Theory of Automata
134
Proving Languages not to be Regular
The class of languages known as the regular languages has four different descriptions. They are the languages accepted by: DFA’s NFA’s ε-NFA’s RE Not every language is a regular language. Dr. Abdus Salam Theory of Automata
135
Nonregular Languages Consider the language L = {0n1n | n ≥ 0}
If we attempt to find a DFA that recognizes L we discover that such a machine needs to remember how many 0s have been seen so far as it reads the input Because the number of 0s isn’t limited, the machine needs to keep track of an unlimited number of possibilities This cannot be done with any finite number of states Dr. Abdus Salam Theory of Automata
136
Intuition may fail us Just because a language appears to require unbounded memory in order to recognized, it doesn’t mean that it is necessarily so Example C = {w |w has an equal number of 0s and 1s} is not regular D = {w |w has an equal number of 01 and 10 as substrings} is regular Dr. Abdus Salam Theory of Automata
137
Language nonregularity
The technique for proving nonregularity of some languages is provided by a theorem about regular languages called pumping lemma Pumping lemma states that all regular languages have a special property If we can show that a language does not have this property we are guaranteed that it is not regular Dr. Abdus Salam Theory of Automata
138
Pumping Property All strings in the language can be “pumped" if they are at least as long as a certain special value, called the pumping length Meaning: each such string in the language contains a section that can be repeated any number of times with the resulting string remaining in the language. Dr. Abdus Salam Theory of Automata
139
The Substring Cycle Let us consider the NFA given below.
Dr. Abdus Salam Theory of Automata
140
The Substring Cycle This NFA accepts among others some strings of length greater than 5 such as abbabbb, abbabbabbb etc. Those strings which are accepted by this NFA and whose length is greater than 5 have a substring which can be repeated any number of times without being rejected by the NFA. For example the string abbabbb is accepted by the NFA and if one of its substrings bba is repeated any number of times in abbabbb, the resultant strings such as abbb (bba repeated 0 times), abbabbabbb, abbabbabbabbb etc. are also accepted by the NFA. In general if a string w (such as abbabbb in the example above) is accepted by an NFA with n states and if its length is longer than n, then there must be a cycle in the NFA along some path from the initial state to some accepting state (such as the cycle in the above example). Then the substring representing that cycle (bba in the example) can be repeated any number of times within the string w without being rejected by the NFA. Dr. Abdus Salam Theory of Automata
141
The Pumping Lemma for RL
Let L be a regular language. Then n, w Є L : |w| ≥ n => w = xyz such that: y ≠ ε |xy| ≤ n k ≥ 0, xykz Є L That is we can always find a nonempty string y not too far from the beginning of w that can be “pumped”; that is, repeating any number of times, or deleting it (the case k = 0), keeps the resulting string in the language L. Theory of Automata Dr. Abdus Salam
142
The Pumping Lemma for RL
Proof Suppose L is regular. Then L = L(A) for some DFA A. Suppose A has n states. Now, consider any string w of length n or more, say w = a1a2…am, where m ≥ n and each ai is an input symbol. For i = 0, 1, . . ., n define state pi to be δ(q0, a1a2…ai), where δ is the transition function of A, and q0 is the start state of A. That is, pi is the state A is in after reading the first i symbols of w. Note that p0 = q0. By the pigeonhole principle, it is not possible for the n+1 different pi’s for i = 0,1,…,n to be distinct, since there are only n different states. Thus we can find two different integers i and j, with 0 ≤ i ≤ j ≤ n, such that pi = pj. Now, we can bring w = xyz as follows: Dr. Abdus Salam Theory of Automata
143
The Pumping Lemma for RL
x = a1a2…ai y = ai+1ai+2…aj z = aj+1aj+2…am That is, x takes us to pi once; y takes us from pi back to pi (since pi is also pj), and z is the balance of w. The relationships among the strings and states are suggested by the following figure. Note that x may be empty, in the case that i = 0. Also, z may be empty if j = n = m. However, y cannot be empty, since i is strictly less than j. Dr. Abdus Salam Theory of Automata
144
The Pumping Lemma for RL
Now, consider what happens if the automaton A receives the input xykz for any k ≥ 0. if k = 0, then the automaton goes from the start state q0 (which is also p0) to pi on input x. Since pi is also pj, it must be that A goes from pi to the accepting state shown in figure on input z. Thus, A accepts xz. If k > 0, then A goes from q0 to pi input x, circles from pi to pi k times on input yk, and then goes to the accepting state on input z. Thus, for any k >= 0, zykz is also accepted by A; that is, xykz is in L. Dr. Abdus Salam Theory of Automata
145
Example Leq = { 0n1n | n ≥ 0 }. We wish to show that L is not regular.
Suppose Leq is regular. Then there is a +ve integer n that satisfies the conditions of pumping lemma. We show that no matter what n is, we may find w, with |w| ≥ n, that produces a contradiction. Consider a string w = 0n1n for that n. Then there must be strings x, y, and z such that w=xyz |xy| ≤ n, |y| ≥ n and xykz Є Leq for every k ≥ 0. w = Dr. Abdus Salam Theory of Automata X y z
146
Since |y| > 0 , y has at least one symbol
Since |y| > 0 , y has at least one symbol. In string w = 0n1n, y can be inside 0n , inside 1n or straddle 0n and 1n . Hence there are the following three possibilities for y: 1. y = 0p, p > 0 , 2. y = 1p, p > 0 or 3. y = 0p1q , p, q > 0 . Let us now consider the string xykz for k = 2 for each of these three cases. In case 1, xy2z = 0n-p02p1n = 0n+p1n . Since p > 0 , n + p ≠ n . Hence 0n+p1n can not be in the language L represented by 0n1n . Similarly in case 2, since xy2z = 0n 1n + p , it can not be in L. In case 3, xy2z = 0n-p(0p1q)21n-q = 0n-p(0p1q0p1q)1n-q = 1n 1q0p1n , which can not be in L. Thus in all three cases xy2z is not in L. This violates the condition that for every k >= 0, xykz Є L. Hence L is not a regular language. Dr. Abdus Salam Theory of Automata
147
Equivalence and Minimization of Automata
Let A = (Q, Σ, δ, q0, F) be DFA, and {p, q} Q. We define; p ≡ q Aw Є Σ* : δ(p, w) Є F iff δ(q, w) Є F If p ≡ q we say that p and q are equivalent. If p ≡ q we say that p and q are distinguishable. In other words p and q are distinguishable iff ≡ w : δ(p, w) Є F and δ(q, w) Є F, or vice versa. / / Theory of Automata Dr. Abdus Salam
148
Example Dr. Abdus Salam Theory of Automata δ(C, ε) Є F, δ (G, ε) Є F => C ≡ G δ(A, 01) = C Є F, δ(G, 01) = E Є F => A ≡ G / / / /
149
What about A and E? Dr. Abdus Salam / / δ(A, ε) = A Є F, δ (E, ε) = E Є F δ(A, 1) = F = δ (E, 1) Therefore δ(A, 1x) = δ(E, 1x) = δ (F, x) δ(A, 00) = G = δ(E, 00) δ(A, 01) = C = δ(E, 01) Conclusion A≡ E. Theory of Automata
150
Table Filling Algorithm
We can compute distinguishable pairs with the following inductive table filling algorithm: Basis: If p Є F and q Є F, then p ≡ q. Induction: If a Є Σ : δ(p, a) ≡ δ(q, a), then p ≡ q. Example: Applying the table filing algo to A: / / / / Theory of Automata Dr. Abdus Salam
151
Applying the Table Filling Algo.
Step-1 Step-2 Step-3 Dr. Abdus Salam B B B C x C x x C D x x D x D x x x E E x E x x x F F x F x x x x G G x G x x x x x x H H x H x x x x x x A B C D E F G A B C D E F G Theory of Automata A B C D E F G The three remaining pairs, which are therefore equivalent pairs, are {A, E}, {B, H} and {D, F}. Thus, the table filling algorithm stops with the table shown in Step-3, which is the correct determination of equivalent and distinguishable states.
152
Testing Equivalence of Regular Languages
Let L and M be regular languages (each given in some form). To test if L = M Convert both L and M to DFA’s. Imagine the DFA that is the union of the two DFA’s (never mind there are two start states). If TF-Algo says that the two start states are distinguishable, then L ≠ M, otherwise L = M. Dr. Abdus Salam Theory of Automata
153
Example Dr. Abdus Salam Theory of Automata
154
Minimization of DFA’s We can minimize the DFA to obtain
Dr. Abdus Salam We can minimize the DFA to obtain Theory of Automata
155
The End Thank You
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.