src/HOL/Tools/Nitpick/nitpick.ML
changeset 37273 4a7fe945412d
parent 37216 3165bc303f66
parent 37260 dde817e6dfb1
child 37497 71fdbffe3275
equal deleted inserted replaced
37246:b3ff14122645 37273:4a7fe945412d
    40      max_threads: int,
    40      max_threads: int,
    41      show_datatypes: bool,
    41      show_datatypes: bool,
    42      show_consts: bool,
    42      show_consts: bool,
    43      evals: term list,
    43      evals: term list,
    44      formats: (term option * int list) list,
    44      formats: (term option * int list) list,
       
    45      atomss: (typ option * string list) list,
    45      max_potential: int,
    46      max_potential: int,
    46      max_genuine: int,
    47      max_genuine: int,
    47      check_potential: bool,
    48      check_potential: bool,
    48      check_genuine: bool,
    49      check_genuine: bool,
    49      batch_size: int,
    50      batch_size: int,
   110    max_threads: int,
   111    max_threads: int,
   111    show_datatypes: bool,
   112    show_datatypes: bool,
   112    show_consts: bool,
   113    show_consts: bool,
   113    evals: term list,
   114    evals: term list,
   114    formats: (term option * int list) list,
   115    formats: (term option * int list) list,
       
   116    atomss: (typ option * string list) list,
   115    max_potential: int,
   117    max_potential: int,
   116    max_genuine: int,
   118    max_genuine: int,
   117    check_potential: bool,
   119    check_potential: bool,
   118    check_genuine: bool,
   120    check_genuine: bool,
   119    batch_size: int,
   121    batch_size: int,
   188     val {cards_assigns, maxes_assigns, iters_assigns, bitss, bisim_depths,
   190     val {cards_assigns, maxes_assigns, iters_assigns, bitss, bisim_depths,
   189          boxes, finitizes, monos, stds, wfs, sat_solver, falsify, debug,
   191          boxes, finitizes, monos, stds, wfs, sat_solver, falsify, debug,
   190          verbose, overlord, user_axioms, assms, merge_type_vars, binary_ints,
   192          verbose, overlord, user_axioms, assms, merge_type_vars, binary_ints,
   191          destroy_constrs, specialize, star_linear_preds, fast_descrs,
   193          destroy_constrs, specialize, star_linear_preds, fast_descrs,
   192          peephole_optim, tac_timeout, max_threads, show_datatypes, show_consts,
   194          peephole_optim, tac_timeout, max_threads, show_datatypes, show_consts,
   193          evals, formats, max_potential, max_genuine, check_potential,
   195          evals, formats, atomss, max_potential, max_genuine, check_potential,
   194          check_genuine, batch_size, ...} = params
   196          check_genuine, batch_size, ...} = params
   195     val state_ref = Unsynchronized.ref state
   197     val state_ref = Unsynchronized.ref state
   196     val pprint =
   198     val pprint =
   197       if auto then
   199       if auto then
   198         Unsynchronized.change state_ref o Proof.goal_message o K
   200         Unsynchronized.change state_ref o Proof.goal_message o K
   233     val (assms_t, evals) =
   235     val (assms_t, evals) =
   234       assms_t :: evals |> merge_type_vars ? merge_type_vars_in_terms
   236       assms_t :: evals |> merge_type_vars ? merge_type_vars_in_terms
   235                        |> pairf hd tl
   237                        |> pairf hd tl
   236     val original_max_potential = max_potential
   238     val original_max_potential = max_potential
   237     val original_max_genuine = max_genuine
   239     val original_max_genuine = max_genuine
   238 (*
       
   239     val _ = print_g ("*** " ^ Syntax.string_of_term ctxt orig_t)
       
   240     val _ = List.app (fn t => print_g ("*** " ^ Syntax.string_of_term ctxt t))
       
   241                      orig_assm_ts
       
   242 *)
       
   243     val max_bisim_depth = fold Integer.max bisim_depths ~1
   240     val max_bisim_depth = fold Integer.max bisim_depths ~1
   244     val case_names = case_const_names thy stds
   241     val case_names = case_const_names thy stds
   245     val (defs, built_in_nondefs, user_nondefs) = all_axioms_of thy subst
   242     val (defs, built_in_nondefs, user_nondefs) = all_axioms_of ctxt subst
   246     val def_table = const_def_table ctxt subst defs
   243     val def_table = const_def_table ctxt subst defs
   247     val nondef_table = const_nondef_table (built_in_nondefs @ user_nondefs)
   244     val nondef_table = const_nondef_table (built_in_nondefs @ user_nondefs)
   248     val simp_table = Unsynchronized.ref (const_simp_table ctxt subst)
   245     val simp_table = Unsynchronized.ref (const_simp_table ctxt subst)
   249     val psimp_table = const_psimp_table ctxt subst
   246     val psimp_table = const_psimp_table ctxt subst
   250     val choice_spec_table = const_choice_spec_table ctxt subst
   247     val choice_spec_table = const_choice_spec_table ctxt subst
   320          else
   317          else
   321            (if length ss = 1 then "is" else "are") ^ " considered monotonic") ^
   318            (if length ss = 1 then "is" else "are") ^ " considered monotonic") ^
   322         ". " ^ extra
   319         ". " ^ extra
   323       end
   320       end
   324     fun is_type_fundamentally_monotonic T =
   321     fun is_type_fundamentally_monotonic T =
   325       (is_datatype thy stds T andalso not (is_quot_type thy T) andalso
   322       (is_datatype ctxt stds T andalso not (is_quot_type thy T) andalso
   326        (not (is_pure_typedef thy T) orelse is_univ_typedef thy T)) orelse
   323        (not (is_pure_typedef ctxt T) orelse is_univ_typedef ctxt T)) orelse
   327       is_number_type thy T orelse is_bit_type T
   324       is_number_type thy T orelse is_bit_type T
   328     fun is_type_actually_monotonic T =
   325     fun is_type_actually_monotonic T =
   329       formulas_monotonic hol_ctxt binarize T (nondef_ts, def_ts)
   326       formulas_monotonic hol_ctxt binarize T (nondef_ts, def_ts)
   330     fun is_type_kind_of_monotonic T =
   327     fun is_type_kind_of_monotonic T =
   331       case triple_lookup (type_match thy) monos T of
   328       case triple_lookup (type_match thy) monos T of
   367           print_v (K (monotonicity_message interesting_mono_Ts
   364           print_v (K (monotonicity_message interesting_mono_Ts
   368                          "Nitpick might be able to skip some scopes."))
   365                          "Nitpick might be able to skip some scopes."))
   369       else
   366       else
   370         ()
   367         ()
   371     val (deep_dataTs, shallow_dataTs) =
   368     val (deep_dataTs, shallow_dataTs) =
   372       all_Ts |> filter (is_datatype thy stds) |> List.partition is_datatype_deep
   369       all_Ts |> filter (is_datatype ctxt stds)
       
   370              |> List.partition is_datatype_deep
   373     val finitizable_dataTs =
   371     val finitizable_dataTs =
   374       shallow_dataTs |> filter_out (is_finite_type hol_ctxt)
   372       shallow_dataTs |> filter_out (is_finite_type hol_ctxt)
   375                      |> filter is_shallow_datatype_finitizable
   373                      |> filter is_shallow_datatype_finitizable
   376     val _ =
   374     val _ =
   377       if verbose andalso not (null finitizable_dataTs) then
   375       if verbose andalso not (null finitizable_dataTs) then
   577              : problem_extension) =
   575              : problem_extension) =
   578       let
   576       let
   579         val (reconstructed_model, codatatypes_ok) =
   577         val (reconstructed_model, codatatypes_ok) =
   580           reconstruct_hol_model {show_datatypes = show_datatypes,
   578           reconstruct_hol_model {show_datatypes = show_datatypes,
   581                                  show_consts = show_consts}
   579                                  show_consts = show_consts}
   582               scope formats frees free_names sel_names nonsel_names rel_table
   580               scope formats atomss frees free_names sel_names nonsel_names
   583               bounds
   581               rel_table bounds
   584         val genuine_means_genuine =
   582         val genuine_means_genuine =
   585           got_all_user_axioms andalso none_true wfs andalso
   583           got_all_user_axioms andalso none_true wfs andalso
   586           sound_finitizes andalso codatatypes_ok
   584           sound_finitizes andalso codatatypes_ok
   587       in
   585       in
   588         (pprint (Pretty.chunks
   586         (pprint (Pretty.chunks