0% found this document useful (0 votes)
8 views

flat unit 1

The document provides an overview of Finite State Machines (FSM) and Automata Theory, detailing key concepts such as symbols, strings, formal languages, and the differences between deterministic (DFA) and nondeterministic finite automata (NFA). It includes definitions, examples, and structural representations of FSMs, along with methods for minimizing DFAs. The document emphasizes the application of FSMs in various systems and the challenges of processing natural languages compared to formal languages.

Uploaded by

aditigade9999
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

flat unit 1

The document provides an overview of Finite State Machines (FSM) and Automata Theory, detailing key concepts such as symbols, strings, formal languages, and the differences between deterministic (DFA) and nondeterministic finite automata (NFA). It includes definitions, examples, and structural representations of FSMs, along with methods for minimizing DFAs. The document emphasizes the application of FSMs in various systems and the challenges of processing natural languages compared to formal languages.

Uploaded by

aditigade9999
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 36

Unit-1

Finite State Machines


What is Automata Theory?
• Automata theory is also known as “Theory of Computation”,
which mainly deals with the logic of computation with the help
of machine.
Symbols:
• A symbol is the smallest unit or element used in a language or
system.

• In FSM: Symbols are the inputs or alphabet (denoted as Σ in


formal terms) that the machine can recognize.
Example:
• If a machine processes binary numbers, the symbols are {0, 1}.

• For a system recognizing letters, the symbols could be {a, b,


c, ...}.
Strings:
• A string is a sequence of symbols combined in a specific order.

• In FSM: A string is the input sequence that the FSM processes


to determine which state to transition to.
Example:
• For the binary alphabet {0, 1}, some strings are:
"0", "1", "01", "10", "101",...

• For the English alphabet {a, b, c}, some strings are:


"abc", "ba", "cab",...
Formal Languages:
• A formal language is a set of strings made from symbols that
follow specific rules or patterns.

• In FSM: Formal languages are the patterns or criteria the FSM is


designed to recognize or process.
Example:
• For binary numbers ending in 01, the formal language is -
{01, 101, 1001, 1101, ...}.
• For strings with only a and b where no two b’s are adjacent, the
formal language is- {a, ab, aba, abab, ...}.
Natural Languages:
• A natural language is a language humans use for communication,
like English, Hindi, Marathi, etc. These are more complex and
ambiguous compared to formal languages.

• In FSM: Natural languages are harder to process because FSMs


are better suited for formal, rule-based languages.
Example:
• English sentence: "The cat sat on the mat."

• FSM struggles here because grammar, context, and semantics


(meaning) in natural languages are beyond the FSM’s simple
transition rules.
Finite State Machine (FSM):
• A Finite State Machine (FSM) is a computational model used to
represent and control the behavior of a system.
• It consists of:
1. States: A set of conditions or configurations the system can be in.
2. Transitions: Rules that describe how the system moves from one
state to another based on inputs.
3. Input: An event or symbol that causes the transition.
4. Start State: The state where the machine begins.
5. Final/Accept State(s): The state(s) where the machine halts or
achieves its goal (if any).
• A finite state machine is a collection of 5-tuple
(Q, ∑, δ, q0, F),
where,
 Q: finite set of states.
 ∑: finite set of the input symbol called alphabets.
 δ: Transition function
 q0: initial state from where any input is processed.
 F: final state

• FSM is widely used in designing digital circuits, programming,


and modeling systems like traffic lights, vending machines, etc.
Figure: Features of Finite Automata
Examples:
Example 1: Binary Strings Ending with 01
• Symbols: {0, 1}.
• Strings: "01", "101", "1001", "1101".
• Formal Language: All binary strings ending with 01.

Example 2: Even Length Strings with {a, b}


• Symbols: {a, b}.
• Strings: "ab", "aabb", "abab".
• Formal Language: Strings with an even number of symbols.
• Example:

where,
• Circle represent the states
• Initial state is denoted by single incoming arc
• Final state is denoted by double circles
 Q={q0,q1,q2}
 ∑={0,1}
 q0={q0}
 F={q2}
• Structural Representation of FA:
1) Transition Diagram

2) Transition Table
Transition Table:
• The transition table is basically a tabular representation of the
transition function. It takes two arguments (a state and a symbol)
and returns a state (the "next state").

• A transition table is represented by the following things:


o Columns correspond to input symbols.
o Rows correspond to states.
o Entries correspond to the next state.
o The start state is denoted by an arrow with no source.
o The accept state is denoted by a star.
Present State Next state for Input 0 Next State of Input 1

→q0 q1 q2

q1 q0 q2

*q2 q2 q2
Acceptance and rejection of String:

1. ACCEPT(final state): A string is accepted means it reaches


the final state.

2. REJECT(non-final state): A string is rejected means it


