(** Completeness proof *)

(* Specifications: *)
Lemma type_def_complete:
forall te e x ty,
satisf te e -> T.sub ty (te x) -> exists e', type_def e x ty = OK e' /\ satisf te e'.
Lemma type_defs_complete:
forall te xl tyl e,
satisf te e -> list_forall2 T.sub tyl (map te xl) ->
exists e', type_defs e xl tyl = OK e' /\ satisf te e'.
Lemma type_use_complete:
forall te e x ty,
satisf te e -> T.sub (te x) ty -> exists e', type_use e x ty = OK e' /\ satisf te e'.
Lemma type_uses_complete:
forall te xl tyl e,
satisf te e -> list_forall2 T.sub (map te xl) tyl ->
exists e', type_uses e xl tyl = OK e' /\ satisf te e'.
Lemma type_move_complete:
forall te e r1 r2,
satisf te e -> T.sub (te r1) (te r2) ->
exists changed e', type_move e r1 r2 = OK(changed, e') /\ satisf te e'.
Lemma solve_rec_complete:
forall te q e changed,
satisf te e ->
(forall r1 r2, In (r1, r2) q -> T.sub (te r1) (te r2)) ->
exists e' changed', solve_rec e changed q = OK(e', changed') /\ satisf te e'.
Lemma solve_constraints_complete:
forall te e, satisf te e -> exists e', solve_constraints e = OK e' /\ satisf te e'.
Lemma solve_complete:
forall te e, satisf te e -> exists te', solve e = OK te'.
Lemma set_complete:
forall te e x ty,
satisf te e -> te x = ty -> exists e', set e x ty = OK e' /\ satisf te e'.
Lemma set_list_complete:
forall te xl tyl e,
satisf te e -> map te xl = tyl ->
exists e', set_list e xl tyl = OK e' /\ satisf te e'.
Lemma move_complete:
forall te e r1 r2,
satisf te e -> te r1 = te r2 ->
exists changed e', move e r1 r2 = OK(changed, e') /\ satisf te e'.
Lemma solve_rec_complete:
forall te q e changed,
satisf te e ->
(forall r1 r2, In (r1, r2) q -> te r1 = te r2) ->
exists e' changed', solve_rec e changed q = OK(e', changed') /\ satisf te e'.
Lemma solve_constraints_complete:
forall te e, satisf te e -> exists e', solve_constraints e = OK e' /\ satisf te e'.
Lemma solve_complete:
forall te e, satisf te e -> exists te', solve e = OK te'.