compiler errors - How to resolve namespace conflict in Lean4 - Stack Overflow

In lean4 I cannot rename imported files, which makes me confused on how to resolve name conflicts.Supp

In lean4 I cannot rename imported files, which makes me confused on how to resolve name conflicts.

Suppose I have two files named A and B, each has a namespace inner and a f,

—- A
namespace inner
def f := 1

—- B
namespace inner
def f := 2

then in file C, if I import A and B, the compiler report error that name inner environment already contains inner.f.

import Lab.A
import Lab.B —- error environment already contains inner.f

Some files may be included from external libs so I cannot rely on renaming original file by hand.

How could I fix namespace problems like this? Also in lean4, do we have any thing like Haskell’s qualified import?

In lean4 I cannot rename imported files, which makes me confused on how to resolve name conflicts.

Suppose I have two files named A and B, each has a namespace inner and a f,

—- A
namespace inner
def f := 1

—- B
namespace inner
def f := 2

then in file C, if I import A and B, the compiler report error that name inner environment already contains inner.f.

import Lab.A
import Lab.B —- error environment already contains inner.f

Some files may be included from external libs so I cannot rely on renaming original file by hand.

How could I fix namespace problems like this? Also in lean4, do we have any thing like Haskell’s qualified import?

Share Improve this question edited Mar 11 at 11:34 Ireina asked Mar 11 at 10:43 IreinaIreina 3862 silver badges10 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I cannot reproduce on Mathlib (which was the Lean project I happened to have open when I read your question)

buzzard@brutus:~/mathlib/Mathlib$ cat > A.lean
namespace inner
buzzard@brutus:~/mathlib/Mathlib$ cat > B.lean
namespace inner
buzzard@brutus:~/mathlib/Mathlib$ cat > C.lean
import Mathlib.A
import Mathlib.B

I can open C.lean without any errors. Indeed this pattern is commonplace in mathlib. Are you sure you've diagnosed your problem correctly?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744800505a4594461.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信