Corrected typos.
It is unclear to me whether this response, which describes how Inclusion-Exclusion may be analytically used to conquer the problem, is what the original poster is looking for. That is, it is unclear to me, what the original poster intends by the phrases "(identifying) the redundant cases" or "a more structured approach".
Under normal circumstances, Inclusion-Exclusion by itself, is a nightmare for this type of problem (at least when the numbers are significantly larger). However, when you combine a convoluted form of Stars and Bars theory to the analysis, the analysis is eased.
See this article for an introduction to Inclusion-Exclusion.
Then, see this answer for an explanation of and justification for the Inclusion-Exclusion formula.
For Stars and Bars theory, see
this article and
this article.
The idea is to use Stars and Bars theory to facilitate the analytical (rather than manual) computation of each $~T_r,~$ where the Inclusion-Exclusion formula will typically have a form like $~\displaystyle \sum_{r = 0}^n (-1)^r T_r.$
For prior examples where such an approach was taken, see
this answer,
or Method 2 only of this answer.
Let $~S~$ denote the set of all $~20~$ bit strings that have exactly $~9~$ 1's.
For $~k \in \{1,2,\cdots,16\},~$ let $~S_k~$ denote the subset of $~S~$ that contains the string 11011 starting in position $~k,~$ where the first position on the left is position $~1,~$ and the last position on the right is position $~20.~$
For example, an element in $~S_1~$ is a binary string of length $~20,~$ that contains exactly $~9~$ 1's, that contains 11011 starting in position $~1,~$ and may or may not also contain 11011 starting in some other position or positions.
Then, the desired computation is
$$| ~S_1 \cup S_2 \cup \cdots \cup S_{16} ~|. \tag1 $$
Let $~T_1~$ denote $~\displaystyle \sum_{1 \leq i_1 \leq 16}
| ~S_{i_1} ~|.$
That is, $~T_1~$ represents the sum of $~\displaystyle \binom{16}{1}~$ terms.
For $~r \in \{2,3,\cdots,16\},~$
let $~T_r~$ denote $~\displaystyle \sum_{1 \leq i_1 < i_2 < \cdots < i_r \leq 16}
| ~S_{i_1} \cap S_{i_2} \cap \cdots \cap S_{i_r} ~|.$
That is, $~T_r~$ represents the sum of $~\displaystyle \binom{16}{r}~$ terms.
Then, in accordance with Inclusion-Exclusion theory, the computation in (1) above is equivalent to
$$\sum_{r=1}^{16} (-1)^{r+1} T_r. \tag2 $$
So, the entire problem reduces to computing $~T_r ~: ~r \in \{1,2,\cdots,16\}.$
$\underline{\text{Computation of} ~T_1}$
By considerations of symmetry, you have that
$~|S_1| = |S_2| = \cdots = |S_{16}|.$
Further, an element in $~S_1~$ will start with 11011, which leaves $~15~$ positions unspecified, of which exactly $~5~$ must be 1's, since the string is required to have exactly $~9~$ 1's.
Therefore, $~\displaystyle |S_1| = \binom{15}{5}.$
Therefore,
$$T_1 = \binom{16}{1} \times \binom{15}{5}.$$
$\underline{\text{Manual Computation of} ~T_2}$
The symmetrical considerations in the computation of $~T_1~$ break down when computing $~T_r ~: r \geq 2.~$ In this section, no attempt at an analytical computation (with Stars and Bars) will be attempted. Instead, a manual approach to the problem will be taken. The idea is to stretch the reader's intuition so that the underlying concepts become instinctive.
First consider the following tableaus:
Tableau-1 : 1 1 0 1 1 1 1 0 1 1 .... : 10 positions taken, 8 1's used.
Tableau-2 : 1 1 0 1 1 0 1 1 .... : 8 positions taken, 6 1's used.
Tableau-3 : 1 1 0 1 1 1 0 1 1 ... : 9 positions taken, 7 1's used.
Tableaus 1,2,3 are represented by
$~[ ~S_1 \cap S_6 ~], [ ~S_1 \cap S_4 ~],~$ and $~[ ~S_1 \cap S_5 ~],~$ respectively.
Note that by the problem constraints, $~[ ~S_1 \cap S_2~] = \emptyset =
[ ~S_1 \cap S_3 ~].~$
Note further, that if a specific intersection uses exactly $~n~$ positions, and has exactly $~m~$ 1's $~: m \leq 9,~$ within those $~n~$ used positions, then the number of elements (i.e. distinct satisfactory binary strings) represented by that intersection will be $~\displaystyle \binom{20-n}{9-m}.$
Keeping in mind that $~T_2~$ represents the sum of $~\displaystyle \binom{16}{2} = 120 ~$ terms, the question is: how many of those $~120~$ terms will have an enumeration of $~0,~$ will have an intersection that corresponds to tableau-1 above, will have an intersection that corresponds to tableau-2 above, or will have an intersection that corresponds to tableau-3 above.
There are exactly $~14~$ possible intersections of form $~S_k \cap S_{k+2},~$ and exactly $~15~$ possible intersections of form $~S_k \cap S_{k+1}.~$
Therefore, $~29~$ of the terms in $~T_2~$ will equal $~0.$
Similarly, there will be exactly $~13~$ terms that correspond to tableau-2, each of which will have an enumeration of $~\displaystyle \binom{12}{3}.~$ The tableau-2 subtotal is therefore,
$$13 \times \binom{12}{3}.$$
Also, there will be exactly $~12~$ terms that correspond to tableau-3, each of which will have an enumeration of $~\displaystyle \binom{11}{2}.~$
The tableau-3 subtotal is therefore,
$$12 \times \binom{11}{2}.$$
By inference, there must be $~120 - [ ~29 + 13 + 12 ~] = 66~$ terms in $~T_2,~$ that correspond to tableau-1. This may be confirmed by reasoning that as $~i_1~$ goes from $~1~$ through $~11,~$ inclusive, the number of corresponding values of $~i_2~$ that will represent a tableau-1 intersection are $~12 - i_1.$
Therefore, the number of tableau-1 terms in $~T_2~$ is
$$\sum_{i_1 = 1}^{11} (12 - i_1) = 66.$$
The tableau-1 subtotal is therefore
$$66 \times \binom{10}{1}.$$
Therefore,
$$T_2 = \left[ ~29 \times 0 ~\right] + \left[ ~13 \times \binom{12}{3} ~\right] + \left[ ~12 \times \binom{11}{2} ~\right] + \left[ ~66 \times \binom{10}{1}~\right].$$
$\underline{\text{Analytical Computation of} ~T_2}$
This section will use Stars and Bars analysis to ease the computations that were detailed in the previous section.
Consider the following tableau:
- - - i-1 - - - - - - i-2 - - - - -
The above tableau, which represents $~i_1 = 4, i_2 = 11, ~$ represents the $~[ ~S_4 \cap S_{11}~]~$ intersection. The placement of $~i_1~$ and $~i_2~$ create $~(2 + 1) = 3 ~$ islands. Letting $~x_1, ~x_2, ~x_3, ~$ denote the respective sizes of these islands, reading the islands from left to right, you have that $~( ~x_1,x_2,x_3 ~) = ( ~3,6,5 ~).$
Note that since $~2~$ of the $~16~$ positions are occupied by the placement of $~i_1~$ and $~i_2,~$ you must have that $~x_1 + x_2 + x_3 = (16 - 2) = 14.$ Therefore, the number of possible intersections is the same as the number of solutions to:
$x_1 + x_2 + x_3 = (16 - 2) = 14.$
$x_1, x_2, x_3 \in \Bbb{Z_{\geq 0}}.$
By basic Stars and Bars theory, the number of such intersections is
$~\displaystyle \binom{14 + [3-1]}{3-1} = \binom{16}{2} = 120.$
So, each intersection represented by $~T_2~$ may be represented by the corresponding ordered $~3$-tuple $~(x_1,x_2,x_3).~$
Further, to classify each such intersection, you can ignore the values of $~x_1~$ and $~x_3,~$ and instead focus on the value of $~x_2.~$
In any such ordered $~3$-tuple, one of the following must occur:
$x_2 = 0.$
$x_2 = 1.$
$x_2 = 2.$
$x_2 = 3.$
$x_2 \geq 4.$
When $~x_2~$ must equal a specific value $~a,~$ then the number of corresponding ordered $~3$-tuples will equal the number of solutions to
By basic Stars and Bars theory, there will be
$~\displaystyle \binom{[16-2] - a + [2-1]}{2-1} = (15 - a)~$ solutions.
Alternatively, when $~x_2~$ must be $~\geq a,~$ then you can use the change of variables $~y_2 = (x_2 - a) \implies y_2 \in \Bbb{Z_{\geq 0}}. ~$. Then, the number of corresponding ordered $~3$-tuples will equal the number of solutions to
$x_1 + y_2 + x_3 = (16 - 2) - a.$
$x_1, x_3 \in \Bbb{Z_{\geq 0}}.$
$y_2 \in \Bbb{Z_{\geq 0}}.$
By basic Stars and Bars theory, there will
$~\displaystyle \binom{[16-2] - a + [3-1]}{3-1} = \binom{16 - a}{2} ~$ solutions.
As discussed in the previous section, any such ordered $~3$-tuple, where $~x_2 = 0,~$ or $~x_2 = 1,~$ may be ignored.
So, to start the analysis, I will create a function $~f,~$ with domain
$~\{2,3,4\},~$ such that
$f(2) = 15 - 2, ~f(3) = 15 - 3, ~f(4) = \displaystyle \binom{16 - 4}{2}.$
Then the function $~f~$ will represent the number of solutions (i.e. ordered $3$-tuples, or intersections).
Then, I will define the function $~g,~$ also with domain $~\{2,3,4\},~$ such that
$g(2) = \displaystyle \binom{20 - 8}{9-6}, ~g(3) = \binom{20 - 9}{9-7}, ~g(4) = \binom{20 - 10}{9-8}.$
Then, the function $~g~$ will denote the number of elements in such a corresponding intersection.
Consequently, you have that
$$T_2 = \sum_{a=2}^4 \left[ ~f(a) \times g(a) ~\right]$$
$$= \left[ ~13 \times \binom{12}{3} ~\right] + \left[ ~12 \times \binom{11}{2} ~\right] + \left[ ~\binom{12}{2} \times \binom{10}{1} ~\right].$$
$\underline{\text{Shortcomings In The Analytical Computation of} ~T_2}$
While the previous section provides a good contrast with the section on manually computing $~T_2,~$ the previous section also has some serious shortcomings.
The previous section did correctly indicate that variables $~x_1,~$ and $~x_3,~$ may be ignored. In fact, for the computation of $~T_r ~: ~r \in \{2,3,\cdots,16\},~$ you will have $~(r + 1)~$ variables $~x_1, x_2, \cdots, x_{r+1},~$ where the two specific variables $~x_1~$ and $~x_{r+1}~$ may be ignored.
However, the remaining $~(r-1)~$ variables $~x_2, \cdots, x_r~$ must each be scrutinized to determine whether they are $~< 2, = 2, = 3,~$ or $~\geq 4.$
This implies that it will take some creativity to determine :
What mutually exclusive categories should be created to classify each of the $~\displaystyle \binom{16}{r}~$ terms in the computation of $~T_r.$
How many terms (i.e. solutions) belong in each category.
This roughly analogizes to the use of the $~f~$ function in the previous section.
In each category, how many positions are used, and how many 1's are used.
This determines, for each category, how many binary strings are in any intersection that is represented by this category.
This roughly analogizes to the use of the $~g~$ function in the previous section.
Some convoluted Stars and Bars theory will be needed to address the above bullet points.
The goal will be to create generalized formulas for $~f~$ and $~g~$ that may be applied in the computation of each $~T_r ~: ~r \geq 2.$
Before discussing/implementing a complete solution to the general problem, I am going to look at the computation of $~T_r ~: ~r \geq 4,~$ for this particular problem. Then, in the subsequent discussion section, I will refer to this computation.
$\underline{\text{Computation of} ~T_r ~: ~r \geq 4}$
Consider the following tableau:
i-1 - - i-2 - - i-3 - - i-4 - - - - - -
This represent $~S_{i_1} \cap S_{i_2} \cap S_{i_3} \cap S_{i_4},~$ which may also be represented as
$~(x_1, x_2, x_3, x_4, x_5) = (0, 2, 2, 2, 6).$
When trying to minimize the number of 1's used in an intersection, the most efficient approach is clearly to have $~S_{k+1} = S_k + 3 \implies x_{k+1} = 2.$
So, the above intersection, which represents one of the terms in the computation of $~T_4,~$ requires $~4 + [ ~2 \times (4-1) ~] = 10~$ 1's.
Since each binary string can have no more than $~9~$ 1's, the above intersection represents the emptyset. Further, since the above intersection represents the most efficient use of 1's for any intersection represented by one of the terms in $~T_4,~$ you must have that any intersection represented by one of the terms in $~T_4~$ must be the empty set.
Therefore, you must have that $~T_4 = 0.$
This similarly implies that for all $~r \in \{4,5,\cdots,16\},~$ you have that $~T_r~$ equals $~0.$
$\underline{\text{General Analysis For} ~T_r ~\text{In Range}}$
For this particular problem, the only values of $~r~$ that are in range are $~r \in \{1,2,3\}.~$
So, for this particular problem, I could have routinely bypassed any analytical discussion of the computation of $~T_2~$ or $~T_3,~$ and used manual discussion instead. After all, besides $~T_1,~$ where symmetrical considerations apply, only two such $~T_r~$ computations are involved, for this particular problem.
However, I am more ambitious than that. Suppose for example, you were concerned about the 11011 pattern in binary strings of length $~100,~$ where each string was required to have exactly $~60~$ 1's. Then, any manual approach would be extremely problematic.
So, in this section, I am going to go beyond the proscribed limits of this problem and consider any $~T_r ~: ~r~$ in range.
However, in this section, the analysis will be more in English, rather than in mathematics. This analogizes to the contrast between pseudocode and coding in a specific coding language.
So, you start by assuming that there are two fixed constants, $~N~$ and $~M,~$ which respectively represent the required exact length of the binary string and the required exact number of 1's in the binary string.
Then, you let $~r~$ represent the number of subsets of $~S~$ that will be intersected. This definition of $~r~$ dovetails with the variable $~T_r.~$
Then, you have the basic equation
$x_1 + x_2 + \cdots + x_r + x_{r+1} = (N - 4 - r).$
Then, you assign the variables, $~b, ~c, ~$ to respectively represent how many of the $~(r-1)~$ variables $~ x_2, x_3, \cdots, x_r,~$ are $\geq 4,~$ or $~= 3.~$
Note that it is (in effect) forbidden for any of the variables $~x_2, x_3, \cdots, x_r~$ to equal either $~0,~$ or $~1.$
Therefore, any of the $~(r - 1)~$ variables that are $~< 3,~$ must be $~= 2.$
So, within the background of the fixed constants $~N~$ and $~M,~$ you have categorized each satisfying solution $~(x_1, x_2, \cdots, x_r, x_{r+1})~$ by the associated variables $~r, b, ~$ and $~c.$
As will be shown in the sections that follow this section, the combined variables $~r,b,c~$ will be sufficient to determine how many distinct intersections are represented as well as how many satisfying binary strings are represented by each such intersection.
It now remains to :
Construct the function $~f(N,r,b,c)~$ to represent how many solutions (i.e. intersections) that there are, for the specific variables $~r,b,c.~$
As will be shown, the fixed constant $~M~$ is not relevant to the function $~f.$
Construct the function $~g(N,M,r,b,c)~$ to represent how many elements (i.e. satisfying binary strings) that there are for each corresponding intersection.
Establish upper and lower bounds, as appropriate, for the fixed constants $~N,M~$ and for each of the variables $~r,b,c.~$
Then, you will have
$$T_r = \sum_{b ~\text{in range}} \left\{ ~\sum_{c ~\text{in range}} \left[ ~f(N,r,b,c) \times g(N,M,r,b,c) ~\right] ~\right\}.$$
$\underline{\text{Definition of} ~f(N, r, b, c)}$
The function $~f(N, r, b, c)~$ represents how many of the $~\displaystyle \binom{N-4}{r}~$ intersections are represented by the specific category represented by the specific values for $~b~$ and $~c.$
The computation of $~f(N, r, b, c)~$ will have two factors:
The first factor will represent the number of different ways that you can select $~(r - 1)~$ variables, such that $~b~$ of them are $~\geq 4,~$ and $~c~$ of them are $~= 3.$
The second factor will then assume that when the variables $~x_2, \cdots, x_r,~$ are read in ascending order by variable index (i.e. $~x_2~$ first, $~x_r~$ last), that the first $~b~$ variables are $~\geq 4,~$ the next $~c~$ variables are $~= 3,~$ and any remaining variables are $~= 2.$
Under these assumptions, the second factor will then represent the number of satisfying ordered $~(k+1)$-tuples $~( ~x_1, x_2, \cdots, x_r, x_{r+1} ~).$
Consequently, the product of the two factors will represent how many of the $~\displaystyle \binom{N-4}{r}~$ intersections are represented by the specific category represented by the specific values for $~b~$ and $~c.$
For the first factor, the computation is simply
$$\displaystyle \binom{r-1}{b} \times \binom{r-1-b}{c}.$$
The second factor will be computed via somewhat convoluted Stars and Bars theory.
Starting from the equation
$x_1 + x_2 + \cdots + x_r + x_{r+1} = (N - 4 - r),~$
two transformations will be made.
The first transformation is that, within the variables $~x_2, \cdots, x_r,~$ the first $~b~$ variables will be preserved, and the remaining
$~(r-1-b)~$ variables will be eliminated. Further, the sum of $~(N - 4 - r)~$ will be altered by deducting $~(3c),~$ since $~c~$ of the variables must have the exact value of $~3.~$ Similarly, the sum will then be altered again, by further deducting $~2 \times (r - 1 - b - c).~$
So, you will end up (in effect) with the variables $~x_1, x_{r+1},~$ which each must be in $~\Bbb{Z_{\geq 0}},~$ and the variables $~y_1, \cdots, y_b~$ which each must be in $~\Bbb{Z_{\geq 4}}.$
Further, the new sum will be
$$(N - 4 - r) - [ ~3c ~] - [ ~2 \times (r-1-b-c) ~]
= [ ~N - 2 - 3r + 2b - c ~].$$
So, the first transformation of the problem will result in enumerating the number of solutions to:
- $x_1 + x_{r+1} + y_1 + \cdots + y_b = [ ~N - 2 - 3r + 2b - c ~].$
- $x_1, x_{r+1} \in \Bbb{Z_{\geq 0}}.$
- $y_1, \cdots, y_b \in \Bbb{Z_{\geq 4}}.$
Basic Stars and Bars theory requires that each variable be in $~\Bbb{Z_{\geq 0}}.~$ So, the second transformation will be
$z_i = y_i - 4 \implies z_i \in \Bbb{Z_{\geq 0}} ~: ~i \in \{1,\cdots,b\}.$
This will reduce the sum by $~4b.$
So, after the second transformation, the problem will be to enumerate the number of solutions to
- $x_1 + x_{r+1} + z_1 + \cdots + z_b = [ ~N - 2 - 3r - 2b - c ~].$
- $x_1, x_{r+1} \in \Bbb{Z_{\geq 0}}.$
- $z_1, \cdots, z_b \in \Bbb{Z_{\geq 0}}.$
Note that the above problem involves exactly $~(b + 2)~$ variables.
Therefore, by basic Stars and Bars theory, the second factor in the computation of $~f(N,r,b,c),~$ which represents the number of solutions to the enumeration problem directly above, will be:
$$\binom{[ ~N - 2 - 3r - 2b - c ~] + [b + 1]}{b + 1} = \binom{N - 1 - 3r - b - c}{b + 1}.$$
Therefore,
$$f(N,r,b,c) = \binom{r-1}{b} \times \binom{r-1-b}{c} \times \binom{N - 1 - 3r - b - c}{b + 1}.$$
$\underline{\text{Definition of} ~g(N, M, r, b, c)}$
For the computation of a specific variable $~T_r,~$ the $~b~$ and $~c~$ variables determine a specific category of intersections.
The function $~g(N, M, r, b, c)~$ then represents the number of binary strings that will pertain to any intersection in the corresponding category. The following analysis will facilitate constructing the function $~g(N, M, r, b, c).$
The subset represented by $~S_{i_1}~$ will always use exactly $~5~$ positions, and exactly $~4~$ 1's. Then, for any $~j \in \{2,3,\cdots,r\},~$ the variable $~x_j~$ will represent the positional displacement between the subsets $~S_{i_{(j-1)}}~$ and $~S_{i_j}.$
If the positional displacement is:
$2$:
then $~3~$ additional positions and $~2~$ additional 1's will be used by $~S_j.$
There will be $~(r - 1 - b - c)~$ such occurrences.
$3$:
then $~4~$ additional positions and $~3~$ additional 1's will be used by $~S_j.$
There will be $~c~$ such occurrences.
$\geq 4$:
then $~5~$ additional positions and $~4~$ additional 1's will be used by $~S_j.$
There will be $~b~$ such occurrences.
Consequently, the total number of positions used will be
$$[ ~5 ~] + [ ~3 \times (r - 1 - b - c) ~] + [ ~4c ~] + [ ~5b ~]$$
$$= [2 + 3r + 2b + c].$$
Similarly, specifically within these used positions, the total number of 1's will be
$$[ ~4 ~] + [ ~2 \times (r - 1 - b - c) ~] + [ ~3c ~] + [ ~4b ~]$$
$$= [2 + 2r + 2b + c].$$
Considering that you start with $~N~$ positions, and $~M~$ 1's, you then have that
$$g(N, M, r, b, c) = \binom{N - [2 + 3r + 2b + c]}{M - [2 + 2r + 2b + c]}.$$
$\underline{\text{Upper and Lower Bounds For } ~N, M, r, b, ~\text{and} ~c}$
The analysis in this section will be facilitated by the following concepts:
If you have $~p,q \in \Bbb{Z_{\geq 0}},~$ then (arguably) it could be asserted that the expression $~\displaystyle \binom{p}{q}~$ only makes sense where $~q \leq p.~$
Similarly, if $~q < 0, ~$ then,again it could be argued that the expression makes no sense.
This section will use these concept to establish upper and lower bounds on the variables $~r,b,c.~$
Edit
In the past, when composing the solutions to very similar problems, I took the alternative, long-winded approach of elaborate analysis/discussion of variables. Then, when establishing upper/lower bounds on these variables, the result was perfectly consistent with the concepts in the previous paragraph.
I am going to construe the value of $~r=1,~$ to be out of range for the variable $~r,~$ since such an assumption is implicit in the function $~f(N,r,b,c).~$ Note that in the general problem, the functions $~f~$ and $~g~$ will not be needed in the computation of $~T_1.$
To prevent the problem from being trivial, I am going to presume that the value of $~r = 2,~$ will always be acceptable in the general problem.
Therefore, you must have that
$$N \in \Bbb{Z}, ~N \geq 8.$$
Similarly, you must have that $~M \geq 6.$
Further, since any satisfying binary string will therefore contain at least $~2~$ zeroes, you must have $~M \leq N-2.$
Therefore, you must have that
$$M \in \Bbb{Z}, ~6 \leq M \leq N-2.$$
As discussed, it will be assumed that $~r \geq 2.$
Clearly, you will always want $~r \leq N-4.$
By analyzing the third factor in the function $~f(N,r,b,c),~$ you see that within this function, the allowable value of $~r~$ is maximized when $~0 = b,c.~$ In that situation, you must have that
$$N - 1 - 3r \geq 1 \implies r \leq \left\lfloor \frac{N - 2}{3} \right\rfloor.$$
Similarly, examination of the function $~g(N,M,r,b,c)~$ establishes the following two constraints:
Putting this all together, you have that
$$r \in \Bbb{Z}, ~r \geq 2, ~r \leq
\min\left\{ ~\left\lfloor \frac{N - 2}{3} \right\rfloor, ~\left\lfloor ~\frac{M - 2}{2} ~\right\rfloor, ~N - M ~\right\}.$$
Lower and upper bounds for $~b~$ will be based on the assumption that $~r~$ is some fixed value. When considering a lower bound for $~b,~$ note that each variable in $~x_2, \cdots, x_r~$ that is not $~\geq 4~$ (in effect) lowers the number of positions used and the number of 1's that occur within these used positions. Therefore, $~b = 0,~$ is always acceptable.
One obvious upper bound on $~b~$ is $~(r-1).~$
Further, by analyzing the third factor in the function $~f(N,r,b,c),~$ you see that within this function, the allowable value of $~b~$ is maximized when $~0 = c.~$ In that situation, you must have that
$$N - 1 - 3r - b \geq b + 1 \implies b \leq \left\lfloor \frac{N - 2 - 3r}{2} \right\rfloor.$$
Similarly, examination of the function $~g(N,M,r,b,c)~$ establishes that
$$M - 2 - 2r \geq 2b \implies b \leq \left\lfloor \frac{M - 2 - 2r}{2} \right\rfloor.$$
Putting this all together, you have that
$$b \in \Bbb{Z}, ~b \geq 0, ~b \leq
\min\left\{ ~r - 1, ~\left\lfloor \frac{N - 2 - 3r}{2} \right\rfloor, ~\left\lfloor \frac{M - 2 - 2r}{2} \right\rfloor ~\right\}.$$
Lower and upper bounds for $~c~$ will be based on the assumption that $~r~$ and $~b~$ are each some fixed value. When considering a lower bound for $~c,~$ note that each of the $~(r - 1 - b) ~$ variables that are not $~= 3,~$ will instead be $~= 2.~$ Therefore, having $~c = 0,~$ (in effect) lowers the number of positions used and the number of 1's that occur within these used positions. Therefore, $~c = 0,~$ is always acceptable.
One obvious upper bound on $~c~$ is $~(r-1-b).~$
Further, by analyzing the third factor in the function $~f(N,r,b,c),~$ you see that you must have that
$$N - 1 - 3r - b - c \geq b + 1 \implies c \leq N - 2 - 3r - 2b.$$
Similarly, examination of the function $~g(N,M,r,b,c)~$ establishes that
$$c \leq M - 2 - 2r - 2b.$$
Putting this all together, you have that
$$c \in \Bbb{Z}, ~c \geq 0, ~c \leq
\min\left\{ ~r - 1 - b, ~N - 2 - 3r - 2b, ~M - 2 - 2r - 2b ~\right\}.$$
$\underline{\text{Closed Form Computation For The Unspecified Constants} ~N,M}$
It is assumed that $~N = ~$ the exact length required for the binary string, and that $~M = ~$ the exact number of 1's in the binary string.
Boundaries for the constants and variables are
$N \in \Bbb{Z}, ~N \geq 8.$
$M \in \Bbb{Z}, ~6 \leq M \leq N-2.$
$\displaystyle r \in \Bbb{Z}, ~r \geq 2, ~r \leq
\min\left\{ ~\left\lfloor \frac{N - 2}{3} \right\rfloor, ~\left\lfloor ~\frac{M - 2}{2} ~\right\rfloor, ~N - M ~\right\}.$
$\displaystyle b \in \Bbb{Z}, ~b \geq 0, ~b \leq
\min\left\{ ~r - 1, ~\left\lfloor \frac{N - 2 - 3r}{2} \right\rfloor, ~\left\lfloor \frac{M - 2 - 2r}{2} \right\rfloor ~\right\}.$
$\displaystyle c \in \Bbb{Z}, ~c \geq 0, ~c \leq
\min\left\{ ~r - 1 - b, ~N - 2 - 3r - 2b, ~M - 2 - 2r - 2b ~\right\}.$
The helper functions are defined as
$\displaystyle f(N,r,b,c) = \binom{r-1}{b} \times \binom{r-1-b}{c} \times \binom{N - 1 - 3r - b - c}{b + 1}.$
$\displaystyle g(N, M, r, b, c) = \binom{N - [2 + 3r + 2b + c]}{M - [2 + 2r + 2b + c]}.$
Then,
$$T_1 = \binom{N-4}{1} \times \binom{N-5}{M-4},$$
and for $~r~$ in range,
$$T_r = \sum_{b ~\text{in range}} \left\{ ~\sum_{c ~\text{in range}} \left[ ~f(N,r,b,c) \times g(N,M,r,b,c) ~\right] ~\right\}.$$
Then, the final computation is
$$\sum_{r = 1 ~~\text{or} ~~r ~~\text{in range}} (-1)^{r+1} T_r.$$
$\underline{\text{Closed Form Computation For} ~N = 20, ~M = 9}$
Boundaries for the variables are
$\displaystyle r \in \{ ~2, 3 ~\}.$
$\displaystyle b \in \Bbb{Z}, ~0 \leq b \leq
\min\left\{ ~r - 1, ~\left\lfloor \frac{7 - 2r}{2} \right\rfloor ~\right\}.$
$\displaystyle c \in \Bbb{Z}, ~0 \leq c \leq
\min\left\{ ~r - 1 - b, ~7 - 2r - 2b ~\right\}.$
The helper functions are defined as
$\displaystyle f(20,r,b,c) = \binom{r-1}{b} \times \binom{r-1-b}{c} \times \binom{20 - 1 - 3r - b - c}{b + 1}.$
$\displaystyle g(20, 9, r, b, c) = \binom{20 - [2 + 3r + 2b + c]}{9 - [2 + 2r + 2b + c]}.$
Then,
$$T_1 = \binom{16}{1} \times \binom{15}{5},$$
and for $~r~$ in range,
$$T_r = \sum_{b ~\text{in range}} \left\{ ~\sum_{c ~\text{in range}} \left[ ~f(20,r,b,c) \times g(20,9,r,b,c) ~\right] ~\right\}.$$
Then, the final computation is
$$\sum_{r = 1 ~~\text{or} ~~r ~~\text{in range}} (-1)^{r+1} T_r.$$
$\underline{\text{Exact Numerical Answer For} ~N = 20, ~M = 9}$
$$T_1 = 16 \times \binom{15}{5} = 48048.$$
$$T_2 = \sum_{b = 0}^1 \left[ ~\sum_{c = 0}^{1-b}
\binom{1}{b} ~\binom{1-b}{c} ~\binom{13 - b - c}{b+1} ~\binom{12 - 2b - c}{3 - 2b - c} ~\right]$$
$$= \left[ ~\binom{13}{1}\binom{12}{3} ~\right] + \left[ ~\binom{12}{1}\binom{11}{2} ~\right] + \left[ ~\binom{12}{2}\binom{10}{1} ~\right]$$
$$= 2860 + 660 + 660 = 4180.$$
$$T_3 = \sum_{b = 0}^0 \left[ ~\sum_{c = 0}^{1-2b}
\binom{2}{b} ~\binom{2-b}{c} ~\binom{10 - b - c}{b+1} ~\binom{9 - 2b - c}{1 - 2b - c} ~\right]$$
$$= \left[ ~\binom{10}{1}\binom{9}{1} ~\right] + \left[ ~2 \times
\binom{9}{1}\binom{8}{0} ~\right]$$
$$= 90 + 18 = 108.$$
Then,
$$\sum_{r=1}^3 (-1)^{r+1}T_r$$
$$= ( ~T_1 + T_3 ~) - T_2 = ( ~48048 + 108 ~) - 4180 = 43976.$$