src/HOL/Computational_Algebra/Polynomial.thy
changeset 76245 4111c94657b4
parent 76208 14dd8b46307f
child 76386 6bc3bb9d0e3e
equal deleted inserted replaced
76244:6ab4bb7cb8b2 76245:4111c94657b4
  3983     case True
  3983     case True
  3984     then show ?thesis
  3984     then show ?thesis
  3985       by simp
  3985       by simp
  3986   next
  3986   next
  3987     case False
  3987     case False
  3988     then show ?thesis
  3988     show ?thesis
  3989       by (cases y \<open>smult a (x div y)\<close> \<open>smult a (x mod y)\<close> \<open>smult a x\<close> rule: euclidean_relation_polyI)
  3989       by (rule euclidean_relation_polyI)
  3990         (simp_all add: dvd_smult_iff degree_mod_less_degree flip: smult_add_right)
  3990         (use False in \<open>simp_all add: dvd_smult_iff degree_mod_less_degree flip: smult_add_right\<close>)
  3991   qed
  3991   qed
  3992   then show ?Q and ?R
  3992   then show ?Q and ?R
  3993     by simp_all
  3993     by simp_all
  3994 qed
  3994 qed
  3995 
  3995 
  4004 lemma poly_div_add_left: \<open>(x + y) div z = x div z + y div z\<close> (is ?Q)
  4004 lemma poly_div_add_left: \<open>(x + y) div z = x div z + y div z\<close> (is ?Q)
  4005   and poly_mod_add_left: \<open>(x + y) mod z = x mod z + y mod z\<close> (is ?R)
  4005   and poly_mod_add_left: \<open>(x + y) mod z = x mod z + y mod z\<close> (is ?R)
  4006   for x y z :: \<open>'a::field poly\<close>
  4006   for x y z :: \<open>'a::field poly\<close>
  4007 proof -
  4007 proof -
  4008   have \<open>((x + y) div z, (x + y) mod z) = (x div z + y div z, x mod z + y mod z)\<close>
  4008   have \<open>((x + y) div z, (x + y) mod z) = (x div z + y div z, x mod z + y mod z)\<close>
  4009   proof (cases z \<open>x div z + y div z\<close> \<open>x mod z + y mod z\<close> \<open>x + y\<close> rule: euclidean_relation_polyI)
  4009   proof (induction rule: euclidean_relation_polyI)
  4010     case by0
  4010     case by0
  4011     then show ?case by simp
  4011     then show ?case by simp
  4012   next
  4012   next
  4013     case divides
  4013     case divides
  4014     then obtain w where \<open>x + y = z * w\<close>
  4014     then obtain w where \<open>x + y = z * w\<close>
  4043 
  4043 
  4044 lemma div_smult_right: \<open>x div smult a y = smult (inverse a) (x div y)\<close> (is ?Q)
  4044 lemma div_smult_right: \<open>x div smult a y = smult (inverse a) (x div y)\<close> (is ?Q)
  4045   and mod_smult_right: \<open>x mod smult a y = (if a = 0 then x else x mod y)\<close> (is ?R)
  4045   and mod_smult_right: \<open>x mod smult a y = (if a = 0 then x else x mod y)\<close> (is ?R)
  4046 proof -
  4046 proof -
  4047   have \<open>(x div smult a y, x mod smult a y) = (smult (inverse a) (x div y), (if a = 0 then x else x mod y))\<close>
  4047   have \<open>(x div smult a y, x mod smult a y) = (smult (inverse a) (x div y), (if a = 0 then x else x mod y))\<close>
  4048   proof (cases \<open>smult a y\<close> \<open>smult (inverse a) (x div y)\<close> \<open>(if a = 0 then x else x mod y)\<close> x rule: euclidean_relation_polyI)
  4048   proof (induction rule: euclidean_relation_polyI)
  4049     case by0
  4049     case by0
  4050     then show ?case by auto
  4050     then show ?case by auto
  4051   next
  4051   next
  4052     case divides
  4052     case divides
  4053     moreover define w where \<open>w = x div y\<close>
  4053     moreover define w where \<open>w = x div y\<close>
  4075 lemma poly_div_mult_right: \<open>x div (y * z) = (x div y) div z\<close> (is ?Q)
  4075 lemma poly_div_mult_right: \<open>x div (y * z) = (x div y) div z\<close> (is ?Q)
  4076   and poly_mod_mult_right: \<open>x mod (y * z) = y * (x div y mod z) + x mod y\<close> (is ?R)
  4076   and poly_mod_mult_right: \<open>x mod (y * z) = y * (x div y mod z) + x mod y\<close> (is ?R)
  4077   for x y z :: \<open>'a::field poly\<close>
  4077   for x y z :: \<open>'a::field poly\<close>
  4078 proof -
  4078 proof -
  4079   have \<open>(x div (y * z), x mod (y * z)) = ((x div y) div z, y * (x div y mod z) + x mod y)\<close>
  4079   have \<open>(x div (y * z), x mod (y * z)) = ((x div y) div z, y * (x div y mod z) + x mod y)\<close>
  4080   proof (cases \<open>y * z\<close> \<open>(x div y) div z\<close> \<open>y * (x div y mod z) + x mod y\<close> x rule: euclidean_relation_polyI)
  4080   proof (induction rule: euclidean_relation_polyI)
  4081     case by0
  4081     case by0
  4082     then show ?case by auto
  4082     then show ?case by auto
  4083   next
  4083   next
  4084     case divides
  4084     case divides
  4085     then show ?case by auto
  4085     then show ?case by auto
  4141   moreover have \<open>?Q\<close> and \<open>?R\<close> if \<open>q \<noteq> 0\<close>
  4141   moreover have \<open>?Q\<close> and \<open>?R\<close> if \<open>q \<noteq> 0\<close>
  4142   proof -
  4142   proof -
  4143     define b where \<open>b = coeff (pCons a (p mod q)) (degree q) / lead_coeff q\<close>
  4143     define b where \<open>b = coeff (pCons a (p mod q)) (degree q) / lead_coeff q\<close>
  4144     have \<open>(pCons a p div q, pCons a p mod q) =
  4144     have \<open>(pCons a p div q, pCons a p mod q) =
  4145       (pCons b (p div q), (pCons a (p mod q) - smult b q))\<close> (is \<open>_ = (?q, ?r)\<close>)
  4145       (pCons b (p div q), (pCons a (p mod q) - smult b q))\<close> (is \<open>_ = (?q, ?r)\<close>)
  4146     proof (cases q ?q ?r \<open>pCons a p\<close> rule: euclidean_relation_polyI)
  4146     proof (induction rule: euclidean_relation_polyI)
  4147       case by0
  4147       case by0
  4148       with \<open>q \<noteq> 0\<close> show ?case by simp
  4148       with \<open>q \<noteq> 0\<close> show ?case by simp
  4149     next
  4149     next
  4150       case divides
  4150       case divides
  4151       show ?case
  4151       show ?case