0% found this document useful (0 votes)
23 views13 pages

Atomat 1

This chapter introduces the theory of computation and its three main branches: automata theory, complexity theory, and computability theory. Automata theory deals with the definition and properties of mathematical models of computation. An automaton is a machine that operates on input according to a defined pattern to produce output. Finite automata (FA) are automata with a finite number of states. There are two types of FA: deterministic FA (DFA) and nondeterministic FA (NDFA). A DFA has a defined transition function that determines the next state for each input symbol, while an NDFA can transition to multiple states for a single input.

Uploaded by

peaceforall5682
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views13 pages

Atomat 1

This chapter introduces the theory of computation and its three main branches: automata theory, complexity theory, and computability theory. Automata theory deals with the definition and properties of mathematical models of computation. An automaton is a machine that operates on input according to a defined pattern to produce output. Finite automata (FA) are automata with a finite number of states. There are two types of FA: deterministic FA (DFA) and nondeterministic FA (NDFA). A DFA has a defined transition function that determines the next state for each input symbol, while an NDFA can transition to multiple states for a single input.

Uploaded by

peaceforall5682
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Automata and Complexity theory- 3rd year chapter-1

Chapter One
Introduction
Theory of computation: is the branch of computer science how effectively deal with the
problem using algorithm.
Writing affective algorithm that run on computing machine Computational problem considers
 What can/can’t computed
 Speed of computation
 Amount of memory used for computation
Three ranch of theory of computation
 Automata theory
 Complexity theory
 Computability theory
Automata theory: deals with definition and properties of mathematical model of computation
Automaton is a machine that operates singularly on input and follows a defined pattern or
configuration to produce the desired output.
Mathematical preliminaries and notations
• Set: is a collection of elements, without any structure other than membership. If m is an element
of the set S, we write m ε S. A set is specified by enclosing some description of its elements in
curly braces. E.g. S={a,b,c}
Universal set U of all possible elements is, if U is specified, then S={ x: x ε U, x ɆS} The set with
no element is called the empty set or null set. It is denoted by Ø.

Operation on sets
 Let A and B be two sets and
 A c B iff, for all x ε A, x ε B
 A=B iff, Ac B and B c A
 A c B iff, Ac B but A ≠B
 A u B={x: x ε A or x ε B}
 A ∩ B={x: x ε A and x ɆB}
 A X B={ (x, y), x ε A and y ε B}

Prepared by: Getahun T.


Automata and Complexity theory- 3rd year chapter-1

Formal Language
• A formal language is an abstraction of the general characteristics of programming languages.
• A formal language consists of a set of symbols and some rules of formation by which these
symbols can be combined into entities called sentences.
Formal Language Natural language
• Developed with strict rules. • Rules come after the language
• Predefined syntax and semantics. • Evolve and develop
• Precise • Highly flexible
•Unambiguous • Quite powerful
Disadvantage: • No special learning effort needed
•Unfamiliar notation Disadvantage:
•Initial learning effort • Vague
E.g. C++, Pascal… • Imprecise and ambiguous
• User and context dependent
E.g. Amharic, English…

Alphabet and Strings


An alphabet is a finite set of symbols which are used to form words in a language. An example of
an alphabet might be a set like {a, b}.
• Example: Σ = {a, b, c, d} is an alphabet set
Where ‘a’, ‘b’, ‘c’, and ‘d’ are alphabets.
• String:
– String over Σ is some number of elements of Σ (possibly none) placed in order. So if Σ ={ a ,b}
then strings over Σ can be a, ab, bbaa, abab and so on.
– Length of a String It is the number of symbols present in a string. (Denoted by |S|).
E.g.
• If S=‘cabcad’, |S|= 6
• If |S|= 0, it is called an empty string (Denoted by λ or ε)

Prepared by: Getahun T.


Automata and Complexity theory- 3rd year chapter-1

Kleene Star
 Definition: The set Σ* is the infinite set of all possible strings of all possible lengths over Σ
including λ.
 Representation: Σ* = Σ0 U Σ1 U Σ2U…….
 Example: If Σ = {a, b}, Σ*= {λ, a, b, aa, ab, ba, bb,………..}
Kleene Closure / Plus
 Definition: The set Σ+ is the infinite set of all possible strings of all possible lengths over
Σ excluding λ.
 Representation: Σ+ = Σ0 U Σ1 U Σ2 U……. Σ+ = Σ* - { λ }
 Example: If Σ = { a, b } , Σ+ ={ a, b, aa, ab, ba, bb,………..}
Transpose Operation
• For any string x ε Σ* and a ε Σ, (xa)T = a(x)T.
• A palindrome of even length can be obtained by the concatenation of a string and its transpose.
E.g. Let Σ={0,1}
Y= (01001)T
(xa)T=(0100 1)T
=1(0100)T
=10(010)T
=100(01)T
=10010

