Saturday, 15 July 2017

Prove reversal of a string by induction




I am trying to prove that:



(uv)R = vRuR



where R is the reversal of a String defined recursively as:



aR = a



(wa)R = awR




I think I have the base case right, but I am having trouble with the inductive step and final proof.



here is what I have:



Base Step



prove for n = 1 where |uv| = 1



(uv)R = uReR = uR = u (where e is the empty string)




I dont really know where to go from here, any help would be great.



Thanks


Answer



I agree with Henning that your induction should be on |v|. Note in the case |v|=1, you're done by definition. It's probably also worth mentioning something about the empty string for completeness.



Let me demonstrate how I would prove this for |v|=3 supposing we knew this were true for when |v|=2. This should illustrate how you should prove |v|=n from assuming |v|=n1 is valid.



Let v=v1v2v3 be a string of length 3. Assume the claim is true for strings of length 2. Then (uv)R=(uv1v2v3)R. By the recursive definition, (uv1v2v3)R=v3(uv1v2)R. Note v1v2 is a string of length 2, so we have v3(uv1v2)R=v3(v1v2)RuR. But by definition, v3(v1v2)RuR=v3v2v1uR=(v1v2v3)RuR.




In almost all inductive proofs, it helps to prove a few small cases by using even smaller cases. If you're still having trouble, try proving this for |v|=4 by using the same ideas as above.


No comments:

Post a Comment

real analysis - How to find limhrightarrow0fracsin(ha)h

How to find lim without lhopital rule? I know when I use lhopital I easy get $$ \lim_{h\rightarrow 0}...