Debian Codegraph @

kernel/redFlags.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 Util
12 open Names
13
14 type reds = {flags : int; ts : TransparentState.t}
15
16 type red_kind =
17 | FLAG of int
18 | CONST of Constant.t
19 | PROJ of Projection.Repr.t
20 | VAR of Id.t
21
22 let fBETA = FLAG 0b000001
23 let fDELTA = FLAG 0b000010
24 let fMATCH = FLAG 0b000100
25 let fFIX = FLAG 0b001000
26 let fCOFIX = FLAG 0b010000
27 let fZETA = FLAG 0b100000
28 let fCONST kn = CONST kn
29 let fPROJ p = PROJ p
30 let fVAR id = VAR id
31
32 let no_red = {flags = 0; ts = TransparentState.empty}
33
34 let red_add ({flags; ts} as red) = function
35 | FLAG f -> {red with flags = flags lor f}
36 | CONST kn -> {red with ts = {ts with tr_cst = Cpred.add kn ts.tr_cst}}
37 | PROJ p -> {red with ts = {ts with tr_prj = PRpred.add p ts.tr_prj}}
38 | VAR id -> {red with ts = {ts with tr_var = Id.Pred.add id ts.tr_var}}
39
40 let red_sub ({flags; ts} as red) = function
41 | FLAG f -> {red with flags = flags land (0b111111 lxor f)}
42 | CONST kn -> {red with ts = {ts with tr_cst = Cpred.remove kn ts.tr_cst}}
43 | PROJ p -> {red with ts = {ts with tr_prj = PRpred.remove p ts.tr_prj}}
44 | VAR id -> { red with ts = {ts with tr_var = Id.Pred.remove id ts.tr_var}}
45
46 let red_sub_list = List.fold_left red_sub
47 let red_add_list = List.fold_left red_add
48
49 let red_transparent red = red.ts
50 let red_add_transparent red ts = {red with ts}
51
52 let mkflags = List.fold_left red_add no_red
53
54 let mkfullflags =
55 List.fold_left red_add { no_red with ts = TransparentState.full }
56
57 let red_set red = function
58 | FLAG f -> red.flags land f != 0
59 | CONST kn -> TransparentState.is_transparent_constant red.ts kn
60 | PROJ p -> TransparentState.is_transparent_projection red.ts p
61 | VAR id -> TransparentState.is_transparent_variable red.ts id
62
63 let red_projection red p =
64 Projection.unfolded p || red_set red (fPROJ (Projection.repr p))
65
66 let all = mkfullflags [fBETA;fDELTA;fZETA;fMATCH;fFIX;fCOFIX]
67 let allnolet = mkfullflags [fBETA;fDELTA;fMATCH;fFIX;fCOFIX]
68 let beta = mkflags [fBETA]
69 let betadeltazeta = mkfullflags [fBETA;fDELTA;fZETA]
70 let betaiota = mkflags [fBETA;fMATCH;fFIX;fCOFIX]
71 let betaiotazeta = mkflags [fBETA;fMATCH;fFIX;fCOFIX;fZETA]
72 let betazeta = mkflags [fBETA;fZETA]
73 let delta = mkfullflags [fDELTA]
74 let zeta = mkflags [fZETA]
75 let nored = no_red