Search code examples
coq

Introducing new hypothesis in the premises


My current goals are following:

  n' : nat
  IHn' : forall m : nat, n' + n' = m + m -> n' = m
  m' : nat
  H1 : n' + n' = m' + m'
  ============================
   S n' = S m'

Now, I want to apply H1 in IHn' such that the following hypothesis is introduced:

n' = m'

I have tried this:

apply H1 with (m := m') in IHn'.

But that gives me this error:

Error: No such bound variable m.

This is the complete reproducible program with those goals:

Theorem my_theorem : forall n m,
     n + n = m + m -> n = m.
Proof.
  intros n. induction n as [| n'].
  - simpl. 
    intros m H.
    symmetry in H.
    destruct m as [| m'].
    + reflexivity.
    + rewrite -> plus_Sn_m in H.
      inversion H.
  - simpl.
    rewrite <- plus_n_Sm.
    intros m.
    intros H.
    destruct m as [| m'].
    + simpl in H.
      inversion H.
    + rewrite -> plus_Sn_m in H.
      rewrite <- plus_n_Sm in H.
      inversion H.
Abort.

Solution

  • The problem is that you had your apply backwards. You need to write apply IHn' with (m := m') in H1. Note that in this case it is safe to omit the with (m := m') clause, since Coq is smart enough to figure out that information on its own.