intro — Introducing Assumptions
intro moves things from the goal into your hypotheses. It's how you assume things to prove implications and universals.
Proving Implications
When your goal is P → Q, use introto assume P and prove Q:
lean
1example : True → True := by2 intro h3 -- Before: ⊢ True → True4 -- After: h : True ⊢ True5 trivial67example (P : Prop) : P → P := by8 intro hp9 -- hp : P ⊢ P10 exact hpLogically, to prove "if P then Q," you assume P and derive Q.
Proving Universals
When your goal is ∀ x, P x, use introto introduce an arbitrary x:
lean
1example : ∀ n : Nat, n = n := by2 intro n3 -- Before: ⊢ ∀ n : Nat, n = n4 -- After: n : Nat ⊢ n = n5 rfl67example : ∀ a b : Nat, a + b = b + a := by8 intro a b9 -- a b : Nat ⊢ a + b = b + a10 exact Nat.add_comm a bKey Takeaway
intro x says "let x be arbitrary" for universals, or "assume x" for implications. The goal changes, and x becomes a hypothesis.Introducing Multiple Things
lean
1-- Introduce several at once2example : ∀ a b c : Nat, a + b + c = c + b + a := by3 intro a b c4 ring56-- Mix of universals and implications7example : ∀ (P Q : Prop), P → Q → P := by8 intro P Q hp hq9 -- P Q : Prop, hp : P, hq : Q ⊢ P10 exact hp1112-- Alternative: use multiple intro calls13example : ∀ (n : Nat), n > 0 → n ≥ 1 := by14 intro n15 intro h16 omegaNaming Conventions
lean
1-- Common patterns:2-- h, h1, h2 for hypotheses (proof terms)3-- hp, hq for proofs of P, Q4-- n, m, k for numbers5-- a, b, c for arbitrary values6-- x, y, z for elements7-- xs, ys for lists8-- f, g for functions910example (P Q R : Prop) : P → Q → R → P := by11 intro hp hq hr12 exact hpintro with Patterns
You can destructure as you introduce:
lean
1-- Introduce and destructure a conjunction2example (P Q : Prop) : P ∧ Q → Q ∧ P := by3 intro ⟨hp, hq⟩4 -- Instead of: intro h; obtain ⟨hp, hq⟩ := h5 exact ⟨hq, hp⟩67-- Works with existentials too8example : (∃ n : Nat, n > 5) → ∃ n : Nat, n > 0 := by9 intro ⟨n, hn⟩10 -- n : Nat, hn : n > 511 exact ⟨n, by omega⟩intros: Introduce All
lean
1-- intros introduces everything it can2example : ∀ a b : Nat, a = b → b = a := by3 intros4 -- Introduces a, b, and the equality proof with auto-generated names5 assumption67-- Better to name them explicitly:8example : ∀ a b : Nat, a = b → b = a := by9 intro a b hab10 exact hab.symm⚠
intros auto-generates names like a✝, which can be confusing. Prefer explicit intro a b cwhen possible.Common Mistakes
Mistake 1: Forgetting intro when needed
lean
1-- ❌ Won't work: can't prove P → Q directly2-- example (P Q : Prop) (hq : Q) : P → Q := by3-- exact hq -- Error: expected P → Q, got Q45-- ✓ Correct: intro first, then provide Q6example (P Q : Prop) (hq : Q) : P → Q := by7 intro hp8 exact hqMistake 2: Wrong number of intros
lean
1-- Be careful with nested implications2example : ∀ n : Nat, n > 0 → n ≠ 0 := by3 intro n hn -- Need TWO intros: one for n, one for the hypothesis4 omega56-- If you only do one intro:7-- intro n would leave goal: n > 0 → n ≠ 0Mistake 3: Introducing when you should apply
lean
1-- If the goal is not an implication or forall, intro won't work2example (P : Prop) (hp : P) : P := by3 -- intro h -- ❌ Error: P is not a function type4 exact hp -- ✓ CorrectExercise 1: Introduce and Use
Use intro to bring assumptions into context and finish the proof.
lean
1example (P Q : Prop) : P → Q → Q := by2 intro hp hq3 exact hqExercise 2: Universal Statement
Introduce the universal variable and prove reflexivity.
lean
1example : ∀ n : Nat, n + 0 = n := by2 intro n3 simpExercise 3: Pattern Intro
Use pattern matching in intro to destructure the conjunction.
lean
1example (P Q : Prop) : P ∧ Q → Q ∧ P := by2 intro ⟨hp, hq⟩3 exact ⟨hq, hp⟩Function Goals
Remember: P → Q is a function type. introis like writing fun hp => ...:
lean
1-- These are equivalent:2example : Nat → Nat := fun n => n + 13example : Nat → Nat := by intro n; exact n + 145-- For propositions:6example (P Q : Prop) (f : P → Q) (hp : P) : Q := by7 apply f8 exact hp910-- Or more directly:11example (P Q : Prop) (f : P → Q) (hp : P) : Q := f hpDeep Dive: intro and Lambda
Under the hood, intro x constructs a lambda:
lean
1-- These produce the same proof term:2theorem t1 : ∀ n : Nat, n = n := by intro n; rfl3theorem t2 : ∀ n : Nat, n = n := fun n => rfl45#print t1 -- fun n => rfl6#print t2 -- fun n => rflTactics are just a convenient way to build proof terms. You can always see what term was built using #print.
Examples
Implication Chain
lean
1example (P Q R : Prop) : (P → Q) → (Q → R) → P → R := by2 intro hpq hqr hp3 -- hpq : P → Q4 -- hqr : Q → R5 -- hp : P6 -- ⊢ R7 apply hqr8 apply hpq9 exact hpUniversal with Hypothesis
lean
1example : ∀ n : Nat, n > 0 → n ≠ 0 := by2 intro n hn3 -- n : Nat4 -- hn : n > 05 -- ⊢ n ≠ 06 omegaNested Universals
lean
1example : ∀ (f : Nat → Nat), (∀ n, f n = n) → f 5 = 5 := by2 intro f hf3 -- f : Nat → Nat4 -- hf : ∀ n, f n = n5 -- ⊢ f 5 = 56 exact hf 5