src/HOL/Algebra/Group.thy
author ballarin
Fri, 14 Feb 2003 17:35:56 +0100
changeset 13817 7e031a968443
parent 13813 722593f2f068
child 13835 12b2ffbe543a
permissions -rw-r--r--
Product operator added --- preliminary.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
     1
(*
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
     2
  Title:  HOL/Algebra/Group.thy
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
     3
  Id:     $Id$
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
     4
  Author: Clemens Ballarin, started 4 February 2003
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
     5
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
     6
Based on work by Florian Kammueller, L C Paulson and Markus Wenzel.
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
     7
*)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
     8
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
     9
header {* Algebraic Structures up to Abelian Groups *}
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    10
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
    11
theory Group = FuncSet + FoldSet:
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    12
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    13
text {*
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    14
  Definitions follow Jacobson, Basic Algebra I, Freeman, 1985; with
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    15
  the exception of \emph{magma} which, following Bourbaki, is a set
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    16
  together with a binary, closed operation.
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    17
*}
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    18
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    19
section {* From Magmas to Groups *}
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    20
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    21
subsection {* Definitions *}
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    22
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
    23
record 'a semigroup =
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    24
  carrier :: "'a set"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    25
  mult :: "['a, 'a] => 'a" (infixl "\<otimes>\<index>" 70)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    26
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
    27
record 'a monoid = "'a semigroup" +
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    28
  one :: 'a ("\<one>\<index>")
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
    29
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
    30
record 'a group = "'a monoid" +
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    31
  m_inv :: "'a => 'a" ("inv\<index> _" [81] 80)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    32
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    33
locale magma = struct G +
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    34
  assumes m_closed [intro, simp]:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    35
    "[| x \<in> carrier G; y \<in> carrier G |] ==> x \<otimes> y \<in> carrier G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    36
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    37
locale semigroup = magma +
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    38
  assumes m_assoc:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    39
    "[| x \<in> carrier G; y \<in> carrier G; z \<in> carrier G |] ==>
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    40
     (x \<otimes> y) \<otimes> z = x \<otimes> (y \<otimes> z)"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    41
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
    42
locale l_one = struct G +
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    43
  assumes one_closed [intro, simp]: "\<one> \<in> carrier G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    44
    and l_one [simp]: "x \<in> carrier G ==> \<one> \<otimes> x = x"
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
    45
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
    46
locale group = semigroup + l_one +
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
    47
  assumes inv_closed [intro, simp]: "x \<in> carrier G ==> inv x \<in> carrier G"
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    48
    and l_inv: "x \<in> carrier G ==> inv x \<otimes> x = \<one>"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    49
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    50
subsection {* Cancellation Laws and Basic Properties *}
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    51
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    52
lemma (in group) l_cancel [simp]:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    53
  "[| x \<in> carrier G; y \<in> carrier G; z \<in> carrier G |] ==>
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    54
   (x \<otimes> y = x \<otimes> z) = (y = z)"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    55
proof
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    56
  assume eq: "x \<otimes> y = x \<otimes> z"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    57
    and G: "x \<in> carrier G" "y \<in> carrier G" "z \<in> carrier G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    58
  then have "(inv x \<otimes> x) \<otimes> y = (inv x \<otimes> x) \<otimes> z" by (simp add: m_assoc)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    59
  with G show "y = z" by (simp add: l_inv)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    60
next
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    61
  assume eq: "y = z"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    62
    and G: "x \<in> carrier G" "y \<in> carrier G" "z \<in> carrier G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    63
  then show "x \<otimes> y = x \<otimes> z" by simp
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    64
qed
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    65
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    66
lemma (in group) r_one [simp]:  
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    67
  "x \<in> carrier G ==> x \<otimes> \<one> = x"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    68
proof -
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    69
  assume x: "x \<in> carrier G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    70
  then have "inv x \<otimes> (x \<otimes> \<one>) = inv x \<otimes> x"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    71
    by (simp add: m_assoc [symmetric] l_inv)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    72
  with x show ?thesis by simp 
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    73
qed
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    74
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    75
lemma (in group) r_inv:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    76
  "x \<in> carrier G ==> x \<otimes> inv x = \<one>"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    77
proof -
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    78
  assume x: "x \<in> carrier G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    79
  then have "inv x \<otimes> (x \<otimes> inv x) = inv x \<otimes> \<one>"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    80
    by (simp add: m_assoc [symmetric] l_inv)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    81
  with x show ?thesis by (simp del: r_one)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    82
