# HG changeset patch # User paulson # Date 1532014064 -7200 # Node ID 227f85b1b98c5a52700cc4b1c6caf532a1b4262e # Parent 7dc9fe795daea31b7d817f9a76f5877fec8c621d de-applying diff -r 7dc9fe795dae -r 227f85b1b98c src/HOL/Algebra/Group.thy --- a/src/HOL/Algebra/Group.thy Tue Jul 17 22:18:27 2018 +0100 +++ b/src/HOL/Algebra/Group.thy Thu Jul 19 17:27:44 2018 +0200 @@ -114,10 +114,8 @@ lemma (in monoid) Units_inv_closed [intro, simp]: "x \ Units G ==> inv x \ carrier G" - apply (unfold Units_def m_inv_def, auto) - apply (rule theI2, fast) - apply (fast intro: inv_unique, fast) - done + apply (simp add: Units_def m_inv_def) + by (metis (mono_tags, lifting) inv_unique the_equality) lemma (in monoid) Units_l_inv_ex: "x \ Units G ==> \y \ carrier G. y \ x = \" @@ -129,10 +127,8 @@ lemma (in monoid) Units_l_inv [simp]: "x \ Units G ==> inv x \ x = \" - apply (unfold Units_def m_inv_def, auto) - apply (rule theI2, fast) - apply (fast intro: inv_unique, fast) - done + apply (unfold Units_def m_inv_def, simp) + by (metis (mono_tags, lifting) inv_unique the_equality) lemma (in monoid) Units_r_inv [simp]: "x \ Units G ==> x \ inv x = \" @@ -415,16 +411,15 @@ by (simp add: int_pow_def2) lemma (in group) int_pow_mult: - "x \ carrier G \ x [^] (i + j::int) = x [^] i \ x [^] j" + assumes "x \ carrier G" shows "x [^] (i + j::int) = x [^] i \ x [^] j" proof - have [simp]: "-i - j = -j - i" by simp - assume "x \ carrier G" then show ?thesis - by (auto simp add: int_pow_def2 inv_solve_left inv_solve_right nat_add_distrib [symmetric] nat_pow_mult ) + by (auto simp add: assms int_pow_def2 inv_solve_left inv_solve_right nat_add_distrib [symmetric] nat_pow_mult ) qed lemma (in group) nat_pow_inv: - "x \ carrier G \ (inv x) [^] (i :: nat) = inv (x [^] i)" + assumes "x \ carrier G" shows "(inv x) [^] (i :: nat) = inv (x [^] i)" proof (induction i) case 0 thus ?case by simp next @@ -434,9 +429,9 @@ also have " ... = (inv (x [^] i)) \ inv x" by (simp add: Suc.IH Suc.prems) also have " ... = inv (x \ (x [^] i))" - using inv_mult_group[OF Suc.prems nat_pow_closed[OF Suc.prems, of i]] by simp + by (simp add: assms inv_mult_group) also have " ... = inv (x [^] (Suc i))" - using Suc.prems nat_pow_Suc2 by auto + using assms nat_pow_Suc2 by auto finally show ?case . qed @@ -475,13 +470,13 @@ lemma (in group) int_pow_diff: "x \ carrier G \ x [^] (n - m :: int) = x [^] n \ inv (x [^] m)" -by(simp only: diff_conv_add_uminus int_pow_mult int_pow_neg) + by(simp only: diff_conv_add_uminus int_pow_mult int_pow_neg) lemma (in group) inj_on_multc: "c \ carrier G \ inj_on (\x. x \ c) (carrier G)" -by(simp add: inj_on_def) + by(simp add: inj_on_def) lemma (in group) inj_on_cmult: "c \ carrier G \ inj_on (\x. c \ x) (carrier G)" -by(simp add: inj_on_def) + by(simp add: inj_on_def) (*Following subsection contributed by Martin Baillon*) subsection \Submonoids\ @@ -736,20 +731,16 @@ simp add: DirProd_def) qed -lemma carrier_DirProd [simp]: - "carrier (G \\ H) = carrier G \ carrier H" +lemma carrier_DirProd [simp]: "carrier (G \\ H) = carrier G \ carrier H" by (simp add: DirProd_def) -lemma one_DirProd [simp]: - "\\<^bsub>G \\ H\<^esub> = (\\<^bsub>G\<^esub>, \\<^bsub>H\<^esub>)" +lemma one_DirProd [simp]: "\\<^bsub>G \\ H\<^esub> = (\\<^bsub>G\<^esub>, \\<^bsub>H\<^esub>)" by (simp add: DirProd_def) -lemma mult_DirProd [simp]: - "(g, h) \\<^bsub>(G \\ H)\<^esub> (g', h') = (g \\<^bsub>G\<^esub> g', h \\<^bsub>H\<^esub> h')" +lemma mult_DirProd [simp]: "(g, h) \\<^bsub>(G \\ H)\<^esub> (g', h') = (g \\<^bsub>G\<^esub> g', h \\<^bsub>H\<^esub> h')" by (simp add: DirProd_def) -lemma DirProd_assoc : -"(G \\ H \\ I) = (G \\ (H \\ I))" +lemma DirProd_assoc: "(G \\ H \\ I) = (G \\ (H \\ I))" by auto lemma inv_DirProd [simp]: @@ -841,8 +832,8 @@ using iso_set_sym unfolding is_iso_def by auto lemma (in group) iso_set_trans: - "[|h \ iso G H; i \ iso H I|] ==> (compose (carrier G) i h) \ iso G I" -by (auto simp add: iso_def hom_compose bij_betw_compose) + "[|h \ iso G H; i \ iso H I|] ==> (compose (carrier G) i h) \ iso G I" + by (auto simp add: iso_def hom_compose bij_betw_compose) corollary (in group) iso_trans: "\G \ H ; H \ I\ \ G \ I" using iso_set_trans unfolding is_iso_def by blast @@ -918,12 +909,11 @@ using iso_set_sym assms unfolding is_iso_def by blast define \ where psi_def: "\ = inv_into (carrier G) \" - from phi have surj: "\ ` (carrier G) = (carrier H)" "\ ` (carrier H) = (carrier G)" and inj: "inj_on \ (carrier G)" "inj_on \ (carrier H)" and phi_hom: "\g1 g2. \ g1 \ carrier G; g2 \ carrier G \ \ \ (g1 \ g2) = (\ g1) \\<^bsub>H\<^esub> (\ g2)" and psi_hom: "\h1 h2. \ h1 \ carrier H; h2 \ carrier H \ \ \ (h1 \\<^bsub>H\<^esub> h2) = (\ h1) \ (\ h2)" - using psi_def unfolding iso_def bij_betw_def hom_def by auto + using phi psi_def unfolding iso_def bij_betw_def hom_def by auto have phi_one: "\ \ = \\<^bsub>H\<^esub>" proof - @@ -1007,8 +997,7 @@ qed corollary (in group) DirProd_iso_trans : - assumes "G \ G2" - and "H \ I" + assumes "G \ G2" and "H \ I" shows "G \\ H \ G2 \\ I" using DirProd_iso_set_trans assms unfolding is_iso_def by blast @@ -1033,12 +1022,10 @@ with homh [unfolded hom_def] show ?thesis by auto qed -lemma (in group_hom) one_closed [simp]: - "h \ \ carrier H" +lemma (in group_hom) one_closed [simp]: "h \ \ carrier H" by simp -lemma (in group_hom) hom_one [simp]: - "h \ = \\<^bsub>H\<^esub>" +lemma (in group_hom) hom_one [simp]: "h \ = \\<^bsub>H\<^esub>" proof - have "h \ \\<^bsub>H\<^esub> \\<^bsub>H\<^esub> = h \ \\<^bsub>H\<^esub> h \" by (simp add: hom_mult [symmetric] del: hom_mult) @@ -1050,15 +1037,11 @@ by simp lemma (in group_hom) hom_inv [simp]: - "x \ carrier G ==> h (inv x) = inv\<^bsub>H\<^esub> (h x)" + assumes "x \ carrier G" shows "h (inv x) = inv\<^bsub>H\<^esub> (h x)" proof - - assume x: "x \ carrier G" - then have "h x \\<^bsub>H\<^esub> h (inv x) = \\<^bsub>H\<^esub>" - by (simp add: hom_mult [symmetric] del: hom_mult) - also from x have "... = h x \\<^bsub>H\<^esub> inv\<^bsub>H\<^esub> (h x)" - by (simp add: hom_mult [symmetric] del: hom_mult) - finally have "h x \\<^bsub>H\<^esub> h (inv x) = h x \\<^bsub>H\<^esub> inv\<^bsub>H\<^esub> (h x)" . - with x show ?thesis by (simp del: H.r_inv H.Units_r_inv) + have "h x \\<^bsub>H\<^esub> h (inv x) = h x \\<^bsub>H\<^esub> inv\<^bsub>H\<^esub> (h x)" + using assms by (simp flip: hom_mult) + with assms show ?thesis by (simp del: H.r_inv H.Units_r_inv) qed (* Contributed by Joachim Breitner *) @@ -1182,8 +1165,7 @@ locale comm_group = comm_monoid + group lemma (in group) group_comm_groupI: - assumes m_comm: "!!x y. [| x \ carrier G; y \ carrier G |] ==> - x \ y = y \ x" + assumes m_comm: "!!x y. [| x \ carrier G; y \ carrier G |] ==> x \ y = y \ x" shows "comm_group G" by standard (simp_all add: m_comm) diff -r 7dc9fe795dae -r 227f85b1b98c src/HOL/Real.thy --- a/src/HOL/Real.thy Tue Jul 17 22:18:27 2018 +0100 +++ b/src/HOL/Real.thy Thu Jul 19 17:27:44 2018 +0200 @@ -76,12 +76,16 @@ unfolding vanishes_def by simp lemma vanishes_const [simp]: "vanishes (\n. c) \ c = 0" - unfolding vanishes_def - apply (cases "c = 0") - apply auto - apply (rule exI [where x = "\c\"]) - apply auto - done +proof (cases "c = 0") + case True + then show ?thesis + by (simp add: vanishesI) +next + case False + then show ?thesis + unfolding vanishes_def + using zero_less_abs_iff by blast +qed lemma vanishes_minus: "vanishes X \ vanishes (\n. - X n)" unfolding vanishes_def by simp @@ -290,12 +294,7 @@ and nz: "\ vanishes X" shows "\b>0. \k. \n\k. b < \X n\" using cauchy_not_vanishes_cases [OF assms] - apply clarify - apply (rule exI) - apply (erule conjI) - apply (rule_tac x = k in exI) - apply auto - done + by (elim ex_forward conj_forward asm_rl) auto lemma cauchy_inverse [simp]: assumes X: "cauchy X" @@ -378,12 +377,7 @@ by (simp add: realrel_def) lemma symp_realrel: "symp realrel" - unfolding realrel_def - apply (rule sympI) - apply clarify - apply (drule vanishes_minus) - apply simp - done + by (simp add: abs_minus_commute realrel_def symp_def vanishes_def) lemma transp_realrel: "transp realrel" unfolding realrel_def @@ -440,10 +434,14 @@ by (simp only: cauchy_minus vanishes_minus simp_thms) lift_definition times_real :: "real \ real \ real" is "\X Y n. X n * Y n" - unfolding realrel_def mult_diff_mult - apply (subst (4) mult.commute) - apply (simp only: cauchy_mult vanishes_add vanishes_mult_bounded cauchy_imp_bounded simp_thms) - done +proof - + fix f1 f2 f3 f4 + have "\cauchy f1; cauchy f4; vanishes (\n. f1 n - f2 n); vanishes (\n. f3 n - f4 n)\ + \ vanishes (\n. f1 n * (f3 n - f4 n) + f4 n * (f1 n - f2 n))" + by (simp add: vanishes_add vanishes_mult_bounded cauchy_imp_bounded) + then show "\realrel f1 f2; realrel f3 f4\ \ realrel (\n. f1 n * f3 n) (\n. f2 n * f4 n)" + by (simp add: mult.commute realrel_def mult_diff_mult) +qed lift_definition inverse_real :: "real \ real" is "\X. if vanishes X then (\n. 0) else (\n. inverse (X n))" @@ -510,17 +508,17 @@ by transfer (simp add: distrib_right realrel_def) show "(0::real) \ (1::real)" by transfer (simp add: realrel_def) - show "a \ 0 \ inverse a * a = 1" - apply transfer - apply (simp add: realrel_def) - apply (rule vanishesI) - apply (frule (1) cauchy_not_vanishes) - apply clarify - apply (rule_tac x=k in exI) - apply clarify - apply (drule_tac x=n in spec) - apply simp - done + have "vanishes (\n. inverse (X n) * X n - 1)" if X: "cauchy X" "\ vanishes X" for X + proof (rule vanishesI) + fix r::rat + assume "0 < r" + obtain b k where "b>0" "\n\k. b < \X n\" + using X cauchy_not_vanishes by blast + then show "\k. \n\k. \inverse (X n) * X n - 1\ < r" + using \0 < r\ by force + qed + then show "a \ 0 \ inverse a * a = 1" + by transfer (simp add: realrel_def) show "a div b = a * inverse b" by (rule divide_real_def) show "inverse (0::real) = 0" @@ -595,9 +593,7 @@ lemma positive_minus: "\ positive x \ x \ 0 \ positive (- x)" apply transfer apply (simp add: realrel_def) - apply (drule (1) cauchy_not_vanishes_cases) - apply safe - apply blast+ + apply (blast intro: dest: cauchy_not_vanishes_cases) done instantiation real :: linordered_field @@ -617,38 +613,18 @@ show "\a\ = (if a < 0 then - a else a)" by (rule abs_real_def) show "a < b \ a \ b \ \ b \ a" - unfolding less_eq_real_def less_real_def - apply auto - apply (drule (1) positive_add) - apply (simp_all add: positive_zero) - done - show "a \ a" - unfolding less_eq_real_def by simp - show "a \ b \ b \ c \ a \ c" + "a \ b \ b \ c \ a \ c" "a \ a" + "a \ b \ b \ a \ a = b" + "a \ b \ c + a \ c + b" unfolding less_eq_real_def less_real_def - apply auto - apply (drule (1) positive_add) - apply (simp add: algebra_simps) - done - show "a \ b \ b \ a \ a = b" - unfolding less_eq_real_def less_real_def - apply auto - apply (drule (1) positive_add) - apply (simp add: positive_zero) - done - show "a \ b \ c + a \ c + b" - by (auto simp: less_eq_real_def less_real_def) - (* FIXME: Procedure int_combine_numerals: c + b - (c + a) \ b + - a *) - (* Should produce c + b - (c + a) \ b - a *) + by (force simp add: positive_zero dest: positive_add)+ show "sgn a = (if a = 0 then 0 else if 0 < a then 1 else - 1)" by (rule sgn_real_def) show "a \ b \ b \ a" by (auto dest!: positive_minus simp: less_eq_real_def less_real_def) show "a < b \ 0 < c \ c * a < c * b" unfolding less_real_def - apply (drule (1) positive_mult) - apply (simp add: algebra_simps) - done + by (force simp add: algebra_simps dest: positive_mult) qed end @@ -672,28 +648,30 @@ by (cases x rule: int_diff_cases) (simp add: of_nat_Real diff_Real) lemma of_rat_Real: "of_rat x = Real (\n. x)" - apply (induct x) +proof (induct x) + case (Fract a b) + then show ?case apply (simp add: Fract_of_int_quotient of_rat_divide) - apply (simp add: of_int_Real divide_inverse) - apply (simp add: inverse_Real mult_Real) + apply (simp add: of_int_Real divide_inverse inverse_Real mult_Real) done +qed instance real :: archimedean_field proof show "\z. x \ of_int z" for x :: real - apply (induct x) - apply (frule cauchy_imp_bounded, clarify) - apply (rule_tac x="\b\ + 1" in exI) - apply (rule less_imp_le) - apply (simp add: of_int_Real less_real_def diff_Real positive_Real) - apply (rule_tac x=1 in exI) - apply (simp add: algebra_simps) - apply (rule_tac x=0 in exI) - apply clarsimp - apply (rule le_less_trans [OF abs_ge_self]) - apply (rule less_le_trans [OF _ le_of_int_ceiling]) - apply simp - done + proof (induct x) + case (1 X) + then obtain b where "0 < b" and b: "\n. \X n\ < b" + by (blast dest: cauchy_imp_bounded) + then have "Real X < of_int (\b\ + 1)" + using 1 + apply (simp add: of_int_Real less_real_def diff_Real positive_Real) + apply (rule_tac x=1 in exI) + apply (simp add: algebra_simps) + by (metis abs_ge_self le_less_trans le_of_int_ceiling less_le) + then show ?case + using less_eq_real_def by blast + qed qed instantiation real :: floor_ceiling @@ -712,30 +690,17 @@ subsection \Completeness\ -lemma not_positive_Real: "\ positive (Real X) \ (\r>0. \k. \n\k. X n \ r)" if "cauchy X" - apply (simp only: positive_Real [OF that]) +lemma not_positive_Real: "\ positive (Real X) \ (\r>0. \k. \n\k. X n \ r)" (is "?lhs = ?rhs") + if "cauchy X" + unfolding positive_Real [OF that] apply auto apply (unfold not_less) apply (erule obtain_pos_sum) apply (drule_tac x=s in spec) apply simp apply (drule_tac r=t in cauchyD [OF that]) - apply clarify - apply (drule_tac x=k in spec) - apply clarsimp - apply (rule_tac x=n in exI) - apply clarify - apply (rename_tac m) - apply (drule_tac x=m in spec) - apply simp - apply (drule_tac x=n in spec) - apply simp - apply (drule spec) - apply (drule (1) mp) - apply clarify - apply (rename_tac i) - apply (rule_tac x = "max i k" in exI) - apply simp + apply fastforce + apply (meson le_cases) done lemma le_Real: @@ -857,12 +822,7 @@ apply (frule_tac y=y in ex_less_of_nat_mult) apply clarify apply (rule_tac x=n in exI) - apply (erule less_trans) - apply (rule mult_strict_right_mono) - apply (rule le_less_trans [OF _ of_nat_less_two_power]) - apply simp - apply assumption - done + by (metis less_trans mult.commute mult_less_cancel_left_pos of_nat_less_two_power) have PA: "\ P (A n)" for n by (induct n) (simp_all add: a) @@ -871,10 +831,7 @@ have ab: "a < b" using a b unfolding P_def apply (clarsimp simp add: not_le) - apply (drule (1) bspec) - apply (drule (1) less_le_trans) - apply (simp add: of_rat_less) - done + using less_le_trans of_rat_less by blast have AB: "A n < B n" for n by (induct n) (simp_all add: ab C_def avg_def) have A_mono: "\i j. i \ j \ A i \ A j"