src/HOL/Tools/Sledgehammer/sledgehammer_mash.ML
changeset 50229 78f3be5e51d2
parent 50220 90280d85cd03
child 50310 b00eeb8e352e
equal deleted inserted replaced
50228:cf1a274bbba6 50229:78f3be5e51d2
    53     Proof.context -> bool -> (string * string list) list -> unit
    53     Proof.context -> bool -> (string * string list) list -> unit
    54   val mash_QUERY :
    54   val mash_QUERY :
    55     Proof.context -> bool -> int -> string list * string list
    55     Proof.context -> bool -> int -> string list * string list
    56     -> (string * real) list
    56     -> (string * real) list
    57   val mash_unlearn : Proof.context -> unit
    57   val mash_unlearn : Proof.context -> unit
    58   val mash_could_suggest_facts : unit -> bool
    58   val is_mash_enabled : unit -> bool
    59   val mash_can_suggest_facts : Proof.context -> bool
    59   val mash_can_suggest_facts : Proof.context -> bool
    60   val mash_suggested_facts :
    60   val mash_suggested_facts :
    61     Proof.context -> params -> string -> int -> term list -> term
    61     Proof.context -> params -> string -> int -> term list -> term
    62     -> fact list -> (fact * real) list * fact list
    62     -> fact list -> (fact * real) list * fact list
    63   val mash_learn_proof :
    63   val mash_learn_proof :
    99 val learn_isarN = "learn_isar"
    99 val learn_isarN = "learn_isar"
   100 val learn_atpN = "learn_atp"
   100 val learn_atpN = "learn_atp"
   101 val relearn_isarN = "relearn_isar"
   101 val relearn_isarN = "relearn_isar"
   102 val relearn_atpN = "relearn_atp"
   102 val relearn_atpN = "relearn_atp"
   103 
   103 
   104 fun is_mash_enabled () = (getenv "MASH" = "yes")
       
   105 fun mash_home () = getenv "ISABELLE_SLEDGEHAMMER_MASH"
   104 fun mash_home () = getenv "ISABELLE_SLEDGEHAMMER_MASH"
   106 fun mash_model_dir () =
   105 fun mash_model_dir () =
   107   getenv "ISABELLE_HOME_USER" ^ "/mash"
   106   getenv "ISABELLE_HOME_USER" ^ "/mash"
   108   |> tap (Isabelle_System.mkdir o Path.explode)
   107   |> tap (Isabelle_System.mkdir o Path.explode)
   109 val mash_state_dir = mash_model_dir
   108 val mash_state_dir = mash_model_dir
   621       (mash_CLEAR ctxt; (* also removes the state file *)
   620       (mash_CLEAR ctxt; (* also removes the state file *)
   622        (true, empty_state)))
   621        (true, empty_state)))
   623 
   622 
   624 end
   623 end
   625 
   624 
   626 fun mash_could_suggest_facts () = is_mash_enabled ()
   625 fun is_mash_enabled () = (getenv "MASH" = "yes")
   627 fun mash_can_suggest_facts ctxt = not (Graph.is_empty (#fact_G (mash_get ctxt)))
   626 fun mash_can_suggest_facts ctxt = not (Graph.is_empty (#fact_G (mash_get ctxt)))
   628 
   627 
   629 fun num_keys keys = Graph.Keys.fold (K (Integer.add 1)) keys 0
   628 fun num_keys keys = Graph.Keys.fold (K (Integer.add 1)) keys 0
   630 
   629 
   631 fun maximal_in_graph fact_G facts =
   630 fun maximal_in_graph fact_G facts =
   972         case fact_filter of
   971         case fact_filter of
   973           SOME ff => (() |> ff <> mepoN ? maybe_learn; ff)
   972           SOME ff => (() |> ff <> mepoN ? maybe_learn; ff)
   974         | NONE =>
   973         | NONE =>
   975           if is_smt_prover ctxt prover then
   974           if is_smt_prover ctxt prover then
   976             mepoN
   975             mepoN
   977           else if mash_could_suggest_facts () then
   976           else if is_mash_enabled () then
   978             (maybe_learn ();
   977             (maybe_learn ();
   979              if mash_can_suggest_facts ctxt then meshN else mepoN)
   978              if mash_can_suggest_facts ctxt then meshN else mepoN)
   980           else
   979           else
   981             mepoN
   980             mepoN
   982       val add_ths = Attrib.eval_thms ctxt add
   981       val add_ths = Attrib.eval_thms ctxt add