CSC262 Ā· 2080 Ā· 5 marks
Define string, substring, empty string, and empty language over alphabet {a,b}.
Define string, substring, empty string, and empty language over alphabet {a,b}. [5]
Quick answer
A string (also called a word) is a finite sequence of symbols taken from an alphabet.
String, Substring, Empty String, and Empty Language over {a, b}
1. String
Over the alphabet Σ = {a, b}, a string is any finite arrangement of the symbols a and b.
Examples over {a, b}:
ababaabbbaabab
Formally, if Σ = {a, b}, then Σ* (Kleene closure) gives the set of all possible strings over {a, b}, including the empty string:
Σ* = {ε, a, b, aa, ab, ba, bb, aaa, aab, ...}
2. Substring
A string v is called a substring of string w if v appears as a contiguous sequence of symbols within w (obtained by removing zero or more leading symbols and zero or more trailing symbols from w).
Example over {a, b}:
Let w = abab
Substrings of w include:
a,b,ab,ba,aba,bab,abab,ε
Note: Every string is a substring of itself, and the empty string ε is a substring of every string.
3. Empty String
The empty string (denoted ε or sometimes λ) is a string that contains no symbols at all. Its length is 0.
Key properties of ε over {a, b}:
| Property | Result |
|---|---|
| Length of ε | |ε| = 0 |
| Concatenation with any string x | ε x = x ε = x |
| ε belongs to | Σ* for any alphabet Σ |
Example:
If x =
ab, then ε · x =aband x · ε =ab
The empty string acts as the identity element for string concatenation.
4. Empty Language
A language over an alphabet Σ is a set of strings, i.e., a subset of Σ*.
The empty language (denoted ā ) is a language that contains no strings at all.
Over {a, b}:
ā = { } (a set with no members)
Important distinction:
| Concept | Notation | Contains |
|---|---|---|
| Empty string | ε | A string of length 0 |
| Empty language | ā | No strings whatsoever |
| Language with only empty string | {ε} | Exactly one string (ε) |
Note: ā ā {ε}. The empty language has no strings, whereas {ε} is a language containing one string (the empty string).
The empty language ā is a valid language over any alphabet, including {a, b}.
Summary Table
| Term | Definition | Example over {a,b} |
|---|---|---|
| String | Finite sequence of symbols from Σ | ab, bba, aab |
| Substring | Contiguous part of a string | ab is substring of aab |
| Empty String (ε) | String with no symbols, length = 0 | ε |
| Empty Language (ā ) | Language containing no strings | ā = { } |
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.