src/HOL/Code_Numeral.thy
changeset 66839 909ba5ed93dd
parent 66838 17989f6bc7b2
child 66886 960509bfd47e
equal deleted inserted replaced
66838:17989f6bc7b2 66839:909ba5ed93dd
   261 lemma [code]:
   261 lemma [code]:
   262   "division_segment (k :: integer) = (if k \<ge> 0 then 1 else - 1)"
   262   "division_segment (k :: integer) = (if k \<ge> 0 then 1 else - 1)"
   263   by transfer (simp add: division_segment_int_def)
   263   by transfer (simp add: division_segment_int_def)
   264 
   264 
   265 instance integer :: ring_parity
   265 instance integer :: ring_parity
   266   by (standard; transfer) (simp_all add: of_nat_div odd_iff_mod_2_eq_one)
   266   by (standard; transfer) (simp_all add: of_nat_div division_segment_int_def)
   267 
   267 
   268 instantiation integer :: unique_euclidean_semiring_numeral
   268 instantiation integer :: unique_euclidean_semiring_numeral
   269 begin
   269 begin
   270 
   270 
   271 definition divmod_integer :: "num \<Rightarrow> num \<Rightarrow> integer \<times> integer"
   271 definition divmod_integer :: "num \<Rightarrow> num \<Rightarrow> integer \<times> integer"
   889 lemma [code]:
   889 lemma [code]:
   890   "division_segment (n::natural) = 1"
   890   "division_segment (n::natural) = 1"
   891   by (simp add: natural_eq_iff)
   891   by (simp add: natural_eq_iff)
   892 
   892 
   893 instance natural :: semiring_parity
   893 instance natural :: semiring_parity
   894   by (standard; transfer) (simp_all add: of_nat_div odd_iff_mod_2_eq_one)
   894   by (standard; transfer) simp_all
   895 
   895 
   896 lift_definition natural_of_integer :: "integer \<Rightarrow> natural"
   896 lift_definition natural_of_integer :: "integer \<Rightarrow> natural"
   897   is "nat :: int \<Rightarrow> nat"
   897   is "nat :: int \<Rightarrow> nat"
   898   .
   898   .
   899 
   899