Removal of Summation theory
authorpaulson
Wed Apr 09 12:51:49 2003 +0200 (2003-04-09)
changeset 13906eefdd6b14508
parent 13905 3e496c70f2f3
child 13907 2bc462b99e70
Removal of Summation theory
src/HOL/GroupTheory/ROOT.ML
src/HOL/GroupTheory/Summation.thy
src/HOL/IsaMakefile
     1.1 --- a/src/HOL/GroupTheory/ROOT.ML	Tue Apr 08 09:44:21 2003 +0200
     1.2 +++ b/src/HOL/GroupTheory/ROOT.ML	Wed Apr 09 12:51:49 2003 +0200
     1.3 @@ -1,4 +1,3 @@
     1.4  no_document use_thy "FuncSet";
     1.5  
     1.6  use_thy "Bij";
     1.7 -use_thy "Summation";
     1.8 \ No newline at end of file
     2.1 --- a/src/HOL/GroupTheory/Summation.thy	Tue Apr 08 09:44:21 2003 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,592 +0,0 @@
     2.4 -(*  Title:      Summation Operator for Abelian Groups
     2.5 -    ID:         $Id$
     2.6 -    Author:     Clemens Ballarin, started 19 November 2002
     2.7 -    Copyright:  TU Muenchen
     2.8 -*)
     2.9 -
    2.10 -header {* Summation Operator *}
    2.11 -
    2.12 -theory Summation = Group:
    2.13 -
    2.14 -(* Instantiation of LC from Finite_Set.thy is not possible,
    2.15 -   because here we have explicit typing rules like x : carrier G.
    2.16 -   We introduce an explicit argument for the domain D *)
    2.17 -
    2.18 -consts
    2.19 -  foldSetD :: "['a set, 'b => 'a => 'a, 'a] => ('b set * 'a) set"
    2.20 -
    2.21 -inductive "foldSetD D f e"
    2.22 -  intros
    2.23 -    emptyI [intro]: "e : D ==> ({}, e) : foldSetD D f e"
    2.24 -    insertI [intro]: "[| x ~: A; f x y : D; (A, y) : foldSetD D f e |] ==>
    2.25 -                      (insert x A, f x y) : foldSetD D f e"
    2.26 -
    2.27 -inductive_cases empty_foldSetDE [elim!]: "({}, x) : foldSetD D f e"
    2.28 -
    2.29 -constdefs
    2.30 -  foldD :: "['a set, 'b => 'a => 'a, 'a, 'b set] => 'a"
    2.31 -  "foldD D f e A == THE x. (A, x) : foldSetD D f e"
    2.32 -
    2.33 -lemma foldSetD_closed:
    2.34 -  "[| (A, z) : foldSetD D f e ; e : D; !!x y. [| x : A; y : D |] ==> f x y : D 
    2.35 -      |] ==> z : D";
    2.36 -  by (erule foldSetD.elims) auto
    2.37 -
    2.38 -lemma Diff1_foldSetD:
    2.39 -  "[| (A - {x}, y) : foldSetD D f e; x : A; f x y : D |] ==>
    2.40 -   (A, f x y) : foldSetD D f e"
    2.41 -  apply (erule insert_Diff [THEN subst], rule foldSetD.intros)
    2.42 -   apply auto
    2.43 -  done
    2.44 -
    2.45 -lemma foldSetD_imp_finite [simp]: "(A, x) : foldSetD D f e ==> finite A"
    2.46 -  by (induct set: foldSetD) auto
    2.47 -
    2.48 -lemma finite_imp_foldSetD:
    2.49 -  "[| finite A; e : D; !!x y. [| x : A; y : D |] ==> f x y : D |] ==>
    2.50 -   EX x. (A, x) : foldSetD D f e"
    2.51 -proof (induct set: Finites)
    2.52 -  case empty then show ?case by auto
    2.53 -next
    2.54 -  case (insert F x)
    2.55 -  then obtain y where y: "(F, y) : foldSetD D f e" by auto
    2.56 -  with insert have "y : D" by (auto dest: foldSetD_closed)
    2.57 -  with y and insert have "(insert x F, f x y) : foldSetD D f e"
    2.58 -    by (intro foldSetD.intros) auto
    2.59 -  then show ?case ..
    2.60 -qed
    2.61 -
    2.62 -subsection {* Left-commutative operations *}
    2.63 -
    2.64 -locale LCD =
    2.65 -  fixes B :: "'b set"
    2.66 -  and D :: "'a set"
    2.67 -  and f :: "'b => 'a => 'a"    (infixl "\<cdot>" 70)
    2.68 -  assumes left_commute: "[| x : B; y : B; z : D |] ==> x \<cdot> (y \<cdot> z) = y \<cdot> (x \<cdot> z)"
    2.69 -  and f_closed [simp, intro!]: "!!x y. [| x : B; y : D |] ==> f x y : D"
    2.70 -
    2.71 -lemma (in LCD) foldSetD_closed [dest]:
    2.72 -  "(A, z) : foldSetD D f e ==> z : D";
    2.73 -  by (erule foldSetD.elims) auto
    2.74 -
    2.75 -lemma (in LCD) Diff1_foldSetD:
    2.76 -  "[| (A - {x}, y) : foldSetD D f e; x : A; A <= B |] ==>
    2.77 -   (A, f x y) : foldSetD D f e"
    2.78 -  apply (subgoal_tac "x : B")
    2.79 -  prefer 2 apply fast
    2.80 -  apply (erule insert_Diff [THEN subst], rule foldSetD.intros)
    2.81 -   apply auto
    2.82 -  done
    2.83 -
    2.84 -lemma (in LCD) foldSetD_imp_finite [simp]:
    2.85 -  "(A, x) : foldSetD D f e ==> finite A"
    2.86 -  by (induct set: foldSetD) auto
    2.87 -
    2.88 -lemma (in LCD) finite_imp_foldSetD:
    2.89 -  "[| finite A; A <= B; e : D |] ==> EX x. (A, x) : foldSetD D f e"
    2.90 -proof (induct set: Finites)
    2.91 -  case empty then show ?case by auto
    2.92 -next
    2.93 -  case (insert F x)
    2.94 -  then obtain y where y: "(F, y) : foldSetD D f e" by auto
    2.95 -  with insert have "y : D" by auto
    2.96 -  with y and insert have "(insert x F, f x y) : foldSetD D f e"
    2.97 -    by (intro foldSetD.intros) auto
    2.98 -  then show ?case ..
    2.99 -qed
   2.100 -
   2.101 -lemma (in LCD) foldSetD_determ_aux:
   2.102 -  "e : D ==> ALL A x. A <= B & card A < n --> (A, x) : foldSetD D f e -->
   2.103 -    (ALL y. (A, y) : foldSetD D f e --> y = x)"
   2.104 -  apply (induct n)
   2.105 -   apply (auto simp add: less_Suc_eq)
   2.106 -  apply (erule foldSetD.cases)
   2.107 -   apply blast
   2.108 -  apply (erule foldSetD.cases)
   2.109 -   apply blast
   2.110 -  apply clarify
   2.111 -  txt {* force simplification of @{text "card A < card (insert ...)"}. *}
   2.112 -  apply (erule rev_mp)
   2.113 -  apply (simp add: less_Suc_eq_le)
   2.114 -  apply (rule impI)
   2.115 -  apply (rename_tac Aa xa ya Ab xb yb, case_tac "xa = xb")
   2.116 -   apply (subgoal_tac "Aa = Ab")
   2.117 -    prefer 2 apply (blast elim!: equalityE)
   2.118 -   apply blast
   2.119 -  txt {* case @{prop "xa \<notin> xb"}. *}
   2.120 -  apply (subgoal_tac "Aa - {xb} = Ab - {xa} & xb : Aa & xa : Ab")
   2.121 -   prefer 2 apply (blast elim!: equalityE)
   2.122 -  apply clarify
   2.123 -  apply (subgoal_tac "Aa = insert xb Ab - {xa}")
   2.124 -   prefer 2 apply blast
   2.125 -  apply (subgoal_tac "card Aa <= card Ab")
   2.126 -   prefer 2
   2.127 -   apply (rule Suc_le_mono [THEN subst])
   2.128 -   apply (simp add: card_Suc_Diff1)
   2.129 -  apply (rule_tac A1 = "Aa - {xb}" in finite_imp_foldSetD [THEN exE])
   2.130 -  apply (blast intro: foldSetD_imp_finite finite_Diff)
   2.131 -(* new subgoal from finite_imp_foldSetD *)
   2.132 -    apply best (* blast doesn't seem to solve this *)
   2.133 -   apply assumption
   2.134 -  apply (frule (1) Diff1_foldSetD)
   2.135 -(* new subgoal from Diff1_foldSetD *)
   2.136 -    apply best
   2.137 -(*
   2.138 -apply (best del: foldSetD_closed elim: foldSetD_closed)
   2.139 -    apply (rule f_closed) apply assumption apply (rule foldSetD_closed)
   2.140 -    prefer 3 apply assumption apply (rule e_closed)
   2.141 -    apply (rule f_closed) apply force apply assumption
   2.142 -*)
   2.143 -  apply (subgoal_tac "ya = f xb x")
   2.144 -   prefer 2
   2.145 -(* new subgoal to make IH applicable *) 
   2.146 -  apply (subgoal_tac "Aa <= B")
   2.147 -   prefer 2 apply best
   2.148 -   apply (blast del: equalityCE)
   2.149 -  apply (subgoal_tac "(Ab - {xa}, x) : foldSetD D f e")
   2.150 -   prefer 2 apply simp
   2.151 -  apply (subgoal_tac "yb = f xa x")
   2.152 -   prefer 2 
   2.153 -(*   apply (drule_tac x = xa in Diff1_foldSetD)
   2.154 -     apply assumption
   2.155 -     apply (rule f_closed) apply best apply (rule foldSetD_closed)
   2.156 -     prefer 3 apply assumption apply (rule e_closed)
   2.157 -     apply (rule f_closed) apply best apply assumption
   2.158 -*)
   2.159 -   apply (blast del: equalityCE dest: Diff1_foldSetD)
   2.160 -   apply (simp (no_asm_simp))
   2.161 -   apply (rule left_commute)
   2.162 -   apply assumption apply best apply best
   2.163 - done
   2.164 -
   2.165 -lemma (in LCD) foldSetD_determ:
   2.166 -  "[| (A, x) : foldSetD D f e; (A, y) : foldSetD D f e; e : D; A <= B |]
   2.167 -   ==> y = x"
   2.168 -  by (blast intro: foldSetD_determ_aux [rule_format])
   2.169 -
   2.170 -lemma (in LCD) foldD_equality:
   2.171 -  "[| (A, y) : foldSetD D f e; e : D; A <= B |] ==> foldD D f e A = y"
   2.172 -  by (unfold foldD_def) (blast intro: foldSetD_determ)
   2.173 -
   2.174 -lemma foldD_empty [simp]:
   2.175 -  "e : D ==> foldD D f e {} = e"
   2.176 -  by (unfold foldD_def) blast
   2.177 -
   2.178 -lemma (in LCD) foldD_insert_aux:
   2.179 -  "[| x ~: A; x : B; e : D; A <= B |] ==>
   2.180 -    ((insert x A, v) : foldSetD D f e) =
   2.181 -    (EX y. (A, y) : foldSetD D f e & v = f x y)"
   2.182 -  apply auto
   2.183 -  apply (rule_tac A1 = A in finite_imp_foldSetD [THEN exE])
   2.184 -   apply (fastsimp dest: foldSetD_imp_finite)
   2.185 -(* new subgoal by finite_imp_foldSetD *)
   2.186 -    apply assumption
   2.187 -    apply assumption
   2.188 -  apply (blast intro: foldSetD_determ)
   2.189 -  done
   2.190 -
   2.191 -lemma (in LCD) foldD_insert:
   2.192 -    "[| finite A; x ~: A; x : B; e : D; A <= B |] ==>
   2.193 -     foldD D f e (insert x A) = f x (foldD D f e A)"
   2.194 -  apply (unfold foldD_def)
   2.195 -  apply (simp add: foldD_insert_aux)
   2.196 -  apply (rule the_equality)
   2.197 -  apply (auto intro: finite_imp_foldSetD
   2.198 -    cong add: conj_cong simp add: foldD_def [symmetric] foldD_equality)
   2.199 -  done
   2.200 -
   2.201 -lemma (in LCD) foldD_closed [simp]:
   2.202 -  "[| finite A; e : D; A <= B |] ==> foldD D f e A : D"
   2.203 -proof (induct set: Finites)
   2.204 -  case empty then show ?case by (simp add: foldD_empty)
   2.205 -next
   2.206 -  case insert then show ?case by (simp add: foldD_insert)
   2.207 -qed
   2.208 -
   2.209 -lemma (in LCD) foldD_commute:
   2.210 -  "[| finite A; x : B; e : D; A <= B |] ==>
   2.211 -   f x (foldD D f e A) = foldD D f (f x e) A"
   2.212 -  apply (induct set: Finites)
   2.213 -   apply simp
   2.214 -  apply (auto simp add: left_commute foldD_insert)
   2.215 -  done
   2.216 -
   2.217 -lemma Int_mono2:
   2.218 -  "[| A <= C; B <= C |] ==> A Int B <= C"
   2.219 -  by blast
   2.220 -
   2.221 -lemma (in LCD) foldD_nest_Un_Int:
   2.222 -  "[| finite A; finite C; e : D; A <= B; C <= B |] ==>
   2.223 -   foldD D f (foldD D f e C) A = foldD D f (foldD D f e (A Int C)) (A Un C)"
   2.224 -  apply (induct set: Finites)
   2.225 -   apply simp
   2.226 -  apply (simp add: foldD_insert foldD_commute Int_insert_left insert_absorb
   2.227 -    Int_mono2 Un_subset_iff)
   2.228 -  done
   2.229 -
   2.230 -lemma (in LCD) foldD_nest_Un_disjoint:
   2.231 -  "[| finite A; finite B; A Int B = {}; e : D; A <= B; C <= B |]
   2.232 -    ==> foldD D f e (A Un B) = foldD D f (foldD D f e B) A"
   2.233 -  by (simp add: foldD_nest_Un_Int)
   2.234 -
   2.235 --- {* Delete rules to do with @{text foldSetD} relation. *}
   2.236 -
   2.237 -declare foldSetD_imp_finite [simp del]
   2.238 -  empty_foldSetDE [rule del]
   2.239 -  foldSetD.intros [rule del]
   2.240 -declare (in LCD)
   2.241 -  foldSetD_closed [rule del]
   2.242 -
   2.243 -subsection {* Commutative monoids *}
   2.244 -
   2.245 -text {*
   2.246 -  We enter a more restrictive context, with @{text "f :: 'a => 'a => 'a"}
   2.247 -  instead of @{text "'b => 'a => 'a"}.
   2.248 -*}
   2.249 -
   2.250 -locale ACeD =
   2.251 -  fixes D :: "'a set"
   2.252 -    and f :: "'a => 'a => 'a"    (infixl "\<cdot>" 70)
   2.253 -    and e :: 'a
   2.254 -  assumes ident [simp]: "x : D ==> x \<cdot> e = x"
   2.255 -    and commute: "[| x : D; y : D |] ==> x \<cdot> y = y \<cdot> x"
   2.256 -    and assoc: "[| x : D; y : D; z : D |] ==> (x \<cdot> y) \<cdot> z = x \<cdot> (y \<cdot> z)"
   2.257 -    and e_closed [simp]: "e : D"
   2.258 -    and f_closed [simp]: "[| x : D; y : D |] ==> x \<cdot> y : D"
   2.259 -
   2.260 -lemma (in ACeD) left_commute:
   2.261 -  "[| x : D; y : D; z : D |] ==> x \<cdot> (y \<cdot> z) = y \<cdot> (x \<cdot> z)"
   2.262 -proof -
   2.263 -  assume D: "x : D" "y : D" "z : D"
   2.264 -  then have "x \<cdot> (y \<cdot> z) = (y \<cdot> z) \<cdot> x" by (simp add: commute)
   2.265 -  also from D have "... = y \<cdot> (z \<cdot> x)" by (simp add: assoc)
   2.266 -  also from D have "z \<cdot> x = x \<cdot> z" by (simp add: commute)
   2.267 -  finally show ?thesis .
   2.268 -qed
   2.269 -
   2.270 -lemmas (in ACeD) AC = assoc commute left_commute
   2.271 -
   2.272 -lemma (in ACeD) left_ident [simp]: "x : D ==> e \<cdot> x = x"
   2.273 -proof -
   2.274 -  assume D: "x : D"
   2.275 -  have "x \<cdot> e = x" by (rule ident)
   2.276 -  with D show ?thesis by (simp add: commute)
   2.277 -qed
   2.278 -
   2.279 -lemma (in ACeD) foldD_Un_Int:
   2.280 -  "[| finite A; finite B; A <= D; B <= D |] ==>
   2.281 -    foldD D f e A \<cdot> foldD D f e B =
   2.282 -    foldD D f e (A Un B) \<cdot> foldD D f e (A Int B)"
   2.283 -  apply (induct set: Finites)
   2.284 -   apply (simp add: left_commute LCD.foldD_closed [OF LCD.intro [of D]])
   2.285 -(* left_commute is required to show premise of LCD.intro *)
   2.286 -  apply (simp add: AC insert_absorb Int_insert_left
   2.287 -    LCD.foldD_insert [OF LCD.intro [of D]]
   2.288 -    LCD.foldD_closed [OF LCD.intro [of D]]
   2.289 -    Int_mono2 Un_subset_iff)
   2.290 -  done
   2.291 -
   2.292 -lemma (in ACeD) foldD_Un_disjoint:
   2.293 -  "[| finite A; finite B; A Int B = {}; A <= D; B <= D |] ==>
   2.294 -    foldD D f e (A Un B) = foldD D f e A \<cdot> foldD D f e B"
   2.295 -  by (simp add: foldD_Un_Int
   2.296 -    left_commute LCD.foldD_closed [OF LCD.intro [of D]] Un_subset_iff)
   2.297 -
   2.298 -subsection {* Abelian groups with summation operator *}
   2.299 -
   2.300 -lemma (in abelian_group) sum_lcomm:
   2.301 -  "[| x : carrier G; y : carrier G; z : carrier G |] ==>
   2.302 -   x \<oplus> (y \<oplus> z) = y \<oplus> (x \<oplus> z)"
   2.303 -proof -
   2.304 -  assume "x : carrier G" "y : carrier G" "z : carrier G"
   2.305 -  then have "x \<oplus> (y \<oplus> z) = (x \<oplus> y) \<oplus> z" by (simp add: sum_assoc)
   2.306 -  also from prems have "... = (y \<oplus> x) \<oplus> z" by (simp add: sum_commute)
   2.307 -  also from prems have "... = y \<oplus> (x \<oplus> z)" by (simp add: sum_assoc)
   2.308 -  finally show ?thesis .
   2.309 -qed
   2.310 -
   2.311 -lemmas (in abelian_group) AC = sum_assoc sum_commute sum_lcomm
   2.312 -
   2.313 -record ('a, 'b) group_with_sum = "'a group" +
   2.314 -  setSum :: "['b => 'a, 'b set] => 'a"
   2.315 -
   2.316 -(* TODO: nice syntax for the summation operator inside the locale
   2.317 -   like \<Oplus>\<index> i\<in>A. f i, probably needs hand-coded translation *)
   2.318 -
   2.319 -locale agroup_with_sum = abelian_group +
   2.320 -  assumes setSum_def:
   2.321 -  "setSum G f A = (if finite A then foldD (carrier G) (op \<oplus> o f) \<zero> A else \<zero>)"
   2.322 -
   2.323 -ML_setup {* 
   2.324 -
   2.325 -Context.>> (fn thy => (simpset_ref_of thy :=
   2.326 -  simpset_of thy setsubgoaler asm_full_simp_tac; thy)) *}
   2.327 -
   2.328 -lemma (in agroup_with_sum) setSum_empty [simp]: 
   2.329 -  "setSum G f {} = \<zero>"
   2.330 -  by (simp add: setSum_def)
   2.331 -
   2.332 -ML_setup {* 
   2.333 -
   2.334 -Context.>> (fn thy => (simpset_ref_of thy :=
   2.335 -  simpset_of thy setsubgoaler asm_simp_tac; thy)) *}
   2.336 -
   2.337 -lemma insert_conj:
   2.338 -  "[| a = b; a : B |] ==> a : insert b B"
   2.339 -  by blast
   2.340 -
   2.341 -declare funcsetI [intro]
   2.342 -  funcset_mem [dest]
   2.343 -
   2.344 -lemma (in agroup_with_sum) setSum_insert [simp]:
   2.345 -  "[| finite F; a \<notin> F; f : F -> carrier G; f a : carrier G |] ==>
   2.346 -   setSum G f (insert a F) = f a \<oplus> setSum G f F"
   2.347 -  apply (rule trans)
   2.348 -  apply (simp add: setSum_def)
   2.349 -  apply (rule trans)
   2.350 -  apply (rule LCD.foldD_insert [OF LCD.intro [of "insert a F"]])
   2.351 -    apply simp
   2.352 -    apply (rule sum_lcomm)
   2.353 -      apply fast apply fast apply assumption
   2.354 -    apply (fastsimp intro: sum_closed)
   2.355 -    apply simp+ apply fast
   2.356 -  apply (auto simp add: setSum_def)
   2.357 -  done
   2.358 -
   2.359 -lemma (in agroup_with_sum) setSum_0:
   2.360 -  "setSum G (%i. \<zero>) A = \<zero>"
   2.361 -(*  apply (case_tac "finite A")
   2.362 -   prefer 2 apply (simp add: setSum_def) *)
   2.363 -proof (cases "finite A")
   2.364 -  case True then show ?thesis
   2.365 -  proof (induct set: Finites)
   2.366 -    case empty show ?case by simp
   2.367 -  next
   2.368 -    case (insert A a)
   2.369 -    have "(%i. \<zero>) : A -> carrier G" by auto
   2.370 -    with insert show ?case by simp
   2.371 -  qed
   2.372 -next
   2.373 -  case False then show ?thesis by (simp add: setSum_def)
   2.374 -qed
   2.375 -
   2.376 -(*
   2.377 -lemma setSum_eq_0_iff [simp]:
   2.378 -    "finite F ==> (setSum f F = 0) = (ALL a:F. f a = (0::nat))"
   2.379 -  by (induct set: Finites) auto
   2.380 -
   2.381 -lemma setSum_SucD: "setSum f A = Suc n ==> EX a:A. 0 < f a"
   2.382 -  apply (case_tac "finite A")
   2.383 -   prefer 2 apply (simp add: setSum_def)
   2.384 -  apply (erule rev_mp)
   2.385 -  apply (erule finite_induct)
   2.386 -   apply auto
   2.387 -  done
   2.388 -
   2.389 -lemma card_eq_setSum: "finite A ==> card A = setSum (\<lambda>x. 1) A"
   2.390 -*)  -- {* Could allow many @{text "card"} proofs to be simplified. *}
   2.391 -(*
   2.392 -  by (induct set: Finites) auto
   2.393 -*)
   2.394 -
   2.395 -lemma (in agroup_with_sum) setSum_closed:
   2.396 -  "[| finite A; f : A -> carrier G |] ==> setSum G f A : carrier G"
   2.397 -proof (induct set: Finites)
   2.398 -  case empty show ?case by simp
   2.399 -next
   2.400 -  case (insert A a)
   2.401 -  then have a: "f a : carrier G" by fast
   2.402 -  from insert have A: "f : A -> carrier G" by fast
   2.403 -  from insert A a show ?case by simp
   2.404 -qed
   2.405 -(*
   2.406 -lemma (in agroup_with_sum) setSum_closed:
   2.407 -  "[| finite A; f``A <= carrier G |] ==> setSum G f A : carrier G"
   2.408 -
   2.409 -lemma (in agroup_with_sum) setSum_closed:
   2.410 -  "[| finite A; !!i. i : A ==> f i : carrier G |] ==>
   2.411 -   setSum G f A : carrier G"
   2.412 -*)
   2.413 -
   2.414 -lemma funcset_Int_left [simp, intro]:
   2.415 -  "[| f : A -> C; f : B -> C |] ==> f : A Int B -> C"
   2.416 -  by fast
   2.417 -
   2.418 -lemma funcset_Int_right:
   2.419 -  "(f : A -> B Int C) = (f : A -> B & f : A -> C)"
   2.420 -  by fast
   2.421 -
   2.422 -lemma funcset_Un_right:
   2.423 -  "[| f : A -> B; f : A -> C |] ==> f : A -> B Un C"
   2.424 -  by fast
   2.425 -
   2.426 -lemma funcset_Un_left [iff]:
   2.427 -  "(f : A Un B -> C) = (f : A -> C & f : B -> C)"
   2.428 -  by fast
   2.429 -
   2.430 -lemma (in agroup_with_sum) setSum_Un_Int:
   2.431 -  "[| finite A; finite B; g : A -> carrier G; g : B -> carrier G |] ==>
   2.432 -   setSum G g (A Un B) \<oplus> setSum G g (A Int B) = setSum G g A \<oplus> setSum G g B"
   2.433 -  -- {* The reversed orientation looks more natural, but LOOPS as a simprule! *}
   2.434 -proof (induct set: Finites)
   2.435 -  case empty then show ?case by (simp add: setSum_closed)
   2.436 -next
   2.437 -  case (insert A a)
   2.438 -  then have a: "g a : carrier G" by fast
   2.439 -  from insert have A: "g : A -> carrier G" by fast
   2.440 -  from insert A a show ?case
   2.441 -    by (simp add: AC Int_insert_left insert_absorb setSum_closed
   2.442 -          Int_mono2 Un_subset_iff) 
   2.443 -qed
   2.444 -
   2.445 -lemma (in agroup_with_sum) setSum_Un_disjoint:
   2.446 -  "[| finite A; finite B; A Int B = {};
   2.447 -      g : A -> carrier G; g : B -> carrier G |]
   2.448 -   ==> setSum G g (A Un B) = setSum G g A \<oplus> setSum G g B"
   2.449 -  apply (subst setSum_Un_Int [symmetric])
   2.450 -    apply (auto simp add: setSum_closed)
   2.451 -  done
   2.452 -
   2.453 -(*
   2.454 -lemma setSum_UN_disjoint:
   2.455 -  fixes f :: "'a => 'b::plus_ac0"
   2.456 -  shows
   2.457 -    "finite I ==> (ALL i:I. finite (A i)) ==>
   2.458 -        (ALL i:I. ALL j:I. i \<noteq> j --> A i Int A j = {}) ==>
   2.459 -      setSum f (UNION I A) = setSum (\<lambda>i. setSum f (A i)) I"
   2.460 -  apply (induct set: Finites)
   2.461 -   apply simp
   2.462 -  apply atomize
   2.463 -  apply (subgoal_tac "ALL i:F. x \<noteq> i")
   2.464 -   prefer 2 apply blast
   2.465 -  apply (subgoal_tac "A x Int UNION F A = {}")
   2.466 -   prefer 2 apply blast
   2.467 -  apply (simp add: setSum_Un_disjoint)
   2.468 -  done
   2.469 -*)
   2.470 -lemma (in agroup_with_sum) setSum_addf:
   2.471 -  "[| finite A; f : A -> carrier G; g : A -> carrier G |] ==>
   2.472 -   setSum G (%x. f x \<oplus> g x) A = (setSum G f A \<oplus> setSum G g A)"
   2.473 -proof (induct set: Finites)
   2.474 -  case empty show ?case by simp
   2.475 -next
   2.476 -  case (insert A a) then
   2.477 -  have fA: "f : A -> carrier G" by fast
   2.478 -  from insert have fa: "f a : carrier G" by fast
   2.479 -  from insert have gA: "g : A -> carrier G" by fast
   2.480 -  from insert have ga: "g a : carrier G" by fast
   2.481 -  from insert have fga: "(%x. f x \<oplus> g x) a : carrier G" by (simp add: Pi_def)
   2.482 -  from insert have fgA: "(%x. f x \<oplus> g x) : A -> carrier G"
   2.483 -    by (simp add: Pi_def)
   2.484 -  show ?case  (* check if all simps are really necessary *)
   2.485 -    by (simp add: insert fA fa gA ga fgA fga AC setSum_closed Int_insert_left insert_absorb Int_mono2 Un_subset_iff)
   2.486 -qed
   2.487 -
   2.488 -(*
   2.489 -lemma setSum_Un: "finite A ==> finite B ==>
   2.490 -    (setSum f (A Un B) :: nat) = setSum f A + setSum f B - setSum f (A Int B)"
   2.491 -  -- {* For the natural numbers, we have subtraction. *}
   2.492 -  apply (subst setSum_Un_Int [symmetric])
   2.493 -    apply auto
   2.494 -  done
   2.495 -
   2.496 -lemma setSum_diff1: "(setSum f (A - {a}) :: nat) =
   2.497 -    (if a:A then setSum f A - f a else setSum f A)"
   2.498 -  apply (case_tac "finite A")
   2.499 -   prefer 2 apply (simp add: setSum_def)
   2.500 -  apply (erule finite_induct)
   2.501 -   apply (auto simp add: insert_Diff_if)
   2.502 -  apply (drule_tac a = a in mk_disjoint_insert)
   2.503 -  apply auto
   2.504 -  done
   2.505 -*)
   2.506 -
   2.507 -lemma (in agroup_with_sum) setSum_cong:
   2.508 -  "[| A = B; g : B -> carrier G;
   2.509 -      !!i. i : B ==> f i = g i |] ==> setSum G f A = setSum G g B"
   2.510 -proof -
   2.511 -  assume prems: "A = B" "g : B -> carrier G"
   2.512 -    "!!i. i : B ==> f i = g i"
   2.513 -  show ?thesis
   2.514 -  proof (cases "finite B")
   2.515 -    case True
   2.516 -    then have "!!A. [| A = B; g : B -> carrier G;
   2.517 -      !!i. i : B ==> f i = g i |] ==> setSum G f A = setSum G g B"
   2.518 -    proof induct
   2.519 -      case empty thus ?case by simp
   2.520 -    next
   2.521 -      case (insert B x)
   2.522 -      then have "setSum G f A = setSum G f (insert x B)" by simp
   2.523 -      also from insert have "... = f x \<oplus> setSum G f B"
   2.524 -      proof (intro setSum_insert)
   2.525 -	show "finite B" .
   2.526 -      next
   2.527 -	show "x ~: B" .
   2.528 -      next
   2.529 -	assume "x ~: B" "!!i. i \<in> insert x B \<Longrightarrow> f i = g i"
   2.530 -	  "g \<in> insert x B \<rightarrow> carrier G"
   2.531 -	thus "f : B -> carrier G" by fastsimp
   2.532 -      next
   2.533 -	assume "x ~: B" "!!i. i \<in> insert x B \<Longrightarrow> f i = g i"
   2.534 -	  "g \<in> insert x B \<rightarrow> carrier G"
   2.535 -	thus "f x \<in> carrier G" by fastsimp
   2.536 -      qed
   2.537 -      also from insert have "... = g x \<oplus> setSum G g B" by fastsimp
   2.538 -      also from insert have "... = setSum G g (insert x B)"
   2.539 -      by (intro setSum_insert [THEN sym]) auto
   2.540 -      finally show ?case .
   2.541 -    qed
   2.542 -    with prems show ?thesis by simp
   2.543 -  next
   2.544 -    case False with prems show ?thesis by (simp add: setSum_def)
   2.545 -  qed
   2.546 -qed
   2.547 -
   2.548 -lemma (in agroup_with_sum) setSum_cong1 [cong]:
   2.549 -  "[| A = B; !!i. i : B ==> f i = g i;
   2.550 -      g : B -> carrier G = True |] ==> setSum G f A = setSum G g B"
   2.551 -  by (rule setSum_cong) fast+
   2.552 -
   2.553 -text {*Usually, if this rule causes a failed congruence proof error,
   2.554 -   the reason is that the premise @{text "g : B -> carrier G"} cannot be shown.
   2.555 -   Adding @{thm [source] Pi_def} to the simpset is often useful. *}
   2.556 -
   2.557 -declare funcsetI [rule del]
   2.558 -  funcset_mem [rule del]
   2.559 -
   2.560 -(*** Examples --- Summation over the integer interval {..n} ***)
   2.561 -
   2.562 -(* New locale where index set is restricted to nat *)
   2.563 -
   2.564 -locale agroup_with_natsum = agroup_with_sum +
   2.565 -  assumes "False ==> setSum G f (A::nat set) = setSum G f A"
   2.566 -
   2.567 -lemma (in agroup_with_natsum) natSum_0 [simp]:
   2.568 -  "f : {0::nat} -> carrier G ==> setSum G f {..0} = f 0"
   2.569 -by (simp add: Pi_def)
   2.570 -
   2.571 -lemma (in agroup_with_natsum) natsum_Suc [simp]:
   2.572 -  "f : {..Suc n} -> carrier G ==>
   2.573 -   setSum G f {..Suc n} = (f (Suc n) \<oplus> setSum G f {..n})"
   2.574 -by (simp add: Pi_def atMost_Suc)
   2.575 -
   2.576 -lemma (in agroup_with_natsum) natsum_Suc2:
   2.577 -  "f : {..Suc n} -> carrier G ==>
   2.578 -   setSum G f {..Suc n} = (setSum G (%i. f (Suc i)) {..n} \<oplus> f 0)"
   2.579 -proof (induct n)
   2.580 -  case 0 thus ?case by (simp add: Pi_def)
   2.581 -next
   2.582 -  case Suc thus ?case by (simp add: sum_assoc Pi_def setSum_closed)
   2.583 -qed
   2.584 -
   2.585 -lemma (in agroup_with_natsum) natsum_zero [simp]:
   2.586 -  "setSum G (%i. \<zero>) {..n::nat} = \<zero>"
   2.587 -by (induct n) (simp_all add: Pi_def)
   2.588 -
   2.589 -lemma (in agroup_with_natsum) natsum_add [simp]:
   2.590 -  "[| f : {..n} -> carrier G; g : {..n} -> carrier G |] ==>
   2.591 -   setSum G (%i. f i \<oplus> g i) {..n::nat} = setSum G f {..n} \<oplus> setSum G g {..n}"
   2.592 -by (induct n) (simp_all add: AC Pi_def setSum_closed)
   2.593 -
   2.594 -end
   2.595 -
     3.1 --- a/src/HOL/IsaMakefile	Tue Apr 08 09:44:21 2003 +0200
     3.2 +++ b/src/HOL/IsaMakefile	Wed Apr 09 12:51:49 2003 +0200
     3.3 @@ -286,7 +286,6 @@
     3.4    Library/Primes.thy Library/FuncSet.thy \
     3.5    GroupTheory/Bij.thy \
     3.6    GroupTheory/Group.thy \
     3.7 -  GroupTheory/Summation.thy \
     3.8    GroupTheory/ROOT.ML \
     3.9    GroupTheory/document/root.tex
    3.10  	@$(ISATOOL) usedir -g true $(OUT)/HOL GroupTheory