eyeling 1.14.13 → 1.15.0

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.
Files changed (29) hide show
  1. package/examples/check/input/deep-taxonomy-100000.c +20 -0
  2. package/examples/check/input/gps.c +127 -0
  3. package/examples/check/input/high-trust-rdf-bloom-envelope.c +148 -0
  4. package/examples/check/input/high-trust-rdf-bloom-tamper-contrast.c +247 -0
  5. package/examples/check/input/odrl-dpv-risk-ranked.c +275 -0
  6. package/examples/check/output/deep-taxonomy-100000.n3 +300004 -0
  7. package/examples/check/output/gps.n3 +6 -0
  8. package/examples/check/output/high-trust-rdf-bloom-envelope.n3 +7 -0
  9. package/examples/check/output/high-trust-rdf-bloom-tamper-contrast.n3 +27 -0
  10. package/examples/check/output/odrl-dpv-risk-ranked.n3 +13 -0
  11. package/examples/decimal-ebike-motor-thermal-envelope.n3 +286 -0
  12. package/examples/decimal-transcendental-servo-envelope.n3 +197 -0
  13. package/examples/deck/high-trust-rdf-bloom-envelope.md +371 -0
  14. package/examples/deck/schema-foaf-mapping.md +3 -1
  15. package/examples/high-trust-rdf-bloom-envelope.n3 +281 -0
  16. package/examples/high-trust-rdf-bloom-tamper-contrast.n3 +395 -0
  17. package/examples/integer-first-control-tank-level.n3 +209 -0
  18. package/examples/integer-first-sqrt2-mediants.n3 +174 -0
  19. package/examples/output/decimal-ebike-motor-thermal-envelope.n3 +25 -0
  20. package/examples/output/decimal-transcendental-servo-envelope.n3 +29 -0
  21. package/examples/output/high-trust-rdf-bloom-envelope.n3 +7 -0
  22. package/examples/output/high-trust-rdf-bloom-tamper-contrast.n3 +27 -0
  23. package/examples/output/integer-first-control-tank-level.n3 +70 -0
  24. package/examples/output/integer-first-sqrt2-mediants.n3 +57 -0
  25. package/eyeling.js +90 -1
  26. package/lib/lexer.js +90 -1
  27. package/package.json +3 -2
  28. package/test/api.test.js +221 -0
  29. package/test/check.test.js +174 -0
