src/HOL/Word/WordBitwise.thy
changeset 67121 116968454d70
parent 67120 491fd7f0b5df
child 67399 eab6ce8368fa
equal deleted inserted replaced
67120:491fd7f0b5df 67121:116968454d70
   414 struct
   414 struct
   415 
   415 
   416 val word_ss = simpset_of @{theory_context Word};
   416 val word_ss = simpset_of @{theory_context Word};
   417 
   417 
   418 fun mk_nat_clist ns =
   418 fun mk_nat_clist ns =
   419   List.foldr
   419   fold_rev (Thm.mk_binop @{cterm "Cons :: nat \<Rightarrow> _"})
   420     (uncurry (Thm.mk_binop @{cterm "Cons :: nat \<Rightarrow> _"}))
   420     ns @{cterm "[] :: nat list"};
   421     @{cterm "[] :: nat list"} ns;
       
   422 
   421 
   423 fun upt_conv ctxt ct =
   422 fun upt_conv ctxt ct =
   424   case Thm.term_of ct of
   423   case Thm.term_of ct of
   425     (@{const upt} $ n $ m) =>
   424     (@{const upt} $ n $ m) =>
   426       let
   425       let
   469     val (f $ arg) = Thm.term_of ct;
   468     val (f $ arg) = Thm.term_of ct;
   470     val n =
   469     val n =
   471       (case arg of @{term nat} $ n => n | n => n)
   470       (case arg of @{term nat} $ n => n | n => n)
   472       |> HOLogic.dest_number |> snd;
   471       |> HOLogic.dest_number |> snd;
   473     val (i, j) = if n > n_sucs then (n_sucs, n - n_sucs) else (n, 0);
   472     val (i, j) = if n > n_sucs then (n_sucs, n - n_sucs) else (n, 0);
   474     val arg' =
   473     val arg' = funpow i HOLogic.mk_Suc (HOLogic.mk_number @{typ nat} j);
   475       List.foldr (op $) (HOLogic.mk_number @{typ nat} j) (replicate i @{term Suc});
       
   476     val _ = if arg = arg' then raise TERM ("", []) else ();
   474     val _ = if arg = arg' then raise TERM ("", []) else ();
   477     fun propfn g =
   475     fun propfn g =
   478       HOLogic.mk_eq (g arg, g arg')
   476       HOLogic.mk_eq (g arg, g arg')
   479       |> HOLogic.mk_Trueprop |> Thm.cterm_of ctxt;
   477       |> HOLogic.mk_Trueprop |> Thm.cterm_of ctxt;
   480     val eq1 =
   478     val eq1 =