src/HOL/Tools/Nitpick/nitpick.ML
changeset 72328 7cb0c5fbe2d9
parent 72327 da2cbe54e53e
child 72329 6255e532aa36
equal deleted inserted replaced
72327:da2cbe54e53e 72328:7cb0c5fbe2d9
   174 
   174 
   175 val isabelle_wrong_message =
   175 val isabelle_wrong_message =
   176   "something appears to be wrong with your Isabelle installation"
   176   "something appears to be wrong with your Isabelle installation"
   177 val java_not_found_message =
   177 val java_not_found_message =
   178   "Java could not be launched -- " ^ isabelle_wrong_message
   178   "Java could not be launched -- " ^ isabelle_wrong_message
   179 val kodkodi_not_installed_message =
       
   180   "Nitpick requires the external Java program Kodkodi"
       
   181 
   179 
   182 val max_unsound_delay_ms = 200
   180 val max_unsound_delay_ms = 200
   183 val max_unsound_delay_percent = 2
   181 val max_unsound_delay_percent = 2
   184 
   182 
   185 fun unsound_delay_for_timeout timeout =
   183 fun unsound_delay_for_timeout timeout =
   714           case KK.solve_any_problem debug overlord deadline max_threads
   712           case KK.solve_any_problem debug overlord deadline max_threads
   715                                     max_solutions (map fst problems) of
   713                                     max_solutions (map fst problems) of
   716             KK.JavaNotFound =>
   714             KK.JavaNotFound =>
   717             (print_nt (K java_not_found_message);
   715             (print_nt (K java_not_found_message);
   718              (found_really_genuine, max_potential, max_genuine, donno + 1))
   716              (found_really_genuine, max_potential, max_genuine, donno + 1))
   719           | KK.KodkodiNotInstalled =>
       
   720             (print_nt (K kodkodi_not_installed_message);
       
   721              (found_really_genuine, max_potential, max_genuine, donno + 1))
       
   722           | KK.Normal ([], unsat_js, s) =>
   717           | KK.Normal ([], unsat_js, s) =>
   723             (update_checked_problems problems unsat_js; show_kodkod_warning s;
   718             (update_checked_problems problems unsat_js; show_kodkod_warning s;
   724              (found_really_genuine, max_potential, max_genuine, donno))
   719              (found_really_genuine, max_potential, max_genuine, donno))
   725           | KK.Normal (sat_ps, unsat_js, s) =>
   720           | KK.Normal (sat_ps, unsat_js, s) =>
   726             let
   721             let
   958                       subst def_assm_ts nondef_assm_ts orig_t =
   953                       subst def_assm_ts nondef_assm_ts orig_t =
   959   let
   954   let
   960     val print_nt = if is_mode_nt mode then writeln else K ()
   955     val print_nt = if is_mode_nt mode then writeln else K ()
   961     val print_t = if mode = TPTP then writeln else K ()
   956     val print_t = if mode = TPTP then writeln else K ()
   962   in
   957   in
   963     if getenv "KODKODI" = "" then
   958     let
   964       (* The "expect" argument is deliberately ignored if Kodkodi is missing so
   959       val unknown_outcome = (unknownN, [])
   965          that the "Nitpick_Examples" can be processed on any machine. *)
   960       val deadline = Time.now () + timeout
   966       (print_nt (Pretty.string_of (plazy (K kodkodi_not_installed_message)));
   961       val outcome as (outcome_code, _) =
   967        ("no_kodkodi", []))
   962         Timeout.apply (timeout + timeout_bonus)
   968     else
   963             (pick_them_nits_in_term deadline state params mode i n step subst
   969       let
   964                                     def_assm_ts nondef_assm_ts) orig_t
   970         val unknown_outcome = (unknownN, [])
   965         handle TOO_LARGE (_, details) =>
   971         val deadline = Time.now () + timeout
   966                (print_t "% SZS status GaveUp";
   972         val outcome as (outcome_code, _) =
   967                 print_nt ("Limit reached: " ^ details); unknown_outcome)
   973           Timeout.apply (timeout + timeout_bonus)
   968              | TOO_SMALL (_, details) =>
   974               (pick_them_nits_in_term deadline state params mode i n step subst
   969                (print_t "% SZS status GaveUp";
   975                                       def_assm_ts nondef_assm_ts) orig_t
   970                 print_nt ("Limit reached: " ^ details); unknown_outcome)
   976           handle TOO_LARGE (_, details) =>
   971              | Kodkod.SYNTAX (_, details) =>
   977                  (print_t "% SZS status GaveUp";
   972                (print_t "% SZS status GaveUp";
   978                   print_nt ("Limit reached: " ^ details); unknown_outcome)
   973                 print_nt ("Malformed Kodkodi output: " ^ details);
   979                | TOO_SMALL (_, details) =>
   974                 unknown_outcome)
   980                  (print_t "% SZS status GaveUp";
   975              | Timeout.TIMEOUT _ =>
   981                   print_nt ("Limit reached: " ^ details); unknown_outcome)
   976                (print_t "% SZS status TimedOut";
   982                | Kodkod.SYNTAX (_, details) =>
   977                 print_nt "Nitpick ran out of time"; unknown_outcome)
   983                  (print_t "% SZS status GaveUp";
   978     in
   984                   print_nt ("Malformed Kodkodi output: " ^ details);
   979       if expect = "" orelse outcome_code = expect then outcome
   985                   unknown_outcome)
   980       else error ("Unexpected outcome: " ^ quote outcome_code)
   986                | Timeout.TIMEOUT _ =>
   981     end
   987                  (print_t "% SZS status TimedOut";
       
   988                   print_nt "Nitpick ran out of time"; unknown_outcome)
       
   989       in
       
   990         if expect = "" orelse outcome_code = expect then outcome
       
   991         else error ("Unexpected outcome: " ^ quote outcome_code)
       
   992       end
       
   993   end
   982   end
   994 
   983 
   995 fun is_fixed_equation ctxt
   984 fun is_fixed_equation ctxt
   996                       (Const (\<^const_name>\<open>Pure.eq\<close>, _) $ Free (s, _) $ Const _) =
   985                       (Const (\<^const_name>\<open>Pure.eq\<close>, _) $ Free (s, _) $ Const _) =
   997     Variable.is_fixed ctxt s
   986     Variable.is_fixed ctxt s