qed
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    83
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    84
lemma (in group) r_cancel [simp]:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    85
  "[| x \<in> carrier G; y \<in> carrier G; z \<in> carrier G |] ==>
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    86
   (y \<otimes> x = z \<otimes> x) = (y = z)"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    87
proof
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    88
  assume eq: "y \<otimes> x = z \<otimes> x"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    89
    and G: "x \<in> carrier G" "y \<in> carrier G" "z \<in> carrier G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    90
  then have "y \<otimes> (x \<otimes> inv x) = z \<otimes> (x \<otimes> inv x)"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    91
    by (simp add: m_assoc [symmetric])
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    92
  with G show "y = z" by (simp add: r_inv)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    93
next
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    94
  assume eq: "y = z"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    95
    and G: "x \<in> carrier G" "y \<in> carrier G" "z \<in> carrier G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    96
  then show "y \<otimes> x = z \<otimes> x" by simp
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    97
qed
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    98
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
    99
lemma (in group) inv_inv [simp]:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   100
  "x \<in> carrier G ==> inv (inv x) = x"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   101
proof -
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   102
  assume x: "x \<in> carrier G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   103
  then have "inv x \<otimes> inv (inv x) = inv x \<otimes> x" by (simp add: l_inv r_inv)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   104
  with x show ?thesis by simp
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   105
qed
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   106
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   107
lemma (in group) inv_mult:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   108
  "[| x \<in> carrier G; y \<in> carrier G |] ==> inv (x \<otimes> y) = inv y \<otimes> inv x"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   109
proof -
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   110
  assume G: "x \<in> carrier G" "y \<in> carrier G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   111
  then have "inv (x \<otimes> y) \<otimes> (x \<otimes> y) = (inv y \<otimes> inv x) \<otimes> (x \<otimes> y)"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   112
    by (simp add: m_assoc l_inv) (simp add: m_assoc [symmetric] l_inv)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   113
  with G show ?thesis by simp
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   114
qed
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   115
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   116
subsection {* Substructures *}
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   117
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   118
locale submagma = var H + struct G +
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   119
  assumes subset [intro, simp]: "H \<subseteq> carrier G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   120
    and m_closed [intro, simp]: "[| x \<in> H; y \<in> H |] ==> x \<otimes> y \<in> H"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   121
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   122
declare (in submagma) magma.intro [intro] semigroup.intro [intro]
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   123
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   124
(*
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   125
alternative definition of submagma
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   126
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   127
locale submagma = var H + struct G +
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   128
  assumes subset [intro, simp]: "carrier H \<subseteq> carrier G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   129
    and m_equal [simp]: "mult H = mult G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   130
    and m_closed [intro, simp]:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   131
      "[| x \<in> carrier H; y \<in> carrier H |] ==> x \<otimes> y \<in> carrier H"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   132
*)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   133
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   134
lemma submagma_imp_subset:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   135
  "submagma H G ==> H \<subseteq> carrier G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   136
  by (rule submagma.subset)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   137
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   138
lemma (in submagma) subsetD [dest, simp]:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   139
  "x \<in> H ==> x \<in> carrier G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   140
  using subset by blast
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   141
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   142
lemma (in submagma) magmaI [intro]:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   143
  includes magma G
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   144
  shows "magma (G(| carrier := H |))"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   145
  by rule simp
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   146
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   147
lemma (in submagma) semigroup_axiomsI [intro]:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   148
  includes semigroup G
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   149
  shows "semigroup_axioms (G(| carrier := H |))"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   150
    by rule (simp add: m_assoc)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   151
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   152
lemma (in submagma) semigroupI [intro]:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   153
  includes semigroup G
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   154
  shows "semigroup (G(| carrier := H |))"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   155
  using prems by fast
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   156
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   157
locale subgroup = submagma H G +
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   158
  assumes one_closed [intro, simp]: "\<one> \<in> H"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   159
    and m_inv_closed [intro, simp]: "x \<in> H ==> inv x \<in> H"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   160
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   161
declare (in subgroup) group.intro [intro]
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   162
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   163
lemma (in subgroup) l_oneI [intro]:
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   164
  includes l_one G
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   165
  shows "l_one (G(| carrier := H |))"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   166
  by rule simp_all
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   167
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   168
lemma (in subgroup) group_axiomsI [intro]:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   169
  includes group G
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   170
  shows "group_axioms (G(| carrier := H |))"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   171
  by rule (simp_all add: l_inv)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   172
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   173
lemma (in subgroup) groupI [intro]:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   174
  includes group G
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   175
  shows "group (G(| carrier := H |))"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   176
  using prems by fast
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   177
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   178
text {*
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   179
  Since @{term H} is nonempty, it contains some element @{term x}.  Since
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   180
  it is closed under inverse, it contains @{text "inv x"}.  Since
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   181
  it is closed under product, it contains @{text "x \<otimes> inv x = \<one>"}.
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   182
*}
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   183
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   184
lemma (in group) one_in_subset:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   185
  "[| H \<subseteq> carrier G; H \<noteq> {}; \<forall>a \<in> H. inv a \<in> H; \<forall>a\<in>H. \<forall>b\<in>H. a \<otimes> b \<in> H |]
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   186
   ==> \<one> \<in> H"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   187
