CSB4301 – Theory of Computation
B.Tech – IVth Semester
Mr. D.S.John Deva Prasanna AP(SG) & Mr.Vasanthraj
Department of Computer Science and Engineering
Languages Strings and Alphabets
Languages :
• The languages we consider for our discussion is an abstraction of natural languages. That is, our focus here is on formal
languages that need precise and formal definitions. Programming languages belong to this category.
Symbols :
• Symbols are indivisible objects or entity that cannot be defined. That is, symbols are the atoms of the world of languages. A
symbol is any single object such as , a, 0, 1, #, begin, or do.
Alphabets :
• An alphabet is a finite, nonempty set of symbols. The alphabet of a language is normally denoted by . When more than
one alphabets are considered for discussion, then
• subscripts may be used (e.g. etc) or sometimes other symbol like G may also be introduced.
Department of Computer science and Engineering CSB4302 - Theory of Computation
Strings
• Strings or Words over Alphabet :
A String is a finite sequence of symbols over ∑.
Department of Computer science and Engineering CSB4302 - Theory of Computation
Example : 0110, 11, 001 are three strings over the binary alphabet { 0, 1 } .
aab, abcb, b, cc are four strings over the alphabet { a, b, c }.
It is not the case that a string over some alphabet should contain all the symbols from the alpha- bet. For example, the string cc over the
alphabet { a, b, c } does not contain the symbols a and b. Hence, it is true that a string over an alphabet is also a string over any superset of
that alphabet.
Length of a string :
The number of symbols in a string w is called its length, denoted by |w|.
Example : | 011 | = 3, |11| = 2, | b | = 1
Operation on Strings
Consider the string 011 over the binary alphabet. All the prefixes, suffixes and substrings of this string are listed below.
• Prefixes: ε, 0, 01, 011.
A string obtained by deleting one more symbols from trailing end.
• Suffixes: ε, 1, 11, 011.
A string obtained by deleting one more symbols from leading end.
• Substrings: ε, 0, 1, 01, 11, 011.
A string obtained by deleting one or more symbols from leading or trailing end or both.
• Note that x is a prefix (suffix or substring) to x, for any string x and ε is a prefix (suffix or substring) to any string.
• A string x is a proper prefix (suffix) of string y if x is a prefix (suffix) of y and x ≠ y. In the above example, all
prefixes except 011 are proper prefixes.
Department of Computer science and Engineering CSB4302 - Theory of Computation
Powers of alphabets
Department of Computer science and Engineering CSB4302 - Theory of Computation
• Powers of Alphabets :
We write ∑k (for some integer k) to denote the set of strings of length k with symbols from ∑. In other words,
• ∑k = { w | w is a string over ∑ and | w | = k}. Hence, for any alphabet, denotes the set of all strings of length zero. That is, ∑0 = { e }. For the binary alphabet { 0, 1 } we have
the following.
Example for powers of alphabet
Department of Computer science and Engineering CSB4302 - Theory of Computation
Example : If = { a, b }, then = { ε, a, b, aa, ab, ba, bb, aaa, aab, aba, abb, baa, …}.
Please note that if , then that is . It may look odd that one can proceed from the empty set
to a non-empty set by iterated concatenation. But there is a reason for this and we accept this convention
The set of all nonempty strings over an alphabet is denoted by . That is,
Languages
Department of Computer science and Engineering CSB4302 - Theory of Computation
Languages :
1. A language over an alphabet ∑ is a set of strings over that alphabet .
2. A language L is any subset of ∑ * .
3. A contain any string but {e} contains one string of length zero.
Some Examples
1. The set of all strings over { 0, 1 } containing equal number of 0's and 1's.
2. The set of all strings over {a, b, c} that starts with a.
Operations Over Languages
• In this section, we define three operations on languages. Later, we will answer the question whether
the set of all regular languages is closed under these operations. Let A and B be two languages over
the same alphabet.
1.The union of A and B is defined as
• A ∪ B = {w : w ∈ A or w ∈B}.
2.The concatenation of A and B is defined as
• AB = {ww′
: w ∈ A and w′ ∈ B}.
In words, AB is the set of all strings obtained by taking an arbitrary string w in A and an arbitrary
string w′ in B, and gluing them together (such that w is to the left of w′).
Department of Computer science and Engineering CSB4302 - Theory of Computation
Operations Over Languages
3.The star of A is defined as
A∗
= {u1u2 . . . uk : k ≥ 0 and ui ∈ A for all i = 1, 2, . . . , k}.
• In words, A∗ is obtained by taking any finite number of strings in A, and gluing them together. Observe that k =
0 is allowed; this corresponds to the empty string ǫ. Thus, ǫ∈ A∗.
• To give an example, let A = {0, 01} and B = {1, 10}. Then
• A ∪ B = {0, 01, 1, 10},
• AB = {01, 010, 011, 0110},
and
• A∗
= {ǫ, 0, 01, 00, 001, 010, 0101, 000, 0001, 00101, . . .}.
• As another example, if Σ = {0, 1}, then Σ∗ is the set of all binary strings (including the empty string). Observe that
a string always has a finite length.
• Before we proceed, we give an alternative (and equivalent) definition of the star of the language A: Define
• A0
= {ǫ}
Department of Computer science and Engineering CSB4302 - Theory of Computation
Thank You
Department of Computer science and Engineering CSB4302 - Theory of Computation

