# HG changeset patch # User wenzelm # Date 1378240252 -7200 # Node ID e93772b451ef595c21e339e133b4a4a5aec161af # Parent 7a41ec2cc522ceda02fe9edd86171c28737c4c96# Parent 344587a4d5cdea32f346ffa498b475ad8d121b1e merged diff -r 7a41ec2cc522 -r e93772b451ef src/Doc/IsarRef/Proof.thy --- a/src/Doc/IsarRef/Proof.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/Doc/IsarRef/Proof.thy Tue Sep 03 22:30:52 2013 +0200 @@ -1195,7 +1195,7 @@ later. @{rail " - @@{command case} (caseref | '(' caseref (('_' | @{syntax name}) +) ')') + @@{command case} (caseref | '(' caseref (('_' | @{syntax name}) *) ')') ; caseref: nameref attributes? ; diff -r 7a41ec2cc522 -r e93772b451ef src/Doc/ROOT --- a/src/Doc/ROOT Tue Sep 03 22:12:48 2013 +0200 +++ b/src/Doc/ROOT Tue Sep 03 22:30:52 2013 +0200 @@ -284,6 +284,8 @@ session Tutorial (doc) in "Tutorial" = HOL + options [document_variants = "tutorial", print_mode = "brackets", skip_proofs = false] + theories [threads = 1] + "ToyList/ToyList_Test" theories [thy_output_indent = 5] "ToyList/ToyList" "Ifexpr/Ifexpr" diff -r 7a41ec2cc522 -r e93772b451ef src/Doc/Tutorial/ToyList/ToyList.thy --- a/src/Doc/Tutorial/ToyList/ToyList.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/Doc/Tutorial/ToyList/ToyList.thy Tue Sep 03 22:30:52 2013 +0200 @@ -2,18 +2,6 @@ imports Datatype begin -(*<*) -ML {* (* FIXME somewhat non-standard, fragile *) - let - val texts = - map (File.read o Path.append (Thy_Load.master_directory @{theory}) o Path.explode) - ["ToyList1", "ToyList2"]; - val trs = Outer_Syntax.parse Position.start (implode texts); - val end_state = fold (Toplevel.command_exception false) trs Toplevel.toplevel; - in @{assert} (Toplevel.is_toplevel end_state) end; -*} -(*>*) - text{*\noindent HOL already has a predefined theory of lists called @{text List} --- @{text ToyList} is merely a small fragment of it chosen as an example. In diff -r 7a41ec2cc522 -r e93772b451ef src/Doc/Tutorial/ToyList/ToyList_Test.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Doc/Tutorial/ToyList/ToyList_Test.thy Tue Sep 03 22:30:52 2013 +0200 @@ -0,0 +1,16 @@ +theory ToyList_Test +imports Datatype +begin + +ML {* (* FIXME somewhat non-standard, fragile *) + let + val texts = + map (File.read o Path.append (Thy_Load.master_directory @{theory}) o Path.explode) + ["ToyList1", "ToyList2"]; + val trs = Outer_Syntax.parse Position.start (implode texts); + val end_state = fold (Toplevel.command_exception false) trs Toplevel.toplevel; + in @{assert} (Toplevel.is_toplevel end_state) end; +*} + +end + diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Algebra/Divisibility.thy --- a/src/HOL/Algebra/Divisibility.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Algebra/Divisibility.thy Tue Sep 03 22:30:52 2013 +0200 @@ -3637,11 +3637,11 @@ assume cunit:"c \ Units G" have "b \ inv c = a \ c \ inv c" by (simp add: b) - also with ccarr acarr cunit + also from ccarr acarr cunit have "\ = a \ (c \ inv c)" by (fast intro: m_assoc) - also with ccarr cunit + also from ccarr cunit have "\ = a \ \" by (simp add: Units_r_inv) - also with acarr + also from acarr have "\ = a" by simp finally have "a = b \ inv c" by simp with ccarr cunit diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/BNF/Examples/Stream.thy --- a/src/HOL/BNF/Examples/Stream.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/BNF/Examples/Stream.thy Tue Sep 03 22:30:52 2013 +0200 @@ -423,9 +423,9 @@ case False hence "x = flat (stl s) !! (y - length (shd s))" by (metis less(2,3) flat_snth) moreover - { from less(2) have "length (shd s) > 0" by (cases s) simp_all - moreover with False have "y > 0" by (cases y) simp_all - ultimately have "y - length (shd s) < y" by simp + { from less(2) have *: "length (shd s) > 0" by (cases s) simp_all + with False have "y > 0" by (cases y) simp_all + with * have "y - length (shd s) < y" by simp } moreover have "\xs \ sset (stl s). xs \ []" using less(2) by (cases s) auto ultimately have "\n m'. x = stl s !! n ! m' \ m' < length (stl s !! n)" by (intro less(1)) auto diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/BNF/More_BNFs.thy --- a/src/HOL/BNF/More_BNFs.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/BNF/More_BNFs.thy Tue Sep 03 22:30:52 2013 +0200 @@ -898,11 +898,10 @@ proof (intro multiset_eqI, transfer fixing: f) fix x :: 'a and M1 M2 :: "'b \ nat" assume "M1 \ multiset" "M2 \ multiset" - moreover hence "setsum M1 {a. f a = x \ 0 < M1 a} = setsum M1 {a. f a = x \ 0 < M1 a + M2 a}" "setsum M2 {a. f a = x \ 0 < M2 a} = setsum M2 {a. f a = x \ 0 < M1 a + M2 a}" by (auto simp: multiset_def intro!: setsum_mono_zero_cong_left) - ultimately show "(\a | f a = x \ 0 < M1 a + M2 a. M1 a + M2 a) = + then show "(\a | f a = x \ 0 < M1 a + M2 a. M1 a + M2 a) = setsum M1 {a. f a = x \ 0 < M1 a} + setsum M2 {a. f a = x \ 0 < M2 a}" by (auto simp: setsum.distrib[symmetric]) diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Big_Operators.thy --- a/src/HOL/Big_Operators.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Big_Operators.thy Tue Sep 03 22:30:52 2013 +0200 @@ -46,7 +46,7 @@ proof - from `x \ A` obtain B where A: "A = insert x B" and "x \ B" by (auto dest: mk_disjoint_insert) - moreover from `finite A` this have "finite B" by simp + moreover from `finite A` A have "finite B" by simp ultimately show ?thesis by simp qed diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Complete_Lattices.thy --- a/src/HOL/Complete_Lattices.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Complete_Lattices.thy Tue Sep 03 22:30:52 2013 +0200 @@ -250,7 +250,7 @@ shows "\A \ u" proof - from `A \ {}` obtain v where "v \ A" by blast - moreover with assms have "v \ u" by blast + moreover from `v \ A` assms(1) have "v \ u" by blast ultimately show ?thesis by (rule Inf_lower2) qed @@ -260,7 +260,7 @@ shows "u \ \A" proof - from `A \ {}` obtain v where "v \ A" by blast - moreover with assms have "u \ v" by blast + moreover from `v \ A` assms(1) have "u \ v" by blast ultimately show ?thesis by (rule Sup_upper2) qed diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Complex.thy --- a/src/HOL/Complex.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Complex.thy Tue Sep 03 22:30:52 2013 +0200 @@ -707,11 +707,11 @@ unfolding d_def by simp moreover from a assms have "cos a = cos x" and "sin a = sin x" by (simp_all add: complex_eq_iff) - hence "cos d = 1" unfolding d_def cos_diff by simp - moreover hence "sin d = 0" by (rule cos_one_sin_zero) + hence cos: "cos d = 1" unfolding d_def cos_diff by simp + moreover from cos have "sin d = 0" by (rule cos_one_sin_zero) ultimately have "d = 0" unfolding sin_zero_iff even_mult_two_ex - by (safe, auto simp add: numeral_2_eq_2 less_Suc_eq) + by (auto simp add: numeral_2_eq_2 less_Suc_eq) thus "a = x" unfolding d_def by simp qed (simp add: assms del: Re_sgn Im_sgn) with `z \ 0` show "arg z = x" diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Decision_Procs/Commutative_Ring_Complete.thy --- a/src/HOL/Decision_Procs/Commutative_Ring_Complete.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Decision_Procs/Commutative_Ring_Complete.thy Tue Sep 03 22:30:52 2013 +0200 @@ -138,7 +138,6 @@ by (auto simp add: norm_Pinj[of _ P2] norm_Pinj[of _ Q2]) moreover note 6 Y0 - moreover ultimately have ?case by (simp add: mkPinj_cn) } moreover { assume "x>y" hence "EX d. x = d + y" by arith @@ -286,7 +285,6 @@ from 6 have "y>0" by (cases y) (auto simp add: norm_Pinj_0_False) moreover note 6 - moreover ultimately have ?case by (simp add: mkPinj_cn) } moreover { assume "x > y" hence "EX d. x = d + y" by arith diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Decision_Procs/Parametric_Ferrante_Rackoff.thy --- a/src/HOL/Decision_Procs/Parametric_Ferrante_Rackoff.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Decision_Procs/Parametric_Ferrante_Rackoff.thy Tue Sep 03 22:30:52 2013 +0200 @@ -2168,7 +2168,6 @@ by(simp add: r[of "- (?t / (2*?c))"] msubstlt_def Let_def evaldjf_ex field_simps lt polyneg_norm polymul_norm) } moreover - moreover {assume c: "?c = 0" and d: "?d>0" from d have d'': "2*?d > 0" by (simp add: zero_less_mult_iff) from d have d': "2*?d \ 0" by simp @@ -2314,7 +2313,6 @@ by(simp add: r[of "- (?t / (2*?c))"] msubstle_def Let_def evaldjf_ex field_simps lt polyneg_norm polymul_norm) } moreover - moreover {assume c: "?c = 0" and d: "?d>0" from d have d'': "2*?d > 0" by (simp add: zero_less_mult_iff) from d have d': "2*?d \ 0" by simp diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Decision_Procs/Reflected_Multivariate_Polynomial.thy --- a/src/HOL/Decision_Procs/Reflected_Multivariate_Polynomial.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Decision_Procs/Reflected_Multivariate_Polynomial.thy Tue Sep 03 22:30:52 2013 +0200 @@ -1314,7 +1314,7 @@ head_isnpolyh_Suc'[OF np norm(5)] head_isnpolyh_Suc'[OF np norm(6)[simplified nn']] have ?case by simp} moreover - {moreover assume nz: "n = 0" + { assume nz: "n = 0" from polymul_degreen[OF norm(5,4), where m="0"] polymul_degreen[OF norm(5,3), where m="0"] nn' nz degree_eq_degreen0 norm(5,6) degree_npolyhCN[OF norm(6)] diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Deriv.thy --- a/src/HOL/Deriv.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Deriv.thy Tue Sep 03 22:30:52 2013 +0200 @@ -416,10 +416,10 @@ proof fix h show "F h = 0" proof (rule ccontr) - assume "F h \ 0" - moreover from this have h: "h \ 0" + assume **: "F h \ 0" + then have h: "h \ 0" by (clarsimp simp add: F.zero) - ultimately have "0 < ?r h" + with ** have "0 < ?r h" by (simp add: divide_pos_pos) from LIM_D [OF * this] obtain s where s: "0 < s" and r: "\x. x \ 0 \ norm x < s \ ?r x < ?r h" by auto @@ -528,11 +528,11 @@ lemma differentiable_def: "(f::real \ real) differentiable x in s \ (\D. DERIV f x : s :> D)" proof safe assume "f differentiable x in s" - then obtain f' where "FDERIV f x : s :> f'" + then obtain f' where *: "FDERIV f x : s :> f'" unfolding isDiff_def by auto - moreover then obtain c where "f' = (\x. x * c)" + then obtain c where "f' = (\x. x * c)" by (metis real_bounded_linear FDERIV_bounded_linear) - ultimately show "\D. DERIV f x : s :> D" + with * show "\D. DERIV f x : s :> D" unfolding deriv_fderiv by auto qed (auto simp: isDiff_def deriv_fderiv) @@ -730,8 +730,8 @@ DERIV f x :> u \ DERIV g y :> v" unfolding DERIV_iff2 proof (rule filterlim_cong) - assume "eventually (\x. f x = g x) (nhds x)" - moreover then have "f x = g x" by (auto simp: eventually_nhds) + assume *: "eventually (\x. f x = g x) (nhds x)" + moreover from * have "f x = g x" by (auto simp: eventually_nhds) moreover assume "x = y" "u = v" ultimately show "eventually (\xa. (f xa - f x) / (xa - x) = (g xa - g y) / (xa - y)) (at x)" by (auto simp: eventually_at_filter elim: eventually_elim1) @@ -1319,7 +1319,8 @@ and fd: "\x. a < x \ x < b \ f differentiable x" and gc: "\x. a \ x \ x \ b \ isCont g x" and gd: "\x. a < x \ x < b \ g differentiable x" - shows "\g'c f'c c. DERIV g c :> g'c \ DERIV f c :> f'c \ a < c \ c < b \ ((f b - f a) * g'c) = ((g b - g a) * f'c)" + shows "\g'c f'c c. + DERIV g c :> g'c \ DERIV f c :> f'c \ a < c \ c < b \ ((f b - f a) * g'c) = ((g b - g a) * f'c)" proof - let ?h = "\x. (f b - f a)*(g x) - (g b - g a)*(f x)" from assms have "a < b" by simp @@ -1348,7 +1349,7 @@ { from cdef have "?h b - ?h a = (b - a) * l" by auto - also with leq have "\ = (b - a) * (g'c * (f b - f a) - f'c * (g b - g a))" by simp + also from leq have "\ = (b - a) * (g'c * (f b - f a) - f'c * (g b - g a))" by simp finally have "?h b - ?h a = (b - a) * (g'c * (f b - f a) - f'c * (g b - g a))" by simp } moreover @@ -1458,14 +1459,15 @@ using `isCont g 0` g by (auto intro: DERIV_isCont simp: le_less) ultimately have "\c. 0 < c \ c < x \ (f x - f 0) * g' c = (g x - g 0) * f' c" using f g `x < a` by (intro GMVT') auto - then guess c .. + then obtain c where *: "0 < c" "c < x" "(f x - f 0) * g' c = (g x - g 0) * f' c" + by blast moreover - with g'(1)[of c] g'(2) have "(f x - f 0) / (g x - g 0) = f' c / g' c" + from * g'(1)[of c] g'(2) have "(f x - f 0) / (g x - g 0) = f' c / g' c" by (simp add: field_simps) ultimately show "\y. 0 < y \ y < x \ f x / g x = f' y / g' y" using `f 0 = 0` `g 0 = 0` by (auto intro!: exI[of _ c]) qed - then guess \ .. + then obtain \ where "\x\{0 <..< a}. 0 < \ x \ \ x < x \ f x / g x = f' (\ x) / g' (\ x)" .. then have \: "eventually (\x. 0 < \ x \ \ x < x \ f x / g x = f' (\ x) / g' (\ x)) (at_right 0)" unfolding eventually_at by (intro exI[of _ a]) (auto simp: dist_real_def) moreover @@ -1581,9 +1583,10 @@ have "\y. t < y \ y < a \ (g a - g t) * f' y = (f a - f t) * g' y" using f0 g0 t(1,2) by (intro GMVT') (force intro!: DERIV_isCont)+ - then guess y .. - from this - have [arith]: "t < y" "y < a" and D_eq: "(f t - f a) / (g t - g a) = f' y / g' y" + then obtain y where [arith]: "t < y" "y < a" + and D_eq0: "(g a - g t) * f' y = (f a - f t) * g' y" + by blast + from D_eq0 have D_eq: "(f t - f a) / (g t - g a) = f' y / g' y" using `g a < g t` g'_neq_0[of y] by (auto simp add: field_simps) have *: "f t / g t - x = ((f t - f a) / (g t - g a) - x) * (1 - g a / g t) + (f a - x * g a) / g t" diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Divides.thy --- a/src/HOL/Divides.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Divides.thy Tue Sep 03 22:30:52 2013 +0200 @@ -742,11 +742,11 @@ apply (subst less_iff_Suc_add) apply (auto simp add: add_mult_distrib) done - from `n \ 0` assms have "fst qr = fst qr'" + from `n \ 0` assms have *: "fst qr = fst qr'" by (auto simp add: divmod_nat_rel_def intro: order_antisym dest: aux sym) - moreover from this assms have "snd qr = snd qr'" + with assms have "snd qr = snd qr'" by (simp add: divmod_nat_rel_def) - ultimately show ?thesis by (cases qr, cases qr') simp + with * show ?thesis by (cases qr, cases qr') simp qed text {* diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Fields.thy --- a/src/HOL/Fields.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Fields.thy Tue Sep 03 22:30:52 2013 +0200 @@ -919,8 +919,8 @@ assume notless: "~ (0 < x)" have "~ (1 < inverse x)" proof - assume "1 < inverse x" - also with notless have "... \ 0" by simp + assume *: "1 < inverse x" + also from notless and * have "... \ 0" by simp also have "... < 1" by (rule zero_less_one) finally show False by auto qed diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Finite_Set.thy --- a/src/HOL/Finite_Set.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Finite_Set.thy Tue Sep 03 22:30:52 2013 +0200 @@ -1103,7 +1103,7 @@ proof - from `x \ A` obtain B where A: "A = insert x B" and "x \ B" by (auto dest: mk_disjoint_insert) - moreover from `finite A` this have "finite B" by simp + moreover from `finite A` A have "finite B" by simp ultimately show ?thesis by simp qed diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Imperative_HOL/Legacy_Mrec.thy --- a/src/HOL/Imperative_HOL/Legacy_Mrec.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Imperative_HOL/Legacy_Mrec.thy Tue Sep 03 22:30:52 2013 +0200 @@ -118,7 +118,7 @@ proof (cases "mrec b h1") case (Some result) then obtain aaa h2 where mrec_rec: "mrec b h1 = Some (aaa, h2)" by fastforce - moreover from this have "P b h1 (snd (the (mrec b h1))) (fst (the (mrec b h1)))" + moreover from mrec_rec have "P b h1 (snd (the (mrec b h1))) (fst (the (mrec b h1)))" apply (intro 1(2)) apply (auto simp add: Inr Inl') done diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Imperative_HOL/ex/Imperative_Quicksort.thy --- a/src/HOL/Imperative_HOL/ex/Imperative_Quicksort.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Imperative_HOL/ex/Imperative_Quicksort.thy Tue Sep 03 22:30:52 2013 +0200 @@ -469,12 +469,12 @@ assume pivot: "l \ p \ p \ r" assume i_outer: "i < l \ r < i" from partition_outer_remains [OF part True] i_outer - have "Array.get h a !i = Array.get h1 a ! i" by fastforce + have 2: "Array.get h a !i = Array.get h1 a ! i" by fastforce moreover - with 1(1) [OF True pivot qs1] pivot i_outer - have "Array.get h1 a ! i = Array.get h2 a ! i" by auto + from 1(1) [OF True pivot qs1] pivot i_outer 2 + have 3: "Array.get h1 a ! i = Array.get h2 a ! i" by auto moreover - with qs2 1(2) [of p h2 h' ret2] True pivot i_outer + from qs2 1(2) [of p h2 h' ret2] True pivot i_outer 3 have "Array.get h2 a ! i = Array.get h' a ! i" by auto ultimately have "Array.get h a ! i= Array.get h' a ! i" by simp } @@ -604,9 +604,9 @@ shows "success (f \= g) h" using assms(1) proof (rule success_effectE) fix h' r - assume "effect f h h' r" - moreover with assms(2) have "success (g r) h'" . - ultimately show "success (f \= g) h" by (rule success_bind_effectI) + assume *: "effect f h h' r" + with assms(2) have "success (g r) h'" . + with * show "success (f \= g) h" by (rule success_bind_effectI) qed lemma success_partitionI: diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Imperative_HOL/ex/Sublist.thy --- a/src/HOL/Imperative_HOL/ex/Sublist.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Imperative_HOL/ex/Sublist.thy Tue Sep 03 22:30:52 2013 +0200 @@ -490,7 +490,6 @@ moreover from right l_r length_eq have "sublist' r (List.length xs) xs = sublist' r (List.length ys) ys" by (auto simp add: length_sublist' nth_sublist' intro!: nth_equalityI) - moreover ultimately show ?thesis by (simp add: multiset_of_append) qed diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Induct/Common_Patterns.thy --- a/src/HOL/Induct/Common_Patterns.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Induct/Common_Patterns.thy Tue Sep 03 22:30:52 2013 +0200 @@ -388,19 +388,18 @@ refl: "star r x x" | step: "r x y \ star r y z \ star r x z" -text{* Underscores are replaced by the default name hyps: *} +text {* Underscores are replaced by the default name hyps: *} -lemmas star_induct = star.induct[case_names base step[r _ IH]] +lemmas star_induct = star.induct [case_names base step[r _ IH]] lemma "star r x y \ star r y z \ star r x z" -proof(induct rule: star_induct) -print_cases - case base thus ?case . +proof (induct rule: star_induct) print_cases + case base + then show ?case . next - case (step a b c) - from step.prems have "star r b z" by(rule step.IH) - from step.r this show ?case by(rule star.step) + case (step a b c) print_facts + from step.prems have "star r b z" by (rule step.IH) + with step.r show ?case by (rule star.step) qed - end \ No newline at end of file diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Library/ContNotDenum.thy --- a/src/HOL/Library/ContNotDenum.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Library/ContNotDenum.thy Tue Sep 03 22:30:52 2013 +0200 @@ -323,64 +323,46 @@ lemma closed_subset_ex: fixes c::real - assumes alb: "a < b" - shows - "\ka kb. ka < kb \ closed_int ka kb \ closed_int a b \ c \ (closed_int ka kb)" -proof - - { - assume clb: "c < b" - { - assume cla: "c < a" - from alb cla clb have "c \ closed_int a b" by (unfold closed_int_def, auto) - with alb have - "a < b \ closed_int a b \ closed_int a b \ c \ closed_int a b" - by auto - hence - "\ka kb. ka < kb \ closed_int ka kb \ closed_int a b \ c \ (closed_int ka kb)" - by auto - } - moreover - { - assume ncla: "\(c < a)" - with clb have cdef: "a \ c \ c < b" by simp - obtain ka where kadef: "ka = (c + b)/2" by blast + assumes "a < b" + shows "\ka kb. ka < kb \ closed_int ka kb \ closed_int a b \ c \ closed_int ka kb" +proof (cases "c < b") + case True + show ?thesis + proof (cases "c < a") + case True + with `a < b` `c < b` have "c \ closed_int a b" + unfolding closed_int_def by auto + with `a < b` show ?thesis by auto + next + case False + then have "a \ c" by simp + def ka \ "(c + b)/2" - from kadef clb have kalb: "ka < b" by auto - moreover from kadef cdef have kagc: "ka > c" by simp - ultimately have "c\(closed_int ka b)" by (unfold closed_int_def, auto) - moreover from cdef kagc have "ka \ a" by simp - hence "closed_int ka b \ closed_int a b" by (unfold closed_int_def, auto) - ultimately have - "ka < b \ closed_int ka b \ closed_int a b \ c \ closed_int ka b" - using kalb by auto - hence - "\ka kb. ka < kb \ closed_int ka kb \ closed_int a b \ c \ (closed_int ka kb)" - by auto - - } + from ka_def `c < b` have kalb: "ka < b" by auto + moreover from ka_def `c < b` have kagc: "ka > c" by simp + ultimately have "c\(closed_int ka b)" by (unfold closed_int_def, auto) + moreover from `a \ c` kagc have "ka \ a" by simp + hence "closed_int ka b \ closed_int a b" by (unfold closed_int_def, auto) ultimately have - "\ka kb. ka < kb \ closed_int ka kb \ closed_int a b \ c \ (closed_int ka kb)" - by (rule case_split) - } - moreover - { - assume "\ (c < b)" - hence cgeb: "c \ b" by simp + "ka < b \ closed_int ka b \ closed_int a b \ c \ closed_int ka b" + using kalb by auto + then show ?thesis + by auto + qed +next + case False + then have "c \ b" by simp - obtain kb where kbdef: "kb = (a + b)/2" by blast - with alb have kblb: "kb < b" by auto - with kbdef cgeb have "a < kb \ kb < c" by auto - moreover hence "c \ (closed_int a kb)" by (unfold closed_int_def, auto) - moreover from kblb have - "closed_int a kb \ closed_int a b" by (unfold closed_int_def, auto) - ultimately have - "a < kb \ closed_int a kb \ closed_int a b \ c\closed_int a kb" - by simp - hence - "\ka kb. ka < kb \ closed_int ka kb \ closed_int a b \ c \ (closed_int ka kb)" - by auto - } - ultimately show ?thesis by (rule case_split) + def kb \ "(a + b)/2" + with `a < b` have "kb < b" by auto + with kb_def `c \ b` have "a < kb" "kb < c" by auto + from `kb < c` have c: "c \ closed_int a kb" + unfolding closed_int_def by auto + with `kb < b` have "closed_int a kb \ closed_int a b" + unfolding closed_int_def by auto + with `a < kb` c have "a < kb \ closed_int a kb \ closed_int a b \ c \ closed_int a kb" + by simp + then show ?thesis by auto qed subsection {* newInt: Interval generation *} diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Library/Countable_Set.thy --- a/src/HOL/Library/Countable_Set.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Library/Countable_Set.thy Tue Sep 03 22:30:52 2013 +0200 @@ -55,7 +55,8 @@ assumes "countable S" "infinite S" obtains e :: "'a \ nat" where "bij_betw e S UNIV" proof - - from `countable S`[THEN countableE] guess f . + obtain f :: "'a \ nat" where "inj_on f S" + using `countable S` by (rule countableE) then have "bij_betw f S (f`S)" unfolding bij_betw_def by simp moreover @@ -169,9 +170,12 @@ "countable I \ (\i. i \ I \ countable (A i)) \ countable (SIGMA i : I. A i)" by (intro countableI'[of "\(i, a). (to_nat_on I i, to_nat_on (A i) a)"]) (auto simp: inj_on_def) -lemma countable_image[intro, simp]: assumes A: "countable A" shows "countable (f`A)" +lemma countable_image[intro, simp]: + assumes "countable A" + shows "countable (f`A)" proof - - from A guess g by (rule countableE) + obtain g :: "'a \ nat" where "inj_on g A" + using assms by (rule countableE) moreover have "inj_on (inv_into A f) (f`A)" "inv_into A f ` f ` A \ A" by (auto intro: inj_on_inv_into inv_into_into) ultimately show ?thesis diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Library/Extended_Real.thy --- a/src/HOL/Library/Extended_Real.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Library/Extended_Real.thy Tue Sep 03 22:30:52 2013 +0200 @@ -146,11 +146,11 @@ "-\ + -\ = -(\::ereal)" proof - case (goal1 P x) - moreover then obtain a b where "x = (a, b)" by (cases x) auto - ultimately show P + then obtain a b where "x = (a, b)" by (cases x) auto + with goal1 show P by (cases rule: ereal2_cases[of a b]) auto qed auto -termination proof qed (rule wf_empty) +termination by default (rule wf_empty) lemma Infty_neq_0[simp]: "(\::ereal) \ 0" "0 \ (\::ereal)" @@ -234,8 +234,8 @@ | " -\ < (\::ereal) \ True" proof - case (goal1 P x) - moreover then obtain a b where "x = (a,b)" by (cases x) auto - ultimately show P by (cases rule: ereal2_cases[of a b]) auto + then obtain a b where "x = (a,b)" by (cases x) auto + with goal1 show P by (cases rule: ereal2_cases[of a b]) auto qed simp_all termination by (relation "{}") simp @@ -496,8 +496,8 @@ "-(\::ereal) * -\ = \" proof - case (goal1 P x) - moreover then obtain a b where "x = (a, b)" by (cases x) auto - ultimately show P by (cases rule: ereal2_cases[of a b]) auto + then obtain a b where "x = (a, b)" by (cases x) auto + with goal1 show P by (cases rule: ereal2_cases[of a b]) auto qed simp_all termination by (relation "{}") simp @@ -1338,9 +1338,9 @@ next { assume "c = \" have ?thesis proof cases - assume "\i. f i = 0" - moreover then have "range f = {0}" by auto - ultimately show "c * SUPR UNIV f \ y" using * + assume **: "\i. f i = 0" + then have "range f = {0}" by auto + with ** show "c * SUPR UNIV f \ y" using * by (auto simp: SUP_def min_max.sup_absorb1) next assume "\ (\i. f i = 0)" @@ -1368,7 +1368,8 @@ next case (real r) with less_PInf_Ex_of_nat[of x] obtain n :: nat where "x < ereal (real n)" by auto - moreover from assms[of n] guess i .. + moreover obtain i where "i \ A" "ereal (real n) \ f i" + using assms .. ultimately show ?thesis by (auto intro!: bexI[of _ i]) qed @@ -1383,11 +1384,12 @@ proof fix n ::nat have "\x\A. Sup A - 1 / ereal (real n) < x" using assms real by (intro Sup_ereal_close) (auto simp: one_ereal_def) - then guess x .. + then obtain x where "x \ A" "Sup A - 1 / ereal (real n) < x" .. then show "\x. x \ A \ Sup A < x + 1 / ereal (real n)" by (auto intro!: exI[of _ x] simp: ereal_minus_less_iff) qed - from choice[OF this] guess f .. note f = this + from choice[OF this] obtain f :: "nat \ ereal" + where f: "\x. f x \ A \ Sup A < f x + 1 / ereal (real x)" .. have "SUPR UNIV f = Sup A" proof (rule SUP_eqI) fix i show "f i \ Sup A" using f @@ -1417,9 +1419,9 @@ from `A \ {}` obtain x where "x \ A" by auto show ?thesis proof cases - assume "\ \ A" - moreover then have "\ \ Sup A" by (intro complete_lattice_class.Sup_upper) - ultimately show ?thesis by (auto intro!: exI[of _ "\x. \"]) + assume *: "\ \ A" + then have "\ \ Sup A" by (intro complete_lattice_class.Sup_upper) + with * show ?thesis by (auto intro!: exI[of _ "\x. \"]) next assume "\ \ A" have "\x\A. 0 \ x" @@ -1433,10 +1435,12 @@ then show False using `x \ A` `\ \ A` PInf by(cases x) auto qed - from choice[OF this] guess f .. note f = this + from choice[OF this] obtain f :: "nat \ ereal" + where f: "\z. f z \ A \ x + ereal (real z) \ f z" .. have "SUPR UNIV f = \" proof (rule SUP_PInfty) - fix n :: nat show "\i\UNIV. ereal (real n) \ f i" + fix n :: nat + show "\i\UNIV. ereal (real n) \ f i" using f[THEN spec, of n] `0 \ x` by (cases rule: ereal2_cases[of "f n" x]) (auto intro!: exI[of _ n]) qed @@ -1489,10 +1493,13 @@ fixes A :: "ereal set" assumes "A \ {}" and "\a\ \ \" shows "Inf ((\x. a - x) ` A) = a - Sup A" proof - - { fix x have "-a - -x = -(a - x)" using assms by (cases x) auto } - moreover then have "(\x. -a - x)`uminus`A = uminus ` (\x. a - x) ` A" + { + fix x + have "-a - -x = -(a - x)" using assms by (cases x) auto + } note * = this + then have "(\x. -a - x)`uminus`A = uminus ` (\x. a - x) ` A" by (auto simp: image_image) - ultimately show ?thesis + with * show ?thesis using Sup_ereal_cminus[of "uminus ` A" "-a"] assms by (auto simp add: ereal_Sup_uminus_image_eq ereal_Inf_uminus_image_eq) qed @@ -1606,9 +1613,9 @@ unfolding open_ereal_generated proof (induct rule: generate_topology.induct) case (Int A B) - moreover then obtain x z where "\ \ A \ {ereal x <..} \ A" "\ \ B \ {ereal z <..} \ B" - by auto - ultimately show ?case + then obtain x z where "\ \ A \ {ereal x <..} \ A" "\ \ B \ {ereal z <..} \ B" + by auto + with Int show ?case by (intro exI[of _ "max x z"]) fastforce next { fix x have "x \ \ \ \t. x \ ereal t" by (cases x) auto } @@ -1621,9 +1628,9 @@ unfolding open_ereal_generated proof (induct rule: generate_topology.induct) case (Int A B) - moreover then obtain x z where "-\ \ A \ {..< ereal x} \ A" "-\ \ B \ {..< ereal z} \ B" - by auto - ultimately show ?case + then obtain x z where "-\ \ A \ {..< ereal x} \ A" "-\ \ B \ {..< ereal z} \ B" + by auto + with Int show ?case by (intro exI[of _ "min x z"]) fastforce next { fix x have "x \ - \ \ \t. ereal t \ x" by (cases x) auto } @@ -1711,8 +1718,9 @@ fixes S :: "ereal set" assumes "open S" "x \ S" and x: "\x\ \ \" obtains a b where "a < x" "x < b" "{a <..< b} \ S" -proof- - guess e using ereal_open_cont_interval[OF assms] . +proof - + obtain e where "0 < e" "{x - e<.. S" + using assms by (rule ereal_open_cont_interval) with that[of "x-e" "x+e"] ereal_between[OF x, of e] show thesis by auto qed @@ -1759,8 +1767,9 @@ lemma tendsto_MInfty: "(f ---> -\) F \ (\r. eventually (\x. f x < ereal r) F)" unfolding tendsto_def proof safe - fix S :: "ereal set" assume "open S" "-\ \ S" - from open_MInfty[OF this] guess B .. note B = this + fix S :: "ereal set" + assume "open S" "-\ \ S" + from open_MInfty[OF this] obtain B where "{.. S" .. moreover assume "\r::real. eventually (\z. f z < r) F" then have "eventually (\z. f z \ {..< B}) F" by auto @@ -1775,7 +1784,7 @@ unfolding tendsto_PInfty eventually_sequentially proof safe fix r assume "\r. \N. \n\N. ereal r \ f n" - from this[rule_format, of "r+1"] guess N .. + then obtain N where "\n\N. ereal (r + 1) \ f n" by blast moreover have "ereal r < ereal (r + 1)" by auto ultimately show "\N. \n\N. ereal r < f n" by (blast intro: less_le_trans) @@ -1785,7 +1794,7 @@ unfolding tendsto_MInfty eventually_sequentially proof safe fix r assume "\r. \N. \n\N. f n \ ereal r" - from this[rule_format, of "r - 1"] guess N .. + then obtain N where "\n\N. f n \ ereal (r - 1)" by blast moreover have "ereal (r - 1) < ereal r" by auto ultimately show "\N. \n\N. f n < ereal r" by (blast intro: le_less_trans) diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Library/FinFun.thy --- a/src/HOL/Library/FinFun.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Library/FinFun.thy Tue Sep 03 22:30:52 2013 +0200 @@ -960,7 +960,7 @@ { fix g' a b show "Abs_finfun (g \ op $ g'(a $:= b)) = (Abs_finfun (g \ op $ g'))(a $:= g b)" proof - obtain y where y: "y \ finfun" and g': "g' = Abs_finfun y" by(cases g') - moreover hence "(g \ op $ g') \ finfun" by(simp add: finfun_left_compose) + moreover from g' have "(g \ op $ g') \ finfun" by(simp add: finfun_left_compose) moreover have "g \ y(a := b) = (g \ y)(a := g b)" by(auto) ultimately show ?thesis by(simp add: finfun_comp_def finfun_update_def) qed } diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Library/Float.thy --- a/src/HOL/Library/Float.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Library/Float.thy Tue Sep 03 22:30:52 2013 +0200 @@ -44,7 +44,7 @@ lemma zero_float[simp]: "0 \ float" by (auto simp: float_def) lemma one_float[simp]: "1 \ float" by (intro floatI[of 1 0]) simp -lemma numeral_float[simp]: "numeral i \ float" by (intro floatI[of "numeral i" 0]) simp +lemma numeral_float[simp]: "numeral i \ float" by (intro floatI[of "numeral i" 0]) simp lemma neg_numeral_float[simp]: "neg_numeral i \ float" by (intro floatI[of "neg_numeral i" 0]) simp lemma real_of_int_float[simp]: "real (x :: int) \ float" by (intro floatI[of x 0]) simp lemma real_of_nat_float[simp]: "real (x :: nat) \ float" by (intro floatI[of x 0]) simp @@ -175,7 +175,7 @@ lemma real_of_float_power[simp]: fixes f::float shows "real (f^n) = real f^n" by (induct n) simp_all -lemma fixes x y::float +lemma fixes x y::float shows real_of_float_min: "real (min x y) = min (real x) (real y)" and real_of_float_max: "real (max x y) = max (real x) (real y)" by (simp_all add: min_def max_def) @@ -197,7 +197,7 @@ then show "\c. a < c \ c < b" apply (intro exI[of _ "(a + b) * Float 1 -1"]) apply transfer - apply (simp add: powr_neg_numeral) + apply (simp add: powr_neg_numeral) done qed @@ -222,14 +222,14 @@ plus_float.rep_eq one_float.rep_eq plus_float numeral_float one_float) done -lemma transfer_numeral [transfer_rule]: +lemma transfer_numeral [transfer_rule]: "fun_rel (op =) pcr_float (numeral :: _ \ real) (numeral :: _ \ float)" unfolding fun_rel_def float.pcr_cr_eq cr_float_def by simp lemma float_neg_numeral[simp]: "real (neg_numeral x :: float) = neg_numeral x" by (simp add: minus_numeral[symmetric] del: minus_numeral) -lemma transfer_neg_numeral [transfer_rule]: +lemma transfer_neg_numeral [transfer_rule]: "fun_rel (op =) pcr_float (neg_numeral :: _ \ real) (neg_numeral :: _ \ float)" unfolding fun_rel_def float.pcr_cr_eq cr_float_def by simp @@ -321,7 +321,7 @@ "exponent f = snd (SOME p::int \ int. (f = 0 \ fst p = 0 \ snd p = 0) \ (f \ 0 \ real f = real (fst p) * 2 powr real (snd p) \ \ 2 dvd fst p))" -lemma +lemma shows exponent_0[simp]: "exponent (float_of 0) = 0" (is ?E) and mantissa_0[simp]: "mantissa (float_of 0) = 0" (is ?M) proof - @@ -351,7 +351,7 @@ lemma mantissa_noteq_0: "f \ float_of 0 \ mantissa f \ 0" using mantissa_not_dvd[of f] by auto -lemma +lemma fixes m e :: int defines "f \ float_of (m * 2 powr e)" assumes dvd: "\ 2 dvd m" @@ -740,19 +740,23 @@ qed lemma bitlen_Float: -fixes m e -defines "f \ Float m e" -shows "bitlen (\mantissa f\) + exponent f = (if m = 0 then 0 else bitlen \m\ + e)" -proof cases - assume "m \ 0" + fixes m e + defines "f \ Float m e" + shows "bitlen (\mantissa f\) + exponent f = (if m = 0 then 0 else bitlen \m\ + e)" +proof (cases "m = 0") + case True + then show ?thesis by (simp add: f_def bitlen_def Float_def) +next + case False hence "f \ float_of 0" unfolding real_of_float_eq by (simp add: f_def) hence "mantissa f \ 0" by (simp add: mantissa_noteq_0) moreover - from f_def[THEN denormalize_shift, OF `f \ float_of 0`] guess i . + obtain i where "m = mantissa f * 2 ^ i" "e = exponent f - int i" + by (rule f_def[THEN denormalize_shift, OF `f \ float_of 0`]) ultimately show ?thesis by (simp add: abs_mult) -qed (simp add: f_def bitlen_def Float_def) +qed lemma compute_bitlen[code]: shows "bitlen x = (if x > 0 then bitlen (x div 2) + 1 else 0)" @@ -865,9 +869,9 @@ is "\prec (x::nat) (y::nat). round_down (rat_precision prec x y) (x / y)" by simp lemma compute_lapprox_posrat[code]: - fixes prec x y - shows "lapprox_posrat prec x y = - (let + fixes prec x y + shows "lapprox_posrat prec x y = + (let l = rat_precision prec x y; d = if 0 \ l then x * 2^nat l div y else x div 2^nat (- l) div y in normfloat (Float d (- l)))" @@ -948,7 +952,7 @@ assumes "0 \ x" and "0 < y" and "2 * x < y" and "0 < n" shows "real (rapprox_posrat n x y) < 1" proof - - have powr1: "2 powr real (rat_precision n (int x) (int y)) = + have powr1: "2 powr real (rat_precision n (int x) (int y)) = 2 ^ nat (rat_precision n (int x) (int y))" using rat_precision_pos[of x y n] assms by (simp add: powr_realpow[symmetric]) have "x * 2 powr real (rat_precision n (int x) (int y)) / y = (x / y) * @@ -978,7 +982,7 @@ (if y = 0 then 0 else if 0 \ x then (if 0 < y then lapprox_posrat prec (nat x) (nat y) - else - (rapprox_posrat prec (nat x) (nat (-y)))) + else - (rapprox_posrat prec (nat x) (nat (-y)))) else (if 0 < y then - (rapprox_posrat prec (nat (-x)) (nat y)) else lapprox_posrat prec (nat (-x)) (nat (-y))))" @@ -993,7 +997,7 @@ (if y = 0 then 0 else if 0 \ x then (if 0 < y then rapprox_posrat prec (nat x) (nat y) - else - (lapprox_posrat prec (nat x) (nat (-y)))) + else - (lapprox_posrat prec (nat x) (nat (-y)))) else (if 0 < y then - (lapprox_posrat prec (nat (-x)) (nat y)) else rapprox_posrat prec (nat (-x)) (nat (-y))))" @@ -1017,7 +1021,7 @@ by (simp add: field_simps powr_divide2[symmetric]) show ?thesis - using not_0 + using not_0 by (transfer fixing: m1 s1 m2 s2 prec) (unfold eq1 eq2 round_down_shift, simp add: field_simps) qed (transfer, auto) hide_fact (open) compute_float_divl @@ -1037,7 +1041,7 @@ by (simp add: field_simps powr_divide2[symmetric]) show ?thesis - using not_0 + using not_0 by (transfer fixing: m1 s1 m2 s2 prec) (unfold eq1 eq2 round_up_shift, simp add: field_simps) qed (transfer, auto) hide_fact (open) compute_float_divr @@ -1104,7 +1108,7 @@ (simp add: powr_minus inverse_eq_divide) qed -lemma rapprox_rat_nonneg_neg: +lemma rapprox_rat_nonneg_neg: "0 \ x \ y < 0 \ real (rapprox_rat n x y) \ 0" unfolding rapprox_rat_def round_up_def by (auto simp: field_simps mult_le_0_iff zero_le_mult_iff) @@ -1157,7 +1161,7 @@ "0 < real x \ real x < 1 \ prec \ 1 \ 1 \ real (float_divl prec 1 x)" proof transfer fix prec :: nat and x :: real assume x: "0 < x" "x < 1" "x \ float" and prec: "1 \ prec" - def p \ "int prec + \log 2 \x\\" + def p \ "int prec + \log 2 \x\\" show "1 \ round_down (int prec + \log 2 \x\\ - \log 2 \1\\) (1 / x) " proof cases assume nonneg: "0 \ p" @@ -1279,12 +1283,16 @@ lemma int_floor_fl: "real (int_floor_fl x) \ real x" by transfer simp lemma floor_pos_exp: "exponent (floor_fl x) \ 0" -proof cases - assume nzero: "floor_fl x \ float_of 0" - have "floor_fl x = Float \real x\ 0" by transfer simp - from denormalize_shift[OF this[THEN eq_reflection] nzero] guess i . note i = this - thus ?thesis by simp -qed (simp add: floor_fl_def) +proof (cases "floor_fl x = float_of 0") + case True + then show ?thesis by (simp add: floor_fl_def) +next + case False + have eq: "floor_fl x = Float \real x\ 0" by transfer simp + obtain i where "\real x\ = mantissa (floor_fl x) * 2 ^ i" "0 = exponent (floor_fl x) - int i" + by (rule denormalize_shift[OF eq[THEN eq_reflection] False]) + then show ?thesis by simp +qed end diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Library/Formal_Power_Series.thy --- a/src/HOL/Library/Formal_Power_Series.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Library/Formal_Power_Series.thy Tue Sep 03 22:30:52 2013 +0200 @@ -3804,8 +3804,8 @@ by (simp add: split_if_asm dist_fps_def) moreover from fps_eq_least_unique[OF `f \ g`] - obtain n where "leastP (\n. f$n \ g$n) n" "The (leastP (\n. f $ n \ g $ n)) = n" by blast - moreover hence "\m. m < n \ f$m = g$m" "f$n \ g$n" + obtain n where n: "leastP (\n. f$n \ g$n) n" "The (leastP (\n. f $ n \ g $ n)) = n" by blast + moreover from n have "\m. m < n \ f$m = g$m" "f$n \ g$n" by (auto simp add: leastP_def setge_def) ultimately show ?thesis using `j \ i` by simp next diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Library/Fraction_Field.thy --- a/src/HOL/Library/Fraction_Field.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Library/Fraction_Field.thy Tue Sep 03 22:30:52 2013 +0200 @@ -209,7 +209,7 @@ next case False then obtain a b where "q = Fract a b" and "b \ 0" by (cases q) auto - moreover with False have "0 \ Fract a b" by simp + with False have "0 \ Fract a b" by simp with `b \ 0` have "a \ 0" by (simp add: Zero_fract_def eq_fract) with Fract `q = Fract a b` `b \ 0` show thesis by auto qed diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Library/FuncSet.thy --- a/src/HOL/Library/FuncSet.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Library/FuncSet.thy Tue Sep 03 22:30:52 2013 +0200 @@ -375,7 +375,8 @@ proof (rule ccontr) assume "\ ?thesis" then have "\i. \y. (i \ I \ y \ F i) \ (i \ I \ y = undefined)" by auto - from choice[OF this] guess f .. + from choice[OF this] + obtain f where " \x. (x \ I \ f x \ F x) \ (x \ I \ f x = undefined)" .. then have "f \ Pi\<^sub>E I F" by (auto simp: extensional_def PiE_def) with `Pi\<^sub>E I F = {}` show False by auto qed @@ -437,8 +438,10 @@ shows "F i \ F' i" proof fix x assume "x \ F i" - with ne have "\j. \y. ((j \ I \ y \ F j \ (i = j \ x = y)) \ (j \ I \ y = undefined))" by auto - from choice[OF this] guess f .. note f = this + with ne have "\j. \y. ((j \ I \ y \ F j \ (i = j \ x = y)) \ (j \ I \ y = undefined))" + by auto + from choice[OF this] obtain f + where f: " \j. (j \ I \ f j \ F j \ (i = j \ x = f j)) \ (j \ I \ f j = undefined)" .. then have "f \ Pi\<^sub>E I F" by (auto simp: extensional_def PiE_def) then have "f \ Pi\<^sub>E I F'" using assms by simp then show "x \ F' i" using f `i \ I` by (auto simp: PiE_def) diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Library/Liminf_Limsup.thy --- a/src/HOL/Library/Liminf_Limsup.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Library/Liminf_Limsup.thy Tue Sep 03 22:30:52 2013 +0200 @@ -169,15 +169,15 @@ moreover { fix y P assume "y < C" and y: "\yx. y < X x) F" have "\P. eventually P F \ y < INFI (Collect P) X" - proof cases - assume "\z. y < z \ z < C" - then guess z .. - moreover then have "z \ INFI {x. z < X x} X" + proof (cases "\z. y < z \ z < C") + case True + then obtain z where z: "y < z \ z < C" .. + moreover from z have "z \ INFI {x. z < X x} X" by (auto intro!: INF_greatest) ultimately show ?thesis using y by (intro exI[of _ "\x. z < X x"]) auto next - assume "\ (\z. y < z \ z < C)" + case False then have "C \ INFI {x. y < X x} X" by (intro INF_greatest) auto with `y < C` show ?thesis @@ -203,7 +203,7 @@ show "f0 \ y" proof cases assume "\z. y < z \ z < f0" - then guess z .. + then obtain z where "y < z \ z < f0" .. moreover have "z \ INFI {x. z < f x} f" by (rule INF_greatest) simp ultimately show ?thesis @@ -240,22 +240,22 @@ next fix y assume lower: "\P. eventually P F \ y \ SUPR (Collect P) f" show "y \ f0" - proof cases - assume "\z. f0 < z \ z < y" - then guess z .. + proof (cases "\z. f0 < z \ z < y") + case True + then obtain z where "f0 < z \ z < y" .. moreover have "SUPR {x. f x < z} f \ z" by (rule SUP_least) simp ultimately show ?thesis using lim[THEN topological_tendstoD, THEN lower, of "{..< z}"] by auto next - assume discrete: "\ (\z. f0 < z \ z < y)" + case False show ?thesis proof (rule classical) assume "\ y \ f0" then have "eventually (\x. f x < y) F" using lim[THEN topological_tendstoD, of "{..< y}"] by auto then have "eventually (\x. f x \ f0) F" - using discrete by (auto elim!: eventually_elim1 simp: not_less) + using False by (auto elim!: eventually_elim1 simp: not_less) then have "y \ SUPR {x. f x \ f0} f" by (rule lower) moreover have "SUPR {x. f x \ f0} f \ f0" diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Library/Permutations.thy --- a/src/HOL/Library/Permutations.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Library/Permutations.thy Tue Sep 03 22:30:52 2013 +0200 @@ -166,8 +166,8 @@ have xfgpF': "?xF = ?g ` ?pF'" . have Fs: "card F = n - 1" using `x \ F` H0 `finite F` by auto from insert.hyps Fs have pFs: "card ?pF = fact (n - 1)" using `finite F` by auto - moreover hence "finite ?pF" using fact_gt_zero_nat by (auto intro: card_ge_0_finite) - ultimately have pF'f: "finite ?pF'" using H0 `finite F` + then have "finite ?pF" using fact_gt_zero_nat by (auto intro: card_ge_0_finite) + then have pF'f: "finite ?pF'" using H0 `finite F` apply (simp only: Collect_split Collect_mem_eq) apply (rule finite_cartesian_product) apply simp_all @@ -195,7 +195,7 @@ thus ?thesis unfolding inj_on_def by blast qed from `x \ F` H0 have n0: "n \ 0 " using `finite F` by auto - hence "\m. n = Suc m" by arith + hence "\m. n = Suc m" by presburger then obtain m where n[simp]: "n = Suc m" by blast from pFs H0 have xFc: "card ?xF = fact n" unfolding xfgpF' card_image[OF ginj] using `finite F` `finite ?pF` diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Library/RBT_Impl.thy --- a/src/HOL/Library/RBT_Impl.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Library/RBT_Impl.thy Tue Sep 03 22:30:52 2013 +0200 @@ -146,8 +146,7 @@ = Set.insert k (dom (rbt_lookup t1) \ dom (rbt_lookup t2))" proof - assume "rbt_sorted (Branch c t1 k v t2)" - moreover from this have "rbt_sorted t1" "rbt_sorted t2" by simp_all - ultimately show ?thesis by (simp add: rbt_lookup_keys) + then show ?thesis by (simp add: rbt_lookup_keys) qed lemma finite_dom_rbt_lookup [simp, intro!]: "finite (dom (rbt_lookup t))" @@ -1405,14 +1404,14 @@ proof(cases "n mod 2 = 0") case True note ge0 moreover from "1.prems" have n2: "n div 2 \ length kvs" by simp - moreover with True have "P (n div 2) kvs" by(rule IH) + moreover from True n2 have "P (n div 2) kvs" by(rule IH) moreover from length_rbtreeify_f[OF n2] ge0 "1.prems" obtain t k v kvs' where kvs': "rbtreeify_f (n div 2) kvs = (t, (k, v) # kvs')" by(cases "snd (rbtreeify_f (n div 2) kvs)") (auto simp add: snd_def split: prod.split_asm) moreover from "1.prems" length_rbtreeify_f[OF n2] ge0 - have "n div 2 \ Suc (length kvs')" by(simp add: kvs') - moreover with True kvs'[symmetric] refl refl + have n2': "n div 2 \ Suc (length kvs')" by(simp add: kvs') + moreover from True kvs'[symmetric] refl refl n2' have "Q (n div 2) kvs'" by(rule IH) moreover note feven[unfolded feven_def] (* FIXME: why does by(rule feven[unfolded feven_def]) not work? *) @@ -1421,14 +1420,14 @@ next case False note ge0 moreover from "1.prems" have n2: "n div 2 \ length kvs" by simp - moreover with False have "P (n div 2) kvs" by(rule IH) + moreover from False n2 have "P (n div 2) kvs" by(rule IH) moreover from length_rbtreeify_f[OF n2] ge0 "1.prems" obtain t k v kvs' where kvs': "rbtreeify_f (n div 2) kvs = (t, (k, v) # kvs')" by(cases "snd (rbtreeify_f (n div 2) kvs)") (auto simp add: snd_def split: prod.split_asm) moreover from "1.prems" length_rbtreeify_f[OF n2] ge0 False - have "n div 2 \ length kvs'" by(simp add: kvs') arith - moreover with False kvs'[symmetric] refl refl have "P (n div 2) kvs'" by(rule IH) + have n2': "n div 2 \ length kvs'" by(simp add: kvs') arith + moreover from False kvs'[symmetric] refl refl n2' have "P (n div 2) kvs'" by(rule IH) moreover note fodd[unfolded fodd_def] ultimately have "P (Suc (2 * (n div 2))) kvs" by - thus ?thesis using False @@ -1451,14 +1450,14 @@ proof(cases "n mod 2 = 0") case True note ge0 moreover from "2.prems" have n2: "n div 2 \ Suc (length kvs)" by simp - moreover with True have "Q (n div 2) kvs" by(rule IH) + moreover from True n2 have "Q (n div 2) kvs" by(rule IH) moreover from length_rbtreeify_g[OF ge0 n2] ge0 "2.prems" obtain t k v kvs' where kvs': "rbtreeify_g (n div 2) kvs = (t, (k, v) # kvs')" by(cases "snd (rbtreeify_g (n div 2) kvs)") (auto simp add: snd_def split: prod.split_asm) moreover from "2.prems" length_rbtreeify_g[OF ge0 n2] ge0 - have "n div 2 \ Suc (length kvs')" by(simp add: kvs') - moreover with True kvs'[symmetric] refl refl + have n2': "n div 2 \ Suc (length kvs')" by(simp add: kvs') + moreover from True kvs'[symmetric] refl refl n2' have "Q (n div 2) kvs'" by(rule IH) moreover note geven[unfolded geven_def] ultimately have "Q (2 * (n div 2)) kvs" by - @@ -1467,14 +1466,14 @@ next case False note ge0 moreover from "2.prems" have n2: "n div 2 \ length kvs" by simp - moreover with False have "P (n div 2) kvs" by(rule IH) + moreover from False n2 have "P (n div 2) kvs" by(rule IH) moreover from length_rbtreeify_f[OF n2] ge0 "2.prems" False obtain t k v kvs' where kvs': "rbtreeify_f (n div 2) kvs = (t, (k, v) # kvs')" by(cases "snd (rbtreeify_f (n div 2) kvs)") (auto simp add: snd_def split: prod.split_asm, arith) moreover from "2.prems" length_rbtreeify_f[OF n2] ge0 False - have "n div 2 \ Suc (length kvs')" by(simp add: kvs') arith - moreover with False kvs'[symmetric] refl refl + have n2': "n div 2 \ Suc (length kvs')" by(simp add: kvs') arith + moreover from False kvs'[symmetric] refl refl n2' have "Q (n div 2) kvs'" by(rule IH) moreover note godd[unfolded godd_def] ultimately have "Q (Suc (2 * (n div 2))) kvs" by - diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Library/Ramsey.thy --- a/src/HOL/Library/Ramsey.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Library/Ramsey.thy Tue Sep 03 22:30:52 2013 +0200 @@ -326,11 +326,11 @@ have part2: "\X. X \ Z & finite X & card X = 2 --> f X < s" using part by (fastforce simp add: eval_nat_numeral card_Suc_eq) obtain Y t - where "Y \ Z" "infinite Y" "t < s" + where *: "Y \ Z" "infinite Y" "t < s" "(\X. X \ Y & finite X & card X = 2 --> f X = t)" by (insert Ramsey [OF infZ part2]) auto - moreover from this have "\x\Y. \y\Y. x \ y \ f {x, y} = t" by auto - ultimately show ?thesis by iprover + then have "\x\Y. \y\Y. x \ y \ f {x, y} = t" by auto + with * show ?thesis by iprover qed diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Library/While_Combinator.thy --- a/src/HOL/Library/While_Combinator.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Library/While_Combinator.thy Tue Sep 03 22:30:52 2013 +0200 @@ -93,8 +93,9 @@ next case (Suc k) hence "\ b ((c^^k) (c s))" by (auto simp: funpow_swap1) - then guess k by (rule exE[OF Suc.IH[of "c s"]]) - with assms show ?case by (cases "b s") (auto simp: funpow_swap1 intro: exI[of _ "Suc k"] exI[of _ "0"]) + from Suc.IH[OF this] obtain k where "\ b' ((c' ^^ k) (f (c s)))" .. + with assms show ?case + by (cases "b s") (auto simp: funpow_swap1 intro: exI[of _ "Suc k"] exI[of _ "0"]) qed next fix k assume "\ b' ((c' ^^ k) (f s))" @@ -107,8 +108,8 @@ show ?case proof (cases "b s") case True - with assms(2) * have "\ b' ((c'^^k) (f (c s)))" by simp - then guess k by (rule exE[OF Suc.IH[of "c s"]]) + with assms(2) * have "\ b' ((c'^^k) (f (c s)))" by simp + from Suc.IH[OF this] obtain k where "\ b ((c ^^ k) (c s))" .. thus ?thesis by (auto simp: funpow_swap1 intro: exI[of _ "Suc k"]) qed (auto intro: exI[of _ "0"]) qed diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Library/Zorn.thy --- a/src/HOL/Library/Zorn.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Library/Zorn.thy Tue Sep 03 22:30:52 2013 +0200 @@ -119,9 +119,9 @@ lemma chain_sucD: assumes "chain X" shows "suc X \ A \ chain (suc X)" proof - - from `chain X` have "chain (suc X)" by (rule chain_suc) - moreover then have "suc X \ A" unfolding chain_def by blast - ultimately show ?thesis by blast + from `chain X` have *: "chain (suc X)" by (rule chain_suc) + then have "suc X \ A" unfolding chain_def by blast + with * show ?thesis by blast qed lemma suc_Union_closed_total': @@ -348,8 +348,8 @@ moreover have "\x\C. x \ X" using `\C \ X` by auto ultimately have "subset.chain A ?C" using subset.chain_extend [of A C X] and `X \ A` by auto - moreover assume "\C \ X" - moreover then have "C \ ?C" using `\C \ X` by auto + moreover assume **: "\C \ X" + moreover from ** have "C \ ?C" using `\C \ X` by auto ultimately show False using * by blast qed @@ -578,11 +578,11 @@ case 0 show ?case by fact next case (Suc i) - moreover obtain s where "s \ R" and "(f (Suc (Suc i)), f(Suc i)) \ s" + then obtain s where s: "s \ R" "(f (Suc (Suc i)), f(Suc i)) \ s" using 1 by auto - moreover hence "s initial_segment_of r \ r initial_segment_of s" + then have "s initial_segment_of r \ r initial_segment_of s" using assms(1) `r \ R` by (simp add: Chains_def) - ultimately show ?case by (simp add: init_seg_of_def) blast + with Suc s show ?case by (simp add: init_seg_of_def) blast qed } thus False using assms(2) and `r \ R` @@ -682,15 +682,14 @@ qed ultimately have "Well_order ?m" by (simp add: order_on_defs) --{*We show that the extension is above m*} - moreover hence "(m, ?m) \ I" using `Well_order m` and `x \ Field m` + moreover have "(m, ?m) \ I" using `Well_order ?m` and `Well_order m` and `x \ Field m` by (fastforce simp: I_def init_seg_of_def Field_def) ultimately --{*This contradicts maximality of m:*} have False using max and `x \ Field m` unfolding Field_def by blast } hence "Field m = UNIV" by auto - moreover with `Well_order m` have "Well_order m" by simp - ultimately show ?thesis by blast + with `Well_order m` show ?thesis by blast qed corollary well_order_on: "\r::'a rel. well_order_on A r" diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Limits.thy --- a/src/HOL/Limits.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Limits.thy Tue Sep 03 22:30:52 2013 +0200 @@ -33,16 +33,17 @@ "(at_infinity \ real filter) = sup at_top at_bot" unfolding sup_filter_def at_infinity_def eventually_at_top_linorder eventually_at_bot_linorder proof (intro arg_cong[where f=Abs_filter] ext iffI) - fix P :: "real \ bool" assume "\r. \x. r \ norm x \ P x" - then guess r .. + fix P :: "real \ bool" + assume "\r. \x. r \ norm x \ P x" + then obtain r where "\x. r \ norm x \ P x" .. then have "(\x\r. P x) \ (\x\-r. P x)" by auto then show "(\r. \x\r. P x) \ (\r. \x\r. P x)" by auto next - fix P :: "real \ bool" assume "(\r. \x\r. P x) \ (\r. \x\r. P x)" + fix P :: "real \ bool" + assume "(\r. \x\r. P x) \ (\r. \x\r. P x)" then obtain p q where "\x\p. P x" "\x\q. P x" by auto then show "\r. \x. r \ norm x \ P x" - by (intro exI[of _ "max p (-q)"]) - (auto simp: abs_real_def) + by (intro exI[of _ "max p (-q)"]) (auto simp: abs_real_def) qed lemma at_top_le_at_infinity: diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/List.thy --- a/src/HOL/List.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/List.thy Tue Sep 03 22:30:52 2013 +0200 @@ -722,12 +722,18 @@ using `xs \ []` proof (induct xs) case Nil then show ?case by simp next - case (Cons x xs) show ?case proof (cases xs) - case Nil with single show ?thesis by simp + case (Cons x xs) + show ?case + proof (cases xs) + case Nil + with single show ?thesis by simp next - case Cons then have "xs \ []" by simp - moreover with Cons.hyps have "P xs" . - ultimately show ?thesis by (rule cons) + case Cons + show ?thesis + proof (rule cons) + from Cons show "xs \ []" by simp + with Cons.hyps show "P xs" . + qed qed qed @@ -1061,12 +1067,13 @@ lemma map_eq_imp_length_eq: assumes "map f xs = map g ys" shows "length xs = length ys" -using assms proof (induct ys arbitrary: xs) + using assms +proof (induct ys arbitrary: xs) case Nil then show ?case by simp next case (Cons y ys) then obtain z zs where xs: "xs = z # zs" by auto from Cons xs have "map f zs = map g ys" by simp - moreover with Cons have "length zs = length ys" by blast + with Cons have "length zs = length ys" by blast with xs show ?case by simp qed @@ -1669,10 +1676,10 @@ hence n: "n < Suc (length xs)" by simp moreover { assume "n < length xs" - with n obtain n' where "length xs - n = Suc n'" + with n obtain n' where n': "length xs - n = Suc n'" by (cases "length xs - n", auto) moreover - then have "length xs - Suc n = n'" by simp + from n' have "length xs - Suc n = n'" by simp ultimately have "xs ! (length xs - Suc n) = (x # xs) ! (length xs - n)" by simp } @@ -3801,14 +3808,12 @@ then have "\m n zs. concat (replicate m zs) = xs' \ concat (replicate n zs) = ws" using False and `xs' \ []` and `ys' = xs' @ ws` and len by (intro less.hyps) auto - then obtain m n zs where "concat (replicate m zs) = xs'" + then obtain m n zs where *: "concat (replicate m zs) = xs'" and "concat (replicate n zs) = ws" by blast - moreover then have "concat (replicate (m + n) zs) = ys'" using `ys' = xs' @ ws` by (simp add: replicate_add) - ultimately - show ?thesis by blast + with * show ?thesis by blast qed then show ?case using xs'_def ys'_def by metis @@ -4074,8 +4079,8 @@ case Nil thus ?case by simp next case (Cons a xs) - moreover hence "!x. x: set xs \ x \ a" by auto - ultimately show ?case by(simp add: sublist_Cons cong:filter_cong) + then have "!x. x: set xs \ x \ a" by auto + with Cons show ?case by(simp add: sublist_Cons cong:filter_cong) qed @@ -4195,8 +4200,8 @@ hence "foldr (\xs. max (length xs)) xss 0 = 0" proof (induct xss) case (Cons x xs) - moreover hence "x = []" by (cases x) auto - ultimately show ?case by auto + then have "x = []" by (cases x) auto + with Cons show ?case by auto qed simp thus ?thesis using True by simp next @@ -4585,7 +4590,7 @@ proof - from assms have "map f xs = map f ys" by (simp add: sorted_distinct_set_unique) - moreover with `inj_on f (set xs \ set ys)` show "xs = ys" + with `inj_on f (set xs \ set ys)` show "xs = ys" by (blast intro: map_inj_on) qed @@ -4620,11 +4625,12 @@ lemma foldr_max_sorted: assumes "sorted (rev xs)" shows "foldr max xs y = (if xs = [] then y else max (xs ! 0) y)" -using assms proof (induct xs) + using assms +proof (induct xs) case (Cons x xs) - moreover hence "sorted (rev xs)" using sorted_append by auto - ultimately show ?case - by (cases xs, auto simp add: sorted_append max_def) + then have "sorted (rev xs)" using sorted_append by auto + with Cons show ?case + by (cases xs) (auto simp add: sorted_append max_def) qed simp lemma filter_equals_takeWhile_sorted_rev: diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Map.thy --- a/src/HOL/Map.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Map.thy Tue Sep 03 22:30:52 2013 +0200 @@ -715,18 +715,19 @@ by (rule set_map_of_compr) ultimately show ?rhs by simp next - assume ?rhs show ?lhs proof + assume ?rhs show ?lhs + proof fix k show "map_of xs k = map_of ys k" proof (cases "map_of xs k") case None - moreover with `?rhs` have "map_of ys k = None" + with `?rhs` have "map_of ys k = None" by (simp add: map_of_eq_None_iff) - ultimately show ?thesis by simp + with None show ?thesis by simp next case (Some v) - moreover with distinct `?rhs` have "map_of ys k = Some v" + with distinct `?rhs` have "map_of ys k = Some v" by simp - ultimately show ?thesis by simp + with Some show ?thesis by simp qed qed qed diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/MicroJava/J/TypeRel.thy --- a/src/HOL/MicroJava/J/TypeRel.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/MicroJava/J/TypeRel.thy Tue Sep 03 22:30:52 2013 +0200 @@ -144,8 +144,8 @@ where "class": "class G C = Some (D', fs', ms')" unfolding class_def by(auto dest!: weak_map_of_SomeI) hence "G \ C \C1 D'" using `C \ Object` .. - hence "(C, D') \ (subcls1 G)^+" .. - also with acyc have "C \ D'" by(auto simp add: acyclic_def) + hence *: "(C, D') \ (subcls1 G)^+" .. + also from * acyc have "C \ D'" by(auto simp add: acyclic_def) with subcls "class" have "(D', C) \ (subcls1 G)^+" by(auto dest: rtranclD) finally show False using acyc by(auto simp add: acyclic_def) qed diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy Tue Sep 03 22:30:52 2013 +0200 @@ -2743,10 +2743,10 @@ using subspace_substandard[of "\i. i \ d"] . ultimately have "span d \ ?B" using span_mono[of d "?B"] span_eq[of "?B"] by blast - moreover have "card d \ dim (span d)" + moreover have *: "card d \ dim (span d)" using independent_card_le_dim[of d "span d"] independent_substdbasis[OF assms] span_inc[of d] by auto - moreover then have "dim ?B \ dim (span d)" + moreover from * have "dim ?B \ dim (span d)" using dim_substandard[OF assms] by auto ultimately show ?thesis using s subspace_dim_equal[of "span d" "?B"] subspace_span[of d] by auto @@ -8604,7 +8604,7 @@ { fix i assume "i:I" { assume "e i = 0" have ge: "u * (c i) >= 0 & v * (d i) >= 0" using xc yc uv `i:I` by (simp add: mult_nonneg_nonneg) - moreover hence "u * (c i) <= 0 & v * (d i) <= 0" using `e i = 0` e_def `i:I` by simp + moreover from ge have "u * (c i) <= 0 & v * (d i) <= 0" using `e i = 0` e_def `i:I` by simp ultimately have "u * (c i) = 0 & v * (d i) = 0" by auto hence "(u * (c i))*\<^sub>R (s i)+(v * (d i))*\<^sub>R (t i) = (e i) *\<^sub>R (q i)" using `e i = 0` by auto diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Multivariate_Analysis/Derivative.thy --- a/src/HOL/Multivariate_Analysis/Derivative.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Multivariate_Analysis/Derivative.thy Tue Sep 03 22:30:52 2013 +0200 @@ -1441,14 +1441,14 @@ have *:"(\x. x *\<^sub>R f') = (\x. x *\<^sub>R f'')" apply(rule frechet_derivative_unique_within_closed_interval[of "a" "b"]) using assms(3-)[unfolded has_vector_derivative_def] using assms(1-2) - by (auto simp: Basis_real_def) + by auto show ?thesis proof(rule ccontr) - assume "f' \ f''" - moreover - hence "(\x. x *\<^sub>R f') 1 = (\x. x *\<^sub>R f'') 1" - using * by (auto simp: fun_eq_iff) - ultimately show False unfolding o_def by auto + assume **: "f' \ f''" + with * have "(\x. x *\<^sub>R f') 1 = (\x. x *\<^sub>R f'') 1" + by (auto simp: fun_eq_iff) + with ** show False + unfolding o_def by auto qed qed diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy --- a/src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy Tue Sep 03 22:30:52 2013 +0200 @@ -63,10 +63,10 @@ assumes "closed S" "S \ {}" shows "Sup S \ S" proof - from compact_eq_closed[of S] compact_attains_sup[of S] assms - obtain s where "s \ S" "\t\S. t \ s" by auto - moreover then have "Sup S = s" + obtain s where S: "s \ S" "\t\S. t \ s" by auto + then have "Sup S = s" by (auto intro!: Sup_eqI) - ultimately show ?thesis + with S show ?thesis by simp qed @@ -75,10 +75,10 @@ assumes "closed S" "S \ {}" shows "Inf S \ S" proof - from compact_eq_closed[of S] compact_attains_inf[of S] assms - obtain s where "s \ S" "\t\S. s \ t" by auto - moreover then have "Inf S = s" + obtain s where S: "s \ S" "\t\S. s \ t" by auto + then have "Inf S = s" by (auto intro!: Inf_eqI) - ultimately show ?thesis + with S show ?thesis by simp qed diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Multivariate_Analysis/Integration.thy --- a/src/HOL/Multivariate_Analysis/Integration.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Multivariate_Analysis/Integration.thy Tue Sep 03 22:30:52 2013 +0200 @@ -905,12 +905,11 @@ then show "\a b. k = {a..b}" by auto have "k \ {a..b} \ k \ {}" proof (simp add: k interval_eq_empty subset_interval not_less, safe) - fix i :: 'a assume i: "i \ Basis" - moreover + fix i :: 'a + assume i: "i \ Basis" with f have "f i = (a, c) \ f i = (c, d) \ f i = (d, b)" by (auto simp: PiE_iff) - moreover note ord[of i] - ultimately + with i ord[of i] show "a \ i \ fst (f i) \ i" "snd (f i) \ i \ b \ i" "fst (f i) \ i \ snd (f i) \ i" by (auto simp: subset_iff eucl_le[where 'a='a]) qed @@ -952,7 +951,7 @@ by auto qed then guess f unfolding bchoice_iff .. note f = this - moreover then have "restrict f Basis \ Basis \\<^sub>E {(a, c), (c, d), (d, b)}" + moreover from f have "restrict f Basis \ Basis \\<^sub>E {(a, c), (c, d), (d, b)}" by auto moreover from f have "x \ ?B (restrict f Basis)" by (auto simp: mem_interval eucl_le[where 'a='a]) @@ -3874,7 +3873,7 @@ setprod_timesf setprod_constant inner_diff_left) next case False - moreover with as have "{m *\<^sub>R b + c..m *\<^sub>R a + c} \ {}" + with as have "{m *\<^sub>R b + c..m *\<^sub>R a + c} \ {}" unfolding interval_ne_empty apply (intro ballI) apply (erule_tac x=i in ballE) @@ -3882,7 +3881,7 @@ done moreover from False have *: "\i. (m *\<^sub>R a + c) \ i - (m *\<^sub>R b + c) \ i = (-m) *\<^sub>R (b - a) \ i" by (simp add: inner_simps field_simps) - ultimately show ?thesis + ultimately show ?thesis using False by (simp add: image_affinity_interval content_closed_interval' setprod_timesf[symmetric] setprod_constant[symmetric] inner_diff_left) qed @@ -3918,17 +3917,20 @@ unfolding interval_ne_empty by auto show "(\xa. x \ i = m i * xa \ a \ i \ xa \ xa \ b \ i) \ min (m i * (a \ i)) (m i * (b \ i)) \ x \ i \ x \ i \ max (m i * (a \ i)) (m i * (b \ i))" - proof cases - assume "m i \ 0" - moreover then have *: "\a b. a = m i * b \ b = a / m i" + proof (cases "m i = 0") + case True + with a_le_b show ?thesis by auto + next + case False + then have *: "\a b. a = m i * b \ b = a / m i" by (auto simp add: field_simps) - moreover have + from False have "min (m i * (a \ i)) (m i * (b \ i)) = (if 0 < m i then m i * (a \ i) else m i * (b \ i))" "max (m i * (a \ i)) (m i * (b \ i)) = (if 0 < m i then m i * (b \ i) else m i * (a \ i))" using a_le_b by (auto simp: min_def max_def mult_le_cancel_left) - ultimately show ?thesis using a_le_b + with False show ?thesis using a_le_b unfolding * by (auto simp add: le_divide_eq divide_le_eq ac_simps) - qed (insert a_le_b, auto) + qed qed qed simp diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy Tue Sep 03 22:30:52 2013 +0200 @@ -288,8 +288,8 @@ next fix S assume "open S" "x \ S" - from open_prod_elim[OF this] guess a' b' . - moreover with A(4)[of a'] B(4)[of b'] + from open_prod_elim[OF this] guess a' b' . note a'b' = this + moreover from a'b' A(4)[of a'] B(4)[of b'] obtain a b where "a \ A" "a \ a'" "b \ B" "b \ b'" by auto ultimately show "\a\(\(a, b). a \ b) ` (A \ B). a \ S" by (auto intro!: bexI[of _ "a \ b"] bexI[of _ a] bexI[of _ b]) @@ -3264,12 +3264,12 @@ unfolding C_def by auto qed then have "U \ \C" using `U \ \A` by auto - ultimately obtain T where "T\C" "finite T" "U \ \T" + ultimately obtain T where T: "T\C" "finite T" "U \ \T" using * by metis - moreover then have "\t\T. \a\A. t \ U \ a" + then have "\t\T. \a\A. t \ U \ a" by (auto simp: C_def) then guess f unfolding bchoice_iff Bex_def .. - ultimately show "\T\A. finite T \ U \ \T" + with T show "\T\A. finite T \ U \ \T" unfolding C_def by (intro exI[of _ "f`T"]) fastforce qed @@ -3708,10 +3708,9 @@ assume f: "bounded (range f)" obtain r where r: "subseq r" "monoseq (f \ r)" unfolding comp_def by (metis seq_monosub) - moreover then have "Bseq (f \ r)" unfolding Bseq_eq_bounded using f by (auto intro: bounded_subset) - ultimately show "\l r. subseq r \ (f \ r) ----> l" + with r show "\l r. subseq r \ (f \ r) ----> l" using Bseq_monoseq_convergent[of "f \ r"] by (auto simp: convergent_def) qed @@ -5558,9 +5557,9 @@ and c: "\y. y \ t \ c y \ C \ open (a y) \ open (b y) \ x \ a y \ y \ b y \ a y \ b y \ c y" by metis then have "\y\t. open (b y)" "t \ (\y\t. b y)" by auto - from compactE_image[OF `compact t` this] obtain D where "D \ t" "finite D" "t \ (\y\D. b y)" + from compactE_image[OF `compact t` this] obtain D where D: "D \ t" "finite D" "t \ (\y\D. b y)" by auto - moreover with c have "(\y\D. a y) \ t \ (\y\D. c y)" + moreover from D c have "(\y\D. a y) \ t \ (\y\D. c y)" by (fastforce simp: subset_eq) ultimately show "\a. open a \ x \ a \ (\d\C. finite d \ a \ t \ \d)" using c by (intro exI[of _ "c`D"] exI[of _ "\(a`D)"] conjI) (auto intro!: open_INT) @@ -7345,8 +7344,8 @@ shows "\S\A. card S = n" proof cases assume "finite A" - from ex_bij_betw_nat_finite[OF this] guess f .. - moreover with `n \ card A` have "{..< n} \ {..< card A}" "inj_on f {..< n}" + from ex_bij_betw_nat_finite[OF this] guess f .. note f = this + moreover from f `n \ card A` have "{..< n} \ {..< card A}" "inj_on f {..< n}" by (auto simp: bij_betw_def intro: subset_inj_on) ultimately have "f ` {..< n} \ A" "card (f ` {..< n}) = n" by (auto simp: bij_betw_def card_image) diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Nat.thy --- a/src/HOL/Nat.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Nat.thy Tue Sep 03 22:30:52 2013 +0200 @@ -1888,8 +1888,8 @@ proof - have "m dvd n - q \ m dvd r * m + (n - q)" by (auto elim: dvd_plusE) - also with assms have "\ \ m dvd r * m + n - q" by simp - also with assms have "\ \ m dvd (r * m - q) + n" by simp + also from assms have "\ \ m dvd r * m + n - q" by simp + also from assms have "\ \ m dvd (r * m - q) + n" by simp also have "\ \ m dvd n + (r * m - q)" by (simp add: add_commute) finally show ?thesis . qed diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Nominal/Examples/Crary.thy --- a/src/HOL/Nominal/Examples/Crary.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Nominal/Examples/Crary.thy Tue Sep 03 22:30:52 2013 +0200 @@ -766,9 +766,8 @@ assumes "\' \ t is s over \" shows "\' \ s is s over \" proof - - have "\' \ t is s over \" by fact - moreover then have "\' \ s is t over \" using logical_symmetry by blast - ultimately show "\' \ s is s over \" using logical_transitivity by blast + from assms have "\' \ s is t over \" using logical_symmetry by blast + with assms show "\' \ s is s over \" using logical_transitivity by blast qed lemma logical_subst_monotonicity : diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Number_Theory/Binomial.thy --- a/src/HOL/Number_Theory/Binomial.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Number_Theory/Binomial.thy Tue Sep 03 22:30:52 2013 +0200 @@ -203,7 +203,7 @@ by (subst choose_reduce_nat, auto simp add: field_simps) also note one also note two - also with less have "(n - k) * fact n + (k + 1) * fact n= fact (n + 1)" + also from less have "(n - k) * fact n + (k + 1) * fact n= fact (n + 1)" apply (subst fact_plus_one_nat) apply (subst distrib_right [symmetric]) apply simp diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Number_Theory/MiscAlgebra.thy --- a/src/HOL/Number_Theory/MiscAlgebra.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Number_Theory/MiscAlgebra.thy Tue Sep 03 22:30:52 2013 +0200 @@ -298,7 +298,7 @@ proof - have "(x \ \) \ (x \ \ \) = x \ x \ \ \" by (simp add: ring_simprules) - also with `x \ x = \` have "\ = \" + also from `x \ x = \` have "\ = \" by (simp add: ring_simprules) finally have "(x \ \) \ (x \ \ \) = \" . then have "(x \ \) = \ | (x \ \ \) = \" diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Predicate.thy --- a/src/HOL/Predicate.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Predicate.thy Tue Sep 03 22:30:52 2013 +0200 @@ -225,9 +225,9 @@ "\!x. eval A x \ eval A (singleton dfault A)" proof - assume assm: "\!x. eval A x" - then obtain x where "eval A x" .. - moreover with assm have "singleton dfault A = x" by (rule singleton_eqI) - ultimately show ?thesis by simp + then obtain x where x: "eval A x" .. + with assm have "singleton dfault A = x" by (rule singleton_eqI) + with x show ?thesis by simp qed lemma single_singleton: diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Predicate_Compile_Examples/Specialisation_Examples.thy --- a/src/HOL/Predicate_Compile_Examples/Specialisation_Examples.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Predicate_Compile_Examples/Specialisation_Examples.thy Tue Sep 03 22:30:52 2013 +0200 @@ -54,7 +54,8 @@ sorted_single [code_pred_intro] sorted_many [code_pred_intro] -code_pred sorted proof - +code_pred sorted +proof - assume "sorted xa" assume 1: "xa = [] \ thesis" assume 2: "\x. xa = [x] \ thesis" @@ -65,9 +66,12 @@ case (Cons x xs) show ?thesis proof (cases xs) case Nil with Cons 2 show ?thesis by simp next - case (Cons y zs) with `xa = x # xs` have "xa = x # y # zs" by simp - moreover with `sorted xa` have "x \ y" and "sorted (y # zs)" by simp_all - ultimately show ?thesis by (rule 3) + case (Cons y zs) + show ?thesis + proof (rule 3) + from Cons `xa = x # xs` show "xa = x # y # zs" by simp + with `sorted xa` show "x \ y" and "sorted (y # zs)" by simp_all + qed qed qed qed diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Probability/Binary_Product_Measure.thy --- a/src/HOL/Probability/Binary_Product_Measure.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Probability/Binary_Product_Measure.thy Tue Sep 03 22:30:52 2013 +0200 @@ -177,9 +177,9 @@ by (auto intro!: measurable_If simp: space_pair_measure) next case (union F) - moreover then have *: "\x. emeasure M (Pair x -` (\i. F i)) = (\i. ?s (F i) x)" + then have "\x. emeasure M (Pair x -` (\i. F i)) = (\i. ?s (F i) x)" by (simp add: suminf_emeasure disjoint_family_vimageI subset_eq vimage_UN sets_pair_measure[symmetric]) - ultimately show ?case + with union show ?case unfolding sets_pair_measure[symmetric] by simp qed (auto simp add: if_distrib Int_def[symmetric] intro!: measurable_If) @@ -515,9 +515,9 @@ shows "(\\<^sup>+ x. \\<^sup>+ y. f (x, y) \M \M1) = integral\<^sup>P (M1 \\<^sub>M M) f" (is "?I f = _") using f proof induct case (cong u v) - moreover then have "?I u = ?I v" + then have "?I u = ?I v" by (intro positive_integral_cong) (auto simp: space_pair_measure) - ultimately show ?case + with cong show ?case by (simp cong: positive_integral_cong) qed (simp_all add: emeasure_pair_measure positive_integral_cmult positive_integral_add positive_integral_monotone_convergence_SUP diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Probability/Fin_Map.thy --- a/src/HOL/Probability/Fin_Map.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Probability/Fin_Map.thy Tue Sep 03 22:30:52 2013 +0200 @@ -342,9 +342,9 @@ case (UN K) show ?case proof safe - fix x X assume "x \ X" "X \ K" - moreover with UN obtain e where "e>0" "\y. dist y x < e \ y \ X" by force - ultimately show "\e>0. \y. dist y x < e \ y \ \K" by auto + fix x X assume "x \ X" and X: "X \ K" + with UN obtain e where "e>0" "\y. dist y x < e \ y \ X" by force + with X show "\e>0. \y. dist y x < e \ y \ \K" by auto qed next case (Basis s) then obtain a b where s: "s = Pi' a b" and b: "\i. i\a \ open (b i)" by auto @@ -363,12 +363,10 @@ show "y \ s" unfolding s proof show "domain y = a" using d s `a \ {}` by (auto simp: dist_le_1_imp_domain_eq a_dom) - fix i assume "i \ a" - moreover + fix i assume i: "i \ a" hence "dist ((y)\<^sub>F i) ((x)\<^sub>F i) < es i" using d by (auto simp: dist_finmap_def `a \ {}` intro!: le_less_trans[OF dist_proj]) - ultimately - show "y i \ b i" by (rule in_b) + with i show "y i \ b i" by (rule in_b) qed next assume "\a \ {}" @@ -715,9 +713,9 @@ proof - have "\{f s|s. P s} = (\n::nat. let s = set (from_nat n) in if P s then f s else {})" proof safe - fix x X s assume "x \ f s" "P s" - moreover with assms obtain l where "s = set l" using finite_list by blast - ultimately show "x \ (\n. let s = set (from_nat n) in if P s then f s else {})" using `P s` + fix x X s assume *: "x \ f s" "P s" + with assms obtain l where "s = set l" using finite_list by blast + with * show "x \ (\n. let s = set (from_nat n) in if P s then f s else {})" using `P s` by (auto intro!: exI[where x="to_nat l"]) next fix x n assume "x \ (let s = set (from_nat n) in if P s then f s else {})" diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Probability/Finite_Product_Measure.thy --- a/src/HOL/Probability/Finite_Product_Measure.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Probability/Finite_Product_Measure.thy Tue Sep 03 22:30:52 2013 +0200 @@ -235,7 +235,7 @@ using sets.sets_into_space by auto then have "A = (\\<^sub>E i\I. if i\J then E i else space (M i))" using A J by (auto simp: prod_emb_PiE) - moreover then have "(\i. if i\J then E i else space (M i)) \ (\ i\I. sets (M i))" + moreover have "(\i. if i\J then E i else space (M i)) \ (\ i\I. sets (M i))" using sets.top E by auto ultimately show ?thesis using that by auto qed @@ -792,9 +792,9 @@ proof (intro measure_eqI[symmetric]) interpret I: finite_product_sigma_finite M "{i}" by default simp fix A assume A: "A \ sets (M i)" - moreover then have "(\x. x i) -` A \ space (Pi\<^sub>M {i} M) = (\\<^sub>E i\{i}. A)" + then have "(\x. x i) -` A \ space (Pi\<^sub>M {i} M) = (\\<^sub>E i\{i}. A)" using sets.sets_into_space by (auto simp: space_PiM) - ultimately show "emeasure (M i) A = emeasure ?D A" + then show "emeasure (M i) A = emeasure ?D A" using A I.measure_times[of "\_. A"] by (simp add: emeasure_distr measurable_component_singleton) qed simp diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Probability/Infinite_Product_Measure.thy --- a/src/HOL/Probability/Infinite_Product_Measure.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Probability/Infinite_Product_Measure.thy Tue Sep 03 22:30:52 2013 +0200 @@ -246,7 +246,7 @@ then show ?case by auto qed moreover - then have "w k \ space (Pi\<^sub>M (J k) M)" by auto + from w have "w k \ space (Pi\<^sub>M (J k) M)" by auto moreover from w have "?a / 2 ^ (k + 1) \ ?q k k (w k)" by auto then have "?M (J k) (A k) (w k) \ {}" @@ -344,10 +344,10 @@ assume "I = {}" then show ?thesis by (simp add: space_PiM_empty) next assume "I \ {}" - then obtain i where "i \ I" by auto - moreover then have "emb I {i} (\\<^sub>E i\{i}. space (M i)) = (space (Pi\<^sub>M I M))" + then obtain i where i: "i \ I" by auto + then have "emb I {i} (\\<^sub>E i\{i}. space (M i)) = (space (Pi\<^sub>M I M))" by (auto simp: prod_emb_def space_PiM) - ultimately show ?thesis + with i show ?thesis using emeasure_PiM_emb_not_empty[of "{i}" "\i. space (M i)"] by (simp add: emeasure_PiM emeasure_space_1) qed diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Probability/Information.thy --- a/src/HOL/Probability/Information.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Probability/Information.thy Tue Sep 03 22:30:52 2013 +0200 @@ -381,10 +381,10 @@ shows "absolutely_continuous S (distr (S \\<^sub>M T) S fst)" proof - interpret sigma_finite_measure T by fact - { fix A assume "A \ sets S" "emeasure S A = 0" - moreover then have "fst -` A \ space (S \\<^sub>M T) = A \ space T" + { fix A assume A: "A \ sets S" "emeasure S A = 0" + then have "fst -` A \ space (S \\<^sub>M T) = A \ space T" by (auto simp: space_pair_measure dest!: sets.sets_into_space) - ultimately have "emeasure (S \\<^sub>M T) (fst -` A \ space (S \\<^sub>M T)) = 0" + with A have "emeasure (S \\<^sub>M T) (fst -` A \ space (S \\<^sub>M T)) = 0" by (simp add: emeasure_pair_measure_Times) } then show ?thesis unfolding absolutely_continuous_def @@ -398,10 +398,10 @@ shows "absolutely_continuous T (distr (S \\<^sub>M T) T snd)" proof - interpret sigma_finite_measure T by fact - { fix A assume "A \ sets T" "emeasure T A = 0" - moreover then have "snd -` A \ space (S \\<^sub>M T) = space S \ A" + { fix A assume A: "A \ sets T" "emeasure T A = 0" + then have "snd -` A \ space (S \\<^sub>M T) = space S \ A" by (auto simp: space_pair_measure dest!: sets.sets_into_space) - ultimately have "emeasure (S \\<^sub>M T) (snd -` A \ space (S \\<^sub>M T)) = 0" + with A have "emeasure (S \\<^sub>M T) (snd -` A \ space (S \\<^sub>M T)) = 0" by (simp add: emeasure_pair_measure_Times) } then show ?thesis unfolding absolutely_continuous_def diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Probability/Lebesgue_Integration.thy --- a/src/HOL/Probability/Lebesgue_Integration.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Probability/Lebesgue_Integration.thy Tue Sep 03 22:30:52 2013 +0200 @@ -675,12 +675,11 @@ assumes f: "simple_function M f" shows "(\\<^sup>Sx. f x * indicator A x \M) = (\x \ f ` space M. x * (emeasure M) (f -` {x} \ space M \ A))" -proof cases - assume "A = space M" - moreover hence "(\\<^sup>Sx. f x * indicator A x \M) = integral\<^sup>S M f" +proof (cases "A = space M") + case True + then have "(\\<^sup>Sx. f x * indicator A x \M) = integral\<^sup>S M f" by (auto intro!: simple_integral_cong) - moreover have "\X. X \ space M \ space M = X \ space M" by auto - ultimately show ?thesis by (simp add: simple_integral_def) + with True show ?thesis by (simp add: simple_integral_def) next assume "A \ space M" then obtain x where x: "x \ space M" "x \ A" using sets.sets_into_space[OF assms(1)] by auto @@ -1001,10 +1000,10 @@ unfolding positive_integral_def_finite[of _ "\x. SUP i. f i x"] proof (safe intro!: SUP_least) fix g assume g: "simple_function M g" - and "g \ max 0 \ (\x. SUP i. f i x)" "range g \ {0..<\}" - moreover then have "\x. 0 \ (SUP i. f i x)" and g': "g`space M \ {0..<\}" + and *: "g \ max 0 \ (\x. SUP i. f i x)" "range g \ {0..<\}" + then have "\x. 0 \ (SUP i. f i x)" and g': "g`space M \ {0..<\}" using f by (auto intro!: SUP_upper2) - ultimately show "integral\<^sup>S M g \ (SUP j. integral\<^sup>P M (f j))" + with * show "integral\<^sup>S M g \ (SUP j. integral\<^sup>P M (f j))" by (intro positive_integral_SUP_approx[OF f g _ g']) (auto simp: le_fun_def max_def) qed @@ -1357,7 +1356,7 @@ proof (safe intro!: incseq_SucI) fix n :: nat and x assume *: "1 \ real n * u x" - also from gt_1[OF this] have "real n * u x \ real (Suc n) * u x" + also from gt_1[OF *] have "real n * u x \ real (Suc n) * u x" using `0 \ u x` by (auto intro!: ereal_mult_right_mono) finally show "1 \ real (Suc n) * u x" by auto qed @@ -2658,10 +2657,9 @@ using f by (simp add: positive_integral_cmult) next case (add u v) - moreover then have "\x. f x * (v x + u x) = f x * v x + f x * u x" + then have "\x. f x * (v x + u x) = f x * v x + f x * u x" by (simp add: ereal_right_distrib) - moreover note f - ultimately show ?case + with add f show ?case by (auto simp add: positive_integral_add ereal_zero_le_0_iff intro!: positive_integral_add[symmetric]) next case (seq U) diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Probability/Lebesgue_Measure.thy --- a/src/HOL/Probability/Lebesgue_Measure.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Probability/Lebesgue_Measure.thy Tue Sep 03 22:30:52 2013 +0200 @@ -983,22 +983,20 @@ shows "integrable lborel f \ integrable (\\<^sub>M (i::'a)\Basis. lborel) (\x. f (p2e x))" (is "_ \ integrable ?B ?f") proof - assume "integrable lborel f" - moreover then have f: "f \ borel_measurable borel" + assume *: "integrable lborel f" + then have f: "f \ borel_measurable borel" by auto - moreover with measurable_p2e - have "f \ p2e \ borel_measurable ?B" + with measurable_p2e have "f \ p2e \ borel_measurable ?B" by (rule measurable_comp) - ultimately show "integrable ?B ?f" + with * f show "integrable ?B ?f" by (simp add: comp_def borel_fubini_positiv_integral integrable_def) next - assume "integrable ?B ?f" - moreover + assume *: "integrable ?B ?f" then have "?f \ e2p \ borel_measurable (borel::'a measure)" by (auto intro!: measurable_e2p) then have "f \ borel_measurable borel" by (simp cong: measurable_cong) - ultimately show "integrable lborel f" + with * show "integrable lborel f" by (simp add: borel_fubini_positiv_integral integrable_def) qed diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Probability/Measure_Space.thy --- a/src/HOL/Probability/Measure_Space.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Probability/Measure_Space.thy Tue Sep 03 22:30:52 2013 +0200 @@ -158,7 +158,8 @@ and A: "A`S \ M" and disj: "disjoint_family_on A S" shows "(\i\S. f (A i)) = f (\i\S. A i)" -using `finite S` disj A proof induct + using `finite S` disj A +proof induct case empty show ?case using f by (simp add: positive_def) next case (insert s S) @@ -168,7 +169,6 @@ have "A s \ M" using insert by blast moreover have "(\i\S. A i) \ M" using insert `finite S` by auto - moreover ultimately have "f (A s \ (\i\S. A i)) = f (A s) + f(\i\S. A i)" using ad UNION_in_sets A by (auto simp add: additive_def) with insert show ?case using ad disjoint_family_on_mono[of S "insert s S" A] @@ -781,15 +781,15 @@ using sets.sets_into_space by auto show "{} \ null_sets M" by auto - fix A B assume sets: "A \ null_sets M" "B \ null_sets M" - then have "A \ sets M" "B \ sets M" + fix A B assume null_sets: "A \ null_sets M" "B \ null_sets M" + then have sets: "A \ sets M" "B \ sets M" by auto - moreover then have "emeasure M (A \ B) \ emeasure M A + emeasure M B" + then have *: "emeasure M (A \ B) \ emeasure M A + emeasure M B" "emeasure M (A - B) \ emeasure M A" by (auto intro!: emeasure_subadditive emeasure_mono) - moreover have "emeasure M B = 0" "emeasure M A = 0" - using sets by auto - ultimately show "A - B \ null_sets M" "A \ B \ null_sets M" + then have "emeasure M B = 0" "emeasure M A = 0" + using null_sets by auto + with sets * show "A - B \ null_sets M" "A \ B \ null_sets M" by (auto intro!: antisym) qed @@ -1563,9 +1563,9 @@ by (auto intro!: Lim_eventually eventually_sequentiallyI[where c=i]) next assume "\ (\i. \j\i. F i = F j)" - then obtain f where "\i. i \ f i" "\i. F i \ F (f i)" by metis - moreover then have "\i. F i \ F (f i)" using `incseq F` by (auto simp: incseq_def) - ultimately have *: "\i. F i \ F (f i)" by auto + then obtain f where f: "\i. i \ f i" "\i. F i \ F (f i)" by metis + then have "\i. F i \ F (f i)" using `incseq F` by (auto simp: incseq_def) + with f have *: "\i. F i \ F (f i)" by auto have "incseq (\i. ?M (F i))" using `incseq F` unfolding incseq_def by (auto simp: card_mono dest: finite_subset) diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Probability/Projective_Limit.thy --- a/src/HOL/Probability/Projective_Limit.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Probability/Projective_Limit.thy Tue Sep 03 22:30:52 2013 +0200 @@ -257,14 +257,13 @@ finally have "fm n x \ fm n ` B n" . thus "x \ B n" proof safe - fix y assume "y \ B n" - moreover + fix y assume y: "y \ B n" hence "y \ space (Pi\<^sub>M (J n) (\_. borel))" using J sets.sets_into_space[of "B n" "P (J n)"] by (auto simp add: proj_space proj_sets) assume "fm n x = fm n y" note inj_onD[OF inj_on_fm[OF space_borel], OF `fm n x = fm n y` `x \ space _` `y \ space _`] - ultimately show "x \ B n" by simp + with y show "x \ B n" by simp qed qed { fix n @@ -438,10 +437,11 @@ apply (subst (2) tendsto_iff, subst eventually_sequentially) proof safe fix e :: real assume "0 < e" - { fix i x assume "i \ n" "t \ domain (fm n x)" - moreover + { fix i x + assume i: "i \ n" + assume "t \ domain (fm n x)" hence "t \ domain (fm i x)" using J_mono[OF `i \ n`] by auto - ultimately have "(fm i x)\<^sub>F t = (fm n x)\<^sub>F t" + with i have "(fm i x)\<^sub>F t = (fm n x)\<^sub>F t" using j by (auto simp: proj_fm dest!: inj_onD[OF inj_on_Utn]) } note index_shift = this have I: "\i. i \ n \ Suc (diagseq i) \ n" @@ -487,11 +487,11 @@ also have "finmap_of (Utn ` J n) z = fm n (\i. z (Utn i))" unfolding finmap_eq_iff proof clarsimp - fix i assume "i \ J n" - moreover hence "from_nat_into (\n. J n) (Utn i) = i" + fix i assume i: "i \ J n" + hence "from_nat_into (\n. J n) (Utn i) = i" unfolding Utn_def by (subst from_nat_into_to_nat_on[OF countable_UN_J]) auto - ultimately show "z (Utn i) = (fm n (\i. z (Utn i)))\<^sub>F (Utn i)" + with i show "z (Utn i) = (fm n (\i. z (Utn i)))\<^sub>F (Utn i)" by (simp add: finmap_eq_iff fm_def compose_def) qed finally have "fm n (\i. z (Utn i)) \ K' n" . diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Probability/Radon_Nikodym.thy --- a/src/HOL/Probability/Radon_Nikodym.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Probability/Radon_Nikodym.thy Tue Sep 03 22:30:52 2013 +0200 @@ -412,14 +412,14 @@ have ac: "absolutely_continuous M ?M" unfolding absolutely_continuous_def proof - fix A assume A: "A \ null_sets M" - with `absolutely_continuous M N` have "A \ null_sets N" + fix A assume A_M: "A \ null_sets M" + with `absolutely_continuous M N` have A_N: "A \ null_sets N" unfolding absolutely_continuous_def by auto - moreover with A have "(\\<^sup>+ x. ?F A x \M) \ N A" using `f \ G` by (auto simp: G_def) + moreover from A_M A_N have "(\\<^sup>+ x. ?F A x \M) \ N A" using `f \ G` by (auto simp: G_def) ultimately have "N A - (\\<^sup>+ x. ?F A x \M) = 0" using positive_integral_positive[of M] by (auto intro!: antisym) then show "A \ null_sets ?M" - using A by (simp add: emeasure_M null_sets_def sets_eq) + using A_M by (simp add: emeasure_M null_sets_def sets_eq) qed have upper_bound: "\A\sets M. ?M A \ 0" proof (rule ccontr) @@ -431,7 +431,7 @@ using emeasure_space[of ?M A] by (simp add: sets_eq[THEN sets_eq_imp_space_eq]) finally have pos_t: "0 < ?M (space M)" by simp moreover - then have "emeasure M (space M) \ 0" + from pos_t have "emeasure M (space M) \ 0" using ac unfolding absolutely_continuous_def by (auto simp: null_sets_def) then have pos_M: "0 < emeasure M (space M)" using emeasure_nonneg[of M "space M"] by (simp add: le_less) @@ -594,12 +594,14 @@ proof (rule disjCI, simp) assume *: "0 < emeasure M A \ N A \ \" show "emeasure M A = 0 \ N A = 0" - proof cases - assume "emeasure M A = 0" moreover with ac A have "N A = 0" + proof (cases "emeasure M A = 0") + case True + with ac A have "N A = 0" unfolding absolutely_continuous_def by auto - ultimately show ?thesis by simp + with True show ?thesis by simp next - assume "emeasure M A \ 0" with * have "N A \ \" using emeasure_nonneg[of M A] by auto + case False + with * have "N A \ \" using emeasure_nonneg[of M A] by auto with A have "emeasure M ?O_0 + emeasure M A = emeasure M (?O_0 \ A)" using Q' by (auto intro!: plus_emeasure sets.countable_UN) also have "\ = (SUP i. emeasure M (?O i \ A))" diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Probability/Sigma_Algebra.thy --- a/src/HOL/Probability/Sigma_Algebra.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Probability/Sigma_Algebra.thy Tue Sep 03 22:30:52 2013 +0200 @@ -1244,8 +1244,8 @@ interpret N: sigma_algebra \' A' using measure_measure by (auto simp: measure_space_def) have "A = sets M" "A' = sets N" using measure_measure by (simp_all add: sets_def Abs_measure_inverse) - with `sets M = sets N` have "A = A'" by simp - moreover with M.top N.top M.space_closed N.space_closed have "\ = \'" by auto + with `sets M = sets N` have AA': "A = A'" by simp + moreover from M.top N.top M.space_closed N.space_closed AA' have "\ = \'" by auto moreover { fix B have "\ B = \' B" proof cases assume "B \ A" @@ -1977,7 +1977,7 @@ moreover have "D \ (\ - E) = (\i. ?f i)" by (auto simp: image_iff split: split_if_asm) moreover - then have "disjoint_family ?f" unfolding disjoint_family_on_def + have "disjoint_family ?f" unfolding disjoint_family_on_def using `D \ M`[THEN sets_into_space] `D \ E` by auto ultimately have "\ - (D \ (\ - E)) \ M" using sets by auto @@ -2193,11 +2193,11 @@ proof - have "E \ Pow \" using E sets_into_space by force - then have "sigma_sets \ E = dynkin \ E" + then have *: "sigma_sets \ E = dynkin \ E" using `Int_stable E` by (rule sigma_eq_dynkin) - moreover then have "dynkin \ E = M" + then have "dynkin \ E = M" using assms dynkin_subset[OF E(1)] by simp - ultimately show ?thesis + with * show ?thesis using assms by (auto simp: dynkin_def) qed diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Probability/ex/Dining_Cryptographers.thy --- a/src/HOL/Probability/ex/Dining_Cryptographers.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Probability/ex/Dining_Cryptographers.thy Tue Sep 03 22:30:52 2013 +0200 @@ -5,7 +5,7 @@ lemma image_ex1_eq: "inj_on f A \ (b \ f ` A) \ (\!x \ A. b = f x)" by (unfold inj_on_def) blast -lemma Ex1_eq: "\! x. P x \ P x \ P y \ x = y" +lemma Ex1_eq: "\!x. P x \ P x \ P y \ x = y" by auto section "Define the state space" @@ -143,8 +143,8 @@ thus "x ! j = y ! j" proof (induct j) case (Suc j) - moreover hence "j < n" by simp - ultimately show ?case using *[OF `j < n`] + hence "j < n" by simp + with Suc show ?case using *[OF `j < n`] by (cases "y ! j") simp_all qed simp qed @@ -234,7 +234,7 @@ hence zs: "inversion (Some i, zs) = xs" by (simp add: xs_inv[symmetric] inversion_def coin_def payer_def) moreover - hence Not_zs: "inversion (Some i, (map Not zs)) = xs" + from zs have Not_zs: "inversion (Some i, (map Not zs)) = xs" by (simp add: xs_inv[symmetric] inversion_def coin_def payer_def) ultimately have "{dc \ dc_crypto. payer dc = Some i \ inversion dc = xs} = diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Quotient_Examples/FSet.thy --- a/src/HOL/Quotient_Examples/FSet.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Quotient_Examples/FSet.thy Tue Sep 03 22:30:52 2013 +0200 @@ -1033,9 +1033,9 @@ case (insert x A) from insert.prems insert.hyps(1) have "\z. z \ fset A \ z \ fset (B - {|x|})" by (auto simp add: in_fset) - then have "A = B - {|x|}" by (rule insert.hyps(2)) - moreover with insert.prems [symmetric, of x] have "x |\| B" by (simp add: in_fset) - ultimately show ?case by (metis in_fset_mdef) + then have A: "A = B - {|x|}" by (rule insert.hyps(2)) + with insert.prems [symmetric, of x] have "x |\| B" by (simp add: in_fset) + with A show ?case by (metis in_fset_mdef) qed subsection {* alternate formulation with a different decomposition principle diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Rat.thy --- a/src/HOL/Rat.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Rat.thy Tue Sep 03 22:30:52 2013 +0200 @@ -237,7 +237,7 @@ next case False then obtain a b where "q = Fract a b" and "b > 0" and "coprime a b" by (cases q) auto - moreover with False have "0 \ Fract a b" by simp + with False have "0 \ Fract a b" by simp with `b > 0` have "a \ 0" by (simp add: Zero_rat_def eq_rat) with Fract `q = Fract a b` `b > 0` `coprime a b` show C by blast qed diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Real.thy --- a/src/HOL/Real.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Real.thy Tue Sep 03 22:30:52 2013 +0200 @@ -947,7 +947,7 @@ using complete_real[of X] by blast then have "Sup X = s" unfolding Sup_real_def by (best intro: Least_equality) - also with s z have "... \ z" + also from s z have "... \ z" by blast finally show "Sup X \ z" . } note Sup_least = this diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Real_Vector_Spaces.thy --- a/src/HOL/Real_Vector_Spaces.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Real_Vector_Spaces.thy Tue Sep 03 22:30:52 2013 +0200 @@ -758,10 +758,10 @@ show "\A::nat \ 'a set. (\i. x \ A i \ open (A i)) \ (\S. open S \ x \ S \ (\i. A i \ S))" proof (safe intro!: exI[of _ "\n. {y. dist x y < inverse (Suc n)}"]) fix S assume "open S" "x \ S" - then obtain e where "0 < e" "{y. dist x y < e} \ S" + then obtain e where e: "0 < e" and "{y. dist x y < e} \ S" by (auto simp: open_dist subset_eq dist_commute) moreover - then obtain i where "inverse (Suc i) < e" + from e obtain i where "inverse (Suc i) < e" by (auto dest!: reals_Archimedean) then have "{y. dist x y < inverse (Suc i)} \ {y. dist x y < e}" by auto @@ -833,7 +833,8 @@ show "(open :: real set \ bool) = generate_topology (range lessThan \ range greaterThan)" proof (rule ext, safe) fix S :: "real set" assume "open S" - then guess f unfolding open_real_def bchoice_iff .. + then obtain f where "\x\S. 0 < f x \ (\y. dist y x < f x \ y \ S)" + unfolding open_real_def bchoice_iff .. then have *: "S = (\x\S. {x - f x <..} \ {..< x + f x})" by (fastforce simp: dist_real_def) show "generate_topology (range lessThan \ range greaterThan) S" @@ -1525,7 +1526,8 @@ with limseq obtain N :: nat where N: "\n. N \ n \ \f (real n) - y\ < e" by (auto simp: LIMSEQ_def dist_real_def) { fix x :: real - from ex_le_of_nat[of x] guess n .. + obtain n where "x \ real_of_nat n" + using ex_le_of_nat[of x] .. note monoD[OF mono this] also have "f (real_of_nat n) \ y" by (rule LIMSEQ_le_const[OF limseq]) diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Set_Interval.thy --- a/src/HOL/Set_Interval.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Set_Interval.thy Tue Sep 03 22:30:52 2013 +0200 @@ -269,9 +269,9 @@ "{a .. b} = {c} \ a = b \ b = c" proof assume "{a..b} = {c}" - hence "\ (\ a \ b)" unfolding atLeastatMost_empty_iff[symmetric] by simp - moreover with `{a..b} = {c}` have "c \ a \ b \ c" by auto - ultimately show "a = b \ b = c" by auto + hence *: "\ (\ a \ b)" unfolding atLeastatMost_empty_iff[symmetric] by simp + with `{a..b} = {c}` have "c \ a \ b \ c" by auto + with * show "a = b \ b = c" by auto qed simp lemma Icc_subset_Ici_iff[simp]: @@ -827,21 +827,23 @@ subset is exactly that interval. *} lemma subset_card_intvl_is_intvl: - "A <= {k.. A = {k.. {k.. A" by auto + with insert have "A <= {k.. 0` have "(1 + y) ^ n = (y * inverse y) * (1 + y) ^ n" by simp + moreover from Suc `y \ 0` have "(1 + y) ^ n = (y * inverse y) * (1 + y) ^ n" by simp ultimately show ?case by (simp add: field_simps divide_inverse) qed ultimately show ?thesis by simp diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Statespace/DistinctTreeProver.thy --- a/src/HOL/Statespace/DistinctTreeProver.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Statespace/DistinctTreeProver.thy Tue Sep 03 22:30:52 2013 +0200 @@ -572,13 +572,13 @@ shows "delete x (Node l y d r) = Some (Node l' y d r)" proof - from delete_Some_x_set_of [OF del_l] - obtain "x \ set_of l" + obtain x: "x \ set_of l" by simp - moreover with dist + with dist have "delete x r = None" by (cases "delete x r") (auto dest:delete_Some_x_set_of) - ultimately + with x show ?thesis using del_l dist by (auto split: option.splits) @@ -590,13 +590,13 @@ shows "delete x (Node l y d r) = Some (Node l y d r')" proof - from delete_Some_x_set_of [OF del_r] - obtain "x \ set_of r" + obtain x: "x \ set_of r" by simp - moreover with dist + with dist have "delete x l = None" by (cases "delete x l") (auto dest:delete_Some_x_set_of) - ultimately + with x show ?thesis using del_r dist by (auto split: option.splits) diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Tools/Nitpick/nitpick.ML --- a/src/HOL/Tools/Nitpick/nitpick.ML Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Tools/Nitpick/nitpick.ML Tue Sep 03 22:30:52 2013 +0200 @@ -456,11 +456,11 @@ provide a hint to the user. *) fun is_struct_induct_step (name, (Rule_Cases.Case {fixes, assumes, ...}, _)) = not (null fixes) andalso - exists (String.isSuffix ".hyps" o fst) assumes andalso + exists (String.isSuffix ".hyps" o Name_Space.full_name Name_Space.default_naming o fst) assumes andalso exists (exists (curry (op =) name o shortest_name o fst) o datatype_constrs hol_ctxt) deep_dataTs val likely_in_struct_induct_step = - exists is_struct_induct_step (Proof_Context.cases_of ctxt) + exists is_struct_induct_step (Proof_Context.dest_cases ctxt) val _ = if standard andalso likely_in_struct_induct_step then pprint_nt (fn () => Pretty.blk (0, pstrs "Hint: To check that the induction hypothesis is \ diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Tools/Predicate_Compile/predicate_compile_core.ML --- a/src/HOL/Tools/Predicate_Compile/predicate_compile_core.ML Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Tools/Predicate_Compile/predicate_compile_core.ML Tue Sep 03 22:30:52 2013 +0200 @@ -1574,6 +1574,9 @@ Attrib.setup @{binding code_pred_intro} (Scan.lift (Scan.option Args.name) >> attrib' add_intro) "adding alternative introduction rules for code generation of inductive predicates" +fun qualified_binding a = + Binding.qualify true (Long_Name.qualifier a) (Binding.name (Long_Name.base_name a)); + (* TODO: make Theory_Data to Generic_Data & remove duplication of local theory and theory *) (* FIXME ... this is important to avoid changing the background theory below *) fun generic_code_pred prep_const options raw_const lthy = @@ -1593,14 +1596,17 @@ val cases_rules = map mk_cases preds val cases = map2 (fn pred_name => fn case_rule => Rule_Cases.Case {fixes = [], - assumes = ("that", tl (Logic.strip_imp_prems case_rule)) - :: (map_filter (fn (fact_name, fact) => Option.map (rpair [fact]) fact_name) - ((SOME (Long_Name.base_name pred_name ^ ".prems") :: names_of ctxt' pred_name) ~~ Logic.strip_imp_prems case_rule)), + assumes = + (Binding.name "that", tl (Logic.strip_imp_prems case_rule)) :: + map_filter (fn (fact_name, fact) => + Option.map (fn a => (qualified_binding a, [fact])) fact_name) + ((SOME (Long_Name.base_name pred_name ^ ".prems") :: names_of ctxt' pred_name) ~~ + Logic.strip_imp_prems case_rule), binds = [], cases = []}) preds cases_rules val case_env = map2 (fn p => fn c => (Long_Name.base_name p, SOME c)) preds cases val lthy'' = lthy' |> fold Variable.auto_fixes cases_rules - |> Proof_Context.add_cases true case_env + |> Proof_Context.update_cases true case_env fun after_qed thms goal_ctxt = let val global_thms = Proof_Context.export goal_ctxt diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/Topological_Spaces.thy --- a/src/HOL/Topological_Spaces.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/Topological_Spaces.thy Tue Sep 03 22:30:52 2013 +0200 @@ -215,14 +215,14 @@ lemma (in linorder) less_separate: assumes "x < y" shows "\a b. x \ {..< a} \ y \ {b <..} \ {..< a} \ {b <..} = {}" -proof cases - assume "\z. x < z \ z < y" - then guess z .. +proof (cases "\z. x < z \ z < y") + case True + then obtain z where "x < z \ z < y" .. then have "x \ {..< z} \ y \ {z <..} \ {z <..} \ {..< z} = {}" by auto then show ?thesis by blast next - assume "\ (\z. x < z \ z < y)" + case False with `x < y` have "x \ {..< y} \ y \ {x <..} \ {x <..} \ {..< y} = {}" by auto then show ?thesis by blast @@ -570,10 +570,11 @@ lemma eventually_at_top_dense: "eventually P at_top \ (\N::'a::unbounded_dense_linorder. \n>N. P n)" unfolding eventually_at_top_linorder proof safe - fix N assume "\n\N. P n" then show "\N. \n>N. P n" by (auto intro!: exI[of _ N]) + fix N assume "\n\N. P n" + then show "\N. \n>N. P n" by (auto intro!: exI[of _ N]) next fix N assume "\n>N. P n" - moreover from gt_ex[of N] guess y .. + moreover obtain y where "N < y" using gt_ex[of N] .. ultimately show "\N. \n\N. P n" by (auto intro!: exI[of _ y]) qed @@ -606,7 +607,7 @@ fix N assume "\n\N. P n" then show "\N. \nnN. \n\N. P n" by (auto intro!: exI[of _ y]) qed @@ -765,7 +766,7 @@ shows "eventually P (at_right x) \ (\b. x < b \ (\z. x < z \ z < b \ P z))" unfolding eventually_at_topological proof safe - from gt_ex[of x] guess y .. + obtain y where "x < y" using gt_ex[of x] .. moreover fix S assume "open S" "x \ S" note open_right[OF this, of y] moreover note gt_ex[of x] moreover assume "\s\S. s \ x \ s \ {x<..} \ P s" @@ -782,7 +783,7 @@ shows "eventually P (at_left x) \ (\b. x > b \ (\z. b < z \ z < x \ P z))" unfolding eventually_at_topological proof safe - from lt_ex[of x] guess y .. + obtain y where "y < x" using lt_ex[of x] .. moreover fix S assume "open S" "x \ S" note open_left[OF this, of y] moreover assume "\s\S. s \ x \ s \ {.. P s" ultimately show "\bz. b < z \ z < x \ P z" @@ -1513,10 +1514,16 @@ "\i. open (A i)" "\i. x \ A i" "\F. (\n. F n \ A n) \ F ----> x" proof atomize_elim - from countable_basis_at_decseq[of x] guess A . note A = this - { fix F S assume "\n. F n \ A n" "open S" "x \ S" + obtain A :: "nat \ 'a set" where A: + "\i. open (A i)" + "\i. x \ A i" + "\S. open S \ x \ S \ eventually (\i. A i \ S) sequentially" + by (rule countable_basis_at_decseq) blast + { + fix F S assume "\n. F n \ A n" "open S" "x \ S" with A(3)[of S] have "eventually (\n. F n \ S) sequentially" - by (auto elim: eventually_elim1 simp: subset_eq) } + by (auto elim: eventually_elim1 simp: subset_eq) + } with A show "\A. (\i. open (A i)) \ (\i. x \ A i) \ (\F. (\n. F n \ A n) \ F ----> x)" by (intro exI[of _ A]) (auto simp: tendsto_def) qed @@ -1525,13 +1532,16 @@ assumes "\f. (\n. f n \ s) \ f ----> a \ eventually (\n. P (f n)) sequentially" shows "eventually P (inf (nhds a) (principal s))" proof (rule ccontr) - from countable_basis[of a] guess A . note A = this - assume "\ eventually P (inf (nhds a) (principal s))" + obtain A :: "nat \ 'a set" where A: + "\i. open (A i)" + "\i. a \ A i" + "\F. \n. F n \ A n \ F ----> a" + by (rule countable_basis) blast + assume "\ ?thesis" with A have P: "\F. \n. F n \ s \ F n \ A n \ \ P (F n)" unfolding eventually_inf_principal eventually_nhds by (intro choice) fastforce - then guess F .. - hence F0: "\n. F n \ s" and F2: "\n. F n \ A n" and F3: "\n. \ P (F n)" - by fast+ + then obtain F where F0: "\n. F n \ s" and F2: "\n. F n \ A n" and F3: "\n. \ P (F n)" + by blast with A have "F ----> a" by auto hence "eventually (\n. P (F n)) sequentially" using assms F0 by simp @@ -1668,7 +1678,8 @@ fix B :: "'b set" assume "continuous_on s f" "open B" then have "\x\f -` B \ s. (\A. open A \ x \ A \ s \ A \ f -` B)" by (auto simp: continuous_on_topological subset_eq Ball_def imp_conjL) - then guess A unfolding bchoice_iff .. + then obtain A where "\x\f -` B \ s. open (A x) \ x \ A x \ s \ A x \ f -` B" + unfolding bchoice_iff .. then show "\A. open A \ A \ s = f -` B \ s" by (intro exI[of _ "\x\f -` B \ s. A x"]) auto next @@ -1883,7 +1894,7 @@ moreover from cover have "s \ \(C \ {-t})" by auto ultimately have "\D\C \ {-t}. finite D \ s \ \D" using `compact s` unfolding compact_eq_heine_borel by auto - then guess D .. + then obtain D where "D \ C \ {- t} \ finite D \ s \ \D" .. then show "\D\C. finite D \ s \ t \ \D" by (intro exI[of _ "D - {-t}"]) auto qed @@ -1925,7 +1936,8 @@ fix C assume "\c\C. open c" and cover: "f`s \ \C" with f have "\c\C. \A. open A \ A \ s = f -` c \ s" unfolding continuous_on_open_invariant by blast - then guess A unfolding bchoice_iff .. note A = this + then obtain A where A: "\c\C. open (A c) \ A c \ s = f -` c \ s" + unfolding bchoice_iff .. with cover have "\c\C. open (A c)" "s \ (\c\C. A c)" by (fastforce simp add: subset_eq set_eq_iff)+ from compactE_image[OF s this] obtain D where "D \ C" "finite D" "s \ (\c\D. A c)" . @@ -2114,7 +2126,8 @@ instance linear_continuum_topology \ perfect_space proof fix x :: 'a - from ex_gt_or_lt [of x] guess y .. + obtain y where "x < y \ y < x" + using ex_gt_or_lt [of x] .. with Inf_notin_open[of "{x}" y] Sup_notin_open[of "{x}" y] show "\ open {x}" by auto @@ -2145,7 +2158,8 @@ moreover obtain b where "b \ B" "x < b" "b < min a y" using cInf_less_iff[of "B \ {x <..}" x "min a y"] `?z < a` `?z < y` `x < y` `y \ B` by (auto intro: less_imp_le) - moreover then have "?z \ b" + moreover have "?z \ b" + using `b \ B` `x < b` by (intro cInf_lower[where z=x]) auto moreover have "b \ U" using `x \ ?z` `?z \ b` `b < min a y` diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/ex/Dedekind_Real.thy --- a/src/HOL/ex/Dedekind_Real.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/ex/Dedekind_Real.thy Tue Sep 03 22:30:52 2013 +0200 @@ -8,7 +8,7 @@ *) theory Dedekind_Real -imports Rat Lubs +imports Complex_Main begin section {* Positive real numbers *} @@ -782,7 +782,7 @@ have "r + ?d < r*x" proof - have "r + ?d < r + (r * ?d)/y" by (simp add: dless) - also with ypos have "... = (r/y) * (y + ?d)" + also from ypos have "... = (r/y) * (y + ?d)" by (simp only: algebra_simps divide_inverse, simp) also have "... = r*x" using ypos by simp @@ -1785,10 +1785,10 @@ proof fix pa assume "pa \ ?pS" - then obtain a where "a \ S" and "a = real_of_preal pa" + then obtain a where a: "a \ S" "a = real_of_preal pa" by simp - moreover hence "a \ u" using sup by simp - ultimately show "pa \ pu" + then have "a \ u" using sup by simp + with a show "pa \ pu" using sup and u_is_pu by (simp add: real_of_preal_le_iff) qed @@ -1864,9 +1864,9 @@ fix s assume "s \ {z. \x\S. z = x + - X + 1}" hence "\ x \ S. s = x + -X + 1" .. - then obtain x1 where "x1 \ S" and "s = x1 + (-X) + 1" .. - moreover hence "x1 \ x" using S_le_x by simp - ultimately have "s \ x + - X + 1" by arith + then obtain x1 where x1: "x1 \ S" "s = x1 + (-X) + 1" .. + then have "x1 \ x" using S_le_x by simp + with x1 have "s \ x + - X + 1" by arith } then have "isUb (UNIV::real set) ?SHIFT (x + (-X) + 1)" by (auto simp add: isUb_def setle_def) diff -r 7a41ec2cc522 -r e93772b451ef src/HOL/ex/HarmonicSeries.thy --- a/src/HOL/ex/HarmonicSeries.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/HOL/ex/HarmonicSeries.thy Tue Sep 03 22:30:52 2013 +0200 @@ -65,7 +65,7 @@ proof - from xs have "x \ 2^(m - 1) + 1" by auto - moreover with mgt0 have + moreover from mgt0 have "2^(m - 1) + 1 \ (1::nat)" by auto ultimately have "x \ 1" by (rule xtrans) diff -r 7a41ec2cc522 -r e93772b451ef src/Pure/General/binding.ML --- a/src/Pure/General/binding.ML Tue Sep 03 22:12:48 2013 +0200 +++ b/src/Pure/General/binding.ML Tue Sep 03 22:30:52 2013 +0200 @@ -9,10 +9,11 @@ signature BINDING = sig - type binding + eqtype binding val dest: binding -> bool * (string * bool) list * bstring val make: bstring * Position.T -> binding val pos_of: binding -> Position.T + val set_pos: Position.T -> binding -> binding val name: bstring -> binding val name_of: binding -> bstring val map_name: (bstring -> bstring) -> binding -> binding @@ -41,13 +42,12 @@ (* datatype *) -abstype binding = Binding of +datatype binding = Binding of {conceal: bool, (*internal -- for foundational purposes only*) prefix: (string * bool) list, (*system prefix*) qualifier: (string * bool) list, (*user qualifier*) name: bstring, (*base name*) - pos: Position.T} (*source position*) -with + pos: Position.T}; (*source position*) fun make_binding (conceal, prefix, qualifier, name, pos) = Binding {conceal = conceal, prefix = prefix, qualifier = qualifier, name = name, pos = pos}; @@ -65,9 +65,12 @@ (* name and position *) fun make (name, pos) = make_binding (false, [], [], name, pos); -fun name name = make (name, Position.none); fun pos_of (Binding {pos, ...}) = pos; +fun set_pos pos = + map_binding (fn (conceal, prefix, qualifier, name, _) => (conceal, prefix, qualifier, name, pos)); + +fun name name = make (name, Position.none); fun name_of (Binding {name, ...}) = name; fun eq_name (b, b') = name_of b = name_of b'; @@ -140,7 +143,6 @@ else legacy_feature (bad binding); end; -end; type binding = Binding.binding; diff -r 7a41ec2cc522 -r e93772b451ef src/Pure/Isar/isar_syn.ML --- a/src/Pure/Isar/isar_syn.ML Tue Sep 03 22:12:48 2013 +0200 +++ b/src/Pure/Isar/isar_syn.ML Tue Sep 03 22:30:52 2013 +0200 @@ -608,14 +608,13 @@ (opt_mode -- Parse.and_list1 (Parse.const -- Parse.mixfix) >> (fn (mode, args) => Toplevel.print o Toplevel.proof (Proof.write_cmd mode args))); -val case_spec = - (@{keyword "("} |-- - Parse.!!! (Parse.xname -- Scan.repeat1 (Parse.maybe Parse.binding) --| @{keyword ")"}) || - Parse.xname >> rpair []) -- Parse_Spec.opt_attribs >> Parse.triple1; - val _ = Outer_Syntax.command @{command_spec "case"} "invoke local context" - (case_spec >> (Toplevel.print oo (Toplevel.proof o Proof.invoke_case_cmd))); + ((@{keyword "("} |-- + Parse.!!! (Parse.position Parse.xname -- Scan.repeat (Parse.maybe Parse.binding) + --| @{keyword ")"}) || + Parse.position Parse.xname >> rpair []) -- Parse_Spec.opt_attribs >> (fn ((c, xs), atts) => + Toplevel.print o Toplevel.proof (Proof.invoke_case_cmd (c, xs, atts)))); (* proof structure *) diff -r 7a41ec2cc522 -r e93772b451ef src/Pure/Isar/keyword.ML --- a/src/Pure/Isar/keyword.ML Tue Sep 03 22:12:48 2013 +0200 +++ b/src/Pure/Isar/keyword.ML Tue Sep 03 22:30:52 2013 +0200 @@ -36,6 +36,7 @@ val prf_decl: T val prf_asm: T val prf_asm_goal: T + val prf_asm_goal_script: T val prf_script: T val kinds: T list val tag: string -> T -> T @@ -115,13 +116,14 @@ val prf_decl = kind "prf_decl"; val prf_asm = kind "prf_asm"; val prf_asm_goal = kind "prf_asm_goal"; +val prf_asm_goal_script = kind "prf_asm_goal_script"; val prf_script = kind "prf_script"; val kinds = [control, diag, thy_begin, thy_end, thy_heading1, thy_heading2, thy_heading3, thy_heading4, thy_load, thy_decl, thy_script, thy_goal, qed, qed_block, qed_global, prf_heading2, prf_heading3, prf_heading4, prf_goal, prf_block, prf_open, - prf_close, prf_chain, prf_decl, prf_asm, prf_asm_goal, prf_script]; + prf_close, prf_chain, prf_decl, prf_asm, prf_asm_goal, prf_asm_goal_script, prf_script]; (* tags *) @@ -242,14 +244,14 @@ val is_proof = command_category [qed, qed_block, qed_global, prf_heading2, prf_heading3, prf_heading4, prf_goal, prf_block, prf_open, prf_close, prf_chain, prf_decl, - prf_asm, prf_asm_goal, prf_script]; + prf_asm, prf_asm_goal, prf_asm_goal_script, prf_script]; val is_proof_body = command_category - [diag, prf_heading2, prf_heading3, prf_heading4, prf_block, prf_open, - prf_close, prf_chain, prf_decl, prf_asm, prf_asm_goal, prf_script]; + [diag, prf_heading2, prf_heading3, prf_heading4, prf_block, prf_open, prf_close, prf_chain, + prf_decl, prf_asm, prf_asm_goal, prf_asm_goal_script, prf_script]; val is_theory_goal = command_category [thy_goal]; -val is_proof_goal = command_category [prf_goal, prf_asm_goal]; +val is_proof_goal = command_category [prf_goal, prf_asm_goal, prf_asm_goal_script]; val is_qed = command_category [qed, qed_block]; val is_qed_global = command_category [qed_global]; diff -r 7a41ec2cc522 -r e93772b451ef src/Pure/Isar/keyword.scala --- a/src/Pure/Isar/keyword.scala Tue Sep 03 22:12:48 2013 +0200 +++ b/src/Pure/Isar/keyword.scala Tue Sep 03 22:30:52 2013 +0200 @@ -38,6 +38,7 @@ val PRF_DECL = "prf_decl" val PRF_ASM = "prf_asm" val PRF_ASM_GOAL = "prf_asm_goal" + val PRF_ASM_GOAL_SCRIPT = "prf_asm_goal_script" val PRF_SCRIPT = "prf_script" @@ -52,11 +53,11 @@ val theory1 = Set(THY_BEGIN, THY_END) val theory2 = Set(THY_DECL, THY_GOAL) val proof = - Set(QED, QED_BLOCK, QED_GLOBAL, PRF_HEADING2, PRF_HEADING3, PRF_HEADING4, PRF_GOAL, - PRF_BLOCK, PRF_OPEN, PRF_CHAIN, PRF_DECL, PRF_ASM, PRF_ASM_GOAL, PRF_SCRIPT) + Set(QED, QED_BLOCK, QED_GLOBAL, PRF_HEADING2, PRF_HEADING3, PRF_HEADING4, PRF_GOAL, PRF_BLOCK, + PRF_OPEN, PRF_CHAIN, PRF_DECL, PRF_ASM, PRF_ASM_GOAL, PRF_ASM_GOAL_SCRIPT, PRF_SCRIPT) val proof1 = Set(QED, QED_BLOCK, QED_GLOBAL, PRF_GOAL, PRF_BLOCK, PRF_OPEN, PRF_CLOSE, PRF_CHAIN, PRF_DECL) - val proof2 = Set(PRF_ASM, PRF_ASM_GOAL) + val proof2 = Set(PRF_ASM, PRF_ASM_GOAL, PRF_ASM_GOAL_SCRIPT) val improper = Set(THY_SCRIPT, PRF_SCRIPT) } diff -r 7a41ec2cc522 -r e93772b451ef src/Pure/Isar/proof.ML --- a/src/Pure/Isar/proof.ML Tue Sep 03 22:12:48 2013 +0200 +++ b/src/Pure/Isar/proof.ML Tue Sep 03 22:30:52 2013 +0200 @@ -70,8 +70,10 @@ val using_cmd: ((Facts.ref * Attrib.src list) list) list -> state -> state val unfolding: ((thm list * attribute list) list) list -> state -> state val unfolding_cmd: ((Facts.ref * Attrib.src list) list) list -> state -> state - val invoke_case: string * binding option list * attribute list -> state -> state - val invoke_case_cmd: string * binding option list * Attrib.src list -> state -> state + val invoke_case: (string * Position.T) * binding option list * attribute list -> + state -> state + val invoke_case_cmd: (string * Position.T) * binding option list * Attrib.src list -> + state -> state val begin_block: state -> state val next_block: state -> state val end_block: state -> state @@ -399,8 +401,8 @@ Method.apply meth ctxt using goal |> Seq.map (fn (meth_cases, goal') => state |> map_goal - (Proof_Context.add_cases false (no_goal_cases goal @ goal_cases goal') #> - Proof_Context.add_cases true meth_cases) + (Proof_Context.update_cases false (no_goal_cases goal @ goal_cases goal') #> + Proof_Context.update_cases true meth_cases) (K (statement, [], using, goal', before_qed, after_qed)) I) end; @@ -741,20 +743,18 @@ local -fun qualified_binding a = - Binding.qualify true (Long_Name.qualifier a) (Binding.name (Long_Name.base_name a)); - -fun gen_invoke_case prep_att (name, xs, raw_atts) state = +fun gen_invoke_case prep_att ((name, pos), xs, raw_atts) state = let val atts = map (prep_att (context_of state)) raw_atts; val (asms, state') = state |> map_context_result (fn ctxt => - ctxt |> Proof_Context.apply_case (Proof_Context.get_case ctxt name xs)); - val assumptions = asms |> map (fn (a, ts) => ((qualified_binding a, atts), map (rpair []) ts)); + ctxt |> Proof_Context.apply_case (Proof_Context.check_case ctxt (name, pos) xs)); + val assumptions = + asms |> map (fn (b, ts) => ((Binding.set_pos pos b, atts), map (rpair []) ts)); in state' |> assume assumptions |> bind_terms Auto_Bind.no_facts - |> `the_facts |-> (fn thms => note_thmss [((Binding.name name, []), [(thms, [])])]) + |> `the_facts |-> (fn thms => note_thmss [((Binding.make (name, pos), []), [(thms, [])])]) end; in diff -r 7a41ec2cc522 -r e93772b451ef src/Pure/Isar/proof_context.ML --- a/src/Pure/Isar/proof_context.ML Tue Sep 03 22:12:48 2013 +0200 +++ b/src/Pure/Isar/proof_context.ML Tue Sep 03 22:30:52 2013 +0200 @@ -31,7 +31,6 @@ val set_syntax_mode: Syntax.mode -> Proof.context -> Proof.context val restore_syntax_mode: Proof.context -> Proof.context -> Proof.context val facts_of: Proof.context -> Facts.T - val cases_of: Proof.context -> (string * (Rule_Cases.T * bool)) list val map_naming: (Name_Space.naming -> Name_Space.naming) -> Proof.context -> Proof.context val naming_of: Proof.context -> Name_Space.naming val restore_naming: Proof.context -> Proof.context -> Proof.context @@ -132,9 +131,10 @@ val add_assms_i: Assumption.export -> (Thm.binding * (term * term list) list) list -> Proof.context -> (string * thm list) list * Proof.context - val add_cases: bool -> (string * Rule_Cases.T option) list -> Proof.context -> Proof.context - val apply_case: Rule_Cases.T -> Proof.context -> (string * term list) list * Proof.context - val get_case: Proof.context -> string -> binding option list -> Rule_Cases.T + val dest_cases: Proof.context -> (string * (Rule_Cases.T * bool)) list + val update_cases: bool -> (string * Rule_Cases.T option) list -> Proof.context -> Proof.context + val apply_case: Rule_Cases.T -> Proof.context -> (binding * term list) list * Proof.context + val check_case: Proof.context -> string * Position.T -> binding option list -> Rule_Cases.T val type_notation: bool -> Syntax.mode -> (typ * mixfix) list -> Proof.context -> Proof.context val notation: bool -> Syntax.mode -> (term * mixfix) list -> Proof.context -> Proof.context val generic_type_notation: bool -> Syntax.mode -> (typ * mixfix) list -> morphism -> @@ -192,6 +192,9 @@ (** Isar proof context information **) +type cases = ((Rule_Cases.T * bool) * int) Name_Space.table; +val empty_cases: cases = Name_Space.empty_table Markup.caseN; + datatype data = Data of {mode: mode, (*inner syntax mode*) @@ -199,7 +202,7 @@ tsig: Type.tsig * Type.tsig, (*local/global type signature -- local name space / defsort only*) consts: Consts.T * Consts.T, (*local/global consts -- local name space / abbrevs only*) facts: Facts.T, (*local facts*) - cases: (string * (Rule_Cases.T * bool)) list}; (*named case contexts*) + cases: cases}; (*named case contexts: case, is_proper, running index*) fun make_data (mode, syntax, tsig, consts, facts, cases) = Data {mode = mode, syntax = syntax, tsig = tsig, consts = consts, facts = facts, cases = cases}; @@ -210,7 +213,7 @@ fun init thy = make_data (mode_default, Local_Syntax.init thy, (Sign.tsig_of thy, Sign.tsig_of thy), - (Sign.consts_of thy, Sign.consts_of thy), Facts.empty, []); + (Sign.consts_of thy, Sign.consts_of thy), Facts.empty, empty_cases); ); fun rep_data ctxt = Data.get ctxt |> (fn Data rep => rep); @@ -1132,28 +1135,23 @@ (** cases **) +fun dest_cases ctxt = + Symtab.fold (fn (a, (c, i)) => cons (i, (a, c))) (#2 (cases_of ctxt)) [] + |> sort (int_ord o pairself #1) |> map #2; + local -fun rem_case name = remove (fn (x: string, (y, _)) => x = y) name; - -fun add_case _ ("", _) cases = cases - | add_case _ (name, NONE) cases = rem_case name cases - | add_case is_proper (name, SOME c) cases = (name, (c, is_proper)) :: rem_case name cases; - -fun prep_case name fxs c = - let - fun replace (opt_x :: xs) ((y, T) :: ys) = (the_default y opt_x, T) :: replace xs ys - | replace [] ys = ys - | replace (_ :: _) [] = error ("Too many parameters for case " ^ quote name); - val Rule_Cases.Case {fixes, assumes, binds, cases} = c; - val fixes' = replace fxs fixes; - val binds' = map drop_schematic binds; - in - if null (fold (Term.add_tvarsT o snd) fixes []) andalso - null (fold (fold Term.add_vars o snd) assumes []) then - Rule_Cases.Case {fixes = fixes', assumes = assumes, binds = binds', cases = cases} - else error ("Illegal schematic variable(s) in case " ^ quote name) - end; +fun update_case _ _ ("", _) res = res + | update_case _ _ (name, NONE) ((space, tab), index) = + let + val tab' = Symtab.delete_safe name tab; + in ((space, tab'), index) end + | update_case context is_proper (name, SOME c) (cases, index) = + let + val (_, cases') = cases |> Name_Space.define context false + (Binding.make (name, Position.none), ((c, is_proper), index)); + val index' = index + 1; + in (cases', index') end; fun fix (b, T) ctxt = let val ([x], ctxt') = add_fixes [(b, SOME T, NoSyn)] ctxt @@ -1161,7 +1159,13 @@ in -fun add_cases is_proper = map_cases o fold (add_case is_proper); +fun update_cases is_proper args ctxt = + let + val context = Context.Proof ctxt |> Name_Space.map_naming (K Name_Space.default_naming); + val cases = cases_of ctxt; + val index = Symtab.fold (fn _ => Integer.add 1) (#2 cases) 0; + val (cases', _) = fold (update_case context is_proper) args (cases, index); + in map_cases (K cases') ctxt end; fun case_result c ctxt = let @@ -1171,16 +1175,29 @@ in ctxt' |> bind_terms (map drop_schematic binds) - |> add_cases true (map (apsnd SOME) cases) + |> update_cases true (map (apsnd SOME) cases) |> pair (assumes, (binds, cases)) end; val apply_case = apfst fst oo case_result; -fun get_case ctxt name xs = - (case AList.lookup (op =) (cases_of ctxt) name of - NONE => error ("Unknown case: " ^ quote name) - | SOME (c, _) => prep_case name xs c); +fun check_case ctxt (name, pos) fxs = + let + val (_, ((Rule_Cases.Case {fixes, assumes, binds, cases}, _), _)) = + Name_Space.check (Context.Proof ctxt) (cases_of ctxt) (name, pos); + + fun replace (opt_x :: xs) ((y, T) :: ys) = (the_default y opt_x, T) :: replace xs ys + | replace [] ys = ys + | replace (_ :: _) [] = + error ("Too many parameters for case " ^ quote name ^ Position.here pos); + val fixes' = replace fxs fixes; + val binds' = map drop_schematic binds; + in + if null (fold (Term.add_tvarsT o snd) fixes []) andalso + null (fold (fold Term.add_vars o snd) assumes []) then + Rule_Cases.Case {fixes = fixes', assumes = assumes, binds = binds', cases = cases} + else error ("Illegal schematic variable(s) in case " ^ quote name ^ Position.here pos) + end; end; @@ -1256,8 +1273,9 @@ [Pretty.quote (prt_term (Var (xi, Term.fastype_of t))), Pretty.str " =", Pretty.brk 1, Pretty.quote (prt_term t)]; - fun prt_asm (a, ts) = Pretty.block (Pretty.breaks - ((if a = "" then [] else [Pretty.str (a ^ ":")]) @ map (Pretty.quote o prt_term) ts)); + fun prt_asm (b, ts) = Pretty.block (Pretty.breaks + ((if Binding.is_empty b then [] + else [Binding.pretty b, Pretty.str ":"]) @ map (Pretty.quote o prt_term) ts)); fun prt_sect _ _ _ [] = [] | prt_sect s sep prt xs = @@ -1278,10 +1296,10 @@ fun pretty_cases ctxt = let - fun add_case (_, (_, false)) = I - | add_case (name, (c as Rule_Cases.Case {fixes, ...}, true)) = - cons (name, (fixes, case_result c ctxt)); - val cases = fold add_case (cases_of ctxt) []; + fun mk_case (_, (_, false)) = NONE + | mk_case (name, (c as Rule_Cases.Case {fixes, ...}, true)) = + SOME (name, (fixes, case_result c ctxt)); + val cases = dest_cases ctxt |> map_filter mk_case; in if null cases then [] else [Pretty.big_list "cases:" (map pretty_case cases)] diff -r 7a41ec2cc522 -r e93772b451ef src/Pure/Isar/rule_cases.ML --- a/src/Pure/Isar/rule_cases.ML Tue Sep 03 22:12:48 2013 +0200 +++ b/src/Pure/Isar/rule_cases.ML Tue Sep 03 22:30:52 2013 +0200 @@ -21,7 +21,7 @@ include BASIC_RULE_CASES datatype T = Case of {fixes: (binding * typ) list, - assumes: (string * term list) list, + assumes: (binding * term list) list, binds: (indexname * term option) list, cases: (string * T) list} val case_hypsN: string @@ -62,7 +62,7 @@ datatype T = Case of {fixes: (binding * typ) list, - assumes: (string * term list) list, + assumes: (binding * term list) list, binds: (indexname * term option) list, cases: (string * T) list}; @@ -91,21 +91,22 @@ | extract_fixes (SOME outline) prop = chop (length (Logic.strip_params outline)) (strip_params prop); -fun extract_assumes _ _ NONE prop = ([("", Logic.strip_assums_hyp prop)], []) - | extract_assumes qual hnames (SOME outline) prop = +fun extract_assumes _ _ NONE prop = ([(Binding.empty, Logic.strip_assums_hyp prop)], []) + | extract_assumes qualifier hyp_names (SOME outline) prop = let + val qual = Binding.qualify true qualifier o Binding.name; val (hyps, prems) = chop (length (Logic.strip_assums_hyp outline)) (Logic.strip_assums_hyp prop) - fun extract ((hname,h)::ps) = (qual hname, h :: map snd ps); - val (hyps1,hyps2) = chop (length hnames) hyps; - val pairs1 = if hyps1 = [] then [] else hnames ~~ hyps1; - val pairs = pairs1 @ (map (pair case_hypsN) hyps2); - val named_hyps = map extract (partition_eq (eq_fst op =) pairs) + fun extract ((hyp_name, hyp) :: rest) = (qual hyp_name, hyp :: map snd rest); + val (hyps1, hyps2) = chop (length hyp_names) hyps; + val pairs1 = if null hyps1 then [] else hyp_names ~~ hyps1; + val pairs = pairs1 @ map (pair case_hypsN) hyps2; + val named_hyps = map extract (partition_eq (eq_fst op =) pairs); in (named_hyps, [(qual case_premsN, prems)]) end; fun bindings args = map (apfst Binding.name) args; -fun extract_case thy (case_outline, raw_prop) name hnames concls = +fun extract_case thy (case_outline, raw_prop) name hyp_names concls = let val props = Logic.dest_conjunctions (Drule.norm_hhf thy raw_prop); val len = length props; @@ -120,7 +121,8 @@ else fold_rev Term.abs fixes1 (app (map (Term.dummy_pattern o #2) fixes2) (fold_rev Term.abs fixes2 t)); - val (assumes1, assumes2) = extract_assumes (Long_Name.qualify name) hnames case_outline prop + val (assumes1, assumes2) = + extract_assumes name hyp_names case_outline prop |> pairself (map (apsnd (maps Logic.dest_conjunctions))); val concl = Object_Logic.drop_judgment thy (Logic.strip_assums_concl prop); @@ -153,11 +155,11 @@ let val n = length cases; val nprems = Logic.count_prems prop; - fun add_case ((name, hnames), concls) (cs, i) = + fun add_case ((name, hyp_names), concls) (cs, i) = ((case try (fn () => (Option.map (curry Logic.nth_prem i) rule_struct, Logic.nth_prem (i, prop))) () of NONE => (name, NONE) - | SOME p => (name, extract_case thy p name hnames concls)) :: cs, i - 1); + | SOME p => (name, extract_case thy p name hyp_names concls)) :: cs, i - 1); in fold_rev add_case (drop (Int.max (n - nprems, 0)) cases) ([], n) |> #1 end; in diff -r 7a41ec2cc522 -r e93772b451ef src/Pure/PIDE/command.ML --- a/src/Pure/PIDE/command.ML Tue Sep 03 22:12:48 2013 +0200 +++ b/src/Pure/PIDE/command.ML Tue Sep 03 22:30:52 2013 +0200 @@ -57,7 +57,7 @@ (case expr of Expr (exec_id, body) => uninterruptible (fn restore_attributes => fn () => - if Execution.running execution_id exec_id then + if Execution.running execution_id exec_id [Future.the_worker_group ()] then let val res = (body diff -r 7a41ec2cc522 -r e93772b451ef src/Pure/PIDE/execution.ML --- a/src/Pure/PIDE/execution.ML Tue Sep 03 22:12:48 2013 +0200 +++ b/src/Pure/PIDE/execution.ML Tue Sep 03 22:30:52 2013 +0200 @@ -11,7 +11,7 @@ val discontinue: unit -> unit val is_running: Document_ID.execution -> bool val is_running_exec: Document_ID.exec -> bool - val running: Document_ID.execution -> Document_ID.exec -> bool + val running: Document_ID.execution -> Document_ID.exec -> Future.group list -> bool val peek: Document_ID.exec -> Future.group list val cancel: Document_ID.exec -> unit val terminate: Document_ID.exec -> unit @@ -33,7 +33,7 @@ fun make_state (execution, execs) = State {execution = execution, execs = execs}; fun map_state f (State {execution, execs}) = make_state (f (execution, execs)); -val init_state = make_state (Document_ID.none, Inttab.empty); +val init_state = make_state (Document_ID.none, Inttab.make [(Document_ID.none, [])]); val state = Synchronized.var "Execution.state" init_state; fun get_state () = let val State args = Synchronized.value state in args end; @@ -58,18 +58,18 @@ fun is_running_exec exec_id = Inttab.defined (#execs (get_state ())) exec_id; -fun running execution_id exec_id = - Synchronized.guarded_access state +fun running execution_id exec_id groups = + Synchronized.change_result state (fn State {execution = execution_id', execs} => let val continue = execution_id = execution_id'; val execs' = if continue then - Inttab.update_new (exec_id, [Future.the_worker_group ()]) execs + Inttab.update_new (exec_id, groups) execs handle Inttab.DUP dup => - error ("Execution already registered: " ^ Document_ID.print dup) + raise Fail ("Execution already registered: " ^ Document_ID.print dup) else execs; - in SOME (continue, make_state (execution_id', execs')) end); + in (continue, make_state (execution_id', execs')) end); fun peek exec_id = Inttab.lookup_list (#execs (get_state ())) exec_id; @@ -89,7 +89,10 @@ let val exec_id = the_default 0 (Position.parse_id pos); val group = Future.worker_subgroup (); - val _ = change_state (apsnd (Inttab.cons_list (exec_id, group))); + val _ = change_state (apsnd (fn execs => + if Inttab.defined execs exec_id + then Inttab.cons_list (exec_id, group) execs + else raise Fail ("Cannot fork from unregistered execution: " ^ Document_ID.print exec_id))); val future = (singleton o Future.forks) @@ -127,7 +130,7 @@ if Inttab.defined execs' exec_id then () else groups |> List.app (fn group => if Task_Queue.is_canceled group then () - else error ("Attempt to purge valid execution: " ^ Document_ID.print exec_id))); + else raise Fail ("Attempt to purge valid execution: " ^ Document_ID.print exec_id))); in execs' end); fun reset () = diff -r 7a41ec2cc522 -r e93772b451ef src/Pure/PIDE/markup.ML --- a/src/Pure/PIDE/markup.ML Tue Sep 03 22:12:48 2013 +0200 +++ b/src/Pure/PIDE/markup.ML Tue Sep 03 22:30:52 2013 +0200 @@ -46,6 +46,7 @@ val type_nameN: string val constantN: string val fixedN: string val fixed: string -> T + val caseN: string val case_: string -> T val dynamic_factN: string val dynamic_fact: string -> T val tfreeN: string val tfree: T val tvarN: string val tvar: T @@ -288,6 +289,7 @@ val constantN = "constant"; val (fixedN, fixed) = markup_string "fixed" nameN; +val (caseN, case_) = markup_string "case" nameN; val (dynamic_factN, dynamic_fact) = markup_string "dynamic_fact" nameN; diff -r 7a41ec2cc522 -r e93772b451ef src/Pure/PIDE/markup.scala --- a/src/Pure/PIDE/markup.scala Tue Sep 03 22:12:48 2013 +0200 +++ b/src/Pure/PIDE/markup.scala Tue Sep 03 22:30:52 2013 +0200 @@ -105,8 +105,8 @@ val CLASS = "class" val TYPE_NAME = "type_name" val FIXED = "fixed" + val CASE = "case" val CONSTANT = "constant" - val DYNAMIC_FACT = "dynamic_fact" diff -r 7a41ec2cc522 -r e93772b451ef src/Pure/Pure.thy --- a/src/Pure/Pure.thy Tue Sep 03 22:12:48 2013 +0200 +++ b/src/Pure/Pure.thy Tue Sep 03 22:30:52 2013 +0200 @@ -60,7 +60,8 @@ and "then" "from" "with" :: prf_chain % "proof" and "note" "using" "unfolding" :: prf_decl % "proof" and "fix" "assume" "presume" "def" :: prf_asm % "proof" - and "obtain" "guess" :: prf_asm_goal % "proof" + and "obtain" :: prf_asm_goal % "proof" + and "guess" :: prf_asm_goal_script % "proof" and "let" "write" :: prf_decl % "proof" and "case" :: prf_asm % "proof" and "{" :: prf_open % "proof" diff -r 7a41ec2cc522 -r e93772b451ef src/Pure/Thy/thy_info.ML --- a/src/Pure/Thy/thy_info.ML Tue Sep 03 22:12:48 2013 +0200 +++ b/src/Pure/Thy/thy_info.ML Tue Sep 03 22:30:52 2013 +0200 @@ -165,18 +165,20 @@ (* scheduling loader tasks *) datatype result = - Result of {theory: theory, id: serial, present: unit -> unit, commit: unit -> unit, weight: int}; + Result of {theory: theory, exec_id: Document_ID.exec, + present: unit -> unit, commit: unit -> unit, weight: int}; -fun theory_result theory = Result {theory = theory, id = 0, present = I, commit = I, weight = 0}; +fun theory_result theory = + Result {theory = theory, exec_id = Document_ID.none, present = I, commit = I, weight = 0}; fun result_theory (Result {theory, ...}) = theory; fun result_present (Result {present, ...}) = present; fun result_commit (Result {commit, ...}) = commit; fun result_ord (Result {weight = i, ...}, Result {weight = j, ...}) = int_ord (j, i); -fun join_theory (Result {theory, id, ...}) = +fun join_theory (Result {theory, exec_id, ...}) = Exn.capture Thm.join_theory_proofs theory :: - map Exn.Exn (maps Task_Queue.group_status (Execution.peek id)); + map Exn.Exn (maps Task_Queue.group_status (Execution.peek exec_id)); datatype task = @@ -271,13 +273,19 @@ val _ = Position.reports (map #2 imports ~~ map Theory.get_markup parents); - val id = serial (); - val text_pos = Position.put_id (Markup.print_int id) (Path.position thy_path); + val exec_id = Document_ID.make (); + val _ = + Execution.running Document_ID.none exec_id [] orelse + raise Fail ("Failed to register execution: " ^ Document_ID.print exec_id); + + val text_pos = Position.put_id (Document_ID.print exec_id) (Path.position thy_path); val (theory, present, weight) = Thy_Load.load_thy last_timing update_time dir header text_pos text (if name = Context.PureN then [ML_Context.the_global_context ()] else parents); fun commit () = update_thy deps theory; - in Result {theory = theory, id = id, present = present, commit = commit, weight = weight} end; + in + Result {theory = theory, exec_id = exec_id, present = present, commit = commit, weight = weight} + end; fun check_deps dir name = (case lookup_deps name of diff -r 7a41ec2cc522 -r e93772b451ef src/Pure/Tools/keywords.scala --- a/src/Pure/Tools/keywords.scala Tue Sep 03 22:12:48 2013 +0200 +++ b/src/Pure/Tools/keywords.scala Tue Sep 03 22:30:52 2013 +0200 @@ -38,6 +38,7 @@ "prf_decl" -> "proof-decl", "prf_asm" -> "proof-asm", "prf_asm_goal" -> "proof-asm-goal", + "prf_asm_goal_script" -> "proof-asm-goal", "prf_script" -> "proof-script" ).withDefault((s: String) => s) diff -r 7a41ec2cc522 -r e93772b451ef src/Tools/jEdit/src/rendering.scala --- a/src/Tools/jEdit/src/rendering.scala Tue Sep 03 22:12:48 2013 +0200 +++ b/src/Tools/jEdit/src/rendering.scala Tue Sep 03 22:30:52 2013 +0200 @@ -77,7 +77,8 @@ Keyword.THY_SCRIPT -> LABEL, Keyword.PRF_SCRIPT -> DIGIT, Keyword.PRF_ASM -> KEYWORD3, - Keyword.PRF_ASM_GOAL -> KEYWORD3 + Keyword.PRF_ASM_GOAL -> KEYWORD3, + Keyword.PRF_ASM_GOAL_SCRIPT -> DIGIT ).withDefaultValue(KEYWORD1) }