0% found this document useful (0 votes)
23 views18 pages

Chapter 1

Uploaded by

aryafalaswad99
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views18 pages

Chapter 1

Uploaded by

aryafalaswad99
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Theory of Computation

Chapter 1: Basic concepts and definitions


Introduction

 The Theory of Computation(TC) is the branch of computer


science that deals with how efficiently problems can be solved on
a model of computation, using an algorithm.
 The field is divided into three major branches:
 Automata theory and language
 Computability theory
 Complexity theory
2
3
Complexity theory

 Classifying problems according to their difficulty.

 The main question asked in this area is “What makes some


problems computationally hard and other problems easy?”

 What can be solved given limited resources of time and space

4
Computability Theory

 Computational models and algorithms for general purpose.

 Classify problems as being solvable or unsolvable.

 What are the fundamental capabilities and limitations of computers


? What can(not) computers solve ? .
5
Automata theory

 Automata Theory deals with definitions and properties of different


types of “computation models”. Examples of such models :
 Finite Automata :these are used in text processing, compilers, and
hardware design.
 Context-Free Grammars: these are used to define programming
languages and in Artificial Intelligence.
 Turing Machines: these form a simple abstract model of a “real”
computer, such as your PC at home.
6
Mathematical notations and Terminology

 Sets
A set is a group of elements represented as a unit.
For example : S ={a, b, c} a set of 3 elements

 Functions
Let f be a function defined on a set A and taking values to a set B. Set A is called the
domain of f; set B is called the range of f.

 Graphs
Is a visual representation of a set and a relation.
7
Mathematical notations and Terminology
(con’d)

 Boolean Logic

Boolean logic, boolean values (True and False), boolean operations, negation (NOT),
conjunction (AND), disjunction (OR), operands of an operation, exclusive OR (XOR),

 Strings and Languages


Alphabet, symbols of alphabet, string over an alphabet, length of a string, empty
string, reverse of a string, substring, concatenation, language,

8
Strings and Languages

▰ Alphabet: Finite, nonempty set of symbols


▻ Examples:
▻  = {0, 1}: binary alphabet
▻  = {a, b, c, …, z}: the set of all lower case letters
▻ The set of all ASCII characters
▰ String: Finite sequence of symbols from an alphabet 
▻ Examples:
▻ 01101 where  = {0, 1}
▻ abracadabra where  = {a, b, c, …, z} 9
Strings and Languages(con’d)

 Empty String: The string with zero occurrences of symbols from  and is
denoted e or .
▰ Length of String: Number of symbols in the string
▻ The length of a string w is usually written |w|
▻ |1010| = 4
▻ |e| = 0
▻ |uv| = |u| + |v|
▰ Reverse : wR
▻ If w = abc, wR = cba 10
Strings and Languages(con’d)

 Concatenation: if x and y are strings, then xy is the string obtained by placing a


copy of y immediately after a copy of x
x = a1a2 …ai, y = b1b2 …bj
xy = a1a2 …aib1b2 …bj
Example: x = 01101, y = 110, xy = 01101110
xe=ex=x
 Power of an Alphabet: k = the set of strings of length k with symbols from 

Example:  = {0, 1}
1 =  = {0, 1}
2 = {00, 01, 10, 11}
0 = {e} 11
Strings and Languages(con’d)

 Substring: any string of consecutive characters in some string w


If w = abc
e, a, ab, abc are substrings of w

 Prefix and suffix:


if w = vu
v is a prefix of w Suppose: S is the string banana
u is a suffix of w  Prefix : ban, banana
Example  Suffix : ana, banana
If w = abc  Substring : nan, ban, ana, banana
a, ab , abc are prefixes of w
c, bc, abc are suffixes of
12
Strings and Languages(con’d)
 Language: set of strings chosen from some alphabet
▰ A language is a subset of *
▻ Example of languages:
▻ The set of valid Arabic words
▻ The set of strings consisting of n 0’s followed by n 1’s
▻ {e, 01, 0011, 000111, …}
▻ The set of strings with equal number of 0’s and 1’s
▻ {e, 01, 10, 0011, 0101, 1010, 1001, 1100, …}
▰ Empty language:  = { }
▰ The language {e} consisting of the empty string 13
▰ Note:   {e}
Strings and Languages(con’d)
▰ Can concatenate languages
▻ L1L2 = {xy | x  L1, y  L2}
▻ Ln = L concatenated with itself n times
▻ L0 = {e}; L1 = L
▰ Star-closure
▻ L* = L0  L1  L2  ...
▻ L + = L* - L 0
▰ Languages can be finite or infinite
▻ L = {a, aba, bba}
▻ L = {an | n > 0} 14
Strings and Languages(con’d)

L = {A, B, …, Z, a, b, …z} D = {1, 2, …, 9}


L  D = the set of letters and digits
LD = all strings consisting of a letter followed by a digit
L2 = the set of all two-letter strings
L4 = L2 L2 = the set of all four-letter strings
L* = { All possible strings of L plus e }, L+ = L* - e
D+ = set of strings of one or more digits
L (L  D ) = set of all strings consisting of a letter followed by a a letter or a digit
L (L  D )* = set of all strings consisting of letters and digits beginning with a
letter 15
Strings and Languages(con’d)

Exercise 1:The language L consists of strings over {a,b} in which each string begins with an a
should have an even length
 aa, ab  L
 aaaa,aaab,aaba,aabb,abaa,abab,abba,abbb  L

 baa  L
 a

Exercise 2:The language L consists of strings over {a,b} in which each occurring of b is immediately
preceded by an a
 eL
 aL
 abaab  L
 bb  L
 bab  L
 abb  L 16
Strings and Languages(con’d)

Exercise 3:
The language L = {a,b}*{bb}{a,b}* = *{bb}*, consists of the strings over {a,b} that contain the
substring bb
bb  L
abb  L
bbb  L
aabb  L
bbaaa  L
bbabba  L
abab  L
bab  L
bL

Exercise 2:The language L consists of strings over {a,b} in which each occurring of b is immediately
preceded by an a
 eL
 aL 17
 abaab  L
Homework

18

You might also like