src/HOL/Library/Groups_Big_Fun.thy
author haftmann
Sat, 14 Nov 2015 08:45:52 +0100
changeset 61671 20d4cd2ceab2
parent 61670 301e0b4ecd45
child 61776 57bb7da5c867
permissions -rw-r--r--
prefer "rewrites" and "defines" to note rewrite morphisms
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
     1
(* Author: Florian Haftmann, TU Muenchen *)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
     2
58881
b9556a055632 modernized header;
wenzelm
parents: 58437
diff changeset
     3
section \<open>Big sum and product over function bodies\<close>
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
     4
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
     5
theory Groups_Big_Fun
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
     6
imports
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
     7
  Main
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
     8
begin
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
     9
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    10
subsection \<open>Abstract product\<close>
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    11
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    12
no_notation times (infixl "*" 70)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    13
no_notation Groups.one ("1")
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    14
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    15
locale comm_monoid_fun = comm_monoid
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    16
begin
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    17
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    18
definition G :: "('b \<Rightarrow> 'a) \<Rightarrow> 'a"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    19
where
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    20
  expand_set: "G g = comm_monoid_set.F f 1 g {a. g a \<noteq> 1}"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    21
61605
1bf7b186542e qualifier is mandatory by default;
wenzelm
parents: 61424
diff changeset
    22
interpretation F: comm_monoid_set f 1
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    23
  ..
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    24
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    25
lemma expand_superset:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    26
  assumes "finite A" and "{a. g a \<noteq> 1} \<subseteq> A"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    27
  shows "G g = F.F g A"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    28
  apply (simp add: expand_set)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    29
  apply (rule F.same_carrierI [of A])
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    30
  apply (simp_all add: assms)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    31
  done
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    32
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    33
lemma conditionalize:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    34
  assumes "finite A"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    35
  shows "F.F g A = G (\<lambda>a. if a \<in> A then g a else 1)"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    36
  using assms
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    37
  apply (simp add: expand_set)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    38
  apply (rule F.same_carrierI [of A])
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    39
  apply auto
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    40
  done
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    41
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    42
lemma neutral [simp]:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    43
  "G (\<lambda>a. 1) = 1"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    44
  by (simp add: expand_set)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    45
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    46
lemma update [simp]:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    47
  assumes "finite {a. g a \<noteq> 1}"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    48
  assumes "g a = 1"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    49
  shows "G (g(a := b)) = b * G g"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    50
proof (cases "b = 1")
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
    51
  case True with \<open>g a = 1\<close> show ?thesis
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    52
    by (simp add: expand_set) (rule F.cong, auto)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    53
next
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    54
  case False
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    55
  moreover have "{a'. a' \<noteq> a \<longrightarrow> g a' \<noteq> 1} = insert a {a. g a \<noteq> 1}"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    56
    by auto
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
    57
  moreover from \<open>g a = 1\<close> have "a \<notin> {a. g a \<noteq> 1}"
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    58
    by simp
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    59
  moreover have "F.F (\<lambda>a'. if a' = a then b else g a') {a. g a \<noteq> 1} = F.F g {a. g a \<noteq> 1}"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
    60
    by (rule F.cong) (auto simp add: \<open>g a = 1\<close>)
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
    61
  ultimately show ?thesis using \<open>finite {a. g a \<noteq> 1}\<close> by (simp add: expand_set)
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    62
qed
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    63
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    64
lemma infinite [simp]:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    65
  "\<not> finite {a. g a \<noteq> 1} \<Longrightarrow> G g = 1"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    66
  by (simp add: expand_set)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    67
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    68
lemma cong:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    69
  assumes "\<And>a. g a = h a"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    70
  shows "G g = G h"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    71
  using assms by (simp add: expand_set)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    72
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    73
lemma strong_cong [cong]:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    74
  assumes "\<And>a. g a = h a"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    75
  shows "G (\<lambda>a. g a) = G (\<lambda>a. h a)"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    76
  using assms by (fact cong)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    77
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    78
lemma not_neutral_obtains_not_neutral:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    79
  assumes "G g \<noteq> 1"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    80
  obtains a where "g a \<noteq> 1"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    81
  using assms by (auto elim: F.not_neutral_contains_not_neutral simp add: expand_set)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    82
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    83
lemma reindex_cong:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    84
  assumes "bij l"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    85
  assumes "g \<circ> l = h"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    86
  shows "G g = G h"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    87
