Zulip Chat Archive

Stream: lean4

Topic: intro


Hallon (Jan 19 2024 at 11:57):

When do I need to use it 'intro'? I'm a little confused. Some proofing need 'intro' after 'by', and some dont need.

Mario Carneiro (Jan 19 2024 at 11:59):

intro is used when the goal is a forall or implication statement and introduces names for the variables

Mario Carneiro (Jan 19 2024 at 12:00):

But when intro is the very first thing in the proof it is usually preferred to instead put the variables you want to introduce in binders before the : of the theorem statement, which has the same effect

Mario Carneiro (Jan 19 2024 at 12:03):

for example:

example :  x y : Nat, x + y = y + x := by
  -- ⊢ ∀ (x y : Nat), x + y = y + x
  intro x y
  -- x y : Nat
  -- ⊢ x + y = y + x
  apply Nat.add_comm

example (x y : Nat) : x + y = y + x := by
  -- x y : Nat
  -- ⊢ x + y = y + x
  apply Nat.add_comm

Hallon (Jan 19 2024 at 12:05):

OK I think I know, Thanks very much

Hallon (Jan 19 2024 at 12:06):

could you give a examply which conclude implication statement and need 'intro'?

Mario Carneiro (Jan 19 2024 at 12:08):

example (x : Nat) : x = 1  x + x = 2 := by
  -- x: Nat
  -- ⊢ x = 1 → x + x = 2
  intro h
  -- x: Nat
  -- h: x = 1
  -- ⊢ x + x = 2
  rw [h]

example (x : Nat) (h : x = 1) : x + x = 2 := by
  -- x: Nat
  -- h: x = 1
  -- ⊢ x + x = 2
  rw [h]

Hallon (Jan 19 2024 at 12:10):

Thanks very much


Last updated: May 02 2025 at 03:31 UTC