# HG changeset patch # User paulson # Date 1531169740 -3600 # Node ID 96a49db47c9743b51b6a95b22ed241188361f377 # Parent 440aa6b7d99a6c4d99a4e69ab00dfaca458b6b6c removal of smt and certain refinements diff -r 440aa6b7d99a -r 96a49db47c97 src/HOL/Algebra/Chinese_Remainder.thy --- a/src/HOL/Algebra/Chinese_Remainder.thy Sun Jul 08 23:35:33 2018 +0100 +++ b/src/HOL/Algebra/Chinese_Remainder.thy Mon Jul 09 21:55:40 2018 +0100 @@ -133,9 +133,7 @@ by (metis abelian_subgroup.a_rcos_sum abelian_subgroupI3 additive_subgroup.a_Hcarr assms(1-2) ideal.axioms(1) is_abelian_group j m_closed r_zero x zero_closed) finally have Ix: "I +> ((j \ x) \ (i \ y)) = I +> x" using mod_I - by (smt additive_subgroup.a_Hcarr assms ideal.axioms(1) ideal.rcoset_mult_add j - monoid.l_one monoid_axioms one_closed x) - + by (metis (full_types) assms ideal.Icarr ideal.rcoset_mult_add is_monoid j monoid.l_one one_closed x) have "J +> ((j \ x) \ (i \ y)) = (J +> (j \ x)) <+> (J +> (i \ y))" by (metis abelian_subgroup.a_rcos_sum abelian_subgroupI3 assms i ideal.Icarr ideal.axioms(1) is_abelian_group j m_closed x y) @@ -147,9 +145,7 @@ additive_subgroup.a_Hcarr additive_subgroup.a_subset assms i ideal.axioms(1) is_abelian_group m_closed y) finally have Jy: "J +> ((j \ x) \ (i \ y)) = J +> y" using mod_J - by (smt additive_subgroup.a_Hcarr assms ideal.axioms(1) ideal.rcoset_mult_add i j - monoid.l_one monoid_axioms one_closed y x) - + by (metis (full_types) assms i ideal.Icarr ideal.rcoset_mult_add local.semiring_axioms one_closed semiring.semiring_simprules(9) y) have "(j \ x) \ (i \ y) \ carrier R" by (meson x y i j assms add.m_closed additive_subgroup.a_Hcarr ideal.axioms(1) m_closed) thus "\a \ carrier R. I +> a = I +> x \ J +> a = J +> y" using Ix Jy by blast @@ -231,21 +227,20 @@ subsection \First Generalization - The Extended Canonical Projection is Surjective\ lemma (in cring) canonical_proj_ext_is_surj: - assumes "\i. i \ {..n :: nat} \ x i \ carrier R" - and "\i. i \ {..n} \ ideal (I i) R" - and "\i j. \ i \ {..n}; j \ {..n}; i \ j \ \ I i <+> I j = carrier R" - shows "\ a \ carrier R. \ i \ {..n}. (I i) +> a = (I i) +> (x i)" using assms + fixes n::nat + assumes "\i. i \ n \ x i \ carrier R" + and "\i. i \ n \ ideal (I i) R" + and "\i j. \ i \ n; j \ n; i \ j \ \ I i <+> I j = carrier R" + shows "\ a \ carrier R. \ i \ n. (I i) +> a = (I i) +> (x i)" using assms proof (induct n) case 0 thus ?case by blast next case (Suc n) - then obtain a where a: "a \ carrier R" "\i. i \ {..n :: nat} \ (I i) +> a = (I i) +> (x i)" + then obtain a where a: "a \ carrier R" "\i. i \ n \ (I i) +> a = (I i) +> (x i)" by force have inter_is_ideal: "ideal (\ i \ n. I i) R" - by (metis (mono_tags, lifting) Suc.prems(2) atMost_Suc i_Intersect image_iff - image_is_empty insert_iff not_empty_eq_Iic_eq_empty) - + by (metis (mono_tags, lifting) Suc.prems(2) atMost_iff i_Intersect imageE image_is_empty le_SucI not_empty_eq_Iic_eq_empty) have "(\ i \ n. I i) <+> I (Suc n) = carrier R" using inter_plus_ideal_eq_carrier Suc by simp then obtain b where b: "b \ carrier R" @@ -255,36 +250,35 @@ hence b_inter: "b \ (\ i \ n. I i)" using ideal.set_add_zero_imp_mem[OF inter_is_ideal b] by (metis additive_subgroup.zero_closed ideal.axioms(1) ideal.set_add_zero inter_is_ideal) - hence eq_zero: "\i. i \ {..n :: nat} \ (I i) +> b = (I i) +> \" + hence eq_zero: "\i. i \ n \ (I i) +> b = (I i) +> \" proof - - fix i assume i: "i \ {..n :: nat}" + fix i assume i: "i \ n" hence "b \ I i" using b_inter by blast moreover have "ideal (I i) R" using Suc i by simp ultimately show "(I i) +> b = (I i) +> \" by (metis b ideal.I_r_closed ideal.set_add_zero r_null zero_closed) qed - have "\i. i \ {..Suc n} \ (I i) +> (a \ b) = (I i) +> (x i)" + have "(I i) +> (a \ b) = (I i) +> (x i)" if "i \ Suc n" for i proof - - fix i assume i: "i \ {..Suc n}" thus "(I i) +> (a \ b) = (I i) +> (x i)" + show "(I i) +> (a \ b) = (I i) +> (x i)" + using that proof (cases) - assume 1: "i \ {..n}" + assume 1: "i \ n" hence "(I i) +> (a \ b) = ((I i) +> (x i)) <+> ((I i) +> b)" - by (metis Suc.prems(2) a b i abelian_subgroup.a_rcos_sum - abelian_subgroupI3 ideal.axioms(1) is_abelian_group) + by (metis Suc.prems(2) a abelian_subgroup.a_rcos_sum abelian_subgroupI3 b ideal_def le_SucI ring_def) also have " ... = ((I i) +> (x i)) <+> ((I i) +> \)" using eq_zero[OF 1] by simp also have " ... = I i +> ((x i) \ \)" - by (meson Suc abelian_subgroup.a_rcos_sum abelian_subgroupI3 i - ideal.axioms(1) is_abelian_group zero_closed) + by (meson Suc.prems abelian_subgroup.a_rcos_sum abelian_subgroupI3 atMost_iff that ideal_def ring_def zero_closed) finally show "(I i) +> (a \ b) = (I i) +> (x i)" - using Suc.prems(1) i by auto + using Suc.prems(1) that by auto next - assume "i \ {..n}" hence 2: "i = Suc n" using i by simp + assume "\ i \ n" hence 2: "i = Suc n" using that by simp hence "I i +> (a \ b) = I (Suc n) +> (a \ b)" by simp also have " ... = (I (Suc n) +> a) <+> (I (Suc n) +> (x (Suc n) \ a))" - using S a b Suc.prems(2)[of "Suc n"] 2 abelian_subgroup.a_rcos_sum - abelian_subgroupI3 i ideal.axioms(1) is_abelian_group by metis + by (metis le_Suc_eq S a b Suc.prems(2)[of "Suc n"] 2 abelian_subgroup.a_rcos_sum + abelian_subgroupI3 ideal.axioms(1) is_abelian_group) also have " ... = I (Suc n) +> (a \ (x (Suc n) \ a))" by (simp add: Suc.prems(1-2) a(1) abelian_subgroup.a_rcos_sum abelian_subgroupI3 ideal.axioms(1) is_abelian_group) @@ -322,7 +316,7 @@ qed lemma DirProd_list_in_carrierI: - assumes "\i. i \ {..<(length rs)} \ rs ! i \ carrier (Rs ! i)" + assumes "\i. i < length rs \ rs ! i \ carrier (Rs ! i)" and "length rs = length Rs" shows "rs \ carrier (DirProd_list Rs)" using assms proof (induct Rs arbitrary: rs rule: DirProd_list.induct) @@ -338,7 +332,7 @@ lemma DirProd_list_in_carrierE: assumes "rs \ carrier (DirProd_list Rs)" - shows "\i. i \ {..<(length rs)} \ rs ! i \ carrier (Rs ! i)" using assms + shows "\i. i < length rs \ rs ! i \ carrier (Rs ! i)" using assms proof (induct Rs arbitrary: rs rule: DirProd_list.induct) case 1 thus ?case by simp next @@ -358,7 +352,7 @@ lemma DirProd_list_m_closed: assumes "r1 \ carrier (DirProd_list Rs)" "r2 \ carrier (DirProd_list Rs)" - and "\i. i \ {..<(length Rs)} \ monoid (Rs ! i)" + and "\i. i < length Rs \ monoid (Rs ! i)" shows "r1 \\<^bsub>(DirProd_list Rs)\<^esub> r2 \ carrier (DirProd_list Rs)" using assms proof (induct Rs arbitrary: r1 r2 rule: DirProd_list.induct) case 1 thus ?case by simp @@ -370,7 +364,7 @@ and "rs2' \ carrier (DirProd_list Rs)" and r1: "r1 = r1' # rs1'" and r2: "r2 = r2' # rs2'" by auto - moreover have "\i. i \ {..<(length Rs)} \ monoid (Rs ! i)" + moreover have "\i. i < length Rs \ monoid (Rs ! i)" using "2.prems"(3) by force ultimately have "rs1' \\<^bsub>(DirProd_list Rs)\<^esub> rs2' \ carrier (DirProd_list Rs)" using "2.hyps"(1) by blast @@ -383,7 +377,7 @@ lemma DirProd_list_m_output: assumes "r1 \ carrier (DirProd_list Rs)" "r2 \ carrier (DirProd_list Rs)" - shows "\i. i \ {..<(length Rs)} \ + shows "\i. i < length Rs \ (r1 \\<^bsub>(DirProd_list Rs)\<^esub> r2) ! i = (r1 ! i) \\<^bsub>(Rs ! i)\<^esub> (r2 ! i)" using assms proof (induct Rs arbitrary: r1 r2 rule: DirProd_list.induct) case 1 thus ?case by simp @@ -400,7 +394,7 @@ lemma DirProd_list_m_comm: assumes "r1 \ carrier (DirProd_list Rs)" "r2 \ carrier (DirProd_list Rs)" - and "\i. i \ {..<(length Rs)} \ comm_monoid (Rs ! i)" + and "\i. i < length Rs \ comm_monoid (Rs ! i)" shows "r1 \\<^bsub>(DirProd_list Rs)\<^esub> r2 = r2 \\<^bsub>(DirProd_list Rs)\<^esub> r1" apply (rule nth_equalityI) apply auto proof - @@ -423,7 +417,7 @@ assumes "r1 \ carrier (DirProd_list Rs)" and "r2 \ carrier (DirProd_list Rs)" and "r3 \ carrier (DirProd_list Rs)" - and "\i. i \ {..<(length Rs)} \ monoid (Rs ! i)" + and "\i. i < length Rs \ monoid (Rs ! i)" shows "(r1 \\<^bsub>(DirProd_list Rs)\<^esub> r2) \\<^bsub>(DirProd_list Rs)\<^esub> r3 = r1 \\<^bsub>(DirProd_list Rs)\<^esub> (r2 \\<^bsub>(DirProd_list Rs)\<^esub> r3)" apply (rule nth_equalityI) apply auto @@ -447,22 +441,22 @@ qed lemma DirProd_list_one: - "\i. i \ {..<(length Rs)} \ (\\<^bsub>(DirProd_list Rs)\<^esub>) ! i = \\<^bsub>(Rs ! i)\<^esub>" + "\i. i < length Rs \ (\\<^bsub>(DirProd_list Rs)\<^esub>) ! i = \\<^bsub>(Rs ! i)\<^esub>" by (induct Rs rule: DirProd_list.induct) (simp_all add: nth_Cons') lemma DirProd_list_one_closed: - assumes "\i. i \ {..<(length Rs)} \ monoid (Rs ! i)" + assumes "\i. i < length Rs \ monoid (Rs ! i)" shows "\\<^bsub>(DirProd_list Rs)\<^esub> \ carrier (DirProd_list Rs)" proof (rule DirProd_list_in_carrierI) show eq_len: "length \\<^bsub>DirProd_list Rs\<^esub> = length Rs" by (induct Rs rule: DirProd_list.induct) (simp_all) - show "\i. i \ {..\<^bsub>DirProd_list Rs\<^esub>} \ \\<^bsub>DirProd_list Rs\<^esub> ! i \ carrier (Rs ! i)" + show "\i. i < length \\<^bsub>DirProd_list Rs\<^esub> \ \\<^bsub>DirProd_list Rs\<^esub> ! i \ carrier (Rs ! i)" using eq_len DirProd_list_one[where ?Rs = Rs] monoid.one_closed by (simp add: assms) qed lemma DirProd_list_l_one: assumes "r1 \ carrier (DirProd_list Rs)" - and "\i. i \ {..<(length Rs)} \ monoid (Rs ! i)" + and "\i. i < length Rs \ monoid (Rs ! i)" shows "\\<^bsub>(DirProd_list Rs)\<^esub> \\<^bsub>(DirProd_list Rs)\<^esub> r1 = r1" apply (rule nth_equalityI) apply auto proof - @@ -485,7 +479,7 @@ lemma DirProd_list_r_one: assumes "r1 \ carrier (DirProd_list Rs)" - and "\i. i \ {..<(length Rs)} \ monoid (Rs ! i)" + and "\i. i < length Rs \ monoid (Rs ! i)" shows "r1 \\<^bsub>(DirProd_list Rs)\<^esub> \\<^bsub>(DirProd_list Rs)\<^esub> = r1" proof - have "r1 \\<^bsub>(DirProd_list Rs)\<^esub> \\<^bsub>(DirProd_list Rs)\<^esub> = @@ -512,7 +506,7 @@ qed lemma DirProd_list_monoid: - assumes "\i. i \ {..<(length Rs)} \ monoid (Rs ! i)" + assumes "\i. i < length Rs \ monoid (Rs ! i)" shows "monoid (DirProd_list Rs)" unfolding monoid_def apply auto proof - @@ -535,7 +529,7 @@ qed lemma DirProd_list_comm_monoid: - assumes "\i. i \ {..<(length Rs)} \ comm_monoid (Rs ! i)" + assumes "\i. i < length Rs \ comm_monoid (Rs ! i)" shows "comm_monoid (DirProd_list Rs)" unfolding comm_monoid_def comm_monoid_axioms_def apply auto using DirProd_list_monoid Group.comm_monoid.axioms(1) assms apply blast @@ -557,7 +551,7 @@ qed lemma DirProd_list_group: - assumes "\i. i \ {..<(length Rs)} \ group (Rs ! i)" + assumes "\i. i < length Rs \ group (Rs ! i)" shows "group (DirProd_list Rs)" using assms proof (induction Rs rule: DirProd_list.induct) case 1 thus ?case @@ -577,7 +571,7 @@ qed lemma DirProd_list_comm_group: - assumes "\i. i \ {..<(length Rs)} \ comm_group (Rs ! i)" + assumes "\i. i < length Rs \ comm_group (Rs ! i)" shows "comm_group (DirProd_list Rs)" using assms unfolding comm_group_def using DirProd_list_group DirProd_list_comm_monoid by auto @@ -604,8 +598,8 @@ lemma DirProd_list_m_inv: assumes "r \ carrier (DirProd_list Rs)" - and "\i. i \ {..<(length Rs)} \ group (Rs ! i)" - shows "\i. i \ {..<(length Rs)} \ (inv\<^bsub>(DirProd_list Rs)\<^esub> r) ! i = inv\<^bsub>(Rs ! i)\<^esub> (r ! i)" + and "\i. i < length Rs \ group (Rs ! i)" + shows "\i. i < length Rs \ (inv\<^bsub>(DirProd_list Rs)\<^esub> r) ! i = inv\<^bsub>(Rs ! i)\<^esub> (r ! i)" using assms proof (induct Rs arbitrary: r rule: DirProd_list.induct) case 1 @@ -656,7 +650,7 @@ by (simp add: monoid.defs) lemma RDirProd_list_monoid: - assumes "\i. i \ {..<(length Rs)} \ monoid (Rs ! i)" + assumes "\i. i < length Rs \ monoid (Rs ! i)" shows "monoid (RDirProd_list Rs)" proof - have "monoid (DirProd_list Rs)" @@ -670,7 +664,7 @@ qed lemma RDirProd_list_comm_monoid: - assumes "\i. i \ {..<(length Rs)} \ comm_monoid (Rs ! i)" + assumes "\i. i < length Rs \ comm_monoid (Rs ! i)" shows "comm_monoid (RDirProd_list Rs)" proof - have "comm_monoid (DirProd_list Rs)" @@ -686,10 +680,10 @@ qed lemma RDirProd_list_abelian_monoid: - assumes "\i. i \ {..<(length Rs)} \ abelian_monoid (Rs ! i)" + assumes "\i. i < length Rs \ abelian_monoid (Rs ! i)" shows "abelian_monoid (RDirProd_list Rs)" proof - - have "\i. i \ {..<(length Rs)} \ comm_monoid ((map add_monoid Rs) ! i)" + have "\i. i < length Rs \ comm_monoid ((map add_monoid Rs) ! i)" using assms unfolding abelian_monoid_def by simp hence "comm_monoid (DirProd_list (map add_monoid Rs))" by (metis (no_types, lifting) DirProd_list_comm_monoid length_map) @@ -698,10 +692,10 @@ qed lemma RDirProd_list_abelian_group: - assumes "\i. i \ {..<(length Rs)} \ abelian_group (Rs ! i)" + assumes "\i. i < length Rs \ abelian_group (Rs ! i)" shows "abelian_group (RDirProd_list Rs)" proof - - have "\i. i \ {..<(length Rs)} \ comm_group ((map add_monoid Rs) ! i)" + have "\i. i < length Rs \ comm_group ((map add_monoid Rs) ! i)" using assms unfolding abelian_group_def abelian_group_axioms_def by simp hence "comm_group (DirProd_list (map add_monoid Rs))" by (metis (no_types, lifting) DirProd_list_comm_group length_map) @@ -717,50 +711,69 @@ lemma RDirProd_list_in_carrierE: assumes "rs \ carrier (RDirProd_list Rs)" - shows "\i. i \ {..<(length rs)} \ rs ! i \ carrier (Rs ! i)" + shows "\i. i < length rs \ rs ! i \ carrier (Rs ! i)" using assms by (simp add: DirProd_list_in_carrierE monoid.defs) lemma RDirProd_list_in_carrierI: - assumes "\i. i \ {..<(length rs)} \ rs ! i \ carrier (Rs ! i)" + assumes "\i. i < length rs \ rs ! i \ carrier (Rs ! i)" and "length rs = length Rs" shows "rs \ carrier (RDirProd_list Rs)" using DirProd_list_in_carrierI assms by (simp add: monoid.defs, blast) lemma RDirProd_list_one: - "\i. i \ {..<(length Rs)} \ (\\<^bsub>(RDirProd_list Rs)\<^esub>) ! i = \\<^bsub>(Rs ! i)\<^esub>" + "\i. i < length Rs \ (\\<^bsub>(RDirProd_list Rs)\<^esub>) ! i = \\<^bsub>(Rs ! i)\<^esub>" by (simp add: DirProd_list_one monoid.defs) lemma RDirProd_list_zero: - "\i. i \ {..<(length Rs)} \ (\\<^bsub>(RDirProd_list Rs)\<^esub>) ! i = \\<^bsub>(Rs ! i)\<^esub>" + "\i. i < length Rs \ (\\<^bsub>(RDirProd_list Rs)\<^esub>) ! i = \\<^bsub>(Rs ! i)\<^esub>" by (induct Rs rule: DirProd_list.induct) (simp_all add: monoid.defs nth_Cons') lemma RDirProd_list_m_output: assumes "r1 \ carrier (RDirProd_list Rs)" "r2 \ carrier (RDirProd_list Rs)" - shows "\i. i \ {..<(length Rs)} \ + shows "\i. i < length Rs \ (r1 \\<^bsub>(RDirProd_list Rs)\<^esub> r2) ! i = (r1 ! i) \\<^bsub>(Rs ! i)\<^esub> (r2 ! i)" using assms by (simp add: DirProd_list_m_output monoid.defs) lemma RDirProd_list_a_output: - assumes "r1 \ carrier (RDirProd_list Rs)" "r2 \ carrier (RDirProd_list Rs)" - shows "\i. i \ {..<(length Rs)} \ - (r1 \\<^bsub>(RDirProd_list Rs)\<^esub> r2) ! i = (r1 ! i) \\<^bsub>(Rs ! i)\<^esub> (r2 ! i)" + fixes i + assumes "r1 \ carrier (RDirProd_list Rs)" "r2 \ carrier (RDirProd_list Rs)" "i < length Rs" + shows "(r1 \\<^bsub>(RDirProd_list Rs)\<^esub> r2) ! i = (r1 ! i) \\<^bsub>(Rs ! i)\<^esub> (r2 ! i)" using RDirProd_list_add_monoid[of Rs] monoid.defs(3) - by (smt DirProd_list_m_output assms length_map lessThan_iff - monoid.select_convs(1) nth_map partial_object.select_convs(1)) +proof - + have "(\\<^bsub>DirProd_list (map add_monoid Rs)\<^esub>) = (\\<^bsub>RDirProd_list Rs\<^esub>)" + by (metis \add_monoid (RDirProd_list Rs) = DirProd_list (map add_monoid Rs)\ monoid.select_convs(1)) + moreover have "r1 \ carrier (DirProd_list (map add_monoid Rs))" + by (metis \add_monoid (RDirProd_list Rs) = DirProd_list (map add_monoid Rs)\ assms(1) partial_object.select_convs(1)) + moreover have "r2 \ carrier (DirProd_list (map add_monoid Rs))" + by (metis \add_monoid (RDirProd_list Rs) = DirProd_list (map add_monoid Rs)\ assms(2) partial_object.select_convs(1)) + ultimately show ?thesis + by (simp add: DirProd_list_m_output assms(3)) +qed lemma RDirProd_list_a_inv: + fixes i assumes "r \ carrier (RDirProd_list Rs)" - and "\i. i \ {..<(length Rs)} \ abelian_group (Rs ! i)" - shows "\i. i \ {..<(length Rs)} \ (\\<^bsub>(RDirProd_list Rs)\<^esub> r) ! i = \\<^bsub>(Rs ! i)\<^esub> (r ! i)" - using RDirProd_list_add_monoid[of Rs] monoid.defs(3) DirProd_list_m_inv - by (smt a_inv_def abelian_group.a_group assms length_map lessThan_iff - monoid.surjective nth_map partial_object.ext_inject) + and "\i. i < length Rs \ abelian_group (Rs ! i)" + and "i < length Rs" + shows "(\\<^bsub>(RDirProd_list Rs)\<^esub> r) ! i = \\<^bsub>(Rs ! i)\<^esub> (r ! i)" +proof - + have f1: "m_inv (DirProd_list (map add_monoid Rs)) = a_inv (RDirProd_list Rs)" + by (metis RDirProd_list_add_monoid a_inv_def) +moreover + have f4: "r \ carrier (DirProd_list (map add_monoid Rs))" + by (metis RDirProd_list_add_monoid assms(1) partial_object.select_convs(1)) +moreover + have f3: "a_inv (Rs ! i) = m_inv (map add_monoid Rs ! i)" + by (simp add: a_inv_def assms(3)) + ultimately show ?thesis using RDirProd_list_add_monoid[of Rs] monoid.defs(3) DirProd_list_m_inv + by (smt abelian_group.a_group assms(2) assms(3) length_map nth_map) +qed lemma RDirProd_list_l_distr: assumes "x \ carrier (RDirProd_list Rs)" and "y \ carrier (RDirProd_list Rs)" and "z \ carrier (RDirProd_list Rs)" - and "\i. i \ {..<(length Rs)} \ ring (Rs ! i)" + and "\i. i < length Rs \ ring (Rs ! i)" shows "(x \\<^bsub>(RDirProd_list Rs)\<^esub> y) \\<^bsub>(RDirProd_list Rs)\<^esub> z = (x \\<^bsub>(RDirProd_list Rs)\<^esub> z) \\<^bsub>(RDirProd_list Rs)\<^esub> (y \\<^bsub>(RDirProd_list Rs)\<^esub> z)" proof - @@ -802,7 +815,7 @@ assumes "x \ carrier (RDirProd_list Rs)" and "y \ carrier (RDirProd_list Rs)" and "z \ carrier (RDirProd_list Rs)" - and "\i. i \ {..<(length Rs)} \ ring (Rs ! i)" + and "\i. i < length Rs \ ring (Rs ! i)" shows "z \\<^bsub>(RDirProd_list Rs)\<^esub> (x \\<^bsub>(RDirProd_list Rs)\<^esub> y) = (z \\<^bsub>(RDirProd_list Rs)\<^esub> x) \\<^bsub>(RDirProd_list Rs)\<^esub> (z \\<^bsub>(RDirProd_list Rs)\<^esub> y)" proof - @@ -841,19 +854,19 @@ qed theorem RDirProd_list_ring: - assumes "\i. i \ {..<(length Rs)} \ ring (Rs ! i)" + assumes "\i. i < length Rs \ ring (Rs ! i)" shows "ring (RDirProd_list Rs)" using assms unfolding ring_def ring_axioms_def using assms by (meson RDirProd_list_abelian_group RDirProd_list_l_distr RDirProd_list_monoid RDirProd_list_r_distr) theorem RDirProd_list_cring: - assumes "\i. i \ {..<(length Rs)} \ cring (Rs ! i)" + assumes "\i. i < length Rs \ cring (Rs ! i)" shows "cring (RDirProd_list Rs)" by (meson RDirProd_list_comm_monoid RDirProd_list_ring assms cring_def) corollary (in cring) RDirProd_list_of_quot_is_cring: - assumes "\i. i \ {..< n} \ ideal (I i) R" + assumes "\i. i < n \ ideal (I i) R" shows "cring (RDirProd_list (map (\i. R Quot (I i)) [0..< n]))" (is "cring (RDirProd_list ?Rs)") proof - @@ -948,8 +961,9 @@ Description of its Kernel\ theorem (in cring) canonical_proj_ext_is_hom: - assumes "\i. i \ {..< (n :: nat)} \ ideal (I i) R" - and "\i j. \ i \ {..< n}; j \ {..< n}; i \ j \ \ I i <+> I j = carrier R" + fixes n::nat + assumes "\i. i < n \ ideal (I i) R" + and "\i j. \ i < n; j < n; i \ j \ \ I i <+> I j = carrier R" shows "(\a. (map (\i. (I i) +> a) [0..< n])) \ ring_hom R (RDirProd_list (map (\i. R Quot (I i)) [0..< n]))" (is "?\ \ ?ring_hom") proof (rule ring_hom_memI) @@ -960,7 +974,6 @@ note aux_lemma = this fix x y assume x: "x \ carrier R" and y: "y \ carrier R" - show x': "?\ x \ carrier (RDirProd_list (map (\i. R Quot I i) [0.. x \ carrier (DirProd_list (map (\i. R Quot I i) [0.. x" "(map (\i. R Quot I i) [0.. y"] x'' y'' - by (simp add: x'' y'' FactRing_def add.left_neutral assms(1) diff_zero ideal.rcoset_mult_add - length_map length_upt lessThan_iff monoid.simps(1) nth_map_upt x y) + by (simp add: x'' y'' FactRing_def assms(1) ideal.rcoset_mult_add x y) show "?\ (x \ y) = ?\ x \\<^bsub>RDirProd_list (map (\i. R Quot I i) [0.. ?\ y" proof - @@ -995,10 +1007,21 @@ have "(?\ (x \ y)) ! j = I j +> x \ y" using j by simp also have " ... = (I j +> x) \\<^bsub>(R Quot I j)\<^esub> (I j +> y)" by (simp add: FactRing_def abelian_subgroup.a_rcos_sum abelian_subgroupI3 - assms(1) ideal.axioms(1) is_abelian_group j x y) + assms(1) ideal.axioms(1) is_abelian_group j x y) also have " ... = ((?\ x) \\<^bsub>RDirProd_list (map (\i. R Quot I i) [0.. (?\ y)) ! j" - by (smt RDirProd_list_a_output add.left_neutral diff_zero j - length_map length_upt lessThan_iff nth_map nth_upt x' y') + proof - + have "R Quot I j = map (\n. R Quot I n) [0.. x = I ([0.. x" + "I j +> y = I ([0.. y" + by (simp_all add: j) + moreover have "\n ns f. n < length ns \ map f ns ! n = (f (ns ! n::nat)::'a set)" + by simp + moreover have "\B ps C n. \B \ carrier (RDirProd_list ps); C \ carrier (RDirProd_list ps); n < length ps\ + \ (B \\<^bsub>RDirProd_list ps\<^esub> C) ! n = (B ! n::'a set) \\<^bsub>ps ! n\<^esub> C ! n" + by (meson RDirProd_list_a_output) + ultimately show ?thesis + by (metis (mono_tags, lifting) diff_zero j length_map length_upt x' y') + qed finally show "(?\ (x \ y)) ! j = ((?\ x) \\<^bsub>RDirProd_list (map (\i. R Quot I i) [0.. (?\ y)) ! j" . qed @@ -1016,8 +1039,9 @@ theorem (in cring) canonical_proj_ext_kernel: - assumes "\i. i \ {..(n :: nat)} \ ideal (I i) R" - and "\i j. \ i \ {..n}; j \ {..n}; i \ j \ \ I i <+> I j = carrier R" + fixes n::nat + assumes "\i. i \ n \ ideal (I i) R" + and "\i j. \ i \ n; j \ n; i \ j \ \ I i <+> I j = carrier R" shows "(\i \ n. I i) = a_kernel R (RDirProd_list (map (\i. R Quot (I i)) [0..< Suc n])) (\a. (map (\i. (I i) +> a) [0..< Suc n]))" proof - @@ -1035,16 +1059,18 @@ "\i. i \ n \ (\\<^bsub>(RDirProd_list (map (\i. R Quot (I i)) [0..< Suc n]))\<^esub>) ! i = \\<^bsub>(R Quot (I i))\<^esub>" using RDirProd_list_zero[where ?Rs = "map (\i. R Quot I i) [0..i. i \ n \ (\\<^bsub>(RDirProd_list (map (\i. R Quot (I i)) [0..< Suc n]))\<^esub>) ! i = I i" unfolding FactRing_def by simp moreover have "length (\\<^bsub>(RDirProd_list (map (\i. R Quot (I i)) [0..< Suc n]))\<^esub>) = Suc n" + using RDirProd_list_carrier_elts RDirProd_list_cring - by (smt add.left_neutral assms(1) cring.cring_simprules(2) diff_zero nth_map_upt - ideal.quotient_is_cring is_cring length_map length_upt lessThan_Suc_atMost lessThan_iff) + add.left_neutral assms(1) cring.cring_simprules(2) diff_zero nth_map_upt + ideal.quotient_is_cring is_cring length_map length_upt lessThan_Suc_atMost lessThan_iff + by (smt less_Suc_eq_le) moreover have "length (?\ s) = Suc n" by simp ultimately have "?\ s = \\<^bsub>(RDirProd_list (map (\i. R Quot (I i)) [0..< Suc n]))\<^esub>" by (simp add: nth_equalityI) @@ -1060,10 +1086,9 @@ fix s assume s: "s \ a_kernel R (RDirProd_list (map (\i. R Quot (I i)) [0..< Suc n])) ?\" hence "?\ s = \\<^bsub>(RDirProd_list (map (\i. R Quot (I i)) [0..< Suc n]))\<^esub>" unfolding a_kernel_def kernel_def by (simp add: monoid.defs) - hence "\i. i \ n \ (I i) +> s = \\<^bsub>(R Quot (I i))\<^esub>" + hence "(I i) +> s = \\<^bsub>(R Quot (I i))\<^esub>" if "i \ n" for i using RDirProd_list_zero[where ?Rs = "map (\i. R Quot I i) [0..i. i \ n \ (I i) +> s = I i" unfolding FactRing_def by simp moreover have "s \ carrier R" @@ -1078,8 +1103,9 @@ subsection \Final Generalization\ theorem (in cring) chinese_remainder: - assumes "\i. i \ {..(n :: nat)} \ ideal (I i) R" - and "\i j. \ i \ {..n}; j \ {..n}; i \ j \ \ I i <+> I j = carrier R" + fixes n::nat + assumes "\i. i \ n \ ideal (I i) R" + and "\i j. \ i \ n; j \ n; i \ j \ \ I i <+> I j = carrier R" shows "R Quot (\i \ n. I i) \ RDirProd_list (map (\i. R Quot (I i)) [0..< Suc n])" using assms proof (induct n) @@ -1100,9 +1126,8 @@ have inter_ideal: "ideal (\ i \ n. I i) R" using Suc.prems(1) i_Intersect[of "I ` {..n}"] atMost_Suc atLeast1_atMost_eq_remove0 by auto hence "R Quot (\ i \ Suc n. I i) \ RDirProd (R Quot (\ i \ n. I i)) (R Quot (I (Suc n)))" - using chinese_remainder_simple[of "\ i \ n. I i" "I (Suc n)"] - inter_plus_ideal_eq_carrier[of n I] by (simp add: Int_commute Suc.prems(1-2) atMost_Suc) - + using chinese_remainder_simple[of "\ i \ n. I i" "I (Suc n)"] inter_plus_ideal_eq_carrier[of n I] + by (simp add: Int_commute Suc.prems(1-2) atMost_Suc) moreover have "R Quot (\ i \ n. I i) \ RDirProd_list (map (\i. R Quot (I i)) [0..< Suc n])" using Suc.hyps Suc.prems(1-2) by auto hence "RDirProd (R Quot (\ i \ n. I i)) (R Quot (I (Suc n))) \ @@ -1124,82 +1149,4 @@ ultimately show ?case using ring_iso_trans by simp qed -theorem (in cring) (* chinese_remainder: another proof *) - assumes "\i. i \ {..(n :: nat)} \ ideal (I i) R" - and "\i j. \ i \ {..n}; j \ {..n}; i \ j \ \ I i <+> I j = carrier R" - shows "R Quot (\i \ n. I i) \ RDirProd_list (map (\i. R Quot (I i)) [0..< Suc n])" -proof - - let ?\ = "\a. (map (\i. (I i) +> a) [0..< Suc n])" - - have phi_hom: "?\ \ ring_hom R (RDirProd_list (map (\i. R Quot (I i)) [0..< Suc n]))" - using canonical_proj_ext_is_hom[of "Suc n"] assms by simp - - moreover have "?\ ` (carrier R) = carrier (RDirProd_list (map (\i. R Quot (I i)) [0..< Suc n]))" - proof - show "carrier (RDirProd_list (map (\i. R Quot (I i)) [0..< Suc n])) \ ?\ ` (carrier R)" - proof - fix x assume x: "x \ carrier (RDirProd_list (map (\i. R Quot (I i)) [0..< Suc n]))" - hence x_nth_eq: "\i. i \ {..< Suc n} \ x ! i \ carrier (R Quot (I i))" - using RDirProd_list_in_carrierE - by (smt RDirProd_list_carrier_elts add.left_neutral diff_zero length_map - length_upt lessThan_iff nth_map nth_upt) - then obtain y where y: "\i. i \ {..< Suc n} \ x ! i = (I i) +> (y i)" - "\i. i \ {..< Suc n} \ y i \ carrier R" - proof - - from x_nth_eq have "\y. (\i \ {..< Suc n}. x ! i = (I i) +> (y i)) \ - (\i \ {..< Suc n}. y i \ carrier R)" - proof (induct n) - case 0 - have "x ! 0 \ carrier (R Quot (I 0))" using x_nth_eq by simp - then obtain x_0 where x_0: "x ! 0 = (I 0) +> x_0" "x_0 \ carrier R" - unfolding FactRing_def using A_RCOSETS_def'[of R "I 0"] by auto - define y :: "nat \ 'a" where "y = (\i. x_0)" - hence "x ! 0 = (I 0) +> (y 0) \ (y 0) \ carrier R" - using x_0 by simp - thus ?case using x_0 by blast - next - case (Suc n) - then obtain y' where y': "\i. i \ {.. x ! i = I i +> y' i" - "\i. i \ {.. y' i \ carrier R" by auto - - have "x ! (Suc n) \ carrier (R Quot (I (Suc n)))" using Suc by simp - then obtain x_Sn where x_Sn: "x ! (Suc n) = (I (Suc n)) +> x_Sn" - "x_Sn \ carrier R" - unfolding FactRing_def using A_RCOSETS_def'[of R "I (Suc n)"] by auto - - define y where "y = (\i. if i = (Suc n) then x_Sn else (y' i))" - thus ?case using y' x_Sn - by (metis (full_types) insert_iff lessThan_Suc) - qed - thus ?thesis using that by blast - qed - - then obtain a where a: "a \ carrier R" - and "\i. i \ {..< Suc n} \ (I i) +> a = (I i) +> (y i)" - using canonical_proj_ext_is_surj[of n y I] assms(1-2) by auto - hence a_x: "\i. i \ {..< Suc n} \ (I i) +> a = x ! i" - using y by simp - have "?\ a = x" - apply (rule nth_equalityI) - using RDirProd_list_carrier_elts x apply fastforce - by (metis a_x add.left_neutral diff_zero length_map length_upt lessThan_iff nth_map_upt) - thus "x \ ?\ ` (carrier R)" - using a by blast - qed - next - show "?\ ` carrier R \ carrier (RDirProd_list (map (\i. R Quot (I i)) [0..< Suc n]))" - using phi_hom unfolding ring_hom_def by blast - qed - - moreover have "a_kernel R (RDirProd_list (map (\i. R Quot (I i)) [0..< Suc n])) ?\ = (\i \ n. I i)" - using canonical_proj_ext_kernel assms by blast - - moreover have "ring (RDirProd_list (map (\i. R Quot (I i)) [0..< Suc n]))" - using RDirProd_list_of_quot_is_cring assms(1) cring_def lessThan_Suc_atMost by blast - - ultimately show ?thesis - using ring_hom_ring.FactRing_iso[of R "RDirProd_list (map (\i. R Quot (I i)) [0..< Suc n])" ?\] - is_ring by (simp add: ring_hom_ringI2) -qed - end diff -r 440aa6b7d99a -r 96a49db47c97 src/HOL/Algebra/Group_Action.thy --- a/src/HOL/Algebra/Group_Action.thy Sun Jul 08 23:35:33 2018 +0100 +++ b/src/HOL/Algebra/Group_Action.thy Mon Jul 09 21:55:40 2018 +0100 @@ -134,7 +134,7 @@ shows "x \ orbit G \ y" proof - have "\ g \ carrier G. (\ g) x = y" - by (smt assms(3) mem_Collect_eq orbit_def) + using assms by (auto simp: orbit_def) then obtain g where g: "g \ carrier G \ (\ g) x = y" by blast hence "(\ (inv g)) y = x" using orbit_sym_aux by (simp add: assms(1)) @@ -149,15 +149,10 @@ proof - interpret group G using group_hom group_hom.axioms(1) by auto - - have "\ g1 \ carrier G. (\ g1) x = y" - by (smt assms mem_Collect_eq orbit_def) - then obtain g1 where g1: "g1 \ carrier G \ (\ g1) x = y" by blast - - have "\ g2 \ carrier G. (\ g2) y = z" - by (smt assms mem_Collect_eq orbit_def) - then obtain g2 where g2: "g2 \ carrier G \ (\ g2) y = z" by blast - + obtain g1 where g1: "g1 \ carrier G \ (\ g1) x = y" + using assms by (auto simp: orbit_def) + obtain g2 where g2: "g2 \ carrier G \ (\ g2) y = z" + using assms by (auto simp: orbit_def) have "(\ (g2 \ g1)) x = ((\ g2) \\<^bsub>BijGroup E\<^esub> (\ g1)) x" using g1 g2 group_hom group_hom.hom_mult by fastforce also have " ... = (\ g2) ((\ g1) x)" @@ -170,12 +165,8 @@ lemma (in group_action) orbits_as_classes: "classes\<^bsub>\ carrier = E, eq = \x. \y. y \ orbit G \ x \\<^esub> = orbits G E \" - unfolding eq_classes_def eq_class_of_def orbits_def apply simp -proof - - have "\x. x \ E \ {y \ E. y \ orbit G \ x} = orbit G \ x" - by (smt Collect_cong element_image mem_Collect_eq orbit_def) - thus "{{y \ E. y \ orbit G \ x} |x. x \ E} = {orbit G \ x |x. x \ E}" by blast -qed + unfolding eq_classes_def eq_class_of_def orbits_def orbit_def + using element_image by auto theorem (in group_action) orbit_partition: "partition E (orbits G E \)" @@ -722,14 +713,15 @@ show " \ x y. \ x \ inv g <# H #> g; y \ inv g <# H #> g \ \ x \ y \ inv g <# H #> g" proof - fix x y assume "x \ inv g <# H #> g" "y \ inv g <# H #> g" - hence "\ h1 \ H. \ h2 \ H. x = (inv g) \ h1 \ g \ y = (inv g) \ h2 \ g" + then obtain h1 h2 where h12: "h1 \ H" "h2 \ H" and "x = (inv g) \ h1 \ g \ y = (inv g) \ h2 \ g" unfolding l_coset_def r_coset_def by blast - hence "\ h1 \ H. \ h2 \ H. x \ y = ((inv g) \ h1 \ g) \ ((inv g) \ h2 \ g)" by blast - hence "\ h1 \ H. \ h2 \ H. x \ y = ((inv g) \ (h1 \ h2) \ g)" - using assms is_group inv_closed l_one m_assoc m_closed - monoid_axioms r_inv subgroup.mem_carrier by smt - hence "\ h \ H. x \ y = (inv g) \ h \ g" - by (meson assms(2) subgroup_def) + hence "x \ y = ((inv g) \ h1 \ g) \ ((inv g) \ h2 \ g)" by blast + also have "\ = ((inv g) \ h1 \ (g \ inv g) \ h2 \ g)" + using h12 assms inv_closed m_assoc m_closed subgroup.mem_carrier [OF \subgroup H G\] by presburger + also have "\ = ((inv g) \ (h1 \ h2) \ g)" + by (simp add: h12 assms m_assoc subgroup.mem_carrier [OF \subgroup H G\]) + finally have "\ h \ H. x \ y = (inv g) \ h \ g" + by (meson assms(2) h12 subgroup_def) thus "x \ y \ inv g <# H #> g" unfolding l_coset_def r_coset_def by blast qed @@ -741,11 +733,9 @@ unfolding r_coset_def l_coset_def by blast then obtain h where h: "h \ H \ x = (inv g) \ h \ g" by blast hence "x \ (inv g) \ (inv h) \ g = \" - using assms inv_closed m_assoc m_closed monoid_axioms - r_inv r_one subgroup.mem_carrier by smt + using assms m_assoc monoid_axioms by (simp add: subgroup.mem_carrier) hence "inv x = (inv g) \ (inv h) \ g" - using assms h inv_closed inv_inv inv_mult_group m_assoc - m_closed monoid_axioms subgroup.mem_carrier by smt + using assms h inv_mult_group m_assoc monoid_axioms by (simp add: subgroup.mem_carrier) moreover have "inv h \ H" by (simp add: assms h subgroup.m_inv_closed) ultimately show "inv x \ inv g <# H #> g" unfolding r_coset_def l_coset_def by blast @@ -843,8 +833,7 @@ by (metis assms l_coset_subset_G mem_Collect_eq r_coset_subset_G subgroup_def subgroup_self) hence "{H. H \ carrier G} \ ?\ ` {H. H \ carrier G}" by blast moreover have "?\ ` {H. H \ carrier G} \ {H. H \ carrier G}" - by (smt assms image_subsetI inv_closed l_coset_subset_G - mem_Collect_eq r_coset_subset_G restrict_apply') + by clarsimp (meson assms contra_subsetD inv_closed l_coset_subset_G r_coset_subset_G) ultimately show "?\ ` {H. H \ carrier G} = {H. H \ carrier G}" by simp qed diff -r 440aa6b7d99a -r 96a49db47c97 src/HOL/Algebra/Ideal_Product.thy --- a/src/HOL/Algebra/Ideal_Product.thy Sun Jul 08 23:35:33 2018 +0100 +++ b/src/HOL/Algebra/Ideal_Product.thy Mon Jul 09 21:55:40 2018 +0100 @@ -400,7 +400,7 @@ lemma (in cring) ideal_prod_eq_Inter_aux: assumes "I: {..(Suc n)} \ { J. ideal J R }" - and "\i j. \ i \ {..(Suc n)}; j \ {..(Suc n)} \ \ + and "\i j. \ i \ Suc n; j \ Suc n \ \ i \ j \ (I i) <+> (I j) = carrier R" shows "(\\<^bsub>(ideals_set R)\<^esub> k \ {..n}. I k) <+> (I (Suc n)) = carrier R" using assms proof (induct n arbitrary: I) @@ -419,7 +419,7 @@ let ?I' = "\i. I (Suc i)" have "?I': {..(Suc n)} \ { J. ideal J R }" using Suc.prems(1) by auto - moreover have "\i j. \ i \ {..(Suc n)}; j \ {..(Suc n)} \ \ + moreover have "\i j. \ i \ Suc n; j \ Suc n \ \ i \ j \ (?I' i) <+> (?I' j) = carrier R" by (simp add: Suc.prems(2)) ultimately have "(\\<^bsub>(ideals_set R)\<^esub> k \ {..n}. ?I' k) <+> (?I' (Suc n)) = carrier R" @@ -508,23 +508,23 @@ qed corollary (in cring) inter_plus_ideal_eq_carrier: - assumes "\i. i \ {..(Suc n)} \ ideal (I i) R" - and "\i j. \ i \ {..(Suc n)}; j \ {..(Suc n)}; i \ j \ \ I i <+> I j = carrier R" + assumes "\i. i \ Suc n \ ideal (I i) R" + and "\i j. \ i \ Suc n; j \ Suc n; i \ j \ \ I i <+> I j = carrier R" shows "(\ i \ n. I i) <+> (I (Suc n)) = carrier R" using ideal_prod_eq_Inter[of I n] ideal_prod_eq_Inter_aux[of I n] by (auto simp add: assms) corollary (in cring) inter_plus_ideal_eq_carrier_arbitrary: - assumes "\i. i \ {..(Suc n)} \ ideal (I i) R" - and "\i j. \ i \ {..(Suc n)}; j \ {..(Suc n)}; i \ j \ \ I i <+> I j = carrier R" - and "j \ {..(Suc n)}" + assumes "\i. i \ Suc n \ ideal (I i) R" + and "\i j. \ i \ Suc n; j \ Suc n; i \ j \ \ I i <+> I j = carrier R" + and "j \ Suc n" shows "(\ i \ ({..(Suc n)} - { j }). I i) <+> (I j) = carrier R" proof - define I' where "I' = (\i. if i = Suc n then (I j) else if i = j then (I (Suc n)) else (I i))" - have "\i. i \ {..(Suc n)} \ ideal (I' i) R" + have "\i. i \ Suc n \ ideal (I' i) R" using I'_def assms(1) assms(3) by auto - moreover have "\i j. \ i \ {..(Suc n)}; j \ {..(Suc n)}; i \ j \ \ I' i <+> I' j = carrier R" + moreover have "\i j. \ i \ Suc n; j \ Suc n; i \ j \ \ I' i <+> I' j = carrier R" using I'_def assms(2-3) by force ultimately have "(\ i \ n. I' i) <+> (I' (Suc n)) = carrier R" using inter_plus_ideal_eq_carrier by simp diff -r 440aa6b7d99a -r 96a49db47c97 src/HOL/Computational_Algebra/Factorial_Ring.thy --- a/src/HOL/Computational_Algebra/Factorial_Ring.thy Sun Jul 08 23:35:33 2018 +0100 +++ b/src/HOL/Computational_Algebra/Factorial_Ring.thy Mon Jul 09 21:55:40 2018 +0100 @@ -296,7 +296,7 @@ with 2 have "a + Suc b = Suc c \ p ^ a dvd m \ p ^ Suc b dvd n" by (auto intro: mult_dvd_mono) with Suc.hyps [of m y] show "\a b. a + b = Suc c \ p ^ a dvd m \ p ^ b dvd n" - by force + by blast qed qed