(* The tactic language *)
(* Submitted by Pierre Crégut *)
(* Checks substitution of x *)
Ltac f x := unfold x; idtac.
f plus.
reflexivity.
Qed.
(* Submitted by Pierre Crégut *)
(* Check syntactic correctness *)
Ltac F x := idtac; G x
with G y := idtac; F y.
(* Check that Match Context keeps a closure *)
Ltac U := let a := constr:(I) in
match goal with
|  |- _ => apply a
end.
U.
Qed.
(* Check that Match giving non-tactic arguments are evaluated at Let-time *)
Ltac B := let y := (match goal with
| z:_ |- _ => z
end) in
(intro H1; exact y).
intros H H0.
B.  (* y is H0 if at let-time, H1 otherwise *)
Qed.
(* Checks the matching order of hypotheses *)
Ltac Y := match goal with
| x:_,y:_ |- _ => apply x
end.
Ltac Z := match goal with
| y:_,x:_ |- _ => apply x
end.
intros H H0.
Z. (* Apply H0 *)
Y. (* Apply H *)
exact I.
Qed.
intros;
match goal with
| _:(0 = ?X1),_:(1 = 1) |- _ => exact (refl_equal X1)
end.
Qed.
intros;
match goal with
| _:(0 = ?X1),_:(1 = 1) |- _ => exact (refl_equal X1)
end.
Qed.
intros;
match goal with
| _:(0 = ?X1),_:(1 = 1) |- _ => exact (refl_equal X1)
end.
Qed.
(* Check context binding *)
Ltac sym t :=
match constr:(t) with
| context C[(?X1 = ?X2)] => context C [X1 = X2]
end.
intro H.
let t := sym type of H in
assert t.
exact H.
intro H1.
apply H.
symmetry .
assumption.
Qed.
(* Check context binding in match goal *)
(* This wasn't working in V8.0pl1, as the list of matched hyps wasn't empty *)
Ltac sym' :=
match goal with
| _:True |- context C[(?X1 = ?X2)] =>
let t := context C [X2 = X1] in
assert t
end.
intros Ht H.
sym'.
exact H.
intro H1.
apply H.
symmetry .
assumption.
Qed.

(* Check that fails abort the current match context *)
Lemma decide : True \/ False.