src/HOL/Algebra/Exponent.thy
author paulson
Tue Mar 18 18:07:06 2003 +0100 (2003-03-18)
changeset 13870 cf947d1ec5ff
child 14706 71590b7733b7
permissions -rw-r--r--
moved Exponent, Coset, Sylow from GroupTheory to Algebra, converting them
to the new Group setup.

Deleted Ring, Module from GroupTheory

Minor UNITY changes
paulson@13870
     1
(*  Title:      HOL/GroupTheory/Exponent
paulson@13870
     2
    ID:         $Id$
paulson@13870
     3
    Author:     Florian Kammueller, with new proofs by L C Paulson
paulson@13870
     4
paulson@13870
     5
    exponent p s   yields the greatest power of p that divides s.
paulson@13870
     6
*)
paulson@13870
     7
paulson@13870
     8
header{*The Combinatorial Argument Underlying the First Sylow Theorem*}
paulson@13870
     9
paulson@13870
    10
theory Exponent = Main + Primes:
paulson@13870
    11
paulson@13870
    12
constdefs
paulson@13870
    13
  exponent      :: "[nat, nat] => nat"
paulson@13870
    14
  "exponent p s == if p \<in> prime then (GREATEST r. p^r dvd s) else 0"
paulson@13870
    15
paulson@13870
    16
subsection{*Prime Theorems*}
paulson@13870
    17
paulson@13870
    18
lemma prime_imp_one_less: "p \<in> prime ==> Suc 0 < p"
paulson@13870
    19
by (unfold prime_def, force)
paulson@13870
    20
paulson@13870
    21
lemma prime_iff:
paulson@13870
    22
     "(p \<in> prime) = (Suc 0 < p & (\<forall>a b. p dvd a*b --> (p dvd a) | (p dvd b)))"
paulson@13870
    23
apply (auto simp add: prime_imp_one_less)
paulson@13870
    24
apply (blast dest!: prime_dvd_mult)
paulson@13870
    25
apply (auto simp add: prime_def)
paulson@13870
    26
apply (erule dvdE)
paulson@13870
    27
apply (case_tac "k=0", simp)
paulson@13870
    28
apply (drule_tac x = m in spec)
paulson@13870
    29
apply (drule_tac x = k in spec)
paulson@13870
    30
apply (simp add: dvd_mult_cancel1 dvd_mult_cancel2, auto)
paulson@13870
    31
done
paulson@13870
    32
paulson@13870
    33
lemma zero_less_prime_power: "p \<in> prime ==> 0 < p^a"
paulson@13870
    34
by (force simp add: prime_iff)
paulson@13870
    35
paulson@13870
    36
paulson@13870
    37
lemma le_extend_mult: "[| 0 < c; a <= b |] ==> a <= b * (c::nat)"
paulson@13870
    38
apply (rule_tac P = "%x. x <= b * c" in subst)
paulson@13870
    39
apply (rule mult_1_right)
paulson@13870
    40
apply (rule mult_le_mono, auto)
paulson@13870
    41
done
paulson@13870
    42
paulson@13870
    43
lemma insert_partition:
paulson@13870
    44
     "[| x \<notin> F; \<forall>c1\<in>insert x F. \<forall>c2 \<in> insert x F. c1 \<noteq> c2 --> c1 \<inter> c2 = {}|] 
paulson@13870
    45
      ==> x \<inter> \<Union> F = {}"
paulson@13870
    46
by auto
paulson@13870
    47
paulson@13870
    48
(* main cardinality theorem *)
paulson@13870
    49
lemma card_partition [rule_format]:
paulson@13870
    50
     "finite C ==>  
paulson@13870
    51
        finite (\<Union> C) -->  
paulson@13870
    52
        (\<forall>c\<in>C. card c = k) -->   
paulson@13870
    53
        (\<forall>c1 \<in> C. \<forall>c2 \<in> C. c1 \<noteq> c2 --> c1 \<inter> c2 = {}) -->  
paulson@13870
    54
        k * card(C) = card (\<Union> C)"
paulson@13870
    55
apply (erule finite_induct, simp)
paulson@13870
    56
apply (simp add: card_insert_disjoint card_Un_disjoint insert_partition 
paulson@13870
    57
       finite_subset [of _ "\<Union> (insert x F)"])
