Library Heap

Parameter Heap : SetSet.
Parameter Loc : Set.

Parameter empty : {A}, Heap A.
Parameter deref : {A}, Heap ALocoption A.
Parameter update : {A}, Heap ALocAHeap A.
Parameter alloc : {A}, Heap AA → (Heap A × Loc).

Parameter hmap: {A B : Set}, (AB) → Heap AHeap B.

Axiom hmap_empty : {A B : Set} {f : AB}, hmap f empty = empty.
Axiom hmap_deref : {A B : Set} {f : AB} h l, deref (hmap f h) l = option_map f (deref h l).
Axiom hmap_update : {A B : Set} {f : AB} h l e, update (hmap f h) l (f e) = hmap f (update h l e).
Axiom hmap_alloc : {A B : Set} {f : AB} {h : Heap A} {h' : Heap A} l e,
                     alloc (hmap f h) (f e) = (hmap f h', l)
                      alloc h e = (h', l).