src/HOL/Code_Evaluation.thy
changeset 58038 f8e6197668c9
parent 58036 f23045003476
child 58152 6fe60a9a5bad
equal deleted inserted replaced
58037:f7be22c6646b 58038:f8e6197668c9
   129 | constant "term_of \<Colon> String.literal \<Rightarrow> term" \<rightharpoonup> (Eval) "HOLogic.mk'_literal"
   129 | constant "term_of \<Colon> String.literal \<Rightarrow> term" \<rightharpoonup> (Eval) "HOLogic.mk'_literal"
   130 
   130 
   131 declare [[code drop: "term_of :: integer \<Rightarrow> _"]]
   131 declare [[code drop: "term_of :: integer \<Rightarrow> _"]]
   132 
   132 
   133 lemma term_of_integer [unfolded typerep_fun_def typerep_num_def typerep_integer_def, code]:
   133 lemma term_of_integer [unfolded typerep_fun_def typerep_num_def typerep_integer_def, code]:
   134   "Code_Evaluation.term_of (i :: integer) =
   134   "term_of (i :: integer) =
   135    Code_Evaluation.App
   135   (if i > 0 then 
   136     (Code_Evaluation.Const (STR ''Num.numeral_class.numeral'') (TYPEREP(num \<Rightarrow> integer)))
   136      App (Const (STR ''Num.numeral_class.numeral'') (TYPEREP(num \<Rightarrow> integer)))
   137     (term_of (num_of_integer i))"
   137       (term_of (num_of_integer i))
       
   138    else if i = 0 then Const (STR ''Groups.zero_class.zero'') TYPEREP(integer)
       
   139    else
       
   140      App (Const (STR ''Groups.uminus_class.uminus'') TYPEREP(integer \<Rightarrow> integer))
       
   141        (term_of (- i)))"
   138 by(rule term_of_anything[THEN meta_eq_to_obj_eq])
   142 by(rule term_of_anything[THEN meta_eq_to_obj_eq])
   139 
   143 
   140 code_reserved Eval HOLogic
   144 code_reserved Eval HOLogic
   141 
   145 
   142 
   146