Section SemanticTyping.
Variable (X: Const).
Definition SemType := exp X -> Prop.
(* ** Logical Relations *)
Definition active (s: exp X) :=
match s with lambda s => True | _ => False end.
Definition C (T: SemType) (s: exp X) :=
exists t, s ▷ t /\ (active t -> T t).
Fixpoint V (A: type) (s: exp X) :=
match A with
| typevar beta => False
| A → B => match s with
| lambda s => normal s /\
forall t delta, C (V A) t -> C (V B) ((ren delta (lambda s)) t)
| _ => False
end
end.
Definition E A := C (V A).
Definition G Gamma gamma := forall i A, nth Gamma i = Some A -> E A (gamma i).
Definition ren_closed (S: SemType) :=
forall delta s, S s -> S (ren delta s).

Lemma compat_var Gamma i A gamma:
nth Gamma i = Some A -> G Gamma gamma -> E A (gamma i).