src/Doc/Codegen/Computations.thy
changeset 65043 fd753468786f
parent 65041 2525e680f94f
child 65044 0940a741adf7
equal deleted inserted replaced
65042:956ea00a162a 65043:fd753468786f
   284     "Rings.dvd :: int \<Rightarrow> int \<Rightarrow> bool"
   284     "Rings.dvd :: int \<Rightarrow> int \<Rightarrow> bool"
   285     "plus :: int \<Rightarrow> int \<Rightarrow> int"
   285     "plus :: int \<Rightarrow> int \<Rightarrow> int"
   286     "minus :: int \<Rightarrow> int \<Rightarrow> int"
   286     "minus :: int \<Rightarrow> int \<Rightarrow> int"
   287     "times :: int \<Rightarrow> int \<Rightarrow> int"
   287     "times :: int \<Rightarrow> int \<Rightarrow> int"
   288     "0 :: int" "1 :: int" "2 :: int" "3 :: int" "-1 :: int"
   288     "0 :: int" "1 :: int" "2 :: int" "3 :: int" "-1 :: int"
   289   } (curry dvd_oracle)
   289   } (K (curry dvd_oracle))
   290 
   290 
   291   end
   291   end
   292 \<close>
   292 \<close>
   293 
   293 
   294 text \<open>
   294 text \<open>
   343 
   343 
   344   val cterm_of_int = Thm.cterm_of @{context} o HOLogic.mk_numeral o integer_of_int;
   344   val cterm_of_int = Thm.cterm_of @{context} o HOLogic.mk_numeral o integer_of_int;
   345 
   345 
   346   val divisor = Thm.dest_arg o Thm.dest_arg;
   346   val divisor = Thm.dest_arg o Thm.dest_arg;
   347 
   347 
   348   fun evaluate thm = 
   348   val evaluate_simps = map mk_eq @{thms arith_simps positive_mult};
   349     Simplifier.rewrite_rule 
   349 
   350       (Proof_Context.transfer (Thm.theory_of_thm thm) @{context})
   350   fun evaluate ctxt = 
   351       (map mk_eq @{thms arith_simps positive_mult}) thm; (*FIXME proper ctxt*)
   351     Simplifier.rewrite_rule ctxt evaluate_simps;
   352 
   352 
   353   fun revaluate k ct =
   353   fun revaluate ctxt k ct =
   354     @{thm conv_div_cert}
   354     @{thm conv_div_cert}
   355     |> Thm.instantiate' [] [SOME (cterm_of_int k), SOME (divisor ct)]
   355     |> Thm.instantiate' [] [SOME (cterm_of_int k), SOME (divisor ct)]
   356     |> evaluate;
   356     |> evaluate ctxt;
   357 
   357 
   358   in
   358   in
   359 
   359 
   360   val conv_div = @{computation_conv int terms:
   360   val conv_div = @{computation_conv int terms:
   361     "divide :: int \<Rightarrow> int \<Rightarrow> int"
   361     "divide :: int \<Rightarrow> int \<Rightarrow> int"