1

Consider the following toy exercise:

Theorem swap_id: forall (m n : nat), m = n -> (m, n) = (n, m).
Proof.
  intros m n H.

At this point I have the following:

1 subgoal
m, n : nat
H : m = n
______________________________________(1/1)
(m, n) = (n, m)

I would like to split the goal into two subgoals, m = n and n = m. Is there a tactic which does that?

Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46

1 Answers1

4

Solve using the f_equal tactic:

Theorem test: forall (m n : nat), m = n -> (m, n) = (n, m).
Proof.
  intros m n H. f_equal.

With state:

2 subgoals
m, n : nat
H : m = n
______________________________________(1/2)
m = n
______________________________________(2/2)
n = m
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
  • 3
    A comment about the reason `f_equal` works: if we unfold some notations, we'll get from the goal `(m, n) = (n, m)` to `pair m n = pair n m`, where `pair` is the only constructor of the `prod` datatype. At this point it should be obvious why `f_equal` splits the goal into two subgoals. – Anton Trunov May 12 '17 at 20:34