(** The semantics of maps is given by the function [MapGet]. The semantics of a map [m] is a partial, finite function from [ad] to [A]: *)
Definition newMap := M0.
Definition MapSingleton := M1.
Definition eqm (g g':ad -> option A) := forall a:ad, g a = g' a.

(* Specifications: *)
Lemma newMap_semantics : eqm (MapGet newMap) (fun a:ad => None).
Lemma MapSingleton_semantics :
forall (a:ad) (y:A),
eqm (MapGet (MapSingleton a y))
(fun a':ad => if Neqb a a' then Some y else None).
Lemma M1_semantics_1 : forall (a:ad) (y:A), MapGet (M1 a y) a = Some y.
Lemma M1_semantics_2 :
forall (a a':ad) (y:A), Neqb a a' = false -> MapGet (M1 a y) a' = None.
Lemma Map2_semantics_1 :
forall m m':Map,
eqm (MapGet m) (fun a:ad => MapGet (M2 m m') (Ndouble a)).
Lemma Map2_semantics_1_eq :
forall (m m':Map) (f:ad -> option A),
eqm (MapGet (M2 m m')) f -> eqm (MapGet m) (fun a:ad => f (Ndouble a)).
Lemma Map2_semantics_2 :
forall m m':Map,
eqm (MapGet m') (fun a:ad => MapGet (M2 m m') (Ndouble_plus_one a)).
Lemma Map2_semantics_2_eq :
forall (m m':Map) (f:ad -> option A),
eqm (MapGet (M2 m m')) f ->
eqm (MapGet m') (fun a:ad => f (Ndouble_plus_one a)).
Lemma MapGet_M2_bit_0_0 :
forall a:ad,
Nbit0 a = false ->
forall m m':Map, MapGet (M2 m m') a = MapGet m (Ndiv2 a).
Lemma MapGet_M2_bit_0_1 :
forall a:ad,
Nbit0 a = true ->
forall m m':Map, MapGet (M2 m m') a = MapGet m' (Ndiv2 a).
Lemma MapGet_M2_bit_0_if :
forall (m m':Map) (a:ad),
MapGet (M2 m m') a =
(if Nbit0 a then MapGet m' (Ndiv2 a) else MapGet m (Ndiv2 a)).
Lemma MapGet_M2_bit_0 :
forall (m m' m'':Map) (a:ad),
(if Nbit0 a then MapGet (M2 m' m) a else MapGet (M2 m m'') a) =
MapGet m (Ndiv2 a).
Lemma Map2_semantics_3 :
forall m m':Map,
eqm (MapGet (M2 m m'))
(fun a:ad =>
match Nbit0 a with
| false => MapGet m (Ndiv2 a)
| true => MapGet m' (Ndiv2 a)
end).
Lemma Map2_semantics_3_eq :
forall (m m':Map) (f f':ad -> option A),
eqm (MapGet m) f ->
eqm (MapGet m') f' ->
eqm (MapGet (M2 m m'))
(fun a:ad =>
match Nbit0 a with
| false => f (Ndiv2 a)
| true => f' (Ndiv2 a)
end).