Zulip Chat Archive

Stream: lean4

Topic: mvt.lean:11:2 unknown identifier 'hgf' mvt.lean:11:6 unexpec


Lewis (Jul 01 2024 at 13:43):

How to correct:

import Mathlib.Analysis.Calculus.MeanValue
import Mathlib.Data.Real.Basic

open Set

theorem mean_value_theorem {a b : } (hab : a < b) {f :   }
  (hfc : ContinuousOn f (Icc a b)) (hfd : DifferentiableOn  f (Ioo a b)) :
   c  Ioo a b, deriv f c = (f b - f a) / (b - a) :=
let
  g := λ x  f x - (f b - f a) / (b - a) * x;
  hgf := ContinuousOn.sub hfc (ContinuousOn.mul continuousOn_const continuousOn_id);
  hgd := DifferentiableOn.sub hfd (DifferentiableOn.mul (differentiableOn_const _) differentiableOn_id);
  hga := rfl;
  hgb := rfl;
  hgab := by rw [hga, hgb]; field_simp [ne_of_lt hab]; ring;
  c, hc, hgc := exists_deriv_eq_zero hgf hgd hgab hab
in c, hc, by
  have h : deriv g c = 0 := hgc;
  rw [deriv_sub, deriv_const_mul_field, deriv_id] at h;
  field_simp [ne_of_lt hab] at h;
  rw sub_eq_zero at h;
  exact h

to fix the errors:

mvt.lean:11:2
unknown identifier 'hgf'
mvt.lean:11:6
unexpected token ':='; expected command

?

Thanks.

Kim Morrison (Jul 01 2024 at 13:50):

You need a separate let for each definition, I think??


Last updated: May 02 2025 at 03:31 UTC