Mode of #cas
member
Proves that a polynomial lies in the ideal of given polynomials, and gives it as a combination of them.
#cas [member x, y, …] f [g₁, …, gₘ]MvPolynomial, and gives f as a combination of them.With ideal membership, the proof is something you can write down. If , then vanishes wherever the do, and the cofactors are the proof. member looks for them. It prints written as such a combination, as with Mathematica’s PolynomialReduce, and the theorem underneath is f ∈ Ideal.span {g₁, …, gₘ}.
We find the cofactors by dividing by the lexicographic Gröbner basis of the generators (groebner) and following the derivation of that basis back to the generators. Then ring checks the identity.
Examples (12)#
Basic Examples (2)
The polynomial lies in the ideal of and :
#cas [member x, y] (x^2 - 1) [x*y - 1, x - y]
a combination of the generators (checked)
x^2 - 1 = (x*y - 1) + x*(x - y)- Domain
ℚ[x, y] as MvPolynomial (Fin 2) ℚ, with x = X 0, y = X 1- Input (polynomial and ideal)
x^2 - 1 and ⟨x*y - 1, x - y⟩
Checked by Lean’s kernel: Membership in the ideal of the generators
X 0 ^ 2 - 1 ∈ Ideal.span {X 0 * X 1 - 1, X 0 - X 1}
The certificate: 1 checked step
Membership in the ideal of the generators
X 0 ^ 2 - 1 ∈ Ideal.span {X 0 * X 1 - 1, X 0 - X 1}
A generator that is not needed does not appear in the combination:
#cas [member x, y, z] (x^3 - y^3) [x - y, z]
a combination of the generators (checked)
x^3 - y^3 = (x^2 + x*y + y^2)*(x - y)- Domain
ℚ[x, y, z] as MvPolynomial (Fin 3) ℚ, with x = X 0, y = X 1, z = X 2- Input (polynomial and ideal)
x^3 - y^3 and ⟨x - y, z⟩
Checked by Lean’s kernel: Membership in the ideal of the generators
X 0 ^ 3 - X 1 ^ 3 ∈ Ideal.span {X 0 - X 1, X 2}
The certificate: 1 checked step
Membership in the ideal of the generators
X 0 ^ 3 - X 1 ^ 3 ∈ Ideal.span {X 0 - X 1, X 2}
Scope (2)
The twisted cubic is the common zero set of and . The polynomial vanishes on it, and it lies in their ideal:
#cas [member x, y, z] (x*z - y^2) [y - x^2, z - x^3]
a combination of the generators (checked)
x*z - y^2 = (-x^2 - y)*(y - x^2) + x*(z - x^3)- Domain
ℚ[x, y, z] as MvPolynomial (Fin 3) ℚ, with x = X 0, y = X 1, z = X 2- Input (polynomial and ideal)
x*z - y^2 and ⟨y - x^2, z - x^3⟩
Checked by Lean’s kernel: Membership in the ideal of the generators
X 0 * X 2 - X 1 ^ 2 ∈ Ideal.span {X 1 - X 0 ^ 2, X 2 - X 0 ^ 3}
The certificate: 1 checked step
Membership in the ideal of the generators
X 0 * X 2 - X 1 ^ 2 ∈ Ideal.span {X 1 - X 0 ^ 2, X 2 - X 0 ^ 3}
With one variable and one generator, membership is divisibility: the remainder of polynomialRemainder is , and the cofactor is the quotient:
#cas [member x] (x^3 - 1) [x - 1]
a combination of the generators (checked)
x^3 - 1 = (x^2 + x + 1)*(x - 1)- Domain
ℚ[x] as MvPolynomial (Fin 1) ℚ, with x = X 0- Input (polynomial and ideal)
x^3 - 1 and ⟨x - 1⟩
Checked by Lean’s kernel: Membership in the ideal of the generators
X 0 ^ 3 - 1 ∈ Ideal.span {X 0 - 1}
The certificate: 1 checked step
Membership in the ideal of the generators
X 0 ^ 3 - 1 ∈ Ideal.span {X 0 - 1}
Applications (4)
The first example as a theorem about Mathlib’s Ideal.span. Only the three standard axioms are used:
open MvPolynomial in theorem sq_sub_one_mem_span : (X 0 ^ 2 - 1 : MvPolynomial (Fin 2) ℚ) ∈ Ideal.span {X 0 * X 1 - 1, X 0 - X 1} := by cas #print axioms sq_sub_one_mem_span
sq_sub_one_mem_span depends on the axioms propext, Classical.choice, Quot.sound.
The tactic cas proves the same membership in the real numbers:
theorem sq_sub_one_mem_span_real (a b : ℝ) : a ^ 2 - 1 ∈ Ideal.span {a * b - 1, a - b} := by cas
Lean accepts the proof.
The cofactors and have integer coefficients, so the membership holds in ℤ as well, and this proof does not use Classical.choice:
theorem sq_sub_one_mem_span_int (a b : ℤ) : a ^ 2 - 1 ∈ Ideal.span {a * b - 1, a - b} := by cas #print axioms sq_sub_one_mem_span_int
sq_sub_one_mem_span_int depends on the axioms propext, Quot.sound.
The same cofactors prove that follows from and , with Mathlib’s linear_combination:
example (x y : ℝ) (h1 : x * y = 1) (h2 : x = y) : x ^ 2 = 1 := by linear_combination h1 + x * h2
Lean accepts the proof.
Properties and Relations (1)
The cofactors come from the division by the lexicographic Gröbner basis of the generators, here and (groebner):
#cas [groebner x, y] [x*y - 1, x - y]
Gröbner basis of the same ideal (checked)
x - y, y^2 - 1- Domain
ℚ[x, y] as MvPolynomial (Fin 2) ℚ, with x = X 0, y = X 1- Input (polynomials)
x*y - 1, x - y
Checked by Lean’s kernel: Ideal of the inputs
Ideal.span {X 0 * X 1 - 1, X 0 - X 1} = Ideal.span {X 0 - X 1, X 1 ^ 2 - 1}The certificate: 2 checked steps
Ideal of the inputs
Ideal.span {X 0 * X 1 - 1, X 0 - X 1} = Ideal.span {X 0 - X 1, X 1 ^ 2 - 1}Gröbner property of the basis
∀ p ∈ Ideal.span {X 0 - X 1, X 1 ^ 2 - 1}, p ≠ 0 → ∃ g ∈ {X 0 - X 1, X 1 ^ 2 - 1}, MonomialOrder.lex.leadingTerm g ∣ MonomialOrder.lex.leadingTerm p
The computation
Gröbner basis
the reduced basis for the lexicographic order x > y, each element scaled to coprime integer coefficients with a positive leading coefficient; computed by SymLean's Buchberger algorithm, 3 polynomials in the derivation, 2 in the basis
Possible Issues (2)
A polynomial with a nonzero remainder is refused. The refusal proves nothing about non-membership, although here is in fact outside the ideal:
#cas [member x, y] x [x^2, y]
Error
member: x is not shown to be in the ideal: its remainder modulo the computed lexicographic basis is x. The basis is not proved to be a Gröbner basis, so this proves nothing about non-membership
In ℤ, a certificate with denominators is refused. Over , , but for the membership is false in ℤ:
example (a : ℤ) : a ∈ Ideal.span {2 * a, a ^ 2} := by cas
Error
cas expected a checked semantic proposition, reflected equality, arithmetic relation, an ordinary inequality on real variables bounded by rational literal hypotheses (a two-sided bound `a ≤ f x ∧ f x ≤ b`, a membership `f x ∈ Set.Icc a b`, or a universally quantified bound), or the statement of a `#cas` command (a limit, a polynomial root count, a polynomial sign condition)
The rest of the message
Command theorem route: no `#cas` command states a goal of this shape Box enclosure route: cas box route: the goal has the head symbol `Membership.mem`; the route proves `f x ≤ c`, `f x < c`, `c ≤ f x`, `c < f x` (also with `≥` and `>`), `|f x| ≤ c`, `|f x| < c`, `a ≤ f x ∧ f x ≤ b` (also with `<`), `f x ∈ Set.Icc a b` (also `Set.Ioo`, `Set.Ico`, `Set.Ioc`), `f x ≤ g x`, `f x < g x`, and conjunctions of these, with `c`, `a`, `b` closed and every real variable bounded by hypotheses `a ≤ x` and `x ≤ b`, `x ∈ Set.Icc a b`, or `|x| ≤ r` with rational literal endpoints Registered route ideal: the certificate divides by 2, and ℤ is not a ℚ-algebra Grind fallback: `grind` failed (`set_option trace.cas.fallback true` shows its diagnostics)
Neat Examples (1)
The factor of , with its cofactor:
#cas [member x, y, z] (x^3 + y^3 + z^3 - 3*x*y*z) [x + y + z]
a combination of the generators (checked)
x^3 - 3*x*y*z + y^3 + z^3 = (x^2 - x*y - x*z + y^2 - y*z + z^2)*(x + y + z)- Domain
ℚ[x, y, z] as MvPolynomial (Fin 3) ℚ, with x = X 0, y = X 1, z = X 2- Input (polynomial and ideal)
x^3 + y^3 + z^3 - 3*x*y*z and ⟨x + y + z⟩
Checked by Lean’s kernel: Membership in the ideal of the generators
X 0 ^ 3 + X 1 ^ 3 + X 2 ^ 3 - 3 * X 0 * X 1 * X 2 ∈ Ideal.span {X 0 + X 1 + X 2}
The certificate: 1 checked step
Membership in the ideal of the generators
X 0 ^ 3 + X 1 ^ 3 + X 2 ^ 3 - 3 * X 0 * X 1 * X 2 ∈ Ideal.span {X 0 + X 1 + X 2}
See Also
groebner · cas · polynomialRemainder · oracle
