L2 Preliminaries
L2 Preliminaries
L2 Preliminaries
Preliminary Concepts
Course Instructors:
Div 1: Praveen Pawar (Div 1)
Div 2: Jibi Abraham (Div 2)
1
Examples of Problems
Examples of problems we will consider
Given a word s, does it contain the subword “fool”?
Given a number n, is it divisible by 7?
Given a pair of words s and t, are they the same?
Given an expression with brackets, e.g. (()()),
does every left bracket match with a subsequent
right bracket?
All of these have “yes/no” answers.
There are other types of problems, that ask
“Find this” or “How many of that”
Preliminaries of Automata
How do we formalize the question
4
Alphabet
An alphabet is a finite, non-empty set of symbols
We use the symbol ∑ (sigma) to denote an alphabet
Examples:
Binary: ∑1 = {0,1}
Set of (base 10) digits: ∑2 = {0, 1, …, 9}
All lower case letters: ∑3 = {a, b, c,..z}
Alphanumeric: ∑4 = {a-z, A-Z, 0-9}
Set of letters plus special symbols ∑5 = {a, b, …, z, #, $, &}
Set of open and closed brackets ∑6 = {(, ), [, ] }
5
Strings
A string or word is a finite sequence of symbols
chosen from an alphabet ∑
Empty string is (or “epsilon”)
Example:
abfbz is a string over S1 = {a, b, c, d, …, z}
9021 is a string over S2 = {0, 1, …, 9}
ab#bc is a string over S3 = {a, b, …, z, #}
))()(() is a string over S4 = {(, )}
Length of a string w, denoted by “|w|”, is equal to the
number of (non- ) characters in the string
E.g., x = 010100 |x| = 6
xy = concatenation of two strings x and y
6
Polling Q1
If S = {0, 1} and x = 01 0 1 00
What is |x| = ?
A. 10
B. 6
C. None
7
Power of an Alphabet
Let ∑ be an alphabet
The set of all strings of a certain length k from the
alphabet is called Power of an alphabet and is
denoted by ∑k.
∑k = the set of all strings of length k
Example: If Σ ={0,1}, then:
0
Σ = { }
1
Σ ={0,1}
2
Σ ={00,01,10,11}
3
Σ ={000,001,010,011,100,101,110,111}
8
Power of an Alphabet
∑* = ∑0 U ∑1 U ∑2 U …
∑+ = ∑1 U ∑2 U ∑3 U …
∑* = ∑+ U { }
9
Kleene star
In the previous example, Σ ={0,1} and
Σ1={0,1}. What is the difference between Σ
and Σ1
Σ is an alphabet; its members 0 and 1 are
symbols
Σ1 is a set of strings; its members are strings
(each one of length 1)
10
Languages
L is a said to be a language over alphabet ∑, if only if
L ∑*
this is because ∑* is the set of all strings (of all
possible length including ) over the given
alphabet ∑
Examples:
1. Let L be the language all strings in {a, b} which
start and end with a or start and end with b over
{a, b}
L = {aa, bb, aba, aabba, bab…}
So L≠Ø
12
Concatenation of Languages
Let L1 and L2 be languages. Then the
concatenation of L1 with L2 is denoted as L1L2
and it is defined as :
L1L2 = { uv | u ϵ L1 and v ϵ L2 }
L1L2 is the set of strings obtained by
concatenating strings of L1 with those of L2.
Example L1={ab, b}, L2= {aaa, abb, aaba}
L1L2= {abaaa, ababb, abaaba, baaa, babb,
baaba}.
13
Polling Q2
If L1 = {a, ab} and L2= {bb, b}, the number of
strings in L1L2 is
A. 2
B. 3
C. 4
D. Infinite
14
Languages and Set Notation
Most of the time it would be more useful to use
set notations to define a language
Example: L1={x | x∈{a, b}∗ and |x| is even}
L2={x | there is a w such that xw = illinois}
L2 is the language made out of all prefixes of
L2.
Explicitly, L2={, i, il, ill, illi, illin, illino, illinoi,
illinois}
15
The Membership Problem
Given a string w ∑*and a language L over ∑,
decide whether or not w L.
Example:
Let w = 100011
Is w the language of strings with equal
number of 0s and 1s?
16
Decidability
The abstract Computation model will decide
whether a string belongs to a language or not
17
?
18