UNIT 3
Context-sensitive languages
A string is any combination of the letters of an alphabet whereas the words of a language are the strings that are always made according to certain rules used to define that language.For example if we take
Alphabet Σ = { a , b } Here a , b are the letters of this alphabet.
As you can see we can make a lot of strings from these letters a and b.
For example a,b,aa,ab,ba,bb,aaa,aab,aba,baa,…………………… and so on.
But when we define a language over this alphabet having no a’s and only odd number ofb’s. Then the words of this language would have only those strings that have only odd number of b’s and no a’s.some example words of our defined language are b , bbb , bbbbb , bbbbbbb ,……………………………..and so on.
So we can say that all the words are strings but all the strings may not be the words of a language. Hence strings are any combination of letters of an alphabet and the words of a language are strings made according to some rule.
2. What Is The Difference Between An Alphabet And An Element Of A Set. Whether Alphabet Is An Element Of A Set Or It Is A Set Itself?
An Alphabet is a set in itself. The elements of an Alphabet are called letters.
For example
Binary Alphabet Σ = {0,1}
Here 0,1 are the letters of binary alphabet.
Binary Alphabet is very important because it the Alphabet used by the computer.
Set of Natural Numbers
N={1,2,3,4,5,…………………………………..}
Here 1,2,3……………………………………. are the elements of set of Natural Numbers.
3. What Is Null String (Λ) ?
The string with zero occurrences of symbols (letters) from ∑.
It is 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.
4. What Is The Concept Of Valid And Invalid Alphabets ?
While defining an alphabet of letters consisting of more than one symbols, no letter should be started with any other the letter of the same alphabet i.e. one letter should not be the prefix of another. However, a letter may be ended in the letter of same alphabet i.e. one letter may be the suffix of another.
Σ= { a , b } ( Valid Alphabet)
Σ= { a , b , cd } ( Valid Alphabet)
Σ= { a , b , ac } ( Invalid Alphabet)
5. What Is Algol ?
ALGOL (ALGOrithmic Language) is one of several high level languages designed specifically for programming scientific computations. It started out in the late 1950’s, first formalized in a report titled ALGOL 58, and then progressed through reports ALGOL 60, and ALGOL 68. It was designed by an international committee to be a universal language. Their original conference, which took place in Zurich, was one of the first formal attempts to address the issue of software portability. ALGOL’s machine independence permitted the designers to be more creative, but it made implementation much more difficult. Although ALGOL never reached the level of commercial popularity of FORTRAN and COBOL, it is considered the most important language of its era in terms of its influence on later language development.
ALGOL’s lexical and syntactic structures became so popular that virtually all languages designed since have been referred to as “ALGOL – like”; that is they have been hierarchical in structure with nesting of both environments and control structures.
6. What Is Non-determinism And Determinism And What Is The Difference Between Them ?
Determinism means that our computational model (machine) knows what to do for every possible inputs. Non determinism our machine may or may not know what it has to do on all possible inputs.
As you can conclude from above definition that Non-Deterministic machine can not be implemented ( used ) on computer unless it is converted in Deterministic machine.
7. Find the language generated by :S->0S1 | 0A | 0 |1B | 1
A->0A | 0 , B->1B | 1
The minimum string is S-> 0 | 1
S->0S1=>001
S->0S1=>011
S->0S1=>00S11=>000S111=>0000A111=>00000111
Thus L={ 0n 1 m | m not equal to n, and n,m >=1}
8. What Is The Difference Between Palindrome And Reverse Function?
It is to be denoted that the words of PALINDROME are called palindromes.
Reverse = w
Example: Σ={a,b},
PALINDROME={Λ , a, b, aa, bb, aaa, aba, bab, bbb, …}
If a is a word in some language L, then reverse (a) is the same string of letters spelled backwards, called the reverse of a.
e.g
reverse (xxx) = xxx
reverse (623) = 326
reverse (140) = 041
9. Find CFG with no useless symbols equivalent to : S→AB | CA , B→BC | AB, A→a , C→aB | b.
S-> AB S->CA B->BC B->AB A->a
C->aB
C->b are the given productions.
* *
A symbol X is useful if S => αXβ => w
The variable B cannot generate terminals as B->BC and B->AB. Hence B is useless symbol and remove B from all productions.
Hence useful productions are: S->CA , A->a , C->b
10. Construct CFG without Є production from : S →a | Ab | aBa , A →b | Є , B →b | A.
S->a |
| ||
S->Ab |
| ||
S->aBa |
| ||
A->b | A->Є | B->b | B->A are the given set of production. |
A->Є is the only empty production. Remove the empty production
S-> Ab , Put A-> Є and hence S-> b.
If B-> A and A->Є then B ->Є Hence S->aBa becomes S->aa . Thus S-> a | Ab | b | aBa | aa
A->b
B->b
Finally the productions are: S-> a | Ab | b | aBa | aa
A->b
B->b