paulson@13870
    58
done
paulson@13870
    59
paulson@13870
    60
lemma zero_less_card_empty: "[| finite S; S \<noteq> {} |] ==> 0 < card(S)"
paulson@13870
    61
by (rule ccontr, simp)
paulson@13870
    62
paulson@13870
    63
paulson@13870
    64
lemma prime_dvd_cases:
paulson@13870
    65
     "[| p*k dvd m*n;  p \<in> prime |]  
paulson@13870
    66
      ==> (\<exists>x. k dvd x*n & m = p*x) | (\<exists>y. k dvd m*y & n = p*y)"
paulson@13870
    67
apply (simp add: prime_iff)
paulson@13870
    68
apply (frule dvd_mult_left)
paulson@13870
    69
apply (subgoal_tac "p dvd m | p dvd n")
paulson@13870
    70
 prefer 2 apply blast
paulson@13870
    71
apply (erule disjE)
paulson@13870
    72
apply (rule disjI1)
paulson@13870
    73
apply (rule_tac [2] disjI2)
paulson@13870
    74
apply (erule_tac n = m in dvdE)
paulson@13870
    75
apply (erule_tac [2] n = n in dvdE, auto)
paulson@13870
    76
apply (rule_tac [2] k = p in dvd_mult_cancel)
paulson@13870
    77
apply (rule_tac k = p in dvd_mult_cancel)
paulson@13870
    78
apply (simp_all add: mult_ac)
paulson@13870
    79
done
paulson@13870
    80
paulson@13870
    81
paulson@13870
    82
lemma prime_power_dvd_cases [rule_format (no_asm)]: "p \<in> prime  
paulson@13870
    83
      ==> \<forall>m n. p^c dvd m*n -->  
paulson@13870
    84
          (\<forall>a b. a+b = Suc c --> p^a dvd m | p^b dvd n)"
paulson@13870
    85
apply (induct_tac "c")
paulson@13870
    86
 apply clarify
paulson@13870
    87
 apply (case_tac "a")
paulson@13870
    88
  apply simp
paulson@13870
    89
 apply simp
paulson@13870
    90
(*inductive step*)
paulson@13870
    91
apply simp
paulson@13870
    92
apply clarify
paulson@13870
    93
apply (erule prime_dvd_cases [THEN disjE], assumption, auto)
paulson@13870
    94
(*case 1: p dvd m*)
paulson@13870
    95
 apply (case_tac "a")
paulson@13870
    96
  apply simp
paulson@13870
    97
 apply clarify
paulson@13870
    98
 apply (drule spec, drule spec, erule (1) notE impE)
paulson@13870
    99
 apply (drule_tac x = nat in spec)
paulson@13870
   100
 apply (drule_tac x = b in spec)
paulson@13870
   101
 apply simp
paulson@13870
   102
 apply (blast intro: dvd_refl mult_dvd_mono)
paulson@13870
   103
(*case 2: p dvd n*)
paulson@13870
   104
apply (case_tac "b")
paulson@13870
   105
 apply simp
paulson@13870
   106
apply clarify
paulson@13870
   107
apply (drule spec, drule spec, erule (1) notE impE)
paulson@13870
   108
apply (drule_tac x = a in spec)
paulson@13870
   109
apply (drule_tac x = nat in spec, simp)
paulson@13870
   110
apply (blast intro: dvd_refl mult_dvd_mono)
paulson@13870
   111
done
paulson@13870
   112
paulson@13870
   113
(*needed in this form in Sylow.ML*)
paulson@13870
   114
lemma div_combine:
paulson@13870
   115
     "[| p \<in> prime; ~ (p ^ (Suc r) dvd n);  p^(a+r) dvd n*k |]  
paulson@13870
   116
      ==> p ^ a dvd k"
paulson@13870
   117
by (drule_tac a = "Suc r" and b = a in prime_power_dvd_cases, assumption, auto)
paulson@13870
   118
paulson@13870
   119
(*Lemma for power_dvd_bound*)
paulson@13870
   120
lemma Suc_le_power: "Suc 0 < p ==> Suc n <= p^n"
paulson@13870
   121
apply (induct_tac "n")
paulson@13870
   122
