src/HOL/Algebra/FiniteProduct.thy
author haftmann
Fri, 02 Mar 2012 21:45:45 +0100
changeset 46767 807a5d219c23
parent 46721 f88b187ad8ca
child 56142 8bb21318e10b
permissions -rw-r--r--
more fundamental pred-to-set conversions for range and domain by means of inductive_set
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14706
71590b7733b7 tuned document;
wenzelm
parents: 14666
diff changeset
     1
(*  Title:      HOL/Algebra/FiniteProduct.thy
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
     2
    Author:     Clemens Ballarin, started 19 November 2002
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
     3
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
     4
This file is largely based on HOL/Finite_Set.thy.
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
     5
*)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
     6
35849
b5522b51cb1e standard headers;
wenzelm
parents: 35848
diff changeset
     7
theory FiniteProduct
b5522b51cb1e standard headers;
wenzelm
parents: 35848
diff changeset
     8
imports Group
b5522b51cb1e standard headers;
wenzelm
parents: 35848
diff changeset
     9
begin
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    10
27717
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27699
diff changeset
    11
subsection {* Product Operator for Commutative Monoids *}
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents: 16638
diff changeset
    12
27717
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27699
diff changeset
    13
subsubsection {* Inductive Definition of a Relation for Products over Sets *}
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    14
14750
paulson
parents: 14706
diff changeset
    15
text {* Instantiation of locale @{text LC} of theory @{text Finite_Set} is not
paulson
parents: 14706
diff changeset
    16
  possible, because here we have explicit typing rules like 
paulson
parents: 14706
diff changeset
    17
  @{text "x \<in> carrier G"}.  We introduce an explicit argument for the domain
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14590
diff changeset
    18
  @{text D}. *}
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    19
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 23350
diff changeset
    20
inductive_set
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    21
  foldSetD :: "['a set, 'b => 'a => 'a, 'a] => ('b set * 'a) set"
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 23350
diff changeset
    22
  for D :: "'a set" and f :: "'b => 'a => 'a" and e :: 'a
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 23350
diff changeset
    23
  where
14750
paulson
parents: 14706
diff changeset
    24
    emptyI [intro]: "e \<in> D ==> ({}, e) \<in> foldSetD D f e"
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 23350
diff changeset
    25
  | insertI [intro]: "[| x ~: A; f x y \<in> D; (A, y) \<in> foldSetD D f e |] ==>
14750
paulson
parents: 14706
diff changeset
    26
                      (insert x A, f x y) \<in> foldSetD D f e"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    27
14750
paulson
parents: 14706
diff changeset
    28
inductive_cases empty_foldSetDE [elim!]: "({}, x) \<in> foldSetD D f e"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    29
35848
5443079512ea slightly more uniform definitions -- eliminated old-style meta-equality;
wenzelm
parents: 35847
diff changeset
    30
definition
5443079512ea slightly more uniform definitions -- eliminated old-style meta-equality;
wenzelm
parents: 35847
diff changeset
    31
  foldD :: "['a set, 'b => 'a => 'a, 'a, 'b set] => 'a"
5443079512ea slightly more uniform definitions -- eliminated old-style meta-equality;
wenzelm
parents: 35847
diff changeset
    32
  where "foldD D f e A = (THE x. (A, x) \<in> foldSetD D f e)"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    33
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    34
lemma foldSetD_closed:
14750
paulson
parents: 14706
diff changeset
    35
  "[| (A, z) \<in> foldSetD D f e ; e \<in> D; !!x y. [| x \<in> A; y \<in> D |] ==> f x y \<in> D 
paulson
parents: 14706
diff changeset
    36
      |] ==> z \<in> D";
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 23350
diff changeset
    37
  by (erule foldSetD.cases) auto
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    38
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    39
lemma Diff1_foldSetD:
14750
paulson
parents: 14706
diff changeset
    40
  "[| (A - {x}, y) \<in> foldSetD D f e; x \<in> A; f x y \<in> D |] ==>
paulson
parents: 14706
diff changeset
    41
   (A, f x y) \<in> foldSetD D f e"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    42
  apply (erule insert_Diff [THEN subst], rule foldSetD.intros)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    43
    apply auto
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    44
  done
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    45
14750
paulson
parents: 14706
diff changeset
    46
lemma foldSetD_imp_finite [simp]: "(A, x) \<in> foldSetD D f e ==> finite A"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    47
  by (induct set: foldSetD) auto
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    48
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    49
lemma finite_imp_foldSetD:
14750
paulson
parents: 14706
diff changeset
    50
  "[| finite A; e \<in> D; !!x y. [| x \<in> A; y \<in> D |] ==> f x y \<in> D |] ==>
paulson
parents: 14706
diff changeset
    51
   EX x. (A, x) \<in> foldSetD D f e"
22265
3c5c6bdf61de Adapted to changes in Finite_Set theory.
berghofe
parents: 20318
diff changeset
    52
