Zulip Chat Archive

Stream: new members

Topic: unknown identifier 'h'


David Renshaw (Apr 20 2021 at 02:00):

I expect this to work:

section

variables (a b : ) (h : a < b)

lemma foo : a < b :=
begin
  exact h,
end

end

but I get:

error: unknown identifier 'h'

What's going wrong here? Am I not allowed to use variables like that?

Bryan Gin-ge Chen (Apr 20 2021 at 02:02):

Lean doesn't include hypotheses from variables unless they appear in the type. You can use include h to force Lean to include the variable in all following declarations.

David Renshaw (Apr 20 2021 at 02:02):

aha! Thanks.

Bryan Gin-ge Chen (Apr 20 2021 at 02:03):

This is discussed briefly about halfway through TPiL 5.1.

David Renshaw (Apr 20 2021 at 02:03):

Yep, I remember reading that a while ago, but I apparently didn't retain it.

Alex Zhang (May 31 2021 at 13:34):

In my case, why does Lean give me the error message unknown identifier 'h' and unknown identifier 'g'?

import data.nat.prime
open nat

-- BEGIN
example {m n : } (h : m  n  m  n) :
  m  n  ¬ n  m :=
 h.1,  λ g, by absurd (dvd_antisymm (h.1) g) h.2 
-- END

Sebastien Gouezel (May 31 2021 at 13:43):

You should remove the by, since absurd is a lemma you are applying, not a tactic.

Alex Zhang (May 31 2021 at 13:44):

I didn't notice that before. Thanks a lot!!


Last updated: Dec 20 2023 at 11:08 UTC