Language
• Definition : A language is a subset of Σ*for some alphabet Σ. It can be finite or infinite.
• Language is a set of string generated by a grammar
• Example: If the language takes all possible strings of length 2 over Σ = {a, b}, then L = {ab, bb,
ba, bb}

Grammars
• Grammars denote syntactical rules for conversation in natural languages. Linguistics have
attempted to define grammars since the inception of natural languages like English, Amharic.
• Strings may be derived from other strings using the productions in a grammar.
• Set of rule used to describe the string of a language

Prepared by: Getahun T.


Automata and Complexity theory- 3rd year chapter-1

• The set of all strings that can be derived from a grammar is said to be the language generated
from that grammar.
A grammar G is defined as a quadruple (represent in four tuples)
G = (V, T, S, P),
Where V is a finite set of objects called variables,
T is a finite set of objects called terminal symbols,
S ∈ V is a special symbol called the start variable,
P is a finite set of productions.
The production rules are the heart of a grammar; they specify how the grammar transforms one
string into another, and through this they define a language associated with the grammar.
Consider the grammar :-
Grammar G (({S, A}, {a, b}, S, {S → aAb, aA → aaAb, A → ε})
Here,
S and A are Non-terminal symbols.
a and b are Terminal symbols. ε is an empty string.
S is the Start symbol, S ∈ N
Production P : S → aAb, aA → aaAb, A → ε
Strings may be derived from other strings using the productions in a grammar.
Some of the strings that can be derived are –
S ⇒ aAb using production S → aAb
⇒ aaAbb using production aA → aAb
⇒ aaaAbbb using production aA → aaAb
⇒ aaabbb using production A → ε
aaabbb is the string that generated from the above grammar.
We can also drive another string
S ⇒ aAb using production S → aA
⇒ aaAbb using production aA → aaAb
⇒ aabb using production A → ε
The string “aabbb” generated from the grammar

Prepared by: Getahun T.


Automata and Complexity theory- 3rd year chapter-1

Normally, a given language has many grammars that generate it. Even though these grammars are
different, they are equivalent in some sense. We say that two grammars G1 and G2 are equivalent
if they generate the same language, that is, if L (G1) = L (G2)
E.g.
G1 (({S,}, {a, b}, S, S → aSb}) and
G2 (({S, A}, {a, b}, S, {S → aSb, s → ε, S → aAb, s → ε})
G1 and G2 are equivalent hence they can generate the same language

Exercise
Alphabet Σ = {a, b}: construct a grammar for a language
(a) All strings in the language L: {anbm |n>0, m ≥ 0}
(b) All strings in the language L: {anbm |m>0, n ≥ 0}
(c) All strings in the language Contains at least two a’s

Prepared by: Getahun T.


Automata and Complexity theory- 3rd year chapter-1

Finite Automata (FA)


 The term "Automata" is derived from the Greek word "αὐτόματα" which means "self- acting".
An automaton (Automata in plural) is an abstract self-propelled computing device which
follows a predetermined sequence of operations automatically.
 An automaton with a finite number of states is called a Finite Automaton (FA) or Finite State
Machine (FSM).
 Finite Automata (Finite state machine)
We denote a FA by the 5-tuple (Ǫ, E, q0, δ, A) where
 Q: Finite set of states.
 ∑: Set of input symbols.
 q0: Initial state.
 F: Set of final states.
 δ: Transition function
• Finite Automaton can be classified into two types:
 Deterministic Finite Automata (DFA)
 Non-deterministic Finite Automata (NDFA)

Deterministic Finite Automaton (DFA)


• In DFA, for each input symbol, one can determine the state to which the machine will move.
Hence, it is called Deterministic Automaton.
• As it has a finite number of states, the machine is called Deterministic Finite Machine or
Deterministic Finite Automaton.

Non-deterministic Finite Automaton (NDFA)


• In NDFA, for a particular input symbol, the machine can move to any combination of the states
in the machine. In other words, the exact state to which the machine moves cannot be determined.
• Hence, it is called Non-deterministic Automaton. As it has finite number of states, the machine
is called Non-deterministic Finite Machine or Non-deterministic Finite Automaton.

Deterministic Finite Automaton (DFA)


Formal Definition of a DFA
A DFA can be represented by a 5-tuple (Q, Σ, δ, q0, F) where:

Prepared by: Getahun T.


Automata and Complexity theory- 3rd year chapter-1

• Q is a finite set of states.


• Σ is a finite set of symbols called the input alphabet.
• δ is the transition function where δ: Q × Σ → Q
• q0 is the initial state from where any input is processed (q0 ∈ Q).
• F is a set of final state/states of Q (F ⊆ Q).
Graphical Representation of a DFA
A DFA is represented by digraphs called state diagram:
 The vertices represent the states.
 The arcs labeled with an input alphabet show the transitions.
 The initial state is denoted by an empty single incoming arc.
 The final state is indicated by double circles.
Example
Let a deterministic finite automaton be
• Q = {a, b, c},
• Σ = {0, 1},
• q0= {a},
• F={c}, and
• Transition function δ as shown by the following table:

Its graphical representation would be as follows:

Prepared by: Getahun T.


Automata and Complexity theory- 3rd year chapter-1

•Find the result of δ (a, 0101) c is Ꜫ final sate hence the string “0101”
Solution: accepted by DFA
δ ( a, 0101) Note
= δ (δ (a, 0), 101) The language accepted by a DFA M = (Q, Σ,
=δ (a, 101) δ, q0,F) is the set of all strings on Σ accepted
=δ (δ (a, 1), 01) by M. In M iff δ(q0,w) =qo for some state qo
=δ (b, 01) in F.
=δ (δ (b, 0), 1) Let M = (Q, Σ, δ, q0, F) be a DFA. Then the
=δ(c, 1) language accepted by M is the set: L (M) =
=c {w | w is in Σ* and δ (q0, w) is in F}

Non-deterministic Finite Automaton (NFA)


NFA means a choice of moves for an automaton. Rather than prescribing a unique move in each
situation, we allow a set of possible moves.
Formal Definition of an NDFA
An NDFA can be represented by a 5-tuple (Q, Σ, δ, q0, F) where:
 Q is a finite set of internal states.
 Σ is a finite set of symbols called the input alphabets.
 δ is the transition function where δ: Q × {Σ U ε} → 2Q (Here the power set of Q (2Q) has been
taken because in case of NDFA, from a state, transition can occur to any combination of Q
states)

Prepared by: Getahun T.


Automata and Complexity theory- 3rd year chapter-1

 q0 is the initial state from where any input is processed (q0∈ Q).
 F is a set of final state/states of Q (F ⊆ Q).
Graphical Representation of an NDFA: (same as DFA)
An NDFA is represented by digraphs called state diagram.
 The vertices represent the states.
 The arcs labeled with an input alphabet show the transitions.
 The initial state is denoted by an empty single incoming arc.
 The final state is indicated by double circles.
Example
• Let a non-deterministic finite automaton be
NFA M = (Q,Σ,δ, q0,F)
• Q = {a, b, c} Σ = {0, 1} q0 = {a} F={c}
A string is accepted by an NFA if there is some sequence of possible moves that will put the
machine in a final state at the end of the string. i.e. the language consists of all strings w for which
there is a walk labelled w from the initial vertex of the transition graph to some final vertex.
A string is rejected (that is, not accepted) only if there is no possible sequence of moves by which
a final state can be reached.
 The transition function δ as shown below:

 Its graphical representation would be as follows:

Converting an NDFA to an Equivalent DFA

Prepared by: Getahun T.


Automata and Complexity theory- 3rd year chapter-1

• Let X = (Qx, Σ, δx, q0, Fx) be an NDFA which accepts the language L(X). We have to design an
equivalent DFA Y = (Qy, Σ, δy, q0, Fy) such that L(Y) = L(X).
The following procedure converts the NDFA to its equivalent DFA:
Algorithm:
Input: An NDFA
Output: An equivalent DFA
• Step 1 Create state table from the given NDFA.
• Step 2 Create a blank state table under possible input alphabets for the equivalent DFA.
• Step 3 Mark the start state of the DFA by q0 (Same as the NDFA).
• Step 4 Find out the combination of States {Q0, Q1... Qn} for each possible input alphabet.
• Step 5 Each time we generate a new DFA state under the input alphabet columns, we have to
apply step 4 again, otherwise go to step 6.
• Step 6 The states which contain any of the final states of the NDFA are the final states of the
equivalent DFA.
Example 1
• Let us consider the NDFA shown in the figure below.

Prepared by: Getahun T.


Automata and Complexity theory- 3rd year chapter-1

Prepared by: Getahun T.


Automata and Complexity theory- 3rd year chapter-1

The difference between DFA & NFA


DFA NFA
 For each symbolic representation of the alphabet,  No need to specify how the NFA reacts according
there is only one state transition in DFA. to some symbol.
 DFA cannot use Empty String transition.  NFA can use Empty String transition
 Time needed for executing an input string is less  Time needed for executing an input string is more
 All DFA are NFA  NFA requires less space than DFA
 DFA requires more space  DFA requires more space
 δ: QxΣ -> Q i.e. next possible state belongs to Q.  δ: QxΣ -> 2Q i.e. next possible state belongs to
power set of Q.

Prepared by: Getahun T.


Automata and Complexity theory- 3rd year chapter-1

Exercise
1. Find a deterministic finite accepter that recognizes the set of all strings on Σ= {a, b} starting
with the prefix ab.
2. Construct grammar for L (M) = {x | x is a string of a’s and b’s and |x| >= 2}
3. Construct NFA all the strings with exactly two a’s and more than two b’s.
4. .Construct an equivalent DFA for a given NDFA

Prepared by: Getahun T.

You might also like