proof (induct set: finite)
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    53
  case empty then show ?case by auto
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    54
next
15328
35951e6a7855 mod because of change in finite set induction
nipkow
parents: 15095
diff changeset
    55
  case (insert x F)
14750
paulson
parents: 14706
diff changeset
    56
  then obtain y where y: "(F, y) \<in> foldSetD D f e" by auto
paulson
parents: 14706
diff changeset
    57
  with insert have "y \<in> D" by (auto dest: foldSetD_closed)
paulson
parents: 14706
diff changeset
    58
  with y and insert have "(insert x F, f x y) \<in> foldSetD D f e"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    59
    by (intro foldSetD.intros) auto
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    60
  then show ?case ..
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    61
qed
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    62
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents: 16638
diff changeset
    63
27717
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27699
diff changeset
    64
text {* Left-Commutative Operations *}
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    65
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    66
locale LCD =
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    67
  fixes B :: "'b set"
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    68
  and D :: "'a set"
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    69
  and f :: "'b => 'a => 'a"    (infixl "\<cdot>" 70)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    70
  assumes left_commute:
14750
paulson
parents: 14706
diff changeset
    71
    "[| x \<in> B; y \<in> B; z \<in> D |] ==> x \<cdot> (y \<cdot> z) = y \<cdot> (x \<cdot> z)"
paulson
parents: 14706
diff changeset
    72
  and f_closed [simp, intro!]: "!!x y. [| x \<in> B; y \<in> D |] ==> f x y \<in> D"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    73
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    74
lemma (in LCD) foldSetD_closed [dest]:
14750
paulson
parents: 14706
diff changeset
    75
  "(A, z) \<in> foldSetD D f e ==> z \<in> D";
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 23350
diff changeset
    76
  by (erule foldSetD.cases) auto
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    77
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    78
lemma (in LCD) Diff1_foldSetD:
14750
paulson
parents: 14706
diff changeset
    79
  "[| (A - {x}, y) \<in> foldSetD D f e; x \<in> A; A \<subseteq> B |] ==>
paulson
parents: 14706
diff changeset
    80
  (A, f x y) \<in> foldSetD D f e"
paulson
parents: 14706
diff changeset
    81
  apply (subgoal_tac "x \<in> B")
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    82
   prefer 2 apply fast
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    83
  apply (erule insert_Diff [THEN subst], rule foldSetD.intros)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    84
    apply auto
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    85
  done
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    86
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    87
lemma (in LCD) foldSetD_imp_finite [simp]:
14750
paulson
parents: 14706
diff changeset
    88
  "(A, x) \<in> foldSetD D f e ==> finite A"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    89
  by (induct set: foldSetD) auto
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    90
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    91
lemma (in LCD) finite_imp_foldSetD:
14750
paulson
parents: 14706
diff changeset
    92
  "[| finite A; A \<subseteq> B; e \<in> D |] ==> EX x. (A, x) \<in> foldSetD D f e"
22265
3c5c6bdf61de Adapted to changes in Finite_Set theory.
berghofe
parents: 20318
diff changeset
    93
proof (induct set: finite)
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    94
  case empty then show ?case by auto
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
    95
next
15328
35951e6a7855 mod because of change in finite set induction
nipkow
parents: 15095
diff changeset
    96
  case (insert x F)
14750
paulson
parents: 14706
diff changeset
    97
  then obtain y where y: "(F, y) \<in> foldSetD D f e" by auto
paulson
parents: 14706
diff changeset
    98
  with insert have "y \<in> D" by auto
paulson
parents: 14706
diff changeset
    99
  with y and insert have "(insert x F, f x y) \<in> foldSetD D f e"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   100
    by (intro foldSetD.intros) auto
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   101
  then show ?case ..
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   102
qed
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   103
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   104
lemma (in LCD) foldSetD_determ_aux:
14750
paulson
parents: 14706
diff changeset
   105
  "e \<in> D ==> \<forall>A x. A \<subseteq> B & card A < n --> (A, x) \<in> foldSetD D f e -->
paulson
parents: 14706
diff changeset
   106
    (\<forall>y. (A, y) \<in> foldSetD D f e --> y = x)"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   107
  apply (induct n)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   108
   apply (auto simp add: less_Suc_eq) (* slow *)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   109
  apply (erule foldSetD.cases)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   110
   apply blast
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   111
  apply (erule foldSetD.cases)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   112
   apply blast
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   113
  apply clarify
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   114
  txt {* force simplification of @{text "card A < card (insert ...)"}. *}
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   115
  apply (erule rev_mp)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   116
  apply (simp add: less_Suc_eq_le)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   117
  apply (rule impI)
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 23350
diff changeset
   118
  apply (rename_tac xa Aa ya xb Ab yb, case_tac "xa = xb")
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   119
   apply (subgoal_tac "Aa = Ab")
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   120
    prefer 2 apply (blast elim!: equalityE)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   121
   apply blast
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   122
  txt {* case @{prop "xa \<notin> xb"}. *}
