Skip to content

Commit de94768

Browse files
committed
List used rewrite rules in Print Assumptions
1 parent 8ae8865 commit de94768

File tree

5 files changed

+33
-1
lines changed

5 files changed

+33
-1
lines changed

kernel/names.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,8 @@ module RewriteRules = struct
10521052

10531053
let to_string { library = d ; id } =
10541054
DirPath.to_string d ^ "." ^ Label.to_string id
1055+
1056+
let print kn = str (to_string kn)
10551057
end
10561058

10571059
module RRmap = HMap.Make(RewriteRules)

kernel/names.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,7 @@ module RewriteRules : sig
669669
val hash : t -> int
670670
val compare : t -> t -> int
671671
val to_string : t -> string
672+
val print : t -> Pp.t
672673
end
673674

674675
module RRset : CSig.USetS with type elt = RewriteRules.t

printing/printer.ml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,7 @@ type axiom =
10341034
| Guarded of GlobRef.t
10351035
| TypeInType of GlobRef.t
10361036
| UIP of MutInd.t
1037+
| RewriteRules of GlobRef.t * RRset.t * RRset.t option
10371038

10381039
type context_object =
10391040
| Variable of Id.t (* A section variable or a Let definition *)
@@ -1056,6 +1057,8 @@ struct
10561057
| Guarded k1 , Guarded k2
10571058
| TypeInType k1, TypeInType k2 ->
10581059
GlobRef.CanOrd.compare k1 k2
1060+
| RewriteRules (kn, _, _), RewriteRules (kn2, _, _) ->
1061+
GlobRef.CanOrd.compare kn kn2
10591062
| Constant _, _ -> -1
10601063
| _, Constant _ -> 1
10611064
| Positive _, _ -> -1
@@ -1064,6 +1067,8 @@ struct
10641067
| _, Guarded _ -> 1
10651068
| TypeInType _, _ -> -1
10661069
| _, TypeInType _ -> 1
1070+
| RewriteRules _, _ -> -1
1071+
| _, RewriteRules _ -> 1
10671072

10681073
let compare x y =
10691074
match x , y with
@@ -1116,6 +1121,17 @@ let pr_assumptionset env sigma s =
11161121
try str " " ++ pr_ltype_env env sigma typ
11171122
with e when CErrors.noncritical e -> mt ()
11181123
in
1124+
let pr_rrs rrs =
1125+
prlist_with_sep spc RewriteRules.print (RRset.elements rrs)
1126+
in
1127+
let pr_rrs_pair rrs rtso =
1128+
let rrs, rps_text = match rtso with
1129+
| None -> rrs, mt()
1130+
| Some rts ->
1131+
rts, spc() ++ str "and its proof additionally relies on" ++ spc() ++ pr_rrs (RRset.diff rrs rts)
1132+
in
1133+
str "relies on" ++ spc() ++ pr_rrs rrs ++ rps_text ++ strbrk"."
1134+
in
11191135
let pr_axiom env ax typ =
11201136
match ax with
11211137
| Constant kn ->
@@ -1128,6 +1144,8 @@ let pr_assumptionset env sigma s =
11281144
hov 2 (safe_pr_global env gr ++ spc () ++ strbrk"relies on an unsafe hierarchy.")
11291145
| UIP mind ->
11301146
hov 2 (safe_pr_inductive env mind ++ spc () ++ strbrk"relies on definitional UIP.")
1147+
| RewriteRules (gr, rrs, rtso) ->
1148+
hov 2 (safe_pr_global env gr ++ spc () ++ pr_rrs_pair rrs rtso)
11311149
in
11321150
let fold t typ accu =
11331151
let (v, a, o, tr) = accu in
@@ -1163,7 +1181,10 @@ let pr_assumptionset env sigma s =
11631181
in
11641182
let theory =
11651183
if rewrite_rules_allowed env then
1166-
str "Rewrite rules are allowed (subject reduction might be broken)" :: theory
1184+
let rrs = get_enabled_rewrite_rules env in
1185+
str "Rewrite rules are allowed (subject reduction might be broken);" ++
1186+
spc() ++ str "enabled rules: " ++ (if RRset.is_empty rrs then str"(none)" else pr_rrs rrs)
1187+
:: theory
11671188
else theory
11681189
in
11691190
let theory =

printing/printer.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ type axiom =
214214
| Guarded of GlobRef.t (* a constant whose (co)fixpoints have been assumed to be guarded *)
215215
| TypeInType of GlobRef.t (* a constant which relies on type in type *)
216216
| UIP of MutInd.t (* An inductive using the special reduction rule. *)
217+
| RewriteRules of GlobRef.t * RRset.t * RRset.t option (* A constant which relies on typing rules (and possibly proof-only rules) *)
217218

218219
type context_object =
219220
| Variable of Id.t (* A section variable or a Let definition *)

vernac/assumptions.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,13 @@ let assumptions ?(add_opaque=false) ?(add_transparent=false) access st gr t =
375375
let l = try GlobRef.Map_env.find obj ax2ty with Not_found -> [] in
376376
ContextObjectMap.add (Axiom (TypeInType obj, l)) Constr.mkProp accu
377377
in
378+
let accu =
379+
match cb.const_typing_flags.enabled_rewrite_rules with
380+
| Some rrs when not (RRset.is_empty rrs) ->
381+
let l = try GlobRef.Map_env.find obj ax2ty with Not_found -> [] in
382+
ContextObjectMap.add (Axiom (RewriteRules (obj, rrs, cb.const_typing_flags.enabled_rewrite_rules_type), l)) Constr.mkProp accu
383+
| Some _ | None -> accu
384+
in
378385
if not (Option.has_some contents) then
379386
let t = type_of_constant cb in
380387
let l = try GlobRef.Map_env.find obj ax2ty with Not_found -> [] in

0 commit comments

Comments
 (0)