src/HOL/Word/Bit_Representation.thy
changeset 54873 c92a0e6ba828
parent 54863 82acc20ded73
child 58410 6d46ad54a2ab
equal deleted inserted replaced
54872:af81b2357e08 54873:c92a0e6ba828
    50   unfolding bin_rest_def Bit_def
    50   unfolding bin_rest_def Bit_def
    51   by (cases b, simp_all)
    51   by (cases b, simp_all)
    52 
    52 
    53 lemma bin_last_BIT [simp]: "bin_last (x BIT b) = b"
    53 lemma bin_last_BIT [simp]: "bin_last (x BIT b) = b"
    54   unfolding bin_last_def Bit_def
    54   unfolding bin_last_def Bit_def
    55   by (cases b, simp_all add: z1pmod2)
    55   by (cases b) simp_all
    56 
    56 
    57 lemma BIT_eq_iff [iff]: "u BIT b = v BIT c \<longleftrightarrow> u = v \<and> b = c"
    57 lemma BIT_eq_iff [iff]: "u BIT b = v BIT c \<longleftrightarrow> u = v \<and> b = c"
    58   apply (auto simp add: Bit_def)
    58   apply (auto simp add: Bit_def)
    59   apply arith
    59   apply arith
    60   apply arith
    60   apply arith
   149   by (simp_all add: Bit_B0_2t Bit_B1_2t algebra_simps)
   149   by (simp_all add: Bit_B0_2t Bit_B1_2t algebra_simps)
   150 
   150 
   151 lemma B_mod_2': 
   151 lemma B_mod_2': 
   152   "X = 2 ==> (w BIT True) mod X = 1 & (w BIT False) mod X = 0"
   152   "X = 2 ==> (w BIT True) mod X = 1 & (w BIT False) mod X = 0"
   153   apply (simp (no_asm) only: Bit_B0 Bit_B1)
   153   apply (simp (no_asm) only: Bit_B0 Bit_B1)
   154   apply (simp add: z1pmod2)
   154   apply simp
   155   done
   155   done
   156 
   156 
   157 lemma bin_ex_rl: "EX w b. w BIT b = bin"
   157 lemma bin_ex_rl: "EX w b. w BIT b = bin"
   158   by (metis bin_rl_simp)
   158   by (metis bin_rl_simp)
   159 
   159 
   167   done
   167   done
   168 
   168 
   169 primrec bin_nth where
   169 primrec bin_nth where
   170   Z: "bin_nth w 0 \<longleftrightarrow> bin_last w"
   170   Z: "bin_nth w 0 \<longleftrightarrow> bin_last w"
   171   | Suc: "bin_nth w (Suc n) \<longleftrightarrow> bin_nth (bin_rest w) n"
   171   | Suc: "bin_nth w (Suc n) \<longleftrightarrow> bin_nth (bin_rest w) n"
   172 
       
   173 find_theorems "bin_rest _ = _"
       
   174 
   172 
   175 lemma bin_abs_lem:
   173 lemma bin_abs_lem:
   176   "bin = (w BIT b) ==> bin ~= -1 --> bin ~= 0 -->
   174   "bin = (w BIT b) ==> bin ~= -1 --> bin ~= 0 -->
   177     nat (abs w) < nat (abs bin)"
   175     nat (abs w) < nat (abs bin)"
   178   apply clarsimp
   176   apply clarsimp
   312   apply (induct n arbitrary: w)
   310   apply (induct n arbitrary: w)
   313    apply simp
   311    apply simp
   314    apply (subst mod_add_left_eq)
   312    apply (subst mod_add_left_eq)
   315    apply (simp add: bin_last_def)
   313    apply (simp add: bin_last_def)
   316    apply arith
   314    apply arith
   317   apply (simp add: bin_last_def bin_rest_def Bit_def mod_2_neq_1_eq_eq_0)
   315   apply (simp add: bin_last_def bin_rest_def Bit_def)
   318   apply (clarsimp simp: mod_mult_mult1 [symmetric] 
   316   apply (clarsimp simp: mod_mult_mult1 [symmetric] 
   319          zmod_zdiv_equality [THEN diff_eq_eq [THEN iffD2 [THEN sym]]])
   317          zmod_zdiv_equality [THEN diff_eq_eq [THEN iffD2 [THEN sym]]])
   320   apply (rule trans [symmetric, OF _ emep1])
   318   apply (rule trans [symmetric, OF _ emep1])
   321      apply auto
   319      apply auto
   322   apply (auto simp: even_def)
   320   apply (auto simp: even_def)