src/HOL/Imperative_HOL/Array.thy
author haftmann
Mon, 05 Jul 2010 15:25:42 +0200
changeset 37716 24bb91462892
parent 37709 70fafefbcc98
child 37719 271ecd4fb9f9
permissions -rw-r--r--
remove primitive operation Heap.array in favour of Heap.array_of_list
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31870
5274d3d0a6f2 dropped id
haftmann
parents: 31205
diff changeset
     1
(*  Title:      HOL/Imperative_HOL/Array.thy
26170
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
     2
    Author:     John Matthews, Galois Connections; Alexander Krauss, Lukas Bulwahn & Florian Haftmann, TU Muenchen
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
     3
*)
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
     4
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
     5
header {* Monadic arrays *}
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
     6
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
     7
theory Array
31203
5c8fb4fd67e0 moved Code_Index, Random and Quickcheck before Main
haftmann
parents: 29822
diff changeset
     8
imports Heap_Monad
26170
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
     9
begin
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    10
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    11
subsection {* Primitives *}
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    12
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    13
definition
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    14
  new :: "nat \<Rightarrow> 'a\<Colon>heap \<Rightarrow> 'a array Heap" where
37716
24bb91462892 remove primitive operation Heap.array in favour of Heap.array_of_list
haftmann
parents: 37709
diff changeset
    15
  [code del]: "new n x = Heap_Monad.heap (Heap.array (replicate n x))"
26170
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    16
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    17
definition
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    18
  of_list :: "'a\<Colon>heap list \<Rightarrow> 'a array Heap" where
37716
24bb91462892 remove primitive operation Heap.array in favour of Heap.array_of_list
haftmann
parents: 37709
diff changeset
    19
  [code del]: "of_list xs = Heap_Monad.heap (Heap.array xs)"
26170
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    20
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    21
definition
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    22
  length :: "'a\<Colon>heap array \<Rightarrow> nat Heap" where
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    23
  [code del]: "length arr = Heap_Monad.heap (\<lambda>h. (Heap.length arr h, h))"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    24
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    25
definition
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    26
  nth :: "'a\<Colon>heap array \<Rightarrow> nat \<Rightarrow> 'a Heap"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    27
where
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    28
  [code del]: "nth a i = (do len \<leftarrow> length a;
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    29
                 (if i < len
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    30
                     then Heap_Monad.heap (\<lambda>h. (get_array a h ! i, h))
37709
70fafefbcc98 simplified representation of monad type
haftmann
parents: 36176
diff changeset
    31
                     else raise ''array lookup: index out of range'')
26170
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    32
              done)"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    33
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    34
definition
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    35
  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
    36
where
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    37
  [code del]: "upd i x a = (do len \<leftarrow> length a;
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    38
                      (if i < len
26719
a259d259c797 improved definition of upd
haftmann
parents: 26182
diff changeset
    39
                           then Heap_Monad.heap (\<lambda>h. (a, Heap.upd a i x h))
37709
70fafefbcc98 simplified representation of monad type
haftmann
parents: 36176
diff changeset
    40
                           else raise ''array update: index out of range'')
26170
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    41
                   done)" 
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    42
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    43
lemma upd_return:
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    44
  "upd i x a \<guillemotright> return a = upd i x a"
37709
70fafefbcc98 simplified representation of monad type
haftmann
parents: 36176
diff changeset
    45
  by (rule Heap_eqI) (simp add: upd_def bindM_def split: option.split) 
26170
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    46
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    47
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    48
subsection {* Derivates *}
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    49
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    50
definition
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    51
  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
    52
where
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    53
  "map_entry i f a = (do
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    54
     x \<leftarrow> nth a i;
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    55
     upd i (f x) a
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    56
   done)"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    57
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    58
definition
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    59
  swap :: "nat \<Rightarrow> 'a \<Rightarrow> 'a\<Colon>heap array \<Rightarrow> 'a Heap"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    60
where
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    61
  "swap i x a = (do
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    62
     y \<leftarrow> nth a i;
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    63
     upd i x a;
27596
bc47d30747e6 dropped map; fixed swap
haftmann
parents: 26752
diff changeset
    64
     return y
26170
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    65
   done)"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    66
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    67
definition
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    68
  make :: "nat \<Rightarrow> (nat \<Rightarrow> 'a\<Colon>heap) \<Rightarrow> 'a array Heap"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    69
