Others have already explained why intro
does not apply here.
One thing you should watch out for here is that you're missing the hypotheses that the functions h
and g
are differentiable. Here's a quickly-written proof of the corrected theorem, which I give here because with the way deriv_add
and deriv_const_smul
are formulated it's a bit of a fight with Lean to finish it up:
import analysis.calculus.deriv
noncomputable def D : (ℝ → ℝ) → (ℝ → ℝ) := λ f, deriv f
lemma D_lin (h g : ℝ → ℝ) (hd : differentiable ℝ h) (gd : differentiable ℝ g)
(a : ℝ) : D (a • h + g) = a • D h + D g :=
begin
unfold D,
ext x,
transitivity deriv (a • h) x + deriv g x,
{ apply deriv_add,
exact differentiable_at.const_mul (hd x) _,
exact gd x, },
{ rw [pi.add_apply, add_left_inj],
exact deriv_const_smul _ (hd x), },
end
Design-wise, this is not the "right" linearity lemma to prove since it's not very easy to apply. Instead, consider having two lemmas so that you can apply it to any expression involving addition and scalar multiplication:
lemma D_add (h g : ℝ → ℝ) (hd : differentiable ℝ h) (gd : differentiable ℝ g) :
D (h + g) = D h + D g :=
begin
ext x,
exact deriv_add (hd x) (gd x),
end
lemma D_smul (h : ℝ → ℝ) (hd : differentiable ℝ h) (a : ℝ) :
D (a • h) = a • D h :=
begin
ext x,
exact deriv_const_smul _ (hd x),
end
With these, one proof of D_lin
is then rw [D_add, D_smul], assumption, apply differentiable.const_mul, assumption, assumption
. (It'd be nice if there were some automation for these differentiability side-goals!)
As a bonus, here's that D
is a derivation:
lemma D_mul (h g : ℝ → ℝ) (hd : differentiable ℝ h) (gd : differentiable ℝ g) :
D (h * g) = D h * g + h * D g :=
begin
ext x,
exact deriv_mul (hd x) (gd x),
end