100 likes | 226 Views
Alphabet and Strings. Topics. Strings over alphabet Language Generation Example Languages Language Generation by Concatenation Example Grammars From Grammar to Language. We first add to * .
E N D
Alphabet and Strings Topics • Strings over alphabet • Language Generation • Example Languages • Language Generation by Concatenation • Example Grammars • From Grammar to Language
We first add to *. Then successively add strings of length 1, 2, 3, … , m, … and so on. We represent this process by the mathematical expression: * = 01 … m … which can be written as m Strings Over Alphabet Let be a non-empty set of symbols, called alphabet. A string is a finite sequences of symbols taken from . The set of all strings over is denoted by *. The null string is denoted by . Inductive Constructing of
Def: A language overis a subset of*. Language Generation * is a countable (infinite) set. Let = {0, 1}, construct *. * = {, row # 1 0, 1row # 2 00, 01, 10, 11, row # 3 000, 001, 010, 011, 100, 101, 110, 111 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111 … … } With exception of the first row, elements in the current row are obtained by right-appending 0 and 1 respectively to each element in the previous row. Some of the languages over {0, 1} are: a language with no words in it! {}a language with one word in it, which can be neither written or pronounced!
Combining Languages Since languages are sets of strings, they can be combined by using operations of , , (set-theoretic difference), compliment, and other set operations. We can also produce a new language by concatenating strings from two other languages. A language obtained like this is called the concatenation of the two languages. If L and M are two languages over alphabets A and B respectively, then LM = {ab : a L and b M}, with C = A B as its alphabet. Example Languages {1, 11, 101, 111, 1001, …} all odd binary integers {0, 10, 100, 110, 1000, …} all even binary integers {0000, 0011, 0101, 0110, 1001, 1010, 1100, 1111} all 4-bit binary integers with even parity. A set of binary integers of a given length is said to have an even parity if it contains even number of 1’s.
Language Generation by Concatenation: Examples A = {a, b, c} the alphabet for languages L and M. L = {ab, ac} and M = {a, bc, abc}, find (i) LM (ii)ML Solution: (i) LM = {aba, abbc, ababc, aca, acbc, acabc} (ii) ML = {aab, aac, bcab, bcac, abcab, abcac} Exercise: Find the value of L that satisfies the equation. {, a, ab}L = {b, ab, ba, aba, abb, abba} L = {b, ab}satisfies the equation.
Example Grammars Grammars Language Grammar to generate it S aS S {ai : i 0} {b2j+1 : j 0} S bbS S b
Example Grammars – Continued … Language Grammar S aSc S b {ajbcj : j 0} S aBc B bB B {abjc : j 0}
S aSA A b 3 1 B c S aB 4 2 If you start with production then the only choice you have is to use to obtain the string ac, which is the smallest word in this language. 2 4 S aaaaacbbbb From Grammar to Language Example 3: Let T = {a, b, c}, V = {S, A, B} and let the productions be S aSA aaSAA aB aaBA aaaBAA ac aacA aaacAA aacb aaacbb
Even and Odd Parities A set of binary integers of a given length is said to have an even parity if it contains even number of 1s. A set of binary integers of a given length is said to have an odd parity if it contains odd number of 1s.
Definition of Grammar A grammar G is defined as a quadruple ( four things) G = (V, T, S, P), where V is a finite set of variable (also called non-terminals), T is a finite set of terminalsymbols, S V is a special symbol called the start symbol, P is a set of productions. The sets V and T are non-empty and V T = Φ. That is, V and T have no elements in common. Go Back