TITLE: Solving P(TRUE) of finding counterpart pairs in 2 sets with constraints involving the Universal Genetic Code
QUESTION [6 upvotes]: Solving P(TRUE) of finding counterpart pairs in 2 sets with constraints involving the Universal Genetic Code
Posting this question here as opposed to in biology, etc. as I only want the answer from a purely mathematical standpoint without any contextual bias.
I apologize for the lack or incorrect usage of formal notation.  Did my best.
I do not know if this can be done via some form of clever mathematics or I'd just need to brute force through with a computer(s) in some way to obtain a sample and then extrapolate that to the population.  
Regardless, here is my question. 
( My use of "|" ANYWHERE means OR )
$$D = D\_EitherUnlessInitialSpecificed = (D\_Initial | D_CounterpartToInitial)$$ $$B = B\_EitherUnlessInitialSpecificed = (B\_Initial | B\_CounterpartToInitial)$$
Yes, I wrote that redundantly, but hopefully clearly.I hope I wrote that correctly.
Definition of counterparts:
a, c, g, and t do not represent anything quantifiable.  They only represent a quality.
As stated more generally above, and more specifically down below:
$$D\; can\; only = a\;  or \; c\; ; \; a < -- > c$$
$$if\;  D = a,\; then \;D_c = c$$$$if\;  D = c,\; then \;D_c = a$$ 
$$B\; can\; only = t\;  or \; g\; ; \; t < -- > g$$
$$if\;  B = t,\; then \;B_c = g$$$$if\;  B = g,\; then \;D_c = t$$ 
In the end, everything comes down to the placement of $a$, $c$, $g$, and $t$ within constraints I'll define shortly.
$$W = (D\;|B)$$
and we'll be using 2 instances of
$W$, $W_1$ & $W_2$ which are not exclusive of each other in any context, nor are they exclusive/equal when the same instance is repeated in the same or a different set/array/etc.
They are more like placeholders for a position which you're trying to find the counterpart to.  
If I use $W_2$ or $W_1$ and then use it again multiple times, each time it takes on a value which is assigned actually only by you.
Now,
$$W_1 = (D | B)$$$$W_2 = (D | B)$$ 
$$Wa\; =\; an\; instance\; of\; the 
\;set \;or\; what\; I\; am\; going \;to \;begin \;calling\; an\;"array"\; \{W_1,W_2\}$$ 
We'll make 8 individual instances of these paired arrays and then store them into an array, $ArrayTop$ aka $ArrT$ 
$$ArrT\;=\;\{Wa_1,Wa_2,Wa_3,Wa_4,Wa_5,Wa_6,Wa_7,Wa_8\}$$
You can also reference the items in the array from their order via 
$ArrT_1,ArrT_2...etc.$ if needed.
Now, we'll make 16 more individual instances of these paired arrays and then store them into another array, $ArrayBottom$ aka $ArrB$. However, we'll start $Wa_x$ at 9.
$$ArrB\;=\;\{Wa_9,Wa_{10},Wa_{11},Wa_{12},Wa_{13},Wa_{14},Wa_{15},Wa_{16},Wa_{17},Wa_{18},Wa_{19},Wa_{20},Wa_{21},Wa_{22},Wa_{23},Wa_{24}\}$$ 
or 
$$ArrB_1, ArrB_2...ArrB_{16}$$
If, given $ArrT$ & $ArrB$ and these constraints,
$$Each$$
$$ a, c, g,\ and\ t$$
$$has \;a \;required \;"point\; usage" \;of \;exactly \;16\; for\; W_1 \;collectively\; and\; W_2\; collectively.$$
Every time one of these 4 letters is used in:

$ArrT$, it acquires 4 points.
$ArrB1$ or $ArrB2$, then it acquires 3 points.
$ArrB3$ through to $ArrB14$, then it acquires 2 points.
$ArrB15$ or $ArrB16$, then it acquires 1 point.

To clarify further, a letter acquires points for it's $W_1$ and separately for its $W_2$. 

