src/HOL/Library/Eval.thy
changeset 24381 560e8ecdf633
parent 24280 c9867bdf2424
child 24423 ae9cd0e92423
equal deleted inserted replaced
24380:c215e256beca 24381:560e8ecdf633
   165 val eval_ref = ref (NONE : term option);
   165 val eval_ref = ref (NONE : term option);
   166 
   166 
   167 end;
   167 end;
   168 *}
   168 *}
   169 
   169 
   170 oracle eval_oracle ("term * CodeThingol.code * CodeThingol.iterm * CodeThingol.itype * cterm") = {* fn thy => fn (t0, code, t, ty, ct) => 
   170 oracle eval_oracle ("term * CodeThingol.code * (CodeThingol.typscheme * CodeThingol.iterm) * cterm") =
       
   171 {* fn thy => fn (t0, code, ((vs, ty), t), ct) => 
   171 let
   172 let
   172   val _ = (Term.map_types o Term.map_atyps) (fn _ =>
   173   val _ = (Term.map_types o Term.map_atyps) (fn _ =>
   173     error ("Term " ^ Sign.string_of_term thy t0 ^ " contains polymorphic type"))
   174     error ("Term " ^ Sign.string_of_term thy t0 ^ " contains polymorphic type"))
   174     t0;
   175     t0;
   175 in Logic.mk_equals (t0, CodeTarget.eval_term thy ("Eval.eval_ref", Eval.eval_ref) code (t, ty) []) end;
   176 in Logic.mk_equals (t0, CodeTarget.eval_term thy ("Eval.eval_ref", Eval.eval_ref) code (t, ty) []) end;
   179 structure Eval : EVAL =
   180 structure Eval : EVAL =
   180 struct
   181 struct
   181 
   182 
   182 open Eval;
   183 open Eval;
   183 
   184 
   184 fun eval_invoke thy t0 code (t, ty) _ ct = eval_oracle thy (t0, code, t, ty, ct);
   185 fun eval_invoke thy t0 code vs_ty_t _ ct = eval_oracle thy (t0, code, vs_ty_t, ct);
   185 
   186 
   186 fun eval_conv ct =
   187 fun eval_conv ct =
   187   let
   188   let
   188     val thy = Thm.theory_of_cterm ct;
   189     val thy = Thm.theory_of_cterm ct;
   189     val ct' = (Thm.cterm_of thy o TermOf.mk_term_of o Thm.term_of) ct;
   190     val ct' = (Thm.cterm_of thy o TermOf.mk_term_of o Thm.term_of) ct;