merged
authorwenzelm
Fri, 12 Feb 2016 22:36:48 +0100
changeset 62284 1fd4831e9f93
parent 62224 9343649abb09 (diff)
parent 62283 f005a691df1f (current diff)
child 62285 747fc3692fca
merged
CONTRIBUTORS
NEWS
--- a/CONTRIBUTORS	Fri Feb 12 17:04:36 2016 +0100
+++ b/CONTRIBUTORS	Fri Feb 12 22:36:48 2016 +0100
@@ -3,6 +3,10 @@
 listed as an author in one of the source files of this Isabelle distribution.
 
 
+Contributions to this Isabelle version
+--------------------------------------
+
+
 Contributions to Isabelle2016
 -----------------------------
 
--- a/NEWS	Fri Feb 12 17:04:36 2016 +0100
+++ b/NEWS	Fri Feb 12 22:36:48 2016 +0100
@@ -4,6 +4,11 @@
 (Note: Isabelle/jEdit shows a tree-view of the NEWS file in Sidekick.)
 
 
+New in this Isabelle version
+----------------------------
+
+
+
 New in Isabelle2016 (February 2016)
 -----------------------------------
 
--- a/src/Doc/Prog_Prove/Basics.thy	Fri Feb 12 17:04:36 2016 +0100
+++ b/src/Doc/Prog_Prove/Basics.thy	Fri Feb 12 22:36:48 2016 +0100
@@ -140,13 +140,15 @@
 message, it refers to the HOL syntax as the \concept{inner syntax} and the
 enclosing theory language as the \concept{outer syntax}.
 
+\ifsem\else
 \subsection{Proof State}
 
 \begin{warn}
-By default Isabelle/jEdit does not show the proof state
-in the output window. You should enable this by ticking the
-``Proof state'' box.
+By default Isabelle/jEdit does not show the proof state but this tutorial
+refers to it frequently. You should tick the ``Proof state'' box
+to see the proof state in the output window.
 \end{warn}
+\fi
 *}
 (*<*)
 end
--- a/src/Doc/Prog_Prove/Bool_nat_list.thy	Fri Feb 12 17:04:36 2016 +0100
+++ b/src/Doc/Prog_Prove/Bool_nat_list.thy	Fri Feb 12 22:36:48 2016 +0100
@@ -58,7 +58,8 @@
 need to be established by induction in most cases.
 Command \isacom{apply}@{text"(induction m)"} instructs Isabelle to
 start a proof by induction on @{text m}. In response, it will show the
-following proof state:
+following proof state\ifsem\footnote{See page \pageref{proof-state} for how to
+display the proof state.}\fi:
 @{subgoals[display,indent=0]}
 The numbered lines are known as \emph{subgoals}.
 The first subgoal is the base case, the second one the induction step.
--- a/src/Doc/Prog_Prove/Logic.thy	Fri Feb 12 17:04:36 2016 +0100
+++ b/src/Doc/Prog_Prove/Logic.thy	Fri Feb 12 22:36:48 2016 +0100
@@ -134,7 +134,7 @@
 \begin{tabular}{l@ {\quad}l}
 @{const_typ set}\index{set@@{const set}} & converts a list to the set of its elements\\
 @{const_typ finite}\index{finite@@{const finite}} & is true iff its argument is finite\\
-@{const_typ card}\index{card@@{const card}} & is the cardinality of a finite set\\
+\noquotes{@{term[source] "card :: 'a set \<Rightarrow> nat"}}\index{card@@{const card}} & is the cardinality of a finite set\\
  & and is @{text 0} for all infinite sets\\
 @{thm image_def}\index{$IMP042@@{term"f ` A"}} & is the image of a function over a set
 \end{tabular}
--- a/src/Doc/Prog_Prove/document/intro-isabelle.tex	Fri Feb 12 17:04:36 2016 +0100
+++ b/src/Doc/Prog_Prove/document/intro-isabelle.tex	Fri Feb 12 22:36:48 2016 +0100
@@ -55,10 +55,11 @@
 \subsection*{Getting Started with Isabelle}
 
 If you have not done so already, download and install Isabelle