@@ -0,0 +1,20 @@
1
+ #include <stdio.h>
2
+ #include <stdlib.h>
3
+
4
+ int main(void) {
5
+ if (printf("@prefix : <http://eulersharp.sourceforge.net/2009/12dtb/test#> .\n\n") < 0) {
6
+ return EXIT_FAILURE;
7
+ }
8
+
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) {
11
+ return EXIT_FAILURE;
12
+ }
13
+ }
14
+
15
+ if (printf(":ind a :A2 .\n:test :is true .\n") < 0) {
16
+ return EXIT_FAILURE;
17
+ }
18
+
19
+ return EXIT_SUCCESS;
20
+ }
@@ -0,0 +1,127 @@
1
+ #include <stdio.h>
2
+ #include <stdlib.h>
3
+ #include <string.h>
4
+
5
+ typedef struct {
6
+ const char *from;
7
+ const char *to;
8
+ const char *action;
9
+ double duration;
10
+ double cost;
11
+ double belief;
12
+ double comfort;
13
+ } Edge;
14
+
15
+ typedef struct {
16
+ const char *actions[8];
17
+ int action_count;
18
+ double duration;
19
+ double cost;
20
+ double belief;
21
+ double comfort;
22
+ } Path;
23
+
24
+ static const Edge EDGES[] = {
25
+ {"Gent", "Brugge", ":drive_gent_brugge", 1500.0, 0.006, 0.96, 0.99},
26
+ {"Gent", "Kortrijk", ":drive_gent_kortrijk", 1600.0, 0.007, 0.96, 0.99},
27
+ {"Kortrijk", "Brugge", ":drive_kortrijk_brugge", 1600.0, 0.007, 0.96, 0.99},
28
+ {"Brugge", "Oostende", ":drive_brugge_oostende", 900.0, 0.004, 0.98, 1.0}
29
+ };
30
+
31
+ static void print_decimal(double value) {
32
+ char buf[64];
33
+ snprintf(buf, sizeof(buf), "%.15f", value);
34
+ char *p = buf + strlen(buf) - 1;
35
+ while (p > buf && *p == '0') {
36
+ *p-- = '\0';
37
+ }
38
+ if (p > buf && *p == '.') {
39
+ *p = '\0';
40
+ }
41
+ printf("\"%s\"^^xsd:decimal", buf);
42
+ }
43
+
44
+ static int contains_city(const char *visited[], int visited_count, const char *city) {
45
+ for (int i = 0; i < visited_count; ++i) {
46
+ if (strcmp(visited[i], city) == 0) {
47
+ return 1;
48
+ }
49
+ }
50
+ return 0;
51
+ }
52
+
53
+ static void emit_path(const Path *path) {
54
+ printf(":i1 gps:path ((");
55
+ for (int i = 0; i < path->action_count; ++i) {
56
+ if (i > 0) {
57
+ putchar(' ');
58
+ }
59
+ fputs(path->actions[i], stdout);
60
+ }
61
+ printf(") ");
62
+ print_decimal(path->duration);
63
+ printf(" ");
64
+ print_decimal(path->cost);
65
+ printf(" ");
66
+ print_decimal(path->belief);
67
+ printf(" ");
68
+ print_decimal(path->comfort);
69
+ printf(") .\n");
70
+ }
71
+
72
+ static void dfs(const char *current,
73
+ const char *goal,
74
+ const char *visited[],
75
+ int visited_count,
76
+ Path *path) {
77
+ if (strcmp(current, goal) == 0) {
78
+ emit_path(path);
79
+ return;
80
+ }
81
+
82
+ for (size_t i = 0; i < sizeof(EDGES) / sizeof(EDGES[0]); ++i) {
83
+ const Edge *e = &EDGES[i];
84
+ if (strcmp(e->from, current) != 0) {
85
+ continue;
86
+ }
87
+ if (contains_city(visited, visited_count, e->to)) {
88
+ continue;
89
+ }
90
+
91
+ path->actions[path->action_count++] = e->action;
92
+ path->duration += e->duration;
93
+ path->cost += e->cost;
94
+ path->belief *= e->belief;
95
+ path->comfort *= e->comfort;
96
+
97
+ const char *next_visited[16];
98
+ for (int j = 0; j < visited_count; ++j) {
99
+ next_visited[j] = visited[j];
100
+ }
101
+ next_visited[visited_count] = e->to;
102
+
103
+ dfs(e->to, goal, next_visited, visited_count + 1, path);
104
+
105
+ path->action_count--;
106
+ path->duration -= e->duration;
107
+ path->cost -= e->cost;
108
+ path->belief /= e->belief;
109
+ path->comfort /= e->comfort;
110
+ }
111
+ }
112
+
113
+ int main(void) {
114
+ puts("@prefix : <https://eyereasoner.github.io/eye/reasoning#> .");
115
+ puts("@prefix gps: <https://eyereasoner.github.io/eye/reasoning/gps/gps-schema#> .");
116
+ puts("@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .");
117
+ putchar('\n');
118
+
119
+ Path path;
120
+ memset(&path, 0, sizeof(path));
121
+ path.belief = 1.0;
122
+ path.comfort = 1.0;
123
+
124
+ const char *visited[] = {"Gent"};
125
+ dfs("Gent", "Oostende", visited, 1, &path);
126
+ return 0;
127
+ }
@@ -0,0 +1,148 @@
1
+ #include <math.h>
2
+ #include <stdbool.h>
3
+ #include <stdio.h>
4
+ #include <string.h>
5
+
6
+ typedef struct {
7
+ const char *name;
8
+ int canonicalTripleCount;
9
+ int spoIndexTripleCount;
10
+ int bloomBits;
11
+ int hashFunctions;
12
+ int negativeLookupsPerBatch;
13
+ double fpRateBudget;
14
+ double extraExactLookupsBudget;
15
+ const char *exactTranscendentalSymbol;
16
+ double certifiedLambda;
17
+ double expMinusLambdaLower;
18
+ double expMinusLambdaUpper;
19
+ const char *maybePositivePolicy;
20
+ const char *definiteNegativePolicy;
21
+ } Artifact;
22
+
23
+ typedef struct {
24
+ bool parameterSanity;
25
+ bool indexAgreement;
26
+ double lambda;
27
+ bool expIntervalCertificate;
28
+ double fpRateLower;
29
+ double fpRateUpper;
30
+ bool withinFpRateBudget;
31
+ double expectedExtraExactLookupsUpper;
32
+ bool withinExactLookupBudget;
33
+ bool accepted;
34
+ } Evaluation;
35
+
36
+ static bool same_policy(const char *lhs, const char *rhs) {
37
+ return strcmp(lhs, rhs) == 0;
38
+ }
39
+
40
+ static Evaluation evaluate_artifact(const Artifact *a) {
41
+ Evaluation ev;
42
+ memset(&ev, 0, sizeof(ev));
43
+
44
+ ev.parameterSanity =
45
+ a->canonicalTripleCount > 0 &&
46
+ a->spoIndexTripleCount > 0 &&
47
+ a->bloomBits > 0 &&
48
+ a->hashFunctions > 0 &&
49
+ a->negativeLookupsPerBatch > 0 &&
50
+ a->fpRateBudget > 0.0 &&
51
+ a->extraExactLookupsBudget > 0.0;
52
+
53
+ ev.indexAgreement = (a->canonicalTripleCount == a->spoIndexTripleCount);
54
+
55
+ if (ev.parameterSanity) {
56
+ ev.lambda = ((double)a->hashFunctions * (double)a->canonicalTripleCount) /
57
+ (double)a->bloomBits;
58
+ }
59
+
60
+ ev.expIntervalCertificate =
61
+ ev.lambda > 0.0 &&
62
+ a->certifiedLambda == ev.lambda &&
63
+ a->expMinusLambdaLower < a->expMinusLambdaUpper &&
64
+ a->expMinusLambdaLower > 0.0 &&
65
+ a->expMinusLambdaUpper < 1.0;
66
+
67
+ if (ev.expIntervalCertificate) {
68
+ const double oneMinusLo = 1.0 - a->expMinusLambdaUpper;
69
+ const double oneMinusHi = 1.0 - a->expMinusLambdaLower;
70
+ ev.fpRateLower = pow(oneMinusLo, a->hashFunctions);
71
+ ev.fpRateUpper = pow(oneMinusHi, a->hashFunctions);
72
+ }
73
+
74
+ ev.withinFpRateBudget =
75
+ ev.fpRateUpper > 0.0 &&
76
+ ev.fpRateUpper < a->fpRateBudget;
77
+
78
+ ev.expectedExtraExactLookupsUpper =
79
+ (double)a->negativeLookupsPerBatch * ev.fpRateUpper;
80
+
81
+ ev.withinExactLookupBudget =
82
+ ev.expectedExtraExactLookupsUpper > 0.0 &&
83
+ ev.expectedExtraExactLookupsUpper < a->extraExactLookupsBudget;
84
+
85
+ ev.accepted =
86
+ ev.parameterSanity &&
87
+ ev.indexAgreement &&
88
+ ev.expIntervalCertificate &&
89
+ ev.withinFpRateBudget &&
90
+ ev.withinExactLookupBudget &&
91
+ same_policy(a->maybePositivePolicy, ":ConfirmAgainstCanonicalGraph") &&
92
+ same_policy(a->definiteNegativePolicy, ":ReturnAbsent");
93
+
94
+ return ev;
95
+ }
96
+
97
+ int main(void) {
98
+ const Artifact artifact = {
99
+ .name = ":artifact",
100
+ .canonicalTripleCount = 1200,
101
+ .spoIndexTripleCount = 1200,
102
+ .bloomBits = 16384,
103
+ .hashFunctions = 7,
104
+ .negativeLookupsPerBatch = 50000,
105
+ .fpRateBudget = 0.002,
106
+ .extraExactLookupsBudget = 100.0,
107
+ .exactTranscendentalSymbol = "exp(-k*n/m)",
108
+ .certifiedLambda = 0.5126953125,
109
+ .expMinusLambdaLower = 0.5988792348,
110
+ .expMinusLambdaUpper = 0.5988792349,
111
+ .maybePositivePolicy = ":ConfirmAgainstCanonicalGraph",
112
+ .definiteNegativePolicy = ":ReturnAbsent"
113
+ };
114
+
115
+ const Evaluation ev = evaluate_artifact(&artifact);
116
+
117
+ printf("@prefix : <http://example.org/high-trust-rdf#> .\n");
118
+ printf("@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n\n");
119
+
120
+ if (ev.expIntervalCertificate) {
121
+ printf(":result :expIntervalCertificate :CertifiedDecimalInterval .\n");
122
+ }
123
+
124
+ if (ev.accepted) {
125
+ printf(":result :summary (\"parameter-sanity\" true ");
126
+ printf("\"index-agreement\" true ");
127
+ printf("\"transcendental\" \"%s\" ", artifact.exactTranscendentalSymbol);
128
+ printf("\"lambda\" \"%.10f\"^^xsd:decimal ", ev.lambda);
129
+ printf("\"certified-lambda\" %.10f ", artifact.certifiedLambda);
130
+ printf("\"exp-lower\" %.10f ", artifact.expMinusLambdaLower);
131
+ printf("\"exp-upper\" %.10f ", artifact.expMinusLambdaUpper);
132
+ printf("\"fp-lower\" \"%.19f\"^^xsd:decimal ", ev.fpRateLower);
133
+ printf("\"fp-upper\" \"%.19f\"^^xsd:decimal ", ev.fpRateUpper);
134
+ printf("\"expected-extra-exact-lookups-upper\" \"%.14f\"^^xsd:decimal ",
135
+ ev.expectedExtraExactLookupsUpper);
136
+ printf("\"decision\" :AcceptForHighTrustUse) .\n");
137
+ }
138
+
139
+ if (ev.withinExactLookupBudget) {
140
+ printf(":result :withinExactLookupBudget true .\n");
141
+ }
142
+
143
+ if (ev.withinFpRateBudget) {
144
+ printf(":result :withinFpRateBudget true .\n");
145
+ }
146
+
147
+ return 0;
148
+ }
@@ -0,0 +1,247 @@
1
+ #include <math.h>
2
+ #include <stdbool.h>
3
+ #include <stdio.h>
4
+ #include <stdlib.h>
5
+ #include <string.h>
6
+
7
+ #define ARRAY_LEN(x) (sizeof(x) / sizeof((x)[0]))
8
+
9
+ typedef struct {
10
+ const char *name;
11
+ int canonicalTripleCount;
12
+ int spoIndexTripleCount;
13
+ int bloomBits;
14
+ int hashFunctions;
15
+ int negativeLookupsPerBatch;
16
+ double fpRateBudget;
17
+ double extraExactLookupsBudget;
18
+ const char *exactTranscendentalSymbol;
19
+ double certifiedLambda;
20
+ double expMinusLambdaLower;
21
+ double expMinusLambdaUpper;
22
+ const char *maybePositivePolicy;
23
+ const char *definiteNegativePolicy;
24
+ } Artifact;
25
+
26
+ typedef enum {
27
+ REJECT_NON_POSITIVE_BLOOM_BITS,
28
+ REJECT_CERTIFIED_LAMBDA_MISMATCH,
29
+ REJECT_MALFORMED_INTERVAL_ORDERING,
30
+ REJECT_NON_POSITIVE_INTERVAL_LOWER_BOUND,
31
+ REJECT_INTERVAL_UPPER_BOUND_NOT_BELOW_ONE
32
+ } RejectReason;
33
+
34
+ typedef struct {
35
+ double lambda;
36
+ double weakFpUpper;
37
+ double weakExtraUpper;
38
+ bool indexAgreement;
39
+ bool weakWithinFpRateBudget;
40
+ bool weakWithinExactLookupBudget;
41
+ bool weakAccepted;
42
+ bool parameterSanity;
43
+ bool expIntervalCertificate;
44
+ bool withinFpRateBudget;
45
+ bool withinExactLookupBudget;
46
+ bool hardenedAccepted;
47
+ RejectReason rejectReasons[8];
48
+ size_t rejectReasonCount;
49
+ } Evaluation;
50
+
51
+ static bool same_policy(const char *lhs, const char *rhs) {
52
+ return strcmp(lhs, rhs) == 0;
53
+ }
54
+
55
+ static double compute_lambda(const Artifact *a) {
56
+ double kn = (double)a->hashFunctions * (double)a->canonicalTripleCount;
57
+ return kn / (double)a->bloomBits;
58
+ }
59
+
60
+ static double compute_weak_fp_upper(const Artifact *a) {
61
+ double oneMinusHi = 1.0 - a->expMinusLambdaLower;
62
+ return pow(oneMinusHi, a->hashFunctions);
63
+ }
64
+
65
+ static void add_reject_reason(Evaluation *ev, RejectReason reason) {
66
+ ev->rejectReasons[ev->rejectReasonCount++] = reason;
67
+ }
68
+
69
+ static const char *reject_reason_name(RejectReason reason) {
70
+ switch (reason) {
71
+ case REJECT_NON_POSITIVE_BLOOM_BITS:
72
+ return ":NonPositiveBloomBits";
73
+ case REJECT_CERTIFIED_LAMBDA_MISMATCH:
74
+ return ":CertifiedLambdaMismatch";
75
+ case REJECT_MALFORMED_INTERVAL_ORDERING:
76
+ return ":MalformedIntervalOrdering";
77
+ case REJECT_NON_POSITIVE_INTERVAL_LOWER_BOUND:
78
+ return ":NonPositiveIntervalLowerBound";
79
+ case REJECT_INTERVAL_UPPER_BOUND_NOT_BELOW_ONE:
80
+ return ":IntervalUpperBoundNotBelowOne";
81
+ }
82
+ return ":UnknownRejectReason";
83
+ }
84
+
85
+ static Evaluation evaluate_artifact(const Artifact *a) {
86
+ Evaluation ev;
87
+ memset(&ev, 0, sizeof(ev));
88
+
89
+ ev.lambda = compute_lambda(a);
90
+ ev.indexAgreement = (a->canonicalTripleCount == a->spoIndexTripleCount);
91
+
92
+ ev.weakFpUpper = compute_weak_fp_upper(a);
93
+ ev.weakWithinFpRateBudget = (ev.weakFpUpper < a->fpRateBudget);
94
+ ev.weakExtraUpper = (double)a->negativeLookupsPerBatch * ev.weakFpUpper;
95
+ ev.weakWithinExactLookupBudget = (ev.weakExtraUpper < a->extraExactLookupsBudget);
96
+ ev.weakAccepted = ev.indexAgreement &&
97
+ ev.weakWithinFpRateBudget &&
98
+ ev.weakWithinExactLookupBudget &&
99
+ same_policy(a->maybePositivePolicy, ":ConfirmAgainstCanonicalGraph") &&
100
+ same_policy(a->definiteNegativePolicy, ":ReturnAbsent");
101
+
102
+ ev.parameterSanity =
103
+ a->canonicalTripleCount > 0 &&
104
+ a->spoIndexTripleCount > 0 &&
105
+ a->bloomBits > 0 &&
106
+ a->hashFunctions > 0 &&
107
+ a->negativeLookupsPerBatch > 0 &&
108
+ a->fpRateBudget > 0.0 &&
109
+ a->extraExactLookupsBudget > 0.0;
110
+
111
+ ev.expIntervalCertificate =
112
+ ev.lambda > 0.0 &&
113
+ a->certifiedLambda == ev.lambda &&
114
+ a->expMinusLambdaLower < a->expMinusLambdaUpper &&
115
+ a->expMinusLambdaLower > 0.0 &&
116
+ a->expMinusLambdaUpper < 1.0;
117
+
118
+ ev.withinFpRateBudget = ev.expIntervalCertificate &&
119
+ ev.weakFpUpper > 0.0 &&
120
+ ev.weakFpUpper < a->fpRateBudget;
121
+
122
+ ev.withinExactLookupBudget = ev.expIntervalCertificate &&
123
+ ev.weakExtraUpper > 0.0 &&
124
+ ev.weakExtraUpper < a->extraExactLookupsBudget;
125
+
126
+ ev.hardenedAccepted = ev.parameterSanity &&
127
+ ev.indexAgreement &&
128
+ ev.expIntervalCertificate &&
129
+ ev.withinFpRateBudget &&
130
+ ev.withinExactLookupBudget &&
131
+ same_policy(a->maybePositivePolicy, ":ConfirmAgainstCanonicalGraph") &&
132
+ same_policy(a->definiteNegativePolicy, ":ReturnAbsent");
133
+
134
+ if (a->bloomBits <= 0) {
135
+ add_reject_reason(&ev, REJECT_NON_POSITIVE_BLOOM_BITS);
136
+ }
137
+ if (a->certifiedLambda != ev.lambda) {
138
+ add_reject_reason(&ev, REJECT_CERTIFIED_LAMBDA_MISMATCH);
139
+ }
140
+ if (!(a->expMinusLambdaUpper > a->expMinusLambdaLower)) {
141
+ add_reject_reason(&ev, REJECT_MALFORMED_INTERVAL_ORDERING);
142
+ }
143
+ if (!(a->expMinusLambdaLower > 0.0)) {
144
+ add_reject_reason(&ev, REJECT_NON_POSITIVE_INTERVAL_LOWER_BOUND);
145
+ }
146
+ if (!(a->expMinusLambdaUpper < 1.0)) {
147
+ add_reject_reason(&ev, REJECT_INTERVAL_UPPER_BOUND_NOT_BELOW_ONE);
148
+ }
149
+
150
+ return ev;
151
+ }
152
+
153
+ static void print_decision(const Artifact *a, const Evaluation *ev) {
154
+ printf(":result :decision [\n");
155
+ printf(" :artifact %s ;\n", a->name);
156
+ printf(" :hardened %s ;\n",
157
+ ev->hardenedAccepted ? ":AcceptForHighTrustUse" : ":RejectForHighTrustUse");
158
+ printf(" :weak %s\n",
159
+ ev->weakAccepted ? ":AcceptUnderWeakBudgetOnlyRules" : ":RejectUnderWeakBudgetOnlyRules");
160
+ printf("] .\n");
161
+ }
162
+
163
+ static void print_reject_reasons(const Artifact *a, const Evaluation *ev) {
164
+ for (size_t i = 0; i < ev->rejectReasonCount; ++i) {
165
+ printf(":result :rejectReason [\n");
166
+ printf(" :artifact %s ;\n", a->name);
167
+ printf(" :why %s\n", reject_reason_name(ev->rejectReasons[i]));
168
+ printf("] .\n");
169
+ }
170
+ }
171
+
172
+ static void print_summary_tampered(const Artifact *a, const Evaluation *ev) {
173
+ long long weakFpUpperInt = (long long)llround(ev->weakFpUpper);
174
+ long long weakExtraUpperInt = (long long)llround(ev->weakExtraUpper);
175
+
176
+ printf(":result :summary (%s \"lambda\" %.0f \"certified-lambda\" %.10f ",
177
+ a->name,
178
+ ev->lambda,
179
+ a->certifiedLambda);
180
+ printf("\"weak-fp-upper\" \"%lld\"^^xsd:decimal ", weakFpUpperInt);
181
+ printf("\"weak-extra-exact-upper\" \"%lld\"^^xsd:decimal ", weakExtraUpperInt);
182
+ printf("\"weak-decision\" %s \"hardened-decision\" %s) .\n",
183
+ ev->weakAccepted ? ":AcceptUnderWeakBudgetOnlyRules" : ":RejectUnderWeakBudgetOnlyRules",
184
+ ev->hardenedAccepted ? ":AcceptForHighTrustUse" : ":RejectForHighTrustUse");
185
+ }
186
+
187
+ static void print_summary_trusted(const Artifact *a, const Evaluation *ev) {
188
+ printf(":result :summary (%s \"lambda\" \"%.10f\"^^xsd:decimal \"certified-lambda\" %.10f ",
189
+ a->name,
190
+ ev->lambda,
191
+ a->certifiedLambda);
192
+ printf("\"weak-fp-upper\" \"%.19f\"^^xsd:decimal ", ev->weakFpUpper);
193
+ printf("\"weak-extra-exact-upper\" \"%.14f\"^^xsd:decimal ", ev->weakExtraUpper);
194
+ printf("\"weak-decision\" %s \"hardened-decision\" %s) .\n",
195
+ ev->weakAccepted ? ":AcceptUnderWeakBudgetOnlyRules" : ":RejectUnderWeakBudgetOnlyRules",
196
+ ev->hardenedAccepted ? ":AcceptForHighTrustUse" : ":RejectForHighTrustUse");
197
+ }
198
+
199
+ int main(void) {
200
+ const Artifact trusted = {
201
+ .name = ":trustedArtifact",
202
+ .canonicalTripleCount = 1200,
203
+ .spoIndexTripleCount = 1200,
204
+ .bloomBits = 16384,
205
+ .hashFunctions = 7,
206
+ .negativeLookupsPerBatch = 50000,
207
+ .fpRateBudget = 0.002,
208
+ .extraExactLookupsBudget = 100.0,
209
+ .exactTranscendentalSymbol = "exp(-k*n/m)",
210
+ .certifiedLambda = 0.5126953125,
211
+ .expMinusLambdaLower = 0.5988792348,
212
+ .expMinusLambdaUpper = 0.5988792349,
213
+ .maybePositivePolicy = ":ConfirmAgainstCanonicalGraph",
214
+ .definiteNegativePolicy = ":ReturnAbsent"
215
+ };
216
+
217
+ const Artifact tampered = {
218
+ .name = ":tamperedArtifact",
219
+ .canonicalTripleCount = 1200,
220
+ .spoIndexTripleCount = 1200,
221
+ .bloomBits = -12,
222
+ .hashFunctions = 7,
223
+ .negativeLookupsPerBatch = 1,
224
+ .fpRateBudget = 0.1,
225
+ .extraExactLookupsBudget = 100.0,
226
+ .exactTranscendentalSymbol = "whatever an attacker writes here",
227
+ .certifiedLambda = 0.5126953125,
228
+ .expMinusLambdaLower = 42.0,
229
+ .expMinusLambdaUpper = -42.0,
230
+ .maybePositivePolicy = ":ConfirmAgainstCanonicalGraph",
231
+ .definiteNegativePolicy = ":ReturnAbsent"
232
+ };
233
+
234
+ const Evaluation trustedEval = evaluate_artifact(&trusted);
235
+ const Evaluation tamperedEval = evaluate_artifact(&tampered);
236
+
237
+ printf("@prefix : <http://example.org/high-trust-rdf#> .\n");
238
+ printf("@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n\n");
239
+
240
+ print_decision(&trusted, &trustedEval);
241
+ print_decision(&tampered, &tamperedEval);
242
+ print_reject_reasons(&tampered, &tamperedEval);
243
+ print_summary_tampered(&tampered, &tamperedEval);
244
+ print_summary_trusted(&trusted, &trustedEval);
245
+
246
+ return 0;
247
+ }