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
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
% and its contents remain quoted formula data. Nothing inside the three formulae
|
|
5
5
|
% is asserted globally unless a rule explicitly projects it.
|
|
6
6
|
|
|
7
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
8
|
materialize(log_nameOf, 2).
|
|
8
9
|
materialize(dataGraph, 2).
|
|
9
10
|
materialize(signatureGraph, 2).
|
|
10
11
|
materialize(metadataGraph, 2).
|
|
11
12
|
|
|
13
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
12
14
|
log_nameOf(skolem_g0, foaf_name(bob, "Bob")).
|
|
13
15
|
|
|
14
16
|
log_nameOf(skolem_g1, (
|
|
@@ -36,6 +38,7 @@ log_nameOf(g3, (
|
|
|
36
38
|
|
|
37
39
|
% A tiny projection shows how a program can inspect a quoted context without
|
|
38
40
|
% making the entire context globally true.
|
|
41
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
39
42
|
context_statement(Context, Subject, Predicate, Object) :-
|
|
40
43
|
log_nameOf(Context, Formula),
|
|
41
44
|
formula_binary(Formula, Subject, Predicate, Object).
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
% The example combines measurements, observations, targets, logarithmic
|
|
4
4
|
% feedforward compensation, square-root normalization, and nonlinear feedback.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(controlSignal, 2).
|
|
7
8
|
materialize(status, 2).
|
|
8
9
|
materialize(normalizedMeasurement, 2).
|
|
9
10
|
materialize(log10, 2).
|
|
10
11
|
|
|
12
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
11
13
|
measurement(input1, [6, 11]).
|
|
12
14
|
measurement(disturbance2, [45, 39]).
|
|
13
15
|
measurement(input2, true).
|
|
@@ -21,6 +23,7 @@ observation(state3, 22).
|
|
|
21
23
|
|
|
22
24
|
target(output2, 29).
|
|
23
25
|
|
|
26
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
24
27
|
measurement_normalized(I, M) :-
|
|
25
28
|
measurement(I, [M1, M2]),
|
|
26
29
|
lt(M1, M2),
|
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
% a six-column addition. Each column constraint is applied as soon as possible
|
|
6
6
|
% so the finite digit search prunes early without cut.
|
|
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(assignment, 2).
|
|
10
11
|
materialize(equation, 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
|
send_more_money(solution(S, E, N, D, M, O, R, Y), Send, More, Money) :-
|
|
13
16
|
alphametic_sum(
|
|
14
17
|
[s, e, n, d, m, o, r, y],
|
package/examples/cyclic-path.pl
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
% variant loop guard prevents recursive proof search from revisiting the same
|
|
3
3
|
% active subgoal forever.
|
|
4
4
|
|
|
5
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
5
6
|
materialize(path, 2).
|
|
6
7
|
|
|
8
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
7
9
|
arc(a, b).
|
|
8
10
|
arc(b, c).
|
|
9
11
|
arc(c, d).
|
|
10
12
|
arc(d, a).
|
|
11
13
|
|
|
14
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
12
15
|
path(X, Y) :- arc(X, Y).
|
|
13
16
|
path(X, Z) :- arc(X, Y), path(Y, Z).
|
|
14
|
-
|
package/examples/d3-group.pl
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
% Eyelet-inspired D3 group example using findall/3 and sort/2.
|
|
2
2
|
% It enumerates subgroups of the dihedral group of order 6.
|
|
3
3
|
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
4
5
|
materialize(subgroups, 2).
|
|
5
6
|
materialize(subgroupCount, 2).
|
|
6
7
|
materialize(reason, 2).
|
|
7
8
|
|
|
9
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
10
|
+
% Six symmetries of an equilateral triangle: identity, rotations, reflections.
|
|
8
11
|
symmetry(identity).
|
|
9
12
|
symmetry(rotation_120).
|
|
10
13
|
symmetry(rotation_240).
|
|
@@ -12,6 +15,7 @@ symmetry(reflection_a).
|
|
|
12
15
|
symmetry(reflection_b).
|
|
13
16
|
symmetry(reflection_c).
|
|
14
17
|
|
|
18
|
+
% Cayley table for D3 composition.
|
|
15
19
|
compose(identity, identity, identity).
|
|
16
20
|
compose(identity, rotation_120, rotation_120).
|
|
17
21
|
compose(identity, rotation_240, rotation_240).
|
|
@@ -48,6 +52,7 @@ compose(reflection_c, rotation_240, reflection_a).
|
|
|
48
52
|
compose(reflection_c, reflection_a, rotation_240).
|
|
49
53
|
compose(reflection_c, reflection_b, rotation_120).
|
|
50
54
|
compose(reflection_c, reflection_c, identity).
|
|
55
|
+
% Each candidate subgroup must also contain inverses.
|
|
51
56
|
inverse(identity, identity).
|
|
52
57
|
inverse(rotation_120, rotation_240).
|
|
53
58
|
inverse(rotation_240, rotation_120).
|
|
@@ -55,7 +60,9 @@ inverse(reflection_a, reflection_a).
|
|
|
55
60
|
inverse(reflection_b, reflection_b).
|
|
56
61
|
inverse(reflection_c, reflection_c).
|
|
57
62
|
|
|
63
|
+
% Candidate subsets are generated as subsequences of the sorted symmetry list.
|
|
58
64
|
subsequence([], []).
|
|
65
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
59
66
|
subsequence([Head | Tail], [Head | Rest]) :-
|
|
60
67
|
subsequence(Tail, Rest).
|
|
61
68
|
subsequence([_Head | Tail], Rest) :-
|
|
@@ -65,6 +72,7 @@ all_symmetries(Symmetries) :-
|
|
|
65
72
|
findall(X, symmetry(X), Raw),
|
|
66
73
|
sort(Raw, Symmetries).
|
|
67
74
|
|
|
75
|
+
% A valid subgroup is closed under both composition and inverse.
|
|
68
76
|
closed_under_composition(Group) :-
|
|
69
77
|
not((member(X, Group), member(Y, Group), compose(X, Y, Z), not(member(Z, Group)))).
|
|
70
78
|
|
|
@@ -2,17 +2,20 @@
|
|
|
2
2
|
% Cows are classified from maintenance, milk requirement, and ration supply.
|
|
3
3
|
|
|
4
4
|
% cow(Cow, BodyWeightKg, MilkKgPerDay, RationEnergyMcalPerKgDM, IntakeKgDM).
|
|
5
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
5
6
|
materialize(energyBalance_Mcal, 2).
|
|
6
7
|
materialize(rationSupportedMilk_kg, 2).
|
|
7
8
|
materialize(status, 2).
|
|
8
9
|
materialize(reason, 2).
|
|
9
10
|
materialize(strongestDeficit, 2).
|
|
10
11
|
|
|
12
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
11
13
|
cow(early_lactation, 650, 38, 6.4, 22).
|
|
12
14
|
cow(mid_lactation, 610, 24, 6.5, 26).
|
|
13
15
|
cow(late_lactation, 580, 16, 6.7, 25).
|
|
14
16
|
cow(grazing, 540, 18, 5.8, 21).
|
|
15
17
|
|
|
18
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
16
19
|
maintenance(C, M) :-
|
|
17
20
|
cow(C, Weight, _, _, _),
|
|
18
21
|
mul(Weight, 0.08, M).
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
% Data negotiation with policies, adapted from Eyelet input/data-negotiation.pl.
|
|
2
2
|
% The accepted negotiation matches Eyelet output-swipl/data-negotiation.pl.
|
|
3
3
|
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
4
5
|
materialize(negotiate, 2).
|
|
5
6
|
|
|
7
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
8
|
+
% Each agent has local data, desired remote data, and a simple policy.
|
|
6
9
|
hasData(agent1, [data1, data2, data3]).
|
|
7
10
|
hasData(agent2, [data4, data5, data6]).
|
|
8
11
|
|
|
@@ -10,11 +13,13 @@ want_negotiate(agent1, [agent2, data4]).
|
|
|
10
13
|
want_negotiate(agent1, [agent2, data5]).
|
|
11
14
|
want_negotiate(agent1, [agent2, data7]).
|
|
12
15
|
|
|
16
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
13
17
|
policy(agent1, [request, Data]) :-
|
|
14
18
|
member(Data, [data4, data6]).
|
|
15
19
|
policy(agent2, [accept, Data]) :-
|
|
16
20
|
neq(Data, data5).
|
|
17
21
|
|
|
22
|
+
% A request is possible only if A lacks the data and A's policy allows asking for it.
|
|
18
23
|
request_data(AgentA, AgentB, Data) :-
|
|
19
24
|
hasData(AgentA, DataListA),
|
|
20
25
|
hasData(AgentB, DataListB),
|
|
@@ -22,6 +27,7 @@ request_data(AgentA, AgentB, Data) :-
|
|
|
22
27
|
not_member(Data, DataListA),
|
|
23
28
|
policy(AgentA, [request, Data]).
|
|
24
29
|
|
|
30
|
+
% B accepts only requests for data it has and its own policy permits sharing.
|
|
25
31
|
accept_request(AgentB, _AgentA, Data) :-
|
|
26
32
|
hasData(AgentB, DataListB),
|
|
27
33
|
member(Data, DataListB),
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
% long adjacent-only proof after a shorter checkpoint proof has succeeded.
|
|
9
9
|
% =============================================================================================================================
|
|
10
10
|
|
|
11
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
11
12
|
materialize(is, 2).
|
|
12
13
|
materialize(answer, 2).
|
|
13
14
|
materialize(reason, 2).
|
|
@@ -15,12 +16,14 @@ materialize(result, 2).
|
|
|
15
16
|
materialize(checkPassed, 2).
|
|
16
17
|
materialize(arc, 2).
|
|
17
18
|
|
|
19
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
18
20
|
% fact
|
|
19
21
|
|
|
20
22
|
a(ind, n0).
|
|
21
23
|
|
|
22
24
|
% terminal rule
|
|
23
25
|
|
|
26
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
24
27
|
is(test, true) :- once(a(ind, a2)).
|
|
25
28
|
a(X, a2) :- a(X, n10).
|
|
26
29
|
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
% long adjacent-only proof after a shorter checkpoint proof has succeeded.
|
|
9
9
|
% =============================================================================================================================
|
|
10
10
|
|
|
11
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
11
12
|
materialize(is, 2).
|
|
12
13
|
materialize(answer, 2).
|
|
13
14
|
materialize(reason, 2).
|
|
@@ -15,12 +16,14 @@ materialize(result, 2).
|
|
|
15
16
|
materialize(checkPassed, 2).
|
|
16
17
|
materialize(arc, 2).
|
|
17
18
|
|
|
19
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
18
20
|
% fact
|
|
19
21
|
|
|
20
22
|
a(ind, n0).
|
|
21
23
|
|
|
22
24
|
% terminal rule
|
|
23
25
|
|
|
26
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
24
27
|
is(test, true) :- once(a(ind, a2)).
|
|
25
28
|
a(X, a2) :- a(X, n100).
|
|
26
29
|
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
% long adjacent-only proof after a shorter checkpoint proof has succeeded.
|
|
9
9
|
% =============================================================================================================================
|
|
10
10
|
|
|
11
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
11
12
|
materialize(is, 2).
|
|
12
13
|
materialize(answer, 2).
|
|
13
14
|
materialize(reason, 2).
|
|
@@ -15,12 +16,14 @@ materialize(result, 2).
|
|
|
15
16
|
materialize(checkPassed, 2).
|
|
16
17
|
materialize(arc, 2).
|
|
17
18
|
|
|
19
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
18
20
|
% fact
|
|
19
21
|
|
|
20
22
|
a(ind, n0).
|
|
21
23
|
|
|
22
24
|
% terminal rule
|
|
23
25
|
|
|
26
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
24
27
|
is(test, true) :- once(a(ind, a2)).
|
|
25
28
|
a(X, a2) :- a(X, n1000).
|
|
26
29
|
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
% long adjacent-only proof after a shorter checkpoint proof has succeeded.
|
|
9
9
|
% =============================================================================================================================
|
|
10
10
|
|
|
11
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
11
12
|
materialize(is, 2).
|
|
12
13
|
materialize(answer, 2).
|
|
13
14
|
materialize(reason, 2).
|
|
@@ -15,12 +16,14 @@ materialize(result, 2).
|
|
|
15
16
|
materialize(checkPassed, 2).
|
|
16
17
|
materialize(arc, 2).
|
|
17
18
|
|
|
19
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
18
20
|
% fact
|
|
19
21
|
|
|
20
22
|
a(ind, n0).
|
|
21
23
|
|
|
22
24
|
% terminal rule
|
|
23
25
|
|
|
26
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
24
27
|
is(test, true) :- once(a(ind, a2)).
|
|
25
28
|
a(X, a2) :- a(X, n10000).
|
|
26
29
|
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
% long adjacent-only proof after a shorter checkpoint proof has succeeded.
|
|
9
9
|
% =============================================================================================================================
|
|
10
10
|
|
|
11
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
11
12
|
materialize(is, 2).
|
|
12
13
|
materialize(answer, 2).
|
|
13
14
|
materialize(reason, 2).
|
|
@@ -15,12 +16,14 @@ materialize(result, 2).
|
|
|
15
16
|
materialize(checkPassed, 2).
|
|
16
17
|
materialize(arc, 2).
|
|
17
18
|
|
|
19
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
18
20
|
% fact
|
|
19
21
|
|
|
20
22
|
a(ind, n0).
|
|
21
23
|
|
|
22
24
|
% terminal rule
|
|
23
25
|
|
|
26
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
24
27
|
is(test, true) :- once(a(ind, a2)).
|
|
25
28
|
a(X, a2) :- a(X, n100000).
|
|
26
29
|
|
package/examples/delfour.pl
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
% Rules project only the fields they need, avoiding global permission/prohibition
|
|
9
9
|
% facts that could contradict another policy formula in the same program.
|
|
10
10
|
|
|
11
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
11
12
|
materialize(caseName, 2).
|
|
12
13
|
materialize(needsLowSugar, 2).
|
|
13
14
|
materialize(derivedFromNeed, 2).
|
|
@@ -39,6 +40,8 @@ materialize(dutyTimingConsistent, 2).
|
|
|
39
40
|
materialize(marketingProhibited, 2).
|
|
40
41
|
materialize(filesWrittenExpected, 2).
|
|
41
42
|
|
|
43
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
44
|
+
% Formula-valued facts keep each input graph scoped and easy to project.
|
|
42
45
|
case_graph(delfourCaseGraph, (
|
|
43
46
|
caseName(case, "delfour"),
|
|
44
47
|
requestPurpose(case, "shopping_assist"),
|
|
@@ -53,6 +56,7 @@ case_graph(delfourCaseGraph, (
|
|
|
53
56
|
scannedProduct(scan, prod_BIS_001)
|
|
54
57
|
)).
|
|
55
58
|
|
|
59
|
+
% Catalog rows are product(IdTerm, DisplayId, Name, SugarTenths, SugarG).
|
|
56
60
|
product_catalog(delfourCatalog, [
|
|
57
61
|
product(prod_BIS_001, "prod_BIS_001", "Classic Tea Biscuits", 120, 12.0),
|
|
58
62
|
product(prod_BIS_101, "prod_BIS_101", "Low-Sugar Tea Biscuits", 30, 3.0),
|
|
@@ -97,6 +101,7 @@ signature_graph(delfourSignatureGraph, (
|
|
|
97
101
|
|
|
98
102
|
reason_text(reasonText, "Household requires low-sugar guidance (diabetes in POD). A neutral Insight is scoped to device 'self-scanner', event 'pick_up_scanner', retailer 'Delfour', and expires soon; the policy confines use to shopping assistance.").
|
|
99
103
|
|
|
104
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
100
105
|
case_statement(S, P, O) :- case_graph(delfourCaseGraph, Formula), formula_binary(Formula, S, P, O).
|
|
101
106
|
insight_statement(S, P, O) :- insight_graph(delfourInsightGraph, Formula), formula_binary(Formula, S, P, O).
|
|
102
107
|
policy_statement(S, P, O) :- policy_graph(delfourPolicyGraph, Formula), formula_binary(Formula, S, P, O).
|
|
@@ -149,6 +154,7 @@ payload_hash_sha256(signature, Hash) :- signature_statement(signature, payloadHa
|
|
|
149
154
|
signature_hmac(signature, Hmac) :- signature_statement(signature, hmac, Hmac).
|
|
150
155
|
hmac_verification_mode(signature, Mode) :- signature_statement(signature, hmacVerificationMode, Mode).
|
|
151
156
|
|
|
157
|
+
% The household profile creates the low-sugar need used by the insight.
|
|
152
158
|
needs_low_sugar(case) :-
|
|
153
159
|
condition(householdProfile, "Diabetes").
|
|
154
160
|
|
|
@@ -200,6 +206,7 @@ better_lower_sugar(ScannedSugar, CandidateSugar) :-
|
|
|
200
206
|
gt(ScannedSugar, OtherSugar),
|
|
201
207
|
lt(OtherSugar, CandidateSugar).
|
|
202
208
|
|
|
209
|
+
% Pick the lowest-sugar alternative according to the insight suggestion policy.
|
|
203
210
|
suggested_alternative(case, Candidate) :-
|
|
204
211
|
scanned_product(scan, Scanned),
|
|
205
212
|
sugar_tenths(Scanned, ScannedSugar),
|
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
% scores the closed cycles, and keeps the cheapest candidate with
|
|
6
6
|
% aggregate_min/5.
|
|
7
7
|
|
|
8
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
8
9
|
materialize(best, 2).
|
|
9
10
|
materialize(candidateCount, 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
|
cities([a, b, c, d, e, f, g, h]).
|
|
14
16
|
|
|
15
17
|
edge(a, b, 3).
|
|
@@ -41,6 +43,7 @@ edge(f, g, 8).
|
|
|
41
43
|
edge(f, h, 45).
|
|
42
44
|
edge(g, h, 9).
|
|
43
45
|
|
|
46
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
44
47
|
weight(A, B, W) :- edge(A, B, W).
|
|
45
48
|
weight(A, B, W) :- edge(B, A, W).
|
|
46
49
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
% Deontic logic: obligations, prohibitions, compensations, and violations.
|
|
2
2
|
|
|
3
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
3
4
|
materialize(violation, 2).
|
|
4
5
|
materialize(compensation, 2).
|
|
5
6
|
materialize(status, 2).
|
|
6
7
|
|
|
8
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
9
|
+
% Facts state what the actor was obliged/prohibited to do and what happened.
|
|
7
10
|
actor(alice).
|
|
8
11
|
action(share_record).
|
|
9
12
|
action(delete_unneeded_copy).
|
|
@@ -17,6 +20,8 @@ performed(alice, notify_dpo).
|
|
|
17
20
|
not_performed(alice, obtain_consent).
|
|
18
21
|
not_performed(alice, delete_unneeded_copy).
|
|
19
22
|
|
|
23
|
+
% Missing an obligation and performing a prohibited action are both violations.
|
|
24
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
20
25
|
violation(Actor, missed_obligation(Action)) :-
|
|
21
26
|
obliged(Actor, Action),
|
|
22
27
|
not_performed(Actor, Action).
|
|
@@ -25,6 +30,7 @@ violation(Actor, prohibited_action(Action)) :-
|
|
|
25
30
|
prohibited(Actor, Action),
|
|
26
31
|
performed(Actor, Action).
|
|
27
32
|
|
|
33
|
+
% Some prohibited actions can be repaired by a configured compensation action.
|
|
28
34
|
compensated_violation(Actor, Action, Compensation) :-
|
|
29
35
|
prohibited(Actor, Action),
|
|
30
36
|
performed(Actor, Action),
|
|
@@ -10,13 +10,16 @@
|
|
|
10
10
|
% log_impliedBy/2, then mirrored as an ordinary eyelang rule so the generated
|
|
11
11
|
% childOf relation can feed the ordinary hasParent rule.
|
|
12
12
|
|
|
13
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
13
14
|
materialize(log_impliedBy, 2).
|
|
14
15
|
materialize(childOf, 2).
|
|
15
16
|
materialize(hasParent, 2).
|
|
16
17
|
|
|
18
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
17
19
|
invOf(parentOf, childOf).
|
|
18
20
|
parentOf(alice, bob).
|
|
19
21
|
|
|
22
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
20
23
|
log_impliedBy(childOf(var(x), var(y)), parentOf(var(y), var(x))) :-
|
|
21
24
|
invOf(parentOf, childOf).
|
|
22
25
|
|
package/examples/derived-rule.pl
CHANGED
|
@@ -9,13 +9,16 @@
|
|
|
9
9
|
% var(y) is not an eyelang variable; it is a ground term that names
|
|
10
10
|
% a variable placeholder inside the quoted formula.
|
|
11
11
|
|
|
12
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
12
13
|
materialize(type, 2).
|
|
13
14
|
materialize(log_implies, 2).
|
|
14
15
|
materialize(is, 2).
|
|
15
16
|
|
|
17
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
16
18
|
type(minka, cat).
|
|
17
19
|
type(charly, dog).
|
|
18
20
|
|
|
21
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
19
22
|
log_implies(type(var(y), dog), is(test, true)) :-
|
|
20
23
|
type(_X, cat).
|
|
21
24
|
|
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
% source can be joined again. This compact eyelang version keeps the same
|
|
5
5
|
% diamond idea and also checks that it is preserved by reflexive closure.
|
|
6
6
|
|
|
7
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
8
|
materialize(holdsFor, 2).
|
|
8
9
|
materialize(commonSuccessor, 2).
|
|
9
10
|
materialize(preservedUnderReflexiveClosure, 2).
|
|
10
11
|
|
|
12
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
11
13
|
node(a).
|
|
12
14
|
node(b).
|
|
13
15
|
node(c).
|
|
@@ -18,6 +20,7 @@ r(a, c).
|
|
|
18
20
|
r(b, d).
|
|
19
21
|
r(c, d).
|
|
20
22
|
|
|
23
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
21
24
|
re(X, X) :- node(X).
|
|
22
25
|
re(X, Y) :- r(X, Y).
|
|
23
26
|
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
% Eyelet-inspired Dijkstra example using findall/3 and sort/2.
|
|
2
2
|
% Adapted to eyelang's explicit built-ins and relation report style.
|
|
3
3
|
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
4
5
|
materialize(shortestPath, 2).
|
|
5
6
|
materialize(cost, 2).
|
|
6
7
|
materialize(reason, 2).
|
|
7
8
|
|
|
9
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
10
|
+
% Weighted undirected graph; the symmetric edge rule below adds reverse arcs.
|
|
8
11
|
edge(a, b, 4).
|
|
9
12
|
edge(a, c, 2).
|
|
10
13
|
edge(b, c, 1).
|
|
@@ -14,14 +17,17 @@ edge(c, e, 10).
|
|
|
14
17
|
edge(d, e, 2).
|
|
15
18
|
edge(d, f, 6).
|
|
16
19
|
edge(e, f, 3).
|
|
20
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
17
21
|
edge(A, B, Cost) :- edge(B, A, Cost).
|
|
18
22
|
|
|
23
|
+
% The frontier is represented as [Cost, Node | ReversePath] entries.
|
|
19
24
|
dijkstra(Start, Goal, Path, Cost) :-
|
|
20
25
|
dijkstra_queue([[0, Start]], Goal, [], RevPath, Cost),
|
|
21
26
|
reverse(RevPath, Path).
|
|
22
27
|
|
|
23
28
|
dijkstra_queue([[Cost, Goal | Path] | _Queue], Goal, _Visited, [Goal | Path], Cost).
|
|
24
29
|
dijkstra_queue([[Cost, Node | Path] | Queue], Goal, Visited, ResultPath, ResultCost) :-
|
|
30
|
+
% Expand all unvisited neighbors, then sort so the cheapest frontier wins.
|
|
25
31
|
findall([NewCost, Neighbor, Node | Path],
|
|
26
32
|
(edge(Node, Neighbor, Weight), not(member(Neighbor, Visited)), add(Cost, Weight, NewCost)),
|
|
27
33
|
Neighbors),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
% Memoize route costs: selected paths, route relations, and trust checks reuse
|
|
2
2
|
% the same path-list reductions.
|
|
3
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
3
4
|
materialize(route, 2).
|
|
4
5
|
materialize(rawCost, 2).
|
|
5
6
|
materialize(riskSum, 2).
|
|
@@ -10,6 +11,7 @@ materialize(trustGate, 2).
|
|
|
10
11
|
materialize(notes, 2).
|
|
11
12
|
materialize(selects, 2).
|
|
12
13
|
|
|
14
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
13
15
|
memoize(route_cost, 4).
|
|
14
16
|
|
|
15
17
|
% Risk-adjusted route selection adapted from Eyeling dijkstra-risk-path.n3.
|
|
@@ -28,6 +30,7 @@ route_network(riskNetwork, (
|
|
|
28
30
|
segment(depotA, segment(labD, 14.0, 0.05))
|
|
29
31
|
)).
|
|
30
32
|
|
|
33
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
31
34
|
route_segment(From, To, Raw, Risk) :-
|
|
32
35
|
route_network(riskNetwork, Formula),
|
|
33
36
|
formula_binary(Formula, From, segment, segment(To, Raw, Risk)).
|
package/examples/dijkstra.pl
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
% The input weighted graph is quoted as ... data and projected locally,
|
|
6
6
|
% so the route network is not asserted as ambient edge facts.
|
|
7
7
|
|
|
8
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
8
9
|
materialize(edge, 2).
|
|
9
10
|
materialize(path, 2).
|
|
10
11
|
|
|
12
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
11
13
|
weighted_graph(dijkstraGraph, (
|
|
12
14
|
edge(a, arc(b, 4)),
|
|
13
15
|
edge(a, arc(c, 2)),
|
|
@@ -20,6 +22,7 @@ weighted_graph(dijkstraGraph, (
|
|
|
20
22
|
edge(e, arc(f, 3))
|
|
21
23
|
)).
|
|
22
24
|
|
|
25
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
23
26
|
base_link(A, B, Cost) :-
|
|
24
27
|
weighted_graph(dijkstraGraph, Formula),
|
|
25
28
|
formula_binary(Formula, A, edge, arc(B, Cost)).
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
% Chandy-Misra dining philosophers trace adapted from Eyeling dining-philosophers.n3.
|
|
2
2
|
% Requests and sends are derived; KeepFork facts copy forks that are not sent.
|
|
3
3
|
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
4
5
|
materialize(dp_type, 2).
|
|
5
6
|
materialize(dp_in, 2).
|
|
6
7
|
materialize(dp_from, 2).
|
|
@@ -11,6 +12,7 @@ materialize(dp_mealNo, 2).
|
|
|
11
12
|
materialize(dp_inSlot, 2).
|
|
12
13
|
materialize(dp_usesFork, 2).
|
|
13
14
|
|
|
15
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
14
16
|
left_fork(dp_P1, dp_F51). right_fork(dp_P1, dp_F12).
|
|
15
17
|
left_fork(dp_P2, dp_F12). right_fork(dp_P2, dp_F23).
|
|
16
18
|
left_fork(dp_P3, dp_F23). right_fork(dp_P3, dp_F34).
|
|
@@ -98,6 +100,7 @@ meal_handle(dp_P3, 1, dp_mP3_1). meal_handle(dp_P3, 2, dp_mP3_2). meal_handle(dp
|
|
|
98
100
|
meal_handle(dp_P4, 1, dp_mP4_1). meal_handle(dp_P4, 2, dp_mP4_2). meal_handle(dp_P4, 3, dp_mP4_3).
|
|
99
101
|
meal_handle(dp_P5, 1, dp_mP5_1). meal_handle(dp_P5, 2, dp_mP5_2). meal_handle(dp_P5, 3, dp_mP5_3).
|
|
100
102
|
|
|
103
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
101
104
|
request(C, P, Q, F) :-
|
|
102
105
|
hungry(C, P), left_fork(P, F), start_state(C, F, Q, _Cleanliness), neq(Q, P).
|
|
103
106
|
request(C, P, Q, F) :-
|
package/examples/dog.pl
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
% The output reports only the compliance obligation derived below.
|
|
2
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
1
3
|
materialize(mustHave, 2).
|
|
2
4
|
|
|
5
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
3
6
|
% Dog-license example adapted from Eyeling dog.n3.
|
|
4
7
|
% A subject with more than four dogs must have a dog license.
|
|
5
8
|
|
|
@@ -11,6 +14,8 @@ hasDog(alice, dog5).
|
|
|
11
14
|
hasDog(bob, dog6).
|
|
12
15
|
hasDog(bob, dog7).
|
|
13
16
|
|
|
17
|
+
% countall/2 counts all matching dogs for the same subject.
|
|
18
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
14
19
|
dogCount(Subject, Count) :-
|
|
15
20
|
hasDog(Subject, _Any),
|
|
16
21
|
countall(hasDog(Subject, _Dog), Count).
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
% Memoize bounded paths because surviving-plan metrics reuse route prefixes.
|
|
2
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
2
3
|
materialize(gps_plan, 2).
|
|
3
4
|
|
|
5
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
4
6
|
memoize(path, 9).
|
|
5
7
|
|
|
6
8
|
% Bounded drone corridor planner adapted from Eyeling drone-corridor-planner.n3.
|
|
@@ -24,6 +26,7 @@ step(state(brugge, mid, P), state(oostende, low, P), public_coastline_brugge_oos
|
|
|
24
26
|
step(state(brugge, full, P), state(oostende, mid, P), public_coastline_brugge_oostende, 1200.0, 0.006, 0.975, 0.96).
|
|
25
27
|
step(state(kortrijk, full, yes), state(oostende, mid, yes), direct_corridor_kortrijk_oostende, 1100.0, 0.009, 0.955, 0.92).
|
|
26
28
|
|
|
29
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
27
30
|
path(From, To, [Act], Duration, Cost, Belief, Comfort, FuelIn, FuelOut) :-
|
|
28
31
|
step(From, To, Act, Duration, Cost, Belief, Comfort),
|
|
29
32
|
rest(FuelIn, FuelOut).
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
% Adapted from Eyeling's easter.n3.
|
|
2
2
|
% Gregorian computus for a sample decade, with independent range/window checks.
|
|
3
3
|
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
4
5
|
materialize(easterDate, 2).
|
|
5
6
|
materialize(computusRemainders, 2).
|
|
6
7
|
materialize(legalGregorianWindow, 2).
|
|
7
8
|
|
|
9
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
10
|
+
% Sample years for which the computed Easter date is materialized.
|
|
8
11
|
case(y2026, 2026).
|
|
9
12
|
case(y2027, 2027).
|
|
10
13
|
case(y2028, 2028).
|
|
@@ -16,6 +19,8 @@ case(y2033, 2033).
|
|
|
16
19
|
case(y2034, 2034).
|
|
17
20
|
case(y2035, 2035).
|
|
18
21
|
|
|
22
|
+
% These checks document the legal ranges of intermediate computus values.
|
|
23
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
19
24
|
valid_golden(N) :- between(0, 18, N).
|
|
20
25
|
valid_epact(N) :- between(0, 29, N).
|
|
21
26
|
valid_weekday(N) :- between(0, 6, N).
|
|
@@ -24,6 +29,7 @@ legal_easter_date(4, D) :- between(1, 25, D).
|
|
|
24
29
|
month_name(3, march).
|
|
25
30
|
month_name(4, april).
|
|
26
31
|
|
|
32
|
+
% Butcher/Meeus-style integer arithmetic, kept explicit for proof readability.
|
|
27
33
|
computus(Case, Year, Month, Day, J, K, Q, R, V, Z) :-
|
|
28
34
|
case(Case, Year),
|
|
29
35
|
mod(Year, 19, J),
|
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
%
|
|
3
3
|
% The cutoff frequency is 1 / (2*pi*R*C).
|
|
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(timeConstant_s, 2).
|
|
7
8
|
materialize(cutoffFrequency_Hz, 2).
|
|
8
9
|
|
|
10
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
9
11
|
component(filter1, resistor_ohm, 10000.0).
|
|
10
12
|
component(filter1, capacitor_f, 0.000001).
|
|
11
13
|
constant(pi, 3.141592653589793).
|
|
12
14
|
|
|
15
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
13
16
|
time_constant(Filter, Tau) :-
|
|
14
17
|
component(Filter, resistor_ohm, R),
|
|
15
18
|
component(Filter, capacitor_f, C),
|