proof -
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    88
  from assms have unfold: "h = g \<circ> l" by simp
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
    89
  from \<open>bij l\<close> have "inj l" by (rule bij_is_inj)
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    90
  then have "inj_on l {a. h a \<noteq> 1}" by (rule subset_inj_on) simp
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
    91
  moreover from \<open>bij l\<close> have "{a. g a \<noteq> 1} = l ` {a. h a \<noteq> 1}"
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    92
    by (auto simp add: image_Collect unfold elim: bij_pointE)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    93
  moreover have "\<And>x. x \<in> {a. h a \<noteq> 1} \<Longrightarrow> g (l x) = h x"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    94
    by (simp add: unfold)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    95
  ultimately have "F.F g {a. g a \<noteq> 1} = F.F h {a. h a \<noteq> 1}"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    96
    by (rule F.reindex_cong)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    97
  then show ?thesis by (simp add: expand_set)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    98
qed
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
    99
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   100
lemma distrib:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   101
  assumes "finite {a. g a \<noteq> 1}" and "finite {a. h a \<noteq> 1}"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   102
  shows "G (\<lambda>a. g a * h a) = G g * G h"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   103
proof -
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   104
  from assms have "finite ({a. g a \<noteq> 1} \<union> {a. h a \<noteq> 1})" by simp
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   105
  moreover have "{a. g a * h a \<noteq> 1} \<subseteq> {a. g a \<noteq> 1} \<union> {a. h a \<noteq> 1}"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   106
    by auto (drule sym, simp)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   107
  ultimately show ?thesis
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   108
    using assms
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   109
    by (simp add: expand_superset [of "{a. g a \<noteq> 1} \<union> {a. h a \<noteq> 1}"] F.distrib)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   110
qed
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   111
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   112
lemma commute:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   113
  assumes "finite C"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   114
  assumes subset: "{a. \<exists>b. g a b \<noteq> 1} \<times> {b. \<exists>a. g a b \<noteq> 1} \<subseteq> C" (is "?A \<times> ?B \<subseteq> C")
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   115
  shows "G (\<lambda>a. G (g a)) = G (\<lambda>b. G (\<lambda>a. g a b))"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   116