+(this book is compatible with Isabelle2016)
 from \url{http://isabelle.in.tum.de}. You can start it by clicking
 on the application icon. This will launch Isabelle's
-user interface based on the text editor \concept{jedit}. Below you see
-a typical example snapshot of a jedit session. At this point we merely explain
+user interface based on the text editor \concept{jEdit}. Below you see
+a typical example snapshot of a session. At this point we merely explain
 the layout of the window, not its contents.
 
 \begin{center}
@@ -71,7 +72,14 @@
 lower part of the window. You can examine the response to any input phrase
 by clicking on that phrase or by hovering over underlined text.
 
-This should suffice to get started with the jedit interface.
+\begin{warn}\label{proof-state}
+Part I frequently refers to the proof state.
+You can see the proof state combined with other system output if you
+press the ``Output'' button to open the output area and tick the 
+``Proof state'' box to see the proof state in the output area.
+\end{warn}
+
+This should suffice to get started with the jEdit interface.
 Now you need to learn what to type into it.
 \else
 If you want to apply what you have learned about Isabelle we recommend you
--- a/src/HOL/IMP/Denotational.thy	Fri Feb 12 17:04:36 2016 +0100
+++ b/src/HOL/IMP/Denotational.thy	Fri Feb 12 22:36:48 2016 +0100
@@ -105,7 +105,7 @@
       by(simp add: cont_def)
     also have "\<dots> = (f^^0){} \<union> \<dots>" by simp
     also have "\<dots> = ?U"
-      by(auto simp del: funpow.simps) (metis not0_implies_Suc)
+      using assms funpow_decreasing le_SucI mono_if_cont by blast
     finally show "f ?U \<subseteq> ?U" by simp
   qed
 next
--- a/src/HOL/Library/Product_Vector.thy	Fri Feb 12 17:04:36 2016 +0100
+++ b/src/HOL/Library/Product_Vector.thy	Fri Feb 12 22:36:48 2016 +0100
@@ -218,6 +218,20 @@
 lemma continuous_on_swap[continuous_intros]: "continuous_on A prod.swap"
   by (simp add: prod.swap_def continuous_on_fst continuous_on_snd continuous_on_Pair continuous_on_id)
 
+lemma continuous_on_swap_args:
+  assumes "continuous_on (A\<times>B) (\<lambda>(x,y). d x y)" 
+    shows "continuous_on (B\<times>A) (\<lambda>(x,y). d y x)"
+proof -
+  have "(\<lambda>(x,y). d y x) = (\<lambda>(x,y). d x y) o prod.swap"
+    by force
+  then show ?thesis
+    apply (rule ssubst)
+    apply (rule continuous_on_compose)
+     apply (force intro: continuous_on_subset [OF continuous_on_swap])
+    apply (force intro: continuous_on_subset [OF assms])
+    done
+qed
+
 lemma isCont_fst [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. fst (f x)) a"
   by (fact continuous_fst)
 
--- a/src/HOL/Multivariate_Analysis/Cauchy_Integral_Thm.thy	Fri Feb 12 17:04:36 2016 +0100
+++ b/src/HOL/Multivariate_Analysis/Cauchy_Integral_Thm.thy	Fri Feb 12 22:36:48 2016 +0100
@@ -5722,8 +5722,8 @@
 
 lemma higher_deriv_ident [simp]:
      "(deriv ^^ n) (\<lambda>w. w) z = (if n = 0 then z else if n = 1 then 1 else 0)"
-  apply (induction n)
-  apply (simp_all add: deriv_ident funpow_Suc_right del: funpow.simps, simp)
+  apply (induction n, simp)
+  apply (metis higher_deriv_linear lambda_one)
   done
 
 corollary higher_deriv_id [simp]:
@@ -6893,6 +6893,60 @@
 
 text\<open>Proof is based on Dixon's, as presented in Lang's "Complex Analysis" book (page 147).\<close>
 
+lemma contour_integral_continuous_on_linepath_2D:
+  assumes "open u" and cont_dw: "\<And>w. w \<in> u \<Longrightarrow> F w contour_integrable_on (linepath a b)"
+      and cond_uu: "continuous_on (u \<times> u) (\<lambda>(x,y). F x y)"
+      and abu: "closed_segment a b \<subseteq> u"
+    shows "continuous_on u (\<lambda>w. contour_integral (linepath a b) (F w))"
+proof -
+  have *: "\<exists>d>0. \<forall>x'\<in>u. dist x' w < d \<longrightarrow>
+                         dist (contour_integral (linepath a b) (F x'))
+                              (contour_integral (linepath a b) (F w)) \<le> \<epsilon>"
+          if "w \<in> u" "0 < \<epsilon>" "a \<noteq> b" for w \<epsilon>
+  proof -
+    obtain \<delta> where "\<delta>>0" and \<delta>: "cball w \<delta> \<subseteq> u" using open_contains_cball \<open>open u\<close> \<open>w \<in> u\<close> by force
+    let ?TZ = "{(t,z) |t z. t \<in> cball w \<delta> \<and> z \<in> closed_segment a b}"
+    have "uniformly_continuous_on ?TZ (\<lambda>(x,y). F x y)"
+      apply (rule compact_uniformly_continuous)
+      apply (rule continuous_on_subset[OF cond_uu])
+      using abu \<delta>
+      apply (auto simp: compact_Times simp del: mem_cball)
+      done
+    then obtain \<eta> where "\<eta>>0"
+        and \<eta>: "\<And>x x'. \<lbrakk>x\<in>?TZ; x'\<in>?TZ; dist x' x < \<eta>\<rbrakk> \<Longrightarrow>
+                         dist ((\<lambda>(x,y). F x y) x') ((\<lambda>(x,y). F x y) x) < \<epsilon>/norm(b - a)"
+      apply (rule uniformly_continuous_onE [where e = "\<epsilon>/norm(b - a)"])
+      using \<open>0 < \<epsilon>\<close> \<open>a \<noteq> b\<close> by auto
+    have \<eta>: "\<lbrakk>norm (w - x1) \<le> \<delta>;   x2 \<in> closed_segment a b; 
+              norm (w - x1') \<le> \<delta>;  x2' \<in> closed_segment a b; norm ((x1', x2') - (x1, x2)) < \<eta>\<rbrakk>
+              \<Longrightarrow> norm (F x1' x2' - F x1 x2) \<le> \<epsilon> / cmod (b - a)"
+             for x1 x2 x1' x2'
+      using \<eta> [of "(x1,x2)" "(x1',x2')"] by (force simp add: dist_norm)
+    have le_ee: "cmod (contour_integral (linepath a b) (\<lambda>x. F x' x - F w x)) \<le> \<epsilon>"
+                if "x' \<in> u" "cmod (x' - w) < \<delta>" "cmod (x' - w) < \<eta>"  for x'
+    proof -
+      have "cmod (contour_integral (linepath a b) (\<lambda>x. F x' x - F w x)) \<le> \<epsilon>/norm(b - a) * norm(b - a)"
+        apply (rule has_contour_integral_bound_linepath [OF has_contour_integral_integral _ \<eta>])
+        apply (rule contour_integrable_diff [OF cont_dw cont_dw])
+        using \<open>0 < \<epsilon>\<close> \<open>a \<noteq> b\<close> \<open>0 < \<delta>\<close> \<open>w \<in> u\<close> that
+        apply (auto simp: norm_minus_commute)
+        done
+      also have "... = \<epsilon>" using \<open>a \<noteq> b\<close> by simp
+      finally show ?thesis .
+    qed
+    show ?thesis
+      apply (rule_tac x="min \<delta> \<eta>" in exI)
+      using \<open>0 < \<delta>\<close> \<open>0 < \<eta>\<close>
+      apply (auto simp: dist_norm contour_integral_diff [OF cont_dw cont_dw, symmetric] \<open>w \<in> u\<close> intro: le_ee)
+      done
+  qed
+  show ?thesis 
+    apply (rule continuous_onI)
+    apply (cases "a=b")
+    apply (auto intro: *)
+    done
+qed  
+
 text\<open>This version has @{term"polynomial_function \<gamma>"} as an additional assumption.\<close>
 lemma Cauchy_integral_formula_global_weak:
     assumes u: "open u" and holf: "f holomorphic_on u"
@@ -7065,10 +7119,10 @@
     by (meson Lim_at_infinityI)
   moreover have "h holomorphic_on UNIV"
   proof -
-    have con_ff: "continuous (at (x,z)) (\<lambda>y. (f(snd y) - f(fst y)) / (snd y - fst y))"
+    have con_ff: "continuous (at (x,z)) (\<lambda>(x,y). (f y - f x) / (y - x))"
                  if "x \<in> u" "z \<in> u" "x \<noteq> z" for x z
       using that conf
-      apply (simp add: continuous_on_eq_continuous_at u)
+      apply (simp add: split_def continuous_on_eq_continuous_at u)
       apply (simp | rule continuous_intros continuous_within_compose2 [where g=f])+
       done
     have con_fstsnd: "continuous_on UNIV (\<lambda>x. (fst x - snd x) ::complex)"
@@ -7083,8 +7137,8 @@
       apply (rule continuous_on_interior [of u])
       apply (simp add: holf holomorphic_deriv holomorphic_on_imp_continuous_on u)
       by (simp add: interior_open that u)
-    have tendsto_f': "((\<lambda>x. if snd x = fst x then deriv f (fst x)
-                                    else (f (snd x) - f (fst x)) / (snd x - fst x)) \<longlongrightarrow> deriv f x)
+    have tendsto_f': "((\<lambda>(x,y). if y = x then deriv f (x)
+                                else (f (y) - f (x)) / (y - x)) \<longlongrightarrow> deriv f x)
                       (at (x, x) within u \<times> u)" if "x \<in> u" for x
     proof (rule Lim_withinI)
       fix e::real assume "0 < e"
@@ -7120,8 +7174,7 @@
       qed
       show "\<exists>d>0. \<forall>xa\<in>u \<times> u.
                   0 < dist xa (x, x) \<and> dist xa (x, x) < d \<longrightarrow>
-                  dist (if snd xa = fst xa then deriv f (fst xa) else (f (snd xa) - f (fst xa)) / (snd xa - fst xa))
-                       (deriv f x)  \<le>  e"
+                  dist (case xa of (x, y) \<Rightarrow> if y = x then deriv f x else (f y - f x) / (y - x)) (deriv f x) \<le> e"
         apply (rule_tac x="min k1 k2" in exI)
         using \<open>k1>0\<close> \<open>k2>0\<close> \<open>e>0\<close>
         apply (force simp: dist_norm neq intro: dual_order.strict_trans2 k1 less_imp_le norm_fst_le)
@@ -7134,16 +7187,16 @@
       using \<gamma>' using path_image_def vector_derivative_at by fastforce
     have f_has_cint: "\<And>w. w \<in> v - path_image \<gamma> \<Longrightarrow> ((\<lambda>u. f u / (u - w) ^ 1) has_contour_integral h w) \<gamma>"
       by (simp add: V)
-    have cond_uu: "continuous_on (u \<times> u) (\<lambda>y. d (fst y) (snd y))"
+    have cond_uu: "continuous_on (u \<times> u) (\<lambda>(x,y). d x y)"
       apply (simp add: continuous_on_eq_continuous_within d_def continuous_within tendsto_f')
       apply (simp add: Lim_within_open_NO_MATCH open_Times u, clarify)
-      apply (rule Lim_transform_within_open [OF _ open_uu_Id, where f = "(\<lambda>x. (f (snd x) - f (fst x)) / (snd x - fst x))"])
+      apply (rule Lim_transform_within_open [OF _ open_uu_Id, where f = "(\<lambda>(x,y). (f y - f x) / (y - x))"])
       using con_ff
       apply (auto simp: continuous_within)
       done
     have hol_dw: "(\<lambda>z. d z w) holomorphic_on u" if "w \<in> u" for w
     proof -
-      have "continuous_on u ((\<lambda>y. d (fst y) (snd y)) o (\<lambda>z. (w,z)))"
+      have "continuous_on u ((\<lambda>(x,y). d x y) o (\<lambda>z. (w,z)))"
         by (rule continuous_on_compose continuous_intros continuous_on_subset [OF cond_uu] | force intro: that)+
       then have *: "continuous_on u (\<lambda>z. if w = z then deriv f z else (f w - f z) / (w - z))"
         by (rule rev_iffD1 [OF _ continuous_on_cong [OF refl]]) (simp add: d_def field_simps)
@@ -7159,53 +7212,11 @@
     qed
     { fix a b
       assume abu: "closed_segment a b \<subseteq> u"
-      then have cont_dw: "\<And>w. w \<in> u \<Longrightarrow> (\<lambda>z. d z w) contour_integrable_on (linepath a b)"
+      then have "\<And>w. w \<in> u \<Longrightarrow> (\<lambda>z. d z w) contour_integrable_on (linepath a b)"
         by (metis hol_dw continuous_on_subset contour_integrable_continuous_linepath holomorphic_on_imp_continuous_on)
-      have *: "\<exists>da>0. \<forall>x'\<in>u. dist x' w < da \<longrightarrow>
-                             dist (contour_integral (linepath a b) (\<lambda>z. d z x'))
-                                  (contour_integral (linepath a b) (\<lambda>z. d z w)) \<le> ee"
-              if "w \<in> u" "0 < ee" "a \<noteq> b" for w ee
-      proof -
-        obtain dd where "dd>0" and dd: "cball w dd \<subseteq> u" using open_contains_cball u \<open>w \<in> u\<close> by force
-        let ?abdd = "{(z,t) |z t. z \<in> closed_segment a b \<and> t \<in> cball w dd}"
-        have "uniformly_continuous_on ?abdd (\<lambda>y. d (fst y) (snd y))"
-          apply (rule compact_uniformly_continuous)
-          apply (rule continuous_on_subset[OF cond_uu])
-          using abu dd
-          apply (auto simp: compact_Times simp del: mem_cball)
-          done
-        then obtain kk where "kk>0"
-            and kk: "\<And>x x'. \<lbrakk>x\<in>?abdd; x'\<in>?abdd; dist x' x < kk\<rbrakk> \<Longrightarrow>
-                             dist ((\<lambda>y. d (fst y) (snd y)) x') ((\<lambda>y. d (fst y) (snd y)) x) < ee/norm(b - a)"
-          apply (rule uniformly_continuous_onE [where e = "ee/norm(b - a)"])
-          using \<open>0 < ee\<close> \<open>a \<noteq> b\<close> by auto
-        have kk: "\<lbrakk>x1 \<in> closed_segment a b; norm (w - x2) \<le> dd;
-                   x1' \<in> closed_segment a b; norm (w - x2') \<le> dd; norm ((x1', x2') - (x1, x2)) < kk\<rbrakk>
-                  \<Longrightarrow> norm (d x1' x2' - d x1 x2) \<le> ee / cmod (b - a)"
-                 for x1 x2 x1' x2'
-          using kk [of "(x1,x2)" "(x1',x2')"] by (force simp add: dist_norm)
-        have le_ee: "cmod (contour_integral (linepath a b) (\<lambda>x. d x x' - d x w)) \<le> ee"
-                    if "x' \<in> u" "cmod (x' - w) < dd" "cmod (x' - w) < kk"  for x'
-        proof -
-          have "cmod (contour_integral (linepath a b) (\<lambda>x. d x x' - d x w)) \<le> ee/norm(b - a) * norm(b - a)"
-            apply (rule has_contour_integral_bound_linepath [OF has_contour_integral_integral _ kk])
-            apply (rule contour_integrable_diff [OF cont_dw cont_dw])
-            using \<open>0 < ee\<close> \<open>a \<noteq> b\<close> \<open>0 < dd\<close> \<open>w \<in> u\<close> that
-            apply (auto simp: norm_minus_commute)
-            done
-          also have "... = ee" using \<open>a \<noteq> b\<close> by simp
-          finally show ?thesis .
-        qed
-        show ?thesis
-          apply (rule_tac x="min dd kk" in exI)
-          using \<open>0 < dd\<close> \<open>0 < kk\<close>
-          apply (auto simp: dist_norm contour_integral_diff [OF cont_dw cont_dw, symmetric] \<open>w \<in> u\<close> intro: le_ee)
-          done
-      qed
-      have cont_cint_d: "continuous_on u (\<lambda>w. contour_integral (linepath a b) (\<lambda>z. d z w))"
-        apply (rule continuous_onI)
-        apply (cases "a=b")
-        apply (auto intro: *)
+      then have cont_cint_d: "continuous_on u (\<lambda>w. contour_integral (linepath a b) (\<lambda>z. d z w))"
+        apply (rule contour_integral_continuous_on_linepath_2D [OF \<open>open u\<close> _ _ abu])
+        apply (auto simp: intro: continuous_on_swap_args cond_uu)
         done
       have cont_cint_d\<gamma>: "continuous_on {0..1} ((\<lambda>w. contour_integral (linepath a b) (\<lambda>z. d z w)) o \<gamma>)"
         apply (rule continuous_on_compose)
@@ -7223,7 +7234,6 @@
         using abu  by (force simp add: h_def intro: contour_integral_eq)
       also have "... =  contour_integral \<gamma> (\<lambda>w. contour_integral (linepath a b) (\<lambda>z. d z w))"
         apply (rule contour_integral_swap)
-        apply (simp add: split_def)
         apply (rule continuous_on_subset [OF cond_uu])
         using abu pasz \<open>valid_path \<gamma>\<close>
         apply (auto intro!: continuous_intros)
@@ -7243,17 +7253,16 @@
       have A2: "\<forall>\<^sub>F n in sequentially. \<forall>xa\<in>path_image \<gamma>. cmod (d (a n) xa - d x xa) < ee" if "0 < ee" for ee
       proof -
         let ?ddpa = "{(w,z) |w z. w \<in> cball x dd \<and> z \<in> path_image \<gamma>}"
-        have "uniformly_continuous_on ?ddpa (\<lambda>y. d (fst y) (snd y))"
+        have "uniformly_continuous_on ?ddpa (\<lambda>(x,y). d x y)"
           apply (rule compact_uniformly_continuous [OF continuous_on_subset[OF cond_uu]])
           using dd pasz \<open>valid_path \<gamma>\<close>
           apply (auto simp: compact_Times compact_valid_path_image simp del: mem_cball)
           done
         then obtain kk where "kk>0"
             and kk: "\<And>x x'. \<lbrakk>x\<in>?ddpa; x'\<in>?ddpa; dist x' x < kk\<rbrakk> \<Longrightarrow>
-                             dist ((\<lambda>y. d (fst y) (snd y)) x') ((\<lambda>y. d (fst y) (snd y)) x) < ee"
+                             dist ((\<lambda>(x,y). d x y) x') ((\<lambda>(x,y). d x y) x) < ee"
           apply (rule uniformly_continuous_onE [where e = ee])
           using \<open>0 < ee\<close> by auto
-
         have kk: "\<lbrakk>norm (w - x) \<le> dd; z \<in> path_image \<gamma>; norm ((w, z) - (x, z)) < kk\<rbrakk> \<Longrightarrow> norm (d w z - d x z) < ee"
                  for  w z
           using \<open>dd>0\<close> kk [of "(x,z)" "(w,z)"] by (force simp add: norm_minus_commute dist_norm)
--- a/src/HOL/Multivariate_Analysis/Complex_Analysis_Basics.thy	Fri Feb 12 17:04:36 2016 +0100
+++ b/src/HOL/Multivariate_Analysis/Complex_Analysis_Basics.thy	Fri Feb 12 22:36:48 2016 +0100
@@ -447,16 +447,16 @@
 lemma holomorphic_cong: "s = t ==> (\<And>x. x \<in> s \<Longrightarrow> f x = g x) \<Longrightarrow> f holomorphic_on s \<longleftrightarrow> g holomorphic_on t"
   by (metis holomorphic_transform)
 
-lemma holomorphic_on_linear [holomorphic_intros]: "(op * c) holomorphic_on s"
+lemma holomorphic_on_linear [simp, holomorphic_intros]: "(op * c) holomorphic_on s"
   unfolding holomorphic_on_def by (metis complex_differentiable_linear)
 
-lemma holomorphic_on_const [holomorphic_intros]: "(\<lambda>z. c) holomorphic_on s"
+lemma holomorphic_on_const [simp, holomorphic_intros]: "(\<lambda>z. c) holomorphic_on s"
   unfolding holomorphic_on_def by (metis complex_differentiable_const)
 
-lemma holomorphic_on_ident [holomorphic_intros]: "(\<lambda>x. x) holomorphic_on s"
+lemma holomorphic_on_ident [simp, holomorphic_intros]: "(\<lambda>x. x) holomorphic_on s"
   unfolding holomorphic_on_def by (metis complex_differentiable_ident)
 
-lemma holomorphic_on_id [holomorphic_intros]: "id holomorphic_on s"
+lemma holomorphic_on_id [simp, holomorphic_intros]: "id holomorphic_on s"
   unfolding id_def by (rule holomorphic_on_ident)
 
 lemma holomorphic_on_compose:
@@ -545,6 +545,11 @@
   unfolding DERIV_deriv_iff_complex_differentiable[symmetric]
   by (auto intro!: DERIV_imp_deriv derivative_eq_intros)
 
+lemma complex_derivative_cdivide_right:
+  "f complex_differentiable at z \<Longrightarrow> deriv (\<lambda>w. f w / c) z = deriv f z / c"
+  unfolding Fields.field_class.field_divide_inverse
+  by (blast intro: complex_derivative_cmult_right)
+
 lemma complex_derivative_transform_within_open:
   "\<lbrakk>f holomorphic_on s; g holomorphic_on s; open s; z \<in> s; \<And>w. w \<in> s \<Longrightarrow> f w = g w\<rbrakk>
    \<Longrightarrow> deriv f z = deriv g z"
--- a/src/HOL/Nat.thy	Fri Feb 12 17:04:36 2016 +0100
+++ b/src/HOL/Nat.thy	Fri Feb 12 22:36:48 2016 +0100
@@ -1329,6 +1329,9 @@
 
 end
 
+lemma funpow_0 [simp]: "(f ^^ 0) x = x"
+  by simp
+
 lemma funpow_Suc_right:
   "f ^^ Suc n = f ^^ n \<circ> f"
 proof (induct n)
--- a/src/HOL/Series.thy	Fri Feb 12 17:04:36 2016 +0100
+++ b/src/HOL/Series.thy	Fri Feb 12 22:36:48 2016 +0100
@@ -129,6 +129,10 @@
        (simp add: eq atLeast0LessThan del: add_Suc_right)
 qed
 
+corollary sums_0:
+   "(\<And>n. f n = 0) \<Longrightarrow> (f sums 0)"
+    by (metis (no_types) finite.emptyI setsum.empty sums_finite)
+
 lemma summable_finite: "finite N \<Longrightarrow> (\<And>n. n \<notin> N \<Longrightarrow> f n = 0) \<Longrightarrow> summable f"
   by (rule sums_summable) (rule sums_finite)
 
--- a/src/HOL/Tools/ATP/atp_problem_generate.ML	Fri Feb 12 17:04:36 2016 +0100
+++ b/src/HOL/Tools/ATP/atp_problem_generate.ML	Fri Feb 12 22:36:48 2016 +0100
@@ -1675,12 +1675,12 @@
        |> class_membs_of_types type_enc add_sorts_on_tvar
        |> map (class_atom type_enc)))
     #> (case type_enc of
-         Native (_, poly, _) =>
+         Native (_, Type_Class_Polymorphic, _) =>
          mk_atyquant AForall (map (fn TVar (z as (_, S)) =>
-           (AType ((tvar_name z, []), []),
-            if poly = Type_Class_Polymorphic then map (`make_class) (normalize_classes S)
-            else [])) Ts)
-        | _ => mk_aquant AForall (map (fn TVar z => (tvar_name z, NONE)) Ts)))
+           (AType ((tvar_name z, []), []), map (`make_class) (normalize_classes S) )) Ts)
+       | Native (_, Raw_Polymorphic _, _) =>
+         mk_atyquant AForall (map (fn TVar (z as (_, S)) => (AType ((tvar_name z, []), []), [])) Ts)
+       | _ => mk_aquant AForall (map (fn TVar z => (tvar_name z, NONE)) Ts)))
 
 fun eq_formula type_enc atomic_Ts bounds pred_sym tm1 tm2 =
   (if pred_sym then AConn (AIff, [AAtom tm1, AAtom tm2])
--- a/src/HOL/Tools/Sledgehammer/sledgehammer_isar.ML	Fri Feb 12 17:04:36 2016 +0100
+++ b/src/HOL/Tools/Sledgehammer/sledgehammer_isar.ML	Fri Feb 12 22:36:48 2016 +0100
@@ -156,284 +156,295 @@
       let
         val (verbose, alt_metis_args, preplay_timeout, compress, try0, minimize, atp_proof0, goal) =
           isar_params ()
-
-        val systematic_methods' = insert (op =) (Metis_Method alt_metis_args) systematic_methods
+      in
+        if null atp_proof0 then
+          one_line_proof_text ctxt 0 one_line_params
+        else
+          let
+            val systematic_methods' = insert (op =) (Metis_Method alt_metis_args) systematic_methods
 
-        fun massage_methods (meths as meth :: _) =
-          if not try0 then [meth]
-          else if smt_proofs = SOME true then SMT_Method :: meths
-          else meths
-
-        val (params, _, concl_t) = strip_subgoal goal subgoal ctxt
-        val fixes = map (fn (s, T) => (Binding.name s, SOME T, NoSyn)) params
-        val ctxt = ctxt |> Variable.set_body false |> Proof_Context.add_fixes fixes |> snd
+            fun massage_methods (meths as meth :: _) =
+              if not try0 then [meth]
+              else if smt_proofs = SOME true then SMT_Method :: meths
+              else meths
 
-        val do_preplay = preplay_timeout <> Time.zeroTime
-        val compress =
-          (case compress of
-            NONE => if isar_proofs = NONE andalso do_preplay then 1000.0 else 10.0
-          | SOME n => n)
+            val (params, _, concl_t) = strip_subgoal goal subgoal ctxt
+            val fixes = map (fn (s, T) => (Binding.name s, SOME T, NoSyn)) params
+            val ctxt = ctxt |> Variable.set_body false |> Proof_Context.add_fixes fixes |> snd
 
-        fun is_fixed ctxt = Variable.is_declared ctxt orf Name.is_skolem
-        fun skolems_of ctxt t = Term.add_frees t [] |> filter_out (is_fixed ctxt o fst) |> rev
+            val do_preplay = preplay_timeout <> Time.zeroTime
+            val compress =
+              (case compress of
+                NONE => if isar_proofs = NONE andalso do_preplay then 1000.0 else 10.0
+              | SOME n => n)
 
-        fun get_role keep_role ((num, _), role, t, rule, _) =
-          if keep_role role then SOME ((raw_label_of_num num, t), rule) else NONE
-
-        val atp_proof =
-          fold_rev add_line_pass1 atp_proof0 []
-          |> add_lines_pass2 []
+            fun is_fixed ctxt = Variable.is_declared ctxt orf Name.is_skolem
+            fun skolems_of ctxt t = Term.add_frees t [] |> filter_out (is_fixed ctxt o fst) |> rev
 
-        val conjs =
-          map_filter (fn (name, role, _, _, _) =>
-              if member (op =) [Conjecture, Negated_Conjecture] role then SOME name else NONE)
-            atp_proof
-        val assms = map_filter (Option.map fst o get_role (curry (op =) Hypothesis)) atp_proof
+            fun get_role keep_role ((num, _), role, t, rule, _) =
+              if keep_role role then SOME ((raw_label_of_num num, t), rule) else NONE
+
+            val atp_proof =
+              fold_rev add_line_pass1 atp_proof0 []
+              |> add_lines_pass2 []
+
+            val conjs =
+              map_filter (fn (name, role, _, _, _) =>
+                  if member (op =) [Conjecture, Negated_Conjecture] role then SOME name else NONE)
+                atp_proof
+            val assms = map_filter (Option.map fst o get_role (curry (op =) Hypothesis)) atp_proof
 
-        fun add_lemma ((l, t), rule) ctxt =
-          let
-            val (skos, meths) =
-              (if is_skolemize_rule rule then (skolems_of ctxt t, skolem_methods)
-               else if is_arith_rule rule then ([], arith_methods)
-               else ([], rewrite_methods))
-              ||> massage_methods
-          in
-            (Prove ([], skos, l, t, [], ([], []), meths, ""),
-             ctxt |> not (null skos) ? (Variable.add_fixes (map fst skos) #> snd))
-          end
+            fun add_lemma ((l, t), rule) ctxt =
+              let
+                val (skos, meths) =
+                  (if is_skolemize_rule rule then (skolems_of ctxt t, skolem_methods)
+                   else if is_arith_rule rule then ([], arith_methods)
+                   else ([], rewrite_methods))
+                  ||> massage_methods
+              in
+                (Prove ([], skos, l, t, [], ([], []), meths, ""),
+                 ctxt |> not (null skos) ? (Variable.add_fixes (map fst skos) #> snd))
+              end
 
-        val (lems, _) =
-          fold_map add_lemma (map_filter (get_role (curry (op =) Lemma)) atp_proof) ctxt
-
-        val bot = #1 (List.last atp_proof)
-
-        val refute_graph =
-          atp_proof
-          |> map (fn (name, _, _, _, from) => (from, name))
-          |> make_refute_graph bot
-          |> fold (Atom_Graph.default_node o rpair ()) conjs
-
-        val axioms = axioms_of_refute_graph refute_graph conjs
+            val (lems, _) =
+              fold_map add_lemma (map_filter (get_role (curry (op =) Lemma)) atp_proof) ctxt
 
-        val tainted = tainted_atoms_of_refute_graph refute_graph conjs
-        val is_clause_tainted = exists (member (op =) tainted)
-        val steps =
-          Symtab.empty
-          |> fold (fn (name as (s, _), role, t, rule, _) =>
-              Symtab.update_new (s, (rule, t
-                |> (if is_clause_tainted [name] then
-                      HOLogic.dest_Trueprop
-                      #> role <> Conjecture ? s_not
-                      #> fold exists_of (map Var (Term.add_vars t []))
-                      #> HOLogic.mk_Trueprop
-                    else
-                      I))))
-            atp_proof
+            val bot = #1 (List.last atp_proof)
+
+            val refute_graph =
+              atp_proof
+              |> map (fn (name, _, _, _, from) => (from, name))
+              |> make_refute_graph bot
+              |> fold (Atom_Graph.default_node o rpair ()) conjs
+
+            val axioms = axioms_of_refute_graph refute_graph conjs
 
-        fun is_referenced_in_step _ (Let _) = false
-          | is_referenced_in_step l (Prove (_, _, _, _, subs, (ls, _), _, _)) =
-            member (op =) ls l orelse exists (is_referenced_in_proof l) subs
-        and is_referenced_in_proof l (Proof (_, _, steps)) =
-          exists (is_referenced_in_step l) steps
+            val tainted = tainted_atoms_of_refute_graph refute_graph conjs
+            val is_clause_tainted = exists (member (op =) tainted)
+            val steps =
+              Symtab.empty
+              |> fold (fn (name as (s, _), role, t, rule, _) =>
+                  Symtab.update_new (s, (rule, t
+                    |> (if is_clause_tainted [name] then
+                          HOLogic.dest_Trueprop
+                          #> role <> Conjecture ? s_not
+                          #> fold exists_of (map Var (Term.add_vars t []))
+                          #> HOLogic.mk_Trueprop
+                        else
+                          I))))
+                atp_proof
 
-        fun insert_lemma_in_step lem
-            (step as Prove (qs, fix, l, t, subs, (ls, gs), meths, comment)) =
-          let val l' = the (label_of_isar_step lem) in
-            if member (op =) ls l' then
-              [lem, step]
-            else
-              let val refs = map (is_referenced_in_proof l') subs in
-                if length (filter I refs) = 1 then
-                  let
-                    val subs' = map2 (fn false => I | true => insert_lemma_in_proof lem) refs subs
-                  in
-                    [Prove (qs, fix, l, t, subs', (ls, gs), meths, comment)]
-                  end
-                else
+            fun is_referenced_in_step _ (Let _) = false
+              | is_referenced_in_step l (Prove (_, _, _, _, subs, (ls, _), _, _)) =
+                member (op =) ls l orelse exists (is_referenced_in_proof l) subs
+            and is_referenced_in_proof l (Proof (_, _, steps)) =
+              exists (is_referenced_in_step l) steps
+
+            fun insert_lemma_in_step lem
+                (step as Prove (qs, fix, l, t, subs, (ls, gs), meths, comment)) =
+              let val l' = the (label_of_isar_step lem) in
+                if member (op =) ls l' then
                   [lem, step]
+                else
+                  let val refs = map (is_referenced_in_proof l') subs in
+                    if length (filter I refs) = 1 then
+                      let
+                        val subs' = map2 (fn false => I | true => insert_lemma_in_proof lem) refs
+                          subs
+                      in
+                        [Prove (qs, fix, l, t, subs', (ls, gs), meths, comment)]
+                      end
+                    else
+                      [lem, step]
+                  end
               end
-          end
-        and insert_lemma_in_steps lem [] = [lem]
-          | insert_lemma_in_steps lem (step :: steps) =
-            if is_referenced_in_step (the (label_of_isar_step lem)) step then
-              insert_lemma_in_step lem step @ steps
-            else
-              step :: insert_lemma_in_steps lem steps
-        and insert_lemma_in_proof lem (Proof (fix, assms, steps)) =
-          Proof (fix, assms, insert_lemma_in_steps lem steps)
-
-        val rule_of_clause_id = fst o the o Symtab.lookup steps o fst
-
-        val finish_off = close_form #> rename_bound_vars
-
-        fun prop_of_clause [(num, _)] = Symtab.lookup steps num |> the |> snd |> finish_off
-          | prop_of_clause names =
-            let
-              val lits =
-                map (HOLogic.dest_Trueprop o snd) (map_filter (Symtab.lookup steps o fst) names)
-            in
-              (case List.partition (can HOLogic.dest_not) lits of
-                (negs as _ :: _, pos as _ :: _) =>
-                s_imp (Library.foldr1 s_conj (map HOLogic.dest_not negs), Library.foldr1 s_disj pos)
-              | _ => fold (curry s_disj) lits @{term False})
-            end
-            |> HOLogic.mk_Trueprop |> finish_off
-
-        fun maybe_show outer c = if outer andalso eq_set (op =) (c, conjs) then [Show] else []
-
-        fun isar_steps outer predecessor accum [] =
-            accum
-            |> (if tainted = [] then
-                  (* e.g., trivial, empty proof by Z3 *)
-                  cons (Prove (if outer then [Show] else [], [], no_label, concl_t, [],
-                    sort_facts (the_list predecessor, []), massage_methods systematic_methods', ""))
+            and insert_lemma_in_steps lem [] = [lem]
+              | insert_lemma_in_steps lem (step :: steps) =
+                if is_referenced_in_step (the (label_of_isar_step lem)) step then
+                  insert_lemma_in_step lem step @ steps
                 else
-                  I)
-            |> rev
-          | isar_steps outer _ accum (Have (id, (gamma, c)) :: infs) =
-            let
-              val l = label_of_clause c
-              val t = prop_of_clause c
-              val rule = rule_of_clause_id id
-              val skolem = is_skolemize_rule rule
+                  step :: insert_lemma_in_steps lem steps
+            and insert_lemma_in_proof lem (Proof (fix, assms, steps)) =
+              Proof (fix, assms, insert_lemma_in_steps lem steps)
+
+            val rule_of_clause_id = fst o the o Symtab.lookup steps o fst
+
+            val finish_off = close_form #> rename_bound_vars
 
-              val deps = ([], [])
-                |> fold add_fact_of_dependency gamma
-                |> is_maybe_ext_rule rule ? add_global_fact [short_thm_name ctxt ext]
-                |> sort_facts
-              val meths =
-                (if skolem then skolem_methods
-                 else if is_arith_rule rule then arith_methods
-                 else if is_datatype_rule rule then datatype_methods
-                 else systematic_methods')
-                |> massage_methods
+            fun prop_of_clause [(num, _)] = Symtab.lookup steps num |> the |> snd |> finish_off
+              | prop_of_clause names =
+                let
+                  val lits =
+                    map (HOLogic.dest_Trueprop o snd) (map_filter (Symtab.lookup steps o fst) names)
+                in
+                  (case List.partition (can HOLogic.dest_not) lits of
+                    (negs as _ :: _, pos as _ :: _) =>
+                    s_imp (Library.foldr1 s_conj (map HOLogic.dest_not negs),
+                      Library.foldr1 s_disj pos)
+                  | _ => fold (curry s_disj) lits @{term False})
+                end
+                |> HOLogic.mk_Trueprop |> finish_off
+
+            fun maybe_show outer c = if outer andalso eq_set (op =) (c, conjs) then [Show] else []
 
-              fun prove sub facts = Prove (maybe_show outer c, [], l, t, sub, facts, meths, "")
-              fun steps_of_rest step = isar_steps outer (SOME l) (step :: accum) infs
-            in
-              if is_clause_tainted c then
-                (case gamma of
-                  [g] =>
-                  if skolem andalso is_clause_tainted g then
-                    let
-                      val skos = skolems_of ctxt (prop_of_clause g)
-                      val subproof = Proof (skos, [], rev accum)
-                    in
-                      isar_steps outer (SOME l) [prove [subproof] ([], [])] infs
-                    end
-                  else
-                    steps_of_rest (prove [] deps)
-                | _ => steps_of_rest (prove [] deps))
-              else
-                steps_of_rest
-                  (if skolem then
-                     (case skolems_of ctxt t of
-                       [] => prove [] deps
-                     | skos => Prove ([], skos, l, t, [], deps, meths, ""))
-                   else
-                     prove [] deps)
-            end
-          | isar_steps outer predecessor accum (Cases cases :: infs) =
-            let
-              fun isar_case (c, subinfs) =
-                isar_proof false [] [(label_of_clause c, prop_of_clause c)] [] subinfs
-              val c = succedent_of_cases cases
-              val l = label_of_clause c
-              val t = prop_of_clause c
-              val step =
-                Prove (maybe_show outer c, [], l, t,
-                  map isar_case (filter_out (null o snd) cases),
-                  sort_facts (the_list predecessor, []), massage_methods systematic_methods', "")
-            in
-              isar_steps outer (SOME l) (step :: accum) infs
-            end
-        and isar_proof outer fix assms lems infs =
-          Proof (fix, assms, fold_rev insert_lemma_in_steps lems (isar_steps outer NONE [] infs))
+            fun isar_steps outer predecessor accum [] =
+                accum
+                |> (if tainted = [] then
+                      (* e.g., trivial, empty proof by Z3 *)
+                      cons (Prove (if outer then [Show] else [], [], no_label, concl_t, [],
+                        sort_facts (the_list predecessor, []), massage_methods systematic_methods',
+                        ""))
+                    else
+                      I)
+                |> rev
+              | isar_steps outer _ accum (Have (id, (gamma, c)) :: infs) =
+                let
+                  val l = label_of_clause c
+                  val t = prop_of_clause c
+                  val rule = rule_of_clause_id id
+                  val skolem = is_skolemize_rule rule
 
-        val trace = Config.get ctxt trace
+                  val deps = ([], [])
+                    |> fold add_fact_of_dependency gamma
+                    |> is_maybe_ext_rule rule ? add_global_fact [short_thm_name ctxt ext]
+                    |> sort_facts
+                  val meths =
+                    (if skolem then skolem_methods
+                     else if is_arith_rule rule then arith_methods
+                     else if is_datatype_rule rule then datatype_methods
+                     else systematic_methods')
+                    |> massage_methods
 
-        val canonical_isar_proof =
-          refute_graph
-          |> trace ? tap (tracing o prefix "Refute graph:\n" o string_of_refute_graph)
-          |> redirect_graph axioms tainted bot
-          |> trace ? tap (tracing o prefix "Direct proof:\n" o string_of_direct_proof)
-          |> isar_proof true params assms lems
-          |> postprocess_isar_proof_remove_show_stuttering
-          |> postprocess_isar_proof_remove_unreferenced_steps I
-          |> relabel_isar_proof_canonically
-
-        val ctxt = ctxt |> enrich_context_with_local_facts canonical_isar_proof
-
-        val preplay_data = Unsynchronized.ref Canonical_Label_Tab.empty
-
-        val _ = fold_isar_steps (fn meth =>
-            K (set_preplay_outcomes_of_isar_step ctxt preplay_timeout preplay_data meth []))
-          (steps_of_isar_proof canonical_isar_proof) ()
+                  fun prove sub facts = Prove (maybe_show outer c, [], l, t, sub, facts, meths, "")
+                  fun steps_of_rest step = isar_steps outer (SOME l) (step :: accum) infs
+                in
+                  if is_clause_tainted c then
+                    (case gamma of
+                      [g] =>
+                      if skolem andalso is_clause_tainted g then
+                        let
+                          val skos = skolems_of ctxt (prop_of_clause g)
+                          val subproof = Proof (skos, [], rev accum)
+                        in
+                          isar_steps outer (SOME l) [prove [subproof] ([], [])] infs
+                        end
+                      else
+                        steps_of_rest (prove [] deps)
+                    | _ => steps_of_rest (prove [] deps))
+                  else
+                    steps_of_rest
+                      (if skolem then
+                         (case skolems_of ctxt t of
+                           [] => prove [] deps
+                         | skos => Prove ([], skos, l, t, [], deps, meths, ""))
+                       else
+                         prove [] deps)
+                end
+              | isar_steps outer predecessor accum (Cases cases :: infs) =
+                let
+                  fun isar_case (c, subinfs) =
+                    isar_proof false [] [(label_of_clause c, prop_of_clause c)] [] subinfs
+                  val c = succedent_of_cases cases
+                  val l = label_of_clause c
+                  val t = prop_of_clause c
+                  val step =
+                    Prove (maybe_show outer c, [], l, t,
+                      map isar_case (filter_out (null o snd) cases),
+                      sort_facts (the_list predecessor, []), massage_methods systematic_methods',
+                      "")
+                in
+                  isar_steps outer (SOME l) (step :: accum) infs
+                end
+            and isar_proof outer fix assms lems infs =
+              Proof (fix, assms,
+                fold_rev insert_lemma_in_steps lems (isar_steps outer NONE [] infs))
 
-        fun str_of_preplay_outcome outcome =
-          if Lazy.is_finished outcome then string_of_play_outcome (Lazy.force outcome) else "?"
-        fun str_of_meth l meth =
-          string_of_proof_method ctxt [] meth ^ " " ^
-          str_of_preplay_outcome (preplay_outcome_of_isar_step_for_method (!preplay_data) l meth)
-        fun comment_of l = map (str_of_meth l) #> commas
+            val trace = Config.get ctxt trace
 
-        fun trace_isar_proof label proof =
-          if trace then
-            tracing (timestamp () ^ "\n" ^ label ^ ":\n\n" ^
-              string_of_isar_proof ctxt subgoal subgoal_count
-                (comment_isar_proof comment_of proof) ^ "\n")
-          else
-            ()
+            val canonical_isar_proof =
+              refute_graph
+              |> trace ? tap (tracing o prefix "Refute graph:\n" o string_of_refute_graph)
+              |> redirect_graph axioms tainted bot
+              |> trace ? tap (tracing o prefix "Direct proof:\n" o string_of_direct_proof)
+              |> isar_proof true params assms lems
+              |> postprocess_isar_proof_remove_show_stuttering
+              |> postprocess_isar_proof_remove_unreferenced_steps I
+              |> relabel_isar_proof_canonically
 
-        fun comment_of l (meth :: _) =
-          (case (verbose,
-              Lazy.force (preplay_outcome_of_isar_step_for_method (!preplay_data) l meth)) of
-            (false, Played _) => ""
-          | (_, outcome) => string_of_play_outcome outcome)
+            val ctxt = ctxt |> enrich_context_with_local_facts canonical_isar_proof
+
+            val preplay_data = Unsynchronized.ref Canonical_Label_Tab.empty
+
+            val _ = fold_isar_steps (fn meth =>
+                K (set_preplay_outcomes_of_isar_step ctxt preplay_timeout preplay_data meth []))
+              (steps_of_isar_proof canonical_isar_proof) ()
 
-        val (play_outcome, isar_proof) =
-          canonical_isar_proof
-          |> tap (trace_isar_proof "Original")
-          |> compress_isar_proof ctxt compress preplay_timeout preplay_data
-          |> tap (trace_isar_proof "Compressed")
-          |> postprocess_isar_proof_remove_unreferenced_steps
-               (keep_fastest_method_of_isar_step (!preplay_data)
-                #> minimize ? minimize_isar_step_dependencies ctxt preplay_data)
-          |> tap (trace_isar_proof "Minimized")
-          |> `(preplay_outcome_of_isar_proof (!preplay_data))
-          ||> (comment_isar_proof comment_of
-               #> chain_isar_proof
-               #> kill_useless_labels_in_isar_proof
-               #> relabel_isar_proof_nicely
-               #> rationalize_obtains_in_isar_proofs ctxt)
-      in
-        (case (num_chained, add_isar_steps (steps_of_isar_proof isar_proof) 0) of
-          (0, 1) =>
-          one_line_proof_text ctxt 0
-            (if play_outcome_ord (play_outcome, one_line_play) = LESS then
-               (case isar_proof of
-                 Proof (_, _, [Prove (_, _, _, _, _, (_, gfs), meth :: _, _)]) =>
-                 let
-                   val used_facts' = filter (fn (s, (sc, _)) =>
-                     member (op =) gfs s andalso sc <> Chained) used_facts
-                 in
-                   ((used_facts', (meth, play_outcome)), banner, subgoal, subgoal_count)
-                 end)
-             else
-               one_line_params) ^
-          (if isar_proofs = SOME true then "\n(No Isar proof available.)"
-           else "")
-        | (_, num_steps) =>
-          let
-            val msg =
-              (if verbose then [string_of_int num_steps ^ " step" ^ plural_s num_steps] else []) @
-              (if do_preplay then [string_of_play_outcome play_outcome] else [])
+            fun str_of_preplay_outcome outcome =
+              if Lazy.is_finished outcome then string_of_play_outcome (Lazy.force outcome) else "?"
+            fun str_of_meth l meth =
+              string_of_proof_method ctxt [] meth ^ " " ^
+              str_of_preplay_outcome
+                (preplay_outcome_of_isar_step_for_method (!preplay_data) l meth)
+            fun comment_of l = map (str_of_meth l) #> commas
+
+            fun trace_isar_proof label proof =
+              if trace then
+                tracing (timestamp () ^ "\n" ^ label ^ ":\n\n" ^
+                  string_of_isar_proof ctxt subgoal subgoal_count
+                    (comment_isar_proof comment_of proof) ^ "\n")
+              else
+                ()
+
+            fun comment_of l (meth :: _) =
+              (case (verbose,
+                  Lazy.force (preplay_outcome_of_isar_step_for_method (!preplay_data) l meth)) of
+                (false, Played _) => ""
+              | (_, outcome) => string_of_play_outcome outcome)
+
+            val (play_outcome, isar_proof) =
+              canonical_isar_proof
+              |> tap (trace_isar_proof "Original")
+              |> compress_isar_proof ctxt compress preplay_timeout preplay_data
+              |> tap (trace_isar_proof "Compressed")
+              |> postprocess_isar_proof_remove_unreferenced_steps
+                   (keep_fastest_method_of_isar_step (!preplay_data)
+                    #> minimize ? minimize_isar_step_dependencies ctxt preplay_data)
+              |> tap (trace_isar_proof "Minimized")
+              |> `(preplay_outcome_of_isar_proof (!preplay_data))
+              ||> (comment_isar_proof comment_of
+                   #> chain_isar_proof
+                   #> kill_useless_labels_in_isar_proof
+                   #> relabel_isar_proof_nicely
+                   #> rationalize_obtains_in_isar_proofs ctxt)
           in
-            one_line_proof_text ctxt 0 one_line_params ^
-            "\n\nIsar proof" ^ (commas msg |> not (null msg) ? enclose " (" ")") ^ ":\n" ^
-            Active.sendback_markup [Markup.padding_command]
-              (string_of_isar_proof ctxt subgoal subgoal_count isar_proof)
-          end)
+            (case (num_chained, add_isar_steps (steps_of_isar_proof isar_proof) 0) of
+              (0, 1) =>
+              one_line_proof_text ctxt 0
+                (if play_outcome_ord (play_outcome, one_line_play) = LESS then
+                   (case isar_proof of
+                     Proof (_, _, [Prove (_, _, _, _, _, (_, gfs), meth :: _, _)]) =>
+                     let
+                       val used_facts' = filter (fn (s, (sc, _)) =>
+                         member (op =) gfs s andalso sc <> Chained) used_facts
+                     in
+                       ((used_facts', (meth, play_outcome)), banner, subgoal, subgoal_count)
+                     end)
+                 else
+                   one_line_params) ^
+              (if isar_proofs = SOME true then "\n(No Isar proof available.)" else "")
+            | (_, num_steps) =>
+              let
+                val msg =
+                  (if verbose then [string_of_int num_steps ^ " step" ^ plural_s num_steps]
+                   else []) @
+                  (if do_preplay then [string_of_play_outcome play_outcome] else [])
+              in
+                one_line_proof_text ctxt 0 one_line_params ^
+                "\n\nIsar proof" ^ (commas msg |> not (null msg) ? enclose " (" ")") ^ ":\n" ^
+                Active.sendback_markup [Markup.padding_command]
+                  (string_of_isar_proof ctxt subgoal subgoal_count isar_proof)
+              end)
+          end
       end
   in
     if debug then
--- a/src/HOL/Topological_Spaces.thy	Fri Feb 12 17:04:36 2016 +0100
+++ b/src/HOL/Topological_Spaces.thy	Fri Feb 12 22:36:48 2016 +0100
@@ -1076,6 +1076,9 @@
 lemma lim_le: "convergent f \<Longrightarrow> (\<And>n. f n \<le> (x::'a::linorder_topology)) \<Longrightarrow> lim f \<le> x"
   using LIMSEQ_le_const2[of f "lim f" x] by (simp add: convergent_LIMSEQ_iff)
 
+lemma lim_const [simp]: "lim (\<lambda>m. a) = a"
+  by (simp add: limI)
+
 subsubsection\<open>Increasing and Decreasing Series\<close>
 
 lemma incseq_le: "incseq X \<Longrightarrow> X \<longlonglongrightarrow> L \<Longrightarrow> X n \<le> (L::'a::linorder_topology)"