Find the number of all possible scenarios for the placements of 
$$a,t,g,\; and\; c$$
where, for each item in $ArrT$, two items in $ArrB$ contain the respective counterparts of $W_1$ and $W_2$ from that item in $ArrT = TRUE$.
Also, the total # of possible scenarios if you want, although that's somewhat easy to figure out.

EDIT: I have included a picture to provide the context for what this is for and where it comes from to hopefully help resolve any confusion.
One very important thing I need to stress here and which can cause confusion with this picture is the fact that there are actually a few symmetries with very low probabilities to occur especially in tandem between the two halves (pending you're looking for them).  I will say that this is our genetic code for everything on earth...so that's kind of cool but the question I'm asking has absolutely nothing to do with symmetry and only the presence of things in the top group that then have their counterparts in the bottom regardless of their location.  If you're just looking at how I define the problem above in the mathematical sense you would already understand that though.
You can basically ignore the upper left part too....the picture explains the rest.

REPLY [4 votes]: The answer is long, but hopefully worth it. I had fun solving this.
First a side note: I am not sure if it is wise to construe this as a probability problem. Counting the number of ways to satisfy all the requirements is a counting problem. If you divide the outcome by the total number of ways to place $a$, $c$, $g$, $t$ then, sure, the outcome can be interpreted as a probability, but only if the possibilities counted in the denominator are all equally likely. I do not know if that latter assumption makes any sense at all in the biological context. However: counting problems are very interesting in and by themselves, so we can solve the counting problem without worrying about probabilities.
Second: I will explicitely repeat here the extra demand revealed in the comments that all 8 elements of $ArrT$ must be disctinct, since it will play an important role at several places of the below answer 
Third: I will adopt the notation $\{x, y\}$ used in the question for an element ('paired array' as the question says) of $ArrT$, even though a mathematician would write it as $(x, y)$, to indicate that the order of $x$ and $y$ matters. (Normally $\{, \}$ is only used for unordered sets.) This is just a warning to mathematicians reading this: in spite of the use of braces the order within the pair is really important and I will frequently speak of the 'first entry of $Wa_1$' or 'the second entry of $Wa_1$'. 
Now for the answer.
The requirement that the 8 elements of $ArrT$ are all distinct means that the 16 elements of $ArrB$ are partioned into 8 pairs. Elements within the same pair are identical (being the counterpart to the same element of $ArrT$) and elements of different pairs are distinct, as a result of the elements of $ArrT$ being distinct too. We first look at the different ways of partioning the 16 elements of $ArrB$ into 8 pairs. There are $\frac{16!}{8!2^8} = 2027025$ different pairings (ways of partion 16 elements into 8 pairs) but they are not all equal from the perspective of the problem. As far as I can see there are six types:

Type A: the 3-point elements of ArrB are paired to eachother, the 2 point elements of ArrB are paired to eachother, the 1-point elements of ArrB are paired to eachother. There are $\frac{12!}{6!2^6} = 10395$ pairings of type A.
Type B: the 3-point elements of ArrB are paired to eachother but the 1-point elements are each paired to a 2-point element. There are $12*11*\frac{10!}{5!2^5} = 124740$ pairings of type B.
Type C: The 3-point elements of ArrB are each paired to a 2-point element and the 1-point elements are paired to eachother. By symmetry there are equally many pairings of type C as there are of type B so there are $124740$ pairings of type C.
Type D: The 3-point elements of ArrB are each paired to a 2-point element, the 1-point elements of ArrB are each paired to a 2-point element. There are $12*11*10*9*\frac{8!}{4!2^4} = 1247400$ pairings of type D.
Type E: One 3-point element of ArrB is paired to a 2-point element and one 3-point element is paired to a 1-point element. There are $2*2*12*11*\frac{10!}{5!2^5} = 498960$ pairings of type E.
Type F: Both 3-points elements of ArrB are paired to 1-point elements. **There are $2*\frac{12!}{6!2^6} = 20790$ pairings of type F.

Quick sanity check: $10395 + 124740 + 124740 + 1247400 + 498960 + 20790 = 2027025$. Ok.
What we will do: For each pairing separately we compute the number of solutions, then add them all up. Since the number of solutions only depends on the type, this amount to 6 computations rather than 2027025. Note that the computation in the type F case is equivalent to the (single) computation we would need to do in the simpler universe where all elements of $ArrB$ had a value of 2.
To simplify things even further: Given a fixed pairing of the elements of $ArrB$ for which we want to compute the number of solutions, we first note that for that particular pairing there are $8! = 40320$ to assign to each of the 8 pairs of elements of $ArrB$ in the pairing one of the 8 elements of $ArrT$. The good news is: if we choose one such assignment, count the number of solutions for that specific combination of 1) a specific pairing of the elements of $ArrB$ and 2) a specific assignment of the pairs in that pairing to the elements of $ArrT$, and say the answer is $N$, then the total number of solutions with the specific pairing, running over all assignments of elements of $ArrT$ to the pairs is simply $8! * N$. So for a given pairing we will just choose one assignment of elements of $ArrT$ to the pairs, more specifically one that simplifies notation somewhat, and calculate the number of solutions there. Then multiply wiht $8!$, then multiply with the number of pairings of the given type and then add all six terms.
Counting solutions in the Type A case
There are $10395 * 40320 * 0 = 0$ solutions in the type A case.
As remarked above we can choose an assignment of elements of $ArrT$ to pairs of elements of $ArrB$ that simplifies notation. Let $Wa_1$ be paired to the unique pair of two 3-point elements of $ArrB$. Let $Wa_2$ be paired to the unique pair of two 1-point elements of $ArrB$. Let $Wa_3, \ldots, Wa_8$ be paired to pairs of 2-point elements.  
Let $X \in \{a, t, c, g\}$ be the first entry of $Wa_1$. This contributes 6 points to the total value (of 16) of $X^c$, thanks to the appearance of $X^c$ as the first entry of both 3-point elements of $ArrB$. Now the first entries of  $Wa_3, \ldots, Wa_8$ will contribute a multiple of 4 to the score of $X^c$: this contribution is 4 when the element itself equals $X^c$ and also 4 when the element equals $X$ (thanks to the corresponding pair in $ArrB$). The contribution is $0$ if the entry is neither $X$ nor $X^c$. Both $4$ and $0$ are multiples of 4 and so the sum of these contributions will be a multiple of 4, and thanks to the 6 coming from $Wa_1$ we end up with a number which is 2 more than a multiple of 4. Now in order to bring the total to 16, the first entry of $Wa_2$ must also contribute 2 more than a multiple of 4 and this happens if and only if the first entry of $Wa_2$ equals $X$ (so $X^c$ gets 2 points from the pair in $ArrB$ corresponding to it.)
What we see is hence: IF solutions of type A with this assignment of elements of $ArrT$ to the pairs exist at all, then the first entry of $Wa_1$ must be equal to the first entry of $Wa_2$.
But by the same reasoning the second entry of $Wa_1$ must equal the second entry of $Wa_2$ and hence we find that $Wa_1 = Wa_2$ which was forbidden by requirements! Hence no solutions of this type exist.
Counting solutions in the Type B case
There are $124740 * 40320 * 0 = 0$ solutions in the type B case.
The reasoning is similar, so I will describe it a bit more consisely. First picking an assignment. Let $Wa_1$ correspond to the pair of 3-point elements of $ArrB$. Let $Wa_2$ and $Wa_3$ correspond to the two pairs in $ArrB$ consisting of one 1-point element and one 2-point element. Let $Wa_4, \ldots W_a8$ correspond to the remaining pairs. Let $X$ be the first element of $Wa_1$. It contributes 6 to the score of $X^c$. IF $X$ appears in the first entry of $Wa_2$ or $Wa_3$ it contributes 3 points to the score of $X^c$. If any other element of $\{a, c, g, t\}$ appears in the first entry of $Wa_2$ or $Wa_3$ or when ANY element of $\{a, c, g, t\}$ appears as the first entry of $Wa_4, \ldots, Wa_8$ it contributes a multiple of 4 to the score of $X^c$ (namely: either 0 or 4). So the only way to give $X^c$ a score of 16 is when $X$ appears as the first entry of both $Wa_2$ and $Wa_3$. In other words: the first entries of $Wa_1$, $Wa_2$ and $Wa_3$ are all equal. But by the same reasoning the second entries of $Wa_1$, $Wa_2$ and $Wa_3$ are all equal (to eachother, not necessarily to the first entries) and hence $Wa_1 = Wa_2 = Wa_3$, contradicting the requirement repeated in the beginning of the anser. So no solutions are possible!
Counting solutions in the Type C case
There are $124740 * 40320 * 0 = 0$ solutions in the type C case.
The reasoning is completely analogous to the type B case and we omit it here.
Counting solutions in the Type D case
There are $1247400 * 40320 *  415488 = 20897038761984000$ solutions in the type D case. This is the most interesting case. We postpone it until we have described all the simpler ones.
Counting solutions in the Type E case
There are $498960 * 40320 * 0 = 0$ solutions in the type E case.
The same reasoning as before. Let $Wa_1$ correspond to the unique pair that has a total of 5-points, $Wa_2$ to the unique pair that has total of 3 points. $Wa_3$ to the pair consisting of a 1-point element of $ArrB$ and a 3-point element of $ArrB$ and $Wa_4, \ldots, Wa_8$ to the generic pairs. Let the first entry of $Wa_1$ equal $X$. The this contributes 5 points to the score of $X^c$. Any instance of $a, c, g, t$ that is not $X$ appearing in the first entry of $Wa_2$ and any instance of $a, c, g, t$ at all appearing in the first entry of $Wa_3, \ldots, Wa_8$ contribute a multiple of 4 to the score of $X^c$. (So even if $Wa_3$ 'feels' really special and different from the $Wa_4, \ldots, Wa_8$, in reality it isn't.) So any hypothetical solution must have an $X$ in the first entry of $Wa_2$ (which will contribute 3 points to the score of $X^c$). Now looking at the second entries we conclude (again) that $Wa_1 = Wa_2$, contradicting the rules.
Counting solutions in the Type F case
There are $20790 * 40320 * 72979200 = 5325963632640000$ solutions in the type F case.
Now things are getting interesting. In the Type F case, the whole 1-point, 2-point, 3-point business that made our life harder before is completely 'neutralized'. Let the two pairs consisting of one 1-point element and one 3-point element of $ArrB$ correspond to $Wa_1$ and $Wa_2$ and let $Wa_3, \ldots, Wa_8$ correspond to 'generic' pairs of $ArrB$-elements consiting of two 2-point elements. Now an $a$ appearing in $Wa_1$ or $Wa_2$ contributes 4 points to $a$ and four points to $t$ and an $a$ appearing in $Wa_3$ or any of the other elements of $ArrT$ also contributes 4 points to $a$ and 4 points to $t$. Similar for $t$, $c$ and $g$, so, put more simply: the elements of $ArrT$ are completely equivalent.
We introduce a nice 'geometric' way of thinking about the contents of $ArrT$. Picture a $4 \times 4$ grid, consisting of 16 little square cells. (I don't know how to insert pictures into answers, but picturing this in your head seems easy enough.) Now imagine that the rows are labeled $a$, $t$, $c$, $g$ (in that order) and the columns are labeled $a$, $t$, $c$, $g$ as well. Then every cell corresponds to one of the 16 possible contents of an element of $ArrT$, for instance $\{a, t\}$ corresponds to the cell in row $a$ and column $t$; $\{c, c\}$ corresponds to row $c$, column $c$ etc. Every way of filling out $ArrT$ now corresponds to putting the numbers $1, \ldots, 8$ in 8 of the 16 cells in the grid and leaving 8 cells blank: a 1 in the cell in row $a$, column $g$ means that $Wa_1 = \{a, g\}$ and a 6 in row $g$ column $c$ means that $Wa_6 = \{g, c\}$ etc. Now not all $16!/8! = 518918400$ ways of putting the numbers $1, \ldots, 8$ in the grid are allowed since the points need to add up in the right ways. We do see however that the question wether or not a placement of the numbers into the grid is allowed does only depend on which cells are occupied and which are empty and not on how exactly the numbers $1, \ldots, 8$ are distributed over the occupied cells. (This is the same remark again that in case F the elements of $ArrT$ are 'equivalent'. So to simplify matters we ask:
In how many ways can we place 8 stars in the 16 cells of a 4 by 4 grid such that the arrangement of stars satisfies the conditions layed out below?
Once we have that number, we multiply it by $8! = 40320$ which is the number of ways to replace each of the 8 stars by one of the numbers 1 through 8. The conditions, coming from the points needing to add up to 16, are easy to find. A star in row $a$ contributes 4 points to the score of $a$ because of the appearance of an $a$ in $ArrT$, but a star in row $t$ also contributes 4 points to the score of $a$ because of the appearance of an $a$ in the corresponding two elements of $ArrB$. Stars in rows $c$ and $g$ don't contribute anything to the score of $a$ and so we find by looking at the first-entry-score of $a$ only that the numbers of stars in the top 2 rows should add up to four. Reasoning similarly with $b, c, g$ and with columns instead of rows we find that conditions on the placement of stars amount to:

The total number of stars in the top 2 rows equals 4
The total number of stars in the bottom 2 rows equals 4
The total number of stars in the leftmost 2 columns equals 4
The total number of stars in the rightmost 2 columns equals 4

To count the number of ways these conditions can be simultaniously met we partition the 4-by-4-grid in a different way: into 4 two-by-two blocks: TL (top left), TR (top right), BL (bottom left) and BR (bottom right). Suppose we have any valid placement of stars and we count the number of stars in block TL. Let's call this number $k$. Then we see that $TR$ contains $4 - k$ stars so it contains $k$ empty spaces, $BL$ contains $k$ empty spaces as well and $BR$ contains $k$ stars again. Conversely, if $k$ is any number in $0, \ldots, 4$, and we have any arrangement of stars where TL contains $k$ stars, TR and BL each contain $k$ empty spaces and $BR$ contains $k$ stars, then this arrangement will satisfy the conditions, no matter how the mentioned stars and empty spaces are distributed over their respective blocks. It follows that the number of ways to place the stars satisfying the conditions equals:
$$\sum_{k =0}^4 \binom{4}{k}^4$$
I don't know if there is a nice formula for this type of sums of powers of binomial coefficients; that would make a nice MSE question in itself. However, 4 is a small number and so in this case we can compute the answer by hand. It is 1810.
It follows that the number of solutions for a given type F pairing of elements of $ArrB$ and a given correspondence between the pairs of $ArrB$ elements and elements of $ArrT$ equals $8!*1810 = 72979200$. From there it follows that the total number of solutions with that given pairing of $ArrB$ elements equals $8!*8!*1810$, and finally that the total number of Type F solutions equals $20790 * 8! * 8! * 1810 = 5325963632640000$
Finally, type D
This combines the reasoning we used in the previous types. There are two pairs of elements of $ArrB$ with a total value of $3 + 2 = 5$ points. Let them correspond to $Wa_1$ and $Wa_2$ in $ArrT$. There are two pairs of elements of $ArrB$ with a total value of $1 + 2 = 3$ points, let them correspond to $Wa_3$ and $Wa_4$. Finally there are 4 pairs worth 4 points; let them correspond to $Wa_5, \ldots, Wa_8$. 
Again, let $x$ be the first entry of $Wa_1$. With reasoning similar to case $A, B, C, E$ we see that the first entry of either $Wa_3$ or $Wa_4$ must be equal to $x$. Also, if $y$ denotes the second entry of $Wa_1$, then we see that the second entry of $Wa_3$ or the second entry of $Wa_4$ must also equal $y$. However, this time around this doesn't give a contradiction! If the first entry of $Wa_3$ equals $x$ and the second entry of $Wa_4$ equals $y$, then we are fine as long the second entry of $Wa_3$ doesn't equal $y$ as well (but does equal the second entry of $Wa_2$) and the first entry of $Wa_4$ doesn't equal $x$ (but does equal the first entry of $Wa_2$). In other words: the 1-point, 3-point stuff does impose a restriction that was not present in the type F case, and we will find less solutions for a given pairing of type D than we found for a given pairing of type F, but it is just that: a restriction. An extra condition we need to compute with. (Also: the smaller number of solutions per pairing in type D as compared to typ F is (over-)compensated by the fact that there are more type D pairings than type F pairings)
We can express the extra condition in the 'geometric' language we developed in type F. Again a solution corresponds to a placement of the numbers 1 through 8 in the 4 by 4 grid. Now the stuff in the previous paragraph says that the locations of the numbers 1, 2, 3, 4 form a rectangle with the number 1 diagonally opposing the number 2 and the number 3 diagonally opposing the number 4. We also note that once that is satisfied, the only condition left on the total configuration of 8 numbers is the same one we saw under type F (so exactly 4 cells occupied in the top 2 rows, in the bottom 2 rows, in the leftmost 2 columns and in the rightmost two columns). I will call this latter condition the 'type F condition' for short.
Consider a fixed rectangle in the 4 by 4 grid. There are 8 ways of putting the numbers 1, 2, 3, 4 in the four corners that satify the condition. There is a number $N$ (to be determined below) ways of placing four more stars in the grid such that the four corners of the rectangle and the 4 additional stars together satisy the type F condition. Then finally for each placement of stars there are $4! = 24$ ways of placing the numbers $5, 6, 7, 8$ in the stars, because the type F condition doesn't care about numbers, only about the place of the stars. This means that for any given rectangle there $8*24*N$ solutions where the pre-given rectangle is the one determined by the content of $Wa_1, Wa_2, Wa_3, Wa_4$ in that solution. What remains is to determine the number $N$ of sets of 8 cells satisfying the type F condition containing the four corners of the given rectangle. Unfortunately, this number $N$ is not the same for every rectangle. It depends on how many of the blocks TL, TR, BL, and BR (discussed before) the rectangle intersects. We distinguish four cases.

Type D1: if the four corners of the rectangle all lie in the same block, then together they are that block. The only way to satify the the type F condition is then to have the remaining four stars occupy the diagonally opposite block. This means that $N = 1$ in this case, and there are 4 rectangles of this type, one for each block.
Type D2: if the four corners of the rectangle together see exactly two blocks, then in any placement of numbers satisfying the type F condition, each of the four blocks contain exactly two points. Conversely: any arrangement of the remaining four stars over the two blocks not met by our rectangle that results in each block having exactly two stars will satisfy the condition. So we have that $N = \binom{4}{2}\binom{4}{2} = 36$ in this case, and there are $16$ rectangles of this type.
Type D3: if the four corners of the rectangle together see exactly 3 blocks, then our rectangle wasn't a rectangle after all. This case does not occur.
Type D4: if each of the four blocks contain exactly 1 corner of the rectangle, then we have quite some freedom left. The total number $k$ of stars in TL can equal 1, 2, or 3. If it equals 1 then we get to choose how to place 2 aditional stars in block TR and 2 aditional stars in block BL, which can be done in $\binom{3}{2}\binom{3}{2} = 9$ ways. If $k = 2$ then we get to place one exta star in each of the four blocks, which can be done in $\binom{3}{1}\binom{3}{1}\binom{3}{1}\binom{3}{1} = 81$ ways. Finally if $k = 3$ we get to place two extra stars in blocks TL and BR which can be done in 9 ways, as above. So we find that $N = 9 + 81 + 9 = 99$ in this case. We also find that the total number of rectangles of this type equals 16.

Putting this all together we find that there are $4*8*24*1 + 16*8*24*36 + 16*8*24*99 = 415488$ solutions for each fixed type $D$ pairing of the elements of $ArrB$ and each fixed correspondence between the pairs in this pairing and the elements of $ArrT$. As written above this means that the total number of solutions in type $D$ is $1247400 * 40320 *  415488 = 20897038761984000$
The final answer
Adding everything up we find:
$$0 + 0 + 0 + 20897038761984000 + 0 + 5325963632640000 =  26223002394624000$$
solutions. A big numbers, sure, but still somewhat manageble. This is in order of magnitude of $4^{27}$ which is negligible compared to the $4^{48}$ ways of just putting the $a, c, g, t$ out there. Of course this isn't a fair comparison. If instead you want to compare to the number of ways of putting $a, c, g, t$ satisfying some but not all of your conditions, you should be a bit more specific about which conditions you want and we can do a second answer computing that number too.