Debian Codegraph @

test-suite/success/name_mangling.v

raw
1 Set Mangle Names.
2
3 (* Check that refine policy of redefining previous names make these names private *)
4
5 Goal True -> True.
6 intro.
7 Fail exact H.
8 exact _0.
9 Abort.
10
11 Unset Mangle Names.
12 Goal True -> True.
13 intro; exact H.
14 Abort.
15
16 Set Mangle Names.
17 Set Mangle Names Prefix "baz".
18 Goal True -> True.
19 intro.
20 Fail exact H.
21 Fail exact _0.
22 exact baz0.
23 Abort.
24
25 Goal True -> True.
26 intro; assumption.
27 Abort.
28
29 Goal True -> True.
30 intro x; exact x.
31 Abort.
32
33 Goal forall x y, x+y=0.
34 intro x.
35 refine (fun x => _).
36 Fail Check x0.
37 Check x.
38 Abort.
39
40 (* Example from Emilio *)
41
42 Goal forall b : False, b = b.
43 intro b.
44 refine (let b := I in _).
45 Fail destruct b0.
46 Abort.
47
48 (* Example from Cyprien *)
49
50 Goal True -> True.
51 Proof.
52 refine (fun _ => _).
53 Fail exact t.
54 Abort.
55
56 (* Example from Jason *)
57
58 Goal False -> False.
59 intro H.
60 abstract exact H.
61 Abort.
62
63 (* Variant *)
64
65 Goal False -> False.
66 intro.
67 Fail abstract exact H.
68 Abort.
69
70 (* Example from Jason *)
71
72 Lemma lem1 : False -> False.
73 intro H.
74 (* Name H' is from Ltac here, so it preserves the privacy *)
75 (* But abstract messes everything up *)
76 let H' := H in abstract exact H'.
77 Qed.
78
79 (* Variant *)
80
81 Goal False -> False.
82 intro.
83 Fail let H' := H in abstract exact H'.
84 Abort.
85
86 (* Indirectly testing preservation of names by move (derived from Jason) *)
87
88 Inductive nat2 := S2 (_ _ : nat2).
89 Goal forall t : nat2, True.
90 intro t.
91 let IHt1 := fresh "IHt1" in
92 let IHt2 := fresh "IHt2" in
93 induction t as [? IHt1 ? IHt2].
94 Fail exact IHt1.
95 Abort.
96
97 (* Example on "pose proof" (from Jason) *)
98
99 Goal False -> False.
100 intro; pose proof I as H0.
101 Fail exact H.
102 Abort.
103
104 (* Testing the approach for which non alpha-renamed quantified names are user-generated *)
105
106 Section foo.
107 Context (b : True).
108 Goal forall b : False, b = b.
109 Fail destruct b0.
110 Abort.
111
112 Lemma lem2 : forall b : False, b = b.
113 now destruct b.
114 Qed.
115 End foo.
116
117 (* Test stability of "fix" *)
118
119 Lemma a : forall n, n = 0.
120 Proof.
121 fix a 1.
122 Check a.
123 Fail fix a 1.
124 Abort.
125
126 (* Test stability of "induction" *)
127
128 Lemma a : forall n : nat, n = n.
129 Proof.
130 intro n; induction n as [ | n IHn ].
131 - auto.
132 - Check n.
133 Check IHn.
134 Abort.
135
136 Inductive I := C : I -> I -> I.
137
138 Lemma a : forall n : I, n = n.
139 Proof.
140 intro n; induction n as [ n1 IHn1 n2 IHn2 ].
141 Check n1.
142 Check n2.
143 apply f_equal2.
144 + apply IHn1.
145 + apply IHn2.
146 Qed.
147
148 (* Testing remember *)
149
150 Lemma c : 0 = 0.
151 Proof.
152 remember 0 as x eqn:Heqx.
153 Check Heqx.
154 Abort.
155
156 Lemma c : forall Heqx, Heqx -> 0 = 0.
157 Proof.
158 intros Heqx X.
159 remember 0 as x.
160 Fail Check Heqx0. (* Heqx0 is not canonical *)
161 Abort.
162
163 (* An example by Jason from the discussion for PR #268 *)
164
165 Goal nat -> Set -> True.
166 intros x y.
167 match goal with
168 | [ x : _, y : _ |- _ ]
169 => let z := fresh "z" in
170 rename y into z, x into y;
171 let x' := fresh "x" in
172 rename z into x'
173 end.
174 revert y. (* x has been explicitly moved to y *)
175 Fail revert x. (* x comes from "fresh" *)
176 Abort.
177
178 Goal nat -> Set -> True.
179 intros.
180 match goal with
181 | [ x : _, y : _ |- _ ]
182 => let z := fresh "z" in
183 rename y into z, x into y;
184 let x' := fresh "x" in
185 rename z into x'
186 end.
187 Fail revert y. (* generated by intros *)
188 Fail revert x. (* generated by intros *)
189 Abort.