0% found this document useful (0 votes)
10 views7 pages

Alphabets, Strings and Languages Languages:: Example

The document provides a comprehensive overview of formal languages, including definitions of symbols, alphabets, strings, and various operations on strings and languages. It discusses concepts such as concatenation, reversal, and the Kleene star operation, along with examples to illustrate these ideas. Additionally, it presents problems related to the discussed concepts for further understanding and application.

Uploaded by

yashkol44
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)
10 views7 pages

Alphabets, Strings and Languages Languages:: Example

The document provides a comprehensive overview of formal languages, including definitions of symbols, alphabets, strings, and various operations on strings and languages. It discusses concepts such as concatenation, reversal, and the Kleene star operation, along with examples to illustrate these ideas. Additionally, it presents problems related to the discussed concepts for further understanding and application.

Uploaded by

yashkol44
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/ 7

mywbut.

com

Introduction
Alphabets, Strings and Languages

Languages:

A general definition of language must cover a variety of distinct categories: natural languages,
programming languages, mathematical languages, etc. The notion of natural languages like
English, Hindi, etc. is familiar to us. Informally, language can be defined as a system suitable for
expression of certain ideas, facts, or concepts, which includes a set of symbols and rules to
manipulate these. 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. We start with some basic concepts
and definitions required in this regard.

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.
Usually, characters from a typical keyboard are only used as symbols.

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.

Example:

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 }.

1
mywbut.com

It is not the case that a string over some alphabet should contain all the symbols from the
alphabet. 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|.

Convention: We will use small case letters towards the beginning of the English alphabet to
denote symbols of an alphabet and small case letters towards the end to denote strings over an
alphabet. That is, (symbols) and are strings.

Some String Operations:


Let and be two strings. The concatenation of x and y
denoted by xy, is the string . That is, the concatenation of x and y
denoted by xy is the string that has a copy of x followed by a copy of y without any intervening
space between them.

Example: Concatenation of the strings 0110 and 11 is 011011 and concatenation of the strings
good and boy is goodboy.

Note that for any string w, we = ew = w. It is also obvious that if | x | = n and | y | = m, then | x +
y | = n + m.

Example: Consider the string 011 over the binary alphabet. All the prefixes, suffixes and
substrings of this string are listed below.

Prefixes: e, 0, 01, 011.


Suffixes: e, 1, 11, 011.
Substrings: e, 0, 1, 01, 11, 011.

Powers of Strings: For any string x and integer , we use to denote the string formed
by sequentially concatenating n copies of x. We can also give an inductive definition of as
follows:

The set of all strings over an alphabet is denoted by . That is,

2
mywbut.com

The set contains all the strings that can be generated by iteratively concatenating symbols
from any number of times.

Example: If = { a, b }, then = { e, a, b, aa, ab, ba, bb, aaa, aab, aba, abb, baa, …}.

The set of all nonempty strings over an alphabet is denoted by . That is,

Note that is infinite. It contains no infinite strings but strings of arbitrary lengths.

Reversal:
For any string the reversal of the string is .

An inductive definition of reversal can be given as follows:

Languages:
A language over an alphabet is a set of strings over that alphabet. Therefore, a language L is any subset
of . That is, any is a language.

Example :

1. F is the empty language.


2. is a language for any .
3. {e} is a language for any . Note that, . Because the language F does not
contain any string but {e} contains one string of length zero.
4. The set of all strings over { 0, 1 } containing equal number of 0's and 1's.
5. The set of all strings over {a, b, c} that starts with a.

Convention: Capital letters A, B, C, L, etc. with or without subscripts are normally used to
denote languages.

3
mywbut.com

Set operations on languages: Since languages are set of strings we can apply set
operations to languages. Here are some simple examples (though there is nothing new in it).

Union: A string iff or

Example: { 0, 11, 01, 011 } { 1, 01, 110 } = { 0, 11, 01, 011, 111 }

Intersection: A string iff and .

Example: { 0, 11, 01, 011 } { 1, 01, 110 } = { 01 }

Complement: Usually, is the universe that a complement is taken with respect to. Thus for a
language L, the complement is L(bar) = { | }.

Example: Let L = { x | |x| is even }. Then its complement is the language { | |x| is odd }.
Similarly we can define other usual set operations on languages like relative complement,
symmetric difference, etc.

Reversal of a language:
The reversal of a language L, denoted as , is defined as: .

Let L = { 0, 11, 01, 011 }. Then = { 0, 11, 10, 110 }.

• Let L = { | n is an integer }. Then = { | n is an integer }.

Language concatenation: The concatenation of languages and is defined as


= { xy | and }.

Note that ,
1. in general.
2.
3.

Iterated concatenation of languages: Since we can concatenate two languages, we also repeat
this to concatenate any number of languages. Or we can concatenate a language with itself any

4
mywbut.com

number of times. The operation denotes the concatenation of L with itself n times. This is
defined formally as follows:

Example: Let L = { a, ab }. Then according to the definition, we have

and so on.

Kleene's Star operation: The Kleene star operation on a language L, denoted as is


defined as follows:

= ( Union n in N )

= { x | x is the concatenation of zero or more strings from L }

Thus is the set of all strings derivable by any number of concatenations of strings in L. It is
also useful to define

= , i.e., all strings derivable by one or more concatenations of strings in L. That is

= (Union n in N and n >0)


=

Example: Let L = { a, ab }. Then we have,

= {e} {a, ab} {aa, aab, aba, abab} …

= {a, ab} {aa, aab, aba, abab} …

5
mywbut.com

Note : e is in , for every language L, including .

The previously introduced definition of is an instance of Kleene star.

Problems

1. Prove that (xy)R = yRxR , x, y

2. Show that | x k | = k |x| , x, y and n 0

3. Consider the language L={ 01, 11, 011}. Which of the following strings are in L*

010101, 0001, 110, 010111101, 0111111110, 11010111111101, 110111110011, 11101101?

4. Let L1={ 00,11} and L2={ Î, 0, 01 }

a) List the strings in the set L1L2.

b) List the strings of the set L2* of length three or less.

c) How many strings of length 5 are there in L1*?

5. Let L1={ aa }*, L2={ a, b } { a, b }{ a, b } , and L3= L2*. Describe the string that are in the
language L2, L3, and L1 L3

6. For the langauge L define

NL={ |x| | x L }, SL={ x L|"y L, |x| |y| }

Prove that the following for every language L.


a) L= iff NL=
b) L= f iff S L=
c) S L*= { }
d) S L+= S L

7. Let be an alphabet. Prove that the relation { (x, y) | x is a prefix of y } is a partial ordering
of .

8. Prove that following for language L, L1, L2.

a) L+=L*-{ } iff L.

6
mywbut.com

b) If L1 L2 then L1 L2 L1L2

You might also like