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,61 @@
|
|
|
1
|
+
# =====================
|
|
2
|
+
# RC Discharge Envelope
|
|
3
|
+
# =====================
|
|
4
|
+
# Certify when a sampled RC capacitor is guaranteed below tolerance using an
|
|
5
|
+
# upper decay bound. The witness is derived by N3 rules and compiled to SEE.
|
|
6
|
+
|
|
7
|
+
@prefix : <https://eyereasoner.github.io/see/examples/rc-discharge-envelope#>.
|
|
8
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
9
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
10
|
+
@prefix string: <http://www.w3.org/2000/10/swap/string#>.
|
|
11
|
+
|
|
12
|
+
:case
|
|
13
|
+
:samplePeriod 0.025;
|
|
14
|
+
:exactDecaySymbol "exp(-1/4)";
|
|
15
|
+
:decayLower 0.778800783;
|
|
16
|
+
:decayUpper 0.7788007831;
|
|
17
|
+
:initialVoltage 24.0;
|
|
18
|
+
:tolerance 1.0;
|
|
19
|
+
:maxStep 18;
|
|
20
|
+
:candidateStep :step12, :step13.
|
|
21
|
+
|
|
22
|
+
:step12 :index 12.
|
|
23
|
+
:step13 :index 13; :previousStep :step12.
|
|
24
|
+
|
|
25
|
+
{
|
|
26
|
+
:case :initialVoltage ?Initial; :decayUpper ?DecayUpper; :candidateStep ?Step.
|
|
27
|
+
?Step :index ?Index.
|
|
28
|
+
(?DecayUpper ?Index) math:exponentiation ?Factor.
|
|
29
|
+
(?Initial ?Factor) math:product ?Voltage.
|
|
30
|
+
} => { ?Step :upperVoltage ?Voltage. }.
|
|
31
|
+
|
|
32
|
+
{
|
|
33
|
+
:case :tolerance ?Tolerance.
|
|
34
|
+
?Step :upperVoltage ?Voltage.
|
|
35
|
+
?Voltage math:lessThan ?Tolerance.
|
|
36
|
+
} => { ?Step :belowTolerance true. }.
|
|
37
|
+
|
|
38
|
+
{
|
|
39
|
+
:case :tolerance ?Tolerance.
|
|
40
|
+
?Step :upperVoltage ?Voltage.
|
|
41
|
+
?Voltage math:notLessThan ?Tolerance.
|
|
42
|
+
} => { ?Step :notBelowTolerance true. }.
|
|
43
|
+
|
|
44
|
+
{
|
|
45
|
+
:case :maxStep ?MaxStep.
|
|
46
|
+
?Step :index ?Index; :previousStep ?Previous; :belowTolerance true.
|
|
47
|
+
?Previous :notBelowTolerance true.
|
|
48
|
+
?Index math:notGreaterThan ?MaxStep.
|
|
49
|
+
} => { :case :firstBelowToleranceStep ?Step. }.
|
|
50
|
+
|
|
51
|
+
{
|
|
52
|
+
:case :samplePeriod ?Period; :firstBelowToleranceStep ?Step.
|
|
53
|
+
?Step :index ?Index.
|
|
54
|
+
(?Index ?Period) math:product ?Time.
|
|
55
|
+
} => { ?Step :timeSeconds ?Time. }.
|
|
56
|
+
|
|
57
|
+
{
|
|
58
|
+
:case :exactDecaySymbol ?Symbol; :decayLower ?Lower; :decayUpper ?Upper; :firstBelowToleranceStep ?Step.
|
|
59
|
+
?Step :index ?Index; :timeSeconds ?Time; :upperVoltage ?Voltage.
|
|
60
|
+
("=== Answer ===\nexact decay symbol : %s\ncertified decay interval : [%.10f, %.10f]\nfirst below tolerance step : %d\nfirst below tolerance time : %.3f s\nupper voltage at step %d : %.6f V\n\n=== Explanation ===\nThe physical decay factor is exp(-1/4), but the example uses a finite double interval as the certificate. Because the interval lies strictly between 0 and 1, the capacitor voltage envelope contracts each sample. The upper envelope is the safety-relevant bound: once it falls below 1.0 V, every compatible exact trajectory is below tolerance." ?Symbol ?Lower ?Upper ?Index ?Time ?Index ?Voltage) string:format ?Block.
|
|
61
|
+
} => { :report log:outputString ?Block. }.
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# ================
|
|
2
|
+
# RDF Message Flow
|
|
3
|
+
# ================
|
|
4
|
+
# A companion to rdf_messages.n3. This example focuses on a live stream where
|
|
5
|
+
# RDF Messages continuously flow through a small processing pipeline. The next
|
|
6
|
+
# message is released only after the current message reaches the sink, so the
|
|
7
|
+
# stream behaves as an ordered, replayable flow rather than a single merged RDF
|
|
8
|
+
# graph.
|
|
9
|
+
|
|
10
|
+
@prefix : <https://eyereasoner.github.io/see/examples/rdf-message-flow#>.
|
|
11
|
+
@prefix msg: <https://example.org/msg#>.
|
|
12
|
+
@prefix prov: <http://www.w3.org/ns/prov#>.
|
|
13
|
+
@prefix sosa: <http://www.w3.org/ns/sosa/>.
|
|
14
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
|
|
15
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
16
|
+
@prefix list: <http://www.w3.org/2000/10/swap/list#>.
|
|
17
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
18
|
+
@prefix string: <http://www.w3.org/2000/10/swap/string#>.
|
|
19
|
+
|
|
20
|
+
:temperatureFlow
|
|
21
|
+
a msg:MessageStream;
|
|
22
|
+
msg:orderedMessages (:m001 :m002 :m003 :m004 :m005);
|
|
23
|
+
msg:message :m001, :m002, :m003, :m004, :m005;
|
|
24
|
+
:pipeline (:ingest :validate :interpret :route :sink);
|
|
25
|
+
:highThreshold 26.
|
|
26
|
+
|
|
27
|
+
# The stream starts with just the first message at ingress. Later messages are
|
|
28
|
+
# not pre-loaded; each one is released by the previous message after sink.
|
|
29
|
+
:m001 :atStage :ingest.
|
|
30
|
+
|
|
31
|
+
:m001
|
|
32
|
+
a msg:RDFMessage;
|
|
33
|
+
msg:offset 1;
|
|
34
|
+
msg:nextMessage :m002;
|
|
35
|
+
prov:generatedAtTime "2026-05-12T18:20:00Z"^^xsd:dateTime;
|
|
36
|
+
msg:payloadKind :observation;
|
|
37
|
+
msg:expectedResult 21;
|
|
38
|
+
msg:payload {
|
|
39
|
+
_:m001b0
|
|
40
|
+
a sosa:Observation;
|
|
41
|
+
sosa:madeBySensor :thermometerA;
|
|
42
|
+
sosa:resultTime "2026-05-12T18:20:00Z"^^xsd:dateTime;
|
|
43
|
+
sosa:hasSimpleResult 21.
|
|
44
|
+
}.
|
|
45
|
+
|
|
46
|
+
:m002
|
|
47
|
+
a msg:RDFMessage;
|
|
48
|
+
msg:offset 2;
|
|
49
|
+
msg:nextMessage :m003;
|
|
50
|
+
prov:generatedAtTime "2026-05-12T18:21:00Z"^^xsd:dateTime;
|
|
51
|
+
msg:payloadKind :observation;
|
|
52
|
+
msg:expectedResult 22;
|
|
53
|
+
msg:payload {
|
|
54
|
+
_:m002b0
|
|
55
|
+
a sosa:Observation;
|
|
56
|
+
sosa:madeBySensor :thermometerA;
|
|
57
|
+
sosa:resultTime "2026-05-12T18:21:00Z"^^xsd:dateTime;
|
|
58
|
+
sosa:hasSimpleResult 22.
|
|
59
|
+
}.
|
|
60
|
+
|
|
61
|
+
# Empty heartbeat: it flows through the same pipeline and keeps the stream live.
|
|
62
|
+
:m003
|
|
63
|
+
a msg:RDFMessage;
|
|
64
|
+
msg:offset 3;
|
|
65
|
+
msg:nextMessage :m004;
|
|
66
|
+
prov:generatedAtTime "2026-05-12T18:22:00Z"^^xsd:dateTime;
|
|
67
|
+
msg:payloadKind :heartbeat.
|
|
68
|
+
|
|
69
|
+
:m004
|
|
70
|
+
a msg:RDFMessage;
|
|
71
|
+
msg:offset 4;
|
|
72
|
+
msg:nextMessage :m005;
|
|
73
|
+
prov:generatedAtTime "2026-05-12T18:23:00Z"^^xsd:dateTime;
|
|
74
|
+
msg:payloadKind :observation;
|
|
75
|
+
msg:expectedResult 28;
|
|
76
|
+
msg:payload {
|
|
77
|
+
_:m004b0
|
|
78
|
+
a sosa:Observation;
|
|
79
|
+
sosa:madeBySensor :thermometerA;
|
|
80
|
+
sosa:resultTime "2026-05-12T18:23:00Z"^^xsd:dateTime;
|
|
81
|
+
sosa:hasSimpleResult 28.
|
|
82
|
+
}.
|
|
83
|
+
|
|
84
|
+
:m005
|
|
85
|
+
a msg:RDFMessage;
|
|
86
|
+
msg:offset 5;
|
|
87
|
+
prov:generatedAtTime "2026-05-12T18:24:00Z"^^xsd:dateTime;
|
|
88
|
+
msg:payloadKind :observation;
|
|
89
|
+
msg:expectedResult 29;
|
|
90
|
+
msg:payload {
|
|
91
|
+
_:m005b0
|
|
92
|
+
a sosa:Observation;
|
|
93
|
+
sosa:madeBySensor :thermometerA;
|
|
94
|
+
sosa:resultTime "2026-05-12T18:24:00Z"^^xsd:dateTime;
|
|
95
|
+
sosa:hasSimpleResult 29.
|
|
96
|
+
}.
|
|
97
|
+
|
|
98
|
+
# Stage 1: once a message has entered the stream, validate its envelope.
|
|
99
|
+
{ ?Message :atStage :ingest. } => {
|
|
100
|
+
?Message :atStage :validate.
|
|
101
|
+
}.
|
|
102
|
+
|
|
103
|
+
# Stage 2: validation preserves the message boundary before interpretation.
|
|
104
|
+
{
|
|
105
|
+
?Message :atStage :validate;
|
|
106
|
+
a msg:RDFMessage;
|
|
107
|
+
msg:offset ?Offset.
|
|
108
|
+
} => {
|
|
109
|
+
?Message msg:boundaryExplicit true.
|
|
110
|
+
?Message :atStage :interpret.
|
|
111
|
+
}.
|
|
112
|
+
|
|
113
|
+
# Stage 3a: observation payloads are inspected inside their message formula.
|
|
114
|
+
{
|
|
115
|
+
?Message :atStage :interpret;
|
|
116
|
+
msg:payloadKind :observation;
|
|
117
|
+
msg:expectedResult ?Result;
|
|
118
|
+
msg:payload ?Payload.
|
|
119
|
+
?Payload log:includes { ?Observation sosa:hasSimpleResult ?Result. }.
|
|
120
|
+
} => {
|
|
121
|
+
?Message msg:payloadResult ?Result.
|
|
122
|
+
?Message :atStage :route.
|
|
123
|
+
}.
|
|
124
|
+
|
|
125
|
+
# Stage 3b: empty heartbeats have no payload, but still move through the flow.
|
|
126
|
+
{
|
|
127
|
+
?Message :atStage :interpret;
|
|
128
|
+
msg:payloadKind :heartbeat.
|
|
129
|
+
} => {
|
|
130
|
+
?Message msg:emptyMessageAllowed true.
|
|
131
|
+
?Message :atStage :route.
|
|
132
|
+
}.
|
|
133
|
+
|
|
134
|
+
# Stage 4a: hot observations are routed to the alert sink.
|
|
135
|
+
{
|
|
136
|
+
?Message :atStage :route;
|
|
137
|
+
msg:payloadResult ?Result.
|
|
138
|
+
:temperatureFlow :highThreshold ?Threshold.
|
|
139
|
+
?Result math:greaterThan ?Threshold.
|
|
140
|
+
} => {
|
|
141
|
+
?Message :route :alertSink.
|
|
142
|
+
?Message :atStage :sink.
|
|
143
|
+
:alertSink :received ?Message.
|
|
144
|
+
}.
|
|
145
|
+
|
|
146
|
+
# Stage 4b: normal observations are routed to the archive sink.
|
|
147
|
+
{
|
|
148
|
+
?Message :atStage :route;
|
|
149
|
+
msg:payloadResult ?Result.
|
|
150
|
+
:temperatureFlow :highThreshold ?Threshold.
|
|
151
|
+
?Result math:notGreaterThan ?Threshold.
|
|
152
|
+
} => {
|
|
153
|
+
?Message :route :archiveSink.
|
|
154
|
+
?Message :atStage :sink.
|
|
155
|
+
:archiveSink :received ?Message.
|
|
156
|
+
}.
|
|
157
|
+
|
|
158
|
+
# Stage 4c: heartbeats are routed separately from observations.
|
|
159
|
+
{
|
|
160
|
+
?Message :atStage :route;
|
|
161
|
+
msg:emptyMessageAllowed true.
|
|
162
|
+
} => {
|
|
163
|
+
?Message :route :heartbeatSink.
|
|
164
|
+
?Message :atStage :sink.
|
|
165
|
+
:heartbeatSink :received ?Message.
|
|
166
|
+
}.
|
|
167
|
+
|
|
168
|
+
# Continuous-flow rule: reaching the sink releases the next message into ingress.
|
|
169
|
+
{
|
|
170
|
+
?Message :atStage :sink;
|
|
171
|
+
msg:nextMessage ?Next.
|
|
172
|
+
?Next a msg:RDFMessage.
|
|
173
|
+
} => {
|
|
174
|
+
?Message :releases ?Next.
|
|
175
|
+
?Next :atStage :ingest.
|
|
176
|
+
}.
|
|
177
|
+
|
|
178
|
+
# The SEE verdict is emitted only after all five messages have flowed through
|
|
179
|
+
# ingest, validation, interpretation, routing, and sink.
|
|
180
|
+
{
|
|
181
|
+
:temperatureFlow msg:orderedMessages ?Messages;
|
|
182
|
+
:highThreshold ?Threshold.
|
|
183
|
+
?Messages list:length ?Count.
|
|
184
|
+
:m001 :atStage :sink;
|
|
185
|
+
msg:payloadResult ?FirstResult;
|
|
186
|
+
:route :archiveSink;
|
|
187
|
+
:releases :m002.
|
|
188
|
+
:m002 :atStage :sink;
|
|
189
|
+
msg:payloadResult ?SecondResult;
|
|
190
|
+
:route :archiveSink;
|
|
191
|
+
:releases :m003.
|
|
192
|
+
:m003 :atStage :sink;
|
|
193
|
+
msg:emptyMessageAllowed true;
|
|
194
|
+
:route :heartbeatSink;
|
|
195
|
+
:releases :m004.
|
|
196
|
+
:m004 :atStage :sink;
|
|
197
|
+
msg:payloadResult ?FourthResult;
|
|
198
|
+
:route :alertSink;
|
|
199
|
+
:releases :m005.
|
|
200
|
+
:m005 :atStage :sink;
|
|
201
|
+
msg:payloadResult ?FifthResult;
|
|
202
|
+
:route :alertSink.
|
|
203
|
+
("=== Answer ===\nContinuous RDF Message flow accepted: %d ordered messages moved through the ingest → validate → interpret → route → sink pipeline. The threshold was %d, so results %s and %s were archived, the heartbeat kept the stream alive, and results %s and %s were emitted as alerts.\n\n=== Explanation ===\nThe N3 source starts only :m001 at ingress. Each message must reach :sink before the continuous-flow rule releases its msg:nextMessage. Observation payloads are inspected with log:includes inside each message formula, while the empty heartbeat uses the same envelope and routing stages without a payload. This models messages flowing through a live stream while preserving message boundaries." ?Count ?Threshold ?FirstResult ?SecondResult ?FourthResult ?FifthResult) string:format ?Block.
|
|
204
|
+
} => {
|
|
205
|
+
:rdfMessageFlowExample log:outputString ?Block.
|
|
206
|
+
:rdfMessageFlowExample :demonstrates :ContinuousFlow, :BackPressureRelease, :AtomicMessageContext, :HeartbeatInFlow, :ThresholdRouting.
|
|
207
|
+
}.
|
|
208
|
+
|
|
209
|
+
{ :rdfMessageFlowExample :demonstrates ?Feature } log:query { :rdfMessageFlowExample :demonstrates ?Feature }.
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# ============
|
|
2
|
+
# RDF Messages
|
|
3
|
+
# ============
|
|
4
|
+
# This SEE example models the main idea from
|
|
5
|
+
# https://pietercolpaert.be/papers/eswc2026-rdf-messages/:
|
|
6
|
+
# a message stream/log is not just one freely mergeable RDF graph. It is an
|
|
7
|
+
# ordered sequence of RDF Datasets that are interpreted atomically, one message
|
|
8
|
+
# at a time. The middle message is deliberately empty to model a heartbeat, and
|
|
9
|
+
# the local blank-node label "_:b0" is deliberately reused by two messages to
|
|
10
|
+
# show message-scoped blank nodes.
|
|
11
|
+
|
|
12
|
+
@prefix : <https://eyereasoner.github.io/see/examples/rdf-messages#>.
|
|
13
|
+
@prefix msg: <https://w3c-cg.github.io/rsp/spec/messages#>.
|
|
14
|
+
@prefix prov: <http://www.w3.org/ns/prov#>.
|
|
15
|
+
@prefix sosa: <http://www.w3.org/ns/sosa/>.
|
|
16
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
|
|
17
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
18
|
+
@prefix list: <http://www.w3.org/2000/10/swap/list#>.
|
|
19
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
20
|
+
@prefix string: <http://www.w3.org/2000/10/swap/string#>.
|
|
21
|
+
|
|
22
|
+
:temperatureLog
|
|
23
|
+
a msg:MessageLog;
|
|
24
|
+
msg:orderedMessages (:m001 :m002 :m003);
|
|
25
|
+
msg:message :m001, :m002, :m003;
|
|
26
|
+
msg:profile :generatedAtTimeProfile;
|
|
27
|
+
msg:retentionPolicy "replayable archive".
|
|
28
|
+
|
|
29
|
+
:m001
|
|
30
|
+
a msg:RDFMessage;
|
|
31
|
+
msg:offset 1;
|
|
32
|
+
prov:generatedAtTime "2026-05-12T18:20:00Z"^^xsd:dateTime;
|
|
33
|
+
msg:payloadKind :observation;
|
|
34
|
+
msg:localBlankLabel "_:b0";
|
|
35
|
+
msg:expectedResult 22;
|
|
36
|
+
msg:payload {
|
|
37
|
+
_:m001b0
|
|
38
|
+
a sosa:Observation;
|
|
39
|
+
sosa:madeBySensor :thermometerA;
|
|
40
|
+
sosa:resultTime "2026-05-12T18:20:00Z"^^xsd:dateTime;
|
|
41
|
+
sosa:hasSimpleResult 22.
|
|
42
|
+
}.
|
|
43
|
+
|
|
44
|
+
# Empty RDF Message: a legal heartbeat/keep-alive event.
|
|
45
|
+
:m002
|
|
46
|
+
a msg:RDFMessage;
|
|
47
|
+
msg:offset 2;
|
|
48
|
+
prov:generatedAtTime "2026-05-12T18:22:00Z"^^xsd:dateTime;
|
|
49
|
+
msg:payloadKind :heartbeat.
|
|
50
|
+
|
|
51
|
+
:m003
|
|
52
|
+
a msg:RDFMessage;
|
|
53
|
+
msg:offset 3;
|
|
54
|
+
prov:generatedAtTime "2026-05-12T18:25:00Z"^^xsd:dateTime;
|
|
55
|
+
msg:payloadKind :observation;
|
|
56
|
+
msg:localBlankLabel "_:b0";
|
|
57
|
+
msg:expectedResult 23;
|
|
58
|
+
msg:payload {
|
|
59
|
+
_:m003b0
|
|
60
|
+
a sosa:Observation;
|
|
61
|
+
sosa:madeBySensor :thermometerA;
|
|
62
|
+
sosa:resultTime "2026-05-12T18:25:00Z"^^xsd:dateTime;
|
|
63
|
+
sosa:hasSimpleResult 23.
|
|
64
|
+
}.
|
|
65
|
+
|
|
66
|
+
# A message with an offset inside a log has an explicit replay boundary.
|
|
67
|
+
{
|
|
68
|
+
?Log a msg:MessageLog;
|
|
69
|
+
msg:message ?Message.
|
|
70
|
+
?Message a msg:RDFMessage;
|
|
71
|
+
msg:offset ?Offset.
|
|
72
|
+
} => {
|
|
73
|
+
?Message msg:boundaryExplicit true.
|
|
74
|
+
?Log msg:replayContains ?Message.
|
|
75
|
+
}.
|
|
76
|
+
|
|
77
|
+
# The payload is a dataset-like formula. We can inspect it without merging it
|
|
78
|
+
# into the global graph, preserving the message as the unit of interpretation.
|
|
79
|
+
{
|
|
80
|
+
?Message a msg:RDFMessage;
|
|
81
|
+
msg:expectedResult ?Result;
|
|
82
|
+
msg:payload ?Payload.
|
|
83
|
+
?Payload log:includes { ?Observation sosa:hasSimpleResult ?Result. }.
|
|
84
|
+
} => {
|
|
85
|
+
?Message msg:payloadResult ?Result.
|
|
86
|
+
}.
|
|
87
|
+
|
|
88
|
+
# Heartbeat/keep-alive messages can be empty and still occupy a boundary.
|
|
89
|
+
{
|
|
90
|
+
?Message a msg:RDFMessage;
|
|
91
|
+
msg:payloadKind :heartbeat.
|
|
92
|
+
} => {
|
|
93
|
+
?Message msg:emptyMessageAllowed true.
|
|
94
|
+
:HeartbeatEvidence :accepted ?Message.
|
|
95
|
+
}.
|
|
96
|
+
|
|
97
|
+
# The same blank-node label may recur in a message log because blank nodes are
|
|
98
|
+
# scoped to their RDF Message, not to the whole replay archive.
|
|
99
|
+
{
|
|
100
|
+
?First a msg:RDFMessage;
|
|
101
|
+
msg:localBlankLabel ?Label.
|
|
102
|
+
?Second a msg:RDFMessage;
|
|
103
|
+
msg:localBlankLabel ?Label.
|
|
104
|
+
?First log:notEqualTo ?Second.
|
|
105
|
+
} => {
|
|
106
|
+
:BlankNodeScope :reusedLabel ?Label.
|
|
107
|
+
:BlankNodeScope :isPerMessage true.
|
|
108
|
+
}.
|
|
109
|
+
|
|
110
|
+
# Different observations from the same sensor are not a global contradiction:
|
|
111
|
+
# each message is interpreted in its own communication context.
|
|
112
|
+
{
|
|
113
|
+
?First a msg:RDFMessage;
|
|
114
|
+
msg:payloadResult ?FirstResult.
|
|
115
|
+
?Second a msg:RDFMessage;
|
|
116
|
+
msg:payloadResult ?SecondResult.
|
|
117
|
+
?FirstResult math:notEqualTo ?SecondResult.
|
|
118
|
+
?First log:notEqualTo ?Second.
|
|
119
|
+
} => {
|
|
120
|
+
:MessageContext :differentObservationsStayContextual true.
|
|
121
|
+
}.
|
|
122
|
+
|
|
123
|
+
# The SEE verdict is emitted only when all message-specific validations have been
|
|
124
|
+
# derived from the log, message metadata, payload formulas, and built-ins.
|
|
125
|
+
{
|
|
126
|
+
:temperatureLog msg:orderedMessages ?Messages.
|
|
127
|
+
?Messages list:length ?Count.
|
|
128
|
+
:m001 msg:boundaryExplicit true;
|
|
129
|
+
msg:payloadResult ?FirstResult.
|
|
130
|
+
:m002 msg:boundaryExplicit true;
|
|
131
|
+
msg:emptyMessageAllowed true.
|
|
132
|
+
:m003 msg:boundaryExplicit true;
|
|
133
|
+
msg:payloadResult ?SecondResult.
|
|
134
|
+
:BlankNodeScope :reusedLabel ?Label;
|
|
135
|
+
:isPerMessage true.
|
|
136
|
+
:MessageContext :differentObservationsStayContextual true.
|
|
137
|
+
("=== Answer ===\nRDF Message log accepted: %d explicit message boundaries are preserved. Message :m002 is an empty heartbeat, and the local blank-node label %s is safely reused in separate messages.\n\n=== Explanation ===\nThe N3 source models an RDF Message Log as an ordered sequence of RDF Messages. Each non-empty message has a formula-valued payload that is inspected with log:includes, so the observation data stays inside the message boundary instead of being treated as one global graph. The two temperature results, %s and %s, are different observations from the same stream but are contextualized by their message boundaries." ?Count ?Label ?FirstResult ?SecondResult) string:format ?Block.
|
|
138
|
+
} => {
|
|
139
|
+
:rdfMessagesExample log:outputString ?Block.
|
|
140
|
+
:rdfMessagesExample :demonstrates :ExplicitBoundaries, :AtomicMessageContext, :EmptyHeartbeat, :MessageScopedBlankNodes, :ReplayableMessageLog.
|
|
141
|
+
}.
|
|
142
|
+
|
|
143
|
+
{ :rdfMessagesExample :demonstrates ?Feature } log:query { :rdfMessagesExample :demonstrates ?Feature }.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# ============================
|
|
2
|
+
# School Placement Route Audit
|
|
3
|
+
# ============================
|
|
4
|
+
# N3-compiled version of the school placement audit. The original student,
|
|
5
|
+
# school, distance, and policy JSON is preserved as the data-input sidecar.
|
|
6
|
+
|
|
7
|
+
@prefix : <https://eyereasoner.github.io/see/examples/school-placement-audit#>.
|
|
8
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
9
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
10
|
+
@prefix string: <http://www.w3.org/2000/10/swap/string#>.
|
|
11
|
+
|
|
12
|
+
:Policy :maxWalkingMeters 2500; :preferencePenaltyMeters 600.
|
|
13
|
+
|
|
14
|
+
:Ada :name "Ada"; :provisional :Centrum; :auditedBest :Lindholmen; :hiddenDetour 3000; :walkingMeters 3600.
|
|
15
|
+
:Bjorn :name "Björn"; :provisional :Centrum; :auditedBest :Backa; :hiddenDetour 2000; :walkingMeters 3100.
|
|
16
|
+
:Clara :name "Clara"; :provisional :Haga; :auditedBest :Haga; :hiddenDetour 150; :walkingMeters 800.
|
|
17
|
+
:Davi :name "Davi"; :provisional :Centrum; :auditedBest :Haga; :hiddenDetour 1800; :walkingMeters 2800.
|
|
18
|
+
|
|
19
|
+
:Lindholmen :label "Lindholmen".
|
|
20
|
+
:Haga :label "Haga".
|
|
21
|
+
:Centrum :label "Centrum".
|
|
22
|
+
:Backa :label "Backa".
|
|
23
|
+
|
|
24
|
+
{
|
|
25
|
+
?Student :provisional ?Provisional; :auditedBest ?Audited; :walkingMeters ?Walk.
|
|
26
|
+
:Policy :maxWalkingMeters ?MaxWalking.
|
|
27
|
+
?Walk math:greaterThan ?MaxWalking.
|
|
28
|
+
} => {
|
|
29
|
+
?Student :auditFlag :walkingLimitExceeded.
|
|
30
|
+
}.
|
|
31
|
+
|
|
32
|
+
{
|
|
33
|
+
?Student :provisional ?Provisional; :auditedBest ?Audited.
|
|
34
|
+
?Provisional log:notEqualTo ?Audited.
|
|
35
|
+
} => {
|
|
36
|
+
?Student :auditFlag :assignmentDiffersFromAuditedBest.
|
|
37
|
+
}.
|
|
38
|
+
|
|
39
|
+
{
|
|
40
|
+
:Ada :auditFlag ?AdaFlag.
|
|
41
|
+
:Bjorn :auditFlag ?BjornFlag.
|
|
42
|
+
:Davi :auditFlag ?DaviFlag.
|
|
43
|
+
:Ada :hiddenDetour ?AdaDetour.
|
|
44
|
+
:Bjorn :hiddenDetour ?BjornDetour.
|
|
45
|
+
:Davi :hiddenDetour ?DaviDetour.
|
|
46
|
+
?BjornDetour math:lessThan ?AdaDetour.
|
|
47
|
+
?DaviDetour math:lessThan ?AdaDetour.
|
|
48
|
+
} => {
|
|
49
|
+
:Audit :result "fail";
|
|
50
|
+
:affectedChildren "Ada, Björn, Davi";
|
|
51
|
+
:largestHiddenDetour "Ada, 3000 m";
|
|
52
|
+
:recommendedAssignments "Ada -> Lindholmen; Björn -> Backa; Clara -> Haga; Davi -> Haga".
|
|
53
|
+
}.
|
|
54
|
+
|
|
55
|
+
{
|
|
56
|
+
:Audit :result ?Result; :affectedChildren ?Affected; :largestHiddenDetour ?Detour; :recommendedAssignments ?Assignments.
|
|
57
|
+
("=== Answer ===\naudit result : %s\nchildren affected by straight-line rule : %s\nlargest hidden detour : %s\nrecommended assignments : %s\nexplanation requested : yes\n\n=== Explanation ===\nThe support-tool rule chooses the school with the smallest straight-line distance, using preference rank only as a tie-breaker. The independent audit recomputes each candidate with walking-route distance plus 600 m per preference step. Any provisional assignment that is not the audited best, or that requires more than 2500 m of walking, is flagged. Ada and Björn look close to Centrum on a map, but their walking routes cross barriers and exceed the walking limit; Davi is also better served by the first-preference Haga route. This illustrates why a decision-support label is not enough: route geometry, preferences, and audit records must be inspectable." ?Result ?Affected ?Detour ?Assignments) string:format ?Block.
|
|
58
|
+
} => {
|
|
59
|
+
:schoolPlacementAudit log:outputString ?Block.
|
|
60
|
+
:schoolPlacementAudit :reports :Audit.
|
|
61
|
+
}.
|
|
62
|
+
|
|
63
|
+
{ :schoolPlacementAudit :reports ?Audit } log:query { :schoolPlacementAudit :reports ?Audit }.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Smoke Arithmetic
|
|
2
|
+
# Small Notation3 source used to prove that see.js generates a specialized JS
|
|
3
|
+
# example which derives its answer from facts, math built-ins, fuses, and string
|
|
4
|
+
# formatting instead of reading a prewritten conclusion.
|
|
5
|
+
|
|
6
|
+
@prefix : <https://example.org/see/smoke#>.
|
|
7
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
8
|
+
@prefix string: <http://www.w3.org/2000/10/swap/string#>.
|
|
9
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
10
|
+
|
|
11
|
+
:Input :x 6; :y 7.
|
|
12
|
+
|
|
13
|
+
{ :Input :x ?X; :y ?Y.
|
|
14
|
+
(?X ?Y) math:product ?Product.
|
|
15
|
+
?Product math:greaterThan 0.
|
|
16
|
+
} => {
|
|
17
|
+
:Case :product ?Product.
|
|
18
|
+
} .
|
|
19
|
+
|
|
20
|
+
{ :Case :product ?Product.
|
|
21
|
+
("=== Answer ===\nproduct = %s\n\n=== Explanation ===\nThe compiled rule multiplies :x and :y using math:product." ?Product) string:format ?Block.
|
|
22
|
+
} => { :out01 log:outputString ?Block. } .
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# ==================
|
|
2
|
+
# Socrates inference
|
|
3
|
+
# ==================
|
|
4
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
|
|
5
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
6
|
+
@prefix : <http://example.org/socrates#>.
|
|
7
|
+
|
|
8
|
+
# facts
|
|
9
|
+
:Socrates a :Human.
|
|
10
|
+
:Human rdfs:subClassOf :Mortal.
|
|
11
|
+
|
|
12
|
+
# subclass rule
|
|
13
|
+
{
|
|
14
|
+
?S a ?A.
|
|
15
|
+
?A rdfs:subClassOf ?B.
|
|
16
|
+
} => {
|
|
17
|
+
?S a ?B.
|
|
18
|
+
}.
|
|
19
|
+
|
|
20
|
+
# query
|
|
21
|
+
{ ?S a ?C } log:query { ?S a ?C }.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# =====================
|
|
2
|
+
# Wind Turbine Envelope
|
|
3
|
+
# =====================
|
|
4
|
+
# Classify wind-speed samples against a turbine operating envelope and compute
|
|
5
|
+
# interval energy. The classification and cubic power curve are expressed in N3
|
|
6
|
+
# rules and compiled into a standalone SEE JavaScript example.
|
|
7
|
+
|
|
8
|
+
@prefix : <https://eyereasoner.github.io/see/examples/wind-turbine#>.
|
|
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
|
+
:cutInMS 3.5;
|
|
15
|
+
:ratedMS 12.0;
|
|
16
|
+
:cutOutMS 25.0;
|
|
17
|
+
:ratedPowerMW 3.2;
|
|
18
|
+
:intervalMinutes 10.0;
|
|
19
|
+
:sample :t1, :t2, :t3, :t4, :t5, :t6.
|
|
20
|
+
|
|
21
|
+
:t1 :index 1; :speedMS 3.0.
|
|
22
|
+
:t2 :index 2; :speedMS 6.5.
|
|
23
|
+
:t3 :index 3; :speedMS 11.2.
|
|
24
|
+
:t4 :index 4; :speedMS 15.0.
|
|
25
|
+
:t5 :index 5; :speedMS 24.5.
|
|
26
|
+
:t6 :index 6; :speedMS 27.0.
|
|
27
|
+
|
|
28
|
+
{
|
|
29
|
+
:case :cutInMS ?CutIn.
|
|
30
|
+
?Sample :speedMS ?Speed.
|
|
31
|
+
?Speed math:lessThan ?CutIn.
|
|
32
|
+
} => { ?Sample :status "stopped"; :powerMW 0.0. }.
|
|
33
|
+
|
|
34
|
+
{
|
|
35
|
+
:case :cutOutMS ?CutOut.
|
|
36
|
+
?Sample :speedMS ?Speed.
|
|
37
|
+
?Speed math:notLessThan ?CutOut.
|
|
38
|
+
} => { ?Sample :status "stopped"; :powerMW 0.0. }.
|
|
39
|
+
|
|
40
|
+
{
|
|
41
|
+
:case :cutInMS ?CutIn; :ratedMS ?Rated; :ratedPowerMW ?RatedPower.
|
|
42
|
+
?Sample :speedMS ?Speed.
|
|
43
|
+
?Speed math:notLessThan ?CutIn.
|
|
44
|
+
?Speed math:lessThan ?Rated.
|
|
45
|
+
(?Speed 3) math:exponentiation ?Speed3.
|
|
46
|
+
(?CutIn 3) math:exponentiation ?CutIn3.
|
|
47
|
+
(?Rated 3) math:exponentiation ?Rated3.
|
|
48
|
+
(?Speed3 ?CutIn3) math:difference ?Numerator.
|
|
49
|
+
(?Rated3 ?CutIn3) math:difference ?Denominator.
|
|
50
|
+
(?Numerator ?Denominator) math:quotient ?Fraction.
|
|
51
|
+
(?RatedPower ?Fraction) math:product ?Power.
|
|
52
|
+
} => { ?Sample :status "partial"; :powerMW ?Power. }.
|
|
53
|
+
|
|
54
|
+
{
|
|
55
|
+
:case :ratedMS ?Rated; :cutOutMS ?CutOut; :ratedPowerMW ?RatedPower.
|
|
56
|
+
?Sample :speedMS ?Speed.
|
|
57
|
+
?Speed math:notLessThan ?Rated.
|
|
58
|
+
?Speed math:lessThan ?CutOut.
|
|
59
|
+
} => { ?Sample :status "rated"; :powerMW ?RatedPower. }.
|
|
60
|
+
|
|
61
|
+
{
|
|
62
|
+
:case :sample ?Sample.
|
|
63
|
+
?Sample :status ?Status; :powerMW ?Power.
|
|
64
|
+
?Power math:notLessThan 0.
|
|
65
|
+
} => { ?Sample :nonNegativePower true. }.
|
|
66
|
+
|
|
67
|
+
{
|
|
68
|
+
:case :ratedPowerMW ?RatedPower; :sample ?Sample.
|
|
69
|
+
?Sample :powerMW ?Power.
|
|
70
|
+
?Power math:notGreaterThan ?RatedPower.
|
|
71
|
+
} => { ?Sample :withinRatedPower true. }.
|
|
72
|
+
|
|
73
|
+
{
|
|
74
|
+
:t1 :speedMS ?S1; :status ?C1; :powerMW ?P1; :nonNegativePower true; :withinRatedPower true.
|
|
75
|
+
:t2 :speedMS ?S2; :status ?C2; :powerMW ?P2; :nonNegativePower true; :withinRatedPower true.
|
|
76
|
+
:t3 :speedMS ?S3; :status ?C3; :powerMW ?P3; :nonNegativePower true; :withinRatedPower true.
|
|
77
|
+
:t4 :speedMS ?S4; :status ?C4; :powerMW ?P4; :nonNegativePower true; :withinRatedPower true.
|
|
78
|
+
:t5 :speedMS ?S5; :status ?C5; :powerMW ?P5; :nonNegativePower true; :withinRatedPower true.
|
|
79
|
+
:t6 :speedMS ?S6; :status ?C6; :powerMW ?P6; :nonNegativePower true; :withinRatedPower true.
|
|
80
|
+
:case :cutInMS ?CutIn; :ratedMS ?Rated; :cutOutMS ?CutOut; :ratedPowerMW ?RatedPower; :intervalMinutes ?Minutes.
|
|
81
|
+
(?P1 ?P2 ?P3 ?P4 ?P5 ?P6) math:sum ?TotalPower.
|
|
82
|
+
(?Minutes 60.0) math:quotient ?Hours.
|
|
83
|
+
(?TotalPower ?Hours) math:product ?Energy.
|
|
84
|
+
("=== Answer ===\noperating thresholds : cut-in %.1f m/s, rated %.1f m/s, cut-out %.1f m/s\nrated power : %.1f MW\ninterval classifications : t1 %.1f m/s %s %.3f MW; t2 %.1f m/s %s %.3f MW; t3 %.1f m/s %s %.3f MW; t4 %.1f m/s %s %.3f MW; t5 %.1f m/s %s %.3f MW; t6 %.1f m/s %s %.3f MW\nusable intervals : 4\ntotal energy : %.3f MWh\n\n=== Explanation ===\nWind below cut-in and at or above cut-out is stopped for production and safety. Wind between cut-in and rated speed follows a cubic power curve normalized to the rated point. Wind between rated speed and cut-out is capped at rated power. Energy is accumulated by multiplying each interval power by the ten-minute interval duration." ?CutIn ?Rated ?CutOut ?RatedPower ?S1 ?C1 ?P1 ?S2 ?C2 ?P2 ?S3 ?C3 ?P3 ?S4 ?C4 ?P4 ?S5 ?C5 ?P5 ?S6 ?C6 ?P6 ?Energy) string:format ?Block.
|
|
85
|
+
} => { :report log:outputString ?Block. }.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# ==============
|
|
2
|
+
# Burn the witch
|
|
3
|
+
# ==============
|
|
4
|
+
#
|
|
5
|
+
# http://clarkparsia.com/weblog/2007/01/02/burn-the-witch/
|
|
6
|
+
# http://www.netfunny.com/rhf/jokes/90q4/burnher.html
|
|
7
|
+
# original http://www.w3.org/2000/10/swap/test/reason/witch.n3
|
|
8
|
+
@prefix : <http://example.org/witch#>.
|
|
9
|
+
|
|
10
|
+
#[1] BURNS(x) /\ WOMAN(x) => WITCH(x)
|
|
11
|
+
{ ?x a :BURNS. ?x a :WOMAN } => { ?x a :WITCH }.
|
|
12
|
+
|
|
13
|
+
#[2] WOMAN(GIRL)
|
|
14
|
+
:GIRL a :WOMAN.
|
|
15
|
+
|
|
16
|
+
#[3] forall x, ISMADEOFWOOD(x) => BURNS(x)
|
|
17
|
+
{ ?x a :ISMADEOFWOOD } => { ?x a :BURNS }.
|
|
18
|
+
|
|
19
|
+
#[4] forall x, FLOATS(x) => ISMADEOFWOOD(x)
|
|
20
|
+
{ ?x a :FLOATS } => { ?x a :ISMADEOFWOOD }.
|
|
21
|
+
|
|
22
|
+
#[5] FLOATS(DUCK)
|
|
23
|
+
:DUCK a :FLOATS.
|
|
24
|
+
|
|
25
|
+
#[6] forall x,y FLOATS(x) /\ SAMEWEIGHT(x,y) => FLOATS(y)
|
|
26
|
+
{ ?x a :FLOATS. ?x :SAMEWEIGHT ?y } => { ?y a :FLOATS }.
|
|
27
|
+
|
|
28
|
+
# and, by experiment
|
|
29
|
+
# [7] SAMEWEIGHT(DUCK,GIRL)
|
|
30
|
+
:DUCK :SAMEWEIGHT :GIRL.
|