73

This is a soft question, but I've tried to be specific about my concerns. When studying basic combinatorics, I was struck by the fact that it seems hard to verify if one has counted correctly.

It's easiest to explain with an example, so I'll give one (it's fun!) and then pose my questions at the bottom. In this example there are two ways to count the number of ways $2n$ people can be placed into $n$ partnerships (from the book Introduction to Probability by Blitzstein and Hwang):

$$\frac{(2n)!}{2^n \cdot n!} = (2n - 1)(2n - 3) \cdots 3 \cdot 1$$

Story proof for the right side: For the first person you have $(2n - 1)$ choices for partner. Then for the next person you have $(2n - 3)$ choices, etc.

Story proof for the left side: Line all $2n$ people up, walk down the line, and select every 2 people as a pair. The ordering you chose for the line determines the pairs, and there are $2n!$ ways to order $2n$ people. But divide by $2^n$ because the order within each pairing doesn't matter. Also divide by $n!$ because the order of the pairings doesn't matter.

My question is:

What if I had been tasked with getting this number at work, and I chose the approach on the left side, but I neglected to divide by $2^n$ and only divided by $n!$? I'd be wrong of course, but how could I have known?

I suppose one answer to my question could just be "Try hard, try to think of ways you might be over/undercounting, look at other examples, and continue to study theory."

But the prospect of not knowing if I'm wrong makes me nervous. So I'm looking for more concrete things I can do. So, three questions of increasing rigor:

  • What are specific "habits of mind" that people in combinatorics use to avoid error?
  • What are specific validation techniques that such people use to check their work? (One does come to mind from my example: Calculate the same thing two ways and confirm equality)
  • Is there any formal list of questions that, if answered, should verify that one's approach is correct?
Stephen
  • 1,113
  • 28
    Checking your answer for small $n$ (in cases where you can count manually) is a good sanity check. – angryavian Jun 28 '17 at 23:45
  • 79
    In 1962 in my sophomore Intro to Probability, my prof asked how many legs a cow had. Twelve, he explained: two in front, two in back, two on the left, two on the right and one at each corner. We did not think it was funny. A few weeks later he told the same joke and everyone laughed. – John Wayland Bales Jun 28 '17 at 23:46
  • What do you mean by "checking for small $n$"? Do you just mean if I have small $n$ I can exhaustively write out all the possibilities? – Stephen Jun 28 '17 at 23:46
  • @Stephen In your example, you have a formula that works for all $n$. If you want to check that you have not over/under-counted, you can compute the cases $n=2$ or $n=3$ manually just to make sure. This is not foolproof, but rather to check for some mistakes. – angryavian Jun 28 '17 at 23:50
  • Ok thanks, that's what I thought you meant. And yeah, I agree, that seems like a good/easy sanity check. – Stephen Jun 28 '17 at 23:53
  • 9
    Often, you can't be sure. And that's one reason I dislike combinatorics personally - I'm never sure if I've massively screwed up. :) – Deepak Jun 29 '17 at 00:06
  • 3
    I think it was in the preface to the 3rd edition of "Generatingfunctionology" where I read the most(?) bijective (read counting) proofs we know were first discovered from messing around with generating functions in the first place. And apparently "A = B" by Petkovsek (and others) provides a(the?) full-proof method/s of solving most any textbook problem of the kind you mentioned. Haven't read either yet, but google them and see for yourself. – user448692 Jun 29 '17 at 01:20
  • Or maybe a better example of how I might have chosen incorrectly: I would naively have thought (in the case where you're looking for 5 pairings of 10 people) that the answer is $\binom{10}{2} \binom{8}{2} \binom{6}{2} \binom{4}{2} \binom{2}{2}$. It turns out that's way off, but I'm not sure why. It looks good! – Stephen Jun 29 '17 at 18:40
  • 2
    @Stephen If you divide that by $5!$: $$ \frac{ {10 \choose 2}{8 \choose 2}{6 \choose 2}{4 \choose 2}{2 \choose 2}}{5!}$$ you get the right answer. – Sera Gunn Jun 29 '17 at 19:24
  • @T.Gunn nice, you're right! How can you know if you need to divide by total orderings like that? I was trying to think of a good rule and I came up with: "divide by r! when order doesn't matter, where r is the number of things that would otherwise be ordered." Is there any more that could be said? Maybe the problem is since I'm not explicitly imposing an order, I don't realize I still need to counteract order that naturally arises. – Stephen Jun 29 '17 at 21:35
  • @Stephen Experience to put it simply. Once you've gotten it wrong enough times you become more familiar with what the pitfalls look like. I know, for example, that when you have a product $a_1 \cdot a_2 \cdots a_n$ that comes from a Cartesian product $A_1 \times A_2 \times \cdots \times A_n$. Cartesian products are ordered tuples. – Sera Gunn Jun 29 '17 at 21:56
  • Now, I'm not thinking "product = Cartesian product = ordered tuples = ordered" in my head. I'm thinking "first choose 2 elements from 10, then choose 2 elements from 8...what's 8? that's the number of remaining elements. Next choose 2 elements from the remaining 6." Then I go back and think "first I chose these two, then second I chose these two, then third, these two...first, second, third, that's 1, 2, 3 which is an order, I should divide by 5!" – Sera Gunn Jun 29 '17 at 21:56
  • @Stephen You did some of that yourself. I never told you why to divide by 5!, but once I told you, you knew what dividing by 5! does to the formula. All of the operations in that formula: the binomial coefficients, multiplying, subtracting 2 from the top number each time, divinding by 5!. All of these have meaning. – Sera Gunn Jun 29 '17 at 22:00
  • Just a quick book plug: ''Principles and Techniques in Combinatorics'' by Chen Chuan-Chong and Koh Khee-Meng gives you a full work out: theory, exercises, and answers :) One of the nicest out there. The books mentioned by user448692 ("generatingfunctionology", and ''A=B'') are classics in their field too. R.P. Stanley has written the 2-volume bible of Combinatorics, ''Enumerative Combinatorics'', for those who really know their multinomials. – Daniel Buck Jul 16 '17 at 13:07
  • I've built a program, which I demoed here, to help verify counting solutions: https://youtu.be/uNSJFOX_fxM – Addem Aug 13 '22 at 15:25
  • This is a great question and actually for a long time I have been planning to write something at length that addresses more or less exactly this.

    I like the phrase 'story proofs' that you use. The fact that such story proofs are acceptable in this kind of combinatorics actually turns a lot of people off the subject. Whereas in real analysis, turning these 'story proofs' into rigorous proofs by carefully using definitions, sets, inequalities etc. is central to the practice of the subject.

    – SBK Oct 27 '25 at 08:21
  • Turning these story proofs in combinatorics into rigorous and verifiable justifications is usually just not taught. That's partly because it's a much more mature skill, but it does make you wonder why 'story' approaches to counting problems are taught at all. – SBK Oct 27 '25 at 08:30
  • In addition to the many other good suggestions, sometimes there's a OEIS sequence that corresponds to what you are trying to calculate, so it's a good resource to check your solution against. The sequences are easily searchable, so you just need the first few terms to find the sequence, or a good description of it. – Simon Goater Oct 27 '25 at 17:25