by (force simp add: l_inv)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   188
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   189
text {* A characterization of subgroups: closed, non-empty subset. *}
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   190
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   191
lemma (in group) subgroupI:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   192
  assumes subset: "H \<subseteq> carrier G" and non_empty: "H \<noteq> {}"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   193
    and inv: "!!a. a \<in> H ==> inv a \<in> H"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   194
    and mult: "!!a b. [|a \<in> H; b \<in> H|] ==> a \<otimes> b \<in> H"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   195
  shows "subgroup H G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   196
proof
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   197
  from subset and mult show "submagma H G" ..
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   198
next
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   199
  have "\<one> \<in> H" by (rule one_in_subset) (auto simp only: prems)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   200
  with inv show "subgroup_axioms H G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   201
    by (intro subgroup_axioms.intro) simp_all
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   202
qed
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   203
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   204
text {*
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   205
  Repeat facts of submagmas for subgroups.  Necessary???
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   206
*}
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   207
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   208
lemma (in subgroup) subset:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   209
  "H \<subseteq> carrier G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   210
  ..
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   211
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   212
lemma (in subgroup) m_closed:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   213
  "[| x \<in> H; y \<in> H |] ==> x \<otimes> y \<in> H"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   214
  ..
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   215
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   216
declare magma.m_closed [simp]
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   217
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   218
declare l_one.one_closed [iff] group.inv_closed [simp]
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   219
  l_one.l_one [simp] group.r_one [simp] group.inv_inv [simp]
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   220
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   221
lemma subgroup_nonempty:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   222
  "~ subgroup {} G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   223
  by (blast dest: subgroup.one_closed)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   224
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   225
lemma (in subgroup) finite_imp_card_positive:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   226
  "finite (carrier G) ==> 0 < card H"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   227
