|Published (Last):||4 March 2006|
|PDF File Size:||20.93 Mb|
|ePub File Size:||6.98 Mb|
|Price:||Free* [*Free Regsitration Required]|
Note: For each input symbol a, from a given state there is exactly one transition there can be no transitions from a state also and we are sure or can determine to which state the machine enters. So, the machine is called Deterministic machine. Obtain a DFA to accept strings of as and bs having a sub string aa Obtain a DFA to accept strings of as and bs except those containing the substring aab.
Obtain DFAs to accept strings of as and bs having exactly one a, Obtain a DFA to accept strings of as and bs having even number of as and bs The machine to accept even number of as and bs is shown in fig. The DFAs are extensively used in the building the various phases of compiler such as - Lexical analysis To identify the tokens, identifiers, to strip of the comments etc. It is not possible to list all the applications as there are infinite number of applications. This section lists some applications: 1.
Large natural vocabularies can be described using finite automaton which includes the applications such as spelling checkers and advisers, multi-language dictionaries, to indent the documents, in calculators to evaluate complex expressions based on the priority of an operator etc.
Any editor that we use uses finite automaton for implementation. Finite automaton is very useful in recognizing difficult problems i. Even though there is no general solution exists for the specified problem, using theory of computation, we can find the approximate solutions.
Finite automaton is very useful in hardware design such as circuit verification, in design of the hardware board mother board or any other hardware unit , automatic traffic signals, radio controlled toys, elevators, automatic sensors, remote sensing or controller etc. In game theory and games wherein we use some control characters to fight against a monster, economics, computer graphics, linguistics etc.
This function shows the change of state from one state to a set of states based on the input symbol. The way to obtain different transitions is shown in step2. Step2: For each state [q i , q j ,. Add the transition from [q i , q j ,. Step3: The state [q a , q b ,. The final transitional table is shown in table 2. So, all these states are reachable from state 2.
The final transition diagram of DFA is shown in figure 2. If R is a regular expression denoting the language L R and S is a regular expression denoting the language L S , then a. S is a regular expression corresponding to the language L R. The expressions obtained by applying any of the rules from are regular expressions. The table 3. String of as and bs of even length can be obtained by the combination of the strings aa, ab, ba and bb.
The language may even consist of an empty string denoted by c. String of as and bs of odd length can be obtained by the combination of the strings aa, ab, ba and bb followed by either a or b.
So, a variety of regular expressions can be obtained for a language and all are equivalent. Proof: By definition, , c and a are regular expressions. So, the corresponding machines to recognize these expressions are shown in figure 3. Fig 3.
Let us take each case separately and construct equivalent machine. Here, q 0 is the start state of the combined machine and q f is the final state of combined machine M. R 2 as shown in figure 3. R2 It is clear from figure 3. Since there is a c-transition, without any input there will be a transition from state f 1 to state q 2.
In state q 2 , upon accepting L R 2 , the machine moves to f 2 which is the final state. Thus, q 1 which is the start state of machine M 1 becomes the start state of the combined machine M and f 2 which is the final state of machine M 2 , becomes the final state of machine M and accepts the language L R 1.
It can also be represented as shown in figure 3. Here, q 0 is the start state q f is the final state. Obtain an NFA which accepts strings of as and bs starting with the string ab. Step 1: The machine to accept a is shown below. Step 2: The machine to accept b is shown below. Step 5: The machine to accept ab is shown below. The general procedure to obtain a regular expression from FA is shown below. Consider the generalized graph Fig. Any graph can be reduced to the graph shown in figure 3.
Then substitute the regular expressions appropriately in the equation 3. If r 3 is not there in figure 3. So, the regular expression is R. We can match an identifier or a decimal number or we can search for a string in the text.
An application of regular expression in UNIX editor ed. In UNIX operating system, we can use the editor ed to search for a specific pattern in the text. Note that the editor ed accepts the regular expression and searches for that particular pattern in the text. As the input can vary dynamically, it is challenging to write programs for string patters of these kinds. This section lists some applications: 5. Step1: q 0 is the start of DFA see step1 in the conversion procedure.
Table 2. Applications of Regular Expressions Pattern Matching refers to a set of objects with some common properties. Khodanpur: Closure properties of regular languages Used to build recognizers for languages that are constructed from other languages by certain operations. Automata for intersection of two regular languages Decision properties of regular languages Used to find whether two automata define the same language Used to minimize the states of DFA eg. Design of switching circuits. This implies DFA has no memory to remember arbitrary n.
In other words if we have to remember n, which varies from 1 to , we have to have infinite states, which is not possible with a finite state machine, which has finite number of states. For all k 0, the string xy k z is also in L. Let the start state be P 1. Uses of Pumping Lemma: - This is to be used to show that, certain languages are not regular. It should never be used to show that some language is regular.
Example 1. Let n is the constant PL Definition. Consider a word w in L. Because xy n. Then, the break up of x. Hence the Language is not regular. Example 2. That is, the break up of x. Contradiction, hence the language is not regular. Example 3. The union of two regular languages is regular. The intersection of two regular languages is regular. The complement of a regular language is regular. The difference of two regular languages is regular.
The reversal of a regular language is regular. The closure star of a regular language is regular. The concatenation of regular languages is regular. A homomorphism substitution of strings for symbols of a regular language is regular.
Consider a DFA that accepts all those strings that have a 0. Consider a DFA that accepts all those strings that have a 1. The product of above two automata is given below. Then pr represents only the initial condition, in which we have seen neither 0 nor 1. Then state qr means that we have seen only once 0s, while state ps represents the condition that we have seen only 1s. The accepting state qs represents the condition where we have seen both 0s and 1s. L R is a language consisting of the reversals of the strings of L.
If L is regular we can show that L R is also regular. If there are more than one final states, we can use e- transitions from the final states going to a common final state. The proof implies the following method 1. Reverse all the transitions.
Finite Automata and Formal Languages : A Simple Approach
FAFL Padma Reddy1