14750
paulson
parents: 14706
diff changeset
   123
  apply (subgoal_tac "Aa - {xb} = Ab - {xa} & xb \<in> Aa & xa \<in> Ab")
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   124
   prefer 2 apply (blast elim!: equalityE)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   125
  apply clarify
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   126
  apply (subgoal_tac "Aa = insert xb Ab - {xa}")
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   127
   prefer 2 apply blast
14750
paulson
parents: 14706
diff changeset
   128
  apply (subgoal_tac "card Aa \<le> card Ab")
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   129
   prefer 2
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   130
   apply (rule Suc_le_mono [THEN subst])
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   131
   apply (simp add: card_Suc_Diff1)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   132
  apply (rule_tac A1 = "Aa - {xb}" in finite_imp_foldSetD [THEN exE])
40786
0a54cfc9add3 gave more standard finite set rules simp and intro attribute
nipkow
parents: 35849
diff changeset
   133
     apply (blast intro: foldSetD_imp_finite)
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   134
    apply best
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   135
   apply assumption
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   136
  apply (frule (1) Diff1_foldSetD)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   137
   apply best
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   138
  apply (subgoal_tac "ya = f xb x")
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   139
   prefer 2
14750
paulson
parents: 14706
diff changeset
   140
   apply (subgoal_tac "Aa \<subseteq> B")
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   141
    prefer 2 apply best (* slow *)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   142
   apply (blast del: equalityCE)
14750
paulson
parents: 14706
diff changeset
   143
  apply (subgoal_tac "(Ab - {xa}, x) \<in> foldSetD D f e")
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   144
   prefer 2 apply simp
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   145
  apply (subgoal_tac "yb = f xa x")
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   146
   prefer 2 
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   147
   apply (blast del: equalityCE dest: Diff1_foldSetD)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   148
  apply (simp (no_asm_simp))
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   149
  apply (rule left_commute)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   150
    apply assumption
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   151
   apply best (* slow *)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   152
  apply best
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   153
  done
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   154
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   155
lemma (in LCD) foldSetD_determ:
14750
paulson
parents: 14706
diff changeset
   156
  "[| (A, x) \<in> foldSetD D f e; (A, y) \<in> foldSetD D f e; e \<in> D; A \<subseteq> B |]
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   157
  ==> y = x"
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   158
  by (blast intro: foldSetD_determ_aux [rule_format])
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   159
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   160
lemma (in LCD) foldD_equality:
14750
paulson
parents: 14706
diff changeset
   161
  "[| (A, y) \<in> foldSetD D f e; e \<in> D; A \<subseteq> B |] ==> foldD D f e A = y"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   162
  by (unfold foldD_def) (blast intro: foldSetD_determ)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   163
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   164
lemma foldD_empty [simp]:
14750
paulson
parents: 14706
diff changeset
   165
  "e \<in> D ==> foldD D f e {} = e"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   166
  by (unfold foldD_def) blast
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   167
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   168
lemma (in LCD) foldD_insert_aux:
14750
paulson
parents: 14706
diff changeset
   169
  "[| x ~: A; x \<in> B; e \<in> D; A \<subseteq> B |] ==>
paulson
parents: 14706
diff changeset
   170
    ((insert x A, v) \<in> foldSetD D f e) =
paulson
parents: 14706
diff changeset
   171
    (EX y. (A, y) \<in> foldSetD D f e & v = f x y)"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   172
  apply auto
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   173
  apply (rule_tac A1 = A in finite_imp_foldSetD [THEN exE])
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 41433
diff changeset
   174
     apply (fastforce dest: foldSetD_imp_finite)
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   175
    apply assumption
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   176
   apply assumption
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   177
  apply (blast intro: foldSetD_determ)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   178
  done
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   179
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   180
lemma (in LCD) foldD_insert:
14750
paulson
parents: 14706
diff changeset
   181
    "[| finite A; x ~: A; x \<in> B; e \<in> D; A \<subseteq> B |] ==>
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   182
     foldD D f e (insert x A) = f x (foldD D f e A)"
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   183
  apply (unfold foldD_def)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   184
  apply (simp add: foldD_insert_aux)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   185
  apply (rule the_equality)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   186
   apply (auto intro: finite_imp_foldSetD
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   187
     cong add: conj_cong simp add: foldD_def [symmetric] foldD_equality)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   188
  done
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   189
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   190
lemma (in LCD) foldD_closed [simp]:
14750
paulson
parents: 14706
diff changeset
   191
  "[| finite A; e \<in> D; A \<subseteq> B |] ==> foldD D f e A \<in> D"
22265
3c5c6bdf61de Adapted to changes in Finite_Set theory.
berghofe
parents: 20318
diff changeset
   192
proof (induct set: finite)
46721
f88b187ad8ca tuned proofs;
wenzelm
parents: 44890
diff changeset
   193
  case empty then show ?case by simp
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   194
next
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   195
  case insert then show ?case by (simp add: foldD_insert)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   196
