-
Notifications
You must be signed in to change notification settings - Fork 0
/
Uniqueness.v
98 lines (86 loc) · 2.43 KB
/
Uniqueness.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
(* Uniqueness of Typing *)
From Coq Require Import Bool String List BinPos Compare_dec Lia Arith.
From Equations Require Import Equations.
From Translation
Require Import util SAst SLiftSubst Equality SCommon ITyping
ITypingInversions ITypingLemmata.
Section Uniqueness.
Context `{Sort_notion : Sorts.notion}.
(* Ltac nlassumption := *)
(* try eapply (f_equal nl) ; assumption. *)
(* Ltac nleassumption := *)
(* try eapply (f_equal nl) ; eassumption. *)
Ltac unih :=
match goal with
| ih : _ -> _ -> _ -> _ ;;; _ |-i ?t : _ -> _ ;;; _ |-i ?t : _ -> _,
h1 : _ ;;; _ |-i ?t : _,
h2 : _ ;;; _ |-i ?t : _
|- _ =>
specialize (ih _ _ _ h1 h2) ;
simpl in ih ;
inversion ih ; subst ; clear ih
end.
Ltac unitac h1 h2 :=
ttinv h1 ; ttinv h2 ;
eapply eq_trans ; [
eapply eq_sym ; eassumption
| repeat unih
].
Ltac nleq :=
repeat (try eapply nl_lift ; try eapply nl_subst) ;
cbn ; auto ; f_equal ; eauto.
Ltac finish :=
lazymatch goal with
| h : nl ?u = nl ?t |- _ = nl ?t =>
transitivity (nl u) ; [ | assumption ] ;
repeat nleq
end.
Ltac reunih :=
match goal with
| ih : _ -> _ -> _ -> _ ;;; _ |-i ?t : _ -> _ ;;; _ |-i ?t : _ -> _,
h1 : ?Σ ;;; ?Γ |-i ?t : _,
h2 : _ ;;; _ |-i ?t : ?A
|- _ =>
let hh2 := fresh h2 in
assert (Σ ;;; Γ |-i t : A) as hh2 ; [
eapply rename_typed ; try eassumption ; try reflexivity
| specialize (ih _ _ _ h1 hh2) ;
simpl in ih ;
inversion ih ; subst ; clear ih
]
end.
Lemma uniqueness :
forall {Σ Γ A B u},
type_glob Σ ->
Σ ;;; Γ |-i u : A ->
Σ ;;; Γ |-i u : B ->
nl A = nl B.
Proof.
intros Σ Γ A B u hg h1 h2.
revert Γ A B h1 h2.
induction u ; intros Γ A B h1 h2.
all: try unitac h1 h2.
all: try assumption.
all: try solve [finish].
- rewrite H1 in H. inversion H. subst. auto.
- reunih.
+ cbn. f_equal. eauto.
+ repeat eapply wf_snoc.
* eapply typing_wf. eassumption.
* eassumption.
+ try assumption. try solve [finish].
- reunih.
+ cbn. f_equal. eauto.
+ repeat eapply wf_snoc.
* eapply typing_wf. eassumption.
* eassumption.
+ try assumption. try solve [finish].
- reunih.
+ cbn. f_equal. eauto.
+ repeat eapply wf_snoc.
* eapply typing_wf. eassumption.
* eassumption.
+ try assumption. try solve [finish].
- rewrite h4 in h0. inversion h0. inversion h0. subst. assumption.
Defined.
End Uniqueness.