Lecture 2: DFA (FSM)
𝑀1
0 1 Let’s begin: Finite Automata
0,1
1
𝑞1 𝑞2 𝑞3
0
Input: finite string
Output: Accept or Reject
1 Computation process: Begin at start state,
read input symbols, follow corresponding transitions,
Accept if end with accept state, Reject if not.
Examples: 01101 → Accept
00101 → Reject
accepts exactly those strings in where
contains substring
Say that is the language of and that recognizes and that .
Credits: Prof. Michael Sipser, MIT
Finite Automata – Formal Definition
Defn: A finite automaton is a 5-tuple
finite set of states
finite set of alphabet symbols
transition function Example:
a
start state
means 𝑞 𝑟 𝑀1 0
1
0,1
set of accept states 𝑞1 𝑞2 1
𝑞3
0
𝛿=¿ 0 1
More DFAs…
DFAs…
Finite Automata – Computation
Strings and languages
- A string is a finite sequence of symbols in
- A language is a set of strings (finite or infinite)
- The empty string ε is the string of length 0
- The empty language is the set with no strings Recognizing languages
-
- is the language of
Defn: accepts string each - recognizes
if there is a sequence of states
where:
-
- for Defn: A language is regular if some
-
finite automaton recognizes it.
Regular Languages – Examples
𝑀1 0 1
0,1
1
𝑞1 𝑞2 𝑞3
0
More examples:
Let has an even number of 1s
Therefore is regular is regular (make automaton for practice).
Let has equal numbers of 0s and 1s
is not regular (we will prove).
Goal: Understand the regular languages
Regular Expressions This slide (RE) to be
covered in Lecture 3
Regular operations. Let be languages:
- Union: or
- Concatenation: and
- Star: each for
Note: always Regular expressions
- Built from , members [Atomic]
- By using [Composite]
Example. Let good, bad and boy, girl.
- {good, bad, boy, girl} Examples:
- {goodboy, goodgirl, badboy, badgirl} - gives all strings over
- {, good, bad, goodgood, goodbad, badgood, - gives all strings that end with 1
badbad, goodgoodgood, goodgoodbad, … } - all strings that contain 11
Goal: Show finite automata equivalent to regular expressions
Closure Properties for Regular Languages
Theorem: If are regular languages, so is (closure under )
Proof: Let recognize
recognize Example…
Construct recognizing
should accept input if either or accept .
𝑀 1Check-in 1.1 Components of :
𝑞 𝑀
In the proof, if and are finite automata and
?
where has states and has states
Then how many states does have? 𝑞,𝑟
𝑀 2 (a)
(b)
𝑟 NO! [gives intersectio
(c)
Check-in 1.1
Closure Properties continued
Theorem: If are regular languages, so is (closure under )
Proof: Let recognize
recognize
Construct recognizing
𝑀1 𝑀2
should accept input
if where
𝑀 accepts and accepts .
𝑤
𝑥 𝑦
Doesn’t work: Where to split ?
Quick review of today
1. Introduction, outline, mechanics,
expectations
2. Finite Automata, formal defi nition, regular
languages
3. Regular Operations and Regular
Expressions
4. Proved: Class of regular languages is
closed under
5. Started: Closure under , to be continued…