src/HOL/Code_Evaluation.thy
changeset 51143 0a2371e7ced3
parent 51126 df86080de4cb
child 51144 0ede9e2266a8
equal deleted inserted replaced
51142:ac9e909fe55d 51143:0a2371e7ced3
   156   "term_of (n::nat) = (
   156   "term_of (n::nat) = (
   157     if n = 0 then termify (0 :: nat)
   157     if n = 0 then termify (0 :: nat)
   158     else termify (numeral :: num \<Rightarrow> nat) <\<cdot>> term_of_num_semiring (2::nat) n)"
   158     else termify (numeral :: num \<Rightarrow> nat) <\<cdot>> term_of_num_semiring (2::nat) n)"
   159   by (simp only: term_of_anything)
   159   by (simp only: term_of_anything)
   160 
   160 
   161 lemma (in term_syntax) term_of_code_numeral_code [code]:
   161 lemma (in term_syntax) term_of_natural_code [code]:
   162   "term_of (k::code_numeral) = (
   162   "term_of (k::natural) = (
   163     if k = 0 then termify (0 :: code_numeral)
   163     if k = 0 then termify (0 :: natural)
   164     else termify (numeral :: num \<Rightarrow> code_numeral) <\<cdot>> term_of_num_semiring (2::code_numeral) k)"
   164     else termify (numeral :: num \<Rightarrow> natural) <\<cdot>> term_of_num_semiring (2::natural) k)"
       
   165   by (simp only: term_of_anything)
       
   166 
       
   167 lemma (in term_syntax) term_of_integer_code [code]:
       
   168   "term_of (k::integer) = (if k = 0 then termify (0 :: integer)
       
   169     else if k < 0 then termify (neg_numeral :: num \<Rightarrow> integer) <\<cdot>> term_of_num_semiring (2::integer) (- k)
       
   170     else termify (numeral :: num \<Rightarrow> integer) <\<cdot>> term_of_num_semiring (2::integer) k)"
   165   by (simp only: term_of_anything)
   171   by (simp only: term_of_anything)
   166 
   172 
   167 lemma (in term_syntax) term_of_int_code [code]:
   173 lemma (in term_syntax) term_of_int_code [code]:
   168   "term_of (k::int) = (if k = 0 then termify (0 :: int)
   174   "term_of (k::int) = (if k = 0 then termify (0 :: int)
   169     else if k < 0 then termify (neg_numeral :: num \<Rightarrow> int) <\<cdot>> term_of_num_semiring (2::int) (- k)
   175     else if k < 0 then termify (neg_numeral :: num \<Rightarrow> int) <\<cdot>> term_of_num_semiring (2::int) (- k)
   197 
   203 
   198 hide_const dummy_term valapp
   204 hide_const dummy_term valapp
   199 hide_const (open) Const App Abs Free termify valtermify term_of term_of_num_semiring tracing
   205 hide_const (open) Const App Abs Free termify valtermify term_of term_of_num_semiring tracing
   200 
   206 
   201 end
   207 end
       
   208