qed
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   197
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   198
lemma (in LCD) foldD_commute:
14750
paulson
parents: 14706
diff changeset
   199
  "[| finite A; x \<in> B; e \<in> D; A \<subseteq> B |] ==>
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   200
   f x (foldD D f e A) = foldD D f (f x e) A"
22265
3c5c6bdf61de Adapted to changes in Finite_Set theory.
berghofe
parents: 20318
diff changeset
   201
  apply (induct set: finite)
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   202
   apply simp
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   203
  apply (auto simp add: left_commute foldD_insert)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   204
  done
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   205
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   206
lemma Int_mono2:
14750
paulson
parents: 14706
diff changeset
   207
  "[| A \<subseteq> C; B \<subseteq> C |] ==> A Int B \<subseteq> C"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   208
  by blast
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   209
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   210
lemma (in LCD) foldD_nest_Un_Int:
14750
paulson
parents: 14706
diff changeset
   211
  "[| finite A; finite C; e \<in> D; A \<subseteq> B; C \<subseteq> B |] ==>
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   212
   foldD D f (foldD D f e C) A = foldD D f (foldD D f e (A Int C)) (A Un C)"
22265
3c5c6bdf61de Adapted to changes in Finite_Set theory.
berghofe
parents: 20318
diff changeset
   213
  apply (induct set: finite)
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   214
   apply simp
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   215
  apply (simp add: foldD_insert foldD_commute Int_insert_left insert_absorb
32693
6c6b1ba5e71e tuned proofs
haftmann
parents: 31727
diff changeset
   216
    Int_mono2)
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   217
  done
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   218
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   219
lemma (in LCD) foldD_nest_Un_disjoint:
14750
paulson
parents: 14706
diff changeset
   220
  "[| finite A; finite B; A Int B = {}; e \<in> D; A \<subseteq> B; C \<subseteq> B |]
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   221
    ==> foldD D f e (A Un B) = foldD D f (foldD D f e B) A"
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   222
  by (simp add: foldD_nest_Un_Int)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   223
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   224
-- {* Delete rules to do with @{text foldSetD} relation. *}
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   225
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   226
declare foldSetD_imp_finite [simp del]
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   227
  empty_foldSetDE [rule del]
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   228
  foldSetD.intros [rule del]
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   229
declare (in LCD)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   230
  foldSetD_closed [rule del]
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   231
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents: 16638
diff changeset
   232
27717
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27699
diff changeset
   233
text {* Commutative Monoids *}
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   234
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   235
text {*
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   236
  We enter a more restrictive context, with @{text "f :: 'a => 'a => 'a"}
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   237
  instead of @{text "'b => 'a => 'a"}.
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   238
*}
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   239
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   240
locale ACeD =
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   241
  fixes D :: "'a set"
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   242
    and f :: "'a => 'a => 'a"    (infixl "\<cdot>" 70)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   243
    and e :: 'a
14750
paulson
parents: 14706
diff changeset
   244
  assumes ident [simp]: "x \<in> D ==> x \<cdot> e = x"
paulson
parents: 14706
diff changeset
   245
    and commute: "[| x \<in> D; y \<in> D |] ==> x \<cdot> y = y \<cdot> x"
paulson
parents: 14706
diff changeset
   246
    and assoc: "[| x \<in> D; y \<in> D; z \<in> D |] ==> (x \<cdot> y) \<cdot> z = x \<cdot> (y \<cdot> z)"
paulson
parents: 14706
diff changeset
   247
    and e_closed [simp]: "e \<in> D"
paulson
parents: 14706
diff changeset
   248
    and f_closed [simp]: "[| x \<in> D; y \<in> D |] ==> x \<cdot> y \<in> D"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   249
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   250
lemma (in ACeD) left_commute:
14750
paulson
parents: 14706
diff changeset
   251
  "[| x \<in> D; y \<in> D; z \<in> D |] ==> x \<cdot> (y \<cdot> z) = y \<cdot> (x \<cdot> z)"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   252
proof -
14750
paulson
parents: 14706
diff changeset
   253
  assume D: "x \<in> D" "y \<in> D" "z \<in> D"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   254
  then have "x \<cdot> (y \<cdot> z) = (y \<cdot> z) \<cdot> x" by (simp add: commute)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   255
  also from D have "... = y \<cdot> (z \<cdot> x)" by (simp add: assoc)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   256
  also from D have "z \<cdot> x = x \<cdot> z" by (simp add: commute)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   257
  finally show ?thesis .
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   258
qed
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   259
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   260
lemmas (in ACeD) AC = assoc commute left_commute
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   261
14750
paulson
parents: 14706
diff changeset
   262
lemma (in ACeD) left_ident [simp]: "x \<in> D ==> e \<cdot> x = x"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   263
proof -
23350
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   264
  assume "x \<in> D"
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   265
  then have "x \<cdot> e = x" by (rule ident)
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   266
  with `x \<in> D` show ?thesis by (simp add: commute)
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   267
qed
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   268
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   269
lemma (in ACeD) foldD_Un_Int:
14750
paulson
parents: 14706
diff changeset
   270
  "[| finite A; finite B; A \<subseteq> D; B \<subseteq> D |] ==>
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   271
    foldD D f e A \<cdot> foldD D f e B =
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   272
    foldD D f e (A Un B) \<cdot> foldD D f e (A Int B)"
