Debian Codegraph @

tactics/redops.ml

raw symbols SCIP
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
11 open Genredexpr
12
13 let union_consts l1 l2 = Util.List.union (=) l1 l2 (* FIXME *)
14
15
16 let all_flags =
17 {rBeta = true; rMatch = true; rFix = true; rCofix = true;
18 rZeta = true; rDelta = true; rConst = []; rStrength = Norm; }
19
20 let make_red_flag l =
21 let rec add_flag red = function
22 | [] -> red
23 | FHead :: lf -> add_flag { red with rStrength = Head } lf
24 | FBeta :: lf -> add_flag { red with rBeta = true } lf
25 | FMatch :: lf -> add_flag { red with rMatch = true } lf
26 | FFix :: lf -> add_flag { red with rFix = true } lf
27 | FCofix :: lf -> add_flag { red with rCofix = true } lf
28 | FZeta :: lf -> add_flag { red with rZeta = true } lf
29 | FConst l :: lf ->
30 if red.rDelta then
31 CErrors.user_err Pp.(str
32 "Cannot set both constants to unfold and constants not to unfold");
33 add_flag { red with rConst = union_consts red.rConst l } lf
34 | FDeltaBut l :: lf ->
35 if red.rConst <> [] && not red.rDelta then
36 CErrors.user_err Pp.(str
37 "Cannot set both constants to unfold and constants not to unfold");
38 add_flag
39 { red with rConst = union_consts red.rConst l; rDelta = true }
40 lf
41 in
42 add_flag
43 {rBeta = false; rMatch = false; rFix = false; rCofix = false;
44 rZeta = false; rDelta = false; rConst = []; rStrength = Norm; }
45 l
46
47 let make_red_flag = function
48 | [FHead] -> { all_flags with rStrength = Head }
49 | l -> make_red_flag l
50
51 (** Mapping [red_expr_gen] *)
52
53 let map_flags f flags =
54 { flags with rConst = List.map f flags.rConst }
55
56 let map_occs f (occ,e) = (occ,f e)
57
58 let map_red_expr_gen f g h i = function
59 | Fold l -> Fold (List.map f l)
60 | Pattern occs_l -> Pattern (List.map (map_occs f) occs_l)
61 | Simpl (flags,occs_o) ->
62 Simpl (map_flags g flags, Option.map (map_occs (Util.map_union g h)) occs_o)
63 | Unfold occs_l -> Unfold (List.map (map_occs g) occs_l)
64 | Cbv flags -> Cbv (map_flags g flags)
65 | Lazy flags -> Lazy (map_flags g flags)
66 | CbvVm occs_o -> CbvVm (Option.map (map_occs (Util.map_union g h)) occs_o)
67 | CbvNative occs_o -> CbvNative (Option.map (map_occs (Util.map_union g h)) occs_o)
68 | Cbn flags -> Cbn (map_flags g flags)
69 | ExtraRedExpr _ | Red | Hnf as x -> x
70 | UserRed usr -> UserRed (i usr)