-
Notifications
You must be signed in to change notification settings - Fork 1
/
factorevars.v
67 lines (54 loc) · 1.34 KB
/
factorevars.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
(* Find all evars in a goal, and migrate them into standalone bodies
of local defs - so that every evar in the goal exists only as such a
standalone body.
This currently only works for evars that are not under binders.
*)
Require Import hypiter.
Ltac get_value H := eval cbv delta [H] in H.
Ltac has_value H := let x:=get_value H in idtac.
Ltac factor_value_evars H :=
repeat
let vH:=get_value H in
has_evar vH;
match vH with
context[?E] =>
is_evar E;
let nE:=fresh "E0" in
set (nE:=E) in *
end.
Ltac factor_type_evars H :=
repeat
let tH:=type of H in
has_evar tH;
match tH with
context[?E] =>
is_evar E;
let nE:=fresh "E0" in
set (nE:=E) in *
end.
Ltac factor_evars H :=
factor_value_evars H;
factor_type_evars H.
Ltac factor_conc_evars :=
repeat
match goal with
|- context[?E] =>
is_evar E;
let nE := fresh "E0" in
set (nE := E) in *
end.
Ltac factor_hyp_evars :=
allhyps_td factor_evars.
Ltac factor_all_evars :=
factor_hyp_evars;
factor_conc_evars.
Ltac defactor_all_evars :=
let f H := try (let v:=get_value H in
is_evar v; unfold H in *; clear H)
in
allhyps_td f.
Ltac clearbody_evars :=
let f H := try (let v:=get_value H in
is_evar v; clearbody H)
in
allhyps_td f.