# Circular optimization

This post will mostly be focused on construction-type problems in which you’re asked to construct something satisfying property ${P}$.

Minor spoilers for USAMO 2011/4, IMO 2014/5.

## 1. What is a leap of faith?

Usually, a good thing to do whenever you can is to make “safe moves” which are implied by the property ${P}$. Here’s a simple example.

Example 1 (USAMO 2011)

Find an integer ${n}$ such that the remainder when ${2^n}$ is divided by ${n}$ is odd.

It is easy to see, for example, that ${n}$ itself must be odd for this to be true, and so we can make our life easier without incurring any worries by restricting our search to odd ${n}$. You might therefore call this an “optimization”: a kind of move that makes the problem easier, essentially for free.

But often times such “safe moves” or not enough to solve the problem, and you have to eventually make “leap-of-faith moves”. For example, maybe in the above problem, we might try to focus our attention on numbers ${n = pq}$ for primes ${p}$ and ${q}$. This does make our life easier, because we’ve zoomed in on a special type of ${n}$ which is easy to compute. But it runs the risk that maybe there is no such example of ${n}$, or that the smallest one is difficult to find.

## 2. Circular reasoning can sometimes save the day

However, a strange type of circular reasoning can sometimes happen, in which a move that would otherwise be a leap-of-faith is actually known to be safe because you also know that the problem statement you are trying to prove is true. I can hardly do better than to give the most famous example:

Example 2 (IMO 2014)

For every positive integer ${n}$, the Bank of Cape Town issues coins of denomination ${\frac 1n}$. Given a finite collection of such coins (of not necessarily different denominations) with total value at most ${99 + \frac12}$, prove that it is possible to split this collection into ${100}$ or fewer groups, such that each group has total value at most ${1}$.

Let’s say in this problem we find ourselves holding two coins of weight ${1/6}$. Perhaps we wish to put these coins in the same group, so that we have one less decision to make. However, this could rightly be viewed as a “leap-of-faith”, because there’s no logical reason why the task must remain possible after making this first move.

Except there is a non-logical reason: this is the same as trading the two coins of weight ${1/6}$ for a single coin of weight ${1/3}$. Why is the task still possible? Because the problem says so: the very problem we are trying to solve includes this case, too. If the problem is going to be true, then it had better be true after we make this trade.

Thus by a perverse circular reasoning we can rest assured that our leap-of-faith here will not come back to bite us. (And in fact, this optimization is a major step of the solution.)

## 3. More examples of circular optimization

Here’s some more examples of problems you can try that I think have a similar idea.

Problem 1

Prove that in any connected graph ${G}$ on ${2004}$ vertices one can delete some edges to obtain a graph (also with ${2004}$ vertices) whose degrees are all odd.

Problem 2 (USA TST 2017)

In a sports league, each team uses a set of at most ${t}$ signature colors. A set ${S}$ of teams is color-identifiable if one can assign each team in ${S}$ one of their signature colors, such that no team in ${S}$ is assigned any signature color of a different team in ${S}$. For all positive integers ${n}$ and ${t}$, determine the maximum integer ${g(n,t)}$ such that: In any sports league with exactly ${n}$ distinct colors present over all teams, one can always find a color-identifiable set of size at least ${g(n,t)}$.

Feel free to post more examples in the comments.

# Hard and soft techniques

In yet another contest-based post, I want to distinguish between two types of thinking: things that could help you solve a problem, and things that could help you understand the problem better. Then I’ll talk a little about how you can use the latter. (I’ve talked about this in my own classes for a while by now, but only recently realized I’ve never gotten the whole thing in writing. So here goes.)

## 1. More silly terminology

As usual, to make these things easier to talk about, I’m going to introduce some words to describe these two. Taking a page from martial arts, I’m going to run with hard and soft techniques.

A hard technique is something you try in the hopes it will prove something — ideally, solve the problem, but at least give you some intermediate lemma. Perhaps a better definition is “things that will end up in the actual proof”. Examples include:

• Angle chasing in geometry, or proving quadrilaterals are cyclic.
• Throwing complex numbers at a geometry problem.
• Plugging in some values into a functional equation (which gives more equations to work with).
• Taking a given Diophantine equation modulo ${p}$ to get some information, or taking ${p}$-adic evaluations.
• Trying to perform an induction, for example by deleting an element.
• Trying to write down an inequality that when summed cyclically gives the desired conclusion.
• Reducing the problem to one or more equivalent claims.

and so on. I’m sure you can come up with more examples.

In contrast, a soft technique is something you might try to help you understand the problem better — even if it might not prove anything. Perhaps a better definition is “things not written up”. Examples include:

• Examining particular small cases of the problem.
• Looking at the equality cases of a min/max problem.
• Considering variants of the problem (for example, adding or deleting conditions).
• Coming up with lots of concrete examples and playing with them.
• Trying to come with a counterexample to the problem’s assertion and seeing what the obstructions are.
• Drawing pictures, even on non-geometry problems (see JMO2 and JMO5 in my 2019 notes for example).
• Deciding whether or not a geometry problem is “purely projective”.
• Counting the algebraic degrees of freedom in a geometry problem.
• Checking all the linear/polynomial solutions to a functional equation, in order to get a guess what the answer might be.
• Blindly trying to guess solutions to an algebraic equation.
• Making up an artificial unnatural function in a functional equation, and then trying to see why it doesn’t work (or occasionally being surprised that it does work).
• Thinking about why a certain hard technique you tried failed, or even better convincing yourself it cannot work (for example, this Diophantine equation has a solution modulo every prime, so stop trying to one-shot by mods).
• Giving a heuristic argument that some claim should be true or false (“probably ${2^n \bmod n}$ is odd infinitely often”), or even easy/hard to prove.

and so on. There is some grey area between these two, some of the examples above might be argued to be in the other category (especially in context of specific problems), but hopefully this gives you a sense of what I’m talking about.

If you look at things I wrote back when I was in high school, you’ll see this referred to as “attacking” and “scouting” instead. This is too silly for me now even by my standards, but back then it was because I played a lot of StarCraft: Brood War (I’ve since switched to StarCraft II). The analogy there is pretty self-explanatory: knowing what your opponent is doing is important because your army composition and gameplay decisions should change in reaction to more information.

## 2. Using soft techniques: an example

Now after all that blabber, here’s the action item for you all: you should try soft techniques when stuck.

When you first start doing a problem, you will often have some good ideas for what to try. (For example: a wild geometry appeared, let’s scout for cyclic quadrilaterals.) Sometimes if you are lucky enough (especially if the problem is easier) this will be enough to topple the problem, and you can move on. But more often what happens is that eventually you run out of steam, and the problem is still standing. When that happens, my advice is to try doing some soft techniques if you haven’t already done so.

Here’s an example that I like to give.

Example 1 (USA TST 2009)

Find all real numbers ${x}$, ${y}$, ${z}$ which satisfy

\displaystyle \begin{aligned} x^3 &= 3x - 12y + 50,\\ y^3 &= 12y + 3z - 2,\\ z^3 &= 27z + 27x. \end{aligned}

A common first thing that people will try to do is add the first two equations, since that will cause the ${12y}$ terms to cancel. This gives a factor of ${x+y}$ in the left and an ${x+z}$ in the right, so then maybe you try to submit that into the ${27(x+z)}$ in the last equation, so you get ${z^3 = 9(x^3+y^3-48)}$, cool, there’s no more linear terms. Then. . .

Usually this doesn’t end well. You add this and subtract that and in the end all you see is equation after equation, and after a while you realize you’re not getting anywhere.

So we’re stuck now. What to do? I’ll now bring in two of the soft techniques I mentioned earlier:

1. Let’s imagine the problem had ${\mathbb R}$ replaced with ${\mathbb C}$. In this new problem, you can imagine solving for ${y}$ in terms of ${x}$ using the first equation, then ${z}$ in terms of ${y}$, and then finally putting everything into the last equation to find a degree ${27}$ polynomial in ${x}$. I say “imagine” because wow would that be ugly.

But here’s the kicker: it’s a polynomial. It should have exactly ${27}$ complex roots, with multiplicity. That’s a lot. Really?

So here’s a hint you might take: there’s a good reason this is over ${\mathbb R}$ but not ${\mathbb C}$. Often these kind of things end up being because there’s an inequality going on somewhere, so there will only be a few real solutions even though there might be tons of complex ones.

2. Okay, but there’s an even more blatant thing we don’t know yet: what is the answer, anyways?

This was more than a little bit embarrassing. We’re half an hour in to the problem and thoroughly stuck, and we don’t even have a single ${(x,y,z)}$ that works? Maybe it’d be a good idea to fix that, like, right now. In the simplest way possible: guess and check.

It’s much easier than it sounds, since if you pick a value of ${z}$, say, then you get ${x}$ from the third equation, ${y}$ from the first, then check whether it fits the second. If we restrict our search to integer values of ${z}$, then there aren’t so many that are reasonable.

I won’t spoil what the answer ${(x,y,z)}$ is, other than saying there is an integer triple and it’s not hard to find it as I described. Once you have these two meta-considerations, you suddenly have a much better foothold, and it’s not too hard to solve the problem from here (for a USA TST problem anyways).

I pick this example because it really illustrates how hopeless repeatedly using hard techniques can be if you miss the right foothold (and also because in this problem it’s unusually tempting to just think that more manipulation is enough). It’s not impossible to solve the problem without first realizing what the answer is, but it is certainly way more difficult.

## 3. Improving at soft techniques

What this also means is that, in the after-math of a problem (when you’ve solved/given up on a problem and are reading and reflecting on the solution), you should also add soft techniques into the list of possible answers to “how might I have thought of that?”. An example of this is at the end of my earlier post On Reading Solutions, in which I describe how you can come up with solutions to two Putnam problems by thinking carefully about what should be the equality case.

Doing this is harder than it sounds, because the soft techniques are the ones that by definition won’t appear in most written solutions, and many people don’t explicitly even recognize them. But soft techniques are the things that tell you which hard techniques to use, which is why they’re so valuable to learn well.

In writing this post, I’m hoping to make the math contest world more aware that these sorts of non-formalizable ideas are things that can (and should) be acknowledged and discussed, the same way that the hard techniques are. In particular, just as there are a plethora of handouts on every hard technique in the olympiad literature, it should also be possible to design handouts aimed at practicing one or more particular soft techniques.

At MOP every year, I’m starting to see more and more classes to this effect (alongside the usual mix of classes called “inversion” or “graph theory” or “induction” or whatnot). I would love to see more! End speech.

# Napkin v1.5 (and more)