where
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    70
  "make n f = of_list (map f [0 ..< n])"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    71
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    72
definition
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    73
  freeze :: "'a\<Colon>heap array \<Rightarrow> 'a list Heap"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    74
where
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    75
  "freeze a = (do
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    76
     n \<leftarrow> length a;
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    77
     mapM (nth a) [0..<n]
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    78
   done)"
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    79
27656
d4f6e64ee7cc added verification framework for the HeapMonad and quicksort as example for this framework
bulwahn
parents: 27596
diff changeset
    80
definition
d4f6e64ee7cc added verification framework for the HeapMonad and quicksort as example for this framework
bulwahn
parents: 27596
diff changeset
    81
   map :: "('a\<Colon>heap \<Rightarrow> 'a) \<Rightarrow> 'a array \<Rightarrow> 'a array Heap"
d4f6e64ee7cc added verification framework for the HeapMonad and quicksort as example for this framework
bulwahn
parents: 27596
diff changeset
    82
where
d4f6e64ee7cc added verification framework for the HeapMonad and quicksort as example for this framework
bulwahn
parents: 27596
diff changeset
    83
  "map f a = (do
d4f6e64ee7cc added verification framework for the HeapMonad and quicksort as example for this framework
bulwahn
parents: 27596
diff changeset
    84
     n \<leftarrow> length a;
d4f6e64ee7cc added verification framework for the HeapMonad and quicksort as example for this framework
bulwahn
parents: 27596
diff changeset
    85
     mapM (\<lambda>n. map_entry n f a) [0..<n];
d4f6e64ee7cc added verification framework for the HeapMonad and quicksort as example for this framework
bulwahn
parents: 27596
diff changeset
    86
     return a
d4f6e64ee7cc added verification framework for the HeapMonad and quicksort as example for this framework
bulwahn
parents: 27596
diff changeset
    87
   done)"
d4f6e64ee7cc added verification framework for the HeapMonad and quicksort as example for this framework
bulwahn
parents: 27596
diff changeset
    88
36176
3fe7e97ccca8 replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents: 35846
diff changeset
    89
hide_const (open) new map -- {* avoid clashed with some popular names *}
26170
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    90
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    91
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    92
subsection {* Properties *}
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    93
28562
4e74209f113e `code func` now just `code`
haftmann
parents: 28145
diff changeset
    94
lemma array_make [code]:
26170
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    95
  "Array.new n x = make n (\<lambda>_. x)"
37716
24bb91462892 remove primitive operation Heap.array in favour of Heap.array_of_list
haftmann
parents: 37709
diff changeset
    96
  by (rule Heap_eqI) (simp add: make_def new_def map_replicate_trivial of_list_def)
26170
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    97
28562
4e74209f113e `code func` now just `code`
haftmann
parents: 28145
diff changeset
    98
lemma array_of_list_make [code]:
26170
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
    99
  "of_list xs = make (List.length xs) (\<lambda>n. xs ! n)"
37709
70fafefbcc98 simplified representation of monad type
haftmann
parents: 36176
diff changeset
   100
  by (rule Heap_eqI) (simp add: make_def map_nth)
26170
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
   101
26182
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   102
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   103
subsection {* Code generator setup *}
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   104
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   105
subsubsection {* Logical intermediate layer *}
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   106
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   107
definition new' where
31205
98370b26c2ce String.literal replaces message_string, code_numeral replaces (code_)index
haftmann
parents: 31203
diff changeset
   108
  [code del]: "new' = Array.new o Code_Numeral.nat_of"
36176
3fe7e97ccca8 replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents: 35846
diff changeset
   109
hide_const (open) new'
28562
4e74209f113e `code func` now just `code`
haftmann
parents: 28145
diff changeset
   110
lemma [code]:
31205
98370b26c2ce String.literal replaces message_string, code_numeral replaces (code_)index
haftmann
parents: 31203
diff changeset
   111
  "Array.new = Array.new' o Code_Numeral.of_nat"
