5

I want to change the goal from S x = S y to x = y. It's like inversion, but for the goal instead of a hypothesis.

Such a tactic seems legit, because when we have x = y, we can simply use rewrite and reflexivity to prove the goal.

Currently I always find myself using assert (x = y) to introduce a new subgoal, but it's tedious to write when x and y are complex expression.

Tianyi Cui
  • 3,933
  • 3
  • 21
  • 18

2 Answers2

7

The tactic apply f_equal. will do what you want, for any constructor or function.

The lema f_equal shows that for any function f, you always have x = y -> f x = f y. This allows you to reduce the goal from f x = f y to x = y:

Proposition myprop (x y: nat) (H : x = y) : S x = S y.
Proof.
  apply f_equal.  assumption.
Qed.

(The injection tactic implements the converse implication — that for some functions, and in particular for constructors, f x = f y -> x = y.)

PLL
  • 1,572
  • 1
  • 13
  • 21
1

You may want to have a look at the injection tactic: http://coq.inria.fr/distrib/V8.4/refman/Reference-Manual011.html#@tactic126

Virgile
  • 9,724
  • 18
  • 42
  • 2
    This is not correct: “injection” implements implications of the form `f x = f y -> x = y` (and this does not hold for arbitrary functions `f`, only for special cases for constructors); what OP describes is just using the converse implication `x = y -> f x = f y`, which holds for any function. – PLL Dec 08 '12 at 21:50
  • 1
    Yes, sorry, I misread the question and thought that the issue was when `S x = S y` occurs in hypothesis. – Virgile Dec 09 '12 at 17:25