22265
3c5c6bdf61de Adapted to changes in Finite_Set theory.
berghofe
parents: 20318
diff changeset
   273
  apply (induct set: finite)
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   274
   apply (simp add: left_commute LCD.foldD_closed [OF LCD.intro [of D]])
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   275
  apply (simp add: AC insert_absorb Int_insert_left
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   276
    LCD.foldD_insert [OF LCD.intro [of D]]
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   277
    LCD.foldD_closed [OF LCD.intro [of D]]
32693
6c6b1ba5e71e tuned proofs
haftmann
parents: 31727
diff changeset
   278
    Int_mono2)
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   279
  done
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   280
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   281
lemma (in ACeD) foldD_Un_disjoint:
14750
paulson
parents: 14706
diff changeset
   282
  "[| finite A; finite B; A Int B = {}; A \<subseteq> D; B \<subseteq> D |] ==>
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   283
    foldD D f e (A Un B) = foldD D f e A \<cdot> foldD D f e B"
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   284
  by (simp add: foldD_Un_Int
32693
6c6b1ba5e71e tuned proofs
haftmann
parents: 31727
diff changeset
   285
    left_commute LCD.foldD_closed [OF LCD.intro [of D]])
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   286
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents: 16638
diff changeset
   287
27717
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27699
diff changeset
   288
subsubsection {* Products over Finite Sets *}
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   289
35847
19f1f7066917 eliminated old constdefs;
wenzelm
parents: 35416
diff changeset
   290
definition
35848
5443079512ea slightly more uniform definitions -- eliminated old-style meta-equality;
wenzelm
parents: 35847
diff changeset
   291
  finprod :: "[('b, 'm) monoid_scheme, 'a => 'b, 'a set] => 'b"
5443079512ea slightly more uniform definitions -- eliminated old-style meta-equality;
wenzelm
parents: 35847
diff changeset
   292
  where "finprod G f A =
5443079512ea slightly more uniform definitions -- eliminated old-style meta-equality;
wenzelm
parents: 35847
diff changeset
   293
   (if finite A
35847
19f1f7066917 eliminated old constdefs;
wenzelm
parents: 35416
diff changeset
   294
    then foldD (carrier G) (mult G o f) \<one>\<^bsub>G\<^esub> A
35848
5443079512ea slightly more uniform definitions -- eliminated old-style meta-equality;
wenzelm
parents: 35847
diff changeset
   295
    else undefined)"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   296
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14590
diff changeset
   297
syntax
02b8f3bcf7fe improved notation;
wenzelm
parents: 14590
diff changeset
   298
  "_finprod" :: "index => idt => 'a set => 'b => 'b"
14666
65f8680c3f16 improved notation;
wenzelm
parents: 14651
diff changeset
   299
      ("(3\<Otimes>__:_. _)" [1000, 0, 51, 10] 10)
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14590
diff changeset
   300
syntax (xsymbols)
02b8f3bcf7fe improved notation;
wenzelm
parents: 14590
diff changeset
   301
  "_finprod" :: "index => idt => 'a set => 'b => 'b"
14666
65f8680c3f16 improved notation;
wenzelm
parents: 14651
diff changeset
   302
      ("(3\<Otimes>__\<in>_. _)" [1000, 0, 51, 10] 10)
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14590
diff changeset
   303
syntax (HTML output)
02b8f3bcf7fe improved notation;
wenzelm
parents: 14590
diff changeset
   304
  "_finprod" :: "index => idt => 'a set => 'b => 'b"
14666
65f8680c3f16 improved notation;
wenzelm
parents: 14651
diff changeset
   305
      ("(3\<Otimes>__\<in>_. _)" [1000, 0, 51, 10] 10)
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14590
diff changeset
   306
translations
35054
a5db9779b026 modernized some syntax translations;
wenzelm
parents: 32960
diff changeset
   307
  "\<Otimes>\<index>i:A. b" == "CONST finprod \<struct>\<index> (%i. b) A"
15095
63f5f4c265dd Theories now take advantage of recent syntax improvements with (structure).
ballarin
parents: 14750
diff changeset
   308
  -- {* Beware of argument permutation! *}
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   309
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   310
lemma (in comm_monoid) finprod_empty [simp]: 
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   311
  "finprod G f {} = \<one>"
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   312
  by (simp add: finprod_def)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   313
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   314
declare funcsetI [intro]
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   315
  funcset_mem [dest]
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   316
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   317
context comm_monoid begin
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   318
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   319
lemma finprod_insert [simp]:
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   320
  "[| finite F; a \<notin> F; f \<in> F -> carrier G; f a \<in> carrier G |] ==>
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   321
   finprod G f (insert a F) = f a \<otimes> finprod G f F"
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   322
  apply (rule trans)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   323
   apply (simp add: finprod_def)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   324
  apply (rule trans)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   325
   apply (rule LCD.foldD_insert [OF LCD.intro [of "insert a F"]])
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   326
         apply simp
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   327
         apply (rule m_lcomm)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   328
           apply fast
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   329
          apply fast
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   330
         apply assumption