5 Answers5

40

Here are some methods I have used. Some of these have already been suggested in the comments, and none of them are fool-proof.

  1. Work out a few small cases by hand, i.e. generate all the possibilities, and verify that your formula works in those cases. (Often working out the small cases will also suggest a method of solution.)
  2. Solve the problem by two different methods. For example, often a problem which is solved by the principle of inclusion/exclusion can also be solved by generating functions. Or it may be that you can derive a recurrence that the solution must satisfy, and verify that your solution satisfies the recurrence; if it is too hard to do the general case, verify the recurrence is satisfied for a few small cases.
  3. Write a computer program that solves a particular case of the problem by "brute force", i.e. enumerates all the possibilities, and check the count against your analytic answer. If you don't yet know how to program, this is one of many reasons why it's good to to learn how. For example, how many ways can you make change for a dollar? It's probably easier to write a program that generates all the ways than to solve this problem analytically.
  4. Sometimes a combinatoric problem can be reinterpreted as a probability problem. For example, the problem of counting all the poker hands that form a full house is closely connected to the probability of drawing a full house. In this case you can check your answer by Monte Carlo simulation: use a random number generator to simulate many computer hands and count the number which are full houses. Once again, this requires computer programming skills. You won't get an exact match against your analytic answer, but the proportion of full houses should be close to your analytic result. Here it helps to know some basic statistics, e.g. the Student's t test, so you can check to see if your answer falls in the range of plausible results.
