Я не думаю, что вы можете изменить G
, но вы можете создать гипотезу, из которой injection
сгенерирует более одного равенства.
Мы определяем injectionInCtx2
, который идентичен injectionInCtx
за исключением того, что он не использует G
.
Ltac injectionInCtx2 :=
match goal with
| [ H : ?F ?X = ?F ?Y |- _ ] =>
(* fail early if it wouldn't progress *)
notInCtx (X = Y);
injection H;
match goal with
| [ |- X = Y -> _ ] =>
try clear H; intros; try subst
end
end.
Definition make_pair {A} (n:A) := (n, n).
Goal forall (x y : nat), make_pair x = make_pair y -> x = y.
Proof.
intros x y H.
(* [injection H] gives [x = y -> x = y -> x = y] *)
Fail injectionInCtx.
injectionInCtx2.
reflexivity.
Qed.