src/HOL/Number_Theory/Gauss.thy
changeset 64282 261d42f0bfac
parent 64272 f76b6dda2e56
child 64631 7705926ee595
equal deleted inserted replaced
64281:bfc2e92d9b4c 64282:261d42f0bfac
     4 *)
     4 *)
     5 
     5 
     6 section \<open>Gauss' Lemma\<close>
     6 section \<open>Gauss' Lemma\<close>
     7 
     7 
     8 theory Gauss
     8 theory Gauss
     9 imports Residues
     9 imports Euler_Criterion
    10 begin
    10 begin
    11 
    11 
    12 lemma cong_prime_prod_zero_nat: 
    12 lemma cong_prime_prod_zero_nat: 
    13   fixes a::nat
    13   fixes a::nat
    14   shows "\<lbrakk>[a * b = 0] (mod p); prime p\<rbrakk> \<Longrightarrow> [a = 0] (mod p) | [b = 0] (mod p)"
    14   shows "\<lbrakk>[a * b = 0] (mod p); prime p\<rbrakk> \<Longrightarrow> [a = 0] (mod p) | [b = 0] (mod p)"
   371     by (metis cong_mult_lcancel_int)
   371     by (metis cong_mult_lcancel_int)
   372   then show ?thesis
   372   then show ?thesis
   373     by (simp add: A_card_eq cong_sym_int)
   373     by (simp add: A_card_eq cong_sym_int)
   374 qed
   374 qed
   375 
   375 
   376 (*NOT WORKING. Old_Number_Theory/Euler.thy needs to be translated, but it's
       
   377 quite a mess and should better be completely redone.
       
   378 
       
   379 theorem gauss_lemma: "(Legendre a p) = (-1) ^ (card E)"
   376 theorem gauss_lemma: "(Legendre a p) = (-1) ^ (card E)"
   380 proof -
   377 proof -
   381   from Euler_Criterion p_prime p_ge_2 have
   378   from euler_criterion p_prime p_ge_2 have
   382       "[(Legendre a p) = a^(nat (((p) - 1) div 2))] (mod p)"
   379       "[(Legendre a p) = a^(nat (((p) - 1) div 2))] (mod p)"
   383     by auto
   380     by auto
       
   381   moreover have "int ((p - 1) div 2) =(int p - 1) div 2" using p_eq2 by linarith
       
   382     hence "[a ^ nat (int ((p - 1) div 2)) = a ^ nat ((int p - 1) div 2)] (mod int p)" by force
   384   moreover note pre_gauss_lemma
   383   moreover note pre_gauss_lemma
   385   ultimately have "[(Legendre a p) = (-1) ^ (card E)] (mod p)"
   384   ultimately have "[(Legendre a p) = (-1) ^ (card E)] (mod p)" using cong_trans_int by blast
   386     by (rule cong_trans_int)
       
   387   moreover from p_a_relprime have "(Legendre a p) = 1 | (Legendre a p) = (-1)"
   385   moreover from p_a_relprime have "(Legendre a p) = 1 | (Legendre a p) = (-1)"
   388     by (auto simp add: Legendre_def)
   386     by (auto simp add: Legendre_def)
   389   moreover have "(-1::int) ^ (card E) = 1 | (-1::int) ^ (card E) = -1"
   387   moreover have "(-1::int) ^ (card E) = 1 | (-1::int) ^ (card E) = -1"
   390     by (rule neg_one_power)
   388     using neg_one_even_power neg_one_odd_power by blast
       
   389   moreover have "[1 \<noteq> - 1] (mod int p)"
       
   390     using cong_altdef_int nonzero_mod_p[of 2] p_odd_int by fastforce
   391   ultimately show ?thesis
   391   ultimately show ?thesis
   392     by (auto simp add: p_ge_2 one_not_neg_one_mod_m zcong_sym)
   392     by (auto simp add: cong_sym_int)
   393 qed
   393 qed
   394 *)
       
   395 
   394 
   396 end
   395 end
   397 
   396 
   398 end
   397 end