src/HOL/Code_Generator.thy
changeset 22886 cdff6ef76009
parent 22845 5f9138bcb3d7
child 22900 f8a7c10e1bd0
equal deleted inserted replaced
22885:ebde66a71ab0 22886:cdff6ef76009
     4 
     4 
     5 header {* Setup of code generator tools *}
     5 header {* Setup of code generator tools *}
     6 
     6 
     7 theory Code_Generator
     7 theory Code_Generator
     8 imports HOL
     8 imports HOL
       
     9 uses "~~/src/HOL/Tools/recfun_codegen.ML"
     9 begin
    10 begin
       
    11 
       
    12 ML {*
       
    13 structure HOL =
       
    14 struct
       
    15   val thy = theory "HOL";
       
    16 end;
       
    17 *}  -- "belongs to theory HOL"
    10 
    18 
    11 subsection {* SML code generator setup *}
    19 subsection {* SML code generator setup *}
    12 
    20 
    13 types_code
    21 types_code
    14   "bool"  ("bool")
    22   "bool"  ("bool")
    53      | _ => NONE);
    61      | _ => NONE);
    54 
    62 
    55 in
    63 in
    56 
    64 
    57 Codegen.add_codegen "eq_codegen" eq_codegen
    65 Codegen.add_codegen "eq_codegen" eq_codegen
       
    66 #> RecfunCodegen.setup
    58 
    67 
    59 end
    68 end
    60 *}
    69 *}
    61 
    70 
    62 text {* Evaluation *}
    71 text {* Evaluation *}
   105 
   114 
   106 lemma [code func]:
   115 lemma [code func]:
   107   shows "(\<not> True) = False"
   116   shows "(\<not> True) = False"
   108     and "(\<not> False) = True" by (rule HOL.simp_thms)+
   117     and "(\<not> False) = True" by (rule HOL.simp_thms)+
   109 
   118 
   110 lemmas [code func] = imp_conv_disj
   119 lemmas [code] = imp_conv_disj
   111 
   120 
   112 lemmas [code func] = if_True if_False
   121 lemmas [code func] = if_True if_False
   113 
   122 
   114 instance bool :: eq ..
   123 instance bool :: eq ..
   115 
   124 
   172 subsection {* Evaluation oracle *}
   181 subsection {* Evaluation oracle *}
   173 
   182 
   174 oracle eval_oracle ("term") = {* fn thy => fn t => 
   183 oracle eval_oracle ("term") = {* fn thy => fn t => 
   175   if CodegenPackage.satisfies thy (HOLogic.dest_Trueprop t) [] 
   184   if CodegenPackage.satisfies thy (HOLogic.dest_Trueprop t) [] 
   176   then t
   185   then t
   177   else HOLogic.Trueprop $ (HOLogic.true_const) (*dummy*)
   186   else HOLogic.Trueprop $ HOLogic.true_const (*dummy*)
   178 *}
   187 *}
   179 
   188 
   180 method_setup eval = {*
   189 method_setup eval = {*
   181 let
   190 let
   182   fun eval_tac thy = 
   191   fun eval_tac thy =