MCS-212 · Block 2 Unit 2

Automata and Languages

Section 1 of 8

Block 2 · Unit 2Automata and Languages9 min · Section 1 of 8

2.1Alphabets, strings and languages

Covers IGNOU MCS-212 §2.2.1

Before a machine can read text we must say exactly which symbols it may see and which sequences of symbols count as “words”. Formal languages give us this precise vocabulary. It is the same vocabulary used in compilers, network protocols and data validation.

Examples of languages over Σ={z}\Sigma = \{z\}

LanguageDescriptionContains λ\lambda?
L1={zn∣n≥1}={z,zz,zzz,… }L_1 = \{z^n \mid n \geq 1\} = \{z, zz, zzz, \dots\}at least one zzno
L2={z2n+1∣n≥0}={z,zzz,… }L_2 = \{z^{2n+1} \mid n \geq 0\} = \{z, zzz, \dots\}odd lengthno
L3={z2n∣n≥0}={λ,zz,zzzz,… }L_3 = \{z^{2n} \mid n \geq 0\} = \{\lambda, zz, zzzz, \dots\}even lengthyes
L4={zp∣p prime}L_4 = \{z^p \mid p \text{ prime}\}prime lengthno

Here znz^n means zz written nn times. Even a one-letter alphabet has infinitely many different languages.

Operations on strings

For u=abu = ab and v=baav = baa: uv=abbaauv = abbaa and vu=baaabvu = baaab. So concatenation is usually not commutative (although zmzn=znzm=zm+nz^m z^n = z^n z^m = z^{m+n} over a one-letter alphabet).

A language need not be closed under concatenation: in L2L_2 (odd lengths), zzz⋅zzzzz=z8zzz \cdot zzzzz = z^8 has even length, so it is not in L2L_2. In L1L_1 and L3L_3, the concatenation of two words is again a word of the language.

Key takeaways

  • Alphabet: finite set of symbols; string: finite sequence of symbols; language: set of strings.
  • λ\lambda (IGNOU: ∧\wedge) is the null string, of length 0.
  • ∣uv∣=∣u∣+∣v∣|uv| = |u| + |v|; concatenation is not commutative in general.
  • A language may or may not be closed under concatenation.

Practice questions

Answer on paper first, then check. The explanation matters more than the letter you chose.

Question 1 · multiple choice

Which of the following is a language over Σ={0,1}\Sigma = \{0, 1\}?

Show answer

Answer: B. {λ,01,0011}\{\lambda, 01, 0011\}

A language is a set of strings over Σ\Sigma; all three strings use only 0 and 1. Option 4 is a single string, not a set of strings.

Question 2 · multiple choice

If u=abbu = abb and v=bav = ba, what is vuvu?

Show answer

Answer: B. baabbbaabb

vuvu is vv followed by uu: ba⋅abb=baabbba \cdot abb = baabb. Option 1 is uvuv.

Question 3 · multiple choice

What is the length of λ⋅ab⋅λ⋅c\lambda \cdot ab \cdot \lambda \cdot c?

Show answer

Answer: C. 3

λ\lambda has length 0, so the string is abcabc of length 3. Option 1 counts each λ\lambda as one symbol.

Question 4 · multiple choice

Which language over {z}\{z\} is NOT closed under concatenation?

Show answer

Answer: D. {z2n+1∣n≥0}\{z^{2n+1} \mid n \geq 0\}

odd + odd = even, so z⋅z=zzz \cdot z = zz leaves the language. Option 2 is closed: even + even is even.

Question 5 · multiple choice

Which string over {a,b}\{a, b\} is a palindrome?

Show answer

Answer: A. abbaabbaabbaabba

Reading abbaabbaabbaabba backwards gives the same string. abababab reversed is babababa.

Question 6 · short answer

Over Σ={a,b}\Sigma = \{a, b\}, list all strings of length 2, and say how many strings of length nn there are.

Show worked answer

Length 2: aa,ab,ba,bbaa, ab, ba, bb — 4 strings. For each of the nn positions there are 2 choices of letter, so there are 2n2^n strings of length nn (in general ∣Σ∣n|\Sigma|^n).

↑ ↓ move↵ openTab switch type