# Proof by double induction on strings

This was a question on an assignment presented to my Logic & Mathematics for computer science course, and I am truly baffled as to go on to prove this by double induction:

Consider a string consisting of one or more decimal digits (0-9). Suppose you repeatedly insert a 0 to the right of the leftmost digit and then replace that string by a string of the same length which represents the result of subtracting one from that string.

ie: start with string 11 you will get the following: 11, 101, 100, 1000, 0999, 00999, 00998, and so on.

Prove by double induction, that no matter what string you start with, you will eventually get a string containing only 0's.

This question seems rather trivial on first glimpse, however trying to prove it via double induction is another thing for me. I'm having trouble deciding what the variables that I will be applying induction on will be. Obviously one of the two variables will be the string input, but what about the other? I've thought of using length but I don't see what that can do to help. What do you guys think?

Assuming I have encapsulated the variables, I plan on proceeding to prove this in the following manner given for all x and y in N. p(x,y):

Let Q(x) = for all y in N, p(x,y) Let x be arbitrary and assume for all i in N, i < x IMPLIES Q(i). We then let y in N be arbitrary then assume that for all j in N, j < y implies p(x,j).

Afterward I will use the assumption that for all i and j, p(i,j) is true such that (i < x) or (i = x and j < y).Then proceed proof.

Does that skeletal proof structure make logical sense? Double induction is still new to me and it wasn't covered whole lot in lectures so I'm rather still insecure.

I suppose it'd make more sense if we used structural induction on each variable, however we're restricted to use double induction only.

I'm sorry for the long question, I'd appreciate any input & help & insight regarding this question or in double induction in general as my Google-fu seems to be coming short on information of the latter :(.

• Feb 12 '11 at 7:41
• @YuvalFilmus: The image link is not valid. Does your link point to something equivalent to the image?
– robjohn
May 15 '19 at 16:56
• @robjohn Given that it was 8 years ago, I can't really say. May 15 '19 at 17:18
• @YuvalFilmus: thanks. I got a flag that the image link was bad and since you posted a comment with a link, I thought I'd ask.
– robjohn
May 15 '19 at 18:05
• @Friday Please could you make the snap-shot of the question available again for other readers? Oct 18 '20 at 13:01

Let $a$ be the first digit of the string, and let $b$ be the value of the remaining digits. Let's prove that the operation is reducing with respect to the lexical order of $\langle a,b\rangle$, which is one version of interpreting your phrase "double induction."

First, note that the operation of inserting the $0$ to the right of the leading digit affects neither the value of $a$ nor $b$.

Next, note that if $b$ is all zero but $a$ is not $0$, then the operation will end up with $a$ being reduced, because when you subtract one, you will have to borrow from $a$, thereby reducing. Thus, the operation will result with a string having lower $\langle a,b\rangle$ in the lexical order.

If $b$ is not all zero, however, then the operation will end up with the $b$ value being value $1$ less (despite the extra $0$), and so will reduce $\langle a,b\rangle$ in the lexical order.

Since the lexical order on $\mathbb{N}\times\mathbb{N}$ is a well-order, it follows that the operation must eventually hit all $0$s.

The argument shows that you can insert any number of $0$s, rather than just one $0$ at each step, although if you insert more, then it will take longer to get to the all $0$ string, since when you borrow, you will get more $9$s.

• Thanks for the reply. I will try to translate this to the pedantic proof structure my course requires. Given the choice of variables you presented, I will see what I can do! Feb 12 '11 at 2:32
• Probably you just need to go by double induction on $a$ and $b$ as I defined them. The point is that you prove that for any fixed $a$, the claim is true for all $b$. You prove each instance of this by induction on $b$, assuming that the claim is true for all smaller values of $a$.
– JDH
Feb 12 '11 at 2:36
• The case $b=0$ amounts to the borrowing case I mention above, using a smaller value for $a$.
– JDH
Feb 12 '11 at 2:43
• This has a bit of the feel of the proof of Goodstein's theorem to me, though the induction is just over $\omega^2$ Feb 12 '11 at 2:49
• Yes, it is similar, but Goodstein's theorem has induction of order type $\epsilon_0$, since every ordinal below $\epsilon_0$ has a finite representation in terms of ordinal additiona, multiplication and exponentiation using only finite numbers and $\omega$.
– JDH
Feb 12 '11 at 2:55