8

Something is Turing Complete if it can be used to simulate any Turing Machine.

So, can a Finite Automaton simulate a Turing Machine?

On the question Can regular languages be Turing complete? they say a Regular Language can be Turing Complete, but it does not make sense to me. I am not talking about the Language being parsed, but the Finite Automaton itself.

Finite Automatons and Regular Languages are not Equivalents. Finite Automatons are machines which accept or reject some Language. But Regular Grammars and Finite Automata are equivalents because I can convert one to another. Then, the question is, are Regular Grammars Turing Complete? Are Type 0 grammars Turing Complete? i.e., can I use a Regular Grammar or a Type 0 Grammar to do any computation I would like?

Can I write a Finite Automaton to do anything a Full-Featured General Purpose Computer can do?

user
  • 245
  • 1
  • 3
  • 10

4 Answers4

21

No finite automaton can simulate a Universal Turing machine, so finite automatons are not Turing complete. This falls out immediately from them having a finite number of states. Universal Turing machines require an unbounded amount of space to work.

The source code of an Jot program can be recognized with a finite automaton. That automaton doesn't evaluate the program (and thus doesn't play the role of a Turing machine), it just determines whether or not it is well-formed enough to be run.

This is in contrast with most programming languages. For example, because JavaScript has nested () and {}, it's necessarily not regular (but is, at least approximately, context free). Indentation sensitive languages like Python aren't even context-free (without preprocessing of identation).

This isn't that interesting of an observation. For example, the following is a Turing-complete a subset of syntactically-valid JavaScript programs that is recognizable with a regular expression:

/^eval\("[^\n\"]+"\)$/

...just most of these will immediately throw a runtime error because eval will not parse its single argument -- essentially we can define a programming language to treat all inputs as "syntactically valid" by just defining a new runtime behavior for all the syntactically invalid ones.

What is maybe more interesting about Iota is that its grammar also naturally parallels the actual structure of programs, instead of being a weird encoding trick like the above.

Curtis F
  • 1,063
  • 9
  • 17
10

Can I write a Finite Automaton to do anything a Full-Featured General Purpose Computer can do?

Your computer is a finite automaton. It's state can be uniquely described by the content of its registers, RAM, SSDs, etc. Every input (including the system clock) causes a transition from one state to the next, in a deterministic manner. Conceivably, you could enumerate all the possible states, and draw the arcs between them, forming a deterministic finite automaton (DFA). There are maaaaany states, but they are finite.

However, this only works because the infinite memory requirement of Turing machines (TMs) is often ignored (exactly because it would never be achievable, so it's of little pragmatic use).

Pushdown automata (PDAs) and TMs can be thought to have two separate components.

  1. A "decision making" part, that decides how one state should transition to a next, analogous to a CPU.
    • In a PDA, this is the automaton
    • In a TM, it's the rule set by which symbols are evaluated
  2. They also have a "working memory", whose job is to contain most of the state of the system, analogous to RAM.
    • In a PDA, this is the push-down stack
    • In a TM, it's the tape

DFAs have both of these components rolled into one. The automaton is responsible both for all decision making, and for all state-keeping. As a consequence, the state can never be bigger than the DFA.

There is an asymmetry here: PDAs and TMs are granted use of infinite storage (bottomless push-down stacks, infinite tapes), whereas DFAs are not, by definition. If a DFA was given the same affordance for infinite state-keeping (by allowing it to have infinite states), it would no longer be a deterministic finite automaton. It would be a deterministic infinite automaton!

Interestingly, infinite state-automata are not only Turing Complete, but they're actually more powerful than Turing Machines. With infinitely many states allowed, any langauge can be expressed as an automaton with one start node, one accepting state, and one non-accepting state. For every string in the language, an arc is made to the accepting state. For every other string, an arc is made to the non-accepting state.

Alexander
  • 528
  • 2
  • 8
1

can a Finite Automaton simulate a Turing Machine?

No. Some Turing machines don't halt on some inputs, but every finite automaton halts on every input.

Also, I'd say that your question contains a category error. Turing completeness is a property of systems analogous to programming languages. You're asking about whether a model of computation is Turing-powerful.

David Richerby
  • 82,470
  • 26
  • 145
  • 239
1

No

Finite Automata are not Turing Complete because they have a limited amount of memory. If that limit of memory were to be removed, the Finite Automaton in question would be Turing Complete.

Let's take a Finite Automaton which is a Turing Machine except it is restricted to 10 states. This would not be able to be Turing Complete because it wouldn't be able to simulate every program with 11 states. Even if you extend it to 10,000,000 states, it will not be able to simulate an optimal program using 1,000,000 states (a program with the minimum states being used being 10,000,000 without being able to be golfed anymore) except with a 10,000,001st state being to move right. Therefore, a Finite Automaton must not be Turing Complete due to memory constraints.

Many programming languages like Malbolge or C are affected by this because they have a limited memory.

MilkyWay90
  • 251
  • 1
  • 10