pnat.xgcd_type

A term of xgcd_type is a system of six naturals. They should be thought of as representing the matrix [[w, x], [y, z]] = [[wp + 1, x], [y, zp + 1]] together with the vector [a, b] = [ap + 1, bp + 1].

pnat.xgcd_type.has_repr

The has_repr instance converts terms to strings in a way that reflects the matrix/vector interpretation as above.

pnat.xgcd_type.vp

The map v gives the product of the matrix [[w, x], [y, z]] = [[wp + 1, x], [y, zp + 1]] and the vector [a, b] = [ap + 1, bp + 1]. The map vp gives [sp, tp] such that v = [sp + 1, tp + 1].

pnat.xgcd_type.is_special

is_special holds if the matrix has determinant one.

pnat.xgcd_type.is_reduced

is_reduced holds if the two entries in the vector are the same. The reduction algorithm will produce a system with this property, whose product vector is the same as for the original system.

pnat.xgcd_type.rq_eq

Properties of division with remainder for a / b.

pnat.xgcd_type.start

The following function provides the starting point for our algorithm. We will apply an iterative reduction process to it, which will produce a system satisfying is_reduced. The gcd can be read off from this final system.

pnat.xgcd_type.step

This is the main reduction step, which is used when u.r ≠ 0, or equivalently b does not divide a.

pnat.xgcd_type.step_wf

We will apply the above step recursively. The following result is used to ensure that the process terminates.

pnat.xgcd_type.step_v

The reduction step does not change the product vector.

pnat.xgcd_type.reduce

We can now define the full reduction function, which applies step as long as possible, and then applies finish. Note that the "have" statement puts a fact in the local context, and the equation compiler uses this fact to help construct the full definition in terms of well-founded recursion. The same fact needs to be introduced in all the inductive proofs of properties given below.