Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 23

1

Chapter 1
INTRODUCTION
Automata & complexity 2

 The word automaton itself, closely related to the word "automation", denotes
automatic processes carrying out the production of specific processes.
 Automata theory deals theory of abstract computing devices with the logic of
computation, referred to as automata.
 Through automata, computer scientists are able to understand
 how machines compute functions and solve problems
 and more importantly, computability or decidability of problems.
… 3

 Complexity theory is the study of what's hard or easy to solve with a


computer.
 In it, the key thing is how the number of steps it takes to solve a problem
grows with the size of the input.
 Suppose, for example, that you want to determine whether a given number, 983
or 105227, is prime or not?
 The number of computational steps in that calculation grows relatively slowly
with the number of digits in the number. Such problem is said to be solvable in
"polynomial time" and is in the complexity class "P."
Concepts of automata theory 4

 Alphabets
• An alphabet is a finite, non-empty set of symbols. Conventionally, we use the
symbol  for alphabet.
•  ={0,1} , the binary alphabet
•  ={a, b, c,…, z} , the lower-case letters
•  ={0, 1, 2,…, 9}, the Arabic numerals
 Strings
• A string (sometimes called word) is a finite sequence of symbols chooses from
some alphabets.
• 11010 is a string from the binary alphabet  ={0,1}
… 5

 The empty string  or 


• The empty string is a string with zero occurrence of symbols and can be chosen
from any alphabet whatsoever.
 Length of a string
• Length of a string is the number of positions for symbols in the string.
• 1001001 is a string of length=7.
• Note: length of a string is not the number of symbols in the string.
 Powers of an alphabet
• If  is an alphabet, we can express the set of all strings of a certain length from
that alphabet by using an exponential notation.
… 6

 k is a set of string of length k, each of whose symbol is in .


 Suppose  = {0, 1}
• 0 ={} which is the only string of length 0.
• 1 =  ={0,1}, which are string of length 1.
• 2 ={00, 01, 10, 11}
• and etc.
 The set of all string over an alphabet  denoted *
• * includes empty string {} also.
• * = 0 U 1 U 2 U…
 The set of all non-empty string over an alphabet  denoted +
 + = 1 U 2 U 3 U…
… 7

 Concatenation of strings
• Let x and y be strings.
• Then xy denotes the concatenation of x and y, that is the string formed by making a copy
of x followed by a copy of y.
• Let x= { a, b, c, … z} and y= { 1, 2, …9}, then xy= {a1, a2, …, b1, b2, … }
 Languages
 A language is a set of strings all of which are chosen from some *, where  is a
particular set of alphabet.
 If  is an alphabet, and L  * then L is a language over .
 አማርኛ is a language consisted all legal አማርኛ words, which are set of strings over
አማርኛ ሆሄያት (alphabets).
… 8

 C++, Java or any other programming languages are languages which consists set of legal
strings over ASCII characters.
 In the study of automata we may create other languages too, like
 Set of strings over alphabet = {0, 1}, that ends with 1. L= {1, 01, 001, 101 …}
 Set of strings over alphabet = {0, 1}, which consists even number of 0’s. L= {0011, 1010 …}
 And others of such a type.
Finite state automata 9

 Finite state automata shortly finite automata is a mathematical or abstract model of


computation.
 Finite automata at its core is used to describe regular languages, a type of language we are going
to learn about in chapter-2.
 Finite automata has a set of states, and it control moves from state to state in response to external
input.
 Finite automata can be deterministic or non-deterministic.
 Deterministic FSA: cannot be in more than one state at any one time (or one input).
 Languages can be executed
 Non-deterministic FSA: can be in more than one state at a time (or for a single input).
 Help us to program solutions to a problem in high-level PL.
DFA 10

 Deterministic Finite Automata (DFA)


 The term “deterministic” refers to the fact that on each input the automata transits to one and only
one state from its current state.
  transition is not allowed in DFA.
 DFA consists of five-tuples A=(Q, , , qi, qf)
 A is the DFA.
 Q denotes a finite number of states.
  denotes a finite number of inputs.
  denotes a set of transition functions.
  accepts a state and an input symbol as arguments and return a state.
 qi is a starting state, which is one of the states in Q.
 qf is a set of final states, which are  Q.
… 11

 How DFA processes a string?


 DFA represents a language, which is the set of strings accepted by the DFA.
 To check whether a certain string accepted by the DFA or not:
1. Suppose a1, a2, a3 … an are sequence of input symbol.
2. We start out the DFA in its start state q i
3. We consult the transition function , say (qi, a1)=q1 to find the state the DFA enters on getting input
symbols a1.
4. We process from the current state q1 for the next symbol a2 by consulting , say (q1, a2)=q2 and repeat
the step until we reach at the last input symbol a n.
5. The string is legal for (or accepted by) the DFA, if for the last input it reached at one of the final state.
Exercise 12

