-
Notifications
You must be signed in to change notification settings - Fork 42
/
HashMap.thy
655 lines (590 loc) · 19 KB
/
HashMap.thy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
theory "HashMap"
imports "lem/Evm" "Hoare"
"HoareTripleForInstructions"
"HoareTripleForStorage"
"HoareTripleForMemory"
begin
declare memory_as_set_def [simp add]
fun storage_array :: "w256 \<Rightarrow> w256 list \<Rightarrow> set_pred" where
"storage_array ind [] = emp"
| "storage_array ind (a#b) = storage ind a ** storage_array (ind+1) b"
fun assoc :: "(w256*w256) list \<Rightarrow> set_pred" where
"assoc [] = emp"
| "assoc ((key,a)#xs) = storage key a ** assoc xs"
definition hash_pair :: "w256 \<Rightarrow> w256*w256 \<Rightarrow> w256*w256" where
"hash_pair table p = (hash2 table (fst p), snd p)"
definition hash_pair_z :: "w256 \<Rightarrow> w256*w256 \<Rightarrow> w256*w256" where
"hash_pair_z table p = (hash2 table (fst p), 0)"
definition mapping :: "w256 \<Rightarrow> (w256*w256) list \<Rightarrow> set_pred" where
"mapping ind lst = assoc (map (hash_pair ind) lst)"
fun get :: "w256 \<Rightarrow> (w256*w256) list \<Rightarrow> w256" where
"get k [] = 0"
| "get k ((ok,ov)#xs) = (if k = ok then ov else get k xs)"
fun mem :: "w256 \<Rightarrow> (w256*w256) list \<Rightarrow> bool" where
"mem k [] = False"
| "mem k ((ok,ov)#xs) = (k = ok \<or> mem k xs)"
fun remove :: "w256 \<Rightarrow> (w256*w256) list \<Rightarrow> (w256*w256) list" where
"remove k [] = []"
| "remove k ((ok,ov)#xs) =
(if k = ok then xs else (ok,ov)#remove k xs)"
fun add :: "w256 \<Rightarrow> w256 \<Rightarrow> (w256*w256) list \<Rightarrow> (w256*w256) list" where
"add k v lst = (k,v)#remove k lst"
lemma add_not_mem : "\<not> (mem k lst) \<Longrightarrow> add k v lst = (k,v)#lst"
apply (induction lst)
apply(auto)
done
lemma stored :
"mem k mp \<Longrightarrow>
assoc mp = assoc (remove k mp) ** storage k (get k mp)"
apply (induction mp)
apply(auto)
done
lemma stored_hash_from_mapping :
"mem k mp \<Longrightarrow>
mapping ind mp =
mapping ind (remove k mp) ** storage (hash2 ind k) (get k mp)"
apply (induction mp)
apply(auto simp:mapping_def hash_pair_def)
done
lemma minus_test : "a - {x} - {y} = a - {y} - {x}"
apply auto
done
lemma mapping_cons :
"mapping ind ((k,v)#mp) = storage (hash2 ind k) v ** mapping ind mp"
apply (induction mp)
apply(auto simp:mapping_def minus_test hash_pair_def)
done
lemma set_storage1 :
assumes a:"mem key m"
shows "triple {OutOfGas}
(\<langle> h \<le> 1024 \<rangle> **
stack (h+1) (hash2 table key) **
stack h v **
stack_height (h+2) **
mapping table m **
program_counter k **
gas_pred g **
continuing)
{(k, Storage SSTORE)}
(mapping table (add key v m) **
program_counter (k+1) **
gas_pred (g - Csstore (get key m) v) **
stack_height h **
continuing)" (is "triple _ ?pre _ ?post")
proof -
from a have good_pre: "?pre =
(\<langle> h \<le> 1024 \<rangle> **
stack_height (h+2) **
stack (h+1) (hash2 table key) **
stack h v **
program_counter k **
storage (hash2 table key) (get key m) **
gas_pred g **
continuing) **
mapping table (remove key m)"
(is "?pre = ?presmall ** _")
by (auto simp:stored_hash_from_mapping)
have good_post: "?post = (
stack_height h **
program_counter (k+1) **
storage (hash2 table key) v **
gas_pred (g - Csstore (get key m) v) **
continuing) **
mapping table (remove key m)" (is "_ = ?postsmall ** _")
by (auto simp:mapping_cons)
have "triple {OutOfGas} ?presmall {(k, Storage SSTORE)} ?postsmall"
by (rule sstore_gas_triple)
then have "triple {OutOfGas} (?presmall ** mapping table (remove key m))
{(k, Storage SSTORE)} (?postsmall ** mapping table (remove key m))"
by (rule frame)
then show ?thesis using good_pre and good_post by simp
qed
lemma set_storage2 :
assumes a:"\<not> (mem key m)"
shows "triple {OutOfGas}
(\<langle> h \<le> 1024 \<rangle> **
stack (h+1) (hash2 table key) **
stack h v **
stack_height (h+2) **
mapping table m **
storage (hash2 table key) 0 **
program_counter k **
gas_pred g **
continuing)
{(k, Storage SSTORE)}
(mapping table (add key v m) **
program_counter (k+1) **
gas_pred (g - Csstore 0 v) **
stack_height h **
continuing)" (is "triple _ ?pre _ ?post")
proof -
have good_pre: "?pre =
(\<langle> h \<le> 1024 \<rangle> **
stack_height (h+2) **
stack (h+1) (hash2 table key) **
stack h v **
program_counter k **
storage (hash2 table key) 0 **
gas_pred g **
continuing) **
mapping table m"
(is "?pre = ?presmall ** _")
by (auto simp:stored_hash_from_mapping)
from a have good_post: "?post = (
stack_height h **
program_counter (k+1) **
storage (hash2 table key) v **
gas_pred (g - Csstore 0 v) **
continuing) **
mapping table m" (is "_ = ?postsmall ** _")
by (subst add_not_mem) (auto simp:mapping_cons)
have "triple {OutOfGas} ?presmall {(k, Storage SSTORE)} ?postsmall"
by (rule sstore_gas_triple)
then have "triple {OutOfGas} (?presmall ** mapping table m)
{(k, Storage SSTORE)} (?postsmall ** mapping table m)"
by (rule frame)
then show ?thesis using good_pre and good_post by simp
qed
definition perhaps_alloc ::
"w256 \<Rightarrow> w256 \<Rightarrow> (w256*w256) list \<Rightarrow> set_pred" where
"perhaps_alloc ind k lst =
(if mem k lst then emp else storage (hash2 ind k) 0)"
lemma mem_perhaps :
"mem key m \<Longrightarrow>
mapping table m ** perhaps_alloc table key m =
mapping table m"
apply(auto simp:perhaps_alloc_def)
done
lemma mem_perhaps_not :
"\<not>mem key m \<Longrightarrow>
mapping table m ** perhaps_alloc table key m =
mapping table m ** storage (hash2 table key) 0"
apply(auto simp:perhaps_alloc_def)
done
lemma not_mem_get_zero : "\<not>mem key m \<Longrightarrow> get key m = 0"
apply (induction m)
apply (auto)
done
lemma set_storage :
"triple {OutOfGas}
(\<langle> h \<le> 1024 \<rangle> **
stack (h+1) (hash2 table key) **
stack h v **
stack_height (h+2) **
(mapping table m ** perhaps_alloc table key m) **
program_counter k **
gas_pred g **
continuing)
{(k, Storage SSTORE)}
(mapping table (add key v m) **
program_counter (k+1) **
gas_pred (g - Csstore (get key m) v) **
stack_height h **
continuing)"
apply (cases "mem key m")
apply(subst mem_perhaps)
apply(simp)
using set_storage1
apply(simp)
apply(subst mem_perhaps_not)
apply(simp)
apply(subst not_mem_get_zero)
apply(simp)
using set_storage2
apply(auto)
done
lemma get_storage1 :
assumes a:"mem key m"
shows
"triple {OutOfGas}
(\<langle>h \<le> 1023 \<and> unat bn \<ge> 2463000 \<rangle> **
stack_height (h+1) **
stack h (hash2 table key) **
mapping table m **
block_number_pred bn **
program_counter k **
gas_pred g **
continuing)
{(k, Storage SLOAD)}
(stack h (get key m) **
mapping table m **
program_counter (k+1) **
block_number_pred bn **
gas_pred (g - Gsload (unat bn)) **
stack_height (h+1) **
continuing)"
(is "triple _ ?pre _ ?post")
proof -
from a have good_pre: "?pre =
(\<langle>h \<le> 1023 \<and> unat bn \<ge> 2463000 \<rangle> **
block_number_pred bn ** stack_height (h + 1) **
stack h (hash2 table key) **
program_counter k **
storage (hash2 table key) (get key m) **
gas_pred g ** continuing) **
mapping table (remove key m)"
(is "?pre = ?presmall ** _")
by (auto simp:stored_hash_from_mapping)
have good_post: "?post = (
block_number_pred bn ** stack_height (h + 1) **
stack h (get key m) **
program_counter (k + 1) **
storage (hash2 table key) (get key m) **
gas_pred (g - Gsload (unat bn)) ** continuing ) **
mapping table (remove key m)" (is "_ = ?postsmall ** _")
by (subst stored_hash_from_mapping) (auto simp:a)
have "triple {OutOfGas} ?presmall {(k, Storage SLOAD)} ?postsmall"
by (rule sload_gas_triple)
then have "triple {OutOfGas} (?presmall ** mapping table (remove key m))
{(k, Storage SLOAD)} (?postsmall ** mapping table (remove key m))"
by (rule frame)
then show ?thesis using good_pre and good_post by simp
qed
lemma get_storage2 :
assumes a:"\<not>mem key m"
shows
"triple {OutOfGas}
(\<langle>h \<le> 1023 \<and> unat bn \<ge> 2463000 \<rangle> **
stack_height (h+1) **
stack h (hash2 table key) **
mapping table m **
storage (hash2 table key) (get key m) **
block_number_pred bn **
program_counter k **
gas_pred g **
continuing)
{(k, Storage SLOAD)}
(stack h (get key m) **
mapping table m **
storage (hash2 table key) (get key m) **
program_counter (k+1) **
block_number_pred bn **
gas_pred (g - Gsload (unat bn)) **
stack_height (h+1) **
continuing)"
(is "triple _ ?pre _ ?post")
proof -
from a have good_pre: "?pre =
(\<langle>h \<le> 1023 \<and> unat bn \<ge> 2463000 \<rangle> **
block_number_pred bn ** stack_height (h + 1) **
stack h (hash2 table key) **
program_counter k **
storage (hash2 table key) 0 **
gas_pred g ** continuing) **
mapping table m"
(is "?pre = ?presmall ** _")
by (simp add:not_mem_get_zero)
from a have good_post: "?post = (
block_number_pred bn ** stack_height (h + 1) **
stack h 0 **
program_counter (k + 1) **
storage (hash2 table key) 0 **
gas_pred (g - Gsload (unat bn)) ** continuing ) **
mapping table m" (is "_ = ?postsmall ** _")
by (simp add:not_mem_get_zero)
have "triple {OutOfGas} ?presmall {(k, Storage SLOAD)} ?postsmall"
by (rule sload_gas_triple)
then have "triple {OutOfGas} (?presmall ** mapping table m)
{(k, Storage SLOAD)} (?postsmall ** mapping table m)"
by (rule frame)
then show ?thesis using good_pre and good_post by simp
qed
lemma get_storage :
"triple {OutOfGas}
(\<langle>h \<le> 1023 \<and> unat bn \<ge> 2463000 \<rangle> **
stack_height (h+1) **
stack h (hash2 table key) **
( mapping table m ** perhaps_alloc table key m ) **
block_number_pred bn **
program_counter k **
gas_pred g **
continuing)
{(k, Storage SLOAD)}
(stack h (get key m) **
( mapping table m ** perhaps_alloc table key m ) **
program_counter (k+1) **
block_number_pred bn **
gas_pred (g - Gsload (unat bn)) **
stack_height (h+1) **
continuing)"
apply (cases "mem key m")
apply(subst mem_perhaps)
apply(simp)
apply(subst mem_perhaps)
apply(simp)
using get_storage1
apply(simp)
apply(subst mem_perhaps_not)
apply(simp)
apply(subst mem_perhaps_not)
apply(simp)
using get_storage2
apply(auto simp:not_mem_get_zero)
done
definition zero_table :: "w256 \<Rightarrow> state_element set" where
"zero_table table = {StorageElm (hash2 table key,0) | key.
hash2 table key \<noteq> 0}"
(* set with exactly correct elems *)
definition alloc_zero_table :: "w256 \<Rightarrow> set_pred" where
"alloc_zero_table table = (\<lambda>st. st = zero_table table)"
definition alloc_zero_tables :: "w256 \<Rightarrow> w256 \<Rightarrow> set_pred" where
"alloc_zero_tables t1 t2 = (\<lambda>st. st = zero_table t1 \<union> zero_table t2)"
lemma separate_table :
"a \<noteq> b \<Longrightarrow> zero_table a \<inter> zero_table b = {}"
apply (auto simp:zero_table_def)
using hash_inj
apply force
done
lemma separate_table2 :
"a \<noteq> b \<Longrightarrow>
alloc_zero_tables a b = alloc_zero_table a ** alloc_zero_table b"
apply(auto simp:alloc_zero_table_def alloc_zero_tables_def
sep_def separate_table)
done
definition assoc_set ::
"(w256*w256) list \<Rightarrow> state_element set" where
"assoc_set m = {StorageElm (a,b) | a b. (a,b) \<in> set m}"
definition mapping_set ::
"w256 \<Rightarrow> (w256*w256) list \<Rightarrow> state_element set" where
"mapping_set table m = assoc_set (map (hash_pair table) m)"
definition mapping_set_z ::
"w256 \<Rightarrow> (w256*w256) list \<Rightarrow> state_element set" where
"mapping_set_z table m = assoc_set (map (hash_pair_z table) m)"
definition mapping_zero ::
"w256 \<Rightarrow> (w256*w256) list \<Rightarrow> state_element set" where
"mapping_zero table m = zero_table table - mapping_set_z table m"
definition alloc_zero ::
"w256 \<Rightarrow> (w256*w256) list \<Rightarrow> set_pred" where
"alloc_zero table m = (\<lambda>st. st = mapping_zero table m)"
lemma start_table :
"alloc_zero_table t = alloc_zero t [] ** mapping t []"
apply(auto simp:alloc_zero_table_def alloc_zero_def sep_def
mapping_def mapping_zero_def mapping_set_def emp_def
assoc_set_def mapping_set_z_def)
done
lemma easy : "p \<in> set m \<Longrightarrow> f p \<in> set (map f m)"
apply (induction m)
apply auto
done
lemma hp_simp : "fst \<circ> hash_pair t = hash2 t \<circ> fst"
apply(auto simp:hash_pair_def)
done
lemma hp_simp2 : "fst (hash_pair t (a, b)) = hash2 t a"
apply(auto simp:hash_pair_def)
done
lemma easy2 : "aa \<notin> fst ` set m \<Longrightarrow> (aa, b) \<in> set m \<Longrightarrow> False"
by (simp add: rev_image_eqI)
lemma add_mapping_set :
"mem a m \<Longrightarrow> fst ` (set m) = fst ` (set (add a b m))"
apply (induction m)
apply (simp)
apply (auto)
apply force
defer
apply force
subgoal for aa b m aaa ba
apply (cases "a = aa")
apply force
apply force
done
subgoal for aa b m aaa ba
apply (cases "a = aa")
apply force
apply force
done
done
lemma hp_unfold : "(hash2 t key, b) = hash_pair t (key,b)"
apply (simp add:hash_pair_def)
done
lemma hp_z_unfold : "(hash2 t key, 0) = hash_pair_z t (key,b)"
apply (simp add:hash_pair_z_def)
done
lemma storage_simp :
"hash2 t key \<noteq> 0 \<Longrightarrow>
(StorageElm (hash2 t key, 0) \<in> mapping_set_z t m) =
(key \<in> fst ` (set m))"
apply (auto simp:mapping_set_z_def assoc_set_def hash_pair_z_def)
using hash_inj2
apply force
subgoal for b
using Set.imageI [of "(key,b)" "set m" "hash_pair_z t"]
apply (subst hp_z_unfold)
apply force
done
done
declare add.simps [simp del]
lemma add_mapping_set2 :
"mem a m \<Longrightarrow> fst ` (set (add a b m)) = fst ` (set m)"
using add_mapping_set
apply simp
done
lemma alloc_zero_mem :
"mem a m \<Longrightarrow>
mapping_zero t (add a b m) = mapping_zero t m"
apply(auto simp:alloc_zero_table_def alloc_zero_def sep_def
emp_def zero_table_def mapping_zero_def)
apply (auto simp:storage_simp)
apply (auto simp:add_mapping_set2)
apply force
using add_mapping_set
apply force
done
lemma mem_as_set : "\<not> mem aa m \<Longrightarrow> (aa, b) \<in> set m \<Longrightarrow> False"
apply (induction m)
apply (auto)
done
(* alloc zero needs to carry the invariant *)
lemma alloc_zero_split :
"hash2 t a \<noteq> 0 \<Longrightarrow>
alloc_zero t m = alloc_zero t (add a b m) ** perhaps_alloc t a m"
apply(auto simp:alloc_zero_table_def alloc_zero_def sep_def
emp_def zero_table_def perhaps_alloc_def)
apply(rule funext)
apply (simp add:alloc_zero_mem)
apply(auto)[1]
apply(rule funext)
apply (simp add:add_not_mem)
apply (auto)
apply (rule exI [of "_" "{StorageElm (hash2 t a, 0)}"])
apply (auto simp:mapping_zero_def mapping_set_z_def
hash_pair_z_def assoc_set_def storage_def)
apply (simp add:zero_table_def)
apply auto
defer
apply (simp add:zero_table_def)
apply auto
subgoal for aa b
using hash_inj2 [of t a t aa]
apply auto
using mem_as_set
apply force
done
subgoal for aa b
using hash_inj2 [of t a t aa]
apply auto
using mem_as_set
apply force
done
done
lemma alloc_zero_split2 :
"hash2 t a \<noteq> 0 \<Longrightarrow>
alloc_zero t (add a b m) ** perhaps_alloc t a m = alloc_zero t m"
using alloc_zero_split
apply simp
done
lemma alloc_table :
"hash2 t a \<noteq> 0 \<Longrightarrow>
alloc_zero t m ** mapping t m =
mapping t m ** (alloc_zero t (add a b m) ** perhaps_alloc t a m)"
apply (subst alloc_zero_split2)
apply auto
done
definition htable :: "w256 \<Rightarrow> (w256 * w256) list \<Rightarrow> set_pred" where
"htable t m = alloc_zero t m ** mapping t m"
lemma set_table :
assumes a:"hash2 table key \<noteq> 0"
shows "triple {OutOfGas}
(\<langle> h \<le> 1024 \<rangle> **
stack (h+1) (hash2 table key) **
stack h v **
stack_height (h+2) **
htable table m **
program_counter k **
gas_pred g **
continuing)
{(k, Storage SSTORE)}
(htable table (add key v m) **
program_counter (k+1) **
gas_pred (g - Csstore (get key m) v) **
stack_height h **
continuing)" (is "triple _ ?pre _ ?post")
proof -
have good_pre: "?pre =
(\<langle> h \<le> 1024 \<rangle> **
stack (h+1) (hash2 table key) **
stack h v **
stack_height (h+2) **
(mapping table m ** perhaps_alloc table key m) **
program_counter k **
gas_pred g **
continuing) **
alloc_zero table (add key v m)"
(is "?pre = ?presmall ** _")
using a
apply (subst htable_def)
apply (subst alloc_table)
apply (auto)
done
have good_post: "?post = (
mapping table (add key v m) **
program_counter (k+1) **
gas_pred (g - Csstore (get key m) v) **
stack_height h **
continuing) **
alloc_zero table (add key v m)"
(is "_ = ?postsmall ** _")
apply (subst htable_def) apply (auto) done
have "triple {OutOfGas} ?presmall {(k, Storage SSTORE)} ?postsmall"
using set_storage by force
then have "triple {OutOfGas} (?presmall ** alloc_zero table (add key v m))
{(k, Storage SSTORE)} (?postsmall ** alloc_zero table (add key v m))"
by (rule frame)
then show ?thesis using good_pre and good_post by simp
qed
lemma get_table :
assumes a:"hash2 table key \<noteq> 0"
shows
"triple {OutOfGas}
(\<langle>h \<le> 1023 \<and> unat bn \<ge> 2463000 \<rangle> **
stack_height (h+1) **
stack h (hash2 table key) **
htable table m **
block_number_pred bn **
program_counter k **
gas_pred g **
continuing)
{(k, Storage SLOAD)}
(stack h (get key m) **
htable table m **
program_counter (k+1) **
block_number_pred bn **
gas_pred (g - Gsload (unat bn)) **
stack_height (h+1) **
continuing)"
(is "triple _ ?pre _ ?post")
proof -
from a have good_pre: "?pre =
(\<langle>h \<le> 1023 \<and> unat bn \<ge> 2463000 \<rangle> **
stack_height (h+1) **
stack h (hash2 table key) **
( mapping table m ** perhaps_alloc table key m ) **
block_number_pred bn **
program_counter k **
gas_pred g **
continuing) ** alloc_zero table (add key 0 m)"
(is "?pre = ?presmall ** _")
apply (subst htable_def)
apply (subst alloc_table)
apply (auto)
done
from a have good_post: "?post = (
stack h (get key m) **
( mapping table m ** perhaps_alloc table key m ) **
program_counter (k+1) **
block_number_pred bn **
gas_pred (g - Gsload (unat bn)) **
stack_height (h+1) **
continuing) **
alloc_zero table (add key 0 m)" (is "_ = ?postsmall ** _")
apply (subst htable_def)
apply (subst alloc_table)
apply (auto)
done
have "triple {OutOfGas} ?presmall {(k, Storage SLOAD)} ?postsmall"
by (rule get_storage)
then have "triple {OutOfGas} (?presmall ** alloc_zero table (add key 0 m))
{(k, Storage SLOAD)} (?postsmall ** alloc_zero table (add key 0 m))"
by (rule frame)
then show ?thesis using good_pre and good_post by simp
qed
end