An implication introduces a temporary assumption. A conjunction requires two pieces of evidence. These two roles suggest the proof structure: introduce the input, split the output, and fill each branch. An existential statement has a related but different structure: it requires a value together with evidence for a property. After this task, read the witness example to compare the two constructions. The starter has two unfinished branches, and neither is a passing result.
Your task
Replace both uses of sorry to prove Q ∧ P from P ∧ Q. Keep the order of the target intact.
theorem and_commutativity (P Q : Prop) : P ∧ Q → Q ∧ P := by
intro h
constructor
· sorry
· sorry
Show hints
- After constructor, the first branch asks for Q and the second for P.
- h.right proves Q; h.left proves P.
- Use exact h.right in the first branch and exact h.left in the second.
When you get stuck
Read the expected type, compare it with your term, and change one line. The experimental browser checker provides actual diagnostics. Goal information is available at the checked cursor when the runtime supports it; it is a source snapshot, not a live language server. Independent exercise verification is not available.
Use the error repair guide