proof (rule classical)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   228
  have sub: "subgroup H G" using prems ..
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   229
  assume fin: "finite (carrier G)"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   230
    and zero: "~ 0 < card H"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   231
  then have "finite H" by (blast intro: finite_subset dest: subset)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   232
  with zero sub have "subgroup {} G" by simp
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   233
  with subgroup_nonempty show ?thesis by contradiction
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   234
qed
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   235
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   236
subsection {* Direct Products *}
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   237
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   238
constdefs
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   239
  DirProdSemigroup ::
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   240
    "[('a, 'c) semigroup_scheme, ('b, 'd) semigroup_scheme]
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   241
    => ('a \<times> 'b) semigroup"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   242
    (infixr "\<times>\<^sub>s" 80)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   243
  "G \<times>\<^sub>s H == (| carrier = carrier G \<times> carrier H,
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   244
    mult = (%(xg, xh) (yg, yh). (mult G xg yg, mult H xh yh)) |)"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   245
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   246
  DirProdMonoid ::
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   247
    "[('a, 'c) monoid_scheme, ('b, 'd) monoid_scheme] => ('a \<times> 'b) monoid"
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   248
    (infixr "\<times>\<^sub>m" 80)
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   249
  "G \<times>\<^sub>m H == (| carrier = carrier (G \<times>\<^sub>s H),
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   250
    mult = mult (G \<times>\<^sub>s H),
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   251
    one = (one G, one H) |)"
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   252
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   253
  DirProdGroup ::
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   254
    "[('a, 'c) group_scheme, ('b, 'd) group_scheme] => ('a \<times> 'b) group"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   255
    (infixr "\<times>\<^sub>g" 80)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   256
  "G \<times>\<^sub>g H == (| carrier = carrier (G \<times>\<^sub>m H),
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   257
    mult = mult (G \<times>\<^sub>m H),
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   258
    one = one (G \<times>\<^sub>m H),
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   259
    m_inv = (%(g, h). (m_inv G g, m_inv H h)) |)"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   260
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   261
lemma DirProdSemigroup_magma:
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   262
  includes magma G + magma H
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   263
  shows "magma (G \<times>\<^sub>s H)"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   264
  by rule (auto simp add: DirProdSemigroup_def)
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   265
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   266
lemma DirProdSemigroup_semigroup_axioms:
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   267
  includes semigroup G + semigroup H
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   268
  shows "semigroup_axioms (G \<times>\<^sub>s H)"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   269
  by rule (auto simp add: DirProdSemigroup_def G.m_assoc H.m_assoc)
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   270
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   271
lemma DirProdSemigroup_semigroup:
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   272
  includes semigroup G + semigroup H
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   273
  shows "semigroup (G \<times>\<^sub>s H)"
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   274
  using prems
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   275
  by (fast intro: semigroup.intro
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   276
    DirProdSemigroup_magma DirProdSemigroup_semigroup_axioms)
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   277
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   278
lemma DirProdGroup_magma:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   279
  includes magma G + magma H
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   280
  shows "magma (G \<times>\<^sub>g H)"
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   281
  by rule
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   282
    (auto simp add: DirProdGroup_def DirProdMonoid_def DirProdSemigroup_def)
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   283
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   284
lemma DirProdGroup_semigroup_axioms:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   285
  includes semigroup G + semigroup H
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   286
  shows "semigroup_axioms (G \<times>\<^sub>g H)"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   287
  by rule
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   288
    (auto simp add: DirProdGroup_def DirProdMonoid_def DirProdSemigroup_def
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   289
      G.m_assoc H.m_assoc)
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   290
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   291
lemma DirProdGroup_semigroup:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   292
  includes semigroup G + semigroup H
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   293
  shows "semigroup (G \<times>\<^sub>g H)"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   294
  using prems
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   295
  by (fast intro: semigroup.intro
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   296
    DirProdGroup_magma DirProdGroup_semigroup_axioms)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   297
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   298
(* ... and further lemmas for group ... *)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   299
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   300
lemma DirProdGroup_group:
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   301
  includes group G + group H
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   302
  shows "group (G \<times>\<^sub>g H)"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   303
by rule
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   304
  (auto intro: magma.intro l_one.intro
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   305
      semigroup_axioms.intro group_axioms.intro
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   306
    simp add: DirProdGroup_def DirProdMonoid_def DirProdSemigroup_def
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   307
      G.m_assoc H.m_assoc G.l_inv H.l_inv)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   308
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   309
subsection {* Homomorphisms *}
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   310
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   311
constdefs
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   312
  hom :: "[('a, 'c) semigroup_scheme, ('b, 'd) semigroup_scheme]
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   313
    => ('a => 'b)set"
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   314
  "hom G H ==
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   315
    {h. h \<in> carrier G -> carrier H &
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   316
      (\<forall>x \<in> carrier G. \<forall>y \<in> carrier G. h (mult G x y) = mult H (h x) (h y))}"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   317
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   318
lemma (in semigroup) hom:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   319
  includes semigroup G
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   320
  shows "semigroup (| carrier = hom G G, mult = op o |)"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   321
proof
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   322
  show "magma (| carrier = hom G G, mult = op o |)"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   323
    by rule (simp add: Pi_def hom_def)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   324
next
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   325
  show "semigroup_axioms (| carrier = hom G G, mult = op o |)"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   326
    by rule (simp add: o_assoc)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   327
