Full Transcript

**University of Science and Technology** **Faculty of Computer Science and Information Technology** **Theory of Computation** **Lecture (3):** **Instructor: Prof. Noureldien A. Noureldien** **3.1 Formal Definition of Computation** So far, we have described finite automata informally, using stat...

**University of Science and Technology** **Faculty of Computer Science and Information Technology** **Theory of Computation** **Lecture (3):** **Instructor: Prof. Noureldien A. Noureldien** **3.1 Formal Definition of Computation** So far, we have described finite automata informally, using state diagrams, and with a formal definition, as a 5-tuple. Next, we do the same for a finite automaton's computation. We already have an informal idea of the way it computes, and we now formalize it mathematically. Let M = (Q,Σ,δ,q~0~,F) be a finite automaton and let w = w~1~w~2~··· w~n~ be a string where each w~i~ is a member of the alphabet Σ. **[Then M accepts w if a sequence]** of states r~0~,r~1~,\...,r~n~ in Q exists with three conditions: 1\. r~0~ = q~0~, 2\. δ(r~i~,w~i~+1) = r~i~+1, for i = 0,\...,n−1, and 3\. r~n~ ∈F. Condition 1 says that the machine starts in the start state. Condition 2 says that the machine goes from state to state according to the transition function. Condition 3 says that the machine accepts its input if it ends up in an accept state. **[We say that M recognizes language A if A = {w\|M accepts w}.]** **3.2 Designing Finite Automata** For example, suppose that the alp**[habet is {0,1} and that the language consists of all strings with an odd number of 1s.]** You want to construct a finite automaton E1 to recognize this language. Pretending to be the automaton, you start getting an input string of 0s and 1s symbol by symbol. Do you need to remember the entire string seen so far in order to determine whether the number of 1s is odd? Of course not. **[Simply remember whether the number of 1s seen so far is even or odd and keep track of this information as you read new symbols]**. If you read a 1, flip the answer; but if you read a 0, leave the answer as is. But how does this help you design the FSM E1? Once you have determined the necessary information to remember about the string as it is being read, you represent this information as a finite list of possibilities. In this instance, the possibilities would be **1.** even so far, and **2.** odd so far. Then you assign a state to each of the possibilities. These are the states of E1, as shown here. **Next, you assign the transitions by seeing how to go from one possibility to** **another upon reading a symbol**. So, if state qeven represents the even possibility and state qodd represents the odd possibility, you would set the transitions to flip state on a 1 and stay put on a 0, as shown here **Next, you set the start state to be the state corresponding to the possibility associated with having seen 0 symbols so** far (the empty string \"). In this case, the start state corresponds to state q~even~ because 0 is an even number. Last, set the accept states to be those corresponding to possibilities where you want to accept the input string. Set q~odd~ to be an accept state because you want to accept when you have seen an odd number of 1s. These additions are shown in the following figure. **EXAMPLE 1.21** This example shows how to design a finite automaton E2 to recognize the regular language of all strings that contain the string 001 as a substring. For example, 0010, 1001, 001, and 11111110011111 are all in the language, but 11 and 0000 are not. **[How would you recognize this language if you were pretending to be E2]**? As symbols come in, you would initially skip over all 1s. If you come to a 0, then you note that you may have just seen the first of the three symbols in the pattern 001 you are seeking. If at this point you see a 1, there were too few 0s, so you go back to skipping over 1s. But if you see a 0 at that point, you should remember that you have just seen two symbols of the pattern. [Now you simply need to continue scanning until you see a 1. If you find it, remember that you succeeded in finding the pattern and continue reading the input string until you get to the end]. So, there are four possibilities: You **1.** haven't just seen any symbols of the pattern, **2.** have just seen a 0, **3.** have just seen 00, or **4.** have seen the entire pattern 001. **Assign the states q, q0, q00, and q001 to these possibilities**. You can assign the transitions by observing that from q reading a 1 you stay in q, but reading a 0 you move to q0. In q0 reading a 1 you return to q, but reading a 0 you move to q00. In q00 reading a 1 you move to q001, but reading 0 leaves you in q00. Finally, in q001 reading a 0 or a 1 leaf you in q001. The start state is q, and the only accept state is q001, as shown in Figure 1.22. **3.3 Regular Operations** We define three operations on languages, called the ***regular operations***, and use them to study properties of the regular languages. You are already familiar with the union operation. It simply takes all the strings in both A and B and lumps them together into one language. The concatenation operation attaches a string from A in front of a string from B in all possible ways to get the strings in the new language. The star operation is a bit different from the other two because it applies to a single language rather than to two different languages. That is, the star operation is a ***unary operation*** instead of a ***binary operation***. It works by attaching any number of strings in A together to get a string in the new language. The empty string \" is always a member of A\*, no matter what A is. EXAMPLE **1.24** Let the alphabet ∑ be the standard 26 letters {a, b,... , z}. If A = {good, bad} and B = {boy, girl}, then A U B = {good, bad, boy, girl}, A ∩ B = {goodboy, goodgirl, badboy, badgirl}, and A\* = {\", good, bad, goodgood, goodbad, badgood, badbad, goodgoodgood, goodgoodbad, goodbadgood, goodbadbad,... }.

Use Quizgecko on...
Browser
Browser