(* ---------------------------------------------------------------------- *)
(** **** Properties of all_binds *)

(* Specifications: *)
(** All_Binds and binds. *)
Theorem all_binds_binds : forall A x (v : A) (E : gen_env A),
(x ∶ v) ⊏ E ->
x ∹ v ⋲ E.
Theorem binds_all_binds : forall A x (v : A) (E : gen_env A),
x ∹ v ⋲ E ->
(x ∶ v) ⊏ E.
(** All_Binds and empty. *)
Theorem all_binds_empty_l : forall A (E : gen_env A),
(@empty A) ⊏ E.
Theorem all_binds_empty_r : forall A (E : gen_env A),
E ⊏ (@empty A) ->
E = (@empty A).
(** All_Binds on singular. *)
Theorem all_binds_single_empty : forall A x (v : A),
(x ∶ v) ⊏ (@empty A) ->
False.
Theorem all_binds_single_single : forall A x y (v w : A),
x = y -> v = w ->
(x ∶ v) ⊏ (y ∶ w).
Theorem all_binds_single_single_inv : forall A x y (v w : A),
(x ∶ v) ⊏ (y ∶ w) ->
x = y ∧ v = w.
Theorem all_binds_single_push_inv : forall A x y (v w : A) (E : gen_env A),
(x ∶ v) ⊏ (E & (y ∶ w)) ->
(x = y ∧ v = w) ∨ (x <> y ∧ (x ∶ v) ⊏ E).
Theorem all_binds_single_singles : forall A x y (v w : A) ys (ws : list A),
x = y -> v = w ->
(x ∶ v) ⊏ (y :: ys ∷ w :: ws).
Theorem all_binds_single_singles_inv :
forall A x y (v w : A) ys (ws : list A),
(x ∶ v) ⊏ (y :: ys ∷ w :: ws) ->
(x = y ∧ v = w) ∨ ((x ∶ v) ⊏ (ys ∷ ws)).
Theorem all_binds_single_eq_inv : forall A x (v w : A) (E : gen_env A),
(x ∶ v) ⊏ E -> (x ∶ w) ⊏ E ->
v = w.
(** All_Binds on singulars. *)
Theorem all_binds_singles_singles : forall A xs ys (vs ws : list A),
xs = ys -> vs = ws ->
(xs ∷ vs) ⊏ (ys ∷ ws).
(** All_Binds and concatenation. *)
Theorem all_binds_concat_r : forall A (E F G : gen_env A),
E ⊏ G ->
E ⊏ (F & G).
Theorem all_binds_concat_l : forall A (E F G : gen_env A),
E ⊏ F ->
(dom E) ⊄ G ->
E ⊏ (F & G).
Theorem all_binds_l_concat : forall A (E F G : gen_env A),
E ⊏ G -> F ⊏ G ->
(E & F) ⊏ G.
Theorem all_binds_l_concat_inv : forall A (E F G : gen_env A),
ok (E & F) ->
(E & F) ⊏ G ->
E ⊏ G ∧ F ⊏ G.
Theorem all_binds_concat_compat : forall A (E F G : gen_env A),
E ⊏ F ->
(E & G) ⊏ (F & G).
(** All_Binds on singulars when ok. *)
Theorem all_binds_singles_eq_inv :
forall A xs (vs vs' : list A) (F : gen_env A),
List.NoDup xs ->
length xs = length vs ->
length xs = length vs' ->
xs ∷ vs ⊏ F -> xs ∷ vs' ⊏ F ->
vs = vs'.
(** All_Binds and belongs. *)
Theorem all_binds_belongs : forall A (E F : gen_env A),
E ⊏ F ->
(dom E) ⊂ F.
Theorem belongs_all_binds : forall A x (F : gen_env A),
x ∈ F ->
exists v, (x ∶ v) ⊏ F.
Theorem all_belongs_all_binds : forall A xs (F : gen_env A),
xs ⊂ F ->
exists vs, (xs ∷ vs) ⊏ F.
(** All_Binds and map. *)
Theorem all_binds_map : forall A B (f : A -> B) (E F : gen_env A),
E ⊏ F ->
map f E ⊏ map f F.
Theorem all_binds_map_inv : forall A B (f : A -> B) (E F : gen_env A),
Image.injective A B f ->
map f E ⊏ map f F ->
E ⊏ F.
(** All_Binds and update. *)
Theorem all_binds_update_self : forall A (E F : gen_env A),
(dom E) ⊂ F ->
E ⊏ (F ::= E).
Theorem all_binds_update : forall A (E F G : gen_env A),
E ⊏ F ->
(E ::= G) ⊏ (F ::= G).
(** All_Binds and remove. *)
Theorem all_binds_remove : forall A y (E F : gen_env A),
y ∉ E -> E ⊏ F ->
E ⊏ (F ∖ {y}).
Theorem all_binds_remove_inv : forall A y (E F : gen_env A),
y ∉ E -> E ⊏ (F ∖ {y}) ->
E ⊏ F.
Theorem all_binds_all_remove : forall A ys (E F : gen_env A),
ys ⊄ E -> E ⊏ F ->
E ⊏ (F ∖ ys).
Theorem all_binds_all_remove_inv : forall A ys (E F : gen_env A),
ys ⊄ E -> E ⊏ (F ∖ ys) ->
E ⊏ F.
Theorem all_binds_remove_compat : forall A x (E F : gen_env A),
ok E -> ok F ->
E ⊏ F ->
E ∖ {x} ⊏ F ∖ {x}.
Theorem all_binds_all_remove_compat : forall A xs (E F : gen_env A),
ok E -> ok F ->
E ⊏ F ->
E ∖ xs ⊏ F ∖ xs.
(** All_Binds and ok *)
Theorem all_binds_ok_concat_inv : forall A (E F G : gen_env A),
ok (E & F) ->
(E & F) ⊏ G ->
E ⊏ G ∧ F ⊏ G.
Theorem all_binds_concat_ok_comm : forall A (E F G : gen_env A),
E ⊏ (F & G) ->
ok (F & G) ->
E ⊏ (G & F).
(** All_Binds is reflexive, anti-symmetric and transitive *)
Theorem all_binds_refl : forall A (E F : gen_env A),
E = F ->
E ⊏ F.