eyeling 1.15.0 → 1.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,198 @@
1
+ #include <stdio.h>
2
+ #include <stdlib.h>
3
+ #include <stdint.h>
4
+ #include <string.h>
5
+
6
+ #define BIG_BASE 1000000000u
7
+
8
+ typedef struct {
9
+ uint32_t *d;
10
+ size_t len;
11
+ size_t cap;
12
+ } BigInt;
13
+
14
+ static void die(const char *msg) {
15
+ fputs(msg, stderr);
16
+ fputc('\n', stderr);
17
+ exit(EXIT_FAILURE);
18
+ }
19
+
20
+ static void bi_init(BigInt *a, unsigned int value) {
21
+ a->cap = 4;
22
+ a->len = 1;
23
+ a->d = (uint32_t *)calloc(a->cap, sizeof(uint32_t));
24
+ if (!a->d) die("out of memory");
25
+ a->d[0] = value;
26
+ }
27
+
28
+ static void bi_reserve(BigInt *a, size_t need) {
29
+ if (need <= a->cap) return;
30
+ size_t cap = a->cap;
31
+ while (cap < need) cap *= 2;
32
+ uint32_t *p = (uint32_t *)realloc(a->d, cap * sizeof(uint32_t));
33
+ if (!p) die("out of memory");
34
+ memset(p + a->cap, 0, (cap - a->cap) * sizeof(uint32_t));
35
+ a->d = p;
36
+ a->cap = cap;
37
+ }
38
+
39
+ static void bi_trim(BigInt *a) {
40
+ while (a->len > 1 && a->d[a->len - 1] == 0) a->len--;
41
+ }
42
+
43
+ static void bi_mul_small(BigInt *a, unsigned int m) {
44
+ uint64_t carry = 0;
45
+ for (size_t i = 0; i < a->len; i++) {
46
+ uint64_t cur = (uint64_t)a->d[i] * m + carry;
47
+ a->d[i] = (uint32_t)(cur % BIG_BASE);
48
+ carry = cur / BIG_BASE;
49
+ }
50
+ while (carry) {
51
+ bi_reserve(a, a->len + 1);
52
+ a->d[a->len++] = (uint32_t)(carry % BIG_BASE);
53
+ carry /= BIG_BASE;
54
+ }
55
+ }
56
+
57
+ static void bi_add_small(BigInt *a, unsigned int add) {
58
+ uint64_t carry = add;
59
+ size_t i = 0;
60
+ while (carry) {
61
+ if (i == a->len) {
62
+ bi_reserve(a, a->len + 1);
63
+ a->d[a->len++] = 0;
64
+ }
65
+ uint64_t cur = (uint64_t)a->d[i] + carry;
66
+ a->d[i] = (uint32_t)(cur % BIG_BASE);
67
+ carry = cur / BIG_BASE;
68
+ i++;
69
+ }
70
+ }
71
+
72
+ static void bi_sub_small(BigInt *a, unsigned int sub) {
73
+ uint64_t borrow = sub;
74
+ size_t i = 0;
75
+ while (borrow) {
76
+ if (i >= a->len) die("underflow");
77
+ uint64_t cur = a->d[i];
78
+ uint64_t part = borrow % BIG_BASE;
79
+ borrow /= BIG_BASE;
80
+ if (cur < part) {
81
+ a->d[i] = (uint32_t)(cur + BIG_BASE - part);
82
+ borrow += 1;
83
+ } else {
84
+ a->d[i] = (uint32_t)(cur - part);
85
+ }
86
+ i++;
87
+ }
88
+ bi_trim(a);
89
+ }
90
+
91
+ static unsigned int bi_to_uint(const BigInt *a) {
92
+ if (a->len == 0) return 0;
93
+ if (a->len > 2) die("value too large for unsigned int");
94
+ uint64_t v = a->d[0];
95
+ if (a->len == 2) v += (uint64_t)a->d[1] * BIG_BASE;
96
+ if (v > 0xffffffffu) die("value too large for unsigned int");
97
+ return (unsigned int)v;
98
+ }
99
+
100
+ static char *bi_to_string(const BigInt *a) {
101
+ size_t bytes = a->len * 10 + 1;
102
+ char *s = (char *)malloc(bytes);
103
+ if (!s) die("out of memory");
104
+ int n = snprintf(s, bytes, "%u", a->d[a->len - 1]);
105
+ if (n < 0) die("snprintf failed");
106
+ size_t pos = (size_t)n;
107
+ for (size_t i = a->len - 1; i-- > 0;) {
108
+ n = snprintf(s + pos, bytes - pos, "%09u", a->d[i]);
109
+ if (n < 0) die("snprintf failed");
110
+ pos += (size_t)n;
111
+ }
112
+ return s;
113
+ }
114
+
115
+ static void bi_free(BigInt *a) {
116
+ free(a->d);
117
+ a->d = NULL;
118
+ a->len = 0;
119
+ a->cap = 0;
120
+ }
121
+
122
+ static BigInt bi_pow2(unsigned int exp) {
123
+ BigInt r;
124
+ bi_init(&r, 1);
125
+ for (unsigned int i = 0; i < exp; i++) bi_mul_small(&r, 2);
126
+ return r;
127
+ }
128
+
129
+ /* Independent evaluator for the fixed-z hyperoperation chain used by
130
+ examples/ackermann.n3:
131
+ A(x,y) = H(x, y+3, 2) - 3
132
+ where H(0,y,2)=y+1, H(1,y,2)=y+2, H(2,y,2)=2y, H(3,y,2)=2^y,
133
+ and H(x,0,2)=1 for x>3, H(x,y,2)=H(x-1, H(x,y-1,2), 2).
134
+ */
135
+ static BigInt hyper2(unsigned int x, unsigned int y) {
136
+ if (x == 0) {
137
+ BigInt r;
138
+ bi_init(&r, y + 1);
139
+ return r;
140
+ }
141
+ if (x == 1) {
142
+ BigInt r;
143
+ bi_init(&r, y + 2);
144
+ return r;
145
+ }
146
+ if (x == 2) {
147
+ BigInt r;
148
+ bi_init(&r, 2u * y);
149
+ return r;
150
+ }
151
+ if (x == 3) {
152
+ return bi_pow2(y);
153
+ }
154
+ if (y == 0) {
155
+ BigInt r;
156
+ bi_init(&r, 1);
157
+ return r;
158
+ }
159
+
160
+ BigInt inner = hyper2(x, y - 1);
161
+ unsigned int inner_u = bi_to_uint(&inner);
162
+ bi_free(&inner);
163
+ return hyper2(x - 1, inner_u);
164
+ }
165
+
166
+ static BigInt ackermann2(unsigned int x, unsigned int y) {
167
+ BigInt r = hyper2(x, y + 3);
168
+ bi_sub_small(&r, 3);
169
+ return r;
170
+ }
171
+
172
+ static void print_line(unsigned int x, unsigned int y) {
173
+ BigInt v = ackermann2(x, y);
174
+ char *s = bi_to_string(&v);
175
+ printf(" (%u %u) :ackermann %s .\n", x, y, s);
176
+ free(s);
177
+ bi_free(&v);
178
+ }
179
+
180
+ int main(void) {
181
+ puts("@prefix : <https://eyereasoner.github.io/ns#> .");
182
+ puts("");
183
+ puts(":test :is {");
184
+ print_line(0, 0);
185
+ print_line(0, 6);
186
+ print_line(1, 2);
187
+ print_line(1, 7);
188
+ print_line(2, 2);
189
+ print_line(2, 9);
190
+ print_line(3, 4);
191
+ print_line(3, 1000);
192
+ print_line(4, 0);
193
+ print_line(4, 1);
194
+ print_line(4, 2);
195
+ print_line(5, 0);
196
+ puts("} .");
197
+ return 0;
198
+ }
@@ -0,0 +1,97 @@
1
+ #include <stdio.h>
2
+ #include <stdlib.h>
3
+ #include <string.h>
4
+
5
+ enum { DEPTH = 10 };
6
+
7
+ static int emit(const char *s) {
8
+ return fputs(s, stdout) != EOF;
9
+ }
10
+
11
+ static int emit_type(const char *kind, int index) {
12
+ return printf(":ind a :%s%d .\n", kind, index) >= 0;
13
+ }
14
+
15
+ int main(void) {
16
+ unsigned char hasN[DEPTH + 1];
17
+ unsigned char hasI[DEPTH + 1];
18
+ unsigned char hasJ[DEPTH + 1];
19
+ unsigned char hasA2 = 0;
20
+ unsigned char hasTest = 0;
21
+ int changed = 1;
22
+
23
+ memset(hasN, 0, sizeof(hasN));
24
+ memset(hasI, 0, sizeof(hasI));
25
+ memset(hasJ, 0, sizeof(hasJ));
26
+
27
+ /* fact: :ind a :N0. */
28
+ hasN[0] = 1;
29
+
30
+ /*
31
+ * Forward-chain the rules to a fixpoint.
32
+ *
33
+ * {?X a :N0} => {?X a :N1, :I1, :J1}.
34
+ * {?X a :N1} => {?X a :N2, :I2, :J2}.
35
+ * ...
36
+ * {?X a :N9} => {?X a :N10, :I10, :J10}.
37
+ * {?X a :N10} => {?X a :A2}.
38
+ * {:ind a :A2} => {:test :is true}.
39
+ */
40
+ while (changed) {
41
+ changed = 0;
42
+
43
+ for (int i = 0; i < DEPTH; i++) {
44
+ if (!hasN[i]) {
45
+ continue;
46
+ }
47
+
48
+ if (!hasN[i + 1]) {
49
+ hasN[i + 1] = 1;
50
+ changed = 1;
51
+ }
52
+ if (!hasI[i + 1]) {
53
+ hasI[i + 1] = 1;
54
+ changed = 1;
55
+ }
56
+ if (!hasJ[i + 1]) {
57
+ hasJ[i + 1] = 1;
58
+ changed = 1;
59
+ }
60
+ }
61
+
62
+ if (hasN[DEPTH] && !hasA2) {
63
+ hasA2 = 1;
64
+ changed = 1;
65
+ }
66
+
67
+ if (hasA2 && !hasTest) {
68
+ hasTest = 1;
69
+ changed = 1;
70
+ }
71
+ }
72
+
73
+ if (!emit("@prefix : <http://eulersharp.sourceforge.net/2009/12dtb/test#> .\n\n")) {
74
+ return EXIT_FAILURE;
75
+ }
76
+
77
+ for (int i = 1; i <= DEPTH; i++) {
78
+ if (!hasN[i] || !hasI[i] || !hasJ[i]) {
79
+ fprintf(stderr, "incomplete closure at depth %d\n", i);
80
+ return EXIT_FAILURE;
81
+ }
82
+ if (!emit_type("N", i) || !emit_type("I", i) || !emit_type("J", i)) {
83
+ return EXIT_FAILURE;
84
+ }
85
+ }
86
+
87
+ if (!hasA2 || !hasTest) {
88
+ fputs("expected conclusions were not derived\n", stderr);
89
+ return EXIT_FAILURE;
90
+ }
91
+
92
+ if (!emit(":ind a :A2 .\n:test :is true .\n")) {
93
+ return EXIT_FAILURE;
94
+ }
95
+
96
+ return EXIT_SUCCESS;
97
+ }
@@ -0,0 +1,97 @@
1
+ #include <stdio.h>
2
+ #include <stdlib.h>
3
+ #include <string.h>
4
+
5
+ enum { DEPTH = 100 };
6
+
7
+ static int emit(const char *s) {
8
+ return fputs(s, stdout) != EOF;
9
+ }
10
+
11
+ static int emit_type(const char *kind, int index) {
12
+ return printf(":ind a :%s%d .\n", kind, index) >= 0;
13
+ }
14
+
15
+ int main(void) {
16
+ unsigned char hasN[DEPTH + 1];
17
+ unsigned char hasI[DEPTH + 1];
18
+ unsigned char hasJ[DEPTH + 1];
19
+ unsigned char hasA2 = 0;
20
+ unsigned char hasTest = 0;
21
+ int changed = 1;
22
+
23
+ memset(hasN, 0, sizeof(hasN));
24
+ memset(hasI, 0, sizeof(hasI));
25
+ memset(hasJ, 0, sizeof(hasJ));
26
+
27
+ /* fact: :ind a :N0. */
28
+ hasN[0] = 1;
29
+
30
+ /*
31
+ * Forward-chain the rules to a fixpoint.
32
+ *
33
+ * {?X a :N0} => {?X a :N1, :I1, :J1}.
34
+ * {?X a :N1} => {?X a :N2, :I2, :J2}.
35
+ * ...
36
+ * {?X a :N99} => {?X a :N100, :I100, :J100}.
37
+ * {?X a :N100} => {?X a :A2}.
38
+ * {:ind a :A2} => {:test :is true}.
39
+ */
40
+ while (changed) {
41
+ changed = 0;
42
+
43
+ for (int i = 0; i < DEPTH; i++) {
44
+ if (!hasN[i]) {
45
+ continue;
46
+ }
47
+
48
+ if (!hasN[i + 1]) {
49
+ hasN[i + 1] = 1;
50
+ changed = 1;
51
+ }
52
+ if (!hasI[i + 1]) {
53
+ hasI[i + 1] = 1;
54
+ changed = 1;
55
+ }
56
+ if (!hasJ[i + 1]) {
57
+ hasJ[i + 1] = 1;
58
+ changed = 1;
59
+ }
60
+ }
61
+
62
+ if (hasN[DEPTH] && !hasA2) {
63
+ hasA2 = 1;
64
+ changed = 1;
65
+ }
66
+
67
+ if (hasA2 && !hasTest) {
68
+ hasTest = 1;
69
+ changed = 1;
70
+ }
71
+ }
72
+
73
+ if (!emit("@prefix : <http://eulersharp.sourceforge.net/2009/12dtb/test#> .\n\n")) {
74
+ return EXIT_FAILURE;
75
+ }
76
+
77
+ for (int i = 1; i <= DEPTH; i++) {
78
+ if (!hasN[i] || !hasI[i] || !hasJ[i]) {
79
+ fprintf(stderr, "incomplete closure at depth %d\n", i);
80
+ return EXIT_FAILURE;
81
+ }
82
+ if (!emit_type("N", i) || !emit_type("I", i) || !emit_type("J", i)) {
83
+ return EXIT_FAILURE;
84
+ }
85
+ }
86
+
87
+ if (!hasA2 || !hasTest) {
88
+ fputs("expected conclusions were not derived\n", stderr);
89
+ return EXIT_FAILURE;
90
+ }
91
+
92
+ if (!emit(":ind a :A2 .\n:test :is true .\n")) {
93
+ return EXIT_FAILURE;
94
+ }
95
+
96
+ return EXIT_SUCCESS;
97
+ }
@@ -0,0 +1,97 @@
1
+ #include <stdio.h>
2
+ #include <stdlib.h>
3
+ #include <string.h>
4
+
5
+ enum { DEPTH = 1000 };
6
+
7
+ static int emit(const char *s) {
8
+ return fputs(s, stdout) != EOF;
9
+ }
10
+
11
+ static int emit_type(const char *kind, int index) {
12
+ return printf(":ind a :%s%d .\n", kind, index) >= 0;
13
+ }
14
+
15
+ int main(void) {
16
+ unsigned char hasN[DEPTH + 1];
17
+ unsigned char hasI[DEPTH + 1];
18
+ unsigned char hasJ[DEPTH + 1];
19
+ unsigned char hasA2 = 0;
20
+ unsigned char hasTest = 0;
21
+ int changed = 1;
22
+
23
+ memset(hasN, 0, sizeof(hasN));
24
+ memset(hasI, 0, sizeof(hasI));
25
+ memset(hasJ, 0, sizeof(hasJ));
26
+
27
+ /* fact: :ind a :N0. */
28
+ hasN[0] = 1;
29
+
30
+ /*
31
+ * Forward-chain the rules to a fixpoint.
32
+ *
33
+ * {?X a :N0} => {?X a :N1, :I1, :J1}.
34
+ * {?X a :N1} => {?X a :N2, :I2, :J2}.
35
+ * ...
36
+ * {?X a :N999} => {?X a :N1000, :I1000, :J1000}.
37
+ * {?X a :N1000} => {?X a :A2}.
38
+ * {:ind a :A2} => {:test :is true}.
39
+ */
40
+ while (changed) {
41
+ changed = 0;
42
+
43
+ for (int i = 0; i < DEPTH; i++) {
44
+ if (!hasN[i]) {
45
+ continue;
46
+ }
47
+
48
+ if (!hasN[i + 1]) {
49
+ hasN[i + 1] = 1;
50
+ changed = 1;
51
+ }
52
+ if (!hasI[i + 1]) {
53
+ hasI[i + 1] = 1;
54
+ changed = 1;
55
+ }
56
+ if (!hasJ[i + 1]) {
57
+ hasJ[i + 1] = 1;
58
+ changed = 1;
59
+ }
60
+ }
61
+
62
+ if (hasN[DEPTH] && !hasA2) {
63
+ hasA2 = 1;
64
+ changed = 1;
65
+ }
66
+
67
+ if (hasA2 && !hasTest) {
68
+ hasTest = 1;
69
+ changed = 1;
70
+ }
71
+ }
72
+
73
+ if (!emit("@prefix : <http://eulersharp.sourceforge.net/2009/12dtb/test#> .\n\n")) {
74
+ return EXIT_FAILURE;
75
+ }
76
+
77
+ for (int i = 1; i <= DEPTH; i++) {
78
+ if (!hasN[i] || !hasI[i] || !hasJ[i]) {
79
+ fprintf(stderr, "incomplete closure at depth %d\n", i);
80
+ return EXIT_FAILURE;
81
+ }
82
+ if (!emit_type("N", i) || !emit_type("I", i) || !emit_type("J", i)) {
83
+ return EXIT_FAILURE;
84
+ }
85
+ }
86
+
87
+ if (!hasA2 || !hasTest) {
88
+ fputs("expected conclusions were not derived\n", stderr);
89
+ return EXIT_FAILURE;
90
+ }
91
+
92
+ if (!emit(":ind a :A2 .\n:test :is true .\n")) {
93
+ return EXIT_FAILURE;
94
+ }
95
+
96
+ return EXIT_SUCCESS;
97
+ }
@@ -0,0 +1,97 @@
1
+ #include <stdio.h>
2
+ #include <stdlib.h>
3
+ #include <string.h>
4
+
5
+ enum { DEPTH = 10000 };
6
+
7
+ static int emit(const char *s) {
8
+ return fputs(s, stdout) != EOF;
9
+ }
10
+
11
+ static int emit_type(const char *kind, int index) {
12
+ return printf(":ind a :%s%d .\n", kind, index) >= 0;
13
+ }
14
+
15
+ int main(void) {
16
+ unsigned char hasN[DEPTH + 1];
17
+ unsigned char hasI[DEPTH + 1];
18
+ unsigned char hasJ[DEPTH + 1];
19
+ unsigned char hasA2 = 0;
20
+ unsigned char hasTest = 0;
21
+ int changed = 1;
22
+
23
+ memset(hasN, 0, sizeof(hasN));
24
+ memset(hasI, 0, sizeof(hasI));
25
+ memset(hasJ, 0, sizeof(hasJ));
26
+
27
+ /* fact: :ind a :N0. */
28
+ hasN[0] = 1;
29
+
30
+ /*
31
+ * Forward-chain the rules to a fixpoint.
32
+ *
33
+ * {?X a :N0} => {?X a :N1, :I1, :J1}.
34
+ * {?X a :N1} => {?X a :N2, :I2, :J2}.
35
+ * ...
36
+ * {?X a :N9999} => {?X a :N10000, :I10000, :J10000}.
37
+ * {?X a :N10000} => {?X a :A2}.
38
+ * {:ind a :A2} => {:test :is true}.
39
+ */
40
+ while (changed) {
41
+ changed = 0;
42
+
43
+ for (int i = 0; i < DEPTH; i++) {
44
+ if (!hasN[i]) {
45
+ continue;
46
+ }
47
+
48
+ if (!hasN[i + 1]) {
49
+ hasN[i + 1] = 1;
50
+ changed = 1;
51
+ }
52
+ if (!hasI[i + 1]) {
53
+ hasI[i + 1] = 1;
54
+ changed = 1;
55
+ }
56
+ if (!hasJ[i + 1]) {
57
+ hasJ[i + 1] = 1;
58
+ changed = 1;
59
+ }
60
+ }
61
+
62
+ if (hasN[DEPTH] && !hasA2) {
63
+ hasA2 = 1;
64
+ changed = 1;
65
+ }
66
+
67
+ if (hasA2 && !hasTest) {
68
+ hasTest = 1;
69
+ changed = 1;
70
+ }
71
+ }
72
+
73
+ if (!emit("@prefix : <http://eulersharp.sourceforge.net/2009/12dtb/test#> .\n\n")) {
74
+ return EXIT_FAILURE;
75
+ }
76
+
77
+ for (int i = 1; i <= DEPTH; i++) {
78
+ if (!hasN[i] || !hasI[i] || !hasJ[i]) {
79
+ fprintf(stderr, "incomplete closure at depth %d\n", i);
80
+ return EXIT_FAILURE;
81
+ }
82
+ if (!emit_type("N", i) || !emit_type("I", i) || !emit_type("J", i)) {
83
+ return EXIT_FAILURE;
84
+ }
85
+ }
86
+
87
+ if (!hasA2 || !hasTest) {
88
+ fputs("expected conclusions were not derived\n", stderr);
89
+ return EXIT_FAILURE;
90
+ }
91
+
92
+ if (!emit(":ind a :A2 .\n:test :is true .\n")) {
93
+ return EXIT_FAILURE;
94
+ }
95
+
96
+ return EXIT_SUCCESS;
97
+ }
@@ -1,18 +1,95 @@
1
1
  #include <stdio.h>
