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
package/conformance/README.md
CHANGED
|
@@ -7,7 +7,7 @@ The suite is intentionally file-based so another implementation can run the same
|
|
|
7
7
|
- `conformance/cases/<profile>/<name>.pl` — input program;
|
|
8
8
|
- `conformance/expected/<profile>/<name>.out` — exact expected standard output.
|
|
9
9
|
|
|
10
|
-
The current runner compares standard output
|
|
10
|
+
The current runner compares standard output from normal execution. Proof explanations are opt-in in the CLI and are not part of these conformance goldens. Standard error, performance, and resource limits are outside this suite.
|
|
11
11
|
|
|
12
12
|
## Running the suite
|
|
13
13
|
|
|
@@ -34,9 +34,9 @@ The runner executes materialized programs in-process through the public JavaScri
|
|
|
34
34
|
|
|
35
35
|
## Profiles
|
|
36
36
|
|
|
37
|
-
`core` covers the portable core language profile from `../SPEC.md`: lexical syntax, facts, definite clauses, first-order terms, lists, conjunction, unification through user predicates, left-to-right goal-directed proof search, and
|
|
37
|
+
`core` covers the portable core language profile from `../SPEC.md`: lexical syntax, facts, definite clauses, first-order terms, lists, conjunction, structured unification through user predicates, left-to-right goal-directed proof search, materialized output, and read-back printing.
|
|
38
38
|
|
|
39
|
-
`extension` covers the standard built-in and host behavior exercised by the current reference implementation: arithmetic, comparison, strings, list relations, aggregation, formula-term helpers, `memoize/2`, `materialize/2`, and default derived output.
|
|
39
|
+
`extension` covers the standard built-in and host behavior exercised by the current reference implementation: arithmetic, comparison, strings, list relations, aggregation, formula-term helpers, number-theory helpers, finite-search helpers, matrix helpers, `memoize/2`, `materialize/2`, and default derived output.
|
|
40
40
|
|
|
41
41
|
The profile name `extension` is a test-suite grouping name. It does not mean that these cases are outside the eyelang specification; most of them correspond to the standard built-in profile and standard host profile in `../SPEC.md`.
|
|
42
42
|
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
% SPEC 9.2: matrix helpers handle small ground numeric matrices.
|
|
2
|
+
answer(sum, M) :- matrix_sum([[[1, 2], [3, 4]], [[5, 6], [7, 8]]], M).
|
|
3
|
+
answer(product, M) :- matrix_multiply([[[1, 2], [3, 4]], [[2, 0], [1, 2]]], M).
|
|
4
|
+
answer(determinant, D) :- determinant([[4, 2], [2, 3]], D).
|
|
5
|
+
materialize(answer, 2).
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
% SPEC 9.5: bounded_subset/7 enumerates subsets within budget and risk caps.
|
|
2
|
+
projects([p(a, 5, 3, 1), p(b, 4, 2, 2), p(c, 7, 5, 3)]).
|
|
3
|
+
answer(selection, result(Names, Value, Cost, Risk)) :- projects(Ps), bounded_subset(Ps, 5, 3, Names, Value, Cost, Risk).
|
|
4
|
+
materialize(answer, 2).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
answer(ok, (left(a), right(b))).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
answer(shared, a).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
answer(gcd, result(2, -9, 47)).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
answer(path, [6, 3, 10, 5, 16, 8, 4, 2, 1]).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
answer(steps, 3).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
answer(model, [value(a, false), value(b, true)]).
|
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
% finite logical conditions. The universal allOf/noneOf checks use negation
|
|
5
5
|
% as failure over bound policy facts.
|
|
6
6
|
|
|
7
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
8
|
materialize(policy, 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
|
policy_request(test1, policy_x).
|
|
12
14
|
has(test1, claim_a).
|
|
13
15
|
has(test1, claim_b).
|
|
@@ -19,6 +21,7 @@ allOf(policy_x, claim_b).
|
|
|
19
21
|
anyOf(policy_x, claim_c).
|
|
20
22
|
noneOf(policy_x, claim_d).
|
|
21
23
|
|
|
24
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
22
25
|
passes_all_of(Request, Policy) :-
|
|
23
26
|
policy_request(Request, Policy),
|
|
24
27
|
policy(Policy),
|
package/examples/ackermann.pl
CHANGED
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
% The two-argument entry point follows the Eyeling encoding:
|
|
3
3
|
% ackermann(X, Y) = hyper(X, Y + 3, 2) - 3.
|
|
4
4
|
|
|
5
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
5
6
|
materialize(ackermann, 2).
|
|
6
7
|
|
|
8
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
9
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
7
10
|
ackermann(X, Y, A) :-
|
|
8
11
|
add(Y, 3, B),
|
|
9
12
|
hyper(X, B, 2, C),
|
package/examples/age.pl
CHANGED
|
@@ -3,16 +3,19 @@
|
|
|
3
3
|
% Is the age of a person above some duration?
|
|
4
4
|
|
|
5
5
|
% Person data.
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(birthDay, 2).
|
|
7
8
|
materialize(duration, 2).
|
|
8
9
|
materialize(ageAbove, 2).
|
|
9
10
|
materialize(is, 2).
|
|
10
11
|
|
|
12
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
11
13
|
birthDay(patH, "1944-08-21").
|
|
12
14
|
duration(check, "P80Y").
|
|
13
15
|
|
|
14
16
|
% A person is above a duration if the local date minus the birthday is greater
|
|
15
17
|
% than that duration.
|
|
18
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
16
19
|
ageAbove(S, A) :-
|
|
17
20
|
birthDay(S, B),
|
|
18
21
|
duration(check, A),
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
% Built-ins use one native spelling each.
|
|
2
2
|
% Vocabulary predicate names remain ordinary user predicates.
|
|
3
3
|
|
|
4
|
+
% The materialized relations below show that built-ins can coexist with
|
|
5
|
+
% ordinary vocabulary predicates that happen to look namespace-like.
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
4
7
|
materialize(value, 2).
|
|
5
8
|
materialize(ok, 2).
|
|
6
9
|
materialize(tail, 2).
|
|
7
10
|
materialize(label, 2).
|
|
8
11
|
|
|
12
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
13
|
+
% Native operations are called through their canonical predicate names.
|
|
14
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
9
15
|
value(nativeMath, X) :- add(0.125, 0.875, X).
|
|
10
16
|
ok(nativeCompare, true) :- lt(2, 3).
|
|
11
17
|
ok(nativeString, true) :- matches("scoped retail insight", "retail|medical").
|
|
12
18
|
tail(nativeList, Tail) :- rest([a, b, c], Tail).
|
|
13
19
|
|
|
20
|
+
% These names are just user data; eyelang does not give them special meaning.
|
|
14
21
|
example_label(vocabularyExample, "vocabulary names are ordinary predicate names").
|
|
15
22
|
label(vocabularyExample, Text) :- example_label(vocabularyExample, Text).
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
% broader/narrower alignments, their transitive closure, the reflexive
|
|
5
5
|
% narrower-or-equal relation, and the concepts that roll up to ref_car.
|
|
6
6
|
|
|
7
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
8
|
materialize(broader, 2).
|
|
8
9
|
materialize(narrower, 2).
|
|
9
10
|
materialize(broaderTransitive, 2).
|
|
@@ -11,6 +12,7 @@ materialize(narrowerTransitive, 2).
|
|
|
11
12
|
materialize(narrowerOrEqualOf, 2).
|
|
12
13
|
materialize(rollsUpTo, 2).
|
|
13
14
|
|
|
15
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
14
16
|
concept(ref_car).
|
|
15
17
|
concept(tel_car).
|
|
16
18
|
concept(tel_heavy_vehicle).
|
|
@@ -22,6 +24,7 @@ assertedBroader(tel_heavy_vehicle, ref_car).
|
|
|
22
24
|
assertedBroader(anpr_vehicle_with_plate, ref_car).
|
|
23
25
|
assertedNarrower(anpr_vehicle_with_plate, anpr_passenger_car).
|
|
24
26
|
|
|
27
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
25
28
|
broader(X, Y) :- assertedBroader(X, Y).
|
|
26
29
|
broader(X, Y) :- assertedNarrower(Y, X).
|
|
27
30
|
|
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
% The input interval table is a list of records, showing how tabular data can
|
|
5
5
|
% stay scoped as one term instead of many unrelated global start/end facts.
|
|
6
6
|
|
|
7
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
8
|
materialize(start, 2).
|
|
8
9
|
materialize(end, 2).
|
|
9
10
|
materialize(duration, 2).
|
|
10
11
|
materialize(statement, 3).
|
|
11
12
|
|
|
13
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
12
14
|
interval_table([
|
|
13
15
|
interval(a, 10, 12),
|
|
14
16
|
interval(b, 13, 15),
|
|
@@ -23,6 +25,7 @@ interval_table([
|
|
|
23
25
|
interval(k, 13, 14)
|
|
24
26
|
]).
|
|
25
27
|
|
|
28
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
26
29
|
interval(I) :- interval_table(Table), member(interval(I, _Start, _End), Table).
|
|
27
30
|
start(I, Start) :- interval_table(Table), member(interval(I, Start, _End), Table).
|
|
28
31
|
end(I, End) :- interval_table(Table), member(interval(I, _Start, End), Table).
|
package/examples/ancestor.pl
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
% Basic recursive relation example.
|
|
2
|
+
% Both input facts and derived recursive answers are printed.
|
|
3
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
2
4
|
materialize(parent, 2).
|
|
3
5
|
materialize(ancestor, 2).
|
|
4
6
|
|
|
7
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
8
|
+
% Direct parent facts form a simple chain.
|
|
5
9
|
parent(pat, jan).
|
|
6
10
|
parent(jan, lies).
|
|
7
11
|
parent(lies, emma).
|
|
8
12
|
|
|
13
|
+
% Base case: every parent is also an ancestor.
|
|
14
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
9
15
|
ancestor(X, Y) :-
|
|
10
16
|
parent(X, Y).
|
|
11
17
|
|
|
18
|
+
% Recursive case: walk one parent edge and continue through the chain.
|
|
12
19
|
ancestor(X, Z) :-
|
|
13
20
|
parent(X, Y),
|
|
14
21
|
ancestor(Y, Z).
|
package/examples/animal.pl
CHANGED
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
% The Eyelet source uses Unicode predicate names; this eyelang version keeps the
|
|
4
4
|
% same tiny inheritance idea with plain vocabulary names.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(type, 2).
|
|
7
8
|
materialize(subclassOf, 2).
|
|
8
9
|
materialize(succeeds, 2).
|
|
9
10
|
|
|
11
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
10
12
|
human(joe).
|
|
11
13
|
animal(human).
|
|
12
14
|
|
|
15
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
13
16
|
animal(X) :- human(X).
|
|
14
17
|
|
|
15
18
|
type(joe, human) :- human(joe).
|
package/examples/annotation.pl
CHANGED
|
@@ -3,17 +3,20 @@
|
|
|
3
3
|
% The program keeps the annotation as data and derives visible relations from it.
|
|
4
4
|
% Formula members become default output only when explicit rules project them.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(name, 2).
|
|
7
8
|
materialize(log_nameOf, 2).
|
|
8
9
|
materialize(statedBy, 2).
|
|
9
10
|
materialize(recorded, 2).
|
|
10
11
|
|
|
12
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
11
13
|
annotation(t, (
|
|
12
14
|
name(a, "Alice"),
|
|
13
15
|
statedBy(t, bob),
|
|
14
16
|
recorded(t, "2021-07-07")
|
|
15
17
|
)).
|
|
16
18
|
|
|
19
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
17
20
|
name(S, O) :-
|
|
18
21
|
annotation(_T, Formula),
|
|
19
22
|
formula_binary(Formula, S, name, O).
|
package/examples/auroracare.pl
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
% translation materializes the policy decisions, reasons, traces, and ARC-style
|
|
4
4
|
% check values as ordinary relation output.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(label, 2).
|
|
7
8
|
materialize(description, 2).
|
|
8
9
|
materialize(careTeamLinked, 2).
|
|
@@ -24,9 +25,11 @@ materialize(checkC8, 2).
|
|
|
24
25
|
materialize(checkC9, 2).
|
|
25
26
|
materialize(checkC10Text, 2).
|
|
26
27
|
|
|
28
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
27
29
|
caseName(case, "auroracare").
|
|
28
30
|
question(case, "For each AuroraCare scenario, should the PDP permit or deny the requested use of health data, and why?").
|
|
29
31
|
|
|
32
|
+
% Policies: primary care, quality improvement, research, and an explicit denial.
|
|
30
33
|
policyUid(policyPrimary, "urn:policy:primary-care-001").
|
|
31
34
|
purposeAllowed(policyPrimary, primaryCareManagement).
|
|
32
35
|
purposeAllowed(policyPrimary, patientRemoteMonitoring).
|
|
@@ -64,6 +67,7 @@ primaryPurpose(auroracare, primaryCareManagement).
|
|
|
64
67
|
primaryPurpose(auroracare, patientRemoteMonitoring).
|
|
65
68
|
prohibitedPurpose(auroracare, insuranceManagement).
|
|
66
69
|
|
|
70
|
+
% Scenarios A-G mirror the upstream Markdown report cases.
|
|
67
71
|
scenario(scenarioA).
|
|
68
72
|
outputKey(scenarioA, out010A).
|
|
69
73
|
scenario_label(scenarioA, "A – Primary care visit").
|
|
@@ -145,6 +149,7 @@ environment(scenarioG, "secure_env").
|
|
|
145
149
|
category(scenarioG, patientSummary).
|
|
146
150
|
category(scenarioG, labResults).
|
|
147
151
|
|
|
152
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
148
153
|
label(S, Label) :- scenario_label(S, Label).
|
|
149
154
|
description(S, Description) :- scenario_description(S, Description).
|
|
150
155
|
|
|
@@ -195,9 +200,11 @@ careTeamLinked(S, true) :- care_team_linked(S).
|
|
|
195
200
|
subjectOptIn(S, true) :- subject_opt_in(S).
|
|
196
201
|
subjectOptOut(S, true) :- subject_opt_out(S).
|
|
197
202
|
|
|
203
|
+
% Permit when a scenario satisfies one of the allowed policy branches.
|
|
198
204
|
decision(S, "PERMIT") :- primary_policy_match(S).
|
|
199
205
|
decision(S, "PERMIT") :- qi_policy_match(S).
|
|
200
206
|
decision(S, "PERMIT") :- research_policy_match(S).
|
|
207
|
+
% Deny branches preserve the reason that will be materialized for the report.
|
|
201
208
|
decision(S, "DENY") :- insurance_prohibition_match(S).
|
|
202
209
|
decision(S, "DENY") :- ai_training_opt_out_match(S).
|
|
203
210
|
decision(scenarioC, "DENY") :- purpose(scenarioC, ensureQualitySafetyHealthcare).
|
|
@@ -223,6 +230,7 @@ trace(S, "urn:policy:deny-insurance:deny:odrl:prohibition_matched") :- insurance
|
|
|
223
230
|
trace(S, "deny:subject_opted_out_ai_training") :- ai_training_opt_out_match(S).
|
|
224
231
|
trace(scenarioC, "urn:policy:qi-2025-aurora:deny:odrl:no_permission_matched") :- purpose(scenarioC, ensureQualitySafetyHealthcare).
|
|
225
232
|
|
|
233
|
+
% C1-C10 below are the ARC-style checklist lines from the upstream output.
|
|
226
234
|
checkC1(scenarioA, "SKIPPED - not a prohibited purpose") :- decision(scenarioA, "PERMIT").
|
|
227
235
|
checkC2(scenarioA, "OK - clinician") :- decision(scenarioA, "PERMIT").
|
|
228
236
|
checkC3(scenarioA, "OK - care-team linked") :- decision(scenarioA, "PERMIT").
|
package/examples/backward.pl
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
1
2
|
materialize(isIndeedMoreInterestingThan, 2).
|
|
2
3
|
|
|
4
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
3
5
|
% Backward rule example adapted from Eyeling backward.n3.
|
|
4
6
|
% Eyeling writes the interestingness rule backward; eyelang records the same
|
|
5
7
|
% relation as an ordinary rule whose body is the numeric comparison.
|
|
6
8
|
|
|
9
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
7
10
|
moreInterestingThan(X, Y) :- gt(X, Y).
|
|
8
11
|
|
|
9
12
|
isIndeedMoreInterestingThan(5, 3) :- moreInterestingThan(5, 3).
|
|
@@ -8,8 +8,10 @@
|
|
|
8
8
|
% EYE reasoning/basic-monadic/10tt_answer.n3 in cardinality and content
|
|
9
9
|
% after translating N3 statements to eyelang relation terms.
|
|
10
10
|
|
|
11
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
11
12
|
materialize(cycle, 2).
|
|
12
13
|
|
|
14
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
13
15
|
edge(i30, i12, i33).
|
|
14
16
|
edge(i61, i29, i42).
|
|
15
17
|
edge(i57, i46, i87).
|
|
@@ -10011,6 +10013,6 @@ edge(i18, i75, i36).
|
|
|
10011
10013
|
edge(i48, i89, i48).
|
|
10012
10014
|
edge(i26, i42, i54).
|
|
10013
10015
|
|
|
10016
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
10014
10017
|
cycle(R, Cycle) :-
|
|
10015
10018
|
fixed_length_cycle(edge, 10, R, Cycle).
|
|
10016
|
-
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
% points, so this example is comparable with examples/output/bayes-diagnosis.n3
|
|
5
5
|
% in the Eyeling repository.
|
|
6
6
|
|
|
7
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
8
|
materialize(scores, 2).
|
|
8
9
|
materialize(evidenceTotal, 2).
|
|
9
10
|
materialize(result, 2).
|
|
@@ -11,6 +12,7 @@ materialize(disease, 2).
|
|
|
11
12
|
materialize(unnormalized, 2).
|
|
12
13
|
materialize(posterior, 2).
|
|
13
14
|
|
|
15
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
14
16
|
disease(covid19).
|
|
15
17
|
disease(influenza).
|
|
16
18
|
disease(allergicRhinitis).
|
|
@@ -53,6 +55,7 @@ evidence([
|
|
|
53
55
|
ev(shortBreath, true)
|
|
54
56
|
]).
|
|
55
57
|
|
|
58
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
56
59
|
factor(Disease, Symptom, true, P) :- p_given(Disease, Symptom, P).
|
|
57
60
|
factor(Disease, Symptom, false, Q) :-
|
|
58
61
|
p_given(Disease, Symptom, P),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
% Memoize shared inference layers: the score vector, disease likelihood tails,
|
|
2
2
|
% and expected therapy success are reused by several report relations.
|
|
3
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
3
4
|
materialize(diseases, 2).
|
|
4
5
|
materialize(therapies, 2).
|
|
5
6
|
materialize(evidence, 2).
|
|
@@ -12,6 +13,7 @@ materialize(expectedAdverse, 2).
|
|
|
12
13
|
materialize(utility, 2).
|
|
13
14
|
materialize(recommendedTherapy, 2).
|
|
14
15
|
|
|
16
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
15
17
|
memoize(scores_for, 2).
|
|
16
18
|
memoize(likelihood, 3).
|
|
17
19
|
memoize(expected_success, 2).
|
|
@@ -81,6 +83,7 @@ adverse(supportiveCare, 0.01).
|
|
|
81
83
|
benefit_weight(10).
|
|
82
84
|
harm_weight(3).
|
|
83
85
|
|
|
86
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
84
87
|
factor(Disease, ev(Symptom, true), P) :- p_given(Disease, Symptom, P).
|
|
85
88
|
factor(Disease, ev(Symptom, false), Q) :-
|
|
86
89
|
p_given(Disease, Symptom, P),
|
|
@@ -2,18 +2,21 @@
|
|
|
2
2
|
%
|
|
3
3
|
% The tip deflection for a point load at the free end is F*L^3/(3*E*I).
|
|
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(tipDeflection_m, 2).
|
|
7
8
|
materialize(tipDeflection_mm, 2).
|
|
8
9
|
materialize(limit_mm, 2).
|
|
9
10
|
materialize(status, 2).
|
|
10
11
|
|
|
12
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
11
13
|
beam(beam1, force_N, 1200.0).
|
|
12
14
|
beam(beam1, length_m, 2.5).
|
|
13
15
|
beam(beam1, elasticModulus_Pa, 200000000000.0).
|
|
14
16
|
beam(beam1, secondMoment_m4, 0.000008).
|
|
15
17
|
limit(beam1, maxDeflection_mm, 5.0).
|
|
16
18
|
|
|
19
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
17
20
|
tip_deflection_m(Beam, Deflection) :-
|
|
18
21
|
beam(Beam, force_N, Force),
|
|
19
22
|
beam(Beam, length_m, Length),
|
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
% are sorted lists of on(Block, Support) facts so equality and visited-state
|
|
5
5
|
% checks are purely structural.
|
|
6
6
|
|
|
7
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
8
|
materialize(status, 2).
|
|
8
9
|
materialize(plan, 2).
|
|
9
10
|
materialize(finalState, 2).
|
|
10
11
|
materialize(blockCount, 2).
|
|
11
12
|
|
|
13
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
12
14
|
initial([on(a, table), on(b, a), on(c, b), on(d, c), on(e, d)]).
|
|
13
15
|
goal([on(a, table), on(b, a), on(c, table), on(d, c), on(e, d)]).
|
|
14
16
|
|
|
@@ -19,6 +21,7 @@ block(d).
|
|
|
19
21
|
block(e).
|
|
20
22
|
|
|
21
23
|
support(table, _State).
|
|
24
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
22
25
|
support(Block, State) :-
|
|
23
26
|
block(Block),
|
|
24
27
|
member(on(Block, _Below), State).
|
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),
|