src/HOL/Tools/SMT/z3_proof_tools.ML
changeset 40662 798aad2229c0
parent 40579 98ebd2300823
child 40663 e080c9e68752
equal deleted inserted replaced
40661:f643399acab3 40662:798aad2229c0
    45 end
    45 end
    46 
    46 
    47 structure Z3_Proof_Tools: Z3_PROOF_TOOLS =
    47 structure Z3_Proof_Tools: Z3_PROOF_TOOLS =
    48 struct
    48 struct
    49 
    49 
       
    50 structure U = SMT_Utils
    50 structure I = Z3_Interface
    51 structure I = Z3_Interface
    51 
    52 
    52 
    53 
    53 
    54 
    54 (* accessing terms *)
    55 (* accessing terms *)
    58 fun term_of ct = dest_prop (Thm.term_of ct)
    59 fun term_of ct = dest_prop (Thm.term_of ct)
    59 fun prop_of thm = dest_prop (Thm.prop_of thm)
    60 fun prop_of thm = dest_prop (Thm.prop_of thm)
    60 
    61 
    61 val mk_prop = Thm.capply (Thm.cterm_of @{theory} @{const Trueprop})
    62 val mk_prop = Thm.capply (Thm.cterm_of @{theory} @{const Trueprop})
    62 
    63 
    63 val eq = I.mk_inst_pair I.destT1 @{cpat "op =="}
    64 fun as_meta_eq ct = uncurry U.mk_cequals (Thm.dest_binop (Thm.dest_arg ct))
    64 fun mk_meta_eq_cterm ct cu = Thm.mk_binop (I.instT' ct eq) ct cu
       
    65 
       
    66 fun as_meta_eq ct = uncurry mk_meta_eq_cterm (Thm.dest_binop (Thm.dest_arg ct))
       
    67 
    65 
    68 
    66 
    69 
    67 
    70 (* theorem nets *)
    68 (* theorem nets *)
    71 
    69 
   110 (* |- c x == t x ==> P (c x)  ~~>  c == t |- P (c x) *) 
   108 (* |- c x == t x ==> P (c x)  ~~>  c == t |- P (c x) *) 
   111 fun make_hyp_def thm ctxt =
   109 fun make_hyp_def thm ctxt =
   112   let
   110   let
   113     val (lhs, rhs) = Thm.dest_binop (Thm.cprem_of thm 1)
   111     val (lhs, rhs) = Thm.dest_binop (Thm.cprem_of thm 1)
   114     val (cf, cvs) = Drule.strip_comb lhs
   112     val (cf, cvs) = Drule.strip_comb lhs
   115     val eq = mk_meta_eq_cterm cf (fold_rev Thm.cabs cvs rhs)
   113     val eq = U.mk_cequals cf (fold_rev Thm.cabs cvs rhs)
   116     fun apply cv th =
   114     fun apply cv th =
   117       Thm.combination th (Thm.reflexive cv)
   115       Thm.combination th (Thm.reflexive cv)
   118       |> Conv.fconv_rule (Conv.arg_conv (Thm.beta_conversion false))
   116       |> Conv.fconv_rule (Conv.arg_conv (Thm.beta_conversion false))
   119   in
   117   in
   120     yield_singleton Assumption.add_assumes eq ctxt
   118     yield_singleton Assumption.add_assumes eq ctxt