Motivating unpublished statements of Gauss about congruences and quaternions Background
Modern claims that Gauss anticipated the quaternions algebra are based primarily on an unpublished fragment of Gauss dated to 1819 and entitled "rotations of space". In this fragment Gauss describes the quaternion rule for multiplication of two quadrupoles of numbers (which he calls "scales"), remarks it is non-commutative (he does not introduce special notation like $i,j,k$), and gives many formulas that relate 3D spatial rotations to unit quaternions, including one complicated $3\times 3$ orthogonal matrix that acts on a cartesian system $XYZ$ as a rotation. This is mentioned just in order to give background on this fragment of Gauss.
Gauss's congruences
What interests me in this fragment is especially part 5 of it; this part appears to deal not with the geometric aspects of quaternions but rather with its structure as an algebra over the integers. In it Gauss gave several congruences involving the elements of two quaternions $q_1=a+bi+cj+dk, q_2 = \alpha +\beta i + \gamma j +\delta k$ and their product $q_3 = q_1\cdot q_2 = A+Bi+Cj+Dk$ modulo the norm of one quaternion.
More specifically, Gauss denotes the norms $m = a^2+b^2+c^2+d^2, \mu=\alpha^2+\beta^2+\gamma^2+\delta^2$, and then says, for example:
$$\frac {{C+Di}}{{A + Bi}} \equiv \frac {{c + di}}{{a + bi}} \pmod m$$
$$\frac {{B+Ci}}{{A + Di}} \equiv \frac {{b + ci}}{{a + di}} \pmod m$$
(actually he writes down six such congruences, but they are all similar in structure so there is no need to write down all of them). For prime $m$, Gauss's first congruence is in fact correct, as I will show here.
Proof of Gauss's first congruence
To prove Gauss congruence lets introduce the following notation: $$x = a+bi,y = c+ di, u = \alpha + \beta i, v = \gamma + \delta i, X = A + Bi, Y = C + Di$$
First of all, one has to understand that Gauss's notation is different from modern convention in two aspects:

*

*When Gauss designates a quaternion by a collection of four coefficients $(a,b,c,d)$, he means $a+ib+jc+kd$ (not $a+bi+cj+dk$).

*Secondly, Gauss defines quaternions multiplication in such way that the product of two fundamental quaternions gives the third one with positive sign if the multiplication operation is done counterclockwise (not clockwise like in modern convention); that is, $ij=-k$ and $jk = -i$. That he defines quaternions multiplication in this way is evident from the bilinear expressions he give for the four coefficients $(A,B,C,D)$ of the product.

Therefore each of the quaternions $q_1= a + ib + jc +kd $ and  $q_2 = \alpha + i\beta  +j\gamma  + k\delta $ can be written as:
$$q_1 = x + jy$$
$$q_2 = u + jv$$
and:
$$q_3 = q_1q_2 = X+jY = (x + jy)(u+jv) = (xu - \bar y v) + j(yu + \bar x v)$$
The complex conjugate symbols appear because of the non-commutitivity of quaternions algebra; that is, $jy = \bar yj$. Finally, to prove Gauss's congruence, let's make the following step (multiplying both sides of the congruence by $(A+iB)(a+ib)$):
$$(C+Di)(a + bi)-(A+Bi)(c+di) = Yx - Xy = (yu + \bar x v)x - (xu - \bar y v)y = (x\bar x + y\bar y)v + (xy - xy)u =\rVert x + jy \rVert ^2 v$$
Since $\rVert x + yj \rVert ^2 = m$ one gets that that the result equals the product of m and an integral complex number.
So far, there was only one problematic step - that is the multiplication of both sides of the congruence by $Xx = (A+iB)(a+ib)$ and the conclusion that if the resulting congruences is correct than the original congruence is also correct. It should be more appropriate to prove, indeed, that m divides $\frac{||x+jy||^2v}{(A+iB)(a+ib)} = m\frac{v}{(A+iB)(a+ib)} = m(\epsilon+i\pi)$ where $\epsilon,\pi$ are rational numbers. However, since we are dealing with modular arithmetic, for prime $m$ every rational number has an equivalent integer (for example, $\frac{1}{3} \equiv 5 \pmod 7$), so after multiplication of the integer equivalent of $\epsilon + i\pi$ with $m$ the resulting Gaussian integer is really congruent to $0$ modulo $m$ . However, Gauss does not say $m$ is a prime number, so I guess these congruences are just intended to illustrate a general structural principle of quaternions.
Questions
Gauss does not explain anything about those six congruences; he just lists them down. Yet it is still surprising that the congruences are in fact correct, even though only for prime $m$. I cannot figure out what was his aim in "mixing" congruences with quaternions, but even if he had an idea here, I think this formula is a very cumbersome way of presenting it.