46721
f88b187ad8ca tuned proofs;
wenzelm
parents: 44890
diff changeset
   331
        apply fastforce
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   332
       apply simp+
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   333
   apply fast
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   334
  apply (auto simp add: finprod_def)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   335
  done
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   336
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   337
lemma finprod_one [simp]:
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14590
diff changeset
   338
  "finite A ==> (\<Otimes>i:A. \<one>) = \<one>"
22265
3c5c6bdf61de Adapted to changes in Finite_Set theory.
berghofe
parents: 20318
diff changeset
   339
proof (induct set: finite)
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   340
  case empty show ?case by simp
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   341
next
15328
35951e6a7855 mod because of change in finite set induction
nipkow
parents: 15095
diff changeset
   342
  case (insert a A)
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   343
  have "(%i. \<one>) \<in> A -> carrier G" by auto
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   344
  with insert show ?case by simp
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   345
qed
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   346
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   347
lemma finprod_closed [simp]:
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   348
  fixes A
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   349
  assumes fin: "finite A" and f: "f \<in> A -> carrier G" 
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   350
  shows "finprod G f A \<in> carrier G"
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   351
using fin f
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   352
proof induct
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   353
  case empty show ?case by simp
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   354
next
15328
35951e6a7855 mod because of change in finite set induction
nipkow
parents: 15095
diff changeset
   355
  case (insert a A)
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   356
  then have a: "f a \<in> carrier G" by fast
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   357
  from insert have A: "f \<in> A -> carrier G" by fast
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   358
  from insert A a show ?case by simp
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   359
qed
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   360
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   361
lemma funcset_Int_left [simp, intro]:
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   362
  "[| f \<in> A -> C; f \<in> B -> C |] ==> f \<in> A Int B -> C"
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   363
  by fast
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   364
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   365
lemma funcset_Un_left [iff]:
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   366
  "(f \<in> A Un B -> C) = (f \<in> A -> C & f \<in> B -> C)"
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   367
  by fast
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   368
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   369
lemma finprod_Un_Int:
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   370
  "[| finite A; finite B; g \<in> A -> carrier G; g \<in> B -> carrier G |] ==>
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   371
     finprod G g (A Un B) \<otimes> finprod G g (A Int B) =
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   372
     finprod G g A \<otimes> finprod G g B"
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   373
-- {* The reversed orientation looks more natural, but LOOPS as a simprule! *}
22265
3c5c6bdf61de Adapted to changes in Finite_Set theory.
berghofe
parents: 20318
diff changeset
   374
proof (induct set: finite)
46721
f88b187ad8ca tuned proofs;
wenzelm
parents: 44890
diff changeset
   375
  case empty then show ?case by simp
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   376
next
15328
35951e6a7855 mod because of change in finite set induction
nipkow
parents: 15095
diff changeset
   377
  case (insert a A)
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   378
  then have a: "g a \<in> carrier G" by fast
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   379
  from insert have A: "g \<in> A -> carrier G" by fast
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   380
  from insert A a show ?case
46721
f88b187ad8ca tuned proofs;
wenzelm
parents: 44890
diff changeset
   381
    by (simp add: m_ac Int_insert_left insert_absorb Int_mono2) 
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   382
qed
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   383
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   384
lemma finprod_Un_disjoint:
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   385
  "[| finite A; finite B; A Int B = {};
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   386
      g \<in> A -> carrier G; g \<in> B -> carrier G |]
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   387
   ==> finprod G g (A Un B) = finprod G g A \<otimes> finprod G g B"
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   388
  apply (subst finprod_Un_Int [symmetric])
46721
f88b187ad8ca tuned proofs;
wenzelm
parents: 44890
diff changeset
   389
      apply auto
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   390
  done
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   391
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   392
lemma finprod_multf:
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   393
  "[| finite A; f \<in> A -> carrier G; g \<in> A -> carrier G |] ==>
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   394
   finprod G (%x. f x \<otimes> g x) A = (finprod G f A \<otimes> finprod G g A)"
22265
3c5c6bdf61de Adapted to changes in Finite_Set theory.
berghofe
parents: 20318
diff changeset
   395
proof (induct set: finite)
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   396
  case empty show ?case by simp
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   397
next
15328
35951e6a7855 mod because of change in finite set induction
nipkow
parents: 15095
diff changeset
   398
  case (insert a A) then
14750
paulson
parents: 14706
diff changeset
   399
  have fA: "f \<in> A -> carrier G" by fast
paulson
parents: 14706
diff changeset
   400
  from insert have fa: "f a \<in> carrier G" by fast
paulson
parents: 14706
diff changeset
   401
  from insert have gA: "g \<in> A -> carrier G" by fast