proof -
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
   117
  from \<open>finite C\<close> subset
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   118
    have "finite ({a. \<exists>b. g a b \<noteq> 1} \<times> {b. \<exists>a. g a b \<noteq> 1})"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   119
    by (rule rev_finite_subset)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   120
  then have fins:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   121
    "finite {b. \<exists>a. g a b \<noteq> 1}" "finite {a. \<exists>b. g a b \<noteq> 1}"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   122
    by (auto simp add: finite_cartesian_product_iff)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   123
  have subsets: "\<And>a. {b. g a b \<noteq> 1} \<subseteq> {b. \<exists>a. g a b \<noteq> 1}"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   124
    "\<And>b. {a. g a b \<noteq> 1} \<subseteq> {a. \<exists>b. g a b \<noteq> 1}"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   125
    "{a. F.F (g a) {b. \<exists>a. g a b \<noteq> 1} \<noteq> 1} \<subseteq> {a. \<exists>b. g a b \<noteq> 1}"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   126
    "{a. F.F (\<lambda>aa. g aa a) {a. \<exists>b. g a b \<noteq> 1} \<noteq> 1} \<subseteq> {b. \<exists>a. g a b \<noteq> 1}"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   127
    by (auto elim: F.not_neutral_contains_not_neutral)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   128
  from F.commute have
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   129
    "F.F (\<lambda>a. F.F (g a) {b. \<exists>a. g a b \<noteq> 1}) {a. \<exists>b. g a b \<noteq> 1} =
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   130
      F.F (\<lambda>b. F.F (\<lambda>a. g a b) {a. \<exists>b. g a b \<noteq> 1}) {b. \<exists>a. g a b \<noteq> 1}" .
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   131
  with subsets fins have "G (\<lambda>a. F.F (g a) {b. \<exists>a. g a b \<noteq> 1}) =
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   132
    G (\<lambda>b. F.F (\<lambda>a. g a b) {a. \<exists>b. g a b \<noteq> 1})"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   133
    by (auto simp add: expand_superset [of "{b. \<exists>a. g a b \<noteq> 1}"]
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   134
      expand_superset [of "{a. \<exists>b. g a b \<noteq> 1}"])
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   135
  with subsets fins show ?thesis
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   136
    by (auto simp add: expand_superset [of "{b. \<exists>a. g a b \<noteq> 1}"]
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   137
      expand_superset [of "{a. \<exists>b. g a b \<noteq> 1}"])
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   138
qed
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   139
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   140
lemma cartesian_product:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   141
  assumes "finite C"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   142
  assumes subset: "{a. \<exists>b. g a b \<noteq> 1} \<times> {b. \<exists>a. g a b \<noteq> 1} \<subseteq> C" (is "?A \<times> ?B \<subseteq> C")
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   143
  shows "G (\<lambda>a. G (g a)) = G (\<lambda>(a, b). g a b)"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   144
proof -
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
   145
  from subset \<open>finite C\<close> have fin_prod: "finite (?A \<times> ?B)"
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   146
    by (rule finite_subset)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   147
  from fin_prod have "finite ?A" and "finite ?B"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   148
    by (auto simp add: finite_cartesian_product_iff)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   149
  have *: "G (\<lambda>a. G (g a)) =
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   150
    (F.F (\<lambda>a. F.F (g a) {b. \<exists>a. g a b \<noteq> 1}) {a. \<exists>b. g a b \<noteq> 1})"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   151
    apply (subst expand_superset [of "?B"])
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
   152
    apply (rule \<open>finite ?B\<close>)
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   153
    apply auto
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   154
    apply (subst expand_superset [of "?A"])
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
   155
    apply (rule \<open>finite ?A\<close>)
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   156
    apply auto
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   157
    apply (erule F.not_neutral_contains_not_neutral)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   158
    apply auto
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   159
    done
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   160
  have "{p. (case p of (a, b) \<Rightarrow> g a b) \<noteq> 1} \<subseteq> ?A \<times> ?B"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   161
    by auto
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   162
  with subset have **: "{p. (case p of (a, b) \<Rightarrow> g a b) \<noteq> 1} \<subseteq> C"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   163
    by blast
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   164
  show ?thesis
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   165
    apply (simp add: *)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   166
    apply (simp add: F.cartesian_product)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   167
    apply (subst expand_superset [of C])
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
   168
    apply (rule \<open>finite C\<close>)
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   169
    apply (simp_all add: **)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   170
    apply (rule F.same_carrierI [of C])
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
   171
    apply (rule \<open>finite C\<close>)
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   172
    apply (simp_all add: subset)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   173
    apply auto
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   174
    done
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   175
qed
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   176
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   177
lemma cartesian_product2:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   178
  assumes fin: "finite D"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   179
  assumes subset: "{(a, b). \<exists>c. g a b c \<noteq> 1} \<times> {c. \<exists>a b. g a b c \<noteq> 1} \<subseteq> D" (is "?AB \<times> ?C \<subseteq> D")
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   180
  shows "G (\<lambda>(a, b). G (g a b)) = G (\<lambda>(a, b, c). g a b c)"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   181
proof -
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   182
  have bij: "bij (\<lambda>(a, b, c). ((a, b), c))"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   183
    by (auto intro!: bijI injI simp add: image_def)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   184
  have "{p. \<exists>c. g (fst p) (snd p) c \<noteq> 1} \<times> {c. \<exists>p. g (fst p) (snd p) c \<noteq> 1} \<subseteq> D"