*

*Since the correctness of Gauss's first congruence was confirmed (for prime $m$), the remaining question is - what was his motivation?

*How to prove Gauss's second congruence? in this case the trick of writing (for example) $q_3=(A+Bi)+(C+Di)j$ is not adequate to prove it, since the two pairs $A+Di$ and $B+Ci$ are not in their original order in $q_3$.

As far as I understand mathematical intuition, writing down such a formula without "walking" through the usual technical road to it must be the result of some idea, especially in mathematical areas that are considered frontiers (and quaternions were indeed a frontier of mathematics at the times of Gauss).
My unsuccesful interpretation
I mention this unsuccesful attempt because maybe someone will be able to continue this line of thought and rewrite it in the language of modern abtract algebra.
The proof above views quaternions as ordered pairs of complex numbers (for example: $q_1 = x+jy$ where $x,y$ are complex numbers); Gauss has already encountered the phenomenon of quaternionic behaviour in ordered pairs of complex numbers in another place (Gauss's werke, vol 3, p.384). Therefore I have an intuitive feeling he casted his statements in this particular form because he viewed the quaternions as an hypercomplex number system over the complex numbers (as an extension of $\mathbb{C}$), in the same way complex numbers can be viewed as an hyperreal number system over the reals.
Therefore I thought it is logical to try and search for a similar pattern in the complex numbers. Let $$c_1=a+bi,c_2=\alpha+\beta i$$ $$c_3 = c_1\cdot c_2 =A+Bi = (a\alpha - b\beta)+(b\alpha+a\beta)i$$
and then one gets that $$\frac{B}{A}-\frac{b}{a} = \frac{(b\alpha+a\beta)a-(a\alpha - b\beta)b}{Aa} = \frac{(a^2+b^2)\beta}{Aa} \equiv 0 \pmod {a^2+b^2}$$
where the last relation holds for prime values of $a^2+b^2$. The fact that this congruence is also correct for complex numbers is obvious from the proof for general quaternions, since the complex integers are a subset of quaternion integers. But maybe by looking at Gauss's congruence in the simpler case of $\mathbb{C}$ one can get idea about the kind of notions Gauss attempted to generalize from $\mathbb{C}$ to the quaternions.
 A: I understand now how to prove all of the six congruences of Gauss from the first one; this answers my second question. To prove Gauss's second congruence, for example, lets define the following new quaternions:
$$q_1' = a+di+bj+ck = (a+bj)+(c-dj)k$$
$$q_2'=\alpha+\delta i+\beta j+\gamma k = (\alpha+\beta j)+(\gamma-\delta j)k$$
$$q_3' = q_1'\cdot q_2' = (a\alpha-b\beta-c\gamma-d\delta)+(a\delta+d\alpha+c\beta-b\gamma)i+(a\beta+b\alpha+d\gamma-c\delta)j+(a\gamma+c\alpha+b\delta-d\beta)k=A+Di+Bj+Ck = (A+Bj)+(C-Dj)k$$
As we can see, the form of $q_3'$ agrees exactly with the form of the left fraction in Gauss's second congruence; this shows Gauss's second congruence follows immediately from its first by applying the theorem contained in the first to the $ q_1',q_2',q_3'$.
Regarding the meaning of Gauss's second congruence, note that it treats, for example, the quaternion $q_1'$ as an ordered pair of "complex numbers" in the j-plane ($a+bj,c-dj$) with $k$ as the imaginary unit of $(c-dj)$; this is an analog of the first congruence in which $i$ is replaced by $j$ and $j$ by $k$.
Therefore, Gauss lists down all three congruences with respect to $m$ which in which $i,j,k$ are cycly permuted, and the same for $\mu$; this explains why there are totally six congruences. The deeper meaning of these assertions is that the three imaginary units $i,j,k$ of the quaternions have an equal footing in the quaternions algebra.