01 alphabets strings and languages

  • 1.
    CSB4301 – Theoryof Computation B.Tech – IVth Semester Mr. D.S.John Deva Prasanna AP(SG) & Mr.Vasanthraj Department of Computer Science and Engineering
  • 2.
    Languages Strings andAlphabets Languages : • The languages we consider for our discussion is an abstraction of natural languages. That is, our focus here is on formal languages that need precise and formal definitions. Programming languages belong to this category. Symbols : • Symbols are indivisible objects or entity that cannot be defined. That is, symbols are the atoms of the world of languages. A symbol is any single object such as , a, 0, 1, #, begin, or do. Alphabets : • An alphabet is a finite, nonempty set of symbols. The alphabet of a language is normally denoted by . When more than one alphabets are considered for discussion, then • subscripts may be used (e.g. etc) or sometimes other symbol like G may also be introduced. Department of Computer science and Engineering CSB4302 - Theory of Computation
  • 3.
    Strings • Strings orWords over Alphabet : A String is a finite sequence of symbols over ∑. Department of Computer science and Engineering CSB4302 - Theory of Computation Example : 0110, 11, 001 are three strings over the binary alphabet { 0, 1 } . aab, abcb, b, cc are four strings over the alphabet { a, b, c }. It is not the case that a string over some alphabet should contain all the symbols from the alpha- bet. For example, the string cc over the alphabet { a, b, c } does not contain the symbols a and b. Hence, it is true that a string over an alphabet is also a string over any superset of that alphabet. Length of a string : The number of symbols in a string w is called its length, denoted by |w|. Example : | 011 | = 3, |11| = 2, | b | = 1
  • 4.
    Operation on Strings Considerthe string 011 over the binary alphabet. All the prefixes, suffixes and substrings of this string are listed below. • Prefixes: ε, 0, 01, 011. A string obtained by deleting one more symbols from trailing end. • Suffixes: ε, 1, 11, 011. A string obtained by deleting one more symbols from leading end. • Substrings: ε, 0, 1, 01, 11, 011. A string obtained by deleting one or more symbols from leading or trailing end or both. • Note that x is a prefix (suffix or substring) to x, for any string x and ε is a prefix (suffix or substring) to any string. • A string x is a proper prefix (suffix) of string y if x is a prefix (suffix) of y and x ≠ y. In the above example, all prefixes except 011 are proper prefixes. Department of Computer science and Engineering CSB4302 - Theory of Computation
  • 5.
    Powers of alphabets Departmentof Computer science and Engineering CSB4302 - Theory of Computation • Powers of Alphabets : We write ∑k (for some integer k) to denote the set of strings of length k with symbols from ∑. In other words, • ∑k = { w | w is a string over ∑ and | w | = k}. Hence, for any alphabet, denotes the set of all strings of length zero. That is, ∑0 = { e }. For the binary alphabet { 0, 1 } we have the following.
  • 6.
    Example for powersof alphabet Department of Computer science and Engineering CSB4302 - Theory of Computation Example : If = { a, b }, then = { ε, a, b, aa, ab, ba, bb, aaa, aab, aba, abb, baa, …}. Please note that if , then that is . It may look odd that one can proceed from the empty set to a non-empty set by iterated concatenation. But there is a reason for this and we accept this convention The set of all nonempty strings over an alphabet is denoted by . That is,
  • 7.
    Languages Department of Computerscience and Engineering CSB4302 - Theory of Computation Languages : 1. A language over an alphabet ∑ is a set of strings over that alphabet . 2. A language L is any subset of ∑ * . 3. A contain any string but {e} contains one string of length zero. Some Examples 1. The set of all strings over { 0, 1 } containing equal number of 0's and 1's. 2. The set of all strings over {a, b, c} that starts with a.
  • 8.
    Operations Over Languages •In this section, we define three operations on languages. Later, we will answer the question whether the set of all regular languages is closed under these operations. Let A and B be two languages over the same alphabet. 1.The union of A and B is defined as • A ∪ B = {w : w ∈ A or w ∈B}. 2.The concatenation of A and B is defined as • AB = {ww′ : w ∈ A and w′ ∈ B}. In words, AB is the set of all strings obtained by taking an arbitrary string w in A and an arbitrary string w′ in B, and gluing them together (such that w is to the left of w′). Department of Computer science and Engineering CSB4302 - Theory of Computation
  • 9.
    Operations Over Languages 3.Thestar of A is defined as A∗ = {u1u2 . . . uk : k ≥ 0 and ui ∈ A for all i = 1, 2, . . . , k}. • In words, A∗ is obtained by taking any finite number of strings in A, and gluing them together. Observe that k = 0 is allowed; this corresponds to the empty string ǫ. Thus, ǫ∈ A∗. • To give an example, let A = {0, 01} and B = {1, 10}. Then • A ∪ B = {0, 01, 1, 10}, • AB = {01, 010, 011, 0110}, and • A∗ = {ǫ, 0, 01, 00, 001, 010, 0101, 000, 0001, 00101, . . .}. • As another example, if Σ = {0, 1}, then Σ∗ is the set of all binary strings (including the empty string). Observe that a string always has a finite length. • Before we proceed, we give an alternative (and equivalent) definition of the star of the language A: Define • A0 = {ǫ} Department of Computer science and Engineering CSB4302 - Theory of Computation
  • 10.
    Thank You Department ofComputer science and Engineering CSB4302 - Theory of Computation