Chapter 1 - Introduction
Chapter 1 - Introduction
1
Introduction to Complexity theory
“Complexity theory" is the body of knowledge
concerning fundamental principles of computation.
Its beginnings can be traced way back in history to
the use of asymptotic complexity and reducibility by
the Babylonians.
2
Modern complexity theory is the result of research activities in
many different fields: biologists studying models for neuron
nets or evolution, electrical engineers developing switching
theory as a tool to hardware design, mathematicians working
on the foundations of logic and arithmetic’s, linguists
investigating grammars for natural languages, physicists
studying the implications of building Quantum computers, and
last but not least, computer scientists searching for efficient
algorithms for hard problems.
The course will give an introduction to some of these areas.
3
Relations and functions
A (binary) relation is a set of pairs. The first
component of each pair is chosen from a set called
the domain, and the second component of each pair is
chosen from a (possibly different) set called the range.
Often, the domain and the range are the same set S. In
that case we say the relation is on S. If R is a relation
and (a; b) is a pair in R, then we often write aRb.
4
Relations and functions
5
Definitions
• Automaton
— A self-operating machine or mechanism, plural is Automata.
• Automata
— Abstract computing devices
• Automata theory
— The study of abstract machines and the computational problems that
can be solved using these machines.
• Mathematical models of computation
— Finite automata
— Push-down automata
— Turing machines
6
Kinds of Automata
• Automata are distinguished by the temporary
memory
— Finite Automata - no temporary memory
— Pushdown Automata - stack
— Turing Machines - random access memory
7
Kinds of Automata …
Finite
temporary memory
Automaton
input memory
Finite
Automaton
output memory
Example: Vending Machine’s small computing power - a machine from which
items such as packaged food or drinks can be bought by inserting money.
8
Kinds of Automata …
Pushdown Stack Push, Pop
Automaton
input memory
Pushdown
Automaton
output memory
input memory
Turing
Machine
output memory
10
Kinds of Automata …
Power of Automata
11
Related Terminology in Complexity Theory
Symbol: an entity or letters
Alphabets: is a finite set of symbols, usually
letters, digits, and punctuations.
String: Sequence of alphabet
Length of Concatenation
u aab, u 3
v abaab, v 5
uv aababaab 8
uv u v 3 5 8
12
Empty String
• A string with no letters: or or
• Observations: 0
w w w
abba abba abba
• Note:
— A language that does not contain any word at all is
denoted by or { }.
— This language doesn’t contain any word not even the
NULL string. i.e. { } ≠ {}
— Suppose a language L doesn’t contain NULL then L = L +
but L ≠ L + {}.
— NULL is identity element with respect to concatenation
13
Substring
• Substring of string is a subsequence of
consecutive characters of the string.
• Example:
String Substring
abbab ab
abbab abba
abbab b
abbab bbab
14
Substring …
• Let a string be abbab
• Example:
Prefixes Suffixes
abbab w uv
a bbab
prefix
ab bab
suffix
abb ab
abba b
abbab
15
The * Operation
•
:*closure of alphabets (also Kleene star)
– Is the set of all strings from alphabet
– There are infinitely many words each of finite length
a, b
* , a, b, aa, ab, ba, bb, aaa, aab,
16
The + Operation
• :Kleene plus
• Is a set of all strings from except
* and
• Note : are infinite
a, b
* , a, b, aa, ab, ba, bb, aaa, aab,
*
a, b, aa, ab, ba, bb, aaa, aab,
17
Finite state automata
– It can be deterministic (DFA) or non-deterministic (NFA)
Deterministic – faster recognizer, but it may take more
space
Non-deterministic – slower, but it may take less space.
20
Regular Expressions …
• Examples:
– (a+b.c)* describes the language
{a,bc}* = {λ, a, bc, aa, abc, bca, …}
– (a+b)+ describes the language
{a,b}+ = {a, b, aa, ab, ba, bb, aaa, …}
21
Pushdown Automata(PDA)
PDAs: a more powerful computation device that can recognize CFLs.
PDA: a є-NFA with a “stack” which serves as “memory”, and store a string of
stack symbols.
●
LR ↔ FSA
●
CFL ↔ PDA
PDA Rejection
• A string is rejected if there is no computation such that:
Recursive Languages
Context-Free Languages
Regular Languages
24
Formal definition of a PDA
● M = (Q, Σ, Γ, δ, q0, z0, F)
δ : Q x ( ΣU {є}) x Γ → 2Q x Γ
* transitions
25
Pushdown Automata (PDA)
tape
tape head
stack head
finite
control stack
p u s h d o w n
The tape is divided into finitely many cells. Each cell contains a symbol in an
26
alphabet Σ.
Pushdown Automata (PDA)
The stack head always scans the top symbol of the stack. It performs
two basic operations:
Push: add a new symbol at the top.
Pop: read and remove the top symbol.
The head/pointer scans at a cell on the tape and can read a symbol on the
cell. In each move, the head can move to the right cell.
27
FINITE AUTOMATA PUSHDOWN AUTOMATA
It doesn’t has the capability to store It has stack to store the input
long sequence of input alphabets alphabets
Finite Automata can be constructed Pushdown Automata can be
for Type-3 grammar constructed for Type-2 grammar
Input alphabets are accepted by Input alphabets are accepted by
reaching “final states” reaching :
1. Empty stack
2. Final state
NFA can be converted into equivalent NPDA has more capability than DPDA
DFA
It consist of 5 tuples: It consists of 7 tuples:
L = {Q, q0, ∑, F, σ} L = {Q, q0, ∑, F, ᴦ, σ, z0 }
Finite automata can be constructed Pushdown automata can be
for regular language constructed for context free grammar
Pushdown Automaton(PDA)
•Go to a new state, which may be the same as the previous state.
The string might be the same as the current stack top (does nothing)
Replace with a new string (pop and push) Replace with multiple symbols
(multiple pushes)
29
PDA. Simple example
L = {0 1 | n 0 }.
n n
0 }.
є, empty
stack
є
q q q
0 1 2
0, 1,
push 0
●
pop 0
q0: push 0.
●
39
Time and Space Complexity of a Turing Machine