src/HOL/Tools/SMT/z3_replay_methods.ML
changeset 59621 291934bac95e
parent 59617 b60e65ad13df
child 60642 48dd1cefb4ae
equal deleted inserted replaced
59620:92d7d8e4f1bf 59621:291934bac95e
    86 fun dest_prop (Const (@{const_name Trueprop}, _) $ t) = t
    86 fun dest_prop (Const (@{const_name Trueprop}, _) $ t) = t
    87   | dest_prop t = t
    87   | dest_prop t = t
    88 
    88 
    89 fun dest_thm thm = dest_prop (Thm.concl_of thm)
    89 fun dest_thm thm = dest_prop (Thm.concl_of thm)
    90 
    90 
    91 fun certify_prop ctxt t = Proof_Context.cterm_of ctxt (as_prop t)
    91 fun certify_prop ctxt t = Thm.cterm_of ctxt (as_prop t)
    92 
    92 
    93 fun try_provers ctxt rule [] thms t = replay_rule_error ctxt rule thms t
    93 fun try_provers ctxt rule [] thms t = replay_rule_error ctxt rule thms t
    94   | try_provers ctxt rule ((name, prover) :: named_provers) thms t =
    94   | try_provers ctxt rule ((name, prover) :: named_provers) thms t =
    95       (case (trace ctxt (K ("Trying prover " ^ quote name)); try prover t) of
    95       (case (trace ctxt (K ("Trying prover " ^ quote name)); try prover t) of
    96         SOME thm => thm
    96         SOME thm => thm
   106     fun cert_inst (ix, (a, b)) = (cert (mk (ix, a)), cert b)
   106     fun cert_inst (ix, (a, b)) = (cert (mk (ix, a)), cert b)
   107   in Vartab.fold (cons o cert_inst) (sel inst) [] end
   107   in Vartab.fold (cons o cert_inst) (sel inst) [] end
   108 
   108 
   109 fun match_instantiateT ctxt t thm =
   109 fun match_instantiateT ctxt t thm =
   110   if Term.exists_type (Term.exists_subtype Term.is_TVar) (dest_thm thm) then
   110   if Term.exists_type (Term.exists_subtype Term.is_TVar) (dest_thm thm) then
   111     Thm.instantiate (gen_certify_inst fst TVar (Proof_Context.ctyp_of ctxt) ctxt thm t, []) thm
   111     Thm.instantiate (gen_certify_inst fst TVar (Thm.ctyp_of ctxt) ctxt thm t, []) thm
   112   else thm
   112   else thm
   113 
   113 
   114 fun match_instantiate ctxt t thm =
   114 fun match_instantiate ctxt t thm =
   115   let val thm' = match_instantiateT ctxt t thm in
   115   let val thm' = match_instantiateT ctxt t thm in
   116     Thm.instantiate ([], gen_certify_inst snd Var (Proof_Context.cterm_of ctxt) ctxt thm' t) thm'
   116     Thm.instantiate ([], gen_certify_inst snd Var (Thm.cterm_of ctxt) ctxt thm' t) thm'
   117   end
   117   end
   118 
   118 
   119 fun apply_rule ctxt t =
   119 fun apply_rule ctxt t =
   120   (case Z3_Replay_Rules.apply ctxt (certify_prop ctxt t) of
   120   (case Z3_Replay_Rules.apply ctxt (certify_prop ctxt t) of
   121     SOME thm => thm
   121     SOME thm => thm
   398     if eq_list (op aconv) (ls, rs) then SOME (ls, (HOLogic.mk_eq (lhs', rhs')))
   398     if eq_list (op aconv) (ls, rs) then SOME (ls, (HOLogic.mk_eq (lhs', rhs')))
   399     else NONE
   399     else NONE
   400   end
   400   end
   401 
   401 
   402 fun forall_intr ctxt t thm =
   402 fun forall_intr ctxt t thm =
   403   let val ct = Proof_Context.cterm_of ctxt t
   403   let val ct = Thm.cterm_of ctxt t
   404   in Thm.forall_intr ct thm COMP_INCR @{thm iff_allI} end
   404   in Thm.forall_intr ct thm COMP_INCR @{thm iff_allI} end
   405 
   405 
   406 in
   406 in
   407 
   407 
   408 fun focus_eq f ctxt t =
   408 fun focus_eq f ctxt t =