apply (simp (no_asm_simp))
paulson@13870
   123
apply simp
paulson@13870
   124
apply (subgoal_tac "2 * n + 2 <= p * p^n", simp)
paulson@13870
   125
apply (subgoal_tac "2 * p^n <= p * p^n")
paulson@13870
   126
(*?arith_tac should handle all of this!*)
paulson@13870
   127
apply (rule order_trans)
paulson@13870
   128
prefer 2 apply assumption
paulson@13870
   129
apply (drule_tac k = 2 in mult_le_mono2, simp)
paulson@13870
   130
apply (rule mult_le_mono1, simp)
paulson@13870
   131
done
paulson@13870
   132
paulson@13870
   133
(*An upper bound for the n such that p^n dvd a: needed for GREATEST to exist*)
paulson@13870
   134
lemma power_dvd_bound: "[|p^n dvd a;  Suc 0 < p;  0 < a|] ==> n < a"
paulson@13870
   135
apply (drule dvd_imp_le)
paulson@13870
   136
apply (drule_tac [2] n = n in Suc_le_power, auto)
paulson@13870
   137
done
paulson@13870
   138
paulson@13870
   139
paulson@13870
   140
subsection{*Exponent Theorems*}
paulson@13870
   141
paulson@13870
   142
lemma exponent_ge [rule_format]:
paulson@13870
   143
     "[|p^k dvd n;  p \<in> prime;  0<n|] ==> k <= exponent p n"
paulson@13870
   144
apply (simp add: exponent_def)
paulson@13870
   145
apply (erule Greatest_le)
paulson@13870
   146
apply (blast dest: prime_imp_one_less power_dvd_bound)
paulson@13870
   147
done
paulson@13870
   148
paulson@13870
   149
lemma power_exponent_dvd: "0<s ==> (p ^ exponent p s) dvd s"
paulson@13870
   150
apply (simp add: exponent_def)
paulson@13870
   151
apply clarify
paulson@13870
   152
apply (rule_tac k = 0 in GreatestI)
paulson@13870
   153
prefer 2 apply (blast dest: prime_imp_one_less power_dvd_bound, simp)
paulson@13870
   154
done
paulson@13870
   155
paulson@13870
   156
lemma power_Suc_exponent_Not_dvd:
paulson@13870
   157
     "[|(p * p ^ exponent p s) dvd s;  p \<in> prime |] ==> s=0"
paulson@13870
   158
apply (subgoal_tac "p ^ Suc (exponent p s) dvd s")
paulson@13870
   159
 prefer 2 apply simp 
paulson@13870
   160
apply (rule ccontr)
paulson@13870
   161
apply (drule exponent_ge, auto)
paulson@13870
   162
done
paulson@13870
   163
paulson@13870
   164
lemma exponent_power_eq [simp]: "p \<in> prime ==> exponent p (p^a) = a"
paulson@13870
   165
apply (simp (no_asm_simp) add: exponent_def)
paulson@13870
   166
apply (rule Greatest_equality, simp)
paulson@13870
   167
apply (simp (no_asm_simp) add: prime_imp_one_less power_dvd_imp_le)
paulson@13870
   168
done
paulson@13870
   169
paulson@13870
   170
lemma exponent_equalityI:
paulson@13870
   171
     "!r::nat. (p^r dvd a) = (p^r dvd b) ==> exponent p a = exponent p b"
paulson@13870
   172
by (simp (no_asm_simp) add: exponent_def)
paulson@13870
   173
paulson@13870
   174
lemma exponent_eq_0 [simp]: "p \<notin> prime ==> exponent p s = 0"
paulson@13870
   175
by (simp (no_asm_simp) add: exponent_def)
paulson@13870
   176
paulson@13870
   177
paulson@13870
   178
(* exponent_mult_add, easy inclusion.  Could weaken p \<in> prime to Suc 0 < p *)
paulson@13870
   179
lemma exponent_mult_add1:
paulson@13870
   180
     "[| 0 < a; 0 < b |]   
paulson@13870
   181
      ==> (exponent p a) + (exponent p b) <= exponent p (a * b)"
paulson@13870
   182
apply (case_tac "p \<in> prime")
paulson@13870
   183
