src/HOL/Library/Numeral_Type.thy
changeset 51288 be7e9a675ec9
parent 51175 9f472d5f112c
child 52143 36ffe23b25f8
equal deleted inserted replaced
51277:546a9a1c315d 51288:be7e9a675ec9
   285 lemmas bit1_iszero_numeral [simp] = bit1.iszero_numeral
   285 lemmas bit1_iszero_numeral [simp] = bit1.iszero_numeral
   286 
   286 
   287 declare eq_numeral_iff_iszero [where 'a="('a::finite) bit0", standard, simp]
   287 declare eq_numeral_iff_iszero [where 'a="('a::finite) bit0", standard, simp]
   288 declare eq_numeral_iff_iszero [where 'a="('a::finite) bit1", standard, simp]
   288 declare eq_numeral_iff_iszero [where 'a="('a::finite) bit1", standard, simp]
   289 
   289 
   290 subsection {* Linorder instance *}
   290 subsection {* Order instances *}
   291 
   291 
   292 instantiation bit0 and bit1 :: (finite) linorder begin
   292 instantiation bit0 and bit1 :: (finite) linorder begin
   293 
       
   294 definition "a < b \<longleftrightarrow> Rep_bit0 a < Rep_bit0 b"
   293 definition "a < b \<longleftrightarrow> Rep_bit0 a < Rep_bit0 b"
   295 definition "a \<le> b \<longleftrightarrow> Rep_bit0 a \<le> Rep_bit0 b"
   294 definition "a \<le> b \<longleftrightarrow> Rep_bit0 a \<le> Rep_bit0 b"
   296 definition "a < b \<longleftrightarrow> Rep_bit1 a < Rep_bit1 b"
   295 definition "a < b \<longleftrightarrow> Rep_bit1 a < Rep_bit1 b"
   297 definition "a \<le> b \<longleftrightarrow> Rep_bit1 a \<le> Rep_bit1 b"
   296 definition "a \<le> b \<longleftrightarrow> Rep_bit1 a \<le> Rep_bit1 b"
   298 
   297 
   299 instance
   298 instance
   300   by(intro_classes)
   299   by(intro_classes)
   301     (auto simp add: less_eq_bit0_def less_bit0_def less_eq_bit1_def less_bit1_def Rep_bit0_inject Rep_bit1_inject)
   300     (auto simp add: less_eq_bit0_def less_bit0_def less_eq_bit1_def less_bit1_def Rep_bit0_inject Rep_bit1_inject)
   302 
   301 end
   303 end
   302 
       
   303 lemma (in preorder) tranclp_less: "op <\<^sup>+\<^sup>+ = op <"
       
   304 by(auto simp add: fun_eq_iff intro: less_trans elim: tranclp.induct)
       
   305 
       
   306 instance bit0 and bit1 :: (finite) wellorder
       
   307 proof -
       
   308   have "wf {(x :: 'a bit0, y). x < y}"
       
   309     by(auto simp add: trancl_def tranclp_less intro!: finite_acyclic_wf acyclicI)
       
   310   thus "OFCLASS('a bit0, wellorder_class)"
       
   311     by(rule wf_wellorderI) intro_classes
       
   312 next
       
   313   have "wf {(x :: 'a bit1, y). x < y}"
       
   314     by(auto simp add: trancl_def tranclp_less intro!: finite_acyclic_wf acyclicI)
       
   315   thus "OFCLASS('a bit1, wellorder_class)"
       
   316     by(rule wf_wellorderI) intro_classes
       
   317 qed
   304 
   318 
   305 subsection {* Code setup and type classes for code generation *}
   319 subsection {* Code setup and type classes for code generation *}
   306 
   320 
   307 text {* Code setup for @{typ num0} and @{typ num1} *}
   321 text {* Code setup for @{typ num0} and @{typ num1} *}
   308 
   322