src/HOL/Tools/SMT/smt_solver.ML
changeset 41242 8edeb1dbbc76
parent 41241 7d07736aaaf6
child 41300 528f5d00b542
equal deleted inserted replaced
41241:7d07736aaaf6 41242:8edeb1dbbc76
    31   val is_locally_installed: Proof.context -> string -> bool
    31   val is_locally_installed: Proof.context -> string -> bool
    32   val is_remotely_available: Proof.context -> string -> bool
    32   val is_remotely_available: Proof.context -> string -> bool
    33   val default_max_relevant: Proof.context -> string -> int
    33   val default_max_relevant: Proof.context -> string -> int
    34 
    34 
    35   (*filter*)
    35   (*filter*)
    36   type 'a smt_filter_head_result = 'a list * (int option * thm) list *
    36   type 'a smt_filter_head_result = ('a list * (int option * thm) list) *
    37     (((int * thm) list * Proof.context) * (int * (int option * thm)) list)
    37     (((int * thm) list * Proof.context) * (int * (int option * thm)) list)
    38   val smt_filter_head: Proof.state ->
    38   val smt_filter_head: Proof.state ->
    39     ('a * (int option * thm)) list -> int -> 'a smt_filter_head_result
    39     ('a * (int option * thm)) list -> int -> 'a smt_filter_head_result
    40   val smt_filter_tail: Time.time -> bool -> 'a smt_filter_head_result ->
    40   val smt_filter_tail: Time.time -> bool -> 'a smt_filter_head_result ->
    41     {outcome: SMT_Failure.failure option, used_facts: ('a * thm) list}
    41     {outcome: SMT_Failure.failure option, used_facts: ('a * thm) list}
   320 
   320 
   321 val cnot = Thm.cterm_of @{theory} @{const Not}
   321 val cnot = Thm.cterm_of @{theory} @{const Not}
   322 
   322 
   323 fun mk_result outcome xrules = { outcome = outcome, used_facts = xrules }
   323 fun mk_result outcome xrules = { outcome = outcome, used_facts = xrules }
   324 
   324 
   325 type 'a smt_filter_head_result = 'a list * (int option * thm) list *
   325 type 'a smt_filter_head_result = ('a list * (int option * thm) list) *
   326   (((int * thm) list * Proof.context) * (int * (int option * thm)) list)
   326   (((int * thm) list * Proof.context) * (int * (int option * thm)) list)
   327 
   327 
   328 fun smt_filter_head st xwrules i =
   328 fun smt_filter_head st xwrules i =
   329   let
   329   let
   330     val ctxt =
   330     val ctxt =
   338     fun negate ct = Thm.dest_comb ct ||> Thm.capply cnot |-> Thm.capply
   338     fun negate ct = Thm.dest_comb ct ||> Thm.capply cnot |-> Thm.capply
   339     val cprop = negate (Thm.rhs_of (SMT_Normalize.atomize_conv ctxt' concl))
   339     val cprop = negate (Thm.rhs_of (SMT_Normalize.atomize_conv ctxt' concl))
   340 
   340 
   341     val (xs, wthms) = split_list xwrules
   341     val (xs, wthms) = split_list xwrules
   342   in
   342   in
   343     (xs, wthms,
   343     ((xs, wthms),
   344      wthms
   344      wthms
   345      |> map_index I
   345      |> map_index I
   346      |> append (map (pair ~1 o pair NONE) (Thm.assume cprop :: prems @ facts))
   346      |> append (map (pair ~1 o pair NONE) (Thm.assume cprop :: prems @ facts))
   347      |> tap check_topsort
   347      |> tap check_topsort
   348      |> `(gen_solver_head ctxt'))
   348      |> `(gen_solver_head ctxt'))
   349   end
   349   end
   350 
   350 
   351 fun smt_filter_tail time_limit run_remote
   351 fun smt_filter_tail time_limit run_remote
   352     (xs, wthms, ((iwthms', ctxt), iwthms)) =
   352     ((xs, wthms), ((iwthms', ctxt), iwthms)) =
   353   let
   353   let
   354     val ctxt = ctxt |> Config.put C.timeout (Time.toReal time_limit)
   354     val ctxt = ctxt |> Config.put C.timeout (Time.toReal time_limit)
   355     val xrules = xs ~~ map snd wthms
   355     val xrules = xs ~~ map snd wthms
   356   in
   356   in
   357     ((iwthms', ctxt), iwthms)
   357     ((iwthms', ctxt), iwthms)