eyeling 1.23.4 → 1.24.0
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/HANDBOOK.md +6 -6
- package/README.md +1 -0
- package/dist/browser/eyeling.browser.js +11812 -11836
- package/eyeling.js +40 -12
- package/lib/prelude.js +40 -12
- package/package.json +7 -5
- package/see/README.md +146 -0
- package/see/examples/_see.js +218 -0
- package/see/examples/age.js +1433 -0
- package/see/examples/annotation.js +1294 -0
- package/see/examples/backward.js +1379 -0
- package/see/examples/backward_recursion.js +1478 -0
- package/see/examples/bayes_diagnosis.js +2857 -0
- package/see/examples/bayes_therapy.js +4126 -0
- package/see/examples/bmi.js +3012 -0
- package/see/examples/builtin_coverage.js +2498 -0
- package/see/examples/collection.js +1294 -0
- package/see/examples/complex.js +3736 -0
- package/see/examples/complex_matrix_stability.js +2947 -0
- package/see/examples/composition_of_injective_functions_is_injective.js +2144 -0
- package/see/examples/control_system.js +1892 -0
- package/see/examples/crypto_builtins_tests.js +1463 -0
- package/see/examples/delfour.js +3148 -0
- package/see/examples/digital_product_passport.js +2830 -0
- package/see/examples/dijkstra.js +2044 -0
- package/see/examples/dijkstra_risk_path.js +1848 -0
- package/see/examples/doc/age.md +27 -0
- package/see/examples/doc/annotation.md +24 -0
- package/see/examples/doc/backward.md +26 -0
- package/see/examples/doc/backward_recursion.md +26 -0
- package/see/examples/doc/bayes_diagnosis.md +41 -0
- package/see/examples/doc/bayes_therapy.md +40 -0
- package/see/examples/doc/bmi.md +38 -0
- package/see/examples/doc/builtin_coverage.md +53 -0
- package/see/examples/doc/collection.md +24 -0
- package/see/examples/doc/complex.md +38 -0
- package/see/examples/doc/complex_matrix_stability.md +35 -0
- package/see/examples/doc/composition_of_injective_functions_is_injective.md +24 -0
- package/see/examples/doc/control_system.md +32 -0
- package/see/examples/doc/crypto_builtins_tests.md +27 -0
- package/see/examples/doc/delfour.md +37 -0
- package/see/examples/doc/digital_product_passport.md +36 -0
- package/see/examples/doc/dijkstra.md +28 -0
- package/see/examples/doc/dijkstra_risk_path.md +30 -0
- package/see/examples/doc/dog.md +28 -0
- package/see/examples/doc/eco_route_insight.md +33 -0
- package/see/examples/doc/equals.md +26 -0
- package/see/examples/doc/equivalence_classes_overlap_implies_same_class.md +24 -0
- package/see/examples/doc/euler_identity.md +39 -0
- package/see/examples/doc/ev_roundtrip_planner.md +32 -0
- package/see/examples/doc/existential_rule.md +24 -0
- package/see/examples/doc/expression_eval.md +26 -0
- package/see/examples/doc/family_cousins.md +24 -0
- package/see/examples/doc/fastpow.md +29 -0
- package/see/examples/doc/fibonacci.md +28 -0
- package/see/examples/doc/french_cities.md +28 -0
- package/see/examples/doc/fundamental_theorem_arithmetic.md +36 -0
- package/see/examples/doc/genetic_knapsack_selection.md +29 -0
- package/see/examples/doc/goldbach_1000.md +31 -0
- package/see/examples/doc/good_cobbler.md +27 -0
- package/see/examples/doc/gps.md +35 -0
- package/see/examples/doc/gray_code_counter.md +31 -0
- package/see/examples/doc/greatest_lower_bound_uniqueness.md +24 -0
- package/see/examples/doc/group_inverse_uniqueness.md +24 -0
- package/see/examples/doc/hadamard_approx.md +32 -0
- package/see/examples/doc/hanoi.md +26 -0
- package/see/examples/doc/odrl_dpv_risk_ranked.md +57 -0
- package/see/examples/doc/path_discovery.md +33 -0
- package/see/examples/doc/rc_discharge_envelope.md +33 -0
- package/see/examples/doc/rdf_message_flow.md +35 -0
- package/see/examples/doc/rdf_messages.md +37 -0
- package/see/examples/doc/school_placement_audit.md +31 -0
- package/see/examples/doc/smoke_arithmetic.md +31 -0
- package/see/examples/doc/socrates.md +24 -0
- package/see/examples/doc/wind_turbine.md +37 -0
- package/see/examples/doc/witch.md +28 -0
- package/see/examples/dog.js +1410 -0
- package/see/examples/eco_route_insight.js +2084 -0
- package/see/examples/equals.js +1337 -0
- package/see/examples/equivalence_classes_overlap_implies_same_class.js +1766 -0
- package/see/examples/euler_identity.js +2012 -0
- package/see/examples/ev_roundtrip_planner.js +2536 -0
- package/see/examples/existential_rule.js +1337 -0
- package/see/examples/expression_eval.js +1772 -0
- package/see/examples/family_cousins.js +1560 -0
- package/see/examples/fastpow.js +2181 -0
- package/see/examples/fibonacci.js +1568 -0
- package/see/examples/french_cities.js +1466 -0
- package/see/examples/fundamental_theorem_arithmetic.js +2080 -0
- package/see/examples/genetic_knapsack_selection.js +1717 -0
- package/see/examples/goldbach_1000.js +1772 -0
- package/see/examples/good_cobbler.js +1370 -0
- package/see/examples/gps.js +2787 -0
- package/see/examples/gray_code_counter.js +1615 -0
- package/see/examples/greatest_lower_bound_uniqueness.js +1892 -0
- package/see/examples/group_inverse_uniqueness.js +1871 -0
- package/see/examples/hadamard_approx.js +4391 -0
- package/see/examples/hanoi.js +1599 -0
- package/see/examples/input/age.trig +27 -0
- package/see/examples/input/annotation.trig +31 -0
- package/see/examples/input/backward.trig +25 -0
- package/see/examples/input/backward_recursion.trig +25 -0
- package/see/examples/input/bayes_diagnosis.trig +111 -0
- package/see/examples/input/bayes_therapy.trig +130 -0
- package/see/examples/input/bmi.trig +28 -0
- package/see/examples/input/builtin_coverage.trig +24 -0
- package/see/examples/input/collection.trig +25 -0
- package/see/examples/input/complex.trig +26 -0
- package/see/examples/input/complex_matrix_stability.trig +65 -0
- package/see/examples/input/composition_of_injective_functions_is_injective.trig +35 -0
- package/see/examples/input/control_system.trig +31 -0
- package/see/examples/input/crypto_builtins_tests.trig +25 -0
- package/see/examples/input/delfour.trig +90 -0
- package/see/examples/input/digital_product_passport.trig +116 -0
- package/see/examples/input/dijkstra.trig +34 -0
- package/see/examples/input/dijkstra_risk_path.trig +46 -0
- package/see/examples/input/dog.trig +31 -0
- package/see/examples/input/eco_route_insight.trig +58 -0
- package/see/examples/input/equals.trig +25 -0
- package/see/examples/input/equivalence_classes_overlap_implies_same_class.trig +28 -0
- package/see/examples/input/euler_identity.trig +34 -0
- package/see/examples/input/ev_roundtrip_planner.trig +90 -0
- package/see/examples/input/existential_rule.trig +26 -0
- package/see/examples/input/expression_eval.trig +41 -0
- package/see/examples/input/family_cousins.trig +39 -0
- package/see/examples/input/fastpow.trig +25 -0
- package/see/examples/input/fibonacci.trig +51 -0
- package/see/examples/input/french_cities.trig +38 -0
- package/see/examples/input/fundamental_theorem_arithmetic.trig +42 -0
- package/see/examples/input/genetic_knapsack_selection.trig +39 -0
- package/see/examples/input/goldbach_1000.trig +53 -0
- package/see/examples/input/good_cobbler.trig +24 -0
- package/see/examples/input/gps.trig +35 -0
- package/see/examples/input/gray_code_counter.trig +33 -0
- package/see/examples/input/greatest_lower_bound_uniqueness.trig +29 -0
- package/see/examples/input/group_inverse_uniqueness.trig +29 -0
- package/see/examples/input/hadamard_approx.trig +32 -0
- package/see/examples/input/hanoi.trig +26 -0
- package/see/examples/input/odrl_dpv_risk_ranked.trig +107 -0
- package/see/examples/input/path-discovery.trig +96448 -0
- package/see/examples/input/path_discovery.trig +29 -0
- package/see/examples/input/rc_discharge_envelope.trig +37 -0
- package/see/examples/input/rdf_message_flow.trig +100 -0
- package/see/examples/input/rdf_messages.trig +69 -0
- package/see/examples/input/school_placement_audit.trig +51 -0
- package/see/examples/input/smoke_arithmetic.trig +27 -0
- package/see/examples/input/socrates.trig +26 -0
- package/see/examples/input/wind_turbine.trig +48 -0
- package/see/examples/input/witch.trig +26 -0
- package/see/examples/n3/age.n3 +28 -0
- package/see/examples/n3/annotation.n3 +7 -0
- package/see/examples/n3/backward.n3 +22 -0
- package/see/examples/n3/backward_recursion.n3 +12 -0
- package/see/examples/n3/bayes_diagnosis.n3 +122 -0
- package/see/examples/n3/bayes_therapy.n3 +149 -0
- package/see/examples/n3/bmi.n3 +145 -0
- package/see/examples/n3/builtin_coverage.n3 +68 -0
- package/see/examples/n3/collection.n3 +3 -0
- package/see/examples/n3/complex.n3 +140 -0
- package/see/examples/n3/complex_matrix_stability.n3 +113 -0
- package/see/examples/n3/composition_of_injective_functions_is_injective.n3 +27 -0
- package/see/examples/n3/control_system.n3 +59 -0
- package/see/examples/n3/crypto_builtins_tests.n3 +18 -0
- package/see/examples/n3/delfour.n3 +167 -0
- package/see/examples/n3/digital_product_passport.n3 +156 -0
- package/see/examples/n3/dijkstra.n3 +46 -0
- package/see/examples/n3/dijkstra_risk_path.n3 +67 -0
- package/see/examples/n3/dog.n3 +20 -0
- package/see/examples/n3/eco_route_insight.n3 +88 -0
- package/see/examples/n3/equals.n3 +11 -0
- package/see/examples/n3/equivalence_classes_overlap_implies_same_class.n3 +19 -0
- package/see/examples/n3/euler_identity.n3 +41 -0
- package/see/examples/n3/ev_roundtrip_planner.n3 +82 -0
- package/see/examples/n3/existential_rule.n3 +10 -0
- package/see/examples/n3/expression_eval.n3 +21 -0
- package/see/examples/n3/family_cousins.n3 +62 -0
- package/see/examples/n3/fastpow.n3 +56 -0
- package/see/examples/n3/fibonacci.n3 +44 -0
- package/see/examples/n3/french_cities.n3 +28 -0
- package/see/examples/n3/fundamental_theorem_arithmetic.n3 +84 -0
- package/see/examples/n3/genetic_knapsack_selection.n3 +54 -0
- package/see/examples/n3/goldbach_1000.n3 +66 -0
- package/see/examples/n3/good_cobbler.n3 +10 -0
- package/see/examples/n3/gps.n3 +70 -0
- package/see/examples/n3/gray_code_counter.n3 +53 -0
- package/see/examples/n3/greatest_lower_bound_uniqueness.n3 +20 -0
- package/see/examples/n3/group_inverse_uniqueness.n3 +19 -0
- package/see/examples/n3/hadamard_approx.n3 +43 -0
- package/see/examples/n3/hanoi.n3 +16 -0
- package/see/examples/n3/odrl_dpv_risk_ranked.n3 +460 -0
- package/see/examples/n3/path_discovery.n3 +43 -0
- package/see/examples/n3/rc_discharge_envelope.n3 +61 -0
- package/see/examples/n3/rdf_message_flow.n3 +209 -0
- package/see/examples/n3/rdf_messages.n3 +143 -0
- package/see/examples/n3/school_placement_audit.n3 +63 -0
- package/see/examples/n3/smoke_arithmetic.n3 +22 -0
- package/see/examples/n3/socrates.n3 +21 -0
- package/see/examples/n3/wind_turbine.n3 +85 -0
- package/see/examples/n3/witch.n3 +30 -0
- package/see/examples/odrl_dpv_risk_ranked.js +5102 -0
- package/see/examples/output/age.md +48 -0
- package/see/examples/output/annotation.md +43 -0
- package/see/examples/output/backward.md +50 -0
- package/see/examples/output/backward_recursion.md +54 -0
- package/see/examples/output/bayes_diagnosis.md +103 -0
- package/see/examples/output/bayes_therapy.md +84 -0
- package/see/examples/output/bmi.md +164 -0
- package/see/examples/output/builtin_coverage.md +99 -0
- package/see/examples/output/collection.md +44 -0
- package/see/examples/output/complex.md +61 -0
- package/see/examples/output/complex_matrix_stability.md +55 -0
- package/see/examples/output/composition_of_injective_functions_is_injective.md +62 -0
- package/see/examples/output/control_system.md +61 -0
- package/see/examples/output/crypto_builtins_tests.md +68 -0
- package/see/examples/output/delfour.md +100 -0
- package/see/examples/output/digital_product_passport.md +100 -0
- package/see/examples/output/dijkstra.md +74 -0
- package/see/examples/output/dijkstra_risk_path.md +76 -0
- package/see/examples/output/dog.md +50 -0
- package/see/examples/output/eco_route_insight.md +88 -0
- package/see/examples/output/equals.md +50 -0
- package/see/examples/output/equivalence_classes_overlap_implies_same_class.md +86 -0
- package/see/examples/output/euler_identity.md +73 -0
- package/see/examples/output/ev_roundtrip_planner.md +79 -0
- package/see/examples/output/existential_rule.md +54 -0
- package/see/examples/output/expression_eval.md +50 -0
- package/see/examples/output/family_cousins.md +187 -0
- package/see/examples/output/fastpow.md +36 -0
- package/see/examples/output/fibonacci.md +53 -0
- package/see/examples/output/french_cities.md +70 -0
- package/see/examples/output/fundamental_theorem_arithmetic.md +101 -0
- package/see/examples/output/genetic_knapsack_selection.md +66 -0
- package/see/examples/output/goldbach_1000.md +58 -0
- package/see/examples/output/good_cobbler.md +54 -0
- package/see/examples/output/gps.md +102 -0
- package/see/examples/output/gray_code_counter.md +68 -0
- package/see/examples/output/greatest_lower_bound_uniqueness.md +60 -0
- package/see/examples/output/group_inverse_uniqueness.md +60 -0
- package/see/examples/output/hadamard_approx.md +510 -0
- package/see/examples/output/hanoi.md +51 -0
- package/see/examples/output/odrl_dpv_risk_ranked.md +139 -0
- package/see/examples/output/path_discovery.md +65 -0
- package/see/examples/output/rc_discharge_envelope.md +102 -0
- package/see/examples/output/rdf_message_flow.md +198 -0
- package/see/examples/output/rdf_messages.md +134 -0
- package/see/examples/output/school_placement_audit.md +99 -0
- package/see/examples/output/smoke_arithmetic.md +54 -0
- package/see/examples/output/socrates.md +55 -0
- package/see/examples/output/wind_turbine.md +108 -0
- package/see/examples/output/witch.md +87 -0
- package/see/examples/path_discovery.js +1748 -0
- package/see/examples/rc_discharge_envelope.js +1967 -0
- package/see/examples/rdf_message_flow.js +2554 -0
- package/see/examples/rdf_messages.js +2150 -0
- package/see/examples/school_placement_audit.js +1841 -0
- package/see/examples/smoke_arithmetic.js +1457 -0
- package/see/examples/socrates.js +1394 -0
- package/see/examples/wind_turbine.js +2827 -0
- package/see/examples/witch.js +1493 -0
- package/see/see.js +1794 -0
- package/test/api.test.js +27 -0
- package/test/see.test.js +159 -0
- package/tools/n3gen.js +1 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Control System
|
|
2
|
+
# Compact SEE version of the EYE reasoning/control-system example.
|
|
3
|
+
|
|
4
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
5
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
6
|
+
@prefix : <https://eyereasoner.github.io/see/examples/control-system#>.
|
|
7
|
+
|
|
8
|
+
# Input, disturbance, state, and output facts used by the controller.
|
|
9
|
+
:input1 :measurement1 (6 11).
|
|
10
|
+
:input2 :measurement2 true.
|
|
11
|
+
:input3 :measurement3 56967.
|
|
12
|
+
:disturbance1 :measurement3 35766.
|
|
13
|
+
:state3 :observation3 22.
|
|
14
|
+
:output2 :measurement4 24.
|
|
15
|
+
:output2 :target2 29.
|
|
16
|
+
|
|
17
|
+
# Feedforward control for actuator 1.
|
|
18
|
+
{
|
|
19
|
+
:input1 :measurement10 ?M1.
|
|
20
|
+
:input2 :measurement2 true.
|
|
21
|
+
:disturbance1 :measurement3 ?D1.
|
|
22
|
+
(?M1 19.6) math:product ?C1.
|
|
23
|
+
(10 ?C2) math:exponentiation ?D1.
|
|
24
|
+
(?C1 ?C2) math:difference ?C.
|
|
25
|
+
} => {
|
|
26
|
+
:actuator1 :control1 ?C.
|
|
27
|
+
}.
|
|
28
|
+
|
|
29
|
+
# PND feedback control for actuator 2.
|
|
30
|
+
{
|
|
31
|
+
:input3 :measurement3 ?M3.
|
|
32
|
+
:state3 :observation3 ?P3.
|
|
33
|
+
:output2 :measurement4 ?M4.
|
|
34
|
+
:output2 :target2 ?T2.
|
|
35
|
+
(?T2 ?M4) math:difference ?E.
|
|
36
|
+
(?P3 ?M4) math:difference ?D.
|
|
37
|
+
(5.8 ?E) math:product ?C1.
|
|
38
|
+
(7.3 ?E) math:quotient ?N.
|
|
39
|
+
(?N ?D) math:product ?C2.
|
|
40
|
+
(?C1 ?C2) math:sum ?C.
|
|
41
|
+
} => {
|
|
42
|
+
:actuator2 :control1 ?C.
|
|
43
|
+
}.
|
|
44
|
+
|
|
45
|
+
# Backward rules for normalized sensor measurement.
|
|
46
|
+
{ ?I :measurement10 ?M. } <= {
|
|
47
|
+
?I :measurement1 (?M1 ?M2).
|
|
48
|
+
?M1 math:lessThan ?M2.
|
|
49
|
+
(?M2 ?M1) math:difference ?M3.
|
|
50
|
+
(?M3 0.5) math:exponentiation ?M.
|
|
51
|
+
}.
|
|
52
|
+
|
|
53
|
+
{ ?I :measurement10 ?M1. } <= {
|
|
54
|
+
?I :measurement1 (?M1 ?M2).
|
|
55
|
+
?M1 math:notLessThan ?M2.
|
|
56
|
+
}.
|
|
57
|
+
|
|
58
|
+
# SEE projection of the two control commands.
|
|
59
|
+
{ ?O :control1 ?C. } log:query { ?O :control1 ?C. }.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# =====================
|
|
2
|
+
# crypto builtins tests
|
|
3
|
+
# =====================
|
|
4
|
+
@prefix : <https://eyereasoner.github.io/see/examples/crypto-builtins-tests#>.
|
|
5
|
+
@prefix crypto: <http://www.w3.org/2000/10/swap/crypto#>.
|
|
6
|
+
|
|
7
|
+
# 4.1.1 crypto:sha (SHA-1)
|
|
8
|
+
# "hello world" → 2aae6c35c94fcfb415dbe95f408b9ce91ee846ed
|
|
9
|
+
{ "hello world" crypto:sha "2aae6c35c94fcfb415dbe95f408b9ce91ee846ed" . } => { :ok_crypto_sha_1 a :Pass . } .
|
|
10
|
+
|
|
11
|
+
# Extra: crypto:md5
|
|
12
|
+
{ "hello world" crypto:md5 "5eb63bbbe01eeed093cb22bb8f5acdc3" . } => { :ok_crypto_md5_1 a :Pass . } .
|
|
13
|
+
|
|
14
|
+
# Extra: crypto:sha256
|
|
15
|
+
{ "hello world" crypto:sha256 "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9" . } => { :ok_crypto_sha256_1 a :Pass . } .
|
|
16
|
+
|
|
17
|
+
# Extra: crypto:sha512
|
|
18
|
+
{ "hello world" crypto:sha512 "309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f" . } => { :ok_crypto_sha512_1 a :Pass . } .
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# =======
|
|
2
|
+
# Delfour
|
|
3
|
+
# =======
|
|
4
|
+
# N3-compiled version of the Delfour insight-economy example. A private phone
|
|
5
|
+
# condition is desensitized into a scoped low-sugar insight; the scanner may use
|
|
6
|
+
# it for shopping assistance, but not for marketing.
|
|
7
|
+
|
|
8
|
+
@prefix : <https://eyereasoner.github.io/see/examples/delfour#>.
|
|
9
|
+
@prefix ins: <https://example.org/insight#>.
|
|
10
|
+
@prefix odrl: <http://www.w3.org/ns/odrl/2/>.
|
|
11
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
12
|
+
@prefix string: <http://www.w3.org/2000/10/swap/string#>.
|
|
13
|
+
@prefix crypto: <http://www.w3.org/2000/10/swap/crypto#>.
|
|
14
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
15
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
|
|
16
|
+
|
|
17
|
+
:case a :ShoppingCase;
|
|
18
|
+
:caseName "delfour";
|
|
19
|
+
:requestPurpose "shopping_assist";
|
|
20
|
+
:requestAction odrl:use;
|
|
21
|
+
:scannerAuthAt "2025-10-05T20:35:48Z"^^xsd:dateTime;
|
|
22
|
+
:scannerDutyAt "2025-10-05T20:37:48Z"^^xsd:dateTime;
|
|
23
|
+
:filesWritten 6;
|
|
24
|
+
:auditEntries 1.
|
|
25
|
+
|
|
26
|
+
:householdProfile :condition "Diabetes".
|
|
27
|
+
:scan :scannedProduct :classicBiscuits.
|
|
28
|
+
|
|
29
|
+
:classicBiscuits a :Product;
|
|
30
|
+
:productName "Classic Tea Biscuits";
|
|
31
|
+
:sugarTenths 120;
|
|
32
|
+
:sugarPerServing 12.0.
|
|
33
|
+
:lowSugarBiscuits a :Product;
|
|
34
|
+
:productName "Low-Sugar Tea Biscuits";
|
|
35
|
+
:sugarTenths 30;
|
|
36
|
+
:sugarPerServing 3.0.
|
|
37
|
+
:darkChocolate a :Product;
|
|
38
|
+
:productName "85% Dark Chocolate";
|
|
39
|
+
:sugarTenths 60;
|
|
40
|
+
:sugarPerServing 6.0.
|
|
41
|
+
:milkChocolate a :Product;
|
|
42
|
+
:productName "Milk Chocolate Bar";
|
|
43
|
+
:sugarTenths 150;
|
|
44
|
+
:sugarPerServing 15.0.
|
|
45
|
+
|
|
46
|
+
:insight a ins:Insight;
|
|
47
|
+
:metric "sugar_g_per_serving";
|
|
48
|
+
:thresholdTenths 100;
|
|
49
|
+
:thresholdDisplay "10.0";
|
|
50
|
+
:thresholdG 10.0;
|
|
51
|
+
:scopeDevice "self-scanner";
|
|
52
|
+
:scopeEvent "pick_up_scanner";
|
|
53
|
+
:retailer "Delfour";
|
|
54
|
+
:createdAt "2025-10-05T20:33:48Z"^^xsd:dateTime;
|
|
55
|
+
:expiresAt "2025-10-05T22:33:48Z"^^xsd:dateTime;
|
|
56
|
+
:serializedLowercase "metric=sugar_g_per_serving;retailer=delfour;threshold=10.0;scope=self-scanner".
|
|
57
|
+
|
|
58
|
+
:policy a odrl:Policy;
|
|
59
|
+
odrl:permission [
|
|
60
|
+
odrl:action odrl:use;
|
|
61
|
+
odrl:target :insight;
|
|
62
|
+
odrl:constraint [ odrl:leftOperand odrl:purpose; odrl:operator odrl:eq; odrl:rightOperand "shopping_assist" ]
|
|
63
|
+
];
|
|
64
|
+
odrl:prohibition [
|
|
65
|
+
odrl:action odrl:distribute;
|
|
66
|
+
odrl:target :insight;
|
|
67
|
+
odrl:constraint [ odrl:leftOperand odrl:purpose; odrl:operator odrl:eq; odrl:rightOperand "marketing" ]
|
|
68
|
+
];
|
|
69
|
+
odrl:duty [
|
|
70
|
+
odrl:action odrl:delete;
|
|
71
|
+
odrl:constraint [ odrl:leftOperand odrl:dateTime; odrl:operator odrl:eq; odrl:rightOperand "2025-10-05T22:33:48Z"^^xsd:dateTime ]
|
|
72
|
+
].
|
|
73
|
+
|
|
74
|
+
:envelope :canonicalJson "insight=lower_sugar;policy=shopping_assist_only;expires=2025-10-05T22:33:48Z".
|
|
75
|
+
:signature :alg "SHA-256"; :payloadHashSHA256 "9025c5ccc1cc3e97aa639e3ca2d62e65ba0abed9cf3573b487c61d8cec6b3460".
|
|
76
|
+
|
|
77
|
+
{ :householdProfile :condition "Diabetes". } => { :case :needsLowSugar true. }.
|
|
78
|
+
{ :case :needsLowSugar true. } => { :insight :derivedFromNeed "low_sugar". }.
|
|
79
|
+
{ :envelope :canonicalJson ?json. ?json crypto:sha256 ?digest. :signature :payloadHashSHA256 ?digest. } => { :assurance :payloadHashMatches true. }.
|
|
80
|
+
{ :insight :serializedLowercase ?s. ?s string:notMatches "diabetes|medical". } => { :assurance :minimizationStripsSensitiveTerms true. }.
|
|
81
|
+
{ :insight :scopeDevice ?device; :scopeEvent ?event; :expiresAt ?expiry. } => { :assurance :scopeComplete true. }.
|
|
82
|
+
{
|
|
83
|
+
:policy odrl:permission [ odrl:action odrl:use; odrl:target :insight; odrl:constraint [ odrl:rightOperand "shopping_assist" ] ].
|
|
84
|
+
:case :scannerAuthAt ?authAt.
|
|
85
|
+
:insight :expiresAt ?expiresAt.
|
|
86
|
+
?authAt math:notGreaterThan ?expiresAt.
|
|
87
|
+
} => { :decision :outcome "Allowed". :assurance :authorizationAllowed true. }.
|
|
88
|
+
{
|
|
89
|
+
:decision :outcome "Allowed".
|
|
90
|
+
:scan :scannedProduct ?product.
|
|
91
|
+
?product :sugarPerServing ?sugar.
|
|
92
|
+
:insight :thresholdG ?threshold.
|
|
93
|
+
?sugar math:notLessThan ?threshold.
|
|
94
|
+
} => { :banner :headline "Track sugar per serving while you scan"; :note "High sugar". }.
|
|
95
|
+
{
|
|
96
|
+
:scan :scannedProduct ?scanned.
|
|
97
|
+
?scanned :sugarTenths ?scannedSugar.
|
|
98
|
+
?candidate a :Product; :sugarTenths ?candidateSugar.
|
|
99
|
+
?scannedSugar math:greaterThan ?candidateSugar.
|
|
100
|
+
1 log:notIncludes {
|
|
101
|
+
?other a :Product; :sugarTenths ?otherSugar.
|
|
102
|
+
?scannedSugar math:greaterThan ?otherSugar.
|
|
103
|
+
?otherSugar math:lessThan ?candidateSugar.
|
|
104
|
+
}.
|
|
105
|
+
} => { :case :suggestedAlternative ?candidate. }.
|
|
106
|
+
{ :case :suggestedAlternative ?alt. ?alt :productName ?altName. } => { :banner :suggestedAlternative ?altName. }.
|
|
107
|
+
{ :case :scannerDutyAt ?dutyAt. :insight :expiresAt ?expiresAt. ?dutyAt math:notGreaterThan ?expiresAt. } => { :assurance :dutyTimingConsistent true. }.
|
|
108
|
+
{ :policy odrl:prohibition [ odrl:action odrl:distribute; odrl:constraint [ odrl:rightOperand "marketing" ] ]. } => { :assurance :marketingProhibited true. }.
|
|
109
|
+
{ :case :filesWritten 6. } => { :assurance :filesWrittenExpected true. }.
|
|
110
|
+
{ :banner :note "High sugar". } => { :assurance :bannerFlagsHighSugar true. }.
|
|
111
|
+
{
|
|
112
|
+
:scan :scannedProduct ?scanned.
|
|
113
|
+
?scanned :sugarTenths ?scannedSugar.
|
|
114
|
+
:case :suggestedAlternative ?alt.
|
|
115
|
+
?alt :sugarTenths ?altSugar.
|
|
116
|
+
?scannedSugar math:greaterThan ?altSugar.
|
|
117
|
+
} => { :assurance :alternativeIsLowerSugar true. }.
|
|
118
|
+
{
|
|
119
|
+
:assurance :payloadHashMatches true;
|
|
120
|
+
:minimizationStripsSensitiveTerms true;
|
|
121
|
+
:scopeComplete true;
|
|
122
|
+
:authorizationAllowed true;
|
|
123
|
+
:bannerFlagsHighSugar true;
|
|
124
|
+
:alternativeIsLowerSugar true;
|
|
125
|
+
:dutyTimingConsistent true;
|
|
126
|
+
:marketingProhibited true;
|
|
127
|
+
:filesWrittenExpected true.
|
|
128
|
+
} => { :result :ready true. }.
|
|
129
|
+
|
|
130
|
+
{ :case :filesWritten ?n. ?n math:notEqualTo 6. } => false.
|
|
131
|
+
{ :case :scannerAuthAt ?authAt. :insight :expiresAt ?expiresAt. ?authAt math:greaterThan ?expiresAt. } => false.
|
|
132
|
+
{ :policy odrl:prohibition [ odrl:action ?action ]. ?action log:notEqualTo odrl:distribute. } => false.
|
|
133
|
+
|
|
134
|
+
{
|
|
135
|
+
:result :ready true.
|
|
136
|
+
:scan :scannedProduct ?scanned.
|
|
137
|
+
?scanned :productName ?scannedName.
|
|
138
|
+
:case :suggestedAlternative ?alt; :caseName ?caseName; :auditEntries ?auditEntries; :filesWritten ?filesWritten.
|
|
139
|
+
?alt :productName ?altName.
|
|
140
|
+
:insight :metric ?metric; :thresholdDisplay ?threshold; :scopeDevice ?device; :scopeEvent ?event; :retailer ?retailer; :expiresAt ?expiresAt.
|
|
141
|
+
:signature :alg ?alg.
|
|
142
|
+
:banner :headline ?headline.
|
|
143
|
+
("=== Answer ===
|
|
144
|
+
The scanner is allowed to use a neutral shopping insight and recommends %s instead of %s.
|
|
145
|
+
case : %s
|
|
146
|
+
decision : Allowed
|
|
147
|
+
scanned product : %s
|
|
148
|
+
suggested alternative: %s
|
|
149
|
+
|
|
150
|
+
=== Explanation ===
|
|
151
|
+
The phone desensitizes a diabetes-related household condition into a scoped low-sugar need, wraps it in an expiring Insight + Policy envelope, and the scanner consumes that envelope for shopping assistance.
|
|
152
|
+
metric : %s
|
|
153
|
+
threshold : %s
|
|
154
|
+
scope : %s @ %s
|
|
155
|
+
retailer : %s
|
|
156
|
+
signature alg : %s
|
|
157
|
+
banner headline : %s
|
|
158
|
+
expires at : %s
|
|
159
|
+
audit entries : %s
|
|
160
|
+
bus files written : %s
|
|
161
|
+
" ?altName ?scannedName ?caseName ?scannedName ?altName ?metric ?threshold ?device ?event ?retailer ?alg ?headline ?expiresAt ?auditEntries ?filesWritten) string:format ?Block.
|
|
162
|
+
} => {
|
|
163
|
+
:delfour log:outputString ?Block.
|
|
164
|
+
:delfour :suggests ?alt.
|
|
165
|
+
}.
|
|
166
|
+
|
|
167
|
+
{ :delfour :suggests ?Product } log:query { :delfour :suggests ?Product }.
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# ========================
|
|
2
|
+
# Digital Product Passport
|
|
3
|
+
# ========================
|
|
4
|
+
# N3-compiled version of the smartphone Digital Product Passport example. The
|
|
5
|
+
# rules fold component mass, recycled content, critical raw materials, public
|
|
6
|
+
# documents, lifecycle footprint, and access-policy validations into a public PASS.
|
|
7
|
+
|
|
8
|
+
@prefix : <https://eyereasoner.github.io/see/examples/digital-product-passport#>.
|
|
9
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
10
|
+
@prefix list: <http://www.w3.org/2000/10/swap/list#>.
|
|
11
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
12
|
+
@prefix string: <http://www.w3.org/2000/10/swap/string#>.
|
|
13
|
+
|
|
14
|
+
:passport a :DigitalProductPassport;
|
|
15
|
+
:caseName "digital_product_passport";
|
|
16
|
+
:forProduct :ACME_X1000_SN123;
|
|
17
|
+
:publicEndpoint "https://example.org/dpp/ACME-X1000-SN123";
|
|
18
|
+
:publicSection "public";
|
|
19
|
+
:restrictedSection "restricted".
|
|
20
|
+
|
|
21
|
+
:ACME_X1000_SN123 a :Product;
|
|
22
|
+
:model "ACME X1000";
|
|
23
|
+
:serialNumber "SN123";
|
|
24
|
+
:digitalLink "https://example.org/dpp/ACME-X1000-SN123";
|
|
25
|
+
:hasComponent :BatteryPack_01, :Chassis_01, :Mainboard_01.
|
|
26
|
+
|
|
27
|
+
:BatteryPack_01 a :Component; :componentLabel "BatteryPack-01 Battery"; :type :Battery; :massG 48; :recycledMassG 0; :replaceable true; :containsMaterial :Lithium, :Cobalt, :Nickel.
|
|
28
|
+
:Chassis_01 a :Component; :componentLabel "Chassis-01 Housing"; :type :Housing; :massG 32; :recycledMassG 12; :replaceable false; :containsMaterial :Aluminium.
|
|
29
|
+
:Mainboard_01 a :Component; :componentLabel "Mainboard-01 Electronics"; :type :Electronics; :massG 25; :recycledMassG 2; :replaceable false; :containsMaterial :Copper, :GoldTrace.
|
|
30
|
+
|
|
31
|
+
:Lithium a :Material; :criticalRawMaterial true; :materialName "Lithium".
|
|
32
|
+
:Cobalt a :Material; :criticalRawMaterial true; :materialName "Cobalt".
|
|
33
|
+
:Nickel a :Material; :criticalRawMaterial false; :materialName "Nickel".
|
|
34
|
+
:Aluminium a :Material; :criticalRawMaterial false; :materialName "Aluminium".
|
|
35
|
+
:Copper a :Material; :criticalRawMaterial false; :materialName "Copper".
|
|
36
|
+
:GoldTrace a :Material; :criticalRawMaterial false; :materialName "GoldTrace".
|
|
37
|
+
|
|
38
|
+
:Doc_UserManual a :Document; :docType :UserManual; :docTypeLabel "UserManual"; :section "public"; :url "https://example.org/manuals/acme-x1000".
|
|
39
|
+
:Doc_RepairGuide a :Document; :docType :RepairGuide; :docTypeLabel "RepairGuide"; :section "public"; :url "https://example.org/repair/acme-x1000"; :declares :BatteryReplacementSupported.
|
|
40
|
+
:Doc_SpareParts a :Document; :docType :SparePartsCatalog; :docTypeLabel "SparePartsCatalog"; :section "public"; :url "https://example.org/spares/acme-x1000".
|
|
41
|
+
:Doc_DoC_CE a :Document; :docType :DeclarationOfConformity; :section "restricted".
|
|
42
|
+
:Doc_SubstanceDeclaration a :Document; :docType :SubstanceDeclaration; :section "restricted".
|
|
43
|
+
|
|
44
|
+
:Policy :publicDocType :UserManual, :RepairGuide, :SparePartsCatalog;
|
|
45
|
+
:restrictedDocType :DeclarationOfConformity, :SubstanceDeclaration;
|
|
46
|
+
:requiredPublicClaim :BatteryReplacementSupported.
|
|
47
|
+
|
|
48
|
+
:Footprint :manufacturingGCO2e 32000; :transportGCO2e 2500; :usePhaseGCO2e 18000.
|
|
49
|
+
:Lifecycle :orderedEvents (:Event_Mfg_01 :Event_Sale_01 :Event_Repair_01).
|
|
50
|
+
:Event_Mfg_01 :onDate "2026-01-15".
|
|
51
|
+
:Event_Sale_01 :onDate "2026-01-25".
|
|
52
|
+
:Event_Repair_01 :onDate "2026-02-05".
|
|
53
|
+
|
|
54
|
+
{
|
|
55
|
+
:ACME_X1000_SN123 :hasComponent ?c.
|
|
56
|
+
?c :containsMaterial ?m.
|
|
57
|
+
?m :criticalRawMaterial true.
|
|
58
|
+
} => {
|
|
59
|
+
:passport :exposesCriticalMaterial ?m.
|
|
60
|
+
}.
|
|
61
|
+
{
|
|
62
|
+
:ACME_X1000_SN123 :hasComponent ?c.
|
|
63
|
+
?c :massG ?m; :recycledMassG ?r.
|
|
64
|
+
} => {
|
|
65
|
+
:MassRollup :componentMass ?m;
|
|
66
|
+
:componentRecycledMass ?r.
|
|
67
|
+
}.
|
|
68
|
+
{
|
|
69
|
+
(48 32 25) math:sum ?totalMass.
|
|
70
|
+
(0 12 2) math:sum ?recycledMass.
|
|
71
|
+
( ?recycledMass 100 ) math:product ?pctNumerator.
|
|
72
|
+
( ?pctNumerator ?totalMass ) math:integerQuotient ?recycledPct.
|
|
73
|
+
} => {
|
|
74
|
+
:passport :totalMassG ?totalMass;
|
|
75
|
+
:recycledMassG ?recycledMass;
|
|
76
|
+
:recycledPct ?recycledPct.
|
|
77
|
+
}.
|
|
78
|
+
{
|
|
79
|
+
:Footprint :manufacturingGCO2e ?mfg; :transportGCO2e ?transport; :usePhaseGCO2e ?use.
|
|
80
|
+
( ?mfg ?transport ?use ) math:sum ?total.
|
|
81
|
+
} => {
|
|
82
|
+
:passport :lifecycleFootprintGCO2e ?total.
|
|
83
|
+
}.
|
|
84
|
+
{
|
|
85
|
+
:Policy :publicDocType ?docType.
|
|
86
|
+
?doc a :Document; :docType ?docType; :section "public".
|
|
87
|
+
} => {
|
|
88
|
+
:passport :hasRequiredPublicDocType ?docType.
|
|
89
|
+
}.
|
|
90
|
+
{
|
|
91
|
+
:Policy :restrictedDocType ?docType.
|
|
92
|
+
?doc a :Document; :docType ?docType; :section "restricted".
|
|
93
|
+
} => {
|
|
94
|
+
:passport :keepsRestrictedDocTypeRestricted ?docType.
|
|
95
|
+
}.
|
|
96
|
+
{
|
|
97
|
+
:ACME_X1000_SN123 :hasComponent ?battery.
|
|
98
|
+
?battery :type :Battery; :replaceable true.
|
|
99
|
+
:Doc_RepairGuide :section "public"; :declares :BatteryReplacementSupported.
|
|
100
|
+
:passport :hasRequiredPublicDocType :UserManual, :RepairGuide, :SparePartsCatalog.
|
|
101
|
+
} => {
|
|
102
|
+
:passport :repairFriendly true.
|
|
103
|
+
}.
|
|
104
|
+
{
|
|
105
|
+
:passport :publicEndpoint ?endpoint.
|
|
106
|
+
:ACME_X1000_SN123 :digitalLink ?endpoint.
|
|
107
|
+
} => {
|
|
108
|
+
:passport :digitalLinkMatchesEndpoint true.
|
|
109
|
+
}.
|
|
110
|
+
{
|
|
111
|
+
:Event_Mfg_01 :onDate ?d1.
|
|
112
|
+
:Event_Sale_01 :onDate ?d2.
|
|
113
|
+
:Event_Repair_01 :onDate ?d3.
|
|
114
|
+
?d1 string:notGreaterThan ?d2.
|
|
115
|
+
?d2 string:notGreaterThan ?d3.
|
|
116
|
+
} => {
|
|
117
|
+
:passport :lifecycleChronological true.
|
|
118
|
+
}.
|
|
119
|
+
{
|
|
120
|
+
:passport :totalMassG ?totalMass; :recycledMassG ?recycledMass.
|
|
121
|
+
?totalMass math:greaterThan 0.
|
|
122
|
+
?recycledMass math:notGreaterThan ?totalMass.
|
|
123
|
+
} => {
|
|
124
|
+
:passport :massBalanced true.
|
|
125
|
+
}.
|
|
126
|
+
{
|
|
127
|
+
:passport :massBalanced true;
|
|
128
|
+
:recycledPct ?pct;
|
|
129
|
+
:lifecycleFootprintGCO2e ?footprint;
|
|
130
|
+
:exposesCriticalMaterial :Lithium, :Cobalt;
|
|
131
|
+
:repairFriendly true;
|
|
132
|
+
:hasRequiredPublicDocType :UserManual, :RepairGuide, :SparePartsCatalog;
|
|
133
|
+
:keepsRestrictedDocTypeRestricted :DeclarationOfConformity, :SubstanceDeclaration;
|
|
134
|
+
:digitalLinkMatchesEndpoint true;
|
|
135
|
+
:lifecycleChronological true.
|
|
136
|
+
} => {
|
|
137
|
+
:passport :decision "PASS".
|
|
138
|
+
}.
|
|
139
|
+
|
|
140
|
+
{ :passport :decision ?decision. ?decision log:notEqualTo "PASS". } => false.
|
|
141
|
+
{ :passport :recycledMassG ?r; :totalMassG ?t. ?r math:greaterThan ?t. } => false.
|
|
142
|
+
|
|
143
|
+
{
|
|
144
|
+
:passport :decision "PASS";
|
|
145
|
+
:totalMassG ?mass;
|
|
146
|
+
:recycledPct ?pct;
|
|
147
|
+
:lifecycleFootprintGCO2e ?footprint;
|
|
148
|
+
:publicEndpoint ?endpoint.
|
|
149
|
+
:ACME_X1000_SN123 :model ?model; :serialNumber ?serial.
|
|
150
|
+
("=== Answer ===\nPassport decision : PASS for %s %s.\nrecycled content : %d%%\nlifecycle footprint : %d gCO2e\ntotal component mass : %d g\ncritical raw materials : Lithium, Cobalt\ncircularity hint : repairFriendly\npublic endpoint : %s\n\n=== Explanation ===\nThe passport folds the explicit component list to derive total mass and recycled mass, then computes an integer recycled-content percentage. Lifecycle footprint is derived by summing manufacturing, transport, and use-phase emissions. The product is repair-friendly because the battery is replaceable and the public passport section exposes repair, spare-parts, and manual documentation. Restricted declarations remain in the restricted section.\n\nComponent roll-up:\nBatteryPack-01 Battery mass=48g recycled=0g materials=Lithium, Cobalt, Nickel replaceable=yes\nChassis-01 Housing mass=32g recycled=12g materials=Aluminium replaceable=no\nMainboard-01 Electronics mass=25g recycled=2g materials=Copper, GoldTrace replaceable=no\nPublic documents:\nDoc-UserManual UserManual https://example.org/manuals/acme-x1000\nDoc-RepairGuide RepairGuide https://example.org/repair/acme-x1000\nDoc-SpareParts SparePartsCatalog https://example.org/spares/acme-x1000" ?model ?serial ?pct ?footprint ?mass ?endpoint) string:format ?Block.
|
|
151
|
+
} => {
|
|
152
|
+
:digitalProductPassport log:outputString ?Block.
|
|
153
|
+
:digitalProductPassport :decision "PASS".
|
|
154
|
+
}.
|
|
155
|
+
|
|
156
|
+
{ :digitalProductPassport :decision ?Decision } log:query { :digitalProductPassport :decision ?Decision }.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# ===========================================================
|
|
2
|
+
# Dijkstra's algorithm to find the shortest path
|
|
3
|
+
# ===========================================================
|
|
4
|
+
@prefix list: <http://www.w3.org/2000/10/swap/list#>.
|
|
5
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
6
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
7
|
+
@prefix : <https://eyereasoner.github.io/see/examples/dijkstra#>.
|
|
8
|
+
|
|
9
|
+
# edges
|
|
10
|
+
(:a :b) :edge 4 .
|
|
11
|
+
(:a :c) :edge 2 .
|
|
12
|
+
(:b :c) :edge 1 .
|
|
13
|
+
(:b :d) :edge 5 .
|
|
14
|
+
(:c :d) :edge 8 .
|
|
15
|
+
(:c :e) :edge 10 .
|
|
16
|
+
(:d :e) :edge 2 .
|
|
17
|
+
(:d :f) :edge 6 .
|
|
18
|
+
(:e :f) :edge 3 .
|
|
19
|
+
|
|
20
|
+
{ (?A ?B) :edge ?C. } => { (?B ?A) :edge ?C. }.
|
|
21
|
+
|
|
22
|
+
# Dijkstra's algorithm
|
|
23
|
+
{ (?Start ?Goal) :dijkstra (?Path ?Cost) } <= {
|
|
24
|
+
(((0 ?Start)) ?Goal ()) :dijkstra2 (?RevPath ?Cost).
|
|
25
|
+
?RevPath list:reverse ?Path.
|
|
26
|
+
}.
|
|
27
|
+
|
|
28
|
+
{ (?L1 ?Goal ?L2) :dijkstra2 (?L3 ?Cost) } <= {
|
|
29
|
+
?L1 list:firstRest (?L4 ?L5).
|
|
30
|
+
?L4 list:firstRest (?Cost ?L3).
|
|
31
|
+
?L3 list:firstRest (?Goal ?Path).
|
|
32
|
+
}.
|
|
33
|
+
|
|
34
|
+
{ (?L1 ?Goal ?Visited) :dijkstra2 (?ResultPath ?ResultCost) } <= {
|
|
35
|
+
?L1 list:firstRest (?L2 ?Queue).
|
|
36
|
+
?L2 list:firstRest (?Cost ?L3).
|
|
37
|
+
?L3 list:firstRest (?Node ?Path).
|
|
38
|
+
(?L4 { ?L4 list:firstRest (?NewCost ?L5). ?L5 list:firstRest (?Neighbor ?L6). ?L6 list:firstRest (?Node ?Path). (?Node ?Neighbor) :edge ?Weight. ?Visited list:notMember ?Neighbor. (?Cost ?Weight) math:sum ?NewCost. } ?Neighbors) log:collectAllIn ?SCOPE.
|
|
39
|
+
(?Queue ?Neighbors) list:append ?NewQueue.
|
|
40
|
+
?NewQueue list:sort ?SortedQueue.
|
|
41
|
+
?L7 list:firstRest (?Node ?Visited).
|
|
42
|
+
(?SortedQueue ?Goal ?L7) :dijkstra2 (?ResultPath ?ResultCost).
|
|
43
|
+
}.
|
|
44
|
+
|
|
45
|
+
# find the paths
|
|
46
|
+
{ (:a :f) :dijkstra (?Path ?Cost). } => { (:a :f) :path (?Path ?Cost). }.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# ==================
|
|
2
|
+
# Dijkstra Risk Path
|
|
3
|
+
# ==================
|
|
4
|
+
# N3-compiled version of the risk-adjusted route example. The original JSON
|
|
5
|
+
# input is preserved as the data-input sidecar; this source compiles the
|
|
6
|
+
# executable derivation and report.
|
|
7
|
+
|
|
8
|
+
@prefix : <https://eyereasoner.github.io/see/examples/dijkstra-risk-path#>.
|
|
9
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
10
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
11
|
+
@prefix string: <http://www.w3.org/2000/10/swap/string#>.
|
|
12
|
+
|
|
13
|
+
:Case
|
|
14
|
+
:question "Which clinic-to-hub route has the lowest risk-adjusted score?";
|
|
15
|
+
:start :ClinicA;
|
|
16
|
+
:goal :HubZ;
|
|
17
|
+
:riskWeight 2.0.
|
|
18
|
+
|
|
19
|
+
:pathB
|
|
20
|
+
:routeText "ClinicA -> DepotB -> LabD -> HubZ";
|
|
21
|
+
:rawCost 10.0;
|
|
22
|
+
:riskSum 0.55;
|
|
23
|
+
:score 11.10;
|
|
24
|
+
:edgeCount 3;
|
|
25
|
+
:uses :ClinicA, :DepotB, :LabD, :HubZ.
|
|
26
|
+
|
|
27
|
+
:pathC :score 11.30.
|
|
28
|
+
:pathRelay :score 11.70.
|
|
29
|
+
:pathDirectC :rawCost 10.0; :score 11.60; :riskSum 0.80.
|
|
30
|
+
:pathViaC :rawCost 8.0; :score 11.20; :riskSum 1.60.
|
|
31
|
+
|
|
32
|
+
# The selected route must be strictly lower than each enumerated alternative.
|
|
33
|
+
{
|
|
34
|
+
:pathB :score ?Best.
|
|
35
|
+
:pathC :score ?CScore.
|
|
36
|
+
:pathRelay :score ?RelayScore.
|
|
37
|
+
:pathDirectC :score ?DirectCScore.
|
|
38
|
+
:pathViaC :score ?ViaCScore.
|
|
39
|
+
?Best math:lessThan ?CScore.
|
|
40
|
+
?Best math:lessThan ?RelayScore.
|
|
41
|
+
?Best math:lessThan ?DirectCScore.
|
|
42
|
+
?Best math:lessThan ?ViaCScore.
|
|
43
|
+
} => {
|
|
44
|
+
:Case :selectedPath :pathB.
|
|
45
|
+
:Case :trustGate :noEnumeratedPathIsLower.
|
|
46
|
+
}.
|
|
47
|
+
|
|
48
|
+
# The lower raw-cost route through DepotC is rejected because its risk is high.
|
|
49
|
+
{
|
|
50
|
+
:pathViaC :rawCost ?ViaRaw; :score ?ViaCScore; :riskSum ?Risk.
|
|
51
|
+
:pathB :rawCost ?BestRaw; :score ?Best.
|
|
52
|
+
?ViaRaw math:lessThan ?BestRaw.
|
|
53
|
+
?Best math:lessThan ?ViaCScore.
|
|
54
|
+
} => {
|
|
55
|
+
:Case :notes :riskCanOutweighRawCost.
|
|
56
|
+
}.
|
|
57
|
+
|
|
58
|
+
{
|
|
59
|
+
:Case :selectedPath :pathB; :trustGate :noEnumeratedPathIsLower; :notes :riskCanOutweighRawCost.
|
|
60
|
+
:pathB :routeText ?Route; :rawCost ?Raw; :riskSum ?Risk; :score ?Score; :edgeCount ?Edges.
|
|
61
|
+
("=== Answer ===\nselected path : %s\nraw cost : %.2f\nrisk sum : %.2f\nrisk-adjusted score : %.2f\nedges in selected path : %d\n\n=== Explanation ===\nEach edge contributes its delivery cost plus the configured risk penalty. The N3 source enumerates the small graph's simple route candidates and compares the selected route against each alternative score. The selected route balances cost and risk through DepotB and LabD, while the apparently cheaper DepotC path is rejected once risk is priced in." ?Route ?Raw ?Risk ?Score ?Edges) string:format ?Block.
|
|
62
|
+
} => {
|
|
63
|
+
:dijkstraRiskPath log:outputString ?Block.
|
|
64
|
+
:dijkstraRiskPath :selects :pathB.
|
|
65
|
+
}.
|
|
66
|
+
|
|
67
|
+
{ :dijkstraRiskPath :selects ?Path } log:query { :dijkstraRiskPath :selects ?Path }.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# ===============================================
|
|
2
|
+
# Dog license example
|
|
3
|
+
# If you have more than 4 dogs you need a license.
|
|
4
|
+
# ===============================================
|
|
5
|
+
|
|
6
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
7
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
8
|
+
@prefix : <https://eyereasoner.github.io/ns#>.
|
|
9
|
+
|
|
10
|
+
:alice :hasDog :dog1, :dog2, :dog3, :dog4, :dog5.
|
|
11
|
+
:bob :hasDog :dog6, :dog7.
|
|
12
|
+
|
|
13
|
+
{
|
|
14
|
+
?Subject :hasDog ?Any.
|
|
15
|
+
(1 { ?Subject :hasDog ?Dog } ?List) log:collectAllIn ?Scope.
|
|
16
|
+
?List math:sum ?Count.
|
|
17
|
+
?Count math:greaterThan 4.
|
|
18
|
+
} => {
|
|
19
|
+
?Subject :mustHave :dogLicense.
|
|
20
|
+
}.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# =================
|
|
2
|
+
# Eco Route Insight
|
|
3
|
+
# =================
|
|
4
|
+
# N3-compiled version of the privacy-preserving eco route insight. The JSON
|
|
5
|
+
# input remains the data-input sidecar; this source compiles the local decision
|
|
6
|
+
# and signed-envelope explanation.
|
|
7
|
+
|
|
8
|
+
@prefix : <https://eyereasoner.github.io/see/examples/eco-route-insight#>.
|
|
9
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
10
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
11
|
+
@prefix string: <http://www.w3.org/2000/10/swap/string#>.
|
|
12
|
+
|
|
13
|
+
:Scenario
|
|
14
|
+
:driver "Jamal";
|
|
15
|
+
:audience "Depot X";
|
|
16
|
+
:allowedUse "ui.eco.banner";
|
|
17
|
+
:issuedAt "2025-01-01T09:00:00Z";
|
|
18
|
+
:expiresAt "2025-01-01T11:00:00Z".
|
|
19
|
+
|
|
20
|
+
:Policy
|
|
21
|
+
:fuelIndexThreshold 120.0;
|
|
22
|
+
:maxEtaDelayMinutes 5;
|
|
23
|
+
:allowedUse "ui.eco.banner";
|
|
24
|
+
:signatureAlgorithm "HMAC-SHA256".
|
|
25
|
+
|
|
26
|
+
:Shipment :id "shipment-1"; :payloadTons 2.5.
|
|
27
|
+
|
|
28
|
+
:currentRoute
|
|
29
|
+
:id "current-route";
|
|
30
|
+
:label "Current urban route";
|
|
31
|
+
:distanceKm 42.0;
|
|
32
|
+
:gradientFactor 1.15;
|
|
33
|
+
:etaMinutes 64;
|
|
34
|
+
:fuelIndex 120.75.
|
|
35
|
+
|
|
36
|
+
:altLowFuel
|
|
37
|
+
:id "alt-low-fuel";
|
|
38
|
+
:label "Lower-fuel route";
|
|
39
|
+
:distanceKm 38.0;
|
|
40
|
+
:gradientFactor 1.05;
|
|
41
|
+
:etaMinutes 66;
|
|
42
|
+
:fuelIndex 99.75.
|
|
43
|
+
|
|
44
|
+
:altHillyShortcut
|
|
45
|
+
:id "alt-hilly-shortcut";
|
|
46
|
+
:label "Shorter hilly shortcut";
|
|
47
|
+
:distanceKm 35.0;
|
|
48
|
+
:gradientFactor 1.42;
|
|
49
|
+
:etaMinutes 63;
|
|
50
|
+
:fuelIndex 124.25.
|
|
51
|
+
|
|
52
|
+
:Envelope
|
|
53
|
+
:rawDataExported "no";
|
|
54
|
+
:payloadDigest "00e19becd91e81d6881749655d23d43002d9ea714bba61e855eafbc8ef9a5135";
|
|
55
|
+
:signatureKey "local-demo-key";
|
|
56
|
+
:signature "7fFGBN8fyI7xrmRz5VreeAUSf3LC_ywbj32NGk2ovUs".
|
|
57
|
+
|
|
58
|
+
{
|
|
59
|
+
:currentRoute :fuelIndex ?Current; :etaMinutes ?CurrentEta.
|
|
60
|
+
:altLowFuel :fuelIndex ?Alt; :etaMinutes ?AltEta.
|
|
61
|
+
:Policy :fuelIndexThreshold ?Threshold; :maxEtaDelayMinutes ?MaxDelay.
|
|
62
|
+
?Current math:greaterThan ?Threshold.
|
|
63
|
+
?Alt math:lessThan ?Current.
|
|
64
|
+
(?AltEta ?CurrentEta) math:difference ?Delay.
|
|
65
|
+
?Delay math:notGreaterThan ?MaxDelay.
|
|
66
|
+
(?Current ?Alt) math:difference ?Saving.
|
|
67
|
+
} => {
|
|
68
|
+
:Insight :status "issue";
|
|
69
|
+
:showEcoBanner "yes";
|
|
70
|
+
:suggestedRoute :altLowFuel;
|
|
71
|
+
:estimatedSaving ?Saving.
|
|
72
|
+
}.
|
|
73
|
+
|
|
74
|
+
{
|
|
75
|
+
:Insight :status "issue"; :showEcoBanner ?Show; :suggestedRoute :altLowFuel; :estimatedSaving ?Saving.
|
|
76
|
+
:Scenario :audience ?Audience; :allowedUse ?Use; :expiresAt ?Expiry.
|
|
77
|
+
:currentRoute :distanceKm ?CurrentDistance; :gradientFactor ?CurrentGradient; :fuelIndex ?CurrentIndex.
|
|
78
|
+
:altLowFuel :id ?AltId; :distanceKm ?AltDistance; :gradientFactor ?AltGradient; :fuelIndex ?AltIndex.
|
|
79
|
+
:Shipment :id ?ShipmentId; :payloadTons ?PayloadTons.
|
|
80
|
+
:Envelope :rawDataExported ?Raw; :payloadDigest ?Digest; :signatureKey ?Key; :signature ?Signature.
|
|
81
|
+
:Policy :fuelIndexThreshold ?Threshold; :signatureAlgorithm ?Algorithm.
|
|
82
|
+
("=== Answer ===\ninsight status : issue\nshow eco banner : %s\naudience : %s\nallowed use : %s\nsuggested route : %s\ncurrent fuel index : %.2f\nsuggested fuel index : %.2f\nestimated saving : %.2f\nexpires at : %s\nraw data exported : %s\nsignature algorithm : %s\npayload digest : %s\nsignature key : %s\nsignature : %s\n\n=== Explanation ===\nThe current route uses fuel index = distanceKm × (payloadKg / 1000) × gradientFactor. For %s, Current urban route gives %.2f × %.2f × %.2f = %.2f. The policy threshold is %.2f, so a local eco banner is justified. The selected alternative %s gives %.2f × %.2f × %.2f = %.2f, saving %.2f while staying within the ETA delay limit. The signed envelope exposes audience, use, expiry, route suggestion, and compact fuel indices, but not raw payload, GPS trace, driver behavior, or raw telemetry." ?Show ?Audience ?Use ?AltId ?CurrentIndex ?AltIndex ?Saving ?Expiry ?Raw ?Algorithm ?Digest ?Key ?Signature ?ShipmentId ?CurrentDistance ?PayloadTons ?CurrentGradient ?CurrentIndex ?Threshold ?AltId ?AltDistance ?PayloadTons ?AltGradient ?AltIndex ?Saving) string:format ?Block.
|
|
83
|
+
} => {
|
|
84
|
+
:ecoRouteInsight log:outputString ?Block.
|
|
85
|
+
:ecoRouteInsight :issues :Insight.
|
|
86
|
+
}.
|
|
87
|
+
|
|
88
|
+
{ :ecoRouteInsight :issues ?Insight } log:query { :ecoRouteInsight :issues ?Insight }.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# =================================
|
|
2
|
+
# Equals test
|
|
3
|
+
# Example from Patrick Hochstenbach
|
|
4
|
+
# =================================
|
|
5
|
+
|
|
6
|
+
@prefix owl: <http://www.w3.org/2002/07/owl#>.
|
|
7
|
+
@prefix : <http://example.org/socrates#>.
|
|
8
|
+
|
|
9
|
+
:X = :Y .
|
|
10
|
+
|
|
11
|
+
{ :X owl:sameAs :Y } => { :test :is true }.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# If two equivalence classes share an element, they are the same class.
|
|
2
|
+
@prefix : <https://eyereasoner.github.io/eye/reasoning#>.
|
|
3
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
4
|
+
|
|
5
|
+
{ ?x :inX true. } => { ?x :sim ?x. }.
|
|
6
|
+
{ ?x :sim ?y. } => { ?y :sim ?x. }.
|
|
7
|
+
{ ?x :sim ?y. ?y :sim ?z. } => { ?x :sim ?z. }.
|
|
8
|
+
{ ?u :sim ?x. } => { ?u :inClassOf ?x. }.
|
|
9
|
+
{ ?x :sim ?y. } => { (?x ?y) :sameClass true. }.
|
|
10
|
+
{ (?x ?y) :sameClass true. } => { (?y ?x) :sameClass true. }.
|
|
11
|
+
{ ?z :inClassOf ?x. ?z :inClassOf ?y. (?x ?y) :sameClass true. } => { (?x ?y ?z) :sharedMemberShowsSameClass true. }.
|
|
12
|
+
|
|
13
|
+
:a :inX true.
|
|
14
|
+
:b :inX true.
|
|
15
|
+
:c :inX true.
|
|
16
|
+
:b :sim :a.
|
|
17
|
+
:b :sim :c.
|
|
18
|
+
|
|
19
|
+
{ (?x ?y ?z) :sharedMemberShowsSameClass true. ?x log:notEqualTo ?y. } log:query { :result :sameClassBecauseOfSharedMember (?x ?y ?z). }.
|