Common — library colibrilib.tagtbl — module TagtblIntf

The interface: the table h maps the keys of h.defined to h.contents

21
module TagtblIntf

Abstract

23
use int.Int
24
use mach.int.Int63
25
use map.Map
26
use map.Const
27
Valid (12ms) (colibri2)
28
clone export S {… begin (* cloned colibrilib.tagtbl.S *) type
key
val function
tag
key : int63 axiom
tag_correct
end
}
with axiom tag_correct
29
30
type
t
'a = abstract {
31
mutable
contents
: map key 'a;
32
defined
: key -> bool;
33
length
: int;
34
}
35
36
function (
[]
) (h: t 'a) (k: key) : 'a = Map.get h.contents k

h stores the key k

39
predicate
mem
(k: key) (h: t 'a) = h.defined k

The table of the keys of defined, all mapped to def

  Valid (21ms) (colibri2)
42
val
create
(s: int63) (def: 'a) (ghost defined: key -> bool) : t 'a
43
requires { forall k. defined k -> 0 <= tag k <= s }
44
requires { -1 <= s < max_int63 }
45
ensures { result.contents = const def }
46
ensures { result.defined = defined }
47
ensures { result.length = s }

The largest tag stored

  Valid (11ms) (colibri2)
50
val function
max_tags
(h: t 'a) : int63
51
ensures { result = h.length }
52
Valid (11ms) (colibri2)
53
val
set
(h: t 'a) (k: key) (v: 'a) : unit
54
requires { mem k h }
55
writes { h.contents }
56
ensures { h.contents = Map.set (old h.contents) k v }
57
Valid (14ms) (colibri2)
58
val
find
(h: t 'a) (k: key) : 'a
59
requires { mem k h }
60
ensures { result = h[k] }
61
62
end