apply (rule exponent_ge)
paulson@13870
   184
apply (auto simp add: power_add)
paulson@13870
   185
apply (blast intro: prime_imp_one_less power_exponent_dvd mult_dvd_mono)
paulson@13870
   186
done
paulson@13870
   187
paulson@13870
   188
(* exponent_mult_add, opposite inclusion *)
paulson@13870
   189
lemma exponent_mult_add2: "[| 0 < a; 0 < b |]  
paulson@13870
   190
      ==> exponent p (a * b) <= (exponent p a) + (exponent p b)"
paulson@13870
   191
apply (case_tac "p \<in> prime")
paulson@13870
   192
apply (rule leI, clarify)
paulson@13870
   193
apply (cut_tac p = p and s = "a*b" in power_exponent_dvd, auto)
paulson@13870
   194
apply (subgoal_tac "p ^ (Suc (exponent p a + exponent p b)) dvd a * b")
paulson@13870
   195
apply (rule_tac [2] le_imp_power_dvd [THEN dvd_trans])
paulson@13870
   196
  prefer 3 apply assumption
paulson@13870
   197
 prefer 2 apply simp 
paulson@13870
   198
apply (frule_tac a = "Suc (exponent p a) " and b = "Suc (exponent p b) " in prime_power_dvd_cases)
paulson@13870
   199
 apply (assumption, force, simp)
paulson@13870
   200
apply (blast dest: power_Suc_exponent_Not_dvd)
paulson@13870
   201
done
paulson@13870
   202
paulson@13870
   203
lemma exponent_mult_add:
paulson@13870
   204
     "[| 0 < a; 0 < b |]  
paulson@13870
   205
      ==> exponent p (a * b) = (exponent p a) + (exponent p b)"
paulson@13870
   206
by (blast intro: exponent_mult_add1 exponent_mult_add2 order_antisym)
paulson@13870
   207
paulson@13870
   208
paulson@13870
   209
lemma not_divides_exponent_0: "~ (p dvd n) ==> exponent p n = 0"
paulson@13870
   210
apply (case_tac "exponent p n", simp)
paulson@13870
   211
apply (case_tac "n", simp)
paulson@13870
   212
apply (cut_tac s = n and p = p in power_exponent_dvd)
paulson@13870
   213
apply (auto dest: dvd_mult_left)
paulson@13870
   214
done
paulson@13870
   215
paulson@13870
   216
lemma exponent_1_eq_0 [simp]: "exponent p (Suc 0) = 0"
paulson@13870
   217
apply (case_tac "p \<in> prime")
paulson@13870
   218
apply (auto simp add: prime_iff not_divides_exponent_0)
paulson@13870
   219
done
paulson@13870
   220
paulson@13870
   221
paulson@13870
   222
subsection{*Lemmas for the Main Combinatorial Argument*}
paulson@13870
   223
paulson@13870
   224
lemma p_fac_forw_lemma:
paulson@13870
   225
     "[| 0 < (m::nat); 0<k; k < p^a; (p^r) dvd (p^a)* m - k |] ==> r <= a"
paulson@13870
   226
apply (rule notnotD)
paulson@13870
   227
apply (rule notI)
paulson@13870
   228
apply (drule contrapos_nn [OF _ leI, THEN notnotD], assumption)
paulson@13870
   229
apply (drule_tac m = a in less_imp_le)
paulson@13870
   230
apply (drule le_imp_power_dvd)
paulson@13870
   231
apply (drule_tac n = "p ^ r" in dvd_trans, assumption)
paulson@13870
   232
apply (frule_tac m = k in less_imp_le)
paulson@13870
   233
apply (drule_tac c = m in le_extend_mult, assumption)
paulson@13870
   234
apply (drule_tac k = "p ^ a" and m = " (p ^ a) * m" in dvd_diffD1)
paulson@13870
   235
prefer 2 apply assumption
paulson@13870
   236
apply (rule dvd_refl [THEN dvd_mult2])
paulson@13870
   237
apply (drule_tac n = k in dvd_imp_le, auto)
paulson@13870
   238
done
paulson@13870
   239
paulson@13870
   240
lemma p_fac_forw: "[| 0 < (m::nat); 0<k; k < p^a; (p^r) dvd (p^a)* m - k |]  
paulson@13870
   241
      ==> (p^r) dvd (p^a) - k"
