Section A.
Variable map : forall (T1 T2 : Type) (f : T1 -> T2) (t11 t12 : T1),
identity (f t11) (f t12).
Variable mapfuncomp : forall (X Y Z : Type) (f : X -> Y) (g : Y -> Z) (x x' : X),
identity (map Y Z g (f x) (f x')) (map X Z (fun x0 : X => g (f x0)) x x').
Goal forall X:Type, forall Y:Type, forall f:X->Y, forall x : X, forall x' : X,
forall g : Y -> X,
let gf := (fun x : X => g (f x)) : X -> X in
identity (map Y X g (f x) (f x')) (map X X gf x x').
intros.
apply mapfuncomp.
Abort.
End A.
(* Check "with" clauses refer to names as they are printed *)
Definition hide p := forall n:nat, p = n.
Goal forall n, (forall n, n=0) -> hide n -> n=0.
unfold hide.
intros n H H'.
(* H is displayed as (forall n, n=0) *)
apply H with (n:=n).
Undo.
(* H' is displayed as (forall n0, n=n0) *)
apply H' with (n0:=0).
Qed.
(* Check that evars originally present in goal do not prevent apply in to work*)
Goal (forall x, x <= 0 -> x = 0) -> exists x, x <= 0 -> 0 = 0.
intros.
eexists.
intros.
apply H in H0.
Abort.
(* Check correct failure of apply in when hypothesis is dependent *)
Goal forall H:0=0, H = H.
intros.
Fail apply eq_sym in H.
Abort.
(* Check that unresolved evars not originally present in goal prevent apply in to work*)
Goal (forall x y, x <= 0 -> x + y = 0) -> exists x, x <= 0 -> 0 = 0.
intros.
eexists.
intros.
Fail apply H in H0.
Abort.
(* Check naming pattern in apply in *)
Goal ((False /\ (True -> True))) -> True -> True.
intros F H.
apply F in H as H0. (* Check that H0 is not used internally *)
exact H0.
Qed.
Goal ((False /\ (True -> True/\True))) -> True -> True/\True.
intros F H.
apply F in H as (?,?).
split.
exact H. (* Check that generated names are H and H0 *)
exact H0.
Qed.
(* This failed at some time in between 18 August 2014 and 2 September 2014 *)
Goal forall A B C: Prop, (True -> A -> B /\ C) -> A -> B.
intros * H.
apply H.
Abort.
(* This failed between 2 and 3 September 2014 *)
Goal forall A B C D:Prop, (A<->B)/\(C<->D) -> A -> B.
intros.
apply H in H0.
pose proof I as H1. (* Test that H1 does not exist *)
Abort.
Goal forall A B C D:Prop, (A<->B)/\(C<->D) -> A.
intros.
apply H.
pose proof I as H0. (* Test that H0 does not exist *)
Abort.
(* The first example below failed at some time in between 18 August 2014 and 2 September 2014 *)
Goal forall x, 2=0 -> x+1=2 -> (forall x, S x = 0) -> True.
intros x H H0 H1.
eapply eq_trans in H. 2:apply H0.
rewrite H1 in H.
change (x+0=0) in H. (* Check the result in H1 *)
Abort.
Goal forall x, 2=x+1 -> (forall x, S x = 0) -> 2 = 0.
intros x H H0.
eapply eq_trans. apply H.
rewrite H0.
change (x+0=0).
Abort.
(* 2nd order apply used to have delta on local definitions even though it does not have delta on global definitions; keep it by compatibility while finding a more uniform way to proceed. *)
Goal forall f:nat->nat, (forall P x, P (f x)) -> let x:=f 0 in x = 0.
intros f H x.
apply H.
Qed.

(* Test that occur-check is not too restrictive (see comments of #3141) *)
Lemma bar (X: nat -> nat -> Prop) (foo:forall x, X x x) (a: unit) (H: tt = a):
exists x, exists y, X x y.