Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Formal language
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Examples== The following rules describe a formal language {{mvar|L}} over the alphabet Ξ£ = {0,β1,β2,β3,β4,β5,β6,β7,β8,β9,β+,β=}: * Every nonempty string that does not contain "+" or "=" and does not start with "0" is in {{mvar|L}}. * The string "0" is in {{mvar|L}}. * A string containing "=" is in {{mvar|L}} if and only if there is exactly one "=", and it separates two valid strings of {{mvar|L}}. * A string containing "+" but not "=" is in {{mvar|L}} if and only if every "+" in the string separates two valid strings of {{mvar|L}}. * No string is in {{mvar|L}} other than those implied by the previous rules. Under these rules, the string "23+4=555" is in {{mvar|L}}, but the string "=234=+" is not. This formal language expresses [[natural number]]s, well-formed additions, and well-formed addition equalities, but it expresses only what they look like (their [[syntax]]), not what they mean ([[semantics]]). For instance, nowhere in these rules is there any indication that "0" means the number zero, "+" means addition, "23+4=555" is false, etc. === Constructions ===<!-- [[empty language]] redirects here --> For finite languages, one can explicitly enumerate all well-formed words. For example, we can describe a language {{mvar|L}} as just {{mvar|L}} = {a,βb,βab,βcba}. The [[degeneracy (mathematics)|degenerate]] case of this construction is the '''empty language''', which contains no words at all (<span class="nounderlines">{{mvar|L}} = [[β ]]</span>). However, even over a finite (non-empty) alphabet such as Ξ£ = {a, b} there are an infinite number of finite-length words that can potentially be expressed: "a", "abb", "ababba", "aaababbbbaab", .... Therefore, formal languages are typically infinite, and describing an infinite formal language is not as simple as writing ''L'' = {a,βb,βab,βcba}. Here are some examples of formal languages: * {{mvar|L}} = Ξ£<sup>*</sup>, the set of ''all'' words over Ξ£; * {{mvar|L}} = {a}<sup>*</sup> = {a<sup>''n''</sup>}, where ''n'' ranges over the natural numbers and "a<sup>''n''</sup>" means "a" repeated ''n'' times (this is the set of words consisting only of the symbol "a"); * the set of syntactically correct programs in a given programming language (the syntax of which is usually defined by a [[context-free grammar]]); * the set of inputs upon which a certain [[Turing machine]] halts; or * the set of maximal strings of [[alphanumeric]] [[ASCII]] characters on this line, i.e.,<br> the set {the, set, of, maximal, strings, alphanumeric, ASCII, characters, on, this, line, i, e}.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)