1 Regular Languages
1.1 Finite Automata
Finite Automata
• Finite automata are good models for computers with an extremely
limited amount of memory.
• Applications
• String processing
• Lexical analyzes
• Designing sequential circuits
• Network intrusion detection
Finite Automata
• 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.
Finite Automata
• 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.
Finite Automata
• Can you describe the language consisting of all strings that M1
accepts?
Formal Definition of a Finite Automaton
Formal Definition of a Finite Automaton
Formal Definition of 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 ∅
Finite Automata
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 Finite Automata
• 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 Finite Automata
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 Finite Automata
Next, you assign the transitions by seeing how to go from one possibility to another
upon reading a symbol.
Designing Finite Automata
• 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 Finite Automata
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 Finite Automata
Designing Finite Automata
Design a FA for the following language:
L = {w | w is a valid variable name}, S = {a, b, 0, 1}.
Designing Finite Automata
Design a FA for the following language:
L = {w | w is a floating-point number}, S = {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 Finite Automata
Design a FA for the following language:
L = {w | the length of w is 3}, S = {a, b}.
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.