2. Automaton
• An automaton is a finite representation of a formal language
that may be an infinite set.
3. Graphs Representing State Machines
• Ex
• Λ – x represents the set of all letters except x
• A word “abstemious” can reach to the accepting state
4. Graphs Representing State Machines
• we can design a program by first designing the graph, and
then mechanically translating the graph into a program
• At previous Ex …
• Boolean testWord(char *p){
• If (findChar(&p, ‘a’))
• If (findChar(&p, ‘e’))
• If (findChar(&p, ‘i’))
• If (findChar(&p, ‘o’))
• If (findChar(&p, ‘u’)) return TRUE;
• return FALSE }
5. Graphs Representing State Machines
• we can design a program by first designing the graph, and
then mechanically translating the graph into a program
• At previous Ex …
• Boolean testWord(char *p){
• If (findChar(&p, ‘a’))
• If (findChar(&p, ‘e’))
• If (findChar(&p, ‘i’))
• If (findChar(&p, ‘o’))
• If (findChar(&p, ‘u’)) return TRUE;
• return FALSE }
This function finds desired
character, and points the next
character, and returns TRUE.
Otherwise, returns FALSE.
6. Graphs Representing State Machines
• we can design a program by first designing the graph, and
then mechanically translating the graph into a program
• At previous Ex …
• Boolean testWord(char *p){
• If (findChar(&p, ‘a’))
• If (findChar(&p, ‘e’))
• If (findChar(&p, ‘i’))
• If (findChar(&p, ‘o’))
• If (findChar(&p, ‘u’)) return TRUE;
• return FALSE }
Ex) think a input “abstemious”
It leads to TRUE!
9. Deterministic and Nondeterministic
Automata
• Deterministic Automataon vs Nondeterminsitc Automaton
vs
Given an input ‘m’,
It can go to state 0 and
1 at the same time
Non programmableprogrammable
10. From Nondeterminism to Determinism
• We say N and D are equivalent if they accept the same set of
input string
• By constructing an equivalent deterministic automaton, we
can convert nondeterministic automaton into deterministic
automaton.
• How? Induction, or Algorithmic way
15. The Subset Construction
Yet there is no guarantee that the
deterministic automaton will be small
because 𝑘-sate nondeterministic
automaton could wind up being
converted to a deterministic
automaton with at most 2 𝑘
states.
16. Minimization of Automata
• One of the issues concerning automata, especially when they
are used to design circuits, is how few states are needed to
perform a given task.
• If states s and t are equivalent, we can merge s and t into a
single state
17. Regular Expressions
• Regular Expressions are algebraic way to define patterns
• Operands
• A character 𝒙 be denoted by that character in boldface
• The symbol ε denotes the 𝑒𝑚𝑝𝑡𝑦 𝑠𝑡𝑟𝑖𝑛𝑔
• The symbol ∅ denotes the 𝑒𝑚𝑝𝑡𝑦 𝑠𝑒𝑡 𝑜𝑓 𝑠𝑡𝑟𝑖𝑛𝑔
• A variable whose value can be any pattern defined by a regular
expression
18. Regular Expressions
• For regular expressions, the value of each expression is a
pattern consisting of a set of strings often called a language
• The language denoted by a regular expression 𝐸 will be referred to
as 𝐿(𝐸)
• The languages of the atomic operands
• If 𝒙 is any character, the regular expression 𝒙 stands for the
language 𝐿 𝒙 = {𝑥}
• 𝐿 ε = ε
• 𝐿 ∅ = ∅
• A variable whose value can be any pattern defined by a regular
expression
19. Operators of Regular Expressions
• Suppose that 𝑅, 𝑆 are two regular expressions
• Union
• 𝑅 | 𝑆 denotes the union of the languages that 𝑅 and 𝑆 denote
• That is, 𝐿 𝑅 𝑆) = 𝐿 𝑅 ∪ L S
• Concatenation
• 𝐿 𝑅𝑆 , the language denoted by 𝑅𝑆, is formed from the languages
𝐿(𝑅) and L(𝑆)
• Closure
• 𝑅 ∗ is the closure of regular expression 𝑅.
• 𝑅 ∗ = ε | R | RR | RRR | ...
20. From Regular Expressions to Automata
• Designing deterministic automata is often a good way to
design a program
• However, we also saw that deterministic automata could be
hard to design
• It is good news that there is a way to convert any regular
expression into a nondeterministic automaton, and from there
we can use the subset construction to convert to a
deterministic automaton
21. From Regular Expressions to Automata
• Convert any regular expression to an automaton with ε-
transitions that defines the same language.
• Convert the automaton with ε-transitions to an automaton
without ε-transitions that accepts the same language.
22. From Regular Expressions to Automata
• Ex) Given a regular expression 𝑎|𝑏𝑐 ∗
• Construct An expression tree for this regular expression
Internal nodes = operators
Precedence is like this arrow
leaves
23. From Regular Expressions to Automata
• There are three leaves, and for each, we construct an instance
of the automaton, given the input 𝑎|𝑏𝑐 ∗
24. From Regular Expressions to Automata
• Apply operators and construct larger automata as we go,
given the input 𝑎|𝑏𝑐 ∗
25. From Regular Expressions to Automata
• Apply operators and construct larger automata as we go,
given the input 𝑎|𝑏𝑐 ∗
26. From Regular Expressions to Automata
• Apply operators and construct larger automata as we go,
given the input 𝑎|𝑏𝑐 ∗
27. From Regular Expressions to Automata
• Using depth-first search, we can construct Table of
reachability
28. From Regular Expressions to Automata
• Find automaton without ε-transitions that accepts the same
language. Important
states
29. From Regular Expressions to Automata
• Find automaton without ε-transitions that accepts the same
language.
30. From Regular Expressions to Automata
• Find automaton without ε-transitions that accepts the same
language. Important
statesBecome the accepting state, if the col has 1
Cannot reach any important state
31. From Regular Expressions to Automata
• Find automaton without ε-transitions that accepts the same
language.
Become the accepting state, if the col has 1
Cannot reach any important state
32. From Regular Expressions to Automata
• Find automaton without ε-transitions that accepts the same
language. Important
statesBecome the accepting state, if the col has 1
33. From Regular Expressions to Automata
• Find automaton without ε-transitions that accepts the same
language.
Become the accepting state, if the col has 1
34. From Regular Expressions to Automata
• Find automaton without ε-transitions that accepts the same
language. Important
statesBecome the accepting state, if the col has 1
35. From Regular Expressions to Automata
• Find automaton without ε-transitions that accepts the same
language.
Become the accepting state, if the col has 1
Accepting states
36. From Regular Expressions to Automata
• Find automaton without ε-transitions that accepts the same
language.
Become the accepting state, if the col has 1
Accepting states
37. From Regular Expressions to Automata
• there is a simpler deterministic automaton that accepts the
same language By recognizing that
states 5 and 8 are
equivalent, they can be
merged.
38. From Automata to Regular Expressions
• The key step in conversion from an automaton to a regular
expression is the elimination of states until two states remains
A regular expression for the set of
strings that get us from state s to
state t is
𝑆 ∗ 𝑈 𝑇 𝑉𝑆 ∗ 𝑈 ∗
39. From Automata to Regular Expressions
• The key step in conversion from an automaton to a regular
expression is the elimination of states
• Ex) bounce filter
• 0101101
• 0000111
40. From Automata to Regular Expressions
• The key step in conversion from an automaton to a regular
expression is the elimination of states
• Ex) bounce filter
• Case1
41. From Automata to Regular Expressions
• The key step in conversion from an automaton to a regular
expression is the elimination of states
• Ex) bounce filter
• Case2
42. From Automata to Regular Expressions
• The key step in conversion from an automaton to a regular
expression is the elimination of states
• Ex) bounce filter
• All cases have elimination of b
43. From Automata to Regular Expressions
• The key step in conversion from an automaton to a regular
expression is the elimination of states
• Ex) bounce filter
• All cases have elimination of b
• For the a–a pair
• 𝑎 → 𝑎 𝑖𝑠 𝑟𝑒𝑝𝑙𝑎𝑐𝑒𝑑 𝑏𝑦 0|1∅0
• ∄ the a-c pair
44. From Automata to Regular Expressions
• The key step in conversion from an automaton to a regular
expression is the elimination of states
• Ex) bounce filter
• After the elimination of b,
• Two cases exist
• Case 1: delete d
• Case 2: delete c
• Union(Case1, Case2)
45. From Automata to Regular Expressions
• The key step in conversion from an automaton to a regular
expression is the elimination of states
Union
0 10 ∗ 11 1 01 00 0 10 ∗ 11 ∗
0 10 ∗ 111 ∗ 0 11 ∗ 0 0 0|10 ∗ 111 ∗ 0 ∗