Careful readers of my blog might have heard about plans to have a second edition of Napkin out by the end of February. As it turns out I was overly ambitious, and (seeing that I am spending the next week … Continue reading

# Math contest platitudes, v3

I think it would be nice if every few years I updated my generic answer to “how do I get better at math contests?”. So here is the 2019 version. Unlike previous instances, I’m going to be a little less olympiad-focused than I usually am, since these days I get a lot of people asking for help on the AMC and AIME too.

(Historical notes: you can see the version from right after I graduated and the version from when I was still in high school. I admit both of them make me cringe slightly when I read them today. I still think everything written there is right, but the style and focus seems off to me now.)

## 0. Stop looking for the “right” training (or: be yourself)

These days many of the questions I get are clearly most focused on trying to find a perfect plan — questions like “what did YOU do to get to X” or “how EXACTLY do I practice for Y”. (Often these words are in all-caps in the email, too!) When I see these I always feel very hesitant to answer. The reason is that I always feel like there’s some implicit hope that I can give you some recipe that, if you follow it, will guarantee reaching your goals.

I’m sorry, math contests don’t work that way (and can’t work that way). I actually think that if I gave you a list of which chapters of which books I read in 2009-2010 over which weeks, and which problems I did on each day, and you followed it to the letter, it would go horribly.

Why? It’s not just a talent thing, I think. Solving math problems is actually a deeply personal art: despite being what might appear to be a cold and logical discipline, learning math and getting better at it actually requires being human. Different people find different things natural or unnatural, easy or hard, et cetera. If you try to squeeze yourself into some mold or timeline then the results will probably be counterproductive.

On the flip side, this means that you can worry a lot less. I actually think that surprisingly often, you can get a first-order approximation of what’s the “best” thing to do by simply doing whatever feels the most engaging or rewarding (assuming you like math, of course). Of course there are some places where this is not correct (e.g., you might hate geometry, but cannot just ignore it). But the first-order approximation is actually quite decent.

That’s why in the introduction to my geometry book, I explicitly have the line:

Readers are encouraged to not be bureaucratic in their learning and move around as they see fit, e.g., skipping complicated sections and returning to them later, or moving quickly through familiar material.

Put another way: as learning math is quite personal, the advice “be yourself” is well-taken.

## 1. Some brief recommendations (anyways)

With all that said, probably no serious harm will come from me listing a little bit of references I think are reasonable — so that you have somewhere to start, and can oscillate from there.

For learning theory and fundamentals:

For sources of additional practice problems (other than the particular test you’re preparing for):

• The collegiate contests HMMT November, PUMaC, CMIMC will typically have decent short-answer problems.
• HMMT February is by far the hardest short-answer contest I know of.
• At the olympiad level, there are so many national olympiads and team selection tests that you will never finish. (My website has an archive of USA problems and solutions if you’re interested in those in particular.)
The IMO Shortlist is also good place to work as it contains proposals of varying difficulty from many countries — and thus is the most culturally diverse. As for other nations, as a rule of thumb, any country that often finishes in the top 20 at the IMO (say) will probably have a good questions on their national olympiad or TST.

For every subject that’s not olympiad geometry, there are actually surprisingly few named theorems.

## 2. Premature optimization is the root of all evil (so just get your hands dirty)

For some people, the easiest first step to getting better is to double the amount of time you spend practicing. (Unless that amount is zero, in which case, you should just start.)

There is a time and place for spending time thinking about how to practice — one example is if you’ve been working a while and feel like nothing has changed, or you’ve been working on some book and it just doesn’t feel fun, etc. Another common example is if you notice you keep missing all the functional equations on the USAMO: then, maybe it’s time to search up some handouts on functional equations. Put another way, if you feel stuck, then you can start thinking about whether you’re not doing something right.

On the other extreme, if you’re wondering whether you are ready to read book X or do problems from Y contest, my advice is to just try it and see if you like it. There is no commitment: just read Chapter 1, see how you feel. If it works, keep doing it, if not, try something else.

(I can draw an analogy from my own life. Whenever I am learning a new board game or card game, like Catan or Splendor or whatever, I always overthink it. I spend all this time thinking and theorizing and trying to come up with this brilliant strategy — which never works, because it’s my first game, for crying out loud. It turns out that until you start grappling at close range and getting your hands dirty, your internal model of something you’ve never done is probably not that good.)

## 3. Doing problems just above your level (and a bit on reflecting on them)

There is one pitfall that I do see sometimes, common enough I will point it out. If you mostly (only?) do old practice tests or past problems, then you’re liable to be spending too much time on easy problems. That was the topic of another old post of mine, but the short story is that if you find yourself constantly getting 130ish on AMC10 practice tests, then maybe you should spend most of your time working on problems 21-25 rather than repeatedly grinding 1-20 over and over. (See 28:30-29:00 here to hear Zuming make fun of them.)

The common wisdom is that you should consistently do problems just above your level so that you gradually increase the difficulty of problems you are able to solve. The situation is a little more nuanced at the AMC/AIME level, since for those short-answer contests it’s also important to be able to do routine problems quickly and accurately. However, I think for most people, you really should be spending at least 70% of your time getting smarter, rather than just faster.

I think in this case, I want to give concrete descriptions. Here’s some examples of what can happen after a problem.

• You looked at the problem and immediately (already?) knew how to do it. Then you probably didn’t learn much from it. (But at least you’ll get faster, if not smarter.)
• You looked at the problem and didn’t know right away how to start, but after a little while figured it out. That’s a little better.
• You struggled with the problem and eventually figured out a solution, but maybe not the most elegant one. I think that’s a great situation to be in. You came up with some solution to the problem, so you understand it fairly well, but there’s still more for you to update your instincts on. What can you do in the future to get solutions more like the elegant one?
• You struggled with the problem and eventually gave up, then when you read the solution you realize quickly what you were missing. I think that’s a great situation to be in, too. You now want to update your instincts by a little bit — how could you make sure you don’t miss something like that again in the future?
• The official solution quoted some theorem you don’t know. If this was among a batch of problems where the other problems felt about the right level to you, then I think often this is a pretty good time to see if you can learn the statement (better, proof) of the theorem. You have just spent some time working on a situation in which the theorem was useful, so that data is fresh in your mind. And pleasantly often, you will find that ideas you came up with during your attempt on the problem correspond to ideas in the statement or proof of the theorem, which is great!
• You didn’t solve the problem, and the solution makes sense, but you don’t see how you would have come up with it. It’s possible that this is the fault of the solutions author (many people are actually quite bad at making solutions read naturally). If you have a teacher, this is the right time to ask them about it. But it’s also possible that the problem was too hard. In general, I think it’s better to miss problems “by a little”, whatever that means, so that you can update your intuition correctly.
• You can’t even understand the solution. Okay, too hard.

You’ll notice how much emphasis I place on the post-problem reflection process. This is actually important — after all the time you spent working on the problem itself, you want to update your instincts as much as possible to get the payoff. In particular, I think it’s usually worth it to read the solutions to problems you worked on, whether or not you solve them. In general, after reading a solution, I think you should be able to state in a couple sentences all the main ideas of the solution, and basically know how to solve the problem from there.

For the olympiad level, I have a whole different post dedicated to reading solutions, and interested readers can read more there. (One point from that post I do want to emphasize since it wasn’t covered explicitly in any of the above examples: by USA(J)MO level it becomes important to begin building intuition that you can’t explicitly formalize. You may start having vague feelings and notions that you can’t quite put your finger on, but you can feel it. These non-formalizable feelings are valuable, take note of them.)

## 4. Leave your ego out (e.g. be willing to give up on problems)

This is easy advice to give, but it’s hard advice to follow. For concreteness, here are examples of things I think can be explained this way.

Sometimes people will ask me whether they need to solve every problem in each chapter of EGMO, or do every past practice test, or so on. The answer is: of course not, and why would you even think that? There’s nothing magical about doing 80% of the problems versus 100% of them. (If there was, then EGMO is secretly a terrible book, because I commented out some problems, and so OH NO YOU SKIPPED SOME AAAHHHHH.) And so it’s okay to start Chapter 5 even though you didn’t finish that last challenge problem at the end. Otherwise you let one problem prevent you from working on the next several.

Or, sometimes I learn about people who, if they do not solve an olympiad problem, will refuse to look at the solution; instead they will mark it in a spreadsheet and to come back to later. In short, they never give up on a problem: which I think is a bad idea, since reflecting on missed problems is so important. (It is not as if you can realistically run out of olympiad problems to do.) And while this is still better than giving up too early, I mean, all things in moderation, right?

I think if somehow people were able to completely leave your ego out, and not worry at all about how good you are and rather just maximize learning, then mistakes like these two would be a lot rarer. Of course, this is impossible to do in practice (we’re all human), but it’s good to keep in mind at least that this is an ideal we can strive for.

## 5. Enjoy it

Which leads me to the one bit that everyone already knows, but that no platitude-filled post would be complete without: to do well at math contests (or anything hard) you probably have to enjoy the process of getting better. Not just the end result. You have to enjoy the work itself.

Which is not to say you have to do it all the time or for hours a day. Doing math is hard, so you get tired eventually, and beyond that forcing yourself to work is not productive. Thus when I see people talk about how they plan to do every shortlist problem, or they will work N hours per day over M time, I always feel a little uneasy, because it always seems too results-oriented.

In particular, I actually think it’s quite hard to spend more than two or three good hours per day on a regular basis. I certainly never did — back in high school (and even now), if I solved one problem that took me more than an hour, that was considered a good day. (But I should also note that the work ethic of my best students consistently amazes me; it far surpasses mine.) In that sense, the learning process can’t be forced or rushed.

There is one sense in which you can get more hours a day, that I am on record saying quite often: if you think about math in the shower, then you know you’re doing it right.

# A trailer for p-adic analysis, second half: Mahler coefficients

In the previous post we defined ${p}$-adic numbers. This post will state (mostly without proof) some more surprising results about continuous functions ${f \colon \mathbb Z_p \rightarrow \mathbb Q_p}$. Then we give the famous proof of the Skolem-Mahler-Lech theorem using ${p}$-adic analysis.

## 1. Digression on ${\mathbb C_p}$

Before I go on, I want to mention that ${\mathbb Q_p}$ is not algebraically closed. So, we can take its algebraic closure ${\overline{\mathbb Q_p}}$ — but this field is now no longer complete (in the topological sense). However, we can then take the completion of this space to obtain ${\mathbb C_p}$. In general, completing an algebraically closed field remains algebraically closed, and so there is a larger space ${\mathbb C_p}$ which is algebraically closed and complete. This space is called the ${p}$-adic complex numbers.

We won’t need ${\mathbb C_p}$ at all in what follows, so you can forget everything you just read.

## 2. Mahler coefficients: a description of continuous functions on ${\mathbb Z_p}$

One of the big surprises of ${p}$-adic analysis is that we can concretely describe all continuous functions ${\mathbb Z_p \rightarrow \mathbb Q_p}$. They are given by a basis of functions

$\displaystyle \binom xn \overset{\mathrm{def}}{=} \frac{x(x-1) \dots (x-(n-1))}{n!}$

in the following way.

Theorem 1 (Mahler; see Schikhof Theorem 51.1 and Exercise 51.B)

Let ${f \colon \mathbb Z_p \rightarrow \mathbb Q_p}$ be continuous, and define

$\displaystyle a_n = \sum_{k=0}^n \binom nk (-1)^{n-k} f(n). \ \ \ \ \ (1)$

Then ${\lim_n a_n = 0}$ and

$\displaystyle f(x) = \sum_{n \ge 0} a_n \binom xn.$

Conversely, if ${a_n}$ is any sequence converging to zero, then ${f(x) = \sum_{n \ge 0} a_n \binom xn}$ defines a continuous function satisfying (1).

The ${a_i}$ are called the Mahler coefficients of ${f}$.

Exercise 2

Last post we proved that if ${f \colon \mathbb Z_p \rightarrow \mathbb Q_p}$ is continuous and ${f(n) = (-1)^n}$ for every ${n \in \mathbb Z_{\ge 0}}$ then ${p = 2}$. Re-prove this using Mahler’s theorem, and this time show conversely that a unique such ${f}$ exists when ${p=2}$.

You’ll note that these are the same finite differences that one uses on polynomials in high school math contests, which is why they are also called “Mahler differences”.

\displaystyle \begin{aligned} a_0 &= f(0) \\ a_1 &= f(1) - f(0) \\ a_2 &= f(2) - 2f(1) - f(0) \\ a_3 &= f(3) - 3f(2) + 3f(1) - f(0). \end{aligned}

Thus one can think of ${a_n \rightarrow 0}$ as saying that the values of ${f(0)}$, ${f(1)}$, \dots behave like a polynomial modulo ${p^e}$ for every ${e \ge 0}$. Amusingly, this fact was used on a USA TST in 2011:

Exercise 3 (USA TST 2011/3)

Let ${p}$ be a prime. We say that a sequence of integers ${\{z_n\}_{n=0}^\infty}$ is a ${p}$-pod if for each ${e \geq 0}$, there is an ${N \geq 0}$ such that whenever ${m \geq N}$, ${p^e}$ divides the sum

$\displaystyle \sum_{k=0}^m (-1)^k \binom mk z_k.$

Prove that if both sequences ${\{x_n\}_{n=0}^\infty}$ and ${\{y_n\}_{n=0}^\infty}$ are ${p}$-pods, then the sequence ${\{x_n y_n\}_{n=0}^\infty}$ is a ${p}$-pod.

## 3. Analytic functions

We say that a function ${f \colon \mathbb Z_p \rightarrow \mathbb Q_p}$ is analytic if it has a power series expansion

$\displaystyle \sum_{n \ge 0} c_n x^n \quad c_n \in \mathbb Q_p \qquad\text{ converging for } x \in \mathbb Z_p.$

As before there is a characterization in terms of the Mahler coefficients:

Theorem 4 (Schikhof Theorem 54.4)

The function ${f(x) = \sum_{n \ge 0} a_n \binom xn}$ is analytic if and only if

$\displaystyle \lim_{n \rightarrow \infty} \frac{a_n}{n!} = 0.$

Just as holomorphic functions have finitely many zeros, we have the following result on analytic functions on ${\mathbb Z_p}$.

Theorem 5 (Strassmann’s theorem)

Let ${f \colon \mathbb Z_p \rightarrow \mathbb Q_p}$ be analytic. Then ${f}$ has finitely many zeros.

## 4. Skolem-Mahler-Lech

We close off with an application of the analyticity results above.

Theorem 6 (Skolem-Mahler-Lech)

Let ${(x_i)_{i \ge 0}}$ be an integral linear recurrence. Then the zero set of ${x_i}$ is eventually periodic.

Proof: According to the theory of linear recurrences, there exists a matrix ${A}$ such that we can write ${x_i}$ as a dot product

$\displaystyle x_i = \left< A^i u, v \right>.$

Let ${p}$ be a prime not dividing ${\det A}$. Let ${T}$ be an integer such that ${A^T \equiv \mathbf{1} \pmod p}$.

Fix any ${0 \le r < N}$. We will prove that either all the terms

$\displaystyle f(n) = x_{nT+r} \qquad n = 0, 1, \dots$

are zero, or at most finitely many of them are. This will conclude the proof.

Let ${A^T = \mathbf{1} + pB}$ for some integer matrix ${B}$. We have

\displaystyle \begin{aligned} f(n) &= \left< A^{nT+r} u, v \right> = \left< (\mathbf1 + pB)^n A^r u, v \right> \\ &= \sum_{k \ge 0} \binom nk \cdot p^n \left< B^n A^r u, v \right> \\ &= \sum_{k \ge 0} a_n \binom nk \qquad \text{ where } a_n = p^n \left< B^n A^r u, v \right> \in p^n \mathbb Z. \end{aligned}

Thus we have written ${f}$ in Mahler form. Initially, we define ${f \colon \mathbb Z_{\ge 0} \rightarrow \mathbb Z}$, but by Mahler’s theorem (since ${\lim_n a_n = 0}$) it follows that ${f}$ extends to a function ${f \colon \mathbb Z_p \rightarrow \mathbb Q_p}$. Also, we can check that ${\lim_n \frac{a_n}{n!} = 0}$ hence ${f}$ is even analytic.

Thus by Strassman’s theorem, ${f}$ is either identically zero, or else it has finitely many zeros, as desired. $\Box$

# A trailer for p-adic analysis, first half: USA TST 2003

I think this post is more than two years late in coming, but anywhow…

This post introduces the ${p}$-adic integers ${\mathbb Z_p}$, and the ${p}$-adic numbers ${\mathbb Q_p}$. The one-sentence description is that these are “integers/rationals carrying full mod ${p^e}$ information” (and only that information).

The first four sections will cover the founding definitions culminating in a short solution to a USA TST problem.

In this whole post, ${p}$ is always a prime. Much of this is based off of Chapter 3A from Straight from the Book.

## 1. Motivation

Before really telling you what ${\mathbb Z_p}$ and ${\mathbb Q_p}$ are, let me tell you what you might expect them to do.

In elementary/olympiad number theory, we’re already well-familiar with the following two ideas:

• Taking modulo a prime ${p}$ or prime ${p^e}$, and
• Looking at the exponent ${\nu_p}$.

Let me expand on the first point. Suppose we have some Diophantine equation. In olympiad contexts, one can take an equation modulo ${p}$ to gain something else to work with. Unfortunately, taking modulo ${p}$ loses some information: (the reduction ${\mathbb Z \twoheadrightarrow \mathbb Z/p}$ is far from injective).

If we want finer control, we could consider instead taking modulo ${p^2}$, rather than taking modulo ${p}$. This can also give some new information (cubes modulo ${9}$, anyone?), but it has the disadvantage that ${\mathbb Z/p^2}$ isn’t a field, so we lose a lot of the nice algebraic properties that we got if we take modulo ${p}$.

One of the goals of ${p}$-adic numbers is that we can get around these two issues I described. The ${p}$-adic numbers we introduce is going to have the following properties:

1. You can “take modulo ${p^e}$ for all ${e}$ at once”. In olympiad contexts, we are used to picking a particular modulus and then seeing what happens if we take that modulus. But with ${p}$-adic numbers, we won’t have to make that choice. An equation of ${p}$-adic numbers carries enough information to take modulo ${p^e}$.
2. The numbers ${\mathbb Q_p}$ form a field, the nicest possible algebraic structure: ${1/p}$ makes sense. Contrast this with ${\mathbb Z/p^2}$, which is not even an integral domain.
3. It doesn’t lose as much information as taking modulo ${p}$ does: rather than the surjective ${\mathbb Z \twoheadrightarrow \mathbb Z/p}$ we have an injective map ${\mathbb Z \hookrightarrow \mathbb Z_p}$.
4. Despite this, you “ignore” some “irrelevant” data. Just like taking modulo ${p}$, you want to zoom-in on a particular type of algebraic information, and this means necessarily losing sight of other things. (To draw an analogy: the equation ${ a^2 + b^2 + c^2 + d^2 = -1}$ has no integer solutions, because, well, squares are nonnegative. But you will find that this equation has solutions modulo any prime ${p}$, because once you take modulo ${p}$ you stop being able to talk about numbers being nonnegative. The same thing will happen if we work in ${p}$-adics: the above equation has a solution in ${\mathbb Z_p}$ for every prime ${p}$.)

So, you can think of ${p}$-adic numbers as the right tool to use if you only really care about modulo ${p^e}$ information, but normal ${\mathbb Z/p^e}$ isn’t quite powerful enough.

To be more concrete, I’ll give a poster example now:

Example 1 (USA TST 2002/2)

For a prime ${p}$, show the value of

$\displaystyle f_p(x) = \sum_{k=1}^{p-1} \frac{1}{(px+k)^2} \pmod{p^3}$

does not depend on ${x}$.

Here is a problem where we clearly only care about ${p^e}$-type information. Yet it’s a nontrivial challenge to do the necessary manipulations mod ${p^3}$ (try it!). The basic issue is that there is no good way to deal with the denominators modulo ${p^3}$ (in part ${\mathbb Z/p^3}$ is not even an integral domain).

However, with ${p}$-adic analysis we’re going to be able to overcome these limitations and give a “straightforward” proof by using the identity

$\displaystyle \left( 1 + \frac{px}{k} \right)^{-2} = \sum_{n \ge 0} \binom{-2}{n} \left( \frac{px}{k} \right)^n.$

Such an identity makes no sense over ${\mathbb Q}$ or ${\mathbb R}$ for converge reasons, but it will work fine over the ${\mathbb Q_p}$, which is all we need.

## 2. Algebraic perspective

We now construct ${\mathbb Z_p}$ and ${\mathbb Q_p}$. I promised earlier that a ${p}$-adic integer will let you look at “all residues modulo ${p^e}$” at once. This definition will formalize this.

### 2.1. Definition of ${\mathbb Z_p}$

Definition 2 (Introducing ${\mathbb Z_p}$)

A ${p}$-adic integer is a sequence

$\displaystyle x = (x_1 \bmod p, \; x_2 \bmod{p^2}, \; x_3 \bmod{p^3}, \; \dots)$

of residues ${x_e}$ modulo ${p^e}$ for each integer ${e}$, satisfying the compatibility relations ${x_i \equiv x_j \pmod{p^i}}$ for ${i < j}$.

The set ${\mathbb Z_p}$ of ${p}$-adic integers forms a ring under component-wise addition and multiplication.

Example 3 (Some ${3}$-adic integers)

Let ${p=3}$. Every usual integer ${n}$ generates a (compatible) sequence of residues modulo ${p^e}$ for each ${e}$, so we can view each ordinary integer as ${p}$-adic one:

$\displaystyle 50 = \left( 2 \bmod 3, \; 5 \bmod 9, \; 23 \bmod{27}, \; 50 \bmod{81}, \; 50 \bmod{243}, \; \dots \right).$

On the other hand, there are sequences of residues which do not correspond to any usual integer despite satisfying compatibility relations, such as

$\displaystyle \left( 1 \bmod 3, \; 4 \bmod 9, \; 13 \bmod{27}, \; 40 \bmod{81}, \; \dots \right)$

which can be thought of as ${x = 1 + p + p^2 + \dots}$.

In this way we get an injective map

$\displaystyle \mathbb Z \hookrightarrow \mathbb Z_p \qquad n \mapsto \left( n \bmod p, n \bmod{p^2}, n \bmod{p^3}, \dots \right)$

which is not surjective. So there are more ${p}$-adic integers than usual integers.

(Remark for experts: those of you familiar with category theory might recognize that this definition can be written concisely as

$\displaystyle \mathbb Z_p \overset{\mathrm{def}}{=} \varprojlim \mathbb Z/p^e \mathbb Z$

where the inverse limit is taken across ${e \ge 1}$.)

Exercise 4

Check that ${\mathbb Z_p}$ is an integral domain.

### 2.2. Base ${p}$ expansion

Here is another way to think about ${p}$-adic integers using “base ${p}$”. As in the example earlier, every usual integer can be written in base ${p}$, for example

$\displaystyle 50 = \overline{1212}_3 = 2 \cdot 3^0 + 1 \cdot 3^1 + 2 \cdot 3^2 + 1 \cdot 3^3.$

More generally, given any ${x = (x_1, \dots) \in \mathbb Z_p}$, we can write down a “base ${p}$” expansion in the sense that there are exactly ${p}$ choices of ${x_k}$ given ${x_{k-1}}$. Continuing the example earlier, we would write

\displaystyle \begin{aligned} \left( 1 \bmod 3, \; 4 \bmod 9, \; 13 \bmod{27}, \; 40 \bmod{81}, \; \dots \right) &= 1 + 3 + 3^2 + \dots \\ &= \overline{\dots1111}_3 \end{aligned}

and in general we can write

$\displaystyle x = \sum_{k \ge 0} a_k p^k = \overline{\dots a_2 a_1 a_0}_p$

where ${a_k \in \{0, \dots, p-1\}}$, such that the equation holds modulo ${p^e}$ for each ${e}$. Note the expansion is infinite to the left, which is different from what you’re used to.

(Amusingly, negative integers also have infinite base ${p}$ expansions: ${-4 = \overline{\dots222212}_3}$, corresponding to ${(2 \bmod 3, \; 5 \bmod 9, \; 23 \bmod{27}, \; 77 \bmod{81} \dots)}$.)

Thus you may often hear the advertisement that a ${p}$-adic integer is an “possibly infinite base ${p}$ expansion”. This is correct, but later on we’ll be thinking of ${\mathbb Z_p}$ in a more and more “analytic” way, and so I prefer to think of this as a “Taylor series with base ${p}$. Indeed, much of your intuition from generating functions ${K[[X]]}$ (where ${K}$ is a field) will carry over to ${\mathbb Z_p}$.

### 2.3. Constructing ${\mathbb Q_p}$

Here is one way in which your intuition from generating functions carries over:

Proposition 5 (Non-multiples of ${p}$ are all invertible)

The number ${x \in \mathbb Z_p}$ is invertible if and only if ${x_1 \ne 0}$. In symbols,

$\displaystyle x \in \mathbb Z_p^\times \iff x \not\equiv 0 \pmod p.$

Contrast this with the corresponding statement for ${K[ [ X ] ]}$: a generating function ${F \in K[ [ X ] ]}$ is invertible iff ${F(0) \neq 0}$.

Proof: If ${x \equiv 0 \pmod p}$ then ${x_1 = 0}$, so clearly not invertible. Otherwise, ${x_e \not\equiv 0 \pmod p}$ for all ${e}$, so we can take an inverse ${y_e}$ modulo ${p^e}$, with ${x_e y_e \equiv 1 \pmod{p^e}}$. As the ${y_e}$ are themselves compatible, the element ${(y_1, y_2, \dots)}$ is an inverse. $\Box$

Example 6 (We have ${-\frac{1}{2} = \overline{\dots1111}_3 \in \mathbb Z_3}$)

We claim the earlier example is actually

\displaystyle \begin{aligned} -\frac{1}{2} = \left( 1 \bmod 3, \; 4 \bmod 9, \; 13 \bmod{27}, \; 40 \bmod{81}, \; \dots \right) &= 1 + 3 + 3^2 + \dots \\ &= \overline{\dots1111}_3. \end{aligned}

Indeed, multiplying it by ${-2}$ gives

$\displaystyle \left( -2 \bmod 3, \; -8 \bmod 9, \; -26 \bmod{27}, \; -80 \bmod{81}, \; \dots \right) = 1.$

(Compare this with the “geometric series” ${1 + 3 + 3^2 + \dots = \frac{1}{1-3}}$. We’ll actually be able to formalize this later, but not yet.)

Remark 7 (${\frac{1}{2}}$ is an integer for ${p > 2}$)

The earlier proposition implies that ${\frac{1}{2} \in \mathbb Z_3}$ (among other things); your intuition about what is an “integer” is different here! In olympiad terms, we already knew ${\frac{1}{2} \pmod 3}$ made sense, which is why calling ${\frac{1}{2}}$ an “integer” in the ${3}$-adics is correct, even though it doesn’t correspond to any element of ${\mathbb Z}$.

Fun (but trickier) exercise: rational numbers correspond exactly to eventually periodic base ${p}$ expansions.

With this observation, here is now the definition of ${\mathbb Q_p}$.

Definition 8 (Introducing ${\mathbb Q_p}$)

Since ${\mathbb Z_p}$ is an integral domain, we let ${\mathbb Q_p}$ denote its field of fractions. These are the ${p}$-adic numbers.

Continuing our generating functions analogy:

$\displaystyle \mathbb Z_p \text{ is to } \mathbb Q_p \quad\text{as}\quad K[[X]] \text{ is to } K((X)).$

This means ${\mathbb Q_p}$ is “Laurent series with base ${p}$”, and in particular according to the earlier proposition we deduce:

Proposition 9 (${\mathbb Q_p}$ looks like formal Laurent series)

Every nonzero element of ${\mathbb Q_p}$ is uniquely of the form

$\displaystyle p^k u \qquad \text{ where } k \in \mathbb Z, \; u \in \mathbb Z_p^\times.$

Thus, continuing our base ${p}$ analogy, elements of ${\mathbb Q_p}$ are in bijection with “Laurent series”

$\displaystyle \sum_{k \ge -n} a_k p^k = \overline{\dots a_2 a_1 a_0 . a_{-1} a_{-2} \dots a_{-n}}_p$

for ${a_k \in \left\{ 0, \dots, p-1 \right\}}$. So the base ${p}$ representations of elements of ${\mathbb Q_p}$ can be thought of as the same as usual, but extending infinitely far to the left (rather than to the right).

(Fair warning: the field ${\mathbb Q_p}$ has characteristic zero, not ${p}$.)

Remark 10 (Warning on fraction field)

This result implies that you shouldn’t think about elements of ${\mathbb Q_p}$ as ${x/y}$ (for ${x,y \in \mathbb Z_p}$) in practice, even though this is the official definition (and what you’d expect from the name ${\mathbb Q_p}$). The only denominators you need are powers of ${p}$.

To keep pushing the formal Laurent series analogy, ${K((X))}$ is usually not thought of as quotient of generating functions but rather as “formal series with some negative exponents”. You should apply the same intuition on ${\mathbb Q_p}$.

(At this point I want to make a remark about the fact ${1/p \in \mathbb Q_p}$, connecting it to the wish-list of properties I had before. In elementary number theory you can take equations modulo ${p}$, but if you do the quantity ${n/p \bmod{p}}$ doesn’t make sense unless you know ${n \bmod{p^2}}$. You can’t fix this by just taking modulo ${p^2}$ since then you need ${n \bmod{p^3}}$ to get ${n/p \bmod{p^2}}$, ad infinitum. You can work around issues like this, but the nice feature of ${\mathbb Z_p}$ and ${\mathbb Q_p}$ is that you have modulo ${p^e}$ information for “all ${e}$ at once”: the information of ${x \in \mathbb Q_p}$ packages all the modulo ${p^e}$ information simultaneously. So you can divide by ${p}$ with no repercussions.)

## 3. Analytic perspective

### 3.1. Definition

Up until now we’ve been thinking about things mostly algebraically, but moving forward it will be helpful to start using the language of analysis. Usually, two real numbers are considered “close” if they are close on the number of line, but for ${p}$-adic purposes we only care about modulo ${p^e}$ information. So, we’ll instead think of two elements of ${\mathbb Z_p}$ or ${\mathbb Q_p}$ as “close” if they differ by a large multiple of ${p^e}$.

For this we’ll borrow the familiar ${\nu_p}$ from elementary number theory.

Definition 11 (${p}$-adic valuation and absolute value)

We define the ${p}$-adic valuation ${\nu_p : \mathbb Q_p^\times \rightarrow \mathbb Z}$ in the following two equivalent ways:

• For ${x = (x_1, x_2, \dots) \in \mathbb Z_p}$ we let ${\nu_p(x)}$ be the largest ${e}$ such that ${x_e \equiv 0 \pmod{p^e}}$ (or ${e=0}$ if ${x \in \mathbb Z_p^\times}$). Then extend to all of ${\mathbb Q_p^\times}$ by ${\nu_p(xy) = \nu_p(x) + \nu_p(y)}$.
• Each ${x \in \mathbb Q_p^\times}$ can be written uniquely as ${p^k u}$ for ${u \in \mathbb Z_p^\times}$, ${k \in \mathbb Z}$. We let ${\nu_p(x) = k}$.

By convention we set ${\nu_p(0) = +\infty}$. Finally, define the ${p}$-adic absolute value ${\left\lvert \bullet \right\rvert_p}$ by

$\displaystyle \left\lvert x \right\rvert_p = p^{-\nu_p(x)}.$

In particular ${\left\lvert 0 \right\rvert_p = 0}$.

This fulfills the promise that ${x}$ and ${y}$ are close if they look the same modulo ${p^e}$ for large ${e}$; in that case ${\nu_p(x-y)}$ is large and accordingly ${\left\lvert x-y \right\rvert_p}$ is small.

### 3.2. Ultrametric space

In this way, ${\mathbb Q_p}$ and ${\mathbb Z_p}$ becomes a metric space with metric given by ${\left\lvert x-y \right\rvert_p}$.

Exercise 12

Suppose ${f \colon \mathbb Z_p \rightarrow \mathbb Q_p}$ is continuous and ${f(n) = (-1)^n}$ for every ${n \in \mathbb Z_{\ge 0}}$. Prove that ${p = 2}$.

In fact, these spaces satisfy a stronger form of the triangle inequality than you are used to from ${\mathbb R}$.

Proposition 13 (${\left\lvert \bullet \right\rvert_p}$ is an ultrametric)

For any ${x,y \in \mathbb Z_p}$, we have the strong triangle inequality

$\displaystyle \left\lvert x+y \right\rvert_p \le \max \left\{ \left\lvert x \right\rvert_p, \left\lvert y \right\rvert_p \right\}.$

Equality holds if (but not only if) ${\left\lvert x \right\rvert_p \neq \left\lvert y \right\rvert_p}$.

However, ${\mathbb Q_p}$ is more than just a metric space: it is a field, with its own addition and multiplication. This means we can do analysis just like in ${\mathbb R}$ or ${\mathbb C}$: basically, any notion such as “continuous function”, “convergent series”, et cetera has a ${p}$-adic analog. In particular, we can define what it means for an infinite sum to converge:

Definition 14 (Convergence notions)

Here are some examples of ${p}$-adic analogs of “real-world” notions.

• A sequence ${s_1}$, \dots converges to a limit ${L}$ if ${\lim_{n \rightarrow \infty} \left\lvert s_n - L \right\rvert_p = 0}$.
• The infinite series ${\sum_k x_k}$ converges if the sequence of partial sums ${s_1 = x_1}$, ${s_2 = x_1 + x_2}$, \dots, converges to some limit.
• \dots et cetera \dots

With this definition in place, the “base ${p}$” discussion we had earlier is now true in the analytic sense: if ${x = \overline{\dots a_2 a_1 a_0}_p \in \mathbb Z_p}$ then

$\displaystyle \sum_{k=0}^\infty a_k p^k \quad\text{converges to } x.$

Indeed, the ${n}$th partial sum is divisible by ${p^n}$, hence the partial sums approach ${x}$ as ${n \rightarrow \infty}$.

While the definitions are all the same, there are some changes in properties that should be true. For example, in ${\mathbb Q_p}$ convergence of partial sums is simpler:

Proposition 15 (${|x_k|_p \rightarrow 0}$ iff convergence of series)

A series ${\sum_{k=1}^\infty x_k}$ in ${\mathbb Q_p}$ converges to some limit if and only if ${\lim_{k \rightarrow \infty} |x_k|_p = 0}$.

Contrast this with ${\sum \frac1n = \infty}$ in ${\mathbb R}$. You can think of this as a consequence of strong triangle inequality. Proof: By multiplying by a large enough power of ${p}$, we may assume ${x_k \in \mathbb Z_p}$. (This isn’t actually necessary, but makes the notation nicer.)

Observe that ${x_k \pmod p}$ must eventually stabilize, since for large enough ${n}$ we have ${\left\lvert x_n \right\rvert_p < 1 \iff \nu_p(x_n) \ge 1}$. So let ${a_1}$ be the eventual residue modulo ${p}$ of ${\sum_{k=0}^N x_k \pmod p}$ for large ${N}$. In the same way let ${a_2}$ be the eventual residue modulo ${p^2}$, and so on. Then one can check we approach the limit ${a = (a_1, a_2, \dots)}$. $\Box$

Here’s a couple exercises to get you used to thinking of ${\mathbb Z_p}$ and ${\mathbb Q_p}$ as metric spaces.

Exercise 16 (${\mathbb Z_p}$ is compact)

Show that ${\mathbb Q_p}$ is not compact, but ${\mathbb Z_p}$ is. (For the latter, I recommend using sequential continuity.)

Exercise 17 (Totally disconnected)

Show that both ${\mathbb Z_p}$ and ${\mathbb Q_p}$ are totally disconnected: there are no connected sets other than the empty set and singleton sets.

### 3.3. More fun with geometric series

While we’re at it, let’s finally state the ${p}$-adic analog of the geometric series formula.

Proposition 18 (Geometric series)

Let ${x \in \mathbb Z_p}$ with ${\left\lvert x \right\rvert_p < 1}$. Then

$\displaystyle \frac{1}{1-x} = 1 + x + x^2 + x^3 + \dots.$

Proof: Note that the partial sums satisfy ${1 + x + x^2 + \dots + x^n = \frac{1-x^n}{1-x}}$, and ${x^n \rightarrow 0}$ as ${n \rightarrow \infty}$ since ${\left\lvert x \right\rvert_p < 1}$. $\Box$

So, ${1 + 3 + 3^2 + \dots = -\frac{1}{2}}$ is really a correct convergence in ${\mathbb Z_3}$. And so on.

If you buy the analogy that ${\mathbb Z_p}$ is generating functions with base ${p}$, then all the olympiad generating functions you might be used to have ${p}$-adic analogs. For example, you can prove more generally that:

Theorem 19 (Generalized binomial theorem)

If ${x \in \mathbb Z_p}$ and ${\left\lvert x \right\rvert_p < 1}$, then for any ${r \in \mathbb Q}$ we have the series convergence

$\displaystyle \sum_{n \ge 0} \binom rn x^n = (1+x)^r.$

(I haven’t defined ${(1+x)^r}$, but it has the properties you expect.) The proof is as in the real case; even the theorem statement is the same except for the change for the extra subscript of ${p}$. I won’t elaborate too much on this now, since ${p}$-adic exponentiation will be described in much more detail in the next post.

### 3.4. Completeness

Note that the definition of ${\left\lvert \bullet \right\rvert_p}$ could have been given for ${\mathbb Q}$ as well; we didn’t need ${\mathbb Q_p}$ to introduce it (after all, we have ${\nu_p}$ in olympiads already). The big important theorem I must state now is:

Theorem 20 (${\mathbb Q_p}$ is complete)

The space ${\mathbb Q_p}$ is the completion of ${\mathbb Q}$ with respect to ${\left\lvert \bullet \right\rvert_p}$.

This is the definition of ${\mathbb Q_p}$ you’ll see more frequently; one then defines ${\mathbb Z_p}$ in terms of ${\mathbb Q_p}$ (rather than vice-versa) according to

$\displaystyle \mathbb Z_p = \left\{ x \in \mathbb Q_p : \left\lvert x \right\rvert_p \le 1 \right\}.$

(Remark for experts: ${\mathbb Q_p}$ is a field with ${\nu_p}$ a non-Arcihmedian valuation; then ${\mathbb Z_p}$ is its valuation ring.)

Let me justify why this definition is philosophically nice.

Suppose you are a numerical analyst and you want to estimate the value of the sum

$\displaystyle S = \frac{1}{1^2} + \frac{1}{2^2} + \dots + \frac{1}{10000^2}$

to within ${0.001}$. The sum ${S}$ consists entirely of rational numbers, so the problem statement would be fair game for ancient Greece. But it turns out that in order to get a good estimate, it really helps if you know about the real numbers: because then you can construct the infinite series ${\sum_{n \ge 1} n^{-2} = \frac16 \pi^2}$, and deduce that ${S \approx \frac{\pi^2}{6}}$, up to some small error term from the terms past ${\frac{1}{10001^2}}$, which can be bounded.

Of course, in order to have access to enough theory to prove that ${S = \pi^2/6}$, you need to have the real numbers; it’s impossible to do serious analysis in the non-complete space ${\mathbb Q}$, where e.g. the sequence ${1}$, ${1.4}$, ${1.41}$, ${1.414}$, \dots is considered “not convergent” because ${\sqrt2 \notin \mathbb Q}$. Instead, all analysis is done in the completion of ${\mathbb Q}$, namely ${\mathbb R}$.

Now suppose you are an olympiad contestant and want to estimate the sum

$\displaystyle f_p(x) = \sum_{k=1}^{p-1} \frac{1}{(px+k)^2}$

to within mod ${p^3}$ (i.e. to within ${p^{-3}}$ in ${\left\lvert \bullet \right\rvert_p}$). Even though ${f_p(x)}$ is a rational number, it still helps to be able to do analysis with infinite sums, and then bound the error term (i.e. take mod ${p^3}$). But the space ${\mathbb Q}$ is not complete with respect to ${\left\lvert \bullet \right\rvert_p}$ either, and thus it makes sense to work in the completion of ${\mathbb Q}$ with respect to ${\left\lvert \bullet \right\rvert_p}$. This is exactly ${\mathbb Q_p}$.

## 4. Solving USA TST 2002/2

Let’s finally solve Example~1, which asks to compute

$\displaystyle f_p(x) = \sum_{k=1}^{p-1} \frac{1}{(px+k)^2} \pmod{p^3}.$

Armed with the generalized binomial theorem, this becomes straightforward.

\displaystyle \begin{aligned} f_p(x) &= \sum_{k=1}^{p-1} \frac{1}{(px+k)^2} = \sum_{k=1}^{p-1} \frac{1}{k^2} \left( 1 + \frac{px}{k} \right)^{-2} \\ &= \sum_{k=1}^{p-1} \frac{1}{k^2} \sum_{n \ge 0} \binom{-2}{n} \left( \frac{px}{k} \right)^{n} \\ &= \sum_{n \ge 0} \binom{-2}{n} \sum_{k=1}^{p-1} \frac{1}{k^2} \left( \frac{x}{k} \right)^{n} p^n \\ &\equiv \sum_{k=1}^{p-1} \frac{1}{k^2} - 2x \left( \sum_{k=1}^{p-1} \frac{1}{k^3} \right) p + 3x^2 \left( \sum_{k=1}^{p-1} \frac{1}{k^4} \right) p^2 \pmod{p^3}. \end{aligned}

Using the elementary facts that ${p^2 \mid \sum_k k^{-3}}$ and ${p \mid \sum k^{-4}}$, this solves the problem.

# New oly handout: Constructing Diagrams

I’ve added a new Euclidean geometry handout, Constructing Diagrams, to my webpage.

Some of the stuff covered in this handout:

• Advice for constructing the triangle centers (hint: circumcenter goes first)
• An example of how to rearrange the conditions of a problem and draw a diagram out-of-order
• Some mechanical suggestions such as dealing with phantom points
• Some examples of computer-generated figures

Enjoy.

# Revisiting arc midpoints in complex numbers

## 1. Synopsis

One of the major headaches of using complex numbers in olympiad geometry problems is dealing with square roots. In particular, it is nontrivial to express the incenter of a triangle inscribed in the unit circle in terms of its vertices.

The following lemma is the standard way to set up the arc midpoints of a triangle. It appears for example as part (a) of Lemma 6.23.

Theorem 1 (Arc midpoint setup for a triangle)

Let ${ABC}$ be a triangle with circumcircle ${\Gamma}$ and let ${M_A}$, ${M_B}$, ${M_C}$ denote the arc midpoints of ${\widehat{BC}}$ opposite ${A}$, ${\widehat{CA}}$ opposite ${B}$, ${\widehat{AB}}$ opposite ${C}$.

Suppose we view ${\Gamma}$ as the unit circle in the complex plane. Then there exist complex numbers ${x}$, ${y}$, ${z}$ such that ${A = x^2}$, ${B = y^2}$, ${C = z^2}$, and

$\displaystyle M_A = -yz, \quad M_B = -zx, \quad M_C = -xy.$

Theorem 1 is often used in combination with the following lemma, which lets one assign the incenter the coordinates ${-(xy+yz+zx)}$ in the above notation.

Lemma 2 (The incenter is the orthocenter of opposite arc midpoints)

Let ${ABC}$ be a triangle with circumcircle ${\Gamma}$ and let ${M_A}$, ${M_B}$, ${M_C}$ denote the arc midpoints of ${\widehat{BC}}$ opposite ${A}$, ${\widehat{CA}}$ opposite ${B}$, ${\widehat{AB}}$ opposite ${C}$. Then the incenter of ${\triangle ABC}$ coincides with the orthocenter of ${\triangle M_A M_B M_C}$.

Unfortunately, the proof of Theorem 1 in my textbook is wrong, and I cannot find a proof online (though I hear that Lemmas in Olympiad Geometry has a proof). So in this post I will give a correct proof of Theorem 1, which will hopefully also explain the mysterious introduction of the minus signs in the theorem statement. In addition I will give a version of the theorem valid for quadrilaterals.

## 2. A Word of Warning

I should at once warn the reader that Theorem 1 is an existence result, and thus must be applied carefully.

To see why this matters, consider the following problem, which appeared as problem 1 of the 2016 JMO.

Example 3 (JMO 2016, by Zuming feng)

The isosceles triangle ${\triangle ABC}$, with ${AB=AC}$, is inscribed in the circle ${\omega}$. Let ${P}$ be a variable point on the arc ${BC}$ that does not contain ${A}$, and let ${I_B}$ and ${I_C}$ denote the incenters of triangles ${\triangle ABP}$ and ${\triangle ACP}$, respectively. Prove that as ${P}$ varies, the circumcircle of triangle ${\triangle PI_{B}I_{C}}$ passes through a fixed point.

By experimenting with the diagram, it is not hard to guess that the correct fixed point is the midpoint of arc ${\widehat{BC}}$, as seen in the figure below. One might be tempted to write ${A = x^2}$, ${B = y^2}$, ${C = z^2}$, ${P = t^2}$ and assert the two incenters are ${-(xy+yt+xt)}$ and ${-(xz+zt+xt)}$, and that the fixed point is ${-yz}$.

This is a mistake! If one applies Theorem 1 twice, then the choices of “square roots” of the common vertices ${A}$ and ${P}$ may not be compatible. In fact, they cannot be compatible, because the arc midpoint of ${\widehat{AP}}$ opposite ${B}$ is different from the arc midpoint of ${\widehat{AP}}$ opposite ${C}$.

In fact, I claim this is not a minor issue that one can work around. This is because the claim that the circumcircle of ${\triangle P I_B I_C}$ passes through the midpoint of arc ${\widehat{BC}}$ is false if ${P}$ lies on the arc on the same side as ${A}$! In that case it actually passes through ${A}$ instead. Thus the truth of the problem really depends on the fact that the quadrilateral ${ABPC}$ is convex, and any attempt with complex numbers must take this into account to have a chance of working.

## 3. Proof of the theorem for triangles

Fix ${ABC}$ now, so we require ${A = x^2}$, ${B = y^2}$, ${C = z^2}$. There are ${2^3 = 8}$ choices of square roots ${x}$, ${y}$, ${z}$ we can take (differing by a sign); we wish to show one of them works.

We pick an arbitrary choice for ${x}$ first. Then, of the two choices of ${y}$, we pick the one such that ${-xy = M_C}$. Similarly, for the two choices of ${z}$, we pick the one such that ${-xz = M_B}$. Our goal is to show that under these conditions, we have ${M_A = -yz}$ again.

The main trick is to now consider the arc midpoint ${\widehat{BAC}}$, which we denote by ${L}$. It is easy to see that:

Lemma 4 (The isosceles trapezoid trick)

We have ${\overline{AL} \parallel \overline{M_B M_C}}$ (both are perpendicular to the ${\angle A}$ bisector). Thus ${A L M_B M_C}$ is an isosceles trapezoid, and so ${ A \cdot L = M_B \cdot M_C }$.

Thus, we have

$\displaystyle L = \frac{M_B M_C}{A} = \frac{(-xz)(-xy)}{x^2} = +yz.$

Thus

$\displaystyle M_A = -L = -yz$

as desired.

From this we can see why the minus signs are necessary.

Exercise 5

Show that Theorem 1 becomes false if we try to use ${+yz}$, ${+zx}$, ${+xy}$ instead of ${-yz}$, ${-zx}$, ${-xy}$.

## 4. A version for quadrilaterals

We now return to the setting of a convex quadrilateral ${ABPC}$ that we encountered in Example 3. Suppose we preserve the variables ${x}$, ${y}$, ${z}$ that we were given from Theorem 1, but now add a fourth complex number ${t}$ with ${P = t^2}$. How are the new arc midpoints determined? The following theorem answers this question.

Theorem 6 (${xytz}$ setup)

Let ${ABPC}$ be a convex quadrilateral inscribed in the unit circle of the complex plane. Then we can choose complex numbers ${x}$, ${y}$, ${z}$, ${t}$ such that ${A = x^2}$, ${B = y^2}$, ${C = z^2}$, ${P = t^2}$ and:

• The opposite arc midpoints ${M_A}$, ${M_B}$, ${M_C}$ of triangle ${ABC}$ are given by ${-yz}$, ${-zx}$, ${-xy}$, as before.
• The midpoint of arc ${\widehat{BP}}$ not including ${A}$ or ${C}$ is given by ${+yt}$.
• The midpoint of arc ${\widehat{CP}}$ not including ${A}$ or ${B}$ is given by ${-zt}$.
• The midpoint of arc ${\widehat{ABP}}$ is ${-xt}$ and the midpoint of arc ${\widehat{ACP}}$ is ${+xt}$.

This setup is summarized in the following figure.

Note that unlike Theorem 1, the four arcs cut out by the sides of ${ABCP}$ do not all have the same sign (I chose ${\widehat{BP}}$ to have coordinates ${+yt}$). This asymmetry is inevitable (see if you can understand why from the proof below).

Proof: We select ${x}$, ${y}$, ${z}$ with Theorem 1. Now, pick a choice of ${t}$ such that ${+yt}$ is the arc midpoint of ${\widehat{BP}}$ not containing ${A}$ and ${C}$. Then the arc midpoint of ${\widehat{CP}}$ not containing ${A}$ or ${B}$ is given by

$\displaystyle \frac{z^2}{-yz} \cdot (+yt) = -zt.$

On the other hand, the calculation of ${-xt}$ for the midpoint of ${\widehat{ABP}}$ follows by applying Lemma 4 again. (applied to triangle ${ABP}$). The midpoint of ${\widehat{ACP}}$ is computed similarly. $\Box$

In other problems, the four vertices of the quadrilateral may play more symmetric roles and in that case it may be desirable to pick a setup in which the four vertices are labeled ${ABCD}$ in order. By relabeling the letters in Theorem 6 one can prove the following alternate formulation.

Corollary 7

Let ${ABCD}$ be a convex quadrilateral inscribed in the unit circle of the complex plane. Then we can choose complex numbers ${a}$, ${b}$, ${c}$, ${d}$ such that ${A = a^2}$, ${B = b^2}$, ${C = c^2}$, ${D = d^2}$ and:

• The midpoints of ${\widehat{AB}}$, ${\widehat{BC}}$, ${\widehat{CD}}$, ${\widehat{DA}}$ cut out by the sides of ${ABCD}$ are ${-ab}$, ${-bc}$, ${-cd}$, ${+da}$.
• The midpoints of ${\widehat{ABC}}$ and ${\widehat{BCD}}$ are ${+ac}$ and ${+bd}$.
• The midpoints of ${\widehat{CDA}}$ and ${\widehat{DAB}}$ are ${-ac}$ and ${-bd}$.

To test the newfound theorem, here is a cute easy application.

Example 8 (Japanese theorem for cyclic quadrilaterals)

In a cyclic quadrilateral ${ABCD}$, the incenters of ${\triangle ABC}$, ${\triangle BCD}$, ${\triangle CDA}$, ${\triangle DAB}$ are the vertices of a rectangle.

In a previous post I tried to make the point that math olympiads should not be judged by their relevance to research mathematics. In doing so I failed to actually explain why I think math olympiads are a valuable experience for high schoolers, so I want to make amends here.

## 1. Summary

In high school I used to think that math contests were primarily meant to encourage contestants to study some math that is (much) more interesting than what’s typically shown in high school. While I still think this is one goal, and maybe it still is the primary goal in some people’s minds, I no longer believe this is the primary benefit.

My current belief is that there are two major benefits from math competitions:

1. To build a social network for gifted high school students with similar interests.
2. To provide a challenging experience that lets gifted students grow and develop intellectually.

I should at once disclaim that I do not claim these are the only purpose of mathematical olympiads. Indeed, mathematics is a beautiful subject and introducing competitors to this field of study is of course a great thing (in particular it was life-changing for me). But as I have said before, many alumni of math olympiads do not eventually become mathematicians, and so in my mind I would like to make the case that these alumni have gained a lot from the experience anyways.

## 2. Social experience

Now that we have email, Facebook, Art of Problem Solving, and whatnot, the math contest community is much larger and stronger than it’s ever been in the past. For the first time, it’s really possible to stay connected with other competitors throughout the entire year, rather than just seeing each other a handful of times during contest season. There’s literally group chats of contestants all over the country where people talk about math problems or the solar eclipse or share funny pictures or inside jokes or everything else. In many ways, being part of the high school math contest community is a lot like having access to the peer group at a top-tier university, except four years earlier.

There’s some concern that a competitive culture is unhealthy for the contestants. I want to make a brief defense here.

I really do think that the contest community is good at being collaborative rather than competitive. You can imagine a world where the competitors think about contests in terms of trying to get a better score than the other person. [1] That would not be a good world. But I think by and large the community is good at thinking about it as just trying to maximize their own score. The score of the person next to you isn’t supposed to matter (and thinking about it doesn’t help, anyways).

Put more bluntly, on contest day, you have one job: get full marks. [2]

Because we have a culture of this shape, we now get a group of talented students all working towards the same thing, rather than against one another. That’s what makes it possible to have a self-supportive community, and what makes it possible for the contestants to really become friends with each other.

I think the strongest contestants don’t even care about the results of contests other than the few really important ones (like USAMO/IMO). It is a long-running joke that the Harvard-MIT Math Tournament is secretly just a MOP reunion, and I personally see to it that this happens every year. [3]

I’ve also heard similar sentiments about ARML:

I enjoy ARML primarily based on the social part of the contest, and many people agree with me; the highlight of ARML for some people is the long bus ride to the contest. Indeed, I think of ARML primarily as a social event, with some mathematics to make it look like the participants are actually doing something important.

(Don’t tell the parents.)

## 3. Intellectual growth

My view is that if you spend a lot of time thinking or working about anything deep, then you will learn and grow from the experience, almost regardless of what that thing is at an object level. Take chess as an example — even though chess definitely has even fewer “real-life applications” than math, if you take anyone with a 2000+ rating I don’t think many of them would think that the time they invested into the game was wasted. [4]

Olympiad mathematics seems to be no exception to this. In fact the sheer depth and difficulty of the subject probably makes it a particularly good example. [5]

I’m now going to fill this section with a bunch of examples although I don’t claim the list is exhaustive. First, here are the ones that everyone talks about and more or less agrees on:

• Learning how to think, because, well, that’s how you solve a contest problem.
• Learning to work hard and not give up, because the contest is difficult and you will not win by accident; you need to actually go through a lot of training.
• Dual to above, learning to give up on a problem, because sometime the problem really is too hard for you and you won’t solve it even if you spend another ten or twenty or fifty hours, and you have to learn to cut your losses. There is a balancing act here that I think really is best taught by experience, rather than the standard high-school moral cheerleading where you are supposed to “never give up” or something.
• But also learning to be humble or to ask for help, which is a really hard thing for a lot of young contestants to do.
• Learning to be patient, not only with solving problems but with the entire journey. You usually do not improve dramatically overnight.

Here are some others I also believe, but don’t hear as often.

• Learning to be independent, because odds are your high-school math teacher won’t be able to help you with USAMO problems. Training for the highest level of contests is these days almost always done more or less independently. I think having the self-motivation to do the training yourself, as well as the capacity to essentially have to design your own training (making judgments on what to work on, et cetera) is itself a valuable cross-domain skill. (I’m a little sad sometimes that by teaching I deprive my students of the opportunity to practice this. It is a cost.)
• Being able to work neatly, not because your parents told you to but because if you are sloppy then it will cost you points when you make small (or large) errors on IMO #1. Olympiad problems are difficult enough as is, and you do not want to let them become any harder because of your own sloppiness. (And there are definitely examples of olympiad problems which are impossible to solve if you are not organized.)
• Being able to organize and write your thoughts well, because some olympiad problems are complex and requires putting together more than one lemma or idea together to solve. For this to work, you need to have the skill of putting together a lot of moving parts into a single coherent argument. Bonus points here if your audience is someone you care about (as opposed to a grader), because then you have to also worry about making the presentation as clean and natural as possible.

These days, whenever I solve a problem I always take the time to write it up cleanly, because in the process of doing so I nearly always find ways that the solution can be made shorter or more elegant, or at least philosophically more natural. (I also often find my solution is wrong.) So it seems that the write-up process here is not merely about presenting the same math in different ways: the underlying math really does change. [6]

• Thinking about how to learn. For example, the Art of Problem Solving forums are often filled with questions of the form “what should I do?”. Many older users find these questions obnoxious, but I find them desirable. I think being able to spend time pondering about what makes people improve or learn well is a good trait to develop, rather than mindlessly doing one book after another.

Of course, many of the questions I referred to are poor, either with no real specific direction: often the questions are essentially “what book should I read?”, or “give me a exhaustive list of everything I should know”. But I think this is inevitable because these are people’s first attempts at understanding contest training. Just like the first difficult math contest you take often goes quite badly, the first time you try to think about learning, you will probably ask questions you will be embarrassed about in five years. My hope is that as these younger users get older and wiser, the questions and thoughts become mature as well. To this end I do not mind seeing people wobble on their first steps.

• Being honest with your own understanding, particularly of fundamentals. When watching experienced contestants, you often see people solving problems using advanced techniques like Brianchon’s theorem or the n-1 equal value principle or whatever. It’s tempting to think that if you learn the names and statements of all these advanced techniques then you’ll be able to apply them too. But the reality is that these techniques are advanced for a reason: they are hard to use without mastery of fundamentals.

This is something I definitely struggled with as a contestant: being forced to patiently learn all the fundamentals and not worry about the fancy stuff. To give an example, the 2011 JMO featured an inequality which was routine for experienced or well-trained contestants, but “almost impossible for people who either have not seen inequalities at all or just like to compile famous names in their proofs”. I was in the latter category, and tried to make up a solution using multivariable Jensen, whatever that meant. Only when I was older did I really understand what I was missing.

• Dual to the above, once you begin to master something completely you start to learn what different depths of understanding feel like, and an appreciation for just how much effort goes into developing a mastery of something.
• Being able to think about things which are not well-defined. This one often comes as a surprise to people, since math is a field which is known for its precision. But I still maintain that this a skill contests train for.

A very simple example is a question like, “when should I use the probabilistic method?”. Yes, we know it’s good for existence questions, but can we say anything more about when we expect it to work? Well, one heuristic (not the only one) is “if a monkey could find it” — the idea that a randomly selected object “should” work. But obviously something like this can’t be subject to a (useful) formal definition that works 100% of the time, and there are plenty of contexts in which even informally this heuristic gives the wrong answer. So that’s an example of a vague and nebulous concept that’s nonetheless necessary in order to understanding the probabilistic method well.

There are much more general examples one can say. What does it mean for a problem to “feel projective”? I can’t tell you a hard set of rules; you’ll have to do a bunch of examples and gain the intuition yourself. Why do I say this problem is “rigid”? Same answer. How do you tell which parts of this problem are natural, and which are artificial? How do you react if you have the feeling the problem gives you nothing to work with? How can you tell if you are making progress on a problem? Trying to figure out partial answers to these questions, even if they can’t be put in words, will go a long way in improving the mythical intuition that everyone knows is so important.

It might not be unreasonable to say that by this point we are studying philosophy, and that’s exactly what I intend. When I teach now I often make a point of referring to the “morally correct” way of thinking about things, or making a point of explaining why X should be true, rather than just providing a proof. I find this type of philosophy interesting in its own right, but that is not the main reason I incorporate it into my teaching. I teach the philosophy now because it is necessary, because you will solve fewer problems without that understanding.

## 4. I think if you don’t do well, it’s better to you

But I think the most surprising benefit of math contests is that most participants won’t win. In high school everyone tells you that if you work hard you will succeed. The USAMO is a fantastic counterexample to this. Every year, there are exactly 12 winners on the USAMO. I can promise you there are far more than 12 people who work very hard every year with the hope of doing well on the USAMO. Some people think this is discouraging, but I find it desirable.

Let me tell you a story.

Back in September of 2015, I sneaked in to the parent’s talk at Math Prize for Girls, because Zuming Feng was speaking and I wanted to hear what he had to say. (The whole talk was is available on YouTube now.) The talk had a lot of different parts that I liked, but one of them struck me in particular, when he recounted something he said to one of his top students:

I really want you to work hard, but I really think if you don’t do well, if you fail, it’s better to you.

I had a hard time relating to this when I first heard it, but it makes sense if you think about it. What I’ve tried to argue is that the benefit of math contests is not that the contestant can now solve N problems on USAMO in late April, but what you gain from the entire year of practice. And so if you hold the other 363 days fixed, and then vary only the final outcome of the USAMO, which of success and failure is going to help a contestant develop more as a person?

For that reason I really like to think that the final lesson from high school olympiads is how to appreciate the entire journey, even in spite of the eventual outcome.

### Footnotes

1. I actually think this is one of the good arguments in favor of the new JMO/USAMO system introduced in 2010. Before this, it was not uncommon for participants in 9th and 10th grade to really only aim for solving one or two entry-level USAMO problems to qualify for MOP. To this end I think the mentality of “the cutoff will probably only be X, so give up on solving problem six” is sub-optimal.
2. That’s a Zuming quote.
3. Which is why I think the HMIC is actually sort of pointless from a contestant’s perspective, but it’s good logistics training for the tournament directors.
4. I could be wrong about people thinking chess is a good experience, given that I don’t actually have any serious chess experience beyond knowing how the pieces move. A cursory scan of the Internet suggests otherwise (was surprised to find that Ben Franklin has an opinion on this) but it’s possible there are people who think chess is a waste of time, and are merely not as vocal as the people who think math contests are a waste of time.
5. Relative to what many high school students work on, not compared to research or something.
6. Privately, I think that working in math olympiads taught me way more about writing well than English class ever did; English class always felt to me like the skill of trying to sound like I was saying something substantial, even when I wasn’t.

# A story of block-ascending permutations

I recently had a combinatorics paper appear in the EJC. In this post I want to brag a bit by telling the “story” of this paper: what motivated it, how I found the conjecture that I originally did, and the process that eventually led me to the proof, and so on.

This work was part of the Duluth REU 2017, and I thank Joe Gallian for suggesting the problem.

## 1. Background

Let me begin by formulating the problem as it was given to me. First, here is the definition and notation for a “block-ascending” permutation.

Definition 1

For nonnegative integers ${a_1}$, …, ${a_n}$ an ${(a_1, \dots, a_n)}$-ascending permutation is a permutation on ${\{1, 2, \dots, a_1 + \dots + a_n\}}$ whose descent set is contained in ${\{a_1, a_1+a_2, \dots, a_1+\dots+a_{n-1}\}}$. In other words the permutation ascends in blocks of length ${a_1}$, ${a_2}$, …, ${a_n}$, and thus has the form

$\displaystyle \pi = \pi_{11} \dots \pi_{1a_1} | \pi_{21} \dots \pi_{2a_2} | \dots | \pi_{n1} \dots \pi_{na_n}$

for which ${\pi_{i1} < \pi_{i2} < \dots < \pi_{ia_i}}$ for all ${i}$.

It turns out that block-ascending permutations which also avoid an increasing subsequence of certain length have nice enumerative properties. To this end, we define the following notation.

Definition 2

Let ${\mathcal L_{k+2}(a_1, \dots, a_n)}$ denote the set of ${(a_1, \dots, a_n)}$-ascending permutations which avoid the pattern ${12 \dots (k+2)}$.

(The reason for using ${k+2}$ will be explained later.) In particular, ${\mathcal L_{k+2}(a_1 ,\dots, a_n) = \varnothing}$ if ${\max \{a_1, \dots, a_n\} \ge k+2}$.

Example 3

Here is a picture of a permutation in ${\mathcal L_7(3,2,4)}$ (but not in ${\mathcal L_6(3,2,4)}$, since one can see an increasing length ${6}$ subsequence shaded). We would denote it ${134|69|2578}$.

Now on to the results. A 2011 paper by Joel Brewster Lewis (JBL) proved (among other things) the following result:

Theorem 4 (Lewis 2011)

The sets ${\mathcal L_{k+2}(k,k,\dots,k)}$ and ${\mathcal L_{k+2}(k+1,k+1,\dots,k+1)}$ are in bijection with Young tableau of shape ${\left< (k+1)^n \right>}$.

Remark 5

When ${k=1}$, this implies ${\mathcal L_3(1,1,\dots,1)}$, which is the set of ${123}$-avoiding permutations of length ${n}$, is in bijection with the Catalan numbers; so is ${\mathcal L_3(2,\dots,2)}$ which is the set of ${123}$-avoiding zig-zag permutations.

Just before the Duluth REU in 2017, Mei and Wang proved that in fact, in Lewis’ result one may freely mix ${k}$ and ${k+1}$‘s. To simplify notation,

Definition 6

Let ${I \subseteq \left\{ 1,\dots,n \right\}}$. Then ${\mathcal L(n,k,I)}$ denotes ${\mathcal L_{k+2}(a_1,\dots,a_n)}$ where

$\displaystyle a_i = \begin{cases} k+1 & i \in I \\ k & i \notin I. \end{cases}$

Theorem 7 (Mei, Wang 2017)

The ${2^n}$ sets ${\mathcal L(n,k,I)}$ are also in bijection with Young tableau of shape ${\left< (k+1)^n \right>}$.

The proof uses the RSK correspondence, but the authors posed at the end of the paper the following open problem:

Problem

Find a direct bijection between the ${2^n}$ sets ${\mathcal L(n,k,I)}$ above, not involving the RSK correspondence.

This was the first problem that I was asked to work on. (I remember I received the problem on Sunday morning; this actually matters a bit for the narrative later.)

At this point I should pause to mention that this ${\mathcal L_{k+2}(\dots)}$ notation is my own invention, and did not exist when I originally started working on the problem. Indeed, all the results are restricted to the case where ${a_i \in \{k,k+1\}}$ for each ${i}$, and so it was unnecessary to think about other possibilities for ${a_i}$: Mei and Wang’s paper use the notation ${\mathcal L(n,k,I)}$. So while I’ll continue to use the ${\mathcal L_{k+2}(\dots)}$ notation in the blog post for readability, it will make some of the steps more obvious than they actually were.

## 2. Setting out

Mei and Wang’s paper originally suggested that rather than finding a bijection ${\mathcal L(n,k,I) \rightarrow \mathcal L(n,k,J)}$ for any ${I}$ and ${J}$, it would suffice to biject

$\displaystyle \mathcal L(n,k,I) \rightarrow \mathcal L(n,k,\varnothing)$

and then compose two such bijections. I didn’t see why this should be much easier, but it didn’t seem to hurt either.

As an example, they show how to do this bijection with ${I = \{1\}}$ and ${I = \{n\}}$. Indeed, suppose ${I = \{1\}}$. Then ${\pi_{11} < \pi_{12} < \dots < \pi_{1(k+1)}}$ is an increasing sequence of length ${k+1}$ right at the start of ${\pi}$. So ${\pi_{1(k+1)}}$ had better be the largest element in the permutation: otherwise later in ${\pi}$ the biggest element would complete an ascending permutation of length ${k+2}$ already! So removing ${\pi_{1(k+1)}}$ gives a bijection between ${\mathcal L(n,k,\{1\}) \rightarrow \mathcal L(n,k,\varnothing)}$.

But if you look carefully, this proof does essentially nothing with the later blocks. The exact same proof gives:

Proposition 8

Suppose ${1 \notin I}$. Then there is a bijection

$\displaystyle \mathcal L(n,k,I \cup \{1\}) \rightarrow \mathcal L(n,k,I)$

by deleting the ${(k+1)}$st element of the permutation (which must be largest one).

Once I found this proposition I rejected the initial suggestion of specializing ${\mathcal L(n,k,I) \rightarrow \mathcal L(n,k,\varnothing)}$. The “easy case” I had found told me that I could take a set ${I}$ and delete the single element ${1}$ from it. So empirically, my intuition from this toy example told me that it would be easier to find bijections ${\mathcal L(n,k,I) \rightarrow \mathcal L(n,k,I')}$ whee ${I'}$ and ${I}$ were only “a little different”, and hope that the resulting bijection only changed things a little bit (in the same way that in the toy example, all the bijection did was delete one element). So I shifted to trying to find small changes of this form.

## 3. The fork in the road

### 3.1. Wishful thinking

I had a lucky break of wishful thinking here. In the notation ${\mathcal L_{k+2}(a_1, \dots, a_n)}$ with ${a_i \in \{k,k+1\}}$, I had found that one could replace ${a_1}$ with either ${k}$ or ${k+1}$ freely. (But this proof relied heavily on the fact the block really being on the far left.) So what other changes might I be able to make?

There were two immediate possibilities that came to my mind.

• Deletion: We already showed ${a_1}$ could be changed from ${k+1}$ to ${k}$ for any ${i}$. If we can do a similar deletion with ${a_i}$ for any ${i}$, not just ${i=1}$, then we would be done.
• Swapping: If we can show that two adjacent ${a_i}$‘s could be swapped, that would be sufficient as well. (It’s also possible to swap non-adjacent ${a_i}$‘s, but that would cause more disruption for no extra benefit.)

Now, I had two paths that both seemed plausible to chase after. How was I supposed to know which one to pick? (Of course, it’s possible neither work, but you have to start somewhere.)

Well, maybe the correct thing to do would have to just try both. But it was Sunday afternoon by the time I got to this point. Granted, it was summer already, but I knew that come Monday I would have doctor appointments and other trivial errands to distract me, so I decided I should pick one of them and throw the rest of the day into it. But that meant I had to pick one.

(I confess that I actually already had a prior guess: the deletion approach seemed less likely to work than the swapping approach. In the deletion approach, if ${i}$ is somewhere in the middle of the permutation, it seemed like deleting an element could cause a lot of disruption. But the swapping approach preserved the total number of elements involved, and so seemed more likely that I could preserve structure. But really I was just grasping at straws.)

### 3.2. Enter C++

Yeah, I cheated. Sorry.

Those of you that know anything about my style of math know that I am an algebraist by nature — sort of. It’s more accurate to say that I depend on having concrete examples to function. True, I can’t do complexity theory for my life, but I also haven’t been able to get the hang of algebraic geometry, despite having tried to learn it three or four times by now. But enumerative combinatorics? OH LOOK EXAMPLES.

Here’s the plan: let ${k=3}$. Then using a C++ computer program:

• Enumerate all the permutations in ${S = \mathcal L_{k+2}(3,4,3,4)}$.
• Enumerate all the permutations in ${A = \mathcal L_{k+2}(3,3,3,4)}$.
• Enumerate all the permutations in ${B = \mathcal L_{k+2}(3,3,4,4)}$.

If the deletion approach is right, then I would hope ${S}$ and ${A}$ look pretty similar. On the flip side, if the swapping approach is right, then ${S}$ and ${B}$ should look close to each other instead.

It’s moments like this where my style of math really shines. I don’t have to make decisions like the above off gut-feeling: do the “data science” instead.

### 3.3. A twist of fate

Except this isn’t actually what I did, since there was one problem. Computing the longest increasing subsequence of a length ${N}$ permutation takes ${O(N \log N)}$ time, and there are ${N!}$ or so permutations. But when ${N = 3+4+3+4=14}$, we have ${N! \cdot N \log N \approx 3 \cdot 10^{12}}$, which is a pretty big number. Unfortunately, my computer is not really that fast, and I didn’t really have the patience to implement the “correct” algorithms to bring the runtime down.

The solution? Use ${N = 1+4+3+2 = 10}$ instead.

In a deep irony that I didn’t realize at the time, it was this moment when I introduced the ${\mathcal L_{k+2}(a_1, \dots, a_n)}$ notation, and for the first time allowed the ${a_i}$ to not be in ${\{k,k+1\}}$. My reasoning was that since I was only doing this for heuristic reasons, I could instead work with ${S = \mathcal L_{k+2}(2,4,3,2)}$ and probably not change much about the structure of the problem, while replacing ${N = 2 + 4 + 3 + 2 = 11}$, which would run ${1000}$ times faster. This was okay since all I wanted to do was see how much changing the “middle” would disrupt the structure.

And so the new plan was:

• Enumerate all the permutations in ${S = \mathcal L_{k+2}(1,4,3,2)}$.
• Enumerate all the permutations in ${A = \mathcal L_{k+2}(1,3,3,2)}$.
• Enumerate all the permutations in ${B = \mathcal L_{k+2}(1,3,4,2)}$.

I admit I never actually ran the enumeration with ${A}$, because the route with ${S}$ and ${B}$ turned out to be even more promising than I expected. When I compared the empirical data for the sets ${S}$ and ${B}$, I found that the number of permutations with any particular triple ${(\pi_1, \pi_9, \pi_{10})}$ were equal. In other words, the outer blocks were preserved: the bijection

$\displaystyle \mathcal L_{k+2}(1,4,3,2) \rightarrow \mathcal L_{k+2}(1,3,4,2)$

does not tamper with the outside blocks of length ${1}$ and ${2}$.

This meant I was ready to make the following conjecture. Suppose ${a_i = k}$, ${a_{i+1} = k+1}$. There is a bijection

$\displaystyle \mathcal L_{k+2}(a_1, \dots, a_i, a_{i+1}, \dots, a_n) \rightarrow \mathcal L_{k+2}(a_1, \dots, a_{i+1}, a_{i}, \dots, a_n)$

which only involves rearranging the elements of the ${i}$th and ${(i+1)}$st blocks.

## 4. Rooting out the bijection

At this point I was in a quite good position. I had pinned down the problem to a finding a particular bijection that I was confident had to exist, since it was showing up to the empirical detail.

Let’s call this mythical bijection ${\mathbf W}$. How could I figure out what it was?

### 4.1. Hunch: ${\mathbf W}$ preserves order-isomorphism

Let me quickly introduce a definition.

Definition 9

We say two words ${a_1 \dots a_m}$ and ${b_1 \dots b_m}$ are order-isomorphic if ${a_i < a_j}$ if and only ${b_i < b_j}$. Then order-isomorphism gives equivalence classes, and there is a canonical representative where the letters are ${\{1,2,\dots,m\}}$; this is called a reduced word.

Example 10

The words ${13957}$, ${12846}$ and ${12534}$ are order-isomorphic; the last is reduced.

Now I guessed one more property of ${\mathbf W}$: this ${\mathbf W}$ should order-isomorphism.

What do I mean by this? Suppose in one context ${139 | 57}$ changed to ${39 | 157}$; then we would expect that in another situation we should have ${124 | 68}$ changing to ${24 | 168}$. Indeed, we expect ${\mathbf W}$ (empirically) to not touch surrounding outside blocks, and so it would be very strange if ${\mathbf W}$ behaved differently due to far-away numbers it wasn’t even touching.

So actually I’ll just write

$\displaystyle \mathbf W(123|45) = 23|145$

for this example, reducing the words in question.

### 4.2. Keep cheating

With this hunch it’s possible to cheat with C++ again. Here’s how.

Let’s for concreteness suppose ${k=2}$ and the particular sets

$\displaystyle \mathcal L_{k+2}(1,3,2,1) \rightarrow \mathcal L_{k+2}(1,2,3,1).$

Well, it turns out if you look at the data:

• The only element of ${\mathcal L_{k+2}(1,3,2,1)}$ which starts with ${2}$ and ends with ${5}$ is ${2|147|36|5}$.
• The only element of ${\mathcal L_{k+2}(1,2,3,1)}$ which starts with ${2}$ and ends with ${5}$ is ${2|47|136|5}$.

So that means that ${147 | 36}$ is changed to ${47 | 136}$. Thus the empirical data shows that

$\displaystyle \mathbf W(135|24) = 35|124.$

In general, it might not be that clear cut. For example, if we look at the permutations starting with ${2}$ and ${4}$, there is more than one.

• ${2 | 1 5 7 | 3 6 | 4}$ and ${2 | 1 6 7 | 3 5 | 4}$ are both in ${\mathcal L_{k+2}(1,3,2,1)}$.
• ${2 | 5 7 | 1 3 6 | 4}$ and ${2 | 6 7 | 1 3 5 | 4}$ are both in in ${\mathcal L_{k+2}(1,2,3,1)}$.

Thus

$\displaystyle \mathbf W( \{135|24, 145|23\} ) = \{35|124, 45|123\}$

but we can’t tell which one goes to which (although you might be able to guess).

Fortunately, there is lots of data. This example narrowed ${135|24}$ down to two values, but if you look at other places you might have different data on ${135|24}$. Since we think ${\mathbf W}$ is behaving the same “globally”, we can piece together different pieces of data to get narrower sets. Even better, ${\mathbf W}$ is a bijection, so once we match either of ${135|24}$ or ${145|23}$, we’ve matched the other.

You know what this sounds like? Perfect matchings.

So here’s the experimental procedure.

• Enumerate all permutations in ${\mathcal L_{k+2}(2,3,4,2)}$ and ${\mathcal L_{k+2}(2,4,3,2)}$.
• Take each possible tuple ${(\pi_1, \pi_2, \pi_{10}, \pi_{11})}$, and look at the permutations that start and end with those particular four elements. Record the reductions of ${\pi_3\pi_4\pi_5|\pi_6\pi_7\pi_8\pi_9}$ and ${\pi_3\pi_4\pi_5\pi_6|\pi_7\pi_8\pi_9}$ for all these permutations. We call these input words and output words, respectively. Each output word is a “candidate” of ${\mathbf W}$ for a input word.
• For each input word ${a_1a_2a_3|b_1b_2b_3b_4}$ that appeared, take the intersection of all output words that appeared. This gives a bipartite graph ${G}$, with input words being matched to their candidates.
• Find perfect matchings of the graph.

And with any luck that would tell us what ${\mathbf W}$ is.

### 4.3. Results

Luckily, the bipartite graph is quite sparse, and there was only one perfect matching.

246|1357 => 2467|135
247|1356 => 2457|136
256|1347 => 2567|134
257|1346 => 2357|146
267|1345 => 2367|145
346|1257 => 3467|125
347|1256 => 3457|126
356|1247 => 3567|124
357|1246 => 1357|246
367|1245 => 1367|245
456|1237 => 4567|123
457|1236 => 1457|236
467|1235 => 1467|235
567|1234 => 1567|234


If you look at the data, well, there are some clear patterns. Exactly one number is “moving” over from the right half, each time. Also, if ${7}$ is on the right half, then it always moves over.

Anyways, if you stare at this for an hour, you can actually figure out the exact rule:

Claim 11

Given an input ${a_1a_2a_3|b_1b_2b_3b_4}$, move ${b_{i+1}}$ if ${i}$ is the largest index for which ${a_i < b_{i+1}}$, or ${b_1 = 1}$ if no such index exists.

And indeed, once I have this bijection, it takes maybe only another hour of thinking to verify that this bijection works as advertised, thus solving the original problem.

Rather than writing up what I had found, I celebrated that Sunday evening by playing Wesnoth for 2.5 hours.

## 5. Generalization

### 5.1. Surprise

On Monday morning I was mindlessly feeding inputs to the program I had worked on earlier and finally noticed that in fact ${\mathcal L_6(1,3,5,2)}$ and ${\mathcal L_6(1,5,3,2)}$ also had the same cardinality. Huh.

It seemed too good to be true, but I played around some more, and sure enough, the cardinality of ${\#\mathcal L_{k+2}(a_1, \dots, a_n)}$ seemed to only depend on the order of the ${a_i}$‘s. And so at last I stumbled upon the final form the conjecture, realizing that all along the assumption ${a_i \in \{k,k+1\}}$ that I had been working with was a red herring, and that the bijection was really true in much vaster generality. There is a bijection

$\displaystyle \mathcal L_{k+2}(a_1, \dots, a_i, a_{i+1}, \dots, a_n) \rightarrow \mathcal L_{k+2}(a_1, \dots, a_{i+1}, a_{i}, \dots, a_n)$

which only involves rearranging the elements of the ${i}$th and ${(i+1)}$st blocks.

It also meant I had more work to do, and so I was now glad that I hadn’t written up my work from yesterday night.

### 5.2. More data science

I re-ran the experiment I had done before, now with ${\mathcal L_7(2,3,5,2) \rightarrow \mathcal L_7(2,5,3,2)}$. (This was interesting, because the ${8}$ elements in question could now have either longest increasing subsequence of length ${5}$, or instead of length ${6}$.)

The data I obtained was:

246|13578 => 24678|135
247|13568 => 24578|136
248|13567 => 24568|137
256|13478 => 25678|134
257|13468 => 23578|146
258|13467 => 23568|147
267|13458 => 23678|145
268|13457 => 23468|157
278|13456 => 23478|156
346|12578 => 34678|125
347|12568 => 34578|126
348|12567 => 34568|127
356|12478 => 35678|124
357|12468 => 13578|246
358|12467 => 13568|247
367|12458 => 13678|245
368|12457 => 13468|257
378|12456 => 13478|256
456|12378 => 45678|123
457|12368 => 14578|236
458|12367 => 14568|237
467|12358 => 14678|235
468|12357 => 12468|357
478|12356 => 12478|356
567|12348 => 15678|234
568|12347 => 12568|347
578|12346 => 12578|346
678|12345 => 12678|345


Okay, so it looks like:

• exactly two numbers are moving each time, and
• the length of the longest run is preserved.

Eventually, I was able to work out the details, but they’re more involved than I want to reproduce here. But the idea is that you can move elements “one at a time”: something like

$\displaystyle \mathcal L_{k+2}(7,4) \rightarrow \mathcal L_{k+2}(6,5) \rightarrow \mathcal L_{k+2}(5,6) \rightarrow \mathcal L_{k+2}(4,7)$

while preserving the length of increasing subsequences at each step.

So, together with the easy observation from the beginning, this not only resolves the original problem, but also gives an elegant generalization. I had now proved:

Theorem 12

For any ${a_1}$, …, ${a_n}$, the cardinality

$\displaystyle \# \mathcal L_{k+2}(a_1, \dots, a_n)$

does not depend on the order of the ${a_i}$‘s.

## 6. Discovered vs invented

Whenever I look back on this, I can’t help thinking just how incredibly lucky I got on this project.

There’s this perpetual debate about whether mathematics is discovered or invented. I think it’s results like this which make the case for “discovered”. I did not really construct the bijection ${\mathbf W}$ myself: it was “already there” and I found it by examining the data. In another world where ${\mathbf W}$ did not exist, all the creativity in the world wouldn’t have changed anything.

So anyways, that’s the behind-the-scenes tour of my favorite combinatorics paper.