src/HOL/Tools/Nitpick/nitpick_model.ML
changeset 36385 ff5f88702590
parent 36384 76d5fd5a45fb
child 36388 30f7ce76712d
     1.1 --- a/src/HOL/Tools/Nitpick/nitpick_model.ML	Sat Apr 24 16:17:30 2010 +0200
     1.2 +++ b/src/HOL/Tools/Nitpick/nitpick_model.ML	Sat Apr 24 16:33:01 2010 +0200
     1.3 @@ -16,7 +16,6 @@
     1.4      show_skolems: bool,
     1.5      show_datatypes: bool,
     1.6      show_consts: bool}
     1.7 -
     1.8    type term_postprocessor =
     1.9      Proof.context -> string -> (typ -> term list) -> typ -> term -> term
    1.10  
    1.11 @@ -82,10 +81,8 @@
    1.12  
    1.13  type atom_pool = ((string * int) * int list) list
    1.14  
    1.15 -(* Proof.context -> ((string * string) * (string * string)) * Proof.context *)
    1.16  fun add_wacky_syntax ctxt =
    1.17    let
    1.18 -    (* term -> string *)
    1.19      val name_of = fst o dest_Const
    1.20      val thy = ProofContext.theory_of ctxt |> Context.reject_draft
    1.21      val (maybe_t, thy) =
    1.22 @@ -107,7 +104,6 @@
    1.23  
    1.24  (** Term reconstruction **)
    1.25  
    1.26 -(* atom_pool Unsynchronized.ref -> string -> int -> int -> string *)
    1.27  fun nth_atom_suffix pool s j k =
    1.28    (case AList.lookup (op =) (!pool) (s, k) of
    1.29       SOME js =>
    1.30 @@ -119,7 +115,6 @@
    1.31    |> nat_subscript
    1.32    |> (s <> "" andalso Symbol.is_ascii_digit (List.last (explode s)))
    1.33       ? prefix "\<^isub>,"
    1.34 -(* atom_pool Unsynchronized.ref -> string -> typ -> int -> int -> string *)
    1.35  fun nth_atom_name pool prefix (Type (s, _)) j k =
    1.36      let val s' = shortest_name s in
    1.37        prefix ^ (if String.isPrefix "\\" s' then s' else substring (s', 0, 1)) ^
    1.38 @@ -129,18 +124,15 @@
    1.39      prefix ^ perhaps (try (unprefix "'")) s ^ nth_atom_suffix pool s j k
    1.40    | nth_atom_name _ _ T _ _ =
    1.41      raise TYPE ("Nitpick_Model.nth_atom_name", [T], [])
    1.42 -(* atom_pool Unsynchronized.ref -> bool -> typ -> int -> int -> term *)
    1.43  fun nth_atom pool for_auto T j k =
    1.44    if for_auto then
    1.45      Free (nth_atom_name pool (hd (space_explode "." nitpick_prefix)) T j k, T)
    1.46    else
    1.47      Const (nth_atom_name pool "" T j k, T)
    1.48  
    1.49 -(* term -> real *)
    1.50  fun extract_real_number (Const (@{const_name divide}, _) $ t1 $ t2) =
    1.51      real (snd (HOLogic.dest_number t1)) / real (snd (HOLogic.dest_number t2))
    1.52    | extract_real_number t = real (snd (HOLogic.dest_number t))
    1.53 -(* term * term -> order *)
    1.54  fun nice_term_ord (Abs (_, _, t1), Abs (_, _, t2)) = nice_term_ord (t1, t2)
    1.55    | nice_term_ord tp = Real.compare (pairself extract_real_number tp)
    1.56      handle TERM ("dest_number", _) =>
    1.57 @@ -151,16 +143,12 @@
    1.58                | ord => ord)
    1.59             | _ => Term_Ord.fast_term_ord tp
    1.60  
    1.61 -(* typ -> term_postprocessor -> theory -> theory *)
    1.62  fun register_term_postprocessor T p = Data.map (cons (T, p))
    1.63 -(* typ -> theory -> theory *)
    1.64  fun unregister_term_postprocessor T = Data.map (AList.delete (op =) T)
    1.65  
    1.66 -(* nut NameTable.table -> KK.raw_bound list -> nut -> int list list *)
    1.67  fun tuple_list_for_name rel_table bounds name =
    1.68    the (AList.lookup (op =) bounds (the_rel rel_table name)) handle NUT _ => [[]]
    1.69  
    1.70 -(* term -> term *)
    1.71  fun unarize_unbox_etc_term (Const (@{const_name FinFun}, _) $ t1) =
    1.72      unarize_unbox_etc_term t1
    1.73    | unarize_unbox_etc_term (Const (@{const_name FunBox}, _) $ t1) =
    1.74 @@ -185,7 +173,6 @@
    1.75    | unarize_unbox_etc_term (Abs (s, T, t')) =
    1.76      Abs (s, uniterize_unarize_unbox_etc_type T, unarize_unbox_etc_term t')
    1.77  
    1.78 -(* typ -> typ -> (typ * typ) * (typ * typ) *)
    1.79  fun factor_out_types (T1 as Type (@{type_name "*"}, [T11, T12]))
    1.80                       (T2 as Type (@{type_name "*"}, [T21, T22])) =
    1.81      let val (n1, n2) = pairself num_factors_in_type (T11, T21) in
    1.82 @@ -210,25 +197,20 @@
    1.83      ((T1, NONE), (T21, SOME T22))
    1.84    | factor_out_types T1 T2 = ((T1, NONE), (T2, NONE))
    1.85  
    1.86 -(* bool -> typ -> typ -> (term * term) list -> term *)
    1.87  fun make_plain_fun maybe_opt T1 T2 =
    1.88    let
    1.89 -    (* typ -> typ -> (term * term) list -> term *)
    1.90      fun aux T1 T2 [] =
    1.91          Const (if maybe_opt then opt_flag else non_opt_flag, T1 --> T2)
    1.92        | aux T1 T2 ((t1, t2) :: tps) =
    1.93          Const (@{const_name fun_upd}, (T1 --> T2) --> T1 --> T2 --> T1 --> T2)
    1.94          $ aux T1 T2 tps $ t1 $ t2
    1.95    in aux T1 T2 o rev end
    1.96 -(* term -> bool *)
    1.97  fun is_plain_fun (Const (s, _)) = (s = opt_flag orelse s = non_opt_flag)
    1.98    | is_plain_fun (Const (@{const_name fun_upd}, _) $ t0 $ _ $ _) =
    1.99      is_plain_fun t0
   1.100    | is_plain_fun _ = false
   1.101 -(* term -> bool * (term list * term list) *)
   1.102  val dest_plain_fun =
   1.103    let
   1.104 -    (* term -> bool * (term list * term list) *)
   1.105      fun aux (Abs (_, _, Const (s, _))) = (s <> irrelevant, ([], []))
   1.106        | aux (Const (s, _)) = (s <> non_opt_flag, ([], []))
   1.107        | aux (Const (@{const_name fun_upd}, _) $ t0 $ t1 $ t2) =
   1.108 @@ -238,7 +220,6 @@
   1.109        | aux t = raise TERM ("Nitpick_Model.dest_plain_fun", [t])
   1.110    in apsnd (pairself rev) o aux end
   1.111  
   1.112 -(* typ -> typ -> typ -> term -> term * term *)
   1.113  fun break_in_two T T1 T2 t =
   1.114    let
   1.115      val ps = HOLogic.flat_tupleT_paths T
   1.116 @@ -246,7 +227,6 @@
   1.117      val (ps1, ps2) = pairself HOLogic.flat_tupleT_paths (T1, T2)
   1.118      val (ts1, ts2) = t |> HOLogic.strip_ptuple ps |> chop cut
   1.119    in (HOLogic.mk_ptuple ps1 T1 ts1, HOLogic.mk_ptuple ps2 T2 ts2) end
   1.120 -(* typ -> term -> term -> term *)
   1.121  fun pair_up (Type (@{type_name "*"}, [T1', T2']))
   1.122              (t1 as Const (@{const_name Pair},
   1.123                            Type (@{type_name fun},
   1.124 @@ -255,13 +235,10 @@
   1.125      if T1 = T1' then HOLogic.mk_prod (t1, t2)
   1.126      else HOLogic.mk_prod (t11, pair_up T2' t12 t2)
   1.127    | pair_up _ t1 t2 = HOLogic.mk_prod (t1, t2)
   1.128 -(* typ -> term -> term list * term list -> (term * term) list*)
   1.129  fun multi_pair_up T1 t1 (ts2, ts3) = map2 (pair o pair_up T1 t1) ts2 ts3
   1.130  
   1.131 -(* typ -> typ -> typ -> term -> term *)
   1.132  fun typecast_fun (Type (@{type_name fun}, [T1', T2'])) T1 T2 t =
   1.133      let
   1.134 -      (* typ -> typ -> typ -> typ -> term -> term *)
   1.135        fun do_curry T1 T1a T1b T2 t =
   1.136          let
   1.137            val (maybe_opt, tsp) = dest_plain_fun t
   1.138 @@ -271,7 +248,6 @@
   1.139                  |> AList.coalesce (op =)
   1.140                  |> map (apsnd (make_plain_fun maybe_opt T1b T2))
   1.141          in make_plain_fun maybe_opt T1a (T1b --> T2) tps end
   1.142 -      (* typ -> typ -> term -> term *)
   1.143        and do_uncurry T1 T2 t =
   1.144          let
   1.145            val (maybe_opt, tsp) = dest_plain_fun t
   1.146 @@ -280,7 +256,6 @@
   1.147                  |> maps (fn (t1, t2) =>
   1.148                              multi_pair_up T1 t1 (snd (dest_plain_fun t2)))
   1.149          in make_plain_fun maybe_opt T1 T2 tps end
   1.150 -      (* typ -> typ -> typ -> typ -> term -> term *)
   1.151        and do_arrow T1' T2' _ _ (Const (s, _)) = Const (s, T1' --> T2')
   1.152          | do_arrow T1' T2' T1 T2
   1.153                     (Const (@{const_name fun_upd}, _) $ t0 $ t1 $ t2) =
   1.154 @@ -297,7 +272,6 @@
   1.155          | ((T1a', SOME T1b'), (_, NONE)) =>
   1.156            t |> do_arrow T1a' (T1b' --> T2') T1 T2 |> do_uncurry T1' T2'
   1.157          | _ => raise TYPE ("Nitpick_Model.typecast_fun.do_fun", [T1, T1'], [])
   1.158 -      (* typ -> typ -> term -> term *)
   1.159        and do_term (Type (@{type_name fun}, [T1', T2']))
   1.160                    (Type (@{type_name fun}, [T1, T2])) t =
   1.161            do_fun T1' T2' T1 T2 t
   1.162 @@ -313,33 +287,25 @@
   1.163    | typecast_fun T' _ _ _ =
   1.164      raise TYPE ("Nitpick_Model.typecast_fun", [T'], [])
   1.165  
   1.166 -(* term -> string *)
   1.167  fun truth_const_sort_key @{const True} = "0"
   1.168    | truth_const_sort_key @{const False} = "2"
   1.169    | truth_const_sort_key _ = "1"
   1.170  
   1.171 -(* typ -> term list -> term *)
   1.172  fun mk_tuple (Type (@{type_name "*"}, [T1, T2])) ts =
   1.173      HOLogic.mk_prod (mk_tuple T1 ts,
   1.174          mk_tuple T2 (List.drop (ts, length (HOLogic.flatten_tupleT T1))))
   1.175    | mk_tuple _ (t :: _) = t
   1.176    | mk_tuple T [] = raise TYPE ("Nitpick_Model.mk_tuple", [T], [])
   1.177  
   1.178 -(* theory -> typ * typ -> bool *)
   1.179  fun varified_type_match thy (candid_T, pat_T) =
   1.180    strict_type_match thy (candid_T, Logic.varifyT_global pat_T)
   1.181  
   1.182 -(* atom_pool -> (string * string) * (string * string) -> scope -> nut list
   1.183 -   -> nut list -> nut list -> nut NameTable.table -> KK.raw_bound list -> typ
   1.184 -   -> term list *)
   1.185  fun all_values_of_type pool wacky_names (scope as {card_assigns, ...} : scope)
   1.186                         sel_names rel_table bounds card T =
   1.187    let
   1.188      val card = if card = 0 then card_of_type card_assigns T else card
   1.189 -    (* nat -> term *)
   1.190      fun nth_value_of_type n =
   1.191        let
   1.192 -        (* bool -> term *)
   1.193          fun term unfold =
   1.194            reconstruct_term unfold pool wacky_names scope sel_names rel_table
   1.195                             bounds T T (Atom (card, 0)) [[n]]
   1.196 @@ -353,15 +319,11 @@
   1.197          | t => t
   1.198        end
   1.199    in index_seq 0 card |> map nth_value_of_type |> sort nice_term_ord end
   1.200 -(* bool -> atom_pool -> (string * string) * (string * string) -> scope
   1.201 -   -> nut list -> nut list -> nut list -> nut NameTable.table
   1.202 -   -> KK.raw_bound list -> typ -> typ -> rep -> int list list -> term *)
   1.203  and reconstruct_term unfold pool (wacky_names as ((maybe_name, abs_name), _))
   1.204          (scope as {hol_ctxt as {ctxt, thy, stds, ...}, binarize, card_assigns,
   1.205                     bits, datatypes, ofs, ...}) sel_names rel_table bounds =
   1.206    let
   1.207      val for_auto = (maybe_name = "")
   1.208 -    (* int list list -> int *)
   1.209      fun value_of_bits jss =
   1.210        let
   1.211          val j0 = offset_of_type ofs @{typ unsigned_bit}
   1.212 @@ -370,10 +332,8 @@
   1.213          fold (fn j => Integer.add (reasonable_power 2 j |> j = bits ? op ~))
   1.214               js 0
   1.215        end
   1.216 -    (* typ -> term list *)
   1.217      val all_values =
   1.218        all_values_of_type pool wacky_names scope sel_names rel_table bounds 0
   1.219 -    (* typ -> term -> term *)
   1.220      fun postprocess_term (Type (@{type_name fun}, _)) = I
   1.221        | postprocess_term T =
   1.222          if null (Data.get thy) then
   1.223 @@ -381,7 +341,6 @@
   1.224          else case AList.lookup (varified_type_match thy) (Data.get thy) T of
   1.225            SOME postproc => postproc ctxt maybe_name all_values T
   1.226          | NONE => I
   1.227 -    (* typ list -> term -> term *)
   1.228      fun postprocess_subterms Ts (t1 $ t2) =
   1.229          let val t = postprocess_subterms Ts t1 $ postprocess_subterms Ts t2 in
   1.230            postprocess_term (fastype_of1 (Ts, t)) t
   1.231 @@ -389,13 +348,11 @@
   1.232        | postprocess_subterms Ts (Abs (s, T, t')) =
   1.233          Abs (s, T, postprocess_subterms (T :: Ts) t')
   1.234        | postprocess_subterms Ts t = postprocess_term (fastype_of1 (Ts, t)) t
   1.235 -    (* bool -> typ -> typ -> (term * term) list -> term *)
   1.236      fun make_set maybe_opt T1 T2 tps =
   1.237        let
   1.238          val empty_const = Const (@{const_abbrev Set.empty}, T1 --> T2)
   1.239          val insert_const = Const (@{const_name insert},
   1.240                                    T1 --> (T1 --> T2) --> T1 --> T2)
   1.241 -        (* (term * term) list -> term *)
   1.242          fun aux [] =
   1.243              if maybe_opt andalso not (is_complete_type datatypes false T1) then
   1.244                insert_const $ Const (unrep, T1) $ empty_const
   1.245 @@ -416,12 +373,10 @@
   1.246          else
   1.247            aux tps
   1.248        end
   1.249 -    (* bool -> typ -> typ -> typ -> (term * term) list -> term *)
   1.250      fun make_map maybe_opt T1 T2 T2' =
   1.251        let
   1.252          val update_const = Const (@{const_name fun_upd},
   1.253                                    (T1 --> T2) --> T1 --> T2 --> T1 --> T2)
   1.254 -        (* (term * term) list -> term *)
   1.255          fun aux' [] = Const (@{const_abbrev Map.empty}, T1 --> T2)
   1.256            | aux' ((t1, t2) :: tps) =
   1.257              (case t2 of
   1.258 @@ -434,7 +389,6 @@
   1.259            else
   1.260              aux' tps
   1.261        in aux end
   1.262 -    (* typ list -> term -> term *)
   1.263      fun polish_funs Ts t =
   1.264        (case fastype_of1 (Ts, t) of
   1.265           Type (@{type_name fun}, [T1, T2]) =>
   1.266 @@ -475,7 +429,6 @@
   1.267                 else
   1.268                   t
   1.269               | t => t
   1.270 -    (* bool -> typ -> typ -> typ -> term list -> term list -> term *)
   1.271      fun make_fun maybe_opt T1 T2 T' ts1 ts2 =
   1.272        ts1 ~~ ts2 |> sort (nice_term_ord o pairself fst)
   1.273                   |> make_plain_fun maybe_opt T1 T2
   1.274 @@ -483,7 +436,6 @@
   1.275                   |> typecast_fun (uniterize_unarize_unbox_etc_type T')
   1.276                                   (uniterize_unarize_unbox_etc_type T1)
   1.277                                   (uniterize_unarize_unbox_etc_type T2)
   1.278 -    (* (typ * int) list -> typ -> typ -> int -> term *)
   1.279      fun term_for_atom seen (T as Type (@{type_name fun}, [T1, T2])) T' j _ =
   1.280          let
   1.281            val k1 = card_of_type card_assigns T1
   1.282 @@ -524,10 +476,8 @@
   1.283          | SOME {deep = false, ...} => nth_atom pool for_auto T j k
   1.284          | SOME {co, standard, constrs, ...} =>
   1.285            let
   1.286 -            (* styp -> int list *)
   1.287              fun tuples_for_const (s, T) =
   1.288                tuple_list_for_name rel_table bounds (ConstName (s, T, Any))
   1.289 -            (* unit -> term *)
   1.290              fun cyclic_atom () =
   1.291                nth_atom pool for_auto (Type (cyclic_type_name, [])) j k
   1.292              fun cyclic_var () = Var ((nth_atom_name pool "" T j k, 0), T)
   1.293 @@ -616,14 +566,11 @@
   1.294                    t
   1.295                end
   1.296            end
   1.297 -    (* (typ * int) list -> int -> rep -> typ -> typ -> typ -> int list
   1.298 -       -> term *)
   1.299      and term_for_vect seen k R T1 T2 T' js =
   1.300        make_fun true T1 T2 T'
   1.301                 (map (fn j => term_for_atom seen T1 T1 j k) (index_seq 0 k))
   1.302                 (map (term_for_rep true seen T2 T2 R o single)
   1.303                      (batch_list (arity_of_rep R) js))
   1.304 -    (* bool -> (typ * int) list -> typ -> typ -> rep -> int list list -> term *)
   1.305      and term_for_rep _ seen T T' Unit [[]] = term_for_atom seen T T' 0 1
   1.306        | term_for_rep _ seen T T' (R as Atom (k, j0)) [[j]] =
   1.307          if j >= j0 andalso j < j0 + k then term_for_atom seen T T' (j - j0) k
   1.308 @@ -675,14 +622,12 @@
   1.309  
   1.310  (** Constant postprocessing **)
   1.311  
   1.312 -(* int -> typ -> typ list *)
   1.313  fun dest_n_tuple_type 1 T = [T]
   1.314    | dest_n_tuple_type n (Type (_, [T1, T2])) =
   1.315      T1 :: dest_n_tuple_type (n - 1) T2
   1.316    | dest_n_tuple_type _ T =
   1.317      raise TYPE ("Nitpick_Model.dest_n_tuple_type", [T], [])
   1.318  
   1.319 -(* theory -> const_table -> styp -> int list *)
   1.320  fun const_format thy def_table (x as (s, T)) =
   1.321    if String.isPrefix unrolled_prefix s then
   1.322      const_format thy def_table (original_name s, range_type T)
   1.323 @@ -702,7 +647,6 @@
   1.324                 else
   1.325                   [num_binder_types T]
   1.326    | NONE => [num_binder_types T]
   1.327 -(* int list -> int list -> int list *)
   1.328  fun intersect_formats _ [] = []
   1.329    | intersect_formats [] _ = []
   1.330    | intersect_formats ks1 ks2 =
   1.331 @@ -712,7 +656,6 @@
   1.332        [Int.min (k1, k2)]
   1.333      end
   1.334  
   1.335 -(* theory -> const_table -> (term option * int list) list -> term -> int list *)
   1.336  fun lookup_format thy def_table formats t =
   1.337    case AList.lookup (fn (SOME x, SOME y) =>
   1.338                          (term_match thy) (x, y) | _ => false)
   1.339 @@ -725,7 +668,6 @@
   1.340                | _ => format
   1.341              end
   1.342  
   1.343 -(* int list -> int list -> typ -> typ *)
   1.344  fun format_type default_format format T =
   1.345    let
   1.346      val T = uniterize_unarize_unbox_etc_type T
   1.347 @@ -743,28 +685,22 @@
   1.348            |> map (HOLogic.mk_tupleT o rev)
   1.349        in List.foldl (op -->) body_T batched end
   1.350    end
   1.351 -(* theory -> const_table -> (term option * int list) list -> term -> typ *)
   1.352  fun format_term_type thy def_table formats t =
   1.353    format_type (the (AList.lookup (op =) formats NONE))
   1.354                (lookup_format thy def_table formats t) (fastype_of t)
   1.355  
   1.356 -(* int list -> int -> int list -> int list *)
   1.357  fun repair_special_format js m format =
   1.358    m - 1 downto 0 |> chunk_list_unevenly (rev format)
   1.359                   |> map (rev o filter_out (member (op =) js))
   1.360                   |> filter_out null |> map length |> rev
   1.361  
   1.362 -(* hol_context -> string * string -> (term option * int list) list
   1.363 -   -> styp -> term * typ *)
   1.364  fun user_friendly_const ({thy, evals, def_table, skolems, special_funs, ...}
   1.365                           : hol_context) (base_name, step_name) formats =
   1.366    let
   1.367      val default_format = the (AList.lookup (op =) formats NONE)
   1.368 -    (* styp -> term * typ *)
   1.369      fun do_const (x as (s, T)) =
   1.370        (if String.isPrefix special_prefix s then
   1.371           let
   1.372 -           (* term -> term *)
   1.373             val do_term = map_aterms (fn Const x => fst (do_const x) | t' => t')
   1.374             val (x' as (_, T'), js, ts) =
   1.375               AList.find (op =) (!special_funs) (s, unarize_unbox_etc_type T)
   1.376 @@ -773,7 +709,6 @@
   1.377             val Ts = List.take (binder_types T', max_j + 1)
   1.378             val missing_js = filter_out (member (op =) js) (0 upto max_j)
   1.379             val missing_Ts = filter_indices missing_js Ts
   1.380 -           (* int -> indexname *)
   1.381             fun nth_missing_var n =
   1.382               ((arg_var_prefix ^ nat_subscript (n + 1), 0), nth missing_Ts n)
   1.383             val missing_vars = map nth_missing_var (0 upto length missing_js - 1)
   1.384 @@ -865,7 +800,6 @@
   1.385        |>> shorten_names_in_term |>> Term.map_abs_vars shortest_name
   1.386    in do_const end
   1.387  
   1.388 -(* styp -> string *)
   1.389  fun assign_operator_for_const (s, T) =
   1.390    if String.isPrefix ubfp_prefix s then
   1.391      if is_fun_type T then "\<subseteq>" else "\<le>"
   1.392 @@ -878,8 +812,6 @@
   1.393  
   1.394  (** Model reconstruction **)
   1.395  
   1.396 -(* atom_pool -> scope -> nut list -> nut NameTable.table -> KK.raw_bound list
   1.397 -   -> nut -> term *)
   1.398  fun term_for_name pool scope sel_names rel_table bounds name =
   1.399    let val T = type_of name in
   1.400      tuple_list_for_name rel_table bounds name
   1.401 @@ -887,13 +819,11 @@
   1.402                          rel_table bounds T T (rep_of name)
   1.403    end
   1.404  
   1.405 -(* term -> term *)
   1.406  fun unfold_outer_the_binders (t as Const (@{const_name The}, _)
   1.407                                     $ Abs (s, T, Const (@{const_name "op ="}, _)
   1.408                                                  $ Bound 0 $ t')) =
   1.409      betapply (Abs (s, T, t'), t) |> unfold_outer_the_binders
   1.410    | unfold_outer_the_binders t = t
   1.411 -(* typ list -> int -> term * term -> bool *)
   1.412  fun bisimilar_values _ 0 _ = true
   1.413    | bisimilar_values coTs max_depth (t1, t2) =
   1.414      let val T = fastype_of t1 in
   1.415 @@ -910,9 +840,6 @@
   1.416          t1 = t2
   1.417      end
   1.418  
   1.419 -(* params -> scope -> (term option * int list) list -> styp list -> nut list
   1.420 -  -> nut list -> nut list -> nut NameTable.table -> KK.raw_bound list
   1.421 -  -> Pretty.T * bool *)
   1.422  fun reconstruct_hol_model {show_skolems, show_datatypes, show_consts}
   1.423          ({hol_ctxt = {thy, ctxt, max_bisim_depth, boxes, stds, wfs, user_axioms,
   1.424                        debug, binary_ints, destroy_constrs, specialize,
   1.425 @@ -945,13 +872,10 @@
   1.426      val scope = {hol_ctxt = hol_ctxt, binarize = binarize,
   1.427                   card_assigns = card_assigns, bits = bits,
   1.428                   bisim_depth = bisim_depth, datatypes = datatypes, ofs = ofs}
   1.429 -    (* bool -> typ -> typ -> rep -> int list list -> term *)
   1.430      fun term_for_rep unfold =
   1.431        reconstruct_term unfold pool wacky_names scope sel_names rel_table bounds
   1.432 -    (* nat -> typ -> nat -> term *)
   1.433      fun nth_value_of_type card T n =
   1.434        let
   1.435 -        (* bool -> term *)
   1.436          fun aux unfold = term_for_rep unfold T T (Atom (card, 0)) [[n]]
   1.437        in
   1.438          case aux false of
   1.439 @@ -962,10 +886,8 @@
   1.440              t
   1.441          | t => t
   1.442        end
   1.443 -    (* nat -> typ -> term list *)
   1.444      val all_values =
   1.445        all_values_of_type pool wacky_names scope sel_names rel_table bounds
   1.446 -    (* dtype_spec list -> dtype_spec -> bool *)
   1.447      fun is_codatatype_wellformed (cos : dtype_spec list)
   1.448                                   ({typ, card, ...} : dtype_spec) =
   1.449        let
   1.450 @@ -975,7 +897,6 @@
   1.451          forall (not o bisimilar_values (map #typ cos) max_depth)
   1.452                 (all_distinct_unordered_pairs_of ts)
   1.453        end
   1.454 -    (* string -> Pretty.T *)
   1.455      fun pretty_for_assign name =
   1.456        let
   1.457          val (oper, (t1, T'), T) =
   1.458 @@ -999,7 +920,6 @@
   1.459              [setmp_show_all_types (Syntax.pretty_term ctxt) t1,
   1.460               Pretty.str oper, Syntax.pretty_term ctxt t2])
   1.461        end
   1.462 -    (* dtype_spec -> Pretty.T *)
   1.463      fun pretty_for_datatype ({typ, card, complete, ...} : dtype_spec) =
   1.464        Pretty.block (Pretty.breaks
   1.465            (Syntax.pretty_typ ctxt (uniterize_unarize_unbox_etc_type typ) ::
   1.466 @@ -1013,7 +933,6 @@
   1.467                  (map (Syntax.pretty_term ctxt) (all_values card typ) @
   1.468                   (if fun_from_pair complete false then []
   1.469                    else [Pretty.str unrep]))]))
   1.470 -    (* typ -> dtype_spec list *)
   1.471      fun integer_datatype T =
   1.472        [{typ = T, card = card_of_type card_assigns T, co = false,
   1.473          standard = true, complete = (false, false), concrete = (true, true),
   1.474 @@ -1036,7 +955,6 @@
   1.475                           (map pretty_for_datatype codatatypes)]
   1.476        else
   1.477          []
   1.478 -    (* bool -> string -> nut list -> Pretty.T list *)
   1.479      fun block_of_names show title names =
   1.480        if show andalso not (null names) then
   1.481          Pretty.str (title ^ plural_s_for_list names ^ ":")
   1.482 @@ -1075,17 +993,13 @@
   1.483       forall (is_codatatype_wellformed codatatypes) codatatypes)
   1.484    end
   1.485  
   1.486 -(* scope -> Time.time option -> nut list -> nut list -> nut NameTable.table
   1.487 -   -> KK.raw_bound list -> term -> bool option *)
   1.488  fun prove_hol_model (scope as {hol_ctxt = {thy, ctxt, debug, ...},
   1.489                                 card_assigns, ...})
   1.490                      auto_timeout free_names sel_names rel_table bounds prop =
   1.491    let
   1.492      val pool = Unsynchronized.ref []
   1.493 -    (* typ * int -> term *)
   1.494      fun free_type_assm (T, k) =
   1.495        let
   1.496 -        (* int -> term *)
   1.497          fun atom j = nth_atom pool true T j k
   1.498          fun equation_for_atom j = HOLogic.eq_const T $ Bound 0 $ atom j
   1.499          val eqs = map equation_for_atom (index_seq 0 k)
   1.500 @@ -1094,14 +1008,12 @@
   1.501                $ Abs ("x", T, foldl1 HOLogic.mk_disj eqs)
   1.502          val distinct_assm = distinctness_formula T (map atom (index_seq 0 k))
   1.503        in s_conj (compreh_assm, distinct_assm) end
   1.504 -    (* nut -> term *)
   1.505      fun free_name_assm name =
   1.506        HOLogic.mk_eq (Free (nickname_of name, type_of name),
   1.507                       term_for_name pool scope sel_names rel_table bounds name)
   1.508      val freeT_assms = map free_type_assm (filter (is_TFree o fst) card_assigns)
   1.509      val model_assms = map free_name_assm free_names
   1.510      val assm = foldr1 s_conj (freeT_assms @ model_assms)
   1.511 -    (* bool -> bool *)
   1.512      fun try_out negate =
   1.513        let
   1.514          val concl = (negate ? curry (op $) @{const Not})