Numeral inverses as rational coefficients #
In a field of characteristic zero, the inverse c⁻¹ of a numeral c ≠ 0 is not an atom of the
polynomial normal form: a / 2 + a / 2 must normalize to a. The reflection language Expr
denotes into any ring and has no inverse, so c⁻¹ is reified as a variable x and the
InvVars list records x ↦ c. The integer polynomial of the term is then normalized into a
PolyQ num / den: an integer polynomial num over the remaining variables and a
denominator den, in lowest terms. Every x is eliminated with Poly.cancelVar, which is
justified by c * x = 1; that equation holds because c ≠ 0 in characteristic zero.
The side condition InvVars.ok (each recorded variable denotes the inverse of its numeral) is
an equation between two lists that the kernel checks by rfl, since the context holds the
inverse terms themselves.
The inverse x⁻¹ of an atom x is a variable y as well. When x ≠ 0 is known, x * y = 1
and every monomial containing both x and y is reduced (Poly.cancelInv); InvAtoms
records the pairs (y, x) and InvAtoms.ok holds their equations, which are proved from
x ≠ 0. This needs no characteristic: Expr.eq_of_cancelInvs_eq and the normA relation
certificates work in any CommRing, and toPolyQ combines both kinds of inverses.
Variables that denote inverses of numerals: (x, c) records that x denotes (OfNat.ofNat c)⁻¹.
Instances For
Inverses of atoms #
Cancels x ^ d * y ^ d from m, where d is the smaller of the degrees of x and y in m.
Justified by x * y = 1; a no-op when x = y.
Instances For
Cancels x ^ d * y ^ d from every monomial of p (Mon.cancelInv).
Instances For
Variables that denote inverses of variables: (y, x) records that y denotes x⁻¹, for x ≠ 0.
Instances For
Inverses of numerals #
Eliminates the variable x, which denotes c⁻¹, from p: the polynomial is multiplied by
c ^ n, where n is the maximal degree of x in p, so that every power x ^ k can be
cancelled against the coefficient (c ^ k * x ^ k = 1); the denominator is c ^ n.
c = 0 is not an inverse and is left alone.