# HG changeset patch # User wenzelm # Date 1632515006 -7200 # Node ID 0135a0c77b64e75eff1f5ddc4f4ea211001cfd1e # Parent 9e71155e36666cf5fa6bbdc7462c08ec77d2daa1 tuned proofs --- avoid 'guess'; diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Analysis/Abstract_Topology_2.thy --- a/src/HOL/Analysis/Abstract_Topology_2.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Analysis/Abstract_Topology_2.thy Fri Sep 24 22:23:26 2021 +0200 @@ -50,9 +50,8 @@ proof (cases "x \ A") assume x: "x \ A" hence "indicator A x \ ({0<..<2} :: real set)" by simp - hence "\U. open U \ x \ U \ (\y\U. indicator A y \ ({0<..<2} :: real set))" - using 1 open_greaterThanLessThan by blast - then guess U .. note U = this + with 1 obtain U where U: "open U" "x \ U" "\y\U. indicator A y \ ({0<..<2} :: real set)" + using open_greaterThanLessThan by metis hence "\y\U. indicator A y > (0::real)" unfolding greaterThanLessThan_def by auto hence "U \ A" using indicator_eq_0_iff by force @@ -61,9 +60,8 @@ next assume x: "x \ A" hence "indicator A x \ ({-1<..<1} :: real set)" by simp - hence "\U. open U \ x \ U \ (\y\U. indicator A y \ ({-1<..<1} :: real set))" - using 1 open_greaterThanLessThan by blast - then guess U .. note U = this + with 1 obtain U where U: "open U" "x \ U" "\y\U. indicator A y \ ({-1<..<1} :: real set)" + using 1 open_greaterThanLessThan by metis hence "\y\U. indicator A y < (1::real)" unfolding greaterThanLessThan_def by auto hence "U \ -A" by auto diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Analysis/Binary_Product_Measure.thy --- a/src/HOL/Analysis/Binary_Product_Measure.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Analysis/Binary_Product_Measure.thy Fri Sep 24 22:23:26 2021 +0200 @@ -242,7 +242,11 @@ lemma (in sigma_finite_measure) measurable_emeasure_Pair: assumes Q: "Q \ sets (N \\<^sub>M M)" shows "(\x. emeasure M (Pair x -` Q)) \ borel_measurable N" (is "?s Q \ _") proof - - from sigma_finite_disjoint guess F . note F = this + obtain F :: "nat \ 'a set" where F: + "range F \ sets M" + "\ (range F) = space M" + "\i. emeasure M (F i) \ \" + "disjoint_family F" by (blast intro: sigma_finite_disjoint) then have F_sets: "\i. F i \ sets M" by auto let ?C = "\x i. F i \ Pair x -` Q" { fix i @@ -361,8 +365,16 @@ shows "\F::nat \ ('a \ 'b) set. range F \ E \ incseq F \ (\i. F i) = space M1 \ space M2 \ (\i. emeasure (M1 \\<^sub>M M2) (F i) \ \)" proof - - from M1.sigma_finite_incseq guess F1 . note F1 = this - from M2.sigma_finite_incseq guess F2 . note F2 = this + obtain F1 where F1: "range F1 \ sets M1" + "\ (range F1) = space M1" + "\i. emeasure M1 (F1 i) \ \" + "incseq F1" + by (rule M1.sigma_finite_incseq) blast + obtain F2 where F2: "range F2 \ sets M2" + "\ (range F2) = space M2" + "\i. emeasure M2 (F2 i) \ \" + "incseq F2" + by (rule M2.sigma_finite_incseq) blast from F1 F2 have space: "space M1 = (\i. F1 i)" "space M2 = (\i. F2 i)" by auto let ?F = "\i. F1 i \ F2 i" show ?thesis @@ -396,9 +408,11 @@ sublocale\<^marker>\tag unimportant\ pair_sigma_finite \ P?: sigma_finite_measure "M1 \\<^sub>M M2" proof - from M1.sigma_finite_countable guess F1 .. - moreover from M2.sigma_finite_countable guess F2 .. - ultimately show + obtain F1 :: "'a set set" and F2 :: "'b set set" where + "countable F1 \ F1 \ sets M1 \ \ F1 = space M1 \ (\a\F1. emeasure M1 a \ \)" + "countable F2 \ F2 \ sets M2 \ \ F2 = space M2 \ (\a\F2. emeasure M2 a \ \)" + using M1.sigma_finite_countable M2.sigma_finite_countable by auto + then show "\A. countable A \ A \ sets (M1 \\<^sub>M M2) \ \A = space (M1 \\<^sub>M M2) \ (\a\A. emeasure (M1 \\<^sub>M M2) a \ \)" by (intro exI[of _ "(\(a, b). a \ b) ` (F1 \ F2)"] conjI) (auto simp: M2.emeasure_pair_measure_Times space_pair_measure set_eq_iff subset_eq ennreal_mult_eq_top_iff) @@ -422,8 +436,10 @@ lemma (in pair_sigma_finite) distr_pair_swap: "M1 \\<^sub>M M2 = distr (M2 \\<^sub>M M1) (M1 \\<^sub>M M2) (\(x, y). (y, x))" (is "?P = ?D") proof - - from sigma_finite_up_in_pair_measure_generator guess F :: "nat \ ('a \ 'b) set" .. note F = this let ?E = "{a \ b |a b. a \ sets M1 \ b \ sets M2}" + obtain F :: "nat \ ('a \ 'b) set" where F: "range F \ ?E" + "incseq F" "\ (range F) = space M1 \ space M2" "\i. emeasure (M1 \\<^sub>M M2) (F i) \ \" + using sigma_finite_up_in_pair_measure_generator by auto show ?thesis proof (rule measure_eqI_generator_eq[OF Int_stable_pair_measure_generator[of M1 M2]]) show "?E \ Pow (space ?P)" @@ -432,9 +448,8 @@ by (simp add: sets_pair_measure space_pair_measure) then show "sets ?D = sigma_sets (space ?P) ?E" by simp - next - show "range F \ ?E" "(\i. F i) = space ?P" "\i. emeasure ?P (F i) \ \" - using F by (auto simp: space_pair_measure) + from F show "range F \ ?E" "(\i. F i) = space ?P" "\i. emeasure ?P (F i) \ \" + by (auto simp: space_pair_measure) next fix X assume "X \ ?E" then obtain A B where X[simp]: "X = A \ B" and A: "A \ sets M1" and B: "B \ sets M2" by auto @@ -899,7 +914,9 @@ shows "sigma_finite_measure M" proof - interpret sigma_finite_measure "distr M N f" by fact - from sigma_finite_countable guess A .. note A = this + obtain A where A: "countable A" "A \ sets (distr M N f)" + "\ A = space (distr M N f)" "\a\A. emeasure (distr M N f) a \ \" + using sigma_finite_countable by auto show ?thesis proof show "\A. countable A \ A \ sets M \ \A = space M \ (\a\A. emeasure M a \ \)" @@ -933,9 +950,12 @@ interpret M1: sigma_finite_measure M1 by fact interpret M2: sigma_finite_measure M2 by fact interpret pair_sigma_finite M1 M2 .. - from sigma_finite_up_in_pair_measure_generator guess F :: "nat \ ('a \ 'b) set" .. note F = this let ?E = "{a \ b |a b. a \ sets M1 \ b \ sets M2}" let ?P = "M1 \\<^sub>M M2" + obtain F :: "nat \ ('a \ 'b) set" where F: + "range F \ ?E" "incseq F" "\ (range F) = space M1 \ space M2" "\i. emeasure ?P (F i) \ \" + using sigma_finite_up_in_pair_measure_generator + by blast show ?thesis proof (rule measure_eqI_generator_eq[OF Int_stable_pair_measure_generator[of M1 M2]]) show "?E \ Pow (space ?P)" diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Analysis/Bochner_Integration.thy --- a/src/HOL/Analysis/Bochner_Integration.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Analysis/Bochner_Integration.thy Fri Sep 24 22:23:26 2021 +0200 @@ -2952,8 +2952,12 @@ assumes f[measurable]: "case_prod f \ borel_measurable (N \\<^sub>M M)" shows "(\x. \y. f x y \M) \ borel_measurable N" proof - - from borel_measurable_implies_sequence_metric[OF f, of 0] guess s .. - then have s: "\i. simple_function (N \\<^sub>M M) (s i)" + from borel_measurable_implies_sequence_metric[OF f, of 0] + obtain s where s: "\i. simple_function (N \\<^sub>M M) (s i)" + and "\x\space (N \\<^sub>M M). (\i. s i x) \ (case x of (x, y) \ f x y)" + and "\i. \x\space (N \\<^sub>M M). dist (s i x) 0 \ 2 * dist (case x of (x, xa) \ f x xa) 0" + by auto + then have *: "\x y. x \ space N \ y \ space M \ (\i. s i (x, y)) \ f x y" "\i x y. x \ space N \ y \ space M \ norm (s i (x, y)) \ 2 * norm (f x y)" by (auto simp: space_pair_measure) @@ -2970,7 +2974,7 @@ { fix i x assume "x \ space N" then have "simple_bochner_integral M (\y. s i (x, y)) = (\z\s i ` (space N \ space M). measure M {y \ space M. s i (x, y) = z} *\<^sub>R z)" - using s(1)[THEN simple_functionD(1)] + using s[THEN simple_functionD(1)] unfolding simple_bochner_integral_def by (intro sum.mono_neutral_cong_left) (auto simp: eq_commute space_pair_measure image_iff cong: conj_cong) } @@ -2991,9 +2995,9 @@ show "\i. (\y. s i (x, y)) \ borel_measurable M" using x by simp show "AE xa in M. (\i. s i (x, xa)) \ f x xa" - using x s(2) by auto + using x * by auto show "\i. AE xa in M. norm (s i (x, xa)) \ 2 * norm (f x xa)" - using x s(3) by auto + using x * by auto qed fact moreover { fix i @@ -3006,7 +3010,7 @@ by (intro simple_function_borel_measurable) (auto simp: space_pair_measure dest: finite_subset) have "(\\<^sup>+ y. ennreal (norm (s i (x, y))) \M) \ (\\<^sup>+ y. 2 * norm (f x y) \M)" - using x s by (intro nn_integral_mono) auto + using x * by (intro nn_integral_mono) auto also have "(\\<^sup>+ y. 2 * norm (f x y) \M) < \" using int_2f unfolding integrable_iff_bounded by simp finally show "(\\<^sup>+ xa. ennreal (norm (s i (x, xa))) \M) < \" . diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Analysis/Borel_Space.thy --- a/src/HOL/Analysis/Borel_Space.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Analysis/Borel_Space.thy Fri Sep 24 22:23:26 2021 +0200 @@ -101,11 +101,10 @@ thus ?thesis by auto qed qed - hence "\g :: real \ nat \ rat . \a \ {a\A. \ continuous (at a within A) f}. + then obtain g :: "real \ nat \ rat" where "\a \ {a\A. \ continuous (at a within A) f}. (fst (g a) = 0 \ of_rat (snd (g a)) < f a \ (\x \ A. x < a \ f x < of_rat (snd (g a)))) | (fst (g a) = 1 \ of_rat (snd (g a)) > f a \ (\x \ A. x > a \ f x > of_rat (snd (g a))))" - by (rule bchoice) - then guess g .. + by (rule bchoice [THEN exE]) blast hence g: "\a x. a \ A \ \ continuous (at a within A) f \ x \ A \ (fst (g a) = 0 \ of_rat (snd (g a)) < f a \ (x < a \ f x < of_rat (snd (g a)))) | (fst (g a) = 1 \ of_rat (snd (g a)) > f a \ (x > a \ f x > of_rat (snd (g a))))" @@ -579,7 +578,8 @@ "borel = sigma UNIV (range lessThan :: 'a::{linorder_topology, second_countable_topology} set set)" unfolding second_countable_borel_measurable[OF open_generated_order] proof (intro sigma_eqI sigma_sets_eqI) - from countable_dense_setE guess D :: "'a set" . note D = this + obtain D :: "'a set" where D: "countable D" "\X. open X \ X \ {} \ \d\D. d \ X" + by (rule countable_dense_setE) blast interpret L: sigma_algebra UNIV "sigma_sets UNIV (range lessThan)" by (rule sigma_algebra_sigma_sets) simp @@ -617,7 +617,8 @@ "borel = sigma UNIV (range greaterThan :: 'a::{linorder_topology, second_countable_topology} set set)" unfolding second_countable_borel_measurable[OF open_generated_order] proof (intro sigma_eqI sigma_sets_eqI) - from countable_dense_setE guess D :: "'a set" . note D = this + obtain D :: "'a set" where D: "countable D" "\X. open X \ X \ {} \ \d\D. d \ X" + by (rule countable_dense_setE) blast interpret L: sigma_algebra UNIV "sigma_sets UNIV (range greaterThan)" by (rule sigma_algebra_sigma_sets) simp @@ -1027,7 +1028,8 @@ then have *: "{x::'a. x\i \ a} = (\k::nat. {.. (\n\Basis. (if n = i then a else real k)*\<^sub>R n)})" proof (safe, simp_all add: eucl_le[where 'a='a] split: if_split_asm) fix x :: 'a - from real_arch_simple[of "Max ((\i. x\i)`Basis)"] guess k::nat .. + obtain k where "Max ((\) x ` Basis) \ real k" + using real_arch_simple by blast then have "\i. i \ Basis \ x\i \ real k" by (subst (asm) Max_le_iff) auto then show "\k::nat. \ia\Basis. ia \ i \ x \ ia \ real k" @@ -1048,8 +1050,8 @@ (\k::nat. {x. (\n\Basis. (if n = i then a else -real k) *\<^sub>R n) i. -x\i)`Basis)"] - guess k::nat .. note k = this + obtain k where k: "Max ((\) (- x) ` Basis) < real k" + using reals_Archimedean2 by blast { fix i :: 'a assume "i \ Basis" then have "-x\i < real k" using k by (subst (asm) Max_less_iff) auto @@ -1074,8 +1076,8 @@ also have *: "{x::'a. x\i < a} = (\k::nat. {x. x n\Basis. (if n = i then a else real k) *\<^sub>R n)})" using \i\ Basis\ proof (safe, simp_all add: eucl_less_def split: if_split_asm) fix x :: 'a - from reals_Archimedean2[of "Max ((\i. x\i)`Basis)"] - guess k::nat .. note k = this + obtain k where k: "Max ((\) x ` Basis) < real k" + using reals_Archimedean2 by blast { fix i :: 'a assume "i \ Basis" then have "x\i < real k" using k by (subst (asm) Max_less_iff) auto @@ -1098,8 +1100,8 @@ have *: "{..a} = (\n::nat. {- real n *\<^sub>R One .. a})" proof (safe, simp_all add: eucl_le[where 'a='a]) fix x :: 'a - from real_arch_simple[of "Max ((\i. - x\i)`Basis)"] - guess k::nat .. note k = this + obtain k where k: "Max ((\) (- x) ` Basis) \ real k" + using real_arch_simple by blast { fix i :: 'a assume "i \ Basis" with k have "- x\i \ real k" by (subst (asm) Max_le_iff) (auto simp: field_simps) @@ -1808,9 +1810,7 @@ proof - from assms is_real_interval have "\a b::real. S = {} \ S = UNIV \ S = {.. S = {..b} \ S = {a<..} \ S = {a..} \ S = {a<.. S = {a<..b} \ S = {a.. S = {a..b}" by auto - then guess a .. - then guess b .. - thus ?thesis + then show ?thesis by auto qed diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Analysis/Caratheodory.thy --- a/src/HOL/Analysis/Caratheodory.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Analysis/Caratheodory.thy Fri Sep 24 22:23:26 2021 +0200 @@ -564,8 +564,9 @@ let ?R = generated_ring have "\a\?R. \m. \C\M. a = \C \ finite C \ disjoint C \ m = (\c\C. \ c)" by (auto simp: generated_ring_def) - from bchoice[OF this] guess \' .. note \'_spec = this - + from bchoice[OF this] obtain \' + where \'_spec: "\x\generated_ring. \C\M. x = \ C \ finite C \ disjoint C \ \' x = sum \ C" + by blast { fix C assume C: "C \ M" "finite C" "disjoint C" fix D assume D: "D \ M" "finite D" "disjoint D" assume "\C = \D" @@ -609,15 +610,19 @@ fix a assume "a \ M" with \'[of "{a}"] show "\' a = \ a" by (simp add: disjoint_def) next - fix a assume "a \ ?R" then guess Ca .. note Ca = this + fix a assume "a \ ?R" + then obtain Ca where Ca: "finite Ca" "disjoint Ca" "Ca \ M" "a = \ Ca" .. with \'[of Ca] \volume M \\[THEN volume_positive] show "0 \ \' a" by (auto intro!: sum_nonneg) next show "\' {} = 0" using \'[of "{}"] by auto next - fix a assume "a \ ?R" then guess Ca .. note Ca = this - fix b assume "b \ ?R" then guess Cb .. note Cb = this + fix a b assume "a \ ?R" "b \ ?R" + then obtain Ca Cb + where Ca: "finite Ca" "disjoint Ca" "Ca \ M" "a = \ Ca" + and Cb: "finite Cb" "disjoint Cb" "Cb \ M" "b = \ Cb" + by (meson generated_ringE) assume "a \ b = {}" with Ca Cb have "Ca \ Cb \ {{}}" by auto then have C_Int_cases: "Ca \ Cb = {{}} \ Ca \ Cb = {}" by auto @@ -650,7 +655,7 @@ fix C assume sets_C: "C \ M" "\C \ M" and "disjoint C" "finite C" have "\F'. bij_betw F' {..finite C\]) auto - then guess F' .. note F' = this + then obtain F' where "bij_betw F' {.. j" @@ -698,10 +703,12 @@ have "countably_additive generated_ring \_r" proof (rule countably_additiveI) - fix A' :: "nat \ 'a set" assume A': "range A' \ generated_ring" "disjoint_family A'" + fix A' :: "nat \ 'a set" + assume A': "range A' \ generated_ring" "disjoint_family A'" and Un_A: "(\i. A' i) \ generated_ring" - from generated_ringE[OF Un_A] guess C' . note C' = this + obtain C' where C': "finite C'" "disjoint C'" "C' \ M" "\ (range A') = \ C'" + using generated_ringE[OF Un_A] by auto { fix c assume "c \ C'" moreover define A where [abs_def]: "A i = A' i \ c" for i @@ -717,11 +724,11 @@ proof fix i from A have Ai: "A i \ generated_ring" by auto - from generated_ringE[OF this] guess C . note C = this - + from generated_ringE[OF this] obtain C + where C: "finite C" "disjoint C" "C \ M" "A i = \ C" by auto have "\F'. bij_betw F' {..finite C\]) auto - then guess F .. note F = this + then obtain F where F: "bij_betw F {..x. \_r (A x) = (\j. \_r (f x j)) \ disjoint_family (f x) \ \ (range (f x)) = A x \ (\j. f x j \ M)" + .. then have UN_f_eq: "(\i. case_prod f (prod_decode i)) = (\i. A i)" unfolding UN_extend_simps surj_prod_decode by (auto simp: set_eq_iff) @@ -808,8 +817,8 @@ finally show "(\n. \_r (A' n)) = \_r (\i. A' i)" using C' by simp qed - from G.caratheodory'[OF \positive generated_ring \_r\ \countably_additive generated_ring \_r\] - guess \' .. + obtain \' where "(\s\generated_ring. \' s = \_r s) \ measure_space \ (sigma_sets \ generated_ring) \'" + using G.caratheodory'[OF pos \countably_additive generated_ring \_r\] by auto with V show ?thesis unfolding sigma_sets_generated_ring_eq by (intro exI[of _ \']) (auto intro: generated_ringI_Basic) diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Analysis/Complete_Measure.thy --- a/src/HOL/Analysis/Complete_Measure.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Analysis/Complete_Measure.thy Fri Sep 24 22:23:26 2021 +0200 @@ -52,16 +52,18 @@ show "{} \ ?A" by auto next let ?C = "space M" - fix A assume "A \ ?A" from completionE[OF this] guess S N N' . + fix A assume "A \ ?A" + then obtain S N N' + where "A = S \ N" "N \ N'" "N' \ null_sets M" "S \ sets M" + by (rule completionE) then show "space M - A \ ?A" by (intro completionI[of _ "(?C - S) \ (?C - N')" "(?C - S) \ N' \ (?C - N)"]) auto next fix A :: "nat \ 'a set" assume A: "range A \ ?A" then have "\n. \S N N'. A n = S \ N \ S \ sets M \ N' \ null_sets M \ N \ N'" by (auto simp: image_subset_iff) - from choice[OF this] guess S .. - from choice[OF this] guess N .. - from choice[OF this] guess N' .. + then obtain S N N' where "\x. A x = S x \ N x \ S x \ sets M \ N' x \ null_sets M \ N x \ N' x" + by metis then show "\(A ` UNIV) \ ?A" using null_sets_UN[of N'] by (intro completionI[of _ "\(S ` UNIV)" "\(N ` UNIV)" "\(N' ` UNIV)"]) auto @@ -104,7 +106,8 @@ show ?thesis unfolding main_part_def null_part_def if_not_P[OF nA] proof (rule someI2_ex) - from assms[THEN sets_completionE] guess S N N' . note A = this + from assms obtain S N N' where A: "A = S \ N" "N \ N'" "N' \ null_sets M" "S \ sets M" + by (blast intro: sets_completionE) let ?P = "(S, N - S)" show "\p. split_completion M A p" unfolding split_completion_def if_not_P[OF nA] using A @@ -140,12 +143,11 @@ assumes "S \ sets M" shows "null_part M S \ sets M" "emeasure M (null_part M S) = 0" proof - have S: "S \ sets (completion M)" using assms by auto - have "S - main_part M S \ sets M" using assms by auto - moreover + have *: "S - main_part M S \ sets M" using assms by auto from main_part_null_part_Un[OF S] main_part_null_part_Int[OF S] have "S - main_part M S = null_part M S" by auto - ultimately show sets: "null_part M S \ sets M" by auto - from null_part[OF S] guess N .. + with * show sets: "null_part M S \ sets M" by auto + from null_part[OF S] obtain N where "N \ null_sets M \ null_part M S \ N" .. with emeasure_eq_0[of N _ "null_part M S"] sets show "emeasure M (null_part M S) = 0" by auto qed @@ -159,10 +161,10 @@ then have UN: "(\i. S i) \ sets (completion M)" by auto have "\i. \N. N \ null_sets M \ null_part M (S i) \ N" using null_part[OF S] by auto - from choice[OF this] guess N .. note N = this + then obtain N where N: "\x. N x \ null_sets M \ null_part M (S x) \ N x" by metis then have UN_N: "(\i. N i) \ null_sets M" by (intro null_sets_UN) auto - have "(\i. S i) \ sets (completion M)" using S by auto - from null_part[OF this] guess N' .. note N' = this + from S have "(\i. S i) \ sets (completion M)" by auto + from null_part[OF this] obtain N' where N': "N' \ null_sets M \ null_part M (\ (range S)) \ N'" .. let ?N = "(\i. N i) \ N'" have null_set: "?N \ null_sets M" using N' UN_N by (intro null_sets.Un) auto have "main_part M (\i. S i) \ ?N = (main_part M (\i. S i) \ null_part M (\i. S i)) \ ?N" @@ -288,21 +290,24 @@ assumes g: "g \ borel_measurable (completion M)" shows "\g'\borel_measurable M. (AE x in M. g x = g' x)" proof - - from g[THEN borel_measurable_implies_simple_function_sequence'] guess f . note f = this - from this(1)[THEN completion_ex_simple_function] + obtain f :: "nat \ 'a \ ennreal" + where *: "\i. simple_function (completion M) (f i)" + and **: "\x. (SUP i. f i x) = g x" + using g[THEN borel_measurable_implies_simple_function_sequence'] by metis + from *[THEN completion_ex_simple_function] have "\i. \f'. simple_function M f' \ (AE x in M. f i x = f' x)" .. - from this[THEN choice] obtain f' where - sf: "\i. simple_function M (f' i)" and - AE: "\i. AE x in M. f i x = f' i x" by auto + then obtain f' + where sf: "\i. simple_function M (f' i)" + and AE: "\i. AE x in M. f i x = f' i x" + by metis show ?thesis proof (intro bexI) from AE[unfolded AE_all_countable[symmetric]] show "AE x in M. g x = (SUP i. f' i x)" (is "AE x in M. g x = ?f x") proof (elim AE_mp, safe intro!: AE_I2) fix x assume eq: "\i. f i x = f' i x" - moreover have "g x = (SUP i. f i x)" - unfolding f by (auto split: split_max) - ultimately show "g x = ?f x" by auto + have "g x = (SUP i. f i x)" by (auto simp: ** split: split_max) + with eq show "g x = ?f x" by auto qed show "?f \ borel_measurable M" using sf[THEN borel_measurable_simple_function] by auto diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Analysis/Finite_Product_Measure.thy --- a/src/HOL/Analysis/Finite_Product_Measure.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Analysis/Finite_Product_Measure.thy Fri Sep 24 22:23:26 2021 +0200 @@ -269,11 +269,24 @@ qed lemma Int_stable_prod_algebra: "Int_stable (prod_algebra I M)" -proof (unfold Int_stable_def, safe) + unfolding Int_stable_def +proof safe fix A assume "A \ prod_algebra I M" - from prod_algebraE[OF this] guess J E . note A = this + from prod_algebraE[OF this] obtain J E where A: + "A = prod_emb I M J (Pi\<^sub>E J E)" + "finite J" + "J \ {} \ I = {}" + "J \ I" + "\i. i \ J \ E i \ sets (M i)" + by auto fix B assume "B \ prod_algebra I M" - from prod_algebraE[OF this] guess K F . note B = this + from prod_algebraE[OF this] obtain K F where B: + "B = prod_emb I M K (Pi\<^sub>E K F)" + "finite K" + "K \ {} \ I = {}" + "K \ I" + "\i. i \ K \ F i \ sets (M i)" + by auto have "A \ B = prod_emb I M (J \ K) (\\<^sub>E i\J \ K. (if i \ J then E i else space (M i)) \ (if i \ K then F i else space (M i)))" unfolding A B using A(2,3,4) A(5)[THEN sets.sets_into_space] B(2,3,4) @@ -360,7 +373,13 @@ proof (rule sigma_sets_eqI) interpret R: sigma_algebra ?\ "sigma_sets ?\ ?R" by (rule sigma_algebra_sigma_sets) auto fix A assume "A \ prod_algebra I M" - from prod_algebraE[OF this] guess J X . note X = this + from prod_algebraE[OF this] obtain J X where X: + "A = prod_emb I M J (Pi\<^sub>E J X)" + "finite J" + "J \ {} \ I = {}" + "J \ I" + "\i. i \ J \ X i \ sets (M i)" + by auto show "A \ sigma_sets ?\ ?R" proof cases assume "I = {}" @@ -525,7 +544,13 @@ using sets_PiM prod_algebra_sets_into_space space proof (rule measurable_sigma_sets) fix A assume "A \ prod_algebra I M" - from prod_algebraE[OF this] guess J X . + from prod_algebraE[OF this] obtain J X where + "A = prod_emb I M J (Pi\<^sub>E J X)" + "finite J" + "J \ {} \ I = {}" + "J \ I" + "\i. i \ J \ X i \ sets (M i)" + by auto with sets[of J X] show "f -` A \ space N \ sets N" by auto qed @@ -537,7 +562,14 @@ using sets_PiM prod_algebra_sets_into_space space proof (rule measurable_sigma_sets) fix A assume "A \ prod_algebra I M" - from prod_algebraE[OF this] guess J X . note X = this + from prod_algebraE[OF this] obtain J X + where X: + "A = prod_emb I M J (Pi\<^sub>E J X)" + "finite J" + "J \ {} \ I = {}" + "J \ I" + "\i. i \ J \ X i \ sets (M i)" + by auto then have "f -` A \ space N = {\ \ space N. \i\J. f \ i \ X i}" using space by (auto simp: prod_emb_def del: PiE_I) also have "\ \ sets N" using X(3,2,4,5) by (rule sets) @@ -844,7 +876,9 @@ proof - have "\i::'i. \F::nat \ 'a set. range F \ sets (M i) \ incseq F \ (\i. F i) = space (M i) \ (\k. emeasure (M i) (F k) \ \)" using M.sigma_finite_incseq by metis - from choice[OF this] guess F :: "'i \ nat \ 'a set" .. + then obtain F :: "'i \ nat \ 'a set" + where "\x. range (F x) \ sets (M x) \ incseq (F x) \ \ (range (F x)) = space (M x) \ (\k. emeasure (M x) (F x k) \ \)" + by metis then have F: "\i. range (F i) \ sets (M i)" "\i. incseq (F i)" "\i. (\j. F i j) = space (M i)" "\i k. emeasure (M i) (F i k) \ \" by auto let ?F = "\k. \\<^sub>E i\I. F i k" @@ -950,8 +984,11 @@ shows "P = PiM I M" proof - interpret finite_product_sigma_finite M I - proof qed fact - from sigma_finite_pairs guess C .. note C = this + by standard fact + from sigma_finite_pairs obtain C where C: + "\i\I. range (C i) \ sets (M i)" "\k. \i\I. emeasure (M i) (C i k) \ \" + "incseq (\k. \\<^sub>E i\I. C i k)" "(\k. \\<^sub>E i\I. C i k) = space (Pi\<^sub>M I M)" + by auto show ?thesis proof (rule measure_eqI_PiM_finite[OF I refl P, symmetric]) show "(\i. i \ I \ A i \ sets (M i)) \ (Pi\<^sub>M I M) (Pi\<^sub>E I A) = P (Pi\<^sub>E I A)" for A diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Analysis/Gamma_Function.thy --- a/src/HOL/Analysis/Gamma_Function.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Analysis/Gamma_Function.thy Fri Sep 24 22:23:26 2021 +0200 @@ -388,7 +388,9 @@ have "summable (\k. inverse ((real_of_nat k)^2))" by (rule inverse_power_summable) simp - from summable_partial_sum_bound[OF this e'] guess M . note M = this + from summable_partial_sum_bound[OF this e'] + obtain M where M: "\m n. M \ m \ norm (\k = m..n. inverse ((real k)\<^sup>2)) < e'" + by auto define N where "N = max 2 (max (nat \2 * (norm z + d)\) M)" { @@ -910,7 +912,8 @@ assume n: "n = 0" let ?f = "\k z. inverse (of_nat (Suc k)) - inverse (z + of_nat k)" let ?F = "\z. \k. ?f k z" and ?f' = "\k z. inverse ((z + of_nat k)\<^sup>2)" - from no_nonpos_Int_in_ball'[OF z] guess d . note d = this + from no_nonpos_Int_in_ball'[OF z] obtain d where d: "0 < d" "\t. t \ ball z d \ t \ \\<^sub>\\<^sub>0" + by auto from z have summable: "summable (\k. inverse (of_nat (Suc k)) - inverse (z + of_nat k))" by (intro summable_Digamma) force from z have conv: "uniformly_convergent_on (ball z d) (\k z. \i2))" @@ -931,7 +934,8 @@ next assume n: "n \ 0" from z have z': "z \ 0" by auto - from no_nonpos_Int_in_ball'[OF z] guess d . note d = this + from no_nonpos_Int_in_ball'[OF z] obtain d where d: "0 < d" "\t. t \ ball z d \ t \ \\<^sub>\\<^sub>0" + by auto define n' where "n' = Suc n" from n have n': "n' \ 2" by (simp add: n'_def) have "((\z. \k. inverse ((z + of_nat k) ^ n')) has_field_derivative @@ -1293,7 +1297,9 @@ case False have "rGamma_series z \ exp (- ln_Gamma z)" proof (rule Lim_transform_eventually) - from ln_Gamma_series_complex_converges'[OF False] guess d by (elim exE conjE) + from ln_Gamma_series_complex_converges'[OF False] + obtain d where "0 < d" "uniformly_convergent_on (ball z d) (\n z. ln_Gamma_series z n)" + by auto from this(1) uniformly_convergent_imp_convergent[OF this(2), of z] have "ln_Gamma_series z \ lim (ln_Gamma_series z)" by (simp add: convergent_LIMSEQ_iff) thus "(\n. exp (-ln_Gamma_series z n)) \ exp (- ln_Gamma z)" @@ -1762,9 +1768,12 @@ proof - have "\\. x < \ \ \ < y \ Polygamma n y - Polygamma n x = (y - x) * Polygamma (Suc n) \" using assms by (intro MVT2 derivative_intros impI allI) (auto elim!: nonpos_Ints_cases) - then guess \ by (elim exE conjE) note \ = this - note \(3) - also from \(1,2) assms have "(y - x) * Polygamma (Suc n) \ > 0" + then obtain \ + where \: "x < \" "\ < y" + and Polygamma: "Polygamma n y - Polygamma n x = (y - x) * Polygamma (Suc n) \" + by auto + note Polygamma + also from \ assms have "(y - x) * Polygamma (Suc n) \ > 0" by (intro mult_pos_pos Polygamma_real_odd_pos) (auto elim!: nonpos_Ints_cases) finally show ?thesis by simp qed @@ -1775,9 +1784,12 @@ proof - have "\\. x < \ \ \ < y \ Polygamma n y - Polygamma n x = (y - x) * Polygamma (Suc n) \" using assms by (intro MVT2 derivative_intros impI allI) (auto elim!: nonpos_Ints_cases) - then guess \ by (elim exE conjE) note \ = this - note \(3) - also from \(1,2) assms have "(y - x) * Polygamma (Suc n) \ < 0" + then obtain \ + where \: "x < \" "\ < y" + and Polygamma: "Polygamma n y - Polygamma n x = (y - x) * Polygamma (Suc n) \" + by auto + note Polygamma + also from \ assms have "(y - x) * Polygamma (Suc n) \ < 0" by (intro mult_pos_neg Polygamma_real_even_neg) simp_all finally show ?thesis by simp qed @@ -1809,9 +1821,11 @@ proof - have "\\. x < \ \ \ < y \ ln_Gamma y - ln_Gamma x = (y - x) * Digamma \" using assms by (intro MVT2 derivative_intros impI allI) (auto elim!: nonpos_Ints_cases) - then guess \ by (elim exE conjE) note \ = this - note \(3) - also from \(1,2) assms have "(y - x) * Digamma \ > 0" + then obtain \ where \: "x < \" "\ < y" + and ln_Gamma: "ln_Gamma y - ln_Gamma x = (y - x) * Digamma \" + by auto + note ln_Gamma + also from \ assms have "(y - x) * Digamma \ > 0" by (intro mult_pos_pos Digamma_real_ge_three_halves_pos) simp_all finally show ?thesis by simp qed diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Analysis/Interval_Integral.thy --- a/src/HOL/Analysis/Interval_Integral.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Analysis/Interval_Integral.thy Fri Sep 24 22:23:26 2021 +0200 @@ -72,7 +72,7 @@ ultimately show thesis by (intro that[of "\i. b' - d / Suc (Suc i)"]) (auto simp: real incseq_def intro!: divide_left_mono) -qed (insert \a < b\, auto) +qed (use \a < b\ in auto) lemma ereal_decseq_approx: fixes a b :: ereal @@ -81,7 +81,12 @@ "decseq X" "\i. a < X i" "\i. X i < b" "X \ a" proof - have "-b < -a" using \a < b\ by simp - from ereal_incseq_approx[OF this] guess X . + from ereal_incseq_approx[OF this] obtain X where + "incseq X" + "\i. - b < ereal (X i)" + "\i. ereal (X i) < - a" + "(\x. ereal (X x)) \ - a" + by auto then show thesis apply (intro that[of "\i. - X i"]) apply (auto simp: decseq_def incseq_def simp flip: uminus_ereal.simps) @@ -98,8 +103,18 @@ "l \ a" "u \ b" proof - from dense[OF \a < b\] obtain c where "a < c" "c < b" by safe - from ereal_incseq_approx[OF \c < b\] guess u . note u = this - from ereal_decseq_approx[OF \a < c\] guess l . note l = this + from ereal_incseq_approx[OF \c < b\] obtain u where u: + "incseq u" + "\i. c < ereal (u i)" + "\i. ereal (u i) < b" + "(\x. ereal (u x)) \ b" + by auto + from ereal_decseq_approx[OF \a < c\] obtain l where l: + "decseq l" + "\i. a < ereal (l i)" + "\i. ereal (l i) < c" + "(\x. ereal (l x)) \ a" + by auto { fix i from less_trans[OF \l i < c\ \c < u i\] have "l i < u i" by simp } have "einterval a b = (\i. {l i .. u i})" proof (auto simp: einterval_iff) @@ -944,8 +959,15 @@ "set_integrable lborel (einterval A B) f" "(LBINT x=A..B. f x) = (LBINT x=a..b. (f (g x) * g' x))" proof - - from einterval_Icc_approximation[OF \a < b\] guess u l . note approx [simp] = this - note less_imp_le [simp] + from einterval_Icc_approximation[OF \a < b\] obtain u l where approx [simp]: + "einterval a b = (\i. {l i..u i})" + "incseq u" + "decseq l" + "\i. l i < u i" + "\i. a < ereal (l i)" + "\i. ereal (u i) < b" + "(\x. ereal (l x)) \ a" + "(\x. ereal (u x)) \ b" by this auto have aless[simp]: "\x i. l i \ x \ a < ereal x" by (rule order_less_le_trans, rule approx, force) have lessb[simp]: "\x i. x \ u i \ ereal x < b" @@ -976,7 +998,7 @@ hence B3: "\i. g (u i) \ B" by (intro incseq_le, auto simp: incseq_def) have "ereal (g (l 0)) \ ereal (g (u 0))" - by auto + by (auto simp: less_imp_le) then show "A \ B" by (meson A3 B3 order.trans) { fix x :: real @@ -1002,7 +1024,7 @@ have "(LBINT x=l i.. u i. g' x *\<^sub>R f (g x)) = (LBINT y=g (l i)..g (u i). f y)" apply (rule interval_integral_substitution_finite [OF _ DERIV_subset [OF deriv_g]]) unfolding has_field_derivative_iff_has_vector_derivative[symmetric] - apply (auto intro!: continuous_at_imp_continuous_on contf contg') + apply (auto simp: less_imp_le intro!: continuous_at_imp_continuous_on contf contg') done then show ?thesis by (simp add: ac_simps) @@ -1031,7 +1053,7 @@ hence "(\i. (LBINT y=g (l i)..g (u i). f y)) \ ?l" by (simp add: eq1) then show "(\i. set_lebesgue_integral lborel {g (l i)<.. ?l" - unfolding interval_lebesgue_integral_def by auto + unfolding interval_lebesgue_integral_def by (auto simp: less_imp_le) have "\x i. g (l i) \ x \ x \ g (u i) \ 0 \ f x" using aless f_nonneg img lessb by blast then show "\x i. x \ {g (l i)<.. 0 \ f x" diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Analysis/Measure_Space.thy --- a/src/HOL/Analysis/Measure_Space.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Analysis/Measure_Space.thy Fri Sep 24 22:23:26 2021 +0200 @@ -1142,7 +1142,9 @@ assumes AE: "AE x in M. P x" and sets: "{x\space M. P x} \ sets M" (is "?P \ sets M") shows "emeasure M {x\space M. P x} = emeasure M (space M)" proof - - from AE_E[OF AE] guess N . note N = this + from AE_E[OF AE] obtain N + where N: "{x \ space M. \ P x} \ N" "emeasure M N = 0" "N \ sets M" + by auto with sets have "emeasure M (space M) \ emeasure M (?P \ N)" by (intro emeasure_mono) auto also have "\ \ emeasure M ?P + emeasure M N" @@ -1513,10 +1515,13 @@ and AE: "AE x in distr M M' f. P x" shows "AE x in M. P (f x)" proof - - from AE[THEN AE_E] guess N . + from AE[THEN AE_E] obtain N + where "{x \ space (distr M M' f). \ P x} \ N" + "emeasure (distr M M' f) N = 0" + "N \ sets (distr M M' f)" + by auto with f show ?thesis - unfolding eventually_ae_filter - by (intro bexI[of _ "f -` N \ space M"]) + by (simp add: eventually_ae_filter, intro bexI[of _ "f -` N \ space M"]) (auto simp: emeasure_distr measurable_def) qed @@ -2352,9 +2357,9 @@ show "(\i. ?M (F i)) \ ?M (\i. F i)" proof cases assume "\i. \j\i. F i = F j" - then guess i .. note i = this - { fix j from i \incseq F\ have "F j \ F i" - by (cases "i \ j") (auto simp: incseq_def) } + then obtain i where i: "\j\i. F i = F j" .. + with \incseq F\ have "F j \ F i" for j + by (cases "i \ j") (auto simp: incseq_def) then have eq: "(\i. F i) = F i" by auto with i show ?thesis @@ -2375,7 +2380,7 @@ fix n :: nat show "\k::nat\UNIV. of_nat n \ ?M (F k)" proof (induct n) case (Suc n) - then guess k .. note k = this + then obtain k where "of_nat n \ ?M (F k)" .. moreover have "finite (F k) \ finite (F (f k)) \ card (F k) < card (F (f k))" using \F k \ F (f k)\ by (simp add: psubset_card_mono) moreover have "finite (F (f k)) \ finite (F k)" @@ -2842,16 +2847,19 @@ show "finite_measure (restrict_space M A)" "finite_measure (restrict_space N A)" by (auto simp: space_restrict_space emeasure_restrict_space less_top intro!: finite_measureI) qed (simp add: sets_restrict_space) - then guess Y .. then show ?thesis - apply (intro bexI[of _ Y] conjI ballI conjI) - apply (simp_all add: sets_restrict_space emeasure_restrict_space) - apply safe - subgoal for X Z - by (erule ballE[of _ _ X]) (auto simp add: Int_absorb1) - subgoal for X Z - by (erule ballE[of _ _ X]) (auto simp add: Int_absorb1 ac_simps) - apply auto + apply - + apply (erule bexE) + subgoal for Y + apply (intro bexI[of _ Y] conjI ballI conjI) + apply (simp_all add: sets_restrict_space emeasure_restrict_space) + apply safe + subgoal for X Z + by (erule ballE[of _ _ X]) (auto simp add: Int_absorb1) + subgoal for X Z + by (erule ballE[of _ _ X]) (auto simp add: Int_absorb1 ac_simps) + apply auto + done done qed diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Analysis/Nonnegative_Lebesgue_Integration.thy --- a/src/HOL/Analysis/Nonnegative_Lebesgue_Integration.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Analysis/Nonnegative_Lebesgue_Integration.thy Fri Sep 24 22:23:26 2021 +0200 @@ -862,7 +862,9 @@ unfolding nn_integral_def proof (safe intro!: SUP_mono) fix n assume n: "simple_function M n" "n \ u" - from ae[THEN AE_E] guess N . note N = this + from ae[THEN AE_E] obtain N + where N: "{x \ space M. \ u x \ v x} \ N" "emeasure M N = 0" "N \ sets M" + by auto then have ae_N: "AE x in M. x \ N" by (auto intro: AE_not_in) let ?n = "\x. n x * indicator (space M - N) x" have "AE x in M. n x \ ?n x" "simple_function M ?n" @@ -1000,7 +1002,9 @@ proof - from f have "AE x in M. \i. f i x \ f (Suc i) x" by (simp add: AE_all_countable) - from this[THEN AE_E] guess N . note N = this + from this[THEN AE_E] obtain N + where N: "{x \ space M. \ (\i. f i x \ f (Suc i) x)} \ N" "emeasure M N = 0" "N \ sets M" + by auto let ?f = "\i x. if x \ space M - N then f i x else 0" have f_eq: "AE x in M. \i. ?f i x = f i x" using N by (auto intro!: AE_I[of _ _ N]) then have "(\\<^sup>+ x. (SUP i. f i x) \M) = (\\<^sup>+ x. (SUP i. ?f i x) \M)" @@ -1045,14 +1049,24 @@ shows "(\\<^sup>+ x. a * f x + g x \M) = a * integral\<^sup>N M f + integral\<^sup>N M g" (is "integral\<^sup>N M ?L = _") proof - - from borel_measurable_implies_simple_function_sequence'[OF f(1)] guess u . + obtain u + where "\i. simple_function M (u i)" "incseq u" "\i x. u i x < top" "\x. (SUP i. u i x) = f x" + using borel_measurable_implies_simple_function_sequence' f(1) + by auto note u = nn_integral_monotone_convergence_simple[OF this(2,1)] this - from borel_measurable_implies_simple_function_sequence'[OF g(1)] guess v . + + obtain v where + "\i. simple_function M (v i)" "incseq v" "\i x. v i x < top" "\x. (SUP i. v i x) = g x" + using borel_measurable_implies_simple_function_sequence' g(1) + by auto note v = nn_integral_monotone_convergence_simple[OF this(2,1)] this + let ?L' = "\i x. a * u i x + v i x" have "?L \ borel_measurable M" using assms by auto - from borel_measurable_implies_simple_function_sequence'[OF this] guess l . + from borel_measurable_implies_simple_function_sequence'[OF this] + obtain l where "\i. simple_function M (l i)" "incseq l" "\i x. l i x < top" "\x. (SUP i. l i x) = a * f x + g x" + by auto note l = nn_integral_monotone_convergence_simple[OF this(2,1)] this have inc: "incseq (\i. a * integral\<^sup>S M (u i))" "incseq (\i. integral\<^sup>S M (v i))" diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Analysis/Radon_Nikodym.thy --- a/src/HOL/Analysis/Radon_Nikodym.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Analysis/Radon_Nikodym.thy Fri Sep 24 22:23:26 2021 +0200 @@ -261,7 +261,10 @@ from this[THEN bspec, OF sets.top] show "integral\<^sup>N M g \ N (space M)" by (simp cong: nn_integral_cong) qed - from ennreal_SUP_countable_SUP [OF \G \ {}\, of "integral\<^sup>N M"] guess ys .. note ys = this + from ennreal_SUP_countable_SUP [OF \G \ {}\, of "integral\<^sup>N M"] + obtain ys :: "nat \ ennreal" + where ys: "range ys \ integral\<^sup>N M ` G \ Sup (integral\<^sup>N M ` G) = Sup (range ys)" + by auto then have "\n. \g. g\G \ integral\<^sup>N M g = ys n" proof safe fix n assume "range ys \ integral\<^sup>N M ` G" @@ -774,8 +777,11 @@ next assume eq: "density M f = density M g" interpret f: sigma_finite_measure "density M f" by fact - from f.sigma_finite_incseq guess A . note cover = this - + from f.sigma_finite_incseq obtain A where cover: "range A \ sets (density M f)" + "\ (range A) = space (density M f)" + "\i. emeasure (density M f) (A i) \ \" + "incseq A" + by auto have "AE x in M. \i. x \ A i \ f x = g x" unfolding AE_all_countable proof @@ -821,7 +827,9 @@ using fin by (auto elim!: AE_Ball_mp simp: less_top ennreal_mult_less_top) next assume AE: "AE x in M. f x \ \" - from sigma_finite guess Q . note Q = this + from sigma_finite obtain Q :: "nat \ 'a set" + where Q: "range Q \ sets M" "\ (range Q) = space M" "\i. emeasure M (Q i) \ \" + by auto define A where "A i = f -` (case i of 0 \ {\} | Suc n \ {.. ennreal(of_nat (Suc n))}) \ space M" for i { fix i j have "A i \ Q j \ sets M" @@ -977,7 +985,8 @@ let ?M' = "distr M M' T" and ?N' = "distr N M' T" interpret M': sigma_finite_measure ?M' proof - from sigma_finite_countable guess F .. note F = this + from sigma_finite_countable obtain F + where F: "countable F \ F \ sets M \ \ F = space M \ (\a\F. emeasure M a \ \)" .. show "\A. countable A \ A \ sets (distr M M' T) \ \A = space (distr M M' T) \ (\a\A. emeasure (distr M M' T) a \ \)" proof (intro exI conjI ballI) show *: "(\A. T' -` A \ space ?M') ` F \ sets ?M'" @@ -992,7 +1001,7 @@ have Fi: "A \ sets M" using F \A\F\ by auto ultimately show "emeasure ?M' X \ \" using F T T' \A\F\ by (simp add: emeasure_distr) - qed (insert F, auto) + qed (use F in auto) qed have "(RN_deriv ?M' ?N') \ T \ borel_measurable M" using T ac by measurable diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Analysis/Regularity.thy --- a/src/HOL/Analysis/Regularity.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Analysis/Regularity.thy Fri Sep 24 22:23:26 2021 +0200 @@ -30,7 +30,9 @@ (\e. e > 0 \ \B. A \ B \ open B \ emeasure M B \ emeasure M A + ennreal e) \ ?outer A" by (rule ennreal_approx_INF) (force intro!: emeasure_mono simp: emeasure_eq_measure sb)+ - from countable_dense_setE guess X::"'a set" . note X = this + from countable_dense_setE obtain X :: "'a set" + where X: "countable X" "\Y :: 'a set. open Y \ Y \ {} \ \d\X. d \ Y" + by auto { fix r::real assume "r > 0" hence "\y. open (ball y r)" "\y. ball y r \ {}" by auto with X(2)[OF this] @@ -114,7 +116,7 @@ proof safe show "complete K" using \closed K\ by (simp add: complete_eq_closed) fix e'::real assume "0 < e'" - from nat_approx_posE[OF this] guess n . note n = this + then obtain n where n: "1 / real (Suc n) < e'" by (rule nat_approx_posE) let ?k = "from_nat_into X ` {0..k e (Suc n)}" have "finite ?k" by simp moreover have "K \ (\x\?k. ball x e')" unfolding K_def B_def using n by force @@ -164,12 +166,11 @@ proof (auto simp del: of_nat_Suc, rule ccontr) fix x assume "infdist x A \ 0" - hence pos: "infdist x A > 0" using infdist_nonneg[of x A] by simp - from nat_approx_posE[OF this] guess n . - moreover + then have pos: "infdist x A > 0" using infdist_nonneg[of x A] by simp + then obtain n where n: "1 / real (Suc n) < infdist x A" by (rule nat_approx_posE) assume "\i. infdist x A < 1 / real (Suc i)" - hence "infdist x A < 1 / real (Suc n)" by auto - ultimately show False by simp + then have "infdist x A < 1 / real (Suc n)" by auto + with n show False by simp qed also have "M \ = (INF n. emeasure M (?G (1 / real (Suc n))))" proof (rule INF_emeasure_decseq[symmetric], safe) diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Analysis/Set_Integral.thy --- a/src/HOL/Analysis/Set_Integral.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Analysis/Set_Integral.thy Fri Sep 24 22:23:26 2021 +0200 @@ -415,7 +415,7 @@ show "(\i. indicator (A i) x *\<^sub>R f x) \ indicator (\i. A i) x *\<^sub>R f x" proof cases assume "\i. x \ A i" - then guess i .. + then obtain i where "x \ A i" .. then have *: "eventually (\i. x \ A i) sequentially" using \x \ A i\ \mono A\ by (auto simp: eventually_sequentially mono_def) show ?thesis diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Analysis/Sigma_Algebra.thy --- a/src/HOL/Analysis/Sigma_Algebra.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Analysis/Sigma_Algebra.thy Fri Sep 24 22:23:26 2021 +0200 @@ -669,7 +669,8 @@ case (Union a) then have "\i. \x. x \ sigma_sets sp st \ a i = A \ x" by (auto simp: image_iff Bex_def) - from choice[OF this] guess f .. + then obtain f where "\x. f x \ sigma_sets sp st \ a x = A \ f x" + by metis then show ?case by (auto intro!: bexI[of _ "(\x. f x)"] sigma_sets.Union simp add: image_iff) @@ -771,8 +772,9 @@ next case (Union F) then have "\i. \B. F i = X -` B \ \ \ B \ sigma_sets \' M'" by auto - from choice[OF this] guess A .. note A = this - with A show ?case + then obtain A where "\x. F x = X -` A x \ \ \ A x \ sigma_sets \' M'" + by metis + then show ?case by (auto simp: vimage_UN[symmetric] intro: sigma_sets.Union) qed qed @@ -843,13 +845,15 @@ and "a \ b = {}" shows "a \ b \ generated_ring" proof - - from a guess Ca .. note Ca = this - from b guess Cb .. note Cb = this + from a b obtain Ca Cb + where Ca: "finite Ca" "disjoint Ca" "Ca \ M" "a = \ Ca" + and Cb: "finite Cb" "disjoint Cb" "Cb \ M" "b = \ Cb" + using generated_ringE by metis show ?thesis proof - show "disjoint (Ca \ Cb)" - using \a \ b = {}\ Ca Cb by (auto intro!: disjoint_union) - qed (insert Ca Cb, auto) + from \a \ b = {}\ Ca Cb show "disjoint (Ca \ Cb)" + by (auto intro!: disjoint_union) + qed (use Ca Cb in auto) qed lemma (in semiring_of_sets) generated_ring_empty: "{} \ generated_ring" @@ -867,8 +871,10 @@ assumes a: "a \ generated_ring" and b: "b \ generated_ring" shows "a \ b \ generated_ring" proof - - from a guess Ca .. note Ca = this - from b guess Cb .. note Cb = this + from a b obtain Ca Cb + where Ca: "finite Ca" "disjoint Ca" "Ca \ M" "a = \ Ca" + and Cb: "finite Cb" "disjoint Cb" "Cb \ M" "b = \ Cb" + using generated_ringE by metis define C where "C = (\(a,b). a \ b)` (Ca\Cb)" show ?thesis proof @@ -890,7 +896,7 @@ then show ?thesis by auto qed qed - qed (insert Ca Cb, auto simp: C_def) + qed (use Ca Cb in \auto simp: C_def\) qed lemma (in semiring_of_sets) generated_ring_Inter: @@ -909,9 +915,12 @@ using sets_into_space by (auto simp: generated_ring_def generated_ring_empty) show "{} \ ?R" by (rule generated_ring_empty) - { fix a assume a: "a \ ?R" then guess Ca .. note Ca = this - fix b assume b: "b \ ?R" then guess Cb .. note Cb = this - + { + fix a b assume "a \ ?R" "b \ ?R" + then obtain Ca Cb + where Ca: "finite Ca" "disjoint Ca" "Ca \ M" "a = \ Ca" + and Cb: "finite Cb" "disjoint Cb" "Cb \ M" "b = \ Cb" + using generated_ringE by metis show "a - b \ ?R" proof cases assume "Cb = {}" with Cb \a \ ?R\ show ?thesis @@ -932,7 +941,8 @@ show "finite Ca" "finite Cb" "Cb \ {}" by fact+ qed finally show "a - b \ ?R" . - qed } + qed + } note Diff = this fix a b assume sets: "a \ ?R" "b \ ?R" diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Analysis/Summation_Tests.thy --- a/src/HOL/Analysis/Summation_Tests.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Analysis/Summation_Tests.thy Fri Sep 24 22:23:26 2021 +0200 @@ -115,7 +115,7 @@ define n where "n = nat \log c K\" from unbounded have "\m>n. c < root m (norm (f m))" unfolding bdd_above_def by (auto simp: not_le) - then guess m by (elim exE conjE) note m = this + then obtain m where m: "n < m" "c < root m (norm (f m))" by auto from c K have "K = c powr log c K" by (simp add: powr_def log_def) also from c have "c powr log c K \ c powr real n" unfolding n_def by (intro powr_mono, linarith, simp) @@ -526,7 +526,7 @@ with assms show ?thesis by simp next assume "\l'. l = ereal l' \ l' > 0" - then guess l' by (elim exE conjE) note l' = this + then obtain l' where l': "l = ereal l'" "0 < l'" by auto hence "l \ \" by auto have "l * ereal (norm z) < l * conv_radius f" by (intro ereal_mult_strict_left_mono) (simp_all add: l' assms) diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Combinatorics/Multiset_Permutations.thy --- a/src/HOL/Combinatorics/Multiset_Permutations.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Combinatorics/Multiset_Permutations.thy Fri Sep 24 22:23:26 2021 +0200 @@ -131,7 +131,7 @@ lemma permutations_of_multiset_not_empty [simp]: "permutations_of_multiset A \ {}" proof - - from ex_mset[of A] guess xs .. + from ex_mset[of A] obtain xs where "mset xs = A" .. thus ?thesis by (auto simp: permutations_of_multiset_def) qed @@ -142,7 +142,8 @@ from ex_mset[of A] obtain ys where ys: "mset ys = A" .. with A have "mset xs = mset (map f ys)" by (simp add: permutations_of_multiset_def) - from mset_eq_permutation[OF this] guess \ . note \ = this + then obtain \ where \: "\ permutes {.. (map f ys) = xs" + by (rule mset_eq_permutation) with ys have "xs = map f (permute_list \ ys)" by (simp add: permute_list_map) moreover from \ ys have "permute_list \ ys \ permutations_of_multiset A" diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Complex_Analysis/Complex_Residues.thy --- a/src/HOL/Complex_Analysis/Complex_Residues.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Complex_Analysis/Complex_Residues.thy Fri Sep 24 22:23:26 2021 +0200 @@ -363,9 +363,11 @@ assumes "f has_fps_expansion F" shows "residue (\z. f z / z ^ Suc n) 0 = fps_nth F n" proof - - from has_fps_expansion_imp_holomorphic[OF assms] guess s . note s = this - have "residue (\z. f z / (z - 0) ^ Suc n) 0 = (deriv ^^ n) f 0 / fact n" - using assms s unfolding has_fps_expansion_def + from has_fps_expansion_imp_holomorphic[OF assms] obtain s + where "open s" "0 \ s" "f holomorphic_on s" "\z. z \ s \ f z = eval_fps F z" + by auto + with assms have "residue (\z. f z / (z - 0) ^ Suc n) 0 = (deriv ^^ n) f 0 / fact n" + unfolding has_fps_expansion_def by (intro residue_holomorphic_over_power[of s]) (auto simp: zero_ereal_def) also from assms have "\ = fps_nth F n" by (subst fps_nth_fps_expansion) auto diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Computational_Algebra/Factorial_Ring.thy --- a/src/HOL/Computational_Algebra/Factorial_Ring.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Computational_Algebra/Factorial_Ring.thy Fri Sep 24 22:23:26 2021 +0200 @@ -755,8 +755,7 @@ thus ?thesis by (intro exI[of _ "{#normalize a#}"]) auto next case True - then guess b by (elim exE conjE) note b = this - + then obtain b where b: "b dvd a" "\ is_unit b" "\ a dvd b" by auto from b have "?fctrs b \ ?fctrs a" by (auto intro: dvd_trans) moreover from b have "normalize a \ ?fctrs b" "normalize a \ ?fctrs a" by simp_all hence "?fctrs b \ ?fctrs a" by blast @@ -766,7 +765,8 @@ moreover from \a \ 0\ b have "b \ 0" by auto ultimately have "\A. (\x. x \# A \ prime_elem x) \ normalize (prod_mset A) = normalize b" by (intro less) auto - then guess A .. note A = this + then obtain A where A: "(\x. x \# A \ prime_elem x) \ normalize (\\<^sub># A) = normalize b" + by auto define c where "c = a div b" from b have c: "a = b * c" by (simp add: c_def) @@ -785,7 +785,8 @@ by (rule psubset_card_mono) with \c \ 0\ have "\A. (\x. x \# A \ prime_elem x) \ normalize (prod_mset A) = normalize c" by (intro less) auto - then guess B .. note B = this + then obtain B where B: "(\x. x \# B \ prime_elem x) \ normalize (\\<^sub># B) = normalize c" + by auto show ?thesis proof (rule exI[of _ "A + B"]; safe) @@ -840,7 +841,15 @@ case False hence "a \ 0" "b \ 0" by blast+ note nz = \x \ 0\ this - from nz[THEN prime_factorization_exists'] guess A B C . note ABC = this + from nz[THEN prime_factorization_exists'] obtain A B C + where ABC: + "\z. z \# A \ prime z" + "normalize (\\<^sub># A) = normalize x" + "\z. z \# B \ prime z" + "normalize (\\<^sub># B) = normalize a" + "\z. z \# C \ prime z" + "normalize (\\<^sub># C) = normalize b" + by this blast have "irreducible (prod_mset A)" by (subst irreducible_cong[OF ABC(2)]) fact @@ -855,7 +864,7 @@ normalize (prod_mset A) dvd normalize (prod_mset C)" by simp thus ?thesis unfolding ABC by simp qed auto -qed (insert assms, simp_all add: irreducible_def) +qed (use assms in \simp_all add: irreducible_def\) lemma finite_divisor_powers: assumes "y \ 0" "\is_unit x" @@ -867,7 +876,14 @@ next case False note nz = this \y \ 0\ - from nz[THEN prime_factorization_exists'] guess A B . note AB = this + from nz[THEN prime_factorization_exists'] obtain A B + where AB: + "\z. z \# A \ prime z" + "normalize (\\<^sub># A) = normalize x" + "\z. z \# B \ prime z" + "normalize (\\<^sub># B) = normalize y" + by this blast + from AB assms have "A \ {#}" by (auto simp: normalize_1_iff) from AB(2,4) prod_mset_primes_finite_divisor_powers [of A B, OF AB(1,3) this] have "finite {n. prod_mset A ^ n dvd prod_mset B}" by simp @@ -883,7 +899,8 @@ assumes "x \ 0" shows "finite {p. prime p \ p dvd x}" proof - - from prime_factorization_exists'[OF assms] guess A . note A = this + from prime_factorization_exists'[OF assms] obtain A + where A: "\z. z \# A \ prime z" "normalize (\\<^sub># A) = normalize x" by this blast have "{p. prime p \ p dvd x} \ set_mset A" proof safe fix p assume p: "prime p" and dvd: "p dvd x" @@ -925,12 +942,14 @@ assumes "a \ 0" "\is_unit a" shows "\b. b dvd a \ prime b" proof - - from prime_factorization_exists'[OF assms(1)] guess A . note A = this - moreover from A and assms have "A \ {#}" by auto + from prime_factorization_exists'[OF assms(1)] + obtain A where A: "\z. z \# A \ prime z" "normalize (\\<^sub># A) = normalize a" + by this blast + with assms have "A \ {#}" by auto then obtain x where "x \# A" by blast with A(1) have *: "x dvd normalize (prod_mset A)" "prime x" by (auto simp: dvd_prod_mset) - hence "x dvd a" unfolding A by simp + hence "x dvd a" by (simp add: A(2)) with * show ?thesis by blast qed @@ -939,7 +958,9 @@ shows "P x" proof (cases "x = 0") case False - from prime_factorization_exists'[OF this] guess A . note A = this + from prime_factorization_exists'[OF this] + obtain A where A: "\z. z \# A \ prime z" "normalize (\\<^sub># A) = normalize x" + by this blast from A obtain u where u: "is_unit u" "x = u * prod_mset A" by (elim associatedE2) @@ -959,7 +980,7 @@ shows "is_unit a" proof (rule ccontr) assume "\is_unit a" - from prime_divisor_exists[OF assms(1) this] guess b by (elim exE conjE) + from prime_divisor_exists[OF assms(1) this] obtain b where "b dvd a" "prime b" by auto with assms(2)[of b] show False by (simp add: prime_def) qed @@ -1138,7 +1159,8 @@ next define n where "n = multiplicity p x" from assms have "\is_unit p" by simp - from multiplicity_decompose'[OF False this] guess y . note y = this [folded n_def] + from multiplicity_decompose'[OF False this] + obtain y where y [folded n_def]: "x = p ^ multiplicity p x * y" "\ p dvd y" . from y have "p ^ Suc n dvd q * x \ p ^ n * p dvd p ^ n * (q * y)" by (simp add: mult_ac) also from assms have "\ \ p dvd q * y" by simp also have "\ \ p dvd q \ p dvd y" by (rule prime_elem_dvd_mult_iff) fact+ diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Computational_Algebra/Formal_Power_Series.thy --- a/src/HOL/Computational_Algebra/Formal_Power_Series.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Computational_Algebra/Formal_Power_Series.thy Fri Sep 24 22:23:26 2021 +0200 @@ -4079,7 +4079,7 @@ from v have [simp]: "length v = Suc m" by (simp add: A_def natpermute_def) from v have "\j. j \ m \ v ! j = k" by (auto simp: set_conv_nth A_def natpermute_def less_Suc_eq_le) - then guess j by (elim exE conjE) note j = this + then obtain j where j: "j \ m" "v ! j = k" by auto from v have "k = sum_list v" by (simp add: A_def natpermute_def) also have "\ = (\i=0..m. v ! i)" diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Computational_Algebra/Normalized_Fraction.thy --- a/src/HOL/Computational_Algebra/Normalized_Fraction.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Computational_Algebra/Normalized_Fraction.thy Fri Sep 24 22:23:26 2021 +0200 @@ -64,8 +64,13 @@ obtains d where "fst x = fst (normalize_quot x) * d" "snd x = snd (normalize_quot x) * d" "d dvd fst x" "d dvd snd x" "d \ 0" proof - - from normalize_quotE[OF assms, of "fst x"] guess d . - from this show ?thesis unfolding prod.collapse by (intro that[of d]) + from normalize_quotE[OF assms, of "fst x"] obtain d where + "fst x = fst (normalize_quot (fst x, snd x)) * d" + "snd x = snd (normalize_quot (fst x, snd x)) * d" + "d dvd fst x" + "d dvd snd x" + "d \ 0" . + then show ?thesis unfolding prod.collapse by (intro that[of d]) qed lemma coprime_normalize_quot: @@ -130,7 +135,13 @@ define x' where "x' = normalize_quot x" obtain a b where [simp]: "x = (a, b)" by (cases x) from rel have "b \ 0" by simp - from normalize_quotE[OF this, of a] guess d . + from normalize_quotE[OF this, of a] obtain d + where + "a = fst (normalize_quot (a, b)) * d" + "b = snd (normalize_quot (a, b)) * d" + "d dvd a" + "d dvd b" + "d \ 0" . hence "a = fst x' * d" "b = snd x' * d" "d \ 0" "snd x' \ 0" by (simp_all add: x'_def) thus "fractrel (case x' of (a, b) \ if b = 0 then (0, 1) else (a, b)) x" by (auto simp add: case_prod_unfold) @@ -173,8 +184,20 @@ snd x * snd y * (fst (normalize_quot x) * snd (normalize_quot y) + snd (normalize_quot x) * fst (normalize_quot y))" proof - - from normalize_quotE'[OF assms(1)] guess d . note d = this - from normalize_quotE'[OF assms(2)] guess e . note e = this + from normalize_quotE'[OF assms(1)] obtain d + where d: + "fst x = fst (normalize_quot x) * d" + "snd x = snd (normalize_quot x) * d" + "d dvd fst x" + "d dvd snd x" + "d \ 0" . + from normalize_quotE'[OF assms(2)] obtain e + where e: + "fst y = fst (normalize_quot y) * e" + "snd y = snd (normalize_quot y) * e" + "e dvd fst y" + "e dvd snd y" + "e \ 0" . show ?thesis by (simp_all add: d e algebra_simps) qed @@ -218,9 +241,16 @@ from assms have "b \ 0" "d \ 0" by auto with assms have "normalize b = b" "normalize d = d" by (auto intro: normalize_unit_factor_eqI) - from normalize_quotE [OF \b \ 0\, of c] guess k . + from normalize_quotE [OF \b \ 0\, of c] obtain k + where + "c = fst (normalize_quot (c, b)) * k" + "b = snd (normalize_quot (c, b)) * k" + "k dvd c" "k dvd b" "k \ 0" . note k = this [folded \gcd a b = 1\ \gcd c d = 1\ assms(3) assms(4)] - from normalize_quotE [OF \d \ 0\, of a] guess l . + from normalize_quotE [OF \d \ 0\, of a] obtain l + where "a = fst (normalize_quot (a, d)) * l" + "d = snd (normalize_quot (a, d)) * l" + "l dvd a" "l dvd d" "l \ 0" . note l = this [folded \gcd a b = 1\ \gcd c d = 1\ assms(3) assms(4)] from k l show "a * c * (f * h) = b * d * (e * g)" by (metis e_def f_def g_def h_def mult.commute mult.left_commute) @@ -241,8 +271,18 @@ (fst (normalize_quot x) * fst (normalize_quot y), snd (normalize_quot x) * snd (normalize_quot y))" proof - - from normalize_quotE'[OF assms(1)] guess d . note d = this - from normalize_quotE'[OF assms(2)] guess e . note e = this + from normalize_quotE'[OF assms(1)] obtain d where d: + "fst x = fst (normalize_quot x) * d" + "snd x = snd (normalize_quot x) * d" + "d dvd fst x" + "d dvd snd x" + "d \ 0" . + from normalize_quotE'[OF assms(2)] obtain e where e: + "fst y = fst (normalize_quot y) * e" + "snd y = snd (normalize_quot y) * e" + "e dvd fst y" + "e dvd snd y" + "e \ 0" . show ?thesis by (simp_all add: d e algebra_simps normalize_quot_eq_iff) qed @@ -269,7 +309,11 @@ defines "a' \ fst (normalize_quot (a, b))" and "b' \ snd (normalize_quot (a, b))" shows "normalize_quot (b, a) = (b' div unit_factor a', a' div unit_factor a')" proof (rule normalize_quotI) - from normalize_quotE[OF assms(2), of a] guess d . note d = this [folded assms(3,4)] + from normalize_quotE[OF assms(2), of a] obtain d where + "a = fst (normalize_quot (a, b)) * d" + "b = snd (normalize_quot (a, b)) * d" + "d dvd a" "d dvd b" "d \ 0" . + note d = this [folded assms(3,4)] show "b * (a' div unit_factor a') = a * (b' div unit_factor a')" using assms(1,2) d by (simp add: div_unit_factor [symmetric] unit_div_mult_swap mult_ac del: div_unit_factor) @@ -301,7 +345,10 @@ by simp_all from \is_unit v\ have "coprime v = top" by (simp add: fun_eq_iff is_unit_left_imp_coprime) - from normalize_quotE[OF False, of x] guess d . + from normalize_quotE[OF False, of x] obtain d where + "x = fst (normalize_quot (x, y)) * d" + "y = snd (normalize_quot (x, y)) * d" + "d dvd x" "d dvd y" "d \ 0" . note d = this[folded assms(2,3)] from assms have "coprime x' y'" "unit_factor y' = 1" by (simp_all add: coprime_normalize_quot) @@ -318,7 +365,12 @@ shows "normalize_quot (x, y div u) = (x' * u, y')" proof (cases "y = 0") case False - from normalize_quotE[OF this, of x] guess d . note d = this[folded assms(2,3)] + from normalize_quotE[OF this, of x] + obtain d where d: + "x = fst (normalize_quot (x, y)) * d" + "y = snd (normalize_quot (x, y)) * d" + "d dvd x" "d dvd y" "d \ 0" . + note d = this[folded assms(2,3)] from assms have "coprime x' y'" "unit_factor y' = 1" by (simp_all add: coprime_normalize_quot) with d \is_unit u\ show ?thesis by (auto simp add: normalized_fracts_def is_unit_left_imp_coprime unit_div_eq_0_iff intro: normalize_quotI) diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Computational_Algebra/Polynomial.thy --- a/src/HOL/Computational_Algebra/Polynomial.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Computational_Algebra/Polynomial.thy Fri Sep 24 22:23:26 2021 +0200 @@ -2661,11 +2661,14 @@ shows "\x\A. poly p b - poly p a = (b - a) * poly (pderiv p) x" proof (cases a b rule: linorder_cases) case less - from poly_MVT[OF less, of p] guess x by (elim exE conjE) + from poly_MVT[OF less, of p] obtain x + where "a < x" "x < b" "poly p b - poly p a = (b - a) * poly (pderiv p) x" + by auto then show ?thesis by (intro bexI[of _ x]) (auto intro!: subsetD[OF assms]) next case greater - from poly_MVT[OF greater, of p] guess x by (elim exE conjE) + from poly_MVT[OF greater, of p] obtain x + where "b < x" "x < a" "poly p a - poly p b = (a - b) * poly (pderiv p) x" by auto then show ?thesis by (intro bexI[of _ x]) (auto simp: algebra_simps intro!: subsetD[OF assms]) qed (use assms in auto) diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Computational_Algebra/Polynomial_Factorial.thy --- a/src/HOL/Computational_Algebra/Polynomial_Factorial.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Computational_Algebra/Polynomial_Factorial.thy Fri Sep 24 22:23:26 2021 +0200 @@ -357,9 +357,15 @@ shows "p dvd q" proof - from assms(1) obtain r where r: "fract_poly q = fract_poly p * r" by (erule dvdE) - from content_decompose_fract[of r] guess c r' . note r' = this + from content_decompose_fract[of r] + obtain c r' where r': "r = smult c (map_poly to_fract r')" "content r' = 1" . from r r' have eq: "fract_poly q = smult c (fract_poly (p * r'))" by simp - from fract_poly_smult_eqE[OF this] guess a b . note ab = this + from fract_poly_smult_eqE[OF this] obtain a b + where ab: + "c = to_fract b / to_fract a" + "smult a q = smult b (p * r')" + "coprime a b" + "normalize a = a" . have "content (smult a q) = content (smult b (p * r'))" by (simp only: ab(2)) hence eq': "normalize b = a * content q" by (simp add: assms content_mult r' ab(4)) have "1 = gcd a (normalize b)" by (simp add: ab) @@ -444,7 +450,7 @@ proof safe assume p: "irreducible p" - from content_decompose[of p] guess p' . note p' = this + from content_decompose[of p] obtain p' where p': "p = smult (content p) p'" "content p' = 1" . hence "p = [:content p:] * p'" by simp from p this have "[:content p:] dvd 1 \ p' dvd 1" by (rule irreducibleD) moreover have "\p' dvd 1" @@ -470,12 +476,16 @@ qed next fix q r assume qr: "fract_poly p = q * r" - from content_decompose_fract[of q] guess cg q' . note q = this - from content_decompose_fract[of r] guess cr r' . note r = this + from content_decompose_fract[of q] + obtain cg q' where q: "q = smult cg (map_poly to_fract q')" "content q' = 1" . + from content_decompose_fract[of r] + obtain cr r' where r: "r = smult cr (map_poly to_fract r')" "content r' = 1" . from qr q r p have nz: "cg \ 0" "cr \ 0" by auto from qr have eq: "fract_poly p = smult (cr * cg) (fract_poly (q' * r'))" by (simp add: q r) - from fract_poly_smult_eqE[OF this] guess a b . note ab = this + from fract_poly_smult_eqE[OF this] obtain a b + where ab: "cr * cg = to_fract b / to_fract a" + "smult a p = smult b (q' * r')" "coprime a b" "normalize a = a" . hence "content (smult a p) = content (smult b (q' * r'))" by (simp only:) with ab(4) have a: "a = normalize b" by (simp add: content_mult q r) then have "normalize b = gcd a b" @@ -641,7 +651,12 @@ finally have eq: "fract_poly p = smult c' (fract_poly e)" . also obtain b where b: "c' = to_fract b" "is_unit b" proof - - from fract_poly_smult_eqE[OF eq] guess a b . note ab = this + from fract_poly_smult_eqE[OF eq] + obtain a b where ab: + "c' = to_fract b / to_fract a" + "smult a p = smult b e" + "coprime a b" + "normalize a = a" . from ab(2) have "content (smult a p) = content (smult b e)" by (simp only: ) with assms content_e have "a = normalize b" by (simp add: ab(4)) with ab have ab': "a = 1" "is_unit b" @@ -673,7 +688,8 @@ define B where "B = image_mset (\x. [:x:]) (prime_factorization (content p))" have "\A. (\p. p \# A \ prime_elem p) \ prod_mset A = normalize (primitive_part p)" by (rule poly_prime_factorization_exists_content_1) (insert assms, simp_all) - then guess A by (elim exE conjE) note A = this + then obtain A where A: "\p. p \# A \ prime_elem p" "\\<^sub># A = normalize (primitive_part p)" + by blast have "normalize (prod_mset (A + B)) = normalize (prod_mset A * normalize (prod_mset B))" by simp also from assms have "normalize (prod_mset B) = normalize [:content p:]" diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Number_Theory/Residue_Primitive_Roots.thy --- a/src/HOL/Number_Theory/Residue_Primitive_Roots.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Number_Theory/Residue_Primitive_Roots.thy Fri Sep 24 22:23:26 2021 +0200 @@ -755,7 +755,15 @@ from assms have "n \ 0" by auto from False have "\p\prime_factors n. p \ 2" using assms Ex_other_prime_factor[of n 2] by auto - from divide_out_primepow_ex[OF \n \ 0\ this] guess p k n' . note p = this + from divide_out_primepow_ex[OF \n \ 0\ this] + obtain p k n' + where p: + "p \ 2" + "prime p" + "p dvd n" + "\ p dvd n'" + "0 < k" + "n = p ^ k * n'" . from p have coprime: "coprime (p ^ k) n'" using p prime_imp_coprime by auto have "odd p" diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Probability/Discrete_Topology.thy --- a/src/HOL/Probability/Discrete_Topology.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Probability/Discrete_Topology.thy Fri Sep 24 22:23:26 2021 +0200 @@ -32,10 +32,10 @@ instance discrete :: (type) complete_space proof - fix X::"nat\'a discrete" assume "Cauchy X" - hence "\n. \m\n. X n = X m" + fix X::"nat\'a discrete" + assume "Cauchy X" + then obtain n where "\m\n. X n = X m" by (force simp: dist_discrete_def Cauchy_def split: if_split_asm dest:spec[where x=1]) - then guess n .. thus "convergent X" by (intro convergentI[where L="X n"] tendstoI eventually_sequentiallyI[of n]) (simp add: dist_discrete_def) diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Probability/Fin_Map.thy --- a/src/HOL/Probability/Fin_Map.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Probability/Fin_Map.thy Fri Sep 24 22:23:26 2021 +0200 @@ -195,10 +195,20 @@ have "\i. \A. countable A \ (\a\A. x i \ a) \ (\a\A. open a) \ (\S. open S \ x i \ S \ (\a\A. a \ S)) \ (\a b. a \ A \ b \ A \ a \ b \ A)" (is "\i. ?th i") proof - fix i from first_countable_basis_Int_stableE[of "x i"] guess A . + fix i from first_countable_basis_Int_stableE[of "x i"] + obtain A where + "countable A" + "\C. C \ A \ (x)\<^sub>F i \ C" + "\C. C \ A \ open C" + "\S. open S \ (x)\<^sub>F i \ S \ \A\A. A \ S" + "\C D. C \ A \ D \ A \ C \ D \ A" + by auto thus "?th i" by (intro exI[where x=A]) simp qed - then guess A unfolding choice_iff .. note A = this + then obtain A + where A: "\i. countable (A i) \ Ball (A i) ((\) ((x)\<^sub>F i)) \ Ball (A i) open \ + (\S. open S \ (x)\<^sub>F i \ S \ (\a\A i. a \ S)) \ (\a b. a \ A i \ b \ A i \ a \ b \ A i)" + by (auto simp: choice_iff) hence open_sub: "\i S. i\domain x \ open (S i) \ x i\(S i) \ (\a\A i. a\(S i))" by auto have A_notempty: "\i. i \ domain x \ A i \ {}" using open_sub[of _ "\_. UNIV"] by auto let ?A = "(\f. Pi' (domain x) f) ` (Pi\<^sub>E (domain x) A)" @@ -492,7 +502,8 @@ fix i assume "i \ d" from p[OF \i \ d\, THEN metric_LIMSEQ_D, OF \0 < e\] show "\no. \n\no. dist (p i n) (q i) < e" . - qed then guess ni .. note ni = this + qed + then obtain ni where ni: "\i\d. \n\ni i. dist (p i n) (q i) < e" .. define N where "N = max Nd (Max (ni ` d))" show "\N. \n\N. dist (P n) Q < e" proof (safe intro!: exI[where x="N"]) @@ -586,10 +597,13 @@ proof (rule bchoice, safe) fix i assume "i \ domain x" hence "open (a i)" "x i \ a i" using a by auto - from topological_basisE[OF basis_proj this] guess b' . + from topological_basisE[OF basis_proj this] obtain b' + where "b' \ basis_proj" "(x)\<^sub>F i \ b'" "b' \ a i" + by blast thus "\y. x i \ y \ y \ a i \ y \ basis_proj" by auto qed - then guess B .. note B = this + then obtain B where B: "\i\domain x. (x)\<^sub>F i \ B i \ B i \ a i \ B i \ basis_proj" + by auto define B' where "B' = Pi' (domain x) (\i. (B i)::'b set)" have "B' \ Pi' (domain x) a" using B by (auto intro!: Pi'_mono simp: B'_def) also note \\ \ O'\ @@ -1016,7 +1030,7 @@ shows "sets (PiF {I} M) = sigma_sets (space (PiF {I} M)) P" proof let ?P = "sigma (space (Pi\<^sub>F {I} M)) P" - from \finite I\[THEN ex_bij_betw_finite_nat] guess T .. + from \finite I\[THEN ex_bij_betw_finite_nat] obtain T where "bij_betw T I {0..i. i \ I \ T i < card I" "\i. i\I \ the_inv_into I T (T i) = i" by (auto simp add: bij_betw_def set_eq_iff image_iff the_inv_into_f_f simp del: \finite I\) have P_closed: "P \ Pow (space (Pi\<^sub>F {I} M))" @@ -1080,7 +1094,9 @@ shows "sets (PiF {I} (\_. borel::'b::second_countable_topology measure)) = sigma_sets (space (PiF {I} (\_. borel))) {Pi' I F |F. (\i\I. F i \ Collect open)}" proof - - from open_countable_basisE[OF open_UNIV] guess S::"'b set set" . note S = this + from open_countable_basisE[OF open_UNIV] obtain S::"'b set set" + where S: "S \ (SOME B. countable B \ topological_basis B)" "UNIV = \ S" + by auto show ?thesis proof (rule sigma_fprod_algebra_sigma_eq) show "finite I" by simp diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Probability/Independent_Family.thy --- a/src/HOL/Probability/Independent_Family.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Probability/Independent_Family.thy Fri Sep 24 22:23:26 2021 +0200 @@ -423,7 +423,7 @@ have "sigma_sets (space M) (\i\I j. E i) = sigma_sets (space M) (?E j)" proof (rule sigma_sets_eqI) fix A assume "A \ (\i\I j. E i)" - then guess i .. + then obtain i where "i \ I j" "A \ E i" .. then show "A \ sigma_sets (space M) (?E j)" by (auto intro!: sigma_sets.intros(2-) exI[of _ "{i}"] exI[of _ "\i. A"]) next @@ -446,13 +446,14 @@ and "\j\K. A j \ ?E j" then have "\j\K. \E' L. A j = (\l\L. E' l) \ finite L \ L \ {} \ L \ I j \ (\l\L. E' l \ E l)" by simp - from bchoice[OF this] guess E' .. + from bchoice[OF this] obtain E' + where "\x\K. \L. A x = \ (E' x ` L) \ finite L \ L \ {} \ L \ I x \ (\l\L. E' x l \ E l)" + .. from bchoice[OF this] obtain L where A: "\j. j\K \ A j = (\l\L j. E' j l)" and L: "\j. j\K \ finite (L j)" "\j. j\K \ L j \ {}" "\j. j\K \ L j \ I j" and E': "\j l. j\K \ l \ L j \ E' j l \ E l" by auto - { fix k l j assume "k \ K" "j \ K" "l \ L j" "l \ L k" have "k = j" proof (rule ccontr) @@ -747,8 +748,9 @@ then show "?A \ Pow (space M)" by auto show "Int_stable ?A" proof (rule Int_stableI) - fix a assume "a \ ?A" then guess n .. note a = this - fix b assume "b \ ?A" then guess m .. note b = this + fix a b assume "a \ ?A" "b \ ?A" then obtain n m + where a: "n \ UNIV" "a \ sigma_sets (space M) (\ (A ` {..n}))" + and b: "m \ UNIV" "b \ sigma_sets (space M) (\ (A ` {..m}))" by auto interpret Amn: sigma_algebra "space M" "sigma_sets (space M) (\i\{..max m n}. A i)" using A sets.sets_into_space[of _ M] by (intro sigma_algebra_sigma_sets) auto have "sigma_sets (space M) (\i\{..n}. A i) \ sigma_sets (space M) (\i\{..max m n}. A i)" @@ -1083,8 +1085,14 @@ { fix i show "emeasure ?D (\\<^sub>E i\I. space (M' i)) \ \" by auto } next fix E assume E: "E \ prod_algebra I M'" - from prod_algebraE[OF E] guess J Y . note J = this - + from prod_algebraE[OF E] obtain J Y + where J: + "E = prod_emb I M' J (Pi\<^sub>E J Y)" + "finite J" + "J \ {} \ I = {}" + "J \ I" + "\i. i \ J \ Y i \ sets (M' i)" + by auto from E have "E \ sets ?P" by (auto simp: sets_PiM) then have "emeasure ?D E = emeasure M (?X -` E \ space M)" by (simp add: emeasure_distr X) diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Probability/Information.thy --- a/src/HOL/Probability/Information.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Probability/Information.thy Fri Sep 24 22:23:26 2021 +0200 @@ -273,7 +273,13 @@ proof - interpret N: prob_space N by fact have "finite_measure N" by unfold_locales - from real_RN_deriv[OF this ac] guess D . note D = this + from real_RN_deriv[OF this ac] obtain D + where D: + "random_variable borel D" + "AE x in M. RN_deriv M N x = ennreal (D x)" + "AE x in N. 0 < D x" + "\x. 0 \ D x" + by this auto have "N = density M (RN_deriv M N)" using ac by (rule density_RN_deriv[symmetric]) diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Probability/Levy.thy --- a/src/HOL/Probability/Levy.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Probability/Levy.thy Fri Sep 24 22:23:26 2021 +0200 @@ -422,7 +422,9 @@ by (subst (asm) dist_complex_def, drule spec, erule mp, auto) hence "\N. \n \ N. cmod ((CLBINT t:{-d/2..d/2}. 1 - char (M n) t) - (CLBINT t:{-d/2..d/2}. 1 - char M' t)) < d * \ / 4" by (simp add: eventually_sequentially) - then guess N .. + then obtain N + where "\n\N. cmod ((CLBINT t:{- d / 2..d / 2}. 1 - char (M n) t) - + (CLBINT t:{- d / 2..d / 2}. 1 - char M' t)) < d * \ / 4" .. hence N: "\n. n \ N \ cmod ((CLBINT t:{-d/2..d/2}. 1 - char (M n) t) - (CLBINT t:{-d/2..d/2}. 1 - char M' t)) < d * \ / 4" by auto { fix n diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Probability/Probability_Measure.thy --- a/src/HOL/Probability/Probability_Measure.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Probability/Probability_Measure.thy Fri Sep 24 22:23:26 2021 +0200 @@ -220,7 +220,8 @@ using \I \ {}\ by auto next fix k assume "k \ (\x. q x + ?F x * (expectation X - x)) ` I" - then guess x .. note x = this + then obtain x + where x: "k = q x + (INF t\{x<..} \ I. (q x - q t) / (x - t)) * (expectation X - x)" "x \ I" .. have "q x + ?F x * (expectation X - x) = expectation (\w. q x + ?F x * (X w - x))" using prob_space by (simp add: X) also have "\ \ expectation (\w. q (X w))" @@ -320,7 +321,8 @@ assumes ae: "AE x in M. P x" obtains S where "S \ {x \ space M. P x}" "S \ events" "prob S = 1" proof - - from ae[THEN AE_E] guess N . + from ae[THEN AE_E] obtain N + where "{x \ space M. \ P x} \ N" "emeasure M N = 0" "N \ events" by auto then show thesis by (intro that[of "space M - N"]) (auto simp: prob_compl prob_space emeasure_eq_measure measure_nonneg) @@ -365,7 +367,12 @@ assumes ae: "AE x in M. (\n. P n x \ Q x) \ (Q x \ (\!n. P n x))" shows "(\n. \

