r/AskComputerScience • u/[deleted] • Mar 20 '21
Why is theory of computation concerned with recognizing languages?
Michael Sipsers's book Introduction to the Theory of Computation introduces automata theory and theory of computation as fields of research trying to answer to questions of format is there an automaton that recognizes the language defined by grammar x. As a programmer, this seems weird. Why talk about recognizing languages rather than approaching the automaton as a computer program or a function, i.e. a series of instructions (or state transitions) mapping input to output? Intuitively, it seems like languages and grammars would only be iteresting to a computer scientist who is designing a programming language or writing a parser.
4
u/redblack-trees Mar 20 '21
Complexity theorists are interested in automata theory because, according to all evidence we've seen thus far, there exists no realistic model of computation that surpasses the computational capacity of a Turing Machine. The same thesis (called the Church-Turing Thesis – iirc Sipser introduces this concept fairly early on) holds for Lambda calculus, which seems to be more like the model of computation that you're imagining. For what it's worth, linguists will always use Lambda calculus over TMs – maybe computer scientists just stick with TMs because we think TMs seem more like circuits? No idea.
I hope that answers your question, though. Sipser also lays it on a bit heavy for non-theory folks. If you're not going into theory, you likely won't ever use the complexity-theoretic proofs that appear in Part III. As fun as automata are, you'll likely only ever rely on results from computability theory and fine-grained complexity theory, both of which don't receive much attention from theoreticians nowadays.
3
Mar 20 '21
True, I guess lamba calculus is kinda like that. When learning to program, we're taught to think of computer programs as functions that map input to output. With that background it just feels weird to think of them as automatons that recognize whether an input string is a member of a formal language. Maybe that approach made more sense when programming languages didn't even exist.
12
u/claytonkb Mar 20 '21
There are a couple solid replies but I'll chip in for what it's worth.
If you go back to Turing's 1936 paper, he was primarily interested in tackling the Entscheidungsproblem or "decision problem". From Wiki, "[The Entscheidungsproblem] is a challenge posed by David Hilbert and Wilhelm Ackermann in 1928. The problem asks for an algorithm that considers, as input, a statement and answers 'Yes' or 'No' according to whether the statement is universally valid, i.e., valid in every structure satisfying the axioms."
We could get into a lot of the back-history in formal logic that predates the era of computer science. But CS obsoletes many aspects of formal logic -- as an example, we now know that the Turing machine can decide any decidable problem and this means that there is no abstraction that is "more powerful" than a Turing machine, at least, not in the specific sense of deciding sentences constructed within a formal system. So, while the history of pre-CS formal logic is a fascinating topic of history, many of the questions that preoccupied formal logic in that era are no longer interesting to us. Remember, it was not obvious in that era that it was possible to build a machine which could be programmed to calculate just any mathematical function. Perhaps there was some faculty in the human mind that permits us to "directly perceive" solutions in non-mechanical ways. No one knew for sure that this wasn't the case. But today, we know that it is not the case (at least, if you believe the Church-Turing thesis, which can hardly be called controversial.)
For finite functions (functions that have finite domain and range), there is no obstacle to using the approach you suggest, just talking about logic circuits, automatons, and the like. But when you want to make claims about "all" this, "for none" that, or "for each" of the other, you want to be able to handle infinite sets. How many strings are there in the Kleene-star over B={0,1}, that is, B*? Why, there are infinitely many.
Suppose you want to say "there is no string s such that property P(s) holds." You need some abstraction that allows you to handle each and every string. You might prove this claim by positing the existence of a machine M that would recognize s if that is possible, and then proving that there is no machine M (perhaps proof by contradiction, or whatever). In this way, you have proven that the property P() does not hold for infinitely many strings. That's how you use a finite proof to do an infinite amount of work!
Another redditor mentioned the logical equivalence between recognizing a language versus generating the language. This equivalence is very powerful because, once again, it allows us to skip the hard work of trying to enumerate every possible example of strings with property P and, instead, just operate on a machine that would recognize such strings. Then we can just prove things about this machine (which is a finite object and so the proof is manageable.)
5
u/not-just-yeti Mar 20 '21 edited Mar 20 '21
Here's a partial answer, in two parts (a) and (b):
(a) Because they are equivalent:
"compute the square of a number" can be re-formulated as "the set of all strings of the form x#y, where stringToInt(y)=stringToInt(x)2 ".
In this case we're transformed the problem from computing-a-function to a 'verifier' version [which affects run-time], but you can also transform it into an optimization version ("is y within 10% of x2 ?"), or maybe something like "is y the checksum of x2 ?".
(b) the language-formulation seems to work better with regular languages and context-free languages, which don't have the same "computing" feel that TMs can have.
Note that when hitting TMs, texts do start to talk about "TMs that accept/reject/loop-on an input" vs "TMs that compute a function", and they tweak the accept/reject state criteria a bit, to capture the 2nd view.
BUT to get to the real nub of your question: I do not know whether a re-formulation of the all the results into a 'compute-function' approach would make standard results easier, harder, or [most likely:] just different. (You'd want to include both classic results through 1980s, plus the interactive-prover results from the 90s onwards.)
It could easily be, as you suggest, that the classical theory was worked out at the same time many other CS people were concerned about implementing parsers, and that the bias of the Zeitgeist set down the initial formalism as determining set-membership rather than compute-function. And since they're usually easy to convert between, it's not worth trying to change everybody's phrasing of the topic?
2
u/chien-royal Mar 21 '21
Theory of computation can be presented primarily using functions rather than languages. This is done, for example, in the book "Theory of Recursive Functions and Effective Computability" by Hartley Rogers. For another example, Rice's theorem in Wikipedia is stated in terms of functions, so this creates an inconvenience for me whenever I want to provide a link to some discussion about undecidable languages. Finite automata also don't have to only recognize languages: there are finite-state transducers, in particular Mealy and Moore machines.
In fact, in Russia it is more customary to teach theory of computation using functions than languages. There is basically only one good language-based textbook, which is a translation of "Introduction to Automata Theory, Languages, and Computations" by Hopcroft, Motwani and Ullman.
2
u/l_lecrup Mar 21 '21
All the top answers were incomplete or a bit unclear. It's actually very simple:
Decision problems and formal languages are equivalent.
In fact, if you try to define decision problems in a nice way computationally you are almost guaranteed to rediscover formal languages. You encode inputs as strings, the yes-inputs form a language, and you have reduced decision problems to deciding formal languages.
In the real world of course we want to know about more general problems than decision problems, but for all function problems a decision problem that is "easier" exists, and we don't fully understand decision problems (P vs NP is about decision problems, or equivalently about formal languages), so from a theoretical point of view it makes sense to focus on those. Recognition just means one-sided decision, i.e. you claim success if your computer can recognise yes-instances/members of the language and it's allowed to run for ever otherwise. That's a way of giving more power to computers, not unlike giving them non-determinism or a coin flip.
1
u/javaHoosier Mar 20 '21
It sounds like you haven’t made it to complexity theory yet.
A formal language is actually quite simple. It’s just a set. How else would you describe what you want all acceptable input to be?
Then down the road you categorize these languages based on what model of computational can recognize them and beyond.
You can pose a problem and hopefully reduce to another problem and understand the complexity class. There are tons of problems out there that could change the world if a more optimized algorithms are discovered. Or we can attempt to prove that their isn’t.
23
u/beeskness420 Mar 20 '21
Because everything we do as computer scientists revolves around formal languages.