src/HOL/Finite_Set.thy
changeset 33960 53993394ac19
parent 33657 a4179bf442d1
child 34007 aea892559fc5
equal deleted inserted replaced
33959:2afc55e8ed27 33960:53993394ac19
     4 *)
     4 *)
     5 
     5 
     6 header {* Finite sets *}
     6 header {* Finite sets *}
     7 
     7 
     8 theory Finite_Set
     8 theory Finite_Set
     9 imports Nat Product_Type Power
     9 imports Power Product_Type Sum_Type
    10 begin
    10 begin
    11 
    11 
    12 subsection {* Definition and basic properties *}
    12 subsection {* Definition and basic properties *}
    13 
    13 
    14 inductive finite :: "'a set => bool"
    14 inductive finite :: "'a set => bool"
  1155 lemma strong_setsum_cong[cong]:
  1155 lemma strong_setsum_cong[cong]:
  1156   "A = B ==> (!!x. x:B =simp=> f x = g x)
  1156   "A = B ==> (!!x. x:B =simp=> f x = g x)
  1157    ==> setsum (%x. f x) A = setsum (%x. g x) B"
  1157    ==> setsum (%x. f x) A = setsum (%x. g x) B"
  1158 by(fastsimp simp: simp_implies_def setsum_def intro: comm_monoid_add.fold_image_cong)
  1158 by(fastsimp simp: simp_implies_def setsum_def intro: comm_monoid_add.fold_image_cong)
  1159 
  1159 
  1160 lemma setsum_cong2: "\<lbrakk>\<And>x. x \<in> A \<Longrightarrow> f x = g x\<rbrakk> \<Longrightarrow> setsum f A = setsum g A";
  1160 lemma setsum_cong2: "\<lbrakk>\<And>x. x \<in> A \<Longrightarrow> f x = g x\<rbrakk> \<Longrightarrow> setsum f A = setsum g A"
  1161 by (rule setsum_cong[OF refl], auto);
  1161 by (rule setsum_cong[OF refl], auto)
  1162 
  1162 
  1163 lemma setsum_reindex_cong:
  1163 lemma setsum_reindex_cong:
  1164    "[|inj_on f A; B = f ` A; !!a. a:A \<Longrightarrow> g a = h (f a)|] 
  1164    "[|inj_on f A; B = f ` A; !!a. a:A \<Longrightarrow> g a = h (f a)|] 
  1165     ==> setsum h B = setsum g A"
  1165     ==> setsum h B = setsum g A"
  1166 by (simp add: setsum_reindex cong: setsum_cong)
  1166 by (simp add: setsum_reindex cong: setsum_cong)