src/HOL/Tools/SMT/smt_normalize.ML
changeset 74282 c2ee8d993d6a
parent 74245 282cd3aa6cc6
child 74382 8d0294d877bd
equal deleted inserted replaced
74281:7829d6435c60 74282:c2ee8d993d6a
    33 local
    33 local
    34   val (cpfalse, cfalse) = `SMT_Util.mk_cprop (Thm.cterm_of \<^context> \<^const>\<open>False\<close>)
    34   val (cpfalse, cfalse) = `SMT_Util.mk_cprop (Thm.cterm_of \<^context> \<^const>\<open>False\<close>)
    35 
    35 
    36   fun inst f ct thm =
    36   fun inst f ct thm =
    37     let val cv = f (Drule.strip_imp_concl (Thm.cprop_of thm))
    37     let val cv = f (Drule.strip_imp_concl (Thm.cprop_of thm))
    38     in Thm.instantiate ([], [(dest_Var (Thm.term_of cv), ct)]) thm end
    38     in Thm.instantiate (TVars.empty, Vars.make [(dest_Var (Thm.term_of cv), ct)]) thm end
    39 in
    39 in
    40 
    40 
    41 fun instantiate_elim thm =
    41 fun instantiate_elim thm =
    42   (case Thm.concl_of thm of
    42   (case Thm.concl_of thm of
    43     \<^const>\<open>Trueprop\<close> $ Var (_, \<^typ>\<open>bool\<close>) => inst Thm.dest_arg cfalse thm
    43     \<^const>\<open>Trueprop\<close> $ Var (_, \<^typ>\<open>bool\<close>) => inst Thm.dest_arg cfalse thm
   201   fun insert_trigger_conv [] ct = Conv.all_conv ct
   201   fun insert_trigger_conv [] ct = Conv.all_conv ct
   202     | insert_trigger_conv ctss ct =
   202     | insert_trigger_conv ctss ct =
   203         let
   203         let
   204           val (ctr, cp) = Thm.dest_binop (Thm.rhs_of trigger_eq) ||> rpair ct
   204           val (ctr, cp) = Thm.dest_binop (Thm.rhs_of trigger_eq) ||> rpair ct
   205           val inst = map (apfst (dest_Var o Thm.term_of)) [cp, (ctr, mk_trigger ctss)]
   205           val inst = map (apfst (dest_Var o Thm.term_of)) [cp, (ctr, mk_trigger ctss)]
   206         in Thm.instantiate ([], inst) trigger_eq end
   206         in Thm.instantiate (TVars.empty, Vars.make inst) trigger_eq end
   207 
   207 
   208   fun infer_trigger_eq_conv outer_ctxt (ctxt, cvs) ct =
   208   fun infer_trigger_eq_conv outer_ctxt (ctxt, cvs) ct =
   209     let
   209     let
   210       val (lhs, rhs) = dest_cond_eq ct
   210       val (lhs, rhs) = dest_cond_eq ct
   211 
   211 
   400 
   400 
   401 fun add_int_of_nat_constraints thms =
   401 fun add_int_of_nat_constraints thms =
   402   let val (q, cts) = fold (add_apps add_int_of_nat [] o Thm.cprop_of) thms (false, [])
   402   let val (q, cts) = fold (add_apps add_int_of_nat [] o Thm.cprop_of) thms (false, [])
   403   in
   403   in
   404     if q then (thms, nat_int_thms)
   404     if q then (thms, nat_int_thms)
   405     else (thms, map (fn ct => Thm.instantiate ([], [(var, ct)]) int_thm) cts)
   405     else (thms, map (fn ct => Thm.instantiate (TVars.empty, Vars.make [(var, ct)]) int_thm) cts)
   406   end
   406   end
   407 
   407 
   408 val setup_nat_as_int =
   408 val setup_nat_as_int =
   409   SMT_Builtin.add_builtin_typ_ext (\<^typ>\<open>nat\<close>,
   409   SMT_Builtin.add_builtin_typ_ext (\<^typ>\<open>nat\<close>,
   410     fn ctxt => K (Config.get ctxt SMT_Config.nat_as_int)) #>
   410     fn ctxt => K (Config.get ctxt SMT_Config.nat_as_int)) #>