| 1 |
(************************************************************************) |
| 2 |
(* * The Rocq Prover / The Rocq Development Team *) |
| 3 |
(* v * Copyright INRIA, CNRS and contributors *) |
| 4 |
(* <O___,, * (see version control and CREDITS file for authors & dates) *) |
| 5 |
(* \VV/ **************************************************************) |
| 6 |
(* // * This file is distributed under the terms of the *) |
| 7 |
(* * GNU Lesser General Public License Version 2.1 *) |
| 8 |
(* * (see LICENSE file for the text of the license) *) |
| 9 |
(************************************************************************) |
| 10 |
(* Test le Hint Unfold sur des var locales *) |
| 11 |
|
| 12 |
Section toto. |
| 13 |
Let EQ := @eq. |
| 14 |
Goal EQ nat 0 0. |
| 15 |
Hint Unfold EQ. |
| 16 |
auto. |
| 17 |
Qed. |
| 18 |
End toto. |
| 19 |
|
| 20 |
(* Check regular failure when statically existing ref does not exist |
| 21 |
any longer at run time *) |
| 22 |
|
| 23 |
Goal let x := 0 in True. |
| 24 |
intro x. |
| 25 |
Fail (clear x; unfold x). |
| 26 |
Abort. |
| 27 |
|
| 28 |
(* Static analysis of unfold *) |
| 29 |
|
| 30 |
Module A. |
| 31 |
|
| 32 |
Opaque id. |
| 33 |
Ltac f := unfold id. |
| 34 |
Goal id 0 = 0. |
| 35 |
Fail f. |
| 36 |
Transparent id. |
| 37 |
f. |
| 38 |
Abort. |
| 39 |
|
| 40 |
End A. |
| 41 |
|
| 42 |
Module B. |
| 43 |
|
| 44 |
Module Type T. Axiom n : nat. End T. |
| 45 |
|
| 46 |
Module F(X:T). |
| 47 |
Ltac f := unfold X.n. |
| 48 |
End F. |
| 49 |
|
| 50 |
Module M. Definition n := 0. End M. |
| 51 |
Module N := F M. |
| 52 |
Goal match M.n with 0 => 0 | S _ => 1 end = 0. |
| 53 |
N.f. |
| 54 |
match goal with |- 0=0 => idtac end. |
| 55 |
Abort. |
| 56 |
|
| 57 |
End B. |
| 58 |
|
| 59 |
Module C. |
| 60 |
|
| 61 |
(* We reject inductive types and constructors *) |
| 62 |
|
| 63 |
Fail Ltac g := unfold nat. |
| 64 |
Fail Ltac g := unfold S. |
| 65 |
|
| 66 |
End C. |
| 67 |
|
| 68 |
Module D. |
| 69 |
|
| 70 |
(* In interactive mode, we delay the interpretation of short names *) |
| 71 |
|
| 72 |
Notation x := Nat.add. |
| 73 |
|
| 74 |
Goal let x := 0 in x = 0+0. |
| 75 |
unfold x. |
| 76 |
match goal with |- 0 = 0 => idtac end. |
| 77 |
Abort. |
| 78 |
|
| 79 |
Goal let x := 0 in x = 0+0. |
| 80 |
intro; unfold x. (* dynamic binding (but is it really the most natural?) *) |
| 81 |
match goal with |- 0 = 0+0 => idtac end. |
| 82 |
Abort. |
| 83 |
|
| 84 |
Goal let fst := 0 in fst = Datatypes.fst (0,0). |
| 85 |
unfold fst. |
| 86 |
match goal with |- 0 = 0 => idtac end. |
| 87 |
Abort. |
| 88 |
|
| 89 |
Goal let fst := 0 in fst = Datatypes.fst (0,0). |
| 90 |
intro; unfold fst. (* dynamic binding *) |
| 91 |
match goal with |- 0 = Datatypes.fst (0,0) => idtac end. |
| 92 |
Abort. |
| 93 |
|
| 94 |
End D. |