Zulip Chat Archive

Stream: lean4

Topic: open `bar` in namespace `foo` when `foo.bar` exists


Kevin Buzzard (May 31 2023 at 18:17):

What's the trick to give me access to lemma2 within the foo namespace?

namespace foo

namespace bar

theorem lemma1 : 2+2=4 := rfl

end bar

end foo

namespace bar

theorem lemma2 : 3+3=6 := rfl

end bar

namespace foo

open bar

#check lemma1 -- fine
#check lemma2 -- not fine

open _root_.bar -- no

-- gaargh

end foo

In the real world example !4#4522 , foo := AlgebraicGeometry and bar := PrimeSpectrum. Is the only option to open bar before namespace foo?

Michael Stoll (May 31 2023 at 19:02):

That probably won't work when there is also bar.foo ...

Adam Topaz (May 31 2023 at 19:40):

The only way I could find to do this is the ridiculous

end foo open bar namespace foo open bar

instead of open bar on line 19 :-/

Adam Topaz (May 31 2023 at 19:43):

How common in this in practice?

Adam Topaz (May 31 2023 at 19:43):

Presumably it's not too common, and using bar.lemma2 would be reasonable?

James Gallicchio (May 31 2023 at 19:43):

I'm surprised open _root_.bar doesn't work. That might be a bug, since I think it is intended to work.

Mario Carneiro (May 31 2023 at 20:39):

open _root_.bar is a late lean 3 addition, it might need to be added to lean 4 as well

Kevin Buzzard (May 31 2023 at 20:56):

How common is this in practice?

If you look at the diff (autoporter v HEAD) in the PR I linked to you'll see that PrimeSpectrum.lemma2 is all over it :-( Somehow solving the problem now would mean that Jujian has to revert a bunch of changes but maybe in the long term that's ok ...


Last updated: Dec 20 2023 at 11:08 UTC