Note that in the context of computers we will usually refer to tuples as strings, so instead of writing something like we instead just write "01234" to represent the same thing.
- is a finite set called the states
- is a finite set called the alphabet
- is the set of possible inputs
- is a finite set called the transition function
- is the start state
- is the set of accept states
Note that when then we get as a possible input, which it the empty tuple, we denote this as .
- if then
If a langauge is not legible by a particlular machine, then there will exists an input in the language such that is not well defined, thus in those cases we cannot say much about the language.
We claim that the following DFA works:
Note that when then an empty concatenation is defined as so that the star of any lanuage will always contain .
- is a finite set called the states
- is a finite set called the alphabet
- is the set of possible inputs
- is the transition function
- is the start state
- is the set of accept states
A NFA is shorthand for the above, to differentiate we call a finite automaton as a DFA where the D stands for deterministic. Additionally sometimes when drawing these out, then you'll notice that sometimes for a given state there is not an arrow for each character in the alphabet, whenever this is the case it means that which means that there is no transition from starting at and reading , this means that an NFA can get "stuck" this is when it is not possible for the NFA to read in the next state in any possible context.
One visual that helps me remember the above is like you're trakcing the whereabouts of multiple trains in a subway station, you want to get on one of the trains as fast as possible, so you see what stations they'll be at next, so you can get on at the nearest station, tha above takes in the collection of train stations they're at now, and tells you where they'll be next.
Note that and that
Then given a string then by induction we can prove that and for any valid , thus so we can conclude that so showing that
Note that we could analyze what it does to other states, but they will not be reachable in the final diagram and thus can be removed, this is true because we explored the graph starting at the root following the BFS algorithm which we know will entirely explore all reachable states, thus here is the final simplified NFA:
Suppose that there exists an NFA such that , then by the above theorem there exists some DFA such that therefore .
The other direction is simpler since then there exists some DFA D such that but a DFA is an NFA so then we've shown that there is some NFA that recognizes as needed.
Because this is true it means that a language is regular iff there is an NFA or DFA which recognizes it.
It was defined as above to allow you to map single characters from an alpabet to strings of another to be more general from the get go, but you can certainly have homomorphisms from characters of one alphabet to characters of another alphabet just the same.
Instead of making an explicit construction we will instead use the fact that regular languages are closed under intersection and homomorphisms to prove that the shuffle is regular.
But now if we consider , then where the last condition comes about because we require that Note that since is a homomorphism and then we have equivalently
Analgously we find that is regular. Now since we have Then the homomorphism defined as (it is a homomorphism, because and you can check the rest), is interesting because it threads them one by one, so that Since we know that and and that regular languages are closed under homomorphism and intersection we conclude that is regular.
Before we continue we cast away two trivial cases, when , then since every number is divisible by 1, then we construct a trivial DFA with one state which is the accept state and all arrows point back towards itself. The case of can also be disposed of quite quickly as we can construct a two state dfa, where we start in the accept state, and if we read a one, we got to or stay in the non-accept state, if we read a zero we go back and stay inside the accept state, this will work because our DFA reads from left to right, and the last digit of a binary number is at the right, and a binary number is odd iff the last digit is one, therefore this DFA would only ever be in the non-accept state if the last read digit is one, as needed.
We construct a DFA as follows, we have states where will be the state when the currently read in binary number has remainder mod that is , to make this claim true, we define our transition function as follows and
We do this because when we read the next binary number it pushes all previous number one power higher (ie multiply by two), and then based on if that new digit is one or zero it adds on as well.
Note that given a number then its true that , since in this case we know that and actually and then and so we have
This shows that the remainder of multiplying by 2 and then either adding or is the same as multiplying by 2 and then adding or , by induction this property holds when iterated, thus this shows that our construction of the transition function actually satisfies the claim that is the state when the currently read in binary number has remainder mod , therefore after reading the entire number if it has remainder mod the DFA will be on state thus by only making the accept state our DFA is correct, and so is regular.
- for some in the alphabet
- The union of two regular expressions , denoted by
- The concatentation of two regular expressions denoted by
- The star of a regular expression denoted by
Given a regular expression we show that there is an NFA that models thus showing that would be regular.
Since the definition of a regular language is recursive by nature we split cases on the possibilities and complete the proof using structural induction.
The first case is if for , if that's the case then a two state NFA N with a start state on the left, and an accept state on the right, with a single transition when the letter is read will work, as . Formally we have where and for or
If then with for any , then
If then with for any
Now by structural induction suppose that such that and .
If then since regular languages are closed under union, we have that .
If , since regular languages are closed under concatenation then
If , since regular languages are closed under the star operation then
Thus by structural induction we can conclude that the statement holds true.
- is a finite set called the states
- is a finite set called the alphabet
- is the set of possible inputs
- is the transition function
- is the start state
- is the accept state
- for every we have
Let be a DFA recognizing then we set . Now suppose that such that , since then we know that , so that by the pigeonhole principle there must exist a duplicated state .
Thus where we note that as , so now let where is the first instance of the duplicate for the part between the duplicates: for the part after the duplicate:
Now we claim that the three properties hold true, for the first property let and so if , then we know that we're looking at the string which is accepted as because on the sequence on the right ends in a accept state. Whenever then in a similar manner for the same reason, the sequence on the right ends in an accept state, so the first property holds true.
The reason why is because in order to move to another state you must process a character, since we encounter twice, it means that we must read at least one character to do this.
We know that it's guarenteed that within the first states there must be a repeated state due to the pigeon hole principle, and add to our assumptions that is the first repetition in the sequence, then we know that
Pumping for Non-Regularity
While the pumping lemma gives us a characterization about strings of regular languages it also provides us a way of determining when something is not regular, for example if we wanted to show that a language was not regular, we would assume for the sake of contradiction that it was regular and thus there would exists some such that any string of length greaer or equal to would have the three properties.
Thus we can obtain our contradiction by constructing a string of length greater than which does not satisfy all the conditions. Most of the time condition one provides the most flexibility, because if we choose our input string in a smart way, then ew cna raise to a power which creates a string which is no longer part of the input language. This is a common technique to prove that a language is not regular.
- for every we have
Let and consider the language given by that is the set of strings that have 0 ^ \left( k - 1 \right) ParseError: Got function '\left' with no arguments as superscript at position 5: 0 ^ \̲l̲e̲f̲t̲( k - 1 \right) as a substring.
Clearly there is a DFA with states which recognizes this language, the DFA constructed by having states all in a line, with the last state being an accept state, and chained together with arrows which allow movement when reading a , and sent back to the initial state whenever a is read, the only way to get to the end state is to read in consecutive zeros, which is the exact condition on having as a substring.
On the other hand if we assume for the sake of contradiction that there was a DFA C with states which could recognize there will be a problem. Since is a subset of a regular language then it is regular, thus using the above corollary from the pumping lemma, since C is a DFA with states that recognizes and is a string with length greater or equal to then by the pumping lemma there exists such that , along with the three properties.
By the second property we know that therefore for some and that which implies simply because when all three are concatentated together we must get , but then based on the first property we have that for any so specifically if we choose then we know that but this is a problem because and so that is a sequence of zeros where but clearly could not be a substring of this, therefore , this is a contradiction, therefore no such DFA must exist.
TODO come back to the above later on
In english the above lemma is saying that whenever you have a regular language, there is a threshold wherein given a string in length exceeding that threshold then it can be decomposed in into three pieces such that the middle piece can be duplicated over and over, and the string remains part of that regular language (under two other small conditions).
Intuitively this is allowing you to split an string in and then glue it the other way around.
Note that since for any we have therefore showing that , moreover that holds in general for any set , so therefore we have
Now suppose that and we want to prove that . By assumption we know that if then if that's true then we can split that string and glue it in reverse order and it would have to be an element of , there are a few cases, that is iff
- and
- and
Since then there is a DFA D that recognizes , we first come up with an idea for a single string and show how to extend it to all strings.
Given the string then we know that it means that for some where , since then we know that is accepted by , therefore after reading the DFA D will be at some state and then after reading it should end up in an accept state.
We construct an NFA by extending the DFA by running the DFA from (since a DFA is an NFA this is fine), once we get to the accepting state add an epsilon transition back to the start state of the DFA and continue running the logic of the DFA, if the NFA ends back at at state after reading this would only be true if .
To generalize this to work for all possible strings we allow any state to take the place of , to allow the NFA to start and end at we duplicate our once for each state and add epslion transitions for each accepting state back to the start state, then to finish the generalization we have our start state and provide an epslion transition to all of the other states.
- is a finite set called the variables
- is a finite set, disjoint from called the terminals
- is a tuple of the form where and is a sequence of elements from which is notated by
- An which is the start variable
Note that if a rule matches we also allow for app, to not do anything by adding in to the set it evaluates to.
Note that we have , but sometimes we want to only allow one rule to be applied at a time.
The above definition captures all the possible strings that you can produce given a string in your CFG and then applying a specific rule. We now overload the noatation to show all possible productions using all rules for a specific string:
Now we have to generalize this definition to be able to recursively apply onto a string, and not just one layer
Note that this implies that for any there is at least one sequence of rules such that
Note that sometimes productions can result in strings which are not all terminal symbols, therefore a language of a CFG are those productions which are entirely terminal symbols.
Note that sometimes we will want to be able to count the number of steps required to derive a string from a CFG, in that case it can be hard to deduce how many steps would be required to make the derivation because so many characters could change in of the one layer productions, so we instroduce the yields of a rule, which only allow one character to change
Note that we may use instead of and receive the same langauge.
Since and , then we have CFGs and such that and . We construct a new CFG such that , we do so by first differentiating varibles in each grammar for and , we do so by subscripting each variable with respectively, and then setting our variables as the union of the the variables in both, and also unioning the rules in both, then we tack on one rule which is .
proof that this actually generates what we expect.
- Since is finite, then and then we define the single rule:
Now given any element then for some function and some thus by sequentially picking the associated rule of the form , then then using the epsilon rule, we've shown that
The other direction is obvious since
- We take inspiration from the CFG which generates the star, and introduce one extra rule
We claim that is the desired set, so suppose that is a string in the desired set, and if it is any of it is immediately in the generated langugae by rule 1. Otherwise it is a string of the form or , where and we proved previously that that rule alone will generate then we know that the second rule will match as needed. We've just shown that any string from the desired set is in the language.
Now if we instead suppose that we have any , then we have to show that its in the desired set, since then any element in there is produced by starting with the first rule and then any sequence of rules, but rule one, automatically guarentees that the first and last character are the same as any subsequent rules cannot modify the first and last character of the string so therefore is a subset of the desired set, showing that the two sets are equal as required.
Make a variable for each state in the DFA. Add the rule to the CFG if is a transition in the DFA. Add the rule if is an accept state of the DFA. Make the start variable of the grammaer, where is the start state of the machine.
We lay out an iterative process which constructs a new grammar in Chomsky Normal form as follows:
We first define our set of rules to be the original set of rules, where means we've processed the rule and means we haven't. We first add a new start variable and the rule , ie where was the original start variable.
Now for each element in of the form , then we get all rules of the form where then we add the rules and remove . On each iteration the number of epsilon rules goes down by one, thus after a finite number of iterations there will be no more epsilon rules of the form although there may be epsilon rules of the form which is ok.
Next we remove all rules of the form which are rules which map a variable to a variable, we do so by finding all rules of the form and add the rule , unless this rule was previoulsy removed (TODO define the removed set)
Finally we convert all the remaining rules to the proper form, the remaining possibilities of rules that need conversion are rules
- where
- where
For the first case since where
For the second case we just replce the terminals with rules pointint to them.
Now we remove the rule the rules of interest are and we have: and so the current set of rules becomes
Since all epsilon rules have been eliminated we start remove variable to variable rules, we start with the rule the only rule of interest is then our rules become
Another unit rule is , the rules thus this generates
Since is of the form where then we replace it with the rules
Now the last two rules that need simplification are and , as per the conversion procedure we replace the rule with , and similarly we replace the rule with and , but note that the rules for and are the same, and thus can be joined into the single rule yielding
Since is in normal form, then there may be a rule of , if that's the case then this rule could only ever derive a string of length zero, that is , since we only care about strings of length greater or equal to one, then that implies that the rule can never be used to deduce a string of length greater or equal to one.
Thus only rules used must be of the form or where . Note that every rule of the form will never modify the length of a string of an intermediate string, and the rule will always extend the length of the intermediate string by each time it is applied.
Thus if we are able to derive a string of length and a derivation always starts with a single variable then a rule of the form must be used times to have a string of length , additionally since the rule of the form only introduces variables and never any terminal symbols, then we will require the rule to be used times to convert each of the variables produced by , thus there will be exactly steps in any derivation for a string of length .
- is the set of states
- is input alphabet
- is the stack alphabet
- is the transition function
- is the start state
- is the set of accept states
- and
- we have where and for some and
We define the following notation for the transition function of a pushdown automata:
- : the machine may make this transition by reading , popping from the stack and push to the stack
- : the machine may make this transition by reading and pushing to the stack
- : the machine may make this transition by reading popping from the stack
- : the machine may make this transition by reading and not doing anything to the stack
- : the machine may make this transition by doing the above logic, without having to read from the input.
If you are at a state, and one of the outgoing rules is , then if and the top of the stack is not then this rule cannot be used. If , then the rule can be used.
Similar to an NFA, when we write out a PDA, if there are no arrows for a particular, state, character, stack character pair, then this means that it maps to the empty set. If you get to a point where there are no possible outgoing rules to be used, then the PDA is said to be stuck, and that line of execution terminates.
The above PDA works because the bottom path will accept the string , and going through the top path reads the first character and pushes it into the stack, then non-determinism kicks in and it will read some number of ccharacters from the input without pushing anything to the stack, in one of paths of non-determinism there will be one where all but one character is read from the input, then the last transition will read a character and attempt to pop off a that character from the stack, if that occurs it ends up in the terminal state, if there were any more characters to read, then since there are no subsequent states the path would terminate, thus this implies that the only way a string could get accepted by this PDA if it starts and ends with the same character.
Note that we could also model this "termination behavior" discussed above by pushing the dollar sign on, and then having a trasition that takes it off the stack.
The second half of this PDA reads an input, and removes whatever character is on the top of the stack over and over non-deterministically, since there are no outgoing transitions from the terminal state, then a string is only accepted if it is entirely read by the non-determinism, additionally the fact that there is a dollar sign transition to the last state means that the stack must also be emptied by the time we get to the state before the terminal state.
If less than half the string is read during the first part of the PDA, then the stack will become empty before all the characters are read, causing the string to not be accept, similarly if more than half the string is read during the first part of the PDA, then the stack will not have the dollar sign when we get to the terminal state.
Therefore if a string is accept it must be that exactly that half the string is read during the first part of the PDA. Now note that there is a transition which reads but does nothing to the stack, this implies that exactly half the characters must be read during the first half of the PDA, and then in the second half of the PDA it will read a character and pop a character off the stack, which will make sure that the number of characters in the first half will equal the number of characters in the second half, showing that it accepts all strings of odd length with in the middle.
Suppose for the sake of contradiction that this language was regular, therefore there is some sucht that the properties hold true, if we consider the string 0 ^ { p } # 0 ^ { 2p } \in L ParseError: Expected 'EOF', got '#' at position 11: 0 ^ { p } #̲ 0 ^ { 2p } \in… then by the lemma we have that 0 ^ { p } # 0 ^ { 2p } = xyz ParseError: Expected 'EOF', got '#' at position 11: 0 ^ { p } #̲ 0 ^ { 2p } = x….
By the third property we have that since the first characters of our string are this implies that and by the second property of the lemma we also know that now we also know that # \in z ParseError: Expected 'EOF', got '#' at position 1: #̲ \in z therefore by the first property we can set to show that , but x y = 0 ^ { p - l } # 0 ^ { 2p } \notin L ParseError: Expected 'EOF', got '#' at position 21: … 0 ^ { p - l } #̲ 0 ^ { 2p } \no… thus a contradiction so is not regular
- T \to 0T \mid T0 \mid # ParseError: Expected 'EOF', got '#' at position 23: …T \mid T0 \mid #̲
- U \to 0U00 \mid # ParseError: Expected 'EOF', got '#' at position 17: … \to 0U00 \mid #̲
First we give an informal description of the language, since the language of a CFG equals to , then by induction on the length of the string produced by the second rule, starting with length 1, we can prove that productions of this rule are given by all strings in such that the string contains exactly one # ParseError: Expected 'EOF', got '#' at position 1: #̲.
Using a similar analysis the productions of the third rule in isolation are given by all strings in such that there is exactly one # ParseError: Expected 'EOF', got '#' at position 1: #̲ and if there are zeros to the left of # ParseError: Expected 'EOF', got '#' at position 1: #̲ then there are # ParseError: Expected 'EOF', got '#' at position 1: #̲'s on the right.
Finally the initial rule creates the union of these two langauges. We now move on to showing that the language is not regular.
Since we assumed was regular, then we'll try and obtain a contradiction through the pumping route, we do this by using the closure rules for regular langauges to focus on an even more specific subset of the language which should also be regular.
Since is regular, and the regular expression 0 ^ * # 0 ^ * ParseError: Expected 'EOF', got '#' at position 7: 0 ^ * #̲ 0 ^ * is also regular, then A = \operatorname{ lang } \left( G \right) \cap 0 ^ * # 0 ^ * = \left\{ 0 ^ { k } # 0 ^ { 2k } : k \in \mathbb{ N } _ 0 \right\} ParseError: Expected 'EOF', got '#' at position 55: …ht) \cap 0 ^ * #̲ 0 ^ * = \left\… is regular, but we know that it is not, thus a condtradiction, so then must not be regular.
- for each
Suppose that the language is context free, therefore the pumping lemma holds, and thus there is some with some properties. Consider since then by the pumping lemma we can write , where at least one of or is non-empty.
If which is to say the consist only of the same character, then makes the following false thus .
If either or contain more than one alphabet character then suppose wlog that , therefore and we know that thus
Thus no matter what we obtain a contradiction so it must be that is not context free.
Suppose that the language is context free for contradiction, therefore the pumping lemma for context free languages holds true and we obtain some such that if a string is longer than it some properties hold true.
Now the string and clearly therefore , we know that so they are both non-empty. Its either the case or not.
If , then there are couple of similar cases to consider, specficially if and , and suppose that so that where f we consider . Observe that in the given language for every we have that , since then , therefore this is a contradiction.
Similarly if we will obtain a symmetrical contradiction, for the case it is an identical anlysis on holds.
If its not true that then since not both of are empty then at least one of is an element of , suppose it is , then since all strings in are a sequence of then a sequence of s then a sequence of s then a sequence of s, clearly as it contains more than four sequences of and s as or , if it is that is non-empty the same analysis applies, which is a contradiction.
Thus not matter the case of we always get a contradiction, therefore is not context free.
Suppose that is context free for the sake of contradiction, then the pumping lemma holds on this language and thus there is some , then we consider the string which clearly has , thus .
We know that one of is non-empty, and they cannot both be empty, suppose that is empty and that is non-empty, then , if we will have a problem because the string has the property that thus . Therefore we must have that , since we assumed then no longer has the property that because it will change the string where the 's meet the 's.
Now suppose that both are non-empty,if resides on the left half of the string and resides on the right half of the string, then because then it must be that , thus this could yield a contradiction since has more 's than 's. Therefore, they most both be substrings of either the right or left hand side of the string, so without loss of generality asssume that they reside within the left side of the string. If then contains more 1s than 0s, which is a contradiction, if similarly if we get the same problem. If then has two 's as substrings in the left side of the string whereas the right side only has one which is a contradiction.
- is the set of states
- is the input alphabet not containing the blank symbol
- is the tape alphaphet which contains the blank symbol and
The machien is defined to halt when in the states or
- is the start configuration of on input
- each yields
- is an accepting configuration
Suppose that is Turing-recognizable, therefore there is some turing machine that recognizes so that which means that for any that accepts and halts on input , for each input, suppose the number of steps taken by the turing machine before halting is given by , then we define the language , this language is decidable. An element iff in steps iff as needed.
Suppose that such a language exists, since it is decidable then it is clearly recognizable and thus some enumerator enumerates, if it enumerates , then if we drop the second component , we obtain an enumerator for , and therefore is Turing-recognizable.
Since we assumed that and are co-Turing Recognizable that means that and are recognizable.
Since a language is turing recognizable iff it is enumerable by some enumerator then there exist enumerators E _ \overline{ A } , E _ \overline{ B } ParseError: Got function '\overline' with no arguments as subscript at position 5: E _ \̲o̲v̲e̲r̲l̲i̲n̲e̲{ A } , E _ \ov… that enumerate respectively.
We will now construct a turing machine and if we can make it a decider then we'll use .
Consider the turing machine such taht given an input it will run and in parallell, if E _ \overline{ A } ParseError: Got function '\overline' with no arguments as subscript at position 5: E _ \̲o̲v̲e̲r̲l̲i̲n̲e̲{ A } prints then we reject the input ; if E _ \overline{ B } ParseError: Got function '\overline' with no arguments as subscript at position 5: E _ \̲o̲v̲e̲r̲l̲i̲n̲e̲{ B } prints accept.
Now we must show that so suppose that then since then we know that , that is and , thus will eventually get printed out only by E _ \overline{ B } ParseError: Got function '\overline' with no arguments as subscript at position 5: E _ \̲o̲v̲e̲r̲l̲i̲n̲e̲{ B } so the machine will accept, so
We also have to show that so let again, are disjoint so this implies that that is and we also know thus will eventually get printed by only E _ \overline{ A } ParseError: Got function '\overline' with no arguments as subscript at position 5: E _ \̲o̲v̲e̲r̲l̲i̲n̲e̲{ A } so the machine will reject, and so , so as needed.
If then therefore E _ \overline{ A } ParseError: Got function '\overline' with no arguments as subscript at position 5: E _ \̲o̲v̲e̲r̲l̲i̲n̲e̲{ A } and E _ \overline{ B } ParseError: Got function '\overline' with no arguments as subscript at position 5: E _ \̲o̲v̲e̲r̲l̲i̲n̲e̲{ B } will print it in finitely many steps, thus our turing machine will halt. If E _ \overline{ A } ParseError: Got function '\overline' with no arguments as subscript at position 5: E _ \̲o̲v̲e̲r̲l̲i̲n̲e̲{ A } prints it first, then reject, otherwise if its E _ \overline{ B } ParseError: Got function '\overline' with no arguments as subscript at position 5: E _ \̲o̲v̲e̲r̲l̲i̲n̲e̲{ B } then accept
Thus we've shown that halts on all inputs and thus is a decider, since we showed that and then it's separated by a decidable language.
If was finite, then since there are infinitely many decidable languages, then at least one of them must be decided by a machine that is not in , therefore assume that is infinite, since is turing recognizable, then we know that its enumerable by some enumerator , now we define the following turing maachine
Let be the turing machine operating on positive integers such that given the input we run the enumerator until we have printed out unique turing machines, say , then run with the input and do the opposite of whatever outputs.
is a decider, this is because must enumerate all of the elements in a finite number of steps and because every turing machine encoded in was a decider, so nothing will loop forever in the above definition.
Since we have inverted the behavior for each then we have induced a diagonalization argument, this is because we have inverted the behavior of the selected machine meaning that XOR must hold true, this shows that cannot decide for each , and therefore no turing machine encoded in can, on the other hand decides that language, as needed.
If we consider the language which is not a regular language as seen earlier. We will show that is mapping reducible to , also note that this finite language is clearly regular.
So we have to show that there is a computable function such that . If we define the function then it satsfies the requirement that
This function is computable because we can create a turing machine that uses a stack to recognize strings from as they are of the form , whenever it recognizes a string then it writes to the tape, and outputs if it rejects the input string , thus this function is computable. Additionally this function halts on all inputs, as for every finite string by the time we get to the end of the string in finitely many steps the stack is observed and a decision is made.
Thus we've shown that where is regular, but is not.
Suppose for the sake of contradiction that was decidable, we'll get a contradiction by showing that is decidable.
Since is decidable, then there exists some decider for the language , we'll now construct a decider for to obtain our contradiction.
We will do this by constructing a decider for by using the following idea, given we only accept if accepts where is a turing machine that we will define during an intermediate phase, will have the property that accepts if and only if .
If all that is set in place, then we have is accepted by iff accepts iff accepts , that is accepts iff accepts .
Now that we have the idea, we can formally construct based on the specification of .
- Given
- Construct as follows
- on input
- if accept
- if
- run on the input if it accepts, then accept, otherwise reject
- Run on the input and output what it outputs
Note that is a decider, this is because the construction of takes finitely many steps as we are not actually running anything, just constructing, then when we run the encoding of this machine on since it is a decider then it is guarenteed to halt in finitely many steps.
The language seems arbitrary, but it was simply chosen as it is one of the many languages that thas the property that that there exists some string in the language such that is not in in the language, for this example we can see that the string is in the language but is not. Keep in mind we could have used any language that satifies this property.
Thus if we have any turing machine such that then we know that , while at the same time if then clearly .
Therefore if we observe our definition of we can see that if accepts then so then . and also if does not accept then so that implies that , thus accepts iff .
Since we have a decider for then we just have to run with the input . Therefore we've constructed a decider for which is a contradiction, therefore it must not be true that is decidable, therefore it is undecidable.
Suppose for the sake of contradiction that was a computable function, that is there is some Turing machine such that on every input it halts with just on its tape.Specifically we'll assume without loss of generality that it does so in unary, so we have some turing machien such that whenever the input is then halts with on the tape.
We'll now observe a special TM that will yield a contradiction, this turing machine will fit those turing machines that the busy beaver function talks about, and so it will be a turing machine that halts when started on a blank tape. It will write ones to the tape, it then doubles the number of ones and then simulates the turing machine on what is currently on the tape (), and therefore will halt with ones on the tape.
Next we can show that is a strictly increasing function, this is because for every -state turing machine that halts when started on a blank tape, there is an analagous -state turing machine that also halts when started on tha blank tape and simulates the other machine with one extra state which does nothing, this shows us that , also if we use that extra state to write another one to the tape, then we have that .
takes states to write each to the tape initially, but doubling the ones on the tape only requires a constant number of states to do, and simulating only takes a finite number of states, therefore would have -states. is a turing machine that halts when started with an empty tape, and when it terminates it has ones on the tape, since is the maximum number of ones over all turing machines with states that terminate when started on an empty tape, then we can conclude that .
Since is some constant, then once then we have that and since we concluded that was a strictly increasing function then this would imply that which is a contradiction, therefore our assumption that was computable is false.
Suppose that is turing-recognizable and and so there exists a turing machine that recognizes A.If we consider the function , clearly there is a turing machine such that for every it halts with just on its tape because all it would have to do is paste the encoding of and then .
Moreover we know iff iff iff , that is to say that showing that is mapping reducible to
Now we show the other direction, where we assume that , since is Turing recognizable by the Universal Turing machine (the turing machine that just simulates other turing machines), then that implies that is turing recognizable, as needed.
Suppose that is decidable, therefore there is some turing machine such that given some it accepts if and rejects if , now if we make a simple wrapper turing machine that simply takes in an input simulates on , and if accepts output and if it rejects output , then this creates a computable function such that if and if .
Since then we can say that , therefore we have
Now we assume that , since we already discovered that regexs are decidable, then is decidable, and thus is decidable.
We claim that is mapping reducible to by the function . The reason this is so is is computable as there is a certainly a turing that can append to the front of an input string onto the tape, additonally if then , and if it implies that therefore , so we have , since is not turing recognizable, then neither is .
We also claim that is mapping reducible to , if we use the function the details are similar to the above in that is computable, and also in that if , then , and that if then it must be that , thus we have and since is not turing recognizable, then neither is
- on input :
- for each string
- since is decidable there is a decider for it, so we can run on and on and compare the results, if they are the same go to the next iteration, otherwise if they are different accept
We claim that this is a recognizer, this is because if and only if there exists some such that and (or vise versa), iff the above turing machine terminates in the accept state after iterations.
Therefore the above turing machine terminates in the accept state if and only iff therefore it is a recognizer.
Instead of doing a turing machine argument we do it by counting, first of all we show that is in bijection with to do this, we consider any subset of which is of the form where each each has a length, that is it is a sequenece of ones in a row, thus for each wherein we have we set the th element of the infinite binary string to and the rest to zero, this sets up the mapping.
Clearly this function can hit any output, so given any infinite binary string, we just select the elements in of corresponding length. Additionally given any collection of subsets we know which string will hit it, all that remains is injectivity which is simple to prove, and we will not go into that detail.
Thus we have a bijection from to therefore since we already know that the latter is uncountable, then so is the former.
Since the set of all turing machines is a subset of all possible strings which is countable, then the number of possible turing machines is countable, and thus the number of languages that are recgonized is also countable, therefore there is some element of which is not recognized by some turing machine, select that one, this is our example of a subset of which is undecidable, because we already know it is unrecognizable.
Recall that the fixed point is a turing machine which when fed through yields a turing machine equivalent to the original. Suppose we had such a machine and lets see the restrictions on this machine, if we gave this machine some input and it halts, then this must be because it either entered the accept or reject state, since inverts this behavior, then on this input the two machines would differ (one accept and one reject), thus if such a fixed point machine were to exist, it must be that it never halts.
If is a turing machine that loops forever, then by definition this means that it never enters the accept or reject state, therefore if we consider then this is still a machine that loops forever on all inputs, thus the language of the two machines is the same (empty) and they are equivalent, thus any machine that loops on all possible inputs is a fixed point.
Something that works well here is embedding both languages into the following set . The reason we use such a set is that we know that and that Now we will start by proving that , to do this we assume that we have an oracle for , and now we construct a decider for , to do this we construct a turing machine as follows:
- on input we query the orcale if is an element of , if it is we accept, and otherwise reject
As mentioned above thus the above turing machine accepts if and rejects if , that is it is a decider for
The exact same construction where we query the oracle with decides
We need to come up with an algorithm which will compute the descritpive complexity of a binary string , we'll first introduce the idea, and then refine it so to actually work correctly. A naive approach would be to simply go through all binary strings in lexographic order, if we were on string we would then try all possible ways of parsing it into the form where is a turing machine an arbitrary input string, if no parsing works for string then we would try the next string.
If it so happened that was parsable into then our goal would be to check if on input halts with on its tape, and we would return , this would work because lexiographic order forces shorter strings to come before longer strings, thus enforcing the two requirements that descriptive complexitiby be as small as possible and in the case of ties choosing the one that comes first in the lexicographic ordering.
The one problem with our plan is that running on input may never halt, as its just a regular turing machine, and so we need a way to get around this, this is why the assumption of having the oracle is there, as it gives us a method to determine if a turing machine will halt. Consdier the turing machine if we construct a new turing machine that is but whenever there is a transition that leads to a reject state, it instead takes us to the accept state, then when we query the oracle with then it accepts iff on input halts (either enters a reject or accept state). This provides us with a way to check if on input will halt in a finite number of steps making our algorithm tractable. Thus our final algorithm as as follows:
- For each binary string iterated in lexicographic order
- attempt to parse into where is a turing machine an input, if it cannot be parsed, then move to the next string otherwise continue to the next step
- Make the modifiation of to as specified in the previous paragraph, and check if using the oracle, if it is not an element then go to the previous step, otherwise therefore we know that on input halts
- Run on input and if what remains on the tape is then return and stop this algorithm
Also note that even though the above seems to be a potentially infinite loop, but we can make it finite as we already know that there is some such that and so we only have to test strings up until this cut off.
Suppose for the sake of contradiction that is decidable relative to , which is to say that there is an oracle machine that decides , and now we construct the following which we will call
- On input
- Run on
- If accepts, then reject and if it rejects then accept
Since this turing machine just inverts the output of a decider it is also a decider. If we run on the input , then it will accept iff rejects , which is a contradiction, and it will reject iff accepts which is also a contradiction, therefore our assumption is incorrect and so is undecidable.
Recall that is not decidable, but it is recognizable. Because of that we know that must not be recognizable, if it were then we would be able to construct a decider for .
If is not recognizable, then if we can make a mapping reduction to , then we could deduce that is unrecognizable as well. In order to do this we would have to come up with a function such that , in otherwords we need a computable function such that whenever we have a turing machine and input that does not halt, it gets mapped to a turing machine that always halts, and if is a turing machine that always halts, then it must be that is of the form where loops on input .
We construct the function as follows, so that on input :
- We construct a turing machine such that on input
- Simulate on input for iterations
- If halted, then go into an infinite loop
- If has not yet halted, then halt
Now supose that , therefore where loops on input , then where is specified above. Then for any input if we run then since loops, we will hit the second if statement, and will halt, which implies that , so
Now suppose that so that where halts on input , then now since halts on , suppose that it halts in steps, if that's the case then we select an input such that , so that after iterations, we've guarenteed that has halted on so that we go into the first if statement and loop forever, this implies that . This concludes showing that , therefore since is computable, then we've showing that is mapping reducible to and since is unrecognizable so is .
We will show that the complement of which is the set is not recognizable. We do a similar reduction from , given any we construct a machine such that on input , it ignores input and just simulates on input .
Suppose , therefore , and does not halt on , therefore the machine doesn't halt on any input, and so .
Now suppose that that is to say that and we know that halts on input , therefore halts on every input, meaning that , this shows that , thus since was unrecognizable, so is .