paulson@13870
   242
apply (frule_tac k1 = k and i = p in p_fac_forw_lemma [THEN le_imp_power_dvd], auto)
paulson@13870
   243
apply (subgoal_tac "p^r dvd p^a*m")
paulson@13870
   244
 prefer 2 apply (blast intro: dvd_mult2)
paulson@13870
   245
apply (drule dvd_diffD1)
paulson@13870
   246
  apply assumption
paulson@13870
   247
 prefer 2 apply (blast intro: dvd_diff)
paulson@13870
   248
apply (drule less_imp_Suc_add, auto)
paulson@13870
   249
done
paulson@13870
   250
paulson@13870
   251
paulson@13870
   252
lemma r_le_a_forw: "[| 0 < (k::nat); k < p^a; 0 < p; (p^r) dvd (p^a) - k |] ==> r <= a"
paulson@13870
   253
by (rule_tac m = "Suc 0" in p_fac_forw_lemma, auto)
paulson@13870
   254
paulson@13870
   255
lemma p_fac_backw: "[| 0<m; 0<k; 0 < (p::nat);  k < p^a;  (p^r) dvd p^a - k |]  
paulson@13870
   256
      ==> (p^r) dvd (p^a)*m - k"
paulson@13870
   257
apply (frule_tac k1 = k and i = p in r_le_a_forw [THEN le_imp_power_dvd], auto)
paulson@13870
   258
apply (subgoal_tac "p^r dvd p^a*m")
paulson@13870
   259
 prefer 2 apply (blast intro: dvd_mult2)
paulson@13870
   260
apply (drule dvd_diffD1)
paulson@13870
   261
  apply assumption
paulson@13870
   262
 prefer 2 apply (blast intro: dvd_diff)
paulson@13870
   263
apply (drule less_imp_Suc_add, auto)
paulson@13870
   264
done
paulson@13870
   265
paulson@13870
   266
lemma exponent_p_a_m_k_equation: "[| 0<m; 0<k; 0 < (p::nat);  k < p^a |]  
paulson@13870
   267
      ==> exponent p (p^a * m - k) = exponent p (p^a - k)"
paulson@13870
   268
apply (blast intro: exponent_equalityI p_fac_forw p_fac_backw)
paulson@13870
   269
done
paulson@13870
   270
paulson@13870
   271
text{*Suc rules that we have to delete from the simpset*}
paulson@13870
   272
lemmas bad_Sucs = binomial_Suc_Suc mult_Suc mult_Suc_right
paulson@13870
   273
paulson@13870
   274
