×

Close

- Other
**29 Views**- Uploaded 1 year ago

1 UNIT – 1 UNIT-01/Lecture-01 Basic machine, FSM , Transition graph, Transition matrix Introduction - Theory of computation is a course of abstractions about what we can compute. It is the purest of all computer science topics attempting to strip away any details about the real computer and replacing in it with abstractions that give a hierarchy of capabilities culminating in a Turing Machine, the abstract model of our modern computer, invented by Alan Turing. Abstractions give us a way of saying something about what we are doing in a rigorous formal way, rather than flailing randomly through a haze of informality. There is great value in abstraction. Applications Finite state machines are used in string searching algorithms, compiler design, control unit design in computer architecture, and many other modeling applications. Context free grammars and their restricted forms are the basis of compilers and parsing. NP-Complete theory helps us distinguish the tractable from the intractable. We do not focus on these applications. They are deep enough to require a separate course, and hopefully you have already seen some of them. There is plenty of basic theory to learn, and we will concentrate on providing a thorough understanding of all the abstract ideas with a constructive focus. That is, when we prove things it will be through examples. When we define things, we will motivate their definitions through examples. Finite automata are a useful model for many important kinds of hardware and software:1. Software for designing and checking the behavior of digital circuits. 2. The “lexical analyzer” of a typical compiler, that is, the component that breaks the input text into logical units such as identifiers, keywords and punctuation. 3. Software for scanning large bodies of text, such as collections of web pages to find occurrences of words, phrases or other patterns. 4. Software for verifying systems of types that have a finite number of distinct states such as communications protocols for secure exchange of information. Finite-state machine (FSM) A finite-state machine (FSM) or finite-state automaton (plural: automata), or simply a state machine, is a mathematical model of computation used to design both computer programs and sequential logic circuits. It is conceived as an abstract machine that can be in one of a finite number of states. The machine is in only one state at a time; the state it is in at any given time is called the current state. It can change from one state to another when initiated by a triggering event or condition; this is called a transition. A particular FSM is defined by a list of its states, and the triggering condition for each transition. The behavior of state machines can be observed in many devices in modern society which perform a predetermined sequence of actions depending on a sequence of events with which they are presented. Simple examples are vending machines which dispense products when the proper combination of coins is deposited, elevators which drop riders off at upper floors before going down, traffic lights which change sequence when cars are waiting, and combination locks which require the input of combination numbers in the proper order. Deterministic Finite AutomataA deterministic ﬁnite automaton (DFA) consists of 5-tuples M=(Q, Σ , δ, q0, F) 1. Q is a ﬁnite set of states 2. Σ is a ﬁnite set of input symbols (alphabet) 3. δ is a transition function that takes as argument a state and a symbol and returns a state 4. q0 a start state 5. F is a set of ﬁnal or accepting states

2 We have q0 ∈ Q and F ∈ Q The transition function δ is a function in Q × Σ → Q Q × Σ is the set of 2-tuples ( q, a) with q ∈ Q and a ∈ Σ Transition GraphsTransition graph can be interpreted as a flowchart for an algorithm recognizing a language. A transition graph consists of three things: 1. A finite set of states, at least one of which is designated the start state and some of which are designated as final states. 2. An alphabet Σ of possible input symbols from which the input strings are formed. 3. A finite set of transitions that show the change of state from the given state on a given input. A successful path through the transition graph is a series of edges forming a path beginning at the start state and ending at one of the final states. Some of the transition graphs are given below- The transition graph in the above figure represents a DFA with at least one a and at least one b. A transition diagram for DFA, M = ( Q, Σ, δ, F, q0) is a graph defined as follows: (a) For each state in Q there is a node represented by the circle. (b) For each state q in Q each input symbol a in Σ, let δ(q, a) = q’. Then transition diagram has an arc from q to q’, labelled a. (c) There is always an arrow into the start state that is not from any other state. (d) Nodes corresponding to accepting states are denoted by a double circle. Rest of the states are depicted by a single circle. Transition Matrix/tableA transition table is a tabular representation of the transition function that takes two argumentsand returns a state. The column contains the state in which the automaton will be on the input represented by that column. The row corresponds to the state the finite control unit can be in. The entry for one row corresponding to state q and the column corresponds to input a is the state δ(q, a). For the transition graph in the above figure the transition table would be as follows:

3 States q0 q1 q2 *q3 a q1 q1 q2 q3 b q2 q3 q3 q3 In the above table we observe that on giving a as input to DFA in state q0 the DFA changes state to q1 and on input b the state changes to q2. Similarly by writing this information for other states we generate the transition graph.

4 UNIT-01/Lecture-02 Deterministic and nondeterministic FSM’s[RGPV/June-2014(7)] Non-deterministic Finite State Machines IntroductionA class of machines which are a generalization of deterministic Finite State Machines. We will mostly be concerned with Finite State Machines which are acceptors (have no output alphabet). Therefore we will also be concerned with the type of languages that can be accepted by some Finite State Machine. It can be shown that when we consider acceptors, the class of non-deterministic FSMs is the same as the class of deterministic FSMs. The result means that when we are considering acceptors, we can always use non-deterministic FSMs rather than deterministic FSMs if we want to (because there is always some deterministic FSM which will accept the same language as our non-deterministic machine). Formal DefinitionThe main difference between non-deterministic Finite State Machines and the machines we have input strings which have may be more than one trace. The concept of non-determinism gives us more flexibility when we are modeling reactive systems. Dentition: A deterministic ﬁnite automaton (DFA) consists of 1. a ﬁnite set of states (often denoted Q) 2. a ﬁnite set Σ of symbols (alphabet) 3. a transition function that takes as argument a state and a symbol and returns a state (often denoted δ) 4. a start state often denoted q0 5. a set of ﬁnal or accepting states (often denoted F) We have q0 ∈ Q and F ⊆ Q So a DFA is mathematically represented as a 5-uple (Q, Σ , δ, q0, F) The transition function δ is a function in Q × Σ → 2Q Equivalence of Deterministic and Nondeterministic Finite AutomataThere are many languages for which an NFA is easier to construct than a DFA, such as the language of strings that ends in 01, it is surprising fact that every language that can be described by some NFA can also be described by some DFA. DFA has many states as the NFA, although it often has more transitions. In the worst case, however, the smallest DFA can have 2n states while the smallest NFA for the same language has only n states. The proof that DFA’s can do whatever NFA’s can do involves an important “construction” called the subset construction because it involves constructing all subsets of the set of states of the NFA. In general many proofs about automata involves constructing one automata from another. There are three main cases of non- determinism in NFAs: 1. Transition to a state without consuming any input. 2. Multiple transitions on the same input symbol. 3. No transition on an input symbol. To convert NFAs to DFAs we need to get rid of non-determinism from NFAs. Subset Construction MethodUsing Subset construction method to convert NFA to DFA involves the following steps: 1. For every state in the NFA, determine all reachable states for every input symbol. 2. The set of reachable states constitute a single state in the converted DFA (Each state in the DFA corresponds to a subset of states in the NFA). 3. Find reachable states for each new DFA state, until no more new states can be found.

## Leave your Comments