Lecture#01
Lecture#01
Lecture#01
Lecture#01
Course Contents
Introduction to the course title
Formal and In-formal languages
Alphabets
Strings
Null string
Words
Valid and In-valid alphabets
length of a string
Reverse of a string
Defining languages
Course Contents
Descriptive definition of languages
EQUAL
EVEN-EVEN
INTEGER
EVEN
{an bn}
{ an bn an }
FACTORIAL
DOUBLEFACTORIAL
SQUARE
DOUBLESQUARE
PRIME
PALINDROME
Regular
(DFA)
Contextfree
(PDA)
Contextsensitive
(LBA)
Recursivelyenumerable
(TM)
Automata
It is the plural of automaton, and it means something that works
automatically
Types of languages
1. Formal Languages (Syntactic languages)
2. Informal Languages (Semantic languages)
Alphabets
A finite non-empty set of symbols (called letters), is called an
alphabet. It is denoted by ( Greek letter sigma)
Example:
1. Binary: = {0,1}
2. All lower case letters: = {a,b,c,..z}
3. Alphanumeric: = {a-z, A-Z, 0-9}
4. DNA molecule letters: = {a,c,g,t}
Note: (alphabet) includes letters, digits and a variety of
operators
Strings
Definition
Concatenation of finite number of letters from the alphabet is
called a string.
Example
If = {a, b} then a, abab, aaabb, ababababababababab are all
strings
Note
Empty string or null string
Sometimes a string with no symbol at all is used, denoted by
(Small Greek letter Lambda) or (Capital Greek letter Lambda)
, is called an empty string or null string
The capital lambda will mostly be used to denote the empty
string in further discussion
Words
Definition
Words are strings belonging to some language
Example
If = {x} then a language L can be defined as
L={xn : n=1,2,3,..} or L={x,xx,xxx,.}
Here x, xx, xxx, are the words of L
Note: All words are strings, but not all strings are
words
Grammar
A grammar can be regarded as a device that enumerates
the sentences of a language - nothing more, nothing less
Alphabet,
String,
Word,
Grammar,
Language
Power of an alphabet
Let be an alphabet:
k = the set of all strings of length k
* = 0 U 1 U 2 U (All combinations of letters in )
+ = 1 U 2 U 3 U (Set of all strings in with length 1
or more)
Languages
L is a said to be a language over alphabet , only if L *
Why?
Examples:
1.
Let L be the language of all strings consisting of n 0s
followed by n 1s: L = {^,01,0011,000111,}
2.
Let L be the language of all strings of with equal number
of 0s and 1s: L = {^,01,10,0011,1100,0101,1010,1001,}
Definition: denotes the Empty language
Let L = {^}; Is L=?
NO
14
action
On/Off switch
Modeling recognition of the
word then
Start state
Transition
Intermediate
state
Final state
state
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)
Length of a String
Definition
The length of string s, denoted by |s|, is the number of
letters in the string.
Example1
={a,b} and s=ababa belongs to then |s|=5
Example2
= {B, aB, bab, d} and s=BaBbabBd belongs to then |s|
=5
Tokenizing=(B), (aB), (bab), (B), (d)
Reverse of a String
Definition
The reverse of a string s denoted by Rev(s) or sr, is obtained
by writing the letters of s in reverse order
Example
If s=abc is a string defined over ={a,b,c} then Rev(s) or sr =
cba
Example
= {B, aB, bab, d} and s=BaBbabBd then Rev(s)=dBbabaBB
Defining a Language
The languages can be defined in different ways:
1.Descriptive definition
2.Recursive definition
3.using Regular Expressions(RE)
4.using Finite Automaton(FA) etc
Remark
It is to be noted that Kleene Star can also be operated on any string i.e.
a* can be considered to be all possible strings defined over {a}, which
shows that a* generates , a, aa, aaa,
It may also be noted that a+ can be considered to be all possible non
empty strings defined over {a}, which shows that a+ generates a, aa,
aaa, aaaa,