-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSemanticswE.v
More file actions
250 lines (223 loc) · 8.52 KB
/
SemanticswE.v
File metadata and controls
250 lines (223 loc) · 8.52 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Generalizable All Variables.
Typeclasses eauto := 1.
Require Import ssreflect Basic LAF LAFwE Semantics List Coq.Program.Equality.
Section SemanticswE.
Context `(LAFwE: LAFswE).
Definition MSwE2MS_base STermsV SLabV SPosV SNegV orthV SContextsV tildV SemTermsV IV
:=
{|
STerms := STermsV;
Valuations := fun qLab: QWorld _ => (qLab:Type) -> STermsV;
SLab := SLabV;
SPos := SPosV;
SNeg := SNegV;
orth := orthV;
SContexts := SContextsV;
tild := tildV;
SemTerms := SemTermsV;
I := IV
|}.
Class ModelStructureswE
{STermsV SLabV SPosV SNegV orthV SContextsV tildV SemTermsV IV}
:=
{
asMS : SClass (@MSwE2MS_base STermsV SLabV SPosV SNegV
orthV SContextsV tildV SemTermsV IV);
qLabSem qLab (xq:qLab)(sigma:Valuations (get asMS) qLab)
: SemTermsV _ sigma (asT xq) = sigma xq;
reSem qLab qLab' (pi:qLab -> qLab')
(r:Terms qLab)(tau:Valuations (get asMS) qLab') sigma:
(forall xq, tau(pi xq) = sigma xq)
-> SemTermsV _ tau (lift2Terms pi r) = SemTermsV _ (sigma:Valuations (get asMS) qLab) r;
SrenProp: renProp (SContexts (get asMS));
SstProp: stProp (SContexts (get asMS))
}
.
Canonical MSwE2MS `(ModelStructureswE)
:= @MSwE2MS_base STermsV SLabV SPosV SNegV orthV SContextsV tildV SemTermsV IV.
Definition RAwE2RA_base `(MSwE:ModelStructureswE)
welfV SemSortsV SemSoCompatV SemAtomV SemAtom_eqV
:=
{|
modelStructure := MSwE2MS MSwE;
welf := welfV;
SemSorts := SemSortsV;
SemSoCont := fun qLab Sigma (sigma: Valuations (MSwE2MS MSwE) qLab)
=> forall xq:qLab, SemSortsV (Sigma xq) (sigma xq);
SemSoCompat := SemSoCompatV;
SemAtom := SemAtomV;
SemAtom_eq := SemAtom_eqV
|}.
Class RealisabilityAlgwE `(MSwE:ModelStructureswE)
{welfV SemSortsV SemSoCompatV SemAtomV SemAtom_eqV}
:=
{
asMSwE := MSwE;
asRA := RAwE2RA_base welfV (SemSortsV := SemSortsV)
SemSoCompatV (SemAtomV := SemAtomV) SemAtom_eqV
}.
Coercion asMSwE: RealisabilityAlgwE >-> ModelStructureswE.
Canonical RAwE2RA `(RAwE:RealisabilityAlgwE)
:= RAwE2RA_base welfV SemSoCompatV SemAtom_eqV.
Lemma Rem53 `{M: RealisabilityAlgwE} w :
forall (Gamma: TCV w.(QLab) w)(rho : SContexts _ w),
SemCont (LAF:= LAFwE2LAF LAFwE) Gamma rho <->
Contlift SemSorts (Pard SemAtom (readE rho)) (Pard (SemNeg (M:= RAwE2RA M)) (readE rho)) Gamma rho.
Proof.
done.
Qed.
Definition TypingCorrwE_Prop `(RA: RealisabilityAlgwE) :=
forall qLab sigma, GenericCorr
(Context1 := TCV qLab)
(Context2 := SContexts (RAwE2RA RA))
SemSorts
(Pard SemAtom sigma)
(Pard (SemNeg (M:= RAwE2RA RA)) sigma).
Lemma SemTermListRen `(MSwE:ModelStructureswE)
{QLab QLab'} (ren:QLab -> QLab') tau sigma
l tl:
(forall xq, tau(ren xq) = sigma xq)
-> SemTermList (M := MSwE2MS MSwE) (l := l) sigma tl
= SemTermList (M := MSwE2MS MSwE) tau (renTList ren tl).
Proof.
intros.
induction l;
dependent inversion tl =>//=.
rewrite (reSem _ (pi := ren)(tau := tau)(sigma := sigma)) =>//.
by rewrite IHl.
Qed.
Definition correctNaming {E A B C D:Type} {qVar st} (Sigma: qVar -> E) v nametree
:= Declift (st:=st) (A:=A) (B:=B) (C:=C) (D:=D)
(fun s q => s = Sigma q)
(fun _ _ => True)
(fun _ _ => True)
v nametree.
Lemma TDec2Dec `{RA: RealisabilityAlgwE}
qLab
(tau: Valuations (RAwE2RA RA) qLab)
l
(tl:TList qLab l)
(st:DecStruct)
(Delta:TypingDec st l)
(qnew: @Dec qLab unit unit st)
(v:SDec st)
: correctNaming tau v qnew
-> SemTDec Delta (SemTermList tau tl) v
-> Declift SemSorts (Pard SemAtom tau) (Pard SemNeg tau) (InstTypingDec qnew tl Delta) v.
Proof.
by induction Delta;
[ move:(Decstruct sleafP qnew)(Decstruct sleafP v)
=> [a' rqnew] [b' rv]; rewrite rqnew rv; clear rqnew rv qnew v
| move:(Decstruct sleafN qnew)(Decstruct sleafN v)
=> [a' rqnew] [b' rv]; rewrite rqnew rv; clear rqnew rv qnew v
| move:(Decstruct sdummy qnew)(Decstruct sdummy v)
=> rqnew rv; rewrite rqnew rv; clear rqnew rv qnew v
| move:(Decstruct (snode _ _) qnew)(Decstruct (snode _ _) v)
=> [qnew1 [qnew2 rqnew]] [v1' [v2' rv]]; rewrite rqnew rv; clear rqnew rv qnew v;
move => [H1 H2] [H3 H4]; split; [ apply IHDelta1 | apply IHDelta2 ]
| move:(Decstruct (sqnode _) qnew)(Decstruct (sqnode _) v)
=> [qnew1 [xq rqnew]] [v' [t rv]]; rewrite rqnew rv; clear rqnew rv qnew v; simpl;
move => [H1 H2] [H3 H4]; split; [ | apply IHDelta; [ | simpl; rewrite qLabSem -H1]]
].
Qed.
Lemma renContlift `{RA: RealisabilityAlgwE}
: forall w (rho : SContexts (RAwE2RA RA) w)
(Gamma : TContext w) st (v:SDec st),
Contlift SemSorts (Pard SemAtom (readE rho)) (Pard SemNeg (readE rho))
Gamma rho
->
Contlift SemSorts
(Pard SemAtom (readE (extends v rho)))
(Pard SemNeg (readE (extends v rho)))
(TCmap (renInst (Extren st)) (renInst (Extren st)) Gamma)
rho.
Proof.
move => w rho Gamma st v.
rewrite/Contlift/TCmap ;elim => H1 [H2 H3] /=.
assert ( ContMap (fun i : Sorts (QSwE2QS LAFwE) => i)
(renInst (Extren st)) (renInst (Extren st)) Gamma
((let (TCstruct, TCmap, _) as TContextswE
return
(forall (qLab qLab' : Type) (w0 : World (get asQS)),
(Inst AtomV qLab -> Inst AtomV qLab') ->
(Inst MoleculeV qLab -> Inst MoleculeV qLab') ->
(TContextswE qLab) w0 -> (TContextswE qLab') w0) := TCV in
TCmap) (QLab w) (QLab (wextendsE st w)) w
(renInst (Extren st)) (renInst (Extren st)) Gamma)
).
apply (TCmapProp (TContextswE:= TCV) (renInst (Extren st)) (renInst (Extren st)) Gamma ).
case: H => [H4 [H5 H6]].
split; [move => xq; clear H5 H6 |split; clear H4; [move => xp; clear H6 | move => xn; clear H5]].
rewrite H4; apply H1.
rewrite H5; clear H5 H1 H3.
move:(H2 xp).
refine (
match readp Gamma xp as A return Pard SemAtom (readE rho) A (readp rho xp) -> Pard SemAtomV (readE (extends v rho))
(renInst (Extren st) A) (readp rho xp)
with
| {{ l , A }} => _
end
).
elim A.
rewrite /renInst/SemAtom/Pard/getA/getTerms/ex2 => a tl.
simpl.
rewrite <- (SemTermListRen _ (sigma := (readE rho))).
done.
apply SrenProp.
rewrite H6; clear H6 H1 H2.
move:(H3 xn).
refine (
match readn Gamma xn as A return Pard SemNeg (readE rho) A (readn rho xn) -> Pard SemNeg (readE (extends v rho))
(renInst (Extren st) A) (readn rho xn)
with
| {{ l , A }} => _
end
).
elim A.
rewrite /renInst/SemNeg/Pard/getA/getTerms/ex2 => a tl.
simpl.
rewrite <- (SemTermListRen _ (sigma := (readE rho))).
done.
apply SrenProp.
Qed.
Lemma Lem54 `(RA: RealisabilityAlgwE):
TypingCorrwE_Prop RA -> TypingCorr_Prop (RAwE2RA RA).
Proof.
rewrite /TypingCorrwE_Prop/TypingCorr_Prop.
move => H w st rho Gamma l Delta tl v H1 H2.
move:(H (wextends st w).(QLab) (readE(extends v rho))) ; clear H => H.
apply (Rem53
(Textends (t:=TContext) (w:=w) (st:=st) [Delta, tl] Gamma)
(extends (c:=SContexts (RAwE2RA RA)) (w:=w) v rho)
).
apply: H;
[
| move: (Rem53 Gamma rho) => [H3 _];
move: (H3 H1);clear H1 H3 => H1; apply (renContlift v H1)].
apply: TDec2Dec.
apply: SstProp.
rewrite /getA/getTerms/ex2.
rewrite (SemTermListRen _ tl (ren:= Extren st)(sigma := readE rho)(tau := (readE (extends v rho)))) in H2.
done.
apply SrenProp.
Qed.
Class FullModelwE `{RA: RealisabilityAlgwE} :=
{
asRAwE := RA;
TypingCorrwE : TypingCorrwE_Prop RA;
StabilitywE : Stability_Prop (RAwE2RA RA)
}.
Coercion asRAwE: FullModelwE >-> RealisabilityAlgwE.
Canonical FMwE2FM `(FullModelwE)
:= {|
M0 := RAwE2RA RA;
TypingCorr := Lem54 TypingCorrwE ;
Stability := StabilitywE
|}.
Definition adequacywE `(FMwE: FullModelwE)
:= adequacy (FMwE2FM FMwE).
(* Check adequacywE. *)
End SemanticswE.