Coq forward reasoning: apply with multiple hypotheses

1.3k views Asked by At

I have two hypothesis, and I would like to use forward reasoning to apply a theorem that uses both of them.

My specific I have the hypothes

H0 : a + b = c + d
H1 : e + f = g + h

and I want to apply the theorem from the standard library:

f_equal2_mult
     : forall x1 y1 x2 y2 : nat, x1 = y1 -> x2 = y2 -> x1 * x2 = y1 * y2

Now I know I could manually give the values for x1, y1, x2, y2, but I would like Coq to automatically determine those values when it unified with H0 and H1. I have figured out that I can get it to work like so:

eapply f_equal2_mult in H0; try exact H1.

But this feels like a hack, with the broken symmetry and the try. I really would like to be able to say apply f_equals2_mult in H0, H1 or something similarly clear. Is there a way like this?

1

There are 1 answers

4
Li-yao Xia On

You could use pose proof to introduce the lemma in the context, and specialize to apply it to other hypotheses.

Lemma f (a b c d : nat) : a = b -> c = d -> False.
intros H1 H2.
pose proof f_equal2_mult as pp.
specialize pp with (1 := H1).
specialize pp with (1 := H2).

(* or *)
specialize pp with (1 := H1) (2 := H2).