(x in M. P n x)) sums \

(x in M. Q x)" proof - - from ae[THEN AE_E_prob] guess S . note S = this + from ae[THEN AE_E_prob] obtain S + where S: + "S \ {x \ space M. (\n. P n x \ Q x) \ (Q x \ (\!n. P n x))}" + "S \ events" + "prob S = 1" + by auto then have disj: "disjoint_family (\n. {x\space M. P n x} \ S)" by (auto simp: disjoint_family_on_def) from S have ae_S: @@ -390,7 +397,12 @@ assumes ae: "AE x in M. (\n\I. P n x \ Q x) \ (Q x \ (\!n\I. P n x))" shows "\

(x in M. Q x) = (\n\I. \

(x in M. P n x))" proof - - from ae[THEN AE_E_prob] guess S . note S = this + from ae[THEN AE_E_prob] obtain S + where S: + "S \ {x \ space M. (\n\I. P n x \ Q x) \ (Q x \ (\!n. n \ I \ P n x))}" + "S \ events" + "prob S = 1" + by auto then have disj: "disjoint_family_on (\n. {x\space M. P n x} \ S) I" by (auto simp: disjoint_family_on_def) from S have ae_S: @@ -692,7 +704,10 @@ interpret T: sigma_finite_measure T by fact interpret ST: pair_sigma_finite S T .. - from ST.sigma_finite_up_in_pair_measure_generator guess F :: "nat \ ('b \ 'c) set" .. note F = this + from ST.sigma_finite_up_in_pair_measure_generator + obtain F :: "nat \ ('b \ 'c) set" + where F: "range F \ {A \ B |A B. A \ sets S \ B \ sets T} \ incseq F \ + \ (range F) = space S \ space T \ (\i. emeasure (S \\<^sub>M T) (F i) \ \)" .. let ?E = "{a \ b |a b. a \ sets S \ b \ sets T}" let ?P = "S \\<^sub>M T" show "distr M ?P (\x. (X x, Y x)) = density ?P f" (is "?L = ?R") diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Probability/Projective_Limit.thy --- a/src/HOL/Probability/Projective_Limit.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Probability/Projective_Limit.thy Fri Sep 24 22:23:26 2021 +0200 @@ -49,7 +49,8 @@ proof atomize_elim have "strict_mono ((+) m)" by (simp add: strict_mono_def) have "\n. (f o (\i. m + i)) n \ S" using assms by auto - from seq_compactE[OF \compact S\[unfolded compact_eq_seq_compact_metric] this] guess l r . + from seq_compactE[OF \compact S\[unfolded compact_eq_seq_compact_metric] this] + obtain l r where "l \ S" "strict_mono r" "(f \ (+) m \ r) \ l" by blast hence "l \ S" "strict_mono ((\i. m + i) o r) \ (f \ ((\i. m + i) o r)) \ l" using strict_mono_o[OF \strict_mono ((+) m)\ \strict_mono r\] by (auto simp: o_def) thus "\l r. l \ S \ strict_mono r \ (f \ r) \ l" by blast @@ -59,7 +60,8 @@ proof fix n and s :: "nat \ nat" assume "strict_mono s" - from proj_in_KE[of n] guess n0 . note n0 = this + from proj_in_KE[of n] obtain n0 where n0: "\m. n0 \ m \ (f m)\<^sub>F n \ (\k. (k)\<^sub>F n) ` K n0" + by blast have "\i \ n0. ((f \ s) i)\<^sub>F n \ (\k. (k)\<^sub>F n) ` K n0" proof safe fix i assume "n0 \ i" @@ -68,7 +70,9 @@ with n0 show "((f \ s) i)\<^sub>F n \ (\k. (k)\<^sub>F n) ` K n0 " by auto qed - from compactE'[OF compact_projset this] guess ls rs . + then obtain ls rs + where "ls \ (\k. (k)\<^sub>F n) ` K n0" "strict_mono rs" "((\i. ((f \ s) i)\<^sub>F n) \ rs) \ ls" + by (rule compactE'[OF compact_projset]) thus "\r'. strict_mono r' \ (\l. (\i. ((f \ (s \ r')) i)\<^sub>F n) \ l)" by (auto simp: o_def) qed diff -r 9e71155e3666 -r 0135a0c77b64 src/HOL/Probability/Stopping_Time.thy --- a/src/HOL/Probability/Stopping_Time.thy Fri Sep 24 13:40:14 2021 +0200 +++ b/src/HOL/Probability/Stopping_Time.thy Fri Sep 24 22:23:26 2021 +0200 @@ -143,8 +143,9 @@ lemma stopping_time_less_const: assumes T: "stopping_time F T" shows "Measurable.pred (F t) (\\. T \ < t)" proof - - guess D :: "'t set" by (rule countable_dense_setE) - note D = this + obtain D :: "'t set" + where D: "countable D" "\X. open X \ X \ {} \ \d\D. d \ X" + using countable_dense_setE by auto show ?thesis proof cases assume *: "\t't''. t' < t'' \ t'' < t"