2

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!

Blue
  • 83,939
  • 2
    First, as stated in that post, this applied to sequences that have $n$ left parentheses and $n$ right parentheses. Otherwise ( 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
  • I don't see that your first "rule" is correct: If I start with (()) and I flip the middle pair, I get ()(), which is still valid. – Brian Tung Oct 10 '21 at 06:32
  • @BrianTung Yes, that is why I wasn't convinced. I wasn't able to see that, thanks for pointing out though. – Book Of Flames Oct 10 '21 at 06:38

1 Answers1

2

Associate to a sequence of parantheses a sequence of $1$, $-1$, by $(\mapsto 1$, $)\mapsto -1$.

Balanced sequence $a_1 a_2 \ldots a_{2n}$ means

  1. $ \sum_1^k a_i\ge 0$ for all $1\le k \le 2n$

  2. $ \sum_1^{2n} a_i = 0$

Let's show first: a sequence of $1$, $-1$, is legal if and only if it is balanced.

Now, legal sequences are sequences obtained as follows: start from the empty sequence, perform several steps of form

$$ A,B \mapsto A, 1,-1, B$$ that is, we insert into the word $A,B$ at some position the piece $1, -1$ ($A$, $B$ are words in $1$, $-1$, possibly empty).

We can see that if $AB$ is balanced, so is the new sequence. Hence, by induction, all legal sequences are balanced.

Conversely: say we have a balanced sequence of $1$, $-1$. Consider the first appearance of $-1$ from the left. Before it, there must be $1$. So our sequence is of the form $A, 1, -1, B$. It is easy to see that $A,B$ is again balanced.

Therefore: legal is equivalent to balanced.

Consider now a sequence with $\sum_1^{2n} a_i = 0$ that is not legal. Then there must exist $k$ such that $\sum_1^k a_i < 0$. Consider $k$ smallest with such property. Then $k=1$, or $\sum_1^{k-1} a_i \ge 0$. The cannot be $> 0$, since then $a_k\le -2$. Therefore we have $\sum_1^{k-1}a_i = 0$, and $a_k=-1$ $\square$

orangeskid
  • 56,630