(* * Copyright (c) 2009 Robert Dockins and Aquinas Hobor. * *)
(* Coq development: using indirection theory to model types in l-calculus *)
(* Typing rules *)
Fixpoint gamma_sub (G G':etype) {struct G} : Prop :=
match G, G' with
| nil, nil => True
| x::xs, y::ys => TT |-- y >=> x /\ gamma_sub xs ys
| _, _ => False
end.
Definition prim (f:nat -> value) : expr -> expr :=
Prim (val_to_exp oo f).
(* Bounded Universal Quantification *)
Definition AllBnd (T:pred world) (X:pred world -> pred world)
:= ALL tau:pred world, !!(TT |-- tau >=> T) --> X tau.
Definition ty_ex (F:pred world -> pred world) : pred world :=
EX tau:pred world, !!(boxy extendM tau) && F tau.

Lemma T_ExtE : forall G e f (X:pred world -> pred world) sigma
(Hext : forall tau, boxy extendM tau -> boxy extendM (X tau)),
Typ G e (ty_ex X) ->
(forall tau, Typ (X tau::G) f sigma) ->
Typ G (App (Lam f) e) sigma.