manual merge;
authorwenzelm
Wed Jun 17 17:54:09 2015 +0200 (2015-06-17)
changeset 60502aa58872267ee
parent 60497 010c26e24c72
parent 60501 839169c70e92
child 60503 47df24e05b1c
manual merge;
src/HOL/Library/Multiset.thy
src/HOL/Library/Multiset_Order.thy
src/HOL/Library/Permutation.thy
src/HOL/Library/Tree_Multiset.thy
     1.1 --- a/src/HOL/Library/AList.thy	Wed Jun 17 17:33:22 2015 +0200
     1.2 +++ b/src/HOL/Library/AList.thy	Wed Jun 17 17:54:09 2015 +0200
     1.3 @@ -2,7 +2,7 @@
     1.4      Author:     Norbert Schirmer, Tobias Nipkow, Martin Wildmoser, TU Muenchen
     1.5  *)
     1.6  
     1.7 -section {* Implementation of Association Lists *}
     1.8 +section \<open>Implementation of Association Lists\<close>
     1.9  
    1.10  theory AList
    1.11  imports Main
    1.12 @@ -11,14 +11,14 @@
    1.13  context
    1.14  begin
    1.15  
    1.16 -text {*
    1.17 +text \<open>
    1.18    The operations preserve distinctness of keys and
    1.19    function @{term "clearjunk"} distributes over them. Since
    1.20    @{term clearjunk} enforces distinctness of keys it can be used
    1.21    to establish the invariant, e.g. for inductive proofs.
    1.22 -*}
    1.23 +\<close>
    1.24  
    1.25 -subsection {* @{text update} and @{text updates} *}
    1.26 +subsection \<open>@{text update} and @{text updates}\<close>
    1.27  
    1.28  qualified primrec update :: "'key \<Rightarrow> 'val \<Rightarrow> ('key \<times> 'val) list \<Rightarrow> ('key \<times> 'val) list"
    1.29  where
    1.30 @@ -68,9 +68,9 @@
    1.31  lemma update_last [simp]: "update k v (update k v' al) = update k v al"
    1.32    by (induct al) auto
    1.33  
    1.34 -text {* Note that the lists are not necessarily the same:
    1.35 +text \<open>Note that the lists are not necessarily the same:
    1.36          @{term "update k v (update k' v' []) = [(k', v'), (k, v)]"} and
    1.37 -        @{term "update k' v' (update k v []) = [(k, v), (k', v')]"}.*}
    1.38 +        @{term "update k' v' (update k v []) = [(k, v), (k', v')]"}.\<close>
    1.39  
    1.40  lemma update_swap:
    1.41    "k \<noteq> k' \<Longrightarrow>
    1.42 @@ -163,7 +163,7 @@
    1.43    by (induct xs arbitrary: ys al) (auto split: list.splits)
    1.44  
    1.45  
    1.46 -subsection {* @{text delete} *}
    1.47 +subsection \<open>@{text delete}\<close>
    1.48  
    1.49  qualified definition delete :: "'key \<Rightarrow> ('key \<times> 'val) list \<Rightarrow> ('key \<times> 'val) list"
    1.50    where delete_eq: "delete k = filter (\<lambda>(k', _). k \<noteq> k')"
    1.51 @@ -215,17 +215,17 @@
    1.52    by (simp add: delete_eq)
    1.53  
    1.54  
    1.55 -subsection {* @{text update_with_aux} and @{text delete_aux}*}
    1.56 +subsection \<open>@{text update_with_aux} and @{text delete_aux}\<close>
    1.57  
    1.58  qualified primrec update_with_aux :: "'val \<Rightarrow> 'key \<Rightarrow> ('val \<Rightarrow> 'val) \<Rightarrow> ('key \<times> 'val) list \<Rightarrow> ('key \<times> 'val) list"
    1.59  where
    1.60    "update_with_aux v k f [] = [(k, f v)]"
    1.61  | "update_with_aux v k f (p # ps) = (if (fst p = k) then (k, f (snd p)) # ps else p # update_with_aux v k f ps)"
    1.62  
    1.63 -text {*
    1.64 +text \<open>
    1.65    The above @{term "delete"} traverses all the list even if it has found the key.
    1.66    This one does not have to keep going because is assumes the invariant that keys are distinct.
    1.67 -*}
    1.68 +\<close>
    1.69  qualified fun delete_aux :: "'key \<Rightarrow> ('key \<times> 'val) list \<Rightarrow> ('key \<times> 'val) list"
    1.70  where
    1.71    "delete_aux k [] = []"
    1.72 @@ -296,7 +296,7 @@
    1.73  by(cases ts)(auto split: split_if_asm)
    1.74  
    1.75  
    1.76 -subsection {* @{text restrict} *}
    1.77 +subsection \<open>@{text restrict}\<close>
    1.78  
    1.79  qualified definition restrict :: "'key set \<Rightarrow> ('key \<times> 'val) list \<Rightarrow> ('key \<times> 'val) list"
    1.80    where restrict_eq: "restrict A = filter (\<lambda>(k, v). k \<in> A)"
    1.81 @@ -380,7 +380,7 @@
    1.82    by (induct ps) auto
    1.83  
    1.84  
    1.85 -subsection {* @{text clearjunk} *}
    1.86 +subsection \<open>@{text clearjunk}\<close>
    1.87  
    1.88  qualified function clearjunk  :: "('key \<times> 'val) list \<Rightarrow> ('key \<times> 'val) list"
    1.89  where
    1.90 @@ -464,7 +464,7 @@
    1.91      (simp_all add: clearjunk_delete delete_map assms)
    1.92  
    1.93  
    1.94 -subsection {* @{text map_ran} *}
    1.95 +subsection \<open>@{text map_ran}\<close>
    1.96  
    1.97  definition map_ran :: "('key \<Rightarrow> 'val \<Rightarrow> 'val) \<Rightarrow> ('key \<times> 'val) list \<Rightarrow> ('key \<times> 'val) list"
    1.98    where "map_ran f = map (\<lambda>(k, v). (k, f k v))"
    1.99 @@ -490,7 +490,7 @@
   1.100    by (simp add: map_ran_def split_def clearjunk_map)
   1.101  
   1.102  
   1.103 -subsection {* @{text merge} *}
   1.104 +subsection \<open>@{text merge}\<close>
   1.105  
   1.106  qualified definition merge :: "('key \<times> 'val) list \<Rightarrow> ('key \<times> 'val) list \<Rightarrow> ('key \<times> 'val) list"
   1.107    where "merge qs ps = foldr (\<lambda>(k, v). update k v) ps qs"
   1.108 @@ -558,7 +558,7 @@
   1.109    by (simp add: merge_conv')
   1.110  
   1.111  
   1.112 -subsection {* @{text compose} *}
   1.113 +subsection \<open>@{text compose}\<close>
   1.114  
   1.115  qualified function compose :: "('key \<times> 'a) list \<Rightarrow> ('a \<times> 'b) list \<Rightarrow> ('key \<times> 'b) list"
   1.116  where
   1.117 @@ -723,7 +723,7 @@
   1.118    by (simp add: compose_conv map_comp_None_iff)
   1.119  
   1.120  
   1.121 -subsection {* @{text map_entry} *}
   1.122 +subsection \<open>@{text map_entry}\<close>
   1.123  
   1.124  qualified fun map_entry :: "'key \<Rightarrow> ('val \<Rightarrow> 'val) \<Rightarrow> ('key \<times> 'val) list \<Rightarrow> ('key \<times> 'val) list"
   1.125  where
   1.126 @@ -745,7 +745,7 @@
   1.127    using assms by (induct xs) (auto simp add: dom_map_entry)
   1.128  
   1.129  
   1.130 -subsection {* @{text map_default} *}
   1.131 +subsection \<open>@{text map_default}\<close>
   1.132  
   1.133  fun map_default :: "'key \<Rightarrow> 'val \<Rightarrow> ('val \<Rightarrow> 'val) \<Rightarrow> ('key \<times> 'val) list \<Rightarrow> ('key \<times> 'val) list"
   1.134  where
     2.1 --- a/src/HOL/Library/AList_Mapping.thy	Wed Jun 17 17:33:22 2015 +0200
     2.2 +++ b/src/HOL/Library/AList_Mapping.thy	Wed Jun 17 17:54:09 2015 +0200
     2.3 @@ -2,7 +2,7 @@
     2.4     Author: Florian Haftmann, TU Muenchen
     2.5  *)
     2.6  
     2.7 -section {* Implementation of mappings with Association Lists *}
     2.8 +section \<open>Implementation of mappings with Association Lists\<close>
     2.9  
    2.10  theory AList_Mapping
    2.11  imports AList Mapping
     3.1 --- a/src/HOL/Library/BNF_Axiomatization.thy	Wed Jun 17 17:33:22 2015 +0200
     3.2 +++ b/src/HOL/Library/BNF_Axiomatization.thy	Wed Jun 17 17:54:09 2015 +0200
     3.3 @@ -5,7 +5,7 @@
     3.4  Axiomatic declaration of bounded natural functors.
     3.5  *)
     3.6  
     3.7 -section {* Axiomatic Declaration of Bounded Natural Functors *}
     3.8 +section \<open>Axiomatic Declaration of Bounded Natural Functors\<close>
     3.9  
    3.10  theory BNF_Axiomatization
    3.11  imports Main
     4.1 --- a/src/HOL/Library/BigO.thy	Wed Jun 17 17:33:22 2015 +0200
     4.2 +++ b/src/HOL/Library/BigO.thy	Wed Jun 17 17:54:09 2015 +0200
     4.3 @@ -2,13 +2,13 @@
     4.4      Authors:    Jeremy Avigad and Kevin Donnelly
     4.5  *)
     4.6  
     4.7 -section {* Big O notation *}
     4.8 +section \<open>Big O notation\<close>
     4.9  
    4.10  theory BigO
    4.11  imports Complex_Main Function_Algebras Set_Algebras
    4.12  begin
    4.13  
    4.14 -text {*
    4.15 +text \<open>
    4.16  This library is designed to support asymptotic ``big O'' calculations,
    4.17  i.e.~reasoning with expressions of the form $f = O(g)$ and $f = g +
    4.18  O(h)$.  An earlier version of this library is described in detail in
    4.19 @@ -30,9 +30,9 @@
    4.20  one should redeclare the theorem @{text "subsetI"} as an intro rule,
    4.21  rather than as an @{text "intro!"} rule, for example, using
    4.22  \isa{\isakeyword{declare}}~@{text "subsetI [del, intro]"}.
    4.23 -*}
    4.24 +\<close>
    4.25  
    4.26 -subsection {* Definitions *}
    4.27 +subsection \<open>Definitions\<close>
    4.28  
    4.29  definition bigo :: "('a \<Rightarrow> 'b::linordered_idom) \<Rightarrow> ('a \<Rightarrow> 'b) set"  ("(1O'(_'))")
    4.30    where "O(f:: 'a \<Rightarrow> 'b) = {h. \<exists>c. \<forall>x. abs (h x) \<le> c * abs (f x)}"
    4.31 @@ -558,7 +558,7 @@
    4.32    done
    4.33  
    4.34  
    4.35 -subsection {* Setsum *}
    4.36 +subsection \<open>Setsum\<close>
    4.37  
    4.38  lemma bigo_setsum_main: "\<forall>x. \<forall>y \<in> A x. 0 \<le> h x y \<Longrightarrow>
    4.39      \<exists>c. \<forall>x. \<forall>y \<in> A x. abs (f x y) \<le> c * (h x y) \<Longrightarrow>
    4.40 @@ -659,7 +659,7 @@
    4.41    done
    4.42  
    4.43  
    4.44 -subsection {* Misc useful stuff *}
    4.45 +subsection \<open>Misc useful stuff\<close>
    4.46  
    4.47  lemma bigo_useful_intro: "A \<subseteq> O(f) \<Longrightarrow> B \<subseteq> O(f) \<Longrightarrow> A + B \<subseteq> O(f)"
    4.48    apply (subst bigo_plus_idemp [symmetric])
    4.49 @@ -712,7 +712,7 @@
    4.50    done
    4.51  
    4.52  
    4.53 -subsection {* Less than or equal to *}
    4.54 +subsection \<open>Less than or equal to\<close>
    4.55  
    4.56  definition lesso :: "('a \<Rightarrow> 'b::linordered_idom) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b"  (infixl "<o" 70)
    4.57    where "f <o g = (\<lambda>x. max (f x - g x) 0)"
     5.1 --- a/src/HOL/Library/Bit.thy	Wed Jun 17 17:33:22 2015 +0200
     5.2 +++ b/src/HOL/Library/Bit.thy	Wed Jun 17 17:54:09 2015 +0200
     5.3 @@ -2,13 +2,13 @@
     5.4      Author:     Brian Huffman
     5.5  *)
     5.6  
     5.7 -section {* The Field of Integers mod 2 *}
     5.8 +section \<open>The Field of Integers mod 2\<close>
     5.9  
    5.10  theory Bit
    5.11  imports Main
    5.12  begin
    5.13  
    5.14 -subsection {* Bits as a datatype *}
    5.15 +subsection \<open>Bits as a datatype\<close>
    5.16  
    5.17  typedef bit = "UNIV :: bool set"
    5.18    morphisms set Bit
    5.19 @@ -96,7 +96,7 @@
    5.20    by (simp_all add: equal set_iff)  
    5.21  
    5.22    
    5.23 -subsection {* Type @{typ bit} forms a field *}
    5.24 +subsection \<open>Type @{typ bit} forms a field\<close>
    5.25  
    5.26  instantiation bit :: field
    5.27  begin
    5.28 @@ -134,7 +134,7 @@
    5.29  lemma bit_mult_eq_1_iff [simp]: "x * y = (1 :: bit) \<longleftrightarrow> x = 1 \<and> y = 1"
    5.30    unfolding times_bit_def by (simp split: bit.split)
    5.31  
    5.32 -text {* Not sure whether the next two should be simp rules. *}
    5.33 +text \<open>Not sure whether the next two should be simp rules.\<close>
    5.34  
    5.35  lemma bit_add_eq_0_iff: "x + y = (0 :: bit) \<longleftrightarrow> x = y"
    5.36    unfolding plus_bit_def by (simp split: bit.split)
    5.37 @@ -143,9 +143,9 @@
    5.38    unfolding plus_bit_def by (simp split: bit.split)
    5.39  
    5.40  
    5.41 -subsection {* Numerals at type @{typ bit} *}
    5.42 +subsection \<open>Numerals at type @{typ bit}\<close>
    5.43  
    5.44 -text {* All numerals reduce to either 0 or 1. *}
    5.45 +text \<open>All numerals reduce to either 0 or 1.\<close>
    5.46  
    5.47  lemma bit_minus1 [simp]: "- 1 = (1 :: bit)"
    5.48    by (simp only: uminus_bit_def)
    5.49 @@ -160,7 +160,7 @@
    5.50    by (simp only: numeral_Bit1 bit_add_self add_0_left)
    5.51  
    5.52  
    5.53 -subsection {* Conversion from @{typ bit} *}
    5.54 +subsection \<open>Conversion from @{typ bit}\<close>
    5.55  
    5.56  context zero_neq_one
    5.57  begin
     6.1 --- a/src/HOL/Library/Boolean_Algebra.thy	Wed Jun 17 17:33:22 2015 +0200
     6.2 +++ b/src/HOL/Library/Boolean_Algebra.thy	Wed Jun 17 17:54:09 2015 +0200
     6.3 @@ -2,7 +2,7 @@
     6.4      Author:     Brian Huffman
     6.5  *)
     6.6  
     6.7 -section {* Boolean Algebras *}
     6.8 +section \<open>Boolean Algebras\<close>
     6.9  
    6.10  theory Boolean_Algebra
    6.11  imports Main
    6.12 @@ -53,7 +53,7 @@
    6.13  apply (rule conj_cancel_right)
    6.14  done
    6.15  
    6.16 -subsection {* Complement *}
    6.17 +subsection \<open>Complement\<close>
    6.18  
    6.19  lemma complement_unique:
    6.20    assumes 1: "a \<sqinter> x = \<zero>"
    6.21 @@ -81,7 +81,7 @@
    6.22  lemma compl_eq_compl_iff [simp]: "(\<sim> x = \<sim> y) = (x = y)"
    6.23  by (rule inj_eq [OF inj_on_inverseI], rule double_compl)
    6.24  
    6.25 -subsection {* Conjunction *}
    6.26 +subsection \<open>Conjunction\<close>
    6.27  
    6.28  lemma conj_absorb [simp]: "x \<sqinter> x = x"
    6.29  proof -
    6.30 @@ -124,7 +124,7 @@
    6.31  lemmas conj_disj_distribs =
    6.32     conj_disj_distrib conj_disj_distrib2
    6.33  
    6.34 -subsection {* Disjunction *}
    6.35 +subsection \<open>Disjunction\<close>
    6.36  
    6.37  lemma disj_absorb [simp]: "x \<squnion> x = x"
    6.38  by (rule boolean.conj_absorb [OF dual])
    6.39 @@ -154,7 +154,7 @@
    6.40  lemmas disj_conj_distribs =
    6.41     disj_conj_distrib disj_conj_distrib2
    6.42  
    6.43 -subsection {* De Morgan's Laws *}
    6.44 +subsection \<open>De Morgan's Laws\<close>
    6.45  
    6.46  lemma de_Morgan_conj [simp]: "\<sim> (x \<sqinter> y) = \<sim> x \<squnion> \<sim> y"
    6.47  proof (rule compl_unique)
    6.48 @@ -178,7 +178,7 @@
    6.49  
    6.50  end
    6.51  
    6.52 -subsection {* Symmetric Difference *}
    6.53 +subsection \<open>Symmetric Difference\<close>
    6.54  
    6.55  locale boolean_xor = boolean +
    6.56    fixes xor :: "'a => 'a => 'a"  (infixr "\<oplus>" 65)
     7.1 --- a/src/HOL/Library/Cardinal_Notations.thy	Wed Jun 17 17:33:22 2015 +0200
     7.2 +++ b/src/HOL/Library/Cardinal_Notations.thy	Wed Jun 17 17:54:09 2015 +0200
     7.3 @@ -5,7 +5,7 @@
     7.4  Cardinal notations.
     7.5  *)
     7.6  
     7.7 -section {* Cardinal Notations *}
     7.8 +section \<open>Cardinal Notations\<close>
     7.9  
    7.10  theory Cardinal_Notations
    7.11  imports Main
     8.1 --- a/src/HOL/Library/Cardinality.thy	Wed Jun 17 17:33:22 2015 +0200
     8.2 +++ b/src/HOL/Library/Cardinality.thy	Wed Jun 17 17:54:09 2015 +0200
     8.3 @@ -2,13 +2,13 @@
     8.4      Author:     Brian Huffman, Andreas Lochbihler
     8.5  *)
     8.6  
     8.7 -section {* Cardinality of types *}
     8.8 +section \<open>Cardinality of types\<close>
     8.9  
    8.10  theory Cardinality
    8.11  imports Phantom_Type
    8.12  begin
    8.13  
    8.14 -subsection {* Preliminary lemmas *}
    8.15 +subsection \<open>Preliminary lemmas\<close>
    8.16  (* These should be moved elsewhere *)
    8.17  
    8.18  lemma (in type_definition) univ:
    8.19 @@ -37,18 +37,18 @@
    8.20      by(auto simp add: type_definition.univ[OF type_definition_literal] infinite_UNIV_listI dest: finite_imageD)
    8.21  qed
    8.22  
    8.23 -subsection {* Cardinalities of types *}
    8.24 +subsection \<open>Cardinalities of types\<close>
    8.25  
    8.26  syntax "_type_card" :: "type => nat" ("(1CARD/(1'(_')))")
    8.27  
    8.28  translations "CARD('t)" => "CONST card (CONST UNIV \<Colon> 't set)"
    8.29  
    8.30 -print_translation {*
    8.31 +print_translation \<open>
    8.32    let
    8.33      fun card_univ_tr' ctxt [Const (@{const_syntax UNIV}, Type (_, [T]))] =
    8.34        Syntax.const @{syntax_const "_type_card"} $ Syntax_Phases.term_of_typ ctxt T
    8.35    in [(@{const_syntax card}, card_univ_tr')] end
    8.36 -*}
    8.37 +\<close>
    8.38  
    8.39  lemma card_prod [simp]: "CARD('a \<times> 'b) = CARD('a) * CARD('b)"
    8.40    unfolding UNIV_Times_UNIV [symmetric] by (simp only: card_cartesian_product)
    8.41 @@ -161,9 +161,9 @@
    8.42  lemma card_literal: "CARD(String.literal) = 0"
    8.43  by(simp add: card_eq_0_iff infinite_literal)
    8.44  
    8.45 -subsection {* Classes with at least 1 and 2  *}
    8.46 +subsection \<open>Classes with at least 1 and 2\<close>
    8.47  
    8.48 -text {* Class finite already captures "at least 1" *}
    8.49 +text \<open>Class finite already captures "at least 1"\<close>
    8.50  
    8.51  lemma zero_less_card_finite [simp]: "0 < CARD('a::finite)"
    8.52    unfolding neq0_conv [symmetric] by simp
    8.53 @@ -171,7 +171,7 @@
    8.54  lemma one_le_card_finite [simp]: "Suc 0 \<le> CARD('a::finite)"
    8.55    by (simp add: less_Suc_eq_le [symmetric])
    8.56  
    8.57 -text {* Class for cardinality "at least 2" *}
    8.58 +text \<open>Class for cardinality "at least 2"\<close>
    8.59  
    8.60  class card2 = finite + 
    8.61    assumes two_le_card: "2 \<le> CARD('a)"
    8.62 @@ -183,7 +183,7 @@
    8.63    using one_less_card [where 'a='a] by simp
    8.64  
    8.65  
    8.66 -subsection {* A type class for deciding finiteness of types *}
    8.67 +subsection \<open>A type class for deciding finiteness of types\<close>
    8.68  
    8.69  type_synonym 'a finite_UNIV = "('a, bool) phantom"
    8.70  
    8.71 @@ -196,7 +196,7 @@
    8.72    \<longleftrightarrow> of_phantom (finite_UNIV :: 'a finite_UNIV)"
    8.73  by(simp add: finite_UNIV)
    8.74  
    8.75 -subsection {* A type class for computing the cardinality of types *}
    8.76 +subsection \<open>A type class for computing the cardinality of types\<close>
    8.77  
    8.78  definition is_list_UNIV :: "'a list \<Rightarrow> bool"
    8.79  where "is_list_UNIV xs = (let c = CARD('a) in if c = 0 then False else size (remdups xs) = c)"
    8.80 @@ -211,7 +211,7 @@
    8.81    fixes card_UNIV :: "'a card_UNIV"
    8.82    assumes card_UNIV: "card_UNIV = Phantom('a) CARD('a)"
    8.83  
    8.84 -subsection {* Instantiations for @{text "card_UNIV"} *}
    8.85 +subsection \<open>Instantiations for @{text "card_UNIV"}\<close>
    8.86  
    8.87  instantiation nat :: card_UNIV begin
    8.88  definition "finite_UNIV = Phantom(nat) False"
    8.89 @@ -396,9 +396,9 @@
    8.90    by intro_classes (simp_all add: UNIV_finite_5 card_UNIV_finite_5_def finite_UNIV_finite_5_def)
    8.91  end
    8.92  
    8.93 -subsection {* Code setup for sets *}
    8.94 +subsection \<open>Code setup for sets\<close>
    8.95  
    8.96 -text {*
    8.97 +text \<open>
    8.98    Implement @{term "CARD('a)"} via @{term card_UNIV} and provide
    8.99    implementations for @{term "finite"}, @{term "card"}, @{term "op \<subseteq>"}, 
   8.100    and @{term "op ="}if the calling context already provides @{class finite_UNIV}
   8.101 @@ -406,7 +406,7 @@
   8.102    always via @{term card_UNIV}, we would require instances of essentially all 
   8.103    element types, i.e., a lot of instantiation proofs and -- at run time --
   8.104    possibly slow dictionary constructions.
   8.105 -*}
   8.106 +\<close>
   8.107  
   8.108  definition card_UNIV' :: "'a card_UNIV"
   8.109  where [code del]: "card_UNIV' = Phantom('a) CARD('a)"
   8.110 @@ -491,13 +491,13 @@
   8.111  
   8.112  end
   8.113  
   8.114 -text {* 
   8.115 +text \<open>
   8.116    Provide more informative exceptions than Match for non-rewritten cases.
   8.117    If generated code raises one these exceptions, then a code equation calls
   8.118    the mentioned operator for an element type that is not an instance of
   8.119    @{class card_UNIV} and is therefore not implemented via @{term card_UNIV}.
   8.120    Constrain the element type with sort @{class card_UNIV} to change this.
   8.121 -*}
   8.122 +\<close>
   8.123  
   8.124  lemma card_coset_error [code]:
   8.125    "card (List.coset xs) = 
     9.1 --- a/src/HOL/Library/Char_ord.thy	Wed Jun 17 17:33:22 2015 +0200
     9.2 +++ b/src/HOL/Library/Char_ord.thy	Wed Jun 17 17:54:09 2015 +0200
     9.3 @@ -2,7 +2,7 @@
     9.4      Author:     Norbert Voelker, Florian Haftmann
     9.5  *)
     9.6  
     9.7 -section {* Order on characters *}
     9.8 +section \<open>Order on characters\<close>
     9.9  
    9.10  theory Char_ord
    9.11  imports Main
    9.12 @@ -123,7 +123,7 @@
    9.13  lifting_update literal.lifting
    9.14  lifting_forget literal.lifting
    9.15  
    9.16 -text {* Legacy aliasses *}
    9.17 +text \<open>Legacy aliasses\<close>
    9.18  
    9.19  lemmas nibble_less_eq_def = less_eq_nibble_def
    9.20  lemmas nibble_less_def = less_nibble_def
    10.1 --- a/src/HOL/Library/Code_Abstract_Nat.thy	Wed Jun 17 17:33:22 2015 +0200
    10.2 +++ b/src/HOL/Library/Code_Abstract_Nat.thy	Wed Jun 17 17:54:09 2015 +0200
    10.3 @@ -2,41 +2,41 @@
    10.4      Author:     Stefan Berghofer, Florian Haftmann, TU Muenchen
    10.5  *)
    10.6  
    10.7 -section {* Avoidance of pattern matching on natural numbers *}
    10.8 +section \<open>Avoidance of pattern matching on natural numbers\<close>
    10.9  
   10.10  theory Code_Abstract_Nat
   10.11  imports Main
   10.12  begin
   10.13  
   10.14 -text {*
   10.15 +text \<open>
   10.16    When natural numbers are implemented in another than the
   10.17    conventional inductive @{term "0::nat"}/@{term Suc} representation,
   10.18    it is necessary to avoid all pattern matching on natural numbers
   10.19    altogether.  This is accomplished by this theory (up to a certain
   10.20    extent).
   10.21 -*}
   10.22 +\<close>
   10.23  
   10.24 -subsection {* Case analysis *}
   10.25 +subsection \<open>Case analysis\<close>
   10.26  
   10.27 -text {*
   10.28 +text \<open>
   10.29    Case analysis on natural numbers is rephrased using a conditional
   10.30    expression:
   10.31 -*}
   10.32 +\<close>
   10.33  
   10.34  lemma [code, code_unfold]:
   10.35    "case_nat = (\<lambda>f g n. if n = 0 then f else g (n - 1))"
   10.36    by (auto simp add: fun_eq_iff dest!: gr0_implies_Suc)
   10.37  
   10.38  
   10.39 -subsection {* Preprocessors *}
   10.40 +subsection \<open>Preprocessors\<close>
   10.41  
   10.42 -text {*
   10.43 +text \<open>
   10.44    The term @{term "Suc n"} is no longer a valid pattern.  Therefore,
   10.45    all occurrences of this term in a position where a pattern is
   10.46    expected (i.e.~on the left-hand side of a code equation) must be
   10.47    eliminated.  This can be accomplished -- as far as possible -- by
   10.48    applying the following transformation rule:
   10.49 -*}
   10.50 +\<close>
   10.51  
   10.52  lemma Suc_if_eq:
   10.53    assumes "\<And>n. f (Suc n) \<equiv> h n"
   10.54 @@ -44,12 +44,12 @@
   10.55    shows "f n \<equiv> if n = 0 then g else h (n - 1)"
   10.56    by (rule eq_reflection) (cases n, insert assms, simp_all)
   10.57  
   10.58 -text {*
   10.59 +text \<open>
   10.60    The rule above is built into a preprocessor that is plugged into
   10.61    the code generator.
   10.62 -*}
   10.63 +\<close>
   10.64  
   10.65 -setup {*
   10.66 +setup \<open>
   10.67  let
   10.68  
   10.69  val Suc_if_eq = Thm.incr_indexes 1 @{thm Suc_if_eq};
   10.70 @@ -111,6 +111,6 @@
   10.71    Code_Preproc.add_functrans ("eqn_Suc", eqn_suc_preproc)
   10.72  
   10.73  end;
   10.74 -*}
   10.75 +\<close>
   10.76  
   10.77  end
    11.1 --- a/src/HOL/Library/Code_Binary_Nat.thy	Wed Jun 17 17:33:22 2015 +0200
    11.2 +++ b/src/HOL/Library/Code_Binary_Nat.thy	Wed Jun 17 17:54:09 2015 +0200
    11.3 @@ -2,22 +2,22 @@
    11.4      Author:     Florian Haftmann, TU Muenchen
    11.5  *)
    11.6  
    11.7 -section {* Implementation of natural numbers as binary numerals *}
    11.8 +section \<open>Implementation of natural numbers as binary numerals\<close>
    11.9  
   11.10  theory Code_Binary_Nat
   11.11  imports Code_Abstract_Nat
   11.12  begin
   11.13  
   11.14 -text {*
   11.15 +text \<open>
   11.16    When generating code for functions on natural numbers, the
   11.17    canonical representation using @{term "0::nat"} and
   11.18    @{term Suc} is unsuitable for computations involving large
   11.19    numbers.  This theory refines the representation of
   11.20    natural numbers for code generation to use binary
   11.21    numerals, which do not grow linear in size but logarithmic.
   11.22 -*}
   11.23 +\<close>
   11.24  
   11.25 -subsection {* Representation *}
   11.26 +subsection \<open>Representation\<close>
   11.27  
   11.28  code_datatype "0::nat" nat_of_num
   11.29  
   11.30 @@ -38,7 +38,7 @@
   11.31    by simp
   11.32  
   11.33  
   11.34 -subsection {* Basic arithmetic *}
   11.35 +subsection \<open>Basic arithmetic\<close>
   11.36  
   11.37  lemma [code, code del]:
   11.38    "(plus :: nat \<Rightarrow> _) = plus" ..
   11.39 @@ -49,7 +49,7 @@
   11.40    "0 + n = (n::nat)"
   11.41    by (simp_all add: nat_of_num_numeral)
   11.42  
   11.43 -text {* Bounded subtraction needs some auxiliary *}
   11.44 +text \<open>Bounded subtraction needs some auxiliary\<close>
   11.45  
   11.46  definition dup :: "nat \<Rightarrow> nat" where
   11.47    "dup n = n + n"
   11.48 @@ -140,7 +140,7 @@
   11.49    by (simp_all add: prod_eq_iff nat_of_num_numeral del: div_nat_numeral mod_nat_numeral)
   11.50  
   11.51  
   11.52 -subsection {* Conversions *}
   11.53 +subsection \<open>Conversions\<close>
   11.54  
   11.55  lemma [code, code del]:
   11.56    "of_nat = of_nat" ..
    12.1 --- a/src/HOL/Library/Code_Char.thy	Wed Jun 17 17:33:22 2015 +0200
    12.2 +++ b/src/HOL/Library/Code_Char.thy	Wed Jun 17 17:54:09 2015 +0200
    12.3 @@ -2,7 +2,7 @@
    12.4      Author:     Florian Haftmann
    12.5  *)
    12.6  
    12.7 -section {* Code generation of pretty characters (and strings) *}
    12.8 +section \<open>Code generation of pretty characters (and strings)\<close>
    12.9  
   12.10  theory Code_Char
   12.11  imports Main Char_ord
   12.12 @@ -15,10 +15,10 @@
   12.13      and (Haskell) "Prelude.Char"
   12.14      and (Scala) "Char"
   12.15  
   12.16 -setup {*
   12.17 +setup \<open>
   12.18    fold String_Code.add_literal_char ["SML", "OCaml", "Haskell", "Scala"] 
   12.19    #> String_Code.add_literal_list_string "Haskell"
   12.20 -*}
   12.21 +\<close>
   12.22  
   12.23  code_printing
   12.24    class_instance char :: equal \<rightharpoonup>
   12.25 @@ -107,9 +107,9 @@
   12.26  |  constant "Orderings.less_eq :: String.literal \<Rightarrow> String.literal \<Rightarrow> bool" \<rightharpoonup>
   12.27      (SML) "!((_ : string) <= _)"
   12.28      and (OCaml) "!((_ : string) <= _)"
   12.29 -    -- {* Order operations for @{typ String.literal} work in Haskell only 
   12.30 +    -- \<open>Order operations for @{typ String.literal} work in Haskell only 
   12.31            if no type class instance needs to be generated, because String = [Char] in Haskell
   12.32 -          and @{typ "char list"} need not have the same order as @{typ String.literal}. *}
   12.33 +          and @{typ "char list"} need not have the same order as @{typ String.literal}.\<close>
   12.34      and (Haskell) infix 4 "<="
   12.35      and (Scala) infixl 4 "<="
   12.36      and (Eval) infixl 6 "<="
    13.1 --- a/src/HOL/Library/Code_Prolog.thy	Wed Jun 17 17:33:22 2015 +0200
    13.2 +++ b/src/HOL/Library/Code_Prolog.thy	Wed Jun 17 17:54:09 2015 +0200
    13.3 @@ -2,7 +2,7 @@
    13.4      Author:     Lukas Bulwahn, TUM 2010
    13.5  *)
    13.6  
    13.7 -section {* Code generation of prolog programs *}
    13.8 +section \<open>Code generation of prolog programs\<close>
    13.9  
   13.10  theory Code_Prolog
   13.11  imports Main
   13.12 @@ -11,10 +11,10 @@
   13.13  
   13.14  ML_file "~~/src/HOL/Tools/Predicate_Compile/code_prolog.ML"
   13.15  
   13.16 -section {* Setup for Numerals *}
   13.17 +section \<open>Setup for Numerals\<close>
   13.18  
   13.19 -setup {* Predicate_Compile_Data.ignore_consts [@{const_name numeral}] *}
   13.20 +setup \<open>Predicate_Compile_Data.ignore_consts [@{const_name numeral}]\<close>
   13.21  
   13.22 -setup {* Predicate_Compile_Data.keep_functions [@{const_name numeral}] *}
   13.23 +setup \<open>Predicate_Compile_Data.keep_functions [@{const_name numeral}]\<close>
   13.24  
   13.25  end
    14.1 --- a/src/HOL/Library/Code_Real_Approx_By_Float.thy	Wed Jun 17 17:33:22 2015 +0200
    14.2 +++ b/src/HOL/Library/Code_Real_Approx_By_Float.thy	Wed Jun 17 17:54:09 2015 +0200
    14.3 @@ -4,7 +4,7 @@
    14.4  imports Complex_Main Code_Target_Int
    14.5  begin
    14.6  
    14.7 -text{* \textbf{WARNING} This theory implements mathematical reals by machine
    14.8 +text\<open>\textbf{WARNING} This theory implements mathematical reals by machine
    14.9  reals (floats). This is inconsistent. See the proof of False at the end of
   14.10  the theory, where an equality on mathematical reals is (incorrectly)
   14.11  disproved by mapping it to machine reals.
   14.12 @@ -12,7 +12,7 @@
   14.13  The value command cannot display real results yet.
   14.14  
   14.15  The only legitimate use of this theory is as a tool for code generation
   14.16 -purposes. *}
   14.17 +purposes.\<close>
   14.18  
   14.19  code_printing
   14.20    type_constructor real \<rightharpoonup>
    15.1 --- a/src/HOL/Library/Code_Target_Int.thy	Wed Jun 17 17:33:22 2015 +0200
    15.2 +++ b/src/HOL/Library/Code_Target_Int.thy	Wed Jun 17 17:54:09 2015 +0200
    15.3 @@ -2,7 +2,7 @@
    15.4      Author:     Florian Haftmann, TU Muenchen
    15.5  *)
    15.6  
    15.7 -section {* Implementation of integer numbers by target-language integers *}
    15.8 +section \<open>Implementation of integer numbers by target-language integers\<close>
    15.9  
   15.10  theory Code_Target_Int
   15.11  imports Main
    16.1 --- a/src/HOL/Library/Code_Target_Nat.thy	Wed Jun 17 17:33:22 2015 +0200
    16.2 +++ b/src/HOL/Library/Code_Target_Nat.thy	Wed Jun 17 17:54:09 2015 +0200
    16.3 @@ -2,13 +2,13 @@
    16.4      Author:     Florian Haftmann, TU Muenchen
    16.5  *)
    16.6  
    16.7 -section {* Implementation of natural numbers by target-language integers *}
    16.8 +section \<open>Implementation of natural numbers by target-language integers\<close>
    16.9  
   16.10  theory Code_Target_Nat
   16.11  imports Code_Abstract_Nat
   16.12  begin
   16.13  
   16.14 -subsection {* Implementation for @{typ nat} *}
   16.15 +subsection \<open>Implementation for @{typ nat}\<close>
   16.16  
   16.17  context
   16.18  includes natural.lifting integer.lifting
   16.19 @@ -129,9 +129,9 @@
   16.20    including integer.lifting by transfer auto
   16.21  
   16.22  lemma term_of_nat_code [code]:
   16.23 -  -- {* Use @{term Code_Numeral.nat_of_integer} in term reconstruction
   16.24 +  -- \<open>Use @{term Code_Numeral.nat_of_integer} in term reconstruction
   16.25          instead of @{term Code_Target_Nat.Nat} such that reconstructed
   16.26 -        terms can be fed back to the code generator *}
   16.27 +        terms can be fed back to the code generator\<close>
   16.28    "term_of_class.term_of n =
   16.29     Code_Evaluation.App
   16.30       (Code_Evaluation.Const (STR ''Code_Numeral.nat_of_integer'')
    17.1 --- a/src/HOL/Library/Code_Target_Numeral.thy	Wed Jun 17 17:33:22 2015 +0200
    17.2 +++ b/src/HOL/Library/Code_Target_Numeral.thy	Wed Jun 17 17:54:09 2015 +0200
    17.3 @@ -2,7 +2,7 @@
    17.4      Author:     Florian Haftmann, TU Muenchen
    17.5  *)
    17.6  
    17.7 -section {* Implementation of natural and integer numbers by target-language integers *}
    17.8 +section \<open>Implementation of natural and integer numbers by target-language integers\<close>
    17.9  
   17.10  theory Code_Target_Numeral
   17.11  imports Code_Target_Int Code_Target_Nat
    18.1 --- a/src/HOL/Library/Code_Test.thy	Wed Jun 17 17:33:22 2015 +0200
    18.2 +++ b/src/HOL/Library/Code_Test.thy	Wed Jun 17 17:54:09 2015 +0200
    18.3 @@ -9,7 +9,7 @@
    18.4  keywords "test_code" :: diag
    18.5  begin
    18.6  
    18.7 -subsection {* YXML encoding for @{typ Code_Evaluation.term} *}
    18.8 +subsection \<open>YXML encoding for @{typ Code_Evaluation.term}\<close>
    18.9  
   18.10  datatype (plugins del: code size "quickcheck") yxml_of_term = YXML
   18.11  
   18.12 @@ -24,7 +24,7 @@
   18.13  definition yot_concat :: "yxml_of_term list \<Rightarrow> yxml_of_term"
   18.14    where [code del]: "yot_concat _ = YXML"
   18.15  
   18.16 -text {* Serialise @{typ yxml_of_term} to native string of target language *}
   18.17 +text \<open>Serialise @{typ yxml_of_term} to native string of target language\<close>
   18.18  
   18.19  code_printing type_constructor yxml_of_term
   18.20    \<rightharpoonup>  (SML) "string"
   18.21 @@ -52,11 +52,11 @@
   18.22    and (Haskell) "Prelude.concat"
   18.23    and (Scala) "_.mkString(\"\")"
   18.24  
   18.25 -text {*
   18.26 +text \<open>
   18.27    Stripped-down implementations of Isabelle's XML tree with YXML encoding
   18.28    as defined in @{file "~~/src/Pure/PIDE/xml.ML"}, @{file "~~/src/Pure/PIDE/yxml.ML"}
   18.29    sufficient to encode @{typ "Code_Evaluation.term"} as in @{file "~~/src/Pure/term_xml.ML"}.
   18.30 -*}
   18.31 +\<close>
   18.32  
   18.33  datatype (plugins del: code size "quickcheck") xml_tree = XML_Tree
   18.34  
   18.35 @@ -64,7 +64,7 @@
   18.36  by(cases x y rule: xml_tree.exhaust[case_product xml_tree.exhaust])(simp)
   18.37  
   18.38  context begin
   18.39 -local_setup {* Local_Theory.map_background_naming (Name_Space.mandatory_path "xml") *}
   18.40 +local_setup \<open>Local_Theory.map_background_naming (Name_Space.mandatory_path "xml")\<close>
   18.41  
   18.42  type_synonym attributes = "(String.literal \<times> String.literal) list"
   18.43  type_synonym body = "xml_tree list"
   18.44 @@ -112,10 +112,10 @@
   18.45  definition yxml_string_of_body :: "xml.body \<Rightarrow> yxml_of_term"
   18.46  where "yxml_string_of_body ts = foldr yxml_string_of_xml_tree ts yot_empty"
   18.47  
   18.48 -text {*
   18.49 +text \<open>
   18.50    Encoding @{typ Code_Evaluation.term} into XML trees
   18.51    as defined in @{file "~~/src/Pure/term_xml.ML"}
   18.52 -*}
   18.53 +\<close>
   18.54  
   18.55  definition xml_of_typ :: "Typerep.typerep \<Rightarrow> xml.body"
   18.56  where [code del]: "xml_of_typ _ = [XML_Tree]"
   18.57 @@ -131,17 +131,17 @@
   18.58    "xml_of_term (Code_Evaluation.Const x ty) = [xml.tagged (STR ''0'') (Some x) (xml_of_typ ty)]"
   18.59    "xml_of_term (Code_Evaluation.App t1 t2)  = [xml.tagged (STR ''5'') None [xml.node (xml_of_term t1), xml.node (xml_of_term t2)]]"
   18.60    "xml_of_term (Code_Evaluation.Abs x ty t) = [xml.tagged (STR ''4'') (Some x) [xml.node (xml_of_typ ty), xml.node (xml_of_term t)]]"
   18.61 -  -- {*
   18.62 +  -- \<open>
   18.63      FIXME: @{const Code_Evaluation.Free} is used only in @{theory Quickcheck_Narrowing} to represent
   18.64      uninstantiated parameters in constructors. Here, we always translate them to @{ML Free} variables.
   18.65 -  *}
   18.66 +\<close>
   18.67    "xml_of_term (Code_Evaluation.Free x ty)  = [xml.tagged (STR ''1'') (Some x) (xml_of_typ ty)]"
   18.68  by(simp_all add: xml_of_term_def xml_tree_anything)
   18.69  
   18.70  definition yxml_string_of_term :: "Code_Evaluation.term \<Rightarrow> yxml_of_term"
   18.71  where "yxml_string_of_term = yxml_string_of_body \<circ> xml_of_term"
   18.72  
   18.73 -subsection {* Test engine and drivers *}
   18.74 +subsection \<open>Test engine and drivers\<close>
   18.75  
   18.76  ML_file "code_test.ML"
   18.77  
    19.1 --- a/src/HOL/Library/ContNotDenum.thy	Wed Jun 17 17:33:22 2015 +0200
    19.2 +++ b/src/HOL/Library/ContNotDenum.thy	Wed Jun 17 17:54:09 2015 +0200
    19.3 @@ -3,15 +3,15 @@
    19.4      Author:     Johannes Hölzl, TU München
    19.5  *)
    19.6  
    19.7 -section {* Non-denumerability of the Continuum. *}
    19.8 +section \<open>Non-denumerability of the Continuum.\<close>
    19.9  
   19.10  theory ContNotDenum
   19.11  imports Complex_Main Countable_Set
   19.12  begin
   19.13  
   19.14 -subsection {* Abstract *}
   19.15 +subsection \<open>Abstract\<close>
   19.16  
   19.17 -text {* The following document presents a proof that the Continuum is
   19.18 +text \<open>The following document presents a proof that the Continuum is
   19.19  uncountable. It is formalised in the Isabelle/Isar theorem proving
   19.20  system.
   19.21  
   19.22 @@ -28,14 +28,14 @@
   19.23  closed intervals (where each successive interval is a subset of the
   19.24  last) is non-empty. We then assume a surjective function @{text
   19.25  "f: \<nat> \<Rightarrow> \<real>"} exists and find a real x such that x is not in the range of f
   19.26 -by generating a sequence of closed intervals then using the NIP. *}
   19.27 +by generating a sequence of closed intervals then using the NIP.\<close>
   19.28  
   19.29  theorem real_non_denum: "\<not> (\<exists>f :: nat \<Rightarrow> real. surj f)"
   19.30  proof
   19.31    assume "\<exists>f::nat \<Rightarrow> real. surj f"
   19.32    then obtain f :: "nat \<Rightarrow> real" where "surj f" ..
   19.33  
   19.34 -  txt {* First we construct a sequence of nested intervals, ignoring @{term "range f"}. *}
   19.35 +  txt \<open>First we construct a sequence of nested intervals, ignoring @{term "range f"}.\<close>
   19.36  
   19.37    have "\<forall>a b c::real. a < b \<longrightarrow> (\<exists>ka kb. ka < kb \<and> {ka..kb} \<subseteq> {a..b} \<and> c \<notin> {ka..kb})"
   19.38      using assms
   19.39 @@ -55,7 +55,7 @@
   19.40      "\<And>n. ivl (Suc n) = (i (fst (ivl n)) (snd (ivl n)) (f n), j (fst (ivl n)) (snd (ivl n)) (f n))"
   19.41      unfolding ivl_def by simp_all
   19.42  
   19.43 -  txt {* This is a decreasing sequence of non-empty intervals. *}
   19.44 +  txt \<open>This is a decreasing sequence of non-empty intervals.\<close>
   19.45  
   19.46    { fix n have "fst (ivl n) < snd (ivl n)"
   19.47        by (induct n) (auto intro!: ij) }
   19.48 @@ -64,7 +64,7 @@
   19.49    have "decseq I"
   19.50      unfolding I_def decseq_Suc_iff ivl fst_conv snd_conv by (intro ij allI less)
   19.51  
   19.52 -  txt {* Now we apply the finite intersection property of compact sets. *}
   19.53 +  txt \<open>Now we apply the finite intersection property of compact sets.\<close>
   19.54  
   19.55    have "I 0 \<inter> (\<Inter>i. I i) \<noteq> {}"
   19.56    proof (rule compact_imp_fip_image)
   19.57 @@ -72,7 +72,7 @@
   19.58      have "{} \<subset> I (Max (insert 0 S))"
   19.59        unfolding I_def using less[of "Max (insert 0 S)"] by auto
   19.60      also have "I (Max (insert 0 S)) \<subseteq> (\<Inter>i\<in>insert 0 S. I i)"
   19.61 -      using fin decseqD[OF `decseq I`, of _ "Max (insert 0 S)"] by (auto simp: Max_ge_iff)
   19.62 +      using fin decseqD[OF \<open>decseq I\<close>, of _ "Max (insert 0 S)"] by (auto simp: Max_ge_iff)
   19.63      also have "(\<Inter>i\<in>insert 0 S. I i) = I 0 \<inter> (\<Inter>i\<in>S. I i)"
   19.64        by auto
   19.65      finally show "I 0 \<inter> (\<Inter>i\<in>S. I i) \<noteq> {}"
   19.66 @@ -80,7 +80,7 @@
   19.67    qed (auto simp: I_def)
   19.68    then obtain x where "\<And>n. x \<in> I n"
   19.69      by blast
   19.70 -  moreover from `surj f` obtain j where "x = f j"
   19.71 +  moreover from \<open>surj f\<close> obtain j where "x = f j"
   19.72      by blast
   19.73    ultimately have "f j \<in> I (Suc j)"
   19.74      by blast
   19.75 @@ -124,7 +124,7 @@
   19.76    show "uncountable {a<..<b}"
   19.77    proof -
   19.78      obtain f where "bij_betw f {a <..< b} {-pi/2<..<pi/2}"
   19.79 -      using bij_betw_open_intervals[OF `a < b`, of "-pi/2" "pi/2"] by auto
   19.80 +      using bij_betw_open_intervals[OF \<open>a < b\<close>, of "-pi/2" "pi/2"] by auto
   19.81      then show ?thesis
   19.82        by (metis bij_betw_tan uncountable_bij_betw uncountable_UNIV_real)
   19.83    qed
    20.1 --- a/src/HOL/Library/Countable.thy	Wed Jun 17 17:33:22 2015 +0200
    20.2 +++ b/src/HOL/Library/Countable.thy	Wed Jun 17 17:54:09 2015 +0200
    20.3 @@ -4,13 +4,13 @@
    20.4      Author:     Jasmin Blanchette, TU Muenchen
    20.5  *)
    20.6  
    20.7 -section {* Encoding (almost) everything into natural numbers *}
    20.8 +section \<open>Encoding (almost) everything into natural numbers\<close>
    20.9  
   20.10  theory Countable
   20.11  imports Old_Datatype Rat Nat_Bijection
   20.12  begin
   20.13  
   20.14 -subsection {* The class of countable types *}
   20.15 +subsection \<open>The class of countable types\<close>
   20.16  
   20.17  class countable =
   20.18    assumes ex_inj: "\<exists>to_nat \<Colon> 'a \<Rightarrow> nat. inj to_nat"
   20.19 @@ -25,7 +25,7 @@
   20.20  qed
   20.21  
   20.22  
   20.23 -subsection {* Conversion functions *}
   20.24 +subsection \<open>Conversion functions\<close>
   20.25  
   20.26  definition to_nat :: "'a\<Colon>countable \<Rightarrow> nat" where
   20.27    "to_nat = (SOME f. inj f)"
   20.28 @@ -50,7 +50,7 @@
   20.29    by (simp add: from_nat_def)
   20.30  
   20.31  
   20.32 -subsection {* Finite types are countable *}
   20.33 +subsection \<open>Finite types are countable\<close>
   20.34  
   20.35  subclass (in finite) countable
   20.36  proof
   20.37 @@ -64,7 +64,7 @@
   20.38  qed
   20.39  
   20.40  
   20.41 -subsection {* Automatically proving countability of old-style datatypes *}
   20.42 +subsection \<open>Automatically proving countability of old-style datatypes\<close>
   20.43  
   20.44  inductive finite_item :: "'a Old_Datatype.item \<Rightarrow> bool" where
   20.45    undefined: "finite_item undefined"
   20.46 @@ -160,7 +160,7 @@
   20.47      by - (rule exI)
   20.48  qed
   20.49  
   20.50 -ML {*
   20.51 +ML \<open>
   20.52    fun old_countable_datatype_tac ctxt =
   20.53      SUBGOAL (fn (goal, _) =>
   20.54        let
   20.55 @@ -191,16 +191,16 @@
   20.56             etac induct_thm' i,
   20.57             REPEAT (resolve_tac ctxt rules i ORELSE atac i)]) 1
   20.58        end)
   20.59 -*}
   20.60 +\<close>
   20.61  
   20.62  hide_const (open) finite_item nth_item
   20.63  
   20.64  
   20.65 -subsection {* Automatically proving countability of datatypes *}
   20.66 +subsection \<open>Automatically proving countability of datatypes\<close>
   20.67  
   20.68  ML_file "bnf_lfp_countable.ML"
   20.69  
   20.70 -ML {*
   20.71 +ML \<open>
   20.72  fun countable_datatype_tac ctxt st =
   20.73    (case try (fn () => HEADGOAL (old_countable_datatype_tac ctxt) st) () of
   20.74      SOME res => res
   20.75 @@ -209,54 +209,54 @@
   20.76  (* compatibility *)
   20.77  fun countable_tac ctxt =
   20.78    SELECT_GOAL (countable_datatype_tac ctxt);
   20.79 -*}
   20.80 +\<close>
   20.81  
   20.82 -method_setup countable_datatype = {*
   20.83 +method_setup countable_datatype = \<open>
   20.84    Scan.succeed (SIMPLE_METHOD o countable_datatype_tac)
   20.85 -*} "prove countable class instances for datatypes"
   20.86 +\<close> "prove countable class instances for datatypes"
   20.87  
   20.88  
   20.89 -subsection {* More Countable types *}
   20.90 +subsection \<open>More Countable types\<close>
   20.91  
   20.92 -text {* Naturals *}
   20.93 +text \<open>Naturals\<close>
   20.94  
   20.95  instance nat :: countable
   20.96    by (rule countable_classI [of "id"]) simp
   20.97  
   20.98 -text {* Pairs *}
   20.99 +text \<open>Pairs\<close>
  20.100  
  20.101  instance prod :: (countable, countable) countable
  20.102    by (rule countable_classI [of "\<lambda>(x, y). prod_encode (to_nat x, to_nat y)"])
  20.103      (auto simp add: prod_encode_eq)
  20.104  
  20.105 -text {* Sums *}
  20.106 +text \<open>Sums\<close>
  20.107  
  20.108  instance sum :: (countable, countable) countable
  20.109    by (rule countable_classI [of "(\<lambda>x. case x of Inl a \<Rightarrow> to_nat (False, to_nat a)
  20.110                                       | Inr b \<Rightarrow> to_nat (True, to_nat b))"])
  20.111      (simp split: sum.split_asm)
  20.112  
  20.113 -text {* Integers *}
  20.114 +text \<open>Integers\<close>
  20.115  
  20.116  instance int :: countable
  20.117    by (rule countable_classI [of int_encode]) (simp add: int_encode_eq)
  20.118  
  20.119 -text {* Options *}
  20.120 +text \<open>Options\<close>
  20.121  
  20.122  instance option :: (countable) countable
  20.123    by countable_datatype
  20.124  
  20.125 -text {* Lists *}
  20.126 +text \<open>Lists\<close>
  20.127  
  20.128  instance list :: (countable) countable
  20.129    by countable_datatype
  20.130  
  20.131 -text {* String literals *}
  20.132 +text \<open>String literals\<close>
  20.133  
  20.134  instance String.literal :: countable
  20.135    by (rule countable_classI [of "to_nat \<circ> String.explode"]) (auto simp add: explode_inject)
  20.136  
  20.137 -text {* Functions *}
  20.138 +text \<open>Functions\<close>
  20.139  
  20.140  instance "fun" :: (finite, countable) countable
  20.141  proof
  20.142 @@ -269,13 +269,13 @@
  20.143    qed
  20.144  qed
  20.145  
  20.146 -text {* Typereps *}
  20.147 +text \<open>Typereps\<close>
  20.148  
  20.149  instance typerep :: countable
  20.150    by countable_datatype
  20.151  
  20.152  
  20.153 -subsection {* The rationals are countably infinite *}
  20.154 +subsection \<open>The rationals are countably infinite\<close>
  20.155  
  20.156  definition nat_to_rat_surj :: "nat \<Rightarrow> rat" where
  20.157    "nat_to_rat_surj n = (let (a, b) = prod_decode n in Fract (int_decode a) (int_decode b))"
    21.1 --- a/src/HOL/Library/Countable_Set.thy	Wed Jun 17 17:33:22 2015 +0200
    21.2 +++ b/src/HOL/Library/Countable_Set.thy	Wed Jun 17 17:54:09 2015 +0200
    21.3 @@ -3,13 +3,13 @@
    21.4      Author:     Andrei Popescu
    21.5  *)
    21.6  
    21.7 -section {* Countable sets *}
    21.8 +section \<open>Countable sets\<close>
    21.9  
   21.10  theory Countable_Set
   21.11  imports Countable Infinite_Set
   21.12  begin
   21.13  
   21.14 -subsection {* Predicate for countable sets *}
   21.15 +subsection \<open>Predicate for countable sets\<close>
   21.16  
   21.17  definition countable :: "'a set \<Rightarrow> bool" where
   21.18    "countable S \<longleftrightarrow> (\<exists>f::'a \<Rightarrow> nat. inj_on f S)"
   21.19 @@ -49,18 +49,18 @@
   21.20  lemma countableI_type[intro, simp]: "countable (A:: 'a :: countable set)"
   21.21    using countableI[of to_nat A] by auto
   21.22  
   21.23 -subsection {* Enumerate a countable set *}
   21.24 +subsection \<open>Enumerate a countable set\<close>
   21.25  
   21.26  lemma countableE_infinite:
   21.27    assumes "countable S" "infinite S"
   21.28    obtains e :: "'a \<Rightarrow> nat" where "bij_betw e S UNIV"
   21.29  proof -
   21.30    obtain f :: "'a \<Rightarrow> nat" where "inj_on f S"
   21.31 -    using `countable S` by (rule countableE)
   21.32 +    using \<open>countable S\<close> by (rule countableE)
   21.33    then have "bij_betw f S (f`S)"
   21.34      unfolding bij_betw_def by simp
   21.35    moreover
   21.36 -  from `inj_on f S` `infinite S` have inf_fS: "infinite (f`S)"
   21.37 +  from \<open>inj_on f S\<close> \<open>infinite S\<close> have inf_fS: "infinite (f`S)"
   21.38      by (auto dest: finite_imageD)
   21.39    then have "bij_betw (the_inv_into UNIV (enumerate (f`S))) (f`S) UNIV"
   21.40      by (intro bij_betw_the_inv_into bij_enumerate)
   21.41 @@ -73,7 +73,7 @@
   21.42    assumes "countable S"
   21.43    obtains (finite) f :: "'a \<Rightarrow> nat" where "finite S" "bij_betw f S {..<card S}"
   21.44          | (infinite) f :: "'a \<Rightarrow> nat" where "infinite S" "bij_betw f S UNIV"
   21.45 -  using ex_bij_betw_finite_nat[of S] countableE_infinite `countable S`
   21.46 +  using ex_bij_betw_finite_nat[of S] countableE_infinite \<open>countable S\<close>
   21.47    by (cases "finite S") (auto simp add: atLeast0LessThan)
   21.48  
   21.49  definition to_nat_on :: "'a set \<Rightarrow> 'a \<Rightarrow> nat" where
   21.50 @@ -164,7 +164,7 @@
   21.51  lemma inj_on_from_nat_into: "inj_on from_nat_into ({A. A \<noteq> {} \<and> countable A})"
   21.52    unfolding inj_on_def by auto
   21.53  
   21.54 -subsection {* Closure properties of countability *}
   21.55 +subsection \<open>Closure properties of countability\<close>
   21.56  
   21.57  lemma countable_SIGMA[intro, simp]:
   21.58    "countable I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> countable (A i)) \<Longrightarrow> countable (SIGMA i : I. A i)"
   21.59 @@ -292,7 +292,7 @@
   21.60  lemma countable_set_option [simp]: "countable (set_option x)"
   21.61  by(cases x) auto
   21.62  
   21.63 -subsection {* Misc lemmas *}
   21.64 +subsection \<open>Misc lemmas\<close>
   21.65  
   21.66  lemma countable_all:
   21.67    assumes S: "countable S"
   21.68 @@ -306,13 +306,13 @@
   21.69      apply (auto simp: image_iff Ball_def intro: from_nat_into split: split_if_asm)
   21.70    proof -
   21.71      fix x n assume "x \<in> X" "\<forall>i m. m \<le> i \<longrightarrow> x \<noteq> from_nat_into X m"
   21.72 -    with from_nat_into_surj[OF `countable X` `x \<in> X`]
   21.73 +    with from_nat_into_surj[OF \<open>countable X\<close> \<open>x \<in> X\<close>]
   21.74      show False
   21.75        by auto
   21.76    qed
   21.77  qed
   21.78  
   21.79 -subsection {* Uncountable *}
   21.80 +subsection \<open>Uncountable\<close>
   21.81  
   21.82  abbreviation uncountable where
   21.83    "uncountable A \<equiv> \<not> countable A"
    22.1 --- a/src/HOL/Library/Countable_Set_Type.thy	Wed Jun 17 17:33:22 2015 +0200
    22.2 +++ b/src/HOL/Library/Countable_Set_Type.thy	Wed Jun 17 17:54:09 2015 +0200
    22.3 @@ -6,14 +6,14 @@
    22.4  Type of (at most) countable sets.
    22.5  *)
    22.6  
    22.7 -section {* Type of (at Most) Countable Sets *}
    22.8 +section \<open>Type of (at Most) Countable Sets\<close>
    22.9  
   22.10  theory Countable_Set_Type
   22.11  imports Countable_Set Cardinal_Notations Conditionally_Complete_Lattices
   22.12  begin
   22.13  
   22.14  
   22.15 -subsection{* Cardinal stuff *}
   22.16 +subsection\<open>Cardinal stuff\<close>
   22.17  
   22.18  lemma countable_card_of_nat: "countable A \<longleftrightarrow> |A| \<le>o |UNIV::nat set|"
   22.19    unfolding countable_def card_of_ordLeq[symmetric] by auto
   22.20 @@ -54,7 +54,7 @@
   22.21  shows "countable A"
   22.22  using countable_ordLeq[OF ordLess_imp_ordLeq[OF AB] B] .
   22.23  
   22.24 -subsection {* The type of countable sets *}
   22.25 +subsection \<open>The type of countable sets\<close>
   22.26  
   22.27  typedef 'a cset = "{A :: 'a set. countable A}" morphisms rcset acset
   22.28    by (rule exI[of _ "{}"]) simp
   22.29 @@ -366,13 +366,13 @@
   22.30  lemmas cimage_cUN = image_UN[Transfer.transferred]
   22.31  lemmas cUN_csingleton [simp] = UN_singleton[Transfer.transferred]
   22.32  
   22.33 -subsection {* Additional lemmas*}
   22.34 +subsection \<open>Additional lemmas\<close>
   22.35  
   22.36 -subsubsection {* @{text cempty} *}
   22.37 +subsubsection \<open>@{text cempty}\<close>
   22.38  
   22.39  lemma cemptyE [elim!]: "cin a cempty \<Longrightarrow> P" by simp
   22.40  
   22.41 -subsubsection {* @{text cinsert} *}
   22.42 +subsubsection \<open>@{text cinsert}\<close>
   22.43  
   22.44  lemma countable_insert_iff: "countable (insert x A) \<longleftrightarrow> countable A"
   22.45  by (metis Diff_eq_empty_iff countable_empty countable_insert subset_insertI uncountable_minus_countable)
   22.46 @@ -385,12 +385,12 @@
   22.47  lemma mk_disjoint_cinsert: "cin a A \<Longrightarrow> \<exists>B. A = cinsert a B \<and> \<not> cin a B"
   22.48    by (rule exI[where x = "cDiff A (csingle a)"]) blast
   22.49  
   22.50 -subsubsection {* @{text cimage} *}
   22.51 +subsubsection \<open>@{text cimage}\<close>
   22.52  
   22.53  lemma subset_cimage_iff: "csubset_eq B (cimage f A) \<longleftrightarrow> (\<exists>AA. csubset_eq AA A \<and> B = cimage f AA)"
   22.54  by transfer (metis countable_subset image_mono mem_Collect_eq subset_imageE) 
   22.55  
   22.56 -subsubsection {* bounded quantification *}
   22.57 +subsubsection \<open>bounded quantification\<close>
   22.58  
   22.59  lemma cBex_simps [simp, no_atp]:
   22.60    "\<And>A P Q. cBex A (\<lambda>x. P x \<and> Q) = (cBex A P \<and> Q)" 
   22.61 @@ -418,15 +418,15 @@
   22.62  apply (rule equal_intr_rule)
   22.63  by (transfer, simp)+
   22.64  
   22.65 -subsubsection {* @{const cUnion} *}
   22.66 +subsubsection \<open>@{const cUnion}\<close>
   22.67  
   22.68  lemma cUNION_cimage: "cUNION (cimage f A) g = cUNION A (g \<circ> f)"
   22.69  including cset.lifting by transfer auto
   22.70  
   22.71  
   22.72 -subsection {* Setup for Lifting/Transfer *}
   22.73 +subsection \<open>Setup for Lifting/Transfer\<close>
   22.74  
   22.75 -subsubsection {* Relator and predicator properties *}
   22.76 +subsubsection \<open>Relator and predicator properties\<close>
   22.77  
   22.78  lift_definition rel_cset :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a cset \<Rightarrow> 'b cset \<Rightarrow> bool"
   22.79    is rel_set parametric rel_set_transfer .
   22.80 @@ -451,9 +451,9 @@
   22.81  lemma rel_cset_csingle_iff [simp]: "rel_cset R (csingle x) (csingle y) \<longleftrightarrow> R x y"
   22.82  by transfer(auto simp add: rel_set_def)
   22.83  
   22.84 -subsubsection {* Transfer rules for the Transfer package *}
   22.85 +subsubsection \<open>Transfer rules for the Transfer package\<close>
   22.86  
   22.87 -text {* Unconditional transfer rules *}
   22.88 +text \<open>Unconditional transfer rules\<close>
   22.89  
   22.90  context begin interpretation lifting_syntax .
   22.91  
   22.92 @@ -489,7 +489,7 @@
   22.93    using rel_set_transfer[unfolded rel_fun_def, rule_format, Transfer.transferred, where A = A and B = B]
   22.94    by simp
   22.95  
   22.96 -text {* Rules requiring bi-unique, bi-total or right-total relations *}
   22.97 +text \<open>Rules requiring bi-unique, bi-total or right-total relations\<close>
   22.98  
   22.99  lemma cin_parametric [transfer_rule]:
  22.100    "bi_unique A \<Longrightarrow> (A ===> rel_cset A ===> op =) cin cin"
  22.101 @@ -516,7 +516,7 @@
  22.102  lifting_update cset.lifting
  22.103  lifting_forget cset.lifting
  22.104  
  22.105 -subsection {* Registration as BNF *}
  22.106 +subsection \<open>Registration as BNF\<close>
  22.107  
  22.108  lemma card_of_countable_sets_range:
  22.109  fixes A :: "'a set"
  22.110 @@ -568,8 +568,8 @@
  22.111    hence *: "rcset R' = ?L'" unfolding R'_def by (intro rcset_to_rcset)
  22.112    thus ?R unfolding Grp_def relcompp.simps conversep.simps including cset.lifting
  22.113    proof (intro CollectI case_prodI exI[of _ a] exI[of _ b] exI[of _ R'] conjI refl)
  22.114 -    from * `?L` show "a = cimage fst R'" by transfer (auto simp: image_def Collect_Int_Times)
  22.115 -    from * `?L` show "b = cimage snd R'" by transfer (auto simp: image_def Collect_Int_Times)
  22.116 +    from * \<open>?L\<close> show "a = cimage fst R'" by transfer (auto simp: image_def Collect_Int_Times)
  22.117 +    from * \<open>?L\<close> show "b = cimage snd R'" by transfer (auto simp: image_def Collect_Int_Times)
  22.118    qed simp_all
  22.119  next
  22.120    assume ?R thus ?L unfolding Grp_def relcompp.simps conversep.simps
    23.1 --- a/src/HOL/Library/Debug.thy	Wed Jun 17 17:33:22 2015 +0200
    23.2 +++ b/src/HOL/Library/Debug.thy	Wed Jun 17 17:54:09 2015 +0200
    23.3 @@ -1,6 +1,6 @@
    23.4  (* Author: Florian Haftmann, TU Muenchen *)
    23.5  
    23.6 -section {* Debugging facilities for code generated towards Isabelle/ML *}
    23.7 +section \<open>Debugging facilities for code generated towards Isabelle/ML\<close>
    23.8  
    23.9  theory Debug
   23.10  imports Main
   23.11 @@ -31,7 +31,7 @@
   23.12  
   23.13  code_printing
   23.14    constant trace \<rightharpoonup> (Eval) "Output.tracing"
   23.15 -| constant flush \<rightharpoonup> (Eval) "Output.tracing/ (@{make'_string} _)" -- {* note indirection via antiquotation *}
   23.16 +| constant flush \<rightharpoonup> (Eval) "Output.tracing/ (@{make'_string} _)" -- \<open>note indirection via antiquotation\<close>
   23.17  | constant timing \<rightharpoonup> (Eval) "Timing.timeap'_msg"
   23.18  
   23.19  code_reserved Eval Output Timing
    24.1 --- a/src/HOL/Library/Diagonal_Subsequence.thy	Wed Jun 17 17:33:22 2015 +0200
    24.2 +++ b/src/HOL/Library/Diagonal_Subsequence.thy	Wed Jun 17 17:54:09 2015 +0200
    24.3 @@ -1,6 +1,6 @@
    24.4  (* Author: Fabian Immler, TUM *)
    24.5  
    24.6 -section {* Sequence of Properties on Subsequences *}
    24.7 +section \<open>Sequence of Properties on Subsequences\<close>
    24.8  
    24.9  theory Diagonal_Subsequence
   24.10  imports Complex_Main
    25.1 --- a/src/HOL/Library/Discrete.thy	Wed Jun 17 17:33:22 2015 +0200
    25.2 +++ b/src/HOL/Library/Discrete.thy	Wed Jun 17 17:54:09 2015 +0200
    25.3 @@ -1,12 +1,12 @@
    25.4  (* Author: Florian Haftmann, TU Muenchen *)
    25.5  
    25.6 -section {* Common discrete functions *}
    25.7 +section \<open>Common discrete functions\<close>
    25.8  
    25.9  theory Discrete
   25.10  imports Main
   25.11  begin
   25.12  
   25.13 -subsection {* Discrete logarithm *}
   25.14 +subsection \<open>Discrete logarithm\<close>
   25.15  
   25.16  fun log :: "nat \<Rightarrow> nat"
   25.17    where [simp del]: "log n = (if n < 2 then 0 else Suc (log (n div 2)))"
   25.18 @@ -59,13 +59,13 @@
   25.19        with mn2 have n2_0: "n div 2 \<noteq> 0" by arith
   25.20        from False "1.hyps" mn2 have "log (m div 2) \<le> log (n div 2)" by blast
   25.21        with m2_0 n2_0 have "log (2 * (m div 2)) \<le> log (2 * (n div 2))" by simp
   25.22 -      with m2_0 n2_0 `m \<ge> 2` `n \<ge> 2` show ?thesis by (simp only: log_rec [of m] log_rec [of n]) simp
   25.23 +      with m2_0 n2_0 \<open>m \<ge> 2\<close> \<open>n \<ge> 2\<close> show ?thesis by (simp only: log_rec [of m] log_rec [of n]) simp
   25.24      qed
   25.25    qed
   25.26  qed
   25.27  
   25.28  
   25.29 -subsection {* Discrete square root *}
   25.30 +subsection \<open>Discrete square root\<close>
   25.31  
   25.32  definition sqrt :: "nat \<Rightarrow> nat"
   25.33    where "sqrt n = Max {m. m\<^sup>2 \<le> n}"
   25.34 @@ -111,7 +111,7 @@
   25.35    have *: "0 * 0 \<le> m" by simp
   25.36    assume "m \<le> n"
   25.37    then show "sqrt m \<le> sqrt n"
   25.38 -    by (auto intro!: Max_mono `0 * 0 \<le> m` finite_less_ub simp add: power2_eq_square sqrt_def)
   25.39 +    by (auto intro!: Max_mono \<open>0 * 0 \<le> m\<close> finite_less_ub simp add: power2_eq_square sqrt_def)
   25.40  qed
   25.41  
   25.42  lemma sqrt_greater_zero_iff [simp]: "sqrt n > 0 \<longleftrightarrow> n > 0"
   25.43 @@ -162,8 +162,8 @@
   25.44            apply (subst Max_le_iff)
   25.45            apply auto
   25.46            apply (metis (mono_tags) finite_imageI finite_less_ub le_square)
   25.47 -          apply (metis `q * q \<le> n`)
   25.48 -          apply (metis `q * q \<le> n` le_cases mult_le_mono1 mult_le_mono2 order_trans)
   25.49 +          apply (metis \<open>q * q \<le> n\<close>)
   25.50 +          apply (metis \<open>q * q \<le> n\<close> le_cases mult_le_mono1 mult_le_mono2 order_trans)
   25.51            done
   25.52        qed
   25.53      qed
    26.1 --- a/src/HOL/Library/Dlist.thy	Wed Jun 17 17:33:22 2015 +0200
    26.2 +++ b/src/HOL/Library/Dlist.thy	Wed Jun 17 17:54:09 2015 +0200
    26.3 @@ -1,12 +1,12 @@
    26.4  (* Author: Florian Haftmann, TU Muenchen *)
    26.5  
    26.6 -section {* Lists with elements distinct as canonical example for datatype invariants *}
    26.7 +section \<open>Lists with elements distinct as canonical example for datatype invariants\<close>
    26.8  
    26.9  theory Dlist
   26.10  imports Main
   26.11  begin
   26.12  
   26.13 -subsection {* The type of distinct lists *}
   26.14 +subsection \<open>The type of distinct lists\<close>
   26.15  
   26.16  typedef 'a dlist = "{xs::'a list. distinct xs}"
   26.17    morphisms list_of_dlist Abs_dlist
   26.18 @@ -22,7 +22,7 @@
   26.19    "list_of_dlist dxs = list_of_dlist dys \<Longrightarrow> dxs = dys"
   26.20    by (simp add: dlist_eq_iff)
   26.21  
   26.22 -text {* Formal, totalized constructor for @{typ "'a dlist"}: *}
   26.23 +text \<open>Formal, totalized constructor for @{typ "'a dlist"}:\<close>
   26.24  
   26.25  definition Dlist :: "'a list \<Rightarrow> 'a dlist" where
   26.26    "Dlist xs = Abs_dlist (remdups xs)"
   26.27 @@ -44,7 +44,7 @@
   26.28    by (simp add: Dlist_def list_of_dlist_inverse distinct_remdups_id)
   26.29  
   26.30  
   26.31 -text {* Fundamental operations: *}
   26.32 +text \<open>Fundamental operations:\<close>
   26.33  
   26.34  definition empty :: "'a dlist" where
   26.35    "empty = Dlist []"
   26.36 @@ -62,7 +62,7 @@
   26.37    "filter P dxs = Dlist (List.filter P (list_of_dlist dxs))"
   26.38  
   26.39  
   26.40 -text {* Derived operations: *}
   26.41 +text \<open>Derived operations:\<close>
   26.42  
   26.43  definition null :: "'a dlist \<Rightarrow> bool" where
   26.44    "null dxs = List.null (list_of_dlist dxs)"
   26.45 @@ -80,7 +80,7 @@
   26.46    "foldr f dxs = List.foldr f (list_of_dlist dxs)"
   26.47  
   26.48  
   26.49 -subsection {* Executable version obeying invariant *}
   26.50 +subsection \<open>Executable version obeying invariant\<close>
   26.51  
   26.52  lemma list_of_dlist_empty [simp, code abstract]:
   26.53    "list_of_dlist empty = []"
   26.54 @@ -103,7 +103,7 @@
   26.55    by (simp add: filter_def)
   26.56  
   26.57  
   26.58 -text {* Explicit executable conversion *}
   26.59 +text \<open>Explicit executable conversion\<close>
   26.60  
   26.61  definition dlist_of_list [simp]:
   26.62    "dlist_of_list = Dlist"
   26.63 @@ -113,7 +113,7 @@
   26.64    by simp
   26.65  
   26.66  
   26.67 -text {* Equality *}
   26.68 +text \<open>Equality\<close>
   26.69  
   26.70  instantiation dlist :: (equal) equal
   26.71  begin
   26.72 @@ -132,7 +132,7 @@
   26.73    by (fact equal_refl)
   26.74  
   26.75  
   26.76 -subsection {* Induction principle and case distinction *}
   26.77 +subsection \<open>Induction principle and case distinction\<close>
   26.78  
   26.79  lemma dlist_induct [case_names empty insert, induct type: dlist]:
   26.80    assumes empty: "P empty"
   26.81 @@ -141,7 +141,7 @@
   26.82  proof (cases dxs)
   26.83    case (Abs_dlist xs)
   26.84    then have "distinct xs" and dxs: "dxs = Dlist xs" by (simp_all add: Dlist_def distinct_remdups_id)
   26.85 -  from `distinct xs` have "P (Dlist xs)"
   26.86 +  from \<open>distinct xs\<close> have "P (Dlist xs)"
   26.87    proof (induct xs)
   26.88      case Nil from empty show ?case by (simp add: empty_def)
   26.89    next
   26.90 @@ -176,13 +176,13 @@
   26.91  qed
   26.92  
   26.93  
   26.94 -subsection {* Functorial structure *}
   26.95 +subsection \<open>Functorial structure\<close>
   26.96  
   26.97  functor map: map
   26.98    by (simp_all add: List.map.id remdups_map_remdups fun_eq_iff dlist_eq_iff)
   26.99  
  26.100  
  26.101 -subsection {* Quickcheck generators *}
  26.102 +subsection \<open>Quickcheck generators\<close>
  26.103  
  26.104  quickcheck_generator dlist predicate: distinct constructors: empty, insert
  26.105  
    27.1 --- a/src/HOL/Library/Extended.thy	Wed Jun 17 17:33:22 2015 +0200
    27.2 +++ b/src/HOL/Library/Extended.thy	Wed Jun 17 17:54:09 2015 +0200
    27.3 @@ -90,8 +90,8 @@
    27.4  instantiation extended :: (plus)plus
    27.5  begin
    27.6  
    27.7 -text {* The following definition of of addition is totalized
    27.8 -to make it asociative and commutative. Normally the sum of plus and minus infinity is undefined. *}
    27.9 +text \<open>The following definition of of addition is totalized
   27.10 +to make it asociative and commutative. Normally the sum of plus and minus infinity is undefined.\<close>
   27.11  
   27.12  fun plus_extended where
   27.13  "Fin x + Fin y = Fin(x+y)" |
   27.14 @@ -155,7 +155,7 @@
   27.15  by (simp_all add: minus_extended_def)
   27.16  
   27.17  
   27.18 -text{* Numerals: *}
   27.19 +text\<open>Numerals:\<close>
   27.20  
   27.21  instance extended :: ("{ab_semigroup_add,one}")numeral ..
   27.22  
    28.1 --- a/src/HOL/Library/Extended_Nat.thy	Wed Jun 17 17:33:22 2015 +0200
    28.2 +++ b/src/HOL/Library/Extended_Nat.thy	Wed Jun 17 17:54:09 2015 +0200
    28.3 @@ -3,7 +3,7 @@
    28.4      Contributions: David Trachtenherz, TU Muenchen
    28.5  *)
    28.6  
    28.7 -section {* Extended natural numbers (i.e. with infinity) *}
    28.8 +section \<open>Extended natural numbers (i.e. with infinity)\<close>
    28.9  
   28.10  theory Extended_Nat
   28.11  imports Main Countable
   28.12 @@ -18,16 +18,16 @@
   28.13  notation (HTML output)
   28.14    infinity  ("\<infinity>")
   28.15  
   28.16 -subsection {* Type definition *}
   28.17 +subsection \<open>Type definition\<close>
   28.18  
   28.19 -text {*
   28.20 +text \<open>
   28.21    We extend the standard natural numbers by a special value indicating
   28.22    infinity.
   28.23 -*}
   28.24 +\<close>
   28.25  
   28.26  typedef enat = "UNIV :: nat option set" ..
   28.27  
   28.28 -text {* TODO: introduce enat as coinductive datatype, enat is just @{const of_nat} *}
   28.29 +text \<open>TODO: introduce enat as coinductive datatype, enat is just @{const of_nat}\<close>
   28.30  
   28.31  definition enat :: "nat \<Rightarrow> enat" where
   28.32    "enat n = Abs_enat (Some n)"
   28.33 @@ -70,7 +70,7 @@
   28.34    where "the_enat (enat n) = n"
   28.35  
   28.36  
   28.37 -subsection {* Constructors and numbers *}
   28.38 +subsection \<open>Constructors and numbers\<close>
   28.39  
   28.40  instantiation enat :: "{zero, one}"
   28.41  begin
   28.42 @@ -141,7 +141,7 @@
   28.43  lemma enat_eSuc_iff: "enat y = eSuc x \<longleftrightarrow> (\<exists>n. y = Suc n \<and> enat n = x)"
   28.44    by (cases y) (auto simp: enat_0 eSuc_enat[symmetric])
   28.45  
   28.46 -subsection {* Addition *}
   28.47 +subsection \<open>Addition\<close>
   28.48  
   28.49  instantiation enat :: comm_monoid_add
   28.50  begin
   28.51 @@ -186,7 +186,7 @@
   28.52  lemma iadd_is_0: "(m + n = (0::enat)) = (m = 0 \<and> n = 0)"
   28.53    by (cases m, cases n, simp_all add: zero_enat_def)
   28.54  
   28.55 -subsection {* Multiplication *}
   28.56 +subsection \<open>Multiplication\<close>
   28.57  
   28.58  instantiation enat :: comm_semiring_1
   28.59  begin
   28.60 @@ -254,7 +254,7 @@
   28.61    by (auto simp add: times_enat_def zero_enat_def split: enat.split)
   28.62  
   28.63  
   28.64 -subsection {* Numerals *}
   28.65 +subsection \<open>Numerals\<close>
   28.66  
   28.67  lemma numeral_eq_enat:
   28.68    "numeral k = enat (numeral k)"
   28.69 @@ -273,7 +273,7 @@
   28.70  lemma eSuc_numeral [simp]: "eSuc (numeral k) = numeral (k + Num.One)"
   28.71    by (simp only: eSuc_plus_1 numeral_plus_one)
   28.72  
   28.73 -subsection {* Subtraction *}
   28.74 +subsection \<open>Subtraction\<close>
   28.75  
   28.76  instantiation enat :: minus
   28.77  begin
   28.78 @@ -316,7 +316,7 @@
   28.79  
   28.80  (*lemmas idiff_self_eq_0_enat = idiff_self_eq_0[unfolded zero_enat_def]*)
   28.81  
   28.82 -subsection {* Ordering *}
   28.83 +subsection \<open>Ordering\<close>
   28.84  
   28.85  instantiation enat :: linordered_ab_semigroup_add
   28.86  begin
   28.87 @@ -499,7 +499,7 @@
   28.88  qed
   28.89  
   28.90  
   28.91 -subsection {* Cancellation simprocs *}
   28.92 +subsection \<open>Cancellation simprocs\<close>
   28.93  
   28.94  lemma enat_add_left_cancel: "a + b = a + c \<longleftrightarrow> a = (\<infinity>::enat) \<or> b = c"
   28.95    unfolding plus_enat_def by (simp split: enat.split)
   28.96 @@ -510,7 +510,7 @@
   28.97  lemma enat_add_left_cancel_less: "a + b < a + c \<longleftrightarrow> a \<noteq> (\<infinity>::enat) \<and> b < c"
   28.98    unfolding plus_enat_def by (simp split: enat.split)
   28.99  
  28.100 -ML {*
  28.101 +ML \<open>
  28.102  structure Cancel_Enat_Common =
  28.103  struct
  28.104    (* copied from src/HOL/Tools/nat_numeral_simprocs.ML *)
  28.105 @@ -557,25 +557,25 @@
  28.106    val dest_bal = HOLogic.dest_bin @{const_name Orderings.less} @{typ enat}
  28.107    fun simp_conv _ _ = SOME @{thm enat_add_left_cancel_less}
  28.108  )
  28.109 -*}
  28.110 +\<close>
  28.111  
  28.112  simproc_setup enat_eq_cancel
  28.113    ("(l::enat) + m = n" | "(l::enat) = m + n") =
  28.114 -  {* fn phi => fn ctxt => fn ct => Eq_Enat_Cancel.proc ctxt (Thm.term_of ct) *}
  28.115 +  \<open>fn phi => fn ctxt => fn ct => Eq_Enat_Cancel.proc ctxt (Thm.term_of ct)\<close>
  28.116  
  28.117  simproc_setup enat_le_cancel
  28.118    ("(l::enat) + m \<le> n" | "(l::enat) \<le> m + n") =
  28.119 -  {* fn phi => fn ctxt => fn ct => Le_Enat_Cancel.proc ctxt (Thm.term_of ct) *}
  28.120 +  \<open>fn phi => fn ctxt => fn ct => Le_Enat_Cancel.proc ctxt (Thm.term_of ct)\<close>
  28.121  
  28.122  simproc_setup enat_less_cancel
  28.123    ("(l::enat) + m < n" | "(l::enat) < m + n") =
  28.124 -  {* fn phi => fn ctxt => fn ct => Less_Enat_Cancel.proc ctxt (Thm.term_of ct) *}
  28.125 +  \<open>fn phi => fn ctxt => fn ct => Less_Enat_Cancel.proc ctxt (Thm.term_of ct)\<close>
  28.126  
  28.127 -text {* TODO: add regression tests for these simprocs *}
  28.128 +text \<open>TODO: add regression tests for these simprocs\<close>
  28.129  
  28.130 -text {* TODO: add simprocs for combining and cancelling numerals *}
  28.131 +text \<open>TODO: add simprocs for combining and cancelling numerals\<close>
  28.132  
  28.133 -subsection {* Well-ordering *}
  28.134 +subsection \<open>Well-ordering\<close>
  28.135  
  28.136  lemma less_enatE:
  28.137    "[| n < enat m; !!k. n = enat k ==> k < m ==> P |] ==> P"
  28.138 @@ -613,7 +613,7 @@
  28.139    show "P n" by (blast intro: enat_less_induct hyp)
  28.140  qed
  28.141  
  28.142 -subsection {* Complete Lattice *}
  28.143 +subsection \<open>Complete Lattice\<close>
  28.144  
  28.145  instantiation enat :: complete_lattice
  28.146  begin
  28.147 @@ -647,7 +647,7 @@
  28.148  
  28.149  instance enat :: complete_linorder ..
  28.150  
  28.151 -subsection {* Traditional theorem names *}
  28.152 +subsection \<open>Traditional theorem names\<close>
  28.153  
  28.154  lemmas enat_defs = zero_enat_def one_enat_def eSuc_def
  28.155    plus_enat_def less_eq_enat_def less_enat_def
    29.1 --- a/src/HOL/Library/Extended_Real.thy	Wed Jun 17 17:33:22 2015 +0200
    29.2 +++ b/src/HOL/Library/Extended_Real.thy	Wed Jun 17 17:54:09 2015 +0200
    29.3 @@ -5,18 +5,18 @@
    29.4      Author:     Bogdan Grechuk, University of Edinburgh
    29.5  *)
    29.6  
    29.7 -section {* Extended real number line *}
    29.8 +section \<open>Extended real number line\<close>
    29.9  
   29.10  theory Extended_Real
   29.11  imports Complex_Main Extended_Nat Liminf_Limsup Order_Continuity
   29.12  begin
   29.13  
   29.14 -text {*
   29.15 +text \<open>
   29.16  
   29.17  This should be part of @{theory Extended_Nat} or @{theory Order_Continuity}, but then the
   29.18  AFP-entry @{text "Jinja_Thread"} fails, as it does overload certain named from @{theory Complex_Main}.
   29.19  
   29.20 -*}
   29.21 +\<close>
   29.22  
   29.23  lemma continuous_at_left_imp_sup_continuous:
   29.24    fixes f :: "'a \<Rightarrow> 'a::{complete_linorder, linorder_topology}"
   29.25 @@ -169,14 +169,14 @@
   29.26  qed
   29.27  
   29.28  
   29.29 -text {*
   29.30 +text \<open>
   29.31  
   29.32  For more lemmas about the extended real numbers go to
   29.33    @{file "~~/src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy"}
   29.34  
   29.35 -*}
   29.36 -
   29.37 -subsection {* Definition and basic properties *}
   29.38 +\<close>
   29.39 +
   29.40 +subsection \<open>Definition and basic properties\<close>
   29.41  
   29.42  datatype ereal = ereal real | PInfty | MInfty
   29.43  
   29.44 @@ -760,7 +760,7 @@
   29.45      assume "\<not> ?thesis"
   29.46      then have "\<And>i. i \<in> P \<Longrightarrow> f i \<noteq> \<infinity>"
   29.47        by auto
   29.48 -    with `finite P` have "setsum f P \<noteq> \<infinity>"
   29.49 +    with \<open>finite P\<close> have "setsum f P \<noteq> \<infinity>"
   29.50        by induct auto
   29.51      with * show False
   29.52        by auto
   29.53 @@ -1121,9 +1121,9 @@
   29.54      {
   29.55        assume "e \<noteq> \<infinity>"
   29.56        then obtain r where "e = ereal r"
   29.57 -        using `e > 0` by (cases e) auto
   29.58 +        using \<open>e > 0\<close> by (cases e) auto
   29.59        then have "x \<le> y + e"
   29.60 -        using assms[rule_format, of r] `e>0` by auto
   29.61 +        using assms[rule_format, of r] \<open>e>0\<close> by auto
   29.62      }
   29.63      ultimately have "x \<le> y + e"
   29.64        by blast
   29.65 @@ -1199,7 +1199,7 @@
   29.66  qed
   29.67  
   29.68  
   29.69 -subsubsection {* Power *}
   29.70 +subsubsection \<open>Power\<close>
   29.71  
   29.72  lemma ereal_power[simp]: "(ereal x) ^ n = ereal (x^n)"
   29.73    by (induct n) (auto simp: one_ereal_def)
   29.74 @@ -1223,7 +1223,7 @@
   29.75    using assms by (induct n) (auto simp: ereal_zero_le_0_iff)
   29.76  
   29.77  
   29.78 -subsubsection {* Subtraction *}
   29.79 +subsubsection \<open>Subtraction\<close>
   29.80  
   29.81  lemma ereal_minus_minus_image[simp]:
   29.82    fixes S :: "ereal set"
   29.83 @@ -1391,7 +1391,7 @@
   29.84    by (cases x y rule: ereal2_cases) simp_all
   29.85  
   29.86  
   29.87 -subsubsection {* Division *}
   29.88 +subsubsection \<open>Division\<close>
   29.89  
   29.90  instantiation ereal :: inverse
   29.91  begin
   29.92 @@ -1627,7 +1627,7 @@
   29.93    show ?thesis
   29.94    proof (cases "S \<noteq> {-\<infinity>} \<and> S \<noteq> {}")
   29.95      case True
   29.96 -    with `\<infinity> \<notin> S` obtain x where x: "x \<in> S" "\<bar>x\<bar> \<noteq> \<infinity>"
   29.97 +    with \<open>\<infinity> \<notin> S\<close> obtain x where x: "x \<in> S" "\<bar>x\<bar> \<noteq> \<infinity>"
   29.98        by auto
   29.99      obtain s where s: "\<forall>x\<in>ereal -` S. x \<le> s" "\<And>z. (\<forall>x\<in>ereal -` S. x \<le> z) \<Longrightarrow> s \<le> z"
  29.100      proof (atomize_elim, rule complete_real)
  29.101 @@ -1640,12 +1640,12 @@
  29.102      proof (safe intro!: exI[of _ "ereal s"])
  29.103        fix y
  29.104        assume "y \<in> S"
  29.105 -      with s `\<infinity> \<notin> S` show "y \<le> ereal s"
  29.106 +      with s \<open>\<infinity> \<notin> S\<close> show "y \<le> ereal s"
  29.107          by (cases y) auto
  29.108      next
  29.109        fix z
  29.110        assume "\<forall>y\<in>S. y \<le> z"
  29.111 -      with `S \<noteq> {-\<infinity>} \<and> S \<noteq> {}` show "ereal s \<le> z"
  29.112 +      with \<open>S \<noteq> {-\<infinity>} \<and> S \<noteq> {}\<close> show "ereal s \<le> z"
  29.113          by (cases z) (auto intro!: s)
  29.114      qed
  29.115    next
  29.116 @@ -1773,14 +1773,14 @@
  29.117    show ?thesis
  29.118    proof (rule filterlim_cong[THEN iffD1, OF refl refl _ tendsto_const])
  29.119      have "0 < x \<or> x < 0"
  29.120 -      using `x \<noteq> 0` by (auto simp add: neq_iff)
  29.121 +      using \<open>x \<noteq> 0\<close> by (auto simp add: neq_iff)
  29.122      then show "eventually (\<lambda>x'. c * x = c * f x') F"
  29.123      proof
  29.124        assume "0 < x" from order_tendstoD(1)[OF f this] show ?thesis
  29.125 -        by eventually_elim (insert `0<x` `\<bar>c\<bar> = \<infinity>`, auto)
  29.126 +        by eventually_elim (insert \<open>0<x\<close> \<open>\<bar>c\<bar> = \<infinity>\<close>, auto)
  29.127      next
  29.128        assume "x < 0" from order_tendstoD(2)[OF f this] show ?thesis
  29.129 -        by eventually_elim (insert `x<0` `\<bar>c\<bar> = \<infinity>`, auto)
  29.130 +        by eventually_elim (insert \<open>x<0\<close> \<open>\<bar>c\<bar> = \<infinity>\<close>, auto)
  29.131      qed
  29.132    qed
  29.133  qed (rule tendsto_cmult_ereal[OF _ f])
  29.134 @@ -1941,12 +1941,12 @@
  29.135    moreover then have "\<And>i. i \<in> I \<Longrightarrow> f i = -\<infinity>"
  29.136      unfolding Sup_eq_MInfty Sup_image_eq[symmetric] by auto
  29.137    ultimately show ?thesis
  29.138 -    by (cases c) (auto simp: `I \<noteq> {}`)
  29.139 +    by (cases c) (auto simp: \<open>I \<noteq> {}\<close>)
  29.140  next
  29.141    assume "(SUP i:I. f i) \<noteq> - \<infinity>" then show ?thesis
  29.142      unfolding Sup_image_eq[symmetric]
  29.143      by (subst continuous_at_Sup_mono[where f="\<lambda>x. x + c"])
  29.144 -       (auto simp: continuous_at_within continuous_at mono_def ereal_add_mono `I \<noteq> {}` `c \<noteq> -\<infinity>`)
  29.145 +       (auto simp: continuous_at_within continuous_at mono_def ereal_add_mono \<open>I \<noteq> {}\<close> \<open>c \<noteq> -\<infinity>\<close>)
  29.146  qed
  29.147  
  29.148  lemma SUP_ereal_add_right:
  29.149 @@ -1963,17 +1963,17 @@
  29.150  lemma SUP_ereal_minus_left:
  29.151    assumes "I \<noteq> {}" "c \<noteq> \<infinity>"
  29.152    shows "(SUP i:I. f i - c:: ereal) = (SUP i:I. f i) - c"
  29.153 -  using SUP_ereal_add_left[OF `I \<noteq> {}`, of "-c" f] by (simp add: `c \<noteq> \<infinity>` minus_ereal_def)
  29.154 +  using SUP_ereal_add_left[OF \<open>I \<noteq> {}\<close>, of "-c" f] by (simp add: \<open>c \<noteq> \<infinity>\<close> minus_ereal_def)
  29.155  
  29.156  lemma INF_ereal_minus_right:
  29.157    assumes "I \<noteq> {}" and "\<bar>c\<bar> \<noteq> \<infinity>"
  29.158    shows "(INF i:I. c - f i) = c - (SUP i:I. f i::ereal)"
  29.159  proof -
  29.160    { fix b have "(-c) + b = - (c - b)"
  29.161 -      using `\<bar>c\<bar> \<noteq> \<infinity>` by (cases c b rule: ereal2_cases) auto }
  29.162 +      using \<open>\<bar>c\<bar> \<noteq> \<infinity>\<close> by (cases c b rule: ereal2_cases) auto }
  29.163    note * = this
  29.164    show ?thesis
  29.165 -    using SUP_ereal_add_right[OF `I \<noteq> {}`, of "-c" f] `\<bar>c\<bar> \<noteq> \<infinity>`
  29.166 +    using SUP_ereal_add_right[OF \<open>I \<noteq> {}\<close>, of "-c" f] \<open>\<bar>c\<bar> \<noteq> \<infinity>\<close>
  29.167      by (auto simp add: * ereal_SUP_uminus_eq)
  29.168  qed
  29.169  
  29.170 @@ -1981,7 +1981,7 @@
  29.171    fixes f :: "'i \<Rightarrow> ereal"
  29.172    assumes "\<And>i. f i + y \<le> z" and "y \<noteq> -\<infinity>"
  29.173    shows "SUPREMUM UNIV f + y \<le> z"
  29.174 -  unfolding SUP_ereal_add_left[OF UNIV_not_empty `y \<noteq> -\<infinity>`, symmetric]
  29.175 +  unfolding SUP_ereal_add_left[OF UNIV_not_empty \<open>y \<noteq> -\<infinity>\<close>, symmetric]
  29.176    by (rule SUP_least assms)+
  29.177  
  29.178  lemma SUP_combine:
  29.179 @@ -2069,7 +2069,7 @@
  29.180    assume "(SUP i:I. f i) \<noteq> 0" then show ?thesis
  29.181      unfolding SUP_def
  29.182      by (subst continuous_at_Sup_mono[where f="\<lambda>x. c * x"])
  29.183 -       (auto simp: mono_def continuous_at continuous_at_within `I \<noteq> {}`
  29.184 +       (auto simp: mono_def continuous_at continuous_at_within \<open>I \<noteq> {}\<close>
  29.185               intro!: ereal_mult_left_mono c)
  29.186  qed
  29.187  
  29.188 @@ -2093,7 +2093,7 @@
  29.189    shows "\<exists>f::nat \<Rightarrow> ereal. incseq f \<and> range f \<subseteq> A \<and> Sup A = (SUP i. f i)"
  29.190  proof cases
  29.191    assume "Sup A = -\<infinity>"
  29.192 -  with `A \<noteq> {}` have "A = {-\<infinity>}"
  29.193 +  with \<open>A \<noteq> {}\<close> have "A = {-\<infinity>}"
  29.194      by (auto simp: Sup_eq_MInfty)
  29.195    then show ?thesis
  29.196      by (auto intro!: exI[of _ "\<lambda>_. -\<infinity>"] simp: bot_ereal_def)
  29.197 @@ -2120,7 +2120,7 @@
  29.198    have "(SUP i. f i) = Sup A"
  29.199    proof (rule tendsto_unique)
  29.200      show "f ----> (SUP i. f i)"
  29.201 -      by (rule LIMSEQ_SUP `incseq f`)+
  29.202 +      by (rule LIMSEQ_SUP \<open>incseq f\<close>)+
  29.203      show "f ----> Sup A"
  29.204        using l f
  29.205        by (intro tendsto_sandwich[OF _ _ l_Sup tendsto_const])
  29.206 @@ -2322,7 +2322,7 @@
  29.207      and "\<bar>x\<bar> \<noteq> \<infinity>"
  29.208    obtains e where "e > 0" and "{x-e <..< x+e} \<subseteq> S"
  29.209  proof -
  29.210 -  from `open S`
  29.211 +  from \<open>open S\<close>
  29.212    have "open (ereal -` S)"
  29.213      by (rule ereal_openE)
  29.214    then obtain e where "e > 0" and e: "\<And>y. dist y (real x) < e \<Longrightarrow> ereal y \<in> S"
  29.215 @@ -2330,7 +2330,7 @@
  29.216    show thesis
  29.217    proof (intro that subsetI)
  29.218      show "0 < ereal e"
  29.219 -      using `0 < e` by auto
  29.220 +      using \<open>0 < e\<close> by auto
  29.221      fix y
  29.222      assume "y \<in> {x - ereal e<..<x + ereal e}"
  29.223      with assms obtain t where "y = ereal t" "dist t (real x) < e"
  29.224 @@ -2354,7 +2354,7 @@
  29.225      by auto
  29.226  qed
  29.227  
  29.228 -subsubsection {* Convergent sequences *}
  29.229 +subsubsection \<open>Convergent sequences\<close>
  29.230  
  29.231  lemma lim_real_of_ereal[simp]:
  29.232    assumes lim: "(f ---> ereal x) net"
  29.233 @@ -2477,7 +2477,7 @@
  29.234  proof (intro topological_tendstoI)
  29.235    fix S
  29.236    assume S: "open S" "x \<in> S"
  29.237 -  with `x \<noteq> 0` have "open (S - {0})" "x \<in> S - {0}"
  29.238 +  with \<open>x \<noteq> 0\<close> have "open (S - {0})" "x \<in> S - {0}"
  29.239      by auto
  29.240    from tendsto[THEN topological_tendstoD, OF this]
  29.241    show "eventually (\<lambda>x. f x \<in> S) net"
  29.242 @@ -2618,7 +2618,7 @@
  29.243    assume "open S" and "x \<in> S"
  29.244    then have "open (ereal -` S)"
  29.245      unfolding open_ereal_def by auto
  29.246 -  with `x \<in> S` obtain r where "0 < r" and dist: "\<And>y. dist y rx < r \<Longrightarrow> ereal y \<in> S"
  29.247 +  with \<open>x \<in> S\<close> obtain r where "0 < r" and dist: "\<And>y. dist y rx < r \<Longrightarrow> ereal y \<in> S"
  29.248      unfolding open_real_def rx by auto
  29.249    then obtain n where
  29.250      upper: "\<And>N. n \<le> N \<Longrightarrow> u N < x + ereal r" and
  29.251 @@ -2628,19 +2628,19 @@
  29.252    proof (safe intro!: exI[of _ n])
  29.253      fix N
  29.254      assume "n \<le> N"
  29.255 -    from upper[OF this] lower[OF this] assms `0 < r`
  29.256 +    from upper[OF this] lower[OF this] assms \<open>0 < r\<close>
  29.257      have "u N \<notin> {\<infinity>,(-\<infinity>)}"
  29.258        by auto
  29.259      then obtain ra where ra_def: "(u N) = ereal ra"
  29.260        by (cases "u N") auto
  29.261      then have "rx < ra + r" and "ra < rx + r"
  29.262 -      using rx assms `0 < r` lower[OF `n \<le> N`] upper[OF `n \<le> N`]
  29.263 +      using rx assms \<open>0 < r\<close> lower[OF \<open>n \<le> N\<close>] upper[OF \<open>n \<le> N\<close>]
  29.264        by auto
  29.265      then have "dist (real (u N)) rx < r"
  29.266        using rx ra_def
  29.267        by (auto simp: dist_real_def abs_diff_less_iff field_simps)
  29.268      from dist[OF this] show "u N \<in> S"
  29.269 -      using `u N  \<notin> {\<infinity>, -\<infinity>}`
  29.270 +      using \<open>u N  \<notin> {\<infinity>, -\<infinity>}\<close>
  29.271        by (auto simp: ereal_real split: split_if_asm)
  29.272    qed
  29.273  qed
  29.274 @@ -2665,7 +2665,7 @@
  29.275      assume "r > 0"
  29.276      then obtain N where "\<forall>n\<ge>N. u n \<in> {x - r <..< x + r}"
  29.277         apply (subst tendsto_obtains_N[of u x "{x - r <..< x + r}"])
  29.278 -       using lim ereal_between[of x r] assms `r > 0`
  29.279 +       using lim ereal_between[of x r] assms \<open>r > 0\<close>
  29.280         apply auto
  29.281         done
  29.282      then have "\<exists>N. \<forall>n\<ge>N. u n < x + r \<and> x < u n + r"
  29.283 @@ -2768,7 +2768,7 @@
  29.284    qed
  29.285  qed
  29.286  
  29.287 -subsubsection {* Tests for code generator *}
  29.288 +subsubsection \<open>Tests for code generator\<close>
  29.289  
  29.290  (* A small list of simple arithmetic expressions *)
  29.291  
    30.1 --- a/src/HOL/Library/FSet.thy	Wed Jun 17 17:33:22 2015 +0200
    30.2 +++ b/src/HOL/Library/FSet.thy	Wed Jun 17 17:54:09 2015 +0200
    30.3 @@ -4,13 +4,13 @@
    30.4      Author:     Andrei Popescu, TU Muenchen
    30.5  *)
    30.6  
    30.7 -section {* Type of finite sets defined as a subtype of sets *}
    30.8 +section \<open>Type of finite sets defined as a subtype of sets\<close>
    30.9  
   30.10  theory FSet
   30.11  imports Conditionally_Complete_Lattices
   30.12  begin
   30.13  
   30.14 -subsection {* Definition of the type *}
   30.15 +subsection \<open>Definition of the type\<close>
   30.16  
   30.17  typedef 'a fset = "{A :: 'a set. finite A}"  morphisms fset Abs_fset
   30.18  by auto
   30.19 @@ -18,7 +18,7 @@
   30.20  setup_lifting type_definition_fset
   30.21  
   30.22  
   30.23 -subsection {* Basic operations and type class instantiations *}
   30.24 +subsection \<open>Basic operations and type class instantiations\<close>
   30.25  
   30.26  (* FIXME transfer and right_total vs. bi_total *)
   30.27  instantiation fset :: (finite) finite
   30.28 @@ -153,7 +153,7 @@
   30.29  declare top_fset.rep_eq[simp]
   30.30  
   30.31  
   30.32 -subsection {* Other operations *}
   30.33 +subsection \<open>Other operations\<close>
   30.34  
   30.35  lift_definition finsert :: "'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset" is insert parametric Lifting_Set.insert_transfer
   30.36    by simp
   30.37 @@ -199,7 +199,7 @@
   30.38  lift_definition ffold :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a fset \<Rightarrow> 'b" is Finite_Set.fold .
   30.39  
   30.40  
   30.41 -subsection {* Transferred lemmas from Set.thy *}
   30.42 +subsection \<open>Transferred lemmas from Set.thy\<close>
   30.43  
   30.44  lemmas fset_eqI = set_eqI[Transfer.transferred]
   30.45  lemmas fset_eq_iff[no_atp] = set_eq_iff[Transfer.transferred]
   30.46 @@ -439,14 +439,14 @@
   30.47  lemmas fequalityI = equalityI[Transfer.transferred]
   30.48  
   30.49  
   30.50 -subsection {* Additional lemmas*}
   30.51 +subsection \<open>Additional lemmas\<close>
   30.52  
   30.53 -subsubsection {* @{text fsingleton} *}
   30.54 +subsubsection \<open>@{text fsingleton}\<close>
   30.55  
   30.56  lemmas fsingletonE = fsingletonD [elim_format]
   30.57  
   30.58  
   30.59 -subsubsection {* @{text femepty} *}
   30.60 +subsubsection \<open>@{text femepty}\<close>
   30.61  
   30.62  lemma fempty_ffilter[simp]: "ffilter (\<lambda>_. False) A = {||}"
   30.63  by transfer auto
   30.64 @@ -456,7 +456,7 @@
   30.65    by simp
   30.66  
   30.67  
   30.68 -subsubsection {* @{text fset} *}
   30.69 +subsubsection \<open>@{text fset}\<close>
   30.70  
   30.71  lemmas fset_simps[simp] = bot_fset.rep_eq finsert.rep_eq
   30.72  
   30.73 @@ -479,7 +479,7 @@
   30.74  lemmas minus_fset[simp] = minus_fset.rep_eq
   30.75  
   30.76  
   30.77 -subsubsection {* @{text filter_fset} *}
   30.78 +subsubsection \<open>@{text filter_fset}\<close>
   30.79  
   30.80  lemma subset_ffilter: 
   30.81    "ffilter P A |\<subseteq>| ffilter Q A = (\<forall> x. x |\<in>| A \<longrightarrow> P x \<longrightarrow> Q x)"
   30.82 @@ -495,7 +495,7 @@
   30.83    unfolding less_fset_def by (auto simp add: subset_ffilter eq_ffilter)
   30.84  
   30.85  
   30.86 -subsubsection {* @{text finsert} *}
   30.87 +subsubsection \<open>@{text finsert}\<close>
   30.88  
   30.89  (* FIXME, transferred doesn't work here *)
   30.90  lemma set_finsert:
   30.91 @@ -507,13 +507,13 @@
   30.92    by (rule_tac x = "A |-| {|a|}" in exI, blast)
   30.93  
   30.94  
   30.95 -subsubsection {* @{text fimage} *}
   30.96 +subsubsection \<open>@{text fimage}\<close>
   30.97  
   30.98  lemma subset_fimage_iff: "(B |\<subseteq>| f|`|A) = (\<exists> AA. AA |\<subseteq>| A \<and> B = f|`|AA)"
   30.99  by transfer (metis mem_Collect_eq rev_finite_subset subset_image_iff)
  30.100  
  30.101  
  30.102 -subsubsection {* bounded quantification *}
  30.103 +subsubsection \<open>bounded quantification\<close>
  30.104  
  30.105  lemma bex_simps [simp, no_atp]:
  30.106    "\<And>A P Q. fBex A (\<lambda>x. P x \<and> Q) = (fBex A P \<and> Q)" 
  30.107 @@ -544,7 +544,7 @@
  30.108  end
  30.109  
  30.110  
  30.111 -subsubsection {* @{text fcard} *}
  30.112 +subsubsection \<open>@{text fcard}\<close>
  30.113  
  30.114  (* FIXME: improve transferred to handle bounded meta quantification *)
  30.115  
  30.116 @@ -627,7 +627,7 @@
  30.117  by transfer (rule card_psubset)
  30.118  
  30.119  
  30.120 -subsubsection {* @{text ffold} *}
  30.121 +subsubsection \<open>@{text ffold}\<close>
  30.122  
  30.123  (* FIXME: improve transferred to handle bounded meta quantification *)
  30.124  
  30.125 @@ -686,7 +686,7 @@
  30.126  end
  30.127  
  30.128  
  30.129 -subsection {* Choice in fsets *}
  30.130 +subsection \<open>Choice in fsets\<close>
  30.131  
  30.132  lemma fset_choice: 
  30.133    assumes "\<forall>x. x |\<in>| A \<longrightarrow> (\<exists>y. P x y)"
  30.134 @@ -694,7 +694,7 @@
  30.135    using assms by transfer metis
  30.136  
  30.137  
  30.138 -subsection {* Induction and Cases rules for fsets *}
  30.139 +subsection \<open>Induction and Cases rules for fsets\<close>
  30.140  
  30.141  lemma fset_exhaust [case_names empty insert, cases type: fset]:
  30.142    assumes fempty_case: "S = {||} \<Longrightarrow> P" 
  30.143 @@ -760,9 +760,9 @@
  30.144    done
  30.145  
  30.146  
  30.147 -subsection {* Setup for Lifting/Transfer *}
  30.148 +subsection \<open>Setup for Lifting/Transfer\<close>
  30.149  
  30.150 -subsubsection {* Relator and predicator properties *}
  30.151 +subsubsection \<open>Relator and predicator properties\<close>
  30.152  
  30.153  lift_definition rel_fset :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a fset \<Rightarrow> 'b fset \<Rightarrow> bool" is rel_set
  30.154  parametric rel_set_transfer .
  30.155 @@ -800,9 +800,9 @@
  30.156    ultimately show ?thesis by metis
  30.157  qed
  30.158  
  30.159 -subsubsection {* Transfer rules for the Transfer package *}
  30.160 +subsubsection \<open>Transfer rules for the Transfer package\<close>
  30.161  
  30.162 -text {* Unconditional transfer rules *}
  30.163 +text \<open>Unconditional transfer rules\<close>
  30.164  
  30.165  context
  30.166  begin
  30.167 @@ -854,7 +854,7 @@
  30.168    using assms unfolding rel_fun_def
  30.169    using bind_transfer[unfolded rel_fun_def, rule_format, Transfer.transferred] by blast
  30.170  
  30.171 -text {* Rules requiring bi-unique, bi-total or right-total relations *}
  30.172 +text \<open>Rules requiring bi-unique, bi-total or right-total relations\<close>
  30.173  
  30.174  lemma fmember_transfer [transfer_rule]:
  30.175    assumes "bi_unique A"
  30.176 @@ -913,7 +913,7 @@
  30.177  lifting_forget fset.lifting
  30.178  
  30.179  
  30.180 -subsection {* BNF setup *}
  30.181 +subsection \<open>BNF setup\<close>
  30.182  
  30.183  context
  30.184  includes fset.lifting
  30.185 @@ -940,9 +940,9 @@
  30.186    hence *: "fset R' = ?L'" unfolding R'_def by (intro fset_to_fset)
  30.187    show ?R unfolding Grp_def relcompp.simps conversep.simps
  30.188    proof (intro CollectI case_prodI exI[of _ a] exI[of _ b] exI[of _ R'] conjI refl)
  30.189 -    from * show "a = fimage fst R'" using conjunct1[OF `?L`]
  30.190 +    from * show "a = fimage fst R'" using conjunct1[OF \<open>?L\<close>]
  30.191        by (transfer, auto simp add: image_def Int_def split: prod.splits)
  30.192 -    from * show "b = fimage snd R'" using conjunct2[OF `?L`]
  30.193 +    from * show "b = fimage snd R'" using conjunct2[OF \<open>?L\<close>]
  30.194        by (transfer, auto simp add: image_def Int_def split: prod.splits)
  30.195    qed (auto simp add: *)
  30.196  next
  30.197 @@ -980,7 +980,7 @@
  30.198  lemmas [simp] = fset.map_comp fset.map_id fset.set_map
  30.199  
  30.200  
  30.201 -subsection {* Size setup *}
  30.202 +subsection \<open>Size setup\<close>
  30.203  
  30.204  context includes fset.lifting begin
  30.205  lift_definition size_fset :: "('a \<Rightarrow> nat) \<Rightarrow> 'a fset \<Rightarrow> nat" is "\<lambda>f. setsum (Suc \<circ> f)" .
  30.206 @@ -1004,15 +1004,15 @@
  30.207    apply (subst fun_eq_iff)
  30.208    including fset.lifting by transfer (auto intro: setsum.reindex_cong subset_inj_on)
  30.209    
  30.210 -setup {*
  30.211 +setup \<open>
  30.212  BNF_LFP_Size.register_size_global @{type_name fset} @{const_name size_fset}
  30.213    @{thms size_fset_simps size_fset_overloaded_simps} @{thms fset_size_o_map}
  30.214 -*}
  30.215 +\<close>
  30.216  
  30.217  lifting_update fset.lifting
  30.218  lifting_forget fset.lifting
  30.219  
  30.220 -subsection {* Advanced relator customization *}
  30.221 +subsection \<open>Advanced relator customization\<close>
  30.222  
  30.223  (* Set vs. sum relators: *)
  30.224  
    31.1 --- a/src/HOL/Library/FinFun.thy	Wed Jun 17 17:33:22 2015 +0200
    31.2 +++ b/src/HOL/Library/FinFun.thy	Wed Jun 17 17:54:09 2015 +0200
    31.3 @@ -1,12 +1,12 @@
    31.4  (* Author: Andreas Lochbihler, Uni Karlsruhe *)
    31.5  
    31.6 -section {* Almost everywhere constant functions *}
    31.7 +section \<open>Almost everywhere constant functions\<close>
    31.8  
    31.9  theory FinFun
   31.10  imports Cardinality
   31.11  begin
   31.12  
   31.13 -text {*
   31.14 +text \<open>
   31.15    This theory defines functions which are constant except for finitely
   31.16    many points (FinFun) and introduces a type finfin along with a
   31.17    number of operators for them. The code generator is set up such that
   31.18 @@ -14,10 +14,10 @@
   31.19    all operators are executable.
   31.20  
   31.21    For details, see Formalising FinFuns - Generating Code for Functions as Data by A. Lochbihler in TPHOLs 2009.
   31.22 -*}
   31.23 +\<close>
   31.24  
   31.25  
   31.26 -subsection {* The @{text "map_default"} operation *}
   31.27 +subsection \<open>The @{text "map_default"} operation\<close>
   31.28  
   31.29  definition map_default :: "'b \<Rightarrow> ('a \<rightharpoonup> 'b) \<Rightarrow> 'a \<Rightarrow> 'b"
   31.30  where "map_default b f a \<equiv> case f a of None \<Rightarrow> b | Some b' \<Rightarrow> b'"
   31.31 @@ -72,7 +72,7 @@
   31.32    qed
   31.33  qed
   31.34  
   31.35 -subsection {* The finfun type *}
   31.36 +subsection \<open>The finfun type\<close>
   31.37  
   31.38  definition "finfun = {f::'a\<Rightarrow>'b. \<exists>b. finite {a. f a \<noteq> b}}"
   31.39  
   31.40 @@ -122,8 +122,8 @@
   31.41      thus ?case by(simp)
   31.42    next
   31.43      case (insert x F)
   31.44 -    note IH = `\<And>y. F = {a. y a \<noteq> b} \<Longrightarrow> finite {c. g (y c) \<noteq> g b}`
   31.45 -    from `insert x F = {a. y a \<noteq> b}` `x \<notin> F`
   31.46 +    note IH = \<open>\<And>y. F = {a. y a \<noteq> b} \<Longrightarrow> finite {c. g (y c) \<noteq> g b}\<close>
   31.47 +    from \<open>insert x F = {a. y a \<noteq> b}\<close> \<open>x \<notin> F\<close>
   31.48      have F: "F = {a. (y(x := b)) a \<noteq> b}" by(auto)
   31.49      show ?case
   31.50      proof(cases "g (y x) = g b")
   31.51 @@ -269,7 +269,7 @@
   31.52  qed
   31.53  
   31.54  
   31.55 -subsection {* Kernel functions for type @{typ "'a \<Rightarrow>f 'b"} *}
   31.56 +subsection \<open>Kernel functions for type @{typ "'a \<Rightarrow>f 'b"}\<close>
   31.57  
   31.58  lift_definition finfun_const :: "'b \<Rightarrow> 'a \<Rightarrow>f 'b" ("K$/ _" [0] 1)
   31.59  is "\<lambda> b x. b" by (rule const_finfun)
   31.60 @@ -287,7 +287,7 @@
   31.61  lemma finfun_update_const_same: "(K$ b)(a $:= b) = (K$ b)"
   31.62  by transfer (simp add: fun_eq_iff)
   31.63  
   31.64 -subsection {* Code generator setup *}
   31.65 +subsection \<open>Code generator setup\<close>
   31.66  
   31.67  definition finfun_update_code :: "'a \<Rightarrow>f 'b \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'a \<Rightarrow>f 'b"
   31.68  where [simp, code del]: "finfun_update_code = finfun_update"
   31.69 @@ -303,11 +303,11 @@
   31.70  by(simp add: finfun_update_twist)
   31.71  
   31.72  
   31.73 -subsection {* Setup for quickcheck *}
   31.74 +subsection \<open>Setup for quickcheck\<close>
   31.75  
   31.76  quickcheck_generator finfun constructors: finfun_update_code, "finfun_const :: 'b \<Rightarrow> 'a \<Rightarrow>f 'b"
   31.77  
   31.78 -subsection {* @{text "finfun_update"} as instance of @{text "comp_fun_commute"} *}
   31.79 +subsection \<open>@{text "finfun_update"} as instance of @{text "comp_fun_commute"}\<close>
   31.80  
   31.81  interpretation finfun_update: comp_fun_commute "\<lambda>a f. f(a :: 'a $:= b')"
   31.82    including finfun
   31.83 @@ -343,7 +343,7 @@
   31.84  qed
   31.85  
   31.86  
   31.87 -subsection {* Default value for FinFuns *}
   31.88 +subsection \<open>Default value for FinFuns\<close>
   31.89  
   31.90  definition finfun_default_aux :: "('a \<Rightarrow> 'b) \<Rightarrow> 'b"
   31.91  where [code del]: "finfun_default_aux f = (if finite (UNIV :: 'a set) then undefined else THE b. finite {a. f a \<noteq> b})"
   31.92 @@ -431,7 +431,7 @@
   31.93    "finfun_default (finfun_update_code f a b) = finfun_default f"
   31.94  by(simp add: finfun_default_update_const)
   31.95  
   31.96 -subsection {* Recursion combinator and well-formedness conditions *}
   31.97 +subsection \<open>Recursion combinator and well-formedness conditions\<close>
   31.98  
   31.99  definition finfun_rec :: "('b \<Rightarrow> 'c) \<Rightarrow> ('a \<Rightarrow> 'b \<Rightarrow> 'c \<Rightarrow> 'c) \<Rightarrow> ('a \<Rightarrow>f 'b) \<Rightarrow> 'c"
  31.100  where [code del]:
  31.101 @@ -469,13 +469,13 @@
  31.102    from fin anf fg show ?thesis
  31.103    proof(induct "dom f" arbitrary: f)
  31.104      case empty
  31.105 -    from `{} = dom f` have "f = empty" by(auto simp add: dom_def)
  31.106 +    from \<open>{} = dom f\<close> have "f = empty" by(auto simp add: dom_def)
  31.107      thus ?case by(simp add: finfun_const_def upd_const_same)
  31.108    next
  31.109      case (insert a' A)
  31.110 -    note IH = `\<And>f.  \<lbrakk> A = dom f; a \<notin> dom f; f \<subseteq>\<^sub>m g \<rbrakk> \<Longrightarrow> upd a d (?fr (dom f)) = ?fr (dom f)`
  31.111 -    note fin = `finite A` note anf = `a \<notin> dom f` note a'nA = `a' \<notin> A`
  31.112 -    note domf = `insert a' A = dom f` note fg = `f \<subseteq>\<^sub>m g`
  31.113 +    note IH = \<open>\<And>f.  \<lbrakk> A = dom f; a \<notin> dom f; f \<subseteq>\<^sub>m g \<rbrakk> \<Longrightarrow> upd a d (?fr (dom f)) = ?fr (dom f)\<close>
  31.114 +    note fin = \<open>finite A\<close> note anf = \<open>a \<notin> dom f\<close> note a'nA = \<open>a' \<notin> A\<close>
  31.115 +    note domf = \<open>insert a' A = dom f\<close> note fg = \<open>f \<subseteq>\<^sub>m g\<close>
  31.116      
  31.117      from domf obtain b where b: "f a' = Some b" by auto
  31.118      let ?f' = "f(a' := None)"
  31.119 @@ -485,7 +485,7 @@
  31.120      hence ga': "map_default d g a' = map_default d f a'" by(simp add: map_default_def)
  31.121      also from anf domf have "a \<noteq> a'" by auto note upd_commute[OF this]
  31.122      also from domf a'nA anf fg have "a \<notin> dom ?f'" "?f' \<subseteq>\<^sub>m g" and A: "A = dom ?f'" by(auto simp add: ran_def map_le_def)
  31.123 -    note A also note IH[OF A `a \<notin> dom ?f'` `?f' \<subseteq>\<^sub>m g`]
  31.124 +    note A also note IH[OF A \<open>a \<notin> dom ?f'\<close> \<open>?f' \<subseteq>\<^sub>m g\<close>]
  31.125      also have "upd a' (map_default d f a') (?fr (dom (f(a' := None)))) = ?fr (dom f)"
  31.126        unfolding domf[symmetric] gwf.fold_insert[OF fin a'nA] ga' unfolding A ..
  31.127      also have "insert a' (dom ?f') = dom f" using domf by auto
  31.128 @@ -507,13 +507,13 @@
  31.129    from fin anf fg show ?thesis
  31.130    proof(induct "dom f" arbitrary: f)
  31.131      case empty
  31.132 -    from `{} = dom f` have "f = empty" by(auto simp add: dom_def)
  31.133 +    from \<open>{} = dom f\<close> have "f = empty" by(auto simp add: dom_def)
  31.134      thus ?case by(auto simp add: finfun_const_def finfun_update_def upd_upd_twice)
  31.135    next
  31.136      case (insert a' A)
  31.137 -    note IH = `\<And>f. \<lbrakk>A = dom f; a \<notin> dom f; f \<subseteq>\<^sub>m g\<rbrakk> \<Longrightarrow> upd a d'' (upd a d' (?fr (dom f))) = upd a d'' (?fr (dom f))`
  31.138 -    note fin = `finite A` note anf = `a \<notin> dom f` note a'nA = `a' \<notin> A`
  31.139 -    note domf = `insert a' A = dom f` note fg = `f \<subseteq>\<^sub>m g`
  31.140 +    note IH = \<open>\<And>f. \<lbrakk>A = dom f; a \<notin> dom f; f \<subseteq>\<^sub>m g\<rbrakk> \<Longrightarrow> upd a d'' (upd a d' (?fr (dom f))) = upd a d'' (?fr (dom f))\<close>
  31.141 +    note fin = \<open>finite A\<close> note anf = \<open>a \<notin> dom f\<close> note a'nA = \<open>a' \<notin> A\<close>
  31.142 +    note domf = \<open>insert a' A = dom f\<close> note fg = \<open>f \<subseteq>\<^sub>m g\<close>
  31.143      
  31.144      from domf obtain b where b: "f a' = Some b" by auto
  31.145      let ?f' = "f(a' := None)"
  31.146 @@ -525,7 +525,7 @@
  31.147      also from anf domf have ana': "a \<noteq> a'" by auto note upd_commute[OF this]
  31.148      also note upd_commute[OF ana']
  31.149      also from domf a'nA anf fg have "a \<notin> dom ?f'" "?f' \<subseteq>\<^sub>m g" and A: "A = dom ?f'" by(auto simp add: ran_def map_le_def)
  31.150 -    note A also note IH[OF A `a \<notin> dom ?f'` `?f' \<subseteq>\<^sub>m g`]
  31.151 +    note A also note IH[OF A \<open>a \<notin> dom ?f'\<close> \<open>?f' \<subseteq>\<^sub>m g\<close>]
  31.152      also note upd_commute[OF ana'[symmetric]] also note ga'[symmetric] also note A[symmetric]
  31.153      also note gwf.fold_insert[symmetric, OF fin a'nA] also note domf
  31.154      finally show ?case .
  31.155 @@ -551,8 +551,8 @@
  31.156        case empty thus ?case by simp
  31.157      next
  31.158        case (insert a B)
  31.159 -      note finB = `finite B` note anB = `a \<notin> B` note sub = `insert a B \<subseteq> A`
  31.160 -      note IH = `B \<subseteq> A \<Longrightarrow> Finite_Set.fold f z B = Finite_Set.fold g z B`
  31.161 +      note finB = \<open>finite B\<close> note anB = \<open>a \<notin> B\<close> note sub = \<open>insert a B \<subseteq> A\<close>
  31.162 +      note IH = \<open>B \<subseteq> A \<Longrightarrow> Finite_Set.fold f z B = Finite_Set.fold g z B\<close>
  31.163        from sub anB have BpsubA: "B \<subset> A" and BsubA: "B \<subseteq> A" and aA: "a \<in> A" by auto
  31.164        from IH[OF BsubA] eq[OF aA] finB anB
  31.165        show ?case by(auto)
  31.166 @@ -770,7 +770,7 @@
  31.167        with True show "g' = empty"
  31.168          by -(rule map_default_inject(2)[OF _ fin g], auto)
  31.169      qed
  31.170 -    show ?thesis unfolding finfun_rec_def using `finite UNIV` True
  31.171 +    show ?thesis unfolding finfun_rec_def using \<open>finite UNIV\<close> True
  31.172        unfolding Let_def the default by(simp)
  31.173    next
  31.174      case False
  31.175 @@ -797,7 +797,7 @@
  31.176  
  31.177  end
  31.178  
  31.179 -subsection {* Weak induction rule and case analysis for FinFuns *}
  31.180 +subsection \<open>Weak induction rule and case analysis for FinFuns\<close>
  31.181  
  31.182  lemma finfun_weak_induct [consumes 0, case_names const update]:
  31.183    assumes const: "\<And>b. P (K$ b)"
  31.184 @@ -807,7 +807,7 @@
  31.185  proof(induct x rule: Abs_finfun_induct)
  31.186    case (Abs_finfun y)
  31.187    then obtain b where "finite {a. y a \<noteq> b}" unfolding finfun_def by blast
  31.188 -  thus ?case using `y \<in> finfun`
  31.189 +  thus ?case using \<open>y \<in> finfun\<close>
  31.190    proof(induct "{a. y a \<noteq> b}" arbitrary: y rule: finite_induct)
  31.191      case empty
  31.192      hence "\<And>a. y a = b" by blast
  31.193 @@ -816,9 +816,9 @@
  31.194      thus ?case by(simp add: const)
  31.195    next
  31.196      case (insert a A)
  31.197 -    note IH = `\<And>y. \<lbrakk> A = {a. y a \<noteq> b}; y \<in> finfun  \<rbrakk> \<Longrightarrow> P (Abs_finfun y)`
  31.198 -    note y = `y \<in> finfun`
  31.199 -    with `insert a A = {a. y a \<noteq> b}` `a \<notin> A`
  31.200 +    note IH = \<open>\<And>y. \<lbrakk> A = {a. y a \<noteq> b}; y \<in> finfun  \<rbrakk> \<Longrightarrow> P (Abs_finfun y)\<close>
  31.201 +    note y = \<open>y \<in> finfun\<close>
  31.202 +    with \<open>insert a A = {a. y a \<noteq> b}\<close> \<open>a \<notin> A\<close>
  31.203      have "A = {a'. (y(a := b)) a' \<noteq> b}" "y(a := b) \<in> finfun" by auto
  31.204      from IH[OF this] have "P (finfun_update (Abs_finfun (y(a := b))) a (y a))" by(rule update)
  31.205      thus ?case using y unfolding finfun_update_def by simp
  31.206 @@ -847,7 +847,7 @@
  31.207  qed
  31.208  
  31.209  
  31.210 -subsection {* Function application *}
  31.211 +subsection \<open>Function application\<close>
  31.212  
  31.213  notation finfun_apply (infixl "$" 999)
  31.214  
  31.215 @@ -905,7 +905,7 @@
  31.216    "((K$ b) = f(a $:= b')) = (b = b' \<and> (\<forall>a'. a \<noteq> a' \<longrightarrow> f $ a' = b))"
  31.217  by(auto simp add: expand_finfun_eq fun_eq_iff finfun_upd_apply)
  31.218  
  31.219 -subsection {* Function composition *}
  31.220 +subsection \<open>Function composition\<close>
  31.221  
  31.222  definition finfun_comp :: "('a \<Rightarrow> 'b) \<Rightarrow> 'c \<Rightarrow>f 'a \<Rightarrow> 'c \<Rightarrow>f 'b" (infixr "o$" 55)
  31.223  where [code del]: "g o$ f  = finfun_rec (\<lambda>b. (K$ g b)) (\<lambda>a b c. c(a $:= g b)) f"
  31.224 @@ -991,7 +991,7 @@
  31.225    with False show ?thesis by(auto simp add: finfun_comp2_def finfun_update_def)
  31.226  qed
  31.227  
  31.228 -subsection {* Universal quantification *}
  31.229 +subsection \<open>Universal quantification\<close>
  31.230  
  31.231  definition finfun_All_except :: "'a list \<Rightarrow> 'a \<Rightarrow>f bool \<Rightarrow> bool"
  31.232  where [code del]: "finfun_All_except A P \<equiv> \<forall>a. a \<in> set A \<or> P $ a"
  31.233 @@ -1035,7 +1035,7 @@
  31.234  by(simp add: finfun_Ex_def)
  31.235  
  31.236  
  31.237 -subsection {* A diagonal operator for FinFuns *}
  31.238 +subsection \<open>A diagonal operator for FinFuns\<close>
  31.239  
  31.240  definition finfun_Diag :: "'a \<Rightarrow>f 'b \<Rightarrow> 'a \<Rightarrow>f 'c \<Rightarrow> 'a \<Rightarrow>f ('b \<times> 'c)" ("(1'($_,/ _$'))" [0, 0] 1000)
  31.241  where [code del]: "($f, g$) = finfun_rec (\<lambda>b. Pair b \<circ>$ g) (\<lambda>a b c. c(a $:= (b, g $ a))) f"
  31.242 @@ -1061,9 +1061,9 @@
  31.243  lemma finfun_Diag_const1: "($K$ b, g$) = Pair b \<circ>$ g"
  31.244  by(simp add: finfun_Diag_def)
  31.245  
  31.246 -text {*
  31.247 +text \<open>
  31.248    Do not use @{thm finfun_Diag_const1} for the code generator because @{term "Pair b"} is injective, i.e. if @{term g} is free of redundant updates, there is no need to check for redundant updates as is done for @{term "op \<circ>$"}.
  31.249 -*}
  31.250 +\<close>
  31.251  
  31.252  lemma finfun_Diag_const_code [code]:
  31.253    "($K$ b, K$ c$) = (K$ (b, c))"
  31.254 @@ -1161,7 +1161,7 @@
  31.255  lemma finfun_Diag_collapse [simp]: "($finfun_fst f, finfun_snd f$) = f"
  31.256  by(induct f rule: finfun_weak_induct)(simp_all add: finfun_fst_const finfun_snd_const finfun_fst_update finfun_snd_update finfun_Diag_update_update)
  31.257  
  31.258 -subsection {* Currying for FinFuns *}
  31.259 +subsection \<open>Currying for FinFuns\<close>
  31.260  
  31.261  definition finfun_curry :: "('a \<times> 'b) \<Rightarrow>f 'c \<Rightarrow> 'a \<Rightarrow>f 'b \<Rightarrow>f 'c"
  31.262  where [code del]: "finfun_curry = finfun_rec (finfun_const \<circ> finfun_const) (\<lambda>(a, b) c f. f(a $:= (f $ a)(b $:= c)))"
  31.263 @@ -1234,7 +1234,7 @@
  31.264    thus ?thesis by(auto simp add: fun_eq_iff)
  31.265  qed
  31.266  
  31.267 -subsection {* Executable equality for FinFuns *}
  31.268 +subsection \<open>Executable equality for FinFuns\<close>
  31.269  
  31.270  lemma eq_finfun_All_ext: "(f = g) \<longleftrightarrow> finfun_All ((\<lambda>(x, y). x = y) \<circ>$ ($f, g$))"
  31.271  by(simp add: expand_finfun_eq fun_eq_iff finfun_All_All o_def)
  31.272 @@ -1248,7 +1248,7 @@
  31.273    "HOL.equal (f :: _ \<Rightarrow>f _) f \<longleftrightarrow> True"
  31.274    by (fact equal_refl)
  31.275  
  31.276 -subsection {* An operator that explicitly removes all redundant updates in the generated representations *}
  31.277 +subsection \<open>An operator that explicitly removes all redundant updates in the generated representations\<close>
  31.278  
  31.279  definition finfun_clearjunk :: "'a \<Rightarrow>f 'b \<Rightarrow> 'a \<Rightarrow>f 'b"
  31.280  where [simp, code del]: "finfun_clearjunk = id"
  31.281 @@ -1260,7 +1260,7 @@
  31.282    "finfun_clearjunk (finfun_update_code f a b) = f(a $:= b)"
  31.283  by simp
  31.284  
  31.285 -subsection {* The domain of a FinFun as a FinFun *}
  31.286 +subsection \<open>The domain of a FinFun as a FinFun\<close>
  31.287  
  31.288  definition finfun_dom :: "('a \<Rightarrow>f 'b) \<Rightarrow> ('a \<Rightarrow>f bool)"
  31.289  where [code del]: "finfun_dom f = Abs_finfun (\<lambda>a. f $ a \<noteq> finfun_default f)"
  31.290 @@ -1270,10 +1270,10 @@
  31.291  unfolding finfun_dom_def finfun_default_const
  31.292  by(auto)(simp_all add: finfun_const_def)
  31.293  
  31.294 -text {*
  31.295 +text \<open>
  31.296    @{term "finfun_dom" } raises an exception when called on a FinFun whose domain is a finite type. 
  31.297    For such FinFuns, the default value (and as such the domain) is undefined.
  31.298 -*}
  31.299 +\<close>
  31.300  
  31.301  lemma finfun_dom_const_code [code]:
  31.302    "finfun_dom ((K$ c) :: ('a :: card_UNIV) \<Rightarrow>f 'b) = 
  31.303 @@ -1311,7 +1311,7 @@
  31.304  qed
  31.305  
  31.306  
  31.307 -subsection {* The domain of a FinFun as a sorted list *}
  31.308 +subsection \<open>The domain of a FinFun as a sorted list\<close>
  31.309  
  31.310  definition finfun_to_list :: "('a :: linorder) \<Rightarrow>f 'b \<Rightarrow> 'a list"
  31.311  where
  31.312 @@ -1422,7 +1422,7 @@
  31.313          assume "set xs' = {x. finfun_dom f $ x} \<and> sorted xs' \<and> distinct xs'"
  31.314          thus "xs' = remove1 a xs" using 1 by(blast intro: sorted_distinct_set_unique)
  31.315        qed
  31.316 -      thus ?thesis using False eq `b \<noteq> finfun_default f` 
  31.317 +      thus ?thesis using False eq \<open>b \<noteq> finfun_default f\<close> 
  31.318          by (simp add: insort_insert_insort insort_remove1)
  31.319      qed
  31.320    qed
  31.321 @@ -1433,7 +1433,7 @@
  31.322    (if b = finfun_default f then List.remove1 a (finfun_to_list f) else List.insort_insert a (finfun_to_list f))"
  31.323  by(simp add: finfun_to_list_update)
  31.324  
  31.325 -text {* More type class instantiations *}
  31.326 +text \<open>More type class instantiations\<close>
  31.327  
  31.328  lemma card_eq_1_iff: "card A = 1 \<longleftrightarrow> A \<noteq> {} \<and> (\<forall>x\<in>A. \<forall>y\<in>A. x = y)"
  31.329    (is "?lhs \<longleftrightarrow> ?rhs")
  31.330 @@ -1442,11 +1442,11 @@
  31.331    moreover {
  31.332      fix x y
  31.333      assume A: "x \<in> A" "y \<in> A" and neq: "x \<noteq> y"
  31.334 -    have "finite A" using `?lhs` by(simp add: card_ge_0_finite)
  31.335 +    have "finite A" using \<open>?lhs\<close> by(simp add: card_ge_0_finite)
  31.336      from neq have "2 = card {x, y}" by simp
  31.337 -    also have "\<dots> \<le> card A" using A `finite A`
  31.338 +    also have "\<dots> \<le> card A" using A \<open>finite A\<close>
  31.339        by(auto intro: card_mono)
  31.340 -    finally have False using `?lhs` by simp }
  31.341 +    finally have False using \<open>?lhs\<close> by simp }
  31.342    ultimately show ?rhs by auto
  31.343  next
  31.344    assume ?rhs
  31.345 @@ -1486,9 +1486,9 @@
  31.346        unfolding type_definition.Abs_image[OF type_definition_finfun, symmetric] F_def
  31.347        by(rule finite_imageD)(auto intro: inj_onI simp add: Abs_finfun_inject)
  31.348      hence "finite (range ?f)" 
  31.349 -      by(rule finite_subset[rotated 1])(auto simp add: F_def finfun_def `b1 \<noteq> b2` intro!: exI[where x=b2])
  31.350 +      by(rule finite_subset[rotated 1])(auto simp add: F_def finfun_def \<open>b1 \<noteq> b2\<close> intro!: exI[where x=b2])
  31.351      thus "finite (UNIV :: 'a set)"
  31.352 -      by(rule finite_imageD)(auto intro: inj_onI simp add: fun_eq_iff `b1 \<noteq> b2` split: split_if_asm)
  31.353 +      by(rule finite_imageD)(auto intro: inj_onI simp add: fun_eq_iff \<open>b1 \<noteq> b2\<close> split: split_if_asm)
  31.354      
  31.355      from finite have "finite (range (\<lambda>b. ((K$ b) :: 'a \<Rightarrow>f 'b)))"
  31.356        by(rule finite_subset[rotated 1]) simp
  31.357 @@ -1526,7 +1526,7 @@
  31.358  instance by intro_classes (simp add: card_UNIV_finfun_def card_UNIV Let_def card_UNIV_finfun)
  31.359  end
  31.360  
  31.361 -text {* Deactivate syntax again. Import theory @{text FinFun_Syntax} to reactivate it again *}
  31.362 +text \<open>Deactivate syntax again. Import theory @{text FinFun_Syntax} to reactivate it again\<close>
  31.363  
  31.364  no_type_notation
  31.365    finfun ("(_ =>f /_)" [22, 21] 21)
    32.1 --- a/src/HOL/Library/FinFun_Syntax.thy	Wed Jun 17 17:33:22 2015 +0200
    32.2 +++ b/src/HOL/Library/FinFun_Syntax.thy	Wed Jun 17 17:54:09 2015 +0200
    32.3 @@ -1,6 +1,6 @@
    32.4  (* Author: Andreas Lochbihler, KIT *)
    32.5  
    32.6 -section {* Pretty syntax for almost everywhere constant functions *}
    32.7 +section \<open>Pretty syntax for almost everywhere constant functions\<close>
    32.8  
    32.9  theory FinFun_Syntax
   32.10  imports FinFun
    33.1 --- a/src/HOL/Library/Finite_Lattice.thy	Wed Jun 17 17:33:22 2015 +0200
    33.2 +++ b/src/HOL/Library/Finite_Lattice.thy	Wed Jun 17 17:54:09 2015 +0200
    33.3 @@ -6,7 +6,7 @@
    33.4  imports Product_Order
    33.5  begin
    33.6  
    33.7 -text {* A non-empty finite lattice is a complete lattice.
    33.8 +text \<open>A non-empty finite lattice is a complete lattice.
    33.9  Since types are never empty in Isabelle/HOL,
   33.10  a type of classes @{class finite} and @{class lattice}
   33.11  should also have class @{class complete_lattice}.
   33.12 @@ -15,7 +15,7 @@
   33.13  with the operators @{const bot}, @{const top}, @{const Inf}, and @{const Sup},
   33.14  along with assumptions that define these operators
   33.15  in terms of the ones of classes @{class finite} and @{class lattice}.
   33.16 -The resulting class is a subclass of @{class complete_lattice}. *}
   33.17 +The resulting class is a subclass of @{class complete_lattice}.\<close>
   33.18  
   33.19  class finite_lattice_complete = finite + lattice + bot + top + Inf + Sup +
   33.20    assumes bot_def: "bot = Inf_fin UNIV"
   33.21 @@ -23,10 +23,10 @@
   33.22    assumes Inf_def: "Inf A = Finite_Set.fold inf top A"
   33.23    assumes Sup_def: "Sup A = Finite_Set.fold sup bot A"
   33.24  
   33.25 -text {* The definitional assumptions
   33.26 +text \<open>The definitional assumptions
   33.27  on the operators @{const bot} and @{const top}
   33.28  of class @{class finite_lattice_complete}
   33.29 -ensure that they yield bottom and top. *}
   33.30 +ensure that they yield bottom and top.\<close>
   33.31  
   33.32  lemma finite_lattice_complete_bot_least: "(bot::'a::finite_lattice_complete) \<le> x"
   33.33    by (auto simp: bot_def intro: Inf_fin.coboundedI)
   33.34 @@ -42,10 +42,10 @@
   33.35  
   33.36  instance finite_lattice_complete \<subseteq> bounded_lattice ..
   33.37  
   33.38 -text {* The definitional assumptions
   33.39 +text \<open>The definitional assumptions
   33.40  on the operators @{const Inf} and @{const Sup}
   33.41  of class @{class finite_lattice_complete}
   33.42 -ensure that they yield infimum and supremum. *}
   33.43 +ensure that they yield infimum and supremum.\<close>
   33.44  
   33.45  lemma finite_lattice_complete_Inf_empty: "Inf {} = (top :: 'a::finite_lattice_complete)"
   33.46    by (simp add: Inf_def)
   33.47 @@ -101,7 +101,7 @@
   33.48    finite_lattice_complete_Inf_empty
   33.49    finite_lattice_complete_Sup_empty)
   33.50  
   33.51 -text {* The product of two finite lattices is already a finite lattice. *}
   33.52 +text \<open>The product of two finite lattices is already a finite lattice.\<close>
   33.53  
   33.54  lemma finite_bot_prod:
   33.55    "(bot :: ('a::finite_lattice_complete \<times> 'b::finite_lattice_complete)) =
   33.56 @@ -126,8 +126,8 @@
   33.57  instance prod :: (finite_lattice_complete, finite_lattice_complete) finite_lattice_complete
   33.58    by default (auto simp: finite_bot_prod finite_top_prod finite_Inf_prod finite_Sup_prod)
   33.59  
   33.60 -text {* Functions with a finite domain and with a finite lattice as codomain
   33.61 -already form a finite lattice. *}
   33.62 +text \<open>Functions with a finite domain and with a finite lattice as codomain
   33.63 +already form a finite lattice.\<close>
   33.64  
   33.65  lemma finite_bot_fun: "(bot :: ('a::finite \<Rightarrow> 'b::finite_lattice_complete)) = Inf_fin UNIV"
   33.66    by (metis Inf_UNIV Inf_fin_Inf empty_not_UNIV finite_code)
   33.67 @@ -149,11 +149,11 @@
   33.68    by default (auto simp: finite_bot_fun finite_top_fun finite_Inf_fun finite_Sup_fun)
   33.69  
   33.70  
   33.71 -subsection {* Finite Distributive Lattices *}
   33.72 +subsection \<open>Finite Distributive Lattices\<close>
   33.73  
   33.74 -text {* A finite distributive lattice is a complete lattice
   33.75 +text \<open>A finite distributive lattice is a complete lattice
   33.76  whose @{const inf} and @{const sup} operators
   33.77 -distribute over @{const Sup} and @{const Inf}. *}
   33.78 +distribute over @{const Sup} and @{const Inf}.\<close>
   33.79  
   33.80  class finite_distrib_lattice_complete =
   33.81    distrib_lattice + finite_lattice_complete
   33.82 @@ -177,42 +177,42 @@
   33.83    finite_distrib_lattice_complete_sup_Inf
   33.84    finite_distrib_lattice_complete_inf_Sup)
   33.85  
   33.86 -text {* The product of two finite distributive lattices
   33.87 -is already a finite distributive lattice. *}
   33.88 +text \<open>The product of two finite distributive lattices
   33.89 +is already a finite distributive lattice.\<close>
   33.90  
   33.91  instance prod ::
   33.92    (finite_distrib_lattice_complete, finite_distrib_lattice_complete)
   33.93    finite_distrib_lattice_complete
   33.94    ..
   33.95  
   33.96 -text {* Functions with a finite domain
   33.97 +text \<open>Functions with a finite domain
   33.98  and with a finite distributive lattice as codomain
   33.99 -already form a finite distributive lattice. *}
  33.100 +already form a finite distributive lattice.\<close>
  33.101  
  33.102  instance "fun" ::
  33.103    (finite, finite_distrib_lattice_complete) finite_distrib_lattice_complete
  33.104    ..
  33.105  
  33.106  
  33.107 -subsection {* Linear Orders *}
  33.108 +subsection \<open>Linear Orders\<close>
  33.109  
  33.110 -text {* A linear order is a distributive lattice.
  33.111 +text \<open>A linear order is a distributive lattice.
  33.112  A type class is defined
  33.113  that extends class @{class linorder}
  33.114  with the operators @{const inf} and @{const sup},
  33.115  along with assumptions that define these operators
  33.116  in terms of the ones of class @{class linorder}.
  33.117 -The resulting class is a subclass of @{class distrib_lattice}. *}
  33.118 +The resulting class is a subclass of @{class distrib_lattice}.\<close>
  33.119  
  33.120  class linorder_lattice = linorder + inf + sup +
  33.121    assumes inf_def: "inf x y = (if x \<le> y then x else y)"
  33.122    assumes sup_def: "sup x y = (if x \<ge> y then x else y)"
  33.123  
  33.124 -text {* The definitional assumptions
  33.125 +text \<open>The definitional assumptions
  33.126  on the operators @{const inf} and @{const sup}
  33.127  of class @{class linorder_lattice}
  33.128  ensure that they yield infimum and supremum
  33.129 -and that they distribute over each other. *}
  33.130 +and that they distribute over each other.\<close>
  33.131  
  33.132  lemma linorder_lattice_inf_le1: "inf (x::'a::linorder_lattice) y \<le> x"
  33.133    unfolding inf_def by (metis (full_types) linorder_linear)
  33.134 @@ -250,17 +250,17 @@
  33.135    linorder_lattice_sup_inf_distrib1)
  33.136  
  33.137  
  33.138 -subsection {* Finite Linear Orders *}
  33.139 +subsection \<open>Finite Linear Orders\<close>
  33.140  
  33.141 -text {* A (non-empty) finite linear order is a complete linear order. *}
  33.142 +text \<open>A (non-empty) finite linear order is a complete linear order.\<close>
  33.143  
  33.144  class finite_linorder_complete = linorder_lattice + finite_lattice_complete
  33.145  
  33.146  instance finite_linorder_complete \<subseteq> complete_linorder ..
  33.147  
  33.148 -text {* A (non-empty) finite linear order is a complete lattice
  33.149 +text \<open>A (non-empty) finite linear order is a complete lattice
  33.150  whose @{const inf} and @{const sup} operators
  33.151 -distribute over @{const Sup} and @{const Inf}. *}
  33.152 +distribute over @{const Sup} and @{const Inf}.\<close>
  33.153  
  33.154  instance finite_linorder_complete \<subseteq> finite_distrib_lattice_complete ..
  33.155  
    34.1 --- a/src/HOL/Library/Float.thy	Wed Jun 17 17:33:22 2015 +0200
    34.2 +++ b/src/HOL/Library/Float.thy	Wed Jun 17 17:54:09 2015 +0200
    34.3 @@ -3,7 +3,7 @@
    34.4      Copyright   2012  TU München
    34.5  *)
    34.6  
    34.7 -section {* Floating-Point Numbers *}
    34.8 +section \<open>Floating-Point Numbers\<close>
    34.9  
   34.10  theory Float
   34.11  imports Complex_Main Lattice_Algebras
   34.12 @@ -43,7 +43,7 @@
   34.13  lemma real_float[simp]: "x \<in> float \<Longrightarrow> real (float_of x) = x"
   34.14    unfolding real_of_float_def by (rule float_of_inverse)
   34.15  
   34.16 -subsection {* Real operations preserving the representation as floating point number *}
   34.17 +subsection \<open>Real operations preserving the representation as floating point number\<close>
   34.18  
   34.19  lemma floatI: fixes m e :: int shows "m * 2 powr e = x \<Longrightarrow> x \<in> float"
   34.20    by (auto simp: float_def)
   34.21 @@ -161,7 +161,7 @@
   34.22  
   34.23  code_datatype Float
   34.24  
   34.25 -subsection {* Arithmetic operations on floating point numbers *}
   34.26 +subsection \<open>Arithmetic operations on floating point numbers\<close>
   34.27  
   34.28  instantiation float :: "{ring_1, linorder, linordered_ring, linordered_idom, numeral, equal}"
   34.29  begin
   34.30 @@ -264,7 +264,7 @@
   34.31      and float_of_neg_numeral[simp]: "- numeral k = float_of (- numeral k)"
   34.32    unfolding real_of_float_eq by simp_all
   34.33  
   34.34 -subsection {* Quickcheck *}
   34.35 +subsection \<open>Quickcheck\<close>
   34.36  
   34.37  instantiation float :: exhaustive
   34.38  begin
   34.39 @@ -304,7 +304,7 @@
   34.40  end
   34.41  
   34.42  
   34.43 -subsection {* Represent floats as unique mantissa and exponent *}
   34.44 +subsection \<open>Represent floats as unique mantissa and exponent\<close>
   34.45  
   34.46  lemma int_induct_abs[case_names less]:
   34.47    fixes j :: int
   34.48 @@ -320,7 +320,7 @@
   34.49    case (less n)
   34.50    { fix m assume n: "n \<noteq> 0" "n = m * r"
   34.51      then have "\<bar>m \<bar> < \<bar>n\<bar>"
   34.52 -      using `1 < r` by (simp add: abs_mult)
   34.53 +      using \<open>1 < r\<close> by (simp add: abs_mult)
   34.54      from less[OF this] n have "\<exists>k i. n = k * r ^ Suc i \<and> \<not> r dvd k" by auto }
   34.55    then show ?case
   34.56      by (metis dvd_def monoid_mult_class.mult.right_neutral mult.commute power_0)
   34.57 @@ -333,7 +333,7 @@
   34.58  proof
   34.59    have "m1 \<noteq> 0" using m1 unfolding dvd_def by auto
   34.60    assume eq: "m1 * 2 powr e1 = m2 * 2 powr e2"
   34.61 -  with `e1 \<le> e2` have "m1 = m2 * 2 powr nat (e2 - e1)"
   34.62 +  with \<open>e1 \<le> e2\<close> have "m1 = m2 * 2 powr nat (e2 - e1)"
   34.63      by (simp add: powr_divide2[symmetric] field_simps)
   34.64    also have "\<dots> = m2 * 2^nat (e2 - e1)"
   34.65      by (simp add: powr_realpow)
   34.66 @@ -342,7 +342,7 @@
   34.67    with m1 have "m1 = m2"
   34.68      by (cases "nat (e2 - e1)") (auto simp add: dvd_def)
   34.69    then show "m1 = m2 \<and> e1 = e2"
   34.70 -    using eq `m1 \<noteq> 0` by (simp add: powr_inj)
   34.71 +    using eq \<open>m1 \<noteq> 0\<close> by (simp add: powr_inj)
   34.72  qed simp
   34.73  
   34.74  lemma mult_powr_eq_mult_powr_iff:
   34.75 @@ -359,9 +359,9 @@
   34.76  proof atomize_elim
   34.77    { assume "x \<noteq> 0"
   34.78      from x obtain m e :: int where x: "x = m * 2 powr e" by (auto simp: float_def)
   34.79 -    with `x \<noteq> 0` int_cancel_factors[of 2 m] obtain k i where "m = k * 2 ^ i" "\<not> 2 dvd k"
   34.80 +    with \<open>x \<noteq> 0\<close> int_cancel_factors[of 2 m] obtain k i where "m = k * 2 ^ i" "\<not> 2 dvd k"
   34.81        by auto
   34.82 -    with `\<not> 2 dvd k` x have "\<exists>(m::int) (e::int). x = m * 2 powr e \<and> \<not> (2::int) dvd m"
   34.83 +    with \<open>\<not> 2 dvd k\<close> x have "\<exists>(m::int) (e::int). x = m * 2 powr e \<and> \<not> (2::int) dvd m"
   34.84        by (rule_tac exI[of _ "k"], rule_tac exI[of _ "e + int i"])
   34.85           (simp add: powr_add powr_realpow) }
   34.86    then show "x = 0 \<or> (\<exists>(m::int) (e::int). x = m * 2 powr e \<and> \<not> (2::int) dvd m \<and> x \<noteq> 0)"
   34.87 @@ -434,7 +434,7 @@
   34.88      by (auto simp: mult_powr_eq_mult_powr_iff)
   34.89  qed
   34.90  
   34.91 -subsection {* Compute arithmetic operations *}
   34.92 +subsection \<open>Compute arithmetic operations\<close>
   34.93  
   34.94  lemma Float_mantissa_exponent: "Float (mantissa f) (exponent f) = f"
   34.95    unfolding real_of_float_eq mantissa_exponent[of f] by simp
   34.96 @@ -467,7 +467,7 @@
   34.97        using eq by simp
   34.98      then have "mantissa f = m * 2^nat (e - exponent f)"
   34.99        unfolding real_of_int_inject by simp
  34.100 -    with `exponent f < e` have "2 dvd mantissa f"
  34.101 +    with \<open>exponent f < e\<close> have "2 dvd mantissa f"
  34.102        apply (intro dvdI[where k="m * 2^(nat (e-exponent f)) div 2"])
  34.103        apply (cases "nat (e - exponent f)")
  34.104        apply auto
  34.105 @@ -476,7 +476,7 @@
  34.106    qed
  34.107    ultimately have "real m = mantissa f * 2^nat (exponent f - e)"
  34.108      by (simp add: powr_realpow[symmetric])
  34.109 -  with `e \<le> exponent f`
  34.110 +  with \<open>e \<le> exponent f\<close>
  34.111    show "m = mantissa f * 2 ^ nat (exponent f - e)" "e = exponent f - nat (exponent f - e)"
  34.112      unfolding real_of_int_inject by auto
  34.113  qed
  34.114 @@ -564,7 +564,7 @@
  34.115  hide_fact (open) compute_float_eq
  34.116  
  34.117  
  34.118 -subsection {* Lemmas for types @{typ real}, @{typ nat}, @{typ int}*}
  34.119 +subsection \<open>Lemmas for types @{typ real}, @{typ nat}, @{typ int}\<close>
  34.120  
  34.121  lemmas real_of_ints =
  34.122    real_of_int_zero
  34.123 @@ -588,7 +588,7 @@
  34.124  lemmas nat_of_reals = real_of_nats[symmetric]
  34.125  
  34.126  
  34.127 -subsection {* Rounding Real Numbers *}
  34.128 +subsection \<open>Rounding Real Numbers\<close>
  34.129  
  34.130  definition round_down :: "int \<Rightarrow> real \<Rightarrow> real" where
  34.131    "round_down prec x = floor (x * 2 powr prec) * 2 powr -prec"
  34.132 @@ -663,9 +663,9 @@
  34.133  proof -
  34.134    have "x * 2 powr p < 1 / 2 * 2 powr p"
  34.135      using assms by simp
  34.136 -  also have "\<dots> \<le> 2 powr p - 1" using `p > 0`
  34.137 +  also have "\<dots> \<le> 2 powr p - 1" using \<open>p > 0\<close>
  34.138      by (auto simp: powr_divide2[symmetric] powr_int field_simps self_le_power)
  34.139 -  finally show ?thesis using `p > 0`
  34.140 +  finally show ?thesis using \<open>p > 0\<close>
  34.141      by (simp add: round_up_def field_simps powr_minus powr_int ceiling_less_eq)
  34.142  qed
  34.143  
  34.144 @@ -705,7 +705,7 @@
  34.145    by (auto simp: field_simps mult_le_0_iff zero_le_mult_iff)
  34.146  
  34.147  
  34.148 -subsection {* Rounding Floats *}
  34.149 +subsection \<open>Rounding Floats\<close>
  34.150  
  34.151  definition div_twopow::"int \<Rightarrow> nat \<Rightarrow> int" where [simp]: "div_twopow x n = x div (2 ^ n)"
  34.152  
  34.153 @@ -763,7 +763,7 @@
  34.154    also have "... = 1 / 2 powr p / 2 powr e"
  34.155      unfolding powr_minus_divide real_of_int_minus by (simp add: powr_add)
  34.156    finally show ?thesis
  34.157 -    using `p + e < 0`
  34.158 +    using \<open>p + e < 0\<close>
  34.159      by transfer (simp add: ac_simps round_down_def floor_divide_eq_div[symmetric])
  34.160  next
  34.161    assume "\<not> p + e < 0"
  34.162 @@ -771,7 +771,7 @@
  34.163    have r: "\<lfloor>(m * 2 powr e) * 2 powr real p\<rfloor> = (m * 2 powr e) * 2 powr real p"
  34.164      by (auto intro: exI[where x="m*2^nat (e+p)"]
  34.165               simp add: ac_simps powr_add[symmetric] r powr_realpow)
  34.166 -  with `\<not> p + e < 0` show ?thesis
  34.167 +  with \<open>\<not> p + e < 0\<close> show ?thesis
  34.168      by transfer (auto simp add: round_down_def field_simps powr_add powr_minus)
  34.169  qed
  34.170  hide_fact (open) compute_float_down
  34.171 @@ -791,16 +791,16 @@
  34.172  proof cases
  34.173    assume "\<not> b dvd a"
  34.174    hence "a mod b \<noteq> 0" by auto
  34.175 -  hence ne: "real (a mod b) / real b \<noteq> 0" using `b \<noteq> 0` by auto
  34.176 +  hence ne: "real (a mod b) / real b \<noteq> 0" using \<open>b \<noteq> 0\<close> by auto
  34.177    have "\<lceil>real a / real b\<rceil> = \<lfloor>real a / real b\<rfloor> + 1"
  34.178    apply (rule ceiling_eq) apply (auto simp: floor_divide_eq_div[symmetric])
  34.179    proof -
  34.180      have "real \<lfloor>real a / real b\<rfloor> \<le> real a / real b" by simp
  34.181      moreover have "real \<lfloor>real a / real b\<rfloor> \<noteq> real a / real b"
  34.182 -    apply (subst (2) real_of_int_div_aux) unfolding floor_divide_eq_div using ne `b \<noteq> 0` by auto
  34.183 +    apply (subst (2) real_of_int_div_aux) unfolding floor_divide_eq_div using ne \<open>b \<noteq> 0\<close> by auto
  34.184      ultimately show "real \<lfloor>real a / real b\<rfloor> < real a / real b" by arith
  34.185    qed
  34.186 -  thus ?thesis using `\<not> b dvd a` by simp
  34.187 +  thus ?thesis using \<open>\<not> b dvd a\<close> by simp
  34.188  qed (simp add: ceiling_def real_of_int_minus[symmetric] divide_minus_left[symmetric]
  34.189    floor_divide_eq_div dvd_neg_div del: divide_minus_left real_of_int_minus)
  34.190  
  34.191 @@ -810,7 +810,7 @@
  34.192  hide_fact (open) compute_float_up
  34.193  
  34.194  
  34.195 -subsection {* Compute bitlen of integers *}
  34.196 +subsection \<open>Compute bitlen of integers\<close>
  34.197  
  34.198  definition bitlen :: "int \<Rightarrow> int" where
  34.199    "bitlen a = (if a > 0 then \<lfloor>log 2 a\<rfloor> + 1 else 0)"
  34.200 @@ -820,7 +820,7 @@
  34.201    {
  34.202      assume "0 > x"
  34.203      have "-1 = log 2 (inverse 2)" by (subst log_inverse) simp_all
  34.204 -    also have "... < log 2 (-x)" using `0 > x` by auto
  34.205 +    also have "... < log 2 (-x)" using \<open>0 > x\<close> by auto
  34.206      finally have "-1 < log 2 (-x)" .
  34.207    } thus "0 \<le> bitlen x" unfolding bitlen_def by (auto intro!: add_nonneg_nonneg)
  34.208  qed
  34.209 @@ -830,22 +830,22 @@
  34.210    shows "2 ^ nat (bitlen x - 1) \<le> x \<and> x < 2 ^ nat (bitlen x)"
  34.211  proof
  34.212    have "(2::real) ^ nat \<lfloor>log 2 (real x)\<rfloor> = 2 powr real (floor (log 2 (real x)))"
  34.213 -    using powr_realpow[symmetric, of 2 "nat \<lfloor>log 2 (real x)\<rfloor>"] `x > 0`
  34.214 +    using powr_realpow[symmetric, of 2 "nat \<lfloor>log 2 (real x)\<rfloor>"] \<open>x > 0\<close>
  34.215      using real_nat_eq_real[of "floor (log 2 (real x))"]
  34.216      by simp
  34.217    also have "... \<le> 2 powr log 2 (real x)"
  34.218      by simp
  34.219    also have "... = real x"
  34.220 -    using `0 < x` by simp
  34.221 +    using \<open>0 < x\<close> by simp
  34.222    finally have "2 ^ nat \<lfloor>log 2 (real x)\<rfloor> \<le> real x" by simp
  34.223 -  thus "2 ^ nat (bitlen x - 1) \<le> x" using `x > 0`
  34.224 +  thus "2 ^ nat (bitlen x - 1) \<le> x" using \<open>x > 0\<close>
  34.225      by (simp add: bitlen_def)
  34.226  next
  34.227 -  have "x \<le> 2 powr (log 2 x)" using `x > 0` by simp
  34.228 +  have "x \<le> 2 powr (log 2 x)" using \<open>x > 0\<close> by simp
  34.229    also have "... < 2 ^ nat (\<lfloor>log 2 (real x)\<rfloor> + 1)"
  34.230      apply (simp add: powr_realpow[symmetric])
  34.231 -    using `x > 0` by simp
  34.232 -  finally show "x < 2 ^ nat (bitlen x)" using `x > 0`
  34.233 +    using \<open>x > 0\<close> by simp
  34.234 +  finally show "x < 2 ^ nat (bitlen x)" using \<open>x > 0\<close>
  34.235      by (simp add: bitlen_def ac_simps)
  34.236  qed
  34.237  
  34.238 @@ -874,7 +874,7 @@
  34.239      by (simp add: mantissa_noteq_0)
  34.240    moreover
  34.241    obtain i where "m = mantissa f * 2 ^ i" "e = exponent f - int i"
  34.242 -    by (rule f_def[THEN denormalize_shift, OF `f \<noteq> float_of 0`])
  34.243 +    by (rule f_def[THEN denormalize_shift, OF \<open>f \<noteq> float_of 0\<close>])
  34.244    ultimately show ?thesis by (simp add: abs_mult)
  34.245  qed
  34.246  
  34.247 @@ -890,28 +890,28 @@
  34.248      next
  34.249        def n \<equiv> "\<lfloor>log 2 (real x)\<rfloor>"
  34.250        then have "0 \<le> n"
  34.251 -        using `2 \<le> x` by simp
  34.252 +        using \<open>2 \<le> x\<close> by simp
  34.253        assume "x mod 2 \<noteq> 0"
  34.254 -      with `2 \<le> x` have "x mod 2 = 1" "\<not> 2 dvd x" by (auto simp add: dvd_eq_mod_eq_0)
  34.255 -      with `2 \<le> x` have "x \<noteq> 2^nat n" by (cases "nat n") auto
  34.256 +      with \<open>2 \<le> x\<close> have "x mod 2 = 1" "\<not> 2 dvd x" by (auto simp add: dvd_eq_mod_eq_0)
  34.257 +      with \<open>2 \<le> x\<close> have "x \<noteq> 2^nat n" by (cases "nat n") auto
  34.258        moreover
  34.259        { have "real (2^nat n :: int) = 2 powr (nat n)"
  34.260            by (simp add: powr_realpow)
  34.261          also have "\<dots> \<le> 2 powr (log 2 x)"
  34.262 -          using `2 \<le> x` by (simp add: n_def del: powr_log_cancel)
  34.263 -        finally have "2^nat n \<le> x" using `2 \<le> x` by simp }
  34.264 +          using \<open>2 \<le> x\<close> by (simp add: n_def del: powr_log_cancel)
  34.265 +        finally have "2^nat n \<le> x" using \<open>2 \<le> x\<close> by simp }
  34.266        ultimately have "2^nat n \<le> x - 1" by simp
  34.267        then have "2^nat n \<le> real (x - 1)"
  34.268          unfolding real_of_int_le_iff[symmetric] by simp
  34.269        { have "n = \<lfloor>log 2 (2^nat n)\<rfloor>"
  34.270 -          using `0 \<le> n` by (simp add: log_nat_power)
  34.271 +          using \<open>0 \<le> n\<close> by (simp add: log_nat_power)
  34.272          also have "\<dots> \<le> \<lfloor>log 2 (x - 1)\<rfloor>"
  34.273 -          using `2^nat n \<le> real (x - 1)` `0 \<le> n` `2 \<le> x` by (auto intro: floor_mono)
  34.274 +          using \<open>2^nat n \<le> real (x - 1)\<close> \<open>0 \<le> n\<close> \<open>2 \<le> x\<close> by (auto intro: floor_mono)
  34.275          finally have "n \<le> \<lfloor>log 2 (x - 1)\<rfloor>" . }
  34.276        moreover have "\<lfloor>log 2 (x - 1)\<rfloor> \<le> n"
  34.277 -        using `2 \<le> x` by (auto simp add: n_def intro!: floor_mono)
  34.278 +        using \<open>2 \<le> x\<close> by (auto simp add: n_def intro!: floor_mono)
  34.279        ultimately show "\<lfloor>log 2 (x - x mod 2)\<rfloor> = \<lfloor>log 2 x\<rfloor>"
  34.280 -        unfolding n_def `x mod 2 = 1` by auto
  34.281 +        unfolding n_def \<open>x mod 2 = 1\<close> by auto
  34.282      qed
  34.283      finally have "\<lfloor>log 2 (x div 2)\<rfloor> + 1 = \<lfloor>log 2 x\<rfloor>" . }
  34.284    moreover
  34.285 @@ -934,7 +934,7 @@
  34.286    hence "m \<noteq> 0" by auto
  34.287    show ?thesis
  34.288    proof (cases "0 \<le> e")
  34.289 -    case True thus ?thesis using `0 < m`  by (simp add: bitlen_def)
  34.290 +    case True thus ?thesis using \<open>0 < m\<close>  by (simp add: bitlen_def)
  34.291    next
  34.292      have "(1::int) < 2" by simp
  34.293      case False let ?S = "2^(nat (-e))"
  34.294 @@ -945,8 +945,8 @@
  34.295      hence "1 * ?S \<le> real m * inverse ?S * ?S" by (rule mult_right_mono, auto)
  34.296      hence "?S \<le> real m" unfolding mult.assoc by auto
  34.297      hence "?S \<le> m" unfolding real_of_int_le_iff[symmetric] by auto
  34.298 -    from this bitlen_bounds[OF `0 < m`, THEN conjunct2]
  34.299 -    have "nat (-e) < (nat (bitlen m))" unfolding power_strict_increasing_iff[OF `1 < 2`, symmetric]
  34.300 +    from this bitlen_bounds[OF \<open>0 < m\<close>, THEN conjunct2]
  34.301 +    have "nat (-e) < (nat (bitlen m))" unfolding power_strict_increasing_iff[OF \<open>1 < 2\<close>, symmetric]
  34.302        by (rule order_le_less_trans)
  34.303      hence "-e < bitlen m" using False by auto
  34.304      thus ?thesis by auto
  34.305 @@ -959,22 +959,22 @@
  34.306  proof -
  34.307    let ?B = "2^nat(bitlen m - 1)"
  34.308  
  34.309 -  have "?B \<le> m" using bitlen_bounds[OF `0 <m`] ..
  34.310 +  have "?B \<le> m" using bitlen_bounds[OF \<open>0 <m\<close>] ..
  34.311    hence "1 * ?B \<le> real m" unfolding real_of_int_le_iff[symmetric] by auto
  34.312    thus "1 \<le> real m / ?B" by auto
  34.313  
  34.314    have "m \<noteq> 0" using assms by auto
  34.315 -  have "0 \<le> bitlen m - 1" using `0 < m` by (auto simp: bitlen_def)
  34.316 +  have "0 \<le> bitlen m - 1" using \<open>0 < m\<close> by (auto simp: bitlen_def)
  34.317  
  34.318 -  have "m < 2^nat(bitlen m)" using bitlen_bounds[OF `0 <m`] ..
  34.319 -  also have "\<dots> = 2^nat(bitlen m - 1 + 1)" using `0 < m` by (auto simp: bitlen_def)
  34.320 -  also have "\<dots> = ?B * 2" unfolding nat_add_distrib[OF `0 \<le> bitlen m - 1` zero_le_one] by auto
  34.321 +  have "m < 2^nat(bitlen m)" using bitlen_bounds[OF \<open>0 <m\<close>] ..
  34.322 +  also have "\<dots> = 2^nat(bitlen m - 1 + 1)" using \<open>0 < m\<close> by (auto simp: bitlen_def)
  34.323 +  also have "\<dots> = ?B * 2" unfolding nat_add_distrib[OF \<open>0 \<le> bitlen m - 1\<close> zero_le_one] by auto
  34.324    finally have "real m < 2 * ?B" unfolding real_of_int_less_iff[symmetric] by auto
  34.325    hence "real m / ?B < 2 * ?B / ?B" by (rule divide_strict_right_mono, auto)
  34.326    thus "real m / ?B < 2" by auto
  34.327  qed
  34.328  
  34.329 -subsection {* Truncating Real Numbers*}
  34.330 +subsection \<open>Truncating Real Numbers\<close>
  34.331  
  34.332  definition truncate_down::"nat \<Rightarrow> real \<Rightarrow> real" where
  34.333    "truncate_down prec x = round_down (prec - \<lfloor>log 2 \<bar>x\<bar>\<rfloor> - 1) x"
  34.334 @@ -1051,7 +1051,7 @@
  34.335    } ultimately show ?thesis by arith
  34.336  qed
  34.337  
  34.338 -subsection {* Truncating Floats*}
  34.339 +subsection \<open>Truncating Floats\<close>
  34.340  
  34.341  lift_definition float_round_up :: "nat \<Rightarrow> float \<Rightarrow> float" is truncate_up
  34.342    by (simp add: truncate_up_def)
  34.343 @@ -1093,7 +1093,7 @@
  34.344  hide_fact (open) compute_float_round_up
  34.345  
  34.346  
  34.347 -subsection {* Approximation of positive rationals *}
  34.348 +subsection \<open>Approximation of positive rationals\<close>
  34.349  
  34.350  lemma div_mult_twopow_eq: fixes a b::nat shows "a div ((2::nat) ^ n) div b = a div (b * 2 ^ n)"
  34.351    by (cases "b=0") (simp_all add: div_mult2_eq[symmetric] ac_simps)
  34.352 @@ -1146,21 +1146,21 @@
  34.353      def x' \<equiv> "x * 2 ^ nat l"
  34.354      have "int x * 2 ^ nat l = x'" by (simp add: x'_def int_mult int_power)
  34.355      moreover have "real x * 2 powr real l = real x'"
  34.356 -      by (simp add: powr_realpow[symmetric] `0 \<le> l` x'_def)
  34.357 +      by (simp add: powr_realpow[symmetric] \<open>0 \<le> l\<close> x'_def)
  34.358      ultimately show ?thesis
  34.359 -      using ceil_divide_floor_conv[of y x'] powr_realpow[of 2 "nat l"] `0 \<le> l` `y \<noteq> 0`
  34.360 +      using ceil_divide_floor_conv[of y x'] powr_realpow[of 2 "nat l"] \<open>0 \<le> l\<close> \<open>y \<noteq> 0\<close>
  34.361          l_def[symmetric, THEN meta_eq_to_obj_eq]
  34.362        by transfer (auto simp add: floor_divide_eq_div [symmetric] round_up_def)
  34.363     next
  34.364      assume "\<not> 0 \<le> l"
  34.365      def y' \<equiv> "y * 2 ^ nat (- l)"
  34.366 -    from `y \<noteq> 0` have "y' \<noteq> 0" by (simp add: y'_def)
  34.367 +    from \<open>y \<noteq> 0\<close> have "y' \<noteq> 0" by (simp add: y'_def)
  34.368      have "int y * 2 ^ nat (- l) = y'" by (simp add: y'_def int_mult int_power)
  34.369      moreover have "real x * real (2::int) powr real l / real y = x / real y'"
  34.370 -      using `\<not> 0 \<le> l`
  34.371 +      using \<open>\<not> 0 \<le> l\<close>
  34.372        by (simp add: powr_realpow[symmetric] powr_minus y'_def field_simps)
  34.373      ultimately show ?thesis
  34.374 -      using ceil_divide_floor_conv[of y' x] `\<not> 0 \<le> l` `y' \<noteq> 0` `y \<noteq> 0`
  34.375 +      using ceil_divide_floor_conv[of y' x] \<open>\<not> 0 \<le> l\<close> \<open>y' \<noteq> 0\<close> \<open>y \<noteq> 0\<close>
  34.376          l_def[symmetric, THEN meta_eq_to_obj_eq]
  34.377        by transfer
  34.378           (auto simp add: round_up_def ceil_divide_floor_conv floor_divide_eq_div [symmetric])
  34.379 @@ -1214,7 +1214,7 @@
  34.380    by transfer (simp add: round_down_uminus_eq)
  34.381  hide_fact (open) compute_rapprox_rat
  34.382  
  34.383 -subsection {* Division *}
  34.384 +subsection \<open>Division\<close>
  34.385  
  34.386  definition "real_divl prec a b = round_down (int prec + \<lfloor> log 2 \<bar>b\<bar> \<rfloor> - \<lfloor> log 2 \<bar>a\<bar> \<rfloor>) (a / b)"
  34.387  
  34.388 @@ -1250,7 +1250,7 @@
  34.389  hide_fact (open) compute_float_divr
  34.390  
  34.391  
  34.392 -subsection {* Approximate Power *}
  34.393 +subsection \<open>Approximate Power\<close>
  34.394  
  34.395  lemma div2_less_self[termination_simp]: fixes n::nat shows "odd n \<Longrightarrow> n div 2 < n"
  34.396    by (simp add: odd_pos)
  34.397 @@ -1306,9 +1306,9 @@
  34.398      also have "\<dots> = x ^ (Suc n div 2 * 2)"
  34.399        by (simp add: power_mult[symmetric])
  34.400      also have "Suc n div 2 * 2 = Suc n"
  34.401 -      using `odd n` by presburger
  34.402 +      using \<open>odd n\<close> by presburger
  34.403      finally have ?case
  34.404 -      using `odd n`
  34.405 +      using \<open>odd n\<close>
  34.406        by (auto intro!: truncate_down_le simp del: odd_Suc_div_two)
  34.407    } thus ?case
  34.408      by (auto intro!: truncate_down_le mult_left_mono 2 mult_nonneg_nonneg power_down_nonneg)
  34.409 @@ -1320,14 +1320,14 @@
  34.410    {
  34.411      assume "odd n"
  34.412      hence "Suc n = Suc n div 2 * 2"
  34.413 -      using `odd n` even_Suc by presburger
  34.414 +      using \<open>odd n\<close> even_Suc by presburger
  34.415      hence "x ^ Suc n \<le> (x ^ (Suc n div 2))\<^sup>2"
  34.416        by (simp add: power_mult[symmetric])
  34.417      also have "\<dots> \<le> (power_up p x (Suc n div 2))\<^sup>2"
  34.418 -      using 2 `odd n`
  34.419 +      using 2 \<open>odd n\<close>
  34.420        by (auto intro: power_mono simp del: odd_Suc_div_two )
  34.421      finally have ?case
  34.422 -      using `odd n`
  34.423 +      using \<open>odd n\<close>
  34.424        by (auto intro!: truncate_up_le simp del: odd_Suc_div_two )
  34.425    } thus ?case
  34.426      by (auto intro!: truncate_up_le mult_left_mono 2)
  34.427 @@ -1350,7 +1350,7 @@
  34.428    by transfer simp
  34.429  
  34.430  
  34.431 -subsection {* Approximate Addition *}
  34.432 +subsection \<open>Approximate Addition\<close>
  34.433  
  34.434  definition "plus_down prec x y = truncate_down prec (x + y)"
  34.435  
  34.436 @@ -1432,7 +1432,7 @@
  34.437      also note b_le_1
  34.438      finally have b_less_1: "b * 2 powr real p < 1" .
  34.439  
  34.440 -    from b_less_1 `b > 0` have floor_eq: "\<lfloor>b * 2 powr real p\<rfloor> = 0" "\<lfloor>sgn b / 2\<rfloor> = 0"
  34.441 +    from b_less_1 \<open>b > 0\<close> have floor_eq: "\<lfloor>b * 2 powr real p\<rfloor> = 0" "\<lfloor>sgn b / 2\<rfloor> = 0"
  34.442        by (simp_all add: floor_eq_iff)
  34.443  
  34.444      have "\<lfloor>(a + b) * 2 powr q\<rfloor> = \<lfloor>(a + b) * 2 powr p * 2 powr (q - p)\<rfloor>"
  34.445 @@ -1474,12 +1474,12 @@
  34.446      also have "\<dots> = \<lfloor>(2 * ai + b * 2 powr (p + 1)) / real ((2::int) ^ nat (p - q + 1))\<rfloor>"
  34.447        using assms by (simp add: algebra_simps powr_realpow[symmetric])
  34.448      also have "\<dots> = \<lfloor>(2 * ai - 1) / real ((2::int) ^ nat (p - q + 1))\<rfloor>"
  34.449 -      using `b < 0` assms
  34.450 +      using \<open>b < 0\<close> assms
  34.451        by (simp add: floor_divide_eq_div floor_eq floor_divide_real_eq_div
  34.452          del: real_of_int_mult real_of_int_power real_of_int_diff)
  34.453      also have "\<dots> = \<lfloor>(2 * ai - 1) * 2 powr (q - p - 1)\<rfloor>"
  34.454        using assms by (simp add: algebra_simps divide_powr_uminus powr_realpow[symmetric])
  34.455 -    finally have ?thesis using `b < 0` by simp
  34.456 +    finally have ?thesis using \<open>b < 0\<close> by simp
  34.457    } ultimately show ?thesis by arith
  34.458  qed
  34.459  
  34.460 @@ -1495,37 +1495,37 @@
  34.461    def k \<equiv> "\<lfloor>log 2 \<bar>ai\<bar>\<rfloor>"
  34.462    hence "\<lfloor>log 2 \<bar>ai\<bar>\<rfloor> = k" by simp
  34.463    hence k: "2 powr k \<le> \<bar>ai\<bar>" "\<bar>ai\<bar> < 2 powr (k + 1)"
  34.464 -    by (simp_all add: floor_log_eq_powr_iff `ai \<noteq> 0`)
  34.465 +    by (simp_all add: floor_log_eq_powr_iff \<open>ai \<noteq> 0\<close>)
  34.466    have "k \<ge> 0"
  34.467      using assms by (auto simp: k_def)
  34.468    def r \<equiv> "\<bar>ai\<bar> - 2 ^ nat k"
  34.469    have r: "0 \<le> r" "r < 2 powr k"
  34.470 -    using `k \<ge> 0` k
  34.471 +    using \<open>k \<ge> 0\<close> k
  34.472      by (auto simp: r_def k_def algebra_simps powr_add abs_if powr_int)
  34.473    hence "r \<le> (2::int) ^ nat k - 1"
  34.474 -    using `k \<ge> 0` by (auto simp: powr_int)
  34.475 -  from this[simplified real_of_int_le_iff[symmetric]] `0 \<le> k`
  34.476 +    using \<open>k \<ge> 0\<close> by (auto simp: powr_int)
  34.477 +  from this[simplified real_of_int_le_iff[symmetric]] \<open>0 \<le> k\<close>
  34.478    have r_le: "r \<le> 2 powr k - 1"
  34.479      by (auto simp: algebra_simps powr_int simp del: real_of_int_le_iff)
  34.480  
  34.481    have "\<bar>ai\<bar> = 2 powr k + r"
  34.482 -    using `k \<ge> 0` by (auto simp: k_def r_def powr_realpow[symmetric])
  34.483 +    using \<open>k \<ge> 0\<close> by (auto simp: k_def r_def powr_realpow[symmetric])
  34.484  
  34.485    have pos: "\<And>b::real. abs b < 1 \<Longrightarrow> 0 < 2 powr k + (r + b)"
  34.486 -    using `0 \<le> k` `ai \<noteq> 0`
  34.487 +    using \<open>0 \<le> k\<close> \<open>ai \<noteq> 0\<close>
  34.488      by (auto simp add: r_def powr_realpow[symmetric] abs_if sgn_if algebra_simps
  34.489        split: split_if_asm)
  34.490    have less: "\<bar>sgn ai * b\<bar> < 1"
  34.491      and less': "\<bar>sgn (sgn ai * b) / 2\<bar> < 1"
  34.492 -    using `abs b \<le> _` by (auto simp: abs_if sgn_if split: split_if_asm)
  34.493 +    using \<open>abs b \<le> _\<close> by (auto simp: abs_if sgn_if split: split_if_asm)
  34.494  
  34.495    have floor_eq: "\<And>b::real. abs b \<le> 1 / 2 \<Longrightarrow>
  34.496        \<lfloor>log 2 (1 + (r + b) / 2 powr k)\<rfloor> = (if r = 0 \<and> b < 0 then -1 else 0)"
  34.497 -    using `k \<ge> 0` r r_le
  34.498 +    using \<open>k \<ge> 0\<close> r r_le
  34.499      by (auto simp: floor_log_eq_powr_iff powr_minus_divide field_simps sgn_if)
  34.500  
  34.501 -  from `real \<bar>ai\<bar> = _` have "\<bar>ai + b\<bar> = 2 powr k + (r + sgn ai * b)"
  34.502 -    using `abs b <= _` `0 \<le> k` r
  34.503 +  from \<open>real \<bar>ai\<bar> = _\<close> have "\<bar>ai + b\<bar> = 2 powr k + (r + sgn ai * b)"
  34.504 +    using \<open>abs b <= _\<close> \<open>0 \<le> k\<close> r
  34.505      by (auto simp add: sgn_if abs_if)
  34.506    also have "\<lfloor>log 2 \<dots>\<rfloor> = \<lfloor>log 2 (2 powr k + r + sgn (sgn ai * b) / 2)\<rfloor>"
  34.507    proof -
  34.508 @@ -1537,14 +1537,14 @@
  34.509      also
  34.510      let ?if = "if r = 0 \<and> sgn ai * b < 0 then -1 else 0"
  34.511      have "\<lfloor>log 2 (1 + (r + sgn ai * b) / 2 powr k)\<rfloor> = ?if"
  34.512 -      using `abs b <= _`
  34.513 +      using \<open>abs b <= _\<close>
  34.514        by (intro floor_eq) (auto simp: abs_mult sgn_if)
  34.515      also
  34.516      have "\<dots> = \<lfloor>log 2 (1 + (r + sgn (sgn ai * b) / 2) / 2 powr k)\<rfloor>"
  34.517        by (subst floor_eq) (auto simp: sgn_if)
  34.518      also have "k + \<dots> = \<lfloor>log 2 (2 powr k * (1 + (r + sgn (sgn ai * b) / 2) / 2 powr k))\<rfloor>"
  34.519        unfolding floor_add2[symmetric]
  34.520 -      using pos[OF less'] `abs b \<le> _`
  34.521 +      using pos[OF less'] \<open>abs b \<le> _\<close>
  34.522        by (simp add: field_simps add_log_eq_powr)
  34.523      also have "2 powr k * (1 + (r + sgn (sgn ai * b) / 2) / 2 powr k) =
  34.524          2 powr k + r + sgn (sgn ai * b) / 2"
  34.525 @@ -1552,7 +1552,7 @@
  34.526      finally show ?thesis .
  34.527    qed
  34.528    also have "2 powr k + r + sgn (sgn ai * b) / 2 = \<bar>ai + sgn b / 2\<bar>"
  34.529 -    unfolding `real \<bar>ai\<bar> = _`[symmetric] using `ai \<noteq> 0`
  34.530 +    unfolding \<open>real \<bar>ai\<bar> = _\<close>[symmetric] using \<open>ai \<noteq> 0\<close>
  34.531      by (auto simp: abs_if sgn_if algebra_simps)
  34.532    finally show ?thesis .
  34.533  qed
  34.534 @@ -1590,7 +1590,7 @@
  34.535      by simp
  34.536    finally have b_less_quarter: "\<bar>?b\<bar> < 1/4 * 2 powr real e1"
  34.537      by (simp add: powr_add field_simps powr_divide2[symmetric] powr_numeral abs_mult)
  34.538 -  also have "1/4 < \<bar>real m1\<bar> / 2" using `m1 \<noteq> 0` by simp
  34.539 +  also have "1/4 < \<bar>real m1\<bar> / 2" using \<open>m1 \<noteq> 0\<close> by simp
  34.540    finally have b_less_half_a: "\<bar>?b\<bar> < 1/2 * \<bar>?a\<bar>"
  34.541      by (simp add: algebra_simps powr_mult_base abs_mult)
  34.542    hence a_half_less_sum: "\<bar>?a\<bar> / 2 < \<bar>?sum\<bar>"
  34.543 @@ -1600,7 +1600,7 @@
  34.544      by simp_all
  34.545  
  34.546    have "\<bar>real (Float m1 e1)\<bar> \<ge> 1/4 * 2 powr real e1"
  34.547 -    using `m1 \<noteq> 0`
  34.548 +    using \<open>m1 \<noteq> 0\<close>
  34.549      by (auto simp: powr_add powr_int bitlen_nonneg divide_right_mono abs_mult)
  34.550    hence "?sum \<noteq> 0" using b_less_quarter
  34.551      by (rule sum_neq_zeroI)
  34.552 @@ -1608,16 +1608,16 @@
  34.553      unfolding sum_eq by (simp add: abs_mult zero_less_mult_iff)
  34.554  
  34.555    have "\<bar>real ?m1\<bar> \<ge> 2 ^ Suc k1" "\<bar>?m2'\<bar> < 2 ^ Suc k1"
  34.556 -    using `m1 \<noteq> 0` `m2 \<noteq> 0` by (auto simp: sgn_if less_1_mult abs_mult simp del: power.simps)
  34.557 +    using \<open>m1 \<noteq> 0\<close> \<open>m2 \<noteq> 0\<close> by (auto simp: sgn_if less_1_mult abs_mult simp del: power.simps)
  34.558    hence sum'_nz: "?m1 + ?m2' \<noteq> 0"
  34.559      by (intro sum_neq_zeroI)
  34.560  
  34.561    have "\<lfloor>log 2 \<bar>real (Float m1 e1) + real (Float m2 e2)\<bar>\<rfloor> = \<lfloor>log 2 \<bar>?m1 + ?m2\<bar>\<rfloor> + ?e"
  34.562 -    using `?m1 + ?m2 \<noteq> 0`
  34.563 +    using \<open>?m1 + ?m2 \<noteq> 0\<close>
  34.564      unfolding floor_add[symmetric] sum_eq
  34.565      by (simp add: abs_mult log_mult)
  34.566    also have "\<lfloor>log 2 \<bar>?m1 + ?m2\<bar>\<rfloor> = \<lfloor>log 2 \<bar>?m1 + sgn (real m2 * 2 powr ?shift) / 2\<bar>\<rfloor>"
  34.567 -    using abs_m2_less_half `m1 \<noteq> 0`
  34.568 +    using abs_m2_less_half \<open>m1 \<noteq> 0\<close>
  34.569      by (intro log2_abs_int_add_less_half_sgn_eq) (auto simp: abs_mult)
  34.570    also have "sgn (real m2 * 2 powr ?shift) = sgn m2"
  34.571      by (auto simp: sgn_if zero_less_mult_iff less_not_sym)
  34.572 @@ -1625,7 +1625,7 @@
  34.573    have "\<bar>?m1 + ?m2'\<bar> * 2 powr ?e = \<bar>?m1 * 2 + sgn m2\<bar> * 2 powr (?e - 1)"
  34.574      by (auto simp: field_simps powr_minus[symmetric] powr_divide2[symmetric] powr_mult_base)
  34.575    hence "\<lfloor>log 2 \<bar>?m1 + ?m2'\<bar>\<rfloor> + ?e = \<lfloor>log 2 \<bar>real (Float (?m1 * 2 + sgn m2) (?e - 1))\<bar>\<rfloor>"
  34.576 -    using `?m1 + ?m2' \<noteq> 0`
  34.577 +    using \<open>?m1 + ?m2' \<noteq> 0\<close>
  34.578      unfolding floor_add[symmetric]
  34.579      by (simp add: log_add_eq_powr abs_mult_pos)
  34.580    finally
  34.581 @@ -1645,16 +1645,16 @@
  34.582          by (simp add: abs_mult powr_add[symmetric] algebra_simps powr_mult_base)
  34.583      next
  34.584        have "e1 + \<lfloor>log 2 \<bar>real m1\<bar>\<rfloor> - 1 = \<lfloor>log 2 \<bar>?a\<bar>\<rfloor> - 1"
  34.585 -        using `m1 \<noteq> 0`
  34.586 +        using \<open>m1 \<noteq> 0\<close>
  34.587          by (simp add: floor_add2[symmetric] algebra_simps log_mult abs_mult del: floor_add2)
  34.588        also have "\<dots> \<le> \<lfloor>log 2 \<bar>?a + ?b\<bar>\<rfloor>"
  34.589 -        using a_half_less_sum `m1 \<noteq> 0` `?sum \<noteq> 0`
  34.590 +        using a_half_less_sum \<open>m1 \<noteq> 0\<close> \<open>?sum \<noteq> 0\<close>
  34.591          unfolding floor_subtract[symmetric]
  34.592          by (auto simp add: log_minus_eq_powr powr_minus_divide
  34.593            intro!: floor_mono)
  34.594        finally
  34.595        have "int p - \<lfloor>log 2 \<bar>?a + ?b\<bar>\<rfloor> \<le> p - (bitlen \<bar>m1\<bar>) - e1 + 2"
  34.596 -        by (auto simp: algebra_simps bitlen_def `m1 \<noteq> 0`)
  34.597 +        by (auto simp: algebra_simps bitlen_def \<open>m1 \<noteq> 0\<close>)
  34.598        also have "\<dots> \<le> 1 - ?e"
  34.599          using bitlen_nonneg[of "\<bar>m1\<bar>"] by (simp add: k1_def)
  34.600        finally show "?f \<le> - ?e" by simp
  34.601 @@ -1707,7 +1707,7 @@
  34.602  by (metis mantissa_0 zero_float.abs_eq)
  34.603  
  34.604  
  34.605 -subsection {* Lemmas needed by Approximate *}
  34.606 +subsection \<open>Lemmas needed by Approximate\<close>
  34.607  
  34.608  lemma Float_num[simp]: shows
  34.609     "real (Float 1 0) = 1" and "real (Float 1 1) = 2" and "real (Float 1 2) = 4" and
  34.610 @@ -1804,7 +1804,7 @@
  34.611    have "x = mantissa x * 2 powr (exponent x)" by (rule mantissa_exponent)
  34.612    also have "mantissa x \<le> \<bar>mantissa x\<bar>" by simp
  34.613    also have "... \<le> 2 powr (bitlen \<bar>mantissa x\<bar>)"
  34.614 -    using bitlen_bounds[of "\<bar>mantissa x\<bar>"] bitlen_nonneg `mantissa x \<noteq> 0`
  34.615 +    using bitlen_bounds[of "\<bar>mantissa x\<bar>"] bitlen_nonneg \<open>mantissa x \<noteq> 0\<close>
  34.616      by (auto simp del: real_of_int_abs simp add: powr_int)
  34.617    finally show ?thesis by (simp add: powr_add)
  34.618  qed
  34.619 @@ -1813,7 +1813,7 @@
  34.620    assumes "0 < x" "x \<le> 1" "prec \<ge> 1"
  34.621    shows "1 \<le> real_divl prec 1 x"
  34.622  proof -
  34.623 -  have "log 2 x \<le> real prec + real \<lfloor>log 2 x\<rfloor>" using `prec \<ge> 1` by arith
  34.624 +  have "log 2 x \<le> real prec + real \<lfloor>log 2 x\<rfloor>" using \<open>prec \<ge> 1\<close> by arith
  34.625    from this assms show ?thesis
  34.626      by (simp add: real_divl_def log_divide round_down_ge1)
  34.627  qed
  34.628 @@ -1827,7 +1827,7 @@
  34.629  
  34.630  lemma real_divr_pos_less1_lower_bound: assumes "0 < x" and "x \<le> 1" shows "1 \<le> real_divr prec 1 x"
  34.631  proof -
  34.632 -  have "1 \<le> 1 / x" using `0 < x` and `x <= 1` by auto
  34.633 +  have "1 \<le> 1 / x" using \<open>0 < x\<close> and \<open>x <= 1\<close> by auto
  34.634    also have "\<dots> \<le> real_divr prec 1 x" using real_divr[where x=1 and y=x] by auto
  34.635    finally show ?thesis by auto
  34.636  qed
  34.637 @@ -1877,7 +1877,7 @@
  34.638          using real_of_int_floor_add_one_ge[of "log 2 x"] assms
  34.639          by (auto simp add: algebra_simps powr_divide2 intro!: mult_left_mono)
  34.640        thus "x * 2 powr real (int prec - \<lfloor>log 2 x\<rfloor> - 1) \<le> real ((2::int) ^ prec)"
  34.641 -        using `0 < x` by (simp add: powr_realpow)
  34.642 +        using \<open>0 < x\<close> by (simp add: powr_realpow)
  34.643      qed
  34.644      hence "real \<lceil>x * 2 powr real (int prec - \<lfloor>log 2 x\<rfloor> - 1)\<rceil> \<le> 2 powr int prec"
  34.645        by (auto simp: powr_realpow)
  34.646 @@ -1885,14 +1885,14 @@
  34.647      have "2 powr - real (int prec - \<lfloor>log 2 x\<rfloor> - 1) \<le> 2 powr - real (int prec - \<lfloor>log 2 y\<rfloor>)"
  34.648        using logless flogless by (auto intro!: floor_mono)
  34.649      also have "2 powr real (int prec) \<le> 2 powr (log 2 y + real (int prec - \<lfloor>log 2 y\<rfloor>))"
  34.650 -      using assms `0 < x`
  34.651 +      using assms \<open>0 < x\<close>
  34.652        by (auto simp: algebra_simps)
  34.653      finally have "truncate_up prec x \<le> 2 powr (log 2 y + real (int prec - \<lfloor>log 2 y\<rfloor>)) * 2 powr - real (int prec - \<lfloor>log 2 y\<rfloor>)"
  34.654        by simp
  34.655      also have "\<dots> = 2 powr (log 2 y + real (int prec - \<lfloor>log 2 y\<rfloor>) - real (int prec - \<lfloor>log 2 y\<rfloor>))"
  34.656        by (subst powr_add[symmetric]) simp
  34.657      also have "\<dots> = y"
  34.658 -      using `0 < x` assms
  34.659 +      using \<open>0 < x\<close> assms
  34.660        by (simp add: powr_add)
  34.661      also have "\<dots> \<le> truncate_up prec y"
  34.662        by (rule truncate_up)
  34.663 @@ -1910,8 +1910,8 @@
  34.664    assumes "x \<le> 0" "0 \<le> y"
  34.665    shows "truncate_up prec x \<le> truncate_up prec y"
  34.666  proof -
  34.667 -  note truncate_up_nonpos[OF `x \<le> 0`]
  34.668 -  also note truncate_up_le[OF `0 \<le> y`]
  34.669 +  note truncate_up_nonpos[OF \<open>x \<le> 0\<close>]
  34.670 +  also note truncate_up_le[OF \<open>0 \<le> y\<close>]
  34.671    finally show ?thesis .
  34.672  qed
  34.673  
  34.674 @@ -1922,7 +1922,7 @@
  34.675    have "x * 2 powr (- real \<lfloor>log 2 x\<rfloor> - 1) = x * inverse (2 powr ((real \<lfloor>log 2 x\<rfloor> + 1)))"
  34.676      by (simp add: powr_divide2[symmetric] powr_add powr_minus inverse_eq_divide)
  34.677    also have "\<dots> = 2 powr (log 2 x - (real \<lfloor>log 2 x\<rfloor>) - 1)"
  34.678 -    using `0 < x`
  34.679 +    using \<open>0 < x\<close>
  34.680      by (auto simp: field_simps powr_add powr_divide2[symmetric])
  34.681    also have "\<dots> < 2 powr 0"
  34.682      using real_of_int_floor_add_one_gt
  34.683 @@ -1933,7 +1933,7 @@
  34.684      by simp
  34.685    moreover
  34.686    have "0 \<le> \<lfloor>x * 2 powr (- real \<lfloor>log 2 x\<rfloor> - 1)\<rfloor>"
  34.687 -    using `x > 0` by auto
  34.688 +    using \<open>x > 0\<close> by auto
  34.689    ultimately have "\<lfloor>x * 2 powr (- real \<lfloor>log 2 x\<rfloor> - 1)\<rfloor> \<in> {0 ..< 1}"
  34.690      by simp
  34.691    also have "\<dots> \<subseteq> {0}" by auto
  34.692 @@ -1947,8 +1947,8 @@
  34.693    assumes "x \<le> y"
  34.694    shows "truncate_down prec x \<le> truncate_down prec y"
  34.695  proof -
  34.696 -  note truncate_down_le[OF `x \<le> 0`]
  34.697 -  also note truncate_down_nonneg[OF `0 \<le> y`]
  34.698 +  note truncate_down_le[OF \<open>x \<le> 0\<close>]
  34.699 +  also note truncate_down_nonneg[OF \<open>0 \<le> y\<close>]
  34.700    finally show ?thesis .
  34.701  qed
  34.702  
  34.703 @@ -1976,33 +1976,33 @@
  34.704      moreover
  34.705      assume "\<lfloor>log 2 \<bar>x\<bar>\<rfloor> \<noteq> \<lfloor>log 2 \<bar>y\<bar>\<rfloor>"
  34.706      ultimately have logless: "log 2 x < log 2 y" and flogless: "\<lfloor>log 2 x\<rfloor> < \<lfloor>log 2 y\<rfloor>"
  34.707 -      unfolding atomize_conj abs_of_pos[OF `0 < x`] abs_of_pos[OF `0 < y`]
  34.708 +      unfolding atomize_conj abs_of_pos[OF \<open>0 < x\<close>] abs_of_pos[OF \<open>0 < y\<close>]
  34.709        by (metis floor_less_cancel linorder_cases not_le)
  34.710      assume "prec \<noteq> 0" hence [simp]: "prec \<ge> Suc 0" by auto
  34.711      have "2 powr (prec - 1) \<le> y * 2 powr real (prec - 1) / (2 powr log 2 y)"
  34.712 -      using `0 < y`
  34.713 +      using \<open>0 < y\<close>
  34.714        by simp
  34.715      also have "\<dots> \<le> y * 2 powr real prec / (2 powr (real \<lfloor>log 2 y\<rfloor> + 1))"
  34.716 -      using `0 \<le> y` `0 \<le> x` assms(2)
  34.717 +      using \<open>0 \<le> y\<close> \<open>0 \<le> x\<close> assms(2)
  34.718        by (auto intro!: powr_mono divide_left_mono
  34.719          simp: real_of_nat_diff powr_add
  34.720          powr_divide2[symmetric])
  34.721      also have "\<dots> = y * 2 powr real prec / (2 powr real \<lfloor>log 2 y\<rfloor> * 2)"
  34.722        by (auto simp: powr_add)
  34.723      finally have "(2 ^ (prec - 1)) \<le> \<lfloor>y * 2 powr real (int prec - \<lfloor>log 2 \<bar>y\<bar>\<rfloor> - 1)\<rfloor>"
  34.724 -      using `0 \<le> y`
  34.725 +      using \<open>0 \<le> y\<close>
  34.726        by (auto simp: powr_divide2[symmetric] le_floor_eq powr_realpow)
  34.727      hence "(2 ^ (prec - 1)) * 2 powr - real (int prec - \<lfloor>log 2 \<bar>y\<bar>\<rfloor> - 1) \<le> truncate_down prec y"
  34.728        by (auto simp: truncate_down_def round_down_def)
  34.729      moreover
  34.730      {
  34.731 -      have "x = 2 powr (log 2 \<bar>x\<bar>)" using `0 < x` by simp
  34.732 +      have "x = 2 powr (log 2 \<bar>x\<bar>)" using \<open>0 < x\<close> by simp
  34.733        also have "\<dots> \<le> (2 ^ (prec )) * 2 powr - real (int prec - \<lfloor>log 2 \<bar>x\<bar>\<rfloor> - 1)"
  34.734          using real_of_int_floor_add_one_ge[of "log 2 \<bar>x\<bar>"]
  34.735          by (auto simp: powr_realpow[symmetric] powr_add[symmetric] algebra_simps)
  34.736        also
  34.737        have "2 powr - real (int prec - \<lfloor>log 2 \<bar>x\<bar>\<rfloor> - 1) \<le> 2 powr - real (int prec - \<lfloor>log 2 \<bar>y\<bar>\<rfloor>)"
  34.738 -        using logless flogless `x > 0` `y > 0`
  34.739 +        using logless flogless \<open>x > 0\<close> \<open>y > 0\<close>
  34.740          by (auto intro!: floor_mono)
  34.741        finally have "x \<le> (2 ^ (prec - 1)) * 2 powr - real (int prec - \<lfloor>log 2 \<bar>y\<bar>\<rfloor> - 1)"
  34.742          by (auto simp: powr_realpow[symmetric] powr_divide2[symmetric] assms real_of_nat_diff)
    35.1 --- a/src/HOL/Library/Formal_Power_Series.thy	Wed Jun 17 17:33:22 2015 +0200
    35.2 +++ b/src/HOL/Library/Formal_Power_Series.thy	Wed Jun 17 17:54:09 2015 +0200
    35.3 @@ -2,13 +2,14 @@
    35.4      Author:     Amine Chaieb, University of Cambridge
    35.5  *)
    35.6  
    35.7 -section{* A formalization of formal power series *}
    35.8 +section \<open>A formalization of formal power series\<close>
    35.9  
   35.10  theory Formal_Power_Series
   35.11  imports Complex_Main
   35.12  begin
   35.13  
   35.14 -subsection {* The type of formal power series*}
   35.15 +
   35.16 +subsection \<open>The type of formal power series\<close>
   35.17  
   35.18  typedef 'a fps = "{f :: nat \<Rightarrow> 'a. True}"
   35.19    morphisms fps_nth Abs_fps
   35.20 @@ -25,16 +26,13 @@
   35.21  lemma fps_nth_Abs_fps [simp]: "Abs_fps f $ n = f n"
   35.22    by (simp add: Abs_fps_inverse)
   35.23  
   35.24 -text{* Definition of the basic elements 0 and 1 and the basic operations of addition,
   35.25 -  negation and multiplication *}
   35.26 +text \<open>Definition of the basic elements 0 and 1 and the basic operations of addition,
   35.27 +  negation and multiplication.\<close>
   35.28  
   35.29  instantiation fps :: (zero) zero
   35.30  begin
   35.31 -
   35.32 -definition fps_zero_def:
   35.33 -  "0 = Abs_fps (\<lambda>n. 0)"
   35.34 -
   35.35 -instance ..
   35.36 +  definition fps_zero_def: "0 = Abs_fps (\<lambda>n. 0)"
   35.37 +  instance ..
   35.38  end
   35.39  
   35.40  lemma fps_zero_nth [simp]: "0 $ n = 0"
   35.41 @@ -42,11 +40,8 @@
   35.42  
   35.43  instantiation fps :: ("{one, zero}") one
   35.44  begin
   35.45 -
   35.46 -definition fps_one_def:
   35.47 -  "1 = Abs_fps (\<lambda>n. if n = 0 then 1 else 0)"
   35.48 -
   35.49 -instance ..
   35.50 +  definition fps_one_def: "1 = Abs_fps (\<lambda>n. if n = 0 then 1 else 0)"
   35.51 +  instance ..
   35.52  end
   35.53  
   35.54  lemma fps_one_nth [simp]: "1 $ n = (if n = 0 then 1 else 0)"
   35.55 @@ -54,11 +49,8 @@
   35.56  
   35.57  instantiation fps :: (plus) plus
   35.58  begin
   35.59 -
   35.60 -definition fps_plus_def:
   35.61 -  "op + = (\<lambda>f g. Abs_fps (\<lambda>n. f $ n + g $ n))"
   35.62 -
   35.63 -instance ..
   35.64 +  definition fps_plus_def: "op + = (\<lambda>f g. Abs_fps (\<lambda>n. f $ n + g $ n))"
   35.65 +  instance ..
   35.66  end
   35.67  
   35.68  lemma fps_add_nth [simp]: "(f + g) $ n = f $ n + g $ n"
   35.69 @@ -66,11 +58,8 @@
   35.70  
   35.71  instantiation fps :: (minus) minus
   35.72  begin
   35.73 -
   35.74 -definition fps_minus_def:
   35.75 -  "op - = (\<lambda>f g. Abs_fps (\<lambda>n. f $ n - g $ n))"
   35.76 -
   35.77 -instance ..
   35.78 +  definition fps_minus_def: "op - = (\<lambda>f g. Abs_fps (\<lambda>n. f $ n - g $ n))"
   35.79 +  instance ..
   35.80  end
   35.81  
   35.82  lemma fps_sub_nth [simp]: "(f - g) $ n = f $ n - g $ n"
   35.83 @@ -78,11 +67,8 @@
   35.84  
   35.85  instantiation fps :: (uminus) uminus
   35.86  begin
   35.87 -
   35.88 -definition fps_uminus_def:
   35.89 -  "uminus = (\<lambda>f. Abs_fps (\<lambda>n. - (f $ n)))"
   35.90 -
   35.91 -instance ..
   35.92 +  definition fps_uminus_def: "uminus = (\<lambda>f. Abs_fps (\<lambda>n. - (f $ n)))"
   35.93 +  instance ..
   35.94  end
   35.95  
   35.96  lemma fps_neg_nth [simp]: "(- f) $ n = - (f $ n)"
   35.97 @@ -90,11 +76,8 @@
   35.98  
   35.99  instantiation fps :: ("{comm_monoid_add, times}") times
  35.100  begin
  35.101 -
  35.102 -definition fps_times_def:
  35.103 -  "op * = (\<lambda>f g. Abs_fps (\<lambda>n. \<Sum>i=0..n. f $ i * g $ (n - i)))"
  35.104 -
  35.105 -instance ..
  35.106 +  definition fps_times_def: "op * = (\<lambda>f g. Abs_fps (\<lambda>n. \<Sum>i=0..n. f $ i * g $ (n - i)))"
  35.107 +  instance ..
  35.108  end
  35.109  
  35.110  lemma fps_mult_nth: "(f * g) $ n = (\<Sum>i=0..n. f$i * g$(n - i))"
  35.111 @@ -120,8 +103,9 @@
  35.112  lemma cond_application_beta: "(if b then f else g) x = (if b then f x else g x)"
  35.113    by auto
  35.114  
  35.115 -subsection{* Formal power series form a commutative ring with unity, if the range of sequences
  35.116 -  they represent is a commutative ring with unity*}
  35.117 +
  35.118 +subsection \<open>Formal power series form a commutative ring with unity, if the range of sequences
  35.119 +  they represent is a commutative ring with unity\<close>
  35.120  
  35.121  instance fps :: (semigroup_add) semigroup_add
  35.122  proof
  35.123 @@ -193,22 +177,28 @@
  35.124  instance fps :: (semiring_1) monoid_mult
  35.125  proof
  35.126    fix a :: "'a fps"
  35.127 -  show "1 * a = a" by (simp add: fps_ext fps_mult_nth mult_delta_left setsum.delta)
  35.128 -  show "a * 1 = a" by (simp add: fps_ext fps_mult_nth mult_delta_right setsum.delta')
  35.129 +  show "1 * a = a"
  35.130 +    by (simp add: fps_ext fps_mult_nth mult_delta_left setsum.delta)
  35.131 +  show "a * 1 = a"
  35.132 +    by (simp add: fps_ext fps_mult_nth mult_delta_right setsum.delta')
  35.133  qed
  35.134  
  35.135  instance fps :: (cancel_semigroup_add) cancel_semigroup_add
  35.136  proof
  35.137    fix a b c :: "'a fps"
  35.138 -  { assume "a + b = a + c" then show "b = c" by (simp add: expand_fps_eq) }
  35.139 -  { assume "b + a = c + a" then show "b = c" by (simp add: expand_fps_eq) }
  35.140 +  show "b = c" if "a + b = a + c"
  35.141 +    using that by (simp add: expand_fps_eq)
  35.142 +  show "b = c" if "b + a = c + a"
  35.143 +    using that by (simp add: expand_fps_eq)
  35.144  qed
  35.145  
  35.146  instance fps :: (cancel_ab_semigroup_add) cancel_ab_semigroup_add
  35.147  proof
  35.148    fix a b c :: "'a fps"
  35.149 -  show "a + b - a = b" by (simp add: expand_fps_eq)
  35.150 -  show "a - b - c = a - (b + c)" by (simp add: expand_fps_eq diff_diff_eq)
  35.151 +  show "a + b - a = b"
  35.152 +    by (simp add: expand_fps_eq)
  35.153 +  show "a - b - c = a - (b + c)"
  35.154 +    by (simp add: expand_fps_eq diff_diff_eq)
  35.155  qed
  35.156  
  35.157  instance fps :: (cancel_comm_monoid_add) cancel_comm_monoid_add ..
  35.158 @@ -242,32 +232,37 @@
  35.159  instance fps :: (semiring_0) semiring_0
  35.160  proof
  35.161    fix a :: "'a fps"
  35.162 -  show "0 * a = 0" by (simp add: fps_ext fps_mult_nth)
  35.163 -  show "a * 0 = 0" by (simp add: fps_ext fps_mult_nth)
  35.164 +  show "0 * a = 0"
  35.165 +    by (simp add: fps_ext fps_mult_nth)
  35.166 +  show "a * 0 = 0"
  35.167 +    by (simp add: fps_ext fps_mult_nth)
  35.168  qed
  35.169  
  35.170  instance fps :: (semiring_0_cancel) semiring_0_cancel ..
  35.171  
  35.172 -subsection {* Selection of the nth power of the implicit variable in the infinite sum*}
  35.173 +
  35.174 +subsection \<open>Selection of the nth power of the implicit variable in the infinite sum\<close>
  35.175  
  35.176  lemma fps_nonzero_nth: "f \<noteq> 0 \<longleftrightarrow> (\<exists> n. f $n \<noteq> 0)"
  35.177    by (simp add: expand_fps_eq)
  35.178  
  35.179  lemma fps_nonzero_nth_minimal: "f \<noteq> 0 \<longleftrightarrow> (\<exists>n. f $ n \<noteq> 0 \<and> (\<forall>m < n. f $ m = 0))"
  35.180 +  (is "?lhs \<longleftrightarrow> ?rhs")
  35.181  proof
  35.182    let ?n = "LEAST n. f $ n \<noteq> 0"
  35.183 -  assume "f \<noteq> 0"
  35.184 -  then have "\<exists>n. f $ n \<noteq> 0"
  35.185 -    by (simp add: fps_nonzero_nth)
  35.186 -  then have "f $ ?n \<noteq> 0"
  35.187 -    by (rule LeastI_ex)
  35.188 -  moreover have "\<forall>m<?n. f $ m = 0"
  35.189 -    by (auto dest: not_less_Least)
  35.190 -  ultimately have "f $ ?n \<noteq> 0 \<and> (\<forall>m<?n. f $ m = 0)" ..
  35.191 -  then show "\<exists>n. f $ n \<noteq> 0 \<and> (\<forall>m<n. f $ m = 0)" ..
  35.192 -next
  35.193 -  assume "\<exists>n. f $ n \<noteq> 0 \<and> (\<forall>m<n. f $ m = 0)"
  35.194 -  then show "f \<noteq> 0" by (auto simp add: expand_fps_eq)
  35.195 +  show ?rhs if ?lhs
  35.196 +  proof -
  35.197 +    from that have "\<exists>n. f $ n \<noteq> 0"
  35.198 +      by (simp add: fps_nonzero_nth)
  35.199 +    then have "f $ ?n \<noteq> 0"
  35.200 +      by (rule LeastI_ex)
  35.201 +    moreover have "\<forall>m<?n. f $ m = 0"
  35.202 +      by (auto dest: not_less_Least)
  35.203 +    ultimately have "f $ ?n \<noteq> 0 \<and> (\<forall>m<?n. f $ m = 0)" ..
  35.204 +    then show ?thesis ..
  35.205 +  qed
  35.206 +  show ?lhs if ?rhs
  35.207 +    using that by (auto simp add: expand_fps_eq)
  35.208  qed
  35.209  
  35.210  lemma fps_eq_iff: "f = g \<longleftrightarrow> (\<forall>n. f $ n = g $n)"
  35.211 @@ -282,7 +277,8 @@
  35.212    then show ?thesis by simp
  35.213  qed
  35.214  
  35.215 -subsection{* Injection of the basic ring elements and multiplication by scalars *}
  35.216 +
  35.217 +subsection \<open>Injection of the basic ring elements and multiplication by scalars\<close>
  35.218  
  35.219  definition "fps_const c = Abs_fps (\<lambda>n. if n = 0 then c else 0)"
  35.220  
  35.221 @@ -329,7 +325,8 @@
  35.222  lemma fps_mult_right_const_nth [simp]: "(f * fps_const (c::'a::semiring_1))$n = f$n * c"
  35.223    by (simp add: fps_mult_nth mult_delta_right setsum.delta')
  35.224  
  35.225 -subsection {* Formal power series form an integral domain*}
  35.226 +
  35.227 +subsection \<open>Formal power series form an integral domain\<close>
  35.228  
  35.229  instance fps :: (ring) ring ..
  35.230  
  35.231 @@ -342,24 +339,29 @@
  35.232  instance fps :: (ring_no_zero_divisors) ring_no_zero_divisors
  35.233  proof
  35.234    fix a b :: "'a fps"
  35.235 -  assume a0: "a \<noteq> 0" and b0: "b \<noteq> 0"
  35.236 -  then obtain i j where i: "a$i\<noteq>0" "\<forall>k<i. a$k=0" and j: "b$j \<noteq>0" "\<forall>k<j. b$k =0"
  35.237 +  assume "a \<noteq> 0" and "b \<noteq> 0"
  35.238 +  then obtain i j where i: "a $ i \<noteq> 0" "\<forall>k<i. a $ k = 0" and j: "b $ j \<noteq> 0" "\<forall>k<j. b $ k =0"
  35.239      unfolding fps_nonzero_nth_minimal
  35.240      by blast+
  35.241 -  have "(a * b) $ (i+j) = (\<Sum>k=0..i+j. a$k * b$(i+j-k))"
  35.242 +  have "(a * b) $ (i + j) = (\<Sum>k=0..i+j. a $ k * b $ (i + j - k))"
  35.243      by (rule fps_mult_nth)
  35.244 -  also have "\<dots> = (a$i * b$(i+j-i)) + (\<Sum>k\<in>{0..i+j}-{i}. a$k * b$(i+j-k))"
  35.245 +  also have "\<dots> = (a $ i * b $ (i + j - i)) + (\<Sum>k\<in>{0..i+j} - {i}. a $ k * b $ (i + j - k))"
  35.246      by (rule setsum.remove) simp_all
  35.247 -  also have "(\<Sum>k\<in>{0..i+j}-{i}. a$k * b$(i+j-k)) = 0"
  35.248 -    proof (rule setsum.neutral [rule_format])
  35.249 -      fix k assume "k \<in> {0..i+j} - {i}"
  35.250 -      then have "k < i \<or> i+j-k < j" by auto
  35.251 -      then show "a$k * b$(i+j-k) = 0" using i j by auto
  35.252 -    qed
  35.253 -  also have "a$i * b$(i+j-i) + 0 = a$i * b$j" by simp
  35.254 -  also have "a$i * b$j \<noteq> 0" using i j by simp
  35.255 +  also have "(\<Sum>k\<in>{0..i+j}-{i}. a $ k * b $ (i + j - k)) = 0"
  35.256 +  proof (rule setsum.neutral [rule_format])
  35.257 +    fix k assume "k \<in> {0..i+j} - {i}"
  35.258 +    then have "k < i \<or> i+j-k < j"
  35.259 +      by auto
  35.260 +    then show "a $ k * b $ (i + j - k) = 0"
  35.261 +      using i j by auto
  35.262 +  qed
  35.263 +  also have "a $ i * b $ (i + j - i) + 0 = a $ i * b $ j"
  35.264 +    by simp
  35.265 +  also have "a $ i * b $ j \<noteq> 0"
  35.266 +    using i j by simp
  35.267    finally have "(a*b) $ (i+j) \<noteq> 0" .
  35.268 -  then show "a*b \<noteq> 0" unfolding fps_nonzero_nth by blast
  35.269 +  then show "a * b \<noteq> 0"
  35.270 +    unfolding fps_nonzero_nth by blast
  35.271  qed
  35.272  
  35.273  instance fps :: (ring_1_no_zero_divisors) ring_1_no_zero_divisors ..
  35.274 @@ -373,7 +375,8 @@
  35.275  lemma neg_numeral_fps_const: "- numeral k = fps_const (- numeral k)"
  35.276    by (simp only: numeral_fps_const fps_const_neg)
  35.277  
  35.278 -subsection{* The eXtractor series X*}
  35.279 +
  35.280 +subsection \<open>The eXtractor series X\<close>
  35.281  
  35.282  lemma minus_one_power_iff: "(- (1::'a::comm_ring_1)) ^ n = (if even n then 1 else - 1)"
  35.283    by (induct n) auto
  35.284 @@ -388,10 +391,12 @@
  35.285      by (simp add: fps_mult_nth)
  35.286    also have "\<dots> = f $ (n - 1)"
  35.287      using False by (simp add: X_def mult_delta_left setsum.delta)
  35.288 -  finally show ?thesis using False by simp
  35.289 +  finally show ?thesis
  35.290 +    using False by simp
  35.291  next
  35.292    case True
  35.293 -  then show ?thesis by (simp add: fps_mult_nth X_def)
  35.294 +  then show ?thesis
  35.295 +    by (simp add: fps_mult_nth X_def)
  35.296  qed
  35.297  
  35.298  lemma X_mult_right_nth[simp]:
  35.299 @@ -404,18 +409,18 @@
  35.300    then show ?case by (simp add: X_def fps_eq_iff)
  35.301  next
  35.302    case (Suc k)
  35.303 -  {
  35.304 -    fix m
  35.305 -    have "(X^Suc k) $ m = (if m = 0 then 0::'a else (X^k) $ (m - 1))"
  35.306 +  have "(X^Suc k) $ m = (if m = Suc k then 1::'a else 0)" for m
  35.307 +  proof -
  35.308 +    have "(X^Suc k) $ m = (if m = 0 then 0 else (X^k) $ (m - 1))"
  35.309        by (simp del: One_nat_def)
  35.310 -    then have "(X^Suc k) $ m = (if m = Suc k then 1::'a else 0)"
  35.311 +    then show ?thesis
  35.312        using Suc.hyps by (auto cong del: if_weak_cong)
  35.313 -  }
  35.314 -  then show ?case by (simp add: fps_eq_iff)
  35.315 +  qed
  35.316 +  then show ?case
  35.317 +    by (simp add: fps_eq_iff)
  35.318  qed
  35.319  
  35.320 -lemma X_power_mult_nth:
  35.321 -    "(X^k * (f :: 'a::comm_ring_1 fps)) $n = (if n < k then 0 else f $ (n - k))"
  35.322 +lemma X_power_mult_nth: "(X^k * (f :: 'a::comm_ring_1 fps)) $n = (if n < k then 0 else f $ (n - k))"
  35.323    apply (induct k arbitrary: n)
  35.324    apply simp
  35.325    unfolding power_Suc mult.assoc
  35.326 @@ -428,7 +433,7 @@
  35.327    by (metis X_power_mult_nth mult.commute)
  35.328  
  35.329  
  35.330 -subsection{* Formal Power series form a metric space *}
  35.331 +subsection \<open>Formal Power series form a metric space\<close>
  35.332  
  35.333  definition (in dist) "ball x r = {y. dist y x < r}"
  35.334  
  35.335 @@ -460,59 +465,49 @@
  35.336  
  35.337  instance
  35.338  proof
  35.339 -  fix S :: "'a fps set"
  35.340 -  show "open S = (\<forall>x\<in>S. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S)"
  35.341 +  show "open S = (\<forall>x\<in>S. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S)" for S :: "'a fps set"
  35.342      by (auto simp add: open_fps_def ball_def subset_eq)
  35.343 -next
  35.344 -  {
  35.345 -    fix a b :: "'a fps"
  35.346 -    {
  35.347 -      assume "a = b"
  35.348 -      then have "\<not> (\<exists>n. a $ n \<noteq> b $ n)" by simp
  35.349 -      then have "dist a b = 0" by (simp add: dist_fps_def)
  35.350 -    }
  35.351 -    moreover
  35.352 -    {
  35.353 -      assume d: "dist a b = 0"
  35.354 -      then have "\<forall>n. a$n = b$n"
  35.355 -        by - (rule ccontr, simp add: dist_fps_def)
  35.356 -      then have "a = b" by (simp add: fps_eq_iff)
  35.357 -    }
  35.358 -    ultimately show "dist a b =0 \<longleftrightarrow> a = b" by blast
  35.359 -  }
  35.360 -  note th = this
  35.361 -  from th have th'[simp]: "\<And>a::'a fps. dist a a = 0" by simp
  35.362 +  show th: "dist a b = 0 \<longleftrightarrow> a = b" for a b :: "'a fps"
  35.363 +  proof
  35.364 +    assume "a = b"
  35.365 +    then have "\<not> (\<exists>n. a $ n \<noteq> b $ n)" by simp
  35.366 +    then show "dist a b = 0" by (simp add: dist_fps_def)
  35.367 +  next
  35.368 +    assume d: "dist a b = 0"
  35.369 +    then have "\<forall>n. a$n = b$n"
  35.370 +      by - (rule ccontr, simp add: dist_fps_def)
  35.371 +    then show "a = b" by (simp add: fps_eq_iff)
  35.372 +  qed
  35.373 +  then have th'[simp]: "dist a a = 0" for a :: "'a fps"
  35.374 +    by simp
  35.375 +
  35.376    fix a b c :: "'a fps"
  35.377 -  {
  35.378 -    assume "a = b"
  35.379 +  consider "a = b" | "c = a \<or> c = b" | "a \<noteq> b" "a \<noteq> c" "b \<noteq> c" by blast
  35.380 +  then show "dist a b \<le> dist a c + dist b c"
  35.381 +  proof cases
  35.382 +    case 1
  35.383      then have "dist a b = 0" unfolding th .
  35.384 -    then have "dist a b \<le> dist a c + dist b c"
  35.385 +    then show ?thesis
  35.386        using dist_fps_ge0 [of a c] dist_fps_ge0 [of b c] by simp
  35.387 -  }
  35.388 -  moreover
  35.389 -  {
  35.390 -    assume "c = a \<or> c = b"
  35.391 -    then have "dist a b \<le> dist a c + dist b c"
  35.392 +  next
  35.393 +    case 2
  35.394 +    then show ?thesis
  35.395        by (cases "c = a") (simp_all add: th dist_fps_sym)
  35.396 -  }
  35.397 -  moreover
  35.398 -  {
  35.399 -    assume ab: "a \<noteq> b" and ac: "a \<noteq> c" and bc: "b \<noteq> c"
  35.400 +  next
  35.401 +    case 3
  35.402      def n \<equiv> "\<lambda>a b::'a fps. LEAST n. a$n \<noteq> b$n"
  35.403      then have n': "\<And>m a b. m < n a b \<Longrightarrow> a$m = b$m"
  35.404        by (auto dest: not_less_Least)
  35.405 -
  35.406 -    from ab ac bc
  35.407 -    have dab: "dist a b = inverse (2 ^ n a b)"
  35.408 +    from 3 have dab: "dist a b = inverse (2 ^ n a b)"
  35.409        and dac: "dist a c = inverse (2 ^ n a c)"
  35.410        and dbc: "dist b c = inverse (2 ^ n b c)"
  35.411        by (simp_all add: dist_fps_def n_def fps_eq_iff)
  35.412 -    from ab ac bc have nz: "dist a b \<noteq> 0" "dist a c \<noteq> 0" "dist b c \<noteq> 0"
  35.413 +    from 3 have nz: "dist a b \<noteq> 0" "dist a c \<noteq> 0" "dist b c \<noteq> 0"
  35.414        unfolding th by simp_all
  35.415      from nz have pos: "dist a b > 0" "dist a c > 0" "dist b c > 0"
  35.416        using dist_fps_ge0[of a b] dist_fps_ge0[of a c] dist_fps_ge0[of b c]
  35.417        by auto
  35.418 -    have th1: "\<And>n. (2::real)^n >0" by auto
  35.419 +    have th1: "\<And>n. (2::real)^n > 0" by auto
  35.420      {
  35.421        assume h: "dist a b > dist a c + dist b c"
  35.422        then have gt: "dist a b > dist a c" "dist a b > dist b c"
  35.423 @@ -522,18 +517,17 @@
  35.424        from n'[OF gtn(2)] n'(1)[OF gtn(1)]
  35.425        have "a $ n a b = b $ n a b" by simp
  35.426        moreover have "a $ n a b \<noteq> b $ n a b"
  35.427 -         unfolding n_def by (rule LeastI_ex) (insert ab, simp add: fps_eq_iff)
  35.428 +         unfolding n_def by (rule LeastI_ex) (insert \<open>a \<noteq> b\<close>, simp add: fps_eq_iff)
  35.429        ultimately have False by contradiction
  35.430      }
  35.431 -    then have "dist a b \<le> dist a c + dist b c"
  35.432 +    then show ?thesis
  35.433        by (auto simp add: not_le[symmetric])
  35.434 -  }
  35.435 -  ultimately show "dist a b \<le> dist a c + dist b c" by blast
  35.436 +  qed
  35.437  qed
  35.438  
  35.439  end
  35.440  
  35.441 -text{* The infinite sums and justification of the notation in textbooks*}
  35.442 +text \<open>The infinite sums and justification of the notation in textbooks\<close>
  35.443  
  35.444  lemma reals_power_lt_ex:
  35.445    fixes x y :: real
  35.446 @@ -584,51 +578,48 @@
  35.447  proof -
  35.448    {
  35.449      fix r :: real
  35.450 -    assume rp: "r > 0"
  35.451 -    have th0: "(2::real) > 1" by simp
  35.452 -    from reals_power_lt_ex[OF rp th0]
  35.453 -    obtain n0 where n0: "(1/2)^n0 < r" "n0 > 0" by blast
  35.454 -    {
  35.455 -      fix n :: nat
  35.456 -      assume nn0: "n \<ge> n0"
  35.457 -      then have thnn0: "(1/2)^n \<le> (1/2 :: real)^n0"
  35.458 -        by (simp add: divide_simps)
  35.459 -      {
  35.460 -        assume "?s n = a"
  35.461 -        then have "dist (?s n) a < r"
  35.462 -          unfolding dist_eq_0_iff[of "?s n" a, symmetric]
  35.463 -          using rp by (simp del: dist_eq_0_iff)
  35.464 -      }
  35.465 -      moreover
  35.466 +    assume "r > 0"
  35.467 +    obtain n0 where n0: "(1/2)^n0 < r" "n0 > 0"
  35.468 +      using reals_power_lt_ex[OF \<open>r > 0\<close>, of 2] by auto
  35.469 +    have "\<exists>n0. \<forall>n \<ge> n0. dist (?s n) a < r"
  35.470 +    proof -
  35.471        {
  35.472 -        assume neq: "?s n \<noteq> a"
  35.473 -        def k \<equiv> "LEAST i. ?s n $ i \<noteq> a $ i"
  35.474 -        from neq have dth: "dist (?s n) a = (1/2)^k"
  35.475 -          by (auto simp add: dist_fps_def inverse_eq_divide power_divide k_def fps_eq_iff)
  35.476 -
  35.477 -        from neq have kn: "k > n"
  35.478 -          by (auto simp: fps_sum_rep_nth not_le k_def fps_eq_iff
  35.479 +        fix n :: nat
  35.480 +        assume nn0: "n \<ge> n0"
  35.481 +        then have thnn0: "(1/2)^n \<le> (1/2 :: real)^n0"
  35.482 +          by (simp add: divide_simps)
  35.483 +        have "dist (?s n) a < r"
  35.484 +        proof (cases "?s n = a")
  35.485 +          case True
  35.486 +          then show ?thesis
  35.487 +            unfolding dist_eq_0_iff[of "?s n" a, symmetric]
  35.488 +            using \<open>r > 0\<close> by (simp del: dist_eq_0_iff)
  35.489 +        next
  35.490 +          case False
  35.491 +          def k \<equiv> "LEAST i. ?s n $ i \<noteq> a $ i"
  35.492 +          from False have dth: "dist (?s n) a = (1/2)^k"
  35.493 +            by (auto simp add: dist_fps_def inverse_eq_divide power_divide k_def fps_eq_iff)
  35.494 +          from False have kn: "k > n"
  35.495 +            by (auto simp: fps_sum_rep_nth not_le k_def fps_eq_iff
  35.496                split: split_if_asm intro: LeastI2_ex)
  35.497 -        then have "dist (?s n) a < (1/2)^n"
  35.498 -          unfolding dth by (simp add: divide_simps)
  35.499 -        also have "\<dots> \<le> (1/2)^n0"
  35.500 -          using nn0 by (simp add: divide_simps)
  35.501 -        also have "\<dots> < r"
  35.502 -          using n0 by simp
  35.503 -        finally have "dist (?s n) a < r" .
  35.504 +          then have "dist (?s n) a < (1/2)^n"
  35.505 +            unfolding dth by (simp add: divide_simps)
  35.506 +          also have "\<dots> \<le> (1/2)^n0"
  35.507 +            using nn0 by (simp add: divide_simps)
  35.508 +          also have "\<dots> < r"
  35.509 +            using n0 by simp
  35.510 +          finally show ?thesis .
  35.511 +        qed
  35.512        }
  35.513 -      ultimately have "dist (?s n) a < r"
  35.514 -        by blast
  35.515 -    }
  35.516 -    then have "\<exists>n0. \<forall> n \<ge> n0. dist (?s n) a < r"
  35.517 -      by blast
  35.518 +      then show ?thesis by blast
  35.519 +    qed
  35.520    }
  35.521    then show ?thesis
  35.522      unfolding lim_sequentially by blast
  35.523  qed
  35.524  
  35.525  
  35.526 -subsection{* Inverses of formal power series *}
  35.527 +subsection \<open>Inverses of formal power series\<close>
  35.528  
  35.529  declare setsum.cong[fundef_cong]
  35.530  
  35.531 @@ -640,11 +631,9 @@
  35.532    "natfun_inverse f 0 = inverse (f$0)"
  35.533  | "natfun_inverse f n = - inverse (f$0) * setsum (\<lambda>i. f$i * natfun_inverse f (n - i)) {1..n}"
  35.534  
  35.535 -definition
  35.536 -  fps_inverse_def: "inverse f = (if f $ 0 = 0 then 0 else Abs_fps (natfun_inverse f))"
  35.537 -
  35.538 -definition
  35.539 -  fps_divide_def: "divide = (\<lambda>(f::'a fps) g. f * inverse g)"
  35.540 +definition fps_inverse_def: "inverse f = (if f $ 0 = 0 then 0 else Abs_fps (natfun_inverse f))"
  35.541 +
  35.542 +definition fps_divide_def: "divide = (\<lambda>(f::'a fps) g. f * inverse g)"
  35.543  
  35.544  instance ..
  35.545  
  35.546 @@ -670,9 +659,8 @@
  35.547      by (simp add: fps_inverse_def)
  35.548    from f0 have th0: "(inverse f * f) $ 0 = 1"
  35.549      by (simp add: fps_mult_nth fps_inverse_def)
  35.550 -  {
  35.551 -    fix n :: nat
  35.552 -    assume np: "n > 0"
  35.553 +  have "(inverse f * f)$n = 0" if np: "n > 0" for n
  35.554 +  proof -
  35.555      from np have eq: "{0..n} = {0} \<union> {1 .. n}"
  35.556        by auto
  35.557      have d: "{0} \<inter> {1 .. n} = {}"
  35.558 @@ -689,31 +677,26 @@
  35.559        by (simp add: eq)
  35.560      also have "\<dots> = 0"
  35.561        unfolding th1 ifn by simp
  35.562 -    finally have "(inverse f * f)$n = 0"
  35.563 -      unfolding c .
  35.564 -  }
  35.565 +    finally show ?thesis unfolding c .
  35.566 +  qed
  35.567    with th0 show ?thesis
  35.568      by (simp add: fps_eq_iff)
  35.569  qed
  35.570  
  35.571 -lemma fps_inverse_0_iff[simp]: "(inverse f)$0 = (0::'a::division_ring) \<longleftrightarrow> f$0 = 0"
  35.572 +lemma fps_inverse_0_iff[simp]: "(inverse f) $ 0 = (0::'a::division_ring) \<longleftrightarrow> f $ 0 = 0"
  35.573    by (simp add: fps_inverse_def nonzero_imp_inverse_nonzero)
  35.574  
  35.575 -lemma fps_inverse_eq_0_iff[simp]: "inverse f = (0:: ('a::field) fps) \<longleftrightarrow> f $0 = 0"
  35.576 -proof -
  35.577 -  {
  35.578 -    assume "f $ 0 = 0"
  35.579 -    then have "inverse f = 0"
  35.580 -      by (simp add: fps_inverse_def)
  35.581 -  }
  35.582 -  moreover
  35.583 -  {
  35.584 -    assume h: "inverse f = 0"
  35.585 +lemma fps_inverse_eq_0_iff[simp]: "inverse f = (0:: ('a::field) fps) \<longleftrightarrow> f $ 0 = 0"
  35.586 +  (is "?lhs \<longleftrightarrow> ?rhs")
  35.587 +proof
  35.588 +  show ?lhs if ?rhs
  35.589 +    using that by (simp add: fps_inverse_def)
  35.590 +  show ?rhs if h: ?lhs
  35.591 +  proof (rule ccontr)
  35.592      assume c: "f $0 \<noteq> 0"
  35.593 -    from inverse_mult_eq_1[OF c] h have False
  35.594 +    from inverse_mult_eq_1[OF c] h show False
  35.595        by simp
  35.596 -  }
  35.597 -  ultimately show ?thesis by blast
  35.598 +  qed
  35.599  qed
  35.600  
  35.601  lemma fps_inverse_idempotent[intro]:
  35.602 @@ -771,14 +754,14 @@
  35.603      done
  35.604  qed
  35.605  
  35.606 -lemma fps_inverse_gp: "inverse (Abs_fps(\<lambda>n. (1::'a::field)))
  35.607 -    = Abs_fps (\<lambda>n. if n= 0 then 1 else if n=1 then - 1 else 0)"
  35.608 +lemma fps_inverse_gp: "inverse (Abs_fps(\<lambda>n. (1::'a::field))) =
  35.609 +    Abs_fps (\<lambda>n. if n= 0 then 1 else if n=1 then - 1 else 0)"
  35.610    apply (rule fps_inverse_unique)
  35.611    apply (simp_all add: fps_eq_iff fps_mult_nth setsum_zero_lemma)
  35.612    done
  35.613  
  35.614  
  35.615 -subsection {* Formal Derivatives, and the MacLaurin theorem around 0 *}
  35.616 +subsection \<open>Formal Derivatives, and the MacLaurin theorem around 0\<close>
  35.617  
  35.618  definition "fps_deriv f = Abs_fps (\<lambda>n. of_nat (n + 1) * f $ (n + 1))"
  35.619  
  35.620 @@ -872,24 +855,27 @@
  35.621  
  35.622  lemma fps_deriv_eq_0_iff [simp]:
  35.623    "fps_deriv f = 0 \<longleftrightarrow> f = fps_const (f$0 :: 'a::{idom,semiring_char_0})"
  35.624 -proof -
  35.625 -  {
  35.626 -    assume "f = fps_const (f$0)"
  35.627 -    then have "fps_deriv f = fps_deriv (fps_const (f$0))" by simp
  35.628 -    then have "fps_deriv f = 0" by simp
  35.629 -  }
  35.630 -  moreover
  35.631 -  {
  35.632 -    assume z: "fps_deriv f = 0"
  35.633 -    then have "\<forall>n. (fps_deriv f)$n = 0" by simp
  35.634 -    then have "\<forall>n. f$(n+1) = 0" by (simp del: of_nat_Suc of_nat_add One_nat_def)
  35.635 -    then have "f = fps_const (f$0)"
  35.636 +  (is "?lhs \<longleftrightarrow> ?rhs")
  35.637 +proof
  35.638 +  show ?lhs if ?rhs
  35.639 +  proof -
  35.640 +    from that have "fps_deriv f = fps_deriv (fps_const (f$0))"
  35.641 +      by simp
  35.642 +    then show ?thesis
  35.643 +      by simp
  35.644 +  qed
  35.645 +  show ?rhs if ?lhs
  35.646 +  proof -
  35.647 +    from that have "\<forall>n. (fps_deriv f)$n = 0"
  35.648 +      by simp
  35.649 +    then have "\<forall>n. f$(n+1) = 0"
  35.650 +      by (simp del: of_nat_Suc of_nat_add One_nat_def)
  35.651 +    then show ?thesis
  35.652        apply (clarsimp simp add: fps_eq_iff fps_const_def)
  35.653        apply (erule_tac x="n - 1" in allE)
  35.654        apply simp
  35.655        done
  35.656 -  }
  35.657 -  ultimately show ?thesis by blast
  35.658 +  qed
  35.659  qed
  35.660  
  35.661  lemma fps_deriv_eq_iff:
  35.662 @@ -900,7 +886,8 @@
  35.663      by simp
  35.664    also have "\<dots> \<longleftrightarrow> f - g = fps_const ((f - g) $ 0)"
  35.665      unfolding fps_deriv_eq_0_iff ..
  35.666 -  finally show ?thesis by (simp add: field_simps)
  35.667 +  finally show ?thesis
  35.668 +    by (simp add: field_simps)
  35.669  qed
  35.670  
  35.671  lemma fps_deriv_eq_iff_ex:
  35.672 @@ -966,7 +953,7 @@
  35.673    by (induct k arbitrary: f) (auto simp add: field_simps of_nat_mult)
  35.674  
  35.675  
  35.676 -subsection {* Powers *}
  35.677 +subsection \<open>Powers\<close>
  35.678  
  35.679  lemma fps_power_zeroth_eq_one: "a$0 =1 \<Longrightarrow> a^n $ 0 = (1::'a::semiring_1)"
  35.680    by (induct n) (auto simp add: expand_fps_eq fps_mult_nth)
  35.681 @@ -977,9 +964,8 @@
  35.682    then show ?case by simp
  35.683  next
  35.684    case (Suc n)
  35.685 -  note h = Suc.hyps[OF `a$0 = 1`]
  35.686    show ?case unfolding power_Suc fps_mult_nth
  35.687 -    using h `a$0 = 1` fps_power_zeroth_eq_one[OF `a$0=1`]
  35.688 +    using Suc.hyps[OF \<open>a$0 = 1\<close>] \<open>a$0 = 1\<close> fps_power_zeroth_eq_one[OF \<open>a$0=1\<close>]
  35.689      by (simp add: field_simps)
  35.690  qed
  35.691  
  35.692 @@ -1000,53 +986,41 @@
  35.693    done
  35.694  
  35.695  lemma startsby_zero_power_prefix:
  35.696 -  assumes a0: "a $0 = (0::'a::idom)"
  35.697 +  assumes a0: "a $ 0 = (0::'a::idom)"
  35.698    shows "\<forall>n < k. a ^ k $ n = 0"
  35.699    using a0
  35.700  proof (induct k rule: nat_less_induct)
  35.701    fix k
  35.702    assume H: "\<forall>m<k. a $0 =  0 \<longrightarrow> (\<forall>n<m. a ^ m $ n = 0)" and a0: "a $ 0 = 0"
  35.703 -  let ?ths = "\<forall>m<k. a ^ k $ m = 0"
  35.704 -  {
  35.705 -    assume "k = 0"
  35.706 -    then have ?ths by simp
  35.707 -  }
  35.708 -  moreover
  35.709 -  {
  35.710 -    fix l
  35.711 -    assume k: "k = Suc l"
  35.712 -    {
  35.713 -      fix m
  35.714 -      assume mk: "m < k"
  35.715 -      {
  35.716 -        assume "m = 0"
  35.717 -        then have "a^k $ m = 0"
  35.718 -          using startsby_zero_power[of a k] k a0 by simp
  35.719 -      }
  35.720 -      moreover
  35.721 -      {
  35.722 -        assume m0: "m \<noteq> 0"
  35.723 -        have "a ^k $ m = (a^l * a) $m"
  35.724 -          by (simp add: k mult.commute)
  35.725 -        also have "\<dots> = (\<Sum>i = 0..m. a ^ l $ i * a $ (m - i))"
  35.726 -          by (simp add: fps_mult_nth)
  35.727 -        also have "\<dots> = 0"
  35.728 -          apply (rule setsum.neutral)
  35.729 -          apply auto
  35.730 -          apply (case_tac "x = m")
  35.731 -          using a0 apply simp
  35.732 -          apply (rule H[rule_format])
  35.733 -          using a0 k mk apply auto
  35.734 -          done
  35.735 -        finally have "a^k $ m = 0" .
  35.736 -      }
  35.737 -      ultimately have "a^k $ m = 0"
  35.738 -        by blast
  35.739 -    }
  35.740 -    then have ?ths by blast
  35.741 -  }
  35.742 -  ultimately show ?ths
  35.743 -    by (cases k) auto
  35.744 +  show "\<forall>m<k. a ^ k $ m = 0"
  35.745 +  proof (cases k)
  35.746 +    case 0
  35.747 +    then show ?thesis by simp
  35.748 +  next
  35.749 +    case (Suc l)
  35.750 +    have "a^k $ m = 0" if mk: "m < k" for m
  35.751 +    proof (cases "m = 0")
  35.752 +      case True
  35.753 +      then show ?thesis
  35.754 +        using startsby_zero_power[of a k] Suc a0 by simp
  35.755 +    next
  35.756 +      case False
  35.757 +      have "a ^k $ m = (a^l * a) $m"
  35.758 +        by (simp add: Suc mult.commute)
  35.759 +      also have "\<dots> = (\<Sum>i = 0..m. a ^ l $ i * a $ (m - i))"
  35.760 +        by (simp add: fps_mult_nth)
  35.761 +      also have "\<dots> = 0"
  35.762 +        apply (rule setsum.neutral)
  35.763 +        apply auto
  35.764 +        apply (case_tac "x = m")
  35.765 +        using a0 apply simp
  35.766 +        apply (rule H[rule_format])
  35.767 +        using a0 Suc mk apply auto
  35.768 +        done
  35.769 +      finally show ?thesis .
  35.770 +    qed
  35.771 +    then show ?thesis by blast
  35.772 +  qed
  35.773  qed
  35.774  
  35.775  lemma startsby_zero_setsum_depends:
  35.776 @@ -1089,37 +1063,31 @@
  35.777  lemma fps_inverse_power:
  35.778    fixes a :: "'a::field fps"
  35.779    shows "inverse (a^n) = inverse a ^ n"
  35.780 -proof -
  35.781 -  {
  35.782 -    assume a0: "a$0 = 0"
  35.783 -    then have eq: "inverse a = 0"
  35.784 +proof (cases "a$0 = 0")
  35.785 +  case True
  35.786 +  then have eq: "inverse a = 0"
  35.787 +    by (simp add: fps_inverse_def)
  35.788 +  consider "n = 0" | "n > 0" by blast
  35.789 +  then show ?thesis
  35.790 +  proof cases
  35.791 +    case 1
  35.792 +    then show ?thesis by simp
  35.793 +  next
  35.794 +    case 2
  35.795 +    from startsby_zero_power[OF True 2] eq show ?thesis
  35.796        by (simp add: fps_inverse_def)
  35.797 -    {
  35.798 -      assume "n = 0"
  35.799 -      then have ?thesis by simp
  35.800 -    }
  35.801 -    moreover
  35.802 -    {
  35.803 -      assume n: "n > 0"
  35.804 -      from startsby_zero_power[OF a0 n] eq a0 n have ?thesis
  35.805 -        by (simp add: fps_inverse_def)
  35.806 -    }
  35.807 -    ultimately have ?thesis by blast
  35.808 -  }
  35.809 -  moreover
  35.810 -  {
  35.811 -    assume a0: "a$0 \<noteq> 0"
  35.812 -    have ?thesis
  35.813 -      apply (rule fps_inverse_unique)
  35.814 -      apply (simp add: a0)
  35.815 -      unfolding power_mult_distrib[symmetric]
  35.816 -      apply (rule ssubst[where t = "a * inverse a" and s= 1])
  35.817 -      apply simp_all
  35.818 -      apply (subst mult.commute)
  35.819 -      apply (rule inverse_mult_eq_1[OF a0])
  35.820 -      done
  35.821 -  }
  35.822 -  ultimately show ?thesis by blast
  35.823 +  qed
  35.824 +next
  35.825 +  case False
  35.826 +  show ?thesis
  35.827 +    apply (rule fps_inverse_unique)
  35.828 +    apply (simp add: False)
  35.829 +    unfolding power_mult_distrib[symmetric]
  35.830 +    apply (rule ssubst[where t = "a * inverse a" and s= 1])
  35.831 +    apply simp_all
  35.832 +    apply (subst mult.commute)
  35.833 +    apply (rule inverse_mult_eq_1[OF False])
  35.834 +    done
  35.835  qed
  35.836  
  35.837  lemma fps_deriv_power:
  35.838 @@ -1158,35 +1126,42 @@
  35.839    fixes a :: "'a::field fps"
  35.840    shows "inverse (a * b) = inverse a * inverse b"
  35.841  proof -
  35.842 -  {
  35.843 -    assume a0: "a$0 = 0"
  35.844 -    then have ab0: "(a*b)$0 = 0" by (simp add: fps_mult_nth)
  35.845 -    from a0 ab0 have th: "inverse a = 0" "inverse (a*b) = 0" by simp_all
  35.846 -    have ?thesis unfolding th by simp
  35.847 -  }
  35.848 -  moreover
  35.849 -  {
  35.850 -    assume b0: "b$0 = 0"
  35.851 -    then have ab0: "(a*b)$0 = 0" by (simp add: fps_mult_nth)
  35.852 -    from b0 ab0 have th: "inverse b = 0" "inverse (a*b) = 0" by simp_all
  35.853 -    have ?thesis unfolding th by simp
  35.854 -  }
  35.855 -  moreover
  35.856 -  {
  35.857 -    assume a0: "a$0 \<noteq> 0" and b0: "b$0 \<noteq> 0"
  35.858 -    from a0 b0 have ab0:"(a*b) $ 0 \<noteq> 0" by (simp  add: fps_mult_nth)
  35.859 +  consider "a $ 0 = 0" | "b $ 0 = 0" | "a $ 0 \<noteq> 0" "b $ 0 \<noteq> 0"
  35.860 +    by blast
  35.861 +  then show ?thesis
  35.862 +  proof cases
  35.863 +    case 1
  35.864 +    then have "(a * b) $ 0 = 0"
  35.865 +      by (simp add: fps_mult_nth)
  35.866 +    with 1 have th: "inverse a = 0" "inverse (a * b) = 0"
  35.867 +      by simp_all
  35.868 +    show ?thesis
  35.869 +      unfolding th by simp
  35.870 +  next
  35.871 +    case 2
  35.872 +    then have "(a * b) $ 0 = 0"
  35.873 +      by (simp add: fps_mult_nth)
  35.874 +    with 2 have th: "inverse b = 0" "inverse (a * b) = 0"
  35.875 +      by simp_all
  35.876 +    show ?thesis
  35.877 +      unfolding th by simp
  35.878 +  next
  35.879 +    case 3
  35.880 +    then have ab0:"(a * b) $ 0 \<noteq> 0"
  35.881 +      by (simp add: fps_mult_nth)
  35.882      from inverse_mult_eq_1[OF ab0]
  35.883 -    have "inverse (a*b) * (a*b) * inverse a * inverse b = 1 * inverse a * inverse b" by simp
  35.884 +    have "inverse (a*b) * (a*b) * inverse a * inverse b = 1 * inverse a * inverse b"
  35.885 +      by simp
  35.886      then have "inverse (a*b) * (inverse a * a) * (inverse b * b) = inverse a * inverse b"
  35.887        by (simp add: field_simps)
  35.888 -    then have ?thesis using inverse_mult_eq_1[OF a0] inverse_mult_eq_1[OF b0] by simp
  35.889 -  }
  35.890 -  ultimately show ?thesis by blast
  35.891 +    then show ?thesis
  35.892 +      using inverse_mult_eq_1[OF \<open>a $ 0 \<noteq> 0\<close>] inverse_mult_eq_1[OF \<open>b $ 0 \<noteq> 0\<close>] by simp
  35.893 +  qed
  35.894  qed
  35.895  
  35.896  lemma fps_inverse_deriv':
  35.897    fixes a :: "'a::field fps"
  35.898 -  assumes a0: "a$0 \<noteq> 0"
  35.899 +  assumes a0: "a $ 0 \<noteq> 0"
  35.900    shows "fps_deriv (inverse a) = - fps_deriv a / a\<^sup>2"
  35.901    using fps_inverse_deriv[OF a0]
  35.902    unfolding power2_eq_square fps_divide_def fps_inverse_mult
  35.903 @@ -1212,9 +1187,8 @@
  35.904  lemma fps_nth_deriv_X[simp]: "fps_nth_deriv n X = (if n = 0 then X else if n=1 then 1 else 0)"
  35.905    by (cases n) simp_all
  35.906  
  35.907 -
  35.908 -lemma fps_inverse_X_plus1:
  35.909 -  "inverse (1 + X) = Abs_fps (\<lambda>n. (- (1::'a::field)) ^ n)" (is "_ = ?r")
  35.910 +lemma fps_inverse_X_plus1: "inverse (1 + X) = Abs_fps (\<lambda>n. (- (1::'a::field)) ^ n)"
  35.911 +  (is "_ = ?r")
  35.912  proof -
  35.913    have eq: "(1 + X) * ?r = 1"
  35.914      unfolding minus_one_power_iff
  35.915 @@ -1224,7 +1198,7 @@
  35.916  qed
  35.917  
  35.918  
  35.919 -subsection{* Integration *}
  35.920 +subsection \<open>Integration\<close>
  35.921  
  35.922  definition fps_integral :: "'a::field_char_0 fps \<Rightarrow> 'a \<Rightarrow> 'a fps"
  35.923    where "fps_integral a a0 = Abs_fps (\<lambda>n. if n = 0 then a0 else (a$(n - 1) / of_nat n))"
  35.924 @@ -1247,9 +1221,9 @@
  35.925  qed
  35.926  
  35.927  
  35.928 -subsection {* Composition of FPSs *}
  35.929 -
  35.930 -definition fps_compose :: "'a::semiring_1 fps \<Rightarrow> 'a fps \<Rightarrow> 'a fps" (infixl "oo" 55)
  35.931 +subsection \<open>Composition of FPSs\<close>
  35.932 +
  35.933 +definition fps_compose :: "'a::semiring_1 fps \<Rightarrow> 'a fps \<Rightarrow> 'a fps"  (infixl "oo" 55)
  35.934    where "a oo b = Abs_fps (\<lambda>n. setsum (\<lambda>i. a$i * (b^i$n)) {0..n})"
  35.935  
  35.936  lemma fps_compose_nth: "(a oo b)$n = setsum (\<lambda>i. a$i * (b^i$n)) {0..n}"
  35.937 @@ -1258,8 +1232,7 @@
  35.938  lemma fps_compose_X[simp]: "a oo X = (a :: 'a::comm_ring_1 fps)"
  35.939    by (simp add: fps_ext fps_compose_def mult_delta_right setsum.delta')
  35.940  
  35.941 -lemma fps_const_compose[simp]:
  35.942 -  "fps_const (a::'a::comm_ring_1) oo b = fps_const a"
  35.943 +lemma fps_const_compose[simp]: "fps_const (a::'a::comm_ring_1) oo b = fps_const a"
  35.944    by (simp add: fps_eq_iff fps_compose_nth mult_delta_left setsum.delta)
  35.945  
  35.946  lemma numeral_compose[simp]: "(numeral k :: 'a::comm_ring_1 fps) oo b = numeral k"
  35.947 @@ -1272,9 +1245,9 @@
  35.948    by (simp add: fps_eq_iff fps_compose_def mult_delta_left setsum.delta not_le)
  35.949  
  35.950  
  35.951 -subsection {* Rules from Herbert Wilf's Generatingfunctionology*}
  35.952 -
  35.953 -subsubsection {* Rule 1 *}
  35.954 +subsection \<open>Rules from Herbert Wilf's Generatingfunctionology\<close>
  35.955 +
  35.956 +subsubsection \<open>Rule 1\<close>
  35.957    (* {a_{n+k}}_0^infty Corresponds to (f - setsum (\<lambda>i. a_i * x^i))/x^h, for h>0*)
  35.958  
  35.959  lemma fps_power_mult_eq_shift:
  35.960 @@ -1282,37 +1255,40 @@
  35.961      Abs_fps a - setsum (\<lambda>i. fps_const (a i :: 'a::comm_ring_1) * X^i) {0 .. k}"
  35.962    (is "?lhs = ?rhs")
  35.963  proof -
  35.964 -  { fix n :: nat
  35.965 +  have "?lhs $ n = ?rhs $ n" for n :: nat
  35.966 +  proof -
  35.967      have "?lhs $ n = (if n < Suc k then 0 else a n)"
  35.968        unfolding X_power_mult_nth by auto
  35.969      also have "\<dots> = ?rhs $ n"
  35.970      proof (induct k)
  35.971        case 0
  35.972 -      then show ?case by (simp add: fps_setsum_nth)
  35.973 +      then show ?case
  35.974 +        by (simp add: fps_setsum_nth)
  35.975      next
  35.976        case (Suc k)
  35.977 -      note th = Suc.hyps[symmetric]
  35.978        have "(Abs_fps a - setsum (\<lambda>i. fps_const (a i :: 'a) * X^i) {0 .. Suc k})$n =
  35.979          (Abs_fps a - setsum (\<lambda>i. fps_const (a i :: 'a) * X^i) {0 .. k} -
  35.980            fps_const (a (Suc k)) * X^ Suc k) $ n"
  35.981          by (simp add: field_simps)
  35.982        also have "\<dots> = (if n < Suc k then 0 else a n) - (fps_const (a (Suc k)) * X^ Suc k)$n"
  35.983 -        using th unfolding fps_sub_nth by simp
  35.984 +        using Suc.hyps[symmetric] unfolding fps_sub_nth by simp
  35.985        also have "\<dots> = (if n < Suc (Suc k) then 0 else a n)"
  35.986          unfolding X_power_mult_right_nth
  35.987          apply (auto simp add: not_less fps_const_def)
  35.988          apply (rule cong[of a a, OF refl])
  35.989          apply arith
  35.990          done
  35.991 -      finally show ?case by simp
  35.992 +      finally show ?case
  35.993 +        by simp
  35.994      qed
  35.995 -    finally have "?lhs $ n = ?rhs $ n" .
  35.996 -  }
  35.997 -  then show ?thesis by (simp add: fps_eq_iff)
  35.998 +    finally show ?thesis .
  35.999 +  qed
 35.1000 +  then show ?thesis
 35.1001 +    by (simp add: fps_eq_iff)
 35.1002  qed
 35.1003  
 35.1004  
 35.1005 -subsubsection {* Rule 2*}
 35.1006 +subsubsection \<open>Rule 2\<close>
 35.1007  
 35.1008    (* We can not reach the form of Wilf, but still near to it using rewrite rules*)
 35.1009    (* If f reprents {a_n} and P is a polynomial, then
 35.1010 @@ -1338,15 +1314,17 @@
 35.1011  lemma fps_mult_X_deriv_shift: "X* fps_deriv a = Abs_fps (\<lambda>n. of_nat n* a$n)"
 35.1012    by (simp add: fps_eq_iff)
 35.1013  
 35.1014 -
 35.1015  lemma fps_mult_XD_shift:
 35.1016    "(XD ^^ k) (a :: 'a::comm_ring_1 fps) = Abs_fps (\<lambda>n. (of_nat n ^ k) * a$n)"
 35.1017    by (induct k arbitrary: a) (simp_all add: XD_def fps_eq_iff field_simps del: One_nat_def)
 35.1018  
 35.1019  
 35.1020 -subsubsection {* Rule 3 is trivial and is given by @{text fps_times_def} *}
 35.1021 -
 35.1022 -subsubsection {* Rule 5 --- summation and "division" by (1 - X) *}
 35.1023 +subsubsection \<open>Rule 3\<close>
 35.1024 +
 35.1025 +text \<open>Rule 3 is trivial and is given by @{text fps_times_def}.\<close>
 35.1026 +
 35.1027 +
 35.1028 +subsubsection \<open>Rule 5 --- summation and "division" by (1 - X)\<close>
 35.1029  
 35.1030  lemma fps_divide_X_minus1_setsum_lemma:
 35.1031    "a = ((1::'a::comm_ring_1 fps) - X) * Abs_fps (\<lambda>n. setsum (\<lambda>i. a $ i) {0..n})"
 35.1032 @@ -1354,39 +1332,33 @@
 35.1033    let ?sa = "Abs_fps (\<lambda>n. setsum (\<lambda>i. a $ i) {0..n})"
 35.1034    have th0: "\<And>i. (1 - (X::'a fps)) $ i = (if i = 0 then 1 else if i = 1 then - 1 else 0)"
 35.1035      by simp
 35.1036 -  {
 35.1037 -    fix n :: nat
 35.1038 -    {
 35.1039 -      assume "n = 0"
 35.1040 -      then have "a $ n = ((1 - X) * ?sa) $ n"
 35.1041 -        by (simp add: fps_mult_nth)
 35.1042 -    }
 35.1043 -    moreover
 35.1044 -    {
 35.1045 -      assume n0: "n \<noteq> 0"
 35.1046 -      then have u: "{0} \<union> ({1} \<union> {2..n}) = {0..n}" "{1} \<union> {2..n} = {1..n}"
 35.1047 -        "{0..n - 1} \<union> {n} = {0..n}"
 35.1048 -        by (auto simp: set_eq_iff)
 35.1049 -      have d: "{0} \<inter> ({1} \<union> {2..n}) = {}" "{1} \<inter> {2..n} = {}" "{0..n - 1} \<inter> {n} = {}"
 35.1050 -        using n0 by simp_all
 35.1051 -      have f: "finite {0}" "finite {1}" "finite {2 .. n}"
 35.1052 -        "finite {0 .. n - 1}" "finite {n}" by simp_all
 35.1053 -      have "((1 - X) * ?sa) $ n = setsum (\<lambda>i. (1 - X)$ i * ?sa $ (n - i)) {0 .. n}"
 35.1054 -        by (simp add: fps_mult_nth)
 35.1055 -      also have "\<dots> = a$n"
 35.1056 -        unfolding th0
 35.1057 -        unfolding setsum.union_disjoint[OF f(1) finite_UnI[OF f(2,3)] d(1), unfolded u(1)]
 35.1058 -        unfolding setsum.union_disjoint[OF f(2) f(3) d(2)]
 35.1059 -        apply (simp)
 35.1060 -        unfolding setsum.union_disjoint[OF f(4,5) d(3), unfolded u(3)]
 35.1061 -        apply simp
 35.1062 -        done
 35.1063 -      finally have "a$n = ((1 - X) * ?sa) $ n"
 35.1064 -        by simp
 35.1065 -    }
 35.1066 -    ultimately have "a$n = ((1 - X) * ?sa) $ n"
 35.1067 -      by blast
 35.1068 -  }
 35.1069 +  have "a$n = ((1 - X) * ?sa) $ n" for n
 35.1070 +  proof (cases "n = 0")
 35.1071 +    case True
 35.1072 +    then show ?thesis
 35.1073 +      by (simp add: fps_mult_nth)
 35.1074 +  next
 35.1075 +    case False
 35.1076 +    then have u: "{0} \<union> ({1} \<union> {2..n}) = {0..n}" "{1} \<union> {2..n} = {1..n}"
 35.1077 +      "{0..n - 1} \<union> {n} = {0..n}"
 35.1078 +      by (auto simp: set_eq_iff)
 35.1079 +    have d: "{0} \<inter> ({1} \<union> {2..n}) = {}" "{1} \<inter> {2..n} = {}" "{0..n - 1} \<inter> {n} = {}"
 35.1080 +      using False by simp_all
 35.1081 +    have f: "finite {0}" "finite {1}" "finite {2 .. n}"
 35.1082 +      "finite {0 .. n - 1}" "finite {n}" by simp_all
 35.1083 +    have "((1 - X) * ?sa) $ n = setsum (\<lambda>i. (1 - X)$ i * ?sa $ (n - i)) {0 .. n}"
 35.1084 +      by (simp add: fps_mult_nth)
 35.1085 +    also have "\<dots> = a$n"
 35.1086 +      unfolding th0
 35.1087 +      unfolding setsum.union_disjoint[OF f(1) finite_UnI[OF f(2,3)] d(1), unfolded u(1)]
 35.1088 +      unfolding setsum.union_disjoint[OF f(2) f(3) d(2)]
 35.1089 +      apply (simp)
 35.1090 +      unfolding setsum.union_disjoint[OF f(4,5) d(3), unfolded u(3)]
 35.1091 +      apply simp
 35.1092 +      done
 35.1093 +    finally show ?thesis
 35.1094 +      by simp
 35.1095 +  qed
 35.1096    then show ?thesis
 35.1097      unfolding fps_eq_iff by blast
 35.1098  qed
 35.1099 @@ -1407,8 +1379,8 @@
 35.1100  qed
 35.1101  
 35.1102  
 35.1103 -subsubsection{* Rule 4 in its more general form: generalizes Rule 3 for an arbitrary
 35.1104 -  finite product of FPS, also the relvant instance of powers of a FPS*}
 35.1105 +subsubsection \<open>Rule 4 in its more general form: generalizes Rule 3 for an arbitrary
 35.1106 +  finite product of FPS, also the relvant instance of powers of a FPS\<close>
 35.1107  
 35.1108  definition "natpermute n k = {l :: nat list. length l = k \<and> listsum l = n}"
 35.1109  
 35.1110 @@ -1576,7 +1548,7 @@
 35.1111    ultimately show ?thesis by auto
 35.1112  qed
 35.1113  
 35.1114 -text {* The general form *}
 35.1115 +text \<open>The general form\<close>
 35.1116  lemma fps_setprod_nth:
 35.1117    fixes m :: nat
 35.1118      and a :: "nat \<Rightarrow> 'a::comm_ring_1 fps"
 35.1119 @@ -1631,7 +1603,7 @@
 35.1120    qed
 35.1121  qed
 35.1122  
 35.1123 -text{* The special form for powers *}
 35.1124 +text \<open>The special form for powers\<close>
 35.1125  lemma fps_power_nth_Suc:
 35.1126    fixes m :: nat
 35.1127      and a :: "'a::comm_ring_1 fps"
 35.1128 @@ -1672,30 +1644,28 @@
 35.1129    shows "(b oo a = c oo a) \<longleftrightarrow> b = c"
 35.1130    (is "?lhs \<longleftrightarrow>?rhs")
 35.1131  proof
 35.1132 -  assume ?rhs
 35.1133 -  then show "?lhs" by simp
 35.1134 -next
 35.1135 -  assume h: ?lhs
 35.1136 -  {
 35.1137 -    fix n
 35.1138 -    have "b$n = c$n"
 35.1139 +  show ?lhs if ?rhs using that by simp
 35.1140 +  show ?rhs if ?lhs
 35.1141 +  proof -
 35.1142 +    have "b$n = c$n" for n
 35.1143      proof (induct n rule: nat_less_induct)
 35.1144        fix n
 35.1145        assume H: "\<forall>m<n. b$m = c$m"
 35.1146 -      {
 35.1147 -        assume n0: "n=0"
 35.1148 -        from h have "(b oo a)$n = (c oo a)$n" by simp
 35.1149 -        then have "b$n = c$n" using n0 by (simp add: fps_compose_nth)
 35.1150 -      }
 35.1151 -      moreover
 35.1152 -      {
 35.1153 -        fix n1 assume n1: "n = Suc n1"
 35.1154 +      show "b$n = c$n"
 35.1155 +      proof (cases n)
 35.1156 +        case 0
 35.1157 +        from \<open>?lhs\<close> have "(b oo a)$n = (c oo a)$n"
 35.1158 +          by simp
 35.1159 +        then show ?thesis
 35.1160 +          using 0 by (simp add: fps_compose_nth)
 35.1161 +      next
 35.1162 +        case (Suc n1)
 35.1163          have f: "finite {0 .. n1}" "finite {n}" by simp_all
 35.1164 -        have eq: "{0 .. n1} \<union> {n} = {0 .. n}" using n1 by auto
 35.1165 -        have d: "{0 .. n1} \<inter> {n} = {}" using n1 by auto
 35.1166 +        have eq: "{0 .. n1} \<union> {n} = {0 .. n}" using Suc by auto
 35.1167 +        have d: "{0 .. n1} \<inter> {n} = {}" using Suc by auto
 35.1168          have seq: "(\<Sum>i = 0..n1. b $ i * a ^ i $ n) = (\<Sum>i = 0..n1. c $ i * a ^ i $ n)"
 35.1169            apply (rule setsum.cong)
 35.1170 -          using H n1
 35.1171 +          using H Suc
 35.1172            apply auto
 35.1173            done
 35.1174          have th0: "(b oo a) $n = (\<Sum>i = 0..n1. c $ i * a ^ i $ n) + b$n * (a$1)^n"
 35.1175 @@ -1706,16 +1676,16 @@
 35.1176            unfolding fps_compose_nth setsum.union_disjoint[OF f d, unfolded eq]
 35.1177            using startsby_zero_power_nth_same[OF a0]
 35.1178            by simp
 35.1179 -        from h[unfolded fps_eq_iff, rule_format, of n] th0 th1 a1
 35.1180 -        have "b$n = c$n" by auto
 35.1181 -      }
 35.1182 -      ultimately show "b$n = c$n" by (cases n) auto
 35.1183 -    qed}
 35.1184 -  then show ?rhs by (simp add: fps_eq_iff)
 35.1185 +        from \<open>?lhs\<close>[unfolded fps_eq_iff, rule_format, of n] th0 th1 a1
 35.1186 +        show ?thesis by auto
 35.1187 +      qed
 35.1188 +    qed
 35.1189 +    then show ?rhs by (simp add: fps_eq_iff)
 35.1190 +  qed
 35.1191  qed
 35.1192  
 35.1193  
 35.1194 -subsection {* Radicals *}
 35.1195 +subsection \<open>Radicals\<close>
 35.1196  
 35.1197  declare setprod.cong [fundef_cong]
 35.1198  
 35.1199 @@ -1777,7 +1747,7 @@
 35.1200    apply auto
 35.1201    done
 35.1202  
 35.1203 -lemma fps_radical_nth_0[simp]: "fps_radical r n a $ 0 = (if n=0 then 1 else r n (a$0))"
 35.1204 +lemma fps_radical_nth_0[simp]: "fps_radical r n a $ 0 = (if n = 0 then 1 else r n (a$0))"
 35.1205    by (cases n) (simp_all add: fps_radical_def)
 35.1206  
 35.1207  lemma fps_radical_power_nth[simp]:
 35.1208 @@ -1797,8 +1767,10 @@
 35.1209      apply (subgoal_tac "replicate k 0 ! x = 0")
 35.1210      apply (auto intro: nth_replicate simp del: replicate.simps)
 35.1211      done
 35.1212 -  also have "\<dots> = a$0" using r Suc by (simp add: setprod_constant)
 35.1213 -  finally show ?thesis using Suc by simp
 35.1214 +  also have "\<dots> = a$0"
 35.1215 +    using r Suc by (simp add: setprod_constant)
 35.1216 +  finally show ?thesis
 35.1217 +    using Suc by simp
 35.1218  qed
 35.1219  
 35.1220  lemma natpermute_max_card:
 35.1221 @@ -1806,15 +1778,17 @@
 35.1222    shows "card {xs \<in> natpermute n (k+1). n \<in> set xs} = k + 1"
 35.1223    unfolding natpermute_contain_maximal
 35.1224  proof -
 35.1225 -  let ?A= "\<lambda>i. {replicate (k + 1) 0[i := n]}"
 35.1226 +  let ?A = "\<lambda>i. {replicate (k + 1) 0[i := n]}"
 35.1227    let ?K = "{0 ..k}"
 35.1228 -  have fK: "finite ?K" by simp
 35.1229 -  have fAK: "\<forall>i\<in>?K. finite (?A i)" by auto
 35.1230 +  have fK: "finite ?K"
 35.1231 +    by simp
 35.1232 +  have fAK: "\<forall>i\<in>?K. finite (?A i)"
 35.1233 +    by auto
 35.1234    have d: "\<forall>i\<in> ?K. \<forall>j\<in> ?K. i \<noteq> j \<longrightarrow>
 35.1235      {replicate (k + 1) 0[i := n]} \<inter> {replicate (k + 1) 0[j := n]} = {}"
 35.1236    proof clarify
 35.1237      fix i j
 35.1238 -    assume i: "i \<in> ?K" and j: "j\<in> ?K" and ij: "i\<noteq>j"
 35.1239 +    assume i: "i \<in> ?K" and j: "j \<in> ?K" and ij: "i \<noteq> j"
 35.1240      {
 35.1241        assume eq: "replicate (k+1) 0 [i:=n] = replicate (k+1) 0 [j:= n]"
 35.1242        have "(replicate (k+1) 0 [i:=n] ! i) = n"
 35.1243 @@ -1842,60 +1816,55 @@
 35.1244    {
 35.1245      assume r0: "(r (Suc k) (a$0)) ^ Suc k = a$0"
 35.1246      from a0 r0 have r00: "r (Suc k) (a$0) \<noteq> 0" by auto
 35.1247 -    {
 35.1248 -      fix z
 35.1249 -      have "?r ^ Suc k $ z = a$z"
 35.1250 -      proof (induct z rule: nat_less_induct)
 35.1251 -        fix n
 35.1252 -        assume H: "\<forall>m<n. ?r ^ Suc k $ m = a$m"
 35.1253 -        {
 35.1254 -          assume "n = 0"
 35.1255 -          then have "?r ^ Suc k $ n = a $n"
 35.1256 -            using fps_radical_power_nth[of r "Suc k" a, OF r0] by simp
 35.1257 -        }
 35.1258 -        moreover
 35.1259 -        {
 35.1260 -          fix n1 assume n1: "n = Suc n1"
 35.1261 -          have nz: "n \<noteq> 0" using n1 by arith
 35.1262 -          let ?Pnk = "natpermute n (k + 1)"
 35.1263 -          let ?Pnkn = "{xs \<in> ?Pnk. n \<in> set xs}"
 35.1264 -          let ?Pnknn = "{xs \<in> ?Pnk. n \<notin> set xs}"
 35.1265 -          have eq: "?Pnkn \<union> ?Pnknn = ?Pnk" by blast
 35.1266 -          have d: "?Pnkn \<inter> ?Pnknn = {}" by blast
 35.1267 -          have f: "finite ?Pnkn" "finite ?Pnknn"
 35.1268 -            using finite_Un[of ?Pnkn ?Pnknn, unfolded eq]
 35.1269 -            by (metis natpermute_finite)+
 35.1270 -          let ?f = "\<lambda>v. \<Prod>j\<in>{0..k}. ?r $ v ! j"
 35.1271 -          have "setsum ?f ?Pnkn = setsum (\<lambda>v. ?r $ n * r (Suc k) (a $ 0) ^ k) ?Pnkn"
 35.1272 -          proof (rule setsum.cong)
 35.1273 -            fix v assume v: "v \<in> {xs \<in> natpermute n (k + 1). n \<in> set xs}"
 35.1274 -            let ?ths = "(\<Prod>j\<in>{0..k}. fps_radical r (Suc k) a $ v ! j) =
 35.1275 -              fps_radical r (Suc k) a $ n * r (Suc k) (a $ 0) ^ k"
 35.1276 -            from v obtain i where i: "i \<in> {0..k}" "v = replicate (k+1) 0 [i:= n]"
 35.1277 -              unfolding natpermute_contain_maximal by auto
 35.1278 -            have "(\<Prod>j\<in>{0..k}. fps_radical r (Suc k) a $ v ! j) =
 35.1279 -                (\<Prod>j\<in>{0..k}. if j = i then fps_radical r (Suc k) a $ n else r (Suc k) (a$0))"
 35.1280 -              apply (rule setprod.cong, simp)
 35.1281 -              using i r0
 35.1282 -              apply (simp del: replicate.simps)
 35.1283 -              done
 35.1284 -            also have "\<dots> = (fps_radical r (Suc k) a $ n) * r (Suc k) (a$0) ^ k"
 35.1285 -              using i r0 by (simp add: setprod_gen_delta)
 35.1286 -            finally show ?ths .
 35.1287 -          qed rule
 35.1288 -          then have "setsum ?f ?Pnkn = of_nat (k+1) * ?r $ n * r (Suc k) (a $ 0) ^ k"
 35.1289 -            by (simp add: natpermute_max_card[OF nz, simplified])
 35.1290 -          also have "\<dots> = a$n - setsum ?f ?Pnknn"
 35.1291 -            unfolding n1 using r00 a0 by (simp add: field_simps fps_radical_def del: of_nat_Suc)
 35.1292 -          finally have fn: "setsum ?f ?Pnkn = a$n - setsum ?f ?Pnknn" .
 35.1293 -          have "(?r ^ Suc k)$n = setsum ?f ?Pnkn + setsum ?f ?Pnknn"
 35.1294 -            unfolding fps_power_nth_Suc setsum.union_disjoint[OF f d, unfolded eq] ..
 35.1295 -          also have "\<dots> = a$n" unfolding fn by simp
 35.1296 -          finally have "?r ^ Suc k $ n = a $n" .
 35.1297 -        }
 35.1298 -        ultimately  show "?r ^ Suc k $ n = a $n" by (cases n) auto
 35.1299 +    have "?r ^ Suc k $ z = a$z" for z
 35.1300 +    proof (induct z rule: nat_less_induct)
 35.1301 +      fix n
 35.1302 +      assume H: "\<forall>m<n. ?r ^ Suc k $ m = a$m"
 35.1303 +      show "?r ^ Suc k $ n = a $n"
 35.1304 +      proof (cases n)
 35.1305 +        case 0
 35.1306 +        then show ?thesis
 35.1307 +          using fps_radical_power_nth[of r "Suc k" a, OF r0] by simp
 35.1308 +      next
 35.1309 +        case (Suc n1)
 35.1310 +        then have "n \<noteq> 0" by simp
 35.1311 +        let ?Pnk = "natpermute n (k + 1)"
 35.1312 +        let ?Pnkn = "{xs \<in> ?Pnk. n \<in> set xs}"
 35.1313 +        let ?Pnknn = "{xs \<in> ?Pnk. n \<notin> set xs}"
 35.1314 +        have eq: "?Pnkn \<union> ?Pnknn = ?Pnk" by blast
 35.1315 +        have d: "?Pnkn \<inter> ?Pnknn = {}" by blast
 35.1316 +        have f: "finite ?Pnkn" "finite ?Pnknn"
 35.1317 +          using finite_Un[of ?Pnkn ?Pnknn, unfolded eq]
 35.1318 +          by (metis natpermute_finite)+
 35.1319 +        let ?f = "\<lambda>v. \<Prod>j\<in>{0..k}. ?r $ v ! j"
 35.1320 +        have "setsum ?f ?Pnkn = setsum (\<lambda>v. ?r $ n * r (Suc k) (a $ 0) ^ k) ?Pnkn"
 35.1321 +        proof (rule setsum.cong)
 35.1322 +          fix v assume v: "v \<in> {xs \<in> natpermute n (k + 1). n \<in> set xs}"
 35.1323 +          let ?ths = "(\<Prod>j\<in>{0..k}. fps_radical r (Suc k) a $ v ! j) =
 35.1324 +            fps_radical r (Suc k) a $ n * r (Suc k) (a $ 0) ^ k"
 35.1325 +          from v obtain i where i: "i \<in> {0..k}" "v = replicate (k+1) 0 [i:= n]"
 35.1326 +            unfolding natpermute_contain_maximal by auto
 35.1327 +          have "(\<Prod>j\<in>{0..k}. fps_radical r (Suc k) a $ v ! j) =
 35.1328 +              (\<Prod>j\<in>{0..k}. if j = i then fps_radical r (Suc k) a $ n else r (Suc k) (a$0))"
 35.1329 +            apply (rule setprod.cong, simp)
 35.1330 +            using i r0
 35.1331 +            apply (simp del: replicate.simps)
 35.1332 +            done
 35.1333 +          also have "\<dots> = (fps_radical r (Suc k) a $ n) * r (Suc k) (a$0) ^ k"
 35.1334 +            using i r0 by (simp add: setprod_gen_delta)
 35.1335 +          finally show ?ths .
 35.1336 +        qed rule
 35.1337 +        then have "setsum ?f ?Pnkn = of_nat (k+1) * ?r $ n * r (Suc k) (a $ 0) ^ k"
 35.1338 +          by (simp add: natpermute_max_card[OF \<open>n \<noteq> 0\<close>, simplified])
 35.1339 +        also have "\<dots> = a$n - setsum ?f ?Pnknn"
 35.1340 +          unfolding Suc using r00 a0 by (simp add: field_simps fps_radical_def del: of_nat_Suc)
 35.1341 +        finally have fn: "setsum ?f ?Pnkn = a$n - setsum ?f ?Pnknn" .
 35.1342 +        have "(?r ^ Suc k)$n = setsum ?f ?Pnkn + setsum ?f ?Pnknn"
 35.1343 +          unfolding fps_power_nth_Suc setsum.union_disjoint[OF f d, unfolded eq] ..
 35.1344 +        also have "\<dots> = a$n" unfolding fn by simp
 35.1345 +        finally show ?thesis .
 35.1346        qed
 35.1347 -    }
 35.1348 +    qed
 35.1349      then have ?thesis using r0 by (simp add: fps_eq_iff)
 35.1350    }
 35.1351    moreover
 35.1352 @@ -1964,7 +1933,8 @@
 35.1353  
 35.1354  *)
 35.1355  lemma eq_divide_imp':
 35.1356 -  fixes c :: "'a::field" shows "c \<noteq> 0 \<Longrightarrow> a * c = b \<Longrightarrow> a = b / c"
 35.1357 +  fixes c :: "'a::field"
 35.1358 +  shows "c \<noteq> 0 \<Longrightarrow> a * c = b \<Longrightarrow> a = b / c"
 35.1359    by (simp add: field_simps)
 35.1360  
 35.1361  lemma radical_unique:
 35.1362 @@ -1972,35 +1942,27 @@
 35.1363      and a0: "r (Suc k) (b$0 ::'a::field_char_0) = a$0"
 35.1364      and b0: "b$0 \<noteq> 0"
 35.1365    shows "a^(Suc k) = b \<longleftrightarrow> a = fps_radical r (Suc k) b"
 35.1366 -proof -
 35.1367 -  let ?r = "fps_radical r (Suc k) b"
 35.1368 -  have r00: "r (Suc k) (b$0) \<noteq> 0" using b0 r0 by auto
 35.1369 -  {
 35.1370 -    assume H: "a = ?r"
 35.1371 -    from H have "a^Suc k = b"
 35.1372 -      using power_radical[OF b0, of r k, unfolded r0] by simp
 35.1373 -  }
 35.1374 -  moreover
 35.1375 -  {
 35.1376 -    assume H: "a^Suc k = b"
 35.1377 +    (is "?lhs \<longleftrightarrow> ?rhs" is "_ \<longleftrightarrow> a = ?r")
 35.1378 +proof
 35.1379 +  show ?lhs if ?rhs
 35.1380 +    using that using power_radical[OF b0, of r k, unfolded r0] by simp
 35.1381 +  show ?rhs if ?lhs
 35.1382 +  proof -
 35.1383 +    have r00: "r (Suc k) (b$0) \<noteq> 0" using b0 r0 by auto
 35.1384      have ceq: "card {0..k} = Suc k" by simp
 35.1385      from a0 have a0r0: "a$0 = ?r$0" by simp
 35.1386 -    {
 35.1387 +    have "a $ n = ?r $ n" for n
 35.1388 +    proof (induct n rule: nat_less_induct)
 35.1389        fix n
 35.1390 -      have "a $ n = ?r $ n"
 35.1391 -      proof (induct n rule: nat_less_induct)
 35.1392 -        fix n
 35.1393 -        assume h: "\<forall>m<n. a$m = ?r $m"
 35.1394 -        {
 35.1395 -          assume "n = 0"
 35.1396 -          then have "a$n = ?r $n" using a0 by simp
 35.1397 -        }
 35.1398 -        moreover
 35.1399 -        {
 35.1400 -          fix n1
 35.1401 -          assume n1: "n = Suc n1"
 35.1402 -          have fK: "finite {0..k}" by simp
 35.1403 -        have nz: "n \<noteq> 0" using n1 by arith
 35.1404 +      assume h: "\<forall>m<n. a$m = ?r $m"
 35.1405 +      show "a$n = ?r $ n"
 35.1406 +      proof (cases n)
 35.1407 +        case 0
 35.1408 +        then show ?thesis using a0 by simp
 35.1409 +      next
 35.1410 +        case (Suc n1)
 35.1411 +        have fK: "finite {0..k}" by simp
 35.1412 +        have nz: "n \<noteq> 0" using Suc by simp
 35.1413          let ?Pnk = "natpermute n (Suc k)"
 35.1414          let ?Pnkn = "{xs \<in> ?Pnk. n \<in> set xs}"
 35.1415          let ?Pnknn = "{xs \<in> ?Pnk. n \<notin> set xs}"
 35.1416 @@ -2034,9 +1996,9 @@
 35.1417          proof (rule setsum.cong, rule refl, rule setprod.cong, simp)
 35.1418            fix xs i
 35.1419            assume xs: "xs \<in> ?Pnknn" and i: "i \<in> {0..k}"
 35.1420 -          {
 35.1421 -            assume c: "n \<le> xs ! i"
 35.1422 -            from xs i have "xs !i \<noteq> n"
 35.1423 +          have False if c: "n \<le> xs ! i"
 35.1424 +          proof -
 35.1425 +            from xs i have "xs ! i \<noteq> n"
 35.1426                by (auto simp add: in_set_conv_nth natpermute_def)
 35.1427              with c have c': "n < xs!i" by arith
 35.1428              have fths: "finite {0 ..< i}" "finite {i}" "finite {i+1..<Suc k}"
 35.1429 @@ -2053,14 +2015,14 @@
 35.1430                unfolding eqs  setsum.union_disjoint[OF fths(1) finite_UnI[OF fths(2,3)] d(1)]
 35.1431                unfolding setsum.union_disjoint[OF fths(2) fths(3) d(2)]
 35.1432                by simp
 35.1433 -            finally have False using c' by simp
 35.1434 -          }
 35.1435 +            finally show ?thesis using c' by simp
 35.1436 +          qed
 35.1437            then have thn: "xs!i < n" by presburger
 35.1438            from h[rule_format, OF thn] show "a$(xs !i) = ?r$(xs!i)" .
 35.1439          qed
 35.1440          have th00: "\<And>x::'a. of_nat (Suc k) * (x * inverse (of_nat (Suc k))) = x"
 35.1441            by (simp add: field_simps del: of_nat_Suc)
 35.1442 -        from H have "b$n = a^Suc k $ n"
 35.1443 +        from \<open>?lhs\<close> have "b$n = a^Suc k $ n"
 35.1444            by (simp add: fps_eq_iff)
 35.1445          also have "a ^ Suc k$n = setsum ?g ?Pnkn + setsum ?g ?Pnknn"
 35.1446            unfolding fps_power_nth_Suc
 35.1447 @@ -2077,18 +2039,15 @@
 35.1448            apply (simp del: of_nat_Suc)
 35.1449            apply (simp add: ac_simps)
 35.1450            done
 35.1451 -        then have "a$n = ?r $n"
 35.1452 +        then show ?thesis
 35.1453            apply (simp del: of_nat_Suc)
 35.1454 -          unfolding fps_radical_def n1
 35.1455 -          apply (simp add: field_simps n1 th00 del: of_nat_Suc)
 35.1456 +          unfolding fps_radical_def Suc
 35.1457 +          apply (simp add: field_simps Suc th00 del: of_nat_Suc)
 35.1458            done
 35.1459 -        }
 35.1460 -        ultimately show "a$n = ?r $ n" by (cases n) auto
 35.1461        qed
 35.1462 -    }
 35.1463 -    then have "a = ?r" by (simp add: fps_eq_iff)
 35.1464 -  }
 35.1465 -  ultimately show ?thesis by blast
 35.1466 +    qed
 35.1467 +    then show ?rhs by (simp add: fps_eq_iff)
 35.1468 +  qed
 35.1469  qed
 35.1470  
 35.1471  
 35.1472 @@ -2148,27 +2107,26 @@
 35.1473      fps_radical r (k) (a*b) = fps_radical r (k) a * fps_radical r (k) (b)"
 35.1474  proof -
 35.1475    {
 35.1476 -    assume  r0': "r k ((a * b) $ 0) = r k (a $ 0) * r k (b $ 0)"
 35.1477 -    from r0' have r0: "(r (k) ((a*b)$0)) ^ k = (a*b)$0"
 35.1478 +    assume r0': "r k ((a * b) $ 0) = r k (a $ 0) * r k (b $ 0)"
 35.1479 +    then have r0: "(r (k) ((a*b)$0)) ^ k = (a*b)$0"
 35.1480        by (simp add: fps_mult_nth ra0 rb0 power_mult_distrib)
 35.1481 -    {
 35.1482 -      assume "k = 0"
 35.1483 -      then have ?thesis using r0' by simp
 35.1484 -    }
 35.1485 -    moreover
 35.1486 -    {
 35.1487 -      fix h assume k: "k = Suc h"
 35.1488 +    have ?thesis
 35.1489 +    proof (cases k)
 35.1490 +      case 0
 35.1491 +      then show ?thesis using r0' by simp
 35.1492 +    next
 35.1493 +      case (Suc h)
 35.1494        let ?ra = "fps_radical r (Suc h) a"
 35.1495        let ?rb = "fps_radical r (Suc h) b"
 35.1496        have th0: "r (Suc h) ((a * b) $ 0) = (fps_radical r (Suc h) a * fps_radical r (Suc h) b) $ 0"
 35.1497 -        using r0' k by (simp add: fps_mult_nth)
 35.1498 +        using r0' Suc by (simp add: fps_mult_nth)
 35.1499        have ab0: "(a*b) $ 0 \<noteq> 0"
 35.1500          using a0 b0 by (simp add: fps_mult_nth)
 35.1501 -      from radical_unique[of r h "a*b" "fps_radical r (Suc h) a * fps_radical r (Suc h) b", OF r0[unfolded k] th0 ab0, symmetric]
 35.1502 -        iffD1[OF power_radical[of _ r], OF a0 ra0[unfolded k]] iffD1[OF power_radical[of _ r], OF b0 rb0[unfolded k]] k r0'
 35.1503 -      have ?thesis by (auto simp add: power_mult_distrib simp del: power_Suc)
 35.1504 -    }
 35.1505 -    ultimately have ?thesis by (cases k) auto
 35.1506 +      from radical_unique[of r h "a*b" "fps_radical r (Suc h) a * fps_radical r (Suc h) b", OF r0[unfolded Suc] th0 ab0, symmetric]
 35.1507 +        iffD1[OF power_radical[of _ r], OF a0 ra0[unfolded Suc]] iffD1[OF power_radical[of _ r], OF b0 rb0[unfolded Suc]] Suc r0'
 35.1508 +      show ?thesis
 35.1509 +        by (auto simp add: power_mult_distrib simp del: power_Suc)
 35.1510 +    qed
 35.1511    }
 35.1512    moreover
 35.1513    {
 35.1514 @@ -2222,26 +2180,26 @@
 35.1515    shows "r k ((a $ 0) / (b$0)) = r k (a$0) / r k (b $ 0) \<longleftrightarrow>
 35.1516      fps_radical r k (a/b) = fps_radical r k a / fps_radical r k b"
 35.1517    (is "?lhs = ?rhs")
 35.1518 -proof -
 35.1519 +proof
 35.1520    let ?r = "fps_radical r k"
 35.1521    from kp obtain h where k: "k = Suc h" by (cases k) auto
 35.1522    have ra0': "r k (a$0) \<noteq> 0" using a0 ra0 k by auto
 35.1523    have rb0': "r k (b$0) \<noteq> 0" using b0 rb0 k by auto
 35.1524  
 35.1525 -  {
 35.1526 -    assume ?rhs
 35.1527 -    then have "?r (a/b) $ 0 = (?r a / ?r b)$0" by simp
 35.1528 -    then have ?lhs using k a0 b0 rb0'
 35.1529 -      by (simp add: fps_divide_def fps_mult_nth fps_inverse_def divide_inverse)
 35.1530 -  }
 35.1531 -  moreover
 35.1532 -  {
 35.1533 -    assume h: ?lhs
 35.1534 +  show ?lhs if ?rhs
 35.1535 +  proof -
 35.1536 +    from that have "?r (a/b) $ 0 = (?r a / ?r b)$0"
 35.1537 +      by simp
 35.1538 +    then show ?thesis
 35.1539 +      using k a0 b0 rb0' by (simp add: fps_divide_def fps_mult_nth fps_inverse_def divide_inverse)
 35.1540 +  qed
 35.1541 +  show ?rhs if ?lhs
 35.1542 +  proof -
 35.1543      from a0 b0 have ab0[simp]: "(a/b)$0 = a$0 / b$0"
 35.1544        by (simp add: fps_divide_def fps_mult_nth divide_inverse fps_inverse_def)
 35.1545      have th0: "r k ((a/b)$0) ^ k = (a/b)$0"
 35.1546 -      by (simp add: h nonzero_power_divide[OF rb0'] ra0 rb0)
 35.1547 -    from a0 b0 ra0' rb0' kp h
 35.1548 +      by (simp add: \<open>?lhs\<close> nonzero_power_divide[OF rb0'] ra0 rb0)
 35.1549 +    from a0 b0 ra0' rb0' kp \<open>?lhs\<close>
 35.1550      have th1: "r k ((a / b) $ 0) = (fps_radical r k a / fps_radical r k b) $ 0"
 35.1551        by (simp add: fps_divide_def fps_mult_nth fps_inverse_def divide_inverse)
 35.1552      from a0 b0 ra0' rb0' kp have ab0': "(a / b) $ 0 \<noteq> 0"
 35.1553 @@ -2251,9 +2209,8 @@
 35.1554      have th2: "(?r a / ?r b)^k = a/b"
 35.1555        by (simp add: fps_divide_def power_mult_distrib fps_inverse_power[symmetric])
 35.1556      from iffD1[OF radical_unique[where r=r and a="?r a / ?r b" and b="a/b" and k=h], symmetric, unfolded k[symmetric], OF th0 th1 ab0' th2]
 35.1557 -    have ?rhs .
 35.1558 -  }
 35.1559 -  ultimately show ?thesis by blast
 35.1560 +    show ?thesis .
 35.1561 +  qed
 35.1562  qed
 35.1563  
 35.1564  lemma radical_inverse:
 35.1565 @@ -2267,15 +2224,16 @@
 35.1566    using radical_divide[where k=k and r=r and a=1 and b=a, OF k ] ra0 r1 a0
 35.1567    by (simp add: divide_inverse fps_divide_def)
 35.1568  
 35.1569 -subsection{* Derivative of composition *}
 35.1570 +
 35.1571 +subsection \<open>Derivative of composition\<close>
 35.1572  
 35.1573  lemma fps_compose_deriv:
 35.1574    fixes a :: "'a::idom fps"
 35.1575    assumes b0: "b$0 = 0"
 35.1576    shows "fps_deriv (a oo b) = ((fps_deriv a) oo b) * fps_deriv b"
 35.1577  proof -
 35.1578 -  {
 35.1579 -    fix n
 35.1580 +  have "(fps_deriv (a oo b))$n = (((fps_deriv a) oo b) * (fps_deriv b)) $n" for n
 35.1581 +  proof -
 35.1582      have "(fps_deriv (a oo b))$n = setsum (\<lambda>i. a $ i * (fps_deriv (b^i))$n) {0.. Suc n}"
 35.1583        by (simp add: fps_compose_def field_simps setsum_right_distrib del: of_nat_Suc)
 35.1584      also have "\<dots> = setsum (\<lambda>i. a$i * ((fps_const (of_nat i)) * (fps_deriv b * (b^(i - 1))))$n) {0.. Suc n}"
 35.1585 @@ -2314,9 +2272,9 @@
 35.1586        apply (rule setsum.cong, rule refl)+
 35.1587        apply simp
 35.1588        done
 35.1589 -    finally have "(fps_deriv (a oo b))$n = (((fps_deriv a) oo b) * (fps_deriv b)) $n"
 35.1590 +    finally show ?thesis
 35.1591        unfolding th0 by simp
 35.1592 -  }
 35.1593 +  qed
 35.1594    then show ?thesis by (simp add: fps_eq_iff)
 35.1595  qed
 35.1596  
 35.1597 @@ -2325,10 +2283,10 @@
 35.1598  proof (cases n)
 35.1599    case 0
 35.1600    then show ?thesis
 35.1601 -    by (simp add: fps_mult_nth )
 35.1602 +    by (simp add: fps_mult_nth)
 35.1603  next
 35.1604    case (Suc m)
 35.1605 -  have "((1+X)*a) $n = setsum (\<lambda>i. (1+X)$i * a$(n-i)) {0..n}"
 35.1606 +  have "((1 + X)*a) $ n = setsum (\<lambda>i. (1 + X) $ i * a $ (n - i)) {0..n}"
 35.1607      by (simp add: fps_mult_nth)
 35.1608    also have "\<dots> = setsum (\<lambda>i. (1+X)$i * a$(n-i)) {0.. 1}"
 35.1609      unfolding Suc by (rule setsum.mono_neutral_right) auto
 35.1610 @@ -2338,23 +2296,21 @@
 35.1611  qed
 35.1612  
 35.1613  
 35.1614 -subsection {* Finite FPS (i.e. polynomials) and X *}
 35.1615 +subsection \<open>Finite FPS (i.e. polynomials) and X\<close>
 35.1616  
 35.1617  lemma fps_poly_sum_X:
 35.1618 -  assumes z: "\<forall>i > n. a$i = (0::'a::comm_ring_1)"
 35.1619 +  assumes "\<forall>i > n. a$i = (0::'a::comm_ring_1)"
 35.1620    shows "a = setsum (\<lambda>i. fps_const (a$i) * X^i) {0..n}" (is "a = ?r")
 35.1621  proof -
 35.1622 -  {
 35.1623 -    fix i
 35.1624 -    have "a$i = ?r$i"
 35.1625 -      unfolding fps_setsum_nth fps_mult_left_const_nth X_power_nth
 35.1626 -      by (simp add: mult_delta_right setsum.delta' z)
 35.1627 -  }
 35.1628 -  then show ?thesis unfolding fps_eq_iff by blast
 35.1629 +  have "a$i = ?r$i" for i
 35.1630 +    unfolding fps_setsum_nth fps_mult_left_const_nth X_power_nth
 35.1631 +    by (simp add: mult_delta_right setsum.delta' assms)
 35.1632 +  then show ?thesis
 35.1633 +    unfolding fps_eq_iff by blast
 35.1634  qed
 35.1635  
 35.1636  
 35.1637 -subsection{* Compositional inverses *}
 35.1638 +subsection \<open>Compositional inverses\<close>
 35.1639  
 35.1640  fun compinv :: "'a fps \<Rightarrow> nat \<Rightarrow> 'a::field"
 35.1641  where
 35.1642 @@ -2370,30 +2326,28 @@
 35.1643    shows "fps_inv a oo a = X"
 35.1644  proof -
 35.1645    let ?i = "fps_inv a oo a"
 35.1646 -  {
 35.1647 +  have "?i $n = X$n" for n
 35.1648 +  proof (induct n rule: nat_less_induct)
 35.1649      fix n
 35.1650 -    have "?i $n = X$n"
 35.1651 -    proof (induct n rule: nat_less_induct)
 35.1652 -      fix n
 35.1653 -      assume h: "\<forall>m<n. ?i$m = X$m"
 35.1654 -      show "?i $ n = X$n"
 35.1655 -      proof (cases n)
 35.1656 -        case 0
 35.1657 -        then show ?thesis using a0
 35.1658 -          by (simp add: fps_compose_nth fps_inv_def)
 35.1659 -      next
 35.1660 -        case (Suc n1)
 35.1661 -        have "?i $ n = setsum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1} + fps_inv a $ Suc n1 * (a $ 1)^ Suc n1"
 35.1662 -          by (simp only: fps_compose_nth) (simp add: Suc startsby_zero_power_nth_same [OF a0] del: power_Suc)
 35.1663 -        also have "\<dots> = setsum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1} +
 35.1664 -          (X$ Suc n1 - setsum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1})"
 35.1665 -          using a0 a1 Suc by (simp add: fps_inv_def)
 35.1666 -        also have "\<dots> = X$n" using Suc by simp
 35.1667 -        finally show ?thesis .
 35.1668 -      qed
 35.1669 +    assume h: "\<forall>m<n. ?i$m = X$m"
 35.1670 +    show "?i $ n = X$n"
 35.1671 +    proof (cases n)
 35.1672 +      case 0
 35.1673 +      then show ?thesis using a0
 35.1674 +        by (simp add: fps_compose_nth fps_inv_def)
 35.1675 +    next
 35.1676 +      case (Suc n1)
 35.1677 +      have "?i $ n = setsum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1} + fps_inv a $ Suc n1 * (a $ 1)^ Suc n1"
 35.1678 +        by (simp only: fps_compose_nth) (simp add: Suc startsby_zero_power_nth_same [OF a0] del: power_Suc)
 35.1679 +      also have "\<dots> = setsum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1} +
 35.1680 +        (X$ Suc n1 - setsum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1})"
 35.1681 +        using a0 a1 Suc by (simp add: fps_inv_def)
 35.1682 +      also have "\<dots> = X$n" using Suc by simp
 35.1683 +      finally show ?thesis .
 35.1684      qed
 35.1685 -  }
 35.1686 -  then show ?thesis by (simp add: fps_eq_iff)
 35.1687 +  qed
 35.1688 +  then show ?thesis
 35.1689 +    by (simp add: fps_eq_iff)
 35.1690  qed
 35.1691  
 35.1692  
 35.1693 @@ -2411,30 +2365,28 @@
 35.1694    shows "fps_ginv b a oo a = b"
 35.1695  proof -
 35.1696    let ?i = "fps_ginv b a oo a"
 35.1697 -  {
 35.1698 +  have "?i $n = b$n" for n
 35.1699 +  proof (induct n rule: nat_less_induct)
 35.1700      fix n
 35.1701 -    have "?i $n = b$n"
 35.1702 -    proof (induct n rule: nat_less_induct)
 35.1703 -      fix n
 35.1704 -      assume h: "\<forall>m<n. ?i$m = b$m"
 35.1705 -      show "?i $ n = b$n"
 35.1706 -      proof (cases n)
 35.1707 -        case 0
 35.1708 -        then show ?thesis using a0
 35.1709 -          by (simp add: fps_compose_nth fps_ginv_def)
 35.1710 -      next
 35.1711 -        case (Suc n1)
 35.1712 -        have "?i $ n = setsum (\<lambda>i. (fps_ginv b a $ i) * (a^i)$n) {0 .. n1} + fps_ginv b a $ Suc n1 * (a $ 1)^ Suc n1"
 35.1713 -          by (simp only: fps_compose_nth) (simp add: Suc startsby_zero_power_nth_same [OF a0] del: power_Suc)
 35.1714 -        also have "\<dots> = setsum (\<lambda>i. (fps_ginv b a $ i) * (a^i)$n) {0 .. n1} +
 35.1715 -          (b$ Suc n1 - setsum (\<lambda>i. (fps_ginv b a $ i) * (a^i)$n) {0 .. n1})"
 35.1716 -          using a0 a1 Suc by (simp add: fps_ginv_def)
 35.1717 -        also have "\<dots> = b$n" using Suc by simp
 35.1718 -        finally show ?thesis .
 35.1719 -      qed
 35.1720 +    assume h: "\<forall>m<n. ?i$m = b$m"
 35.1721 +    show "?i $ n = b$n"
 35.1722 +    proof (cases n)
 35.1723 +      case 0
 35.1724 +      then show ?thesis using a0
 35.1725 +        by (simp add: fps_compose_nth fps_ginv_def)
 35.1726 +    next
 35.1727 +      case (Suc n1)
 35.1728 +      have "?i $ n = setsum (\<lambda>i. (fps_ginv b a $ i) * (a^i)$n) {0 .. n1} + fps_ginv b a $ Suc n1 * (a $ 1)^ Suc n1"
 35.1729 +        by (simp only: fps_compose_nth) (simp add: Suc startsby_zero_power_nth_same [OF a0] del: power_Suc)
 35.1730 +      also have "\<dots> = setsum (\<lambda>i. (fps_ginv b a $ i) * (a^i)$n) {0 .. n1} +
 35.1731 +        (b$ Suc n1 - setsum (\<lambda>i. (fps_ginv b a $ i) * (a^i)$n) {0 .. n1})"
 35.1732 +        using a0 a1 Suc by (simp add: fps_ginv_def)
 35.1733 +      also have "\<dots> = b$n" using Suc by simp
 35.1734 +      finally show ?thesis .
 35.1735      qed
 35.1736 -  }
 35.1737 -  then show ?thesis by (simp add: fps_eq_iff)
 35.1738 +  qed
 35.1739 +  then show ?thesis
 35.1740 +    by (simp add: fps_eq_iff)
 35.1741  qed
 35.1742  
 35.1743  lemma fps_inv_ginv: "fps_inv = fps_ginv X"
 35.1744 @@ -2463,7 +2415,8 @@
 35.1745    case True
 35.1746    show ?thesis
 35.1747    proof (rule finite_induct[OF True])
 35.1748 -    show "setsum f {} oo a = (\<Sum>i\<in>{}. f i oo a)" by simp
 35.1749 +    show "setsum f {} oo a = (\<Sum>i\<in>{}. f i oo a)"
 35.1750 +      by simp
 35.1751    next
 35.1752      fix x F
 35.1753      assume fF: "finite F"
 35.1754 @@ -2569,13 +2522,10 @@
 35.1755  
 35.1756  lemma fps_compose_mult_distrib_lemma:
 35.1757    assumes c0: "c$0 = (0::'a::idom)"
 35.1758 -  shows "((a oo c) * (b oo c))$n =
 35.1759 -    setsum (\<lambda>s. setsum (\<lambda>i. a$i * b$(s - i) * (c^s) $ n) {0..s}) {0..n}"
 35.1760 -    (is "?l = ?r")
 35.1761 +  shows "((a oo c) * (b oo c))$n = setsum (\<lambda>s. setsum (\<lambda>i. a$i * b$(s - i) * (c^s) $ n) {0..s}) {0..n}"
 35.1762    unfolding product_composition_lemma[OF c0 c0] power_add[symmetric]
 35.1763    unfolding setsum_pair_less_iff[where a = "\<lambda>k. a$k" and b="\<lambda>m. b$m" and c="\<lambda>s. (c ^ s)$n" and n = n] ..
 35.1764  
 35.1765 -
 35.1766  lemma fps_compose_mult_distrib:
 35.1767    assumes c0: "c $ 0 = (0::'a::idom)"
 35.1768    shows "(a * b) oo c = (a oo c) * (b oo c)"
 35.1769 @@ -2596,7 +2546,6 @@
 35.1770  lemma fps_compose_power:
 35.1771    assumes c0: "c$0 = (0::'a::idom)"
 35.1772    shows "(a oo c)^n = a^n oo c"
 35.1773 -  (is "?l = ?r")
 35.1774  proof (cases n)
 35.1775    case 0
 35.1776    then show ?thesis by simp
 35.1777 @@ -2699,8 +2648,8 @@
 35.1778      and b0: "b$0 = 0"
 35.1779    shows "a oo (b oo c) = a oo b oo c" (is "?l = ?r")
 35.1780  proof -
 35.1781 -  {
 35.1782 -    fix n
 35.1783 +  have "?l$n = ?r$n" for n
 35.1784 +  proof -
 35.1785      have "?l$n = (setsum (\<lambda>i. (fps_const (a$i) * b^i) oo c) {0..n})$n"
 35.1786        by (simp add: fps_compose_nth fps_compose_power[OF c0] fps_const_mult_apply_left
 35.1787          setsum_right_distrib mult.assoc fps_setsum_nth)
 35.1788 @@ -2714,9 +2663,10 @@
 35.1789        apply (auto simp add: not_le)
 35.1790        apply (erule startsby_zero_power_prefix[OF b0, rule_format])
 35.1791        done
 35.1792 -    finally have "?l$n = ?r$n" .
 35.1793 -  }
 35.1794 -  then show ?thesis by (simp add: fps_eq_iff)
 35.1795 +    finally show ?thesis .
 35.1796 +  qed
 35.1797 +  then show ?thesis
 35.1798 +    by (simp add: fps_eq_iff)
 35.1799  qed
 35.1800  
 35.1801  
 35.1802 @@ -2729,23 +2679,23 @@
 35.1803    then show ?thesis by simp
 35.1804  next
 35.1805    case (Suc h)
 35.1806 -  {
 35.1807 -    fix n
 35.1808 -    {
 35.1809 -      assume kn: "k>n"
 35.1810 -      then have "?l $ n = ?r $n" using a0 startsby_zero_power_prefix[OF a0] Suc
 35.1811 +  have "?l $ n = ?r $n" for n
 35.1812 +  proof -
 35.1813 +    consider "k > n" | "k \<le> n" by arith
 35.1814 +    then show ?thesis
 35.1815 +    proof cases
 35.1816 +      case 1
 35.1817 +      then show ?thesis
 35.1818 +        using a0 startsby_zero_power_prefix[OF a0] Suc
 35.1819          by (simp add: fps_compose_nth del: power_Suc)
 35.1820 -    }
 35.1821 -    moreover
 35.1822 -    {
 35.1823 -      assume kn: "k \<le> n"
 35.1824 -      then have "?l$n = ?r$n"
 35.1825 +    next
 35.1826 +      case 2
 35.1827 +      then show ?thesis
 35.1828          by (simp add: fps_compose_nth mult_delta_left setsum.delta)
 35.1829 -    }
 35.1830 -    moreover have "k >n \<or> k\<le> n"  by arith
 35.1831 -    ultimately have "?l$n = ?r$n"  by blast
 35.1832 -  }
 35.1833 -  then show ?thesis unfolding fps_eq_iff by blast
 35.1834 +    qed
 35.1835 +  qed
 35.1836 +  then show ?thesis
 35.1837 +    unfolding fps_eq_iff by blast
 35.1838  qed
 35.1839  
 35.1840  lemma fps_inv_right:
 35.1841 @@ -2755,32 +2705,38 @@
 35.1842  proof -
 35.1843    let ?ia = "fps_inv a"
 35.1844    let ?iaa = "a oo fps_inv a"
 35.1845 -  have th0: "?ia $ 0 = 0" by (simp add: fps_inv_def)
 35.1846 -  have th1: "?iaa $ 0 = 0" using a0 a1
 35.1847 -    by (simp add: fps_inv_def fps_compose_nth)
 35.1848 -  have th2: "X$0 = 0" by simp
 35.1849 -  from fps_inv[OF a0 a1] have "a oo (fps_inv a oo a) = a oo X" by simp
 35.1850 +  have th0: "?ia $ 0 = 0"
 35.1851 +    by (simp add: fps_inv_def)
 35.1852 +  have th1: "?iaa $ 0 = 0"
 35.1853 +    using a0 a1 by (simp add: fps_inv_def fps_compose_nth)
 35.1854 +  have th2: "X$0 = 0"
 35.1855 +    by simp
 35.1856 +  from fps_inv[OF a0 a1] have "a oo (fps_inv a oo a) = a oo X"
 35.1857 +    by simp
 35.1858    then have "(a oo fps_inv a) oo a = X oo a"
 35.1859      by (simp add: fps_compose_assoc[OF a0 th0] X_fps_compose_startby0[OF a0])
 35.1860 -  with fps_compose_inj_right[OF a0 a1]
 35.1861 -  show ?thesis by simp
 35.1862 +  with fps_compose_inj_right[OF a0 a1] show ?thesis
 35.1863 +    by simp
 35.1864  qed
 35.1865  
 35.1866  lemma fps_inv_deriv:
 35.1867 -  assumes a0:"a$0 = (0::'a::field)"
 35.1868 +  assumes a0: "a$0 = (0::'a::field)"
 35.1869      and a1: "a$1 \<noteq> 0"
 35.1870    shows "fps_deriv (fps_inv a) = inverse (fps_deriv a oo fps_inv a)"
 35.1871  proof -
 35.1872    let ?ia = "fps_inv a"
 35.1873    let ?d = "fps_deriv a oo ?ia"
 35.1874    let ?dia = "fps_deriv ?ia"
 35.1875 -  have ia0: "?ia$0 = 0" by (simp add: fps_inv_def)
 35.1876 -  have th0: "?d$0 \<noteq> 0" using a1 by (simp add: fps_compose_nth)
 35.1877 +  have ia0: "?ia$0 = 0"
 35.1878 +    by (simp add: fps_inv_def)
 35.1879 +  have th0: "?d$0 \<noteq> 0"
 35.1880 +    using a1 by (simp add: fps_compose_nth)
 35.1881    from fps_inv_right[OF a0 a1] have "?d * ?dia = 1"
 35.1882      by (simp add: fps_compose_deriv[OF ia0, of a, symmetric] )
 35.1883 -  then have "inverse ?d * ?d * ?dia = inverse ?d * 1" by simp
 35.1884 -  with inverse_mult_eq_1 [OF th0]
 35.1885 -  show "?dia = inverse ?d" by simp
 35.1886 +  then have "inverse ?d * ?d * ?dia = inverse ?d * 1"
 35.1887 +    by simp
 35.1888 +  with inverse_mult_eq_1 [OF th0] show "?dia = inverse ?d"
 35.1889 +    by simp
 35.1890  qed
 35.1891  
 35.1892  lemma fps_inv_idempotent:
 35.1893 @@ -2789,15 +2745,20 @@
 35.1894    shows "fps_inv (fps_inv a) = a"
 35.1895  proof -
 35.1896    let ?r = "fps_inv"
 35.1897 -  have ra0: "?r a $ 0 = 0" by (simp add: fps_inv_def)
 35.1898 -  from a1 have ra1: "?r a $ 1 \<noteq> 0" by (simp add: fps_inv_def field_simps)
 35.1899 -  have X0: "X$0 = 0" by simp
 35.1900 +  have ra0: "?r a $ 0 = 0"
 35.1901 +    by (simp add: fps_inv_def)
 35.1902 +  from a1 have ra1: "?r a $ 1 \<noteq> 0"
 35.1903 +    by (simp add: fps_inv_def field_simps)
 35.1904 +  have X0: "X$0 = 0"
 35.1905 +    by simp
 35.1906    from fps_inv[OF ra0 ra1] have "?r (?r a) oo ?r a = X" .
 35.1907 -  then have "?r (?r a) oo ?r a oo a = X oo a" by simp
 35.1908 +  then have "?r (?r a) oo ?r a oo a = X oo a"
 35.1909 +    by simp
 35.1910    then have "?r (?r a) oo (?r a oo a) = a"
 35.1911      unfolding X_fps_compose_startby0[OF a0]
 35.1912      unfolding fps_compose_assoc[OF a0 ra0, symmetric] .
 35.1913 -  then show ?thesis unfolding fps_inv[OF a0 a1] by simp
 35.1914 +  then show ?thesis
 35.1915 +    unfolding fps_inv[OF a0 a1] by simp
 35.1916  qed
 35.1917  
 35.1918  lemma fps_ginv_ginv:
 35.1919 @@ -2808,11 +2769,14 @@
 35.1920    shows "fps_ginv b (fps_ginv c a) = b oo a oo fps_inv c"
 35.1921  proof -
 35.1922    let ?r = "fps_ginv"
 35.1923 -  from c0 have rca0: "?r c a $0 = 0" by (simp add: fps_ginv_def)
 35.1924 -  from a1 c1 have rca1: "?r c a $ 1 \<noteq> 0" by (simp add: fps_ginv_def field_simps)
 35.1925 +  from c0 have rca0: "?r c a $0 = 0"
 35.1926 +    by (simp add: fps_ginv_def)
 35.1927 +  from a1 c1 have rca1: "?r c a $ 1 \<noteq> 0"
 35.1928 +    by (simp add: fps_ginv_def field_simps)
 35.1929    from fps_ginv[OF rca0 rca1]
 35.1930    have "?r b (?r c a) oo ?r c a = b" .
 35.1931 -  then have "?r b (?r c a) oo ?r c a oo a = b oo a" by simp
 35.1932 +  then have "?r b (?r c a) oo ?r c a oo a = b oo a"
 35.1933 +    by simp
 35.1934    then have "?r b (?r c a) oo (?r c a oo a) = b oo a"
 35.1935      apply (subst fps_compose_assoc)
 35.1936      using a0 c0
 35.1937 @@ -2820,13 +2784,15 @@
 35.1938      done
 35.1939    then have "?r b (?r c a) oo c = b oo a"
 35.1940      unfolding fps_ginv[OF a0 a1] .
 35.1941 -  then have "?r b (?r c a) oo c oo fps_inv c= b oo a oo fps_inv c" by simp
 35.1942 +  then have "?r b (?r c a) oo c oo fps_inv c= b oo a oo fps_inv c"
 35.1943 +    by simp
 35.1944    then have "?r b (?r c a) oo (c oo fps_inv c) = b oo a oo fps_inv c"
 35.1945      apply (subst fps_compose_assoc)
 35.1946      using a0 c0
 35.1947      apply (auto simp add: fps_inv_def)
 35.1948      done
 35.1949 -  then show ?thesis unfolding fps_inv_right[OF c0 c1] by simp
 35.1950 +  then show ?thesis
 35.1951 +    unfolding fps_inv_right[OF c0 c1] by simp
 35.1952  qed
 35.1953  
 35.1954  lemma fps_ginv_deriv:
 35.1955 @@ -2838,14 +2804,19 @@
 35.1956    let ?iXa = "fps_ginv X a"
 35.1957    let ?d = "fps_deriv"
 35.1958    let ?dia = "?d ?ia"
 35.1959 -  have iXa0: "?iXa $ 0 = 0" by (simp add: fps_ginv_def)
 35.1960 -  have da0: "?d a $ 0 \<noteq> 0" using a1 by simp
 35.1961 -  from fps_ginv[OF a0 a1, of b] have "?d (?ia oo a) = fps_deriv b" by simp
 35.1962 -  then have "(?d ?ia oo a) * ?d a = ?d b" unfolding fps_compose_deriv[OF a0] .
 35.1963 -  then have "(?d ?ia oo a) * ?d a * inverse (?d a) = ?d b * inverse (?d a)" by simp
 35.1964 +  have iXa0: "?iXa $ 0 = 0"
 35.1965 +    by (simp add: fps_ginv_def)
 35.1966 +  have da0: "?d a $ 0 \<noteq> 0"
 35.1967 +    using a1 by simp
 35.1968 +  from fps_ginv[OF a0 a1, of b] have "?d (?ia oo a) = fps_deriv b"
 35.1969 +    by simp
 35.1970 +  then have "(?d ?ia oo a) * ?d a = ?d b"
 35.1971 +    unfolding fps_compose_deriv[OF a0] .
 35.1972 +  then have "(?d ?ia oo a) * ?d a * inverse (?d a) = ?d b * inverse (?d a)"
 35.1973 +    by simp
 35.1974    then have "(?d ?ia oo a) * (inverse (?d a) * ?d a) = ?d b / ?d a"
 35.1975      by (simp add: fps_divide_def)
 35.1976 -  then have "(?d ?ia oo a) oo ?iXa =  (?d b / ?d a) oo ?iXa "
 35.1977 +  then have "(?d ?ia oo a) oo ?iXa =  (?d b / ?d a) oo ?iXa"
 35.1978      unfolding inverse_mult_eq_1[OF da0] by simp
 35.1979    then have "?d ?ia oo (a oo ?iXa) =  (?d b / ?d a) oo ?iXa"
 35.1980      unfolding fps_compose_assoc[OF iXa0 a0] .
 35.1981 @@ -2853,57 +2824,58 @@
 35.1982      unfolding fps_inv_right[OF a0 a1] by simp
 35.1983  qed
 35.1984  
 35.1985 -subsection{* Elementary series *}
 35.1986 -
 35.1987 -subsubsection{* Exponential series *}
 35.1988 +
 35.1989 +subsection \<open>Elementary series\<close>
 35.1990 +
 35.1991 +subsubsection \<open>Exponential series\<close>
 35.1992  
 35.1993  definition "E x = Abs_fps (\<lambda>n. x^n / of_nat (fact n))"
 35.1994  
 35.1995  lemma E_deriv[simp]: "fps_deriv (E a) = fps_const (a::'a::field_char_0) * E a" (is "?l = ?r")
 35.1996  proof -
 35.1997 -  {
 35.1998 -    fix n
 35.1999 -    have "?l$n = ?r $ n"
 35.2000 -      apply (auto simp add: E_def field_simps power_Suc[symmetric]
 35.2001 -        simp del: fact.simps of_nat_Suc power_Suc)
 35.2002 -      apply (simp add: of_nat_mult field_simps)
 35.2003 -      done
 35.2004 -  }
 35.2005 -  then show ?thesis by (simp add: fps_eq_iff)
 35.2006 +  have "?l$n = ?r $ n" for n
 35.2007 +    apply (auto simp add: E_def field_simps power_Suc[symmetric]
 35.2008 +      simp del: fact.simps of_nat_Suc power_Suc)
 35.2009 +    apply (simp add: of_nat_mult field_simps)
 35.2010 +    done
 35.2011 +  then show ?thesis
 35.2012 +    by (simp add: fps_eq_iff)
 35.2013  qed
 35.2014  
 35.2015  lemma E_unique_ODE:
 35.2016    "fps_deriv a = fps_const c * a \<longleftrightarrow> a = fps_const (a$0) * E (c::'a::field_char_0)"
 35.2017    (is "?lhs \<longleftrightarrow> ?rhs")
 35.2018  proof
 35.2019 -  assume d: ?lhs
 35.2020 -  from d have th: "\<And>n. a $ Suc n = c * a$n / of_nat (Suc n)"
 35.2021 -    by (simp add: fps_deriv_def fps_eq_iff field_simps del: of_nat_Suc)
 35.2022 -  {
 35.2023 -    fix n
 35.2024 -    have "a$n = a$0 * c ^ n/ (fact n)"
 35.2025 -      apply (induct n)
 35.2026 -      apply simp
 35.2027 -      unfolding th
 35.2028 -      using fact_gt_zero
 35.2029 -      apply (simp add: field_simps del: of_nat_Suc fact_Suc)
 35.2030 -      apply simp
 35.2031 -      done
 35.2032 -  }
 35.2033 -  note th' = this
 35.2034 -  show ?rhs by (auto simp add: fps_eq_iff fps_const_mult_left E_def intro: th')
 35.2035 -next
 35.2036 -  assume h: ?rhs
 35.2037 -  show ?lhs
 35.2038 -    by (metis E_deriv fps_deriv_mult_const_left h mult.left_commute)
 35.2039 +  show ?rhs if ?lhs
 35.2040 +  proof -
 35.2041 +    from that have th: "\<And>n. a $ Suc n = c * a$n / of_nat (Suc n)"
 35.2042 +      by (simp add: fps_deriv_def fps_eq_iff field_simps del: of_nat_Suc)
 35.2043 +    have th': "a$n = a$0 * c ^ n/ (fact n)" for n
 35.2044 +    proof (induct n)
 35.2045 +      case 0
 35.2046 +      then show ?case by simp
 35.2047 +    next
 35.2048 +      case Suc
 35.2049 +      then show ?case
 35.2050 +        unfolding th
 35.2051 +        using fact_gt_zero
 35.2052 +        apply (simp add: field_simps del: of_nat_Suc fact_Suc)
 35.2053 +        apply simp
 35.2054 +        done
 35.2055 +    qed
 35.2056 +    show ?thesis
 35.2057 +      by (auto simp add: fps_eq_iff fps_const_mult_left E_def intro: th')
 35.2058 +  qed
 35.2059 +  show ?lhs if ?rhs
 35.2060 +    using that by (metis E_deriv fps_deriv_mult_const_left mult.left_commute)
 35.2061  qed
 35.2062  
 35.2063  lemma E_add_mult: "E (a + b) = E (a::'a::field_char_0) * E b" (is "?l = ?r")
 35.2064  proof -
 35.2065 -  have "fps_deriv (?r) = fps_const (a+b) * ?r"
 35.2066 +  have "fps_deriv ?r = fps_const (a + b) * ?r"
 35.2067      by (simp add: fps_const_add[symmetric] field_simps del: fps_const_add)
 35.2068 -  then have "?r = ?l" apply (simp only: E_unique_ODE)
 35.2069 -    by (simp add: fps_mult_nth E_def)
 35.2070 +  then have "?r = ?l"
 35.2071 +    by (simp only: E_unique_ODE) (simp add: fps_mult_nth E_def)
 35.2072    then show ?thesis ..
 35.2073  qed
 35.2074  
 35.2075 @@ -2928,19 +2900,20 @@
 35.2076    by (simp add: fps_eq_iff X_fps_compose)
 35.2077  
 35.2078  lemma LE_compose:
 35.2079 -  assumes a: "a\<noteq>0"
 35.2080 +  assumes a: "a \<noteq> 0"
 35.2081    shows "fps_inv (E a - 1) oo (E a - 1) = X"
 35.2082      and "(E a - 1) oo fps_inv (E a - 1) = X"
 35.2083  proof -
 35.2084    let ?b = "E a - 1"
 35.2085 -  have b0: "?b $ 0 = 0" by simp
 35.2086 -  have b1: "?b $ 1 \<noteq> 0" by (simp add: a)
 35.2087 +  have b0: "?b $ 0 = 0"
 35.2088 +    by simp
 35.2089 +  have b1: "?b $ 1 \<noteq> 0"
 35.2090 +    by (simp add: a)
 35.2091    from fps_inv[OF b0 b1] show "fps_inv (E a - 1) oo (E a - 1) = X" .
 35.2092    from fps_inv_right[OF b0 b1] show "(E a - 1) oo fps_inv (E a - 1) = X" .
 35.2093  qed
 35.2094  
 35.2095 -lemma fps_const_inverse:
 35.2096 -  "a \<noteq> 0 \<Longrightarrow> inverse (fps_const (a::'a::field)) = fps_const (inverse a)"
 35.2097 +lemma fps_const_inverse: "a \<noteq> 0 \<Longrightarrow> inverse (fps_const (a::'a::field)) = fps_const (inverse a)"
 35.2098    apply (auto simp add: fps_eq_iff fps_inverse_def)
 35.2099    apply (case_tac n)
 35.2100    apply auto
 35.2101 @@ -2960,8 +2933,8 @@
 35.2102    have th0: "E ?ck ^ (Suc k) = E c" unfolding E_power_mult eq0 ..
 35.2103    have th: "r (Suc k) (E c $0) ^ Suc k = E c $ 0"
 35.2104      "r (Suc k) (E c $ 0) = E ?ck $ 0" "E c $ 0 \<noteq> 0" using r by simp_all
 35.2105 -  from th0 radical_unique[where r=r and k=k, OF th]
 35.2106 -  show ?thesis by auto
 35.2107 +  from th0 radical_unique[where r=r and k=k, OF th] show ?thesis
 35.2108 +    by auto
 35.2109  qed
 35.2110  
 35.2111  lemma Ec_E1_eq: "E (1::'a::field_char_0) oo (fps_const c * X) = E c"
 35.2112 @@ -2970,10 +2943,11 @@
 35.2113    done
 35.2114  
 35.2115  
 35.2116 -subsubsection{* Logarithmic series *}
 35.2117 +subsubsection \<open>Logarithmic series\<close>
 35.2118  
 35.2119  lemma Abs_fps_if_0:
 35.2120 -  "Abs_fps(\<lambda>n. if n=0 then (v::'a::ring_1) else f n) = fps_const v + X * Abs_fps (\<lambda>n. f (Suc n))"
 35.2121 +  "Abs_fps (\<lambda>n. if n = 0 then (v::'a::ring_1) else f n) =
 35.2122 +    fps_const v + X * Abs_fps (\<lambda>n. f (Suc n))"
 35.2123    by (auto simp add: fps_eq_iff)
 35.2124  
 35.2125  definition L :: "'a::field_char_0 \<Rightarrow> 'a fps"
 35.2126 @@ -2983,7 +2957,7 @@
 35.2127    unfolding fps_inverse_X_plus1
 35.2128    by (simp add: L_def fps_eq_iff del: of_nat_Suc)
 35.2129  
 35.2130 -lemma L_nth: "L c $ n = (if n=0 then 0 else 1/c * ((- 1) ^ (n - 1) / of_nat n))"
 35.2131 +lemma L_nth: "L c $ n = (if n = 0 then 0 else 1/c * ((- 1) ^ (n - 1) / of_nat n))"
 35.2132    by (simp add: L_def field_simps)
 35.2133  
 35.2134  lemma L_0[simp]: "L c $ 0 = 0" by (simp add: L_def)
 35.2135 @@ -3032,7 +3006,7 @@
 35.2136  qed
 35.2137  
 35.2138  
 35.2139 -subsubsection{* Binomial series *}
 35.2140 +subsubsection \<open>Binomial series\<close>
 35.2141  
 35.2142  definition "fps_binomial a = Abs_fps (\<lambda>n. a gchoose n)"
 35.2143  
 35.2144 @@ -3043,65 +3017,68 @@
 35.2145    fixes c :: "'a::field_char_0"
 35.2146    shows "fps_deriv a = (fps_const c * a) / (1 + X) \<longleftrightarrow> a = fps_const (a$0) * fps_binomial c"
 35.2147    (is "?lhs \<longleftrightarrow> ?rhs")
 35.2148 -proof -
 35.2149 +proof
 35.2150    let ?da = "fps_deriv a"
 35.2151    let ?x1 = "(1 + X):: 'a fps"
 35.2152    let ?l = "?x1 * ?da"
 35.2153    let ?r = "fps_const c * a"
 35.2154 -  have x10: "?x1 $ 0 \<noteq> 0" by simp
 35.2155 -  have "?l = ?r \<longleftrightarrow> inverse ?x1 * ?l = inverse ?x1 * ?r" by simp
 35.2156 -  also have "\<dots> \<longleftrightarrow> ?da = (fps_const c * a) / ?x1"
 35.2157 -    apply (simp only: fps_divide_def  mult.assoc[symmetric] inverse_mult_eq_1[OF x10])
 35.2158 -    apply (simp add: field_simps)
 35.2159 -    done
 35.2160 -  finally have eq: "?l = ?r \<longleftrightarrow> ?lhs" by simp
 35.2161 -  moreover
 35.2162 -  {assume h: "?l = ?r"
 35.2163 -    {fix n
 35.2164 -      from h have lrn: "?l $ n = ?r$n" by simp
 35.2165 -
 35.2166 -      from lrn
 35.2167 -      have "a$ Suc n = ((c - of_nat n) / of_nat (Suc n)) * a $n"
 35.2168 +
 35.2169 +  have eq: "?l = ?r \<longleftrightarrow> ?lhs"
 35.2170 +  proof -
 35.2171 +    have x10: "?x1 $ 0 \<noteq> 0" by simp
 35.2172 +    have "?l = ?r \<longleftrightarrow> inverse ?x1 * ?l = inverse ?x1 * ?r" by simp
 35.2173 +    also have "\<dots> \<longleftrightarrow> ?da = (fps_const c * a) / ?x1"
 35.2174 +      apply (simp only: fps_divide_def  mult.assoc[symmetric] inverse_mult_eq_1[OF x10])
 35.2175 +      apply (simp add: field_simps)
 35.2176 +      done
 35.2177 +    finally show ?thesis .
 35.2178 +  qed
 35.2179 +
 35.2180 +  show ?rhs if ?lhs
 35.2181 +  proof -
 35.2182 +    from eq that have h: "?l = ?r" ..
 35.2183 +    have th0: "a$ Suc n = ((c - of_nat n) / of_nat (Suc n)) * a $n" for n
 35.2184 +    proof -
 35.2185 +      from h have "?l $ n = ?r $ n" by simp
 35.2186 +      then show ?thesis
 35.2187          apply (simp add: field_simps del: of_nat_Suc)
 35.2188 -        by (cases n, simp_all add: field_simps del: of_nat_Suc)
 35.2189 -    }
 35.2190 -    note th0 = this
 35.2191 -    {
 35.2192 -      fix n
 35.2193 -      have "a$n = (c gchoose n) * a$0"
 35.2194 -      proof (induct n)
 35.2195 -        case 0
 35.2196 -        then show ?case by simp
 35.2197 -      next
 35.2198 -        case (Suc m)
 35.2199 -        then show ?case unfolding th0
 35.2200 -          apply (simp add: field_simps del: of_nat_Suc)
 35.2201 -          unfolding mult.assoc[symmetric] gbinomial_mult_1
 35.2202 -          apply (simp add: field_simps)
 35.2203 -          done
 35.2204 -      qed
 35.2205 -    }
 35.2206 -    note th1 = this
 35.2207 -    have ?rhs
 35.2208 +        apply (cases n)
 35.2209 +        apply (simp_all add: field_simps del: of_nat_Suc)
 35.2210 +        done
 35.2211 +    qed
 35.2212 +    have th1: "a $ n = (c gchoose n) * a $ 0" for n
 35.2213 +    proof (induct n)
 35.2214 +      case 0
 35.2215 +      then show ?case by simp
 35.2216 +    next
 35.2217 +      case (Suc m)
 35.2218 +      then show ?case
 35.2219 +        unfolding th0
 35.2220 +        apply (simp add: field_simps del: of_nat_Suc)
 35.2221 +        unfolding mult.assoc[symmetric] gbinomial_mult_1
 35.2222 +        apply (simp add: field_simps)
 35.2223 +        done
 35.2224 +    qed
 35.2225 +    show ?thesis
 35.2226        apply (simp add: fps_eq_iff)
 35.2227        apply (subst th1)
 35.2228        apply (simp add: field_simps)
 35.2229        done
 35.2230 -  }
 35.2231 -  moreover
 35.2232 -  {
 35.2233 -    assume h: ?rhs
 35.2234 -    have th00: "\<And>x y. x * (a$0 * y) = a$0 * (x*y)"
 35.2235 +  qed
 35.2236 +
 35.2237 +  show ?lhs if ?rhs
 35.2238 +  proof -
 35.2239 +    have th00: "x * (a $ 0 * y) = a $ 0 * (x * y)" for x y
 35.2240        by (simp add: mult.commute)
 35.2241      have "?l = ?r"
 35.2242 -      apply (subst h)
 35.2243 -      apply (subst (2) h)
 35.2244 +      apply (subst \<open>?rhs\<close>)
 35.2245 +      apply (subst (2) \<open>?rhs\<close>)
 35.2246        apply (clarsimp simp add: fps_eq_iff field_simps)
 35.2247        unfolding mult.assoc[symmetric] th00 gbinomial_mult_1
 35.2248        apply (simp add: field_simps gbinomial_mult_1)
 35.2249        done
 35.2250 -  }
 35.2251 -  ultimately show ?thesis by blast
 35.2252 +    with eq show ?thesis ..
 35.2253 +  qed
 35.2254  qed
 35.2255  
 35.2256  lemma fps_binomial_deriv: "fps_deriv (fps_binomial c) = fps_const c * fps_binomial c / (1 + X)"
 35.2257 @@ -3145,7 +3122,7 @@
 35.2258    show ?thesis by (simp add: fps_inverse_def)
 35.2259  qed
 35.2260  
 35.2261 -text{* Vandermonde's Identity as a consequence *}
 35.2262 +text \<open>Vandermonde's Identity as a consequence\<close>
 35.2263  lemma gbinomial_Vandermonde:
 35.2264    "setsum (\<lambda>k. (a gchoose k) * (b gchoose (n - k))) {0..n} = (a + b) gchoose n"
 35.2265  proof -
 35.2266 @@ -3164,8 +3141,8 @@
 35.2267    apply simp
 35.2268    done
 35.2269  
 35.2270 -lemma binomial_Vandermonde_same: "setsum (\<lambda>k. (n choose k)\<^sup>2) {0..n} = (2*n) choose n"
 35.2271 -  using binomial_Vandermonde[of n n n,symmetric]
 35.2272 +lemma binomial_Vandermonde_same: "setsum (\<lambda>k. (n choose k)\<^sup>2) {0..n} = (2 * n) choose n"
 35.2273 +  using binomial_Vandermonde[of n n n, symmetric]
 35.2274    unfolding mult_2
 35.2275    apply (simp add: power2_eq_square)
 35.2276    apply (rule setsum.cong)
 35.2277 @@ -3183,22 +3160,24 @@
 35.2278    let ?m1 = "\<lambda>m. (- 1 :: 'a) ^ m"
 35.2279    let ?f = "\<lambda>m. of_nat (fact m)"
 35.2280    let ?p = "\<lambda>(x::'a). pochhammer (- x)"
 35.2281 -  from b have bn0: "?p b n \<noteq> 0" unfolding pochhammer_eq_0_iff by simp
 35.2282 +  from b have bn0: "?p b n \<noteq> 0"
 35.2283 +    unfolding pochhammer_eq_0_iff by simp
 35.2284    {
 35.2285      fix k
 35.2286      assume kn: "k \<in> {0..n}"
 35.2287 -    {
 35.2288 -      assume c:"pochhammer (b - of_nat n + 1) n = 0"
 35.2289 +    have nz: "pochhammer (1 + b - of_nat n) n \<noteq> 0"
 35.2290 +    proof
 35.2291 +      assume "pochhammer (1 + b - of_nat n) n = 0"
 35.2292 +      then have c: "pochhammer (b - of_nat n + 1) n = 0"
 35.2293 +        by (simp add: algebra_simps)
 35.2294        then obtain j where j: "j < n" "b - of_nat n + 1 = - of_nat j"
 35.2295          unfolding pochhammer_eq_0_iff by blast
 35.2296        from j have "b = of_nat n - of_nat j - of_nat 1"
 35.2297          by (simp add: algebra_simps)
 35.2298        then have "b = of_nat (n - j - 1)"
 35.2299          using j kn by (simp add: of_nat_diff)
 35.2300 -      with b have False using j by auto
 35.2301 -    }
 35.2302 -    then have nz: "pochhammer (1 + b - of_nat n) n \<noteq> 0"
 35.2303 -      by (auto simp add: algebra_simps)
 35.2304 +      with b show False using j by auto
 35.2305 +    qed
 35.2306  
 35.2307      from nz kn [simplified] have nz': "pochhammer (1 + b - of_nat n) k \<noteq> 0"
 35.2308        by (rule pochhammer_neq_0_mono)
 35.2309 @@ -3212,24 +3191,26 @@
 35.2310      moreover
 35.2311      {
 35.2312        assume n0: "n \<noteq> 0" and k0: "k \<noteq> 0"
 35.2313 -      then obtain m where m: "n = Suc m" by (cases n) auto
 35.2314 -      from k0 obtain h where h: "k = Suc h" by (cases k) auto
 35.2315 -      {
 35.2316 -        assume "k = n"
 35.2317 -        then have "b gchoose (n - k) =
 35.2318 -          (?m1 n * ?p b n * ?m1 k * ?p (of_nat n) k) / (?f n * pochhammer (b - of_nat n + 1) k)"
 35.2319 +      then obtain m where m: "n = Suc m"
 35.2320 +        by (cases n) auto
 35.2321 +      from k0 obtain h where h: "k = Suc h"
 35.2322 +        by (cases k) auto
 35.2323 +      have "b gchoose (n - k) =
 35.2324 +        (?m1 n * ?p b n * ?m1 k * ?p (of_nat n) k) / (?f n * pochhammer (b - of_nat n + 1) k)"
 35.2325 +      proof (cases "k = n")
 35.2326 +        case True
 35.2327 +        then show ?thesis
 35.2328            using pochhammer_minus'[where k=k and b=b]
 35.2329            apply (simp add: pochhammer_same)
 35.2330            using bn0
 35.2331            apply (simp add: field_simps power_add[symmetric])
 35.2332            done
 35.2333 -      }
 35.2334 -      moreover
 35.2335 -      {
 35.2336 -        assume nk: "k \<noteq> n"
 35.2337 +      next
 35.2338 +        case False
 35.2339 +        with kn have kn': "k < n"
 35.2340 +          by simp
 35.2341          have m1nk: "?m1 n = setprod (\<lambda>i. - 1) {0..m}" "?m1 k = setprod (\<lambda>i. - 1) {0..h}"
 35.2342            by (simp_all add: setprod_constant m h)
 35.2343 -        from kn nk have kn': "k < n" by simp
 35.2344          have bnz0: "pochhammer (b - of_nat n + 1) k \<noteq> 0"
 35.2345            using bn0 kn
 35.2346            unfolding pochhammer_eq_0_iff
 35.2347 @@ -3291,14 +3272,8 @@
 35.2348          also have "\<dots> = b gchoose (n - k)"
 35.2349            unfolding th1 th2
 35.2350            using kn' by (simp add: gbinomial_def)
 35.2351 -        finally have "b gchoose (n - k) =
 35.2352 -          (?m1 n * ?p b n * ?m1 k * ?p (of_nat n) k) / (?f n * pochhammer (b - of_nat n + 1) k)"
 35.2353 -          by simp
 35.2354 -      }
 35.2355 -      ultimately
 35.2356 -      have "b gchoose (n - k) =
 35.2357 -        (?m1 n * ?p b n * ?m1 k * ?p (of_nat n) k) / (?f n * pochhammer (b - of_nat n + 1) k)"
 35.2358 -        by (cases "k = n") auto
 35.2359 +        finally show ?thesis by simp
 35.2360 +      qed
 35.2361      }
 35.2362      ultimately have "b gchoose (n - k) =
 35.2363          (?m1 n * ?p b n * ?m1 k * ?p (of_nat n) k) / (?f n * pochhammer (b - of_nat n + 1) k)"
 35.2364 @@ -3338,7 +3313,7 @@
 35.2365    let ?b = "c + of_nat n - 1"
 35.2366    have h: "\<forall> j \<in>{0..< n}. ?b \<noteq> of_nat j" using c
 35.2367      apply (auto simp add: algebra_simps of_nat_diff)
 35.2368 -    apply (erule_tac x= "n - j - 1" in ballE)
 35.2369 +    apply (erule_tac x = "n - j - 1" in ballE)
 35.2370      apply (auto simp add: of_nat_diff algebra_simps)
 35.2371      done
 35.2372    have th0: "pochhammer (- (?a + ?b)) n = (- 1)^n * pochhammer (c - a) n"
 35.2373 @@ -3350,11 +3325,12 @@
 35.2374    have nz: "pochhammer c n \<noteq> 0" using c
 35.2375      by (simp add: pochhammer_eq_0_iff)
 35.2376    from Vandermonde_pochhammer_lemma[where a = "?a" and b="?b" and n=n, OF h, unfolded th0 th1]
 35.2377 -  show ?thesis using nz by (simp add: field_simps setsum_right_distrib)
 35.2378 +  show ?thesis
 35.2379 +    using nz by (simp add: field_simps setsum_right_distrib)
 35.2380  qed
 35.2381  
 35.2382  
 35.2383 -subsubsection{* Formal trigonometric functions  *}
 35.2384 +subsubsection \<open>Formal trigonometric functions\<close>
 35.2385  
 35.2386  definition "fps_sin (c::'a::field_char_0) =
 35.2387    Abs_fps (\<lambda>n. if even n then 0 else (- 1) ^((n - 1) div 2) * c^n /(of_nat (fact n)))"
 35.2388 @@ -3367,52 +3343,58 @@
 35.2389    (is "?lhs = ?rhs")
 35.2390  proof (rule fps_ext)
 35.2391    fix n :: nat
 35.2392 -  {
 35.2393 -    assume en: "even n"
 35.2394 +  show "?lhs $ n = ?rhs $ n"
 35.2395 +  proof (cases "even n")
 35.2396 +    case True
 35.2397      have "?lhs$n = of_nat (n+1) * (fps_sin c $ (n+1))" by simp
 35.2398      also have "\<dots> = of_nat (n+1) * ((- 1)^(n div 2) * c^Suc n / of_nat (fact (Suc n)))"
 35.2399 -      using en by (simp add: fps_sin_def)
 35.2400 +      using True by (simp add: fps_sin_def)
 35.2401      also have "\<dots> = (- 1)^(n div 2) * c^Suc n * (of_nat (n+1) / (of_nat (Suc n) * of_nat (fact n)))"
 35.2402        unfolding fact_Suc of_nat_mult
 35.2403        by (simp add: field_simps del: of_nat_add of_nat_Suc)
 35.2404      also have "\<dots> = (- 1)^(n div 2) *c^Suc n / of_nat (fact n)"
 35.2405        by (simp add: field_simps del: of_nat_add of_nat_Suc)
 35.2406 -    finally have "?lhs $n = ?rhs$n" using en
 35.2407 -      by (simp add: fps_cos_def field_simps)
 35.2408 -  }
 35.2409 -  then show "?lhs $ n = ?rhs $ n"
 35.2410 -    by (cases "even n") (simp_all add: fps_deriv_def fps_sin_def fps_cos_def)
 35.2411 +    finally show ?thesis
 35.2412 +      using True by (simp add: fps_cos_def field_simps)
 35.2413 +  next
 35.2414 +    case False
 35.2415 +    then show ?thesis
 35.2416 +      by (simp_all add: fps_deriv_def fps_sin_def fps_cos_def)
 35.2417 +  qed
 35.2418  qed
 35.2419  
 35.2420  lemma fps_cos_deriv: "fps_deriv (fps_cos c) = fps_const (- c)* (fps_sin c)"
 35.2421    (is "?lhs = ?rhs")
 35.2422  proof (rule fps_ext)
 35.2423 -  have th0: "\<And>n. - ((- 1::'a) ^ n) = (- 1)^Suc n" by simp
 35.2424 -  have th1: "\<And>n. odd n \<Longrightarrow> Suc ((n - 1) div 2) = Suc n div 2"
 35.2425 -    by (case_tac n, simp_all)
 35.2426 -  fix n::nat
 35.2427 -  {
 35.2428 -    assume en: "odd n"
 35.2429 -    from en have n0: "n \<noteq>0 " by presburger
 35.2430 +  have th0: "- ((- 1::'a) ^ n) = (- 1)^Suc n" for n
 35.2431 +    by simp
 35.2432 +  show "?lhs $ n = ?rhs $ n" for n
 35.2433 +  proof (cases "even n")
 35.2434 +    case False
 35.2435 +    then have n0: "n \<noteq> 0" by presburger
 35.2436 +    from False have th1: "Suc ((n - 1) div 2) = Suc n div 2"
 35.2437 +      by (cases n) simp_all
 35.2438      have "?lhs$n = of_nat (n+1) * (fps_cos c $ (n+1))" by simp
 35.2439      also have "\<dots> = of_nat (n+1) * ((- 1)^((n + 1) div 2) * c^Suc n / of_nat (fact (Suc n)))"
 35.2440 -      using en by (simp add: fps_cos_def)
 35.2441 +      using False by (simp add: fps_cos_def)
 35.2442      also have "\<dots> = (- 1)^((n + 1) div 2)*c^Suc n * (of_nat (n+1) / (of_nat (Suc n) * of_nat (fact n)))"
 35.2443        unfolding fact_Suc of_nat_mult
 35.2444        by (simp add: field_simps del: of_nat_add of_nat_Suc)
 35.2445      also have "\<dots> = (- 1)^((n + 1) div 2) * c^Suc n / of_nat (fact n)"
 35.2446        by (simp add: field_simps del: of_nat_add of_nat_Suc)
 35.2447      also have "\<dots> = (- ((- 1)^((n - 1) div 2))) * c^Suc n / of_nat (fact n)"
 35.2448 -      unfolding th0 unfolding th1[OF en] by simp
 35.2449 -    finally have "?lhs $n = ?rhs$n" using en
 35.2450 -      by (simp add: fps_sin_def field_simps)
 35.2451 -  }
 35.2452 -  then show "?lhs $ n = ?rhs $ n"
 35.2453 -    by (cases "even n") (simp_all add: fps_deriv_def fps_sin_def fps_cos_def)
 35.2454 +      unfolding th0 unfolding th1 by simp
 35.2455 +    finally show ?thesis
 35.2456 +      using False by (simp add: fps_sin_def field_simps)
 35.2457 +  next
 35.2458 +    case True
 35.2459 +    then show ?thesis
 35.2460 +      by (simp_all add: fps_deriv_def fps_sin_def fps_cos_def)
 35.2461 +  qed
 35.2462  qed
 35.2463  
 35.2464 -lemma fps_sin_cos_sum_of_squares:
 35.2465 -  "(fps_cos c)\<^sup>2 + (fps_sin c)\<^sup>2 = 1" (is "?lhs = 1")
 35.2466 +lemma fps_sin_cos_sum_of_squares: "(fps_cos c)\<^sup>2 + (fps_sin c)\<^sup>2 = 1"
 35.2467 +  (is "?lhs = _")
 35.2468  proof -
 35.2469    have "fps_deriv ?lhs = 0"
 35.2470      apply (simp add:  fps_deriv_power fps_sin_deriv fps_cos_deriv)
 35.2471 @@ -3432,9 +3414,10 @@
 35.2472    unfolding fps_sin_def by simp
 35.2473  
 35.2474  lemma fps_sin_nth_add_2:
 35.2475 -  "fps_sin c $ (n + 2) = - (c * c * fps_sin c $ n / (of_nat(n+1) * of_nat(n+2)))"
 35.2476 +    "fps_sin c $ (n + 2) = - (c * c * fps_sin c $ n / (of_nat (n + 1) * of_nat (n + 2)))"
 35.2477    unfolding fps_sin_def
 35.2478 -  apply (cases n, simp)
 35.2479 +  apply (cases n)
 35.2480 +  apply simp
 35.2481    apply (simp add: nonzero_divide_eq_eq nonzero_eq_divide_eq del: of_nat_Suc fact_Suc)
 35.2482    apply (simp add: of_nat_mult del: of_nat_Suc mult_Suc)
 35.2483    done
 35.2484 @@ -3446,7 +3429,7 @@
 35.2485    unfolding fps_cos_def by simp
 35.2486  
 35.2487  lemma fps_cos_nth_add_2:
 35.2488 -  "fps_cos c $ (n + 2) = - (c * c * fps_cos c $ n / (of_nat(n+1) * of_nat(n+2)))"
 35.2489 +  "fps_cos c $ (n + 2) = - (c * c * fps_cos c $ n / (of_nat (n + 1) * of_nat (n + 2)))"
 35.2490    unfolding fps_cos_def
 35.2491    apply (simp add: nonzero_divide_eq_eq nonzero_eq_divide_eq del: of_nat_Suc fact_Suc)
 35.2492    apply (simp add: of_nat_mult del: of_nat_Suc mult_Suc)
 35.2493 @@ -3544,28 +3527,26 @@
 35.2494      done
 35.2495  qed
 35.2496  
 35.2497 -text {* Connection to E c over the complex numbers --- Euler and De Moivre*}
 35.2498 -lemma Eii_sin_cos: "E (ii * c) = fps_cos c + fps_const ii * fps_sin c "
 35.2499 +text \<open>Connection to E c over the complex numbers --- Euler and De Moivre\<close>
 35.2500 +
 35.2501 +lemma Eii_sin_cos: "E (ii * c) = fps_cos c + fps_const ii * fps_sin c"
 35.2502    (is "?l = ?r")
 35.2503  proof -
 35.2504 -  { fix n :: nat
 35.2505 -    {
 35.2506 -      assume en: "even n"
 35.2507 -      from en obtain m where m: "n = 2 * m" ..
 35.2508 -
 35.2509 -      have "?l $n = ?r$n"
 35.2510 -        by (simp add: m fps_sin_def fps_cos_def power_mult_distrib power_mult power_minus [of "c ^ 2"])
 35.2511 -    }
 35.2512 -    moreover
 35.2513 -    {
 35.2514 -      assume "odd n"
 35.2515 -      then obtain m where m: "n = 2 * m + 1" ..
 35.2516 -      have "?l $n = ?r$n"
 35.2517 -        by (simp add: m fps_sin_def fps_cos_def power_mult_distrib
 35.2518 -          power_mult power_minus [of "c ^ 2"])
 35.2519 -    }
 35.2520 -    ultimately have "?l $n = ?r$n"  by blast
 35.2521 -  } then show ?thesis by (simp add: fps_eq_iff)
 35.2522 +  have "?l $ n = ?r $ n" for n
 35.2523 +  proof (cases "even n")
 35.2524 +    case True
 35.2525 +    then obtain m where m: "n = 2 * m" ..
 35.2526 +    show ?thesis
 35.2527 +      by (simp add: m fps_sin_def fps_cos_def power_mult_distrib power_mult power_minus [of "c ^ 2"])
 35.2528 +  next
 35.2529 +    case False
 35.2530 +    then obtain m where m: "n = 2 * m + 1" ..
 35.2531 +    show ?thesis
 35.2532 +      by (simp add: m fps_sin_def fps_cos_def power_mult_distrib
 35.2533 +        power_mult power_minus [of "c ^ 2"])
 35.2534 +  qed
 35.2535 +  then show ?thesis
 35.2536 +    by (simp add: fps_eq_iff)
 35.2537  qed
 35.2538  
 35.2539  lemma E_minus_ii_sin_cos: "E (- (ii * c)) = fps_cos c - fps_const ii * fps_sin c"
 35.2540 @@ -3582,8 +3563,8 @@
 35.2541    have th: "fps_cos c + fps_cos c = fps_cos c * fps_const 2"
 35.2542      by (simp add: numeral_fps_const)
 35.2543    show ?thesis
 35.2544 -  unfolding Eii_sin_cos minus_mult_commute
 35.2545 -  by (simp add: fps_sin_even fps_cos_odd numeral_fps_const fps_divide_def fps_const_inverse th)
 35.2546 +    unfolding Eii_sin_cos minus_mult_commute
 35.2547 +    by (simp add: fps_sin_even fps_cos_odd numeral_fps_const fps_divide_def fps_const_inverse th)
 35.2548  qed
 35.2549  
 35.2550  lemma fps_sin_Eii: "fps_sin c = (E (ii * c) - E (- ii * c)) / fps_const (2*ii)"
 35.2551 @@ -3602,12 +3583,14 @@
 35.2552    apply simp
 35.2553    done
 35.2554  
 35.2555 -lemma fps_demoivre: "(fps_cos a + fps_const ii * fps_sin a)^n = fps_cos (of_nat n * a) + fps_const ii * fps_sin (of_nat n * a)"
 35.2556 +lemma fps_demoivre:
 35.2557 +  "(fps_cos a + fps_const ii * fps_sin a)^n =
 35.2558 +    fps_cos (of_nat n * a) + fps_const ii * fps_sin (of_nat n * a)"
 35.2559    unfolding Eii_sin_cos[symmetric] E_power_mult
 35.2560    by (simp add: ac_simps)
 35.2561  
 35.2562  
 35.2563 -subsection {* Hypergeometric series *}
 35.2564 +subsection \<open>Hypergeometric series\<close>
 35.2565  
 35.2566  definition "F as bs (c::'a::{field_char_0,field}) =
 35.2567    Abs_fps (\<lambda>n. (foldl (\<lambda>r a. r* pochhammer a n) 1 as * c^n) /
 35.2568 @@ -3648,7 +3631,7 @@
 35.2569  lemma F_B[simp]: "F [-a] [] (- 1) = fps_binomial a"
 35.2570    by (simp add: fps_eq_iff gbinomial_pochhammer algebra_simps)
 35.2571  
 35.2572 -lemma F_0[simp]: "F as bs c $0 = 1"
 35.2573 +lemma F_0[simp]: "F as bs c $ 0 = 1"
 35.2574    apply simp
 35.2575    apply (subgoal_tac "\<forall>as. foldl (\<lambda>(r::'a) (a::'a). r) 1 as = 1")
 35.2576    apply auto
 35.2577 @@ -3674,8 +3657,10 @@
 35.2578  lemma XD_nth[simp]: "XD a $ n = (if n = 0 then 0 else of_nat n * a$n)"
 35.2579    by (simp add: XD_def)
 35.2580  
 35.2581 -lemma XD_0th[simp]: "XD a $ 0 = 0" by simp
 35.2582 -lemma XD_Suc[simp]:" XD a $ Suc n = of_nat (Suc n) * a $ Suc n" by simp
 35.2583 +lemma XD_0th[simp]: "XD a $ 0 = 0"
 35.2584 +  by simp
 35.2585 +lemma XD_Suc[simp]:" XD a $ Suc n = of_nat (Suc n) * a $ Suc n"
 35.2586 +  by simp
 35.2587  
 35.2588  definition "XDp c a = XD a + fps_const c * a"
 35.2589  
 35.2590 @@ -3731,23 +3716,26 @@
 35.2591    with assms have "i < (LEAST n. f $ n \<noteq> g $ n)"
 35.2592      by (simp add: split_if_asm dist_fps_def)
 35.2593    also have "\<dots> \<le> j"
 35.2594 -    using `f $ j \<noteq> g $ j` by (auto intro: Least_le)
 35.2595 -  finally show False using `j \<le> i` by simp
 35.2596 +    using \<open>f $ j \<noteq> g $ j\<close> by (auto intro: Least_le)
 35.2597 +  finally show False using \<open>j \<le> i\<close> by simp
 35.2598  qed
 35.2599  
 35.2600  lemma nth_equal_imp_dist_less:
 35.2601    assumes "\<And>j. j \<le> i \<Longrightarrow> f $ j = g $ j"
 35.2602    shows "dist f g < inverse (2 ^ i)"
 35.2603  proof (cases "f = g")
 35.2604 +  case True
 35.2605 +  then show ?thesis by simp
 35.2606 +next
 35.2607    case False
 35.2608    then have "\<exists>n. f $ n \<noteq> g $ n" by (simp add: fps_eq_iff)
 35.2609    with assms have "dist f g = inverse (2 ^ (LEAST n. f $ n \<noteq> g $ n))"
 35.2610      by (simp add: split_if_asm dist_fps_def)
 35.2611    moreover
 35.2612 -  from assms `\<exists>n. f $ n \<noteq> g $ n` have "i < (LEAST n. f $ n \<noteq> g $ n)"
 35.2613 +  from assms \<open>\<exists>n. f $ n \<noteq> g $ n\<close> have "i < (LEAST n. f $ n \<noteq> g $ n)"
 35.2614      by (metis (mono_tags) LeastI not_less)
 35.2615    ultimately show ?thesis by simp
 35.2616 -qed simp
 35.2617 +qed
 35.2618  
 35.2619  lemma dist_less_eq_nth_equal: "dist f g < inverse (2 ^ i) \<longleftrightarrow> (\<forall>j \<le> i. f $ j = g $ j)"
 35.2620    using dist_less_imp_nth_equal nth_equal_imp_dist_less by blast
 35.2621 @@ -3756,14 +3744,17 @@
 35.2622  proof
 35.2623    fix X :: "nat \<Rightarrow> 'a fps"
 35.2624    assume "Cauchy X"
 35.2625 -  {
 35.2626 -    fix i
 35.2627 -    have "0 < inverse ((2::real)^i)" by simp
 35.2628 -    from metric_CauchyD[OF `Cauchy X` this] dist_less_imp_nth_equal
 35.2629 -    have "\<exists>M. \<forall>m \<ge> M. \<forall>j\<le>i. X M $ j = X m $ j" by blast
 35.2630 -  }
 35.2631 -  then obtain M where M: "\<forall>i. \<forall>m \<ge> M i. \<forall>j \<le> i. X (M i) $ j = X m $ j" by metis
 35.2632 -  then have "\<forall>i. \<forall>m \<ge> M i. \<forall>j \<le> i. X (M i) $ j = X m $ j" by metis
 35.2633 +  obtain M where M: "\<forall>i. \<forall>m \<ge> M i. \<forall>j \<le> i. X (M i) $ j = X m $ j"
 35.2634 +  proof -
 35.2635 +    have "\<exists>M. \<forall>m \<ge> M. \<forall>j\<le>i. X M $ j = X m $ j" for i
 35.2636 +    proof -
 35.2637 +      have "0 < inverse ((2::real)^i)" by simp
 35.2638 +      from metric_CauchyD[OF \<open>Cauchy X\<close> this] dist_less_imp_nth_equal
 35.2639 +      show ?thesis by blast
 35.2640 +    qed
 35.2641 +    then show ?thesis using that by metis
 35.2642 +  qed
 35.2643 +
 35.2644    show "convergent X"
 35.2645    proof (rule convergentI)
 35.2646      show "X ----> Abs_fps (\<lambda>i. X (M i) $ i)"
 35.2647 @@ -3776,20 +3767,21 @@
 35.2648          unfolding eventually_nhds
 35.2649          apply clarsimp
 35.2650          apply (rule FalseE)
 35.2651 -        apply auto --{*slow*}
 35.2652 +        apply auto -- \<open>slow\<close>
 35.2653          done
 35.2654 -      then obtain i where "inverse (2 ^ i) < e" by (auto simp: eventually_sequentially)
 35.2655 -      have "eventually (\<lambda>x. M i \<le> x) sequentially" by (auto simp: eventually_sequentially)
 35.2656 +      then obtain i where "inverse (2 ^ i) < e"
 35.2657 +        by (auto simp: eventually_sequentially)
 35.2658 +      have "eventually (\<lambda>x. M i \<le> x) sequentially"
 35.2659 +        by (auto simp: eventually_sequentially)
 35.2660        then show "eventually (\<lambda>x. dist (X x) (Abs_fps (\<lambda>i. X (M i) $ i)) < e) sequentially"
 35.2661        proof eventually_elim
 35.2662          fix x
 35.2663 -        assume "M i \<le> x"
 35.2664 -        moreover
 35.2665 -        have "\<And>j. j \<le> i \<Longrightarrow> X (M i) $ j = X (M j) $ j"
 35.2666 -          using M by (metis nat_le_linear)
 35.2667 -        ultimately have "dist (X x) (Abs_fps (\<lambda>j. X (M j) $ j)) < inverse (2 ^ i)"
 35.2668 +        assume x: "M i \<le> x"
 35.2669 +        have "X (M i) $ j = X (M j) $ j" if "j \<le> i" for j
 35.2670 +          using M that by (metis nat_le_linear)
 35.2671 +        with x have "dist (X x) (Abs_fps (\<lambda>j. X (M j) $ j)) < inverse (2 ^ i)"
 35.2672            using M by (force simp: dist_less_eq_nth_equal)
 35.2673 -        also note `inverse (2 ^ i) < e`
 35.2674 +        also note \<open>inverse (2 ^ i) < e\<close>
 35.2675          finally show "dist (X x) (Abs_fps (\<lambda>j. X (M j) $ j)) < e" .
 35.2676        qed
 35.2677      qed
    36.1 --- a/src/HOL/Library/Fraction_Field.thy	Wed Jun 17 17:33:22 2015 +0200
    36.2 +++ b/src/HOL/Library/Fraction_Field.thy	Wed Jun 17 17:54:09 2015 +0200
    36.3 @@ -2,16 +2,16 @@
    36.4      Author:     Amine Chaieb, University of Cambridge
    36.5  *)
    36.6  
    36.7 -section{* A formalization of the fraction field of any integral domain;
    36.8 -         generalization of theory Rat from int to any integral domain *}
    36.9 +section\<open>A formalization of the fraction field of any integral domain;
   36.10 +         generalization of theory Rat from int to any integral domain\<close>
   36.11  
   36.12  theory Fraction_Field
   36.13  imports Main
   36.14  begin
   36.15  
   36.16 -subsection {* General fractions construction *}
   36.17 +subsection \<open>General fractions construction\<close>
   36.18  
   36.19 -subsubsection {* Construction of the type of fractions *}
   36.20 +subsubsection \<open>Construction of the type of fractions\<close>
   36.21  
   36.22  definition fractrel :: "(('a::idom * 'a ) * ('a * 'a)) set" where
   36.23    "fractrel = {(x, y). snd x \<noteq> 0 \<and> snd y \<noteq> 0 \<and> fst x * snd y = fst y * snd x}"
   36.24 @@ -69,7 +69,7 @@
   36.25  declare Abs_fract_inject [simp] Abs_fract_inverse [simp]
   36.26  
   36.27  
   36.28 -subsubsection {* Representation and basic operations *}
   36.29 +subsubsection \<open>Representation and basic operations\<close>
   36.30  
   36.31  definition Fract :: "'a::idom \<Rightarrow> 'a \<Rightarrow> 'a fract"
   36.32    where "Fract a b = Abs_fract (fractrel `` {if b = 0 then (0, 1) else (a, b)})"
   36.33 @@ -210,12 +210,12 @@
   36.34    case False
   36.35    then obtain a b where "q = Fract a b" and "b \<noteq> 0" by (cases q) auto
   36.36    with False have "0 \<noteq> Fract a b" by simp
   36.37 -  with `b \<noteq> 0` have "a \<noteq> 0" by (simp add: Zero_fract_def eq_fract)
   36.38 -  with Fract `q = Fract a b` `b \<noteq> 0` show thesis by auto
   36.39 +  with \<open>b \<noteq> 0\<close> have "a \<noteq> 0" by (simp add: Zero_fract_def eq_fract)
   36.40 +  with Fract \<open>q = Fract a b\<close> \<open>b \<noteq> 0\<close> show thesis by auto
   36.41  qed
   36.42  
   36.43  
   36.44 -subsubsection {* The field of rational numbers *}
   36.45 +subsubsection \<open>The field of rational numbers\<close>
   36.46  
   36.47  context idom
   36.48  begin
   36.49 @@ -264,7 +264,7 @@
   36.50  end
   36.51  
   36.52  
   36.53 -subsubsection {* The ordered field of fractions over an ordered idom *}
   36.54 +subsubsection \<open>The ordered field of fractions over an ordered idom\<close>
   36.55  
   36.56  lemma le_congruent2:
   36.57    "(\<lambda>x y::'a \<times> 'a::linordered_idom.
    37.1 --- a/src/HOL/Library/Fun_Lexorder.thy	Wed Jun 17 17:33:22 2015 +0200
    37.2 +++ b/src/HOL/Library/Fun_Lexorder.thy	Wed Jun 17 17:54:09 2015 +0200
    37.3 @@ -52,9 +52,9 @@
    37.4    assumes "less_fun f g" and "less_fun g h"
    37.5    shows "less_fun f h"
    37.6  proof (rule less_funI)
    37.7 -  from `less_fun f g` obtain k1 where k1: "f k1 < g k1" "\<And>k'. k' < k1 \<Longrightarrow> f k' = g k'"
    37.8 +  from \<open>less_fun f g\<close> obtain k1 where k1: "f k1 < g k1" "\<And>k'. k' < k1 \<Longrightarrow> f k' = g k'"
    37.9      by (blast elim!: less_funE) 
   37.10 -  from `less_fun g h` obtain k2 where k2: "g k2 < h k2" "\<And>k'. k' < k2 \<Longrightarrow> g k' = h k'"
   37.11 +  from \<open>less_fun g h\<close> obtain k2 where k2: "g k2 < h k2" "\<And>k'. k' < k2 \<Longrightarrow> g k' = h k'"
   37.12      by (blast elim!: less_funE) 
   37.13    show "\<exists>k. f k < h k \<and> (\<forall>k'<k. f k' = h k')"
   37.14    proof (cases k1 k2 rule: linorder_cases)
   37.15 @@ -85,7 +85,7 @@
   37.16      then have "q \<in> K" and "\<And>k. k \<in> K \<Longrightarrow> k \<ge> q" by auto
   37.17      then have "\<And>k. \<not> k \<ge> q \<Longrightarrow> k \<notin> K" by blast
   37.18      then have *: "\<And>k. k < q \<Longrightarrow> f k = g k" by (simp add: K_def)
   37.19 -    from `q \<in> K` have "f q \<noteq> g q" by (simp add: K_def)
   37.20 +    from \<open>q \<in> K\<close> have "f q \<noteq> g q" by (simp add: K_def)
   37.21      then have "f q < g q \<or> f q > g q" by auto
   37.22      with * have "less_fun f g \<or> less_fun g f"
   37.23        by (auto intro!: less_funI)
    38.1 --- a/src/HOL/Library/Function_Algebras.thy	Wed Jun 17 17:33:22 2015 +0200
    38.2 +++ b/src/HOL/Library/Function_Algebras.thy	Wed Jun 17 17:54:09 2015 +0200
    38.3 @@ -2,13 +2,13 @@
    38.4      Author:     Jeremy Avigad and Kevin Donnelly; Florian Haftmann, TUM
    38.5  *)
    38.6  
    38.7 -section {* Pointwise instantiation of functions to algebra type classes *}
    38.8 +section \<open>Pointwise instantiation of functions to algebra type classes\<close>
    38.9  
   38.10  theory Function_Algebras
   38.11  imports Main
   38.12  begin
   38.13  
   38.14 -text {* Pointwise operations *}
   38.15 +text \<open>Pointwise operations\<close>
   38.16  
   38.17  instantiation "fun" :: (type, plus) plus
   38.18  begin
   38.19 @@ -59,7 +59,7 @@
   38.20    by (simp add: one_fun_def)
   38.21  
   38.22  
   38.23 -text {* Additive structures *}
   38.24 +text \<open>Additive structures\<close>
   38.25  
   38.26  instance "fun" :: (type, semigroup_add) semigroup_add
   38.27    by default (simp add: fun_eq_iff add.assoc)
   38.28 @@ -89,7 +89,7 @@
   38.29    by default simp_all
   38.30  
   38.31  
   38.32 -text {* Multiplicative structures *}
   38.33 +text \<open>Multiplicative structures\<close>
   38.34  
   38.35  instance "fun" :: (type, semigroup_mult) semigroup_mult
   38.36    by default (simp add: fun_eq_iff mult.assoc)
   38.37 @@ -104,7 +104,7 @@
   38.38    by default simp
   38.39  
   38.40  
   38.41 -text {* Misc *}
   38.42 +text \<open>Misc\<close>
   38.43  
   38.44  instance "fun" :: (type, "Rings.dvd") "Rings.dvd" ..
   38.45  
   38.46 @@ -115,7 +115,7 @@
   38.47    by default (simp add: fun_eq_iff)
   38.48  
   38.49  
   38.50 -text {* Ring structures *}
   38.51 +text \<open>Ring structures\<close>
   38.52  
   38.53  instance "fun" :: (type, semiring) semiring
   38.54    by default (simp_all add: fun_eq_iff algebra_simps)
   38.55 @@ -176,7 +176,7 @@
   38.56  instance "fun" :: (type, ring_char_0) ring_char_0 ..
   38.57  
   38.58  
   38.59 -text {* Ordered structures *}
   38.60 +text \<open>Ordered structures\<close>
   38.61  
   38.62  instance "fun" :: (type, ordered_ab_semigroup_add) ordered_ab_semigroup_add
   38.63    by default (auto simp add: le_fun_def intro: add_left_mono)
    39.1 --- a/src/HOL/Library/Function_Division.thy	Wed Jun 17 17:33:22 2015 +0200
    39.2 +++ b/src/HOL/Library/Function_Division.thy	Wed Jun 17 17:54:09 2015 +0200
    39.3 @@ -2,13 +2,13 @@
    39.4      Author:     Florian Haftmann, TUM
    39.5  *)
    39.6  
    39.7 -section {* Pointwise instantiation of functions to division *}
    39.8 +section \<open>Pointwise instantiation of functions to division\<close>
    39.9  
   39.10  theory Function_Division
   39.11  imports Function_Algebras
   39.12  begin
   39.13  
   39.14 -subsection {* Syntactic with division *}
   39.15 +subsection \<open>Syntactic with division\<close>
   39.16  
   39.17  instantiation "fun" :: (type, inverse) inverse
   39.18  begin
   39.19 @@ -29,12 +29,12 @@
   39.20    "(f / g) x = f x / g x"
   39.21    by (simp add: divide_fun_def)
   39.22  
   39.23 -text {*
   39.24 +text \<open>
   39.25    Unfortunately, we cannot lift this operations to algebraic type
   39.26    classes for division: being different from the constant
   39.27    zero function @{term "f \<noteq> 0"} is too weak as precondition.
   39.28    So we must introduce our own set of lemmas.
   39.29 -*}
   39.30 +\<close>
   39.31  
   39.32  abbreviation zero_free :: "('b \<Rightarrow> 'a::field) \<Rightarrow> bool" where
   39.33    "zero_free f \<equiv> \<not> (\<exists>x. f x = 0)"
   39.34 @@ -54,12 +54,12 @@
   39.35    shows "f / g = f * inverse g"
   39.36    by (simp add: fun_eq_iff divide_inverse)
   39.37  
   39.38 -text {* Feel free to extend this. *}
   39.39 +text \<open>Feel free to extend this.\<close>
   39.40  
   39.41 -text {*
   39.42 +text \<open>
   39.43    Another possibility would be a reformulation of the division type
   39.44    classes to user a @{term zero_free} predicate rather than
   39.45    a direct @{term "a \<noteq> 0"} condition.
   39.46 -*}
   39.47 +\<close>
   39.48  
   39.49  end
    40.1 --- a/src/HOL/Library/Function_Growth.thy	Wed Jun 17 17:33:22 2015 +0200
    40.2 +++ b/src/HOL/Library/Function_Growth.thy	Wed Jun 17 17:54:09 2015 +0200
    40.3 @@ -1,15 +1,15 @@
    40.4  
    40.5  (* Author: Florian Haftmann, TU Muenchen *)
    40.6  
    40.7 -section {* Comparing growth of functions on natural numbers by a preorder relation *}
    40.8 +section \<open>Comparing growth of functions on natural numbers by a preorder relation\<close>
    40.9  
   40.10  theory Function_Growth
   40.11  imports Main Preorder Discrete
   40.12  begin
   40.13  
   40.14 -subsection {* Motivation *}
   40.15 +subsection \<open>Motivation\<close>
   40.16  
   40.17 -text {*
   40.18 +text \<open>
   40.19    When comparing growth of functions in computer science, it is common to adhere
   40.20    on Landau Symbols (``O-Notation'').  However these come at the cost of notational
   40.21    oddities, particularly writing @{text "f = O(g)"} for @{text "f \<in> O(g)"} etc.
   40.22 @@ -21,11 +21,11 @@
   40.23    avoid the notational oddities mentioned above but also emphasizes the key insight
   40.24    of a growth hierarchy of functions:
   40.25    @{text "(\<lambda>n. 0) \<lesssim> (\<lambda>n. k) \<lesssim> Discrete.log \<lesssim> Discrete.sqrt \<lesssim> id \<lesssim> \<dots>"}.
   40.26 -*}
   40.27 +\<close>
   40.28  
   40.29 -subsection {* Model *}
   40.30 +subsection \<open>Model\<close>
   40.31  
   40.32 -text {*
   40.33 +text \<open>
   40.34    Our growth functions are of type @{text "\<nat> \<Rightarrow> \<nat>"}.  This is different
   40.35    to the usual conventions for Landau symbols for which @{text "\<real> \<Rightarrow> \<real>"}
   40.36    would be appropriate, but we argue that @{text "\<real> \<Rightarrow> \<real>"} is more
   40.37 @@ -33,19 +33,19 @@
   40.38  
   40.39    Note that we also restrict the additional coefficients to @{text \<nat>}, something
   40.40    we discuss at the particular definitions.
   40.41 -*}
   40.42 +\<close>
   40.43  
   40.44 -subsection {* The @{text "\<lesssim>"} relation *}
   40.45 +subsection \<open>The @{text "\<lesssim>"} relation\<close>
   40.46  
   40.47  definition less_eq_fun :: "(nat \<Rightarrow> nat) \<Rightarrow> (nat \<Rightarrow> nat) \<Rightarrow> bool" (infix "\<lesssim>" 50)
   40.48  where
   40.49    "f \<lesssim> g \<longleftrightarrow> (\<exists>c>0. \<exists>n. \<forall>m>n. f m \<le> c * g m)"
   40.50  
   40.51 -text {*
   40.52 +text \<open>
   40.53    This yields @{text "f \<lesssim> g \<longleftrightarrow> f \<in> O(g)"}.  Note that @{text c} is restricted to
   40.54    @{text \<nat>}.  This does not pose any problems since if @{text "f \<in> O(g)"} holds for
   40.55    a @{text "c \<in> \<real>"}, it also holds for @{text "\<lceil>c\<rceil> \<in> \<nat>"} by transitivity.
   40.56 -*}
   40.57 +\<close>
   40.58  
   40.59  lemma less_eq_funI [intro?]:
   40.60    assumes "\<exists>c>0. \<exists>n. \<forall>m>n. f m \<le> c * g m"
   40.61 @@ -68,17 +68,17 @@
   40.62    using assms unfolding less_eq_fun_def linorder_not_le [symmetric] by blast
   40.63  
   40.64  
   40.65 -subsection {* The @{text "\<approx>"} relation, the equivalence relation induced by @{text "\<lesssim>"} *}
   40.66 +subsection \<open>The @{text "\<approx>"} relation, the equivalence relation induced by @{text "\<lesssim>"}\<close>
   40.67  
   40.68  definition equiv_fun :: "(nat \<Rightarrow> nat) \<Rightarrow> (nat \<Rightarrow> nat) \<Rightarrow> bool" (infix "\<cong>" 50)
   40.69  where
   40.70    "f \<cong> g \<longleftrightarrow>
   40.71      (\<exists>c\<^sub>1>0. \<exists>c\<^sub>2>0. \<exists>n. \<forall>m>n. f m \<le> c\<^sub>1 * g m \<and> g m \<le> c\<^sub>2 * f m)"
   40.72  
   40.73 -text {*
   40.74 +text \<open>
   40.75    This yields @{text "f \<cong> g \<longleftrightarrow> f \<in> \<Theta>(g)"}.  Concerning @{text "c\<^sub>1"} and @{text "c\<^sub>2"}
   40.76    restricted to @{typ nat}, see note above on @{text "(\<lesssim>)"}.
   40.77 -*}
   40.78 +\<close>
   40.79  
   40.80  lemma equiv_funI [intro?]:
   40.81    assumes "\<exists>c\<^sub>1>0. \<exists>c\<^sub>2>0. \<exists>n. \<forall>m>n. f m \<le> c\<^sub>1 * g m \<and> g m \<le> c\<^sub>2 * f m"
   40.82 @@ -105,7 +105,7 @@
   40.83    using assms unfolding equiv_fun_def linorder_not_le [symmetric] by blast
   40.84  
   40.85  
   40.86 -subsection {* The @{text "\<prec>"} relation, the strict part of @{text "\<lesssim>"} *}
   40.87 +subsection \<open>The @{text "\<prec>"} relation, the strict part of @{text "\<lesssim>"}\<close>
   40.88  
   40.89  definition less_fun :: "(nat \<Rightarrow> nat) \<Rightarrow> (nat \<Rightarrow> nat) \<Rightarrow> bool" (infix "\<prec>" 50)
   40.90  where
   40.91 @@ -129,11 +129,11 @@
   40.92      and "\<And>c n. c > 0 \<Longrightarrow> \<exists>m>n. c * f m < g m"
   40.93  proof -
   40.94    from assms have "f \<lesssim> g" and "\<not> g \<lesssim> f" by (simp_all add: less_fun_def)
   40.95 -  from `f \<lesssim> g` obtain n c where *:"c > 0" "\<And>m. m > n \<Longrightarrow> f m \<le> c * g m"
   40.96 +  from \<open>f \<lesssim> g\<close> obtain n c where *:"c > 0" "\<And>m. m > n \<Longrightarrow> f m \<le> c * g m"
   40.97      by (rule less_eq_funE) blast
   40.98    { fix c n :: nat
   40.99      assume "c > 0"
  40.100 -    with `\<not> g \<lesssim> f` obtain m where "m > n" "c * f m < g m"
  40.101 +    with \<open>\<not> g \<lesssim> f\<close> obtain m where "m > n" "c * f m < g m"
  40.102        by (rule not_less_eq_funE) blast
  40.103      then have **: "\<exists>m>n. c * f m < g m" by blast
  40.104    } note ** = this
  40.105 @@ -146,7 +146,7 @@
  40.106      | d q where "\<And>m. d > 0 \<Longrightarrow> m > q \<Longrightarrow> g q \<le> d * f q"
  40.107    using assms unfolding less_fun_def linorder_not_less [symmetric] by blast
  40.108  
  40.109 -text {*
  40.110 +text \<open>
  40.111    I did not find a proof for @{text "f \<prec> g \<longleftrightarrow> f \<in> o(g)"}.  Maybe this only
  40.112    holds if @{text f} and/or @{text g} are of a certain class of functions.
  40.113    However @{text "f \<in> o(g) \<longrightarrow> f \<prec> g"} is provable, and this yields a
  40.114 @@ -161,14 +161,14 @@
  40.115    works since @{text c} may become arbitrary small.  Since this is not possible
  40.116    within @{term \<nat>}, we push the coefficient to the left hand side instead such
  40.117    that it become arbitrary big instead.
  40.118 -*}
  40.119 +\<close>
  40.120  
  40.121  lemma less_fun_strongI:
  40.122    assumes "\<And>c. c > 0 \<Longrightarrow> \<exists>n. \<forall>m>n. c * f m < g m"
  40.123    shows "f \<prec> g"
  40.124  proof (rule less_funI)
  40.125    have "1 > (0::nat)" by simp
  40.126 -  from assms `1 > 0` have "\<exists>n. \<forall>m>n. 1 * f m < g m" .
  40.127 +  from assms \<open>1 > 0\<close> have "\<exists>n. \<forall>m>n. 1 * f m < g m" .
  40.128    then obtain n where *: "\<And>m. m > n \<Longrightarrow> 1 * f m < g m" by blast
  40.129    have "\<forall>m>n. f m \<le> 1 * g m"
  40.130    proof (rule allI, rule impI)
  40.131 @@ -177,7 +177,7 @@
  40.132      with * have "1 * f m < g m" by simp
  40.133      then show "f m \<le> 1 * g m" by simp
  40.134    qed
  40.135 -  with `1 > 0` show "\<exists>c>0. \<exists>n. \<forall>m>n. f m \<le> c * g m" by blast
  40.136 +  with \<open>1 > 0\<close> show "\<exists>c>0. \<exists>n. \<forall>m>n. f m \<le> c * g m" by blast
  40.137    fix c n :: nat
  40.138    assume "c > 0"
  40.139    with assms obtain q where "\<And>m. m > q \<Longrightarrow> c * f m < g m" by blast
  40.140 @@ -187,9 +187,9 @@
  40.141  qed
  40.142  
  40.143  
  40.144 -subsection {* @{text "\<lesssim>"} is a preorder *}
  40.145 +subsection \<open>@{text "\<lesssim>"} is a preorder\<close>
  40.146  
  40.147 -text {* This yields all lemmas relating @{text "\<lesssim>"}, @{text "\<prec>"} and @{text "\<cong>"}. *}
  40.148 +text \<open>This yields all lemmas relating @{text "\<lesssim>"}, @{text "\<prec>"} and @{text "\<cong>"}.\<close>
  40.149  
  40.150  interpretation fun_order: preorder_equiv less_eq_fun less_fun
  40.151    where "preorder_equiv.equiv less_eq_fun = equiv_fun"
  40.152 @@ -207,10 +207,10 @@
  40.153      assume "f \<lesssim> g" and "g \<lesssim> h"
  40.154      show "f \<lesssim> h"
  40.155      proof
  40.156 -      from `f \<lesssim> g` obtain n\<^sub>1 c\<^sub>1
  40.157 +      from \<open>f \<lesssim> g\<close> obtain n\<^sub>1 c\<^sub>1
  40.158          where "c\<^sub>1 > 0" and P\<^sub>1: "\<And>m. m > n\<^sub>1 \<Longrightarrow> f m \<le> c\<^sub>1 * g m"
  40.159          by rule blast
  40.160 -      from `g \<lesssim> h` obtain n\<^sub>2 c\<^sub>2
  40.161 +      from \<open>g \<lesssim> h\<close> obtain n\<^sub>2 c\<^sub>2
  40.162          where "c\<^sub>2 > 0" and P\<^sub>2: "\<And>m. m > n\<^sub>2 \<Longrightarrow> g m \<le> c\<^sub>2 * h m"
  40.163          by rule blast
  40.164        have "\<forall>m>max n\<^sub>1 n\<^sub>2. f m \<le> (c\<^sub>1 * c\<^sub>2) * h m"
  40.165 @@ -219,11 +219,11 @@
  40.166          assume Q: "m > max n\<^sub>1 n\<^sub>2"
  40.167          from P\<^sub>1 Q have *: "f m \<le> c\<^sub>1 * g m" by simp
  40.168          from P\<^sub>2 Q have "g m \<le> c\<^sub>2 * h m" by simp
  40.169 -        with `c\<^sub>1 > 0` have "c\<^sub>1 * g m \<le> (c\<^sub>1 * c\<^sub>2) * h m" by simp
  40.170 +        with \<open>c\<^sub>1 > 0\<close> have "c\<^sub>1 * g m \<le> (c\<^sub>1 * c\<^sub>2) * h m" by simp
  40.171          with * show "f m \<le> (c\<^sub>1 * c\<^sub>2) * h m" by (rule order_trans)
  40.172        qed
  40.173        then have "\<exists>n. \<forall>m>n. f m \<le> (c\<^sub>1 * c\<^sub>2) * h m" by rule
  40.174 -      moreover from `c\<^sub>1 > 0` `c\<^sub>2 > 0` have "c\<^sub>1 * c\<^sub>2 > 0" by simp
  40.175 +      moreover from \<open>c\<^sub>1 > 0\<close> \<open>c\<^sub>2 > 0\<close> have "c\<^sub>1 * c\<^sub>2 > 0" by simp
  40.176        ultimately show "\<exists>c>0. \<exists>n. \<forall>m>n. f m \<le> c * h m" by blast
  40.177      qed
  40.178    qed
  40.179 @@ -243,7 +243,7 @@
  40.180          assume "m > n"
  40.181          with * show "f m \<le> c\<^sub>1 * g m" by simp
  40.182        qed
  40.183 -      with `c\<^sub>1 > 0` have "\<exists>c>0. \<exists>n. \<forall>m>n. f m \<le> c * g m" by blast
  40.184 +      with \<open>c\<^sub>1 > 0\<close> have "\<exists>c>0. \<exists>n. \<forall>m>n. f m \<le> c * g m" by blast
  40.185        then have "f \<lesssim> g" ..
  40.186        have "\<forall>m>n. g m \<le> c\<^sub>2 * f m"
  40.187        proof (rule allI, rule impI)
  40.188 @@ -251,15 +251,15 @@
  40.189          assume "m > n"
  40.190          with * show "g m \<le> c\<^sub>2 * f m" by simp
  40.191        qed
  40.192 -      with `c\<^sub>2 > 0` have "\<exists>c>0. \<exists>n. \<forall>m>n. g m \<le> c * f m" by blast
  40.193 +      with \<open>c\<^sub>2 > 0\<close> have "\<exists>c>0. \<exists>n. \<forall>m>n. g m \<le> c * f m" by blast
  40.194        then have "g \<lesssim> f" ..
  40.195 -      from `f \<lesssim> g` and `g \<lesssim> f` show "f \<lesssim> g \<and> g \<lesssim> f" ..
  40.196 +      from \<open>f \<lesssim> g\<close> and \<open>g \<lesssim> f\<close> show "f \<lesssim> g \<and> g \<lesssim> f" ..
  40.197      next
  40.198        assume "f \<lesssim> g \<and> g \<lesssim> f"
  40.199        then have "f \<lesssim> g" and "g \<lesssim> f" by auto
  40.200 -      from `f \<lesssim> g` obtain n\<^sub>1 c\<^sub>1 where "c\<^sub>1 > 0"
  40.201 +      from \<open>f \<lesssim> g\<close> obtain n\<^sub>1 c\<^sub>1 where "c\<^sub>1 > 0"
  40.202          and P\<^sub>1: "\<And>m. m > n\<^sub>1 \<Longrightarrow> f m \<le> c\<^sub>1 * g m" by rule blast
  40.203 -      from `g \<lesssim> f` obtain n\<^sub>2 c\<^sub>2 where "c\<^sub>2 > 0"
  40.204 +      from \<open>g \<lesssim> f\<close> obtain n\<^sub>2 c\<^sub>2 where "c\<^sub>2 > 0"
  40.205          and P\<^sub>2: "\<And>m. m > n\<^sub>2 \<Longrightarrow> g m \<le> c\<^sub>2 * f m" by rule blast
  40.206        have "\<forall>m>max n\<^sub>1 n\<^sub>2. f m \<le> c\<^sub>1 * g m \<and> g m \<le> c\<^sub>2 * f m"
  40.207        proof (rule allI, rule impI)
  40.208 @@ -269,7 +269,7 @@
  40.209          moreover from P\<^sub>2 Q have "g m \<le> c\<^sub>2 * f m" by simp
  40.210          ultimately show "f m \<le> c\<^sub>1 * g m \<and> g m \<le> c\<^sub>2 * f m" ..
  40.211        qed
  40.212 -      with `c\<^sub>1 > 0` `c\<^sub>2 > 0` have "\<exists>c\<^sub>1>0. \<exists>c\<^sub>2>0. \<exists>n.
  40.213 +      with \<open>c\<^sub>1 > 0\<close> \<open>c\<^sub>2 > 0\<close> have "\<exists>c\<^sub>1>0. \<exists>c\<^sub>2>0. \<exists>n.
  40.214          \<forall>m>n. f m \<le> c\<^sub>1 * g m \<and> g m \<le> c\<^sub>2 * f m" by blast
  40.215        then show "f \<cong> g" ..
  40.216      qed
  40.217 @@ -277,18 +277,18 @@
  40.218  qed
  40.219  
  40.220  
  40.221 -subsection {* Simple examples *}
  40.222 +subsection \<open>Simple examples\<close>
  40.223  
  40.224 -text {*
  40.225 +text \<open>
  40.226    Most of these are left as constructive exercises for the reader.  Note that additional
  40.227    preconditions to the functions may be necessary.  The list here is by no means to be
  40.228    intended as complete construction set for typical functions, here surely something
  40.229    has to be added yet.
  40.230 -*}
  40.231 +\<close>
  40.232  
  40.233 -text {* @{prop "(\<lambda>n. f n + k) \<cong> f"} *}
  40.234 +text \<open>@{prop "(\<lambda>n. f n + k) \<cong> f"}\<close>
  40.235  
  40.236 -text {* @{prop "(\<lambda>n. Suc k * f n) \<cong> f"} *}
  40.237 +text \<open>@{prop "(\<lambda>n. Suc k * f n) \<cong> f"}\<close>
  40.238  
  40.239  lemma "f \<lesssim> (\<lambda>n. f n + g n)"
  40.240    by rule auto
  40.241 @@ -312,7 +312,7 @@
  40.242    then show "\<exists>n. \<forall>m>n. c * k < Discrete.log m" ..
  40.243  qed
  40.244    
  40.245 -text {* @{prop "Discrete.log \<prec> Discrete.sqrt"} *}
  40.246 +text \<open>@{prop "Discrete.log \<prec> Discrete.sqrt"}\<close>
  40.247  
  40.248  lemma "Discrete.sqrt \<prec> id"
  40.249  proof (rule less_fun_strongI)
  40.250 @@ -326,7 +326,7 @@
  40.251      with mono_sqrt have "Discrete.sqrt ((Suc c)\<^sup>2) \<le> Discrete.sqrt m" by (rule monoE)
  40.252      then have "Suc c \<le> Discrete.sqrt m" by simp
  40.253      then have "c < Discrete.sqrt m" by simp
  40.254 -    moreover from `(Suc c)\<^sup>2 < m` have "Discrete.sqrt m > 0" by simp
  40.255 +    moreover from \<open>(Suc c)\<^sup>2 < m\<close> have "Discrete.sqrt m > 0" by simp
  40.256      ultimately have "c * Discrete.sqrt m < Discrete.sqrt m * Discrete.sqrt m" by simp
  40.257      also have "\<dots> \<le> m" by (simp add: power2_eq_square [symmetric])
  40.258      finally show "c * Discrete.sqrt m < id m" by simp
  40.259 @@ -340,7 +340,7 @@
  40.260  lemma "(\<lambda>n. n ^ k) \<prec> (\<lambda>n. n ^ Suc k)"
  40.261    by (rule less_fun_strongI) auto
  40.262  
  40.263 -text {* @{prop "(\<lambda>n. n ^ k) \<prec> (\<lambda>n. 2 ^ n)"} *}
  40.264 +text \<open>@{prop "(\<lambda>n. n ^ k) \<prec> (\<lambda>n. 2 ^ n)"}\<close>
  40.265  
  40.266  end
  40.267  
    41.1 --- a/src/HOL/Library/Groups_Big_Fun.thy	Wed Jun 17 17:33:22 2015 +0200
    41.2 +++ b/src/HOL/Library/Groups_Big_Fun.thy	Wed Jun 17 17:54:09 2015 +0200
    41.3 @@ -49,17 +49,17 @@
    41.4    assumes "g a = 1"
    41.5    shows "G (g(a := b)) = b * G g"
    41.6  proof (cases "b = 1")
    41.7 -  case True with `g a = 1` show ?thesis
    41.8 +  case True with \<open>g a = 1\<close> show ?thesis
    41.9      by (simp add: expand_set) (rule F.cong, auto)
   41.10  next
   41.11    case False
   41.12    moreover have "{a'. a' \<noteq> a \<longrightarrow> g a' \<noteq> 1} = insert a {a. g a \<noteq> 1}"
   41.13      by auto
   41.14 -  moreover from `g a = 1` have "a \<notin> {a. g a \<noteq> 1}"
   41.15 +  moreover from \<open>g a = 1\<close> have "a \<notin> {a. g a \<noteq> 1}"
   41.16      by simp
   41.17    moreover have "F.F (\<lambda>a'. if a' = a then b else g a') {a. g a \<noteq> 1} = F.F g {a. g a \<noteq> 1}"
   41.18 -    by (rule F.cong) (auto simp add: `g a = 1`)
   41.19 -  ultimately show ?thesis using `finite {a. g a \<noteq> 1}` by (simp add: expand_set)
   41.20 +    by (rule F.cong) (auto simp add: \<open>g a = 1\<close>)
   41.21 +  ultimately show ?thesis using \<open>finite {a. g a \<noteq> 1}\<close> by (simp add: expand_set)
   41.22  qed
   41.23  
   41.24  lemma infinite [simp]:
   41.25 @@ -87,9 +87,9 @@
   41.26    shows "G g = G h"
   41.27  proof -
   41.28    from assms have unfold: "h = g \<circ> l" by simp
   41.29 -  from `bij l` have "inj l" by (rule bij_is_inj)
   41.30 +  from \<open>bij l\<close> have "inj l" by (rule bij_is_inj)
   41.31    then have "inj_on l {a. h a \<noteq> 1}" by (rule subset_inj_on) simp
   41.32 -  moreover from `bij l` have "{a. g a \<noteq> 1} = l ` {a. h a \<noteq> 1}"
   41.33 +  moreover from \<open>bij l\<close> have "{a. g a \<noteq> 1} = l ` {a. h a \<noteq> 1}"
   41.34      by (auto simp add: image_Collect unfold elim: bij_pointE)
   41.35    moreover have "\<And>x. x \<in> {a. h a \<noteq> 1} \<Longrightarrow> g (l x) = h x"
   41.36      by (simp add: unfold)
   41.37 @@ -115,7 +115,7 @@
   41.38    assumes subset: "{a. \<exists>b. g a b \<noteq> 1} \<times> {b. \<exists>a. g a b \<noteq> 1} \<subseteq> C" (is "?A \<times> ?B \<subseteq> C")
   41.39    shows "G (\<lambda>a. G (g a)) = G (\<lambda>b. G (\<lambda>a. g a b))"
   41.40  proof -
   41.41 -  from `finite C` subset
   41.42 +  from \<open>finite C\<close> subset
   41.43      have "finite ({a. \<exists>b. g a b \<noteq> 1} \<times> {b. \<exists>a. g a b \<noteq> 1})"
   41.44      by (rule rev_finite_subset)
   41.45    then have fins:
   41.46 @@ -143,17 +143,17 @@
   41.47    assumes subset: "{a. \<exists>b. g a b \<noteq> 1} \<times> {b. \<exists>a. g a b \<noteq> 1} \<subseteq> C" (is "?A \<times> ?B \<subseteq> C")
   41.48    shows "G (\<lambda>a. G (g a)) = G (\<lambda>(a, b). g a b)"
   41.49  proof -
   41.50 -  from subset `finite C` have fin_prod: "finite (?A \<times> ?B)"
   41.51 +  from subset \<open>finite C\<close> have fin_prod: "finite (?A \<times> ?B)"
   41.52      by (rule finite_subset)
   41.53    from fin_prod have "finite ?A" and "finite ?B"
   41.54      by (auto simp add: finite_cartesian_product_iff)
   41.55    have *: "G (\<lambda>a. G (g a)) =
   41.56      (F.F (\<lambda>a. F.F (g a) {b. \<exists>a. g a b \<noteq> 1}) {a. \<exists>b. g a b \<noteq> 1})"
   41.57      apply (subst expand_superset [of "?B"])
   41.58 -    apply (rule `finite ?B`)
   41.59 +    apply (rule \<open>finite ?B\<close>)
   41.60      apply auto
   41.61      apply (subst expand_superset [of "?A"])
   41.62 -    apply (rule `finite ?A`)
   41.63 +    apply (rule \<open>finite ?A\<close>)
   41.64      apply auto
   41.65      apply (erule F.not_neutral_contains_not_neutral)
   41.66      apply auto
   41.67 @@ -166,10 +166,10 @@
   41.68      apply (simp add: *)
   41.69      apply (simp add: F.cartesian_product)
   41.70      apply (subst expand_superset [of C])
   41.71 -    apply (rule `finite C`)
   41.72 +    apply (rule \<open>finite C\<close>)
   41.73      apply (simp_all add: **)
   41.74      apply (rule F.same_carrierI [of C])
   41.75 -    apply (rule `finite C`)
   41.76 +    apply (rule \<open>finite C\<close>)
   41.77      apply (simp_all add: subset)
   41.78      apply auto
   41.79      done
   41.80 @@ -330,9 +330,9 @@
   41.81    assumes "f a = 0"
   41.82    shows "(\<Prod>a. f a) = 0"
   41.83  proof -
   41.84 -  from `f a = 0` have "f a \<noteq> 1" by simp
   41.85 -  with `f a = 0` have "\<exists>a. f a \<noteq> 1 \<and> f a = 0" by blast
   41.86 -  with `finite {a. f a \<noteq> 1}` show ?thesis
   41.87 +  from \<open>f a = 0\<close> have "f a \<noteq> 1" by simp
   41.88 +  with \<open>f a = 0\<close> have "\<exists>a. f a \<noteq> 1 \<and> f a = 0" by blast
   41.89 +  with \<open>finite {a. f a \<noteq> 1}\<close> show ?thesis
   41.90      by (simp add: Prod_any.expand_set setprod_zero)
   41.91  qed
   41.92  
    42.1 --- a/src/HOL/Library/IArray.thy	Wed Jun 17 17:33:22 2015 +0200
    42.2 +++ b/src/HOL/Library/IArray.thy	Wed Jun 17 17:54:09 2015 +0200
    42.3 @@ -4,14 +4,14 @@
    42.4  imports Main
    42.5  begin
    42.6  
    42.7 -text{* Immutable arrays are lists wrapped up in an additional constructor.
    42.8 +text\<open>Immutable arrays are lists wrapped up in an additional constructor.
    42.9  There are no update operations. Hence code generation can safely implement
   42.10  this type by efficient target language arrays.  Currently only SML is
   42.11  provided. Should be extended to other target languages and more operations.
   42.12  
   42.13  Note that arrays cannot be printed directly but only by turning them into
   42.14  lists first. Arrays could be converted back into lists for printing if they
   42.15 -were wrapped up in an additional constructor. *}
   42.16 +were wrapped up in an additional constructor.\<close>
   42.17  
   42.18  datatype 'a iarray = IArray "'a list"
   42.19  
    43.1 --- a/src/HOL/Library/Indicator_Function.thy	Wed Jun 17 17:33:22 2015 +0200
    43.2 +++ b/src/HOL/Library/Indicator_Function.thy	Wed Jun 17 17:54:09 2015 +0200
    43.3 @@ -2,7 +2,7 @@
    43.4      Author:     Johannes Hoelzl (TU Muenchen)
    43.5  *)
    43.6  
    43.7 -section {* Indicator Function *}
    43.8 +section \<open>Indicator Function\<close>
    43.9  
   43.10  theory Indicator_Function
   43.11  imports Complex_Main
   43.12 @@ -88,7 +88,7 @@
   43.13    then have 
   43.14      "\<And>n. (indicator (A (n + i)) x :: 'a) = 1"
   43.15      "(indicator (\<Union> i. A i) x :: 'a) = 1"
   43.16 -    using incseqD[OF `incseq A`, of i "n + i" for n] `x \<in> A i` by (auto simp: indicator_def)
   43.17 +    using incseqD[OF \<open>incseq A\<close>, of i "n + i" for n] \<open>x \<in> A i\<close> by (auto simp: indicator_def)
   43.18    then show ?thesis
   43.19      by (rule_tac LIMSEQ_offset[of _ i]) simp
   43.20  qed (auto simp: indicator_def)
   43.21 @@ -113,7 +113,7 @@
   43.22    then have 
   43.23      "\<And>n. (indicator (A (n + i)) x :: 'a) = 0"
   43.24      "(indicator (\<Inter>i. A i) x :: 'a) = 0"
   43.25 -    using decseqD[OF `decseq A`, of i "n + i" for n] `x \<notin> A i` by (auto simp: indicator_def)
   43.26 +    using decseqD[OF \<open>decseq A\<close>, of i "n + i" for n] \<open>x \<notin> A i\<close> by (auto simp: indicator_def)
   43.27    then show ?thesis
   43.28      by (rule_tac LIMSEQ_offset[of _ i]) simp
   43.29  qed (auto simp: indicator_def)
    44.1 --- a/src/HOL/Library/Infinite_Set.thy	Wed Jun 17 17:33:22 2015 +0200
    44.2 +++ b/src/HOL/Library/Infinite_Set.thy	Wed Jun 17 17:54:09 2015 +0200
    44.3 @@ -2,7 +2,7 @@
    44.4      Author:     Stephan Merz
    44.5  *)
    44.6  
    44.7 -section {* Infinite Sets and Related Concepts *}
    44.8 +section \<open>Infinite Sets and Related Concepts\<close>
    44.9  
   44.10  theory Infinite_Set
   44.11  imports Main
   44.12 @@ -10,19 +10,19 @@
   44.13  
   44.14  subsection "Infinite Sets"
   44.15  
   44.16 -text {*
   44.17 +text \<open>
   44.18    Some elementary facts about infinite sets, mostly by Stephan Merz.
   44.19    Beware! Because "infinite" merely abbreviates a negation, these
   44.20    lemmas may not work well with @{text "blast"}.
   44.21 -*}
   44.22 +\<close>
   44.23  
   44.24  abbreviation infinite :: "'a set \<Rightarrow> bool"
   44.25    where "infinite S \<equiv> \<not> finite S"
   44.26  
   44.27 -text {*
   44.28 +text \<open>
   44.29    Infinite sets are non-empty, and if we remove some elements from an
   44.30    infinite set, the result is still infinite.
   44.31 -*}
   44.32 +\<close>
   44.33  
   44.34  lemma infinite_imp_nonempty: "infinite S \<Longrightarrow> S \<noteq> {}"
   44.35    by auto
   44.36 @@ -62,10 +62,10 @@
   44.37    with S show False by simp
   44.38  qed
   44.39  
   44.40 -text {*
   44.41 +text \<open>
   44.42    As a concrete example, we prove that the set of natural numbers is
   44.43    infinite.
   44.44 -*}
   44.45 +\<close>
   44.46  
   44.47  lemma infinite_nat_iff_unbounded_le: "infinite (S::nat set) \<longleftrightarrow> (\<forall>m. \<exists>n\<ge>m. n \<in> S)"
   44.48    using frequently_cofinite[of "\<lambda>x. x \<in> S"]
   44.49 @@ -84,11 +84,11 @@
   44.50  lemma finite_nat_bounded: "finite (S::nat set) \<Longrightarrow> \<exists>k. S \<subseteq> {..<k}"
   44.51    by (simp add: finite_nat_iff_bounded)
   44.52  
   44.53 -text {*
   44.54 +text \<open>
   44.55    For a set of natural numbers to be infinite, it is enough to know
   44.56    that for any number larger than some @{text k}, there is some larger
   44.57    number that is an element of the set.
   44.58 -*}
   44.59 +\<close>
   44.60  
   44.61  lemma unbounded_k_infinite: "\<forall>m>k. \<exists>n>m. n \<in> S \<Longrightarrow> infinite (S::nat set)"
   44.62    by (metis (full_types) infinite_nat_iff_unbounded_le le_imp_less_Suc not_less
   44.63 @@ -106,12 +106,12 @@
   44.64    then show False by simp
   44.65  qed
   44.66  
   44.67 -text {*
   44.68 +text \<open>
   44.69    For any function with infinite domain and finite range there is some
   44.70    element that is the image of infinitely many domain elements.  In
   44.71    particular, any infinite sequence of elements from a finite set
   44.72    contains some element that occurs infinitely often.
   44.73 -*}
   44.74 +\<close>
   44.75  
   44.76  lemma inf_img_fin_dom':
   44.77    assumes img: "finite (f ` A)" and dom: "infinite A"
   44.78 @@ -142,11 +142,11 @@
   44.79  
   44.80  subsection "Infinitely Many and Almost All"
   44.81  
   44.82 -text {*
   44.83 +text \<open>
   44.84    We often need to reason about the existence of infinitely many
   44.85    (resp., all but finitely many) objects satisfying some predicate, so
   44.86    we introduce corresponding binders and their proof rules.
   44.87 -*}
   44.88 +\<close>
   44.89  
   44.90  (* The following two lemmas are available as filter-rules, but not in the simp-set *)
   44.91  lemma not_INFM [simp]: "\<not> (INFM x. P x) \<longleftrightarrow> (MOST x. \<not> P x)" by (fact not_frequently)
   44.92 @@ -167,7 +167,7 @@
   44.93  lemma INFM_conjI: "INFM x. P x \<Longrightarrow> MOST x. Q x \<Longrightarrow> INFM x. P x \<and> Q x"
   44.94    by (rule frequently_rev_mp[of P]) (auto elim: eventually_elim1)
   44.95  
   44.96 -text {* Properties of quantifiers with injective functions. *}
   44.97 +text \<open>Properties of quantifiers with injective functions.\<close>
   44.98  
   44.99  lemma INFM_inj: "INFM x. P (f x) \<Longrightarrow> inj f \<Longrightarrow> INFM x. P x"
  44.100    using finite_vimageI[of "{x. P x}" f] by (auto simp: frequently_cofinite)
  44.101 @@ -175,7 +175,7 @@
  44.102  lemma MOST_inj: "MOST x. P x \<Longrightarrow> inj f \<Longrightarrow> MOST x. P (f x)"
  44.103    using finite_vimageI[of "{x. \<not> P x}" f] by (auto simp: eventually_cofinite)
  44.104  
  44.105 -text {* Properties of quantifiers with singletons. *}
  44.106 +text \<open>Properties of quantifiers with singletons.\<close>
  44.107  
  44.108  lemma not_INFM_eq [simp]:
  44.109    "\<not> (INFM x. x = a)"
  44.110 @@ -202,7 +202,7 @@
  44.111    "MOST x. a = x \<longrightarrow> P x"
  44.112    unfolding eventually_cofinite by simp_all
  44.113  
  44.114 -text {* Properties of quantifiers over the naturals. *}
  44.115 +text \<open>Properties of quantifiers over the naturals.\<close>
  44.116  
  44.117  lemma MOST_nat: "(\<forall>\<^sub>\<infinity>n. P (n::nat)) \<longleftrightarrow> (\<exists>m. \<forall>n>m. P n)"
  44.118    by (auto simp add: eventually_cofinite finite_nat_iff_bounded_le subset_eq not_le[symmetric])
  44.119 @@ -251,9 +251,9 @@
  44.120  
  44.121  subsection "Enumeration of an Infinite Set"
  44.122  
  44.123 -text {*
  44.124 +text \<open>
  44.125    The set's element type must be wellordered (e.g. the natural numbers).
  44.126 -*}
  44.127 +\<close>
  44.128  
  44.129  text \<open>
  44.130    Could be generalized to
  44.131 @@ -304,7 +304,7 @@
  44.132  next
  44.133    case (Suc n)
  44.134    then have "n \<le> enumerate S n" by simp
  44.135 -  also note enumerate_mono[of n "Suc n", OF _ `infinite S`]
  44.136 +  also note enumerate_mono[of n "Suc n", OF _ \<open>infinite S\<close>]
  44.137    finally show ?case by simp
  44.138  qed
  44.139  
  44.140 @@ -323,10 +323,10 @@
  44.141  next
  44.142    case (Suc n S)
  44.143    show ?case
  44.144 -    using enumerate_mono[OF zero_less_Suc `infinite S`, of n] `infinite S`
  44.145 +    using enumerate_mono[OF zero_less_Suc \<open>infinite S\<close>, of n] \<open>infinite S\<close>
  44.146      apply (subst (1 2) enumerate_Suc')
  44.147      apply (subst Suc)
  44.148 -    using `infinite S`
  44.149 +    using \<open>infinite S\<close>
  44.150      apply simp
  44.151      apply (intro arg_cong[where f = Least] ext)
  44.152      apply (auto simp: enumerate_Suc'[symmetric])
  44.153 @@ -354,7 +354,7 @@
  44.154    next
  44.155      assume *: "\<not> (\<exists>y\<in>S. y < s)"
  44.156      then have "\<forall>t\<in>S. s \<le> t" by auto
  44.157 -    with `s \<in> S` show ?thesis
  44.158 +    with \<open>s \<in> S\<close> show ?thesis
  44.159        by (auto intro!: exI[of _ 0] Least_equality simp: enumerate_0)
  44.160    qed
  44.161  qed
  44.162 @@ -365,22 +365,22 @@
  44.163    shows "bij_betw (enumerate S) UNIV S"
  44.164  proof -
  44.165    have "\<And>n m. n \<noteq> m \<Longrightarrow> enumerate S n \<noteq> enumerate S m"
  44.166 -    using enumerate_mono[OF _ `infinite S`] by (auto simp: neq_iff)
  44.167 +    using enumerate_mono[OF _ \<open>infinite S\<close>] by (auto simp: neq_iff)
  44.168    then have "inj (enumerate S)"
  44.169      by (auto simp: inj_on_def)
  44.170    moreover have "\<forall>s \<in> S. \<exists>i. enumerate S i = s"
  44.171      using enumerate_Ex[OF S] by auto
  44.172 -  moreover note `infinite S`
  44.173 +  moreover note \<open>infinite S\<close>
  44.174    ultimately show ?thesis
  44.175      unfolding bij_betw_def by (auto intro: enumerate_in_set)
  44.176  qed
  44.177  
  44.178  subsection "Miscellaneous"
  44.179  
  44.180 -text {*
  44.181 +text \<open>
  44.182    A few trivial lemmas about sets that contain at most one element.
  44.183    These simplify the reasoning about deterministic automata.
  44.184 -*}
  44.185 +\<close>
  44.186  
  44.187  definition atmost_one :: "'a set \<Rightarrow> bool"
  44.188    where "atmost_one S \<longleftrightarrow> (\<forall>x y. x\<in>S \<and> y\<in>S \<longrightarrow> x = y)"
    45.1 --- a/src/HOL/Library/Inner_Product.thy	Wed Jun 17 17:33:22 2015 +0200
    45.2 +++ b/src/HOL/Library/Inner_Product.thy	Wed Jun 17 17:54:09 2015 +0200
    45.3 @@ -2,27 +2,27 @@
    45.4      Author:     Brian Huffman
    45.5  *)
    45.6  
    45.7 -section {* Inner Product Spaces and the Gradient Derivative *}
    45.8 +section \<open>Inner Product Spaces and the Gradient Derivative\<close>
    45.9  
   45.10  theory Inner_Product
   45.11  imports "~~/src/HOL/Complex_Main"
   45.12  begin
   45.13  
   45.14 -subsection {* Real inner product spaces *}
   45.15 +subsection \<open>Real inner product spaces\<close>
   45.16  
   45.17 -text {*
   45.18 +text \<open>
   45.19    Temporarily relax type constraints for @{term "open"},
   45.20    @{term dist}, and @{term norm}.
   45.21 -*}
   45.22 +\<close>
   45.23  
   45.24 -setup {* Sign.add_const_constraint
   45.25 -  (@{const_name "open"}, SOME @{typ "'a::open set \<Rightarrow> bool"}) *}
   45.26 +setup \<open>Sign.add_const_constraint
   45.27 +  (@{const_name "open"}, SOME @{typ "'a::open set \<Rightarrow> bool"})\<close>
   45.28  
   45.29 -setup {* Sign.add_const_constraint
   45.30 -  (@{const_name dist}, SOME @{typ "'a::dist \<Rightarrow> 'a \<Rightarrow> real"}) *}
   45.31 +setup \<open>Sign.add_const_constraint
   45.32 +  (@{const_name dist}, SOME @{typ "'a::dist \<Rightarrow> 'a \<Rightarrow> real"})\<close>
   45.33  
   45.34 -setup {* Sign.add_const_constraint
   45.35 -  (@{const_name norm}, SOME @{typ "'a::norm \<Rightarrow> real"}) *}
   45.36 +setup \<open>Sign.add_const_constraint
   45.37 +  (@{const_name norm}, SOME @{typ "'a::norm \<Rightarrow> real"})\<close>
   45.38  
   45.39  class real_inner = real_vector + sgn_div_norm + dist_norm + open_dist +
   45.40    fixes inner :: "'a \<Rightarrow> 'a \<Rightarrow> real"
   45.41 @@ -46,7 +46,7 @@
   45.42  lemma inner_setsum_left: "inner (\<Sum>x\<in>A. f x) y = (\<Sum>x\<in>A. inner (f x) y)"
   45.43    by (cases "finite A", induct set: finite, simp_all add: inner_add_left)
   45.44  
   45.45 -text {* Transfer distributivity rules to right argument. *}
   45.46 +text \<open>Transfer distributivity rules to right argument.\<close>
   45.47  
   45.48  lemma inner_add_right: "inner x (y + z) = inner x y + inner x z"
   45.49    using inner_add_left [of y z x] by (simp only: inner_commute)
   45.50 @@ -70,7 +70,7 @@
   45.51  lemmas inner_diff [algebra_simps]  = inner_diff_left inner_diff_right
   45.52  lemmas inner_scaleR = inner_scaleR_left inner_scaleR_right
   45.53  
   45.54 -text {* Legacy theorem names *}
   45.55 +text \<open>Legacy theorem names\<close>
   45.56  lemmas inner_left_distrib = inner_add_left
   45.57  lemmas inner_right_distrib = inner_add_right
   45.58  lemmas inner_distrib = inner_left_distrib inner_right_distrib
   45.59 @@ -141,19 +141,19 @@
   45.60  
   45.61  end
   45.62  
   45.63 -text {*
   45.64 +text \<open>
   45.65    Re-enable constraints for @{term "open"},
   45.66    @{term dist}, and @{term norm}.
   45.67 -*}
   45.68 +\<close>
   45.69  
   45.70 -setup {* Sign.add_const_constraint
   45.71 -  (@{const_name "open"}, SOME @{typ "'a::topological_space set \<Rightarrow> bool"}) *}
   45.72 +setup \<open>Sign.add_const_constraint
   45.73 +  (@{const_name "open"}, SOME @{typ "'a::topological_space set \<Rightarrow> bool"})\<close>
   45.74  
   45.75 -setup {* Sign.add_const_constraint
   45.76 -  (@{const_name dist}, SOME @{typ "'a::metric_space \<Rightarrow> 'a \<Rightarrow> real"}) *}
   45.77 +setup \<open>Sign.add_const_constraint
   45.78 +  (@{const_name dist}, SOME @{typ "'a::metric_space \<Rightarrow> 'a \<Rightarrow> real"})\<close>
   45.79  
   45.80 -setup {* Sign.add_const_constraint
   45.81 -  (@{const_name norm}, SOME @{typ "'a::real_normed_vector \<Rightarrow> real"}) *}
   45.82 +setup \<open>Sign.add_const_constraint
   45.83 +  (@{const_name norm}, SOME @{typ "'a::real_normed_vector \<Rightarrow> real"})\<close>
   45.84  
   45.85  lemma bounded_bilinear_inner:
   45.86    "bounded_bilinear (inner::'a::real_inner \<Rightarrow> 'a \<Rightarrow> real)"
   45.87 @@ -199,7 +199,7 @@
   45.88    "f differentiable (at x within s) \<Longrightarrow> g differentiable at x within s \<Longrightarrow> (\<lambda>x. inner (f x) (g x)) differentiable at x within s"
   45.89    unfolding differentiable_def by (blast intro: has_derivative_inner)
   45.90  
   45.91 -subsection {* Class instances *}
   45.92 +subsection \<open>Class instances\<close>
   45.93  
   45.94  instantiation real :: real_inner
   45.95  begin
   45.96 @@ -263,7 +263,7 @@
   45.97    unfolding inner_complex_def by simp
   45.98  
   45.99  
  45.100 -subsection {* Gradient derivative *}
  45.101 +subsection \<open>Gradient derivative\<close>
  45.102  
  45.103  definition
  45.104    gderiv ::
  45.105 @@ -339,7 +339,7 @@
  45.106      by (intro has_derivative_inner has_derivative_ident)
  45.107    have 2: "(\<lambda>h. inner x h + inner h x) = (\<lambda>h. inner h (scaleR 2 x))"
  45.108      by (simp add: fun_eq_iff inner_commute)
  45.109 -  have "0 < inner x x" using `x \<noteq> 0` by simp
  45.110 +  have "0 < inner x x" using \<open>x \<noteq> 0\<close> by simp
  45.111    then have 3: "DERIV sqrt (inner x x) :> (inverse (sqrt (inner x x)) / 2)"
  45.112      by (rule DERIV_real_sqrt)
  45.113    have 4: "(inverse (sqrt (inner x x)) / 2) *\<^sub>R 2 *\<^sub>R x = sgn x"
    46.1 --- a/src/HOL/Library/LaTeXsugar.thy	Wed Jun 17 17:33:22 2015 +0200
    46.2 +++ b/src/HOL/Library/LaTeXsugar.thy	Wed Jun 17 17:54:09 2015 +0200
    46.3 @@ -101,7 +101,7 @@
    46.4    "_asms" :: "prop \<Rightarrow> asms \<Rightarrow> asms" ("_ /\<^raw:{\normalsize \,>and\<^raw:\,}>/ _")
    46.5    "_asm" :: "prop \<Rightarrow> asms" ("_")
    46.6  
    46.7 -setup{*
    46.8 +setup\<open>
    46.9    let
   46.10      fun pretty ctxt c =
   46.11        let val tc = Proof_Context.read_const {proper = true, strict = false} ctxt c
   46.12 @@ -115,7 +115,7 @@
   46.13            Thy_Output.output ctxt
   46.14              (Thy_Output.maybe_pretty_source pretty ctxt src [arg]))
   46.15    end;
   46.16 -*}
   46.17 +\<close>
   46.18  
   46.19  end
   46.20  (*>*)
    47.1 --- a/src/HOL/Library/Lattice_Algebras.thy	Wed Jun 17 17:33:22 2015 +0200
    47.2 +++ b/src/HOL/Library/Lattice_Algebras.thy	Wed Jun 17 17:54:09 2015 +0200
    47.3 @@ -1,6 +1,6 @@
    47.4  (* Author: Steven Obua, TU Muenchen *)
    47.5  
    47.6 -section {* Various algebraic structures combined with a lattice *}
    47.7 +section \<open>Various algebraic structures combined with a lattice\<close>
    47.8  
    47.9  theory Lattice_Algebras
   47.10  imports Complex_Main
   47.11 @@ -110,7 +110,7 @@
   47.12  qed
   47.13  
   47.14  
   47.15 -subsection {* Positive Part, Negative Part, Absolute Value *}
   47.16 +subsection \<open>Positive Part, Negative Part, Absolute Value\<close>
   47.17  
   47.18  definition nprt :: "'a \<Rightarrow> 'a"
   47.19    where "nprt x = inf x 0"
   47.20 @@ -444,7 +444,7 @@
   47.21      by (rule abs_ge_minus_self)
   47.22    then have "c + (- b) \<le> c + \<bar>b\<bar>"
   47.23      by (rule add_left_mono)
   47.24 -  with `a \<le> c + (- b)` show ?thesis
   47.25 +  with \<open>a \<le> c + (- b)\<close> show ?thesis
   47.26      by (rule order_trans)
   47.27  qed
   47.28  
    48.1 --- a/src/HOL/Library/Lattice_Constructions.thy	Wed Jun 17 17:33:22 2015 +0200
    48.2 +++ b/src/HOL/Library/Lattice_Constructions.thy	Wed Jun 17 17:54:09 2015 +0200
    48.3 @@ -7,7 +7,7 @@
    48.4  imports Main
    48.5  begin
    48.6  
    48.7 -subsection {* Values extended by a bottom element *}
    48.8 +subsection \<open>Values extended by a bottom element\<close>
    48.9  
   48.10  datatype 'a bot = Value 'a | Bot
   48.11  
   48.12 @@ -106,7 +106,7 @@
   48.13  instance bot :: (lattice) bounded_lattice_bot
   48.14  by(intro_classes)(simp add: bot_bot_def)
   48.15  
   48.16 -section {* Values extended by a top element *}
   48.17 +section \<open>Values extended by a top element\<close>
   48.18  
   48.19  datatype 'a top = Value 'a | Top
   48.20  
   48.21 @@ -205,7 +205,7 @@
   48.22  instance top :: (lattice) bounded_lattice_top
   48.23  by(intro_classes)(simp add: top_top_def)
   48.24  
   48.25 -subsection {* Values extended by a top and a bottom element *}
   48.26 +subsection \<open>Values extended by a top and a bottom element\<close>
   48.27  
   48.28  datatype 'a flat_complete_lattice = Value 'a | Bot | Top
   48.29  
   48.30 @@ -296,12 +296,12 @@
   48.31      from this have "(THE v. A - {Top} = {Value v}) = v"
   48.32        by (auto intro!: the1_equality)
   48.33      moreover
   48.34 -    from `x : A` `A - {Top} = {Value v}` have "x = Top \<or> x = Value v"
   48.35 +    from \<open>x : A\<close> \<open>A - {Top} = {Value v}\<close> have "x = Top \<or> x = Value v"
   48.36        by auto
   48.37      ultimately have "Value (THE v. A - {Top} = {Value v}) <= x"
   48.38        by auto
   48.39    }
   48.40 -  from `x : A` this show "Inf A <= x"
   48.41 +  from \<open>x : A\<close> this show "Inf A <= x"
   48.42      unfolding Inf_flat_complete_lattice_def
   48.43      by fastforce
   48.44  next
   48.45 @@ -355,12 +355,12 @@
   48.46      from this have "(THE v. A - {Bot} = {Value v}) = v"
   48.47        by (auto intro!: the1_equality)
   48.48      moreover
   48.49 -    from `x : A` `A - {Bot} = {Value v}` have "x = Bot \<or> x = Value v"
   48.50 +    from \<open>x : A\<close> \<open>A - {Bot} = {Value v}\<close> have "x = Bot \<or> x = Value v"
   48.51        by auto
   48.52      ultimately have "x <= Value (THE v. A - {Bot} = {Value v})"
   48.53        by auto
   48.54    }
   48.55 -  from `x : A` this show "x <= Sup A"
   48.56 +  from \<open>x : A\<close> this show "x <= Sup A"
   48.57      unfolding Sup_flat_complete_lattice_def
   48.58      by fastforce
   48.59  next
    49.1 --- a/src/HOL/Library/Lattice_Syntax.thy	Wed Jun 17 17:33:22 2015 +0200
    49.2 +++ b/src/HOL/Library/Lattice_Syntax.thy	Wed Jun 17 17:54:09 2015 +0200
    49.3 @@ -1,6 +1,6 @@
    49.4  (* Author: Florian Haftmann, TU Muenchen *)
    49.5  
    49.6 -section {* Pretty syntax for lattice operations *}
    49.7 +section \<open>Pretty syntax for lattice operations\<close>
    49.8  
    49.9  theory Lattice_Syntax
   49.10  imports Complete_Lattices
    50.1 --- a/src/HOL/Library/Liminf_Limsup.thy	Wed Jun 17 17:33:22 2015 +0200
    50.2 +++ b/src/HOL/Library/Liminf_Limsup.thy	Wed Jun 17 17:54:09 2015 +0200
    50.3 @@ -2,7 +2,7 @@
    50.4      Author:     Johannes Hölzl, TU München
    50.5  *)
    50.6  
    50.7 -section {* Liminf and Limsup on complete lattices *}
    50.8 +section \<open>Liminf and Limsup on complete lattices\<close>
    50.9  
   50.10  theory Liminf_Limsup
   50.11  imports Complex_Main
   50.12 @@ -30,7 +30,7 @@
   50.13    shows "(INF i : A. INF j : B. f i j) = (INF p : A \<times> B. f (fst p) (snd p))"
   50.14    by (rule antisym) (auto intro!: INF_greatest INF_lower2)
   50.15  
   50.16 -subsubsection {* @{text Liminf} and @{text Limsup} *}
   50.17 +subsubsection \<open>@{text Liminf} and @{text Limsup}\<close>
   50.18  
   50.19  definition Liminf :: "'a filter \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b :: complete_lattice" where
   50.20    "Liminf F f = (SUP P:{P. eventually P F}. INF x:{x. P x}. f x)"
   50.21 @@ -171,7 +171,7 @@
   50.22        case False
   50.23        then have "C \<le> INFIMUM {x. y < X x} X"
   50.24          by (intro INF_greatest) auto
   50.25 -      with `y < C` show ?thesis
   50.26 +      with \<open>y < C\<close> show ?thesis
   50.27          using y by (intro exI[of _ "\<lambda>x. y < X x"]) auto
   50.28      qed }
   50.29    ultimately show ?thesis
   50.30 @@ -290,7 +290,7 @@
   50.31    have "\<And>n. (INF m:{n..}. X m) \<le> (INF m:{n..}. (X \<circ> r) m)"
   50.32    proof (safe intro!: INF_mono)
   50.33      fix n m :: nat assume "n \<le> m" then show "\<exists>ma\<in>{n..}. X ma \<le> (X \<circ> r) m"
   50.34 -      using seq_suble[OF `subseq r`, of m] by (intro bexI[of _ "r m"]) auto
   50.35 +      using seq_suble[OF \<open>subseq r\<close>, of m] by (intro bexI[of _ "r m"]) auto
   50.36    qed
   50.37    then show ?thesis by (auto intro!: SUP_mono simp: liminf_SUP_INF comp_def)
   50.38  qed
   50.39 @@ -303,7 +303,7 @@
   50.40    have "\<And>n. (SUP m:{n..}. (X \<circ> r) m) \<le> (SUP m:{n..}. X m)"
   50.41    proof (safe intro!: SUP_mono)
   50.42      fix n m :: nat assume "n \<le> m" then show "\<exists>ma\<in>{n..}. (X \<circ> r) m \<le> X ma"
   50.43 -      using seq_suble[OF `subseq r`, of m] by (intro bexI[of _ "r m"]) auto
   50.44 +      using seq_suble[OF \<open>subseq r\<close>, of m] by (intro bexI[of _ "r m"]) auto
   50.45    qed
   50.46    then show ?thesis by (auto intro!: INF_mono simp: limsup_INF_SUP comp_def)
   50.47  qed
    51.1 --- a/src/HOL/Library/Linear_Temporal_Logic_on_Streams.thy	Wed Jun 17 17:33:22 2015 +0200
    51.2 +++ b/src/HOL/Library/Linear_Temporal_Logic_on_Streams.thy	Wed Jun 17 17:54:09 2015 +0200
    51.3 @@ -3,13 +3,13 @@
    51.4      Author:     Dmitriy Traytel, TU Muenchen
    51.5  *)
    51.6  
    51.7 -section {* Linear Temporal Logic on Streams *}
    51.8 +section \<open>Linear Temporal Logic on Streams\<close>
    51.9  
   51.10  theory Linear_Temporal_Logic_on_Streams
   51.11    imports Stream Sublist Extended_Nat Infinite_Set
   51.12  begin
   51.13  
   51.14 -section{* Preliminaries *}
   51.15 +section\<open>Preliminaries\<close>
   51.16  
   51.17  lemma shift_prefix:
   51.18  assumes "xl @- xs = yl @- ys" and "length xl \<le> length yl"
   51.19 @@ -26,7 +26,7 @@
   51.20  by (metis, metis assms nat_le_linear shift_prefix)
   51.21  
   51.22  
   51.23 -section{* Linear temporal logic *}
   51.24 +section\<open>Linear temporal logic\<close>
   51.25  
   51.26  (* Propositional connectives: *)
   51.27  abbreviation (input) IMPL (infix "impl" 60)
   51.28 @@ -587,7 +587,7 @@
   51.29  lemma not_holds_eq[simp]: "holds (- op = x) = not (HLD {x})"
   51.30    by rule (auto simp: HLD_iff)
   51.31  
   51.32 -text {* Strong until *}
   51.33 +text \<open>Strong until\<close>
   51.34  
   51.35  inductive suntil (infix "suntil" 60) for \<phi> \<psi> where
   51.36    base: "\<psi> \<omega> \<Longrightarrow> (\<phi> suntil \<psi>) \<omega>"
    52.1 --- a/src/HOL/Library/ListVector.thy	Wed Jun 17 17:33:22 2015 +0200
    52.2 +++ b/src/HOL/Library/ListVector.thy	Wed Jun 17 17:54:09 2015 +0200
    52.3 @@ -1,16 +1,16 @@
    52.4  (*  Author: Tobias Nipkow, 2007 *)
    52.5  
    52.6 -section {* Lists as vectors *}
    52.7 +section \<open>Lists as vectors\<close>
    52.8  
    52.9  theory ListVector
   52.10  imports List Main
   52.11  begin
   52.12  
   52.13 -text{* \noindent
   52.14 +text\<open>\noindent
   52.15  A vector-space like structure of lists and arithmetic operations on them.
   52.16 -Is only a vector space if restricted to lists of the same length. *}
   52.17 +Is only a vector space if restricted to lists of the same length.\<close>
   52.18  
   52.19 -text{* Multiplication with a scalar: *}
   52.20 +text\<open>Multiplication with a scalar:\<close>
   52.21  
   52.22  abbreviation scale :: "('a::times) \<Rightarrow> 'a list \<Rightarrow> 'a list" (infix "*\<^sub>s" 70)
   52.23  where "x *\<^sub>s xs \<equiv> map (op * x) xs"
   52.24 @@ -18,7 +18,7 @@
   52.25  lemma scale1[simp]: "(1::'a::monoid_mult) *\<^sub>s xs = xs"
   52.26  by (induct xs) simp_all
   52.27  
   52.28 -subsection {* @{text"+"} and @{text"-"} *}
   52.29 +subsection \<open>@{text"+"} and @{text"-"}\<close>
   52.30  
   52.31  fun zipwith0 :: "('a::zero \<Rightarrow> 'b::zero \<Rightarrow> 'c) \<Rightarrow> 'a list \<Rightarrow> 'b list \<Rightarrow> 'c list"
   52.32  where
    53.1 --- a/src/HOL/Library/List_lexord.thy	Wed Jun 17 17:33:22 2015 +0200
    53.2 +++ b/src/HOL/Library/List_lexord.thy	Wed Jun 17 17:54:09 2015 +0200
    53.3 @@ -2,7 +2,7 @@
    53.4      Author:     Norbert Voelker
    53.5  *)
    53.6  
    53.7 -section {* Lexicographic order on lists *}
    53.8 +section \<open>Lexicographic order on lists\<close>
    53.9  
   53.10  theory List_lexord
   53.11  imports Main
    54.1 --- a/src/HOL/Library/Lub_Glb.thy	Wed Jun 17 17:33:22 2015 +0200
    54.2 +++ b/src/HOL/Library/Lub_Glb.thy	Wed Jun 17 17:54:09 2015 +0200
    54.3 @@ -2,13 +2,13 @@
    54.4      Author:     Jacques D. Fleuriot, University of Cambridge
    54.5      Author:     Amine Chaieb, University of Cambridge *)
    54.6  
    54.7 -section {* Definitions of Least Upper Bounds and Greatest Lower Bounds *}
    54.8 +section \<open>Definitions of Least Upper Bounds and Greatest Lower Bounds\<close>
    54.9  
   54.10  theory Lub_Glb
   54.11  imports Complex_Main
   54.12  begin
   54.13  
   54.14 -text {* Thanks to suggestions by James Margetson *}
   54.15 +text \<open>Thanks to suggestions by James Margetson\<close>
   54.16  
   54.17  definition setle :: "'a set \<Rightarrow> 'a::ord \<Rightarrow> bool"  (infixl "*<=" 70)
   54.18    where "S *<= x = (ALL y: S. y \<le> x)"
   54.19 @@ -17,7 +17,7 @@
   54.20    where "x <=* S = (ALL y: S. x \<le> y)"
   54.21  
   54.22  
   54.23 -subsection {* Rules for the Relations @{text "*<="} and @{text "<=*"} *}
   54.24 +subsection \<open>Rules for the Relations @{text "*<="} and @{text "<=*"}\<close>
   54.25  
   54.26  lemma setleI: "ALL y: S. y \<le> x \<Longrightarrow> S *<= x"
   54.27    by (simp add: setle_def)
   54.28 @@ -45,7 +45,7 @@
   54.29    where "ubs R S = Collect (isUb R S)"
   54.30  
   54.31  
   54.32 -subsection {* Rules about the Operators @{term leastP}, @{term ub} and @{term lub} *}
   54.33 +subsection \<open>Rules about the Operators @{term leastP}, @{term ub} and @{term lub}\<close>
   54.34  
   54.35  lemma leastPD1: "leastP P x \<Longrightarrow> P x"
   54.36    by (simp add: leastP_def)
   54.37 @@ -118,7 +118,7 @@
   54.38    where "lbs R S = Collect (isLb R S)"
   54.39  
   54.40  
   54.41 -subsection {* Rules about the Operators @{term greatestP}, @{term isLb} and @{term isGlb} *}
   54.42 +subsection \<open>Rules about the Operators @{term greatestP}, @{term isLb} and @{term isGlb}\<close>
   54.43  
   54.44  lemma greatestPD1: "greatestP P x \<Longrightarrow> P x"
   54.45    by (simp add: greatestP_def)
   54.46 @@ -208,7 +208,7 @@
   54.47  lemma cInf_unique: "b <=* (S::'a :: {conditionally_complete_linorder, no_top} set) \<Longrightarrow> (\<forall>b'>b. \<exists>x\<in>S. b' > x) \<Longrightarrow> Inf S = b"
   54.48    by (rule cInf_eq) (auto simp: not_le[symmetric] setge_def)
   54.49  
   54.50 -text{* Use completeness of reals (supremum property) to show that any bounded sequence has a least upper bound*}
   54.51 +text\<open>Use completeness of reals (supremum property) to show that any bounded sequence has a least upper bound\<close>
   54.52  
   54.53  lemma reals_complete: "\<exists>X. X \<in> S \<Longrightarrow> \<exists>Y. isUb (UNIV::real set) S Y \<Longrightarrow> \<exists>t. isLub (UNIV :: real set) S t"
   54.54    by (intro exI[of _ "Sup S"] isLub_cSup) (auto simp: setle_def isUb_def intro!: cSup_upper)
    55.1 --- a/src/HOL/Library/Mapping.thy	Wed Jun 17 17:33:22 2015 +0200
    55.2 +++ b/src/HOL/Library/Mapping.thy	Wed Jun 17 17:54:09 2015 +0200
    55.3 @@ -2,15 +2,15 @@
    55.4      Author:     Florian Haftmann and Ondrej Kuncar
    55.5  *)
    55.6  
    55.7 -section {* An abstract view on maps for code generation. *}
    55.8 +section \<open>An abstract view on maps for code generation.\<close>
    55.9  
   55.10  theory Mapping
   55.11  imports Main
   55.12  begin
   55.13  
   55.14 -subsection {* Parametricity transfer rules *}
   55.15 +subsection \<open>Parametricity transfer rules\<close>
   55.16  
   55.17 -lemma map_of_foldr: -- {* FIXME move *}
   55.18 +lemma map_of_foldr: -- \<open>FIXME move\<close>
   55.19    "map_of xs = foldr (\<lambda>(k, v) m. m(k \<mapsto> v)) xs Map.empty"
   55.20    using map_add_map_of_foldr [of Map.empty] by auto
   55.21  
   55.22 @@ -92,7 +92,7 @@
   55.23  end
   55.24  
   55.25  
   55.26 -subsection {* Type definition and primitive operations *}
   55.27 +subsection \<open>Type definition and primitive operations\<close>
   55.28  
   55.29  typedef ('a, 'b) mapping = "UNIV :: ('a \<rightharpoonup> 'b) set"
   55.30    morphisms rep Mapping
   55.31 @@ -130,13 +130,13 @@
   55.32  declare [[code drop: map]]
   55.33  
   55.34  
   55.35 -subsection {* Functorial structure *}
   55.36 +subsection \<open>Functorial structure\<close>
   55.37  
   55.38  functor map: map
   55.39    by (transfer, auto simp add: fun_eq_iff option.map_comp option.map_id)+
   55.40  
   55.41  
   55.42 -subsection {* Derived operations *}
   55.43 +subsection \<open>Derived operations\<close>
   55.44  
   55.45  definition ordered_keys :: "('a\<Colon>linorder, 'b) mapping \<Rightarrow> 'a list"
   55.46  where
   55.47 @@ -158,7 +158,7 @@
   55.48  where
   55.49    "default k v m = (if k \<in> keys m then m else update k v m)"
   55.50  
   55.51 -text {* Manual derivation of transfer rule is non-trivial *}
   55.52 +text \<open>Manual derivation of transfer rule is non-trivial\<close>
   55.53  
   55.54  lift_definition map_entry :: "'a \<Rightarrow> ('b \<Rightarrow> 'b) \<Rightarrow> ('a, 'b) mapping \<Rightarrow> ('a, 'b) mapping" is
   55.55    "\<lambda>k f m. (case m k of None \<Rightarrow> m
   55.56 @@ -207,7 +207,7 @@
   55.57  end
   55.58  
   55.59  
   55.60 -subsection {* Properties *}
   55.61 +subsection \<open>Properties\<close>
   55.62  
   55.63  lemma lookup_update:
   55.64    "lookup (update k v m) k = Some v" 
   55.65 @@ -408,7 +408,7 @@
   55.66  qed
   55.67  
   55.68  
   55.69 -subsection {* Code generator setup *}
   55.70 +subsection \<open>Code generator setup\<close>
   55.71  
   55.72  hide_const (open) empty is_empty rep lookup update delete ordered_keys keys size
   55.73    replace default map_entry map_default tabulate bulkload map of_alist
    56.1 --- a/src/HOL/Library/Monad_Syntax.thy	Wed Jun 17 17:33:22 2015 +0200
    56.2 +++ b/src/HOL/Library/Monad_Syntax.thy	Wed Jun 17 17:54:09 2015 +0200
    56.3 @@ -2,17 +2,17 @@
    56.4     Author: Christian Sternagel, University of Innsbruck
    56.5  *)
    56.6  
    56.7 -section {* Monad notation for arbitrary types *}
    56.8 +section \<open>Monad notation for arbitrary types\<close>
    56.9  
   56.10  theory Monad_Syntax
   56.11  imports Main "~~/src/Tools/Adhoc_Overloading"
   56.12  begin
   56.13  
   56.14 -text {*
   56.15 +text \<open>
   56.16    We provide a convenient do-notation for monadic expressions
   56.17    well-known from Haskell.  @{const Let} is printed
   56.18    specially in do-expressions.
   56.19 -*}
   56.20 +\<close>
   56.21  
   56.22  consts
   56.23    bind :: "['a, 'b \<Rightarrow> 'c] \<Rightarrow> 'd" (infixr ">>=" 54)
    57.1 --- a/src/HOL/Library/More_List.thy	Wed Jun 17 17:33:22 2015 +0200
    57.2 +++ b/src/HOL/Library/More_List.thy	Wed Jun 17 17:54:09 2015 +0200
    57.3 @@ -304,7 +304,7 @@
    57.4        with last_conv_nth_default [of ?ys dflt]
    57.5        have "last ?ys = nth_default dflt ?ys (length ?ys - 1)"
    57.6          by auto
    57.7 -      moreover from `?ys \<noteq> []` no_trailing_strip_while [of "HOL.eq dflt" ys]
    57.8 +      moreover from \<open>?ys \<noteq> []\<close> no_trailing_strip_while [of "HOL.eq dflt" ys]
    57.9          have "last ?ys \<noteq> dflt" by (simp add: no_trailing_unfold)
   57.10        ultimately have "nth_default dflt ?xs (length ?ys - 1) \<noteq> dflt"
   57.11          using eq by simp
    58.1 --- a/src/HOL/Library/Multiset.thy	Wed Jun 17 17:33:22 2015 +0200
    58.2 +++ b/src/HOL/Library/Multiset.thy	Wed Jun 17 17:54:09 2015 +0200
    58.3 @@ -6,13 +6,13 @@
    58.4      Author:     Mathias Fleury, MPII
    58.5  *)
    58.6  
    58.7 -section {* (Finite) multisets *}
    58.8 +section \<open>(Finite) multisets\<close>
    58.9  
   58.10  theory Multiset
   58.11  imports Main
   58.12  begin
   58.13  
   58.14 -subsection {* The type of multisets *}
   58.15 +subsection \<open>The type of multisets\<close>
   58.16  
   58.17  definition "multiset = {f :: 'a => nat. finite {x. f x > 0}}"
   58.18  
   58.19 @@ -39,9 +39,9 @@
   58.20    "(\<And>x. count A x = count B x) \<Longrightarrow> A = B"
   58.21    using multiset_eq_iff by auto
   58.22  
   58.23 -text {*
   58.24 +text \<open>
   58.25   \medskip Preservation of the representing set @{term multiset}.
   58.26 -*}
   58.27 +\<close>
   58.28  
   58.29  lemma const0_in_multiset:
   58.30    "(\<lambda>a. 0) \<in> multiset"
   58.31 @@ -79,9 +79,9 @@
   58.32    union_preserves_multiset diff_preserves_multiset filter_preserves_multiset
   58.33  
   58.34  
   58.35 -subsection {* Representing multisets *}
   58.36 -
   58.37 -text {* Multiset enumeration *}
   58.38 +subsection \<open>Representing multisets\<close>
   58.39 +
   58.40 +text \<open>Multiset enumeration\<close>
   58.41  
   58.42  instantiation multiset :: (type) cancel_comm_monoid_add
   58.43  begin
   58.44 @@ -119,15 +119,15 @@
   58.45    by (simp add: single.rep_eq)
   58.46  
   58.47  
   58.48 -subsection {* Basic operations *}
   58.49 -
   58.50 -subsubsection {* Union *}
   58.51 +subsection \<open>Basic operations\<close>
   58.52 +
   58.53 +subsubsection \<open>Union\<close>
   58.54  
   58.55  lemma count_union [simp]: "count (M + N) a = count M a + count N a"
   58.56    by (simp add: plus_multiset.rep_eq)
   58.57  
   58.58  
   58.59 -subsubsection {* Difference *}
   58.60 +subsubsection \<open>Difference\<close>
   58.61  
   58.62  instantiation multiset :: (type) comm_monoid_diff
   58.63  begin
   58.64 @@ -177,7 +177,7 @@
   58.65    by (simp add: multiset_eq_iff)
   58.66  
   58.67  
   58.68 -subsubsection {* Equality of multisets *}
   58.69 +subsubsection \<open>Equality of multisets\<close>
   58.70  
   58.71  lemma single_not_empty [simp]: "{#a#} \<noteq> {#} \<and> {#} \<noteq> {#a#}"
   58.72    by (simp add: multiset_eq_iff)
   58.73 @@ -234,12 +234,12 @@
   58.74    assume ?lhs
   58.75    show ?rhs
   58.76    proof (cases "a = b")
   58.77 -    case True with `?lhs` show ?thesis by simp
   58.78 +    case True with \<open>?lhs\<close> show ?thesis by simp
   58.79    next
   58.80      case False
   58.81 -    from `?lhs` have "a \<in># N + {#b#}" by (rule union_single_eq_member)
   58.82 +    from \<open>?lhs\<close> have "a \<in># N + {#b#}" by (rule union_single_eq_member)
   58.83      with False have "a \<in># N" by auto
   58.84 -    moreover from `?lhs` have "M = N + {#b#} - {#a#}" by (rule union_single_eq_diff)
   58.85 +    moreover from \<open>?lhs\<close> have "M = N + {#b#} - {#a#}" by (rule union_single_eq_diff)
   58.86      moreover note False
   58.87      ultimately show ?thesis by (auto simp add: diff_right_commute [of _ "{#a#}"] diff_union_swap)
   58.88    qed
   58.89 @@ -269,7 +269,7 @@
   58.90    assumes "c \<in># B" and "b \<noteq> c"
   58.91    shows "B - {#c#} + {#b#} = B + {#b#} - {#c#}"
   58.92  proof -
   58.93 -  from `c \<in># B` obtain A where B: "B = A + {#c#}"
   58.94 +  from \<open>c \<in># B\<close> obtain A where B: "B = A + {#c#}"
   58.95      by (blast dest: multi_member_split)
   58.96    have "A + {#b#} = A + {#b#} + {#c#} - {#c#}" by simp
   58.97    then have "A + {#b#} = A + {#c#} + {#b#} - {#c#}"
   58.98 @@ -278,7 +278,7 @@
   58.99  qed
  58.100  
  58.101  
  58.102 -subsubsection {* Pointwise ordering induced by count *}
  58.103 +subsubsection \<open>Pointwise ordering induced by count\<close>
  58.104  
  58.105  definition subseteq_mset :: "'a multiset \<Rightarrow> 'a multiset \<Rightarrow> bool" (infix "<=#" 50) where
  58.106  "subseteq_mset A B = (\<forall>a. count A a \<le> count B a)"
  58.107 @@ -396,7 +396,7 @@
  58.108    by (auto simp: subset_mset_def subseteq_mset_def multiset_eq_iff)
  58.109  
  58.110  
  58.111 -subsubsection {* Intersection *}
  58.112 +subsubsection \<open>Intersection\<close>
  58.113  
  58.114  definition inf_subset_mset :: "'a multiset \<Rightarrow> 'a multiset \<Rightarrow> 'a multiset" (infixl "#\<inter>" 70) where
  58.115    multiset_inter_def: "inf_subset_mset A B = A - (A - B)"
  58.116 @@ -454,7 +454,7 @@
  58.117    by (simp add: multiset_eq_iff)
  58.118  
  58.119  
  58.120 -subsubsection {* Bounded union *}
  58.121 +subsubsection \<open>Bounded union\<close>
  58.122  definition sup_subset_mset :: "'a multiset \<Rightarrow> 'a multiset \<Rightarrow> 'a multiset"(infixl "#\<union>" 70)  where
  58.123    "sup_subset_mset A B = A + (B - A)"
  58.124  
  58.125 @@ -493,12 +493,12 @@
  58.126    "x \<in># N \<Longrightarrow> N #\<union> (M + {#x#}) = ((N - {#x#}) #\<union> M) + {#x#}"
  58.127    by (simp add: multiset_eq_iff)
  58.128  
  58.129 -subsubsection {*Subset is an order*}
  58.130 +subsubsection \<open>Subset is an order\<close>
  58.131  interpretation subset_mset: order "op \<le>#" "op <#" by unfold_locales auto
  58.132  
  58.133 -subsubsection {* Filter (with comprehension syntax) *}
  58.134 -
  58.135 -text {* Multiset comprehension *}
  58.136 +subsubsection \<open>Filter (with comprehension syntax)\<close>
  58.137 +
  58.138 +text \<open>Multiset comprehension\<close>
  58.139  
  58.140  lift_definition filter_mset :: "('a \<Rightarrow> bool) \<Rightarrow> 'a multiset \<Rightarrow> 'a multiset"
  58.141  is "\<lambda>P M. \<lambda>x. if P x then M x else 0"
  58.142 @@ -547,7 +547,7 @@
  58.143    "{#x \<in># M. P#}" == "CONST filter_mset (\<lambda>x. P) M"
  58.144  
  58.145  
  58.146 -subsubsection {* Set of elements *}
  58.147 +subsubsection \<open>Set of elements\<close>
  58.148  
  58.149  definition set_mset :: "'a multiset => 'a set" where
  58.150    "set_mset M = {x. x :# M}"
  58.151 @@ -583,7 +583,7 @@
  58.152    by auto
  58.153  
  58.154  
  58.155 -subsubsection {* Size *}
  58.156 +subsubsection \<open>Size\<close>
  58.157  
  58.158  definition wcount where "wcount f M = (\<lambda>x. count M x * Suc (f x))"
  58.159  
  58.160 @@ -673,7 +673,7 @@
  58.161    "M \<le># M' \<Longrightarrow> size (M' - M) = size M' - size(M::'a multiset)"
  58.162  by (metis add_diff_cancel_left' size_union mset_le_exists_conv)
  58.163  
  58.164 -subsection {* Induction and case splits *}
  58.165 +subsection \<open>Induction and case splits\<close>
  58.166  
  58.167  theorem multiset_induct [case_names empty add, induct type: multiset]:
  58.168    assumes empty: "P {#}"
  58.169 @@ -684,7 +684,7 @@
  58.170  next
  58.171    case (Suc k)
  58.172    obtain N x where "M = N + {#x#}"
  58.173 -    using `Suc k = size M` [symmetric]
  58.174 +    using \<open>Suc k = size M\<close> [symmetric]
  58.175      using size_eq_Suc_imp_eq_union by fast
  58.176    with Suc add show "P M" by simp
  58.177  qed
  58.178 @@ -729,9 +729,9 @@
  58.179  lemma size_1_singleton_mset: "size M = 1 \<Longrightarrow> \<exists>a. M = {#a#}"
  58.180  by (cases M) auto
  58.181  
  58.182 -subsubsection {* Strong induction and subset induction for multisets *}
  58.183 -
  58.184 -text {* Well-foundedness of strict subset relation *}
  58.185 +subsubsection \<open>Strong induction and subset induction for multisets\<close>
  58.186 +
  58.187 +text \<open>Well-foundedness of strict subset relation\<close>
  58.188  
  58.189  lemma wf_less_mset_rel: "wf {(M, N :: 'a multiset). M <# N}"
  58.190  apply (rule wf_measure [THEN wf_subset, where f1=size])
  58.191 @@ -751,7 +751,7 @@
  58.192    and insert: "\<And>a F. a \<in># A \<Longrightarrow> P F \<Longrightarrow> P (F + {#a#})"
  58.193  shows "P F"
  58.194  proof -
  58.195 -  from `F \<le># A`
  58.196 +  from \<open>F \<le># A\<close>
  58.197    show ?thesis
  58.198    proof (induct F)
  58.199      show "P {#}" by fact
  58.200 @@ -768,7 +768,7 @@
  58.201  qed
  58.202  
  58.203  
  58.204 -subsection {* The fold combinator *}
  58.205 +subsection \<open>The fold combinator\<close>
  58.206  
  58.207  definition fold_mset :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a multiset \<Rightarrow> 'b"
  58.208  where
  58.209 @@ -840,7 +840,7 @@
  58.210  
  58.211  end
  58.212  
  58.213 -text {*
  58.214 +text \<open>
  58.215    A note on code generation: When defining some function containing a
  58.216    subterm @{term "fold_mset F"}, code generation is not automatic. When
  58.217    interpreting locale @{text left_commutative} with @{text F}, the
  58.218 @@ -849,10 +849,10 @@
  58.219    contains defined symbols, i.e.\ is not a code thm. Hence a separate
  58.220    constant with its own code thms needs to be introduced for @{text
  58.221    F}. See the image operator below.
  58.222 -*}
  58.223 -
  58.224 -
  58.225 -subsection {* Image *}
  58.226 +\<close>
  58.227 +
  58.228 +
  58.229 +subsection \<open>Image\<close>
  58.230  
  58.231  definition image_mset :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a multiset \<Rightarrow> 'b multiset" where
  58.232    "image_mset f = fold_mset (plus o single o f) {#}"
  58.233 @@ -920,12 +920,12 @@
  58.234  translations
  58.235    "{#e | x\<in>#M. P#}" => "{#e. x \<in># {# x\<in>#M. P#}#}"
  58.236  
  58.237 -text {*
  58.238 +text \<open>
  58.239    This allows to write not just filters like @{term "{#x:#M. x<c#}"}
  58.240    but also images like @{term "{#x+x. x:#M #}"} and @{term [source]
  58.241    "{#x+x|x:#M. x<c#}"}, where the latter is currently displayed as
  58.242    @{term "{#x+x|x:#M. x<c#}"}.
  58.243 -*}
  58.244 +\<close>
  58.245  
  58.246  lemma in_image_mset: "y \<in># {#f x. x \<in># M#} \<longleftrightarrow> y \<in> f ` set_mset M"
  58.247    by (metis mem_set_mset_iff set_mset_image_mset)
  58.248 @@ -961,7 +961,7 @@
  58.249    by (metis image_mset_cong split_cong)
  58.250  
  58.251  
  58.252 -subsection {* Further conversions *}
  58.253 +subsection \<open>Further conversions\<close>
  58.254  
  58.255  primrec multiset_of :: "'a list \<Rightarrow> 'a multiset" where
  58.256    "multiset_of [] = {#}" |
  58.257 @@ -1117,12 +1117,12 @@
  58.258      proof (cases "finite A")
  58.259        case False then show ?thesis by simp
  58.260      next
  58.261 -      case True from True `x \<notin> A` show ?thesis by (induct A) auto
  58.262 +      case True from True \<open>x \<notin> A\<close> show ?thesis by (induct A) auto
  58.263      qed
  58.264    } note * = this
  58.265    then show "PROP ?P" "PROP ?Q" "PROP ?R"
  58.266    by (auto elim!: Set.set_insert)
  58.267 -qed -- {* TODO: maybe define @{const multiset_of_set} also in terms of @{const Abs_multiset} *}
  58.268 +qed -- \<open>TODO: maybe define @{const multiset_of_set} also in terms of @{const Abs_multiset}\<close>
  58.269  
  58.270  lemma elem_multiset_of_set[simp, intro]: "finite A \<Longrightarrow> x \<in># multiset_of_set A \<longleftrightarrow> x \<in> A"
  58.271    by (induct A rule: finite_induct) simp_all
  58.272 @@ -1181,7 +1181,7 @@
  58.273    by (cases "finite A") (induct A rule: finite_induct, simp_all add: ac_simps)
  58.274  
  58.275  
  58.276 -subsection {* Big operators *}
  58.277 +subsection \<open>Big operators\<close>
  58.278  
  58.279  no_notation times (infixl "*" 70)
  58.280  no_notation Groups.one ("1")
  58.281 @@ -1350,7 +1350,7 @@
  58.282  qed
  58.283  
  58.284  
  58.285 -subsection {* Replicate operation *}
  58.286 +subsection \<open>Replicate operation\<close>
  58.287  
  58.288  definition replicate_mset :: "nat \<Rightarrow> 'a \<Rightarrow> 'a multiset" where
  58.289    "replicate_mset n x = ((op + {#x#}) ^^ n) {#}"
  58.290 @@ -1381,9 +1381,9 @@
  58.291    by (induct D) simp_all
  58.292  
  58.293  
  58.294 -subsection {* Alternative representations *}
  58.295 -
  58.296 -subsubsection {* Lists *}
  58.297 +subsection \<open>Alternative representations\<close>
  58.298 +
  58.299 +subsubsection \<open>Lists\<close>
  58.300  
  58.301  context linorder
  58.302  begin
  58.303 @@ -1396,10 +1396,10 @@
  58.304    "multiset_of (sort_key k xs) = multiset_of xs"
  58.305    by (induct xs) (simp_all add: ac_simps)
  58.306  
  58.307 -text {*
  58.308 +text \<open>
  58.309    This lemma shows which properties suffice to show that a function
  58.310    @{text "f"} with @{text "f xs = ys"} behaves like sort.
  58.311 -*}
  58.312 +\<close>
  58.313  
  58.314  lemma properties_for_sort_key:
  58.315    assumes "multiset_of ys = multiset_of xs"
  58.316 @@ -1427,7 +1427,7 @@
  58.317    shows "sort xs = ys"
  58.318  proof (rule properties_for_sort_key)
  58.319    from multiset show "multiset_of ys = multiset_of xs" .
  58.320 -  from `sorted ys` show "sorted (map (\<lambda>x. x) ys)" by simp
  58.321 +  from \<open>sorted ys\<close> show "sorted (map (\<lambda>x. x) ys)" by simp
  58.322    from multiset have "\<And>k. length (filter (\<lambda>y. k = y) ys) = length (filter (\<lambda>x. k = x) xs)"
  58.323      by (rule multiset_of_eq_length_filter)
  58.324    then have "\<And>k. replicate (length (filter (\<lambda>y. k = y) ys)) k = replicate (length (filter (\<lambda>x. k = x) xs)) k"
  58.325 @@ -1481,7 +1481,7 @@
  58.326      @ sort [x\<leftarrow>xs. x > xs ! (length xs div 2)]" (is "sort ?lhs = ?rhs")
  58.327    using sort_key_by_quicksort [of "\<lambda>x. x", symmetric] by simp
  58.328  
  58.329 -text {* A stable parametrized quicksort *}
  58.330 +text \<open>A stable parametrized quicksort\<close>
  58.331  
  58.332  definition part :: "('b \<Rightarrow> 'a) \<Rightarrow> 'a \<Rightarrow> 'b list \<Rightarrow> 'b list \<times> 'b list \<times> 'b list" where
  58.333    "part f pivot xs = ([x \<leftarrow> xs. f x < pivot], [x \<leftarrow> xs. f x = pivot], [x \<leftarrow> xs. pivot < f x])"
  58.334 @@ -1557,9 +1557,9 @@
  58.335    by (cases "i = j") (simp_all add: multiset_of_update nth_mem_multiset_of)
  58.336  
  58.337  
  58.338 -subsection {* The multiset order *}
  58.339 -
  58.340 -subsubsection {* Well-foundedness *}
  58.341 +subsection \<open>The multiset order\<close>
  58.342 +
  58.343 +subsubsection \<open>Well-foundedness\<close>
  58.344  
  58.345  definition mult1 :: "('a \<times> 'a) set => ('a multiset \<times> 'a multiset) set" where
  58.346    "mult1 r = {(N, M). \<exists>a M0 K. M = M0 + {#a#} \<and> N = M0 + K \<and>
  58.347 @@ -1628,7 +1628,7 @@
  58.348        proof (elim exE disjE conjE)
  58.349          fix M assume "(M, M0) \<in> ?R" and N: "N = M + {#a#}"
  58.350          from acc_hyp have "(M, M0) \<in> ?R --> M + {#a#} \<in> ?W" ..
  58.351 -        from this and `(M, M0) \<in> ?R` have "M + {#a#} \<in> ?W" ..
  58.352 +        from this and \<open>(M, M0) \<in> ?R\<close> have "M + {#a#} \<in> ?W" ..
  58.353          then show "N \<in> ?W" by (simp only: N)
  58.354        next
  58.355          fix K
  58.356 @@ -1673,7 +1673,7 @@
  58.357            by (rule acc_induct) (rule tedious_reasoning [OF _ r])
  58.358        qed
  58.359      qed
  58.360 -    from this and `M \<in> ?W` show "M + {#a#} \<in> ?W" ..
  58.361 +    from this and \<open>M \<in> ?W\<close> show "M + {#a#} \<in> ?W" ..
  58.362    qed
  58.363  qed
  58.364  
  58.365 @@ -1684,9 +1684,9 @@
  58.366  unfolding mult_def by (rule wf_trancl) (rule wf_mult1)
  58.367  
  58.368  
  58.369 -subsubsection {* Closure-free presentation *}
  58.370 -
  58.371 -text {* One direction. *}
  58.372 +subsubsection \<open>Closure-free presentation\<close>
  58.373 +
  58.374 +text \<open>One direction.\<close>
  58.375  
  58.376  lemma mult_implies_one_step:
  58.377    "trans r ==> (M, N) \<in> mult r ==>
  58.378 @@ -1732,7 +1732,7 @@
  58.379   apply (simp add: mult_def)
  58.380   apply (rule r_into_trancl)
  58.381   apply (simp add: mult1_def set_mset_def, blast)
  58.382 -txt {* Now we know @{term "J' \<noteq> {#}"}. *}
  58.383 +txt \<open>Now we know @{term "J' \<noteq> {#}"}.\<close>
  58.384  apply (cut_tac M = K and P = "\<lambda>x. (x, a) \<in> r" in multiset_partition)
  58.385  apply (erule_tac P = "\<forall>k \<in> set_mset K. P k" for P in rev_mp)
  58.386  apply (erule ssubst)
  58.387 @@ -1757,7 +1757,7 @@
  58.388  using one_step_implies_mult_aux by blast
  58.389  
  58.390  
  58.391 -subsubsection {* Partial-order properties *}
  58.392 +subsubsection \<open>Partial-order properties\<close>
  58.393  
  58.394  definition less_multiset :: "'a\<Colon>order multiset \<Rightarrow> 'a multiset \<Rightarrow> bool" (infix "#<#" 50) where
  58.395    "M' #<# M \<longleftrightarrow> (M', M) \<in> mult {(x', x). x' < x}"
  58.396 @@ -1800,7 +1800,7 @@
  58.397    by simp
  58.398  
  58.399  
  58.400 -subsubsection {* Monotonicity of multiset union *}
  58.401 +subsubsection \<open>Monotonicity of multiset union\<close>
  58.402  
  58.403  lemma mult1_union: "(B, D) \<in> mult1 r ==> (C + B, C + D) \<in> mult1 r"
  58.404  apply (unfold mult1_def)
  58.405 @@ -1832,7 +1832,7 @@
  58.406  qed (auto simp add: le_multiset_def intro: union_less_mono2)
  58.407  
  58.408  
  58.409 -subsubsection {* Termination proofs with multiset orders *}
  58.410 +subsubsection \<open>Termination proofs with multiset orders\<close>
  58.411  
  58.412  lemma multi_member_skip: "x \<in># XS \<Longrightarrow> x \<in># {# y #} + XS"
  58.413    and multi_member_this: "x \<in># {# x #} + XS"
  58.414 @@ -1940,7 +1940,7 @@
  58.415  and nonempty_single: "{# x #} \<noteq> {#}"
  58.416  by auto
  58.417  
  58.418 -setup {*
  58.419 +setup \<open>
  58.420  let
  58.421    fun msetT T = Type (@{type_name multiset}, [T]);
  58.422  
  58.423 @@ -1980,10 +1980,10 @@
  58.424      reduction_pair= @{thm ms_reduction_pair}
  58.425    })
  58.426  end
  58.427 -*}
  58.428 -
  58.429 -
  58.430 -subsection {* Legacy theorem bindings *}
  58.431 +\<close>
  58.432 +
  58.433 +
  58.434 +subsection \<open>Legacy theorem bindings\<close>
  58.435  
  58.436  lemmas multi_count_eq = multiset_eq_iff [symmetric]
  58.437  
  58.438 @@ -2040,7 +2040,7 @@
  58.439    "M #\<subset># N ==> (\<not> P ==> N #\<subset># (M::'a::order multiset)) ==> P"
  58.440    by (fact multiset_order.less_asym)
  58.441  
  58.442 -ML {*
  58.443 +ML \<open>
  58.444  fun multiset_postproc _ maybe_name all_values (T as Type (_, [elem_T]))
  58.445                        (Const _ $ t') =
  58.446      let
  58.447 @@ -2063,15 +2063,15 @@
  58.448                                                  elem_T --> T))) ts)
  58.449      end
  58.450    | multiset_postproc _ _ _ _ t = t
  58.451 -*}
  58.452 -
  58.453 -declaration {*
  58.454 +\<close>
  58.455 +
  58.456 +declaration \<open>
  58.457  Nitpick_Model.register_term_postprocessor @{typ "'a multiset"}
  58.458      multiset_postproc
  58.459 -*}
  58.460 -
  58.461 -
  58.462 -subsection {* Naive implementation using lists *}
  58.463 +\<close>
  58.464 +
  58.465 +
  58.466 +subsection \<open>Naive implementation using lists\<close>
  58.467  
  58.468  code_datatype multiset_of
  58.469  
  58.470 @@ -2136,7 +2136,7 @@
  58.471  
  58.472  declare sorted_list_of_multiset_multiset_of [code]
  58.473  
  58.474 -lemma [code]: -- {* not very efficient, but representation-ignorant! *}
  58.475 +lemma [code]: -- \<open>not very efficient, but representation-ignorant!\<close>
  58.476    "multiset_of_set A = multiset_of (sorted_list_of_set A)"
  58.477    apply (cases "finite A")
  58.478    apply simp_all
  58.479 @@ -2221,12 +2221,12 @@
  58.480    then show ?thesis by simp
  58.481  qed
  58.482  
  58.483 -text {*
  58.484 +text \<open>
  58.485    Exercise for the casual reader: add implementations for @{const le_multiset}
  58.486    and @{const less_multiset} (multiset order).
  58.487 -*}
  58.488 -
  58.489 -text {* Quickcheck generators *}
  58.490 +\<close>
  58.491 +
  58.492 +text \<open>Quickcheck generators\<close>
  58.493  
  58.494  definition (in term_syntax)
  58.495    msetify :: "'a\<Colon>typerep list \<times> (unit \<Rightarrow> Code_Evaluation.term)
  58.496 @@ -2263,7 +2263,7 @@
  58.497  hide_const (open) msetify
  58.498  
  58.499  
  58.500 -subsection {* BNF setup *}
  58.501 +subsection \<open>BNF setup\<close>
  58.502  
  58.503  definition rel_mset where
  58.504    "rel_mset R X Y \<longleftrightarrow> (\<exists>xs ys. multiset_of xs = X \<and> multiset_of ys = Y \<and> list_all2 R xs ys)"
  58.505 @@ -2576,17 +2576,17 @@
  58.506           rel_mset'.induct[unfolded rel_mset_rel_mset'[symmetric]]
  58.507  
  58.508  
  58.509 -subsection {* Size setup *}
  58.510 +subsection \<open>Size setup\<close>
  58.511  
  58.512  lemma multiset_size_o_map: "size_multiset g \<circ> image_mset f = size_multiset (g \<circ> f)"
  58.513    unfolding o_apply by (rule ext) (induct_tac, auto)
  58.514  
  58.515 -setup {*
  58.516 +setup \<open>
  58.517  BNF_LFP_Size.register_size_global @{type_name multiset} @{const_name size_multiset}
  58.518    @{thms size_multiset_empty size_multiset_single size_multiset_union size_empty size_single
  58.519      size_union}
  58.520    @{thms multiset_size_o_map}
  58.521 -*}
  58.522 +\<close>
  58.523  
  58.524  hide_const (open) wcount
  58.525  
    59.1 --- a/src/HOL/Library/Multiset_Order.thy	Wed Jun 17 17:33:22 2015 +0200
    59.2 +++ b/src/HOL/Library/Multiset_Order.thy	Wed Jun 17 17:54:09 2015 +0200
    59.3 @@ -3,13 +3,13 @@
    59.4      Author:     Jasmin Blanchette, Inria, LORIA, MPII
    59.5  *)
    59.6  
    59.7 -section {* More Theorems about the Multiset Order *}
    59.8 +section \<open>More Theorems about the Multiset Order\<close>
    59.9  
   59.10  theory Multiset_Order
   59.11  imports Multiset
   59.12  begin
   59.13  
   59.14 -subsubsection {* Alternative characterizations *}
   59.15 +subsubsection \<open>Alternative characterizations\<close>
   59.16  
   59.17  context order
   59.18  begin
   59.19 @@ -65,14 +65,14 @@
   59.20      by default (auto simp add: le_multiset_def irrefl dest: trans)
   59.21  qed
   59.22  
   59.23 -text {* The Dershowitz--Manna ordering: *}
   59.24 +text \<open>The Dershowitz--Manna ordering:\<close>
   59.25  
   59.26  definition less_multiset\<^sub>D\<^sub>M where
   59.27    "less_multiset\<^sub>D\<^sub>M M N \<longleftrightarrow>
   59.28     (\<exists>X Y. X \<noteq> {#} \<and> X \<le># N \<and> M = (N - X) + Y \<and> (\<forall>k. k \<in># Y \<longrightarrow> (\<exists>a. a \<in># X \<and> k < a)))"
   59.29  
   59.30  
   59.31 -text {* The Huet--Oppen ordering: *}
   59.32 +text \<open>The Huet--Oppen ordering:\<close>
   59.33  
   59.34  definition less_multiset\<^sub>H\<^sub>O where
   59.35    "less_multiset\<^sub>H\<^sub>O M N \<longleftrightarrow> M \<noteq> N \<and> (\<forall>y. count N y < count M y \<longrightarrow> (\<exists>x. y < x \<and> count M x < count N x))"
   59.36 @@ -110,7 +110,7 @@
   59.37          then show ?thesis by (cases "count P a \<le> count M a") (auto dest: count_a intro: less_trans)
   59.38        next
   59.39          case False
   59.40 -        with `y \<noteq> a` have "count P y = count N y" unfolding *(1,2) by simp
   59.41 +        with \<open>y \<noteq> a\<close> have "count P y = count N y" unfolding *(1,2) by simp
   59.42          with count_y step(3) obtain z where z: "z > y" "count M z < count N z" by auto
   59.43          show ?thesis
   59.44          proof (cases "z \<in># K")
   59.45 @@ -138,7 +138,7 @@
   59.46      unfolding less_multiset\<^sub>D\<^sub>M_def by blast
   59.47    then have "(N - X + Y, N - X + X) \<in> mult {(x, y). x < y}"
   59.48      by (intro one_step_implies_mult) (auto simp: Bex_def trans_def)
   59.49 -  with `M = N - X + Y` `X \<le># N` show "(M, N) \<in> mult {(x, y). x < y}"
   59.50 +  with \<open>M = N - X + Y\<close> \<open>X \<le># N\<close> show "(M, N) \<in> mult {(x, y). x < y}"
   59.51      by (metis subset_mset.diff_add)
   59.52  qed
   59.53  
   59.54 @@ -158,7 +158,7 @@
   59.55      fix k
   59.56      assume "k \<in># Y"
   59.57      then have "count N k < count M k" unfolding Y_def by auto
   59.58 -    with `less_multiset\<^sub>H\<^sub>O M N` obtain a where "k < a" and "count M a < count N a"
   59.59 +    with \<open>less_multiset\<^sub>H\<^sub>O M N\<close> obtain a where "k < a" and "count M a < count N a"
   59.60        unfolding less_multiset\<^sub>H\<^sub>O_def by blast
   59.61      then show "\<exists>a. a \<in># X \<and> k < a" unfolding X_def by auto
   59.62    qed
    60.1 --- a/src/HOL/Library/Nat_Bijection.thy	Wed Jun 17 17:33:22 2015 +0200
    60.2 +++ b/src/HOL/Library/Nat_Bijection.thy	Wed Jun 17 17:54:09 2015 +0200
    60.3 @@ -6,13 +6,13 @@
    60.4      Author:     Alexander Krauss
    60.5  *)
    60.6  
    60.7 -section {* Bijections between natural numbers and other types *}
    60.8 +section \<open>Bijections between natural numbers and other types\<close>
    60.9  
   60.10  theory Nat_Bijection
   60.11  imports Main
   60.12  begin
   60.13  
   60.14 -subsection {* Type @{typ "nat \<times> nat"} *}
   60.15 +subsection \<open>Type @{typ "nat \<times> nat"}\<close>
   60.16  
   60.17  text "Triangle numbers: 0, 1, 3, 6, 10, 15, ..."
   60.18  
   60.19 @@ -32,7 +32,7 @@
   60.20  where
   60.21    "prod_encode = (\<lambda>(m, n). triangle (m + n) + m)"
   60.22  
   60.23 -text {* In this auxiliary function, @{term "triangle k + m"} is an invariant. *}
   60.24 +text \<open>In this auxiliary function, @{term "triangle k + m"} is an invariant.\<close>
   60.25  
   60.26  fun
   60.27    prod_decode_aux :: "nat \<Rightarrow> nat \<Rightarrow> nat \<times> nat"
   60.28 @@ -96,7 +96,7 @@
   60.29  lemma prod_decode_eq: "prod_decode x = prod_decode y \<longleftrightarrow> x = y"
   60.30  by (rule inj_prod_decode [THEN inj_eq])
   60.31  
   60.32 -text {* Ordering properties *}
   60.33 +text \<open>Ordering properties\<close>
   60.34  
   60.35  lemma le_prod_encode_1: "a \<le> prod_encode (a, b)"
   60.36  unfolding prod_encode_def by simp
   60.37 @@ -105,7 +105,7 @@
   60.38  unfolding prod_encode_def by (induct b, simp_all)
   60.39  
   60.40  
   60.41 -subsection {* Type @{typ "nat + nat"} *}
   60.42 +subsection \<open>Type @{typ "nat + nat"}\<close>
   60.43  
   60.44  definition
   60.45    sum_encode  :: "nat + nat \<Rightarrow> nat"
   60.46 @@ -149,7 +149,7 @@
   60.47  by (rule inj_sum_decode [THEN inj_eq])
   60.48  
   60.49  
   60.50 -subsection {* Type @{typ "int"} *}
   60.51 +subsection \<open>Type @{typ "int"}\<close>
   60.52  
   60.53  definition
   60.54    int_encode :: "int \<Rightarrow> nat"
   60.55 @@ -193,7 +193,7 @@
   60.56  by (rule inj_int_decode [THEN inj_eq])
   60.57  
   60.58  
   60.59 -subsection {* Type @{typ "nat list"} *}
   60.60 +subsection \<open>Type @{typ "nat list"}\<close>
   60.61  
   60.62  fun
   60.63    list_encode :: "nat list \<Rightarrow> nat"
   60.64 @@ -249,9 +249,9 @@
   60.65  by (rule inj_list_decode [THEN inj_eq])
   60.66  
   60.67  
   60.68 -subsection {* Finite sets of naturals *}
   60.69 +subsection \<open>Finite sets of naturals\<close>
   60.70  
   60.71 -subsubsection {* Preliminaries *}
   60.72 +subsubsection \<open>Preliminaries\<close>
   60.73  
   60.74  lemma finite_vimage_Suc_iff: "finite (Suc -` F) \<longleftrightarrow> finite F"
   60.75  apply (safe intro!: finite_vimageI inj_Suc)
   60.76 @@ -274,7 +274,7 @@
   60.77    and "even x \<longleftrightarrow> even y"
   60.78    shows "x = y"
   60.79  proof -
   60.80 -  from `even x \<longleftrightarrow> even y` have "x mod 2 = y mod 2"
   60.81 +  from \<open>even x \<longleftrightarrow> even y\<close> have "x mod 2 = y mod 2"
   60.82      by (simp only: even_iff_mod_2_eq_zero) auto
   60.83    with assms have "x div 2 * 2 + x mod 2 = y div 2 * 2 + y mod 2"
   60.84      by simp
   60.85 @@ -283,7 +283,7 @@
   60.86  qed
   60.87  
   60.88  
   60.89 -subsubsection {* From sets to naturals *}
   60.90 +subsubsection \<open>From sets to naturals\<close>
   60.91  
   60.92  definition
   60.93    set_encode :: "nat set \<Rightarrow> nat"
   60.94 @@ -314,7 +314,7 @@
   60.95  
   60.96  lemmas set_encode_div_2 = set_encode_vimage_Suc [symmetric]
   60.97  
   60.98 -subsubsection {* From naturals to sets *}
   60.99 +subsubsection \<open>From naturals to sets\<close>
  60.100  
  60.101  definition
  60.102    set_decode :: "nat \<Rightarrow> nat set"
  60.103 @@ -358,7 +358,7 @@
  60.104  apply (simp add: finite_vimage_Suc_iff)
  60.105  done
  60.106  
  60.107 -subsubsection {* Proof of isomorphism *}
  60.108 +subsubsection \<open>Proof of isomorphism\<close>
  60.109  
  60.110  lemma set_decode_inverse [simp]: "set_encode (set_decode n) = n"
  60.111  apply (induct n rule: nat_less_induct)
    61.1 --- a/src/HOL/Library/Numeral_Type.thy	Wed Jun 17 17:33:22 2015 +0200
    61.2 +++ b/src/HOL/Library/Numeral_Type.thy	Wed Jun 17 17:54:09 2015 +0200
    61.3 @@ -2,13 +2,13 @@
    61.4      Author:     Brian Huffman
    61.5  *)
    61.6  
    61.7 -section {* Numeral Syntax for Types *}
    61.8 +section \<open>Numeral Syntax for Types\<close>
    61.9  
   61.10  theory Numeral_Type
   61.11  imports Cardinality
   61.12  begin
   61.13  
   61.14 -subsection {* Numeral Types *}
   61.15 +subsection \<open>Numeral Types\<close>
   61.16  
   61.17  typedef num0 = "UNIV :: nat set" ..
   61.18  typedef num1 = "UNIV :: unit set" ..
   61.19 @@ -70,7 +70,7 @@
   61.20      by simp
   61.21  qed
   61.22  
   61.23 -subsection {* Locales for for modular arithmetic subtypes *}
   61.24 +subsection \<open>Locales for for modular arithmetic subtypes\<close>
   61.25  
   61.26  locale mod_type =
   61.27    fixes n :: int
   61.28 @@ -179,12 +179,12 @@
   61.29  end
   61.30  
   61.31  
   61.32 -subsection {* Ring class instances *}
   61.33 +subsection \<open>Ring class instances\<close>
   61.34  
   61.35 -text {*
   61.36 +text \<open>
   61.37    Unfortunately @{text ring_1} instance is not possible for
   61.38    @{typ num1}, since 0 and 1 are not distinct.
   61.39 -*}
   61.40 +\<close>
   61.41  
   61.42  instantiation num1 :: "{comm_ring,comm_monoid_mult,numeral}"
   61.43  begin
   61.44 @@ -273,7 +273,7 @@
   61.45             "Abs_bit1 :: int \<Rightarrow> 'a::finite bit1"
   61.46    ..
   61.47  
   61.48 -text {* Set up cases, induction, and arithmetic *}
   61.49 +text \<open>Set up cases, induction, and arithmetic\<close>
   61.50  
   61.51  lemmas bit0_cases [case_names of_int, cases type: bit0] = bit0.cases
   61.52  lemmas bit1_cases [case_names of_int, cases type: bit1] = bit1.cases
   61.53 @@ -287,7 +287,7 @@
   61.54  lemmas [simp] = eq_numeral_iff_iszero [where 'a="'a bit0"] for dummy :: "'a::finite"
   61.55  lemmas [simp] = eq_numeral_iff_iszero [where 'a="'a bit1"] for dummy :: "'a::finite"
   61.56  
   61.57 -subsection {* Order instances *}
   61.58 +subsection \<open>Order instances\<close>
   61.59  
   61.60  instantiation bit0 and bit1 :: (finite) linorder begin
   61.61  definition "a < b \<longleftrightarrow> Rep_bit0 a < Rep_bit0 b"
   61.62 @@ -316,9 +316,9 @@
   61.63      by(rule wf_wellorderI) intro_classes
   61.64  qed
   61.65  
   61.66 -subsection {* Code setup and type classes for code generation *}
   61.67 +subsection \<open>Code setup and type classes for code generation\<close>
   61.68  
   61.69 -text {* Code setup for @{typ num0} and @{typ num1} *}
   61.70 +text \<open>Code setup for @{typ num0} and @{typ num1}\<close>
   61.71  
   61.72  definition Num0 :: num0 where "Num0 = Abs_num0 0"
   61.73  code_datatype Num0
   61.74 @@ -366,7 +366,7 @@
   61.75  end
   61.76  
   61.77  
   61.78 -text {* Code setup for @{typ "'a bit0"} and @{typ "'a bit1"} *}
   61.79 +text \<open>Code setup for @{typ "'a bit0"} and @{typ "'a bit1"}\<close>
   61.80  
   61.81  declare
   61.82    bit0.Rep_inverse[code abstype]
   61.83 @@ -465,7 +465,7 @@
   61.84  instance by intro_classes (simp_all add: card_UNIV_bit0_def card_UNIV_bit1_def card_UNIV)
   61.85  end
   61.86  
   61.87 -subsection {* Syntax *}
   61.88 +subsection \<open>Syntax\<close>
   61.89  
   61.90  syntax
   61.91    "_NumeralType" :: "num_token => type"  ("_")
   61.92 @@ -476,7 +476,7 @@
   61.93    (type) "1" == (type) "num1"
   61.94    (type) "0" == (type) "num0"
   61.95  
   61.96 -parse_translation {*
   61.97 +parse_translation \<open>
   61.98    let
   61.99      fun mk_bintype n =
  61.100        let
  61.101 @@ -495,9 +495,9 @@
  61.102        | numeral_tr ts = raise TERM ("numeral_tr", ts);
  61.103  
  61.104    in [(@{syntax_const "_NumeralType"}, K numeral_tr)] end;
  61.105 -*}
  61.106 +\<close>
  61.107  
  61.108 -print_translation {*
  61.109 +print_translation \<open>
  61.110    let
  61.111      fun int_of [] = 0
  61.112        | int_of (b :: bs) = b + 2 * int_of bs;
  61.113 @@ -521,9 +521,9 @@
  61.114     [(@{type_syntax bit0}, K (bit_tr' 0)),
  61.115      (@{type_syntax bit1}, K (bit_tr' 1))]
  61.116    end;
  61.117 -*}
  61.118 +\<close>
  61.119  
  61.120 -subsection {* Examples *}
  61.121 +subsection \<open>Examples\<close>
  61.122  
  61.123  lemma "CARD(0) = 0" by simp
  61.124  lemma "CARD(17) = 17" by simp
    62.1 --- a/src/HOL/Library/Old_Datatype.thy	Wed Jun 17 17:33:22 2015 +0200
    62.2 +++ b/src/HOL/Library/Old_Datatype.thy	Wed Jun 17 17:54:09 2015 +0200
    62.3 @@ -3,7 +3,7 @@
    62.4      Author:     Stefan Berghofer and Markus Wenzel, TU Muenchen
    62.5  *)
    62.6  
    62.7 -section {* Old Datatype package: constructing datatypes from Cartesian Products and Disjoint Sums *}
    62.8 +section \<open>Old Datatype package: constructing datatypes from Cartesian Products and Disjoint Sums\<close>
    62.9  
   62.10  theory Old_Datatype
   62.11  imports "../Main"
   62.12 @@ -13,7 +13,7 @@
   62.13  ML_file "~~/src/HOL/Tools/datatype_realizer.ML"
   62.14