Let $U$ be the following language. A string $s$ is in $U$ if it can be written as:
$s = 1^{a_1}01^{a_2}0 ... 1^{a_n}01^b$,
where $a_1,..., a_n$ are positive integers such that there is a 0-1 sequence $x_1, ..., x_n$ with $x_1a_1 + ... + x_na_n = b$. Show that $U \in P$.
Not sure how to even approach the problem. Any help would be appreciated. I dont want the answer specifically, but any hints or help would be great.
Thanks
If I’ve understood the description of $U$ correctly, it’s context-free, and all context-free languages are in $P$. I’ve spoiler-protected a context-free grammar for it below.