Lucas's Theorem
Let’s explore a theorem that breaks massive combinatorial problems down into hand-computable pieces.
Combination questions take the form of “how many ways can you choose items from options?” If you’ve got six flowers, all different colors, how many ways can you choose three of them for a small bouquet?
The standard syntax and factorial definition of combinationsCombinations are better known as binomial coefficients. are:
While accurate, the above formula is difficult to deal with for even moderately large values. The value of is practically intractible using factorials. Most applications don’t even have a use for a number that large.
Taking the residue constrains the magnitude of the final result, but the computation is still prodigious:
Assuming the modulus is prime-powered, Lucas’s theorem gives us a useful decomposition of this problem.
A binomial coefficient under a prime modulus is congruent to the product of the binomial coefficients created by the base- digits of the original coefficient. In mathematical notation:
For example, take the example from above. Convert the two values to base 5:
The coefficients to the powers of 5 are inserted into the binomial coefficient product:
Considering the fact that the non-residue value is approximately , computing a residue so efficiently with Lucas’s theroem is quite a feat.
We use the “binomial” characteristic of binomial coefficients as the basis of the proof.
The product is simply using the base- expansion of .
To go much further we need to justify a binomial quirk. For prime :
Let’s look at the binomial coefficients. The factorial definition gives that . Multiply over and the result is:
The right-hand side is divisible by at least times, and since , will be divisible by at most times (or equal ). Binomial coefficients are integers, so must divide for every . The boundary cases are each by definition.
Any coefficient divisible by is congruent to , which leaves only the first and last terms in the binomial expansion: , and . The aforementioned congruence follows.
Returning to the main equation:
Expand that inner binomial out into a sum:
The distributive law allows us to move the inner sum outside, turning it into an iterated sum:
Consider the set of . The term in the inner product becomes , making the combined exponent .
In other words, the sets of are the base- representations of each term’s exponent.
- When all , the exponent is .
- When all , the exponent is .
Now, recall our original summation variable . It would be nice to replace the iterated sum with a simple , but not every number from to is necessarily represented in the iterated sum. Consider, for example, where . All of the , the maximum valid coefficient value, but not all necessarily go that high.
Nonetheless, the replacement sum can still be justified if, for each of those extra cases where , the resulting term is . Consider the binomial coefficient at one of those cases: when the inequality is trueAfter all, one cannot “choose” more items than exist in the set..
Let’s collapse that iterated sum using that justification:
We now have a structure that closely parallels our original expression:
Compare each coefficient, and you arrive at the theorem statement.
Problems where Lucas's theorem can be directly applied are tricky to invent, and rarely practical. If you have a quantity of items expressible as a binomial coefficient, and wish to find the number left over after divvying the items into prime-numbered groups, Lucas can get you there easilyBrilliant has an example of counting oranges stacked in a pyramid structure. That’s about as practical of an example as I can find..
However, binomial coefficients in general tend to appear in many unexpected places throughout both number theory and applied math. Knowing a little trick exists when a binomial and prime modulus are involved can be the ticket you need to drastically reduce complexity.
Larry Riddle’s writeup of the theorem’s proof was instrumental in helping me understand it. Most of the steps above, down to the variable names, are taken from his summary: I simply fleshed out several steps that caught me off-guard when I was learning. The numeric example he works through is worth a read, in particular. I wouldn’t have understood the general proof without it!