(*The bound K is needed; otherwise it's too weak to be used.*)
paulson@13870
   275
lemma p_not_div_choose_lemma [rule_format]:
paulson@13870
   276
     "[| \<forall>i. Suc i < K --> exponent p (Suc i) = exponent p (Suc(j+i))|]  
paulson@13870
   277
      ==> k<K --> exponent p ((j+k) choose k) = 0"
paulson@13870
   278
apply (case_tac "p \<in> prime")
paulson@13870
   279
 prefer 2 apply simp 
paulson@13870
   280
apply (induct_tac "k")
paulson@13870
   281
apply (simp (no_asm))
paulson@13870
   282
(*induction step*)
paulson@13870
   283
apply (subgoal_tac "0 < (Suc (j+n) choose Suc n) ")
paulson@13870
   284
 prefer 2 apply (simp add: zero_less_binomial_iff, clarify)
paulson@13870
   285
apply (subgoal_tac "exponent p ((Suc (j+n) choose Suc n) * Suc n) = 
paulson@13870
   286
                    exponent p (Suc n)")
paulson@13870
   287
 txt{*First, use the assumed equation.  We simplify the LHS to
paulson@13870
   288
  @{term "exponent p (Suc (j + n) choose Suc n) + exponent p (Suc n)"}
paulson@13870
   289
  the common terms cancel, proving the conclusion.*}
paulson@13870
   290
 apply (simp del: bad_Sucs add: exponent_mult_add)
paulson@13870
   291
txt{*Establishing the equation requires first applying 
paulson@13870
   292
   @{text Suc_times_binomial_eq} ...*}
paulson@13870
   293
apply (simp del: bad_Sucs add: Suc_times_binomial_eq [symmetric])
paulson@13870
   294
txt{*...then @{text exponent_mult_add} and the quantified premise.*}
paulson@13870
   295
apply (simp del: bad_Sucs add: zero_less_binomial_iff exponent_mult_add)
paulson@13870
   296
done
paulson@13870
   297
paulson@13870
   298
(*The lemma above, with two changes of variables*)
paulson@13870
   299
lemma p_not_div_choose:
paulson@13870
   300
     "[| k<K;  k<=n;   
paulson@13870
   301
       \<forall>j. 0<j & j<K --> exponent p (n - k + (K - j)) = exponent p (K - j)|]  
paulson@13870
   302
      ==> exponent p (n choose k) = 0"
paulson@13870
   303
apply (cut_tac j = "n-k" and k = k and p = p in p_not_div_choose_lemma)
paulson@13870
   304
  prefer 3 apply simp
paulson@13870
   305
 prefer 2 apply assumption
paulson@13870
   306
apply (drule_tac x = "K - Suc i" in spec)
paulson@13870
   307
apply (simp add: Suc_diff_le)
paulson@13870
   308
done
paulson@13870
   309
paulson@13870
   310
paulson@13870
   311
lemma const_p_fac_right:
paulson@13870
   312
     "0 < m ==> exponent p ((p^a * m - Suc 0) choose (p^a - Suc 0)) = 0"
paulson@13870
   313
apply (case_tac "p \<in> prime")
paulson@13870
   314
 prefer 2 apply simp 
paulson@13870
   315
apply (frule_tac a = a in zero_less_prime_power)
paulson@13870
   316
apply (rule_tac K = "p^a" in p_not_div_choose)
paulson@13870
   317
   apply simp
paulson@13870
   318
  apply simp
paulson@13870
   319
 apply (case_tac "m")
paulson@13870
   320
  apply (case_tac [2] "p^a")
paulson@13870
   321
   apply auto
paulson@13870
   322
(*now the hard case, simplified to
paulson@13870
   323
    exponent p (Suc (p ^ a * m + i - p ^ a)) = exponent p (Suc i) *)
paulson@13870
   324
apply (subgoal_tac "0<p")
paulson@13870
   325
 prefer 2 apply (force dest!: prime_imp_one_less)
paulson@13870
   326
apply (subst exponent_p_a_m_k_equation, auto)
paulson@13870
   327
done
paulson@13870
   328
paulson@13870
   329
lemma const_p_fac:
paulson@13870
   330
     "0 < m ==> exponent p (((p^a) * m) choose p^a) = exponent p m"
paulson@13870
   331
apply (case_tac "p \<in> prime")
paulson@13870
   332
 prefer 2 apply simp 
paulson@13870
   333
apply (subgoal_tac "0 < p^a * m & p^a <= p^a * m")
paulson@13870
   334
 prefer 2 apply (force simp add: prime_iff)
paulson@13870
   335
txt{*A similar trick to the one used in @{text p_not_div_choose_lemma}:
paulson@13870
   336
  insert an equation; use @{text exponent_mult_add} on the LHS; on the RHS,
paulson@13870
   337
  first
paulson@13870
   338
  transform the binomial coefficient, then use @{text exponent_mult_add}.*}
paulson@13870
   339
apply (subgoal_tac "exponent p ((( (p^a) * m) choose p^a) * p^a) = 
paulson@13870
   340
                    a + exponent p m")
paulson@13870
   341
 apply (simp del: bad_Sucs add: zero_less_binomial_iff exponent_mult_add prime_iff)
paulson@13870
   342
txt{*one subgoal left!*}
paulson@13870
   343
apply (subst times_binomial_minus1_eq, simp, simp)
paulson@13870
   344
apply (subst exponent_mult_add, simp)
paulson@13870
   345
apply (simp (no_asm_simp) add: zero_less_binomial_iff)
paulson@13870
   346
apply arith
paulson@13870
   347
apply (simp del: bad_Sucs add: exponent_mult_add const_p_fac_right)
paulson@13870
   348
done
paulson@13870
   349
paulson@13870
   350
paulson@13870
   351
end