7

There's a list of $N$ natural numbers on the blackboard. At one step you can pick any two number, which do not divide each other. Instead of this pairs you write its gcd and lcm. Problem asks to prove that final result doesn't depend on order on which this operation applied. I guess to prove the operation is associative.

$$(4, 6, 9) \rightarrow\ (2, 12, 9) \rightarrow \ (2, 3, 36) \rightarrow \ (1, 6, 36)$$

$$(4, 6, 9)\ \rightarrow\ (4, 3, 18)\ \rightarrow\ (1, 12, 18) \rightarrow\ (1, 6, 36)$$

I figure that in the head and tail of final result list contains gcd and lcd of the whole list. However, what's going in between I didn't.

6 Answers6

9

The operations $\gcd$ and $\def\lcm{\operatorname{lcm}}\lcm$ can be represented as the operations $\min$ and $\max$, respectively, on the exponents in the prime factorizations:

$$ \gcd\left(\prod_ip_i^{a_i},\prod_ip_i^{b_i}\right)=\prod_ip_i^{\min(a_i,b_i)}\;,\\ \lcm\left(\prod_ip_i^{a_i},\prod_ip_i^{b_i}\right)=\prod_ip_i^{\max(a_i,b_i)}\;. $$

When you apply $\gcd$ and $\lcm$ to two numbers, for each prime you put the lesser exponent in the $\gcd$ and the greater exponent in the $\lcm$. You still have the same exponents; they just get sorted into lesser and greater ones. By defining a suitable sorting measure, e.g. $\left|\sum_i(a_i-b_i)\right|$ summed over all pairs of numbers, and noting that it increases in every step and is bounded from above, you can show that the process terminates. Clearly it can only terminate if a total order has been reached, where for any two pairs one contains all the lesser exponents and the other all the greater exponents. It follows that when the numbers are arranged in this order, the exponents for each prime are also arranged in this order. This determines the exponents, and hence the numbers, and it follows that the terminal state is independent of the order of operations.

Thanks to Carl for suggesting this approach.

P.S.: To make this a bit more concrete, we can represent the numbers $4,6,9$ in your example by their exponents for the two primes $2$ and $3$ that occur in them. Then we start out with $(2,0)$, $(1,1)$ and $(0,2)$. Sorting the exponents in the first component yields $0,1,2$, and likewise for the second component, so the terminal vectors are $(0,0)$, $(1,1)$ and $(2,2)$, corresponding to $1,6,36$.

joriki
  • 242,601
  • 1
    +1 Very insightful! (That the proces terminates can also be seen because $\gcd(a,b)+\DeclareMathOperator\lcm{lcm}\lcm(a,b)>a+b$ if $a\nmid b$ and $b\nmid a$. And the sum of all numbers is at most $n$ times their product, which is invariant, so it is bounded.) – Bart Michels Sep 19 '15 at 09:13
3

Neat problem. I don't have a complete solution, but I think a productive area would be to look at the prime factorizations of the numbers and see what happens to the exponents.

$$(2^2\cdot3^0, 2^1\cdot3^1, 2^0\cdot 3^2)$$

$$\to (2^1\cdot3^0, 2^2\cdot 3^1, 2^0\cdot3^2) \to (2^1\cdot3^0, 2^0\cdot3^1, 2^2\cdot 3^2) \to$$

or

$$\to(2^2\cdot3^0, 2^0\cdot3^1, 2^1\cdot3^2) \to(2^0\cdot3^0, 2^2\cdot 3^1, 2^1\cdot3^2) \to$$

$$(2^0\cdot3^0, 2^1\cdot3^1, 2^2\cdot 3^2)$$

In the first case the powers of 2 are $(2^2,2^1,2^0)$, which get transformed into $(2^1,2^2,2^0)$ and then $(2^1,2^0,2^2)$ before ending up as $(2^0,2^1,2^2)$. In the second case $(2^2,2^1,2^0)$ becomes $(2^2,2^0,2^1)$ and then $(2^0,2^2,2^1)$ before ending up as $(2^0,2^1,2^2)$. The exponents appear to be sorting themselves. The same thing happens to the powers of 3, and would happen to the powers of any other primes.

