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)⁻¹.
Equations
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
Equations
- Lean.Grind.CommRing.InvVars.denoteVars ctx invs = List.map (fun (p : Lean.Grind.CommRing.Var × Nat) => Lean.Grind.CommRing.Var.denote ctx p.fst) invs
Instances For
Equations
- invs.denoteInvs = List.map (fun (p : Lean.Grind.CommRing.Var × Nat) => (OfNat.ofNat p.snd)⁻¹) invs
Instances For
Each variable recorded in invs denotes the inverse of its numeral.
Equations
- Lean.Grind.CommRing.InvVars.ok ctx invs = (Lean.Grind.CommRing.InvVars.denoteVars ctx invs = invs.denoteInvs)
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.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Lean.Grind.CommRing.Poly.cancelInv.go x y (Lean.Grind.CommRing.Poly.num k) a✝ = a✝.addConst k
Instances For
Variables that denote inverses of variables: (y, x) records that y denotes x⁻¹, for x ≠ 0.
Instances For
x.denote ctx * y.denote ctx = 1 for each (y, x).
Equations
- Lean.Grind.CommRing.InvAtoms.ok ctx [] = True
- Lean.Grind.CommRing.InvAtoms.ok ctx ((y, x_1) :: l) = (Lean.Grind.CommRing.Var.denote ctx x_1 * Lean.Grind.CommRing.Var.denote ctx y = 1 ∧ Lean.Grind.CommRing.InvAtoms.ok ctx l)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Inverses of numerals #
Equations
- Lean.Grind.CommRing.PolyQ.denote ctx q = Lean.Grind.CommRing.Poly.denote ctx q.num * (↑q.den)⁻¹
Instances For
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.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Cancels the inverse pairs of ainvs, eliminates the numeral inverses of invs, and reduces
the result to lowest terms.
Equations
- p.toPolyQ invs ainvs = (List.foldl (fun (q : Lean.Grind.CommRing.PolyQ) (xc : Lean.Grind.CommRing.Var × Nat) => q.substInv xc.fst xc.snd) { num := p.cancelInvs ainvs, den := 1 } invs).reduce
Instances For
Certificates for inverses of atoms only #
Equations
- Lean.Grind.CommRing.Expr.cancelInvs_cert ainvs a b = (a.toPoly.cancelInvs ainvs == b.toPoly.cancelInvs ainvs)
Instances For
Equations
- Lean.Grind.CommRing.normA_cert ainvs lhs rhs lhs' rhs' = ((lhs.sub rhs).toPoly.cancelInvs ainvs == (lhs'.sub rhs').toPoly)
Instances For
Certificates for rational coefficients #
lhs' - rhs' is the numerator of lhs - rhs; the relation between lhs' and rhs' is denominator-free.