src/HOL/GCD.thy
changeset 69785 9e326f6f8a24
parent 69768 7e4966eaf781
child 69906 55534affe445
equal deleted inserted replaced
69784:24bbc4e30e5b 69785:9e326f6f8a24
   679   then have "normalize k * unit_factor k * lcm a b  = lcm (k * a) (k * b) * unit_factor k"
   679   then have "normalize k * unit_factor k * lcm a b  = lcm (k * a) (k * b) * unit_factor k"
   680     by (simp only: ac_simps)
   680     by (simp only: ac_simps)
   681   then show ?thesis
   681   then show ?thesis
   682     by simp
   682     by simp
   683 qed
   683 qed
       
   684 
       
   685 lemma gcd_mono: "a dvd c \<Longrightarrow> b dvd d \<Longrightarrow> gcd a b dvd gcd c d"
       
   686   by (simp add: gcd_dvdI1 gcd_dvdI2)
       
   687 
       
   688 lemma lcm_mono: "a dvd c \<Longrightarrow> b dvd d \<Longrightarrow> lcm a b dvd lcm c d"
       
   689   by (simp add: dvd_lcmI1 dvd_lcmI2)
   684 
   690 
   685 lemma dvd_productE:
   691 lemma dvd_productE:
   686   assumes "p dvd a * b"
   692   assumes "p dvd a * b"
   687   obtains x y where "p = x * y" "x dvd a" "y dvd b"
   693   obtains x y where "p = x * y" "x dvd a" "y dvd b"
   688 proof (cases "a = 0")
   694 proof (cases "a = 0")
  1078 lemma Gcd_singleton [simp]: "Gcd {a} = normalize a"
  1084 lemma Gcd_singleton [simp]: "Gcd {a} = normalize a"
  1079   by simp
  1085   by simp
  1080 
  1086 
  1081 lemma Gcd_2 [simp]: "Gcd {a, b} = gcd a b"
  1087 lemma Gcd_2 [simp]: "Gcd {a, b} = gcd a b"
  1082   by simp
  1088   by simp
       
  1089 
       
  1090 lemma Gcd_mono:
       
  1091   assumes "\<And>x. x \<in> A \<Longrightarrow> f x dvd g x"
       
  1092   shows   "(GCD x\<in>A. f x) dvd (GCD x\<in>A. g x)"
       
  1093 proof (intro Gcd_greatest, safe)
       
  1094   fix x assume "x \<in> A"
       
  1095   hence "(GCD x\<in>A. f x) dvd f x"
       
  1096     by (intro Gcd_dvd) auto
       
  1097   also have "f x dvd g x"
       
  1098     using \<open>x \<in> A\<close> assms by blast
       
  1099   finally show "(GCD x\<in>A. f x) dvd \<dots>" .
       
  1100 qed
       
  1101 
       
  1102 lemma Lcm_mono:
       
  1103   assumes "\<And>x. x \<in> A \<Longrightarrow> f x dvd g x"
       
  1104   shows   "(LCM x\<in>A. f x) dvd (LCM x\<in>A. g x)"
       
  1105 proof (intro Lcm_least, safe)
       
  1106   fix x assume "x \<in> A"
       
  1107   hence "f x dvd g x" by (rule assms)
       
  1108   also have "g x dvd (LCM x\<in>A. g x)"
       
  1109     using \<open>x \<in> A\<close> by (intro dvd_Lcm) auto
       
  1110   finally show "f x dvd \<dots>" .
       
  1111 qed
  1083 
  1112 
  1084 end
  1113 end
  1085 
  1114 
  1086 
  1115 
  1087 subsection \<open>An aside: GCD and LCM on finite sets for incomplete gcd rings\<close>
  1116 subsection \<open>An aside: GCD and LCM on finite sets for incomplete gcd rings\<close>