/
TypeInv.v
62 lines (56 loc) · 1.16 KB
/
TypeInv.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Require Import Lambda.
Require Import List.
Require Import String.
(* Inversion of the typing relation *)
Lemma VarRel :
forall (tenv : list (string * type)) (x : string) (r : type),
Some r = typing (Var x) tenv -> In (x,r) tenv.
Proof.
simpl in |- *.
intro tenv.
induction tenv.
intros.
simpl in H.
discriminate H.
intros x r.
simpl in |- *.
destruct a.
case (string_dec x s).
intros.
left.
rewrite e in |- *.
inversion H.
reflexivity.
intros.
right.
apply IHtenv.
assumption.
Qed.
Lemma LambdaRel :
forall (x : string)
(t r1 : type)
(body : term)
(tenv : list (string * type)),
Some r1 = typing (Lambda x t body) tenv ->
exists r2 : type,
Some r2 = typing body ((x,t)::tenv) /\
r1 = FunT t r2.
Proof.
simpl in |- *.
intros until tenv.
case (typing body ((x, t) :: tenv)).
intros.
inversion H.
exists t0.
split; reflexivity; reflexivity.
intro.
discriminate H.
Qed.
Lemma ApplyRel:
forall (r : type)
(f x : term)
(tenv : list (string * type)),
Some r = typing (Apply f x) tenv ->
exists t : type,
Some (FunT t r) = typing f tenv /\
Some t = typing x tenv.