∴LeanProofs
Learn Lean 4

Control the direction of a rewrite

Use a reversed equality to replace the right expression.

Rewriting is directed substitution. In this variant the first equality is hba : b = a, while the target starts with a. A reverse rewrite uses the arrow syntax ← to move from a to b. After a rewrite, inspect the new target rather than guessing that a tactic solved it. The starter deliberately applies the wrong direction. Run the starter to read the actual diagnostic in the separately versioned browser environment. The hint describes the intended rewrite; it is not live compiler output.

Your task

Fix the rewrite direction and complete the equality without changing hba or hbc.

theorem reverse_rewrite (a b c : Nat) (hba : b = a) (hbc : b = c) : a = c := by
  rw [hba]
  exact hbc
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. The target contains a. The given equality starts with b.
  2. A reverse rewrite is written rw [← hba].
  3. Then the target is b = c, supplied by hbc.

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