A Formal Language as a Set of Strings
A formal language is a set of finite strings over a chosen alphabet. It can include the empty string, regardless of whether longer strings are present.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a small membership rule
Over symbols 0 and 1, strings ending in one include 1 and 101 and exclude 10. The empty string has no final symbol and is also excluded. See sets described by rules.
Keep alphabet and language separate
An alphabet of two symbols permits arbitrarily many finite strings. The language selects a subset of those strings. Counting finite-length strings shows the effect of selecting only one length.[1]
Inspect an accepting word and two near misses
Define a language over alphabet \(\{a,b\}\) containing exactly words that start with a and end with b. Word ab belongs, ba fails the first condition, and aa fails the second. Internal letters are unrestricted. See universal and existential conditions.
ab → accept
aabb → accept
ba → reject
aa → reject
Empty word fails this start-and-end rule
Keep alphabet and language separate
Alphabet symbols are available to construct candidate words. A language selects some of those words. A string containing another symbol is outside the announced alphabet and needs its own interpretation at an implementation boundary.