Zulip Chat Archive
Stream: lean4
Topic: Confusion about matching on exists
Anna Williams (Oct 08 2025 at 15:28):
Sometimes I can match on exists and sometimes I cannot, resulting in an error "Case tag 'rhs' not found.", I'm a bit confused as to how and when this occurs.
Is there some way I can get the witness of the exists in this instance?
Kenny Lau (Oct 08 2025 at 15:29):
i don't know what the error means because you didn't provide an #mwe , but you can't eliminate from Prop into data, so there is no way to get the witness computably from an exists
Aaron Liu (Oct 08 2025 at 15:30):
that's weird
Kenny Lau (Oct 08 2025 at 15:30):
there are ways around this, but i'm refraining from saying them, because usually it means you're in the wrong situation and "eliminating prop into data" is not the right step to take in this instance
Aaron Liu (Oct 08 2025 at 15:30):
consider using docs#Exists.choose instead
Kenny Lau (Oct 08 2025 at 15:30):
that's the workaround i was deliberately omitting
Aaron Liu (Oct 08 2025 at 15:31):
your theorem lubUnique probably does not mean what you think it does
Aaron Liu (Oct 08 2025 at 15:31):
Lean has proof irrelevance so any two proofs of the same thing are automatically equal
Kenny Lau (Oct 08 2025 at 15:31):
oh yeah, that too
Anna Williams (Oct 08 2025 at 16:03):
When you say "proof irrelevance" do you mean that the entire thing is forgotten or that just the proof corresponding to one witness is forgotten? I think this is where I'm getting confused
Anna Williams (Oct 08 2025 at 16:06):
I've tried using Σ'which I know keeps the data, but then I run into problems with certain structures being Types instead of Props
Kenny Lau (Oct 08 2025 at 16:08):
the problem is that you're trying to translate some natural language directly into symbol without considering the logic behind
Anna Williams (Oct 08 2025 at 16:12):
I don't think that's very helpful?
Aaron Liu (Oct 08 2025 at 17:01):
Anna Williams said:
When you say "proof irrelevance" do you mean that the entire thing is forgotten or that just the proof corresponding to one witness is forgotten? I think this is where I'm getting confused
Proof irrelevance means that any two proofs of the same theorem are always considered equal
Aaron Liu (Oct 08 2025 at 17:03):
so for example, any two proofs of ∃ a : D, LeastUpperBound p a S will be definitionally equal
Kenny Lau (Oct 08 2025 at 17:09):
Anna Williams said:
I don't think that's very helpful?
To someone who has had little contact with formal logic, they might think about "there exists x such that p(x)" vaguely, and to them this might be already equivalent to having that x already, but when you're doing formal logic (especially in a verification system such as Lean), the expression "there exists x such that p(x)" is a proposition (i.e. a true/false statement), while the witness x itself "contains data" (i.e. is an object of some set), and it cannot be compared to a proposition
Siddhartha Gadgil (Oct 13 2025 at 11:03):
To clarify, a longish example. Here we have an existence theorem but cannot resolve without proving a non-trivial theorem:
Noncomputable exists proof
Wrenna Robson (Oct 13 2025 at 12:20):
You could use Subtype.
Wrenna Robson (Oct 13 2025 at 12:21):
That is often a good way to hold "this is a term, that satisfies a given predicate"
Wrenna Robson (Oct 13 2025 at 12:21):
to say that there exists some x with p x is to say that there exists a term of type Subtype p
Aaron Liu (Oct 13 2025 at 12:22):
often a better way is to construct the term first and only afterwards prove it satisfies the predicate in a separate theorem
Aaron Liu (Oct 13 2025 at 12:22):
this doesn't always work for recursive definitions
Last updated: Dec 20 2025 at 21:32 UTC