1. Check if the string 011010 and 111110 are legal for the DFA given below.

2. Draw a DFA that accept the following languages over alphabet  ={0, 1}
a. Set of all strings ends with 00.
b. Set of all strings with three consecutive 000’s (not necessarily at the end)
Notation 13

 DFA can be represented using


1. Transition diagram: which is a graphical representation of a language as we have seen earlier.
2. Transition table: which is a tabular listing of  functions, that tells us the set of states and the
input alphabet.

0 1
qi q1 qi
q1 qf qi
qf qf qi

Transition table for DFA

 Exercise: draw DFA that can accept even number of 0’s and 1’s.
Language of DFA 14

 The language of DFA A=(Q, , , qi, qf) denoted by L(A) can be defined as:
 L(A)= {w| (qi, w) is in qf}
 If L is L(A) for some DFA A then we can say L is a regular language.
 Which means, the language of A is the set of strings w that takes the start state qi to one of
the accepting states qf.
 Generally, language of DFA is a regular language.
NFA 15

 Non-deterministic finite automata (NFA)


 Has the power to be in several states at once.
 This ability of NFA often expressed as the ability to “guess” about its input.
 NFA can accept the language of DFA.
 All NFA’s can be converted into an equivalent DFA.
 So, why NFA?
 Because NFA’s are more succinct and easier to design than DFA.
 Rarely, DFA will have more states than NFA.
… 16

 Like DFA, NFA has


 A finite set of states, a finite set of inputs, one start state, a finite set of accepting (or final) states
and set of transition functions .
 The difference is only on the type of the transition function .
  in the case of DFA:
 accepts a state and input and returns exactly one state.
  in the case of NFA:
 accepts a state and input and returns zero, one, or more states.

 Example: design an NFA that accepts strings ends with 01 over ={0,1}
Language of NFA 17

 NFA consists of five-tuples A=(Q, , , qi, qf)


 A is the NFA.
 Q denotes a finite number of states.
  denotes a finite number of inputs.
  denotes a set of transition functions.
  accepts a state and an input symbol as arguments and return a subset of Q.
 qi is a starting state, which is one of the states in Q.
 qf is a set of final states, which are  Q.
 Like DFA, NFA can also be represented using transition diagram and transition table.
Conversion of NFA to DFA 18

 Suppose there is an NFA N =( Q, ∑, q0, δ, F) which recognizes a language L.


 Then the DFA D =( Q’, ∑, q0, δ’, F’) can be constructed for language L as:
1. Initially set Q’ = ɸ.
2. Add q0 to Q’.
3. For each state in Q’, find the possible set of states for each input symbol using transition function
of NFA. If this set of states is not in Q’, add it to Q’.
4. Final state of DFA will be all states with contain F (final states of NFA)
 Example: convert the following NFA to their equivalence DFA.
-NFA 19

 -NFA is a finite automata with -transitions.


 -NFA is allowed to make a transition spontaneously, without receiving an input symbol.
 This new feature doesn’t expand the class of languages that can be accepted by finite automata.
 Instead, it does give some added “programming convenience”.
 Uses of -transitions
 In a transition, if we found  along a path it contributes nothing to the string along the path.
 Example: design a FSM that accepts +ve or –ve integers.
… 20

 Formally -NFA can be defined as A=(Q, , , qi, qf) where all components have the same
interpretation as NFA except a transition function .
  now is a function that takes arguments
 A state in Q, and
 A member of  U {} that is ether input symbol or .
 Note  can not be a member of any alphabet, it’s a string of length zero.
 -closures
 State q is ECLOSE (q)
 If state p is ECLOSE(q), and there is a transition from state p to state r labeled , then r is
ECLOSE(q).
 if  is a transition function of -NFA involved, p is ECLOSE(q) then ECLOSE(q) also contains all
states in (p, ).
… 21

 What are ECLOSE(q0), ECLOSE(q1) and ECLOSE(q)?

 What are ECLOSE(1), ECLOSE(4) and ECLOSE(2)?


Conversion of -NFA to DFA 22

1. take the ε-closure for the starting state of -NFA as a starting state of DFA.
2. Find the states for each input symbol that can be traversed from the present.
 That means the union of transition value and their closures for each state of NFA present in the
current state of DFA.
3. If we found a new state, take it as current state and repeat step 2.
4. Repeat Step 2 and Step 3 until there is no new state present in the transition table of DFA.
5. Mark the states of DFA as a final state which contains the final state of NFA.
Examples 23

 Convert the following -NFA to equivalent DFA

You might also like