Prove an equivalence

P ↔ Q is two implications. constructor gives you both.

13 minBeginner↔Iff.introconstructor on an equivalence
0/11 completed in this course

P ↔ Q, typed \iff, says each side implies the other. A proof of it is the pair of implications P → Q and Q → P, so constructor splits an ↔ goal into two, exactly as it did for ∧.

The two new goals are implications, so a branch normally opens with intro. When you already hold the implication as a hypothesis, exact closes the branch immediately, and that is the shape of your exercise.

Order matters: the first goal is the forward direction P → Q, the second is Q → P. Swapping them gives a type mismatch that names both propositions, so the fix takes one glance at the message.

Equivalences are worth building because they can be used like equations. Once you hold h : P ↔ Q, rw [h] rewrites P into Q inside another goal. The Rewriting and automation course uses that often.

Worked example

example (A : Prop) (ha : A) : A ↔ (2 + 2 = 4) := by
  constructor
  · intro _
    rfl
  · intro _
    exact ha

Neither direction is a hypothesis here, so both branches start with intro and then do real work: one computes, the other uses ha. In your exercise both implications are already in the context.

Takeaway

P ↔ Q is a pair of implications. constructor splits it, and each direction is proven on its own.

Exercise 1 of 3

Combine hpq and hqp into a proof of P ↔ Q.

Suggested steps
  1. Split the equivalence into its two implications
  2. Prove the forward direction
  3. Prove the backward direction

These marks only recognize text. Another correct proof may use different steps; Lean checks whether it works.

Exercise.lean
1theorem exercise (P Q : Prop) (hpq : P → Q) (hqp : Q → P) : P ↔ Q := by
given
Loading editor…

Where you start. Everything above ⊢ may be assumed; the line below it is what you must prove.

P Q:Prop
hpq:P → Q
hqp:Q → P
⊢P ↔ Q
ReadyLn 1, Col 1Lean 4
Draft saved in this browser
Stuck?
Recall and apply

Knowledge check

Answer without looking back, then check your reasoning.

0of 3
correct
Question 1 of 3After constructor on P ↔ Q, the two goals are:
Question 2 of 3Why does a branch of an ↔ proof usually start with intro?
Question 3 of 3What is the term form of an ↔ proof?