(** Correctness of [labels_branched_to]. *)

Definition instr_branches_to (i: instruction) (lbl: label) : Prop :=
  match i with
  | Lgoto lbl' => lbl = lbl'
  | Lcond cond args lbl' => lbl = lbl'
  | Ljumptable arg tbl => In lbl tbl
  | _ => False
  end.Remark add_label_branched_to_incr:
  forall ls i, Labelset.Subset ls (add_label_branched_to ls i).Remark add_label_branched_to_contains:
  forall ls i lbl,
  instr_branches_to i lbl ->
  Labelset.In lbl (add_label_branched_to ls i).

(* Specifications: *)
Lemma labels_branched_to_correct: forall c i lbl, In i c -> instr_branches_to i lbl -> Labelset.In lbl (labels_branched_to c).
Lemma remove_unused_labels_cons: forall bto i c, remove_unused_labels bto (i :: c) = match i with | Llabel lbl => if Labelset.mem lbl bto then i :: remove_unused_labels bto c else remove_unused_labels bto c | _ => i :: remove_unused_labels bto c end.
Lemma find_label_commut: forall lbl bto, Labelset.In lbl bto -> forall c c', find_label lbl c = Some c' -> find_label lbl (remove_unused_labels bto c) = Some (remove_unused_labels bto c').