61424
c3658c18b7bc prod_case as canonical name for product type eliminator
haftmann
parents: 61378
diff changeset
   185
    by auto (insert subset, blast)
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   186
  with fin have "G (\<lambda>p. G (g (fst p) (snd p))) = G (\<lambda>(p, c). g (fst p) (snd p) c)"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   187
    by (rule cartesian_product)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   188
  then have "G (\<lambda>(a, b). G (g a b)) = G (\<lambda>((a, b), c). g a b c)"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   189
    by (auto simp add: split_def)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   190
  also have "G (\<lambda>((a, b), c). g a b c) = G (\<lambda>(a, b, c). g a b c)"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   191
    using bij by (rule reindex_cong [of "\<lambda>(a, b, c). ((a, b), c)"]) (simp add: fun_eq_iff)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   192
  finally show ?thesis .
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   193
qed
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   194
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   195
lemma delta [simp]:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   196
  "G (\<lambda>b. if b = a then g b else 1) = g a"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   197
proof -
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   198
  have "{b. (if b = a then g b else 1) \<noteq> 1} \<subseteq> {a}" by auto
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   199
  then show ?thesis by (simp add: expand_superset [of "{a}"])
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   200
qed
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   201
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   202
lemma delta' [simp]:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   203
  "G (\<lambda>b. if a = b then g b else 1) = g a"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   204
proof -
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   205
  have "(\<lambda>b. if a = b then g b else 1) = (\<lambda>b. if b = a then g b else 1)"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   206
    by (simp add: fun_eq_iff)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   207
  then have "G (\<lambda>b. if a = b then g b else 1) = G (\<lambda>b. if b = a then g b else 1)"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   208
    by (simp cong del: strong_cong)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   209
  then show ?thesis by simp
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   210
qed
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   211
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   212
end
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   213
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   214
notation times (infixl "*" 70)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   215
notation Groups.one ("1")
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   216
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   217
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   218
subsection \<open>Concrete sum\<close>
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   219
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   220
context comm_monoid_add
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   221
begin
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   222
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   223
definition Sum_any :: "('b \<Rightarrow> 'a) \<Rightarrow> 'a"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   224
where
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   225
  "Sum_any = comm_monoid_fun.G plus 0"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   226
61605
1bf7b186542e qualifier is mandatory by default;
wenzelm
parents: 61424
diff changeset
   227
permanent_interpretation Sum_any: comm_monoid_fun plus 0
61671
20d4cd2ceab2 prefer "rewrites" and "defines" to note rewrite morphisms
haftmann
parents: 61670
diff changeset
   228
rewrites
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   229
  "comm_monoid_fun.G plus 0 = Sum_any" and
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   230
  "comm_monoid_set.F plus 0 = setsum"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   231
proof -
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   232
  show "comm_monoid_fun plus 0" ..
61605
1bf7b186542e qualifier is mandatory by default;
wenzelm
parents: 61424
diff changeset
   233
  then interpret Sum_any: comm_monoid_fun plus 0 .
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   234
  from Sum_any_def show "comm_monoid_fun.G plus 0 = Sum_any" by rule
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   235
  from setsum_def show "comm_monoid_set.F plus 0 = setsum" by rule
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   236
qed
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   237
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   238
end
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   239
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   240
syntax
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   241
  "_Sum_any" :: "pttrn \<Rightarrow> 'a \<Rightarrow> 'a::comm_monoid_add"    ("(3SUM _. _)" [0, 10] 10)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   242
syntax (xsymbols)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   243
  "_Sum_any" :: "pttrn \<Rightarrow> 'a \<Rightarrow> 'a::comm_monoid_add"    ("(3\<Sum>_. _)" [0, 10] 10)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   244
