Prove that $(()())\in P$ (the set of balanced paranthesis) and $))(() \notin P$

102 Views Asked by At

Given the recursive definition of $P$ (the set of balanced paranthesis):

Base: $() \in P $. Recursive step: if $w \in P$ then: $$(w) \in P$$ $$()w \in P$$ $$w() \in P$$

And I have to prove that $(()()) \in P$ and $))(() \notin P$. For the first one, can I assume that the starting word is $()() \in P$, then by applying the first rule I get $(()())$. And for that starting word $()() \in P$. I can asume that the starting word is $() \in P$, then by appling the third rule I get $()() \in P$.

However this reasoning doesn't seem correct. And I don't how to extend this possibly incorrect reasoning to the second part.

What is the right way to do it. At least, how should I think?

2

There are 2 best solutions below

2
On BEST ANSWER

$() \rightarrow_2 ()() \rightarrow_1 (()()).$

For the second part, it is clear (can be proved by induction) that, for every element of $P$, there always is a $($ on the further left.

0
On

Define the imbalance of a word $u$ on the alphabet $\{(,)\}$ as $|u|_( - |u|_)$, that is, the difference between the number of occurrences of $($ and $)$ in $u$. There is a nice characterisation of the set of balanced parenthesis:

A word on the alphabet $\{(,)\}$ is balanced if and only if its imbalance is $0$ and the imbalance of each of its prefixes is nonnegative.

It follows that $(()())$ is balanced and $))(()$ is not.