Zulip Chat Archive
Stream: general
Topic: Definition of ℕ (nat)
Julin S (Oct 24 2025 at 18:51):
Hi.
Where is the nat type defined in lean4?
I couldn't spot it in
https://github.com/leanprover/lean4/blob/master/src/Init/Data/Nat/Basic.lean
Is it compiled in or something?
I am a newbie in lean.
Christian Merten (Oct 24 2025 at 18:54):
If you search on https://leanprover-community.github.io/mathlib4_docs for Nat, you will get to docs#Nat. If you then click on source on the top right, you get here: https://github.com/leanprover/lean4/blob/744f98064b056ee27fc8c97f524797c8cc96f436/src/Init/Prelude.lean#L1185-L1206.
Kenny Lau (Oct 24 2025 at 18:54):
@Julin S there are two ways to find out,
- if you have lean installed, you can do
#check Nat, and when you right click theNatin your code, you'll have an option that says "go to definiton", which will bring you to the file - or, you can search
Naton loogle, which will bring you to the docs
(btw #new members is usually where newbies ask questions)
Julin S (Oct 24 2025 at 18:56):
Thanks!
Got it: https://github.com/leanprover/lean4/blob/744f98064b056ee27fc8c97f524797c8cc96f436/src/Init/Prelude.lean#L1192
Julin S (Oct 24 2025 at 18:56):
Sorry had forgotten that newbies channel existed.
Julin S (Oct 24 2025 at 18:56):
I don't have an lsp set up yet. I guess the 'go to definition' would need that.
Julin S (Oct 24 2025 at 18:57):
I'm on nvim.
Kenny Lau (Oct 24 2025 at 19:02):
Julin S said:
I don't have an lsp set up yet. I guess the 'go to definition' would need that.
no, 'go to definition' just searches within your lean, no internet required
Andrew Yang (Oct 24 2025 at 19:10):
LSP means (part of the) lean vscode (or whatever your editor is) plugin and you will need that for go to definition to work.
Patrick Massot (Oct 24 2025 at 20:24):
LSP has nothing to do with VSCode and work in nvim
Patrick Massot (Oct 24 2025 at 20:25):
Julin, you need to install lean.nvim.
Snir Broshi (Oct 24 2025 at 22:34):
Patrick Massot said:
LSP has nothing to do with VSCode and work in nvim
LSP was invented by the VSCode team, so while nvim does support LSP the claim "LSP has nothing to do with VSCode" is false.
Patrick Massot (Oct 24 2025 at 22:52):
I almost wrote “except if you do history of software engineering”, but decided it was too much noise.
Last updated: Dec 20 2025 at 21:32 UTC