(** * Properties of availability sets *)

(** These properties are not used in the semantic preservation proof,
    but establish some confidence in the availability analysis. *)

Definition avail_above (v: ident) (s: avail) : Prop :=
  forall v' i', In (v', i') s -> Plt v v'.Inductive wf_avail: avail -> Prop :=
  | wf_avail_nil:
      wf_avail nil
  | wf_avail_cons: forall v i s,
     avail_above v s ->
     wf_avail s ->
     wf_avail ((v, i) :: s).Inductive wf_avail: avail -> Prop :=
  | wf_avail_nil:
      wf_avail nil
  | wf_avail_cons: forall v i s,
     avail_above v s ->
     wf_avail s ->
     wf_avail ((v, i) :: s).Inductive wf_avail: avail -> Prop :=
  | wf_avail_nil:
      wf_avail nil
  | wf_avail_cons: forall v i s,
     avail_above v s ->
     wf_avail s ->
     wf_avail ((v, i) :: s).

(* Specifications: *)
Lemma set_state_1: forall v i s, In (v, i) (set_state v i s).
Lemma set_state_2: forall v i v' i' s, v' <> v -> In (v', i') s -> In (v', i') (set_state v i s).
Lemma set_state_3: forall v i v' i' s, wf_avail s -> In (v', i') (set_state v i s) -> (v' = v /\ i' = i) \/ (v' <> v /\ In (v', i') s).
Lemma wf_set_state: forall v i s, wf_avail s -> wf_avail (set_state v i s).
Lemma remove_state_1: forall v i s, wf_avail s -> ~ In (v, i) (remove_state v s).
Lemma remove_state_2: forall v v' i' s, v' <> v -> In (v', i') s -> In (v', i') (remove_state v s).
Lemma remove_state_3: forall v v' i' s, wf_avail s -> In (v', i') (remove_state v s) -> v' <> v /\ In (v', i') s.
Lemma wf_remove_state: forall v s, wf_avail s -> wf_avail (remove_state v s).
Lemma wf_filter: forall pred s, wf_avail s -> wf_avail (List.filter pred s).
Lemma join_1: forall v i s1, wf_avail s1 -> forall s2, wf_avail s2 -> In (v, i) s1 -> In (v, i) s2 -> In (v, i) (join s1 s2).
Lemma join_2: forall v i s1, wf_avail s1 -> forall s2, wf_avail s2 -> In (v, i) (join s1 s2) -> In (v, i) s1 /\ In (v, i) s2.
Lemma wf_join: forall s1, wf_avail s1 -> forall s2, wf_avail s2 -> wf_avail (join s1 s2).
Lemma symbols_preserved: forall (s: ident), Genv.find_symbol tge s = Genv.find_symbol ge s.
Lemma senv_preserved: Senv.equiv ge tge.
Lemma functions_translated: forall (v: val) (f: fundef), Genv.find_funct ge v = Some f -> exists tf, Genv.find_funct tge v = Some tf /\ transf_fundef f = OK tf.
Lemma function_ptr_translated: forall (b: block) (f: fundef), Genv.find_funct_ptr ge b = Some f -> exists tf, Genv.find_funct_ptr tge b = Some tf /\ transf_fundef f = OK tf.
Lemma sig_preserved: forall f tf, transf_fundef f = OK tf -> funsig tf = funsig f.
Lemma find_function_translated: forall ros ls f, find_function ge ros ls = Some f -> exists tf, find_function tge ros ls = Some tf /\ transf_fundef f = OK tf.
Lemma can_eval_safe_arg: forall (rs: locset) sp m (a: builtin_arg loc), safe_builtin_arg a -> exists v, eval_builtin_arg tge rs sp m a v.
Lemma eval_add_delta_ranges: forall s f sp c rs m before after, star step tge (State s f sp (add_delta_ranges before after c) rs m) E0 (State s f sp c rs m).