diff -r 69eb69659bf3 -r c2b8be5ddc4a src/HOL/Library/Pocklington.thy --- a/src/HOL/Library/Pocklington.thy Wed Nov 19 17:54:55 2008 +0100 +++ b/src/HOL/Library/Pocklington.thy Wed Nov 19 17:55:18 2008 +0100 @@ -554,11 +554,11 @@ (* Fermat's Little theorem / Fermat-Euler theorem. *) -lemma (in comm_monoid_mult) fold_related: +lemma (in comm_monoid_mult) fold_image_related: assumes Re: "R e e" and Rop: "\x1 y1 x2 y2. R x1 x2 \ R y1 y2 \ R (x1 * y1) (x2 * y2)" and fS: "finite S" and Rfg: "\x\S. R (h x) (g x)" - shows "R (fold (op *) h e S) (fold (op *) g e S)" + shows "R (fold_image (op *) h e S) (fold_image (op *) g e S)" using fS by (rule finite_subset_induct) (insert assms, auto) lemma nproduct_mod: @@ -571,7 +571,7 @@ [x1 = x2] (mod n) \ [y1 = y2] (mod n) \ [x1 * y1 = x2 * y2] (mod n)" by blast have th4:"\x\S. [a x mod n = a x] (mod n)" by (simp add: modeq_def) - from fold_related[where h="(\m. a(m) mod n)" and g=a, OF th1 th3 fS, OF th4] show ?thesis unfolding setprod_def by (simp add: fS) + from fold_image_related[where h="(\m. a(m) mod n)" and g=a, OF th1 th3 fS, OF th4] show ?thesis unfolding setprod_def by (simp add: fS) qed lemma nproduct_cmul: @@ -586,21 +586,21 @@ (insert Sn, auto simp add: coprime_mul) lemma (in comm_monoid_mult) - fold_eq_general: + fold_image_eq_general: assumes fS: "finite S" and h: "\y\S'. \!x. x\ S \ h(x) = y" and f12: "\x\S. h x \ S' \ f2(h x) = f1 x" - shows "fold (op *) f1 e S = fold (op *) f2 e S'" + shows "fold_image (op *) f1 e S = fold_image (op *) f2 e S'" proof- from h f12 have hS: "h ` S = S'" by auto {fix x y assume H: "x \ S" "y \ S" "h x = h y" from f12 h H have "x = y" by auto } hence hinj: "inj_on h S" unfolding inj_on_def Ex1_def by blast from f12 have th: "\x. x \ S \ (f2 \ h) x = f1 x" by auto - from hS have "fold (op *) f2 e S' = fold (op *) f2 e (h ` S)" by simp - also have "\ = fold (op *) (f2 o h) e S" - using fold_reindex[OF fS hinj, of f2 e] . - also have "\ = fold (op *) f1 e S " using th fold_cong[OF fS, of "f2 o h" f1 e] + from hS have "fold_image (op *) f2 e S' = fold_image (op *) f2 e (h ` S)" by simp + also have "\ = fold_image (op *) (f2 o h) e S" + using fold_image_reindex[OF fS hinj, of f2 e] . + also have "\ = fold_image (op *) f1 e S " using th fold_image_cong[OF fS, of "f2 o h" f1 e] by blast finally show ?thesis .. qed @@ -633,9 +633,9 @@ have "a\0" using an n1 nz apply- apply (rule ccontr) by simp hence inj: "inj_on (op * a) ?S" unfolding inj_on_def by simp - have eq0: "fold op * (?h \ op * a) 1 {m. coprime m n \ m < n} = - fold op * (\m. m) 1 {m. coprime m n \ m < n}" - proof (rule fold_eq_general[where h="?h o (op * a)"]) + have eq0: "fold_image op * (?h \ op * a) 1 {m. coprime m n \ m < n} = + fold_image op * (\m. m) 1 {m. coprime m n \ m < n}" + proof (rule fold_image_eq_general[where h="?h o (op * a)"]) show "finite ?S" using fS . next {fix y assume yS: "y \ ?S" hence y: "coprime y n" "y < n" by simp_all