Strings and languages
Hopcroft 2e, §1.5 — the vocabulary the rest of the subject is written in.
Alphabet
An alphabet Σ is a finite, non-empty set of symbols. Σ = {0, 1} is the binary alphabet; Σ = {a, b, c} is another. A symbol is atomic — it has no parts.
String
A string over Σ is a finite sequence of symbols from Σ. Its length |w| is how many symbols it has, counting repeats: |0110| = 4.
The empty string ε is the string of length zero. It is a string like any other — it is not "nothing", and it is not the same as the empty set. Half the marks lost on this topic come from that one confusion.
Powers of an alphabet
Σk is the set of strings of length exactly k. So Σ1 is essentially Σ itself, Σ2 is every pair, and:
Σ0 = {ε}
One element, not zero — whatever the alphabet is, there is exactly one string of length 0 over it.
Σ* and Σ⁺
Σ* is the set of all strings over Σ: Σ0 ∪ Σ1 ∪ Σ2 ∪ … It is infinite for any non-empty alphabet, though every string in it is finite. Σ⁺ is the same set without ε.
A language over Σ is any subset of Σ*. That is the whole definition — which is why "is this language regular?" is a question worth a whole module.
Try it
Change the alphabet and the bound. Watch the count, not just the list.
15 strings of length at most 3 over an alphabet of 2 symbols. |Σ≤k| = 1 + |Σ| + |Σ|² + … + |Σ|k
- ε
- 0
- 1
- 00
- 01
- 10
- 11
- 000
- 001
- 010
- 011
- 100
- 101
- 110
- 111
Concatenation
If x and y are strings, xy is x followed by y, and |xy| = |x| + |y|. Concatenation is associative, and ε is its identity: εw = wε = w.
The same thing, spelled differently
The question papers and the textbook do not always agree on names. These all mean the same thing, and this tool accepts either spelling.
| Textbook | Also written |
|---|---|
| DFA — deterministic finite automaton | DFSM, deterministic finite state machine, deterministic finite acceptor, FSA |
| NFA — nondeterministic finite automaton | NDFSM, NDFA, nondeterministic finite state machine, non-deterministic finite automaton |
| ε-NFA — nondeterministic finite automaton with ε-transitions | epsilon-NFA, e-NFA, NFA with epsilon moves, ε-NDFSM |
| PDA — pushdown automaton | NPDA, nondeterministic pushdown automaton, push-down automaton |
| DPDA — deterministic pushdown automaton | deterministic PDA, deterministic push-down automaton |
| ID — instantaneous description | instantaneous description, configuration |
| TM — Turing machine | Turing Machine, DTM, deterministic Turing machine |
| CFG — context-free grammar | context free grammar, CFL grammar |
| CNF — Chomsky normal form | Chomsky Normal Form, chomsky normal form |
| GNF — Greibach normal form | Greibach Normal Form |
| regular expression — regular expression | RE, regex, regexp |