src/HOL/Computational_Algebra/Primes.thy
changeset 83358 1cf4f1e930af
parent 83357 d7c525fd68b2
child 83359 518a1464f1ac
equal deleted inserted replaced
83357:d7c525fd68b2 83358:1cf4f1e930af
  1059 lemmas primes_coprime_int = primes_coprime[where ?'a = nat]
  1059 lemmas primes_coprime_int = primes_coprime[where ?'a = nat]
  1060 lemmas prime_divprod_pow_nat = prime_elem_divprod_pow[where ?'a = nat]
  1060 lemmas prime_divprod_pow_nat = prime_elem_divprod_pow[where ?'a = nat]
  1061 lemmas prime_exp = prime_elem_power_iff[where ?'a = nat]
  1061 lemmas prime_exp = prime_elem_power_iff[where ?'a = nat]
  1062 
  1062 
  1063 text \<open>Code generation\<close>
  1063 text \<open>Code generation\<close>
  1064   
  1064 
       
  1065 lemma divisor_less_eq_half_nat:
       
  1066   \<open>m \<le> n div 2\<close> if \<open>m dvd n\<close> \<open>m < n\<close> for m n :: nat
       
  1067   using that by (auto simp add: less_eq_div_iff_mult_less_eq)
       
  1068 
       
  1069 lemma divisor_less_eq_half_int:
       
  1070   \<open>k \<le> l div 2\<close> if \<open>k dvd l\<close> \<open>k < l\<close> \<open>l \<ge> 0\<close> \<open>k \<ge> 0\<close> for k l :: int
       
  1071 proof -
       
  1072   define m n where \<open>m = nat \<bar>k\<bar>\<close> \<open>n = nat \<bar>l\<bar>\<close>
       
  1073   with \<open>l \<ge> 0\<close> \<open>k \<ge> 0\<close> have \<open>k = int m\<close> \<open>l = int n\<close>
       
  1074     by simp_all
       
  1075   with that show ?thesis
       
  1076     using divisor_less_eq_half_nat [of m n] by simp
       
  1077 qed
       
  1078 
       
  1079 lemma
       
  1080   \<open>prime n \<longleftrightarrow> 1 < n \<and> (\<forall>n\<in>{1<..n div 2}. \<not> n dvd p)\<close>
       
  1081 
       
  1082 thm prime_nat_iff prime_int_iff [no_vars]
       
  1083 
  1065 context
  1084 context
  1066 begin
  1085 begin
  1067 
  1086 
  1068 qualified definition prime_nat :: "nat \<Rightarrow> bool"
  1087 qualified definition prime_nat :: "nat \<Rightarrow> bool"
  1069   where [simp, code_abbrev]: "prime_nat = prime"
  1088   where [simp, code_abbrev]: "prime_nat = prime"