final fa part1

Download Final fa part1

If you can't read please download the document

Upload: megha-khanna

Post on 16-Apr-2017

473 views

Category:

Technology


0 download

TRANSCRIPT

Finite Automata

What are machines?Automation of various steps.

What are constituents of a machine?Each step takes an input and produces an output.

Machine can be defined asSet of states which take input in specified format and produce desired output.

Finite Automata

Finite Automata (FA) is a language recognizing machine.

Accepts all words of the language for which it is built.

Rejects all other words.

Finite Automata

Five tuple machine defined as M = (Q, , , Q0, F)Q: Set of states such as Q0, Q1, Q2, Q3..... Qn.

: Alphabet of the language for which the machine is built such as {a, b} or {0, 1}.

: Transition function or Next Move function. It maps Q X -> Q . (Qi, a) = Qj where 'Qi' -> current state

'a' -> current input symbol

'Qj' -> next state

Q0 -> start state.

F -> collection of final states.

Finite Automata

Example of a Switch to switch on a fan.Q = {OFF, ON}

= {push}

has two rules (OFF, push) = ON.

(ON, push) = OFF.

Q0 = {OFF}

F = {ON}

Finite Automata

FA is a collection of 3 things:A finite set of states, one of them is the start state and some (maybe) none as the final states.

An alphabet , which consists of all possible input letters.

A finite set of transition rules which direct from each state and for each particular input letter which state to go next.

Finite Automata

ab

- xyz

yxz

+ zzz

Transition Graph

Transition Table

We discuss an example here. Following are two representations of an FA:

Transition Table

Transition Graph

Finite Automata

Depiction of initial and final states for an FA can be defined in several ways:Use a '-' symbol for initial state and a '+' symbol for final state.

Use a '->' symbol for initial state and double encircle the final state.

Write 'start' for the initial state and 'final' for the final state.

Finite Automata

FA has3 states labelled x, y and z

= {a,b}

State x is designated as the start state.

State z is designated as the final state.

Finite Automata

ab

- xyz

yxz

+ zzz

Transition Graph

Transition Table

The transition table as well as the transition diagrams clearly define the function. It is a depiction of the following rules:

Rule 1: If we are in state x and we encounter an input 'a' then we go to state y.Rule 2: If we are in state x and we encounter an input 'b' then we go to state z.Rule 3: If we are in state y and we encounter an input 'a' then we go to state x.Rule 4: If we are in state y and we encounter an input 'b' then we go to state z.Rule 5: If we are in state z and we encounter an input 'a' then we remain in state z.Rule 6: If we are in state z and we encounter an input 'b' then we remain in state z.

Finite Automata

To understand the language dry run the input aaa

abba

Finite Automata

If after complete string traversal, we do not reach the final state, the string is then REJECTED by the FA.

If after complete string traversal, we reach the final state, the string is then ACCEPTED by the FA.

Thus, FA is a language recognizer, which accepts all the words in the language for which it is defined and rejects all the other strings.

Finite Automata

What language does this FA represents?

Regular Expression for the language of the FA: (a + b)* b (a + b)*

Finite Automata

A finite automata isDeterministic in nature.

Finite

Note: By convention we say that the null word () starts as well as ends in the initial state.

Finite Automata

Analyse the FA given below

Regular Expression for the language of the FA: (a + b) (a + b)*

Finite Automata

What is the language of the FA given below?

Regular Expression for the language of the FA: (a + b)*

Finite Automata

What is the language accepted by the FA which has no final state?

Such FA's accept no language.

Finite Automata

An interesting example. Identify the language.

This FA also accepts no language.

Finite Automata

What is the language of the FA given below?

This FA accepts all words of even length over the alphabet = {a,b}.

Finite Automata

Draw an FA which accepts all the words in the language a (a + b)* where = {a,b}.

First draw a diagram which accepts the minimum length word which is 'a'.

Finite Automata

Now complete all the other transitions.

For words starting from 'b', we introduce a new state y, which is a trap state .

Trap StateOn reaching trap state, we can never go back to the other states of the FA and accept the word.

Reaching a trap state means we reject the word.

We have only one trap state for the whole FA.

We need to complete the transitions of the trap state too.

Finite Automata

Draw an FA which accepts all the words that have a double 'a' or a double 'b' in them where = {a,b}.

Two minimum length words 'aa' and 'bb'.

First draw an FA which accepts these two words.

All the states signify something:State 1: Neither an 'a' nor a 'b' has occurred.

State 2: One 'a' has occurred.

State 3: One 'b' has occurred.

State 4: Either two a's or two b's have occurred in continuation.

Finite Automata

Now complete the remaining transitions.

Finite Automata

Examine the following FA and find out the language represented by it.

FA accepts all the words which have their third letter as 'b'. The regular expression is (a+b) (a+b) (b) (a+b)*.

Finite Automata

Construct an FA that accepts only the word 'baa' where = {a,b}.

First draw the word 'baa'. Now complete the FA.

Finite Automata

Note that there is only one trap state for the whole FA.

Finite Automata

Draw an FA which accepts only the word where = {a,b}.

Now complete the transitions.

Finite Automata

FA which accepts only the word where = {a,b}.

Finite Automata

Draw an FA for all the words which end in 'a' where = {a,b}.

Draw the minimum word i.e. 'a'.

Finite Automata

Complete the transitions.

Finite Automata

Draw an FA for all the words which have a double 'a' in them where = {a,b}.

Significance of each state:State 1: Zero a's are encountered consecutively.

State 2: One 'a' is encountered consecutively.

State 3: Double 'a' has been encountered.

Finite Automata

Now complete all the transitions.

Finite Automata

Draw an FA for all the words with different first and last letters where = {a,b}.

Finite Automata

Now complete all the transitions.