eyelang 1.5.3 → 1.5.5
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/conformance/README.md +3 -3
- package/conformance/cases/core/021_repeated_variable_head.pl +7 -0
- package/conformance/cases/core/022_rule_head_structure.pl +5 -0
- package/conformance/cases/core/023_quoted_escapes_readback.pl +5 -0
- package/conformance/cases/core/024_numeric_literal_readback.pl +6 -0
- package/conformance/cases/core/025_body_parentheses_with_formula_data.pl +5 -0
- package/conformance/cases/core/026_underscore_named_variable_reuse.pl +5 -0
- package/conformance/cases/extension/035_date_difference.pl +4 -0
- package/conformance/cases/extension/036_extended_gcd.pl +3 -0
- package/conformance/cases/extension/037_collatz_trajectory.pl +3 -0
- package/conformance/cases/extension/038_kaprekar_steps.pl +3 -0
- package/conformance/cases/extension/039_goldbach_pair.pl +3 -0
- package/conformance/cases/extension/040_matrix_operations.pl +5 -0
- package/conformance/cases/extension/041_atom_range_generators.pl +5 -0
- package/conformance/cases/extension/042_n_queens_small.pl +3 -0
- package/conformance/cases/extension/043_cnf_model.pl +3 -0
- package/conformance/cases/extension/044_cover9_filter.pl +6 -0
- package/conformance/cases/extension/045_alphametic_sum_small.pl +3 -0
- package/conformance/cases/extension/046_bounded_subset.pl +4 -0
- package/conformance/expected/core/021_repeated_variable_head.out +2 -0
- package/conformance/expected/core/022_rule_head_structure.out +2 -0
- package/conformance/expected/core/023_quoted_escapes_readback.out +2 -0
- package/conformance/expected/core/024_numeric_literal_readback.out +3 -0
- package/conformance/expected/core/025_body_parentheses_with_formula_data.out +1 -0
- package/conformance/expected/core/026_underscore_named_variable_reuse.out +1 -0
- package/conformance/expected/extension/035_date_difference.out +2 -0
- package/conformance/expected/extension/036_extended_gcd.out +1 -0
- package/conformance/expected/extension/037_collatz_trajectory.out +1 -0
- package/conformance/expected/extension/038_kaprekar_steps.out +1 -0
- package/conformance/expected/extension/039_goldbach_pair.out +2 -0
- package/conformance/expected/extension/040_matrix_operations.out +3 -0
- package/conformance/expected/extension/041_atom_range_generators.out +8 -0
- package/conformance/expected/extension/042_n_queens_small.out +2 -0
- package/conformance/expected/extension/043_cnf_model.out +1 -0
- package/conformance/expected/extension/044_cover9_filter.out +2 -0
- package/conformance/expected/extension/045_alphametic_sum_small.out +4 -0
- package/conformance/expected/extension/046_bounded_subset.out +5 -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 +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
|
@@ -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,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
|
|