src/HOL/Library/Array.thy
author haftmann
Thu, 28 Feb 2008 16:50:52 +0100
changeset 26182 8262ec0e8782
parent 26170 66e6b967ccf1
child 26719 a259d259c797
permissions -rw-r--r--
added code generator setup
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26170
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
     1
(*  Title:      HOL/Library/Array.thy
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
     2
    ID:         $Id$
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
     3
    Author:     John Matthews, Galois Connections; Alexander Krauss, Lukas Bulwahn & Florian Haftmann, TU Muenchen
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
     4
*)
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
     5
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
     6
header {* Monadic arrays *}
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
     7
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
     8
theory Array
26182
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
     9
imports Heap_Monad Code_Index
26170
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    10
begin
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    11
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    12
subsection {* Primitives *}
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    13
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    14
definition
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    15
  new :: "nat \<Rightarrow> 'a\<Colon>heap \<Rightarrow> 'a array Heap" where
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    16
  [code del]: "new n x = Heap_Monad.heap (Heap.array n x)"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    17
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    18
definition
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    19
  of_list :: "'a\<Colon>heap list \<Rightarrow> 'a array Heap" where
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    20
  [code del]: "of_list xs = Heap_Monad.heap (Heap.array_of_list xs)"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    21
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    22
definition
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    23
  length :: "'a\<Colon>heap array \<Rightarrow> nat Heap" where
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    24
  [code del]: "length arr = Heap_Monad.heap (\<lambda>h. (Heap.length arr h, h))"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    25
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    26
definition
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    27
  nth :: "'a\<Colon>heap array \<Rightarrow> nat \<Rightarrow> 'a Heap"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    28
where
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    29
  [code del]: "nth a i = (do len \<leftarrow> length a;
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    30
                 (if i < len
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    31
                     then Heap_Monad.heap (\<lambda>h. (get_array a h ! i, h))
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    32
                     else raise (''array lookup: index out of range''))
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    33
              done)"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    34
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    35
-- {* FIXME adjustion for List theory *}
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    36
no_syntax
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    37
  nth  :: "'a list \<Rightarrow> nat \<Rightarrow> 'a" (infixl "!" 100)
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    38
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    39
abbreviation
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    40
  nth_list :: "'a list \<Rightarrow> nat \<Rightarrow> 'a" (infixl "!" 100)
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    41
where
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    42
  "nth_list \<equiv> List.nth"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    43
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    44
definition
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    45
  upd :: "nat \<Rightarrow> 'a \<Rightarrow> 'a\<Colon>heap array \<Rightarrow> 'a\<Colon>heap array Heap"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    46
where
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    47
  [code del]: "upd i x a = (do len \<leftarrow> length a;
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    48
                      (if i < len
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    49
                           then Heap_Monad.heap (\<lambda>h. ((), Heap.upd a i x h))
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    50
                           else raise (''array update: index out of range''));
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    51
                      return a
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    52
                   done)" 
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    53
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    54
lemma upd_return:
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    55
  "upd i x a \<guillemotright> return a = upd i x a"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    56
  unfolding upd_def by (simp add: monad_simp)
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    57
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    58
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    59
subsection {* Derivates *}
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    60
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    61
definition
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    62
  map_entry :: "nat \<Rightarrow> ('a\<Colon>heap \<Rightarrow> 'a) \<Rightarrow> 'a array \<Rightarrow> 'a array Heap"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    63
where
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    64
  "map_entry i f a = (do
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    65
     x \<leftarrow> nth a i;
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    66
     upd i (f x) a
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    67
   done)"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    68
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    69
definition
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    70
  swap :: "nat \<Rightarrow> 'a \<Rightarrow> 'a\<Colon>heap array \<Rightarrow> 'a Heap"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    71
where
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    72
  "swap i x a = (do
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    73
     y \<leftarrow> nth a i;
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    74
     upd i x a;
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    75
     return x
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    76
   done)"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    77
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    78
definition
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    79
  make :: "nat \<Rightarrow> (nat \<Rightarrow> 'a\<Colon>heap) \<Rightarrow> 'a array Heap"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    80
where
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    81
  "make n f = of_list (map f [0 ..< n])"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    82
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    83
definition
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    84
  freeze :: "'a\<Colon>heap array \<Rightarrow> 'a list Heap"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    85
where
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    86
  "freeze a = (do
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    87
     n \<leftarrow> length a;
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    88
     mapM (nth a) [0..<n]
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    89
   done)"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    90
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    91
definition
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    92
  map :: "('a\<Colon>heap \<Rightarrow> 'a) \<Rightarrow> 'a array \<Rightarrow> 'a array Heap"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    93
where
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    94
  "map f a = (do
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    95
     n \<leftarrow> length a;
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    96
     foldM (\<lambda>n. map_entry n f) [0..<n] a
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    97
   done)"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    98
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    99
hide (open) const new map -- {* avoid clashed with some popular names *}
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
   100
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
   101
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
   102
