ring
#
Evaluate expressions in the language of commutative (semi)rings. Based on http://www.cs.ru.nl/~freek/courses/tt-2014/read/10.1.1.61.3041.pdf .
The normal form that ring
uses is mediated by the function horner a x n b := a * x ^ n + b
.
The reason we use a definition rather than the (more readable) expression on the right is because
this expression contains a number of typeclass arguments in different positions, while horner
contains only one comm_semiring
instance at the top level. See also horner_expr
for a
description of normal form.
Equations
- tactic.ring.horner a x n b = a * x ^ n + b
theorem
tactic.ring.zero_horner
{α : Type u_1}
[comm_semiring α]
(x : α)
(n : ℕ)
(b : α) :
tactic.ring.horner 0 x n b = b
theorem
tactic.ring.horner_horner
{α : Type u_1}
[comm_semiring α]
(a₁ x : α)
(n₁ n₂ : ℕ)
(b : α)
(n' : ℕ)
(h : n₁ + n₂ = n') :
tactic.ring.horner (tactic.ring.horner a₁ x n₁ 0) x n₂ b = tactic.ring.horner a₁ x n' b
theorem
tactic.ring.const_add_horner
{α : Type u_1}
[comm_semiring α]
(k a x : α)
(n : ℕ)
(b b' : α)
(h : k + b = b') :
k + tactic.ring.horner a x n b = tactic.ring.horner a x n b'
theorem
tactic.ring.horner_add_const
{α : Type u_1}
[comm_semiring α]
(a x : α)
(n : ℕ)
(b k b' : α)
(h : b + k = b') :
tactic.ring.horner a x n b + k = tactic.ring.horner a x n b'
theorem
tactic.ring.horner_add_horner_lt
{α : Type u_1}
[comm_semiring α]
(a₁ x : α)
(n₁ : ℕ)
(b₁ a₂ : α)
(n₂ : ℕ)
(b₂ : α)
(k : ℕ)
(a' b' : α)
(h₁ : n₁ + k = n₂)
(h₂ : a₁ + tactic.ring.horner a₂ x k 0 = a')
(h₃ : b₁ + b₂ = b') :
tactic.ring.horner a₁ x n₁ b₁ + tactic.ring.horner a₂ x n₂ b₂ = tactic.ring.horner a' x n₁ b'
theorem
tactic.ring.horner_add_horner_gt
{α : Type u_1}
[comm_semiring α]
(a₁ x : α)
(n₁ : ℕ)
(b₁ a₂ : α)
(n₂ : ℕ)
(b₂ : α)
(k : ℕ)
(a' b' : α)
(h₁ : n₂ + k = n₁)
(h₂ : tactic.ring.horner a₁ x k 0 + a₂ = a')
(h₃ : b₁ + b₂ = b') :
tactic.ring.horner a₁ x n₁ b₁ + tactic.ring.horner a₂ x n₂ b₂ = tactic.ring.horner a' x n₂ b'
theorem
tactic.ring.horner_add_horner_eq
{α : Type u_1}
[comm_semiring α]
(a₁ x : α)
(n : ℕ)
(b₁ a₂ b₂ a' b' t : α)
(h₁ : a₁ + a₂ = a')
(h₂ : b₁ + b₂ = b')
(h₃ : tactic.ring.horner a' x n b' = t) :
tactic.ring.horner a₁ x n b₁ + tactic.ring.horner a₂ x n b₂ = t
theorem
tactic.ring.horner_neg
{α : Type u_1}
[comm_ring α]
(a x : α)
(n : ℕ)
(b a' b' : α)
(h₁ : -a = a')
(h₂ : -b = b') :
-tactic.ring.horner a x n b = tactic.ring.horner a' x n b'
theorem
tactic.ring.horner_const_mul
{α : Type u_1}
[comm_semiring α]
(c a x : α)
(n : ℕ)
(b a' b' : α)
(h₁ : c * a = a')
(h₂ : c * b = b') :
c * tactic.ring.horner a x n b = tactic.ring.horner a' x n b'
theorem
tactic.ring.horner_mul_const
{α : Type u_1}
[comm_semiring α]
(a x : α)
(n : ℕ)
(b c a' b' : α)
(h₁ : a * c = a')
(h₂ : b * c = b') :
(tactic.ring.horner a x n b) * c = tactic.ring.horner a' x n b'
theorem
tactic.ring.horner_mul_horner_zero
{α : Type u_1}
[comm_semiring α]
(a₁ x : α)
(n₁ : ℕ)
(b₁ a₂ : α)
(n₂ : ℕ)
(aa t : α)
(h₁ : (tactic.ring.horner a₁ x n₁ b₁) * a₂ = aa)
(h₂ : tactic.ring.horner aa x n₂ 0 = t) :
(tactic.ring.horner a₁ x n₁ b₁) * tactic.ring.horner a₂ x n₂ 0 = t
theorem
tactic.ring.horner_mul_horner
{α : Type u_1}
[comm_semiring α]
(a₁ x : α)
(n₁ : ℕ)
(b₁ a₂ : α)
(n₂ : ℕ)
(b₂ aa haa ab bb t : α)
(h₁ : (tactic.ring.horner a₁ x n₁ b₁) * a₂ = aa)
(h₂ : tactic.ring.horner aa x n₂ 0 = haa)
(h₃ : a₁ * b₂ = ab)
(h₄ : b₁ * b₂ = bb)
(H : haa + tactic.ring.horner ab x n₁ bb = t) :
(tactic.ring.horner a₁ x n₁ b₁) * tactic.ring.horner a₂ x n₂ b₂ = t
theorem
tactic.ring.horner_pow
{α : Type u_1}
[comm_semiring α]
(a x : α)
(n m n' : ℕ)
(a' : α)
(h₁ : n * m = n')
(h₂ : a ^ m = a') :
tactic.ring.horner a x n 0 ^ m = tactic.ring.horner a' x n' 0
theorem
tactic.ring.horner_atom
{α : Type u_1}
[comm_semiring α]
(x : α) :
x = tactic.ring.horner 1 x 1 0
theorem
tactic.ring.horner_def'
{α : Type u_1}
[comm_semiring α]
(a x : α)
(n : ℕ)
(b : α) :
tactic.ring.horner a x n b = (x ^ n) * a + b
- raw : tactic.ring.normalize_mode
- SOP : tactic.ring.normalize_mode
- horner : tactic.ring.normalize_mode
If ring
fails to close the goal, it falls back on normalizing the expression to a "pretty"
form so that you can see why it failed. This setting adjusts the resulting form:
raw
is the form thatring
actually uses internally, with iterated applications ofhorner
. Not very readable but useful if you don't want any postprocessing. This results in terms likehorner (horner (horner 3 y 1 0) x 2 1) x 1 (horner 1 y 1 0)
.horner
maintains the Horner form structure, but it unfolds thehorner
definition itself, and tries to otherwise minimize parentheses. This results in terms like(3 * x ^ 2 * y + 1) * x + y
.SOP
means sum of products form, expanding everything to monomials. This results in terms like3 * x ^ 3 * y + x + y
.
@[protected, instance]
@[protected, instance]