Ring identities by Kronecker substitution.
Evaluating a polynomial with integer coefficients at the point xᵢ = X ^ (B ^ i) maps the
monomial with packed code v to X ^ v. When B is larger than every degree and 2 * ‖p‖₁ < X,
two polynomials with the same value are equal: the value written in base X has the coefficients
as digits. So the kernel checks an identity a = b by evaluating a and b at the point, which is
arithmetic on large natural numbers that it performs on literals directly, and by bounding the
coefficients with Expr.majorant_k. The polynomials of a and b are not computed: they only
appear in the proof (Expr.toPP_k).
The value of p at the point xᵢ = X ^ (B ^ i), where the monomial with code v is X ^ v.
Equations
Instances For
The coefficient of the monomial with code c (the constant has code 0).
Equations
- Lean.Grind.CommRing.PPoly.coeff c (Lean.Grind.CommRing.PPoly.num k) = if c = 0 then k else 0
- Lean.Grind.CommRing.PPoly.coeff c (Lean.Grind.CommRing.PPoly.add k d v p) = (if v = c then k else 0) + Lean.Grind.CommRing.PPoly.coeff c p
Instances For
The sum of the absolute values of the coefficients.
Equations
- (Lean.Grind.CommRing.PPoly.num k).norm1 = k.natAbs
- (Lean.Grind.CommRing.PPoly.add k d v p).norm1 = k.natAbs + p.norm1
Instances For
Equations
- (Lean.Grind.CommRing.PPoly.num k).size = 0
- (Lean.Grind.CommRing.PPoly.add k d v p).size = p.size + 1
Instances For
p without its terms with code c.
Equations
- One or more equations did not get rendered due to their size.
- Lean.Grind.CommRing.PPoly.removeCode c (Lean.Grind.CommRing.PPoly.num k) = if c = 0 then Lean.Grind.CommRing.PPoly.num 0 else Lean.Grind.CommRing.PPoly.num k
Instances For
p without the terms with code 0, and the other codes decremented.
Equations
- (Lean.Grind.CommRing.PPoly.num k).shiftDown = Lean.Grind.CommRing.PPoly.num 0
- (Lean.Grind.CommRing.PPoly.add k d v p).shiftDown = if v = 0 then p.shiftDown else Lean.Grind.CommRing.PPoly.add k d (v - 1) p.shiftDown
Instances For
p followed by q, without merging.
Equations
- (Lean.Grind.CommRing.PPoly.num k).append x✝ = Lean.Grind.CommRing.PPoly.append.addConst x✝ k
- (Lean.Grind.CommRing.PPoly.add k d v p).append x✝ = Lean.Grind.CommRing.PPoly.add k d v (p.append x✝)
Instances For
Equations
Instances For
Equations
- (Lean.Grind.CommRing.PPoly.num k).neg = Lean.Grind.CommRing.PPoly.num (-k)
- (Lean.Grind.CommRing.PPoly.add k d v p).neg = Lean.Grind.CommRing.PPoly.add (-k) d v p.neg
Instances For
Bounds on the coefficients of the polynomials of Expr.toPP_k.
Equations
- Lean.Grind.CommRing.PPoly.norm1List ps = List.foldr (fun (p : Lean.Grind.CommRing.PPoly) (n : Nat) => p.norm1 + n) 0 ps
Instances For
An upper bound on ‖p‖₁ for the polynomial p of e: the value of e with the absolute values of its numerals at 1.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The value of e at the point xᵢ = (2 ^ K) ^ (B ^ i).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Checks that 2 ^ K is larger than twice the coefficients of a and b.
Equations
- Lean.Grind.CommRing.Expr.kronOk_k K a b = (Nat.mul 2 (a.majorant_k.add b.majorant_k)).blt (Nat.pow 2 K)
Instances For
Semiring relations with a common part c of both sides: a = a' + c and b = b' + c are
checked at the point, and c is cancelled, so it is never written as a term of the semiring.
Linear identities by evaluation at xᵢ = X ^ (i + 1): when every product has a constant factor
(Expr.degB_k e ≤ 1), the monomials are the variables, and their codes can be i + 1 instead of
B ^ i, so the values stay small for many variables (Expr.eq_of_kronLin).
p with its coefficients multiplied by k, without dropping zeros.
Equations
- Lean.Grind.CommRing.PPoly.scale k (Lean.Grind.CommRing.PPoly.num k_1) = Lean.Grind.CommRing.PPoly.num (k * k_1)
- Lean.Grind.CommRing.PPoly.scale k (Lean.Grind.CommRing.PPoly.add k_1 d v p) = Lean.Grind.CommRing.PPoly.add (k * k_1) d v (Lean.Grind.CommRing.PPoly.scale k p)
Instances For
The value of a constant expression (variables at 0).
Equations
- (Lean.Grind.CommRing.Expr.num k).evalConst = k
- (Lean.Grind.CommRing.Expr.intCast k).evalConst = k
- (Lean.Grind.CommRing.Expr.natCast n).evalConst = ↑n
- (Lean.Grind.CommRing.Expr.var i).evalConst = 0
- a.neg.evalConst = -a.evalConst
- (a.add b).evalConst = a.evalConst + b.evalConst
- (a.sub b).evalConst = a.evalConst - b.evalConst
- (a.mul b).evalConst = a.evalConst * b.evalConst
- (a.pow k).evalConst = a.evalConst ^ k
Instances For
The terms of a linear expression, with code i + 1 for the variable i (only used in proofs).
Equations
- (Lean.Grind.CommRing.Expr.num k).toLin = Lean.Grind.CommRing.PPoly.num k
- (Lean.Grind.CommRing.Expr.intCast k).toLin = Lean.Grind.CommRing.PPoly.num k
- (Lean.Grind.CommRing.Expr.natCast n).toLin = Lean.Grind.CommRing.PPoly.num ↑n
- (Lean.Grind.CommRing.Expr.var i).toLin = Lean.Grind.CommRing.PPoly.add 1 1 (i + 1) (Lean.Grind.CommRing.PPoly.num 0)
- a.neg.toLin = a.toLin.neg
- (a.add b).toLin = a.toLin.append b.toLin
- (a.sub b).toLin = a.toLin.append b.toLin.neg
- (a.mul b).toLin = if a.degB_k = 0 then Lean.Grind.CommRing.PPoly.scale a.evalConst b.toLin else Lean.Grind.CommRing.PPoly.scale b.evalConst a.toLin
- (a.pow k).toLin = if k = 0 then Lean.Grind.CommRing.PPoly.num 1 else if k = 1 then a.toLin else Lean.Grind.CommRing.PPoly.num (a.evalConst ^ k)
Instances For
The value of e at the point xᵢ = (2 ^ K) ^ (i + 1).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The valuation of the codes of Expr.toLin: the code i + 1 is the variable i.
Instances For
An upper bound on Expr.degB_k e, with Nat.lor in place of the maximum: it is the degree when
the degree is at most 1, and is cheaper to reduce.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The difference of a and b is the constant k, for the theorems eq_false_of_sub, le_true_of_sub, ....
The difference of a and b is the constant k, by Kronecker substitution.
Expr.lin_k e, or at least 2 if e is not a semiring term (Expr.semi_k): one traversal checks
that a semiring term is linear.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Kronecker certificates for grind's Gröbner steps: a chain p = p₁ + Σ kᵢ * mᵢ * qᵢ of stated
polynomials is checked by comparing values at the point (Stepwise.simpsK, Stepwise.d_stepsK).
In characteristic c, the difference is c * E for a stated polynomial E (Stepwise.simpsKC).
a * 2 ^ s for kernel reduction.
Equations
- Lean.Grind.CommRing.Int.shl_k a s = Int.rec (fun (n : Nat) => Int.ofNat (n.shiftLeft s)) (fun (n : Nat) => Int.negOfNat_k ((n.add 1).shiftLeft s)) a
Instances For
Adds the integers of ps by levels of pairwise additions, so that the kernel evaluates sums of nesting depth logarithmic in their number.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
The value of p at the point xᵢ = (2 ^ K) ^ (B ^ i).
Equations
Instances For
Equations
- p.norm1_k = Lean.Grind.CommRing.Poly.rec (fun (k : Int) => k.natAbs_k) (fun (k : Int) (x : Lean.Grind.CommRing.Mon) (x_1 : Lean.Grind.CommRing.Poly) (ih : Nat) => k.natAbs_k.add ih) p
Instances For
Equations
Instances For
Equations
Instances For
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.
Instances For
The multiples of ls with packed monomials, appended.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
- ls.norm_k = Lean.Grind.CommRing.MList.rec 0 (fun (M q : Lean.Grind.CommRing.Poly) (x : Lean.Grind.CommRing.MList) (ih : Nat) => (M.norm1_k.mul q.norm1_k).add ih) ls
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
p and p₁ + Σ ls + c * E have the same value at the point, so they denote the same.
e and p + c * E have the same value at the point, so they denote the same.
The input step lhs = rhs of grind's ring solver, with p the polynomial of lhs - rhs, by Kronecker substitution.
Field identities with inverses of numerals (Expr.eq_of_kronQ). With the variables of invs
denoting 1 / c, an expression e is num / den for an integer polynomial num
(Expr.toPPQ, only used in proofs). The kernel computes the value of num at the point and den
(Expr.kronQ_k), so a = b follows from num_a * den_b = num_b * den_a at the point, with a
bound on the coefficients (Expr.majQ_k).
invs.lookup x for kernel reduction, for invs sorted by variable: the search stops at the first
larger variable, so a variable below all of invs costs one comparison.
Equations
- One or more equations did not get rendered due to their size.
Instances For
true if the numerals of invs are not 0.
Equations
Instances For
Expr.degB_k, where the variables of invs are constants.
Equations
- One or more equations did not get rendered due to their size.
Instances For
(num, den) of e, where the variables of invs are the constants 1 / c (only used in proofs).
Equations
- One or more equations did not get rendered due to their size.
- Lean.Grind.CommRing.Expr.toPPQ B invs (Lean.Grind.CommRing.Expr.num k) = (Lean.Grind.CommRing.PPoly.num k, 1)
- Lean.Grind.CommRing.Expr.toPPQ B invs (Lean.Grind.CommRing.Expr.intCast k) = (Lean.Grind.CommRing.PPoly.num k, 1)
- Lean.Grind.CommRing.Expr.toPPQ B invs (Lean.Grind.CommRing.Expr.natCast n) = (Lean.Grind.CommRing.PPoly.num ↑n, 1)
- Lean.Grind.CommRing.Expr.toPPQ B invs a.neg = (Lean.Grind.CommRing.PPoly.mulConst_k (-1) (Lean.Grind.CommRing.Expr.toPPQ B invs a).fst, (Lean.Grind.CommRing.Expr.toPPQ B invs a).snd)
- Lean.Grind.CommRing.Expr.toPPQ B invs (a.pow k) = ((Lean.Grind.CommRing.Expr.toPPQ B invs a).fst.powB_k k, (Lean.Grind.CommRing.Expr.toPPQ B invs a).snd ^ k)
Instances For
Linear field identities over many variables (Expr.eq_of_kronQLin): with the variables of invs
as the inverses of their numerals, both sides are linear in the other variables, which are
evaluated at xᵢ = (2 ^ K) ^ (i + 1) as in Expr.eq_of_kronLin.
Expr.lin_k, where the variables of invs are constants.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The value of a constant expression: its variables at 0, those of invs at the inverses of their numerals.
Equations
- One or more equations did not get rendered due to their size.
- Lean.Grind.CommRing.Expr.evalQ invs (Lean.Grind.CommRing.Expr.num k) = (k, 1)
- Lean.Grind.CommRing.Expr.evalQ invs (Lean.Grind.CommRing.Expr.intCast k) = (k, 1)
- Lean.Grind.CommRing.Expr.evalQ invs (Lean.Grind.CommRing.Expr.natCast n) = (↑n, 1)
- Lean.Grind.CommRing.Expr.evalQ invs (Lean.Grind.CommRing.Expr.var i) = match invs.lookup_k i with | some c => (1, c) | none => (0, 1)
- Lean.Grind.CommRing.Expr.evalQ invs a.neg = (-(Lean.Grind.CommRing.Expr.evalQ invs a).fst, (Lean.Grind.CommRing.Expr.evalQ invs a).snd)
- Lean.Grind.CommRing.Expr.evalQ invs (a.pow k) = ((Lean.Grind.CommRing.Expr.evalQ invs a).fst ^ k, (Lean.Grind.CommRing.Expr.evalQ invs a).snd ^ k)
Instances For
The terms of the numerator of a linear e, with code i + 1 for the variable i, and its
denominator; the variables of invs are constants (only used in proofs).
Equations
- One or more equations did not get rendered due to their size.
- Lean.Grind.CommRing.Expr.toLinQ invs (Lean.Grind.CommRing.Expr.num k) = (Lean.Grind.CommRing.PPoly.num k, 1)
- Lean.Grind.CommRing.Expr.toLinQ invs (Lean.Grind.CommRing.Expr.intCast k) = (Lean.Grind.CommRing.PPoly.num k, 1)
- Lean.Grind.CommRing.Expr.toLinQ invs (Lean.Grind.CommRing.Expr.natCast n) = (Lean.Grind.CommRing.PPoly.num ↑n, 1)
- Lean.Grind.CommRing.Expr.toLinQ invs a.neg = ((Lean.Grind.CommRing.Expr.toLinQ invs a).fst.neg, (Lean.Grind.CommRing.Expr.toLinQ invs a).snd)
Instances For
Checks that a and b are linear, with the variables of invs as constants.
Equations
- Lean.Grind.CommRing.Expr.linQOk_k invs a b = Bool.rec false ((Lean.Grind.CommRing.Expr.degQL_k invs b).ble 1) ((Lean.Grind.CommRing.Expr.degQL_k invs a).ble 1)
Instances For
lhs - rhs is lhs' - rhs' divided by d, by Kronecker substitution: the normalization of a
relation with inverses of numerals, whose sides lhs' and rhs' have no denominators.
Expr.sub_mul_eq_of_kronQ for linear terms over many variables (Expr.eq_of_kronQLin).
Relations lhs ⋈ rhs rewritten to lhs' ⋈ rhs' with lhs - rhs and lhs' - rhs' the same
polynomial, checked at a point (le_of_kron_rel, and le_of_kronLin_rel for linear terms over
many variables).
eq_cancel_of_kronS and its variants for linear terms over many variables.
Identities in commutative semirings without AddRightCancel, where the ring envelope does not
apply (Expr.eq_of_kronSN): the terms of both sides, expanded without merging (Expr.toTL), have
nonnegative coefficients; equal values at the point give equal coefficients for each monomial,
and terms with the same monomial are regrouped in the semiring.
All coefficients of p are nonnegative.
Equations
- (Lean.Grind.CommRing.PPoly.num k).NonNeg = (0 ≤ k)
- (Lean.Grind.CommRing.PPoly.add k d v p).NonNeg = (0 ≤ k ∧ p.NonNeg)
Instances For
q multiplied by the term k * x^v of degree d, without merging.
Equations
- Lean.Grind.CommRing.PPoly.mulTermTL k d v (Lean.Grind.CommRing.PPoly.num k_1) = Lean.Grind.CommRing.PPoly.add (k * k_1) d v (Lean.Grind.CommRing.PPoly.num 0)
- Lean.Grind.CommRing.PPoly.mulTermTL k d v (Lean.Grind.CommRing.PPoly.add k_1 d_1 v_1 p) = Lean.Grind.CommRing.PPoly.add (k * k_1) (d + d_1) (v + v_1) (Lean.Grind.CommRing.PPoly.mulTermTL k d v p)
Instances For
The product of p and q, without merging.
Equations
- (Lean.Grind.CommRing.PPoly.num k).mulTL x✝ = Lean.Grind.CommRing.PPoly.scale k x✝
- (Lean.Grind.CommRing.PPoly.add k d v p).mulTL x✝ = (Lean.Grind.CommRing.PPoly.mulTermTL k d v x✝).append (p.mulTL x✝)
Instances For
The terms of e with packed monomials in base B, without merging (only used in proofs).
Equations
- Lean.Grind.CommRing.Expr.toTL B (Lean.Grind.CommRing.Expr.num k) = Lean.Grind.CommRing.PPoly.num k
- Lean.Grind.CommRing.Expr.toTL B (Lean.Grind.CommRing.Expr.intCast k) = Lean.Grind.CommRing.PPoly.num k
- Lean.Grind.CommRing.Expr.toTL B (Lean.Grind.CommRing.Expr.natCast n) = Lean.Grind.CommRing.PPoly.num ↑n
- Lean.Grind.CommRing.Expr.toTL B (Lean.Grind.CommRing.Expr.var i) = Lean.Grind.CommRing.PPoly.add 1 1 (B ^ i) (Lean.Grind.CommRing.PPoly.num 0)
- Lean.Grind.CommRing.Expr.toTL B a.neg = (Lean.Grind.CommRing.Expr.toTL B a).neg
- Lean.Grind.CommRing.Expr.toTL B (a.add b) = (Lean.Grind.CommRing.Expr.toTL B a).append (Lean.Grind.CommRing.Expr.toTL B b)
- Lean.Grind.CommRing.Expr.toTL B (a.sub b) = (Lean.Grind.CommRing.Expr.toTL B a).append (Lean.Grind.CommRing.Expr.toTL B b).neg
- Lean.Grind.CommRing.Expr.toTL B (a.mul b) = (Lean.Grind.CommRing.Expr.toTL B a).mulTL (Lean.Grind.CommRing.Expr.toTL B b)
- Lean.Grind.CommRing.Expr.toTL B (a.pow k) = (Lean.Grind.CommRing.Expr.toTL B a).powTL k
Instances For
Identities in commutative semirings, without cancellation: the terms of both sides have
nonnegative coefficients, the same value at the point gives the same coefficient for each
monomial, and terms with the same monomial are regrouped (PPoly.denoteSN_eq_of_coeff).