Zulip Chat Archive

Stream: new members

Topic: A .Lean file with no imports


Martin Epstein (Oct 25 2025 at 14:59):

In my file Queue.lean I put import Mathlib.Tactic at the top out of habit, but I don't think I actually use anything from this module. I tried deleting this statement so the file just begins with the definition "inductive Queue..." on line 1 but then Lean raised bizarre errors all over the place. I am confident the issue isnot that I really need Mathlib after all, but just that Lean expects some header code and I don't have any. What's the right way to handle this?

Aaron Liu (Oct 25 2025 at 15:00):

what's the errors

Aaron Liu (Oct 25 2025 at 15:00):

maybe it's the notation

Aaron Liu (Oct 25 2025 at 15:00):

can you give a #mwe

Martin Epstein (Oct 25 2025 at 15:26):

Oops, my attempt at a mwe didn't work.

def hello := "world"
#eval hello

compiles just fine. Here is a reduced version of Queue.lean:

-- import Mathlib.Tactic

inductive Queue (α : Type*) where
  | empty : Queue α
  | mk : α  List α  List α  Queue α

The first ) is flagged with "unexpected token ')'; expected term". The error goes away if I import Mathlib.Tactic. So I guess this definition relies on Mathlib after all.

I thought I didn't need Mathlib.Tactic because I have another much more sophisticated file (including new inductive definitions) that doesn't import it. However, that file does import Queue.lean so maybe it implicitly imports whatever Queue.lean imports.

Aaron Liu (Oct 25 2025 at 15:27):

you're missing import Mathlib.Tactic.TypeStar

Aaron Liu (Oct 25 2025 at 15:27):

file#Tactic/TypeStar

Martin Epstein (Oct 25 2025 at 15:37):

Aaron Liu said:

you're missing import Mathlib.Tactic.TypeStar

Ahh okay, that fixes most of the issues. Can you tell me which submodule l need in order to parse the blackboard bold N symbol as Nat?

Aaron Liu (Oct 25 2025 at 15:39):

that would be Mathlib.Data.Nat.Notation

Kenny Lau (Oct 25 2025 at 15:49):

@Martin Epstein finding notations is slightly less straightforward but it's actually still pretty straightforward, you search the symbol with quotation marks in Loogle, e.g. "Type*" and "termℕ" and then it will tell you where the notation is defined


Last updated: Dec 20 2025 at 21:32 UTC