| 1 |
(* ========================================================================== *) |
| 2 |
(* Formal verification of nonlinear inequalities in HOL Light *) |
| 3 |
(* *) |
| 4 |
(* Copyright (c) 2011 Thomas C. Hales *) |
| 5 |
(* *) |
| 6 |
(* This file is distributed under the terms of the MIT licence *) |
| 7 |
(* ========================================================================== *) |
| 8 |
|
| 9 |
(* -------------------------------------------------------------------------- *) |
| 10 |
(* Report functions *) |
| 11 |
(* port of error.cc *) |
| 12 |
(* basic procedures to print messages to the standard output *) |
| 13 |
(* and to count errors. *) |
| 14 |
(* -------------------------------------------------------------------------- *) |
| 15 |
|
| 16 |
module Report = struct |
| 17 |
|
| 18 |
exception Fatal;; |
| 19 |
|
| 20 |
let time_string () = Printf.sprintf "time(%.0f)" (Sys.time());; |
| 21 |
|
| 22 |
let (get_error_count,reset_error_count,inc_error_count) = |
| 23 |
let error_count = ref 0 in |
| 24 |
((fun () -> !error_count),(fun () -> error_count := 0), |
| 25 |
(fun () -> error_count:= !error_count + 1));; |
| 26 |
|
| 27 |
let (get_corner_count,reset_corner_count,inc_corner_count) = |
| 28 |
let corner_count = ref 0 in |
| 29 |
((fun () -> !corner_count),(fun () -> corner_count := 0), |
| 30 |
(fun () -> corner_count:= !corner_count + 1));; |
| 31 |
|
| 32 |
let diagnostic_string () = |
| 33 |
let d = get_error_count() in |
| 34 |
if (d>0) then Printf.sprintf "(errors %d)" (get_error_count()) else "(no errors)";; |
| 35 |
|
| 36 |
let report s = |
| 37 |
Format.print_string s; Format.print_newline(); Format.print_flush();; |
| 38 |
|
| 39 |
let report_timed s = report (s^" "^(time_string()));; |
| 40 |
|
| 41 |
let report_error = |
| 42 |
let error_max = 25 in (* was 200, recurse.cc had a separate counter limit at 25 *) |
| 43 |
fun s -> |
| 44 |
let ec = get_error_count() in |
| 45 |
(inc_error_count(); report_timed (Printf.sprintf "error(%d) --\n%s" ec s); |
| 46 |
ignore(get_error_count() < error_max || raise Fatal));; |
| 47 |
|
| 48 |
let report_fatal s = |
| 49 |
( inc_error_count(); report_timed ("error --\n"^s); raise Fatal);; |
| 50 |
|
| 51 |
end;; |