Skip to content

Commit

Permalink
feat(data/polynomial/eval): generalize smul lemmas (#13479)
Browse files Browse the repository at this point in the history
  • Loading branch information
negiizhao committed Apr 16, 2022
1 parent 010f09e commit 874dde5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/data/polynomial/eval.lean
Expand Up @@ -306,9 +306,10 @@ eval₂_monomial _ _

@[simp] lemma eval_bit1 : (bit1 p).eval x = bit1 (p.eval x) := eval₂_bit1 _ _

@[simp] lemma eval_smul (p : R[X]) (x : R) {s : R} :
(s • p).eval x = s * p.eval x :=
eval₂_smul (ring_hom.id _) _ _
@[simp] lemma eval_smul [monoid S] [distrib_mul_action S R] [is_scalar_tower S R R]
(s : S) (p : R[X]) (x : R) :
(s • p).eval x = s • p.eval x :=
by rw [← smul_one_smul R s p, eval, eval₂_smul, ring_hom.id_apply, smul_one_mul]

@[simp] lemma eval_C_mul : (C a * p).eval x = a * p.eval x :=
begin
Expand All @@ -323,7 +324,7 @@ end
@[simps] def leval {R : Type*} [semiring R] (r : R) : R[X] →ₗ[R] R :=
{ to_fun := λ f, f.eval r,
map_add' := λ f g, eval_add,
map_smul' := λ c f, eval_smul f r }
map_smul' := λ c f, eval_smul c f r }

@[simp] lemma eval_nat_cast_mul {n : ℕ} : ((n : R[X]) * p).eval x = n * p.eval x :=
by rw [←C_eq_nat_cast, eval_C_mul]
Expand Down Expand Up @@ -469,6 +470,10 @@ by simp only [bit0, add_comp]
@[simp] lemma bit1_comp : comp (bit1 p : R[X]) q = bit1 (p.comp q) :=
by simp only [bit1, add_comp, bit0_comp, one_comp]

@[simp] lemma smul_comp [monoid S] [distrib_mul_action S R] [is_scalar_tower S R R]
(s : S) (p q : R[X]) : (s • p).comp q = s • p.comp q :=
by rw [← smul_one_smul R s p, comp, comp, eval₂_smul, ← smul_eq_C_mul, smul_assoc, one_smul]

lemma comp_assoc {R : Type*} [comm_semiring R] (φ ψ χ : R[X]) :
(φ.comp ψ).comp χ = φ.comp (ψ.comp χ) :=
begin
Expand Down
2 changes: 1 addition & 1 deletion src/topology/continuous_function/polynomial.lean
Expand Up @@ -153,7 +153,7 @@ begin
simp only [neg_mul,
ring_hom.map_neg, ring_hom.map_mul, alg_hom.coe_to_ring_hom,
polynomial.eval_X, polynomial.eval_neg, polynomial.eval_C, polynomial.eval_smul,
polynomial.eval_mul, polynomial.eval_add, polynomial.coe_aeval_eq_eval,
smul_eq_mul, polynomial.eval_mul, polynomial.eval_add, polynomial.coe_aeval_eq_eval,
polynomial.eval_comp, polynomial.to_continuous_map_on_alg_hom_apply,
polynomial.to_continuous_map_on_to_fun, polynomial.to_continuous_map_to_fun],
convert w ⟨_, _⟩; clear w,
Expand Down

0 comments on commit 874dde5

Please sign in to comment.