translations
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   245
  "\<Sum>a. b" == "CONST Sum_any (\<lambda>a. b)"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   246
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   247
lemma Sum_any_left_distrib:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   248
  fixes r :: "'a :: semiring_0"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   249
  assumes "finite {a. g a \<noteq> 0}"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   250
  shows "Sum_any g * r = (\<Sum>n. g n * r)"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   251
proof -
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   252
  note assms
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   253
  moreover have "{a. g a * r \<noteq> 0} \<subseteq> {a. g a \<noteq> 0}" by auto
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   254
  ultimately show ?thesis
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   255
    by (simp add: setsum_left_distrib Sum_any.expand_superset [of "{a. g a \<noteq> 0}"])
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   256
qed  
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   257
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   258
lemma Sum_any_right_distrib:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   259
  fixes r :: "'a :: semiring_0"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   260
  assumes "finite {a. g a \<noteq> 0}"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   261
  shows "r * Sum_any g = (\<Sum>n. r * g n)"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   262
proof -
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   263
  note assms
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   264
  moreover have "{a. r * g a \<noteq> 0} \<subseteq> {a. g a \<noteq> 0}" by auto
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   265
  ultimately show ?thesis
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   266
    by (simp add: setsum_right_distrib Sum_any.expand_superset [of "{a. g a \<noteq> 0}"])
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   267
qed
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   268
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   269
lemma Sum_any_product:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   270
  fixes f g :: "'b \<Rightarrow> 'a::semiring_0"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   271
  assumes "finite {a. f a \<noteq> 0}" and "finite {b. g b \<noteq> 0}"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   272
  shows "Sum_any f * Sum_any g = (\<Sum>a. \<Sum>b. f a * g b)"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   273
proof -
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   274
  have subset_f: "{a. (\<Sum>b. f a * g b) \<noteq> 0} \<subseteq> {a. f a \<noteq> 0}"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   275
    by rule (simp, rule, auto)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   276
  moreover have subset_g: "\<And>a. {b. f a * g b \<noteq> 0} \<subseteq> {b. g b \<noteq> 0}"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   277
    by rule (simp, rule, auto)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   278
  ultimately show ?thesis using assms
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   279
    by (auto simp add: Sum_any.expand_set [of f] Sum_any.expand_set [of g]
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   280
      Sum_any.expand_superset [of "{a. f a \<noteq> 0}"] Sum_any.expand_superset [of "{b. g b \<noteq> 0}"]
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   281
      setsum_product)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   282
qed
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   283
58437
8d124c73c37a added lemmas
haftmann
parents: 58197
diff changeset
   284
lemma Sum_any_eq_zero_iff [simp]: 
8d124c73c37a added lemmas
haftmann
parents: 58197
diff changeset
   285
  fixes f :: "'a \<Rightarrow> nat"
8d124c73c37a added lemmas
haftmann
parents: 58197
diff changeset
   286
  assumes "finite {a. f a \<noteq> 0}"
8d124c73c37a added lemmas
haftmann
parents: 58197
diff changeset
   287
  shows "Sum_any f = 0 \<longleftrightarrow> f = (\<lambda>_. 0)"
8d124c73c37a added lemmas
haftmann
parents: 58197
diff changeset
   288
  using assms by (simp add: Sum_any.expand_set fun_eq_iff)
8d124c73c37a added lemmas
haftmann
parents: 58197
diff changeset
   289
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   290
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   291
subsection \<open>Concrete product\<close>
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   292
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   293
context comm_monoid_mult
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   294
begin
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   295
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   296
definition Prod_any :: "('b \<Rightarrow> 'a) \<Rightarrow> 'a"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   297
where
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   298
  "Prod_any = comm_monoid_fun.G times 1"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   299
61605
1bf7b186542e qualifier is mandatory by default;
wenzelm
parents: 61424
diff changeset
   300
permanent_interpretation Prod_any: comm_monoid_fun times 1
61671
20d4cd2ceab2 prefer "rewrites" and "defines" to note rewrite morphisms
haftmann
parents: 61670
diff changeset
   301
