Zulip Chat Archive

Stream: new members

Topic: Is there a way to quickly check the definition?


jsodd (Aug 26 2024 at 05:46):

Is there a quick way of checking how, say, an inner product is defined? Here's an example: I want to see what these two definitions expand to without going to the documentation:

import Mathlib
variable {x y : EuclideanSpace  n}
#check x, y⟫_
#check x, y⟫_

Yaël Dillies (Aug 26 2024 at 05:48):

If you guess how they are defined, you can do

lemma foo : x, y⟫_ =  _  _, _ := rfl
#check foo

jsodd (Aug 26 2024 at 05:50):

Well, if I could always guess the definitions, I probably wouldn't need this :smile:

Yaël Dillies (Aug 26 2024 at 05:52):

My point is that you only need to know what the outermost symbol is (eg the above works for both ⟪x, y⟫_ℂ := ∑ i, conj (x i) * y i and ⟪x, y⟫_ℂ := ∑ i, x i * conj (y i) . In this specific case, since there is no notation typeclass you can just Go to definition by eg Ctrl+click

jsodd (Aug 26 2024 at 06:00):

Well, even the outermost symbol depends on the way things are implemented in mathlib, which I don't expect to be in perfect correspondence to how I think about them. And trying out several choices quickly gets slower than looking for the definition in the docs.

jsodd (Aug 26 2024 at 06:01):

By the way, your code doesn't work for me, maybe I forgot to open something...

Yaël Dillies (Aug 26 2024 at 06:02):

I mean, I would usually just look in the docs, but you asked for a doc-less way :shrug:

jsodd (Aug 26 2024 at 06:03):

I honestly thought there would be something like #eval# or #print for this...

Sebastian Ullrich (Aug 26 2024 at 06:12):

What's wrong with the mentioned Go to definition?

jsodd (Aug 26 2024 at 06:16):

If you click on Go to definition (on the brackets or on what?), lean first sends you to the definition of inner product notation, then to the general inner products and so on. There seems to be no easy way to see the exact way it is defined in the current context

jsodd (Aug 26 2024 at 06:19):

You can go to the definition of EuclideanSpace instead and then go through the definitions of PiLp and WithLp just to find how the inner product is defined

jsodd (Aug 26 2024 at 06:20):

Seems to be too much for a thing that simple

Daniel Weber (Aug 26 2024 at 06:22):

#reduce ⟪x, y⟫_ℝ
shows the definition, but at a very low level

Daniel Weber (Aug 26 2024 at 06:22):

#whnf ⟪x, y⟫_ℝ, perhaps?

Sebastian Ullrich (Aug 26 2024 at 06:23):

A new command would have to make the exact same decisions of what to unfold and what not, there is no straightforward answer here. The one tool other than unfolding nothing we have is to unfold everything, which is #reduce as just mentioned

jsodd (Aug 26 2024 at 06:23):

Let's say I've redefined it for myself somewhere, but don't remember where. I'd like to be able to quickly check

Daniel Weber (Aug 26 2024 at 06:23):

import Mathlib
variable {n : Type*} [Fintype n] {x y : EuclideanSpace  n}
#simp => x, y⟫_

works in here, but that's only thanks to the simp lemma docs#PiLp.inner_apply

jsodd (Aug 26 2024 at 06:25):

Sebastian Ullrich said:

A new command would have to make the exact same decisions of what to unfold and what not, there is no straightforward answer here. The one tool other than unfolding nothing we have is to unfold everything, which is #reduce as just mentioned

Maybe some command which would allow me to manually unfold it? Just without guessing names of what must be unfolded


Last updated: May 02 2025 at 03:31 UTC