src/HOL/NumberTheory/WilsonRuss.thy
author paulson
Mon Oct 22 11:54:22 2001 +0200 (2001-10-22)
changeset 11868 56db9f3a6b3e
parent 11704 3c50a2cd6f00
child 13187 e5434b822a96
permissions -rw-r--r--
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
to their abstract counterparts, while other binary numerals work correctly.
wenzelm@11049
     1
(*  Title:      HOL/NumberTheory/WilsonRuss.thy
paulson@9508
     2
    ID:         $Id$
wenzelm@11049
     3
    Author:     Thomas M. Rasmussen
wenzelm@11049
     4
    Copyright   2000  University of Cambridge
paulson@9508
     5
*)
paulson@9508
     6
wenzelm@11049
     7
header {* Wilson's Theorem according to Russinoff *}
wenzelm@11049
     8
wenzelm@11049
     9
theory WilsonRuss = EulerFermat:
wenzelm@11049
    10
wenzelm@11049
    11
text {*
wenzelm@11049
    12
  Wilson's Theorem following quite closely Russinoff's approach
wenzelm@11049
    13
  using Boyer-Moore (using finite sets instead of lists, though).
wenzelm@11049
    14
*}
wenzelm@11049
    15
wenzelm@11049
    16
subsection {* Definitions and lemmas *}
paulson@9508
    17
paulson@9508
    18
consts
wenzelm@11049
    19
  inv :: "int => int => int"
wenzelm@11049
    20
  wset :: "int * int => int set"
paulson@9508
    21
paulson@9508
    22
defs
wenzelm@11704
    23
  inv_def: "inv p a == (a^(nat (p - 2))) mod p"
wenzelm@11049
    24
wenzelm@11049
    25
recdef wset
wenzelm@11049
    26
  "measure ((\<lambda>(a, p). nat a) :: int * int => nat)"
wenzelm@11049
    27
  "wset (a, p) =
paulson@11868
    28
    (if 1 < a then
paulson@11868
    29
      let ws = wset (a - 1, p)
wenzelm@11049
    30
      in (if a \<in> ws then ws else insert a (insert (inv p a) ws)) else {})"
wenzelm@11049
    31
wenzelm@11049
    32
wenzelm@11049
    33
text {* \medskip @{term [source] inv} *}
wenzelm@11049
    34
paulson@11868
    35
lemma aux: "1 < m ==> Suc (nat (m - 2)) = nat (m - 1)"
wenzelm@11049
    36
  apply (subst int_int_eq [symmetric])
wenzelm@11049
    37
  apply auto
wenzelm@11049
    38
  done
wenzelm@11049
    39
wenzelm@11049
    40
lemma inv_is_inv:
paulson@11868
    41
    "p \<in> zprime \<Longrightarrow> 0 < a \<Longrightarrow> a < p ==> [a * inv p a = 1] (mod p)"
wenzelm@11049
    42
  apply (unfold inv_def)
wenzelm@11049
    43
  apply (subst zcong_zmod)
wenzelm@11049
    44
  apply (subst zmod_zmult1_eq [symmetric])
wenzelm@11049
    45
  apply (subst zcong_zmod [symmetric])
wenzelm@11049
    46
  apply (subst power_Suc [symmetric])
wenzelm@11049
    47
  apply (subst aux)
wenzelm@11049
    48
   apply (erule_tac [2] Little_Fermat)
wenzelm@11049
    49
   apply (erule_tac [2] zdvd_not_zless)
wenzelm@11049
    50
   apply (unfold zprime_def)
wenzelm@11049
    51
   apply auto
wenzelm@11049
    52
  done
wenzelm@11049
    53
wenzelm@11049
    54
lemma inv_distinct:
paulson@11868
    55
    "p \<in> zprime \<Longrightarrow> 1 < a \<Longrightarrow> a < p - 1 ==> a \<noteq> inv p a"
wenzelm@11049
    56
  apply safe
wenzelm@11049
    57
  apply (cut_tac a = a and p = p in zcong_square)
wenzelm@11049
    58
     apply (cut_tac [3] a = a and p = p in inv_is_inv)
wenzelm@11049
    59
        apply auto
paulson@11868
    60
   apply (subgoal_tac "a = 1")
wenzelm@11049
    61
    apply (rule_tac [2] m = p in zcong_zless_imp_eq)
paulson@11868
    62
        apply (subgoal_tac [7] "a = p - 1")
wenzelm@11049
    63
         apply (rule_tac [8] m = p in zcong_zless_imp_eq)
wenzelm@11049
    64
             apply auto
wenzelm@11049
    65
  done
wenzelm@11049
    66
wenzelm@11049
    67
lemma inv_not_0:
paulson@11868
    68
    "p \<in> zprime \<Longrightarrow> 1 < a \<Longrightarrow> a < p - 1 ==> inv p a \<noteq> 0"
wenzelm@11049
    69
  apply safe
wenzelm@11049
    70
  apply (cut_tac a = a and p = p in inv_is_inv)
wenzelm@11049
    71
     apply (unfold zcong_def)
wenzelm@11049
    72
     apply auto
paulson@11868
    73
  apply (subgoal_tac "\<not> p dvd 1")
wenzelm@11049
    74
   apply (rule_tac [2] zdvd_not_zless)
paulson@11868
    75
    apply (subgoal_tac "p dvd 1")
wenzelm@11049
    76
     prefer 2
wenzelm@11049
    77
     apply (subst zdvd_zminus_iff [symmetric])
wenzelm@11049
    78
     apply auto
wenzelm@11049
    79
  done
wenzelm@11049
    80
wenzelm@11049
    81
lemma inv_not_1:
paulson@11868
    82
    "p \<in> zprime \<Longrightarrow> 1 < a \<Longrightarrow> a < p - 1 ==> inv p a \<noteq> 1"
wenzelm@11049
    83
  apply safe
wenzelm@11049
    84
  apply (cut_tac a = a and p = p in inv_is_inv)
wenzelm@11049
    85
     prefer 4
wenzelm@11049
    86
     apply simp
paulson@11868
    87
     apply (subgoal_tac "a = 1")
wenzelm@11049
    88
      apply (rule_tac [2] zcong_zless_imp_eq)
wenzelm@11049
    89
          apply auto
wenzelm@11049
    90
  done
wenzelm@11049
    91
paulson@11868
    92
lemma aux: "[a * (p - 1) = 1] (mod p) = [a = p - 1] (mod p)"
wenzelm@11049
    93
  apply (unfold zcong_def)
wenzelm@11049
    94
  apply (simp add: zdiff_zdiff_eq zdiff_zdiff_eq2 zdiff_zmult_distrib2)
paulson@11868
    95
  apply (rule_tac s = "p dvd -((a + 1) + (p * -a))" in trans)
wenzelm@11049
    96
   apply (simp add: zmult_commute zminus_zdiff_eq)
wenzelm@11049
    97
  apply (subst zdvd_zminus_iff)
wenzelm@11049
    98
  apply (subst zdvd_reduce)
paulson@11868
    99
  apply (rule_tac s = "p dvd (a + 1) + (p * -1)" in trans)
wenzelm@11049
   100
   apply (subst zdvd_reduce)
wenzelm@11049
   101
   apply auto
wenzelm@11049
   102
  done
wenzelm@11049
   103
wenzelm@11049
   104
lemma inv_not_p_minus_1:
paulson@11868
   105
    "p \<in> zprime \<Longrightarrow> 1 < a \<Longrightarrow> a < p - 1 ==> inv p a \<noteq> p - 1"
wenzelm@11049
   106
  apply safe
wenzelm@11049
   107
  apply (cut_tac a = a and p = p in inv_is_inv)
wenzelm@11049
   108
     apply auto
wenzelm@11049
   109
  apply (simp add: aux)
paulson@11868
   110
  apply (subgoal_tac "a = p - 1")
wenzelm@11049
   111
   apply (rule_tac [2] zcong_zless_imp_eq)
wenzelm@11049
   112
       apply auto
wenzelm@11049
   113
  done
wenzelm@11049
   114
wenzelm@11049
   115
lemma inv_g_1:
paulson@11868
   116
    "p \<in> zprime \<Longrightarrow> 1 < a \<Longrightarrow> a < p - 1 ==> 1 < inv p a"
paulson@11868
   117
  apply (case_tac "0\<le> inv p a")
paulson@11868
   118
   apply (subgoal_tac "inv p a \<noteq> 1")
paulson@11868
   119
    apply (subgoal_tac "inv p a \<noteq> 0")
wenzelm@11049
   120
     apply (subst order_less_le)
wenzelm@11049
   121
     apply (subst zle_add1_eq_le [symmetric])
wenzelm@11049
   122
     apply (subst order_less_le)
wenzelm@11049
   123
     apply (rule_tac [2] inv_not_0)
wenzelm@11049
   124
       apply (rule_tac [5] inv_not_1)
wenzelm@11049
   125
         apply auto
wenzelm@11049
   126
  apply (unfold inv_def zprime_def)
wenzelm@11049
   127
  apply (simp add: pos_mod_sign)
wenzelm@11049
   128
  done
wenzelm@11049
   129
wenzelm@11049
   130
lemma inv_less_p_minus_1:
paulson@11868
   131
    "p \<in> zprime \<Longrightarrow> 1 < a \<Longrightarrow> a < p - 1 ==> inv p a < p - 1"
wenzelm@11049
   132
  apply (case_tac "inv p a < p")
wenzelm@11049
   133
   apply (subst order_less_le)
wenzelm@11049
   134
   apply (simp add: inv_not_p_minus_1)
wenzelm@11049
   135
  apply auto
wenzelm@11049
   136
  apply (unfold inv_def zprime_def)
wenzelm@11049
   137
  apply (simp add: pos_mod_bound)
wenzelm@11049
   138
  done
wenzelm@11049
   139
wenzelm@11704
   140
lemma aux: "5 \<le> p ==>
paulson@11868
   141
    nat (p - 2) * nat (p - 2) = Suc (nat (p - 1) * nat (p - 3))"
wenzelm@11049
   142
  apply (subst int_int_eq [symmetric])
wenzelm@11049
   143
  apply (simp add: zmult_int [symmetric])
wenzelm@11049
   144
  apply (simp add: zdiff_zmult_distrib zdiff_zmult_distrib2)
wenzelm@11049
   145
  done
wenzelm@11049
   146
wenzelm@11049
   147
lemma zcong_zpower_zmult:
paulson@11868
   148
    "[x^y = 1] (mod p) \<Longrightarrow> [x^(y * z) = 1] (mod p)"
wenzelm@11049
   149
  apply (induct z)
wenzelm@11049
   150
   apply (auto simp add: zpower_zadd_distrib)
paulson@11868
   151
  apply (subgoal_tac "zcong (x^y * x^(y * n)) (1 * 1) p")
wenzelm@11049
   152
   apply (rule_tac [2] zcong_zmult)
wenzelm@11049
   153
    apply simp_all
wenzelm@11049
   154
  done
wenzelm@11049
   155
wenzelm@11049
   156
lemma inv_inv: "p \<in> zprime \<Longrightarrow>
paulson@11868
   157
    5 \<le> p \<Longrightarrow> 0 < a \<Longrightarrow> a < p ==> inv p (inv p a) = a"
wenzelm@11049
   158
  apply (unfold inv_def)
wenzelm@11049
   159
  apply (subst zpower_zmod)
wenzelm@11049
   160
  apply (subst zpower_zpower)
wenzelm@11049
   161
  apply (rule zcong_zless_imp_eq)
wenzelm@11049
   162
      prefer 5
wenzelm@11049
   163
      apply (subst zcong_zmod)
wenzelm@11049
   164
      apply (subst mod_mod_trivial)
wenzelm@11049
   165
      apply (subst zcong_zmod [symmetric])
wenzelm@11049
   166
      apply (subst aux)
wenzelm@11049
   167
       apply (subgoal_tac [2]
paulson@11868
   168
	 "zcong (a * a^(nat (p - 1) * nat (p - 3))) (a * 1) p")
wenzelm@11049
   169
        apply (rule_tac [3] zcong_zmult)
wenzelm@11049
   170
         apply (rule_tac [4] zcong_zpower_zmult)
wenzelm@11049
   171
         apply (erule_tac [4] Little_Fermat)
wenzelm@11049
   172
         apply (rule_tac [4] zdvd_not_zless)
wenzelm@11049
   173
          apply (simp_all add: pos_mod_bound pos_mod_sign)
wenzelm@11049
   174
  done
wenzelm@11049
   175
wenzelm@11049
   176
wenzelm@11049
   177
text {* \medskip @{term wset} *}
wenzelm@11049
   178
wenzelm@11049
   179
declare wset.simps [simp del]
paulson@9508
   180
wenzelm@11049
   181
lemma wset_induct:
wenzelm@11049
   182
  "(!!a p. P {} a p) \<Longrightarrow>
paulson@11868
   183
    (!!a p. 1 < (a::int) \<Longrightarrow> P (wset (a - 1, p)) (a - 1) p
wenzelm@11049
   184
      ==> P (wset (a, p)) a p)
wenzelm@11049
   185
    ==> P (wset (u, v)) u v"
wenzelm@11049
   186
proof -
wenzelm@11549
   187
  case rule_context
wenzelm@11049
   188
  show ?thesis
wenzelm@11049
   189
    apply (rule wset.induct)
wenzelm@11049
   190
    apply safe
paulson@11868
   191
     apply (case_tac [2] "1 < a")
wenzelm@11549
   192
      apply (rule_tac [2] rule_context)
wenzelm@11049
   193
        apply simp_all
wenzelm@11549
   194
      apply (simp_all add: wset.simps rule_context)
wenzelm@11049
   195
    done
wenzelm@11049
   196
qed
wenzelm@11049
   197
wenzelm@11049
   198
lemma wset_mem_imp_or [rule_format]:
paulson@11868
   199
  "1 < a \<Longrightarrow> b \<notin> wset (a - 1, p)
wenzelm@11049
   200
    ==> b \<in> wset (a, p) --> b = a \<or> b = inv p a"
wenzelm@11049
   201
  apply (subst wset.simps)
wenzelm@11049
   202
  apply (unfold Let_def)
wenzelm@11049
   203
  apply simp
wenzelm@11049
   204
  done
wenzelm@11049
   205
paulson@11868
   206
lemma wset_mem_mem [simp]: "1 < a ==> a \<in> wset (a, p)"
wenzelm@11049
   207
  apply (subst wset.simps)
wenzelm@11049
   208
  apply (unfold Let_def)
wenzelm@11049
   209
  apply simp
wenzelm@11049
   210
  done
wenzelm@11049
   211
paulson@11868
   212
lemma wset_subset: "1 < a \<Longrightarrow> b \<in> wset (a - 1, p) ==> b \<in> wset (a, p)"
wenzelm@11049
   213
  apply (subst wset.simps)
wenzelm@11049
   214
  apply (unfold Let_def)
wenzelm@11049
   215
  apply auto
wenzelm@11049
   216
  done
wenzelm@11049
   217
wenzelm@11049
   218
lemma wset_g_1 [rule_format]:
paulson@11868
   219
    "p \<in> zprime --> a < p - 1 --> b \<in> wset (a, p) --> 1 < b"
wenzelm@11049
   220
  apply (induct a p rule: wset_induct)
wenzelm@11049
   221
   apply auto
wenzelm@11049
   222
  apply (case_tac "b = a")
wenzelm@11049
   223
   apply (case_tac [2] "b = inv p a")
wenzelm@11049
   224
    apply (subgoal_tac [3] "b = a \<or> b = inv p a")
wenzelm@11049
   225
     apply (rule_tac [4] wset_mem_imp_or)
wenzelm@11049
   226
       prefer 2
wenzelm@11049
   227
       apply simp
wenzelm@11049
   228
       apply (rule inv_g_1)
wenzelm@11049
   229
         apply auto
wenzelm@11049
   230
  done
wenzelm@11049
   231
wenzelm@11049
   232
lemma wset_less [rule_format]:
paulson@11868
   233
    "p \<in> zprime --> a < p - 1 --> b \<in> wset (a, p) --> b < p - 1"
wenzelm@11049
   234
  apply (induct a p rule: wset_induct)
wenzelm@11049
   235
   apply auto
wenzelm@11049
   236
  apply (case_tac "b = a")
wenzelm@11049
   237
   apply (case_tac [2] "b = inv p a")
wenzelm@11049
   238
    apply (subgoal_tac [3] "b = a \<or> b = inv p a")
wenzelm@11049
   239
     apply (rule_tac [4] wset_mem_imp_or)
wenzelm@11049
   240
       prefer 2
wenzelm@11049
   241
       apply simp
wenzelm@11049
   242
       apply (rule inv_less_p_minus_1)
wenzelm@11049
   243
         apply auto
wenzelm@11049
   244
  done
wenzelm@11049
   245
wenzelm@11049
   246
lemma wset_mem [rule_format]:
wenzelm@11049
   247
  "p \<in> zprime -->
paulson@11868
   248
    a < p - 1 --> 1 < b --> b \<le> a --> b \<in> wset (a, p)"
wenzelm@11049
   249
  apply (induct a p rule: wset.induct)
wenzelm@11049
   250
  apply auto
wenzelm@11049
   251
   apply (subgoal_tac "b = a")
wenzelm@11049
   252
    apply (rule_tac [2] zle_anti_sym)
wenzelm@11049
   253
     apply (rule_tac [4] wset_subset)
wenzelm@11049
   254
      apply (simp (no_asm_simp))
wenzelm@11049
   255
     apply auto
wenzelm@11049
   256
  done
wenzelm@11049
   257
wenzelm@11049
   258
lemma wset_mem_inv_mem [rule_format]:
paulson@11868
   259
  "p \<in> zprime --> 5 \<le> p --> a < p - 1 --> b \<in> wset (a, p)
wenzelm@11049
   260
    --> inv p b \<in> wset (a, p)"
wenzelm@11049
   261
  apply (induct a p rule: wset_induct)
wenzelm@11049
   262
   apply auto
wenzelm@11049
   263
   apply (case_tac "b = a")
wenzelm@11049
   264
    apply (subst wset.simps)
wenzelm@11049
   265
    apply (unfold Let_def)
wenzelm@11049
   266
    apply (rule_tac [3] wset_subset)
wenzelm@11049
   267
     apply auto
wenzelm@11049
   268
  apply (case_tac "b = inv p a")
wenzelm@11049
   269
   apply (simp (no_asm_simp))
wenzelm@11049
   270
   apply (subst inv_inv)
wenzelm@11049
   271
       apply (subgoal_tac [6] "b = a \<or> b = inv p a")
wenzelm@11049
   272
        apply (rule_tac [7] wset_mem_imp_or)
wenzelm@11049
   273
          apply auto
wenzelm@11049
   274
  done
wenzelm@11049
   275
wenzelm@11049
   276
lemma wset_inv_mem_mem:
paulson@11868
   277
  "p \<in> zprime \<Longrightarrow> 5 \<le> p \<Longrightarrow> a < p - 1 \<Longrightarrow> 1 < b \<Longrightarrow> b < p - 1
wenzelm@11049
   278
    \<Longrightarrow> inv p b \<in> wset (a, p) \<Longrightarrow> b \<in> wset (a, p)"
wenzelm@11049
   279
  apply (rule_tac s = "inv p (inv p b)" and t = b in subst)
wenzelm@11049
   280
   apply (rule_tac [2] wset_mem_inv_mem)
wenzelm@11049
   281
      apply (rule inv_inv)
wenzelm@11049
   282
         apply simp_all
wenzelm@11049
   283
  done
wenzelm@11049
   284
wenzelm@11049
   285
lemma wset_fin: "finite (wset (a, p))"
wenzelm@11049
   286
  apply (induct a p rule: wset_induct)
wenzelm@11049
   287
   prefer 2
wenzelm@11049
   288
   apply (subst wset.simps)
wenzelm@11049
   289
   apply (unfold Let_def)
wenzelm@11049
   290
   apply auto
wenzelm@11049
   291
  done
wenzelm@11049
   292
wenzelm@11049
   293
lemma wset_zcong_prod_1 [rule_format]:
wenzelm@11049
   294
  "p \<in> zprime -->
paulson@11868
   295
    5 \<le> p --> a < p - 1 --> [setprod (wset (a, p)) = 1] (mod p)"
wenzelm@11049
   296
  apply (induct a p rule: wset_induct)
wenzelm@11049
   297
   prefer 2
wenzelm@11049
   298
   apply (subst wset.simps)
wenzelm@11049
   299
   apply (unfold Let_def)
wenzelm@11049
   300
   apply auto
wenzelm@11049
   301
  apply (subst setprod_insert)
wenzelm@11049
   302
    apply (tactic {* stac (thm "setprod_insert") 3 *})
wenzelm@11049
   303
      apply (subgoal_tac [5]
paulson@11868
   304
	"zcong (a * inv p a * setprod (wset (a - 1, p))) (1 * 1) p")
wenzelm@11049
   305
       prefer 5
wenzelm@11049
   306
       apply (simp add: zmult_assoc)
wenzelm@11049
   307
      apply (rule_tac [5] zcong_zmult)
wenzelm@11049
   308
       apply (rule_tac [5] inv_is_inv)
wenzelm@11049
   309
         apply (tactic "Clarify_tac 4")
paulson@11868
   310
         apply (subgoal_tac [4] "a \<in> wset (a - 1, p)")
wenzelm@11049
   311
          apply (rule_tac [5] wset_inv_mem_mem)
wenzelm@11049
   312
               apply (simp_all add: wset_fin)
wenzelm@11049
   313
  apply (rule inv_distinct)
wenzelm@11049
   314
    apply auto
wenzelm@11049
   315
  done
wenzelm@11049
   316
wenzelm@11704
   317
lemma d22set_eq_wset: "p \<in> zprime ==> d22set (p - 2) = wset (p - 2, p)"
wenzelm@11049
   318
  apply safe
wenzelm@11049
   319
   apply (erule wset_mem)
wenzelm@11049
   320
     apply (rule_tac [2] d22set_g_1)
wenzelm@11049
   321
     apply (rule_tac [3] d22set_le)
wenzelm@11049
   322
     apply (rule_tac [4] d22set_mem)
wenzelm@11049
   323
      apply (erule_tac [4] wset_g_1)
wenzelm@11049
   324
       prefer 6
wenzelm@11049
   325
       apply (subst zle_add1_eq_le [symmetric])
paulson@11868
   326
       apply (subgoal_tac "p - 2 + 1 = p - 1")
wenzelm@11049
   327
        apply (simp (no_asm_simp))
wenzelm@11049
   328
        apply (erule wset_less)
wenzelm@11049
   329
         apply auto
wenzelm@11049
   330
  done
wenzelm@11049
   331
wenzelm@11049
   332
wenzelm@11049
   333
subsection {* Wilson *}
wenzelm@11049
   334
wenzelm@11704
   335
lemma prime_g_5: "p \<in> zprime \<Longrightarrow> p \<noteq> 2 \<Longrightarrow> p \<noteq> 3 ==> 5 \<le> p"
wenzelm@11049
   336
  apply (unfold zprime_def dvd_def)
wenzelm@11704
   337
  apply (case_tac "p = 4")
wenzelm@11049
   338
   apply auto
wenzelm@11049
   339
   apply (rule notE)
wenzelm@11049
   340
    prefer 2
wenzelm@11049
   341
    apply assumption
wenzelm@11049
   342
   apply (simp (no_asm))
wenzelm@11704
   343
   apply (rule_tac x = "2" in exI)
wenzelm@11049
   344
   apply safe
wenzelm@11704
   345
     apply (rule_tac x = "2" in exI)
wenzelm@11049
   346
     apply auto
wenzelm@11049
   347
  apply arith
wenzelm@11049
   348
  done
wenzelm@11049
   349
wenzelm@11049
   350
theorem Wilson_Russ:
paulson@11868
   351
    "p \<in> zprime ==> [zfact (p - 1) = -1] (mod p)"
paulson@11868
   352
  apply (subgoal_tac "[(p - 1) * zfact (p - 2) = -1 * 1] (mod p)")
wenzelm@11049
   353
   apply (rule_tac [2] zcong_zmult)
wenzelm@11049
   354
    apply (simp only: zprime_def)
wenzelm@11049
   355
    apply (subst zfact.simps)
paulson@11868
   356
    apply (rule_tac t = "p - 1 - 1" and s = "p - 2" in subst)
wenzelm@11049
   357
     apply auto
wenzelm@11049
   358
   apply (simp only: zcong_def)
wenzelm@11049
   359
   apply (simp (no_asm_simp))
wenzelm@11704
   360
  apply (case_tac "p = 2")
wenzelm@11049
   361
   apply (simp add: zfact.simps)
wenzelm@11704
   362
  apply (case_tac "p = 3")
wenzelm@11049
   363
   apply (simp add: zfact.simps)
wenzelm@11704
   364
  apply (subgoal_tac "5 \<le> p")
wenzelm@11049
   365
   apply (erule_tac [2] prime_g_5)
wenzelm@11049
   366
    apply (subst d22set_prod_zfact [symmetric])
wenzelm@11049
   367
    apply (subst d22set_eq_wset)
wenzelm@11049
   368
     apply (rule_tac [2] wset_zcong_prod_1)
wenzelm@11049
   369
       apply auto
wenzelm@11049
   370
  done
paulson@9508
   371
paulson@9508
   372
end