paulson
parents: 14706
diff changeset
   402
  from insert have ga: "g a \<in> carrier G" by fast
paulson
parents: 14706
diff changeset
   403
  from insert have fgA: "(%x. f x \<otimes> g x) \<in> A -> carrier G"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   404
    by (simp add: Pi_def)
15095
63f5f4c265dd Theories now take advantage of recent syntax improvements with (structure).
ballarin
parents: 14750
diff changeset
   405
  show ?case
63f5f4c265dd Theories now take advantage of recent syntax improvements with (structure).
ballarin
parents: 14750
diff changeset
   406
    by (simp add: insert fA fa gA ga fgA m_ac)
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   407
qed
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   408
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   409
lemma finprod_cong':
14750
paulson
parents: 14706
diff changeset
   410
  "[| A = B; g \<in> B -> carrier G;
paulson
parents: 14706
diff changeset
   411
      !!i. i \<in> B ==> f i = g i |] ==> finprod G f A = finprod G g B"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   412
proof -
14750
paulson
parents: 14706
diff changeset
   413
  assume prems: "A = B" "g \<in> B -> carrier G"
paulson
parents: 14706
diff changeset
   414
    "!!i. i \<in> B ==> f i = g i"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   415
  show ?thesis
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   416
  proof (cases "finite B")
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   417
    case True
14750
paulson
parents: 14706
diff changeset
   418
    then have "!!A. [| A = B; g \<in> B -> carrier G;
paulson
parents: 14706
diff changeset
   419
      !!i. i \<in> B ==> f i = g i |] ==> finprod G f A = finprod G g B"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   420
    proof induct
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   421
      case empty thus ?case by simp
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   422
    next
15328
35951e6a7855 mod because of change in finite set induction
nipkow
parents: 15095
diff changeset
   423
      case (insert x B)
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   424
      then have "finprod G f A = finprod G f (insert x B)" by simp
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   425
      also from insert have "... = f x \<otimes> finprod G f B"
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   426
      proof (intro finprod_insert)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32693
diff changeset
   427
        show "finite B" by fact
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   428
      next
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32693
diff changeset
   429
        show "x ~: B" by fact
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   430
      next
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32693
diff changeset
   431
        assume "x ~: B" "!!i. i \<in> insert x B \<Longrightarrow> f i = g i"
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32693
diff changeset
   432
          "g \<in> insert x B \<rightarrow> carrier G"
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 41433
diff changeset
   433
        thus "f \<in> B -> carrier G" by fastforce
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   434
      next
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32693
diff changeset
   435
        assume "x ~: B" "!!i. i \<in> insert x B \<Longrightarrow> f i = g i"
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32693
diff changeset
   436
          "g \<in> insert x B \<rightarrow> carrier G"
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 41433
diff changeset
   437
        thus "f x \<in> carrier G" by fastforce
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   438
      qed
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 41433
diff changeset
   439
      also from insert have "... = g x \<otimes> finprod G g B" by fastforce
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   440
      also from insert have "... = finprod G g (insert x B)"
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   441
      by (intro finprod_insert [THEN sym]) auto
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   442
      finally show ?case .
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   443
    qed
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   444
    with prems show ?thesis by simp
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   445
  next
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   446
    case False with prems show ?thesis by (simp add: finprod_def)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   447
  qed
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   448
qed
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   449
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   450
lemma finprod_cong:
14750
paulson
parents: 14706
diff changeset
   451
  "[| A = B; f \<in> B -> carrier G = True;
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 40786
diff changeset
   452
      !!i. i \<in> B =simp=> f i = g i |] ==> finprod G f A = finprod G g B"
