Skip to content

Commit 464fb48

Browse files
committed
List used rewrite rules in Print Assumptions
1 parent cc34440 commit 464fb48

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
@@ -1035,6 +1035,7 @@ type axiom =
10351035
| Guarded of GlobRef.t
10361036
| TypeInType of GlobRef.t
10371037
| UIP of MutInd.t
1038+
| RewriteRules of GlobRef.t * RRset.t * RRset.t option
10381039

10391040
type context_object =
10401041
| Variable of Id.t (* A section variable or a Let definition *)
@@ -1057,6 +1058,8 @@ struct
10571058
| Guarded k1 , Guarded k2
10581059
| TypeInType k1, TypeInType k2 ->
10591060
GlobRef.CanOrd.compare k1 k2
1061+
| RewriteRules (kn, _, _), RewriteRules (kn2, _, _) ->
1062+
GlobRef.CanOrd.compare kn kn2
10601063
| Constant _, _ -> -1
10611064
| _, Constant _ -> 1
10621065
| Positive _, _ -> -1
@@ -1065,6 +1068,8 @@ struct
10651068
| _, Guarded _ -> 1
10661069
| TypeInType _, _ -> -1
10671070
| _, TypeInType _ -> 1
1071+
| RewriteRules _, _ -> -1
1072+
| _, RewriteRules _ -> 1
10681073

10691074
let compare x y =
10701075
match x , y with
@@ -1117,6 +1122,17 @@ let pr_assumptionset env sigma s =
11171122
try str " " ++ pr_ltype_env env sigma typ
11181123
with e when CErrors.noncritical e -> mt ()
11191124
in
1125+
let pr_rrs rrs =
1126+
prlist_with_sep spc RewriteRules.print (RRset.elements rrs)
1127+
in
1128+
let pr_rrs_pair rrs rtso =
1129+
let rrs, rps_text = match rtso with
1130+
| None -> rrs, mt()
1131+
| Some rts ->
1132+
rts, spc() ++ str "and its proof additionally relies on" ++ spc() ++ pr_rrs (RRset.diff rrs rts)
1133+
in
1134+
str "relies on" ++ spc() ++ pr_rrs rrs ++ rps_text ++ strbrk"."
1135+
in
11201136
let pr_axiom env ax typ =
11211137
match ax with
11221138
| Constant kn ->
@@ -1129,6 +1145,8 @@ let pr_assumptionset env sigma s =
11291145
hov 2 (safe_pr_global env gr ++ spc () ++ strbrk"relies on an unsafe hierarchy.")
11301146
| UIP mind ->
11311147
hov 2 (safe_pr_inductive env mind ++ spc () ++ strbrk"relies on definitional UIP.")
1148+
| RewriteRules (gr, rrs, rtso) ->
1149+
hov 2 (safe_pr_global env gr ++ spc () ++ pr_rrs_pair rrs rtso)
11321150
in
11331151
let fold t typ accu =
11341152
let (v, a, o, tr) = accu in
@@ -1164,7 +1182,10 @@ let pr_assumptionset env sigma s =
11641182
in
11651183
let theory =
11661184
if rewrite_rules_allowed env then
1167-
str "Rewrite rules are allowed (subject reduction might be broken)" :: theory
1185+
let rrs = get_enabled_rewrite_rules env in
1186+
str "Rewrite rules are allowed (subject reduction might be broken);" ++
1187+
spc() ++ str "enabled rules: " ++ (if RRset.is_empty rrs then str"(none)" else pr_rrs rrs)
1188+
:: theory
11681189
else theory
11691190
in
11701191
let theory =

printing/printer.mli

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

217218
type context_object =
218219
| 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)