Introduction
The Basic Concepts of Automata
Alphabet
String
Languages
Grammars
Finite automata, Deterministic and Non-
deterministic finite automata
3. Some Applications
1
Automata theory
.
Automaton theory: Study of abstract computing devices, or
machines
Automata theory deals with the definitions and properties of
mathematical models of computation.
Automata : is a self-operating machine, or a machine or control
mechanism designed to follow automatically a predetermined
sequence of operations, or respond to predetermined instructions.
2
Automaton
.
Automaton = an abstract computing device
Note: A device need not even be a physical hardware!
Automata means something that works automatically.
Automata are a model that used in text processing, compilers,
and hardware design called the finite automaton
Another model, called the context-free grammar, is used in
programming languages and artificial intelligence.
3
Con…
.
A fundamental question in computer science are:
Find out what different models of machines can do and
cannot do?
The theory of computation
Computability vs. Complexity
Computability theory: what kinds of things can you
solve with a computer and what kinds of things can’t
you solve with a computer?
4
Con…
.
Complexity theory: focuses on how hard is problem to solve using
a computer?
We’ll define different ways of measuring
hardness: time and space (memory)
The time complexity - is the number of steps until the
machine halts.
The space complexity is the number of tape cells used by
the computation.
Example is factorial number
A famous unsolved problem is the P vs. NP problem, which will
5
Con…
.
A pioneer of automata theory
ALAN TURING (1912-1954)
Father of Modern Computer Science
English mathematician
Studied abstract machines called Turing
machines even before computers existed
6
Con…
.
7
Con…
Halting— means that the program on certain input
will accept it and halt or reject it and halt.
Basically halting means terminating.
Halting Problem: There does not exist a Turing
machine
that always halts.
Undecidable: there is no Turing machine that
decides it.
Intractable: Certain computational problems are solvable in
8
principle, but the solutions require so much time or space that
Con…
.
9
THE CENTRAL CONCEPTS OF AUTOMATA THEORY
.
In this section, we define the basic notions of the subject:
symbols, strings, alphabets and (formal) languages
The mathematical study of the “Theory of Computation” begins by
understanding the Mathematics of strings of symbols.
* A symbol is one of the finite sequences of ASCII characters:
* One of the digits 0–9;
* One of the upper case letters A–Z;
* One of the lower case letters a–z;
* A (, followed by any finite sequence of printable ASCII characters in
10 which ( and) are properly nested, followed by a)
Alphabet & String
.
Alphabet: A finite non-empty set of symbols (letters), is
called an alphabet. It is denoted by Σ (Greek letter sigma).
Example
Σ = {a,b}, Σ = {i,j,k}
String: A “string” over an alphabet is a finite sequence of
symbols from that alphabet, which is usually written next
to one another and not separated by commas.
(i) If Σa = {0 ,1}then 001001 is a string over Σa
(ii) If Σb = {a ,b , , , z) then axyrpqstcd is a string over Σb.
11
String operations
.
Length of String
12
String
.
Empty String: The string of zero length is called the empty
string. This is denoted by ∈.
The empty string plays the role of 0 in a number system.
Reverse String: If w=w1w2...wn where each wi ∈ Σ, the
reverse of w is wnwn-1... w1.
13
Substring:
.
z is a substring of w if z appears consecutively within w.
Example deck is a substring of abcdeckabcjkl.
Concatenation: Assume a string x of length m and string y of
length n, the concatenation of x and y is written xy, which is the
string obtained by appending y to the end of x, as in x1x2 ...xmy1
y2..... yn .
To concatenate a string with itself many times we use the
“superscript” notation:
14
Substring:
.
Suffix: If w=xv for some x, then v is a suffix of w.
Prefix: If w=vy for some y, then v is a prefix of w
Lexicographic ordering: The Lexicographic ordering of strings
is the same as the dictionary ordering, except that shorter
strings precede longer strings. The lexicographic ordering of all
strings over the alphabet {0, 1} is (∈, 0,1, 00, 01, 10, 11,
000, ...).
15
Summary
.
16
Language
.
Language: Any set of strings over an alphabet Σ is called a language.
A language L is regular if it is the language accepted by some DFA
The set of all strings, including the empty string over an alphabet Σ
is denoted as Σ*.
Infinite languages L are denoted as: L={w∈ Σ*: has property P}
Examples:
a) L1 = {w ∈{0,1}* : has an equal number of 0's and 1's}
b) L2 = {w∈ Σ* : w= wR } where wR is the reverse string of w.
17
Language
.
Concatenation of Languages: If L1 and L2 are languages over Σ,
their concatenation is L = L1•L2, or simply L =L1L2, where
L = {w ∈ Σ* :w = x •y for some x∈ L1 and y∈L2}.
Example: Given Σ = {0, 1}
L1 = {w ∈ Σ* : w has an even number of 0's}
L 2 = { w: w starts with a 0 and the rest of the symbols are 1's}
then L1 L2 = {w : w has an odd number of 0's}
18
Language
.
Kleene Star: is the set of all strings that can be written as the concatenation
of zero or more strings from L, which is denoted by L*.
L* is the set of all strings obtained by concatenating zero or more strings
from L.
L*= w ∈ Σ*: w=w1....w k for some k ≥0 and some w1,w2,...,wk
∈L
Example: If L = {01, 1, 100} then 110001110011∈ L*, since 110001110011 = 1•
100• 01• 1• 100 • 1• 1, each of these strings is in L.
19
Example
.
Given Σ = {a, b} obtain Σ*.
(a) Give an example of a finite language in Σ.
(b) Given L = {anbn : n ≥0 } , check if the strings aabb, aaaabbbb, abb are in the language L.
Solution: Σ = {a, b} Therefore we have
Σ* = {λ , a, b, aa ,ab, ba, bb, aaa }
(a) {a, aa, aab} is an example of a finite language in Σ.
(i) aa bb → a string in L. (n = 2)
(ii) aaaa bbbb → a string in L. (n = 4)
(iii) abb → not a string in L (since there is no n satisfying this).
20
Summary
.
21
Grammars
.
Grammar is a mechanism to describe the languages.
A grammar (G) is defined as a quadruple
G = (V, T, S, P) where
V = Finite set of objects called VARIABLES
T = Finite set of objects called TERMINAL SYMBOLS
S ∈V = Start variables
P = Finite set of Productions.
A production rule P is of the form x→y
Given a string w, of the form w = uxv, we can use
the production rule x → y and obtain a new string
z = uyv.
Grammars
.
The set of all strings obtained by using production rules is the Language generated
by the Grammar.
If the grammar G = (V, T, S, P) then
L(G ) = {w∈T* :S w}
If W ∈ L(G) , then the sequence
S ⇒w1 ⇒w2 ⇒ w3 . . .⇒ wn ⇒ w is a “derivation” of the sentence w.
The string S, w1, w2, wn which contain variables as well as terminals, are called
“SENTENTIAL FORMS” of the derivation.
23
.
Grammars
Example: Given a Grammar
G = ({S } , {a ,b}, S , P) with P defined as
S →aSb,
S→λ
i. Obtain a sentence in the language generated by G and the sentential form
ii. Obtain the language L(G).
24
.
Grammars
Applying the production rule S → aSb , we get
ai S bi ⇒ ai+1 S bi+1
This is true for all i.
In order to get a sentence we apply S → λ.
Therefore we get S an S bn ⇒an bn
There fore L(G) = {anbn ;n ≥ 0 }.
25
.
Grammars
26
Summary
.
27
Practical Examples
.
On/Off switch
actio
n
state
Modeling recognition of the word “then”
Start state Transition Intermediate Final state
state
28
Structural expressions
.
Grammars
Regular expressions
E.g. Unix style to capture city names such as “Palo Alto CA”:
[A-Z][a-z]*([ ][A-Z][a-z]*)*[ ][A-Z][A-Z]
Start with a letter
A string of other
letters (possibly empty) Should end w/ 2-letter state code
Other space delimited words
(part of city name)
29
Some Applications
.
Software for designing and checking the behavior of digital
circuits
Lexical analyzer of a typical compiler
Software for scanning large bodies of text (e.g., web pages),
for pattern finding
Software for verifying systems of all types that have a finite
number of states (e.g., stock market transaction,
communication/network protocol)
30
Exercise
Given L1={ab,bc,ca}, L2={aa,ac,cb} determine
a. L1L2
b. L1
c. L1- L2
d. L1L2
31
.
Questions ?
32