eyelang 1.5.2 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/examples/access-control-policy.pl +3 -0
- package/examples/ackermann.pl +3 -0
- package/examples/age.pl +3 -0
- package/examples/aliases-and-namespaces.pl +7 -0
- package/examples/alignment-demo.pl +3 -0
- package/examples/allen-interval-calculus.pl +3 -0
- package/examples/ancestor.pl +7 -0
- package/examples/animal.pl +3 -0
- package/examples/annotation.pl +3 -0
- package/examples/auroracare.pl +309 -0
- package/examples/backward.pl +3 -0
- package/examples/basic-monadic.pl +3 -1
- package/examples/bayes-diagnosis.pl +3 -0
- package/examples/bayes-therapy.pl +3 -0
- package/examples/beam-deflection.pl +3 -0
- package/examples/blocks-world-planning.pl +3 -0
- package/examples/bmi.pl +3 -0
- package/examples/braking-safety-worlds.pl +3 -0
- package/examples/buck-converter-design.pl +3 -0
- package/examples/cache-performance.pl +3 -0
- package/examples/canary-release.pl +3 -0
- package/examples/cat-koko.pl +3 -0
- package/examples/clinical-trial-screening.pl +3 -0
- package/examples/collatz-1000.pl +3 -0
- package/examples/combinatorics-findall-sort.pl +6 -0
- package/examples/competitive-enzyme-kinetics.pl +3 -0
- package/examples/complex-matrix-stability.pl +3 -0
- package/examples/complex.pl +3 -0
- package/examples/composition-of-injective-functions-is-injective.pl +3 -0
- package/examples/context-association.pl +3 -0
- package/examples/control-system.pl +3 -0
- package/examples/cryptarithmetic-send-more-money.pl +3 -0
- package/examples/cyclic-path.pl +3 -1
- package/examples/d3-group.pl +8 -0
- package/examples/dairy-energy-balance.pl +3 -0
- package/examples/data-negotiation.pl +6 -0
- package/examples/deep-taxonomy-10.pl +3 -0
- package/examples/deep-taxonomy-100.pl +3 -0
- package/examples/deep-taxonomy-1000.pl +3 -0
- package/examples/deep-taxonomy-10000.pl +3 -0
- package/examples/deep-taxonomy-100000.pl +3 -0
- package/examples/delfour.pl +18 -1
- package/examples/dense-hamiltonian-cycle.pl +3 -0
- package/examples/deontic-logic.pl +6 -0
- package/examples/derived-backward-rule.pl +3 -0
- package/examples/derived-rule.pl +3 -0
- package/examples/diamond-property.pl +3 -0
- package/examples/dijkstra-findall-sort.pl +6 -0
- package/examples/dijkstra-risk-path.pl +3 -0
- package/examples/dijkstra.pl +3 -0
- package/examples/dining-philosophers.pl +3 -0
- package/examples/dog.pl +5 -0
- package/examples/drone-corridor-planner.pl +3 -0
- package/examples/easter-computus.pl +6 -0
- package/examples/electrical-rc-filter.pl +3 -0
- package/examples/epidemic-policy.pl +6 -0
- package/examples/equivalence-classes-overlap-implies-same-class.pl +3 -0
- package/examples/eulerian-path.pl +6 -0
- package/examples/ev-range-worlds.pl +3 -0
- package/examples/exact-cover-sudoku.pl +3 -0
- package/examples/existential-rule.pl +3 -0
- package/examples/exoplanet-validation-worlds.pl +3 -0
- package/examples/expression-eval.pl +5 -0
- package/examples/family-cousins.pl +3 -0
- package/examples/fastpow.pl +5 -0
- package/examples/fft8-numeric.pl +6 -0
- package/examples/fibonacci.pl +3 -0
- package/examples/field-nitrogen-balance.pl +3 -0
- package/examples/flandor.pl +296 -0
- package/examples/floating-point.pl +5 -0
- package/examples/four-color-map.pl +3 -0
- package/examples/fundamental-theorem-arithmetic.pl +3 -0
- package/examples/gcd-bezout-identity.pl +3 -0
- package/examples/gd-step-certified.pl +3 -0
- package/examples/gdpr-compliance.pl +6 -0
- package/examples/goldbach-1000.pl +3 -0
- package/examples/good-cobbler.pl +3 -0
- package/examples/gps.pl +3 -0
- package/examples/graph-reachability.pl +3 -0
- package/examples/gray-code-counter.pl +6 -0
- package/examples/greatest-lower-bound-uniqueness.pl +3 -0
- package/examples/group-inverse-uniqueness.pl +3 -0
- package/examples/hamiltonian-cycle.pl +3 -0
- package/examples/hamiltonian-path.pl +3 -0
- package/examples/hamming-code.pl +3 -0
- package/examples/hanoi.pl +3 -0
- package/examples/heat-loss.pl +3 -0
- package/examples/heron-theorem.pl +5 -0
- package/examples/ideal-gas-law.pl +3 -0
- package/examples/illegitimate-reasoning.pl +3 -0
- package/examples/kaprekar.pl +3 -0
- package/examples/law-of-cosines.pl +5 -0
- package/examples/least-squares-regression.pl +3 -0
- package/examples/list-collection.pl +5 -0
- package/examples/lldm.pl +3 -0
- package/examples/manufacturing-quality-control.pl +3 -0
- package/examples/matrix.pl +3 -0
- package/examples/microgrid-dispatch.pl +3 -0
- package/examples/monkey-bananas.pl +3 -0
- package/examples/n-queens.pl +3 -0
- package/examples/network-sla.pl +3 -0
- package/examples/newton-raphson.pl +3 -0
- package/examples/nixon-diamond.pl +3 -0
- package/examples/odrl-dpv-healthcare-risk-ranked.pl +3 -0
- package/examples/odrl-dpv-risk-ranked.pl +3 -0
- package/examples/orbital-transfer-design.pl +3 -0
- package/examples/output/auroracare.pl +117 -0
- package/examples/output/delfour.pl +7 -1
- package/examples/output/flandor.pl +43 -0
- package/examples/path-discovery.pl +3 -0
- package/examples/peano-arithmetic.pl +3 -0
- package/examples/peasant.pl +5 -0
- package/examples/pendulum-period.pl +3 -0
- package/examples/polynomial.pl +3 -0
- package/examples/project-portfolio-optimization.pl +3 -0
- package/examples/proof-contrapositive.pl +3 -0
- package/examples/quadratic-formula.pl +3 -0
- package/examples/quine-mccluskey.pl +3 -0
- package/examples/radioactive-decay.pl +3 -0
- package/examples/sat-dpll.pl +3 -0
- package/examples/security-incident-correlation.pl +3 -0
- package/examples/service-impact.pl +3 -0
- package/examples/sieve.pl +3 -0
- package/examples/skolem-functions.pl +3 -0
- package/examples/socket-age.pl +3 -0
- package/examples/socket-family.pl +3 -0
- package/examples/socrates.pl +3 -0
- package/examples/statistics-summary.pl +3 -0
- package/examples/sudoku.pl +3 -0
- package/examples/superdense-coding.pl +3 -0
- package/examples/traveling-salesman.pl +6 -0
- package/examples/turing.pl +3 -0
- package/examples/vector-similarity.pl +6 -0
- package/examples/witch.pl +3 -0
- package/examples/wolf-goat-cabbage.pl +3 -0
- package/examples/zebra.pl +3 -0
- package/package.json +1 -1
- package/playground.html +2 -0
package/examples/bmi.pl
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
% For reproducibility and documentation only; not medical advice.
|
|
8
8
|
|
|
9
9
|
% Editable metric input.
|
|
10
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
10
11
|
materialize(unitSystem, 2).
|
|
11
12
|
materialize(weight, 2).
|
|
12
13
|
materialize(height, 2).
|
|
@@ -39,6 +40,7 @@ materialize(result, 2).
|
|
|
39
40
|
materialize(healthyWeightRangeKg, 2).
|
|
40
41
|
materialize(checkPassed, 2).
|
|
41
42
|
|
|
43
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
42
44
|
unitSystem(input, metric).
|
|
43
45
|
weight(input, 72.0).
|
|
44
46
|
height(input, 178.0).
|
|
@@ -49,6 +51,7 @@ height(input, 178.0).
|
|
|
49
51
|
% height(input, 70.08).
|
|
50
52
|
|
|
51
53
|
% Normalization and BMI calculation.
|
|
54
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
52
55
|
weightKg(case, W) :-
|
|
53
56
|
unitSystem(input, metric),
|
|
54
57
|
weight(input, W).
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
% Four simplified models classify the same road scenarios. The example is not a
|
|
4
4
|
% real safety calculator; it demonstrates rule-level model comparison.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(safeInWorld, 2).
|
|
7
8
|
materialize(riskyInWorld, 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
|
scenario(city_dry, 13.9, 0.8, 40.0).
|
|
12
14
|
scenario(highway_dry_short_gap, 27.8, 0.8, 60.0).
|
|
13
15
|
scenario(city_wet, 13.9, 0.4, 40.0).
|
|
@@ -18,6 +20,7 @@ world(w1, "simplified braking-only rule without reaction time").
|
|
|
18
20
|
world(w2, "naive dry-road friction assumption").
|
|
19
21
|
world(w3, "cautious factor over the physics model").
|
|
20
22
|
|
|
23
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
21
24
|
stop_distance(Scenario, w0, Distance) :-
|
|
22
25
|
scenario(Scenario, V, Mu, Avail),
|
|
23
26
|
mul(V, 1.0, Reaction),
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
% A simplified continuous-conduction buck converter model computes duty cycle,
|
|
4
4
|
% inductor ripple current, capacitor ripple voltage, and checks design limits.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(dutyCycle, 2).
|
|
7
8
|
materialize(inductorRipple_A, 2).
|
|
8
9
|
materialize(rippleRatio, 2).
|
|
@@ -10,6 +11,7 @@ materialize(capacitorRipple_V, 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
|
converter(regulator1, inputVoltage_V, 24.0).
|
|
14
16
|
converter(regulator1, outputVoltage_V, 5.0).
|
|
15
17
|
converter(regulator1, loadCurrent_A, 2.0).
|
|
@@ -19,6 +21,7 @@ converter(regulator1, capacitance_F, 0.000047).
|
|
|
19
21
|
limit(regulator1, maxRippleRatio, 0.30).
|
|
20
22
|
limit(regulator1, maxOutputRipple_V, 0.05).
|
|
21
23
|
|
|
24
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
22
25
|
duty_cycle(Converter, Duty) :-
|
|
23
26
|
converter(Converter, outputVoltage_V, OutputVoltage),
|
|
24
27
|
converter(Converter, inputVoltage_V, InputVoltage),
|
|
@@ -4,15 +4,18 @@
|
|
|
4
4
|
% rules compute hit rate and weighted average latency, then classify whether
|
|
5
5
|
% the cache is effective.
|
|
6
6
|
|
|
7
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
8
|
materialize(hitRate, 2).
|
|
8
9
|
materialize(averageLatency_ms, 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
|
cache_sample(api_cache, 8600.0, 1400.0, 5.0, 80.0).
|
|
13
15
|
threshold(api_cache, minimum_hit_rate, 0.80).
|
|
14
16
|
threshold(api_cache, maximum_average_latency_ms, 20.0).
|
|
15
17
|
|
|
18
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
16
19
|
total_requests(Cache, Total) :-
|
|
17
20
|
cache_sample(Cache, Hits, Misses, _HitLatency, _MissLatency),
|
|
18
21
|
add(Hits, Misses, Total).
|
|
@@ -3,16 +3,19 @@
|
|
|
3
3
|
% A canary deployment is rolled back when its measured error rate exceeds the
|
|
4
4
|
% allowed budget, even when latency is still acceptable.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(errorRate, 2).
|
|
7
8
|
materialize(p95Latency_ms, 2).
|
|
8
9
|
materialize(latencyCheck, 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
|
canary(canary42, 5000.0, 75.0, 180.0).
|
|
13
15
|
threshold(canary42, maximum_error_rate, 0.01).
|
|
14
16
|
threshold(canary42, maximum_p95_latency_ms, 200.0).
|
|
15
17
|
|
|
18
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
16
19
|
error_rate(Release, Rate) :-
|
|
17
20
|
canary(Release, Requests, Errors, _P95Latency),
|
|
18
21
|
div(Errors, Requests, Rate).
|
package/examples/cat-koko.pl
CHANGED
|
@@ -4,14 +4,17 @@
|
|
|
4
4
|
% node constructor in the portable core, so this adaptation names those
|
|
5
5
|
% witnesses sk_0 and sk_1.
|
|
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(is, 2).
|
|
9
10
|
|
|
11
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
10
12
|
animal(koko).
|
|
11
13
|
|
|
12
14
|
witness(cat, sk_0).
|
|
13
15
|
witness(british_short_hair, sk_1).
|
|
14
16
|
|
|
17
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
15
18
|
type(X, cat) :- animal(koko), witness(cat, X).
|
|
16
19
|
type(X, british_short_hair) :- animal(koko), witness(british_short_hair, X).
|
|
17
20
|
|
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
% predicates keep the inclusion/exclusion logic separate from the concise
|
|
5
5
|
% public relation report.
|
|
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(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
|
patient(p001).
|
|
12
14
|
patient(p002).
|
|
13
15
|
patient(p003).
|
|
@@ -35,6 +37,7 @@ lab(p004, egfr_ml_min, 72.0).
|
|
|
35
37
|
|
|
36
38
|
condition(p003, pregnant).
|
|
37
39
|
|
|
40
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
38
41
|
inclusion_adult(Patient) :-
|
|
39
42
|
patient(Patient),
|
|
40
43
|
age(Patient, Age),
|
package/examples/collatz-1000.pl
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
% Memoize trajectories because different start values quickly merge into
|
|
2
2
|
% shared Collatz tails.
|
|
3
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
3
4
|
materialize(collatzTrajectory, 2).
|
|
4
5
|
|
|
6
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
5
7
|
% Collatz trajectory benchmark adapted from Eyeling collatz-1000.n3.
|
|
6
8
|
% The reusable builtin keeps this large output example focused on data volume
|
|
7
9
|
% rather than recursive integer arithmetic overhead.
|
|
8
10
|
|
|
11
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
9
12
|
collatzTrajectory(N, Trajectory) :-
|
|
10
13
|
between(1, 1000, N),
|
|
11
14
|
collatz_trajectory(N, Trajectory).
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
% Eyelet-inspired combinations example using findall/3 and sort/2.
|
|
2
2
|
% The source-level select/3 relation remains an ordinary eyelang rule.
|
|
3
3
|
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
4
5
|
materialize(combinations, 2).
|
|
5
6
|
materialize(count, 2).
|
|
6
7
|
materialize(reason, 2).
|
|
7
8
|
|
|
9
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
10
|
+
% select/3 nondeterministically removes one item from a list.
|
|
8
11
|
select(Item, [Item | Rest], Rest).
|
|
12
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
9
13
|
select(Item, [Head | Tail], [Head | Rest]) :-
|
|
10
14
|
select(Item, Tail, Rest).
|
|
11
15
|
|
|
16
|
+
% combination/3 builds an unordered K-combination by repeated selection.
|
|
12
17
|
combination(0, _Items, []).
|
|
13
18
|
combination(I, Items, Combination) :-
|
|
14
19
|
gt(I, 0),
|
|
@@ -17,6 +22,7 @@ combination(I, Items, Combination) :-
|
|
|
17
22
|
combination(J, Remaining, Partial),
|
|
18
23
|
sort([Item | Partial], Combination).
|
|
19
24
|
|
|
25
|
+
% findall collects all generation orders; sort canonicalizes and deduplicates.
|
|
20
26
|
unique_combinations(K, Items, Unique) :-
|
|
21
27
|
findall(C, combination(K, Items, C), All),
|
|
22
28
|
sort(All, Unique).
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
% Km_effective = Km * (1 + Inhibitor / Ki)
|
|
5
5
|
% rate = Vmax * Substrate / (Km_effective + Substrate)
|
|
6
6
|
|
|
7
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
8
|
materialize(effectiveKm_uM, 2).
|
|
8
9
|
materialize(uninhibitedRate_uM_s, 2).
|
|
9
10
|
materialize(inhibitedRate_uM_s, 2).
|
|
@@ -11,6 +12,7 @@ materialize(inhibitionFraction, 2).
|
|
|
11
12
|
materialize(status, 2).
|
|
12
13
|
materialize(reason, 2).
|
|
13
14
|
|
|
15
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
14
16
|
assay(assay1, vmax_uM_s, 120.0).
|
|
15
17
|
assay(assay1, substrate_uM, 50.0).
|
|
16
18
|
assay(assay1, km_uM, 30.0).
|
|
@@ -18,6 +20,7 @@ assay(assay1, inhibitor_uM, 10.0).
|
|
|
18
20
|
assay(assay1, ki_uM, 5.0).
|
|
19
21
|
threshold(assay1, significant_inhibition_fraction, 0.25).
|
|
20
22
|
|
|
23
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
21
24
|
competitive_multiplier(Assay, Multiplier) :-
|
|
22
25
|
assay(Assay, inhibitor_uM, Inhibitor),
|
|
23
26
|
assay(Assay, ki_uM, Ki),
|
|
@@ -3,14 +3,17 @@
|
|
|
3
3
|
% trace < 0 and determinant > 0. A negative discriminant indicates a
|
|
4
4
|
% complex-conjugate eigenvalue pair.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(trace, 2).
|
|
7
8
|
materialize(determinant, 2).
|
|
8
9
|
materialize(discriminant, 2).
|
|
9
10
|
materialize(eigenShape, 2).
|
|
10
11
|
materialize(status, 2).
|
|
11
12
|
|
|
13
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
12
14
|
matrix(controller_loop, -0.7, 1.2, -0.4, -0.5).
|
|
13
15
|
|
|
16
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
14
17
|
trace(Matrix, Trace) :-
|
|
15
18
|
matrix(Matrix, A, _B, _C, D),
|
|
16
19
|
add(A, D, Trace).
|
package/examples/complex.pl
CHANGED
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
% Complex values are represented as two-item lists [Real, Imaginary], matching
|
|
4
4
|
% the pair-shaped pair lists used by the Eyeling source.
|
|
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
|
pi(3.141592653589793).
|
|
9
11
|
e(2.718281828459045).
|
|
10
12
|
|
|
13
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
11
14
|
complex_exponentiation([A, B], [C, D], [E, F]) :-
|
|
12
15
|
complex_polar([A, B], [R, T]),
|
|
13
16
|
pow(R, C, Z1),
|
|
@@ -4,14 +4,17 @@
|
|
|
4
4
|
% The output mirrors the Eyeling golden result shape:
|
|
5
5
|
% sameInputByCompositeInjectivity(h, a, b) and the symmetric counterpart.
|
|
6
6
|
|
|
7
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
8
|
materialize(sameInputByCompositeInjectivity, 3).
|
|
8
9
|
|
|
10
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
9
11
|
inX(a).
|
|
10
12
|
inX(b).
|
|
11
13
|
inY(c).
|
|
12
14
|
inY(d).
|
|
13
15
|
inZ(e).
|
|
14
16
|
|
|
17
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
15
18
|
sameTerm(X, X) :- inX(X).
|
|
16
19
|
sameTerm(X, X) :- inY(X).
|
|
17
20
|
sameTerm(X, X) :- inZ(X).
|
|
@@ -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,15 +8,22 @@
|
|
|
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).
|
|
14
15
|
materialize(outcome, 2).
|
|
15
16
|
materialize(target, 2).
|
|
17
|
+
materialize(metric, 2).
|
|
18
|
+
materialize(threshold, 2).
|
|
19
|
+
materialize(scope, 2).
|
|
20
|
+
materialize(retailer, 2).
|
|
21
|
+
materialize(expiresAt, 2).
|
|
16
22
|
materialize(scannedProduct, 2).
|
|
17
23
|
materialize(suggestedAlternative, 2).
|
|
18
24
|
materialize(headline, 2).
|
|
19
25
|
materialize(note, 2).
|
|
26
|
+
materialize(reason, 2).
|
|
20
27
|
materialize(value, 2).
|
|
21
28
|
materialize(alg, 2).
|
|
22
29
|
materialize(auditEntries, 2).
|
|
@@ -33,6 +40,8 @@ materialize(dutyTimingConsistent, 2).
|
|
|
33
40
|
materialize(marketingProhibited, 2).
|
|
34
41
|
materialize(filesWrittenExpected, 2).
|
|
35
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.
|
|
36
45
|
case_graph(delfourCaseGraph, (
|
|
37
46
|
caseName(case, "delfour"),
|
|
38
47
|
requestPurpose(case, "shopping_assist"),
|
|
@@ -47,6 +56,7 @@ case_graph(delfourCaseGraph, (
|
|
|
47
56
|
scannedProduct(scan, prod_BIS_001)
|
|
48
57
|
)).
|
|
49
58
|
|
|
59
|
+
% Catalog rows are product(IdTerm, DisplayId, Name, SugarTenths, SugarG).
|
|
50
60
|
product_catalog(delfourCatalog, [
|
|
51
61
|
product(prod_BIS_001, "prod_BIS_001", "Classic Tea Biscuits", 120, 12.0),
|
|
52
62
|
product(prod_BIS_101, "prod_BIS_101", "Low-Sugar Tea Biscuits", 30, 3.0),
|
|
@@ -91,6 +101,7 @@ signature_graph(delfourSignatureGraph, (
|
|
|
91
101
|
|
|
92
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.").
|
|
93
103
|
|
|
104
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
94
105
|
case_statement(S, P, O) :- case_graph(delfourCaseGraph, Formula), formula_binary(Formula, S, P, O).
|
|
95
106
|
insight_statement(S, P, O) :- insight_graph(delfourInsightGraph, Formula), formula_binary(Formula, S, P, O).
|
|
96
107
|
policy_statement(S, P, O) :- policy_graph(delfourPolicyGraph, Formula), formula_binary(Formula, S, P, O).
|
|
@@ -143,6 +154,7 @@ payload_hash_sha256(signature, Hash) :- signature_statement(signature, payloadHa
|
|
|
143
154
|
signature_hmac(signature, Hmac) :- signature_statement(signature, hmac, Hmac).
|
|
144
155
|
hmac_verification_mode(signature, Mode) :- signature_statement(signature, hmacVerificationMode, Mode).
|
|
145
156
|
|
|
157
|
+
% The household profile creates the low-sugar need used by the insight.
|
|
146
158
|
needs_low_sugar(case) :-
|
|
147
159
|
condition(householdProfile, "Diabetes").
|
|
148
160
|
|
|
@@ -194,6 +206,7 @@ better_lower_sugar(ScannedSugar, CandidateSugar) :-
|
|
|
194
206
|
gt(ScannedSugar, OtherSugar),
|
|
195
207
|
lt(OtherSugar, CandidateSugar).
|
|
196
208
|
|
|
209
|
+
% Pick the lowest-sugar alternative according to the insight suggestion policy.
|
|
197
210
|
suggested_alternative(case, Candidate) :-
|
|
198
211
|
scanned_product(scan, Scanned),
|
|
199
212
|
sugar_tenths(Scanned, ScannedSugar),
|
|
@@ -243,7 +256,11 @@ derivedFromNeed(insight, Need) :- derived_from_need(insight, Need).
|
|
|
243
256
|
outcome(decision, Outcome) :- decision(decision, Outcome, _Target).
|
|
244
257
|
target(decision, Target) :- decision(decision, _Outcome, Target).
|
|
245
258
|
scannedProduct(scan, ProductName) :- scanned_product(scan, Product), product_name(Product, ProductName).
|
|
246
|
-
suggestedAlternative(case,
|
|
259
|
+
suggestedAlternative(case, Name) :- suggested_alternative(case, Alternative), product_name(Alternative, Name).
|
|
260
|
+
threshold(insight, Threshold) :- threshold_display(insight, Threshold).
|
|
261
|
+
scope(insight, "self-scanner @ pick_up_scanner") :- scope_device(insight, "self-scanner"), scope_event(insight, "pick_up_scanner").
|
|
262
|
+
expiresAt(insight, Time) :- expires_at(insight, Time).
|
|
263
|
+
reason(why, "The phone desensitizes a diabetes-related household condition into a scoped low-sugar need, wraps it in an expiring Insight + Policy envelope, signs it, and the scanner consumes that envelope for shopping assistance.") :- authorization_allowed(check).
|
|
247
264
|
headline(banner, Headline) :- banner_headline(banner, Headline).
|
|
248
265
|
note(banner, Note) :- banner_note(banner, Note).
|
|
249
266
|
suggestedAlternative(banner, Name) :- banner_suggested_alternative(banner, Name).
|