Recursive language: Difference between revisions
No edit summary |
Change parenthetical references. |
||
(148 intermediate revisions by more than 100 users not shown) | |||
Line 1: | Line 1: | ||
{{About|a class of formal languages as they are studied in mathematics and theoretical computer science|computer languages that allow a function to call itself recursively |Recursion (computer science)}} |
|||
I'm guessing you mean h4ck0r? |
|||
In [[mathematics]], [[logic]] and [[computer science]], a [[formal language]] (a [[set (mathematics)|set]] of finite sequences of [[symbol (formal)|symbol]]s taken from a fixed [[alphabet (computer science)|alphabet]]) is called '''recursive''' if it is a [[recursive set|recursive subset]] of the set of all possible finite sequences over the alphabet of the language. Equivalently, a formal language is recursive if there exists a Turing machine that, when given a finite sequence of symbols as input, always halts and accepts it if it belongs to the language and halts and rejects it otherwise. In [[Theoretical computer science]], such always-halting Turing machines are called [[total Turing machine]]s or '''algorithms'''.{{sfnp|Sipser|1997}} Recursive languages are also called '''decidable'''. |
|||
:) |
|||
The concept of '''decidability''' may be extended to other [[models of computation]]. For example, one may speak of languages decidable on a [[non-deterministic Turing machine]]. Therefore, whenever an ambiguity is possible, the synonym used for "recursive language" is '''Turing-decidable language''', rather than simply ''decidable''. |
|||
#1 |
|||
The class of all recursive languages is often called '''[[R (complexity)|R]]''', although this name is also used for the class [[RP (complexity)|RP]]. |
|||
I need to go just as bad as you. |
|||
What I had this morning |
|||
I don’t even wanna say to you. |
|||
Kick! Punch! Turn and chop the door |
|||
Or, I will fall to the floor. |
|||
Kick! Punch! Turn and chop the door |
|||
Or, I will fall to the floor. |
|||
This type of language was not defined in the [[Chomsky hierarchy]].{{sfnp|Chomsky|1959}} All recursive languages are also [[recursively enumerable language|recursively enumerable]]. All [[regular language|regular]], [[context-free language|context-free]] and [[context-sensitive language|context-sensitive]] languages are recursive. |
|||
Hatatatatatatatatah! |
|||
== Definitions == |
|||
#2 |
|||
There are two equivalent major definitions for the concept of a recursive language: |
|||
U, uh, u, uh |
|||
No way! |
|||
I’ve been sitting in my car |
|||
Yes, now for days. |
|||
Did you check the toilets on the right? |
|||
Did you check the toilets on the left? |
|||
Did you check the toilets on the right? |
|||
Did you check the toilets on the left? |
|||
# A recursive formal language is a [[recursive set|recursive]] [[subset]] in the [[set (mathematics)|set]] of all possible words over the [[alphabet]] of the [[formal language|language]]. |
|||
OK, OK, you win. |
|||
# A recursive language is a formal language for which there exists a [[Turing machine]] that, when presented with any finite input [[literal string|string]], halts and accepts if the string is in the language, and halts and rejects otherwise. The Turing machine always halts: it is known as a [[Machine that always halts|decider]] and is said to ''decide'' the recursive language. |
|||
By the second definition, any [[decision problem]] can be shown to be decidable by exhibiting an [[algorithm]] for it that terminates on all inputs. An [[undecidable problem]] is a problem that is not decidable. |
|||
#3 |
|||
== Examples == |
|||
Ribet, ribet |
|||
I can’t hold it |
|||
Last toilet I had, I already sold it. |
|||
In the rain or in the snow |
|||
I’ve got the funky flow |
|||
But, now I really gotta go. |
|||
The toilet over there |
|||
Will bring you luck |
|||
So give, I’ve got no time to spare. |
|||
As noted above, every context-sensitive language is recursive. Thus, a simple example of a recursive language is the set ''L={abc, {{not a typo|aabbcc}}, {{not a typo|aaabbbccc}}, ...}''; |
|||
Ah, me lose to you |
|||
more formally, the set |
|||
I’m outta here. |
|||
: <math>L=\{\,w \in \{a,b,c\}^* \mid w=a^nb^nc^n \mbox{ for some } n\ge 1 \,\}</math> |
|||
is context-sensitive and therefore recursive. |
|||
Examples of decidable languages that are not context-sensitive are more difficult to describe. For one such example, some familiarity with [[mathematical logic]] is required: [[Presburger arithmetic]] is the first-order theory of the natural numbers with addition (but without multiplication). While the set of [[First-order_logic#Formulas|well-formed formulas]] in Presburger arithmetic is context-free, every deterministic Turing machine accepting the set of true statements in Presburger arithmetic has a worst-case runtime of at least <math>2^{2^{cn}}</math>, for some constant ''c''>0.{{sfnp|Fischer|Rabin|1974}} Here, ''n'' denotes the length of the given formula. Since every context-sensitive language can be accepted by a [[linear bounded automaton]], and such an automaton can be simulated by a deterministic Turing machine with worst-case running time at most <math>c^n</math> for some constant ''c'' {{citation needed|date=March 2015}}, the set of valid formulas in Presburger arithmetic is not context-sensitive. On positive side, it is known that there is a deterministic Turing machine running in time at most triply exponential in ''n'' that decides the set of true formulas in Presburger arithmetic.{{sfnp|Oppen|1978}} Thus, this is an example of a language that is decidable but not context-sensitive. |
|||
#4 |
|||
== Closure properties == |
|||
Walk the walk |
|||
Even if you can’t talk the talk |
|||
Recursive languages are [[closure (mathematics)|closed]] under the following operations. That is, if ''L'' and ''P'' are two recursive languages, then the following languages are recursive as well: |
|||
Bwock! I gotta call. |
|||
* The [[Kleene star]] <math>L^*</math> |
|||
I am a chicken from the kitchen |
|||
* The image φ(L) under an [[Homomorphism#Formal language theory|e-free homomorphism]] φ |
|||
And I ain’t kiddin’ although |
|||
* The concatenation <math>L \circ P</math> |
|||
Nothing is written. |
|||
* The union <math>L \cup P</math> |
|||
Crack! Break! Fix the door, you know |
|||
* The intersection <math>L \cap P</math> |
|||
I gotta go, so just open up, you know. |
|||
* The complement of <math>L</math> |
|||
Crack! Break! Fix the door, you know |
|||
* The set difference <math>L - P</math> |
|||
I gotta go, so just open up, you know. |
|||
The last property follows from the fact that the set difference can be expressed in terms of intersection and complement. |
|||
== See also == |
|||
*[[Recursively enumerable language]] |
|||
*[[Computable set]] |
|||
*[[Recursion]] |
|||
== References == |
|||
{{reflist}} |
|||
* {{cite journal | last = Chomsky | first = Noam | year = 1959 | title = On certain formal properties of grammars | journal = Information and Control | volume = 2 | issue = 2 | pages = 137–167 | doi = 10.1016/S0019-9958(59)90362-6 | doi-access = }} |
|||
* {{cite journal | first1=Michael J. | last1=Fischer | authorlink1=Michael J. Fischer | first2=Michael O. | last2=Rabin | authorlink2=Michael O. Rabin | date=1974 | title=Super-Exponential Complexity of Presburger Arithmetic | url=http://www.lcs.mit.edu/publications/pubs/ps/MIT-LCS-TM-043.ps | journal=Proceedings of the SIAM-AMS Symposium in Applied Mathematics | volume=7 | pages=27–41 }} |
|||
*{{cite journal | last1 = Oppen | first1 = Derek C. | year = 1978 | title = A 2<sup>2<sup>2<sup>''pn''</sup></sup></sup> Upper Bound on the Complexity of Presburger Arithmetic | journal = J. Comput. Syst. Sci. | volume = 16 | issue = 3| pages = 323–332 | doi = 10.1016/0022-0000(78)90021-1 | doi-access = free }} |
|||
* {{Cite book |last=Sipser | first = Michael | year = 1997 | title = Introduction to the Theory of Computation | publisher = PWS Publishing | chapter = Decidability | pages = [https://archive.org/details/introductiontoth00sips/page/151 151–170] | isbn = 978-0-534-94728-6 | author-link = Michael Sipser | chapter-url-access = registration | chapter-url = https://archive.org/details/introductiontoth00sips/page/151 }} |
|||
{{Formal languages and grammars}} |
|||
[[Category:Computability theory]] |
|||
[[Category:Formal languages]] |
|||
[[Category:Theory of computation]] |
|||
[[Category:Recursion]] |
Latest revision as of 13:36, 25 June 2024
In mathematics, logic and computer science, a formal language (a set of finite sequences of symbols taken from a fixed alphabet) is called recursive if it is a recursive subset of the set of all possible finite sequences over the alphabet of the language. Equivalently, a formal language is recursive if there exists a Turing machine that, when given a finite sequence of symbols as input, always halts and accepts it if it belongs to the language and halts and rejects it otherwise. In Theoretical computer science, such always-halting Turing machines are called total Turing machines or algorithms.[1] Recursive languages are also called decidable.
The concept of decidability may be extended to other models of computation. For example, one may speak of languages decidable on a non-deterministic Turing machine. Therefore, whenever an ambiguity is possible, the synonym used for "recursive language" is Turing-decidable language, rather than simply decidable.
The class of all recursive languages is often called R, although this name is also used for the class RP.
This type of language was not defined in the Chomsky hierarchy.[2] All recursive languages are also recursively enumerable. All regular, context-free and context-sensitive languages are recursive.
Definitions
[edit]There are two equivalent major definitions for the concept of a recursive language:
- A recursive formal language is a recursive subset in the set of all possible words over the alphabet of the language.
- A recursive language is a formal language for which there exists a Turing machine that, when presented with any finite input string, halts and accepts if the string is in the language, and halts and rejects otherwise. The Turing machine always halts: it is known as a decider and is said to decide the recursive language.
By the second definition, any decision problem can be shown to be decidable by exhibiting an algorithm for it that terminates on all inputs. An undecidable problem is a problem that is not decidable.
Examples
[edit]As noted above, every context-sensitive language is recursive. Thus, a simple example of a recursive language is the set L={abc, aabbcc, aaabbbccc, ...}; more formally, the set
is context-sensitive and therefore recursive.
Examples of decidable languages that are not context-sensitive are more difficult to describe. For one such example, some familiarity with mathematical logic is required: Presburger arithmetic is the first-order theory of the natural numbers with addition (but without multiplication). While the set of well-formed formulas in Presburger arithmetic is context-free, every deterministic Turing machine accepting the set of true statements in Presburger arithmetic has a worst-case runtime of at least , for some constant c>0.[3] Here, n denotes the length of the given formula. Since every context-sensitive language can be accepted by a linear bounded automaton, and such an automaton can be simulated by a deterministic Turing machine with worst-case running time at most for some constant c [citation needed], the set of valid formulas in Presburger arithmetic is not context-sensitive. On positive side, it is known that there is a deterministic Turing machine running in time at most triply exponential in n that decides the set of true formulas in Presburger arithmetic.[4] Thus, this is an example of a language that is decidable but not context-sensitive.
Closure properties
[edit]Recursive languages are closed under the following operations. That is, if L and P are two recursive languages, then the following languages are recursive as well:
- The Kleene star
- The image φ(L) under an e-free homomorphism φ
- The concatenation
- The union
- The intersection
- The complement of
- The set difference
The last property follows from the fact that the set difference can be expressed in terms of intersection and complement.
See also
[edit]References
[edit]- Chomsky, Noam (1959). "On certain formal properties of grammars". Information and Control. 2 (2): 137–167. doi:10.1016/S0019-9958(59)90362-6.
- Fischer, Michael J.; Rabin, Michael O. (1974). "Super-Exponential Complexity of Presburger Arithmetic". Proceedings of the SIAM-AMS Symposium in Applied Mathematics. 7: 27–41.
- Oppen, Derek C. (1978). "A 222pn Upper Bound on the Complexity of Presburger Arithmetic". J. Comput. Syst. Sci. 16 (3): 323–332. doi:10.1016/0022-0000(78)90021-1.
- Sipser, Michael (1997). "Decidability". Introduction to the Theory of Computation. PWS Publishing. pp. 151–170. ISBN 978-0-534-94728-6.