Zulip Chat Archive

Stream: general

Topic: replace goal with definition


Leonard Wiechmann (Nov 18 2021 at 14:09):

This is something I run into again and again:
Given a goal of some "non-trivial" form (eg: A <= B for A B : set α),
how do I make lean tell me what the goal means?

as in: how to replace the goal with its definition without knowing what the definition is?
I've tried all kinds of rws/applys, but can't seem to figure out what <= is supposed to mean. Lean surely knows. How do I make it tell me? The very useful go to definition feature only shows me the definition of class has_le, not the instance.

Yaël Dillies (Nov 18 2021 at 14:12):

You can inspect in the goal in the infoview what has_le instance it is.

Johan Commelin (Nov 18 2021 at 14:12):

@Leonard Wiechmann In the case of notation, this can be a bit tricky. But if you have foo x y z, then you can do unfold foo to unfold the definition.

Johan Commelin (Nov 18 2021 at 14:13):

With notation, you can use widgets in the infoview, like Yaël says, if you are using VSCode.

Johan Commelin (Nov 18 2021 at 14:13):

Just click on the and drill down the popup windows. The popup windows also have buttons that allow you to "go to definition".

Leonard Wiechmann (Nov 18 2021 at 14:14):

I'm not quite sure what it's trying to tell me :thinking:
image.png

Yaël Dillies (Nov 18 2021 at 14:14):

Click on preorder.to_has_le. That's the next step.

Leonard Wiechmann (Nov 18 2021 at 14:16):

oh boy
image.png

Leonard Wiechmann (Nov 18 2021 at 14:17):

unfold got rid of the notation, but I still don't have a "useful" goal:
image.png

Johan Commelin (Nov 18 2021 at 14:17):

That was a wrong turn :wink: In the second box, click on the third subitem

Johan Commelin (Nov 18 2021 at 14:18):

Leonard Wiechmann said:

I've tried all kinds of intros/rws/applys, but can't seem to figure out what <= is supposed to mean.

Did you try intros x hx?

Leonard Wiechmann (Nov 18 2021 at 14:19):

yep. I can only introduce one thing. (A : set \a)

Alex J. Best (Nov 18 2021 at 14:20):

You can also do this with simp

example {T R : set } : T  R :=
begin
  simp [()],
  simp [()],
  simp [set.subset],
end

Reid Barton (Nov 18 2021 at 14:20):

The <= is whatever partial instance your function takes!

Reid Barton (Nov 18 2021 at 14:20):

You should just delete that

Leonard Wiechmann (Nov 18 2021 at 14:21):

Alex J. Best said:

You can also do this with simp

that's very useful, thanks!

Leonard Wiechmann (Nov 18 2021 at 14:23):

Reid Barton said:

The <= is whatever partial instance your function takes!

I had a feeling, that was the issue.
But without it, I'm having trouble getting is_smallest to choose the right partial order.
image.png

Reid Barton (Nov 18 2021 at 14:24):

that's because Lean has no idea what you mean

Leonard Wiechmann (Nov 18 2021 at 14:24):

yeah, I'm just giving it a function. It can't really know what I mean. So I have to tell it somehow.

Reid Barton (Nov 18 2021 at 14:24):

You should help it by giving a type annotation (and help us by copying and pasting text not screenshots)

Leonard Wiechmann (Nov 18 2021 at 14:25):

sorry, I wanted to include the error messages

def is_smallest {α : Type} [partial_order α] (a : α): Prop :=
   x, a <= x

lemma powerset_empty_smallest {α : Type}
  : is_smallest (λ x, false) := sorry

Reid Barton (Nov 18 2021 at 14:25):

The normal way to write the argument of is_smallest is (∅ : set α)

Leonard Wiechmann (Nov 18 2021 at 14:27):

Reid Barton said:

The normal way to write the argument of is_smallest is (∅ : set α)

oooooh, that's what emptyc is for!
ok, is_smallest (∅ : set α) isn't giving me an error so far.
let's see if I can make the proof work.
thanks!

Leonard Wiechmann (Nov 18 2021 at 14:35):

ok, got it working! all of that notation is nice to look at, but really obfuscates what the hypotheses and the goal actually mean.
thanks everyone!

Kevin Buzzard (Nov 18 2021 at 15:29):

The reason that using "canonical" notation is important, is that this is what all the simp lemmas are designed to use, and simp works up to syntactic equality so it matters.

Mario Carneiro (Nov 18 2021 at 22:44):

Leonard Wiechmann said:

sorry, I wanted to include the error messages

The usual way I include error messages in code snippets is to put them in comments immediately after the failing command


Last updated: Dec 20 2023 at 11:08 UTC