src/HOL/Tools/monomorph.ML
changeset 43234 9d717505595f
parent 43232 bd4d26327633
parent 43230 dabf6e311213
child 43251 f4d15a58ed8b
equal deleted inserted replaced
43233:2749c357f865 43234:9d717505595f
    35     typ list Symtab.table
    35     typ list Symtab.table
    36 
    36 
    37   (* configuration options *)
    37   (* configuration options *)
    38   val max_rounds: int Config.T
    38   val max_rounds: int Config.T
    39   val max_new_instances: int Config.T
    39   val max_new_instances: int Config.T
    40   val complete_instances: bool Config.T
    40   val keep_partial_instances: bool Config.T
    41 
    41 
    42   (* monomorphization *)
    42   (* monomorphization *)
    43   val monomorph: (term -> typ list Symtab.table) -> (int * thm) list ->
    43   val monomorph: (term -> typ list Symtab.table) -> (int * thm) list ->
    44     Proof.context -> (int * thm) list list * Proof.context
    44     Proof.context -> (int * thm) list list * Proof.context
    45 end
    45 end
    64 (* configuration options *)
    64 (* configuration options *)
    65 
    65 
    66 val max_rounds = Attrib.setup_config_int @{binding monomorph_max_rounds} (K 5)
    66 val max_rounds = Attrib.setup_config_int @{binding monomorph_max_rounds} (K 5)
    67 val max_new_instances =
    67 val max_new_instances =
    68   Attrib.setup_config_int @{binding monomorph_max_new_instances} (K 300)
    68   Attrib.setup_config_int @{binding monomorph_max_new_instances} (K 300)
    69 val complete_instances =
    69 val keep_partial_instances =
    70   Attrib.setup_config_bool @{binding monomorph_complete_instances} (K true)
    70   Attrib.setup_config_bool @{binding monomorph_keep_partial_instances} (K true)
    71 
    71 
    72 
    72 
    73 
    73 
    74 (* monomorphization *)
    74 (* monomorphization *)
    75 
    75 
   159 
   159 
   160 
   160 
   161 fun refine ctxt round known_grounds new_grounds (tvars, schematics) cx =
   161 fun refine ctxt round known_grounds new_grounds (tvars, schematics) cx =
   162   let
   162   let
   163     val thy = Proof_Context.theory_of ctxt
   163     val thy = Proof_Context.theory_of ctxt
   164     val count_partial = Config.get ctxt complete_instances
   164     val count_partial = Config.get ctxt keep_partial_instances
   165 
   165 
   166     fun add_new_ground subst n T =
   166     fun add_new_ground subst n T =
   167       let val T' = Envir.subst_type subst T
   167       let val T' = Envir.subst_type subst T
   168       in
   168       in
   169         (* FIXME: maybe keep types in a table or net for known_grounds,
   169         (* FIXME: maybe keep types in a table or net for known_grounds,
   285           Inttab.lookup_list subs index
   285           Inttab.lookup_list subs index
   286           |> map_filter (with_subst tvars (instantiate theorem))
   286           |> map_filter (with_subst tvars (instantiate theorem))
   287   in (map inst thm_infos, ctxt) end
   287   in (map inst thm_infos, ctxt) end
   288 
   288 
   289 fun instantiate_all ctxt thm_infos (_, (_, subs, _)) =
   289 fun instantiate_all ctxt thm_infos (_, (_, subs, _)) =
   290   if Config.get ctxt complete_instances then
   290   if Config.get ctxt keep_partial_instances then
   291     let fun is_refined ((_, _, refined), _) = refined
   291     let fun is_refined ((_, _, refined), _) = refined
   292     in
   292     in
   293       (Inttab.map (K (filter_out is_refined)) subs, thm_infos)
   293       (Inttab.map (K (filter_out is_refined)) subs, thm_infos)
   294       |-> instantiate_all' (new_super_type ctxt thm_infos)
   294       |-> instantiate_all' (new_super_type ctxt thm_infos)
   295     end
   295     end