eyelang 1.5.2 → 1.5.4
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.
- package/README.md +2 -0
- package/examples/access-control-policy.pl +3 -0
- package/examples/ackermann.pl +3 -0
- package/examples/age.pl +3 -0
- package/examples/aliases-and-namespaces.pl +7 -0
- package/examples/alignment-demo.pl +3 -0
- package/examples/allen-interval-calculus.pl +3 -0
- package/examples/ancestor.pl +7 -0
- package/examples/animal.pl +3 -0
- package/examples/annotation.pl +3 -0
- package/examples/auroracare.pl +309 -0
- package/examples/backward.pl +3 -0
- package/examples/basic-monadic.pl +3 -1
- package/examples/bayes-diagnosis.pl +3 -0
- package/examples/bayes-therapy.pl +3 -0
- package/examples/beam-deflection.pl +3 -0
- package/examples/blocks-world-planning.pl +3 -0
- package/examples/bmi.pl +3 -0
- package/examples/braking-safety-worlds.pl +3 -0
- package/examples/buck-converter-design.pl +3 -0
- package/examples/cache-performance.pl +3 -0
- package/examples/canary-release.pl +3 -0
- package/examples/cat-koko.pl +3 -0
- package/examples/clinical-trial-screening.pl +3 -0
- package/examples/collatz-1000.pl +3 -0
- package/examples/combinatorics-findall-sort.pl +6 -0
- package/examples/competitive-enzyme-kinetics.pl +3 -0
- package/examples/complex-matrix-stability.pl +3 -0
- package/examples/complex.pl +3 -0
- package/examples/composition-of-injective-functions-is-injective.pl +3 -0
- package/examples/context-association.pl +3 -0
- package/examples/control-system.pl +3 -0
- package/examples/cryptarithmetic-send-more-money.pl +3 -0
- package/examples/cyclic-path.pl +3 -1
- package/examples/d3-group.pl +8 -0
- package/examples/dairy-energy-balance.pl +3 -0
- package/examples/data-negotiation.pl +6 -0
- package/examples/deep-taxonomy-10.pl +3 -0
- package/examples/deep-taxonomy-100.pl +3 -0
- package/examples/deep-taxonomy-1000.pl +3 -0
- package/examples/deep-taxonomy-10000.pl +3 -0
- package/examples/deep-taxonomy-100000.pl +3 -0
- package/examples/delfour.pl +18 -1
- package/examples/dense-hamiltonian-cycle.pl +3 -0
- package/examples/deontic-logic.pl +6 -0
- package/examples/derived-backward-rule.pl +3 -0
- package/examples/derived-rule.pl +3 -0
- package/examples/diamond-property.pl +3 -0
- package/examples/dijkstra-findall-sort.pl +6 -0
- package/examples/dijkstra-risk-path.pl +3 -0
- package/examples/dijkstra.pl +3 -0
- package/examples/dining-philosophers.pl +3 -0
- package/examples/dog.pl +5 -0
- package/examples/drone-corridor-planner.pl +3 -0
- package/examples/easter-computus.pl +6 -0
- package/examples/electrical-rc-filter.pl +3 -0
- package/examples/epidemic-policy.pl +6 -0
- package/examples/equivalence-classes-overlap-implies-same-class.pl +3 -0
- package/examples/eulerian-path.pl +6 -0
- package/examples/ev-range-worlds.pl +3 -0
- package/examples/exact-cover-sudoku.pl +3 -0
- package/examples/existential-rule.pl +3 -0
- package/examples/exoplanet-validation-worlds.pl +3 -0
- package/examples/expression-eval.pl +5 -0
- package/examples/family-cousins.pl +3 -0
- package/examples/fastpow.pl +5 -0
- package/examples/fft8-numeric.pl +6 -0
- package/examples/fibonacci.pl +3 -0
- package/examples/field-nitrogen-balance.pl +3 -0
- package/examples/flandor.pl +296 -0
- package/examples/floating-point.pl +5 -0
- package/examples/four-color-map.pl +3 -0
- package/examples/fundamental-theorem-arithmetic.pl +3 -0
- package/examples/gcd-bezout-identity.pl +3 -0
- package/examples/gd-step-certified.pl +3 -0
- package/examples/gdpr-compliance.pl +6 -0
- package/examples/goldbach-1000.pl +3 -0
- package/examples/good-cobbler.pl +3 -0
- package/examples/gps.pl +3 -0
- package/examples/graph-reachability.pl +3 -0
- package/examples/gray-code-counter.pl +6 -0
- package/examples/greatest-lower-bound-uniqueness.pl +3 -0
- package/examples/group-inverse-uniqueness.pl +3 -0
- package/examples/hamiltonian-cycle.pl +3 -0
- package/examples/hamiltonian-path.pl +3 -0
- package/examples/hamming-code.pl +3 -0
- package/examples/hanoi.pl +3 -0
- package/examples/heat-loss.pl +3 -0
- package/examples/heron-theorem.pl +5 -0
- package/examples/ideal-gas-law.pl +3 -0
- package/examples/illegitimate-reasoning.pl +3 -0
- package/examples/kaprekar.pl +3 -0
- package/examples/law-of-cosines.pl +5 -0
- package/examples/least-squares-regression.pl +3 -0
- package/examples/list-collection.pl +5 -0
- package/examples/lldm.pl +3 -0
- package/examples/manufacturing-quality-control.pl +3 -0
- package/examples/matrix.pl +3 -0
- package/examples/microgrid-dispatch.pl +3 -0
- package/examples/monkey-bananas.pl +3 -0
- package/examples/n-queens.pl +3 -0
- package/examples/network-sla.pl +3 -0
- package/examples/newton-raphson.pl +3 -0
- package/examples/nixon-diamond.pl +3 -0
- package/examples/odrl-dpv-healthcare-risk-ranked.pl +3 -0
- package/examples/odrl-dpv-risk-ranked.pl +3 -0
- package/examples/orbital-transfer-design.pl +3 -0
- package/examples/output/auroracare.pl +117 -0
- package/examples/output/delfour.pl +7 -1
- package/examples/output/flandor.pl +43 -0
- package/examples/path-discovery.pl +3 -0
- package/examples/peano-arithmetic.pl +3 -0
- package/examples/peasant.pl +5 -0
- package/examples/pendulum-period.pl +3 -0
- package/examples/polynomial.pl +3 -0
- package/examples/project-portfolio-optimization.pl +3 -0
- package/examples/proof-contrapositive.pl +3 -0
- package/examples/quadratic-formula.pl +3 -0
- package/examples/quine-mccluskey.pl +3 -0
- package/examples/radioactive-decay.pl +3 -0
- package/examples/sat-dpll.pl +3 -0
- package/examples/security-incident-correlation.pl +3 -0
- package/examples/service-impact.pl +3 -0
- package/examples/sieve.pl +3 -0
- package/examples/skolem-functions.pl +3 -0
- package/examples/socket-age.pl +3 -0
- package/examples/socket-family.pl +3 -0
- package/examples/socrates.pl +3 -0
- package/examples/statistics-summary.pl +3 -0
- package/examples/sudoku.pl +3 -0
- package/examples/superdense-coding.pl +3 -0
- package/examples/traveling-salesman.pl +6 -0
- package/examples/turing.pl +3 -0
- package/examples/vector-similarity.pl +6 -0
- package/examples/witch.pl +3 -0
- package/examples/wolf-goat-cabbage.pl +3 -0
- package/examples/zebra.pl +3 -0
- package/package.json +1 -1
- package/playground.html +2 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
% Flandor insight-economy case adapted from Eyeling flandor.n3.
|
|
2
|
+
% The original N3 renders a Markdown ARC report. This eyelang translation keeps
|
|
3
|
+
% the neutral insight, policy envelope, authorization, package choice, and checks
|
|
4
|
+
% as materialized relation output.
|
|
5
|
+
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
|
+
materialize(caseName, 2).
|
|
8
|
+
materialize(regionName, 2).
|
|
9
|
+
materialize(metric, 2).
|
|
10
|
+
materialize(activeNeedCount, 2).
|
|
11
|
+
materialize(activeNeedThreshold, 2).
|
|
12
|
+
materialize(recommendedPackageName, 2).
|
|
13
|
+
materialize(budgetCapMEUR, 2).
|
|
14
|
+
materialize(packageCostMEUR, 2).
|
|
15
|
+
materialize(envelopeExpiresAt, 2).
|
|
16
|
+
materialize(workerCoverage, 2).
|
|
17
|
+
materialize(gridReliefMW, 2).
|
|
18
|
+
materialize(outcome, 2).
|
|
19
|
+
materialize(target, 2).
|
|
20
|
+
materialize(reason, 2).
|
|
21
|
+
materialize(alg, 2).
|
|
22
|
+
materialize(payloadHashSHA256, 2).
|
|
23
|
+
materialize(signatureHMAC, 2).
|
|
24
|
+
materialize(auditEntries, 2).
|
|
25
|
+
materialize(filesWritten, 2).
|
|
26
|
+
materialize(allChecksPass, 2).
|
|
27
|
+
materialize(exportWeakness, 2).
|
|
28
|
+
materialize(skillsStrain, 2).
|
|
29
|
+
materialize(gridStress, 2).
|
|
30
|
+
materialize(needsRetoolingPulse, 2).
|
|
31
|
+
materialize(derivedFromNeed, 2).
|
|
32
|
+
materialize(signatureVerifies, 2).
|
|
33
|
+
materialize(payloadHashMatches, 2).
|
|
34
|
+
materialize(hmacMatches, 2).
|
|
35
|
+
materialize(minimizationStripsSensitiveTerms, 2).
|
|
36
|
+
materialize(scopeComplete, 2).
|
|
37
|
+
materialize(authorizationAllowed, 2).
|
|
38
|
+
materialize(thresholdReached, 2).
|
|
39
|
+
materialize(packageWithinBudget, 2).
|
|
40
|
+
materialize(packageCoversAllNeeds, 2).
|
|
41
|
+
materialize(dutyTimingConsistent, 2).
|
|
42
|
+
materialize(surveillanceReuseProhibited, 2).
|
|
43
|
+
materialize(filesWrittenExpected, 2).
|
|
44
|
+
materialize(lowestCostEligiblePackageChosen, 2).
|
|
45
|
+
|
|
46
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
47
|
+
% Case metadata describes the request, audit window, and expected file writes.
|
|
48
|
+
case_name(case, "flandor").
|
|
49
|
+
question(case, "Is the Flemish Economic Resilience Board allowed to use a neutral macro-economic insight for regional stabilization, and if so which package should it activate for Flanders?").
|
|
50
|
+
expectedFilesWritten(case, 6).
|
|
51
|
+
requestPurpose(case, "regional_stabilization").
|
|
52
|
+
requestAction(case, odrlUse).
|
|
53
|
+
hubCreatedAt(case, "2026-04-08T07:00:00+00:00").
|
|
54
|
+
hubExpiresAt(case, "2026-04-08T19:00:00+00:00").
|
|
55
|
+
boardAuthAt(case, "2026-04-08T09:15:00+00:00").
|
|
56
|
+
boardDutyAt(case, "2026-04-08T18:30:00+00:00").
|
|
57
|
+
files_written(case, 6).
|
|
58
|
+
audit_entries(case, 1).
|
|
59
|
+
|
|
60
|
+
region_name(flanders, "Flanders").
|
|
61
|
+
observedFirms(signals, 217).
|
|
62
|
+
aggregationLevel(signals, "regional_cluster").
|
|
63
|
+
containsFirmNames(signals, false).
|
|
64
|
+
containsPayrollRows(signals, false).
|
|
65
|
+
|
|
66
|
+
% Signals are intentionally aggregated: no firm names or payroll rows are present.
|
|
67
|
+
industrialCluster(clusterAntwerp).
|
|
68
|
+
clusterName(clusterAntwerp, "Antwerp chemicals").
|
|
69
|
+
exportOrdersIndex(clusterAntwerp, 84).
|
|
70
|
+
energyIntensity(clusterAntwerp, 92).
|
|
71
|
+
industrialCluster(clusterGhent).
|
|
72
|
+
clusterName(clusterGhent, "Ghent manufacturing").
|
|
73
|
+
exportOrdersIndex(clusterGhent, 87).
|
|
74
|
+
energyIntensity(clusterGhent, 76).
|
|
75
|
+
|
|
76
|
+
techVacancyRateTenths(labourMarket, 46).
|
|
77
|
+
techVacancyRate(labourMarket, 4.6).
|
|
78
|
+
congestionHours(grid, 19).
|
|
79
|
+
renewableCurtailmentMWh(grid, 240).
|
|
80
|
+
maxMEUR(budget, 140).
|
|
81
|
+
windowName(budget, "Q2 resilience window").
|
|
82
|
+
|
|
83
|
+
% Candidate packages expose cost and which active needs they cover.
|
|
84
|
+
policyPackage(pkgTrainingOnly).
|
|
85
|
+
packageId(pkgTrainingOnly, "pkg:TRAIN_070").
|
|
86
|
+
packageName(pkgTrainingOnly, "Flanders Skills Sprint").
|
|
87
|
+
costMEUR(pkgTrainingOnly, 70).
|
|
88
|
+
worker_coverage(pkgTrainingOnly, 900).
|
|
89
|
+
grid_relief_mw(pkgTrainingOnly, 0).
|
|
90
|
+
coversSkillsStrain(pkgTrainingOnly, true).
|
|
91
|
+
|
|
92
|
+
policyPackage(pkgLogisticsOnly).
|
|
93
|
+
packageId(pkgLogisticsOnly, "pkg:PORT_095").
|
|
94
|
+
packageName(pkgLogisticsOnly, "Schelde Trade Buffer").
|
|
95
|
+
costMEUR(pkgLogisticsOnly, 95).
|
|
96
|
+
worker_coverage(pkgLogisticsOnly, 300).
|
|
97
|
+
grid_relief_mw(pkgLogisticsOnly, 10).
|
|
98
|
+
coversExportWeakness(pkgLogisticsOnly, true).
|
|
99
|
+
|
|
100
|
+
policyPackage(pkgFlandor).
|
|
101
|
+
packageId(pkgFlandor, "pkg:RET_FLEX_120").
|
|
102
|
+
packageName(pkgFlandor, "Flandor Retooling Pulse").
|
|
103
|
+
costMEUR(pkgFlandor, 120).
|
|
104
|
+
worker_coverage(pkgFlandor, 1200).
|
|
105
|
+
grid_relief_mw(pkgFlandor, 85).
|
|
106
|
+
coversExportWeakness(pkgFlandor, true).
|
|
107
|
+
coversSkillsStrain(pkgFlandor, true).
|
|
108
|
+
coversGridStress(pkgFlandor, true).
|
|
109
|
+
|
|
110
|
+
policyPackage(pkgFullCorridor).
|
|
111
|
+
packageId(pkgFullCorridor, "pkg:CORRIDOR_165").
|
|
112
|
+
packageName(pkgFullCorridor, "Full Corridor Shock Shield").
|
|
113
|
+
costMEUR(pkgFullCorridor, 165).
|
|
114
|
+
worker_coverage(pkgFullCorridor, 1600).
|
|
115
|
+
grid_relief_mw(pkgFullCorridor, 110).
|
|
116
|
+
coversExportWeakness(pkgFullCorridor, true).
|
|
117
|
+
coversSkillsStrain(pkgFullCorridor, true).
|
|
118
|
+
coversGridStress(pkgFullCorridor, true).
|
|
119
|
+
|
|
120
|
+
insight(macroInsight).
|
|
121
|
+
id(macroInsight, "https://example.org/insight/flandor").
|
|
122
|
+
insight_metric(macroInsight, "regional_retooling_priority").
|
|
123
|
+
thresholdScore(macroInsight, 3).
|
|
124
|
+
thresholdDisplay(macroInsight, "3 active needs").
|
|
125
|
+
suggestionPolicy(macroInsight, "lowest_cost_package_covering_all_active_needs").
|
|
126
|
+
scopeDevice(macroInsight, "economic-resilience-board").
|
|
127
|
+
scopeEvent(macroInsight, "budget-prep-window").
|
|
128
|
+
region(macroInsight, "Flanders").
|
|
129
|
+
createdAt(macroInsight, "2026-04-08T07:00:00+00:00").
|
|
130
|
+
expiresAt(macroInsight, "2026-04-08T19:00:00+00:00").
|
|
131
|
+
serializedLowercase(macroInsight, "createdat expiresat insight metric regional_retooling_priority region flanders scopedevice economic-resilience-board scopeevent budget-prep-window suggestionpolicy lowest_cost_package_covering_all_active_needs threshold 3").
|
|
132
|
+
|
|
133
|
+
envelopeInsight(envelope, macroInsight).
|
|
134
|
+
envelopePolicy(envelope, policy).
|
|
135
|
+
envelopeHash(envelope, "10a85e861075bef2a96c01c7f3238735f82b8f368deb62eafcedd1c4b7f7c707").
|
|
136
|
+
permission(policy, odrlUse, macroInsight, "regional_stabilization").
|
|
137
|
+
prohibition(policy, odrlDistribute, macroInsight, "firm_surveillance").
|
|
138
|
+
duty(policy, odrlDelete, "2026-04-08T19:00:00+00:00").
|
|
139
|
+
|
|
140
|
+
signature_alg(signature, "HMAC-SHA256").
|
|
141
|
+
keyid(signature, "demo-shared-secret").
|
|
142
|
+
created(signature, "2026-04-08T07:00:00+00:00").
|
|
143
|
+
payload_hash_sha256(signature, "10a85e861075bef2a96c01c7f3238735f82b8f368deb62eafcedd1c4b7f7c707").
|
|
144
|
+
display_payload_hash_sha256(signature, "718f5b17d07ab6a95503bc04a1000ddb132409f600659c03d21def81914b780b").
|
|
145
|
+
signature_hmac(signature, "955968ca99a191783bc00cba068128ccb9ff40a5e6114fda13a52c74ee27329e").
|
|
146
|
+
hmacVerificationMode(signature, trustedPrecomputedInput).
|
|
147
|
+
|
|
148
|
+
reason_value(reasonText, "Secure aggregates from Flanders indicate simultaneous export weakness, technical labour scarcity, and grid congestion. A neutral macro insight is scoped to the economic-resilience board for one budget window only, enabling a temporary package without exposing firm-level books.").
|
|
149
|
+
|
|
150
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
151
|
+
caseName(Case, Name) :- case_name(Case, Name).
|
|
152
|
+
regionName(Region, Name) :- region_name(Region, Name).
|
|
153
|
+
metric(Insight, Metric) :- insight_metric(Insight, Metric).
|
|
154
|
+
alg(Signature, Alg) :- signature_alg(Signature, Alg).
|
|
155
|
+
payloadHashSHA256(Signature, Hash) :- display_payload_hash_sha256(Signature, Hash).
|
|
156
|
+
signatureHMAC(Signature, Hmac) :- signature_hmac(Signature, Hmac).
|
|
157
|
+
auditEntries(Case, Count) :- audit_entries(Case, Count).
|
|
158
|
+
filesWritten(Case, Count) :- files_written(Case, Count).
|
|
159
|
+
|
|
160
|
+
export_weakness(case) :-
|
|
161
|
+
industrialCluster(Cluster),
|
|
162
|
+
exportOrdersIndex(Cluster, Index),
|
|
163
|
+
lt(Index, 90).
|
|
164
|
+
|
|
165
|
+
skills_strain(case) :-
|
|
166
|
+
techVacancyRateTenths(labourMarket, Rate),
|
|
167
|
+
gt(Rate, 39).
|
|
168
|
+
|
|
169
|
+
grid_stress(case) :-
|
|
170
|
+
congestionHours(grid, Hours),
|
|
171
|
+
gt(Hours, 11).
|
|
172
|
+
|
|
173
|
+
needs_retooling_pulse(case) :-
|
|
174
|
+
export_weakness(case),
|
|
175
|
+
skills_strain(case),
|
|
176
|
+
grid_stress(case).
|
|
177
|
+
|
|
178
|
+
payload_hash_matches(check) :-
|
|
179
|
+
envelopeHash(envelope, Digest),
|
|
180
|
+
payload_hash_sha256(signature, Digest).
|
|
181
|
+
|
|
182
|
+
signature_verifies(check) :- hmacVerificationMode(signature, trustedPrecomputedInput).
|
|
183
|
+
hmac_matches(check) :-
|
|
184
|
+
hmacVerificationMode(signature, trustedPrecomputedInput),
|
|
185
|
+
signature_hmac(signature, "955968ca99a191783bc00cba068128ccb9ff40a5e6114fda13a52c74ee27329e").
|
|
186
|
+
|
|
187
|
+
minimization_strips_sensitive_terms(check) :-
|
|
188
|
+
serializedLowercase(macroInsight, Text),
|
|
189
|
+
not_matches(Text, "salary|payroll|invoice|medical|firmname").
|
|
190
|
+
|
|
191
|
+
scope_complete(check) :-
|
|
192
|
+
scopeDevice(macroInsight, _Device),
|
|
193
|
+
scopeEvent(macroInsight, _Event),
|
|
194
|
+
expiresAt(macroInsight, _Expiry).
|
|
195
|
+
|
|
196
|
+
% Authorization combines policy scope, envelope timing, and use permission.
|
|
197
|
+
authorization_allowed(check) :-
|
|
198
|
+
permission(policy, odrlUse, macroInsight, "regional_stabilization"),
|
|
199
|
+
boardAuthAt(case, AuthAt),
|
|
200
|
+
expiresAt(macroInsight, ExpiresAt),
|
|
201
|
+
le(AuthAt, ExpiresAt).
|
|
202
|
+
|
|
203
|
+
decision(decision, "Allowed", macroInsight) :- authorization_allowed(check).
|
|
204
|
+
|
|
205
|
+
% An eligible package must cover every active need and fit under the budget cap.
|
|
206
|
+
eligible_package(Pkg) :-
|
|
207
|
+
needs_retooling_pulse(case),
|
|
208
|
+
maxMEUR(budget, Max),
|
|
209
|
+
policyPackage(Pkg),
|
|
210
|
+
costMEUR(Pkg, Cost),
|
|
211
|
+
coversExportWeakness(Pkg, true),
|
|
212
|
+
coversSkillsStrain(Pkg, true),
|
|
213
|
+
coversGridStress(Pkg, true),
|
|
214
|
+
le(Cost, Max).
|
|
215
|
+
|
|
216
|
+
lower_cost_eligible_package(Cost) :-
|
|
217
|
+
eligible_package(Other),
|
|
218
|
+
costMEUR(Other, OtherCost),
|
|
219
|
+
lt(OtherCost, Cost).
|
|
220
|
+
|
|
221
|
+
% The recommendation is the lowest-cost eligible package.
|
|
222
|
+
recommended_package(case, Pkg) :-
|
|
223
|
+
eligible_package(Pkg),
|
|
224
|
+
costMEUR(Pkg, Cost),
|
|
225
|
+
not(lower_cost_eligible_package(Cost)).
|
|
226
|
+
|
|
227
|
+
package_within_budget(check) :-
|
|
228
|
+
recommended_package(case, Pkg),
|
|
229
|
+
costMEUR(Pkg, Cost),
|
|
230
|
+
maxMEUR(budget, Max),
|
|
231
|
+
le(Cost, Max).
|
|
232
|
+
|
|
233
|
+
package_covers_all_needs(check) :-
|
|
234
|
+
recommended_package(case, Pkg),
|
|
235
|
+
coversExportWeakness(Pkg, true),
|
|
236
|
+
coversSkillsStrain(Pkg, true),
|
|
237
|
+
coversGridStress(Pkg, true).
|
|
238
|
+
|
|
239
|
+
duty_timing_consistent(check) :-
|
|
240
|
+
boardDutyAt(case, DutyAt),
|
|
241
|
+
expiresAt(macroInsight, ExpiresAt),
|
|
242
|
+
le(DutyAt, ExpiresAt).
|
|
243
|
+
|
|
244
|
+
surveillance_reuse_prohibited(check) :- prohibition(policy, odrlDistribute, macroInsight, "firm_surveillance").
|
|
245
|
+
files_written_expected(check) :- files_written(case, 6).
|
|
246
|
+
threshold_reached(check) :- export_weakness(case), skills_strain(case), grid_stress(case).
|
|
247
|
+
lowest_cost_eligible_package_chosen(check) :- recommended_package(case, _Pkg).
|
|
248
|
+
|
|
249
|
+
all_checks_pass(result) :-
|
|
250
|
+
signature_verifies(check),
|
|
251
|
+
payload_hash_matches(check),
|
|
252
|
+
minimization_strips_sensitive_terms(check),
|
|
253
|
+
scope_complete(check),
|
|
254
|
+
authorization_allowed(check),
|
|
255
|
+
package_within_budget(check),
|
|
256
|
+
package_covers_all_needs(check),
|
|
257
|
+
duty_timing_consistent(check),
|
|
258
|
+
surveillance_reuse_prohibited(check),
|
|
259
|
+
files_written_expected(check).
|
|
260
|
+
|
|
261
|
+
exportWeakness(case, true) :- export_weakness(case).
|
|
262
|
+
skillsStrain(case, true) :- skills_strain(case).
|
|
263
|
+
gridStress(case, true) :- grid_stress(case).
|
|
264
|
+
needsRetoolingPulse(case, true) :- needs_retooling_pulse(case).
|
|
265
|
+
derivedFromNeed(case, "regional_retooling_and_flexibility") :- needs_retooling_pulse(case).
|
|
266
|
+
activeNeedCount(answer, 3) :- threshold_reached(check).
|
|
267
|
+
activeNeedThreshold(answer, 3) :- thresholdScore(macroInsight, 3).
|
|
268
|
+
recommendedPackageName(answer, Name) :- recommended_package(case, Pkg), packageName(Pkg, Name).
|
|
269
|
+
budgetCapMEUR(answer, Max) :- maxMEUR(budget, Max).
|
|
270
|
+
packageCostMEUR(answer, Cost) :- recommended_package(case, Pkg), costMEUR(Pkg, Cost).
|
|
271
|
+
envelopeExpiresAt(answer, Time) :- expiresAt(macroInsight, Time).
|
|
272
|
+
workerCoverage(why, Workers) :- recommended_package(case, Pkg), worker_coverage(Pkg, Workers).
|
|
273
|
+
gridReliefMW(why, MW) :- recommended_package(case, Pkg), grid_relief_mw(Pkg, MW).
|
|
274
|
+
outcome(decision, Outcome) :- decision(decision, Outcome, _Target).
|
|
275
|
+
target(decision, Target) :- decision(decision, _Outcome, Target).
|
|
276
|
+
allChecksPass(result, true) :- all_checks_pass(result).
|
|
277
|
+
signatureVerifies(check, true) :- signature_verifies(check).
|
|
278
|
+
payloadHashMatches(check, true) :- payload_hash_matches(check).
|
|
279
|
+
hmacMatches(check, true) :- hmac_matches(check).
|
|
280
|
+
minimizationStripsSensitiveTerms(check, true) :- minimization_strips_sensitive_terms(check).
|
|
281
|
+
scopeComplete(check, true) :- scope_complete(check).
|
|
282
|
+
authorizationAllowed(check, true) :- authorization_allowed(check).
|
|
283
|
+
thresholdReached(check, true) :- threshold_reached(check).
|
|
284
|
+
packageWithinBudget(check, true) :- package_within_budget(check).
|
|
285
|
+
packageCoversAllNeeds(check, true) :- package_covers_all_needs(check).
|
|
286
|
+
dutyTimingConsistent(check, true) :- duty_timing_consistent(check).
|
|
287
|
+
surveillanceReuseProhibited(check, true) :- surveillance_reuse_prohibited(check).
|
|
288
|
+
filesWrittenExpected(check, true) :- files_written_expected(check).
|
|
289
|
+
lowestCostEligiblePackageChosen(check, true) :- lowest_cost_eligible_package_chosen(check).
|
|
290
|
+
|
|
291
|
+
reason(whyExportWeakness, "Export weakness is active because at least one cluster has exportOrdersIndex < 90 (Antwerp chemicals=84, Ghent manufacturing=87).") :- export_weakness(case).
|
|
292
|
+
reason(whySkillsStrain, "Skills strain is active because technical vacancy rate is 4.6% (threshold > 3.9%).") :- skills_strain(case).
|
|
293
|
+
reason(whyGridStress, "Grid stress is active because congestion hours = 19 (threshold > 11).") :- grid_stress(case).
|
|
294
|
+
reason(whyRecommendationPolicy, "The recommendation policy is \"lowest_cost_package_covering_all_active_needs\", so the cheapest package that covers all active needs within budget is selected.") :- recommended_package(case, _Pkg).
|
|
295
|
+
reason(whySelectedPackage, "Selected package \"Flandor Retooling Pulse\" covers export=true, skills=true, grid=true, cost=€120M.") :- recommended_package(case, pkgFlandor).
|
|
296
|
+
reason(whyUsage, "Usage is permitted only for purpose \"regional_stabilization\" and the envelope expires at 2026-04-08T19:00:00+00:00.") :- authorization_allowed(check).
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
% Floating-point arithmetic and comparisons.
|
|
2
2
|
% Integer-only operands continue to use arbitrary-size integer arithmetic.
|
|
3
3
|
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
4
5
|
materialize(value, 2).
|
|
5
6
|
materialize(than, 2).
|
|
6
7
|
|
|
8
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
9
|
+
% Floating-point constants can be mixed with integer constants in built-ins.
|
|
7
10
|
sample(roomC, 21.5).
|
|
8
11
|
sample(targetC, 19.25).
|
|
9
12
|
|
|
13
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
10
14
|
value(sum, X) :- add(1.5, 2.25, X).
|
|
11
15
|
value(difference, X) :- sub(10.0, 3.125, X).
|
|
12
16
|
value(product, X) :- mul(2.5, 4.0, X).
|
|
@@ -15,4 +19,5 @@ value(sqrtByPower, X) :- pow(9.0, 0.5, X).
|
|
|
15
19
|
value(mathSum, X) :- add(0.125, 0.875, X).
|
|
16
20
|
value(mathProduct, X) :- mul(6.0, 0.5, X).
|
|
17
21
|
than(warmer, targetC) :- sample(roomC, R), sample(targetC, T), gt(R, T).
|
|
22
|
+
% Boolean-like conclusions remain ordinary atoms.
|
|
18
23
|
value(comfortable, true) :- sample(roomC, R), ge(R, 21.0), le(R, 22.0).
|
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
% four colours. This eyelang version keeps the same map/assignment shape and adds
|
|
5
5
|
% a rule-level validation layer that rejects equal colours across borders.
|
|
6
6
|
|
|
7
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
8
|
materialize(color, 2).
|
|
8
9
|
materialize(status, 2).
|
|
9
10
|
materialize(reason, 2).
|
|
10
11
|
|
|
12
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
11
13
|
country(belgium). country(netherlands). country(luxemburg). country(france).
|
|
12
14
|
country(germany). country(italy). country(denmark). country(ireland).
|
|
13
15
|
country(greece). country(spain). country(portugal). country(austria).
|
|
@@ -36,6 +38,7 @@ border(estonia, latvia).
|
|
|
36
38
|
border(latvia, lithuania).
|
|
37
39
|
border(bulgaria, romania).
|
|
38
40
|
|
|
41
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
39
42
|
adjacent(A, B) :- border(A, B).
|
|
40
43
|
adjacent(A, B) :- border(B, A).
|
|
41
44
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
% Compute a prime factorization by repeated smallest-divisor decomposition,
|
|
3
3
|
% then check product reconstruction and primality of the distinct factors.
|
|
4
4
|
|
|
5
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
5
6
|
materialize(n, 2).
|
|
6
7
|
materialize(factorsSmallest, 2).
|
|
7
8
|
materialize(factorsLargest, 2).
|
|
@@ -12,10 +13,12 @@ materialize(distinctPrimeCount, 2).
|
|
|
12
13
|
materialize(smallestPrimeFactor, 2).
|
|
13
14
|
materialize(largestPrimeFactor, 2).
|
|
14
15
|
|
|
16
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
15
17
|
case(fta, 202692987).
|
|
16
18
|
expected_factors(fta, [3, 3, 7, 829, 3881]).
|
|
17
19
|
|
|
18
20
|
% A divides B in positive integers.
|
|
21
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
19
22
|
divides(A, B) :-
|
|
20
23
|
gt(A, 0),
|
|
21
24
|
gt(B, 0),
|
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
% Each case derives gcd(a,b), coefficients s,t, and validation checks for
|
|
5
5
|
% a*s + b*t = gcd(a,b) and divisibility.
|
|
6
6
|
|
|
7
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
8
|
materialize(gcd, 2).
|
|
8
9
|
materialize(bezoutCoefficients, 2).
|
|
9
10
|
materialize(check, 2).
|
|
10
11
|
materialize(status, 2).
|
|
11
12
|
|
|
13
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
12
14
|
case(c1, 48, 18).
|
|
13
15
|
case(c2, 101, 462).
|
|
14
16
|
case(c3, 0, 5).
|
|
@@ -16,6 +18,7 @@ case(c4, 270, 192).
|
|
|
16
18
|
case(c5, -27, 36).
|
|
17
19
|
case(c6, 123456, 7890).
|
|
18
20
|
|
|
21
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
19
22
|
answer(Case, Gcd, S, T) :-
|
|
20
23
|
case(Case, A, B),
|
|
21
24
|
extended_gcd(A, B, Gcd, S, T).
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
% Memoize interval computations reused across width, midpoint, gradient, step,
|
|
2
2
|
% objective, and contraction report relations.
|
|
3
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
3
4
|
materialize(eta, 2).
|
|
4
5
|
materialize(etaLeHalf, 2).
|
|
5
6
|
materialize(xBounds, 2).
|
|
@@ -10,6 +11,7 @@ materialize(stepBounds, 2).
|
|
|
10
11
|
materialize(objectiveBounds, 2).
|
|
11
12
|
materialize(widthContractsAt, 2).
|
|
12
13
|
|
|
14
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
13
15
|
memoize(x_bounds, 3).
|
|
14
16
|
memoize(width, 2).
|
|
15
17
|
memoize(g_bounds, 3).
|
|
@@ -23,6 +25,7 @@ memoize(f_upper, 2).
|
|
|
23
25
|
|
|
24
26
|
max_k(10).
|
|
25
27
|
target(1.0).
|
|
28
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
26
29
|
eta(Eta) :- div(1.0, 5, Eta).
|
|
27
30
|
x_bounds(0, 0.0, 2.0).
|
|
28
31
|
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
% GDPR-style compliance check: purpose, basis, minimisation, safeguards, and export.
|
|
2
2
|
|
|
3
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
3
4
|
materialize(status, 2).
|
|
4
5
|
materialize(reason, 2).
|
|
5
6
|
|
|
7
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
8
|
+
% case_alpha is intended to pass; case_beta is intentionally incomplete.
|
|
6
9
|
processing(case_alpha).
|
|
7
10
|
processing(case_beta).
|
|
8
11
|
|
|
@@ -25,6 +28,8 @@ safeguard(case_beta, encryption).
|
|
|
25
28
|
third_country_transfer(case_beta).
|
|
26
29
|
adequacy_decision(case_alpha).
|
|
27
30
|
|
|
31
|
+
% Compliance is decomposed into reusable checks so reasons can be reported.
|
|
32
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
28
33
|
has_required_basis(Case) :- legal_basis(Case, explicit_consent).
|
|
29
34
|
has_required_basis(Case) :- legal_basis(Case, medical_care).
|
|
30
35
|
|
|
@@ -43,6 +48,7 @@ compliant(Case) :-
|
|
|
43
48
|
has_health_safeguards(Case),
|
|
44
49
|
transfer_ok(Case).
|
|
45
50
|
|
|
51
|
+
% Individual failure rules explain why a case is noncompliant.
|
|
46
52
|
noncompliance_reason(Case, missing_legal_basis) :-
|
|
47
53
|
processing(Case),
|
|
48
54
|
not(has_required_basis(Case)).
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
% Goldbach pairs up to 1000.
|
|
2
2
|
% Prime numbers are input data; the rule below derives all Goldbach pairs.
|
|
3
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
3
4
|
materialize(isPrime, 2).
|
|
4
5
|
materialize(goldbachOk, 2).
|
|
5
6
|
|
|
7
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
6
8
|
prime(2).
|
|
7
9
|
prime(3).
|
|
8
10
|
prime(5).
|
|
@@ -172,6 +174,7 @@ prime(983).
|
|
|
172
174
|
prime(991).
|
|
173
175
|
prime(997).
|
|
174
176
|
|
|
177
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
175
178
|
even_between_4_1000(N) :- between(4, 1000, N), mod(N, 2, 0).
|
|
176
179
|
|
|
177
180
|
isPrime(N, true) :-
|
package/examples/good-cobbler.pl
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
% The Eyeling result is a quoted assertion saying that joe is a good Cobbler.
|
|
4
4
|
% Here the quoted assertion is represented as an eyelang term.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(is, 2).
|
|
7
8
|
|
|
9
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
8
10
|
assertedIs(joe, good(cobbler)).
|
|
9
11
|
|
|
12
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
10
13
|
is(test, is(X, good(Y))) :-
|
|
11
14
|
assertedIs(X, good(Y)).
|
package/examples/gps.pl
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
% Memoize route paths because the same candidate routes are checked repeatedly
|
|
2
2
|
% for explanation and verification relations.
|
|
3
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
3
4
|
materialize(recommendedRoute, 2).
|
|
4
5
|
materialize(outcome, 2).
|
|
5
6
|
materialize(statement, 3).
|
|
@@ -12,6 +13,7 @@ materialize(comfort, 2).
|
|
|
12
13
|
materialize(selectedRoute, 2).
|
|
13
14
|
materialize(comparison, 2).
|
|
14
15
|
|
|
16
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
15
17
|
memoize(path, 7).
|
|
16
18
|
memoize(traveller_path, 6).
|
|
17
19
|
|
|
@@ -35,6 +37,7 @@ map_graph(mapBE, (
|
|
|
35
37
|
gps_description(mapBE, description(location(S, brugge), true, location(S, oostende), drive_brugge_oostende, 900.0, 0.004, 0.98, 1.0))
|
|
36
38
|
)).
|
|
37
39
|
|
|
40
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
38
41
|
case_statement(S, P, O) :-
|
|
39
42
|
case_graph(caseGraph, Formula),
|
|
40
43
|
formula_binary(Formula, S, P, O).
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
% The original uses Prolog negation and member/2 to avoid revisiting nodes.
|
|
4
4
|
% eyelang expresses the same finite search with not(member(...)).
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(reachable, 2).
|
|
7
8
|
materialize(not_reachable, 2).
|
|
8
9
|
|
|
10
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
9
11
|
edge(a, b).
|
|
10
12
|
edge(a, c).
|
|
11
13
|
edge(b, d).
|
|
@@ -15,6 +17,7 @@ edge(e, f).
|
|
|
15
17
|
edge(f, g).
|
|
16
18
|
|
|
17
19
|
reachable(Node, Node, _Visited).
|
|
20
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
18
21
|
reachable(Start, Goal, Visited) :-
|
|
19
22
|
edge(Start, Next),
|
|
20
23
|
not(member(Next, Visited)),
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
% Gray-code counter adapted from Eyeling gray-code-counter.n3 and the
|
|
2
2
|
% Clause and Effect example referenced there.
|
|
3
3
|
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
4
5
|
materialize(isgcc, 2).
|
|
5
6
|
|
|
7
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
8
|
+
% Boolean gates are truth tables; the circuit rules compose them.
|
|
6
9
|
and(0, 0, 0). and(0, 1, 0). and(1, 0, 0). and(1, 1, 1).
|
|
7
10
|
or(0, 0, 0). or(0, 1, 1). or(1, 0, 1). or(1, 1, 1).
|
|
8
11
|
inv(0, 1). inv(1, 0).
|
|
@@ -10,6 +13,7 @@ inv(0, 1). inv(1, 0).
|
|
|
10
13
|
dff(D, 0, Q, Q).
|
|
11
14
|
dff(D, 1, _Q, D).
|
|
12
15
|
|
|
16
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
13
17
|
neta(A, B, Q) :-
|
|
14
18
|
and(A, B, T1),
|
|
15
19
|
inv(A, NA),
|
|
@@ -26,6 +30,7 @@ netb(A, B, C, Q1, Q2) :-
|
|
|
26
30
|
or(T1, T2, Q1),
|
|
27
31
|
or(T2, T3, Q2).
|
|
28
32
|
|
|
33
|
+
% One clock step computes D inputs, then updates the three flip-flops.
|
|
29
34
|
gcc(C, [Qa, Qb, Qc], [Za, Zb, Zc]) :-
|
|
30
35
|
netb(Qa, Qb, Qc, D1, D2),
|
|
31
36
|
neta(Qa, Qb, D3),
|
|
@@ -33,6 +38,7 @@ gcc(C, [Qa, Qb, Qc], [Za, Zb, Zc]) :-
|
|
|
33
38
|
dff(D2, C, Qb, Zb),
|
|
34
39
|
dff(D3, C, Qc, Zc).
|
|
35
40
|
|
|
41
|
+
% testgcc/3 runs the circuit over a list of clock inputs.
|
|
36
42
|
testgcc([], _State, []).
|
|
37
43
|
testgcc([C|Cs], State, [Next|Rest]) :-
|
|
38
44
|
gcc(C, State, Next),
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
1
2
|
materialize(sameGreatestLowerBound, 4).
|
|
2
3
|
|
|
4
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
3
5
|
% Greatest-lower-bound uniqueness example adapted from Eyeling
|
|
4
6
|
% greatest-lower-bound-uniqueness.n3.
|
|
5
7
|
% If M and N are both greatest lower bounds of A and B, each is below the other;
|
|
@@ -8,6 +10,7 @@ materialize(sameGreatestLowerBound, 4).
|
|
|
8
10
|
glbOf(g1, a, b).
|
|
9
11
|
glbOf(g2, a, b).
|
|
10
12
|
|
|
13
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
11
14
|
lowerBoundOf(M, A, B) :- glbOf(M, A, B).
|
|
12
15
|
|
|
13
16
|
leq(L, M) :-
|
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
% The output mirrors the Eyeling golden result shape:
|
|
4
4
|
% sameInverse(x, i, j) and sameInverse(x, j, i).
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(sameInverse, 3).
|
|
7
8
|
|
|
9
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
8
10
|
element(e).
|
|
9
11
|
element(x).
|
|
10
12
|
element(i).
|
|
11
13
|
element(j).
|
|
12
14
|
|
|
15
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
13
16
|
op(e, X, X) :- element(X).
|
|
14
17
|
op(X, e, X) :- element(X).
|
|
15
18
|
op(i, x, e).
|
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
% cycle directions are still distinct, so the count is for cycles from a fixed
|
|
6
6
|
% start in traversal order.
|
|
7
7
|
|
|
8
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
8
9
|
materialize(status, 2).
|
|
9
10
|
materialize(witness, 2).
|
|
10
11
|
materialize(vertexCount, 2).
|
|
11
12
|
materialize(cycleCountFromA, 2).
|
|
12
13
|
|
|
14
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
13
15
|
edge(a, b).
|
|
14
16
|
edge(a, f).
|
|
15
17
|
edge(a, g).
|
|
@@ -28,6 +30,7 @@ edge(e, f).
|
|
|
28
30
|
edge(f, g).
|
|
29
31
|
edge(g, h).
|
|
30
32
|
|
|
33
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
31
34
|
adjacent(X, Y) :- edge(X, Y).
|
|
32
35
|
adjacent(X, Y) :- edge(Y, X).
|
|
33
36
|
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
% vertex set directly and derives every path that visits each vertex exactly
|
|
5
5
|
% once.
|
|
6
6
|
|
|
7
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
8
|
materialize(hasHamiltonianPath, 2).
|
|
8
9
|
materialize(hamiltonianPath, 2).
|
|
9
10
|
|
|
11
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
10
12
|
memoize(adjacent, 2).
|
|
11
13
|
|
|
12
14
|
edge(v1, v2).
|
|
@@ -21,6 +23,7 @@ edge(v3, v6).
|
|
|
21
23
|
edge(v4, v5).
|
|
22
24
|
edge(v4, v6).
|
|
23
25
|
|
|
26
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
24
27
|
adjacent(V, U) :- edge(V, U).
|
|
25
28
|
adjacent(V, U) :- edge(U, V).
|
|
26
29
|
|
package/examples/hamming-code.pl
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
% The received word has one corrupted bit. Syndrome bits identify the bad
|
|
4
4
|
% position, then the corrected codeword and decoded payload are derived.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(syndrome, 2).
|
|
7
8
|
materialize(errorBit, 2).
|
|
8
9
|
materialize(correctedCodeword, 2).
|
|
@@ -10,6 +11,7 @@ materialize(decodedPayload, 2).
|
|
|
10
11
|
materialize(status, 2).
|
|
11
12
|
materialize(reason, 2).
|
|
12
13
|
|
|
14
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
13
15
|
received_bit(packet1, 1, 1).
|
|
14
16
|
received_bit(packet1, 2, 0).
|
|
15
17
|
received_bit(packet1, 3, 1).
|
|
@@ -21,6 +23,7 @@ received_bit(packet1, 7, 0).
|
|
|
21
23
|
flip(0, 1).
|
|
22
24
|
flip(1, 0).
|
|
23
25
|
|
|
26
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
24
27
|
parity4(A, B, C, D, Parity) :-
|
|
25
28
|
add(A, B, AB),
|
|
26
29
|
add(AB, C, ABC),
|
package/examples/hanoi.pl
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
% Towers of Hanoi adapted from Eyeling hanoi.n3.
|
|
2
2
|
% Output is the complete list of moves for size 3.
|
|
3
3
|
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
4
5
|
materialize(answer, 2).
|
|
5
6
|
|
|
7
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
6
8
|
memoize(hanoi, 5).
|
|
7
9
|
|
|
8
10
|
hanoi(0, _From, _To, _Via, []).
|
|
11
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
9
12
|
hanoi(N, From, To, Via, Moves) :-
|
|
10
13
|
gt(N, 0),
|
|
11
14
|
sub(N, 1, N1),
|