Sie sind auf Seite 1von 45

Introduction

Mechanical model for computation

E.g : Washing machine, Lift

Main focusState
What is a state? Current State decides what a system does next To and Extend every machine made by human is finite

But when the no of states exceeds a limit we call it infinite


E.g. 32 MB computer 1081000000 states

So FSA is characterized by
Finite set of states Transition Function

Statesdiscs Transitionarcs Start statedisc with a tailless arc pointing to it

Input to the automaton String Outputnothing //for the time being


Automaton process a string from right to left

Each transition is labelled by symbols What is an alphabet? What is a string?

Figure above shows an automaton with input alphabet {0,1} Automaton stops when input string is completely processed

Transition can by shown by a table

Note: is not defined for every possible pair If machine is in q2 state and input symbol is 1 automata stops in error

We give an input string and get another string as output transducer

FSA is used to recognize languages


Helps to decide whether a string is part of a language or not

Output either a 0(reject) or 1(accept)

Here FSA takes two states of output


Accepting state double circle Rejecting Stateothers

Accept states with even no of ones Since initial state itself is accepting accepts empty strings

Accepts only empty string

Trap: Accepting state

Accepts {0,1}+ but not empty string E.g in Linguistics gerund form

Trap: rejecting state

Accepts strings with equal number of 0s and 1s Trapforms the rejecting state

Definition: A deterministic finite automaton is a fivetuple, (, Q, q0, F, ), where


is the input alphabet, Q the set of states, q0 Q the start state, F C Q the final states, and : Q x E Q the transition function

Devise an automata that accepts strings ending in zero

Devise an automata that accepts multiples of 5

In FSA we have seen till now


For one state+input symbol combination there is only one transition
Transition function is well defined When automata reaches a state where there is no transition, it aborts the operation and rejects the string

We call this type of automata as Deterministic

But when an FSA has


For one state+input symbol combination more than one transition Transition function is not well defined (uncertanity is involved)

We call this type of automata as Non-Deterministic

Nondeterminism induces a tree computations for each input string

of

possible

Branches possible transitions available to the machine at that stage of computation. Computations eventually terminates (after exactly n transitions, if there are n input symbols) at a leaf of the computation tree.

The machine may accept reject the same input in different cases
If all leaves correspond to accepting statesthe input can be defined as accepted If all leaves correspond to rejecting statesthe input can be defined as rejected.

When some computation paths lead to acceptance and others to rejection Accept input

Definition: A nondeterministic finite automaton is a five-tuple, (, Q, q0, F, ), where


is the input alphabet, Q the set of states, q0 Q the start state, F C Q the final states, and : Q x 2 Q the transition function

Here Q x 2Q is the set of all subsets of Q

This change allows transition functions that map state/character pairs to zero, one, or more next states. So a finite automaton is deterministic whenever we have I (q, a) l less than or equal to 1 for all q Q and a E.

Consider the nondeterministic finite automaton of Figure Non determinism

Non determinism

Consider the computation of the string 01011000

The strength of a nondeterministic finite automaton resides in its ability to choose the right path with perfect accuracy under the rules of nondeterminism.

Draw an FSA to represent strings that end in either 100 or 001

The nondeterministic automaton just "gobbles up" symbols until it guesses that there are only three symbols left, at which point it also guesses which ending the string will have and proceeds to verify that guess
Some guesses may be wrong But the input string is accepted if there is atleast one accept state

NDFSA Checking
DFSA Computing
Nondeterministic automaton only verify a simple guess to establish that the string is in the language Whereas the deterministic automaton must painstakingly process the string

Nondeterminism allows a machine to make efficient decisions whenever a series of guesses leads rapidly to a conclusion.

Depending on the context verifying can some times be simple or sometimes as hard as actual solving the answer

So the question whether NDFSA is more powerful that FSAthe answer is NO..
Whatever a nondeterministic automaton can do can also be done by a (generally much larger) deterministic finite automaton;

Thus the attraction of nondeterministic finite automata resides in their relative simplicity.

Nondeterministic finite automata are no more powerful than deterministic ones.

Our proof is a simulation:


given an arbitrary nondeterministic finite automaton, we construct a deterministic one that mimics the behavior of the nondeterministic machine.

Theorem 3.1 : For every nondeterministic finite automaton, there exists an equivalent deterministic finite automaton (one that accepts same language). Proof : For the nondeterministic finite automata (, Q, F, q0, ) ,We construct an equivalent deterministic automaton, (, Q, F, q0, ) as follows: = Q=2 Q F={ s Q | s F !=} q0= {q0}

The key idea is to define one state of the deterministic machine for each possible combination of states of the nondeterministic one-hence the 2IQI possible states of the equivalent deterministic machine.

Let at some stage in computation ,the next input symbolto the machine is a. If the nondeterministic machine can be in any of states qi1, qi2, . ., qjk, at that step so that the corresponding deterministic machine is then in state {qi1, qi2 , . ., qjk, }, then it can move to any of the states contained in the sets (qi1, a), (qi2, a)... I(qik,,a)

So that the corresponding deterministic machine


moves to state

Let at some stage in computation ,the next input symbolto the machine is a. If the nondeterministic machine can be in any of states qi, qi2, . ., qjk, at that step so that the corresponding deterministic machine is then in state {qi,, qi2 , . ., qjk, }, then it can move to any of the states contained in the sets (qi1, a), (qi2, a)... I(qik,,a)

So that the corresponding deterministic machine


moves to state

An NFA given by

The conversion takes a NFA with n states and creates a DFA with 2' states, an exponential increase. Many of these states may be useless, because they are unreachable from the start state

Convert the NFA to DFA

An transition is a transition that does not use any input The automaton simply "decides" to change states without reading any symbol Used only in NFA

Assume that we are given a finite automaton with transitions; let its transition function be . can be reached by
1. zero or more transitions; followed by 2. one transition on a; followed by 3. zero or more transitions.

Let us define (q, a) to be the set of all states that

This is the set of all states reachable from state q in our machine while reading the single input symbol a; we call ' the -closure

of .

In the figure. 1. {q, 1, 2, 3) 2. {4, 6, 8} 3. {4, 5, 6, 7, 8, 9, 10

so that we get '(q, a)


{4,

5, 6, 7, 8, 9, 10}

Theorem : For every finite automaton with transitions, there exists an equivalent finite automaton without transitions. Proof: We are given a NFA with transitions and with transition function We construct ' as defined earlier.
Our new automaton has the same set of states, the same alphabet, the same starting state, and (with one possible exception) the same set of accepting states, but its transition function is now ' rather than and so does not include any moves.

Finally, if the original automaton had any (chain of) a transitions from its start state to an accepting state, we make that start state in our new automaton an accepting state.

Design finite automata for the following languages over {O, 1}: 1. The set of all strings where no pair of adjacent Os appears in the last four characters. 2. The set of all strings where pairs of adjacent Os must be separated by at least one 1, except in the last four characters.

Das könnte Ihnen auch gefallen