src/HOL/Tools/Sledgehammer/sledgehammer_filter_mash.ML
changeset 48305 399f7e20e17f
parent 48304 50e64af9c829
child 48306 e699f754d9f7
equal deleted inserted replaced
48304:50e64af9c829 48305:399f7e20e17f
   278 
   278 
   279 fun mash_RESET () = (warning "MaSh RESET"; File.rm (mk_path model_file))
   279 fun mash_RESET () = (warning "MaSh RESET"; File.rm (mk_path model_file))
   280 
   280 
   281 val mash_ADD =
   281 val mash_ADD =
   282   let
   282   let
   283     fun add_fact (fact, access, feats, deps) =
   283     fun add_record (fact, access, feats, deps) =
   284       let
   284       let
   285         val s =
   285         val s =
   286           escape_meta fact ^ ": " ^ escape_metas access ^ "; " ^
   286           escape_meta fact ^ ": " ^ escape_metas access ^ "; " ^
   287           escape_metas feats ^ "; " ^ escape_metas deps
   287           escape_metas feats ^ "; " ^ escape_metas deps
   288       in warning ("MaSh ADD " ^ s) end
   288       in warning ("MaSh ADD " ^ s) end
   289   in List.app add_fact end
   289   in List.app add_record end
   290 
   290 
   291 fun mash_DEL facts feats =
   291 fun mash_DEL facts feats =
   292   warning ("MaSh DEL " ^ escape_metas facts ^ "; " ^ escape_metas feats)
   292   warning ("MaSh DEL " ^ escape_metas facts ^ "; " ^ escape_metas feats)
   293 
   293 
   294 fun mash_SUGGEST access feats =
   294 fun mash_SUGGEST access feats =
   348 val global_state =
   348 val global_state =
   349   Synchronized.var "Sledgehammer_Filter_MaSh.global_state" (false, empty_state)
   349   Synchronized.var "Sledgehammer_Filter_MaSh.global_state" (false, empty_state)
   350 
   350 
   351 in
   351 in
   352 
   352 
   353 fun mash_set state =
   353 fun mash_set f =
   354   Synchronized.change global_state (K (true, state |> tap mash_save))
   354   Synchronized.change global_state (fn _ => (true, f () |> tap mash_save))
   355 
   355 
   356 fun mash_change f =
   356 fun mash_change f =
   357   Synchronized.change global_state (mash_load ##> (f #> tap mash_save))
   357   Synchronized.change global_state (mash_load ##> (f #> tap mash_save))
   358 
   358 
   359 fun mash_peek f = Synchronized.change global_state (mash_load ##> tap f)
   359 fun mash_peek f = Synchronized.change global_state (mash_load ##> tap f)
   393     fun is_old (_, th) = is_fact_in_thy_facts thy_facts (Thm.get_name_hint th)
   393     fun is_old (_, th) = is_fact_in_thy_facts thy_facts (Thm.get_name_hint th)
   394     val (old_facts, new_facts) =
   394     val (old_facts, new_facts) =
   395       facts |> List.partition is_old ||> sort (thm_ord o pairself snd)
   395       facts |> List.partition is_old ||> sort (thm_ord o pairself snd)
   396     val ths = facts |> map snd
   396     val ths = facts |> map snd
   397     val all_names = ths |> map Thm.get_name_hint
   397     val all_names = ths |> map Thm.get_name_hint
   398     fun do_fact ((_, (_, status)), th) prevs =
   398     fun do_fact ((_, (_, status)), th) (prevs, records) =
   399       let
   399       let
   400         val name = Thm.get_name_hint th
   400         val name = Thm.get_name_hint th
   401         val feats = features_of thy status [prop_of th]
   401         val feats = features_of thy status [prop_of th]
   402         val deps = isabelle_dependencies_of all_names th
   402         val deps = isabelle_dependencies_of all_names th
   403         val kind = Thm.legacy_get_kind th
   403         val record = (name, prevs, feats, deps)
   404         val s =
   404       in ([name], record :: records) end
   405           "! " ^ escape_meta name ^ ": " ^ escape_metas prevs ^ "; " ^
       
   406           escape_metas feats ^ "; " ^ escape_metas deps ^ "\n"
       
   407       in [name] end
       
   408     val thy_facts = old_facts |> thy_facts_from_thms
   405     val thy_facts = old_facts |> thy_facts_from_thms
   409     val parents = parent_facts thy thy_facts
   406     val parents = parent_facts thy thy_facts
       
   407     val (_, records) = (parents, []) |> fold_rev do_fact new_facts
   410   in
   408   in
   411     fold do_fact new_facts parents;
   409     mash_set (fn () => (mash_ADD records;
   412     mash_set {fresh = fresh, completed_thys = completed_thys,
   410                         {fresh = fresh, completed_thys = completed_thys,
   413               thy_facts = thy_facts}
   411                          thy_facts = thy_facts}))
   414   end
   412   end
   415 
   413 
   416 (* ###
   414 (* ###
   417 fun compute_accessibility thy thy_facts =
   415 fun compute_accessibility thy thy_facts =
   418   let
   416   let