does not reach the final state.
Types of Automata:
There are two types of finite automata:
1. DFA(deterministic finite automata)
2. NFA(non-deterministic finite automata)
Deterministic Finite Automata (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.
• Formal Definition of a DFA:
A DFA can be represented by a 5-tuple (Q, ∑, δ, q 0, F)
where,
 Q is a finite set of states.
 ∑ is a finite set of symbols called the 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).
c

Transition function δ as shown by the following table-

Next State for Next State for


Present State
Input 0 Input 1

a a b

b c a

c b c
• Example 1:
1) Q = {q0, q1, q2}
∑ = {0, 1}
q0 = {q0}
F = {q2}

• Transition Diagram:

• Transition Table: Present State Next state for Input 0 Next State of Input 1

→q0 q0 q1

q1 q2 q1

*q2 q2 q2
• Example 2:
1
Q = {q0, q1}
0
Σ = {0, 1}
q0 q1 1
Initial state= {q0} 0
F = {q0}
δ:
0 1
q1 q0
q0
q1 q0 q1
• Example 3:
Accepts those strings that contain at least two c’s
a a a/b/c

c c
q0 q1 q2

b b

a c c c b accepted
q0 q0 q1 q2 q2 q2

a a c rejected
q0 q0 q0 q1
• Revisit example #3:
a a a/b/c
Q = {q0, q1, q2}
c c q2
Σ = {a, b, c} q0 q1

Initial state= {q0} b


b
F = {q2}
δ: a b c
q0 q0 q0 q1

q1 q1 q1 q2

q2 q2 q2 q2

• Since δ is a function, at each step Machine has exactly one option.


• It follows that for a given string, there is exactly one computation.
• Let Σ = {0, 1}. Give DFAs for {}, {ε}, Σ*, and Σ+.

For {}: For {ε}:


0/1
0/1

q0 0/1 q1
q0

For Σ*: For Σ+:


0/1 0/1

0/1
q0 q0 q1
Nondeterministic Finite Automata (NFA):
• An NFA is a five-tuple:
M = (Q, Σ, δ, q0, F)
where,
 Q = A finite set of states
 Σ = A finite input alphabet
 q0 = initial/starting state, q0 is in Q
 F= A set of final/accepting states, which is a subset of Q
 δ = A transition function, which is a total function from Q x Σ to 2 Q
δ: (Q x Σ) –> 2Q :2Q is the power set of Q,
the set of all subsets δ(q,s) is a function from Q x S to 2Q (but not only
to Q)
• Example 1:
One or more 0’s followed by one or0more 1’s
1 0/1
 Q = {q0, q1, q2} 0 1
q1 q2
q0
 Σ = {0, 1}
 Initial state = {q0}
 F = {q2}

δ: 0 1
q0{q0, q1} {}

{} {q1, q2}
q1
{q2} {q2}

q2
• Example 2:
Pair of 0’s or pair of 1’s as substring 0/1
0/1
Q = {q0, q1, q2 , q3 , q4} 0 0
q0 q3 q4
Σ = {0, 1}
Start state is q0 1 0/1
F = {q2, q4}
1
q1 q2
δ: 0 1
{q0, q3} {q0, q1}
q0
{} {q2}
q1
{q2} {q2}
q2
{q4} {}
q3
{q4} {q4}

q4
• Determining if a given NFA (example 2) accepts a given string (001) can
be done algorithmically:
q0 q0 q0 q0
0 0 1
q3 q3 q1

q4 q4 accepted
0/1

• Each level will have at most n states: 0


q4
q0 q3
Complexity: O(|x|*n), for running over a string x 1
0/1

1
0/1
q1 q2
Minimization of DFA:
• Minimization of DFA means reducing the number of states from given
FA. Thus, we get the FSM(finite state machine) with redundant states
after minimizing the FSM.
• We have to follow the various steps to minimize the DFA. These are
as follows:
• Step 1: Remove all the states that are unreachable from the initial
state via any set of the transition of DFA.
• Step 2: Draw the transition table for all pair of states.
• Step 3: Now split the transition table into two tables T1 and T2. T1
contains all final states, and T2 contains non-final states.
• Step 4: Find similar rows from T1 such that:
• 1. δ (q, a) = p
• 2. δ (r, a) = p
• That means, find the two states which have the same value of a and b
and remove one of them.
• Step 5: Repeat step 3 until we find no similar rows available in the
transition table T1.
• Step 6: Repeat step 3 and step 4 for table T2 also.
• Step 7: Now combine the reduced T1 and T2 tables. The combined
transition table is the transition table of minimized DFA.
Very Simple Example

s0
s1
s2

s0 s1 s2
Very Simple Example

s0
s1 ε
s2 ε
s s s
0 1 2

Label pairs with ε where one is a final state and the other is not
Very Simple Example

s0
s1 ε
s2 ε
s s s
0 1 2

Main loop (no changes occur)


Very Simple Example

s0
s1 ε
s2 ε
s s s
0 1 2

DISTINCT(s1, s2) is empty, so s1 and s2 are equivalent states


Difference between DFA and NFA:

You might also like