∴LeanProofs
Learn Lean 4

Build a conjunction

Use both parts of an assumption in the required order.

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
Exercise not verified. The target is a teaching task; changing it cannot earn a pass. A trusted fixed-challenge verifier is required before passes can be issued.
Show hints
  1. After constructor, the first branch asks for Q and the second for P.
  2. h.right proves Q; h.left proves P.
  3. Use exact h.right in the first branch and exact h.left in the second.

The repository’s six reference answers have a separate native type-and-axiom audit. This does not check or certify your edited answer. Read the reference audit (JSON)

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