qed
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   328
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   329
lemma hom_mult:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   330
  "[| h \<in> hom G H; x \<in> carrier G; y \<in> carrier G |] 
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   331
   ==> h (mult G x y) = mult H (h x) (h y)"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   332
  by (simp add: hom_def) 
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   333
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   334
lemma hom_closed:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   335
  "[| h \<in> hom G H; x \<in> carrier G |] ==> h x \<in> carrier H"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   336
  by (auto simp add: hom_def funcset_mem)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   337
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   338
locale group_hom = group G + group H + var h +
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   339
  assumes homh: "h \<in> hom G H"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   340
  notes hom_mult [simp] = hom_mult [OF homh]
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   341
    and hom_closed [simp] = hom_closed [OF homh]
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   342
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   343
lemma (in group_hom) one_closed [simp]:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   344
  "h \<one> \<in> carrier H"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   345
  by simp
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   346
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   347
lemma (in group_hom) hom_one [simp]:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   348
  "h \<one> = \<one>\<^sub>2"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   349
proof -
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   350
  have "h \<one> \<otimes>\<^sub>2 \<one>\<^sub>2 = h \<one> \<otimes>\<^sub>2 h \<one>"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   351
    by (simp add: hom_mult [symmetric] del: hom_mult)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   352
  then show ?thesis by (simp del: r_one)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   353
qed
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   354
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   355
lemma (in group_hom) inv_closed [simp]:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   356
  "x \<in> carrier G ==> h (inv x) \<in> carrier H"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   357
  by simp
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   358
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   359
lemma (in group_hom) hom_inv [simp]:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   360
  "x \<in> carrier G ==> h (inv x) = inv\<^sub>2 (h x)"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   361
proof -
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   362
  assume x: "x \<in> carrier G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   363
  then have "h x \<otimes>\<^sub>2 h (inv x) = \<one>\<^sub>2"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   364
    by (simp add: hom_mult [symmetric] G.r_inv del: hom_mult)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   365
  also from x have "... = h x \<otimes>\<^sub>2 inv\<^sub>2 (h x)"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   366
    by (simp add: hom_mult [symmetric] H.r_inv del: hom_mult)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   367
  finally have "h x \<otimes>\<^sub>2 h (inv x) = h x \<otimes>\<^sub>2 inv\<^sub>2 (h x)" .
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   368
  with x show ?thesis by simp
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   369
qed
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   370
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   371
section {* Abelian Structures *}
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   372
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   373
subsection {* Definition *}
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   374
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   375
locale abelian_semigroup = semigroup +
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   376
  assumes m_comm: "[| x \<in> carrier G; y \<in> carrier G |] ==> x \<otimes> y = y \<otimes> x"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   377
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   378
lemma (in abelian_semigroup) m_lcomm:
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   379
  "[| x \<in> carrier G; y \<in> carrier G; z \<in> carrier G |] ==>
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   380
   x \<otimes> (y \<otimes> z) = y \<otimes> (x \<otimes> z)"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   381
proof -
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   382
  assume xyz: "x \<in> carrier G" "y \<in> carrier G" "z \<in> carrier G"
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   383
  from xyz have "x \<otimes> (y \<otimes> z) = (x \<otimes> y) \<otimes> z" by (simp add: m_assoc)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   384
  also from xyz have "... = (y \<otimes> x) \<otimes> z" by (simp add: m_comm)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   385
  also from xyz have "... = y \<otimes> (x \<otimes> z)" by (simp add: m_assoc)
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   386
  finally show ?thesis .
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   387
qed
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   388
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   389
lemmas (in abelian_semigroup) ac = m_assoc m_comm m_lcomm
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   390
13817
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   391
locale abelian_monoid = abelian_semigroup + l_one
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   392
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   393
lemma (in abelian_monoid) l_one [simp]:
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   394
  "x \<in> carrier G ==> x \<otimes> \<one> = x"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   395
