forked from Barry-Jay/lambdaSF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Binding.v
619 lines (598 loc) · 21.6 KB
/
Binding.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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
(* This program is free software; you can redistribute it and/or *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1 *)
(* of the License, or (at your option) any later version. *)
(* *)
(* This program is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU Lesser General Public *)
(* License along with this program; if not, write to the Free *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA *)
(**********************************************************************)
(* Intensional Lambda Calculus *)
(* *)
(* is implemented in Coq by adapting the implementation of *)
(* Lambda Calculus from Project Coq *)
(* 2015 *)
(**********************************************************************)
(**********************************************************************)
(* Binding.v *)
(* *)
(* Barry Jay *)
(* *)
(**********************************************************************)
Require Import Arith.
Require Import Max.
Require Import Test.
Require Import General.
Require Import LamSF_Terms.
Require Import LamSF_Substitution_term.
Require Import LamSF_Tactics.
Require Import Beta_Reduction.
Require Import LamSF_Confluence.
Require Import SF_reduction.
Require Import LamSF_reduction.
Require Import LamSF_Normal.
Require Import LamSF_Closed.
Require Import LamSF_Eval.
Require Import Equal.
Require Import Combinators.
Require Import Omega.
Ltac eval_lamSF := eval_lamSF0; relocate_lt; unfold subst; unfold subst_rec; fold subst_rec; insert_Ref_out; repeat (rewrite lift_rec_null).
Definition binds_fn := Abs (Abs
(App (App (App (App equal i_op) (Ref 0)) k_op)
(App (App (App f_op (Ref 0)) (App k_op i_op)) (Abs (Abs
(App (App (App (Ref 3) (Ref 1)) k_op)
(App (Ref 3) (Ref 0))
)))))).
Definition binds := App fixpoint binds_fn.
Lemma binds_rank : forall M, program M -> rank i_op > rank M ->
lamSF_red (App binds M) (App k_op i_op).
Proof.
unfold program; split_all. induction H1; split_all.
(* 5 *)
inversion H2; split_all.
(* 4 *)
unfold binds.
fixtac. fold binds. unfold binds_fn.
eval_lamSF.
repeat (rewrite (subst_rec_closed equal); [| split_all]).
unfold subst_rec; fold subst_rec. insert_Ref_out.
rewrite subst_rec_lift_rec; [|split_all|split_all].
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App k_op i_op) M)N)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 unequal_programs.
split_all.
split_all.
discriminate.
eval_lamSF. eval_lamSF. eval_lamSF. auto.
(* 3 *)
assert(rank M > 0) by eapply2 rank_positive.
simpl in *. noway.
(* 2 *)
assert(status (App M1 M2) <= maxvar (App M1 M2)) by eapply2 status_lt_maxvar. noway.
(* 1 *)
unfold binds.
fixtac. fold binds. unfold binds_fn.
eval_lamSF.
repeat (rewrite (subst_rec_closed equal); [| split_all]).
unfold subst_rec; fold subst_rec. insert_Ref_out.
repeat(rewrite lift_rec_null).
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App k_op i_op) M)N)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 unequal_programs.
split_all.
split_all.
intro.
rewrite <- H1 in H0.
simpl in *; noway.
eval_lamSF. eval_lamSF.
match goal with
| |- _ _ (App _ ?N) _ =>
apply succ_red with (App (App N (left_component (App M1 M2))) (right_component (App M1 M2)))
end.
eapply2 f_compound_lamSF_red.
eval_lamSF.
repeat (rewrite (subst_rec_closed binds); [| split_all]).
unfold left_component, right_component.
rewrite subst_rec_lift_rec; try omega.
repeat(rewrite lift_rec_null).
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App k_op i_op) M)N)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 IHnormal1. simpl in *. omega. simpl in *. max_out.
eval_lamSF. eval_lamSF.
eapply2 IHnormal2. simpl in *. omega. simpl in *. max_out.
Qed.
Lemma binds_abs : forall M, program (Abs M) ->
lamSF_red (App binds (Abs M)) (App binds (star M)).
Proof.
unfold program; split_all.
unfold binds. fixtac. fold binds. unfold binds_fn. eval_lamSF.
repeat (rewrite (subst_rec_closed equal); [| split_all]).
unfold subst_rec; fold subst_rec. insert_Ref_out.
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App k_op i_op) M)N)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
rewrite lift_rec_null.
eapply2 unequal_programs; split_all.
eval_lamSF. eval_lamSF.
match goal with
| |- _ _ (App _ ?N) _ =>
apply succ_red with (App (App N (left_component (Abs M))) (right_component (Abs M)))
end.
eapply2 f_compound_lamSF_red.
assert(factorable (Abs M)) . eapply2 programs_are_factorable; split_all.
inversion H; split_all.
eval_lamSF.
repeat (rewrite (subst_rec_closed binds); [| split_all]).
unfold left_component, right_component.
unfold_op; rewrite subst_rec_lift_rec; try omega.
rewrite lift_rec_null.
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App k_op i_op) M)N)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 binds_rank; split_all; omega.
eval_lamSF. eval_lamSF. auto.
Qed.
Lemma binds_star_0 : forall M, program M ->
lamSF_red (App binds (star M)) (App k_op i_op).
Proof.
cut(forall p M, rank M <= p -> normal M -> maxvar M = 0 ->
lamSF_red (App binds (star M)) (App k_op i_op)).
split_all.
inversion H0.
eapply2 H.
induction p.
split_all.
assert(rank M >0) by eapply2 rank_positive; noway.
(* p > 0 *)
intros M rnk nor; induction nor; split_all.
(* 4 *)
unfold_op; eapply2 binds_rank; split_all; omega.
(* 3 *)
unfold binds. fixtac. fold binds. unfold binds_fn. eval_lamSF.
repeat (rewrite (subst_rec_closed equal); [| split_all]).
unfold subst_rec; fold subst_rec. insert_Ref_out.
rewrite lift_rec_preserves_star.
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App k_op i_op) M)N)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
rewrite lift_rec_null.
eapply2 unequal_programs; split_all.
eapply2 nf_abs. eapply2 normal_star.
rewrite maxvar_star. omega.
eval_lamSF. eval_lamSF.
match goal with
| |- _ _ (App _ ?N) _ =>
apply succ_red with (App (App N (left_component (Abs (star M)))) (right_component (Abs (star M))))
end.
eapply2 f_compound_lamSF_red.
eapply2 abs_compound_compound.
eapply2 star_compound.
eval_lamSF.
repeat (rewrite (subst_rec_closed binds); [| split_all]).
unfold left_component, right_component.
unfold_op. rewrite subst_rec_lift_rec; try omega. rewrite lift_rec_null.
repeat (rewrite (subst_rec_closed equal); [| split_all]).
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App k_op i_op) M)N)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 binds_rank; split_all.
eval_lamSF; eval_lamSF.
eapply2 IHp.
assert(rank (star M) < rank (Abs M)) by eapply2 rank_star.
omega.
eapply2 normal_star.
rewrite maxvar_star. auto.
(* 2 *)
assert(status (App M1 M2) <= maxvar (App M1 M2)) by eapply2 status_lt_maxvar.
simpl in *; omega.
(* 1 *)
unfold binds. fixtac. fold binds. unfold binds_fn. eval_lamSF.
repeat (rewrite (subst_rec_closed equal); [| split_all]).
unfold subst_rec; fold subst_rec. insert_Ref_out.
rewrite subst_rec_lift_rec; [|split_all|split_all].
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App k_op i_op) M)N)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
max_out.
rewrite lift_rec_closed; try (split_all; omega).
rewrite lift_rec_closed; try (split_all; omega).
eapply2 unequal_programs; split_all.
rewrite H1; rewrite H2; split_all.
eval_lamSF; eval_lamSF.
eval_lamSF; eval_lamSF; auto.
repeat (rewrite (subst_rec_closed binds); [| split_all]).
unfold subst_rec; fold subst_rec. insert_Ref_out.
rewrite subst_rec_lift_rec; [|split_all|split_all].
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App k_op i_op) M)N)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
max_out.
rewrite lift_rec_closed; try (split_all; omega).
(* 2 : Abs -> star *)
unfold binds. fixtac. fold binds. unfold binds_fn. eval_lamSF.
repeat (rewrite (subst_rec_closed equal); [| split_all]).
unfold subst_rec; fold subst_rec. insert_Ref_out.
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App k_op i_op) M)N)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
rewrite lift_rec_null.
eapply2 unequal_programs; split_all.
omega.
eval_lamSF; eval_lamSF.
eval_lamSF; eval_lamSF.
repeat (rewrite (subst_rec_closed binds); [| split_all]).
unfold subst_rec; fold subst_rec. insert_Ref_out.
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App k_op i_op) M)N)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 binds_rank; split_all. omega.
eval_lamSF. eval_lamSF.
(* M1 *)
unfold binds. fold lamSF_red. fixtac. fold binds. unfold binds_fn. eval_lamSF.
repeat (rewrite (subst_rec_closed equal); [| split_all]).
unfold subst_rec; fold subst_rec. insert_Ref_out.
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App k_op i_op) M)N)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
rewrite lift_rec_null.
eapply2 unequal_programs; split_all.
omega.
eval_lamSF. eval_lamSF.
match goal with
| |- _ _ (App _ ?N) _ =>
apply succ_red with (App (App N (left_component (Abs M1))) (right_component (Abs M1)))
end.
eapply2 f_compound_lamSF_red.
inversion H; subst; split_all.
eval_lamSF.
repeat (rewrite (subst_rec_lift_rec binds); try omega).
unfold left_component, right_component.
unfold_op; rewrite subst_rec_lift_rec; try omega.
rewrite lift_rec_null.
rewrite lift_rec_null.
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App k_op i_op) M)N)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 binds_rank; split_all.
eval_lamSF. eval_lamSF.
eapply2 IHnor1.
simpl in *; omega.
eval_lamSF. eval_lamSF.
(* now M2 *)
max_out.
unfold binds. fold lamSF_red. fixtac. fold binds. unfold binds_fn. eval_lamSF.
repeat (rewrite (subst_rec_closed equal); [| split_all]).
unfold subst_rec; fold subst_rec. insert_Ref_out.
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App k_op i_op) M)N)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
rewrite lift_rec_null.
eapply2 unequal_programs; split_all. omega.
eval_lamSF. eval_lamSF.
match goal with
| |- _ _ (App _ ?N) _ =>
apply succ_red with (App (App N (left_component (Abs M2))) (right_component (Abs M2)))
end.
eapply2 f_compound_lamSF_red.
assert(factorable (Abs M2)) . eapply2 programs_are_factorable; split_all. omega.
inversion H0; split_all.
eval_lamSF.
repeat (rewrite (subst_rec_closed binds); [| split_all]).
unfold left_component, right_component.
unfold_op; rewrite subst_rec_lift_rec; try omega.
rewrite lift_rec_null.
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App k_op i_op) M)N)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 binds_rank; split_all; omega.
eval_lamSF. eval_lamSF.
eapply2 IHnor2.
simpl in *; omega.
Qed.
Lemma binds_star_1 : forall M, normal M -> maxvar M = 1 ->
lamSF_red (App binds (star M)) k_op.
Proof.
cut(forall p M, rank M <= p -> normal M -> maxvar M = 1 ->
lamSF_red (App binds (star M)) k_op).
split_all.
eapply2 H.
induction p.
split_all.
assert(rank M >0) by eapply2 rank_positive; noway.
(* p > 0 *)
intros M rnk nor; induction nor; split_all.
(* 4 *)
assert(n=0) by omega. subst; split_all.
unfold binds. fixtac. fold binds. unfold binds_fn. eval_lamSF.
repeat (rewrite (subst_rec_closed equal); [| split_all]).
unfold subst_rec; fold subst_rec. insert_Ref_out.
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App k_op M)N)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 equal_programs; split_all.
eval_lamSF. auto.
(* 3 *)
unfold binds. fixtac. fold binds. unfold binds_fn. eval_lamSF.
repeat (rewrite (subst_rec_closed equal); [| split_all]).
unfold subst_rec; fold subst_rec. insert_Ref_out.
rewrite lift_rec_preserves_star.
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App k_op i_op) M)N)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
rewrite lift_rec_null.
eapply2 unequal_programs; split_all.
eapply2 nf_abs. eapply2 normal_star.
rewrite maxvar_star. omega.
eval_lamSF; eval_lamSF.
match goal with
| |- _ _ (App _ ?N) _ =>
apply succ_red with (App (App N (left_component (Abs (star M)))) (right_component (Abs (star M))))
end.
eapply2 f_compound_lamSF_red.
eapply2 abs_compound_compound.
eapply2 star_compound.
eval_lamSF.
repeat (rewrite (subst_rec_closed binds); [| split_all]).
unfold left_component, right_component.
unfold_op. rewrite subst_rec_lift_rec; try omega. rewrite lift_rec_null.
unfold subst_rec; fold subst_rec. insert_Ref_out. rewrite lift_rec_null.
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App k_op i_op) M)N)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 binds_rank; split_all.
eval_lamSF; eval_lamSF.
eapply2 IHp.
assert(rank (star M) < rank (Abs M)) by eapply2 rank_star.
omega.
eapply2 normal_star.
rewrite maxvar_star. auto.
(* 2 *)
unfold binds. fixtac. fold binds. unfold binds_fn. eval_lamSF.
repeat (rewrite (subst_rec_closed equal); [| split_all]).
unfold subst_rec; fold subst_rec. insert_Ref_out.
rewrite subst_rec_lift_rec; [|split_all|split_all].
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App k_op i_op) M)N)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
rewrite lift_rec_null. rewrite lift_rec_null.
eapply2 unequal_programs; split_all.
assert(pred (max(maxvar M1) (maxvar M2)) = 0) by omega.
rewrite max_pred in H1.
auto.
eval_lamSF; eval_lamSF.
eval_lamSF; eval_lamSF; auto.
repeat (rewrite (subst_rec_lift_rec binds); try omega).
rewrite lift_rec_null.
unfold subst_rec; fold subst_rec. insert_Ref_out.
rewrite subst_rec_lift_rec; [|split_all|split_all].
rewrite lift_rec_null.
unfold binds. fold lamSF_red. fixtac. fold binds. unfold binds_fn. eval_lamSF.
repeat (rewrite (subst_rec_closed equal); [| split_all]).
unfold subst_rec; fold subst_rec. insert_Ref_out.
rewrite subst_rec_lift_rec; [|split_all|split_all].
match goal with
| |- multi_step lamSF_red1 (App (App (App (App _ ?M)?N)?P)?Q) _ =>
apply transitive_red with (App (App (App (App (App k_op i_op) M)N)P)Q)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
rewrite lift_rec_null.
eapply2 unequal_programs; split_all.
assert(pred (max(maxvar M1) (maxvar M2)) = 0) by omega.
rewrite max_pred in H1.
max_out.
eval_lamSF; eval_lamSF.
eval_lamSF; eval_lamSF; auto.
repeat (rewrite (subst_rec_lift_rec binds); try omega).
rewrite lift_rec_null.
unfold subst_rec; fold subst_rec. insert_Ref_out.
match goal with
| |- multi_step lamSF_red1 (App (App (App (App _ ?M)?N)?P)?Q) _ =>
apply transitive_red with (App (App (App (App (App k_op i_op) M)N)P)Q)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 binds_rank; split_all; omega.
eval_lamSF.
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App binds (Abs M1)) M)N)
end.
eapply2 preserves_app_lamSF_red.
assert(pred (max(maxvar M1) (maxvar M2)) = 0) by omega.
rewrite max_pred in H1.
max_out.
apply transitive_red with (App (App (App binds (star M1)) (App (Op Fop) (Op Fop)))
(App binds (star M2))) .
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 binds_abs; split_all.
eapply2 binds_abs; split_all.
assert(maxvar M1 = 1 \/ maxvar M1 = 0) by omega.
inversion H1.
apply transitive_red with (App (App k_op (App (Op Fop) (Op Fop)))
(App binds (star M2))) .
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 IHnor1.
simpl in *; omega.
eval_lamSF. auto.
apply transitive_red with (App (App (App k_op i_op) (App (Op Fop) (Op Fop)))
(App binds (star M2))) .
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 binds_star_0; split_all.
eval_lamSF. eval_lamSF.
rewrite H4 in H0; simpl in H0.
eapply2 IHnor2; split_all. simpl in *; omega.
(* 1 *)
unfold binds. fixtac. fold binds. unfold binds_fn. eval_lamSF.
repeat (rewrite (subst_rec_closed equal); [| split_all]).
unfold subst_rec; fold subst_rec. insert_Ref_out.
rewrite subst_rec_lift_rec; [|split_all|split_all].
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App k_op i_op) M)N)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
rewrite lift_rec_null. rewrite lift_rec_null.
eapply2 unequal_programs; split_all.
assert(pred (max(maxvar M1) (maxvar M2)) = 0) by omega.
rewrite max_pred in H1.
auto.
eval_lamSF; eval_lamSF.
eval_lamSF; eval_lamSF; auto.
repeat (rewrite (subst_rec_lift_rec binds); try omega).
rewrite lift_rec_null.
unfold subst_rec; fold subst_rec. insert_Ref_out.
rewrite subst_rec_lift_rec; [|split_all|split_all].
rewrite lift_rec_null.
unfold binds. fold lamSF_red. fixtac. fold binds. unfold binds_fn. eval_lamSF.
repeat (rewrite (subst_rec_closed equal); [| split_all]).
unfold subst_rec; fold subst_rec. insert_Ref_out.
rewrite subst_rec_lift_rec; [|split_all|split_all].
match goal with
| |- multi_step lamSF_red1 (App (App (App (App _ ?M)?N)?P)?Q) _ =>
apply transitive_red with (App (App (App (App (App k_op i_op) M)N)P)Q)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
rewrite lift_rec_null.
eapply2 unequal_programs; split_all.
assert(pred (max(maxvar M1) (maxvar M2)) = 0) by omega.
rewrite max_pred in H1.
max_out.
eval_lamSF; eval_lamSF.
eval_lamSF; eval_lamSF; auto.
repeat (rewrite (subst_rec_lift_rec binds); try omega).
rewrite lift_rec_null.
unfold subst_rec; fold subst_rec. insert_Ref_out.
match goal with
| |- multi_step lamSF_red1 (App (App (App (App _ ?M)?N)?P)?Q) _ =>
apply transitive_red with (App (App (App (App (App k_op i_op) M)N)P)Q)
end.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 binds_rank; split_all; omega.
eval_lamSF.
match goal with
| |- multi_step lamSF_red1 (App (App _ ?M)?N) _ =>
apply transitive_red with (App (App (App binds (Abs M1)) M)N)
end.
eapply2 preserves_app_lamSF_red.
assert(pred (max(maxvar M1) (maxvar M2)) = 0) by omega.
rewrite max_pred in H1.
max_out.
apply transitive_red with (App (App (App binds (star M1)) (App (Op Fop) (Op Fop)))
(App binds (star M2))) .
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 binds_abs; split_all.
eapply2 binds_abs; split_all.
assert(maxvar M1 = 1 \/ maxvar M1 = 0) by omega.
inversion H1.
apply transitive_red with (App (App k_op (App (Op Fop) (Op Fop)))
(App binds (star M2))) .
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 IHnor1.
simpl in *; omega.
eval_lamSF. auto.
apply transitive_red with (App (App (App k_op i_op) (App (Op Fop) (Op Fop)))
(App binds (star M2))) .
eapply2 preserves_app_lamSF_red.
eapply2 preserves_app_lamSF_red.
eapply2 binds_star_0; split_all.
eval_lamSF. eval_lamSF.
rewrite H4 in H0; simpl in H0.
eapply2 IHnor2; split_all. simpl in *; omega.
Qed.
Theorem binds_abs_false :
forall M, program (Abs M) -> closed M -> lamSF_red (App binds (Abs M)) (App k_op i_op).
Proof.
split_all.
apply transitive_red with (App binds (star M)). eapply2 binds_abs.
eapply2 binds_star_0. inversion H. inversion H1. split_all.
Qed.
Theorem binds_abs_true :
forall M, program (Abs M) -> maxvar M = 1 -> lamSF_red (App binds (Abs M)) k_op.
Proof.
split_all.
apply transitive_red with (App binds (star M)). eapply2 binds_abs.
eapply2 binds_star_1. inversion H. inversion H1. split_all.
Qed.