Skip to content

Commit 642943d

Browse files
committed
List used rewrite rules in Print Assumptions
1 parent 55fa117 commit 642943d

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
@@ -986,6 +986,8 @@ module RewriteRules = struct
986986

987987
let to_string { library = d ; id } =
988988
DirPath.to_string d ^ "." ^ Id.to_string id
989+
990+
let print kn = str (to_string kn)
989991
end
990992

991993
module RRmap = HMap.Make(RewriteRules)

kernel/names.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ module RewriteRules : sig
633633
val hash : t -> int
634634
val compare : t -> t -> int
635635
val to_string : t -> string
636+
val print : t -> Pp.t
636637
end
637638

638639
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
@@ -1098,6 +1098,7 @@ type axiom =
10981098
| Guarded of GlobRef.t
10991099
| TypeInType of GlobRef.t
11001100
| UIP of MutInd.t
1101+
| RewriteRules of GlobRef.t * RRset.t * RRset.t option
11011102

11021103
type context_object =
11031104
| Variable of Id.t (* A section variable or a Let definition *)
@@ -1120,6 +1121,8 @@ struct
11201121
| Guarded k1 , Guarded k2
11211122
| TypeInType k1, TypeInType k2 ->
11221123
GlobRef.UserOrd.compare k1 k2
1124+
| RewriteRules (kn, _, _), RewriteRules (kn2, _, _) ->
1125+
GlobRef.CanOrd.compare kn kn2
11231126
| Constant _, _ -> -1
11241127
| _, Constant _ -> 1
11251128
| Positive _, _ -> -1
@@ -1128,6 +1131,8 @@ struct
11281131
| _, Guarded _ -> 1
11291132
| TypeInType _, _ -> -1
11301133
| _, TypeInType _ -> 1
1134+
| RewriteRules _, _ -> -1
1135+
| _, RewriteRules _ -> 1
11311136

11321137
let compare x y =
11331138
match x , y with
@@ -1180,6 +1185,17 @@ let pr_assumptionset ?(flags=current_combined()) env sigma s =
11801185
try str " " ++ pr_ltype_env ~flags env sigma typ
11811186
with e when CErrors.noncritical e -> mt ()
11821187
in
1188+
let pr_rrs rrs =
1189+
prlist_with_sep spc RewriteRules.print (RRset.elements rrs)
1190+
in
1191+
let pr_rrs_pair rrs rtso =
1192+
let rrs, rps_text = match rtso with
1193+
| None -> rrs, mt()
1194+
| Some rts ->
1195+
rts, spc() ++ str "and its proof additionally relies on" ++ spc() ++ pr_rrs (RRset.diff rrs rts)
1196+
in
1197+
str "relies on rewrite rules" ++ spc() ++ pr_rrs rrs ++ rps_text ++ strbrk"."
1198+
in
11831199
let pr_axiom env ax typ =
11841200
match ax with
11851201
| Constant kn ->
@@ -1192,6 +1208,8 @@ let pr_assumptionset ?(flags=current_combined()) env sigma s =
11921208
hov 2 (safe_pr_global env gr ++ spc () ++ strbrk"relies on an unsafe hierarchy.")
11931209
| UIP mind ->
11941210
hov 2 (safe_pr_inductive env mind ++ spc () ++ strbrk"relies on definitional UIP.")
1211+
| RewriteRules (gr, rrs, rtso) ->
1212+
hov 2 (safe_pr_global env gr ++ spc () ++ pr_rrs_pair rrs rtso)
11951213
in
11961214
let fold t typ accu =
11971215
let (v, a, o, tr) = accu in
@@ -1233,7 +1251,10 @@ let pr_assumptionset ?(flags=current_combined()) env sigma s =
12331251
in
12341252
let theory =
12351253
if rewrite_rules_allowed env then
1236-
str "Rewrite rules are allowed (subject reduction might be broken)" :: theory
1254+
let rrs = get_enabled_rewrite_rules env in
1255+
str "Rewrite rules are allowed (subject reduction might be broken);" ++
1256+
spc() ++ str "enabled rules: " ++ (if RRset.is_empty rrs then str"(none)" else pr_rrs rrs)
1257+
:: theory
12371258
else theory
12381259
in
12391260
let theory =

printing/printer.mli

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

255256
type context_object =
256257
| 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
@@ -385,6 +385,13 @@ let assumptions ?(add_opaque=false) ?(add_transparent=false) access st grs =
385385
let l = try GlobRef.Map_env.find obj ax2ty with Not_found -> [] in
386386
ContextObjectMap.add (Axiom (TypeInType obj, l)) Constr.mkProp accu
387387
in
388+
let accu =
389+
match cb.const_typing_flags.enabled_rewrite_rules with
390+
| Some rrs when not (RRset.is_empty rrs) ->
391+
let l = try GlobRef.Map_env.find obj ax2ty with Not_found -> [] in
392+
ContextObjectMap.add (Axiom (RewriteRules (obj, rrs, cb.const_typing_flags.enabled_rewrite_rules_type), l)) Constr.mkProp accu
393+
| Some _ | None -> accu
394+
in
388395
if not (Option.has_some contents) then
389396
let t = type_of_constant cb in
390397
let l = try GlobRef.Map_env.find obj ax2ty with Not_found -> [] in

0 commit comments

Comments
 (0)