0% found this document useful (0 votes)
34 views35 pages

CMP3008 LN2 FiniteAutomata

This document provides lecture notes on finite automata and regular languages. It defines deterministic finite automata (DFAs) as state machines that can exist in only one state at a time. DFAs are formally defined as 5-tuples consisting of a set of states, input symbols, start state, accepting states, and transition function. The document discusses how DFAs process input strings and recognizes languages. It also provides examples of DFAs and their recognized languages. Finally, it introduces regular operations and languages.

Uploaded by

Ammar Jagadhita
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)
34 views35 pages

CMP3008 LN2 FiniteAutomata

This document provides lecture notes on finite automata and regular languages. It defines deterministic finite automata (DFAs) as state machines that can exist in only one state at a time. DFAs are formally defined as 5-tuples consisting of a set of states, input symbols, start state, accepting states, and transition function. The document discusses how DFAs process input strings and recognizes languages. It also provides examples of DFAs and their recognized languages. Finally, it introduces regular operations and languages.

Uploaded by

Ammar Jagadhita
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/ 35

CMP3008

Formal Languages
and Automata Theory
Lecture Notes 2
Finite Automata
Sources
https://eecs.wsu.edu/~ananth/CptS317/Lectures/index.htm
"Introduction to automata theory, languages and
computation" by JE Hopcroft, R Motwani and JD Ullman.
"An Introduction to Formal Languages and Automata Theory" by
Peter Linz
Content
• Deterministic finite automata (dfa)
• Formal Definition of dfa
• DFA Design Examples
• Regular Languages
• Regular Operations

2
Finite Automata (DFA)
• Informally, a state diagram that comprehensively captures all possible states and
transitions that a machine can take while responding to a stream or sequence of
input symbols
• Recognizer for “Regular Languages”

• Deterministic Finite Automata (DFA)


• The machine can exist in only one state at any given time
• Non-deterministic Finite Automata (NFA)
• The machine can exist in multiple states at the same time

3
Deterministic Finite Automata (DFA)
• A Deterministic Finite Automaton (DFA) consists of:
• Q ==> a finite set of states
• ∑ ==> a finite set of input symbols (alphabet)
• q0 ==> a start state
• F ==> set of accepting states
• δ ==> a transition function, which is a mapping between Q x ∑ ==> Q
• A DFA is defined by the 5-tuple:
• {Q, ∑ , q0,F, δ }

4
Formal Definition of a Finite Automaton
Formal Definition of a Finite Automaton
Deterministic Finite Automata (DFA)
• Input: a word w in ∑*
• Question: Is w acceptable by the DFA?
• Steps:
• Start at the “start state” q0
• For every input symbol in the sequence w do
• Compute the next state from the current state, given the current input symbol in w and
the transition function
• If after all symbols in w are consumed, the current state is one of the
accepting states (F) then accept w;
• Otherwise, reject w.

7
Deterministic Finite Automata (DFA)

• The above figure depicts a finite automaton called M1.


• The figure is called the state diagram of M1.
• It has three states, labeled q1, q2, and q3.
• The start state, q1, is indicated by the arrow pointing at it from
nowhere.
• The accept state, q2, is the one with a double circle.
• The arrows going from one state to another are called transitions.
Deterministic Finite Automata (DFA)

• When this automaton receives an input string such as 1101, it processes


that string and produces an output.
• The output is either accept or reject.
• The processing begins in M1’s start state. The automaton receives the
symbols from the input string one by one from left to right. After reading
each symbol, M1 moves from one state to another along the transition that
has that symbol as its label.
• When it reads the last symbol, M1 produces its output. The output is
accept if M1 is now in an accept state and reject if it is not.
Deterministic Finite Automata (DFA)

• Can you describe the language consisting of all strings that M1