proof -
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   396
  assume G: "x \<in> carrier G"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   397
  then have "x \<otimes> \<one> = \<one> \<otimes> x" by (simp add: m_comm)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   398
  also from G have "... = x" by simp
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   399
  finally show ?thesis .
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   400
qed
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   401
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   402
locale abelian_group = abelian_monoid + group
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   403
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   404
subsection {* Products over Finite Sets *}
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   405
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   406
locale finite_prod = abelian_monoid + var prod +
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   407
  defines "prod == (%f A. if finite A
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   408
      then foldD (carrier G) (op \<otimes> o f) \<one> A
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   409
      else arbitrary)"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   410
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   411
(* TODO: nice syntax for the summation operator inside the locale
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   412
   like \<Otimes>\<index> i\<in>A. f i, probably needs hand-coded translation *)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   413
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   414
ML_setup {* 
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   415
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   416
Context.>> (fn thy => (simpset_ref_of thy :=
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   417
  simpset_of thy setsubgoaler asm_full_simp_tac; thy)) *}
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   418
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   419
lemma (in finite_prod) prod_empty [simp]: 
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   420
  "prod f {} = \<one>"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   421
  by (simp add: prod_def)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   422
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   423
ML_setup {* 
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   424
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   425
Context.>> (fn thy => (simpset_ref_of thy :=
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   426
  simpset_of thy setsubgoaler asm_simp_tac; thy)) *}
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   427
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   428
declare funcsetI [intro]
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   429
  funcset_mem [dest]
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   430
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   431
lemma (in finite_prod) prod_insert [simp]:
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   432
  "[| finite F; a \<notin> F; f \<in> F -> carrier G; f a \<in> carrier G |] ==>
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   433
   prod f (insert a F) = f a \<otimes> prod f F"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   434
  apply (rule trans)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   435
  apply (simp add: prod_def)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   436
  apply (rule trans)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   437
  apply (rule LCD.foldD_insert [OF LCD.intro [of "insert a F"]])
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   438
    apply simp
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   439
    apply (rule m_lcomm)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   440
      apply fast apply fast apply assumption
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   441
    apply (fastsimp intro: m_closed)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   442
    apply simp+ apply fast
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   443
  apply (auto simp add: prod_def)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   444
  done
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   445
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   446
lemma (in finite_prod) prod_one:
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   447
  "finite A ==> prod (%i. \<one>) A = \<one>"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   448
proof (induct set: Finites)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   449
  case empty show ?case by simp
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   450
next
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   451
  case (insert A a)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   452
  have "(%i. \<one>) \<in> A -> carrier G" by auto
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   453
  with insert show ?case by simp
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   454
qed
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   455
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   456
(*
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   457
lemma prod_eq_0_iff [simp]:
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   458
    "finite F ==> (prod f F = 0) = (ALL a:F. f a = (0::nat))"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   459
  by (induct set: Finites) auto
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   460
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   461
lemma prod_SucD: "prod f A = Suc n ==> EX a:A. 0 < f a"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   462
  apply (case_tac "finite A")
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   463
   prefer 2 apply (simp add: prod_def)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   464
  apply (erule rev_mp)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   465
  apply (erule finite_induct)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   466
   apply auto
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   467
  done
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   468
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   469
lemma card_eq_prod: "finite A ==> card A = prod (\<lambda>x. 1) A"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   470
*)  -- {* Could allow many @{text "card"} proofs to be simplified. *}
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   471
(*
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   472
  by (induct set: Finites) auto
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   473
*)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   474
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   475
lemma (in finite_prod) prod_closed:
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   476
  fixes A
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   477
  assumes fin: "finite A" and f: "f \<in> A -> carrier G" 
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   478
  shows "prod f A \<in> carrier G"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   479
using fin f
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   480
proof induct
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   481
  case empty show ?case by simp
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   482
next
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   483
  case (insert A a)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   484
  then have a: "f a \<in> carrier G" by fast
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   485
  from insert have A: "f \<in> A -> carrier G" by fast
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   486
  from insert A a show ?case by simp
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   487
qed
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   488
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   489
lemma funcset_Int_left [simp, intro]:
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   490
  "[| f \<in> A -> C; f \<in> B -> C |] ==> f \<in> A Int B -> C"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   491
  by fast
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   492
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   493
lemma funcset_Un_left [iff]:
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   494
  "(f \<in> A Un B -> C) = (f \<in> A -> C & f \<in> B -> C)"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   495
  by fast
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   496
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   497
lemma (in finite_prod) prod_Un_Int:
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   498
  "[| finite A; finite B; g \<in> A -> carrier G; g \<in> B -> carrier G |] ==>
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   499
   prod g (A Un B) \<otimes> prod g (A Int B) = prod g A \<otimes> prod g B"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   500
  -- {* The reversed orientation looks more natural, but LOOPS as a simprule! *}
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   501
proof (induct set: Finites)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   502
  case empty then show ?case by (simp add: prod_closed)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   503
