Zulip Chat Archive

Stream: lean4

Topic: What's the meaning of this underscore _ in last line?


Hallon (Jan 23 2024 at 08:07):

example (h : s ⊆ t) : s ∩ u ⊆ t ∩ u := by
simp only [subset_def, mem_inter_iff] at *
-- h: ∀ x ∈ s, x ∈ t
-- ∀ (x : α), x ∈ s ∧ x ∈ u → x ∈ t ∧ x ∈ u
rintro x ⟨xs, xu⟩
exact ⟨h _ xs, xu⟩

Hallon (Jan 23 2024 at 08:10):

Similar to this hypothesis h, I need x \in t by x \in s. Sometimes directly write h xs, sometimes need to underline h _ xs, how to distinguish between adding underline or not?

Hallon (Jan 23 2024 at 08:16):

Is anybody here? Help!!! :pleading_face:

Hallon (Jan 23 2024 at 08:17):

This is the example which dont need underscore:

example (h : s  t) : s  u  t  u :=
  fun x xs, xu  h xs, xu

Sébastien Gouëzel (Jan 23 2024 at 08:18):

It means "Hey, Lean, could you please fill this out for me by putting the only thing that makes sense here". In this case, it is x, and Lean can guess it because it's mentioned in xs.

Sébastien Gouëzel (Jan 23 2024 at 08:19):

Whether you need it or not depends on whether it is declared as an implicit or explicit argument in the theorem you're applying. If you go to the definition of subset, you will see that the point is implicit, as it is written in curly braces {x : α}.

Sébastien Gouëzel (Jan 23 2024 at 08:21):

When you declare a theorem

theorem foo (a : A) (b : B) {c : C} (d : D) : ...

arguments between parentheses (called explicit arguments) will need to be provided when applying the theorem, while you expect that arguments between curly braces (called implicit arguments) should be guessed by Lean.

Hallon (Jan 23 2024 at 08:22):

Uh-huh


Last updated: May 02 2025 at 03:31 UTC