BU CS 332 – Theory of Computation
Lecture 2:
- Deterministic Finite
Automata
- Regular Operations
- Non‐deterministic FAs
Reading: Sipser Ch 1.1‐1.2
Mark Bun January 27, 2020
BU CS 332 Theory of Computation Lecture 2: Reading: Deterministic - - PowerPoint PPT Presentation
BU CS 332 Theory of Computation Lecture 2: Reading: Deterministic Finite Automata Sipser Ch 1.1 1.2 Regular Operations Non deterministic FAs Mark Bun January 27, 2020 Deterministic Finite Automata 1/29/2020 CS332
Lecture 2:
Automata
Reading: Sipser Ch 1.1‐1.2
Mark Bun January 27, 2020
1/29/2020 CS332 ‐ Theory of Computation 2
Only works when stereo is ON, but source remembered when stereo is OFF
presses in
∗ leave the stereo ON in USB mode?
1/29/2020 CS332 ‐ Theory of Computation 3
unstructured memory
1/29/2020 CS332 ‐ Theory of Computation 4
Input 𝑄 𝑇 𝑄 𝑇 Finite control …
Control scans left‐to‐right
1/29/2020 CS332 ‐ Theory of Computation 5
Parity: Given a string consisting of ’s and ’s, does it contain an even number of ’s? = = contains an even number of ’s
1/29/2020 CS332 ‐ Theory of Computation 6
1/29/2020 CS332 ‐ Theory of Computation 7
𝒓𝟑 0,1 1 1 1 𝒓𝟏 𝒓𝟐 𝒓𝟒
1/29/2020 CS332 ‐ Theory of Computation 8
is the set of states is the alphabet is the transition function
0
is the start state is the set of accept states
A finite automaton is a 5‐tuple
Parity: Given a string consisting of ’s and ’s, does it contain an even number of ’s? = = contains an even number of ’s
1/29/2020 CS332 ‐ Theory of Computation 9
1
State set = Alphabet = Transition function Start state Set of accept states =
𝜀 𝑏 𝑐 𝑟0 𝑟1
1/29/2020 CS332 ‐ Theory of Computation 10
= the language of machine = set of all (finite) strings machine accepts recognizes the language A DFA accepts a string
, . . . ,
such that 1.
and 3.
1/29/2020 CS332 ‐ Theory of Computation 11
1
A DFA accepts a string
, . . . ,
such that 1.
and 3.
Let 𝑥 𝑏𝑐𝑐𝑏 Does 𝑁 accept 𝑥?
1/29/2020 CS332 ‐ Theory of Computation 12
http://automatatutor.com/
1/29/2020 CS332 ‐ Theory of Computation 13
Definition: A language is regular if it is recognized by a DFA
𝑴 = { 𝒙 ∈ 𝟏, 𝟐 ∗| 𝒙 contains 𝟏𝟏𝟐 } is regular 𝑴 = { 𝒙 ∈ 𝒃, 𝒄 ∗ | 𝒙 has an even number of 𝒃’s } is regular
Many interesting programs recognize regular languages
NETWORK PROTOCOLS COMPILERS GENETIC TESTING ARITHMETIC
1/29/2020 CS332 ‐ Theory of Computation 14
Let TCPS = { | is a complete TCP Session}
1/29/2020 CS332 ‐ Theory of Computation 15
Comments : Are delimited by /* */ Cannot have nested /* */ Must be closed by */ */ is illegal outside a comment
COMMENTS = {strings over {0,1, /, *} with legal comments}
1/29/2020 CS332 ‐ Theory of Computation 16
DNA sequences are strings over the alphabet 𝑩, 𝑫, 𝑯, 𝑼. A gene 𝒉 is a special substring over this alphabet. A genetic test searches a DNA sequence for a gene. GENETICTEST𝒉 = {strings over 𝑩, 𝑫, 𝑯, 𝑼 containing 𝒉 as a substring}
1/29/2020 CS332 ‐ Theory of Computation 17
LET 3 =
𝟏 𝟐 𝟑 𝑶 represents the integer 𝟏 𝟐 𝑶 𝑶.
𝟒
∗
| ROW1 + ROW2 = ROW3 }
1 1 1 1 1 1 1 1 1 1 1 1
1/29/2020 CS332 ‐ Theory of Computation 18
In algebra, we try to identify operations which are common to many different mathematical structures
1/29/2020 CS332 ‐ Theory of Computation 19
Example: The integers are closed under
We’d like to investigate similar closure properties of the class of regular languages
Let
∗ be languages. Define
Union: Concatenation: Star:
∗
1/29/2020 CS332 ‐ Theory of Computation 20
Let
∗ be languages. Define
Complement: Intersection: Reverse:
CS332 ‐ Theory of Computation 21
Theorem: The class of regular languages is closed under all three regular operations (union, concatenation, star), as well as under complement, intersection, and reverse. i.e., if and are regular, applying any of these
1/29/2020 CS332 ‐ Theory of Computation 22
1/29/2020 CS332 ‐ Theory of Computation 23
Complement: Theorem: If is regular, then is also regular Proof idea:
1/29/2020 CS332 ‐ Theory of Computation 24
1/29/2020 CS332 ‐ Theory of Computation 25
Union:
Theorem: If and are regular, then so is Proof: Let
𝐵 𝐵
𝐵
be a DFA recognizing and
𝐶 𝐶
𝐶
be a DFA recognizing Goal: Construct a DFA
1/29/2020 CS332 ‐ Theory of Computation 26
1
1
𝑩 𝑪
Idea: Run both
𝐵 and 𝐶 at the same time
“Cross‐product construction”
𝐵 × 𝐶
,
𝐵 𝐶
𝐵
𝐵 𝐶 𝐶
𝐵 × 𝐶 𝐵 × 𝐶
1/29/2020 CS332 ‐ Theory of Computation 27
1/29/2020 CS332 ‐ Theory of Computation 28
1
1
𝑩 𝑪
1/29/2020 CS332 ‐ Theory of Computation 29
Intersection: and Theorem: If and are regular, then so is Proof: Let
𝐵 𝐵
𝐵
be a DFA recognizing and
𝐶 𝐶
𝐶
be a DFA recognizing Goal: Construct a DFA
1/29/2020 CS332 ‐ Theory of Computation 30
Intersection: and Theorem: If and are regular, then so is Another Proof: =
1/29/2020 CS332 ‐ Theory of Computation 31
Reverse:
is regular, then
is also regular
Proof idea: Let
Goal: Construct a DFA
as but
1/29/2020 CS332 ‐ Theory of Computation 32
1 1 1 0,1
𝑵 𝑵′
none at all
1/29/2020 CS332 ‐ Theory of Computation 33
1/29/2020 CS332 ‐ Theory of Computation 34
1 1 1 0,1 A Nondeterministic Finite Automaton (NFA) accepts if there is a way to make it reach an accept state.