Polynomial #
An extensible tactic for proving equality of polynomial expressions implemented using algebra.
To add support for a new polynomial-like type, one needs to do three things:
- Implement a polynomial extension that lets
polynomialinfer the base ring from the algebraic type. For example:
@[polynomial_infer_base]
def polynomialInferBase : PolynomialExt where
infer e := do
match_expr e with
| Polynomial R _ => pure R
| _ => failure
- Tag any preprocessing lemmas with @[polynomial_pre]. This would include a lemma saying that
C = algebraMap _ _so thatalgebraknows how to normalize it. - Tag any postprocessing lemmas with @[polynomial_post], so that
polynomial_nfproduces a pretty expression.
Infer base ring for Polynomial R
Equations
- One or more equations did not get rendered due to their size.
Instances For
Run the polynomial_pre simpset to turn nonstandard spellings of algebraMap such as
Polynomial.C into algebraMap
Equations
- One or more equations did not get rendered due to their size.
Instances For
polynomial solves equalities of Polynomials and similar types.
Given a goal which is an equality in Polynomial R with a commutative ring R, polynomial
turns both sides of the equation into a normal form by expanding out the brackets. It then closes
the goal if both sides contain the same terms and fails otherwise. polynomial_nf normalizes all
subexpressions at a given location.
Variants of polynomial include:
polynomial: normalize both sides of an equation and close the goal if they are equalpolynomial!: runpolynomialat default transparencypolynomial_nf: normalize all subexpression of the goalpolynomial_nf at h₁ h₂ ⊢: normalize all subexpressions at hypothesesh₁h₁and the goalpolynomial_nf at *: normalize all subexpressions of all local hypotheses and the goalpolynomial_nf!: runpolynomial_nfat default transparency
The polynomial tactic can be extended to work with algebras other than Polynomial using the
attributes polynomial_infer_base, polynomial_pre and polynomial_post. This is only possible
if the base ring can be inferred from the structure of the type.
Examples:
example (a : ℚ) : (X + C a) * (X - C a) = X^2 + C (a^2) := by polynomial
example {P : ℚ[X] → Prop} (h : P (X ^ 2 + X + C 4⁻¹)) : P ((X + C 2⁻¹) ^ 2) := by
polynomial_nf at h ⊢
exact h
Equations
- One or more equations did not get rendered due to their size.
Instances For
polynomial solves equalities of Polynomials and similar types.
Given a goal which is an equality in Polynomial R with a commutative ring R, polynomial
turns both sides of the equation into a normal form by expanding out the brackets. It then closes
the goal if both sides contain the same terms and fails otherwise. polynomial_nf normalizes all
subexpressions at a given location.
Variants of polynomial include:
polynomial: normalize both sides of an equation and close the goal if they are equalpolynomial!: runpolynomialat default transparencypolynomial_nf: normalize all subexpression of the goalpolynomial_nf at h₁ h₂ ⊢: normalize all subexpressions at hypothesesh₁h₁and the goalpolynomial_nf at *: normalize all subexpressions of all local hypotheses and the goalpolynomial_nf!: runpolynomial_nfat default transparency
The polynomial tactic can be extended to work with algebras other than Polynomial using the
attributes polynomial_infer_base, polynomial_pre and polynomial_post. This is only possible
if the base ring can be inferred from the structure of the type.
Examples:
example (a : ℚ) : (X + C a) * (X - C a) = X^2 + C (a^2) := by polynomial
example {P : ℚ[X] → Prop} (h : P (X ^ 2 + X + C 4⁻¹)) : P ((X + C 2⁻¹) ^ 2) := by
polynomial_nf at h ⊢
exact h
Equations
- Mathlib.Tactic.Polynomial.tacticPolynomial! = Lean.ParserDescr.node `Mathlib.Tactic.Polynomial.tacticPolynomial! 1024 (Lean.ParserDescr.nonReservedSymbol "polynomial!" false)
Instances For
A cleanup routine, which simplifies normalized expressions to a more human-friendly format.
This is the algebra_nf cleanup routine with a little extra work to turn scalar multiplication
into (MV)Polynomial.C
Equations
- One or more equations did not get rendered due to their size.
Instances For
Normalize a polynomial expression into standard form. Used by polynomial_nf.
Equations
- One or more equations did not get rendered due to their size.
Instances For
polynomial solves equalities of Polynomials and similar types.
Given a goal which is an equality in Polynomial R with a commutative ring R, polynomial
turns both sides of the equation into a normal form by expanding out the brackets. It then closes
the goal if both sides contain the same terms and fails otherwise. polynomial_nf normalizes all
subexpressions at a given location.
Variants of polynomial include:
polynomial: normalize both sides of an equation and close the goal if they are equalpolynomial!: runpolynomialat default transparencypolynomial_nf: normalize all subexpression of the goalpolynomial_nf at h₁ h₂ ⊢: normalize all subexpressions at hypothesesh₁h₁and the goalpolynomial_nf at *: normalize all subexpressions of all local hypotheses and the goalpolynomial_nf!: runpolynomial_nfat default transparency
The polynomial tactic can be extended to work with algebras other than Polynomial using the
attributes polynomial_infer_base, polynomial_pre and polynomial_post. This is only possible
if the base ring can be inferred from the structure of the type.
Examples:
example (a : ℚ) : (X + C a) * (X - C a) = X^2 + C (a^2) := by polynomial
example {P : ℚ[X] → Prop} (h : P (X ^ 2 + X + C 4⁻¹)) : P ((X + C 2⁻¹) ^ 2) := by
polynomial_nf at h ⊢
exact h
Equations
- One or more equations did not get rendered due to their size.
Instances For
polynomial solves equalities of Polynomials and similar types.
Given a goal which is an equality in Polynomial R with a commutative ring R, polynomial
turns both sides of the equation into a normal form by expanding out the brackets. It then closes
the goal if both sides contain the same terms and fails otherwise. polynomial_nf normalizes all
subexpressions at a given location.
Variants of polynomial include:
polynomial: normalize both sides of an equation and close the goal if they are equalpolynomial!: runpolynomialat default transparencypolynomial_nf: normalize all subexpression of the goalpolynomial_nf at h₁ h₂ ⊢: normalize all subexpressions at hypothesesh₁h₁and the goalpolynomial_nf at *: normalize all subexpressions of all local hypotheses and the goalpolynomial_nf!: runpolynomial_nfat default transparency
The polynomial tactic can be extended to work with algebras other than Polynomial using the
attributes polynomial_infer_base, polynomial_pre and polynomial_post. This is only possible
if the base ring can be inferred from the structure of the type.
Examples:
example (a : ℚ) : (X + C a) * (X - C a) = X^2 + C (a^2) := by polynomial
example {P : ℚ[X] → Prop} (h : P (X ^ 2 + X + C 4⁻¹)) : P ((X + C 2⁻¹) ^ 2) := by
polynomial_nf at h ⊢
exact h
Equations
- One or more equations did not get rendered due to their size.