rewrites
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   302
  "comm_monoid_fun.G times 1 = Prod_any" and
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   303
  "comm_monoid_set.F times 1 = setprod"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   304
proof -
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   305
  show "comm_monoid_fun times 1" ..
61605
1bf7b186542e qualifier is mandatory by default;
wenzelm
parents: 61424
diff changeset
   306
  then interpret Prod_any: comm_monoid_fun times 1 .
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   307
  from Prod_any_def show "comm_monoid_fun.G times 1 = Prod_any" by rule
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   308
  from setprod_def show "comm_monoid_set.F times 1 = setprod" by rule
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   309
qed
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   310
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   311
end
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   312
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   313
syntax
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   314
  "_Prod_any" :: "pttrn \<Rightarrow> 'a \<Rightarrow> 'a::comm_monoid_mult"    ("(3PROD _. _)" [0, 10] 10)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   315
syntax (xsymbols)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   316
  "_Prod_any" :: "pttrn \<Rightarrow> 'a \<Rightarrow> 'a::comm_monoid_mult"    ("(3\<Prod>_. _)" [0, 10] 10)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   317
translations
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   318
  "\<Prod>a. b" == "CONST Prod_any (\<lambda>a. b)"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   319
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   320
lemma Prod_any_zero:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   321
  fixes f :: "'b \<Rightarrow> 'a :: comm_semiring_1"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   322
  assumes "finite {a. f a \<noteq> 1}"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   323
  assumes "f a = 0"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   324
  shows "(\<Prod>a. f a) = 0"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   325
proof -
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
   326
  from \<open>f a = 0\<close> have "f a \<noteq> 1" by simp
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
   327
  with \<open>f a = 0\<close> have "\<exists>a. f a \<noteq> 1 \<and> f a = 0" by blast
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
   328
  with \<open>finite {a. f a \<noteq> 1}\<close> show ?thesis
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   329
    by (simp add: Prod_any.expand_set setprod_zero)
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   330
qed
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   331
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   332
lemma Prod_any_not_zero:
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   333
  fixes f :: "'b \<Rightarrow> 'a :: comm_semiring_1"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   334
  assumes "finite {a. f a \<noteq> 1}"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   335
  assumes "(\<Prod>a. f a) \<noteq> 0"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   336
  shows "f a \<noteq> 0"
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   337
  using assms Prod_any_zero [of f] by blast
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   338
58437
8d124c73c37a added lemmas
haftmann
parents: 58197
diff changeset
   339
lemma power_Sum_any:
8d124c73c37a added lemmas
haftmann
parents: 58197
diff changeset
   340
  assumes "finite {a. f a \<noteq> 0}"
8d124c73c37a added lemmas
haftmann
parents: 58197
diff changeset
   341
  shows "c ^ (\<Sum>a. f a) = (\<Prod>a. c ^ f a)"
8d124c73c37a added lemmas
haftmann
parents: 58197
diff changeset
   342
proof -
8d124c73c37a added lemmas
haftmann
parents: 58197
diff changeset
   343
  have "{a. c ^ f a \<noteq> 1} \<subseteq> {a. f a \<noteq> 0}"
8d124c73c37a added lemmas
haftmann
parents: 58197
diff changeset
   344
    by (auto intro: ccontr)
8d124c73c37a added lemmas
haftmann
parents: 58197
diff changeset
   345
  with assms show ?thesis
8d124c73c37a added lemmas
haftmann
parents: 58197
diff changeset
   346
    by (simp add: Sum_any.expand_set Prod_any.expand_superset power_setsum)
8d124c73c37a added lemmas
haftmann
parents: 58197
diff changeset
   347
qed
8d124c73c37a added lemmas
haftmann
parents: 58197
diff changeset
   348
58197
4fd7f47ead6c theory about sum and product on function bodies
haftmann
parents:
diff changeset
   349
end
58437
8d124c73c37a added lemmas
haftmann
parents: 58197
diff changeset
   350