2
2
  #include <stdlib.h>
3
+ #include <string.h>
4
+
5
+ enum { DEPTH = 100000 };
6
+
7
+ static int emit(const char *s) {
8
+ return fputs(s, stdout) != EOF;
9
+ }
10
+
11
+ static int emit_type(const char *kind, int index) {
12
+ return printf(":ind a :%s%d .\n", kind, index) >= 0;
13
+ }
3
14
 
4
15
  int main(void) {
5
- if (printf("@prefix : <http://eulersharp.sourceforge.net/2009/12dtb/test#> .\n\n") < 0) {
16
+ unsigned char hasN[DEPTH + 1];
17
+ unsigned char hasI[DEPTH + 1];
18
+ unsigned char hasJ[DEPTH + 1];
19
+ unsigned char hasA2 = 0;
20
+ unsigned char hasTest = 0;
21
+ int changed = 1;
22
+
23
+ memset(hasN, 0, sizeof(hasN));
24
+ memset(hasI, 0, sizeof(hasI));
25
+ memset(hasJ, 0, sizeof(hasJ));
26
+
27
+ /* fact: :ind a :N0. */
28
+ hasN[0] = 1;
29
+
30
+ /*
31
+ * Forward-chain the rules to a fixpoint.
32
+ *
33
+ * {?X a :N0} => {?X a :N1, :I1, :J1}.
34
+ * {?X a :N1} => {?X a :N2, :I2, :J2}.
35
+ * ...
36
+ * {?X a :N99999} => {?X a :N100000, :I100000, :J100000}.
37
+ * {?X a :N100000} => {?X a :A2}.
38
+ * {:ind a :A2} => {:test :is true}.
39
+ */
40
+ while (changed) {
41
+ changed = 0;
42
+
43
+ for (int i = 0; i < DEPTH; i++) {
44
+ if (!hasN[i]) {
45
+ continue;
46
+ }
47
+
48
+ if (!hasN[i + 1]) {
49
+ hasN[i + 1] = 1;
50
+ changed = 1;
51
+ }
52
+ if (!hasI[i + 1]) {
53
+ hasI[i + 1] = 1;
54
+ changed = 1;
55
+ }
56
+ if (!hasJ[i + 1]) {
57
+ hasJ[i + 1] = 1;
58
+ changed = 1;
59
+ }
60
+ }
61
+
62
+ if (hasN[DEPTH] && !hasA2) {
63
+ hasA2 = 1;
64
+ changed = 1;
65
+ }
66
+
67
+ if (hasA2 && !hasTest) {
68
+ hasTest = 1;
69
+ changed = 1;
70
+ }
71
+ }
72
+
73
+ if (!emit("@prefix : <http://eulersharp.sourceforge.net/2009/12dtb/test#> .\n\n")) {
6
74
  return EXIT_FAILURE;
7
75
  }
8
76
 
9
- for (int i = 1; i <= 100000; i++) {
10
- if (printf(":ind a :N%d .\n:ind a :I%d .\n:ind a :J%d .\n", i, i, i) < 0) {
77
+ for (int i = 1; i <= DEPTH; i++) {
78
+ if (!hasN[i] || !hasI[i] || !hasJ[i]) {
79
+ fprintf(stderr, "incomplete closure at depth %d\n", i);
11
80
  return EXIT_FAILURE;
12
81
  }
82
+ if (!emit_type("N", i) || !emit_type("I", i) || !emit_type("J", i)) {
83
+ return EXIT_FAILURE;
84
+ }
85
+ }
86
+
87
+ if (!hasA2 || !hasTest) {
88
+ fputs("expected conclusions were not derived\n", stderr);
89
+ return EXIT_FAILURE;
13
90
  }
14
91
 
15
- if (printf(":ind a :A2 .\n:test :is true .\n") < 0) {
92
+ if (!emit(":ind a :A2 .\n:test :is true .\n")) {
16
93
  return EXIT_FAILURE;
17
94
  }
18
95