Fixpoint prog_funct' {F V} (l: list (ident * globdef F V)) : list (ident * F) :=
 match l with nil => nil | (i,Gfun f)::r => (i,f):: prog_funct' r | _::r => prog_funct' r
 end.Definition prog_funct {F} (p: program F) := prog_funct' (prog_defs p).

(* Specifications: *)
Lemma find_symbol_add_globals_nil: forall {F V} i g id p prog_pub, (Genv.find_symbol (Genv.add_globals (Genv.empty_genv F V prog_pub) ((i, g) :: nil)) id = Some p <-> (i = id /\ 1%positive = p)).
Lemma find_symbol_add_globals_cons: forall {F V} i g id dl prog_pub (HD: 0 < Zlength dl), ~ In i (map fst dl) -> list_norepet (map fst dl) -> (Genv.find_symbol (Genv.add_globals (Genv.empty_genv F V prog_pub) (dl ++ (i, g) :: nil)) id = Some (1 + (Z.to_pos (Zlength dl)))%positive <-> i = id).
Lemma find_symbol_add_globals: forall {F V} i g id dl prog_pub, ~ In i (map fst dl) -> list_norepet (map fst dl) -> match dl with nil => forall p, (Genv.find_symbol (Genv.add_globals (Genv.empty_genv F V prog_pub) ((i, g) :: nil)) id = Some p <-> (i = id /\ 1%positive = p)) | _ => (Genv.find_symbol (Genv.add_globals (Genv.empty_genv F V prog_pub) (dl ++ (i, g) :: nil)) id = Some (1 + (Z.to_pos (Zlength dl)))%positive <-> i = id) end.
Lemma find_symbol_add_globals': forall {F V} i g id dl prog_pub, match dl with nil => forall p, (Genv.find_symbol (Genv.add_globals (Genv.empty_genv F V prog_pub) ((i, g) :: nil)) id = Some p <-> (i = id /\ 1%positive = p)) | _ => ~ In i (map fst dl) -> list_norepet (map fst dl) -> (Genv.find_symbol (Genv.add_globals (Genv.empty_genv F V prog_pub) (dl ++ (i, g) :: nil)) id = Some (1 + (Z.to_pos (Zlength dl)))%positive <-> i = id) end.
Lemma nth_error_app: forall {T} (al bl : list T) (j: nat), nth_error (al++bl) (length al + j) = nth_error bl j.
Lemma nth_error_app1: forall {T} (al bl : list T) (j: nat), (j < length al)%nat -> nth_error (al++bl) j = nth_error al j.
Lemma nth_error_rev: forall T (vl: list T) (n: nat), (n < length vl)%nat -> nth_error (rev vl) n = nth_error vl (length vl - n - 1).
Lemma Zlength_app: forall T (al bl: list T), Zlength (al++bl) = Zlength al + Zlength bl.
Lemma Zlength_rev: forall T (vl: list T), Zlength (rev vl) = Zlength vl.
Lemma Zlength_map: forall A B (f: A -> B) l, Zlength (map f l) = Zlength l.
Lemma add_globals_hack_nil {F}: forall gev prog_pub, gev = Genv.add_globals (Genv.empty_genv (fundef F) type prog_pub) (rev nil) -> forall id, Genv.find_symbol gev id = None.
Lemma add_globals_hack_single {F}: forall v gev prog_pub, gev = Genv.add_globals (Genv.empty_genv (fundef F) type prog_pub) (cons v nil) -> forall id b, (Genv.find_symbol gev id = Some b <-> fst v = id /\ b = 1%positive).