Using regular expressions, prove that if L is a regular language then the \emph{reversal} of L, LR={wR:w∈L}, is also regular. In particular, given a regular expression that describes L, show by induction how to convert it into a regular expression that describes LR. Your proof should not make recourse to NFAs.
We will assume that we are given a regular expression that describes L. Let us first look at the concatination operator (∘), and then we can move onto more advanced operators. So our cases of concatenation deal with the length of what is being concatenated. So first we will break all concatenations from ab to a∘b. When dealing with these break the components up as much as possible: (ab∪a)b→(ab∪a)∘b, but you cannot break associative order between different comprehensions of course.
When ∅R→∅
When s=ϵ, we have the empty string which is already reversed thus the mechanism does not change
When s is just a letter, as in s∈Σ, the reversal is just that letter, s
When s=σ, we have a single constituent so we just reverse that constituent and thus σR
When s=(σ0σ1...σk−1σk) where k is odd, we have a regular expression which can be written as (σ0∘σ1...σk−1∘σk). The reversal of these even length strings is simple. Merely switch the 0 index with the k index. Then Switch the 1 index with k-1 index. Continue till the each element was switched once. Thus the last element is now the first in the reg ex, and the first is the last. The second to last is the second and the second is the second to last. Thus we have a reversed reg ex which will accept the reversed string (first letter is the last etc.) And of course we reverse each constituent. Thus we would get (σRkσRk−1...σR1σR0)
When s=(σ0σ1...σk/2...σk−1σk) where k is even, we have a regular expression generally which can be written as (σ0∘σ1...σk−1∘σk). The reversal of these even length strings is simple. Merely switch the 0 index with the k index. Then Switch the 1 index with k-1 index. Continue till the each element was switched once, but the k/2 element (an integer because k is even). Thus the last element is now the first in the reg ex, and the first is the last. The second to last is the second and the second is the second to last. Thus we have a reversed reg ex which will accept the reversed string (first letter is the last etc.). And that middle letter. And of course we reverse each constituent. Thus we would get (σRkσRk−1...σRk/2...σR1σR0)
Okay the hard part is done. Let us look to the ∪ operator. This is merely a union of sets. So given two strings, s1,s2, the reverse of s1∪s2 is only sR1∪sR2. The union will not change. And this makes sense. This will only add strings to a set. It does not matter which order they are added to the set, all that matters is that they are.
The kleene star operator is the same. It is merely adding strings to a set, not telling us how we should construt the string persay. So to reverse a kleene star of a string s, is only ((sR)∗). Reversal can just move through them.
Thus to reverse this (((a∪b)∘(a))∗∪((a∪b)∘(b))∗)R we simply follow the rules. To reverse the outer union we simply reverse its two components. To reverse this: ((a∪b)∘(a))∗ kleene star, we simply reverse what is inside it →(((a∪b)∘(a))R)∗. Then to reverse a concatenation, we index and then switch greatest with least. So we start with ((a∪b)∘(a))R and get ((a)R∘(a∪b)R). To reverse that single letter, we reach our base case and get (a)R→(a). This process outlined above describes an inductive description of this change.