next
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   504
  case (insert A a)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   505
  then have a: "g a \<in> carrier G" by fast
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   506
  from insert have A: "g \<in> A -> carrier G" by fast
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   507
  from insert A a show ?case
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   508
    by (simp add: ac Int_insert_left insert_absorb prod_closed
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   509
          Int_mono2 Un_subset_iff) 
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   510
qed
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   511
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   512
lemma (in finite_prod) prod_Un_disjoint:
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   513
  "[| finite A; finite B; A Int B = {};
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   514
      g \<in> A -> carrier G; g \<in> B -> carrier G |]
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   515
   ==> prod g (A Un B) = prod g A \<otimes> prod g B"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   516
  apply (subst prod_Un_Int [symmetric])
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   517
    apply (auto simp add: prod_closed)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   518
  done
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   519
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   520
(*
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   521
lemma prod_UN_disjoint:
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   522
  fixes f :: "'a => 'b::plus_ac0"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   523
  shows
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   524
    "finite I ==> (ALL i:I. finite (A i)) ==>
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   525
        (ALL i:I. ALL j:I. i \<noteq> j --> A i Int A j = {}) ==>
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   526
      prod f (UNION I A) = prod (\<lambda>i. prod f (A i)) I"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   527
  apply (induct set: Finites)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   528
   apply simp
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   529
  apply atomize
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   530
  apply (subgoal_tac "ALL i:F. x \<noteq> i")
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   531
   prefer 2 apply blast
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   532
  apply (subgoal_tac "A x Int UNION F A = {}")
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   533
   prefer 2 apply blast
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   534
  apply (simp add: prod_Un_disjoint)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   535
  done
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   536
*)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   537
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   538
lemma (in finite_prod) prod_addf:
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   539
  "[| finite A; f \<in> A -> carrier G; g \<in> A -> carrier G |] ==>
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   540
   prod (%x. f x \<otimes> g x) A = (prod f A \<otimes> prod g A)"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   541
proof (induct set: Finites)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   542
  case empty show ?case by simp
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   543
next
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   544
  case (insert A a) then
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   545
  have fA: "f : A -> carrier G" by fast
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   546
  from insert have fa: "f a : carrier G" by fast
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   547
  from insert have gA: "g : A -> carrier G" by fast
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   548
  from insert have ga: "g a : carrier G" by fast
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   549
  from insert have fga: "(%x. f x \<otimes> g x) a : carrier G" by (simp add: Pi_def)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   550
  from insert have fgA: "(%x. f x \<otimes> g x) : A -> carrier G"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   551
    by (simp add: Pi_def)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   552
  show ?case  (* check if all simps are really necessary *)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   553
    by (simp add: insert fA fa gA ga fgA fga ac prod_closed Int_insert_left insert_absorb Int_mono2 Un_subset_iff)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   554
qed
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   555
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   556
(*
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   557
lemma prod_Un: "finite A ==> finite B ==>
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   558
    (prod f (A Un B) :: nat) = prod f A + prod f B - prod f (A Int B)"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   559
  -- {* For the natural numbers, we have subtraction. *}
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   560
  apply (subst prod_Un_Int [symmetric])
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   561
    apply auto
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   562
  done
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   563
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   564
lemma prod_diff1: "(prod f (A - {a}) :: nat) =
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   565
    (if a:A then prod f A - f a else prod f A)"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   566
  apply (case_tac "finite A")
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   567
   prefer 2 apply (simp add: prod_def)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   568
  apply (erule finite_induct)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   569
   apply (auto simp add: insert_Diff_if)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   570
  apply (drule_tac a = a in mk_disjoint_insert)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   571
  apply auto
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   572
  done
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   573
*)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   574
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   575
lemma (in finite_prod) prod_cong:
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   576
  "[| A = B; g : B -> carrier G;
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   577
      !!i. i : B ==> f i = g i |] ==> prod f A = prod g B"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   578
