lecture# 2 (2)
lecture# 2 (2)
AND FORMAL
LANGUAGE
LECTURE#2
Text and reference material
• Make token ?
• Length find ?
• Reverse find ?
• Is palindrome ?
∑(sigma)
Length of string
• Is a number of letters in a string , donated by |k|
• Example :- s = abab
|s|= 4
or
length (s)= 4
or
length (abab)= 4
9
Reverse of string
• is obtained by writing letters of
string in reverse order, donated by
Rev(s) or s® or Reverse(s)
Example :- s= abab , Rev(s)= baba,
Reverse(s)= baba
∑={aa,bab} and string is babaabab
so find length?
10
Power of Alphabet
Determined that the strings made from
alphabet will be of length equal to the power ^
of alphabet.
2^2
4
Introduction to languages 11
• PALINDROME:
The language consisting of Λ and the strings s
defined over Σ such that Rev(s)=s.
babaabab= babaabab
It is to be denoted that the words of
PALINDROME are called palindromes.
• Example: For Σ={a,b},
PALINDROME={Λ , a, b, aa, bb, aaa, aba, bab,
bbb, ...}
Remark
Defining languages
The languages can be defined in different
ways , such as Descriptive definition,
Recursive definition, using Regular
Expressions(RE) and using Finite
Automaton(FA) , NFA, DFA etc.
Example:
The language L of strings that
does not start with a, defined over
Σ={a,b,c}, can be written as
L={b, c, ba, bb, bc, ca, cb, cc,
…}
19
Assignment:
-
1: The language of strings of length 2, defined over Σ={0,1,2}
2: The language of strings ending in 0, defined over Σ ={0,1}
3: The language EQUAL, of strings with number of a’s equal to
number of b’s, defined over Σ={a,b}
4: The language EVEN-EVEN, of strings with even number of a’s
and even number of b’s, defined over Σ={a,b}
5: The language INTEGER, of strings defined over
Σ={-,0,1,2,3,4,5,6,7,8,9}
6: The language EVEN, of stings defined over
Σ={-,0,1,2,3,4,5,6,7,8,9}
7: The language {anbn }, of strings defined over Σ={a,b}, as
{an bn : n=1,2,3,…}
20