awkward
  • 15,731
  • 3
    Being a programmer, I think, "of course my hammer works on this nail", but intellectually I rebel against the idea that the best way to check my theory is to use a machine that didn't exist when the study of combinatorics was born... – Kristen Hammack Jun 29 '17 at 12:55
  • 13
    @KristenHammack - Why would that be a problem? Hammers and nails didn't exist when someone first had to figure out how to hold two pieces of wood together. But in most situations they are a superior solution to tying the wood together with braided grass or strips of leather. – Paul Sinclair Jun 29 '17 at 16:49
  • 1
    @PaulSinclair that's certainly an interesting way of looking at it. But I was wondering if maybe there was a more elegant "screwdriver" type of solution, with the brute force programming method being more like "let me hammer this screw into the wood", and a formal proof being "here's the perfectly-fitting screwdriver for this particular screw". I'm used to seeing that in CS. – Kristen Hammack Jun 29 '17 at 17:04
  • 1
    Plus a programming check probably won't give much extra intuition about why a solution is correct or incorrect. I am also a programmer and wouldn't hesitate to write a program to do the check if I needed it, but it wouldn't be my first choice. – Stephen Jun 29 '17 at 21:42
  • 6
    @KristenHammack But the question is not about "how do you figure this out". It is about "I think I have it solved, but I want to double-check that I haven't missed something". For this, "experimental mathematics" is and always has been a tool-of-choice. And computers vastly increase the amount of experimentation that is feasible. And for Stephen's comment, even if you are still trying to figure it out, having a good sample of actual solutions can be a godsend for better understanding the behavior. Computer proofs may be boring, but they are excellent mathematical telescopes. – Paul Sinclair Jun 29 '17 at 23:10
  • I like to hear a second voice and therefore chat with my friend Ruby. – mvw Jun 30 '17 at 22:38
14

Here are some other methods:

  • Estimate what the answer should be. For example, Let's say I want to count all 3-element subsets of $1,\dots,n$ where the sum of any two elements is not equal to the third. I think to myself "hmm, if $n$ is large then most three element subsets should be valid." So whatever the answer is, I know that it should be close to $\binom{n}{3}$ if $n \gg 0$.

  • Also keep in mind that your intuition about how large the answer should be might be off. This is ok! It means you will put more thought into the problem.

  • Have someone look over your work. This can work really well because sometimes you'll have something you are mistaken about in the back of your mind when you are writing. When this happens, what you write will (hopefully) look funny to other people whereas it might take a lot of thought on your part to catch that something is off.

  • Be more rigorous. This is easier said than done, obviously. For example if you are applying a theorem, look to make sure that you satisfy all the necessary hypotheses to be able to apply it.

  • Slow down and think about "why am I multiplying here?" or dividing, or differentiating. Make sure the algebra makes sense combinatorially. If you are dividing, make sure you end up with integers where there should be integers.

Sera Gunn
  • 28,131
  • 1
    Having somebody look over work is a very good suggestion. Fortunately I am in a programming context where code review is de rigeur – Stephen Jun 29 '17 at 01:34
12

It is actually possible to be rigorous in questions like this – though it can be a lot of work.

The first step is to build a mathematical model that corresponds to the question. This part deserves some thought, and there is scope for error, but usually just expressing the question mathematically is easier to do without error than finding the actual answer.

