src/HOL/Code_Eval.thy
changeset 31203 5c8fb4fd67e0
parent 31191 7733125bac3c
child 31205 98370b26c2ce
equal deleted inserted replaced
31202:52d332f8f909 31203:5c8fb4fd67e0
     3 *)
     3 *)
     4 
     4 
     5 header {* Term evaluation using the generic code generator *}
     5 header {* Term evaluation using the generic code generator *}
     6 
     6 
     7 theory Code_Eval
     7 theory Code_Eval
     8 imports Plain Typerep
     8 imports Plain Typerep Code_Index
     9 begin
     9 begin
    10 
    10 
    11 subsection {* Term representation *}
    11 subsection {* Term representation *}
    12 
    12 
    13 subsubsection {* Terms and class @{text term_of} *}
    13 subsubsection {* Terms and class @{text term_of} *}
   213   "term_of (k::int) = (if k = 0 then termify (0 :: int)
   213   "term_of (k::int) = (if k = 0 then termify (0 :: int)
   214     else if k > 0 then termify (number_of :: int \<Rightarrow> int) <\<cdot>> term_of_num (2::int) k
   214     else if k > 0 then termify (number_of :: int \<Rightarrow> int) <\<cdot>> term_of_num (2::int) k
   215       else termify (uminus :: int \<Rightarrow> int) <\<cdot>> (termify (number_of :: int \<Rightarrow> int) <\<cdot>> term_of_num (2::int) (- k)))"
   215       else termify (uminus :: int \<Rightarrow> int) <\<cdot>> (termify (number_of :: int \<Rightarrow> int) <\<cdot>> term_of_num (2::int) (- k)))"
   216   by (simp only: term_of_anything)
   216   by (simp only: term_of_anything)
   217 
   217 
       
   218 lemma (in term_syntax) term_of_index_code [code]:
       
   219   "term_of (k::index) = termify (number_of :: int \<Rightarrow> index) <\<cdot>> term_of_num (2::index) k"
       
   220   by (simp only: term_of_anything)
   218 
   221 
   219 subsection {* Obfuscate *}
   222 subsection {* Obfuscate *}
   220 
   223 
   221 print_translation {*
   224 print_translation {*
   222 let
   225 let