| 1 |
Record T (x : nat) := { t : x = x }. |
| 2 |
|
| 3 |
Goal exists x, T x. |
| 4 |
refine (ex_intro _ _ _). |
| 5 |
Show Existentials. |
| 6 |
simple refine {| t := _ |}. |
| 7 |
reflexivity. |
| 8 |
Unshelve. exact 0. |
| 9 |
Qed. |
| 10 |
|
| 11 |
(** Fine if the new evar is defined as the originally shelved evar: we do nothing. |
| 12 |
In the other direction we promote the non-shelved new goal to a shelved one: |
| 13 |
shelved status has priority over goal status. *) |
| 14 |
|
| 15 |
Goal forall a : nat, exists x, T x. |
| 16 |
evar (x : nat). subst x. Show Existentials. |
| 17 |
intros a. simple refine (ex_intro ?[x0] _ _). shelve. simpl. |
| 18 |
(** Here ?x := ?x0 which is shelved, so ?x becomes shelved even if it would |
| 19 |
not be by default (refine ?x and _ produce non-shelved evars by default)*) |
| 20 |
simple refine (Build_T ?x _). |
| 21 |
reflexivity. |
| 22 |
Unshelve. exact 0. |
| 23 |
Qed. |
| 24 |
|
| 25 |
Goal { A : _ & { P : _ & @sigT A P } }. |
| 26 |
epose _ as A; |
| 27 |
epose _ as P; |
| 28 |
exists A, P. |
| 29 |
(* Regardless of which evars are in the goals vs the hypotheses, |
| 30 |
[simple refine (existT _ _ _)] should leave over two goals. This |
| 31 |
should be true even when chained with epose. *) |
| 32 |
assert_succeeds (simple refine (existT _ _ _); let n := numgoals in guard n = 2); |
| 33 |
subst P; |
| 34 |
assert_succeeds (simple refine (existT _ _ _); let n := numgoals in guard n = 2); |
| 35 |
subst A; |
| 36 |
assert_succeeds (simple refine (existT _ _ _); let n := numgoals in guard n = 2). |
| 37 |
(* fails *) |
| 38 |
Abort. |
| 39 |
|
| 40 |
Goal { A : _ & { P : _ & @sigT A P } }. |
| 41 |
epose _ as A; |
| 42 |
epose _ as P; |
| 43 |
exists A, P; (* In this example we chain everything *) |
| 44 |
assert_succeeds (simple refine (existT _ _ _); let n := numgoals in guard n = 2); |
| 45 |
subst P; |
| 46 |
assert_succeeds (simple refine (existT _ _ _); let n := numgoals in guard n = 2); |
| 47 |
subst A; |
| 48 |
assert_succeeds (simple refine (existT _ _ _); let n := numgoals in guard n = 2). |
| 49 |
(* fails *) |
| 50 |
Abort. |