r/AskComputerScience • u/WiggWamm • Nov 11 '20
What role does automata theory play in computer science?
How does it relate to computer science in a general and day to day sense? I don’t understand what it does.
Thank you.
9
u/faraznomani Nov 12 '20 edited Nov 12 '20
To add to other answers and give a more practical world use case of automata.
It plays a great bit of role in compiler designing. Regular expressions are used almost everywhere. All Parsers use some form of chomsky hierarchy grammars which you study theoretically in Automata.
For creating DSLs you need to create CFG grammars. You might have heard of tools like YACC or Antlr.
If you are interested in creating a simple parser lexer do give a try to JISON. It’s a Java script based parser generator. It is very similar in looks to Bison. You can try your theoretical CFGs to create working parser evaluators.
Automata is a core computer science field. But like everyone studying Operating System does not work on kernels similarly everyone studying Automata does not design compilers.
In my personal experience I have worked on multiple DSL grammars and have used great bunch of things I learned theoretically in Automata.
Hope this gives you a practical perspective.
Edit: have a look at this grammar file (Antlr G4). It is a form of context free grammar which is used to define a Java parser. You can create your own grammar and grammar evaluator similarly (DSL aka Domain specific language).
2
15
u/javaHoosier Nov 12 '20 edited Nov 13 '20
I think the previous answers are kind of lacking.
In a nutshell there was a search to mathematically define computation. Then something that can compute it. If you provided some form of input, does it succeed or does it fail. Then there needs to be a set of information that is proven to succeed. All other input fails. You can formally define all this. But I’ll keep it simple. I won’t describe how these machines work. Just understand that they have rules on how they work.
Imagine strings of every length that only contain the letter a. So a, aa, aaa, ... to infinity. But nothing else. You can create an automata that can accept this input. Lets imagine another set of strings ab, aabb, aaabbb, ... Unfortunately you can’t create an automata to accept this. In a sense you can’t design one that can remember the number of a’s and produce the same number of b’s. So a new more ‘powerful’ machine is needed. The next level up are grammars and push-down automata. But then what about abc, aabbcc, aaabbbccc, to infinity. Same story, these machines fail. Now we need a new ‘machine’ which is a turing machine or lambda calculus. We are at the most powerful machine of computation we have came up with. Every other new definition created has at most only ever been equivalent in power.
What I described to you are called formal languages. There are many different classes of them. For example, the class of languages that automata can accept are called Regular languages. They are useful to understand what is computable and how long it can take to compute something. If it will accept or not. Instead of strings you can now prove if specific problems are in the set of certain languages. Such as, if a graph has a hamiltonian path? Then using something called reductions, you can try to turn a problem into another and prove its simpler than you thought. This moves into Complexity theory. This is where if P = NP comes from. These are both a class of languages. This is in computer science.
In the software engineering world its typically not seen at all in a real sense in my day to day. Automata can be synonymous with finite state machines though. They are useful for programming things such as an elevator, turnstile, washing machine, robot movement. Algorithm complexity is important occasionally but I don’t think in terms of complexity class. Just O(n) and O(n2) usually.
4
u/WiggWamm Nov 12 '20
Thank you. Sometimes it’s hard when the class just teaches you stuff doesn’t doesn’t teach you why you need to know it. Thanks again for the answer! I appreciate it.
8
u/javaHoosier Nov 12 '20
No problem! As for why you need to know. I think there are two solid reasons. If you want to continue to grad school this knowledge should be in your toolkit. The more practical answer is that it opens your mind and lets you understand a bit more about reasoning. Your intuition can grow without ever needing to use something.
2
u/WiggWamm Nov 12 '20
Very true very true. If all goes well I’m undergrad, I would probably only go to grad school if my employer covered it haha
2
2
u/salamyinyourmommy Nov 12 '20
Thank you so much for the wonderful explanation. I had this subject last fall. 30% students failed this subject. Almost everyone I knew in my class got exactly the minimum passing mark. Ironically I got the highest marks in the class(65%) crappy score. I had no idea what this subject was used for until now
1
Nov 12 '20
finite state machines is also good for programming virtual agents. you can write a parser with them too.
30
u/Magdaki Ph.D CS Nov 11 '20
It is used mainly on the theory side. Automata are a good way to describe an algorithm for a computational problem in a mathematical way, which is useful for proving theorems about the algorithms relative to the computational problem. For example, are they guaranteed to finish? What are the bounds on memory? What grammars are needed to solve the problem? Etc.
16
u/lead999x Nov 11 '20
Day to day depends on what you do for a living.
If you're a theoretical computer scientist working in academia then you might use automata theory in your research regularly. If you're a corporate or government software developer then you could go a whole career without ever using it.
10
u/UntangledQubit Nov 12 '20
There's the caveat that state machines are a common design tool, especially for networked applications, because of how easy they are to reason about. It's common to do so somewhat informally, talking about a state machine while actually mutating global state, but I'd say that counts.
8
u/lead999x Nov 12 '20
I've heard they're also useful for designing parsers and regular expression engines. That's why I made sure to say that you could go a whole career without using them but I stopped short of saying that working devs don't use them.
4
u/ashah201291 Nov 12 '20
I am software developer for a corporate, my day to day life is about writing java ee applications.
I used Automata theory once in my professional career when I had to prove a regex was not possible for some weird pattern checking my client wanted to have.
3
u/Zikker Nov 12 '20
Just to give you a real-world example, the life cycle of a user's session to a MongoDB database is modelled as a finite-state machine.
Give a look at automata-based programming, pretty interesting stuff!
1
Nov 12 '20
it's formalization of computation. you have to formalize things if you want to study them
1
u/20420 Nov 12 '20
A straight forward way of viewing it is the fact that automata is simply another (turing complete) programming language. Just like C, Java, etc. Any modern app could be written entirely in automata.
What is outstanding is it was invented in 1943, many years before the invention of the computer.
It is in a way the first pogramming language. It is the stuff that all modern technology is based on.
18
u/ZestyTheory321 Nov 11 '20
That sorting hat telling real pros from bootcampers