proof -
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   579
  assume prems: "A = B" "g : B -> carrier G"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   580
    "!!i. i : B ==> f i = g i"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   581
  show ?thesis
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   582
  proof (cases "finite B")
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   583
    case True
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   584
    then have "!!A. [| A = B; g : B -> carrier G;
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   585
      !!i. i : B ==> f i = g i |] ==> prod f A = prod g B"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   586
    proof induct
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   587
      case empty thus ?case by simp
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   588
    next
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   589
      case (insert B x)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   590
      then have "prod f A = prod f (insert x B)" by simp
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   591
      also from insert have "... = f x \<otimes> prod f B"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   592
      proof (intro prod_insert)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   593
	show "finite B" .
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   594
      next
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   595
	show "x ~: B" .
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   596
      next
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   597
	assume "x ~: B" "!!i. i \<in> insert x B \<Longrightarrow> f i = g i"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   598
	  "g \<in> insert x B \<rightarrow> carrier G"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   599
	thus "f : B -> carrier G" by fastsimp
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   600
      next
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   601
	assume "x ~: B" "!!i. i \<in> insert x B \<Longrightarrow> f i = g i"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   602
	  "g \<in> insert x B \<rightarrow> carrier G"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   603
	thus "f x \<in> carrier G" by fastsimp
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   604
      qed
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   605
      also from insert have "... = g x \<otimes> prod g B" by fastsimp
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   606
      also from insert have "... = prod g (insert x B)"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   607
      by (intro prod_insert [THEN sym]) auto
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   608
      finally show ?case .
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   609
    qed
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   610
    with prems show ?thesis by simp
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   611
  next
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   612
    case False with prems show ?thesis by (simp add: prod_def)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   613
  qed
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   614
qed
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   615
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   616
lemma (in finite_prod) prod_cong1 [cong]:
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   617
  "[| A = B; !!i. i : B ==> f i = g i;
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   618
      g : B -> carrier G = True |] ==> prod f A = prod g B"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   619
  by (rule prod_cong) fast+
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   620
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   621
text {*Usually, if this rule causes a failed congruence proof error,
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   622
   the reason is that the premise @{text "g : B -> carrier G"} cannot be shown.
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   623
   Adding @{thm [source] Pi_def} to the simpset is often useful. *}
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   624
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   625
declare funcsetI [rule del]
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   626
  funcset_mem [rule del]
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   627
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   628
subsection {* Summation over the integer interval @{term "{..n}"} *}
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   629
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   630
text {*
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   631
  For technical reasons (locales) a new locale where the index set is
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   632
  restricted to @{term "nat"} is necessary.
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   633
*}
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   634
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   635
locale finite_prod_nat = finite_prod +
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   636
  assumes "False ==> prod f (A::nat set) = prod f A"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   637
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   638
lemma (in finite_prod_nat) natSum_0 [simp]:
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   639
  "f : {0::nat} -> carrier G ==> prod f {..0} = f 0"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   640
by (simp add: Pi_def)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   641
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   642
lemma (in finite_prod_nat) natsum_Suc [simp]:
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   643
  "f : {..Suc n} -> carrier G ==>
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   644
   prod f {..Suc n} = (f (Suc n) \<otimes> prod f {..n})"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   645
by (simp add: Pi_def atMost_Suc)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   646
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   647
lemma (in finite_prod_nat) natsum_Suc2:
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   648
  "f : {..Suc n} -> carrier G ==>
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   649
   prod f {..Suc n} = (prod (%i. f (Suc i)) {..n} \<otimes> f 0)"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   650
proof (induct n)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   651
  case 0 thus ?case by (simp add: Pi_def)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   652
next
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   653
  case Suc thus ?case by (simp add: m_assoc Pi_def prod_closed)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   654
qed
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   655
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   656
lemma (in finite_prod_nat) natsum_zero [simp]:
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   657
  "prod (%i. \<one>) {..n::nat} = \<one>"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   658
by (induct n) (simp_all add: Pi_def)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   659
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   660
lemma (in finite_prod_nat) natsum_add [simp]:
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   661
  "[| f : {..n} -> carrier G; g : {..n} -> carrier G |] ==>
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   662
   prod (%i. f i \<otimes> g i) {..n::nat} = prod f {..n} \<otimes> prod g {..n}"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   663
by (induct n) (simp_all add: ac Pi_def prod_closed)
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   664
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   665
thm setsum_cong
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   666
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   667
ML_setup {* 
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   668
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   669
Context.>> (fn thy => (simpset_ref_of thy :=
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   670
  simpset_of thy setsubgoaler asm_full_simp_tac; thy)) *}
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   671
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   672
lemma "(\<Sum>i\<in>{..10::nat}. if i<=10 then 0 else 1) = (0::nat)"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   673
apply simp done
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   674
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   675
lemma (in finite_prod_nat) "prod (%i. if i<=10 then \<one> else x) {..10} = \<one>"
7e031a968443 Product operator added --- preliminary.
ballarin
parents: 13813
diff changeset
   676
apply (simp add: Pi_def)
13813
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   677
722593f2f068 New development of algebra: Groups.
ballarin
parents:
diff changeset
   678
end