Debian Codegraph @

examples/example_reduction_surgery.v

raw
1 (**
2 This file mocks up a reduction tactic unfolding only constants
3 from a given module.
4 *)
5
6 From elpi Require Import elpi.
7
8 Elpi Tactic reduce.
9 Elpi Accumulate lp:{{
10
11 pred gref->redflag i:gref, o:coq.redflag.
12 gref->redflag (const C) (coq.redflags.const C).
13
14 solve (goal _ _ Ty _ [str M] as G) GS :-
15 coq.locate-module M MP,
16 coq.env.module MP GREFS,
17 std.map-filter GREFS (x\r\x = gref r, r = (const _)) CONSTANTS,
18 std.map CONSTANTS (gr\r\ coq.env.transitive-dependencies gr _ r) DEPS,
19 std.fold DEPS {coq.gref.set.empty} coq.gref.set.union ALLDEPS,
20 std.append CONSTANTS {coq.gref.set.elements ALLDEPS} All,
21 std.map-filter All gref->redflag DELTAFLAGS,
22 coq.redflags.add coq.redflags.nored
23 [ coq.redflags.beta, coq.redflags.fix, coq.redflags.match | DELTAFLAGS ]
24 F,
25 (@redflags! F ==> coq.reduction.cbv.norm Ty Ty1),
26 refine {{ _ : lp:Ty1 }} G GS. % to leave a vmcast one needs to call ltac1
27
28 }}.
29
30
31
32 Module ToRed.
33 Definition x := 1.
34 Definition y := 1.
35 Definition alias := plus.
36 End ToRed.
37
38 Goal ToRed.x + ToRed.y = let z := 1 in S z.
39 elpi reduce "ToRed".
40 match goal with |- 2 = let z := 1 in S z => trivial end.
41 Show Proof.
42 Abort.