14213
7bf882b0a51e Changed order of prems in finprod_cong. Slight speedup.
ballarin
parents: 13936
diff changeset
   453
  (* This order of prems is slightly faster (3%) than the last two swapped. *)
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 40786
diff changeset
   454
  by (rule finprod_cong') (auto simp add: simp_implies_def)
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   455
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   456
text {*Usually, if this rule causes a failed congruence proof error,
14750
paulson
parents: 14706
diff changeset
   457
  the reason is that the premise @{text "g \<in> B -> carrier G"} cannot be shown.
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   458
  Adding @{thm [source] Pi_def} to the simpset is often useful.
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   459
  For this reason, @{thm [source] comm_monoid.finprod_cong}
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   460
  is not added to the simpset by default.
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   461
*}
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   462
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   463
end
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   464
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   465
declare funcsetI [rule del]
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   466
  funcset_mem [rule del]
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   467
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   468
context comm_monoid begin
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   469
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   470
lemma finprod_0 [simp]:
14750
paulson
parents: 14706
diff changeset
   471
  "f \<in> {0::nat} -> carrier G ==> finprod G f {..0} = f 0"
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   472
by (simp add: Pi_def)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   473
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   474
lemma finprod_Suc [simp]:
14750
paulson
parents: 14706
diff changeset
   475
  "f \<in> {..Suc n} -> carrier G ==>
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   476
   finprod G f {..Suc n} = (f (Suc n) \<otimes> finprod G f {..n})"
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   477
by (simp add: Pi_def atMost_Suc)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   478
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   479
lemma finprod_Suc2:
14750
paulson
parents: 14706
diff changeset
   480
  "f \<in> {..Suc n} -> carrier G ==>
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   481
   finprod G f {..Suc n} = (finprod G (%i. f (Suc i)) {..n} \<otimes> f 0)"
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   482
proof (induct n)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   483
  case 0 thus ?case by (simp add: Pi_def)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   484
next
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   485
  case Suc thus ?case by (simp add: m_assoc Pi_def)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   486
qed
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   487
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   488
lemma finprod_mult [simp]:
14750
paulson
parents: 14706
diff changeset
   489
  "[| f \<in> {..n} -> carrier G; g \<in> {..n} -> carrier G |] ==>
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   490
     finprod G (%i. f i \<otimes> g i) {..n::nat} =
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   491
     finprod G f {..n} \<otimes> finprod G g {..n}"
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   492
  by (induct n) (simp_all add: m_ac Pi_def)
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   493
27699
489e3f33af0e New theorems on summation.
ballarin
parents: 23746
diff changeset
   494
(* The following two were contributed by Jeremy Avigad. *)
489e3f33af0e New theorems on summation.
ballarin
parents: 23746
diff changeset
   495
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   496
lemma finprod_reindex:
27699
489e3f33af0e New theorems on summation.
ballarin
parents: 23746
diff changeset
   497
  assumes fin: "finite A"
489e3f33af0e New theorems on summation.
ballarin
parents: 23746
diff changeset
   498
    shows "f : (h ` A) \<rightarrow> carrier G \<Longrightarrow> 
489e3f33af0e New theorems on summation.
ballarin
parents: 23746
diff changeset
   499
        inj_on h A ==> finprod G f (h ` A) = finprod G (%x. f (h x)) A"
46721
f88b187ad8ca tuned proofs;
wenzelm
parents: 44890
diff changeset
   500
  using fin
f88b187ad8ca tuned proofs;
wenzelm
parents: 44890
diff changeset
   501
  by induct (auto simp add: Pi_def)
27699
489e3f33af0e New theorems on summation.
ballarin
parents: 23746
diff changeset
   502
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   503
lemma finprod_const:
27699
489e3f33af0e New theorems on summation.
ballarin
parents: 23746
diff changeset
   504
  assumes fin [simp]: "finite A"
489e3f33af0e New theorems on summation.
ballarin
parents: 23746
diff changeset
   505
      and a [simp]: "a : carrier G"
489e3f33af0e New theorems on summation.
ballarin
parents: 23746
diff changeset
   506
    shows "finprod G (%x. a) A = a (^) card A"
489e3f33af0e New theorems on summation.
ballarin
parents: 23746
diff changeset
   507
  using fin apply induct
489e3f33af0e New theorems on summation.
ballarin
parents: 23746
diff changeset
   508
  apply force
489e3f33af0e New theorems on summation.
ballarin
parents: 23746
diff changeset
   509
  apply (subst finprod_insert)
489e3f33af0e New theorems on summation.
ballarin
parents: 23746
diff changeset
   510
  apply auto
489e3f33af0e New theorems on summation.
ballarin
parents: 23746
diff changeset
   511
  apply (subst m_comm)
489e3f33af0e New theorems on summation.
ballarin
parents: 23746
diff changeset
   512
  apply auto
46721
f88b187ad8ca tuned proofs;
wenzelm
parents: 44890
diff changeset
   513
  done
27699
489e3f33af0e New theorems on summation.
ballarin
parents: 23746
diff changeset
   514
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   515
(* The following lemma was contributed by Jesus Aransay. *)
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   516
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   517
lemma finprod_singleton:
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   518
  assumes i_in_A: "i \<in> A" and fin_A: "finite A" and f_Pi: "f \<in> A \<rightarrow> carrier G"
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   519
  shows "(\<Otimes>j\<in>A. if i = j then f j else \<one>) = f i"
29237
e90d9d51106b More porting to new locales.
ballarin
parents: 28524
diff changeset
   520
  using i_in_A finprod_insert [of "A - {i}" i "(\<lambda>j. if i = j then f j else \<one>)"]
e90d9d51106b More porting to new locales.
ballarin
parents: 28524
diff changeset
   521
    fin_A f_Pi finprod_one [of "A - {i}"]
e90d9d51106b More porting to new locales.
ballarin
parents: 28524
diff changeset
   522
    finprod_cong [of "A - {i}" "A - {i}" "(\<lambda>j. if i = j then f j else \<one>)" "(\<lambda>i. \<one>)"] 
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   523
  unfolding Pi_def simp_implies_def by (force simp add: insert_absorb)
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   524
13936
d3671b878828 Greatly extended CRing. Added Module.
ballarin
parents:
diff changeset
   525
end
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   526
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   527
end