26182
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   112
  by (simp add: new'_def o_def)
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   113
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   114
definition of_list' where
31205
98370b26c2ce String.literal replaces message_string, code_numeral replaces (code_)index
haftmann
parents: 31203
diff changeset
   115
  [code del]: "of_list' i xs = Array.of_list (take (Code_Numeral.nat_of i) xs)"
36176
3fe7e97ccca8 replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents: 35846
diff changeset
   116
hide_const (open) of_list'
28562
4e74209f113e `code func` now just `code`
haftmann
parents: 28145
diff changeset
   117
lemma [code]:
31205
98370b26c2ce String.literal replaces message_string, code_numeral replaces (code_)index
haftmann
parents: 31203
diff changeset
   118
  "Array.of_list xs = Array.of_list' (Code_Numeral.of_nat (List.length xs)) xs"
26182
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   119
  by (simp add: of_list'_def)
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   120
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   121
definition make' where
31205
98370b26c2ce String.literal replaces message_string, code_numeral replaces (code_)index
haftmann
parents: 31203
diff changeset
   122
  [code del]: "make' i f = Array.make (Code_Numeral.nat_of i) (f o Code_Numeral.of_nat)"
36176
3fe7e97ccca8 replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents: 35846
diff changeset
   123
hide_const (open) make'
28562
4e74209f113e `code func` now just `code`
haftmann
parents: 28145
diff changeset
   124
lemma [code]:
31205
98370b26c2ce String.literal replaces message_string, code_numeral replaces (code_)index
haftmann
parents: 31203
diff changeset
   125
  "Array.make n f = Array.make' (Code_Numeral.of_nat n) (f o Code_Numeral.nat_of)"
26182
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   126
  by (simp add: make'_def o_def)
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   127
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   128
definition length' where
37709
70fafefbcc98 simplified representation of monad type
haftmann
parents: 36176
diff changeset
   129
  [code del]: "length' a = Array.length a \<guillemotright>= (\<lambda>n. return (Code_Numeral.of_nat n))"
36176
3fe7e97ccca8 replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents: 35846
diff changeset
   130
hide_const (open) length'
28562
4e74209f113e `code func` now just `code`
haftmann
parents: 28145
diff changeset
   131
lemma [code]:
37709
70fafefbcc98 simplified representation of monad type
haftmann
parents: 36176
diff changeset
   132
  "Array.length a = Array.length' a \<guillemotright>= (\<lambda>i. return (Code_Numeral.nat_of i))"
70fafefbcc98 simplified representation of monad type
haftmann
parents: 36176
diff changeset
   133
  by (simp add: length'_def)
26182
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   134
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   135
definition nth' where
31205
98370b26c2ce String.literal replaces message_string, code_numeral replaces (code_)index
haftmann
parents: 31203
diff changeset
   136
  [code del]: "nth' a = Array.nth a o Code_Numeral.nat_of"
36176
3fe7e97ccca8 replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents: 35846
diff changeset
   137
hide_const (open) nth'
28562
4e74209f113e `code func` now just `code`
haftmann
parents: 28145
diff changeset
   138
lemma [code]:
31205
98370b26c2ce String.literal replaces message_string, code_numeral replaces (code_)index
haftmann
parents: 31203
diff changeset
   139
  "Array.nth a n = Array.nth' a (Code_Numeral.of_nat n)"
26182
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   140
  by (simp add: nth'_def)
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   141
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   142
definition upd' where
31205
98370b26c2ce String.literal replaces message_string, code_numeral replaces (code_)index
haftmann
parents: 31203
diff changeset
   143
  [code del]: "upd' a i x = Array.upd (Code_Numeral.nat_of i) x a \<guillemotright> return ()"
36176
3fe7e97ccca8 replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents: 35846
diff changeset
   144
hide_const (open) upd'
28562
4e74209f113e `code func` now just `code`
haftmann
parents: 28145
diff changeset
   145
lemma [code]:
31205
98370b26c2ce String.literal replaces message_string, code_numeral replaces (code_)index
haftmann
parents: 31203
diff changeset
   146
  "Array.upd i x a = Array.upd' a (Code_Numeral.of_nat i) x \<guillemotright> return a"
37709
70fafefbcc98 simplified representation of monad type
haftmann
parents: 36176
diff changeset
   147
  by (simp add: upd'_def upd_return)
26182
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   148
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   149
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   150
subsubsection {* SML *}
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   151
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   152
code_type array (SML "_/ array")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   153
code_const Array (SML "raise/ (Fail/ \"bare Array\")")
26752
6b276119139b corrected ML semantics
haftmann
parents: 26743
diff changeset
   154
code_const Array.new' (SML "(fn/ ()/ =>/ Array.array/ ((_),/ (_)))")
35846
2ae4b7585501 corrected setup for of_list
haftmann
parents: 32580
diff changeset
   155
code_const Array.of_list' (SML "(fn/ ()/ =>/ Array.fromList/ _)")
26752
6b276119139b corrected ML semantics
haftmann
parents: 26743
diff changeset
   156
code_const Array.make' (SML "(fn/ ()/ =>/ Array.tabulate/ ((_),/ (_)))")
6b276119139b corrected ML semantics
haftmann
parents: 26743
diff changeset
   157
code_const Array.length' (SML "(fn/ ()/ =>/ Array.length/ _)")
6b276119139b corrected ML semantics
haftmann
parents: 26743
diff changeset
   158
code_const Array.nth' (SML "(fn/ ()/ =>/ Array.sub/ ((_),/ (_)))")
6b276119139b corrected ML semantics
haftmann
parents: 26743
diff changeset
   159
code_const Array.upd' (SML "(fn/ ()/ =>/ Array.update/ ((_),/ (_),/ (_)))")
26182
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   160
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   161
code_reserved SML Array
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   162
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   163
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   164
subsubsection {* OCaml *}
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   165
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   166
code_type array (OCaml "_/ array")
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   167
code_const Array (OCaml "failwith/ \"bare Array\"")
32580
5b88ae4307ff restored code generation for OCaml
haftmann
parents: 31870
diff changeset
   168
code_const Array.new' (OCaml "(fun/ ()/ ->/ Array.make/ (Big'_int.int'_of'_big'_int/ _)/ _)")
35846
2ae4b7585501 corrected setup for of_list
haftmann
parents: 32580
diff changeset
   169
code_const Array.of_list' (OCaml "(fun/ ()/ ->/ Array.of'_list/ _)")
32580
5b88ae4307ff restored code generation for OCaml
haftmann
parents: 31870
diff changeset
   170
code_const Array.length' (OCaml "(fun/ ()/ ->/ Big'_int.big'_int'_of'_int/ (Array.length/ _))")
5b88ae4307ff restored code generation for OCaml
haftmann
parents: 31870
diff changeset
   171
code_const Array.nth' (OCaml "(fun/ ()/ ->/ Array.get/ _/ (Big'_int.int'_of'_big'_int/ _))")
5b88ae4307ff restored code generation for OCaml
haftmann
parents: 31870
diff changeset
   172
code_const Array.upd' (OCaml "(fun/ ()/ ->/ Array.set/ _/ (Big'_int.int'_of'_big'_int/ _)/ _)")
26182
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   173
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   174
code_reserved OCaml Array
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   175
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   176
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   177
subsubsection {* Haskell *}
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   178
29793
86cac1fab613 changed name space policy for Haskell includes
haftmann
parents: 29399
diff changeset
   179
code_type array (Haskell "Heap.STArray/ Heap.RealWorld/ _")
26182
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   180
code_const Array (Haskell "error/ \"bare Array\"")
29793
86cac1fab613 changed name space policy for Haskell includes
haftmann
parents: 29399
diff changeset
   181
code_const Array.new' (Haskell "Heap.newArray/ (0,/ _)")
86cac1fab613 changed name space policy for Haskell includes
haftmann
parents: 29399
diff changeset
   182
code_const Array.of_list' (Haskell "Heap.newListArray/ (0,/ _)")
86cac1fab613 changed name space policy for Haskell includes
haftmann
parents: 29399
diff changeset
   183
code_const Array.length' (Haskell "Heap.lengthArray")
86cac1fab613 changed name space policy for Haskell includes
haftmann
parents: 29399
diff changeset
   184
code_const Array.nth' (Haskell "Heap.readArray")
86cac1fab613 changed name space policy for Haskell includes
haftmann
parents: 29399
diff changeset
   185
code_const Array.upd' (Haskell "Heap.writeArray")
26182
8262ec0e8782 added code generator setup
haftmann
parents: 26170
diff changeset
   186
26170
66e6b967ccf1 added theories for imperative HOL
haftmann
parents:
diff changeset
   187
end