forked from TiarkRompf/minidot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
dot.elf
4150 lines (3163 loc) · 124 KB
/
dot.elf
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
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%%%%% Natural numbers %%%%%
nat : type. %name nat N.
z : nat.
s : nat -> nat.
add : nat -> nat -> nat -> type. %name add A.
add/z: add z N N.
add/s: add (s N1) N2 (s N3) <- add N1 N2 N3.
lte : nat -> nat -> type.
lte/z : lte z N.
lte/s : lte (s N1) (s N2)
<- lte N1 N2.
%%%%% Syntax %%%%%
% sorts
tp : type. %name tp T.
dc: type. %name dc D.
dcs: type.
tm : type.
val : type.
ic: type.
ics: type.
% types
top : tp.
sel : nat -> nat -> tp.
bind : nat -> dcs -> tp.
topt : type.
tnone : topt.
tsome : tp -> topt.
% declarations
arrow : tp -> tp -> dc.
rect : topt -> tp -> dc.
dnil: dcs.
dcons: dc -> dcs -> dcs.
% initializations
fun: tm -> ic.
non: ic. % place holder for type member
inil: ics.
icons: ic -> ics -> ics.
% environments
tenv: type. %name tenv G.
tnil: tenv.
tcons: tp -> tenv -> tenv.
venv: type.
vnil: venv.
vcons: val -> venv -> venv.
% terms / expressions
new: nat -> dcs -> ics -> tm.
app: tm -> nat -> tm -> tm.
var: nat -> tm.
%abbrev
let: nat -> tm -> tp -> tm -> tp -> tm
= [n] [e1] [t1] [e2] [t2]
(app (new n
(dcons (arrow t1 t2) dnil)
(icons (fun e2) inil))
z
e1).
% values
clo: venv -> ics -> val.
%{ ------- environments ----- }%
vlookup-zero : venv -> nat -> val -> type.
vl/hit : vlookup-zero (vcons V H) z V.
vl/miss : vlookup-zero (vcons V' H) (s N) V <- vlookup-zero H N V.
vsize : venv -> nat -> type.
%mode vsize +A -B.
vf/n : vsize vnil z.
vf/c : vsize (vcons V H) (s N) <- vsize H N.
%worlds () (vsize _ _).
%total A (vsize A _).
vlookup: venv -> nat -> val -> type.
vl : vlookup G N V
<- vsize G S
<- add (s N) M S
<- vlookup-zero G M V.
tlookup-zero: tenv -> nat -> tp -> type.
tl/hit : tlookup-zero (tcons V G) z V.
tl/miss : tlookup-zero (tcons V' G) (s N) V <- tlookup-zero G N V.
tsize : tenv -> nat -> type.
tf/n : tsize tnil z.
tf/c : tsize (tcons V G) (s N) <- tsize G N.
%worlds () (tsize _ _).
tlookup: tenv -> nat -> tp -> type.
tl : tlookup G N V
<- tsize G S
<- add (s N) M S
<- tlookup-zero G M V.
% Partial ordering on environments
sub-env: tenv -> tenv -> type.
sub-env/refl: sub-env G G.
sub-env/ext: sub-env G1 (tcons Z G2) <- sub-env G1 G2.
sub-env-size: tenv -> nat -> tenv -> type.
ses: sub-env-size GN N G
<- sub-env GN G
<- tsize GN N.
sub-venv: venv -> venv -> type.
sub-venv/refl: sub-venv G G.
sub-venv/ext: sub-venv G1 (vcons Z G2) <- sub-venv G1 G2.
sub-venv-size: venv -> nat -> venv -> type.
svs: sub-venv-size GN N G
<- sub-venv GN G
<- vsize GN N.
%%%%% Semantics %%%%%
% --------------- operational (evaluation) ------------- %
ilk : ics -> nat -> ic -> type.
ilk/z : ilk (icons D DS) z D.
ilk/s : ilk (icons D DS) (s N) D' <- ilk DS N D'.
eval : venv -> tm -> val -> type.
e/var: eval G (var N) V
<- vlookup G N V
.
e/new: eval G (new N DS IS) (clo GN IS)
<- sub-venv-size GN N G
.
e/app: eval G (app E1 X E2) V3
<- eval G E1 (clo G1 IS)
<- ilk IS X (fun E3)
<- eval G E2 V2
<- eval (vcons V2 (vcons (clo G1 IS) G1)) E3 V3
.
% --------------- typing ------------- %
dlk : dcs -> nat -> dc -> type.
dlk/z : dlk (dcons D DS) z D.
dlk/s : dlk (dcons D DS) (s N) D' <- dlk DS N D'.
xp : tenv -> tp -> nat -> dcs -> type.
has-mem : tenv -> nat -> nat -> dc -> type.
xp/bind : xp G (bind N DS) N DS.
xp/sel : xp G (sel N' X') N DS
<- has-mem G N' X' (rect _ U)
<- xp G U N DS.
xp/top : xp G top N dnil.
has : has-mem G N X D
<- tlookup G N T
<- sub-env-size GN N G
<- xp (tcons T GN) T N DS
<- dlk DS X D.
mode1: type.
notrans: mode1.
oktrans: mode1.
stp : {I1:mode1} tenv -> tp -> tp -> type.
sdcs : {I1:mode1} tenv -> dcs -> dcs -> type.
sdc : {I1:mode1} tenv -> dc -> dc -> type.
stpo : {I1:mode1} tenv -> topt -> tp -> type.
stpoo: {I1:mode1} tenv -> topt -> topt -> type.
stpo/n : stpo I0 G tnone U.
stpo/s : stpo I0 G (tsome S) U <- stp I0 G S U.
stpoo/nn : stpoo I0 G tnone tnone.
stpoo/ns : stpoo I0 G tnone (tsome U).
stpoo/ss : stpoo I0 G (tsome S) (tsome U) <- stp I0 G S U.
stp/top2 : stp notrans G top top.
stp/top : stp notrans G A top
<- stp oktrans G A A.
stp/sel1 : stp notrans G (sel N X) T
<- sub-env-size GN (s N) G
<- has-mem GN N X (rect OL U)
<- stpoo oktrans G OL OL
<- stp oktrans G U T
.
stp/sel2 : stp notrans G T (sel N X)
<- sub-env-size GN (s N) G
<- has-mem GN N X (rect (tsome L) U)
<- stp oktrans GN L U
<- stp oktrans G T L
.
stp/selx : stp notrans G (sel N X) (sel N X)
<- sub-env-size GN (s N) G
<- has-mem GN N X (rect OL U)
<- stp oktrans G U U
<- stpoo oktrans G OL OL
.
stp/bind : stp notrans G (bind N DS1) (bind N DS2)
<- sub-env-size GN N G
<- sdcs oktrans (tcons (bind N DS2) GN) DS2 DS2
<- sdcs oktrans (tcons (bind N DS1) GN) DS1 DS1
<- sdcs oktrans (tcons (bind N DS1) GN) DS1 DS2
.
stp/trans0 : stp oktrans G T1 T2
<- stp notrans G T1 T2
.
sdc/arrow : sdc I0 G (arrow L1 U1) (arrow L2 U2)
<- stp I0 G U1 U2
<- stp I0 G L2 L1
.
sdc/rect : sdc I0 G (rect OL1 U1) (rect OL2 U2)
<- stpo I0 G OL2 U2
<- stpo I0 G OL1 U1
<- stp I0 G U1 U2
<- stpoo I0 G OL2 OL1
.
sdcs/nil : sdcs I0 G dnil dnil.
sdcs/ext : sdcs I0 G (dcons D DS) dnil
% <- sdcs I0 G (dcons D DS) (dcons D DS)
.
sdcs/cons : sdcs I0 G (dcons D1 DS1) (dcons D2 DS2)
<- sdc I0 G D1 D2
<- sdcs I0 G DS1 DS2.
wf-tp : tenv -> tp -> type.
stprefl : wf-tp G T <- stp notrans G T T.
wf-dc : tenv -> dc -> type.
sdcrefl : wf-dc G D <- sdc notrans G D D.
stp2 : tenv -> tp -> tenv -> tp -> type.
stp2/top : stp2 G1 T1 G2 top
<- wf-tp G1 T1.
stp2/sel1 : stp2 G1 (sel N X) G2 T
<- sub-env-size GN (s N) G1
<- has-mem GN N X (rect OL U)
<- stpoo oktrans G1 OL OL
<- stp2 G1 U G2 T
.
stp2/sel2 : stp2 G1 T G2 (sel N X)
<- sub-env-size GN (s N) G2
<- has-mem GN N X (rect (tsome L) U)
<- stp oktrans GN L U
<- stp2 G1 T G2 U
<- stp2 G1 T G2 L
.
stp2/selxn: stp2 G1 (sel N X) G2 (sel N X)
<- sub-env-size GN (s N) G2
<- sub-env-size GN (s N) G1
<- has-mem GN N X (rect tnone U)
<- stp2 G1 U G2 U
.
stp2/selxs: stp2 G1 (sel N X) G2 (sel N X)
<- sub-env-size GN (s N) G2
<- sub-env-size GN (s N) G1
<- has-mem GN N X (rect (tsome L) U)
<- stp2 G1 U G2 U
<- stp2 G1 L G2 L
.
stp2/bind : stp2 G1 (bind N DS1) G2 (bind N DS2)
<- sub-env-size GN N G2
<- sub-env-size GN N G1
<- sdcs oktrans (tcons (bind N DS2) GN) DS2 DS2
<- sdcs oktrans (tcons (bind N DS1) GN) DS1 DS1
<- sdcs oktrans (tcons (bind N DS1) GN) DS1 DS2
.
typ : tenv -> tm -> tp -> type.
typcs: tenv -> ics -> dcs -> type.
t/var : typ G (var N) T
<- tlookup G N T
<- wf-tp G T
.
t/new : typ G (new N DCS ICS) (bind N DCS)
<- sub-env-size GN N G
<- typcs (tcons (bind N DCS) GN) ICS DCS
<- wf-tp GN (bind N DCS)
.
t/app : typ G (app E1 X E2) T
<- typ G E1 (bind N DS)
<- dlk DS X (arrow T2 T)
<- typ G E2 T2
<- sub-env-size GN N G
<- wf-tp GN T2
<- wf-tp GN T
.
t/nil : typcs G inil dnil.
t/fun : typcs G (icons (fun E) ICS) (dcons (arrow S U) DCS)
<- typ (tcons S G) E U
<- typcs G ICS DCS
.
t/non : typcs G (icons non ICS) (dcons (rect S U) DCS)
<- typcs G ICS DCS
.
t/sub : typ G E U
<- typ G E T
<- stp2 G T G U
.
wf-val : val -> tenv -> tp -> type.
wf-env : venv -> tenv -> type.
v/clo : wf-val (clo H ICS) G T
<- wf-env H GC
<- tsize GC N
<- typcs (tcons (bind N DCS) GC) ICS DCS
<- stp2 GC (bind N DCS) G T
.
v/sub : wf-val V G U
<- wf-val V G0 T
<- stp2 G0 T G U
.
wfe/n : wf-env vnil tnil.
wfe/c : wf-env (vcons V H) (tcons T G)
<- wf-val V (tcons T G) T
<- wf-env H G.
%%% QUERIES %%%
%query 1 1 stp2 tnil top tnil top.
%query 1 1 stp2 tnil (bind z dnil) tnil top.
%query 1 1 stp2 tnil (bind z dnil) tnil (bind z dnil).
%query 1 1 stp2 tnil (bind z (dcons (rect tnone top) dnil))
tnil (bind z (dcons (rect tnone top) dnil)).
%query 1 1 stp2 tnil (bind z (dcons (rect (tsome top) top) dnil))
tnil (bind z (dcons (rect tnone top) dnil)).
%query 1 1 stp2 tnil (bind z (dcons (rect (tsome top) top) (dcons (arrow (sel z z) top) dnil)))
tnil (bind z (dcons (rect tnone top) dnil)).
%query 1 1 stp2 tnil (bind z (dcons (rect (tsome top) top) (dcons (arrow top (sel z z)) dnil)))
tnil (bind z (dcons (rect tnone top) dnil)).
%query 1 1 stp2 tnil (bind z (dcons (rect (tsome top) top) (dcons (arrow top (sel z z)) dnil)))
tnil (bind z (dcons (rect (tsome top) top) (dcons (arrow top (sel z z)) dnil))).
%query 1 1 stp2 tnil (bind z (dcons (rect (tsome top) top) (dcons (arrow (sel z z) (sel z z)) dnil)))
tnil (bind z (dcons (rect (tsome top) top) (dcons (arrow (sel z z) (sel z z)) dnil))).
%query 1 1 stp2 tnil (bind z (dcons (rect (tsome top) top) (dcons (arrow top (sel z z)) dnil)))
tnil (bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil))).
%query 1 1 stp2 tnil (bind z (dcons (rect (tsome top) top) (dcons (arrow (sel z z) top) dnil)))
tnil (bind z (dcons (rect tnone top) (dcons (arrow (sel z z) top) dnil))).
%query 1 1 stp2 tnil (bind z (dcons (rect (tsome top) top) (dcons (arrow (sel z z) (sel z z)) dnil)))
tnil (bind z (dcons (rect tnone top) (dcons (arrow (sel z z) (sel z z)) dnil))).
%query 1 1 stp2 tnil (bind z (dcons (rect (tsome top) top) dnil)) tnil (bind z dnil).
%query 1 1 stp2 tnil (bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil)))
tnil (bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil))).
%query 1 1 stp2 tnil (bind z (dcons (rect (tsome top) top) (dcons (arrow top (sel z z)) dnil)))
tnil (bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil))).
%query 1 1 typ tnil (new z dnil inil) top.
%query 1 1 typ tnil (new z (dcons (rect (tsome top) top) dnil) (icons non inil)) top.
%query 1 1 typ tnil (new z (dcons (arrow top top) dnil) (icons (fun (var (s z))) inil)) top.
%query 1 1 typ tnil (new z (dcons (arrow top top) dnil) (icons (fun (var (s z))) inil)) (bind z (dcons (arrow top top) dnil)).
%query 1 1 typ tnil (new z (dcons (rect (tsome top) top) (dcons (arrow top top) dnil)) (icons non (icons (fun (var (s z))) inil))) top.
%query 1 1 typ tnil (new z (dcons (rect (tsome top) top) (dcons (arrow top top) dnil)) (icons non (icons (fun (var (s z))) inil))) (bind z (dcons (rect (tsome top) top) (dcons (arrow top top) dnil))).
%query 1 1 typ tnil (new z (dcons (rect (tsome top) top) (dcons (arrow top top) dnil)) (icons non (icons (fun (var (s z))) inil))) (bind z (dcons (rect tnone top) (dcons (arrow top top) dnil))).
%query 1 1 typ tnil (new z (dcons (rect (tsome top) top) (dcons (arrow top top) dnil)) (icons non (icons (fun (var (s z))) inil))) (bind z (dcons (rect tnone top) dnil)).
%query 1 1 typ tnil (new z (dcons (rect (tsome top) top) (dcons (arrow top (sel z z)) dnil)) (icons non (icons (fun (var (s z))) inil))) (bind z (dcons (rect (tsome top) top) (dcons (arrow top top) dnil))).
%query 1 1 typ tnil (new z (dcons (rect (tsome top) top) (dcons (arrow top (sel z z)) dnil)) (icons non (icons (fun (var (s z))) inil))) (bind z (dcons (rect (tsome top) top) (dcons (arrow top (sel z z)) dnil))).
%query 1 1 typ tnil (new z (dcons (rect (tsome top) top) (dcons (arrow top (sel z z)) dnil)) (icons non (icons (fun (var (s z))) inil))) (bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil))).
%query 1 1 typ tnil (let z (new z dnil inil) top (var (s z)) top) top.
%query 1 1 typ tnil (new z (dcons (arrow top top) dnil) (icons (fun (var (s z))) inil)) (bind z (dcons (arrow top top) dnil)).
%query 1 1 typ tnil (app (new z (dcons (arrow top top) dnil) (icons (fun (var (s z))) inil))
z
(new z dnil inil))
top.
%query 1 1 typ tnil (app (new z (dcons (arrow top top) dnil) (icons (fun (var (s z))) inil))
z
(new z (dcons (arrow top top) dnil) (icons (fun (var (s z))) inil)))
top.
%query 1 1 typ tnil (let z (new z (dcons (rect (tsome top) top) dnil) (icons non inil)) top (var (s z)) top) top.
%query 1 1 typ tnil (let z (new z (dcons (rect (tsome top) top) dnil) (icons non inil)) (bind z (dcons (rect tnone top) dnil)) (var (s z)) top) top.
%query 1 1 typ tnil (let z (new z (dcons (rect (tsome top) top) (dcons (arrow top top) dnil)) (icons non (icons (fun (var (s z))) inil))) (bind z (dcons (rect tnone top) dnil)) (var (s z)) top) top.
%query 1 1 typ tnil (let z (new z (dcons (rect (tsome top) top) (dcons (arrow top top) dnil)) (icons non (icons (fun (var (s z))) inil))) (bind z (dcons (rect tnone top) (dcons (arrow top top) dnil))) (var (s z)) top) top.
%query 1 1 typ tnil (let z (new z (dcons (rect (tsome top) top) (dcons (arrow top (sel z z)) dnil)) (icons non (icons (fun (var (s z))) inil))) (bind z (dcons (rect tnone top) (dcons (arrow top top) dnil))) (var (s z)) top) top.
%query 1 1 typ tnil (let z (new z (dcons (rect (tsome top) top) (dcons (arrow top (sel z z)) dnil)) (icons non (icons (fun (var (s z))) inil))) (bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil))) (var (s z)) top) top.
%query 1 1 typ (tcons (bind z (dcons (arrow top top) dnil)) tnil) (var z) top.
%query 1 1 typ (tcons (bind z (dcons (arrow top top) dnil)) tnil) (var z) (bind z (dcons (arrow top top) dnil)).
%query 1 1 typ (tcons (bind z (dcons (arrow top top) dnil)) tnil) (app (var z) z (var z)) top.
%query 1 1 typ (tcons (bind z (dcons (rect tnone top) (dcons (arrow top top) dnil))) tnil) (app (var z) (s z) (var z)) top.
%query 1 1 typ (tcons (bind (s z) (dcons (arrow top (sel z z)) dnil))
(tcons (bind z (dcons (rect (tsome top) top) (dcons (arrow top (sel z z)) dnil))) tnil))
(var z) top.
%query 1 1 typ (tcons (bind (s z) (dcons (arrow top (sel z z)) dnil))
(tcons (bind z (dcons (rect (tsome top) top) (dcons (arrow top (sel z z)) dnil))) tnil))
(var (s z)) top.
%query 1 1 typ (tcons (bind (s z) (dcons (arrow top (sel z z)) dnil))
(tcons (bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil))) tnil))
(var z) top.
%query 1 1 typ (tcons (bind (s z) (dcons (arrow top (sel z z)) dnil))
(tcons (bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil))) tnil))
(var (s z)) top.
%query 1 1 stp2 (tcons (bind (s z) (dcons (arrow top (sel z z)) dnil))
(tcons (bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil))) tnil))
(sel z z)
(tcons (bind (s z) (dcons (arrow top (sel z z)) dnil))
(tcons (bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil))) tnil))
(sel z z).
%query 1 1 stp oktrans
(tcons (bind (s z) (dcons (arrow top (sel z z)) dnil))
(tcons (bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil))) tnil))
(sel z z)
(sel z z).
%query 1 1 stp2 (tcons (bind (s z) (dcons (arrow top (sel z z)) dnil))
(tcons (bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil))) tnil))
(sel z z)
(tcons (bind (s z) (dcons (arrow top (sel z z)) dnil))
(tcons (bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil))) tnil))
top.
%query 1 1 stp2 (tcons (bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil))) tnil)
(sel z z)
(tcons (bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil))) tnil)
top.
%query 1 1 typ (tcons (bind (s z) (dcons (arrow top (sel z z)) dnil))
(tcons (bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil))) tnil))
(var (s z)) (bind (s z) (dcons (arrow top (sel z z)) dnil)).
%query 1 1 typ (tcons (bind (s z) (dcons (arrow top (sel z z)) dnil))
(tcons (bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil))) tnil))
(app (var (s z)) z (new z dnil inil)) (sel z z).
%query 1 1 typ (tcons (bind (s z) (dcons (arrow top (sel z z)) dnil))
(tcons (bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil))) tnil))
(let (s z) (app (var (s z)) z (new z dnil inil)) (sel z z) (var (s (s z))) (sel z z)) (sel z z).
%query 1 1 typ (tcons (bind (s z) (dcons (arrow top (sel z z)) dnil))
(tcons (bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil))) tnil))
(let (s z) (app (var (s z)) z (new z dnil inil)) (sel z z) (var (s (s z))) top) top.
%query 1 1 typ tnil
(let z
(new z (dcons (rect (tsome top) top) (dcons (arrow top (sel z z)) dnil)) (icons non (icons (fun (var (s z))) inil)))
(bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil)))
(let (s z)
(new (s z) (dcons (arrow top top) dnil) (icons (fun (new z dnil inil)) inil))
(bind (s z) (dcons (arrow top top) dnil))
(new z dnil inil)
top)
top)
top.
%query 1 1 typ tnil
(let z
(new z (dcons (rect (tsome top) top) (dcons (arrow top (sel z z)) dnil)) (icons non (icons (fun (var (s z))) inil)))
(bind z (dcons (rect tnone top) (dcons (arrow top (sel z z)) dnil)))
(let (s z)
(var z)
(top)
(new z dnil inil)
top)
top)
top.
%query 1 1 typ tnil (new z (dcons (rect (tsome top) top) (dcons (arrow top (bind (s z) (dcons (arrow top (sel z z)) dnil))) dnil))
(icons non (icons (fun (new (s z) (dcons (arrow top (sel z z)) dnil)
(icons (fun (var (s (s z)))) inil))) inil))) top.
%query 1 1 typ tnil (new z (dcons (rect (tsome top) top) (dcons (arrow top (bind (s z) (dcons (arrow top (sel z z)) dnil))) dnil))
(icons non (icons (fun (new (s z) (dcons (arrow top (sel z z)) dnil)
(icons (fun (var (s (s z)))) inil))) inil)))
(bind z (dcons (rect (tsome top) top) (dcons (arrow top (bind (s z) (dcons (arrow top (sel z z)) dnil))) dnil))).
%query 1 1 stp2 tnil (bind z (dcons (rect (tsome top) top) (dcons (arrow top (bind (s z) (dcons (arrow top (sel z z)) dnil))) dnil)))
tnil (bind z (dcons (rect tnone top) (dcons (arrow top (bind (s z) (dcons (arrow top (sel z z)) dnil))) dnil))).
%query 1 1 typ tnil (new z (dcons (rect (tsome top) top) (dcons (arrow top (bind (s z) (dcons (arrow top (sel z z)) dnil))) dnil))
(icons non (icons (fun (new (s z) (dcons (arrow top (sel z z)) dnil)
(icons (fun (var (s (s z)))) inil))) inil)))
(bind z (dcons (rect tnone top) (dcons (arrow top (bind (s z) (dcons (arrow top (sel z z)) dnil))) dnil))).
%query 1 1 typ tnil
(let z
(new z (dcons (rect (tsome top) top) (dcons (arrow top (bind (s z) (dcons (arrow top (sel z z)) dnil))) dnil))
(icons non (icons (fun (new (s z) (dcons (arrow top (sel z z)) dnil)
(icons (fun (var (s (s z)))) inil))) inil)))
(bind z (dcons (rect tnone top) (dcons (arrow top (bind (s z) (dcons (arrow top (sel z z)) dnil))) dnil)))
(var z)
top)
top.
% EOF
stp/trans : stp oktrans G T1 T3
<- stp oktrans G T2 T3
<- stp oktrans G T1 T2
.
%%% PROOFS %%%
sev : {I1:mode1} tenv -> tenv -> tenv -> type.
sev/sub : sev IO (tcons (bind N P) G) (tcons (bind N P) G1) (tcons (bind N Q) G2)
<- sev IO G G1 G2
<- sdcs IO (tcons (bind N P) G) P Q.
sev/refl0 : sev IO (tcons (bind N P) G) (tcons (bind N P) G1) (tcons (bind N P) G2)
<- sev IO G G1 G2.
sev/refl : sev IO G G1 G1.
% --------------- basic math ------------- %
add-reduces: {N1}{N2}{N3}add N1 N2 N3 -> type.
%mode add-reduces +N1 +N2 +N3 +A.
- : add-reduces _ _ _ (add/z).
- : add-reduces _ _ _ (add/s A) <- add-reduces _ _ _ A.
%worlds () (add-reduces _ _ _ _).
%total (A) (add-reduces A _ _ _).
%reduces N2 <= N3 (add-reduces N1 N2 N3 A).
add-inc: add A B C -> add A (s B) (s C) -> type.
%mode add-inc +E1 -E2.
- : add-inc add/z add/z.
- : add-inc (add/s A1) (add/s A2)
<- add-inc A1 A2.
%worlds () (add-inc _ _).
%total {A} (add-inc A _).
add-swap: add A (s B) C -> add (s A) B C -> type.
%mode add-swap +E1 -E2.
- : add-swap add/z (add/s add/z).
- : add-swap (add/s A) (add/s B)
<- add-swap A B.
%worlds () (add-swap _ _).
%total {A} (add-swap A _).
add-commute : {N1}{N2}{N3}add N1 N2 N3 -> add N2 N1 N3 -> type.
%mode add-commute +X1 +X2 +X3 +X4 -X5.
-: add-commute z (s M) _ add/z (add/s D)
<- add-commute z M _ add/z D.
-: add-commute _ z _ _ add/z.
-: add-commute (s N1) N2 _ (add/s D) D''
<- add-commute N1 N2 _ D D'
<- add-inc D' D''.
%worlds () (add-commute _ _ _ _ _).
%total [N1 N2] (add-commute N1 N2 _ _ _).
lte-inc : lte A B -> lte A (s B) -> type.
%mode lte-inc +A -B.
- : lte-inc lte/z lte/z.
- : lte-inc (lte/s A) (lte/s B)
<- lte-inc A B.
%worlds () (lte-inc _ _).
%total A (lte-inc A _).
% --------------- equalities ------------- %
eq-nat : nat -> nat -> type.
eq-nat/z : eq-nat z z.
eq-nat/s : eq-nat (s N1) (s N2)
<- eq-nat N1 N2.
id-nat : nat -> nat -> type.
id-nat/refl : id-nat N N.
s-injective : id-nat N1 N2 -> id-nat (s N1) (s N2) -> type.
%mode s-injective +A -B.
s-injective/refl : s-injective id-nat/refl id-nat/refl.
%worlds () (s-injective _ _).
%total (A) (s-injective A _).
eq2id-nat : eq-nat N1 N2 -> id-nat N1 N2 -> type.
%mode eq2id-nat +A -B.
eq2id-nat/z : eq2id-nat eq-nat/z id-nat/refl.
eq2id-nat/s : eq2id-nat (eq-nat/s A) OUT
<- eq2id-nat A B
<- s-injective B OUT.
%worlds () (eq2id-nat _ _).
%total (A) (eq2id-nat A _).
eq-nat-refl : {N} eq-nat N N -> type.
%mode eq-nat-refl +N -EQ.
eq-nat-refl/z : eq-nat-refl z eq-nat/z.
eq-nat-refl/s : eq-nat-refl (s N) (eq-nat/s EQ)
<- eq-nat-refl N EQ.
%worlds () (eq-nat-refl _ _).
%total (N) (eq-nat-refl N _).
id2eq-nat : id-nat N1 N2 -> eq-nat N1 N2 -> type.
%mode id2eq-nat +A -B.
- : id2eq-nat id-nat/refl EQ
<- eq-nat-refl _ EQ.
%worlds () (id2eq-nat _ _).
%total (A) (id2eq-nat A _).
id-nat-sym : id-nat N1 N2 -> id-nat N2 N1 -> type.
%mode id-nat-sym +A -B.
- : id-nat-sym id-nat/refl id-nat/refl.
%worlds () (id-nat-sym _ _).
%total (A) (id-nat-sym A _).
eq-nat-sym : eq-nat C C' -> eq-nat C' C -> type.
%mode eq-nat-sym +A -B.
- : eq-nat-sym eq-nat/z eq-nat/z.
- : eq-nat-sym (eq-nat/s A) (eq-nat/s B)
<- eq-nat-sym A B.
%worlds () (eq-nat-sym _ _).
%total A (eq-nat-sym A _).
id-tp : tp -> tp -> type.
id-tp/refl : id-tp D D.
id-topt : topt -> topt -> type.
id-topt/refl : id-topt D D.
id-dc : dc -> dc -> type.
id-dc/refl : id-dc D D.
id-dcs : dcs -> dcs -> type.
id-dcs/refl : id-dcs D D.
id-tenv : tenv -> tenv -> type.
id-tenv/refl : id-tenv G G.
id-tenv-trans : id-tenv G1 G2 -> id-tenv G2 G3 -> id-tenv G1 G3 -> type.
%mode id-tenv-trans +A +B -C.
- : id-tenv-trans id-tenv/refl id-tenv/refl id-tenv/refl.
%worlds () (id-tenv-trans _ _ _).
%total {A B} (id-tenv-trans A B _).
id-tenv-sym : id-tenv G1 G2 -> id-tenv G2 G1 -> type.
%mode id-tenv-sym +A -B.
- : id-tenv-sym id-tenv/refl id-tenv/refl.
%worlds () (id-tenv-sym _ _).
%total (A) (id-tenv-sym A _).
id-venv : venv -> venv -> type.
id-venv/refl : id-venv G G.
id-venv-trans : id-venv G1 G2 -> id-venv G2 G3 -> id-venv G1 G3 -> type.
%mode id-venv-trans +A +B -C.
- : id-venv-trans id-venv/refl id-venv/refl id-venv/refl.
%worlds () (id-venv-trans _ _ _).
%total {A B} (id-venv-trans A B _).
id-venv-sym : id-venv G1 G2 -> id-venv G2 G1 -> type.
%mode id-venv-sym +A -B.
- : id-venv-sym id-venv/refl id-venv/refl.
%worlds () (id-venv-sym _ _).
%total (A) (id-venv-sym A _).
sub-venv-refl : id-venv V V' -> sub-venv V V' -> type.
%mode sub-venv-refl +A -B.
- : sub-venv-refl id-venv/refl sub-venv/refl.
%worlds () (sub-venv-refl _ _).
%total (A) (sub-venv-refl A _).
id-val : val -> val -> type.
id-val/refl : id-val D D.
id-ic : ic -> ic -> type.
id-ic/refl : id-ic I I.
% --------------- contradictions ------------- %
false: type.
lte-s-false: lte (s N) N -> false -> type.
%mode lte-s-false +A -B.
- : lte-s-false (lte/s A) CONTRA
<- lte-s-false A CONTRA.
%worlds () (lte-s-false _ _).
%total A (lte-s-false A _).
add-contra : add (s N1) N2 N1 -> false -> type.
%mode add-contra +A -B.
- : add-contra (add/s A) B
<- add-contra A B.
%worlds () (add-contra _ _).
%total (A) (add-contra A _).
id-topt-contra : id-topt tnone (tsome T) -> false -> type.
%mode id-topt-contra +A -B.
%worlds () (id-topt-contra _ _).
%total (A) (id-topt-contra A _).
tlookup-contra : tlookup tnil N DS -> false -> type.
%mode tlookup-contra +A -B.
%worlds () (tlookup-contra _ _).
%total (A) (tlookup-contra A _).
contra-tlookup : false -> {G} {N} {DS} tlookup G N DS -> type.
%mode contra-tlookup +CONTRA +G +N +DS -A.
%worlds () (contra-tlookup _ _ _ _ _).
%total (A) (contra-tlookup A _ _ _ _).
contra-has-mem : false -> {G} {N} {X} {D} has-mem G N X D -> type.
%mode contra-has-mem +CONTRA +G +N +X +D -A.
%worlds () (contra-has-mem _ _ _ _ _ _).
%total (A) (contra-has-mem A _ _ _ _ _).
contra-sdc : false -> {G} {D1} {D2} sdc oktrans G D1 D2 -> type.
%mode contra-sdc +CONTRA +G +D1 +D2 -A.
%worlds () (contra-sdc _ _ _ _ _).
%total (A) (contra-sdc A _ _ _ _).
contra-dcs : false -> {Z1}{Z2} id-dcs Z1 Z2 -> type.
%mode contra-dcs +CONTRA +Z1 +Z2 -A.
%worlds () (contra-dcs _ _ _ _).
%total (A) (contra-dcs A _ _ _).
contra-tp : false -> {T1}{T2} id-tp T1 T2 -> type.
%mode contra-tp +CONTRA +Z1 +Z2 -A.
%worlds () (contra-tp _ _ _ _).
%total (A) (contra-tp A _ _ _).
contra-val : false -> {T1}{T2} id-val T1 T2 -> type.
%mode contra-val +CONTRA +Z1 +Z2 -A.
%worlds () (contra-val _ _ _ _).
%total (A) (contra-val A _ _ _).
contra-nat : false -> {N1} {N2} id-nat N1 N2 -> type.
%mode contra-nat +CONTRA +Z1 +Z2 -A.
%worlds () (contra-nat _ _ _ _).
%total (A) (contra-nat A _ _ _).
contra-venv : false -> {N1} {N2} id-venv N1 N2 -> type.
%mode contra-venv +CONTRA +Z1 +Z2 -A.
%worlds () (contra-venv _ _ _ _).
%total (A) (contra-venv A _ _ _).
contra-sub-env : false -> {G1} {G2} sub-env G1 G2 -> type.
%mode contra-sub-env +CONTRA +G1 +G2 -A.
%worlds () (contra-sub-env _ _ _ _).
%total (A) (contra-sub-env A _ _ _).
contra-stp2 : false -> {G1} {T1} {G2} {T2} stp2 G1 T1 G2 T2 -> type.
%mode contra-stp2 +CONTRA +G1 +T1 +G2 +T2 -A.
%worlds () (contra-stp2 _ _ _ _ _ _).
%total (A) (contra-stp2 A _ _ _ _ _).
% --------------- more arithmetic lemmas ------------- %
add-zero : add N N0 N -> id-nat N0 z -> type.
%mode add-zero +A -B.
- : add-zero add/z id-nat/refl.
- : add-zero (add/s A) ID
<- add-zero A ID.
%worlds () (add-zero _ _).
%total (A) (add-zero A _).
add-z : add z N1 N2 -> id-nat N1 N2 -> type.
%mode add-z +A -B.
- : add-z add/z id-nat/refl.
%worlds () (add-z _ _).
%total (A) (add-z A _).
add-dec : add A (s B) (s C) -> add A B C -> type.
%mode add-dec +A -B.
- : add-dec add/z add/z.
- : add-dec (add/s A) (add/s B)
<- add-dec A B.
%worlds () (add-dec _ _).
%total {A} (add-dec A _).
% --------------- uniqueness lemmas ------------- %
eq-add : add N1 N2 N3 -> id-nat N3 N3' -> add N1 N2 N3' -> type.
%mode eq-add +A +EQ -B.
- : eq-add A id-nat/refl A.
%worlds () (eq-add _ _ _).
%total (EQ) (eq-add _ EQ _).
dlk-unique : dlk DS X D -> dlk DS X D' -> id-dc D D' -> type.
%mode dlk-unique +A +B -EQ.
dlk-unique/z : dlk-unique dlk/z _ id-dc/refl.
dlk-unique/s : dlk-unique (dlk/s A) (dlk/s B) EQ
<- dlk-unique A B EQ.
%worlds () (dlk-unique _ _ _).
%total (A) (dlk-unique A _ _).
dlk-unique-rec : dlk DS X D -> dlk DS' X D' -> id-dcs DS DS' -> id-dc D D' -> type.
%mode dlk-unique-rec +A +B +EQDS -EQD.
- : dlk-unique-rec A B id-dcs/refl EQD
<- dlk-unique A B EQD.
%worlds () (dlk-unique-rec _ _ _ _).
%total (EQ) (dlk-unique-rec _ _ EQ _).
eq-bind : id-nat N N' -> {DS} id-tp (bind N DS) (bind N' DS) -> type.
%mode eq-bind +A +B -C.
- : eq-bind id-nat/refl _ id-tp/refl.
%worlds () (eq-bind _ _ _).
%total (A) (eq-bind A _ _).
eq-some : id-topt (tsome L) (tsome L') -> id-tp L L' -> type.
%mode eq-some +A -B.
eq-some/refl : eq-some id-topt/refl id-tp/refl.
%worlds () (eq-some _ _).
%total (A) (eq-some A _).
eq-rect : id-dc (rect L U) (rect L' U') -> id-topt L L' -> id-tp U U' -> type.
%mode eq-rect +A -EQL -EQU.
eq-rect/refl : eq-rect id-dc/refl id-topt/refl id-tp/refl.
%worlds () (eq-rect _ _ _).
%total (A) (eq-rect A _ _).
eq-sub-env-size-l : id-tenv G1 G1' -> sub-env-size G1 N G2 -> sub-env-size G1' N G2 -> type.
%mode eq-sub-env-size-l +EQ +A -B.
- : eq-sub-env-size-l id-tenv/refl B B.
%worlds () (eq-sub-env-size-l _ _ _).
%total (A) (eq-sub-env-size-l A _ _).
%reduces C <= B (eq-sub-env-size-l _ B C).
eq-wf-env-v : id-venv H H' -> wf-env H G -> wf-env H' G -> type.
%mode eq-wf-env-v +A +B -C.
- : eq-wf-env-v id-venv/refl B B.
%worlds () (eq-wf-env-v _ _ _).
%total (A) (eq-wf-env-v A _ _).
eq-wf-tp : id-tp T T' -> wf-tp G T -> wf-tp G T' -> type.
%mode eq-wf-tp +EQ +B -C.
- : eq-wf-tp id-tp/refl B B.
%worlds () (eq-wf-tp _ _ _).
%total (A) (eq-wf-tp A _ _).
eq-wf-tp-g : id-tenv G G' -> wf-tp G T -> wf-tp G' T -> type.
%mode eq-wf-tp-g +EQ +B -C.
- : eq-wf-tp-g id-tenv/refl B B.
%worlds () (eq-wf-tp-g _ _ _).
%total (A) (eq-wf-tp-g A _ _).
eq-sdc-l : id-dc L L' -> sdc I G L U -> sdc I G L' U -> type.
%mode eq-sdc-l +EQ +B -C.
- : eq-sdc-l id-dc/refl B B.
%worlds () (eq-sdc-l _ _ _).
%total (A) (eq-sdc-l A _ _).
%reduces C <= B (eq-sdc-l _ B C).
eq-stp-l : id-tp L L' -> stp I G L U -> stp I G L' U -> type.
%mode eq-stp-l +EQ +B -C.
- : eq-stp-l id-tp/refl B B.
%worlds () (eq-stp-l _ _ _).
%total (A) (eq-stp-l A _ _).
%reduces C <= B (eq-stp-l _ B C).
eq-stp-u : id-tp U U' -> stp I G L U -> stp I G L U' -> type.
%mode eq-stp-u +EQ +B -C.
- : eq-stp-u id-tp/refl B B.
%worlds () (eq-stp-u _ _ _).
%total (A) (eq-stp-u A _ _).
%reduces C <= B (eq-stp-u _ B C).
eq-stp-g : id-tenv G G' -> stp I G L U -> stp I G' L U -> type.
%mode eq-stp-g +EQ +B -C.
- : eq-stp-g id-tenv/refl B B.
%worlds () (eq-stp-g _ _ _).
%total (A) (eq-stp-g A _ _).
%reduces C <= B (eq-stp-g _ B C).
eq-stp2-l : id-tp L L' -> stp2 G1 L G2 U -> stp2 G1 L' G2 U -> type.
%mode eq-stp2-l +EQ +B -C.
- : eq-stp2-l id-tp/refl B B.
%worlds () (eq-stp2-l _ _ _).
%total (A) (eq-stp2-l A _ _).
%reduces C <= B (eq-stp2-l _ B C).
eq-stp2-u : id-tp U U' -> stp2 G1 L G2 U -> stp2 G1 L G2 U' -> type.
%mode eq-stp2-u +EQ +B -C.
- : eq-stp2-u id-tp/refl B B.
%worlds () (eq-stp2-u _ _ _).
%total (A) (eq-stp2-u A _ _).
%reduces C <= B (eq-stp2-u _ B C).
eq-stp2-gu : id-tenv G2 G2' -> stp2 G1 L G2 U -> stp2 G1 L G2' U -> type.
%mode eq-stp2-gu +EQ +B -C.
- : eq-stp2-gu id-tenv/refl B B.
%worlds () (eq-stp2-gu _ _ _).
%total (A) (eq-stp2-gu A _ _).
%reduces C <= B (eq-stp2-gu _ B C).
eq-stp2-gl : id-tenv G1 G1' -> stp2 G1 L G2 U -> stp2 G1' L G2 U -> type.
%mode eq-stp2-gl +EQ +B -C.
- : eq-stp2-gl id-tenv/refl B B.
%worlds () (eq-stp2-gl _ _ _).
%total (A) (eq-stp2-gl A _ _).
%reduces C <= B (eq-stp2-gl _ B C).
eq-sdcs-g : id-tenv G G' -> sdcs I G A B -> sdcs I G' A B -> type.
%mode eq-sdcs-g +EQ +A -B.
- : eq-sdcs-g id-tenv/refl B B.