# Finite strings and relationships between words [closed]

I have a finite alphabet Σ and Σ* refers to the set of all finite strings over Σ.

1) Given x, y ∈ Σ* we say that x is a prefix of y if ∃z ∈ Σ* y = xz. If x is a prefix of y and y is a prefix of x what is the relationship between x and y?

I'm assuming it is a direct relationship because as x goes up so does y, but I'm not sure if that's correct.

2) For this part we assume that Σ = {a, b}. We write #a(x) for the number of occurrences of the letter a in the word x and similarly for #b. We claim that ∀x ∈ Σ*, ∃y, z ∈ Σ* such that x = yz ∧ [#a(y) = #b(z)].

Is this true? Prove or disprove.

• What are your thoughts? We are not a homework solution service. Commented Sep 23, 2015 at 22:43
• Hello! We discourage posts that simply state a problem out of context, and expect the community to solve it. Assuming you tried to solve it yourself and got stuck, it may be helpful if you wrote your thoughts and what you could not figure out. It will definitely draw more answers to your post. Until then, the question will be put on hold to give you a chance to try to solve it yourself and then edit the question. You might want to try working with some examples, and see if you can spot any patterns -- then see if you can prove they always hold.
– D.W.
Commented Sep 24, 2015 at 4:06
• Hint for the second part: consider #a(y)-#b(z) as a function of the splitting point. What is its value at the extreme cases? How does it change when the point moves? Commented Sep 24, 2015 at 11:34

For your first question, if $x$ is a prefix of $y$ then there is a $z$ such that $y=xz$. Similarly, if $y$ is a prefix of $x$ then $x=yw$ for some $w$. Then $$y=xz=ywz$$ and if we remove the characters in $y$ from both sides sequentially, we conclude that $wx=\epsilon$, the empty string, so $w=x=\epsilon$ and hence $y=x$.