diff -r 143f58bb34f9 -r 0909deb8059b src/HOL/Imperative_HOL/Array.thy --- a/src/HOL/Imperative_HOL/Array.thy Thu May 26 16:57:14 2016 +0200 +++ b/src/HOL/Imperative_HOL/Array.thy Thu May 26 17:51:22 2016 +0200 @@ -2,13 +2,13 @@ Author: John Matthews, Galois Connections; Alexander Krauss, Lukas Bulwahn & Florian Haftmann, TU Muenchen *) -section {* Monadic arrays *} +section \Monadic arrays\ theory Array imports Heap_Monad begin -subsection {* Primitives *} +subsection \Primitives\ definition present :: "heap \ 'a::heap array \ bool" where "present h a \ addr_of_array a < lim h" @@ -36,7 +36,7 @@ "r =!!= s \ TYPEREP('a) \ TYPEREP('b) \ addr_of_array r \ addr_of_array s" -subsection {* Monad operations *} +subsection \Monad operations\ definition new :: "nat \ 'a::heap \ 'a array Heap" where [code del]: "new n x = Heap_Monad.heap (alloc (replicate n x))" @@ -70,12 +70,12 @@ [code del]: "freeze a = Heap_Monad.tap (\h. get h a)" -subsection {* Properties *} +subsection \Properties\ -text {* FIXME: Does there exist a "canonical" array axiomatisation in -the literature? *} +text \FIXME: Does there exist a "canonical" array axiomatisation in +the literature?\ -text {* Primitives *} +text \Primitives\ lemma noteq_sym: "a =!!= b \ b =!!= a" and unequal [simp]: "a \ a' \ a =!!= a'" @@ -160,7 +160,7 @@ by (simp add: present_def alloc_def Let_def) -text {* Monad operations *} +text \Monad operations\ lemma execute_new [execute_simps]: "execute (new n x) h = Some (alloc (replicate n x) h)" @@ -352,9 +352,9 @@ hide_const (open) present get set alloc length update noteq new of_list make len nth upd map_entry swap freeze -subsection {* Code generator setup *} +subsection \Code generator setup\ -subsubsection {* Logical intermediate layer *} +subsubsection \Logical intermediate layer\ definition new' where [code del]: "new' = Array.new o nat_of_integer" @@ -439,7 +439,7 @@ hide_const (open) new' make' len' nth' upd' -text {* SML *} +text \SML\ code_printing type_constructor array \ (SML) "_/ array" code_printing constant Array \ (SML) "raise/ (Fail/ \"bare Array\")" @@ -454,7 +454,7 @@ code_reserved SML Array -text {* OCaml *} +text \OCaml\ code_printing type_constructor array \ (OCaml) "_/ array" code_printing constant Array \ (OCaml) "failwith/ \"bare Array\"" @@ -470,7 +470,7 @@ code_reserved OCaml Array -text {* Haskell *} +text \Haskell\ code_printing type_constructor array \ (Haskell) "Heap.STArray/ Heap.RealWorld/ _" code_printing constant Array \ (Haskell) "error/ \"bare Array\"" @@ -484,7 +484,7 @@ code_printing class_instance array :: HOL.equal \ (Haskell) - -text {* Scala *} +text \Scala\ code_printing type_constructor array \ (Scala) "!collection.mutable.ArraySeq[_]" code_printing constant Array \ (Scala) "!sys.error(\"bare Array\")"