(Sorry this isn't a complete proof, but it looks like it could lead to one.)

2

Note that in the configuration at the end, for each pair of numbers one is the least common multiple of the two and the other is the greatest common divisor (otherwise you get a different list). So the higher is an integer multiple of the lower.

Organise the numbers in ascending order - you get $d, a_1d, a_1a_2d \dots$

Now notice that if you drop the first element (or the last, or in fact any of them) the same property remains. Drop $d$ and divide through by $d$. Then $a_1$ is the hcf of what remains (etc).

Mark Bennet
  • 101,769
1

As you say, you are proving that $f: \langle x,y \rangle \mapsto \langle \text{gcd}(x,y), \text{lcm}(x, y) \rangle$ is associative.

I'll write $g: \mathbb{N}^n \to \mathbb{N}$ for the GCD function, and $l: \mathbb{N}^n \to \mathbb{N}$ for the LCM, using the handy convention of $g(a,b,c)$ for $g(g(a,b),c)$ etc - justified by the next paragraph.

I claim first that $g$ is associative. Indeed, that's obvious just by considering the prime factorisations of the inputs. Likewise $l$, although you could prove this by using $l(x, y) = \frac{x y}{g(x, y)}$.

Now, I claim that $g(l(x, y), z) = l(g(x,z), g(y, z))$. This again follows by considering the prime factorisations.

Therefore, it is possible in any expression of the form "sequence of LCMs and GCDs" to pull out all the LCM terms to the front. Moreover, the resulting expression is precisely of the form $l( g(a,b,\dots), g(c,d,\dots), \dots)$ with no further levels of nesting. We just need to prove that the structure is the same however we apply the operations.

In your example, {4, 6, 9}, we find {g(4, 6), l(4, 6), 9}, then {g(4, 6), g(l(4, 6), 9), l(l(4, 6), 9)} which is $$\{g(4, 6), l(g(4, 9), g(6, 9)), l(4, 6, 9)\}$$

Finally, $\{g(g(4,6), l(g(4,9),g(6,9))), l(g(4,6), l(g(4,9),g(6,9))), l(4,6,9)\}$ which is $$\{g(4, 6, 9), l(g(4,6), g(4,9), g(6,9)), l(4,6,9)\}$$

This is manifestly symmetric, so it can't matter which order we took the operations in to get there.

I didn't rely on any special properties of 4, 6, 9: they stand in for general $a, b, c$. It's clear, by the way, that we need to stop the procedure here, because $g(a,b,c)$ divides $l(g(a,b),g(b,c),g(a,c))$ which divides $l(a,b,c)$.

This generalises, messily, by induction.

1

This is a much more heavy-handed argument than necessary (see other answers for elementary approaches), but let me add it to offer a different perpective.

We can view the described procedure as an abstract rewriting system. As shown in this question, it is terminating, and we want to prove that it is confluent (this gives uniqueness of normal forms, i.e., of the result as in the question). By Newman’s lemma, it is enough to prove that it is locally confluent.

Thus, let $S$ be a given multiset of numbers, and rewrite it in two ways to multisets $S_0$ and $S_1$, respectively, using the rule $\{a,b\}\mapsto\{a\land b,a\lor b\}$, where I am denoting $a\land b=\gcd(a,b)$, $a\lor b=\operatorname{lcm}(a,b)$ (in general, we could work with any distributive lattice). We have to show that there is $S'$ such that both $S_0$ and $S_1$ can be rewritten to $S'$ in finitely many steps.

This is trivial if the pairs $\{a,b\}$ used in the two reductions are the same (as the result is then also the same) or when they are disjoint (as we can then apply both reductions independently in either order). Thus, the only nontrivial case is when the two pairs share one element: that is, $S$ contains a triple $a,b,c$ which is rewritten as $$(\underbrace{a,b},c)\mapsto(a\land b,a\lor b,c)$$ in $S_0$, and as $$(a,\underbrace{b,c})\mapsto(a,b\land c,b\lor c)$$ in $S_1$, where the redexes are indicated. These can be reduced to the same triple using $$(a\land b,\underbrace{a\lor b,c})\mapsto(\underbrace{a\land b,(a\lor b)\land c},a\lor b\lor c)\mapsto (a\land b\land c,{\color{blue}{(a\land b)\lor((a\lor b)\land c)}},a\lor b\lor c)$$ and $$(\underbrace{a,b\land c},b\lor c)\mapsto(a\land b\land c,\underbrace{a\lor(b\land c),b\lor c})\mapsto(a\land b\land c,{\color{green}{(a\lor(b\land c))\land(b\lor c)}},a\lor b\lor c).$$ We only need to show that the coloured expressions are the same: $$(a\land b)\lor((a\lor b)\land c)=(a\lor(b\land c))\land(b\lor c).$$ The direct verification is that for each prime $p$, if its exponents in the prime factorizations of $a,b,c$ are $i,j,k$, then the exponents on the LHS and RHS of the equation above are both equal to the numerically middle one of $i,j,k$. Or abstractly, the equation holds in all distributive lattices, because any such lattice embeds in a product of $2$-element lattices, and in the $2$-element lattice $\{0,1\}$, both sides of the equation define the ternary majority function $\mathrm{maj}\colon\{0,1\}^3\to\{0,1\}$.

0

The operation doesn't change the product of the numbers. Since you've figured out what two of the numbers of the final result will be, you can solve for the remaining one.