最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin5浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论