Variable eqK : K -> K -> bool.
Notation "i '==' j" := (eqK i j) (at level 80, right associativity).
Definition totalMap := K -> V.
Definition emptyTMap (v : V) : totalMap := fun _ => v.
Definition updateTMap (m : totalMap) (k : K) (v : V) :=
fun k' => if k == k' then v else m k'.
Variable eqK : K -> K -> bool.
Definition partialMap := totalMap K (option V).
Definition emptyPMap : partialMap := emptyTMap None.
Definition updatePMap (m : partialMap) (k : K) (v : V) :=
updateTMap eqK m k (Some v).
Variable eqK : K -> K -> bool.
Notation "i '==' j" := (eqK i j) (at level 80, right associativity).
Definition listMap := list (K * V).
Definition add (kvs : listMap) (k : K) (v : V) : listMap :=
Fixpoint update (kvs : listMap) (k : K) (v : V) : listMap :=
| cons (k',v') kvs' => if (k' == k) then cons (k',v) kvs'
else cons (k',v') (update kvs' k v)
Fixpoint lookup (kvs : listMap) (k : K) : option V :=
| cons (k',v) kvs' => if (k' == k) then Some v
Definition union (kvs1 kvs2 : listMap) : listMap := app kvs1 kvs2.
Lemma lookup_deterministic :
forall (A B : Type) (eqA : A -> A -> bool) (Sigma : listMap A B) (k : A) (v1 v2 : option B),
lookup eqA Sigma k = v1 ->
lookup eqA Sigma k = v2 ->
Lemma lookupT_deterministic :
forall (A B : Type) (Sigma : totalMap A B) (k : A) (v1 v2 : B),
Lemma lookupP_deterministic :
forall (A B : Type) (Sigma : partialMap A B) (k : A) (v1 v2 : option B),
forall (A B : Type) (eqA : A -> A -> bool) (Sigma : totalMap A B) (k : A) (v : B),
(forall x : A, eqA x x = true) ->
(updateTMap eqA Sigma k v) k = v.
forall (A B : Type) (eqA : A -> A -> bool) (Sigma : totalMap A B) (k1 k2 : A) (v1 v2 : B),
(updateTMap eqA Sigma k2 v2) k1 = Sigma k1.
forall (A B : Type) (eqA : A -> A -> bool) (Sigma : listMap A B) (k : A) (v : B),
(forall x : A, eqA x x = true) ->
lookup eqA (add Sigma k v) k = Some v.
forall (A B : Type) (eqA : A -> A -> bool) (Sigma : listMap A B) (k1 k2 : A) (v : B),
lookup eqA (add Sigma k2 v) k1 = lookup eqA Sigma k1.
forall (A B : Type) (eqA : A -> A -> bool) (Sigma : listMap A B) (k : A) (v : B),
(forall x : A, eqA x x = true) ->
lookup eqA (update eqA Sigma k v) k = Some v.
destruct (eqA k' k) eqn:HeqKK.
forall (A B : Type) (eqA : A -> A -> bool) (Sigma : listMap A B) (k1 k2 : A) (v : B),
(forall x y z : A, eqA x y = eqA x z -> true = eqA y z) ->
lookup eqA (update eqA Sigma k2 v) k1 = lookup eqA Sigma k1.
destruct (eqA k' k2) eqn:HeqKK2.
destruct (eqA k' k1) eqn:HeqKK1.
* rewrite <- HeqKK1 in HeqKK2.
specialize (H k' k2 k1 HeqKK2).
destruct (eqA k' k1) eqn:HeqKK1.
forall (A B : Type) (eqA : A -> A -> bool) (Sigma Delta : listMap A B) (k : A),
lookup eqA Delta k = None ->
lookup eqA (union Delta Sigma ) k = lookup eqA Sigma k.