src/HOL/Word/WordBitwise.thy
changeset 54883 dd04a8b654fc
parent 54847 d6cf9a5b9be9
child 55465 0d31c0546286
equal deleted inserted replaced
54882:61276a7fc369 54883:dd04a8b654fc
   515           |> mk_nat_clist;
   515           |> mk_nat_clist;
   516         val prop = Thm.mk_binop @{cterm "op = :: nat list => _"} ct ns
   516         val prop = Thm.mk_binop @{cterm "op = :: nat list => _"} ct ns
   517                      |> Thm.apply @{cterm Trueprop};
   517                      |> Thm.apply @{cterm Trueprop};
   518       in
   518       in
   519         try (fn () =>
   519         try (fn () =>
   520           Goal.prove_internal [] prop 
   520           Goal.prove_internal ctxt [] prop 
   521             (K (REPEAT_DETERM (resolve_tac @{thms upt_eq_list_intros} 1
   521             (K (REPEAT_DETERM (resolve_tac @{thms upt_eq_list_intros} 1
   522                 ORELSE simp_tac (put_simpset word_ss ctxt) 1))) |> mk_meta_eq) ()
   522                 ORELSE simp_tac (put_simpset word_ss ctxt) 1))) |> mk_meta_eq) ()
   523       end
   523       end
   524   | _ => NONE;
   524   | _ => NONE;
   525 
   525 
   533     Const (@{const_name len_of}, _) $ t => (let
   533     Const (@{const_name len_of}, _) $ t => (let
   534         val T = fastype_of t |> dest_Type |> snd |> the_single
   534         val T = fastype_of t |> dest_Type |> snd |> the_single
   535         val n = Numeral.mk_cnumber @{ctyp nat} (Word_Lib.dest_binT T);
   535         val n = Numeral.mk_cnumber @{ctyp nat} (Word_Lib.dest_binT T);
   536         val prop = Thm.mk_binop @{cterm "op = :: nat => _"} ct n
   536         val prop = Thm.mk_binop @{cterm "op = :: nat => _"} ct n
   537                  |> Thm.apply @{cterm Trueprop};
   537                  |> Thm.apply @{cterm Trueprop};
   538       in Goal.prove_internal [] prop (K (simp_tac (put_simpset word_ss ctxt) 1))
   538       in Goal.prove_internal ctxt [] prop (K (simp_tac (put_simpset word_ss ctxt) 1))
   539              |> mk_meta_eq |> SOME end
   539              |> mk_meta_eq |> SOME end
   540     handle TERM _ => NONE | TYPE _ => NONE)
   540     handle TERM _ => NONE | TYPE _ => NONE)
   541   | _ => NONE;
   541   | _ => NONE;
   542 
   542 
   543 val word_len_simproc = Simplifier.make_simproc
   543 val word_len_simproc = Simplifier.make_simproc
   559     val arg' = List.foldr (op $) (HOLogic.mk_number @{typ nat} j)
   559     val arg' = List.foldr (op $) (HOLogic.mk_number @{typ nat} j)
   560         (replicate i @{term Suc});
   560         (replicate i @{term Suc});
   561     val _ = if arg = arg' then raise TERM ("", []) else ();
   561     val _ = if arg = arg' then raise TERM ("", []) else ();
   562     fun propfn g = HOLogic.mk_eq (g arg, g arg')
   562     fun propfn g = HOLogic.mk_eq (g arg, g arg')
   563       |> HOLogic.mk_Trueprop |> cterm_of thy;
   563       |> HOLogic.mk_Trueprop |> cterm_of thy;
   564     val eq1 = Goal.prove_internal [] (propfn I)
   564     val eq1 = Goal.prove_internal ctxt [] (propfn I)
   565       (K (simp_tac (put_simpset word_ss ctxt) 1));
   565       (K (simp_tac (put_simpset word_ss ctxt) 1));
   566   in Goal.prove_internal [] (propfn (curry (op $) f))
   566   in Goal.prove_internal ctxt [] (propfn (curry (op $) f))
   567       (K (simp_tac (put_simpset HOL_ss ctxt addsimps [eq1]) 1))
   567       (K (simp_tac (put_simpset HOL_ss ctxt addsimps [eq1]) 1))
   568        |> mk_meta_eq |> SOME end
   568        |> mk_meta_eq |> SOME end
   569     handle TERM _ => NONE;
   569     handle TERM _ => NONE;
   570 
   570 
   571 fun nat_get_Suc_simproc n_sucs thy cts = Simplifier.make_simproc
   571 fun nat_get_Suc_simproc n_sucs cts = Simplifier.make_simproc
   572   {lhss = map (fn t => Thm.apply t @{cpat "?n :: nat"}) cts,
   572   {lhss = map (fn t => Thm.apply t @{cpat "?n :: nat"}) cts,
   573    name = "nat_get_Suc", identifier = [],
   573    name = "nat_get_Suc", identifier = [],
   574    proc = K (nat_get_Suc_simproc_fn n_sucs)};
   574    proc = K (nat_get_Suc_simproc_fn n_sucs)};
   575 
   575 
   576 val no_split_ss =
   576 val no_split_ss =
   599                                 takefill_Suc_Nil takefill.Z rbl_succ2_simps
   599                                 takefill_Suc_Nil takefill.Z rbl_succ2_simps
   600                                 rbl_plus_simps rev_bin_to_bl_simps append.simps
   600                                 rbl_plus_simps rev_bin_to_bl_simps append.simps
   601                                 takefill_last_simps drop_nonempty_simps
   601                                 takefill_last_simps drop_nonempty_simps
   602                                 rev_bl_order_simps}
   602                                 rev_bl_order_simps}
   603           addsimprocs [expand_upt_simproc,
   603           addsimprocs [expand_upt_simproc,
   604                        nat_get_Suc_simproc 4 @{theory}
   604                        nat_get_Suc_simproc 4
   605                          [@{cpat replicate}, @{cpat "takefill ?x"},
   605                          [@{cpat replicate}, @{cpat "takefill ?x"},
   606                           @{cpat drop}, @{cpat "bin_to_bl"},
   606                           @{cpat drop}, @{cpat "bin_to_bl"},
   607                           @{cpat "takefill_last ?x"},
   607                           @{cpat "takefill_last ?x"},
   608                           @{cpat "drop_nonempty ?x"}]],
   608                           @{cpat "drop_nonempty ?x"}]],
   609     put_simpset no_split_ss @{context} addsimps @{thms xor3_simps carry_simps if_bool_simps}
   609     put_simpset no_split_ss @{context} addsimps @{thms xor3_simps carry_simps if_bool_simps}