accepts?
Relation Between a Formal Language and
a Finite Automaton
• If A is the set of all strings that machine M accepts, we say
that A is the language of machine M and write L(M ) = A.
• We say that M recognizes A.
• A machine may accept several strings, but it always recognizes
only one language.
• If the machine accepts no strings, it still recognizes one
language— namely, the empty language ∅
Deterministic Finite Automata (DFA)

Can you describe the language consisting of all strings that M1 accepts?
Examples

L(M2) = {w| w ends in a 1}.


Examples
Examples

L(M4) = {w| w starts and ends with the same symbol}.

Note that in this example Σ = {a, b}


Examples

Example: 10⟨RESET⟩22⟨RESET⟩012
Formal Definition of Computation
Designing DFA
• Whether it be of automaton or artwork, design is a creative process.
• A helpful approach: put yourself in the place of the machine you are
trying to design and then see how you would go about performing
the machine’s task.
• First, in order to make these decisions, you have to figure out what
you need to remember about the string as you are reading it.
• Once you have determined the necessary information to remember
about the string as it is being read, you represent this information as
a finite list of possibilities.
Designing DFA
Example: Design a FA for the following language:

L = {w | w contains an odd number of 1s}

What information do you need to remember?


1. even so far, and
2. odd so far.
Then you assign a state to each of the possibilities
Designing DFA

Next, you assign the transitions by seeing how to go from one possibility to another
upon reading a symbol.
Designing DFA

• Next, you set the start state to be the state corresponding to the possibility
associated with having seen 0 symbols so far (the empty string ε).
• Last, set the accept states to be those corresponding to possibilities where you
want to accept the input string.
Designing DFA
Example: Design a FA for the following language:
L = {w | w contains 001 as a substring}
What information do you need to remember?

Then you assign a state to each of the possibilities


Designing DFA
Designing DFA
Design a FA for the following language:

L = {w | w is a valid variable name},  = {a, b, 0, 1}.


Designing DFA
Design a FA for the following language:
L = {w | w is a floating-point number},  = {0, 1, 2, 3, .}
Example strings:
• 320, 12.0, 0.13, .21, 32.  L
• 23.1.2, 11.., .2.1, .,  L

Will accept a single .


Designing DFA
Design a FA for the following language:

L = {w | the length of w is 3},  = {a, b}.


Regular Languages
• Let L(A) be a language recognized by a DFA A.
• Then L(A) is called a “Regular Language”.
• Locate regular languages in the Chomsky Hierarchy

27
Regular Languages
• Finite automata accept a family of languages
collectively known as regular languages.
• A language L is regular if and only if there is a DFA that
accepts L. Therefore, to show that a language is regular, one
must construct a DFA to accept it.
• Practice: show that L = {(ab)na, n > 0} is regular.
• Regular languages have wide applicability in problems
that involve scanning input strings in search of specific
patterns.
Example
• Build a DFA for the following language:
• L = {w | w is a binary string that contains 01 as a substring}
• Steps for building a DFA to recognize L:
• ∑ = {0,1}
• Decide on the states: Q
• Designate start state and final state(s)
• δ: Decide on the transitions:
• “Final” states == same as “accepting states”
• Other states == same as “non-accepting states”

29
Regular expression: (0+1)*01(0+1)*

DFA for strings containing 01


• What makes this DFA deterministic?
• Q = {q0,q1,q2}

1 0,1 • ∑ = {0,1}
0
• start state = q0
start 0 1
q0 q1 q2 • F = {q2}
Accepting • Transition table
state symbols
0 1
• What if the language allows q0 q1 q0
empty strings?

states
q1 q1 q2
*q2 q2 q2
30
The Regular Operations
• In arithmetic, the basic objects are numbers and the tools are
operations for manipulating them, such as + and ×.
• In the theory of computation, the objects are languages and the tools
include operations specifically designed for manipulating them.
• We define three operations on languages, called the regular
operations, and use them to study properties of the regular
languages.
The Regular Operations
The Regular Operations
The Regular Operations
The Regular Operations

To prove this, we need to introduce a new technique called nondeterminisim.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy