From this answer, proving the formula $\binom{2n}{n}-\binom{2n}{n+1}$ for the number of "legal" (ie, "balanced" or "properly matched") sequences of parentheses of length $2n$,
there is a least $k$ where there is a right parenthesis at position $k$ and equally many left and right parentheses before $k$
Why should this be necessarily true? Though I don't see any counterexamples, I can't prove it either.
Here is my digging:
Take any legal sequence and flip a correctly matched pair, then we have an illegal sequence. Note that, in any legal sequence, the ( will always be before the ) in one pair. So after the flipping, the ) will come first. As everything before the ) is correctly matched, so that proves that there is a ) before which there are equally many left and right parentheses.
But I'm not convinced. Why should this account for all illegal sequences? What if there are more than one correctly matched sequences flipped?
I want to have a rigorous proof, but I can't find it. Does anyone has an idea?
Thanks!
(is a counter example. I would prove this inductively. It's clear for $n=1$:)(. Assume it's true for $n=k$, then break $n=k+1$ into three cases: First parentheses is right (immediate), first is left and last is left, and first is left and last is right (reduces to $n=k$). In the middle case, #LP-#RP in first $c$ characters goes from 1 at $c=1$, to negative at some point, so it must equal $-1$ at at least one value of $c$. – Joe Oct 10 '21 at 05:31(())and I flip the middle pair, I get()(), which is still valid. – Brian Tung Oct 10 '21 at 06:32