Zulip Chat Archive
Stream: new members
Topic: Importing Packages using Web-version of Lean
Mark Santa Clara Munro (Jun 20 2024 at 15:13):
When I tried to copy this from the book "Mathematics in Lean", it did not work, which makes sense because their next sentence is: "The import lines at the beginning of the associated examples file import the theory of the real numbers from Mathlib, as well as useful automation. For the sake of brevity, we generally suppress information like this in the textbook."
So, how do I know what to import and use in general and on that example?
Shreyas Srinivas (Jun 20 2024 at 15:43):
There's a lot that's wrong here. For starters, please copy and paste these code into a multi-line code block like below and paste it in the chat.
```
your code here
```
Shreyas Srinivas (Jun 20 2024 at 15:44):
This should give you what we call an #mwe and make it easier to help you
Mark Santa Clara Munro (Jun 20 2024 at 15:47):
import Webeditor.Tools
import Mathlib
example (a b c : R) : a * b * c = b * (a * c) := by
rw [mul_comm a b]
rw [mul_assoc b a c]
Ruben Van de Velde (Jun 20 2024 at 15:52):
As far as I can tell, the MIL code block has ℝ (as in, the real numbers), not R
Mark Santa Clara Munro (Jun 20 2024 at 16:15):
I didn't realize thank you so much
Mark Santa Clara Munro (Jun 20 2024 at 16:16):
In general, though, do I need to import everything or is what imported good enough?
Shreyas Srinivas (Jun 20 2024 at 16:50):
You don't need WebEditor.Tools 9/10 times
Shreyas Srinivas (Jun 20 2024 at 16:52):
and this works:
import Mathlib
example (a b c : ℝ) : a * b * c = b * (a * c) := by
rw [mul_comm a b, mul_assoc b a c]
Although the indentation is not strictly necessary, I'd recommend having it for code organisation
Mark Santa Clara Munro (Jun 20 2024 at 23:44):
Thank you!
Last updated: May 02 2025 at 03:31 UTC