For this example, we might say that a partnering of a group of $2n$ people (whom we'll refer to as $G=\left\{0, 1, \ldots, 2n-1\right\}$) is any function $p: G \rightarrow G$ such that:

  • For all $m$: $p(p(m)) = m$ (i.e. a person's partner is paired with the person)
  • For all $m$: $p(m) \neq m$ (i.e. nobody is partnered with themself)

Hopefully it's fairly clear that the above corresponds to the definition of a partnering from the question - if not, you can do it in a way that's clearer to you.

Having made that definition, the question becomes: how many such functions $p$ are there?

One way to establish the answer rigorously is to come up with a bijection $B$ between the set of partnerings $P = \{p: p \,\hbox{is a partnering of $2n$ people}\}$ and an initial subset of the natural numbers $\mathbb N$.

That can be done as follows – I'll omit a lot of details for brevity, but hopefully it should be clear that this can be made fully rigorous. Given a partnering $p$:

Start with a set $U_0=G$ of unpartnered people, and a value $v_0=0$. At each step $k$, starting from 0:

  • Consider the person from $U_k$ with the smallest number – call them $g_k$.
  • Find out who they're partnered with – that is, evaluate $p(g_k)$ - and find that person's "rank" in $U_k\setminus g_k$ starting from 0. That is, if (of all people other than $g_k$ who are so far unpartnered) $p(g_k)$ has the lowest number, call them rank 0, and if there are three with numbers lower than $p(g_k)$ that are unpartnered, call them rank 3, and so on. Call that rank $r_k$.
  • Set $U_{k+1} = U_k \setminus \{g_k, p(g_k)\}$ and $v_{k+1} = v_k\left|U_k-1\right| + r_k$. That is, take out the two people we just partnered, and calculate a new value from the previous step's value and the rank of the person we just partnered with $g_k$.

Repeat for $k$ from 0 to $n-2$, and take $v_{n-1}$ as our result for $B(p)$.

It's clear that, given any partnering $p$, this procedure gives us back a number $B(p)$. What may not yet be clear is that, given $B(p)$, we can determine what $p$ was – that is, $B$ is a bijection.

I won't go into the details of that, but note that, when calculating the value, the person who gets partnered with person 0 has their rank multiplied by $(2n-3)(2n-5)\ldots1$, and we can get it back by dividing $B(p)$ by that number – the integer part of the answer gives us $p(0)$, and then we can use the remainder in a similar way to deduce the rest of the pairings in $p$.

So (again I'm leaving out some proof details) we have a function that is a bijection between $\left\{0,1,2,\ldots,m-1\right\}$ and the set of possible partnerings of $2n$ people. This is enough to show that there are $m$ such partnerings – and it's reasonably easy to see (by taking the maximum possible value at each step in the procedure above) that the value of $m$ is exactly $(2n-1)(2n-3)\cdots 1$ as you already knew.

psmears
  • 812
  • It's good to be able to do things with symbols like this; it's seldom necessary. Excellent mathematics uses symbols to convey an intuitive understanding. Mediocre mathematics uses symbols in place of intuitive understanding. Poor mathematics uses symbols to disguise the total absence of intuitive understanding. – Wildcard Jun 29 '17 at 19:37
  • 4
    @Wildcard: I don't think anyone said it was necessary! The point is that it is possible to achieve a high degree of rigour in combinatorics. The OP was asking about how to be more sure about one's answers; symbolic reasoning is a powerful tool that can help with that. – psmears Jun 29 '17 at 20:08
  • 1
    psmears upvoted for your efforts. I didn't quite understand it, but I will come back to it once my math is a bit stronger (specifically once I understand bijections). Also @Wildcard that is quite funny. – Stephen Jun 29 '17 at 23:52
  • @Stephen:Sorry--it's hard to know what level to go for! A "bijection" is a fancy name for a function that is invertible: the basic idea above is to find a way of giving each possible partnering a unique number, such that given a partnering you can find its number, and given a number you can find the corresponding partnering. Once that's done, if the partnerings are numbered 0 to $m-1$, you know there are $m$ partnerings in total. The advantage is everything (after the initial definition) can be 100% rigorous--but that's a lot of work (my long answer omits many details), hence it's rarely done! – psmears Jun 30 '17 at 09:38
  • This is an enlightening answer. We go to a lot of trouble to develop other subjects rigorousIy, we should know how to do it for combinatorics as well. I especially like your emphasis on the modeling step, which I think is often glossed over in combinatorics books. – littleO Jul 06 '17 at 09:24
0

One practical method, which I can illustrate with your example, is to get rid of fractions.

This gives you more concrete things to count and avoids 'story proof' phrases like "divide by ... because order doesn't matter''.

It means that if we want to check the claim that $$\mathrm{Answer} = \frac{(2n)!}{2^nn^!}, $$ then we should instead to consider proving that $$\mathrm{Answer} \times n! \times 2^n = (2n)!$$

This more readily suggests how to count: The idea is now clearly to count something of cardinality $(2n)!$ in two ways. Obviously, the problem suggests we should count the elements of $S_{2n}$ i.e. the number of ways of ordering the $2n$ people.

Looking at the factors on the left it is clear that a rigorous proof can be obtained if we can come up with a bijection $$ A_1 \times A_2 \times A_3 \longleftrightarrow S_{2n},$$ where $$ |A_1| = \mathrm{Answer}; \qquad |A_2| = n!; \qquad |A_3| = 2^n$$

There are of course very natural candidates for things of size $n!$ and $2^n$, leading us to see that an arrangement of $\{1,...,2n\}$ is obtained by

  1. Picking a partition of $\{1,...,2n\}$ into $n$ pairs (in one of $|A_1|$ ways).
  2. Picking an arrangement for those $n$ pairs (in one of $|A_2| = n!$ ways).
  3. Choosing an ordering for each pair in the partition (in one of $|A_3| = 2^n$ ways).

If you want to make these steps more verifiable, then the notation is bound to get more complicated: Off the top of my head you could say:

  1. Pick a partition $$X = \bigl\{\{x_{11},x_{12}\}, \{x_{21},x_{22}\},\dots,\{x_{n1},x_{n2}\}\bigr\}$$ of $\{1,...,2n\}$ into $n$ pairs.
  2. Pick an arrangement $\alpha \in S_n$ for those pairs.
  3. Choose an element from each pair to go 'first', by picking $\beta = (\beta_1,\dots,\beta_n) \in S_2^n$ (i.e. the cartesian product of $S_2$ with itself $n$ times).

Then we can actually define $F : A_1 \times S_n \times S_2^n \longrightarrow S_{2n}$ by saying $F(X,\alpha,\beta) = \sigma$, where, for odd $i$: $$ \sigma(i) = x_{\alpha(i)\beta_i(1)}; \qquad \text{and} \qquad \sigma(i+1) = x_{\alpha(i)\beta_i(2)} $$ Then one really can claim: "$F$ is surjective" and actually write down a proof. And then: "$F$ is injective" and write a proof.

I personally don't think these things should be glossed over and that in principle there's loads to be learned from completely thinking through a problem in the way I'm doing here, but typically this sort of thing isn't taught.

SBK
  • 3,754
0

If you are working with specific numbers in the form $\binom{n}{k}$, there's a really neat thing you can do involving Pascal's Triangle. Although this works best for small numbers, it is a reliable way to check your method and ensure that you have gotten the correct answer. The table is as follows:

\begin{array}{|r|rrrrrr} \hline & 0 & 1 & 2 & 3 & 4 & \cdots \\ \hline 0 & 1 & & & \\ 1 & 1 & 1 & & \\ 2 & 1 & 2 & 1 & \\ 3 & 1 & 3 & 3 & 1 \\ 4 & 1 & 4 & 6 & 4 & 1 \\ \cdots & . & . & . & . & . & . \\ \end{array}

Using the vertical column for $n$ and the horizontal row for $k$, we can use this property to check an answer for a specific combinatorics question. For instance, if we calculate $\binom{4}{2}$, we get the answer of $6$.

This works because Pascal's Triangle gives us binomial coefficients: for example, expanding the binomial $(a + b)(a + b)$, we get $a^2 + 2ab + b^2$. The coefficients of each match the 3rd line of Pascal's Triangle, [1, 2, 1], as there is 1 way to write $aa$, 2 ways to write $ab$ ($ab$ or $ba$), and 1 way to write $bb$. That's the link to combinatorics, and that's why this is an effective way to check if your answer is correct, for small values of $n$ and $k$. That said, using this as verification is best to check if your method is correct, and extrapolate with larger $n$ from there. Unless you have a big enough Pascal's Triangle lying around! (:

Useful links:

Pascal's Triangle - Wikipedia

Combinatorics - Wikipedia, especially the subfields section

Combinatorial proof - Wikipedia, for proving the formula used to help understand it.