src/HOL/Extraction/Pigeonhole.thy
changeset 37287 9834c21c4ba1
parent 32960 69916a850301
child 37678 0040bafffdef
equal deleted inserted replaced
37252:b79df37bbdc4 37287:9834c21c4ba1
   234 
   234 
   235 instance ..
   235 instance ..
   236 
   236 
   237 end
   237 end
   238 
   238 
   239 consts_code
       
   240   "default :: nat" ("{* 0::nat *}")
       
   241   "default :: nat \<times> nat" ("{* (0::nat, 0::nat) *}")
       
   242 
       
   243 definition
   239 definition
   244   "test n u = pigeonhole n (\<lambda>m. m - 1)"
   240   "test n u = pigeonhole n (\<lambda>m. m - 1)"
   245 definition
   241 definition
   246   "test' n u = pigeonhole_slow n (\<lambda>m. m - 1)"
   242   "test' n u = pigeonhole_slow n (\<lambda>m. m - 1)"
   247 definition
   243 definition
   248   "test'' u = pigeonhole 8 (op ! [0, 1, 2, 3, 4, 5, 6, 3, 7, 8])"
   244   "test'' u = pigeonhole 8 (op ! [0, 1, 2, 3, 4, 5, 6, 3, 7, 8])"
   249 
   245 
       
   246 ML "timeit (@{code test} 10)" 
       
   247 ML "timeit (@{code test'} 10)"
       
   248 ML "timeit (@{code test} 20)"
       
   249 ML "timeit (@{code test'} 20)"
       
   250 ML "timeit (@{code test} 25)"
       
   251 ML "timeit (@{code test'} 25)"
       
   252 ML "timeit (@{code test} 500)"
       
   253 ML "timeit @{code test''}"
       
   254 
       
   255 consts_code
       
   256   "default :: nat" ("{* 0::nat *}")
       
   257   "default :: nat \<times> nat" ("{* (0::nat, 0::nat) *}")
       
   258 
   250 code_module PH
   259 code_module PH
   251 contains
   260 contains
   252   test = test
   261   test = test
   253   test' = test'
   262   test' = test'
   254   test'' = test''
   263   test'' = test''
   255 
   264 
   256 ML "timeit (PH.test 10)"
   265 ML "timeit (PH.test 10)"
   257 ML "timeit (@{code test} 10)" 
       
   258 
       
   259 ML "timeit (PH.test' 10)"
   266 ML "timeit (PH.test' 10)"
   260 ML "timeit (@{code test'} 10)"
       
   261 
       
   262 ML "timeit (PH.test 20)"
   267 ML "timeit (PH.test 20)"
   263 ML "timeit (@{code test} 20)"
       
   264 
       
   265 ML "timeit (PH.test' 20)"
   268 ML "timeit (PH.test' 20)"
   266 ML "timeit (@{code test'} 20)"
       
   267 
       
   268 ML "timeit (PH.test 25)"
   269 ML "timeit (PH.test 25)"
   269 ML "timeit (@{code test} 25)"
       
   270 
       
   271 ML "timeit (PH.test' 25)"
   270 ML "timeit (PH.test' 25)"
   272 ML "timeit (@{code test'} 25)"
       
   273 
       
   274 ML "timeit (PH.test 500)"
   271 ML "timeit (PH.test 500)"
   275 ML "timeit (@{code test} 500)"
       
   276 
       
   277 ML "timeit PH.test''"
   272 ML "timeit PH.test''"
   278 ML "timeit @{code test''}"
       
   279 
   273 
   280 end
   274 end
       
   275