library colibrilib.tagtbl — module TagtblIntfThe interface: the table h maps the keys of h.defined to h.contents
module TagtblIntf21
Abstract
use int.Int23use mach.int.Int6324use map.Map25use map.Const26Valid (12ms) (colibri2)27clone export S {… begin (* cloned colibrilib.tagtbl.S *) type key val function tag key : int63 axiom tag_correct end } with axiom tag_correct2829type t 'a = abstract {30mutable contents: map key 'a;31defined: key -> bool;32length: int;33}3435function ([]) (h: t 'a) (k: key) : 'a = Map.get h.contents k36
h stores the key k
predicate mem (k: key) (h: t 'a) = h.defined k39
The table of the keys of defined, all mapped to def
Valid (21ms) (colibri2)val create (s: int63) (def: 'a) (ghost defined: key -> bool) : t 'a42requires { forall k. defined k -> 0 <= tag k <= s }43requires { -1 <= s < max_int63 }44ensures { result.contents = const def }45ensures { result.defined = defined }46ensures { result.length = s }47
The largest tag stored
Valid (11ms) (colibri2)val function max_tags (h: t 'a) : int6350ensures { result = h.length }51Valid (11ms) (colibri2)52val set (h: t 'a) (k: key) (v: 'a) : unit53requires { mem k h }54writes { h.contents }55ensures { h.contents = Map.set (old h.contents) k v }56Valid (14ms) (colibri2)57val find (h: t 'a) (k: key) : 'a58requires { mem k h }59ensures { result = h[k] }6061end62