eyelang 1.5.3 → 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/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 +8 -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 +7 -0
- 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 +9 -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/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
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
% EYE-inspired epidemic policy choice.
|
|
2
2
|
% Policies are evaluated by estimated reproduction risk and social cost.
|
|
3
3
|
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
4
5
|
materialize(riskScore, 2).
|
|
5
6
|
materialize(cost, 2).
|
|
6
7
|
materialize(status, 2).
|
|
7
8
|
materialize(recommendedPolicy, 2).
|
|
8
9
|
materialize(reason, 2).
|
|
9
10
|
|
|
11
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
12
|
+
% Candidate interventions combine vaccination and mask factors.
|
|
10
13
|
policy(no_mandate).
|
|
11
14
|
policy(vaccination_campaign).
|
|
12
15
|
policy(indoor_masks).
|
|
@@ -29,6 +32,8 @@ policy_cost(vaccination_campaign, 3).
|
|
|
29
32
|
policy_cost(indoor_masks, 2).
|
|
30
33
|
policy_cost(vaccination_and_masks, 5).
|
|
31
34
|
|
|
35
|
+
% Risk multiplies the base reproduction estimate by policy-specific factors.
|
|
36
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
32
37
|
risk_score(P, R) :-
|
|
33
38
|
base_risk(Base),
|
|
34
39
|
vaccination_factor(P, VF),
|
|
@@ -48,6 +53,7 @@ status(P, insufficient_control) :-
|
|
|
48
53
|
status(P, acceptable_control) :-
|
|
49
54
|
acceptable(P).
|
|
50
55
|
|
|
56
|
+
% The recommendation is the only candidate below the outbreak threshold.
|
|
51
57
|
recommended(vaccination_and_masks) :-
|
|
52
58
|
acceptable(vaccination_and_masks),
|
|
53
59
|
status(no_mandate, insufficient_control),
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
1
2
|
materialize(sameClassBecauseOfSharedMember, 3).
|
|
2
3
|
|
|
4
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
3
5
|
% Equivalence-classes example adapted from Eyeling
|
|
4
6
|
% equivalence-classes-overlap-implies-same-class.n3.
|
|
5
7
|
% The finite class membership facts represent the equivalence closure generated
|
|
@@ -9,6 +11,7 @@ classMember(class_abc, a).
|
|
|
9
11
|
classMember(class_abc, b).
|
|
10
12
|
classMember(class_abc, c).
|
|
11
13
|
|
|
14
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
12
15
|
inClassOf(U, X) :-
|
|
13
16
|
classMember(Class, U),
|
|
14
17
|
classMember(Class, X).
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
% Eyelet-inspired Eulerian path example using findall/3 and sort/2.
|
|
2
2
|
% The graph is undirected; edges are represented by identifiers so each edge is used once.
|
|
3
3
|
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
4
5
|
materialize(oddVertices, 2).
|
|
5
6
|
materialize(path, 2).
|
|
6
7
|
materialize(edgeCount, 2).
|
|
7
8
|
materialize(reason, 2).
|
|
8
9
|
|
|
10
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
11
|
+
% Edge identifiers let the search remove each physical edge exactly once.
|
|
9
12
|
edge(e12, v1, v2).
|
|
10
13
|
edge(e13, v1, v3).
|
|
11
14
|
edge(e15, v1, v5).
|
|
@@ -18,6 +21,7 @@ edge(e36, v3, v6).
|
|
|
18
21
|
edge(e45, v4, v5).
|
|
19
22
|
edge(e46, v4, v6).
|
|
20
23
|
|
|
24
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
21
25
|
vertex(V) :- edge(_E, V, _U).
|
|
22
26
|
vertex(V) :- edge(_E, _U, V).
|
|
23
27
|
|
|
@@ -31,6 +35,7 @@ select(Item, [Item | Rest], Rest).
|
|
|
31
35
|
select(Item, [Head | Tail], [Head | Rest]) :-
|
|
32
36
|
select(Item, Tail, Rest).
|
|
33
37
|
|
|
38
|
+
% Eulerian paths start at an odd-degree vertex when exactly two exist.
|
|
34
39
|
odd_degree(V) :-
|
|
35
40
|
findall(E, incident(V, E), Edges),
|
|
36
41
|
length(Edges, Degree),
|
|
@@ -60,6 +65,7 @@ eulerian_path(Path) :-
|
|
|
60
65
|
dfs_euler(Start, [Start], Edges, ReversedPath),
|
|
61
66
|
reverse(ReversedPath, Path).
|
|
62
67
|
|
|
68
|
+
% Depth-first search consumes the remaining edge-id list one edge at a time.
|
|
63
69
|
dfs_euler(_Current, Path, [], Path).
|
|
64
70
|
dfs_euler(Current, Visited, Remaining, Path) :-
|
|
65
71
|
adjacent_by_edge(Current, Next, Edge),
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
% EYE-inspired electric-vehicle range worlds.
|
|
2
2
|
% Four simple worlds estimate whether trips fit the available battery.
|
|
3
3
|
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
4
5
|
materialize(safeInWorld, 2).
|
|
5
6
|
materialize(riskyInWorld, 2).
|
|
6
7
|
materialize(reason, 2).
|
|
7
8
|
materialize(status, 2).
|
|
8
9
|
|
|
10
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
9
11
|
trip(city_errand).
|
|
10
12
|
trip(winter_highway).
|
|
11
13
|
trip(heavy_delivery).
|
|
@@ -17,6 +19,7 @@ trip_data(winter_highway, 260, 115, -5, 400, 60, 0.20).
|
|
|
17
19
|
trip_data(heavy_delivery, 180, 80, 15, 700, 55, 0.22).
|
|
18
20
|
trip_data(cold_commute, 120, 90, -8, 100, 35, 0.19).
|
|
19
21
|
|
|
22
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
20
23
|
speed_factor(T, 1.20) :- trip_data(T, _, S, _, _, _, _), gt(S, 100).
|
|
21
24
|
speed_factor(T, 1.00) :- trip_data(T, _, S, _, _, _, _), le(S, 100).
|
|
22
25
|
|
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
% The solver then chooses one candidate per row and checks the exact-cover
|
|
6
6
|
% constraints for all columns and 3x3 boxes.
|
|
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(solution, 2).
|
|
10
11
|
materialize(firstRow, 2).
|
|
11
12
|
|
|
13
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
14
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
12
15
|
cover9(Cells) :-
|
|
13
16
|
sort(Cells, [1, 2, 3, 4, 5, 6, 7, 8, 9]).
|
|
14
17
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
1
2
|
materialize(is, 2).
|
|
2
3
|
|
|
4
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
3
5
|
% Existential-rule example adapted from Eyeling existential-rule.n3.
|
|
4
6
|
% Eyeling creates blank-node witnesses. eyelang has Herbrand terms only, so the
|
|
5
7
|
% witness is represented explicitly by a deterministic Skolem-style term.
|
|
@@ -10,6 +12,7 @@ type(plato, human).
|
|
|
10
12
|
witness(socrates, sk_0).
|
|
11
13
|
witness(plato, sk_1).
|
|
12
14
|
|
|
15
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
13
16
|
is(Person, Witness) :-
|
|
14
17
|
type(Person, human),
|
|
15
18
|
witness(Person, Witness).
|
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
% Four simplified worlds classify candidate transit signals using either Bayes,
|
|
4
4
|
% sensitivity-only reasoning, a heuristic threshold, or a stricter Bayesian rule.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(ppvPlanetGivenDetection, 2).
|
|
7
8
|
materialize(confirmsInWorld, 2).
|
|
8
9
|
materialize(rejectsInWorld, 2).
|
|
9
10
|
materialize(status, 2).
|
|
10
11
|
materialize(reason, 2).
|
|
11
12
|
|
|
13
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
12
14
|
candidate(rare_wide_orbit, 0.001, 0.99, 0.99).
|
|
13
15
|
candidate(mstar_short_period, 0.20, 0.99, 0.99).
|
|
14
16
|
candidate(common_hot_neptune_good, 0.25, 0.95, 0.97).
|
|
@@ -19,6 +21,7 @@ world(w1, sensitivity_only_naive).
|
|
|
19
21
|
world(w2, occurrence_sensitivity_specificity_heuristic).
|
|
20
22
|
world(w3, cautious_bayes_threshold).
|
|
21
23
|
|
|
24
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
22
25
|
ppv_planet(Candidate, PPV) :-
|
|
23
26
|
candidate(Candidate, Occurrence, Sensitivity, Specificity),
|
|
24
27
|
mul(Sensitivity, Occurrence, Numerator),
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
% Tiny expression evaluator adapted from Eyeling's expression-eval.n3 example.
|
|
2
2
|
% Data: (2 * 3) + (10 - 4) = 12.
|
|
3
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
3
4
|
materialize(result, 2).
|
|
4
5
|
|
|
6
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
7
|
+
% Leaves are number/2 facts; internal nodes name an operator and two children.
|
|
5
8
|
number(n2, 2).
|
|
6
9
|
number(n3, 3).
|
|
7
10
|
number(n10, 10).
|
|
@@ -12,6 +15,8 @@ expr(eSub, sub, n10, n4).
|
|
|
12
15
|
expr(eAdd, add, eMul, eSub).
|
|
13
16
|
root(eAdd).
|
|
14
17
|
|
|
18
|
+
% Evaluation is recursive over the expression tree.
|
|
19
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
15
20
|
value(Node, Value) :-
|
|
16
21
|
number(Node, Value).
|
|
17
22
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
% Memoize scoped family projection and recursive labels; cousin derivation asks
|
|
2
2
|
% for the same generation and branch facts many times.
|
|
3
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
3
4
|
materialize(generation, 2).
|
|
4
5
|
materialize(branch, 2).
|
|
5
6
|
materialize(cousin, 2).
|
|
6
7
|
|
|
8
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
7
9
|
memoize(family_statement, 3).
|
|
8
10
|
memoize(generation, 2).
|
|
9
11
|
memoize(branch, 2).
|
|
@@ -30,6 +32,7 @@ family_graph(familyGraph, (
|
|
|
30
32
|
seedBranch(grace, c)
|
|
31
33
|
)).
|
|
32
34
|
|
|
35
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
33
36
|
family_statement(S, P, O) :- family_graph(familyGraph, Formula), formula_binary(Formula, S, P, O).
|
|
34
37
|
|
|
35
38
|
parent(Parent, Child) :- family_statement(Parent, parent, Child).
|
package/examples/fastpow.pl
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
% Fast exponentiation examples adapted from Eyeling fastpow.n3.
|
|
2
2
|
|
|
3
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
3
4
|
materialize(pow, 2).
|
|
4
5
|
materialize(powSlow, 2).
|
|
5
6
|
materialize(powMod1e6, 2).
|
|
6
7
|
materialize(tower, 2).
|
|
7
8
|
materialize(towerMod1e6, 2).
|
|
8
9
|
|
|
10
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
11
|
+
% pow/3 uses exponentiation by squaring.
|
|
9
12
|
pow(_Base, 0, 1).
|
|
13
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
10
14
|
pow(Base, Exp, Value) :-
|
|
11
15
|
gt(Exp, 0),
|
|
12
16
|
mod(Exp, 2, 0),
|
|
@@ -20,6 +24,7 @@ pow(Base, Exp, Value) :-
|
|
|
20
24
|
pow(Base, EvenExp, EvenValue),
|
|
21
25
|
mul(Base, EvenValue, Value).
|
|
22
26
|
|
|
27
|
+
% pow_mod/4 applies the modulus at each multiplication to keep values small.
|
|
23
28
|
pow_mod(_Base, 0, _Mod, 1).
|
|
24
29
|
pow_mod(Base, Exp, Mod, Value) :-
|
|
25
30
|
gt(Exp, 0),
|
package/examples/fft8-numeric.pl
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
% Adapted from Eyeling's fft8-numeric.n3.
|
|
2
2
|
% A radix-2 FFT over explicit complex pairs c(Re, Im).
|
|
3
3
|
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
4
5
|
materialize(fft, 2).
|
|
5
6
|
materialize(dcComponent, 2).
|
|
6
7
|
|
|
8
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
9
|
+
% Twiddle factors are encoded as complex pairs c(Real, Imag).
|
|
7
10
|
w8(0, c(1.0, 0.0)).
|
|
8
11
|
w8(1, c(0.7071067811865476, -0.7071067811865476)).
|
|
9
12
|
w8(2, c(0.0, -1.0)).
|
|
@@ -13,6 +16,8 @@ w8(5, c(-0.7071067811865476, 0.7071067811865476)).
|
|
|
13
16
|
w8(6, c(0.0, 1.0)).
|
|
14
17
|
w8(7, c(0.7071067811865476, 0.7071067811865476)).
|
|
15
18
|
|
|
19
|
+
% Complex arithmetic is expressed through ordinary numeric built-ins.
|
|
20
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
16
21
|
c_add(c(AR, AI), c(BR, BI), c(CR, CI)) :-
|
|
17
22
|
add(AR, BR, CR),
|
|
18
23
|
add(AI, BI, CI).
|
|
@@ -47,6 +52,7 @@ fft4([X0, X1, X2, X3], [Y0, Y1, Y2, Y3]) :-
|
|
|
47
52
|
c_sub(E0, O0, Y2),
|
|
48
53
|
c_sub(E1, T1, Y3).
|
|
49
54
|
|
|
55
|
+
% Split even/odd samples, transform halves, then combine with W8 factors.
|
|
50
56
|
fft8([X0, X1, X2, X3, X4, X5, X6, X7], [Y0, Y1, Y2, Y3, Y4, Y5, Y6, Y7]) :-
|
|
51
57
|
fft4([X0, X2, X4, X6], [E0, E1, E2, E3]),
|
|
52
58
|
fft4([X1, X3, X5, X7], [O0, O1, O2, O3]),
|
package/examples/fibonacci.pl
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
% Memoize the fast-doubling helper: several requested Fibonacci numbers reuse
|
|
2
2
|
% the same half-size subproblems.
|
|
3
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
3
4
|
materialize(fibonacci, 2).
|
|
4
5
|
|
|
6
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
5
7
|
memoize(fib_pair, 3).
|
|
6
8
|
|
|
7
9
|
% BigInt Fibonacci via fast doubling, implemented in Prolog using generic
|
|
@@ -14,6 +16,7 @@ fib_case(100).
|
|
|
14
16
|
fib_case(1000).
|
|
15
17
|
fib_case(10000).
|
|
16
18
|
|
|
19
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
17
20
|
fib(N, Value) :- fib_pair(N, Value, _Next).
|
|
18
21
|
|
|
19
22
|
fib_pair(0, 0, 1).
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
% Fields are classified from soil N, fertilizer N, losses, and crop demand.
|
|
3
3
|
|
|
4
4
|
% field(Field, SoilN, FertilizerN, LossFraction, CropDemandN).
|
|
5
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
5
6
|
materialize(availableN_kg_ha, 2).
|
|
6
7
|
materialize(deficitN_kg_ha, 2).
|
|
7
8
|
materialize(surplusN_kg_ha, 2).
|
|
@@ -10,11 +11,13 @@ materialize(status, 2).
|
|
|
10
11
|
materialize(highestLeachingRisk, 2).
|
|
11
12
|
materialize(reason, 2).
|
|
12
13
|
|
|
14
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
13
15
|
field(low_input, 25, 40, 0.10, 110).
|
|
14
16
|
field(balanced_loam, 45, 80, 0.12, 110).
|
|
15
17
|
field(sandy_high, 30, 150, 0.35, 105).
|
|
16
18
|
field(clay_surplus, 70, 90, 0.08, 120).
|
|
17
19
|
|
|
20
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
18
21
|
total_n(F, Total) :-
|
|
19
22
|
field(F, Soil, Fert, _, _),
|
|
20
23
|
add(Soil, Fert, Total).
|
package/examples/flandor.pl
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
% the neutral insight, policy envelope, authorization, package choice, and checks
|
|
4
4
|
% as materialized relation output.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(caseName, 2).
|
|
7
8
|
materialize(regionName, 2).
|
|
8
9
|
materialize(metric, 2).
|
|
@@ -42,6 +43,8 @@ materialize(surveillanceReuseProhibited, 2).
|
|
|
42
43
|
materialize(filesWrittenExpected, 2).
|
|
43
44
|
materialize(lowestCostEligiblePackageChosen, 2).
|
|
44
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.
|
|
45
48
|
case_name(case, "flandor").
|
|
46
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?").
|
|
47
50
|
expectedFilesWritten(case, 6).
|
|
@@ -60,6 +63,7 @@ aggregationLevel(signals, "regional_cluster").
|
|
|
60
63
|
containsFirmNames(signals, false).
|
|
61
64
|
containsPayrollRows(signals, false).
|
|
62
65
|
|
|
66
|
+
% Signals are intentionally aggregated: no firm names or payroll rows are present.
|
|
63
67
|
industrialCluster(clusterAntwerp).
|
|
64
68
|
clusterName(clusterAntwerp, "Antwerp chemicals").
|
|
65
69
|
exportOrdersIndex(clusterAntwerp, 84).
|
|
@@ -76,6 +80,7 @@ renewableCurtailmentMWh(grid, 240).
|
|
|
76
80
|
maxMEUR(budget, 140).
|
|
77
81
|
windowName(budget, "Q2 resilience window").
|
|
78
82
|
|
|
83
|
+
% Candidate packages expose cost and which active needs they cover.
|
|
79
84
|
policyPackage(pkgTrainingOnly).
|
|
80
85
|
packageId(pkgTrainingOnly, "pkg:TRAIN_070").
|
|
81
86
|
packageName(pkgTrainingOnly, "Flanders Skills Sprint").
|
|
@@ -142,6 +147,7 @@ hmacVerificationMode(signature, trustedPrecomputedInput).
|
|
|
142
147
|
|
|
143
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.").
|
|
144
149
|
|
|
150
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
145
151
|
caseName(Case, Name) :- case_name(Case, Name).
|
|
146
152
|
regionName(Region, Name) :- region_name(Region, Name).
|
|
147
153
|
metric(Insight, Metric) :- insight_metric(Insight, Metric).
|
|
@@ -187,6 +193,7 @@ scope_complete(check) :-
|
|
|
187
193
|
scopeEvent(macroInsight, _Event),
|
|
188
194
|
expiresAt(macroInsight, _Expiry).
|
|
189
195
|
|
|
196
|
+
% Authorization combines policy scope, envelope timing, and use permission.
|
|
190
197
|
authorization_allowed(check) :-
|
|
191
198
|
permission(policy, odrlUse, macroInsight, "regional_stabilization"),
|
|
192
199
|
boardAuthAt(case, AuthAt),
|
|
@@ -195,6 +202,7 @@ authorization_allowed(check) :-
|
|
|
195
202
|
|
|
196
203
|
decision(decision, "Allowed", macroInsight) :- authorization_allowed(check).
|
|
197
204
|
|
|
205
|
+
% An eligible package must cover every active need and fit under the budget cap.
|
|
198
206
|
eligible_package(Pkg) :-
|
|
199
207
|
needs_retooling_pulse(case),
|
|
200
208
|
maxMEUR(budget, Max),
|
|
@@ -210,6 +218,7 @@ lower_cost_eligible_package(Cost) :-
|
|
|
210
218
|
costMEUR(Other, OtherCost),
|
|
211
219
|
lt(OtherCost, Cost).
|
|
212
220
|
|
|
221
|
+
% The recommendation is the lowest-cost eligible package.
|
|
213
222
|
recommended_package(case, Pkg) :-
|
|
214
223
|
eligible_package(Pkg),
|
|
215
224
|
costMEUR(Pkg, Cost),
|
|
@@ -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).
|