-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.elpi
802 lines (727 loc) · 29.4 KB
/
test.elpi
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
%tests
accumulate debug.
accumulate main.
accumulate calc/and.
accumulate calc/propEq.
accumulate calc/forall.
accumulate calc/exist.
accumulate calc/propId.
accumulate calc/implies.
%accumulate calc/letIn.
accumulate calc/list.
accumulate calc/or.
accumulate calc/setSum.
accumulate calc/singleton.
accumulate calc/setPi.
accumulate calc/setSigma.
accumulate extractor.
accumulate to_language.
kind testFlag type.
type m,l,f,g,h,i,n,p,q testFlag.
type s1,s2,s3,s4,s5,s6,s7,s8 testFlag.
type pd1 testFlag.
type test A.
sigmaTest :- setSigma_test.
macro_test I O
:- spy(ofType I _Te ext)
, spy(interp I O)
, spy(ofType O _Ti int)
.
quicktest
:- makeline
, spy(setoid_tran (setPi (propEq singleton star star) x\singleton ) _), makeline
, spy(setoid_tran (setPi singleton x\singleton ) _), makeline
, spy(setoid_tran (setPi (setPi singleton x\singleton ) x\(setPi singleton x\singleton ) ) _), makeline
, spy(setoid_tran (setPi (propEq singleton star star) x\propEq singleton star star ) _), makeline
, spy(sigma P\ setoid_tran singleton P), makeline
, spy(setoid_refl (setPi (propEq singleton star star) x\singleton) _), makeline
, spy(setoid_refl (setPi (setPi singleton _\singleton) x\singleton) _), makeline
, spy(setoid_symm (setPi singleton x\singleton) _), makeline
, spy(setoid_symm (setPi (setPi singleton x\singleton) x\singleton) _), makeline
, spy(setoid_symm (setPi (setPi (setPi singleton x\singleton) x\(setPi singleton x\singleton)) x\(setPi singleton x\singleton)) _), makeline
, spy(setoid_tran
(setPi (setPi singleton x\(propEq singleton x star) )
x\(setPi (setPi singleton x\singleton ) x\(setPi singleton x\singleton ) ) ) _), makeline
, spy(setoid_tran (setPi singleton x\(setPi singleton y\(propEq singleton x y) ) ) _), makeline
, spy(setoid_tran (setPi (propEq singleton star star) x\(setPi (propEq singleton star star) x\singleton ) ) _), makeline
, spy(setoid_refl (setPi (setPi (propEq singleton star star) x\singleton) x\(setPi (propEq singleton star star) x\singleton)) _), makeline
.
notquicktest
:- makeline
, spy(sigma A\ sigma B\ sigma C\ test m A B C), makeline %This one takes a lot of time
, spy(sigma A\ sigma B\ sigma C\ test l A B C), makeline
, spy(sigma A\ sigma B\ sigma C\ test f A B C), makeline
, spy(sigma A\ sigma B\ sigma C\ test g A B C), makeline
, spy(sigma A\ sigma B\ sigma C\ test h A B C), makeline
, spy(sigma A\ sigma B\ sigma C\ test i A B C), makeline
, spy(sigma O\ test n O), makeline
, quicktest
.
test n O
:- (T =
setPi (setPi (setPi singleton _\singleton) _\singleton) f\
(propEq singleton (app f (lambda singleton x\ x)) star)
)
, macro_test T O
.
test pd1 A Q Qy
:- Long = ( forall singleton x\ forall singleton z \
setPi (propEq singleton x z) _ \
(setPi (setPi singleton y \ propEq singleton x y) f \
setPi (propEq (propEq singleton x x) (app f x) (eq singleton x)) p \
setPi (propEq (propEq singleton z z) (app f z) (eq singleton z)) q \
propEq (propEq (propEq singleton x x) (app f x) (eq singleton x)) p q)),
spy(ofType Long A ext),
%print "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n",
spy(interp Long Q),
%print "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n",
spy(ofType Q Qy int)
.
test m A Q Qy
:- Long = ( forall singleton x\
implies (propEq singleton x star)
(implies (propEq singleton star x)
(forall
(setPi
(setPi
(setPi singleton y\ propEq singleton star x) _\
singleton)
_\singleton
) f\
(propEq singleton
(app f (lambda (setPi singleton y\ propEq singleton star star)
x\ star))
star)
))
),
spy(ofType Long A ext),
%print "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n",
spy(interp Long Q),
%print "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n",
spy(ofType Q Qy int)
.
test l A Q Qy
:- Long = ( forall singleton x\
implies (propEq singleton x star)
(implies (propEq singleton star x)
( forall
(setPi
(setPi singleton y\ propEq singleton star x)
_\singleton
) f\
(propEq singleton
(app f (lambda singleton x\ (eq singleton star)))
star)
))
),
spy(ofType Long A ext),
%print "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n",
spy(interp Long Q),
%print "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n",
spy(ofType Q Qy int)
.
test i A B C
:- Long = ( forall singleton x\ forall singleton y\
(implies
(propEq singleton x y) (implies
(propEq singleton y x) (implies
(propEq singleton x star) (implies
(propEq singleton y star) (implies
(propEq singleton star x) (implies
(propEq singleton star y) (
forall
(setPi (propEq singleton x star) d\
setPi (propEq singleton x x) h\
(propEq
(propEq singleton x star)
d
h
)) f\
propEq
(propEq
(propEq singleton star star)
(eq singleton y)
(eq singleton x))
(app
(app f (eq singleton y))
(eq singleton x))
(app
(app f (eq singleton x))
(eq singleton x))
)
)))))))
,
spy(ofType Long A ext),
%print "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n",
spy(interp Long B),
%print "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n",
spy(ofType B C int)
.
test h A Q Qy
:- Long = (
forall (setPi (setPi singleton _\singleton) _\singleton) f\
(propEq singleton (app f (lambda singleton x\ x)) star)
),
spy(ofType Long A ext),
%print "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n",
spy(interp Long Q),
%print "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n",
spy(ofType Q Qy int)
.
test g A Q Qy
:- Long = (
forall singleton x\
forall (setPi singleton _\singleton) g\
forall (setPi (propEq singleton (app g x) (app g star)) _\singleton) f\
(implies (propEq singleton star x)
(propEq singleton
(app f (eq singleton (app g star)))
(app f (eq singleton (app g star)))
)
)
),
spy(ofType Long A ext),
%print "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n",
spy(interp Long Q),
%print "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n",
spy(ofType Q Qy int)
.
test f A Q Qy
:- Long = (
forall singleton x\
forall (setPi (propEq singleton x star) _\singleton) f\
( implies (propEq singleton star x)
(propEq singleton
(app f (eq singleton star))
(app f (eq singleton star))
)
)
),
spy(ofType Long A ext),
%print "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n",
spy(interp Long Q),
%print "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n",
spy(ofType Q Qy int)
.
test p A B C
:- Long =
(forall
singleton x\
(implies (propEq singleton x star) (implies (propEq singleton star x)
(forall
(setPi
(propEq
singleton star x) y\
(setPi
(propEq (propEq singleton star star) y (eq singleton star)) _\
singleton)) f\
(propEq singleton
(app
(app f (eq singleton star))
(eq (propEq singleton star star)
(eq singleton star)
))
star)
) ))
)
, spy(ofType Long A ext)
, spy(interp Long B)
, spy(ofType B C int)
.
test q A B C
:- Long =
(forall
(propEq singleton star star) x\
(implies (propEq (propEq singleton star star) x (eq singleton star)) (implies (propEq (propEq singleton star star) (eq singleton star) x)
(forall
(setPi
(propEq
(propEq singleton star star) (eq singleton star) x) y\
(setPi
(propEq (propEq (propEq singleton star star) (eq singleton star) (eq singleton star)) y (eq (propEq singleton star star) (eq singleton star))) _\
(propEq singleton star star))) f\
(propEq (propEq singleton star star)
(app
(app f (eq (propEq singleton star star) (eq singleton star)))
(eq (propEq (propEq singleton star star) (eq singleton star) (eq singleton star))
(eq (propEq singleton star star) (eq singleton star))
))
(eq singleton star))
) ))
)
, spy(ofType Long A ext)
, spy(interp Long B)
, spy(ofType B C int)
.
%%% SETSIGMA TESTS %%%
%% Using interp pair, setoid_eq. No type mismatches, simple interpretation and typing of sigma-terms.
test s1 A Q Ai
:- Long = (forall singleton x\
(propEq (setSigma singleton x\singleton)
(pair singleton (x\singleton) star star)
(pair singleton (x\singleton) star star))),
spy (ofType Long A ext),
spy (interp Long Q),
spy (ofType Q Ai int)
.
%% same as s1, slightly more elaborate.
test s2 A Q Ai
:- Long = (forall singleton x\
(implies (propEq singleton x star) (implies (propEq singleton star x)
(propEq singleton
star
(app (lambda (setSigma singleton x\singleton) _\star)
(pair singleton (x\singleton) star star)))))),
ofType Long A ext,
print "END OF TYPING",
interp Long Q,
print "END OF TRANSLATION",
ofType Q Ai int
.
%% Using tau and setoid_eq. The version with setoid_refl terminates successfully. Type mismatch in the type B of (setSigma B C).
test s3 A Q Ai
:- Long = (forall singleton x\
(implies (propEq singleton x star) (implies (propEq singleton star x)
(propEq singleton
star
(app (lambda (setSigma (propEq singleton x star) x\singleton)
x\star)
(pair (propEq singleton star star) (x\singleton)
(eq singleton star) star)))))),
ofType Long A ext,
interp Long Q,
ofType Q Ai int
.
%% Using tau. Here the type mismatch is in the type C of (setSigma B C), which is not really dependent in this case.
test s4 A Q Ai
:- Long = (forall singleton x\
(implies (propEq singleton x star) (implies (propEq singleton star x)
(propEq singleton
star
(app (lambda (setSigma singleton z\(propEq singleton x star))
z\star)
(pair singleton (x\propEq singleton star star)
star (eq singleton star))))))),
ofType Long A ext,
interp Long Q,
ofType Q Ai int
.
%% Using tau and setoid_eq. NOTE: this is almost useless, because of the way equalities of equalities are interpreted
test s5 A Q Ai
:- Long = (forall singleton x\
(implies (propEq singleton x star) (implies (propEq singleton star x)
(propEq singleton
star
(app (lambda (setSigma (propEq singleton x star) p\
propEq (propEq singleton star star)
p
(eq singleton star))
z\ star)
(pair (propEq singleton star star)
(p\ propEq (propEq singleton star star)
p
(eq singleton x))
(eq singleton star)
(eq (propEq singleton star star) (eq singleton star)))))))),
ofType Long A ext,
interp Long Q,
ofType Q Ai int
.
test s6 A Q Ai
:- Long = (forall singleton x\
(implies (propEq singleton x star) (implies (propEq singleton star x)
(propEq singleton
star
(app (lambda (setSigma (setPi (propEq singleton x star) _ \ singleton) p\
propEq (setPi (propEq singleton star star) _ \ singleton)
p
p)
z\ star)
(pair (setPi (propEq singleton star star) _ \ singleton)
(p\ propEq (setPi (propEq singleton star star) _ \singleton) p p)
(lambda (propEq singleton star star) _ \ star)
(eq (setPi (propEq singleton star star) _ \singleton) (lambda (propEq singleton star star) _ \ star)))))))),
(ofType Long A ext),
print "CSC2",
(interp Long Q),
print "CSC3",
print "test s6:" A Q,
(ofType Q Ai int)
.
%% uses setoid_refl, prop_eq functions (prop_eq not yet implemented)
test s7 A Q :-
Long = (forall singleton x\
(implies (propEq singleton x star) (implies (propEq singleton star x)
(propEq singleton
star
(app (lambda (propEq (setSigma singleton x\singleton)
(pair singleton (_\singleton) x star)
(pair singleton (_\singleton) star x))
z\ star)
(eq (setSigma singleton x\singleton) (pair singleton (_\singleton) star star))))))),
ofType Long A ext,
interp Long Q
.
test s8 A Q:-
Long = (forall singleton x\
(implies (propEq singleton x star) (implies (propEq singleton star x)
(propEq singleton
star
(app (lambda (setSigma singleton _\singleton) z\star)
(elim_setSigma (pair singleton (_\ (setSigma singleton _\singleton))
star (pair singleton (_\singleton) star star))
(p\ (setSigma singleton _\singleton))
(x\ y\ y))))))),
ofType Long A ext,
print "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||",
interp Long Q
.
setSigma_test :-
print "||||||||||START S1|||||||||||\n",
test s1 _A1 _Q1 _Ai1,
print "||||||||||START S2||||||||||\n",
test s2 _A2 _Q2 _Ai2,
print "||||||||||START S3||||||||||\n",
test s3 _A3 _Q3 _Ai3,
print "||||||||||START S4||||||||||\n",
test s4 _A4 _Q4 _Ai4,
print "||||||||||START S5||||||||||\n",
test s5 _A5 _Q5 _Ai5,
print "||||||||||START S6||||||||||\n",
test s6 A6 Q6 Ai6,
print ["test s6:", A6, Q6, Ai6 ]
.
testLib P :-
in_library (setoid_eq (setSigma singleton x \ singleton) P).
testLib2 P :-
in_library (setoid_eq (setSigma singleton y \ setSigma singleton x \ propEq singleton x y) P).
testLib3 P TY :-
in_library ( % debug =>
(spy (new_interp_type (setSigma singleton x \ singleton) P),
spy (of P TY int))).
testLib4 P TY :-
in_library ( % debug =>
(spy (new_interp_type (setSigma (setSigma singleton x \ singleton) f \ singleton) P),
spy (of P TY int))).
testLib5 P TY :-
in_library ( % debug =>
(spy (new_interp_type (setSigma singleton x \ setSigma singleton y \ singleton) P),
spy (of P TY int)
)).
testLib6 P _TY :-
in_library ( debug =>
(spy (new_interp_type (setSigma singleton x \ setSigma singleton y \ propEq singleton x y) P),
true %spy (of P TY int)
)).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% ESTRAZIONE %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
type bool_t mttType.
type bool_e mttTerm.
type true_bool mttTerm.
type false_bool mttTerm.
ofType bool_t props IE_.
of bool_e bool_t IE_.
of true_bool bool_t IE_.
of false_bool bool_t IE_.
type col_t mttType.
type col_e mttTerm.
ofType col_t col IE_.
of col_e col_t IE_.
type propc_t mttType.
type propc_e mttTerm.
ofType propc_t propc IE_.
of propc_e propc_t IE_.
type num_t mttType.
type num_1 mttTerm.
type num_2 mttTerm.
type num_3 mttTerm.
ofType num_t set int.
of num_1 num_t int.
of num_2 num_t int.
of num_3 num_t int.
type pse_t mttType.
type pse_a mttTerm.
ofType pse_t props ext.
of pse_a pse_t ext.
testExtr 1 A :- debug => starify_term (id (propId bool_t true_bool true_bool) (id bool_t true_bool)) [] A.
testExtr 2 A :- debug => starify_term (id (propId singleton star star) (id singleton star)) [] A.
testExtr 3 A :- debug => starify_term (app (lambda bool_t x\x) true_bool) [] A.
testExtr 4 A :- debug => starify_term (pair bool_t (_\bool_t) false_bool true_bool) [] A.
testExtr 5 A :- debug => starify_term (pair singleton (_\singleton) star star) [] A.
testExtr 6 A :- debug => starify_term (pair bool_t (x\propId bool_t x x) true_bool (id bool_t true_bool)) [] A.
testExtr 7 A :- debug => starify_term (pair singleton (x\propId singleton x x) star (id singleton star)) [] A.
testExtr 8 A :- debug => starify_term (app (lambda singleton x\x) star) [] A.
testExtr 9 A :- debug => starify_term (app (lambda singleton (x\ id singleton x)) star) [] A.
testExtr 10 A :- debug => starify_term (app (lambda bool_t (x\ id bool_t x)) true_bool) [] A.
testExtr 11 A :- debug => starify_term (elim_id (id singleton star) (x\ y\ propId singleton x y) (x\ id singleton x)) [] A.
testExtr 12 A :- debug => starify_term (elim_id (id bool_t true_bool) (x\ y\ propId bool_t x y) (x\ id bool_t x)) [] A.
testExtr 13 A :- debug => starify_term (elim_id (id bool_t true_bool) (x\ y\ implies bool_t bool_t) (x\ impl_lam bool_t (_\x))) [] A.
testExtr 14 A :- debug => starify_term (elim_singleton star (x\ singleton) star) [] A.
testExtr 15 A :- debug => starify_term (p1 (pair singleton (x\ bool_t) star bool_e)) [] A.
testExtr 16 A :- debug => starify_term (p2 (pair bool_t (x\ singleton) bool_e star)) [] A.
testExtr 17 A :- debug => starify_term (elim_setSum (x\setSum singleton bool_t) (inl singleton bool_t star) (l\ inl singleton bool_t l) (r\ inr singleton bool_t r)) [] A.
testExtr 18 A :- debug => starify_term (elim_setSum (x\setSum bool_t bool_t) (inl bool_t bool_t true_bool) (l\ inl bool_t bool_t l) (r\ inr bool_t bool_t r)) [] A.
testExtr 19 A :- debug => starify_term (elim_setSum (x\setSum singleton singleton) (inl singleton singleton star) (l\ inl singleton singleton l) (r\ inr singleton singleton r)) [] A.
testExtr 20 A :- debug => starify_term (elim_setSum (x\setSum singleton (implies bool_t bool_t)) (inl singleton (implies bool_t bool_t) star) (l\ inl singleton (implies bool_t bool_t) l) (r\ inr singleton (implies bool_t bool_t) r)) [] A.
testExtr 21 A :- debug => starify_term
(
elim_setSum (x\ propId (setSum singleton bool_t) x x) (inl singleton bool_t star)
(l\ id (setSum singleton bool_t) (inl singleton bool_t l))
(r\ id (setSum singleton bool_t) (inr singleton bool_t r))
) [] A.
testExtr 22 A :- debug => starify_term (elim_setSigma (pair singleton (_\bool_t) star bool_e) (x\singleton) (l\r\ l)) [] A.
testExtr 23 A :- debug => starify_term (elim_setSigma (pair singleton (_\bool_t) star true_bool) (x\bool_t) (l\r\ r)) [] A.
testExtr 24 A :- debug => starify_term (elim_setSigma (pair singleton (_\bool_t) star true_bool) (x\singleton) (l\r\ l)) [] A.
testExtr 25 A :- debug => starify_term (elim_setSigma (pair bool_t (_\bool_t) true_bool bool_e) (x\bool_t) (l\r\ l)) [] A.
testExtr 26 A :- debug => starify_term (pair singleton (x\propId bool_t true_bool true_bool) star (id bool_t true_bool)) [] A.
testExtr 27 A :- debug => starify_term (app
(lambda
(setSigma (propId bool_t true_bool true_bool) (_\singleton))
(x\ id (setSigma (propId bool_t true_bool true_bool) (_\singleton)) x))
(pair (propId bool_t true_bool true_bool) (_\singleton) (id bool_t true_bool) star)
) [] A.
testExtr 28 A :- debug => starify_term (app
(lambda
(setSigma (setSigma bool_t (_\bool_t)) (_\singleton))
(x\ id (setSigma (setSigma bool_t (_\bool_t)) (_\singleton)) x))
(pair (setSigma bool_t (_\bool_t)) (_\singleton)
(pair bool_t (_\bool_t) true_bool false_bool)
star)
) [] A.
testExtr 29 A :- debug => starify_term (app
(lambda (setSigma singleton (_\setSigma bool_t (_\bool_t)))
(x\ id (setSigma singleton (_\setSigma bool_t (_\bool_t))) x)
)
(pair singleton (_\setSigma bool_t (_\bool_t))
star (pair bool_t (_\bool_t) true_bool false_bool))
) [] A.
testExtr 30 A :- debug => starify_term (app
(lambda (setSigma singleton (_\bool_t))
(x\ id (setSigma singleton (_\bool_t)) x)
)
(pair singleton (_\bool_t) star bool_e)
) [] A.
testExtr 31 A :- debug => starify_term
(app
(lambda (setSigma bool_t (_\setSigma singleton (_\bool_t)))
(x\ id (setSigma bool_t (_\setSigma singleton (_\bool_t))) x)
)
(pair bool_t (_\setSigma singleton (_\bool_t))
true_bool (pair singleton (_\bool_t) star bool_e))
) [] A.
testExtr 32 A :- debug => starify_term
(app
(lambda (setSigma singleton (_\setSigma bool_t (_\col_t)))
(x\ id (setSigma singleton (_\setSigma bool_t (_\col_t))) x)
)
(pair singleton (_\setSigma bool_t (_\col_t))
star (pair bool_t (_\col_t) true_bool col_e))
) [] A.
testExtr 33 A :- debug => starify_term
(app
(lambda (setSigma singleton (_\setSigma singleton (_\bool_t)))
(x\ id (setSigma singleton (_\setSigma singleton (_\bool_t))) x)
)
(pair singleton (_\setSigma singleton (_\bool_t))
star (pair singleton (_\bool_t) star bool_e))
) [] A.
testExtr 34 A :- debug => starify_term
(app
(p1 (pair
(setPi (setSigma singleton (_\bool_t)) (x\setSigma singleton (_\bool_t)))
(_\bool_t)
(lambda (setSigma singleton (_\bool_t)) (x\ x))
true_bool
))
(pair singleton (_\bool_t) star bool_e)
) [] A.
testExtr 35 A :- debug => starify_term
(app
(p1 (pair
(setPi (setSigma singleton (_\bool_t)) (x\setSigma singleton (_\bool_t)))
(_\singleton)
(lambda (setSigma singleton (_\bool_t)) (x\ x))
star
))
(pair singleton (_\bool_t) star bool_e)
) [] A.
testExtr 36 A :- debug => starify_term (pair_exist singleton (_\propc_t) star propc_e) [] A.
testExtr 37 A :- debug => starify_term (pair_exist singleton (_\bool_t) star true_bool) [] A.
testExtr 38 A :- debug => starify_term (forall_app (forall_lam singleton (x\propc_e)) star) [] A.
testExtr 39 A :- debug => starify_term (forall_app (forall_lam singleton (x\true_bool)) star) [] A.
testExtr 40 A :- debug => starify_term (app (lambda singleton (x\propc_e)) star) [] A.
testExtr 41 A :- debug => starify_term (app (lambda singleton (x\true_bool)) star) [] A.
testExtr 42 A :- debug => starify_term (pair (exist singleton (_\propc_t)) (_\singleton)(pair_exist singleton (_\propc_t) star propc_e) star) [] A.
testExtr 43 A :- debug => starify_term (pair (forall singleton (x\propc_t)) (_\singleton)(forall_lam singleton (x\propc_e)) star) [] A.
testExtr 44 A :- debug => starify_term (elim_id (id singleton star) (x\ y\ exist singleton (x\propc_t)) (x\ pair_exist singleton (x\propc_t) x propc_e)) [] A.
testExtr 45 A :- debug => starify_term (elim_setSigma (pair bool_t (_\bool_t) bool_e bool_e) (x\singleton) (l\r\ star)) [] A.
testExtr 46 A :- debug => starify_term (elim_setSigma (pair singleton (_\singleton) star star) (x\bool_t) (l\r\ bool_e)) [] A.
testExtr 47 A :- debug => starify_term (app
(lambda (setPi singleton (x\ setSigma singleton (_\singleton))) (y\ app y star))
(lambda singleton (x\ pair singleton (_\singleton) x x))
) [] A.
testExtr 48 A :- debug => starify_term (app
(lambda (setPi singleton (x\singleton)) (y\ app y star))
(lambda singleton (x\x))
) [] A.
testExtr 49 A :- debug => starify_term (app
(lambda (setPi bool_t (x\ setSigma (propId bool_t x x) (_\singleton)))
(y\ id (setSigma (propId bool_t true_bool true_bool) (_\singleton)) (app y true_bool))
)
(lambda bool_t
(x\ pair (propId bool_t x x) (_\singleton) (id bool_t x) star)
)
) [] A.
testExtr 50 A :- debug => starify_term (elim_setSum
(x\ decode (elim_setSum
(y\propS)
x
(l\ encode extractor_singleton)
(r\ encode (and extractor_singleton extractor_singleton))))
(inr extractor_singleton (and extractor_singleton extractor_singleton)
(pair_and extractor_singleton extractor_singleton extractor_star extractor_star))
(l\ l)
(r\ r)
) [] A.
testExtr 51 A :- debug => starify_term
(elim_setSum
(x\num_t)
(inr singleton (and extractor_singleton extractor_singleton) (pair_and extractor_singleton extractor_singleton extractor_star extractor_star))
(l\ num_1)
(r\ num_2)
) [] A.
testExtr 52 A :- debug => starify_term
(elim_setSum
(x\extractor_singleton)
(inr singleton singleton star)
(l\ extractor_star)
(r\ extractor_star)
) [] A.
testExtr 53 A :- debug => starify_term (elim_setSigma
(pair singleton (_\singleton) star star)
(x\ exist (setSigma singleton (_\singleton)) (_\extractor_singleton))
(l\r\ pair_exist
(setSigma singleton (_\singleton)) (_\extractor_singleton)
(pair singleton (_\singleton) r l) extractor_star)
) [] A.
testExtr 54 A :- debug => starify_term (lambda
(setSigma singleton (_\singleton))
(y\ elim_setSigma
y
(x\ exist (setSigma singleton (_\singleton)) (_\extractor_singleton))
(l\r\ pair_exist
(setSigma singleton (_\singleton))
(_\extractor_singleton)
(elim_setSigma
(pair singleton (_\singleton) star star)
(x\ setSigma singleton (_\singleton))
(p\q\ pair singleton (_\singleton) p r))
extractor_star))
) [] A.
testExtr 55 A :- debug => starify_term (app
(lambda
(propId bool_t true_bool true_bool)
(x\ id
(setSigma (propId bool_t true_bool true_bool) (_\singleton))
(pair (propId bool_t true_bool true_bool) (_\singleton) x star)))
(id bool_t true_bool)
) [] A.
% begin ext tests: richiedono di impostare il livello a ext
testExtr 56 A :- debug => starify_term (impl_lam (propEq propS (encode pse_t) (encode (implies pse_t pse_t))) (_\pse_a)) [] A.
testExtr 57 A :- debug => starify_term (lambda (propEq propS (encode pse_t) (encode (implies pse_t pse_t))) (_\pse_a)) [] A.
% end ext tests
testExtr 58 A :- debug => starify_term (elim_list
(_\list (exist singleton (_\extractor_singleton)))
(list_cons singleton star (list_cons singleton star (list_empty singleton)))
(list_empty (exist singleton (_\extractor_singleton)))
(y\x\z\ list_cons
(exist singleton (_\extractor_singleton))
(pair_exist singleton (_\extractor_singleton) y extractor_star)
z)
) [] A.
testExtr 59 A :- debug => starify_term (lambda singleton (x\
lambda singleton (y\
lambda singleton (z\
id (list singleton)
(list_cons singleton z
(list_cons singleton y
(list_cons singleton x
(list_empty singleton)))))))) [] A.
testExtr 60 A :- debug => starify_term (elim_list
(_\exist singleton (_\extractor_singleton))
(list_cons singleton star (list_cons singleton star (list_empty singleton)))
(pair_exist singleton (_\extractor_singleton) star extractor_star)
(y\x\z\ pair_exist singleton (_\extractor_singleton) y extractor_star)
) [] A.
%% Test infrastructure code
build_library Lib
:- translateLib L1
, trueLib L2
, propLib L3
, singletonLib L4
, setSigmaLib L5
, setPiLib L6
, impliesLib Limpl
, forallLib Lforall
, propEqLib LpropEq
, concat [L1, L2, L3, L4, L5, L6, Lforall, Limpl, LpropEq] Lib
.
/*
translib -Index +Result
Index is the index of the n-th library entry whose extraction is being requested
Result is the translation of the n-th entry in the target language and its type signature, if present
Side effects: just before completing execution it prints out the output of the extraction phase
*/
translib Index Result
:- build_library Lib
, translate_entry_from_library Lib [] Index Result
.
/*
pack_and_translate_library +Result
Result is a list of all the translated entries from the library
*/
pack_and_translate_library Result
:- build_library Lib
, debug => translate_library Lib [] Result
.
pack_and_process_library Result
:- build_library Lib
, debug => process_library Lib Result
.
/*
testExtr -X +Term
X is the index of the n-th extractor test whose starification is being required
Term is the starification of the n-th test
*/
%% tests are defined above, I keep the documentation here to cluster it with the other entry-points
/*
typecheckExtr -X +Type
X is the index of the n-th extractor test whose starification is being required
Type is the type of the starification of the n-th test
*/
typecheckExtr X Type
:- testExtr X Result
, debug => spy(of Result Type int)
.
/*
testStEx -X +TermList
X is the index of the n-th extractor test whose extraction is being required
TermList is the list of extracted terms produced from the n-th test
*/
testStEx X TermList
:- testExtr X Term
, debug => spy(extract_term Term Result (context [] [] []) SetList)
, concat [[Result], SetList] TermList
.
typecheckStExList [SH|STL] [RH|RTL] :- of SH RH int, typecheckStExList STL RTL, !.
typecheckStExList [] [].
/*
typecheckStEx -X +TypeList
X is the index of the n-th extractor test whose extraction is being required
TypeList is the list of the types of extracted terms produced from the n-th test
*/
typecheckStEx X TypeList
:- testStEx X Result
, debug => typecheckStExList Result TypeList
.