subsection {* Properties *}
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
   103
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
   104
lemma array_make [code func]:
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
   105
  "Array.new n x = make n (\<lambda>_. x)"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
   106
  by (induct n) (simp_all add: make_def new_def Heap_Monad.heap_def
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
   107
    monad_simp array_of_list_replicate [symmetric]
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
   108
    map_replicate_trivial replicate_append_same
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
   109
    of_list_def)
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
   110
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
   111
lemma array_of_list_make [code func]:
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
   112
  "of_list xs = make (List.length xs) (\<lambda>n. xs ! n)"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
   113
  unfolding make_def map_nth ..
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
   114
26182
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   115
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   116
subsection {* Code generator setup *}
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   117
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   118
subsubsection {* Logical intermediate layer *}
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   119
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   120
definition new' where
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   121
  [code del]: "new' = Array.new o nat_of_index"
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   122
hide (open) const new'
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   123
lemma [code func]:
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   124
  "Array.new = Array.new' o index_of_nat"
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   125
  by (simp add: new'_def o_def)
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   126
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   127
definition of_list' where
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   128
  [code del]: "of_list' i xs = Array.of_list (take (nat_of_index i) xs)"
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   129
hide (open) const of_list'
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   130
lemma [code func]:
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   131
  "Array.of_list xs = Array.of_list' (index_of_nat (List.length xs)) xs"
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   132
  by (simp add: of_list'_def)
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   133
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   134
definition make' where
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   135
  [code del]: "make' i f = Array.make (nat_of_index i) (f o index_of_nat)"
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   136
hide (open) const make'
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   137
lemma [code func]:
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   138
  "Array.make n f = Array.make' (index_of_nat n) (f o nat_of_index)"
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   139
  by (simp add: make'_def o_def)
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   140
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   141
definition length' where
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   142
  [code del]: "length' = Array.length \<guillemotright>== liftM index_of_nat"
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   143
hide (open) const length'
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   144
lemma [code func]:
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   145
  "Array.length = Array.length' \<guillemotright>== liftM nat_of_index"
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   146
  by (simp add: length'_def monad_simp',
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   147
    simp add: liftM_def comp_def monad_simp,
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   148
    simp add: monad_simp')
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   149
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   150
definition nth' where
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   151
  [code del]: "nth' a = Array.nth a o nat_of_index"
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   152
hide (open) const nth'
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   153
lemma [code func]:
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   154
  "Array.nth a n = Array.nth' a (index_of_nat n)"
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   155
  by (simp add: nth'_def)
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   156
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   157
definition upd' where
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   158
  [code del]: "upd' a i x = Array.upd (nat_of_index i) x a \<guillemotright> return ()"
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   159
hide (open) const upd'
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   160
lemma [code func]:
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   161
  "Array.upd i x a = Array.upd' a (index_of_nat i) x \<guillemotright> return a"
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   162
  by (simp add: upd'_def monad_simp upd_return)
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   163
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   164
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   165
subsubsection {* SML *}
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   166
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   167
code_type array (SML "_/ array")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   168
code_const Array (SML "raise/ (Fail/ \"bare Array\")")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   169
code_const Array.new' (SML "Array.array ((_), (_))")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   170
code_const Array.of_list (SML "Array.fromList")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   171
code_const Array.make' (SML "Array.tabulate ((_), (_))")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   172
code_const Array.length' (SML "Array.length")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   173
code_const Array.nth' (SML "Array.sub ((_), (_))")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   174
code_const Array.upd' (SML "Array.update ((_), (_), (_))")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   175
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   176
code_reserved SML Array
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   177
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   178
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   179
subsubsection {* OCaml *}
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   180
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   181
code_type array (OCaml "_/ array")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   182
code_const Array (OCaml "failwith/ \"bare Array\"")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   183
code_const Array.new' (OCaml "Array.make")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   184
code_const Array.of_list (OCaml "Array.of_list")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   185
code_const Array.make' (OCaml "Array.init")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   186
code_const Array.length' (OCaml "Array.length")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   187
code_const Array.nth' (OCaml "Array.get")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   188
code_const Array.upd' (OCaml "Array.set")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   189
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   190
code_reserved OCaml Array
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   191
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   192
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   193
subsubsection {* Haskell *}
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   194
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   195
code_type array (Haskell "STArray '_s _")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   196
code_const Array (Haskell "error/ \"bare Array\"")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   197
code_const Array.new' (Haskell "newArray/ (0,/ _)")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   198
code_const Array.of_list' (Haskell "newListArray/ (0,/ _)")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   199
code_const Array.length' (Haskell "length")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   200
code_const Array.nth' (Haskell "readArray")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   201
code_const Array.upd' (Haskell "writeArray")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   202
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   203
26170
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
   204
end