-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathordered_sequent.v
288 lines (272 loc) · 8.5 KB
/
ordered_sequent.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
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
From mm Require Import util.
Set Implicit Arguments.
Module prop.
Inductive t :=
| under : t -> t -> t
(*
| over : t -> t -> t
| fuse : t -> t -> t
| twist : t -> t -> t
| ichoose : t -> t -> t
| uchoose : t -> t -> t
*)
| one : t
.
Fixpoint size (A : t) : nat :=
match A with
| one => 1
| under A1 A2 => S (size A1 + size A2)
end.
End prop.
Module expr.
Inductive t :=
| var : t
| tt : t
| lettt : t -> t
| underabs : t -> t
| underapp : t -> t -> t
.
Fixpoint size (e : t) : nat :=
match e with
| var => 1
| tt => 1
| lettt e' => S (size e')
| underabs e' => S (size e')
| underapp e1 e2 => S (size e1 + size e2)
end.
End expr.
Module cf_sequent.
(* cut-free sequent calculus with proof terms *)
Inductive t : list prop.t -> expr.t -> prop.t -> Prop :=
| id : forall A, t [A] expr.var A
| under_R : forall Ω A B e,
t (B :: Ω) e A ->
t Ω (expr.underabs e) (prop.under B A)
| under_L : forall Ω_L Ω' Ω_R A B C e1 e2,
t Ω' e1 B ->
t (Ω_L ++ A :: Ω_R) e2 C ->
t (Ω_L ++ Ω' ++ prop.under B A :: Ω_R) (expr.underapp e1 e2) C
| one_R : t [] expr.tt prop.one
| one_L : forall Ω_L Ω_R e C,
t (Ω_L ++ Ω_R) e C ->
t (Ω_L ++ prop.one :: Ω_R) (expr.lettt e) C
.
Lemma cut_admissible' :
forall n e1 e2 A Ω Ω_L Ω_R C,
prop.size A + expr.size e1 + expr.size e2 < n ->
t Ω e1 A ->
t (Ω_L ++ A :: Ω_R) e2 C ->
exists e, t (Ω_L ++ Ω ++ Ω_R) e C /\ expr.size e <= expr.size e1 + expr.size e2.
Proof.
induction n; intros e1 e2 A Ω Ω_L Ω_R C LT SA SC.
- lia.
- invc SC.
+ apply app_singleton_middle_inv in H0.
invc H0.
rewrite app_nil_r.
exists e1. split. auto. lia.
+ rewrite app_comm_cons in H.
eapply IHn with (e2 := e) (e1 := e1) in H; eauto.
2: simpl in *; lia.
destruct H as [e' [? ?]].
eexists.
split.
econstructor.
exact H.
simpl in *. lia.
+ simpl in *.
rewrite <- app_ass in H.
apply app_middle_inv in H.
destruct H as [[? ? ?]|[W [? ?]]|[W [? ?]]]; subst.
* invc SA.
-- eexists. split.
rewrite app_ass.
simpl.
apply under_L; eauto.
simpl in *. lia.
-- simpl in *.
eapply IHn with (e1 := e0) (e2 := e) (Ω_L := []) in H4; eauto.
2: lia.
destruct H4 as [e' [He' Size']].
simpl in *.
eapply IHn with (e2 := e3)(e1 := e') in H1; eauto.
2: lia.
destruct H1 as [e'' [He'' Size'']].
rewrite app_ass in *.
eexists. split. eauto.
lia.
-- simpl in *.
eapply under_L with (A := A0) in H0; eauto.
rewrite <- app_ass in H0.
eapply IHn with (A := prop.under B A0) in H0; eauto.
2: simpl in *; lia.
destruct H0 as [? [??]].
rewrite !app_ass in *.
rewrite <- app_ass in H0.
rewrite <- app_ass in H0.
simpl in H0.
eapply under_L with (B := B0) in H0; eauto.
rewrite !app_ass in *.
eexists.
split.
eauto.
simpl in *. lia.
-- eapply under_L with (B := B)(A := A0) in H1; eauto.
rewrite <- app_ass in H1.
eapply IHn in H1; [| |eassumption].
2: simpl in*; lia.
destruct H1 as [?[??]].
eexists. split.
rewrite !app_ass.
rewrite <- app_ass.
rewrite <- app_ass.
simpl.
apply one_L.
rewrite !app_ass in *.
eassumption.
simpl in *. lia.
* apply app_inv in H.
destruct H as [[W' [? ?]]|[W' [? ?]]]; subst.
-- apply app_cons_inv in H2.
destruct H2 as [[? ?]|[W1 [? ?]]]; subst.
++ rewrite app_nil_r in *.
eapply IHn with (A := A) (Ω_L := []) in H0; [| |eassumption].
2: lia.
destruct H0 as [e' [S' Size']].
simpl in S'.
eapply under_L with (A := A0) (B := B) in H1; eauto.
rewrite !app_ass in *.
eexists.
split. eauto.
simpl in *; lia.
++ rewrite !app_ass in *.
simpl in *.
eapply IHn with (A := A) in H1; eauto.
2: lia.
destruct H1 as [e' [S' Size']].
rewrite <- app_ass in S'.
rewrite <- app_ass in S'.
eapply under_L with (B := B) in S'; eauto.
rewrite !app_ass in *.
eexists. split. eauto.
simpl in *. lia.
-- eapply IHn with (A := A) in H0; eauto.
2: lia.
destruct H0 as [e' [S' Size']].
eapply under_L with (B := B) in H1; eauto.
rewrite !app_ass in *.
eexists. split. eauto.
simpl in *. lia.
* rewrite app_comm_cons' in H1.
rewrite <- app_ass in H1.
eapply IHn with (A := A) in H1; eauto.
2: lia.
destruct H1 as [e' [S' Size']].
rewrite !app_ass in *.
simpl in *.
eapply under_L with (B := B) in S'; eauto.
eexists. split. eauto.
simpl in *. lia.
+ destruct Ω_L; discriminate.
+ apply app_middle_inv in H.
destruct H as [[? ? ?]|[W [? ?]]|[W [? ?]]]; subst.
* invc SA.
-- eexists. split.
apply one_L. eauto.
simpl in *. lia.
-- apply one_L in H0.
eapply IHn with (A := prop.one) in H0; [| |eassumption].
2: simpl in *; lia.
destruct H0 as [e' [S' Size']].
rewrite !app_ass in *.
simpl in *.
rewrite <- app_ass in S'.
eapply under_L with (B := B) in S'; eauto.
rewrite !app_ass in *.
eexists. split. eauto.
simpl in *. lia.
-- eexists. split. eauto.
simpl in *. lia.
-- rewrite app_ass. simpl.
rewrite <- app_ass.
eapply IHn with (e1 := e0)(e2 := expr.lettt e) in H.
3: apply one_L; eassumption.
2: simpl in *; lia.
destruct H as [e' [He' Size']].
eexists. split.
apply one_L.
rewrite !app_ass in *.
eauto.
simpl in *. lia.
* rewrite app_ass in *.
simpl in *.
eapply IHn with (e2 := e) (e1 := e1) in H0; eauto.
2: lia.
destruct H0 as [? [? ?]].
eexists. split.
rewrite <- app_ass.
rewrite <- app_ass.
apply one_L.
rewrite !app_ass.
eauto.
simpl in *. lia.
* rewrite <- app_ass in H0.
eapply IHn with (e1 := e1) (e2 := e) in H0; eauto.
2: simpl in *; lia.
destruct H0 as [? [? ?]].
eexists. split.
rewrite !app_ass in *.
simpl.
apply one_L.
eauto.
simpl in *. lia.
Qed.
Theorem cut_admissible :
forall A e2 Ω e1 Ω_L Ω_R C,
t Ω e1 A ->
t (Ω_L ++ A :: Ω_R) e2 C ->
exists e, t (Ω_L ++ Ω ++ Ω_R) e C.
Proof.
intros A e2 Ω e1 Ω_L Ω_R C SA SC.
eapply cut_admissible' in SC; eauto.
destruct SC as [? [? _]].
eauto.
Qed.
Print Assumptions cut_admissible.
End cf_sequent.
Module sequent.
Inductive t : list prop.t -> prop.t -> Prop :=
| id : forall A, t [A] A
| under_R : forall Ω A B,
t (B :: Ω) A ->
t Ω (prop.under B A)
| under_L : forall Ω_L Ω' Ω_R A B C,
t Ω' B ->
t (Ω_L ++ A :: Ω_R) C ->
t (Ω_L ++ Ω' ++ prop.under B A :: Ω_R) C
| one_R : t [] prop.one
| one_L : forall Ω_L Ω_R C,
t (Ω_L ++ Ω_R) C ->
t (Ω_L ++ prop.one :: Ω_R) C
| cut : forall Ω_L Ω Ω_R A B,
t Ω A ->
t (Ω_L ++ A :: Ω_R) B ->
t (Ω_L ++ Ω ++ Ω_R) B
.
Theorem cut_elim :
forall Ω A,
t Ω A ->
exists e, cf_sequent.t Ω e A.
Proof.
induction 1.
- eexists. constructor.
- destruct IHt. eexists. econstructor. eauto.
- destruct IHt1, IHt2. eexists.
econstructor; eauto.
- eexists. constructor.
- destruct IHt.
eexists. econstructor. eauto.
- destruct IHt1, IHt2.
eapply cf_sequent.cut_admissible; eauto.
Qed.
End sequent.