| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
open Pp |
| 12 |
open Names |
| 13 |
open Declarations |
| 14 |
open Environ |
| 15 |
|
| 16 |
let memory_stat = ref false |
| 17 |
|
| 18 |
let print_memory_stat () = |
| 19 |
if !memory_stat then begin |
| 20 |
Format.printf "total heap size = %d kbytes\n" (CObj.heap_size_kb ()); |
| 21 |
Format.print_newline(); |
| 22 |
Format.print_flush() |
| 23 |
end |
| 24 |
|
| 25 |
let output_context = ref false |
| 26 |
|
| 27 |
let pr_impredicative_set env = |
| 28 |
if is_impredicative_set env then str "Theory: Set is impredicative" |
| 29 |
else str "Theory: Set is predicative" |
| 30 |
|
| 31 |
let pr_rewrite_rules env = |
| 32 |
if rewrite_rules_allowed env then str "Theory: Rewrite rules are allowed (consistency, subject reduction, confluence and normalization might be broken)" |
| 33 |
else str "Theory: Rewrite rules are not allowed" |
| 34 |
|
| 35 |
let pr_assumptions ass axs = |
| 36 |
if axs = [] then |
| 37 |
str ass ++ str ": <none>" |
| 38 |
else |
| 39 |
hv 2 (str ass ++ str ":" ++ fnl() ++ prlist_with_sep fnl str axs) |
| 40 |
|
| 41 |
let pr_axioms env opac = |
| 42 |
let add c cb acc = |
| 43 |
if Declareops.constant_has_body cb then acc else |
| 44 |
match Cmap.find_opt c opac with |
| 45 |
| None -> Cset.add c acc |
| 46 |
| Some s -> Cset.union s acc in |
| 47 |
let csts = fold_constants add env Cset.empty in |
| 48 |
let csts = Cset.fold (fun c acc -> Constant.to_string c :: acc) csts [] in |
| 49 |
pr_assumptions "Axioms" csts |
| 50 |
|
| 51 |
let pr_type_in_type env = |
| 52 |
let csts = fold_constants (fun c cb acc -> if not cb.const_typing_flags.check_universes then Constant.to_string c :: acc else acc) env [] in |
| 53 |
let csts = fold_inductives (fun c cb acc -> if not cb.mind_typing_flags.check_universes then MutInd.to_string c :: acc else acc) env csts in |
| 54 |
pr_assumptions "Constants/Inductives relying on type-in-type" csts |
| 55 |
|
| 56 |
let pr_unguarded env = |
| 57 |
let csts = fold_constants (fun c cb acc -> if not cb.const_typing_flags.check_guarded then Constant.to_string c :: acc else acc) env [] in |
| 58 |
let csts = fold_inductives (fun c cb acc -> if not cb.mind_typing_flags.check_guarded then MutInd.to_string c :: acc else acc) env csts in |
| 59 |
pr_assumptions "Constants/Inductives relying on unsafe (co)fixpoints" csts |
| 60 |
|
| 61 |
let pr_nonpositive env = |
| 62 |
let inds = fold_inductives (fun c cb acc -> if not cb.mind_typing_flags.check_positive then MutInd.to_string c :: acc else acc) env [] in |
| 63 |
pr_assumptions "Inductives whose positivity is assumed" inds |
| 64 |
|
| 65 |
let print_context env opac = |
| 66 |
if !output_context then begin |
| 67 |
Feedback.msg_notice |
| 68 |
(hov 0 |
| 69 |
(fnl() ++ str"CONTEXT SUMMARY" ++ fnl() ++ |
| 70 |
str"===============" ++ fnl() ++ fnl() ++ |
| 71 |
str "* " ++ hov 0 (pr_impredicative_set env ++ fnl()) ++ fnl() ++ |
| 72 |
str "* " ++ hov 0 (pr_rewrite_rules env ++ fnl()) ++ fnl() ++ |
| 73 |
str "* " ++ hov 0 (pr_axioms env opac ++ fnl()) ++ fnl() ++ |
| 74 |
str "* " ++ hov 0 (pr_type_in_type env ++ fnl()) ++ fnl() ++ |
| 75 |
str "* " ++ hov 0 (pr_unguarded env ++ fnl()) ++ fnl() ++ |
| 76 |
str "* " ++ hov 0 (pr_nonpositive env ++ fnl())) |
| 77 |
) |
| 78 |
end |
| 79 |
|
| 80 |
let stats env opac = |
| 81 |
print_context env opac; |
| 82 |
print_memory_stat () |