src/HOL/Library/GCD.thy
changeset 23983 79dc793bec43
parent 23951 b188cac107ad
child 23994 3ddc90d1eda1
equal deleted inserted replaced
23982:e3c4c0b9ae05 23983:79dc793bec43
   417   with igcd_pos show "?g' = 1" by simp
   417   with igcd_pos show "?g' = 1" by simp
   418 qed
   418 qed
   419 
   419 
   420 definition "ilcm = (\<lambda>i j. int (lcm(nat(abs i),nat(abs j))))"
   420 definition "ilcm = (\<lambda>i j. int (lcm(nat(abs i),nat(abs j))))"
   421 
   421 
   422 (* ilcm_dvd12 are needed later *)
   422 lemma dvd_ilcm_self1[simp]: "i dvd ilcm i j"
       
   423 by(simp add:ilcm_def dvd_int_iff)
       
   424 
       
   425 lemma dvd_ilcm_self2[simp]: "j dvd ilcm i j"
       
   426 by(simp add:ilcm_def dvd_int_iff)
       
   427 
   423 lemma ilcm_dvd1: 
   428 lemma ilcm_dvd1: 
   424 assumes anz: "a \<noteq> 0" 
   429 assumes anz: "a \<noteq> 0" 
   425   and bnz: "b \<noteq> 0"
   430   and bnz: "b \<noteq> 0"
   426   shows "a dvd (ilcm a b)"
   431   shows "a dvd (ilcm a b)"
   427 proof-
   432 proof-
   442   let ?nb = "nat (abs b)"
   447   let ?nb = "nat (abs b)"
   443   have nap: "?na >0" using anz by simp
   448   have nap: "?na >0" using anz by simp
   444   have nbp: "?nb >0" using bnz by simp
   449   have nbp: "?nb >0" using bnz by simp
   445   from nap nbp have "?nb dvd lcm(?na,?nb)" using lcm_dvd2 by simp
   450   from nap nbp have "?nb dvd lcm(?na,?nb)" using lcm_dvd2 by simp
   446   thus ?thesis by (simp add: ilcm_def dvd_int_iff)
   451   thus ?thesis by (simp add: ilcm_def dvd_int_iff)
       
   452 qed
       
   453 
       
   454 lemma dvd_imp_dvd_ilcm1:
       
   455   assumes "k dvd i" shows "k dvd (ilcm i j)"
       
   456 proof -
       
   457   have "nat(abs k) dvd nat(abs i)" using `k dvd i`
       
   458     by(simp add:int_dvd_iff[symmetric] dvd_int_iff[symmetric]IntDiv.zdvd_abs1)
       
   459   thus ?thesis by(simp add:ilcm_def dvd_int_iff)(blast intro: dvd_trans)
       
   460 qed
       
   461 
       
   462 lemma dvd_imp_dvd_ilcm2:
       
   463   assumes "k dvd j" shows "k dvd (ilcm i j)"
       
   464 proof -
       
   465   have "nat(abs k) dvd nat(abs j)" using `k dvd j`
       
   466     by(simp add:int_dvd_iff[symmetric] dvd_int_iff[symmetric]IntDiv.zdvd_abs1)
       
   467   thus ?thesis by(simp add:ilcm_def dvd_int_iff)(blast intro: dvd_trans)
   447 qed
   468 qed
   448 
   469 
   449 lemma zdvd_self_abs1: "(d::int) dvd (abs d)"
   470 lemma zdvd_self_abs1: "(d::int) dvd (abs d)"
   450 by (case_tac "d <0", simp_all)
   471 by (case_tac "d <0", simp_all)
   451 
   472 
   476  with t1 have "gcd(m,n) \<le> m*n" by arith
   497  with t1 have "gcd(m,n) \<le> m*n" by arith
   477 ultimately show "False" by simp
   498 ultimately show "False" by simp
   478 qed
   499 qed
   479 
   500 
   480 lemma ilcm_pos: 
   501 lemma ilcm_pos: 
   481   assumes apos: " 0 < a"
   502   assumes anz: "a \<noteq> 0"
   482   and bpos: "0 < b" 
   503   and bnz: "b \<noteq> 0" 
   483   shows "0 < ilcm  a b"
   504   shows "0 < ilcm a b"
   484 proof-
   505 proof-
   485   let ?na = "nat (abs a)"
   506   let ?na = "nat (abs a)"
   486   let ?nb = "nat (abs b)"
   507   let ?nb = "nat (abs b)"
   487   have nap: "?na >0" using apos by simp
   508   have nap: "?na >0" using anz by simp
   488   have nbp: "?nb >0" using bpos by simp
   509   have nbp: "?nb >0" using bnz by simp
   489   have "0 < lcm (?na,?nb)" by (rule lcm_pos[OF nap nbp])
   510   have "0 < lcm (?na,?nb)" by (rule lcm_pos[OF nap nbp])
   490   thus ?thesis by (simp add: ilcm_def)
   511   thus ?thesis by (simp add: ilcm_def)
   491 qed
   512 qed
   492 
   513 
   493 end
   514 end