src/HOL/Int.thy
changeset 40819 2ac5af6eb8a8
parent 39910 10097e0a9dbd
child 41959 b460124855b8
equal deleted inserted replaced
40818:b117df72e56b 40819:2ac5af6eb8a8
   100 subsection {* Arithmetic Operations *}
   100 subsection {* Arithmetic Operations *}
   101 
   101 
   102 lemma minus: "- Abs_Integ(intrel``{(x,y)}) = Abs_Integ(intrel `` {(y,x)})"
   102 lemma minus: "- Abs_Integ(intrel``{(x,y)}) = Abs_Integ(intrel `` {(y,x)})"
   103 proof -
   103 proof -
   104   have "(\<lambda>(x,y). intrel``{(y,x)}) respects intrel"
   104   have "(\<lambda>(x,y). intrel``{(y,x)}) respects intrel"
   105     by (simp add: congruent_def) 
   105     by (auto simp add: congruent_def)
   106   thus ?thesis
   106   thus ?thesis
   107     by (simp add: minus_int_def UN_equiv_class [OF equiv_intrel])
   107     by (simp add: minus_int_def UN_equiv_class [OF equiv_intrel])
   108 qed
   108 qed
   109 
   109 
   110 lemma add:
   110 lemma add:
   111      "Abs_Integ (intrel``{(x,y)}) + Abs_Integ (intrel``{(u,v)}) =
   111      "Abs_Integ (intrel``{(x,y)}) + Abs_Integ (intrel``{(u,v)}) =
   112       Abs_Integ (intrel``{(x+u, y+v)})"
   112       Abs_Integ (intrel``{(x+u, y+v)})"
   113 proof -
   113 proof -
   114   have "(\<lambda>z w. (\<lambda>(x,y). (\<lambda>(u,v). intrel `` {(x+u, y+v)}) w) z) 
   114   have "(\<lambda>z w. (\<lambda>(x,y). (\<lambda>(u,v). intrel `` {(x+u, y+v)}) w) z) 
   115         respects2 intrel"
   115         respects2 intrel"
   116     by (simp add: congruent2_def)
   116     by (auto simp add: congruent2_def)
   117   thus ?thesis
   117   thus ?thesis
   118     by (simp add: add_int_def UN_UN_split_split_eq
   118     by (simp add: add_int_def UN_UN_split_split_eq
   119                   UN_equiv_class2 [OF equiv_intrel equiv_intrel])
   119                   UN_equiv_class2 [OF equiv_intrel equiv_intrel])
   120 qed
   120 qed
   121 
   121 
   286   "of_int z = the_elem (\<Union>(i, j) \<in> Rep_Integ z. { of_nat i - of_nat j })"
   286   "of_int z = the_elem (\<Union>(i, j) \<in> Rep_Integ z. { of_nat i - of_nat j })"
   287 
   287 
   288 lemma of_int: "of_int (Abs_Integ (intrel `` {(i,j)})) = of_nat i - of_nat j"
   288 lemma of_int: "of_int (Abs_Integ (intrel `` {(i,j)})) = of_nat i - of_nat j"
   289 proof -
   289 proof -
   290   have "(\<lambda>(i,j). { of_nat i - (of_nat j :: 'a) }) respects intrel"
   290   have "(\<lambda>(i,j). { of_nat i - (of_nat j :: 'a) }) respects intrel"
   291     by (simp add: congruent_def algebra_simps of_nat_add [symmetric]
   291     by (auto simp add: congruent_def) (simp add: algebra_simps of_nat_add [symmetric]
   292             del: of_nat_add) 
   292             del: of_nat_add) 
   293   thus ?thesis
   293   thus ?thesis
   294     by (simp add: of_int_def UN_equiv_class [OF equiv_intrel])
   294     by (simp add: of_int_def UN_equiv_class [OF equiv_intrel])
   295 qed
   295 qed
   296 
   296 
   392   "nat z = the_elem (\<Union>(x, y) \<in> Rep_Integ z. {x-y})"
   392   "nat z = the_elem (\<Union>(x, y) \<in> Rep_Integ z. {x-y})"
   393 
   393 
   394 lemma nat: "nat (Abs_Integ (intrel``{(x,y)})) = x-y"
   394 lemma nat: "nat (Abs_Integ (intrel``{(x,y)})) = x-y"
   395 proof -
   395 proof -
   396   have "(\<lambda>(x,y). {x-y}) respects intrel"
   396   have "(\<lambda>(x,y). {x-y}) respects intrel"
   397     by (simp add: congruent_def) arith
   397     by (auto simp add: congruent_def)
   398   thus ?thesis
   398   thus ?thesis
   399     by (simp add: nat_def UN_equiv_class [OF equiv_intrel])
   399     by (simp add: nat_def UN_equiv_class [OF equiv_intrel])
   400 qed
   400 qed
   401 
   401 
   402 lemma nat_int [simp]: "nat (of_nat n) = n"
   402 lemma nat_int [simp]: "nat (of_nat n) = n"