Every regular language is decidable - math

I am a trying to prove that every regular language is decidable.
So in order to prove that I am trying to show that I can move from deterministic finite automaton (DFA) to a Turing decidable machine.
So I am not sure how to construct a Turing machine that simulates the original automate (DFA).
The states (in the automate and the Turing machine ) will be similar off course.. but I am not sure how to continue..
Thanks in advance.
Shiran

Wouldn't this work : the input tape carries the word to be recognised followed by some letter # from outside the input alphabet. For each state q of the DFA, you have a Turing machine state q with transitions:
input letter -> tape operation, next state, write symbol
c for each input letter -> move right, the state the DFA reaches from state q with letter c, write c
# -> STOP ACCEPT or STOP REJECT, depending on whether q is final in the DFA.

Related

Implement enumerator using turing machine - redundant prints

In the following algorithm:
we implement an enumerator using a turing machine and the enumerator is supposed to output the language accepted by the turing machine. The accepted words from Σ* are printed multiple times (each iteration previously printed words will be printed again).
Why can't we just say - "for each word in Σ* run M on it. If it accepts then print, if rejects then move on to the next word". Then we won't print each word more than once.
Why the unnecessary prints?
The algorithm from the image is:
If a TM M recognizes a language A, we can construct the following enumerator for A. Assume s1, s2, s3, ... is a list of possible strings in Σ*.
E = “Ignore the input
1) Repeat the following for i = 1, 2, 3, ...
2) Run M for i steps on each input s1, s2, s3, . . . si.
3) If any computations accept, print out corresponding sj.”
If M accepts a particular string, it will appear on the list generated by E (in fact infinitely many times)
Thanks
As stated in the comments: the problem is that some computation might not terminate. So if you do them sequentially, the ones after the first non-terminating computation will never be executed.
The given algorithm uses the standard technique to work around this: dovetailing.
You can change step 3 to "If any computation accepts after i steps, then print" - then there are no unnecessary prints. But then you have to count the steps during each simulation, which means some extra work. The author choses an option that is simple to program, but not very efficient.

Is it possible to design an automaton that accepts irrational number?

Given a rational number, would it be possible to know whether the root or some other power of the number is an irrational number? Can an automaton be designed for such a purpose?
An irrational number is an infinite string, and if you want an automaton that can read it, it will need to continue reading infinitely.
You cannot build a decider (a machine that always halts with output true or false), but you can build an acceptor (a machine that halts with false, but continues forever for true), which is what I believe you're asking.
Consider a machine that accepts the irrational number of the form
0.10110111011110111110...
Where the lengths of runs of 1s is always growing between 0s. It's relatively easy to define a Turing machine that can accept this number.
(For the implementation for such a machine, I'd suggest The Annotated Turing, which also has an implementation for a machine that accepts √2.)

Recursive definition of set strings over {a,b} that contains one b and even number of a's before the first b

I'm working on a problem from the Languages and Machines: An Introduction to the Theory of Computer Science (3rd Edition) in Chapter 2 Example 6.
I need help finding the answer of:
Recursive definition of set strings over {a,b} that contains one b and even number of a's before the first b?
When looking for a recursive definition, start by identifying the base cases and then look for the recursive steps - like you're doing induction. What are the smallest strings in this language? Well, any string must have a b. Is b alone a string in the language? Why yes it is, since there are zero as that come before it and zero is an even number.
Rule 1: b is in L.
Now, given any string in the language, how can we get more strings? Well, we can apparently add any number of as to the end of the string and get another string in the language. In fact, we can get all such strings from b if we simply allow you to add one more a to the end of a string in the language. From x in L, we therefore recover xa, xaa, ..., xa^n, ... = xa*.
Rule 2: if x is in L then xa is in L.
Finally, what can we do to the beginning of strings in our language? The number of as must be even. So far, rules 1 and 2 only allow us to construct strings that have zero as before the b. We should be able to get two, four, six, etc., all the even numbers, of as. A rule that lets us add two as to any string in our language will let us add ever more as to the beginning while maintaining the evenness property we require. Starting with x in L, we recover aax, aaaax, ..., (aa)^(2n)x, ... = (aa)*x.
Rule 3: if x is in L, then aax is in L.
Optionally, you may add the sometimes implicitly understood rule that only those things allowed by the aforementioned rules are allowed. Otherwise, technically anything is allowed since we haven't explicitly disallowed anything yet.
Rule 4: Nothing is in L unless by virtue of some combination of the rules 1, 2 and/or 3 above.

Is this language decidable?

I'm struggling with whether or not this is decidable:
A = {x is an element of the set of Natural Numbers | for every y greater than x, 2y is the sum of two primes}
I'm inclined to think that this is decidable given the fact that when fed into a Turing Machine, it will never reach an accept state and loop for infinity unless it rejects. However, I also do know that for a language to be decidable, there must only exist an algorithm to decide it; we don't necessarily have to know how it's done. With this, part of me think that it is decidable? Does anyone know how to prove either?
This language is decidable, though the proof is a bit evil.
For starters, let's think about the properties of this language. Clearly, if n is a natural number contained in the language, then every number greater than n is also in the language. Thus there are three possible forms this language can take:
This language contains all natural numbers, or
This language contains no natural numbers, or
This language contains all natural numbers greater than some natural number n.
Languages (1) and (2) are, respectively, {0, 1}* and the empty language, both of which are decidable (so there are TMs that always halt that accept those languages). Every language of form (3) is also decidable, because for any n we can easily write a TM with n hardcoded into it that simply checks whether the input is at least n. Consequently, no matter which case is true (either 1, 2, or 3), there exists some TM that always halts whose language is the language you've provided, so your language is decidable.
But that said, this proof is nonconstructive. We can show that the language has to be decidable, but we can't actually find the TM that always halts that accepts it! In fact, no one knows which TM it is, because Goldbach's Conjecture (whether every even number greater than two is the sum of two primes) is an open problem in mathematics.
Hope this helps!

regular languages with concatenations

the regular languages are closed under the operation:
init(L) = the set of the strings w such that for some x, wx is in L.
EDIT :
x can be any string, a character or empty string
How can I prove that ?
OK, misread the quesion on the first time, now I get it. It still trivial. Looking at the automate what you searching is a partion of the automate into two state sets S1 and S2, so that just one transition is between them (and if its from S1->S2 S1 contains of course the start node, and S2 the end node). Such exist always (exception empty language), in case there is no such node you can add one, so w is just a set containing the empty word, which is of course also regular (as well as the empty language case).
Unless I'm misunderstanding, the answer is that you can't. Because it's not true.
First, let's consider the language L = {aa, bb, cc} and alphabet {a, b, c}
So, init(L) = {a, b, c}. However, each of the elemnts in init(L) are not in L.
Edit: If we are concatenating empty characters, then init(L) = {a, b, c, aa, bb, cc}. Which is still not equal to L.
A language is regular iff there's a finite-state automaton that recognizes it. So, suppose L is a regular language and let A be an automaton that recognizes it. Now, say that a state of A is "good" if there's some set of possible transitions starting there and ending in the "accept" state. Define a new automaton A' in which all transitions to "good" states are replaced by direct transitions to the accept state. Then the language recognized by A' is exactly init(L).
I think it's a new DFA B, that makes all the state of A(the original DFA) that can reach to the final states of A the final state of B.

Resources