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
|
@@ -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),
|
package/examples/heat-loss.pl
CHANGED
|
@@ -2,18 +2,21 @@
|
|
|
2
2
|
%
|
|
3
3
|
% Thermal resistance is L/(k*A), and heat loss is DeltaT/R.
|
|
4
4
|
|
|
5
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
5
6
|
materialize(type, 2).
|
|
6
7
|
materialize(temperatureDifference_K, 2).
|
|
7
8
|
materialize(thermalResistance_K_W, 2).
|
|
8
9
|
materialize(heatLoss_W, 2).
|
|
9
10
|
materialize(status, 2).
|
|
10
11
|
|
|
12
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
11
13
|
wall(wall1, conductivity_W_mK, 0.8).
|
|
12
14
|
wall(wall1, area_m2, 12.0).
|
|
13
15
|
wall(wall1, thickness_m, 0.2).
|
|
14
16
|
wall(wall1, indoor_C, 21.0).
|
|
15
17
|
wall(wall1, outdoor_C, -4.0).
|
|
16
18
|
|
|
19
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
17
20
|
temperature_difference(Wall, DeltaT) :-
|
|
18
21
|
wall(Wall, indoor_C, Indoor),
|
|
19
22
|
wall(Wall, outdoor_C, Outdoor),
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
% Heron's theorem: area = sqrt(s(s-a)(s-b)(s-c)).
|
|
2
2
|
|
|
3
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
3
4
|
materialize(semiperimeter, 2).
|
|
4
5
|
materialize(heronProduct, 2).
|
|
5
6
|
materialize(area, 2).
|
|
6
7
|
materialize(status, 2).
|
|
7
8
|
|
|
9
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
10
|
+
% 13-14-15 is a classic integer-sided triangle with area 84.
|
|
8
11
|
triangle(field_plot, 13, 14, 15).
|
|
9
12
|
|
|
13
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
10
14
|
semiperimeter(Triangle, S) :-
|
|
11
15
|
triangle(Triangle, A, B, C),
|
|
12
16
|
add(A, B, AB),
|
|
13
17
|
add(AB, C, Sum),
|
|
14
18
|
div(Sum, 2, S).
|
|
15
19
|
|
|
20
|
+
% Area is obtained by taking the square root of this Heron product.
|
|
16
21
|
heron_product(Triangle, Product) :-
|
|
17
22
|
triangle(Triangle, A, B, C),
|
|
18
23
|
semiperimeter(Triangle, S),
|
|
@@ -3,14 +3,17 @@
|
|
|
3
3
|
% A simple gas cell uses P*V = n*R*T. The constants are chosen so that the
|
|
4
4
|
% computed pressure is exactly near one atmosphere in this small example.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(pressure_Pa, 2).
|
|
7
8
|
materialize(status, 2).
|
|
8
9
|
materialize(reason, 2).
|
|
9
10
|
|
|
11
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
10
12
|
gas_cell(cell1, 1.0, 8.0, 300.0, 0.024).
|
|
11
13
|
pressure_limit(cell1, low_Pa, 95000.0).
|
|
12
14
|
pressure_limit(cell1, high_Pa, 105000.0).
|
|
13
15
|
|
|
16
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
14
17
|
pressure(Cell, Pressure) :-
|
|
15
18
|
gas_cell(Cell, Moles, GasConstant, Temperature, Volume),
|
|
16
19
|
mul(Moles, GasConstant, NR),
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
% Affirming the consequent:
|
|
9
9
|
% If it rained, the street is wet. The street is wet. Therefore it rained.
|
|
10
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
10
11
|
materialize(type, 2).
|
|
11
12
|
materialize(fallacy, 2).
|
|
12
13
|
materialize(conclusion, 2).
|
|
@@ -15,6 +16,7 @@ materialize(sampleSize, 2).
|
|
|
15
16
|
materialize(requiredSampleSize, 2).
|
|
16
17
|
materialize(omittedAlternative, 2).
|
|
17
18
|
|
|
19
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
18
20
|
argument(arg_affirming_consequent).
|
|
19
21
|
implication(arg_affirming_consequent, rain, street_wet).
|
|
20
22
|
observed(arg_affirming_consequent, street_wet).
|
|
@@ -47,6 +49,7 @@ implication(arg_modus_ponens, subscription_paid, access_allowed).
|
|
|
47
49
|
observed(arg_modus_ponens, subscription_paid).
|
|
48
50
|
concludes(arg_modus_ponens, access_allowed).
|
|
49
51
|
|
|
52
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
50
53
|
fallacy(A, affirming_consequent) :-
|
|
51
54
|
argument(A),
|
|
52
55
|
implication(A, Antecedent, Consequent),
|
package/examples/kaprekar.pl
CHANGED
|
@@ -5,12 +5,15 @@
|
|
|
5
5
|
% until Kaprekar's constant 6174 is reached. The sample set is small so the
|
|
6
6
|
% example remains a millisecond-scale demo in the normal test suite.
|
|
7
7
|
|
|
8
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
8
9
|
materialize(constant, 2).
|
|
9
10
|
materialize(kaprekarSteps, 2).
|
|
10
11
|
materialize(reachesConstant, 2).
|
|
11
12
|
|
|
13
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
12
14
|
memoize(kaprekar, 3).
|
|
13
15
|
|
|
16
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
14
17
|
recursion_count(N, Count) :-
|
|
15
18
|
kaprekar_steps(N, Count).
|
|
16
19
|
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
% Law of cosines: c^2 = a^2 + b^2 - 2ab cos(C).
|
|
2
2
|
% The example uses a 60-degree included angle, so cos(C) is represented as 0.5.
|
|
3
3
|
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
4
5
|
materialize(sideCSquared, 2).
|
|
5
6
|
materialize(sideC, 2).
|
|
6
7
|
materialize(status, 2).
|
|
7
8
|
|
|
9
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
10
|
+
% Stored tuple is triangle(Name, sideA, sideB, cosIncludedAngle).
|
|
8
11
|
triangle(tri60, 7, 9, 0.5).
|
|
9
12
|
|
|
13
|
+
% Compute c^2 first so both squared and square-rooted outputs can be shown.
|
|
14
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
10
15
|
side_c_squared(Triangle, C2) :-
|
|
11
16
|
triangle(Triangle, A, B, CosC),
|
|
12
17
|
mul(A, A, A2),
|
|
@@ -3,16 +3,19 @@
|
|
|
3
3
|
% The rules reduce a list of points to sufficient statistics, then derive the
|
|
4
4
|
% fitted slope, intercept, and coefficient of determination R^2.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(slope, 2).
|
|
7
8
|
materialize(intercept, 2).
|
|
8
9
|
materialize(rSquared, 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
|
dataset(regression1, [point(1.0, 2.0), point(2.0, 3.0), point(3.0, 5.0), point(4.0, 4.0)]).
|
|
13
15
|
threshold(regression1, minimum_r_squared, 0.60).
|
|
14
16
|
|
|
15
17
|
stats([], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0).
|
|
18
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
16
19
|
stats([point(X, Y)|Rest], N, SumX, SumY, SumXX, SumXY, SumYY) :-
|
|
17
20
|
stats(Rest, N0, SumX0, SumY0, SumXX0, SumXY0, SumYY0),
|
|
18
21
|
add(N0, 1.0, N),
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
% List collections inspired by the Eyeling collection example.
|
|
2
2
|
% Demonstrates list literals, member/2, length/2, append/3, and [Head|Tail].
|
|
3
|
+
% Each materialized relation demonstrates one list operation.
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
3
5
|
materialize(length, 2).
|
|
4
6
|
materialize(member, 2).
|
|
5
7
|
materialize(append, 2).
|
|
6
8
|
materialize(head, 2).
|
|
7
9
|
materialize(tail, 2).
|
|
8
10
|
|
|
11
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
12
|
+
% Lists are first-class terms in facts and rule heads/bodies.
|
|
9
13
|
collection(numbers, [1, 2, 3]).
|
|
10
14
|
collection(letters, [a, b]).
|
|
11
15
|
|
|
16
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
12
17
|
length(numbers, N) :-
|
|
13
18
|
collection(numbers, List),
|
|
14
19
|
length(List, N).
|
package/examples/lldm.pl
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
% the default relation materialization stays concise. The visible output is
|
|
5
5
|
% the alarm plus the small set of relations explaining why the alarm fired.
|
|
6
6
|
|
|
7
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
8
|
materialize(type, 2).
|
|
8
9
|
materialize(lld_left_length_cm, 2).
|
|
9
10
|
materialize(lld_right_length_cm, 2).
|
|
@@ -11,6 +12,7 @@ materialize(lld_discrepancy_cm, 2).
|
|
|
11
12
|
materialize(lld_threshold_cm, 2).
|
|
12
13
|
materialize(lld_reason, 2).
|
|
13
14
|
|
|
15
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
14
16
|
measurement(meas47).
|
|
15
17
|
|
|
16
18
|
% measured landmark coordinates, in centimetres
|
|
@@ -27,6 +29,7 @@ val(meas47, p4yCm, 28.5).
|
|
|
27
29
|
threshold(meas47, lld_alarm_threshold_cm, 1.25).
|
|
28
30
|
|
|
29
31
|
% geometric intermediate values
|
|
32
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
30
33
|
val(M, dx12Cm, Z) :- measurement(M), val(M, p1xCm, X), val(M, p2xCm, Y), sub(X, Y, Z).
|
|
31
34
|
val(M, dx51Cm, Z) :- measurement(M), val(M, p5xCm, X), val(M, p1xCm, Y), sub(X, Y, Z).
|
|
32
35
|
val(M, dx53Cm, Z) :- measurement(M), val(M, p5xCm, X), val(M, p3xCm, Y), sub(X, Y, Z).
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
% The rules compute process capability indices from measurement summaries and
|
|
4
4
|
% classify production lines using a practical Cpk threshold.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(cpk, 2).
|
|
7
8
|
materialize(status, 2).
|
|
8
9
|
materialize(reason, 2).
|
|
9
10
|
|
|
11
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
10
12
|
run(line7_shift_a).
|
|
11
13
|
run(line8_shift_b).
|
|
12
14
|
|
|
@@ -22,6 +24,7 @@ summary(line8_shift_b, sigma_mm, 0.02).
|
|
|
22
24
|
|
|
23
25
|
capability_threshold(cpk, 1.33).
|
|
24
26
|
|
|
27
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
25
28
|
upper_margin_mm(Run, Margin) :-
|
|
26
29
|
spec(Run, upper_mm, Upper),
|
|
27
30
|
summary(Run, mean_mm, Mean),
|
package/examples/matrix.pl
CHANGED
|
@@ -7,10 +7,13 @@
|
|
|
7
7
|
|
|
8
8
|
% --- small list helpers -----------------------------------------------------
|
|
9
9
|
|
|
10
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
10
11
|
materialize(result, 2).
|
|
11
12
|
materialize(checksConsistentWithTreallaReference, 2).
|
|
12
13
|
|
|
14
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
13
15
|
nth0(0, [H|_T], H).
|
|
16
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
14
17
|
nth0(N, [_H|T], V) :-
|
|
15
18
|
gt(N, 0),
|
|
16
19
|
sub(N, 1, N1),
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
% The rules compute renewable supply, reserve-aware battery dispatch, remaining
|
|
4
4
|
% grid import, and a concise feasibility report for a campus microgrid interval.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(renewablePower_kW, 2).
|
|
7
8
|
materialize(batteryDispatch_kW, 2).
|
|
8
9
|
materialize(gridImport_kW, 2).
|
|
@@ -10,6 +11,7 @@ materialize(reserveAfterDispatch_kW, 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
|
site(campus_interval_17).
|
|
14
16
|
|
|
15
17
|
load_kW(campus_interval_17, 620.0).
|
|
@@ -19,6 +21,7 @@ battery_max_discharge_kW(campus_interval_17, 320.0).
|
|
|
19
21
|
required_battery_reserve_kW(campus_interval_17, 80.0).
|
|
20
22
|
grid_contract_limit_kW(campus_interval_17, 150.0).
|
|
21
23
|
|
|
24
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
22
25
|
renewable_kW(Site, Renewable) :-
|
|
23
26
|
solar_kW(Site, Solar),
|
|
24
27
|
wind_kW(Site, Wind),
|
|
@@ -5,11 +5,14 @@
|
|
|
5
5
|
% has_bananas]. The selected output searches bounded move lists and derives successful
|
|
6
6
|
% plans.
|
|
7
7
|
|
|
8
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
8
9
|
materialize(plan, 2).
|
|
9
10
|
materialize(solved, 2).
|
|
10
11
|
|
|
12
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
11
13
|
memoize(reachable, 3).
|
|
12
14
|
|
|
15
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
13
16
|
plan(Moves) :-
|
|
14
17
|
candidate_plan(Moves),
|
|
15
18
|
initial_state(I),
|
package/examples/n-queens.pl
CHANGED
|
@@ -10,9 +10,12 @@
|
|
|
10
10
|
% Row - Q. Rejecting repeats in those two lists enforces the remaining
|
|
11
11
|
% N-queens constraints declaratively, without cut or destructive update.
|
|
12
12
|
|
|
13
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
13
14
|
materialize(solution, 2).
|
|
14
15
|
materialize(solved, 2).
|
|
15
16
|
|
|
17
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
18
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
16
19
|
queens(N, Qs) :-
|
|
17
20
|
n_queens(N, Qs).
|
|
18
21
|
|
package/examples/network-sla.pl
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
% The path latency is the sum of link delays plus jitter. The path is compliant
|
|
4
4
|
% when the resulting end-to-end latency stays below the SLA limit.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(endToEndLatency_ms, 2).
|
|
7
8
|
materialize(slaLimit_ms, 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
|
path(edge_path, [link_a, link_b, link_c]).
|
|
12
14
|
link_latency(link_a, 12.0).
|
|
13
15
|
link_latency(link_b, 18.0).
|
|
@@ -16,6 +18,7 @@ jitter(edge_path, 8.0).
|
|
|
16
18
|
sla(edge_path, maximum_latency_ms, 50.0).
|
|
17
19
|
|
|
18
20
|
latency_sum([], 0.0).
|
|
21
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
19
22
|
latency_sum([Link|Links], Total) :-
|
|
20
23
|
link_latency(Link, LinkLatency),
|
|
21
24
|
latency_sum(Links, Rest),
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
% Newton-Raphson root finding, adapted from Eyelet input/newton-raphson.pl.
|
|
2
2
|
% The selected roots match Eyelet output-swipl/newton-raphson.pl.
|
|
3
3
|
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
4
5
|
materialize(findRoot, 2).
|
|
5
6
|
|
|
7
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
6
8
|
want_root([1, 1.0, 1.0e-15]).
|
|
7
9
|
want_root([2, 2.0, 1.0e-15]).
|
|
8
10
|
want_root([3, 3.0, 1.0e-15]).
|
|
9
11
|
|
|
12
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
10
13
|
findRoot(Input, Root) :-
|
|
11
14
|
want_root(Input),
|
|
12
15
|
find_root(Input, Root).
|
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
% a subject with both defaults is reported as conflicted rather than forced to
|
|
4
4
|
% choose one extension.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(defaultSupports, 2).
|
|
7
8
|
materialize(conflict, 2).
|
|
8
9
|
materialize(status, 2).
|
|
9
10
|
|
|
11
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
10
12
|
kind(nixon, quaker).
|
|
11
13
|
kind(nixon, republican).
|
|
12
14
|
|
|
15
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
13
16
|
supports_default(Person, pacifist) :-
|
|
14
17
|
kind(Person, quaker).
|
|
15
18
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
% odrl-dpv-healthcare-risk-ranked.n3.
|
|
3
3
|
% The agreement policy and mitigation suggestions are formula-valued terms.
|
|
4
4
|
|
|
5
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
5
6
|
materialize(policyGraph, 2).
|
|
6
7
|
materialize(contains, 2).
|
|
7
8
|
materialize(dpv_hasRisk, 2).
|
|
@@ -20,6 +21,7 @@ materialize(suggestAddGraph, 2).
|
|
|
20
21
|
materialize(firstRisk, 2).
|
|
21
22
|
materialize(retentionRiskScore, 2).
|
|
22
23
|
|
|
24
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
23
25
|
party(hospital).
|
|
24
26
|
party(researchUnit).
|
|
25
27
|
party(pharmaPartner).
|
|
@@ -110,6 +112,7 @@ policy_graph(policyGraphHC1, (
|
|
|
110
112
|
clause(permRetention10y, clauseH4)
|
|
111
113
|
)).
|
|
112
114
|
|
|
115
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
113
116
|
policy_statement(GraphName, Subject, Predicate, Object) :-
|
|
114
117
|
policy_graph(GraphName, Formula),
|
|
115
118
|
formula_binary(Formula, Subject, Predicate, Object).
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
% reasoning, and materializes the derived DPV risks as relation output.
|
|
6
6
|
|
|
7
7
|
% Consumer profile and needs.
|
|
8
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
8
9
|
materialize(dct_title, 2).
|
|
9
10
|
materialize(dpv_hasRisk, 2).
|
|
10
11
|
materialize(type, 2).
|
|
@@ -31,6 +32,7 @@ materialize(dpv_mitigatesRisk, 2).
|
|
|
31
32
|
materialize(clauseId, 2).
|
|
32
33
|
materialize(text, 2).
|
|
33
34
|
|
|
35
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
34
36
|
consumer(consumerExample).
|
|
35
37
|
title(consumerExample, "Example consumer profile").
|
|
36
38
|
has_need(consumerExample, need_DataCannotBeRemoved).
|
|
@@ -94,6 +96,7 @@ policy_graph(policyGraph1, (
|
|
|
94
96
|
clause(prohibitExportData, clauseC4)
|
|
95
97
|
)).
|
|
96
98
|
|
|
99
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
97
100
|
policy_statement(Subject, Predicate, Object) :-
|
|
98
101
|
policy_graph(_Graph, Formula),
|
|
99
102
|
formula_binary(Formula, Subject, Predicate, Object).
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
% mission constraints. Distances are in kilometres, speeds in kilometres per
|
|
5
5
|
% second, and time in days.
|
|
6
6
|
|
|
7
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
8
|
materialize(transferSemiMajorAxis_km, 2).
|
|
8
9
|
materialize(departureDeltaV_km_s, 2).
|
|
9
10
|
materialize(arrivalDeltaV_km_s, 2).
|
|
@@ -12,6 +13,7 @@ materialize(transferTime_days, 2).
|
|
|
12
13
|
materialize(status, 2).
|
|
13
14
|
materialize(reason, 2).
|
|
14
15
|
|
|
16
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
15
17
|
mission(mars_hohmann, centralBodyMu_km3_s2, 132712440018.0).
|
|
16
18
|
mission(mars_hohmann, departureOrbitRadius_km, 149597870.7).
|
|
17
19
|
mission(mars_hohmann, arrivalOrbitRadius_km, 227939200.0).
|
|
@@ -19,6 +21,7 @@ mission(mars_hohmann, deltaVBudget_km_s, 6.0).
|
|
|
19
21
|
mission(mars_hohmann, pi, 3.141592653589793).
|
|
20
22
|
mission(mars_hohmann, secondsPerDay, 86400.0).
|
|
21
23
|
|
|
24
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
22
25
|
semi_major_axis(Mission, Axis) :-
|
|
23
26
|
mission(Mission, departureOrbitRadius_km, R1),
|
|
24
27
|
mission(Mission, arrivalOrbitRadius_km, R2),
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
% Generic path discovery over the air-routes graph.
|
|
2
2
|
% Change or add route_request(FromLabel, ToLabel, MaxStopOvers) to answer other routes.
|
|
3
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
3
4
|
materialize(airroute, 2).
|
|
4
5
|
|
|
6
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
5
7
|
route_request("Ostend-Bruges International Airport", "Václav Havel Airport Prague", 2).
|
|
6
8
|
|
|
9
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
7
10
|
airroute(discovered, RouteText) :-
|
|
8
11
|
route_request(From, To, MaxStopOvers),
|
|
9
12
|
airport(Source, From),
|
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
% The EYE example defines add, multiply and factorial over Peano numerals.
|
|
4
4
|
% Its selected output computes (1 * 2 + 3)! and emits the factorial of 5.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(factorial, 2).
|
|
7
8
|
|
|
9
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
8
10
|
peano_add(A, 0, A).
|
|
11
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
9
12
|
peano_add(A, s(B), s(C)) :-
|
|
10
13
|
peano_add(A, B, C).
|
|
11
14
|
|
package/examples/peasant.pl
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
% Peasant multiplication and exponentiation cases, adapted from Eyelet
|
|
2
2
|
% input/peasant.pl. The selected answers match Eyelet output-swipl/peasant.pl.
|
|
3
3
|
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
4
5
|
materialize(prod, 2).
|
|
5
6
|
materialize(pow, 2).
|
|
6
7
|
|
|
8
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
9
|
+
% Inputs are explicit so the example does not enumerate an unbounded domain.
|
|
7
10
|
want_prod([3, 0]).
|
|
8
11
|
want_prod([5, 6]).
|
|
9
12
|
want_prod([238, 13]).
|
|
@@ -16,6 +19,8 @@ want_pow([5, 6]).
|
|
|
16
19
|
want_pow([238, 13]).
|
|
17
20
|
want_pow([8367238, 2713]).
|
|
18
21
|
|
|
22
|
+
% The arithmetic itself is delegated to the native numeric built-ins.
|
|
23
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
19
24
|
prod([A, B], C) :-
|
|
20
25
|
want_prod([A, B]),
|
|
21
26
|
mul(A, B, C).
|
|
@@ -3,17 +3,20 @@
|
|
|
3
3
|
% For small oscillations, T = 2*pi*sqrt(length / gravity). Gravity is chosen
|
|
4
4
|
% as pi^2 m/s^2 so a one-meter pendulum has a period of two seconds.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(period_s, 2).
|
|
7
8
|
materialize(periodError_s, 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
|
constant(pi, 3.141592653589793).
|
|
12
14
|
experiment(pendulum1, length_m, 1.0).
|
|
13
15
|
experiment(pendulum1, gravity_m_s2, 9.869604401089358).
|
|
14
16
|
limit(pendulum1, target_period_s, 2.0).
|
|
15
17
|
limit(pendulum1, tolerance_s, 0.01).
|
|
16
18
|
|
|
19
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
17
20
|
period(Experiment, Period) :-
|
|
18
21
|
experiment(Experiment, length_m, Length),
|
|
19
22
|
experiment(Experiment, gravity_m_s2, Gravity),
|
package/examples/polynomial.pl
CHANGED
|
@@ -6,12 +6,14 @@
|
|
|
6
6
|
% searching a finite complex-integer candidate grid. The two cases below are
|
|
7
7
|
% the same quartic polynomials used by the Eyelet source.
|
|
8
8
|
|
|
9
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
9
10
|
materialize(polynomial, 2).
|
|
10
11
|
materialize(root, 2).
|
|
11
12
|
materialize(reconstructedPolynomial, 2).
|
|
12
13
|
materialize(reconstructionMatches, 2).
|
|
13
14
|
materialize(allRootsVerified, 2).
|
|
14
15
|
|
|
16
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
15
17
|
case(real_quartic).
|
|
16
18
|
case(complex_quartic).
|
|
17
19
|
|
|
@@ -32,6 +34,7 @@ known_roots(complex_quartic, [[0, 1], [1, 1], [3, 2], [5, 1]]).
|
|
|
32
34
|
|
|
33
35
|
c_zero([0, 0]).
|
|
34
36
|
|
|
37
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
35
38
|
c_add([A, B], [C, D], [E, F]) :-
|
|
36
39
|
add(A, C, E),
|
|
37
40
|
add(B, D, F).
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
% accumulate, then use aggregate builtins to select useful optima without
|
|
6
6
|
% building and sorting a large bag of candidate portfolios.
|
|
7
7
|
|
|
8
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
8
9
|
materialize(bestPortfolio, 2).
|
|
9
10
|
materialize(lowRiskTarget, 2).
|
|
10
11
|
materialize(feasibleCount, 2).
|
|
@@ -12,6 +13,7 @@ materialize(projectCount, 2).
|
|
|
12
13
|
materialize(totalAvailableValue, 2).
|
|
13
14
|
materialize(note, 2).
|
|
14
15
|
|
|
16
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
15
17
|
budget(portfolio2026, 75).
|
|
16
18
|
riskCap(portfolio2026, 28).
|
|
17
19
|
targetValue(portfolio2026, 125).
|
|
@@ -31,6 +33,7 @@ allProjectData([
|
|
|
31
33
|
p(security, 25, 16, 7)
|
|
32
34
|
]).
|
|
33
35
|
|
|
36
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
34
37
|
project(Name, Value, Cost, Risk) :-
|
|
35
38
|
allProjectData(Projects),
|
|
36
39
|
member(p(Name, Value, Cost, Risk), Projects).
|
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
% The implication itself is represented as data with implies/2. The proof
|
|
4
4
|
% rule remains ordinary eyelang: if A implies B and B is false, then A is false.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(refutes, 2).
|
|
7
8
|
materialize(method, 2).
|
|
8
9
|
materialize(reason, 2).
|
|
9
10
|
|
|
11
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
10
12
|
implies(raining, wet_ground).
|
|
11
13
|
false(wet_ground).
|
|
12
14
|
|
|
15
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
13
16
|
false(A) :-
|
|
14
17
|
implies(A, B),
|
|
15
18
|
false(B).
|
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
% Each equation is represented as a*x^2 + b*x + c = 0. The example uses
|
|
4
4
|
% eyelang arithmetic predicates to derive the discriminant and the two roots.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(discriminant, 2).
|
|
7
8
|
materialize(root, 2).
|
|
8
9
|
|
|
10
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
9
11
|
equation(eq1, 1.0, -5.0, 6.0).
|
|
10
12
|
equation(eq2, 2.0, -4.0, -6.0).
|
|
11
13
|
|
|
14
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
12
15
|
discriminant(Case, D) :-
|
|
13
16
|
equation(Case, A, B, C),
|
|
14
17
|
pow(B, 2.0, B2),
|