src/Tools/Code/code_preproc.ML
changeset 52736 317663b422bb
parent 51717 9e7d1c139569
child 53437 b098d53152d9
equal deleted inserted replaced
52735:842b5e7dcac8 52736:317663b422bb
   141       | t as Var _ => insert (op aconv) t
   141       | t as Var _ => insert (op aconv) t
   142       | _ => I) t [];
   142       | _ => I) t [];
   143     val resubst = curry (Term.betapplys o swap) all_vars;
   143     val resubst = curry (Term.betapplys o swap) all_vars;
   144   in (resubst, term_of_conv thy conv (fold_rev lambda all_vars t)) end;
   144   in (resubst, term_of_conv thy conv (fold_rev lambda all_vars t)) end;
   145 
   145 
       
   146 fun lift_ss_conv f ss ct = f (Simplifier.put_simpset ss (Proof_Context.init_global (theory_of_cterm ct))) ct;
       
   147 
   146 fun preprocess_conv thy =
   148 fun preprocess_conv thy =
   147   let
   149   let
   148     val pre = (Simplifier.global_context thy o #pre o the_thmproc) thy;
   150     val pre = (#pre o the_thmproc) thy;
   149   in
   151   in
   150     Simplifier.rewrite pre
   152     lift_ss_conv Simplifier.rewrite pre
   151     #> trans_conv_rule (Axclass.unoverload_conv thy)
   153     #> trans_conv_rule (Axclass.unoverload_conv thy)
   152   end;
   154   end;
   153 
   155 
   154 fun preprocess_term thy = term_of_conv_resubst thy (preprocess_conv thy);
   156 fun preprocess_term thy = term_of_conv_resubst thy (preprocess_conv thy);
   155 
   157 
   156 fun postprocess_conv thy =
   158 fun postprocess_conv thy =
   157   let
   159   let
   158     val post = (Simplifier.global_context thy o #post o the_thmproc) thy;
   160     val post = (#post o the_thmproc) thy;
   159   in
   161   in
   160     Axclass.overload_conv thy
   162     Axclass.overload_conv thy
   161     #> trans_conv_rule (Simplifier.rewrite post)
   163     #> trans_conv_rule (lift_ss_conv Simplifier.rewrite post)
   162   end;
   164   end;
   163 
   165 
   164 fun postprocess_term thy = term_of_conv thy (postprocess_conv thy);
   166 fun postprocess_term thy = term_of_conv thy (postprocess_conv thy);
   165 
   167 
   166 fun print_codeproc thy =
   168 fun print_codeproc thy =
   482 
   484 
   483 fun static_value thy postproc consts evaluator =
   485 fun static_value thy postproc consts evaluator =
   484   let
   486   let
   485     val (algebra, eqngr) = obtain true thy consts [];
   487     val (algebra, eqngr) = obtain true thy consts [];
   486     val evaluator' = evaluator algebra eqngr;
   488     val evaluator' = evaluator algebra eqngr;
       
   489     val postproc' = postprocess_term thy;
   487   in 
   490   in 
   488     preprocess_term thy
   491     preprocess_term thy
   489     #-> (fn resubst => fn t => t
   492     #-> (fn resubst => fn t => t
   490       |> evaluator' (Term.add_tfrees t [])
   493       |> evaluator' (Term.add_tfrees t [])
   491       |> postproc (postprocess_term thy o resubst))
   494       |> postproc (postproc' o resubst))
   492   end;
   495   end;
   493 
   496 
   494 
   497 
   495 (** setup **)
   498 (** setup **)
   496 
   499