eyelang 0.1.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/LICENSE.md +9 -0
- package/README.md +61 -0
- package/bin/eyelang.js +7 -0
- package/docs/guide.md +525 -0
- package/docs/language-reference.md +697 -0
- package/examples/access-control-policy.pl +52 -0
- package/examples/ackermann.pl +46 -0
- package/examples/age.pl +28 -0
- package/examples/aliases-and-namespaces.pl +22 -0
- package/examples/alignment-demo.pl +44 -0
- package/examples/allen-interval-calculus.pl +64 -0
- package/examples/ancestor.pl +21 -0
- package/examples/animal.pl +21 -0
- package/examples/annotation.pl +34 -0
- package/examples/auroracare.pl +309 -0
- package/examples/backward.pl +12 -0
- package/examples/basic-monadic.pl +10032 -0
- package/examples/bayes-diagnosis.pl +108 -0
- package/examples/bayes-therapy.pl +182 -0
- package/examples/beam-deflection.pl +50 -0
- package/examples/blocks-world-planning.pl +75 -0
- package/examples/bmi.pl +232 -0
- package/examples/braking-safety-worlds.pl +69 -0
- package/examples/buck-converter-design.pl +78 -0
- package/examples/cache-performance.pl +54 -0
- package/examples/canary-release.pl +49 -0
- package/examples/cat-koko.pl +24 -0
- package/examples/clinical-trial-screening.pl +92 -0
- package/examples/combinatorics-findall-sort.pl +37 -0
- package/examples/competitive-enzyme-kinetics.pl +78 -0
- package/examples/complex.pl +121 -0
- package/examples/composition-of-injective-functions-is-injective.pl +50 -0
- package/examples/context-association.pl +53 -0
- package/examples/context-schema-audit.pl +46 -0
- package/examples/control-system.pl +72 -0
- package/examples/cyclic-path.pl +16 -0
- package/examples/d3-group.pl +100 -0
- package/examples/dairy-energy-balance.pl +65 -0
- package/examples/data-negotiation.pl +39 -0
- package/examples/deep-taxonomy-10.pl +115 -0
- package/examples/deep-taxonomy-100.pl +385 -0
- package/examples/deep-taxonomy-1000.pl +3085 -0
- package/examples/deep-taxonomy-10000.pl +30094 -0
- package/examples/deep-taxonomy-100000.pl +300184 -0
- package/examples/delfour.pl +281 -0
- package/examples/deontic-logic.pl +52 -0
- package/examples/derived-backward-rule.pl +30 -0
- package/examples/derived-rule.pl +27 -0
- package/examples/diamond-property.pl +38 -0
- package/examples/dijkstra-findall-sort.pl +44 -0
- package/examples/dijkstra-risk-path.pl +86 -0
- package/examples/dijkstra.pl +46 -0
- package/examples/dining-philosophers.pl +140 -0
- package/examples/dog.pl +25 -0
- package/examples/dpv-odrl-purpose-mapping.pl +46 -0
- package/examples/drone-corridor-planner.pl +51 -0
- package/examples/easter-computus.pl +89 -0
- package/examples/electrical-rc-filter.pl +36 -0
- package/examples/epidemic-policy.pl +67 -0
- package/examples/equivalence-classes-overlap-implies-same-class.pl +27 -0
- package/examples/eulerian-path.pl +85 -0
- package/examples/ev-range-worlds.pl +82 -0
- package/examples/existential-rule.pl +18 -0
- package/examples/exoplanet-validation-worlds.pl +88 -0
- package/examples/expression-eval.pl +43 -0
- package/examples/family-cousins.pl +65 -0
- package/examples/fastpow.pl +53 -0
- package/examples/fft8-numeric.pl +83 -0
- package/examples/fibonacci.pl +53 -0
- package/examples/field-nitrogen-balance.pl +70 -0
- package/examples/flandor.pl +296 -0
- package/examples/floating-point.pl +23 -0
- package/examples/four-color-map.pl +127 -0
- package/examples/fundamental-theorem-arithmetic.pl +113 -0
- package/examples/gd-step-certified.pl +158 -0
- package/examples/gdpr-compliance.pl +69 -0
- package/examples/good-cobbler.pl +14 -0
- package/examples/gps.pl +152 -0
- package/examples/graph-reachability.pl +36 -0
- package/examples/gray-code-counter.pl +48 -0
- package/examples/greatest-lower-bound-uniqueness.pl +28 -0
- package/examples/group-inverse-uniqueness.pl +34 -0
- package/examples/hamiltonian-path.pl +49 -0
- package/examples/hamming-code.pl +105 -0
- package/examples/hanoi.pl +20 -0
- package/examples/heat-loss.pl +51 -0
- package/examples/heron-theorem.pl +36 -0
- package/examples/ideal-gas-law.pl +37 -0
- package/examples/illegitimate-reasoning.pl +88 -0
- package/examples/knowledge-engineering-alignment-flow.pl +40 -0
- package/examples/law-of-cosines.pl +31 -0
- package/examples/least-squares-regression.pl +81 -0
- package/examples/list-collection.pl +33 -0
- package/examples/lldm.pl +78 -0
- package/examples/manufacturing-quality-control.pl +73 -0
- package/examples/microgrid-dispatch.pl +85 -0
- package/examples/monkey-bananas.pl +45 -0
- package/examples/network-sla.pl +48 -0
- package/examples/newton-raphson.pl +49 -0
- package/examples/nixon-diamond.pl +37 -0
- package/examples/observability-log-correlation.pl +34 -0
- package/examples/odrl-dpv-fpv-trust-flow.pl +43 -0
- package/examples/odrl-dpv-healthcare-risk-ranked.pl +266 -0
- package/examples/odrl-dpv-risk-ranked.pl +320 -0
- package/examples/orbital-transfer-design.pl +113 -0
- package/examples/output/access-control-policy.pl +2 -0
- package/examples/output/ackermann.pl +12 -0
- package/examples/output/age.pl +2 -0
- package/examples/output/aliases-and-namespaces.pl +5 -0
- package/examples/output/alignment-demo.pl +32 -0
- package/examples/output/allen-interval-calculus.pl +154 -0
- package/examples/output/ancestor.pl +6 -0
- package/examples/output/animal.pl +4 -0
- package/examples/output/annotation.pl +4 -0
- package/examples/output/auroracare.pl +117 -0
- package/examples/output/backward.pl +1 -0
- package/examples/output/basic-monadic.pl +1518 -0
- package/examples/output/bayes-diagnosis.pl +13 -0
- package/examples/output/bayes-therapy.pl +23 -0
- package/examples/output/beam-deflection.pl +5 -0
- package/examples/output/blocks-world-planning.pl +4 -0
- package/examples/output/bmi.pl +32 -0
- package/examples/output/braking-safety-worlds.pl +18 -0
- package/examples/output/buck-converter-design.pl +6 -0
- package/examples/output/cache-performance.pl +4 -0
- package/examples/output/canary-release.pl +5 -0
- package/examples/output/cat-koko.pl +3 -0
- package/examples/output/clinical-trial-screening.pl +9 -0
- package/examples/output/combinatorics-findall-sort.pl +2 -0
- package/examples/output/competitive-enzyme-kinetics.pl +6 -0
- package/examples/output/complex.pl +1 -0
- package/examples/output/composition-of-injective-functions-is-injective.pl +2 -0
- package/examples/output/context-association.pl +3 -0
- package/examples/output/context-schema-audit.pl +12 -0
- package/examples/output/control-system.pl +6 -0
- package/examples/output/cyclic-path.pl +16 -0
- package/examples/output/d3-group.pl +2 -0
- package/examples/output/dairy-energy-balance.pl +13 -0
- package/examples/output/data-negotiation.pl +1 -0
- package/examples/output/deep-taxonomy-10.pl +16 -0
- package/examples/output/deep-taxonomy-100.pl +16 -0
- package/examples/output/deep-taxonomy-1000.pl +16 -0
- package/examples/output/deep-taxonomy-10000.pl +16 -0
- package/examples/output/deep-taxonomy-100000.pl +16 -0
- package/examples/output/delfour.pl +31 -0
- package/examples/output/deontic-logic.pl +4 -0
- package/examples/output/derived-backward-rule.pl +3 -0
- package/examples/output/derived-rule.pl +2 -0
- package/examples/output/diamond-property.pl +4 -0
- package/examples/output/dijkstra-findall-sort.pl +2 -0
- package/examples/output/dijkstra-risk-path.pl +29 -0
- package/examples/output/dijkstra.pl +16 -0
- package/examples/output/dining-philosophers.pl +350 -0
- package/examples/output/dog.pl +1 -0
- package/examples/output/dpv-odrl-purpose-mapping.pl +18 -0
- package/examples/output/drone-corridor-planner.pl +17 -0
- package/examples/output/easter-computus.pl +30 -0
- package/examples/output/electrical-rc-filter.pl +3 -0
- package/examples/output/epidemic-policy.pl +14 -0
- package/examples/output/equivalence-classes-overlap-implies-same-class.pl +18 -0
- package/examples/output/eulerian-path.pl +3 -0
- package/examples/output/ev-range-worlds.pl +19 -0
- package/examples/output/existential-rule.pl +2 -0
- package/examples/output/exoplanet-validation-worlds.pl +22 -0
- package/examples/output/expression-eval.pl +1 -0
- package/examples/output/family-cousins.pl +28 -0
- package/examples/output/fastpow.pl +6 -0
- package/examples/output/fft8-numeric.pl +4 -0
- package/examples/output/fibonacci.pl +6 -0
- package/examples/output/field-nitrogen-balance.pl +21 -0
- package/examples/output/flandor.pl +43 -0
- package/examples/output/floating-point.pl +9 -0
- package/examples/output/four-color-map.pl +3 -0
- package/examples/output/fundamental-theorem-arithmetic.pl +9 -0
- package/examples/output/gd-step-certified.pl +79 -0
- package/examples/output/gdpr-compliance.pl +6 -0
- package/examples/output/good-cobbler.pl +1 -0
- package/examples/output/gps.pl +21 -0
- package/examples/output/graph-reachability.pl +3 -0
- package/examples/output/gray-code-counter.pl +1 -0
- package/examples/output/greatest-lower-bound-uniqueness.pl +2 -0
- package/examples/output/group-inverse-uniqueness.pl +2 -0
- package/examples/output/hamiltonian-path.pl +121 -0
- package/examples/output/hamming-code.pl +6 -0
- package/examples/output/hanoi.pl +1 -0
- package/examples/output/heat-loss.pl +5 -0
- package/examples/output/heron-theorem.pl +4 -0
- package/examples/output/ideal-gas-law.pl +3 -0
- package/examples/output/illegitimate-reasoning.pl +15 -0
- package/examples/output/knowledge-engineering-alignment-flow.pl +17 -0
- package/examples/output/law-of-cosines.pl +3 -0
- package/examples/output/least-squares-regression.pl +5 -0
- package/examples/output/list-collection.pl +3 -0
- package/examples/output/lldm.pl +6 -0
- package/examples/output/manufacturing-quality-control.pl +6 -0
- package/examples/output/microgrid-dispatch.pl +6 -0
- package/examples/output/monkey-bananas.pl +5 -0
- package/examples/output/network-sla.pl +4 -0
- package/examples/output/newton-raphson.pl +3 -0
- package/examples/output/nixon-diamond.pl +5 -0
- package/examples/output/observability-log-correlation.pl +28 -0
- package/examples/output/odrl-dpv-fpv-trust-flow.pl +9 -0
- package/examples/output/odrl-dpv-healthcare-risk-ranked.pl +42 -0
- package/examples/output/odrl-dpv-risk-ranked.pl +120 -0
- package/examples/output/orbital-transfer-design.pl +7 -0
- package/examples/output/path-discovery.pl +3 -0
- package/examples/output/peano-arithmetic.pl +3 -0
- package/examples/output/peasant.pl +10 -0
- package/examples/output/pendulum-period.pl +4 -0
- package/examples/output/polynomial.pl +14 -0
- package/examples/output/proof-contrapositive.pl +3 -0
- package/examples/output/quadratic-formula.pl +6 -0
- package/examples/output/radioactive-decay.pl +5 -0
- package/examples/output/reusable-builtins.pl +5 -0
- package/examples/output/riemann-hypothesis.pl +12 -0
- package/examples/output/security-incident-correlation.pl +3 -0
- package/examples/output/service-impact.pl +11 -0
- package/examples/output/sieve.pl +1 -0
- package/examples/output/skolem-functions.pl +16 -0
- package/examples/output/socket-age.pl +1 -0
- package/examples/output/socket-family.pl +3 -0
- package/examples/output/socrates.pl +2 -0
- package/examples/output/statistics-summary.pl +4 -0
- package/examples/output/superdense-coding.pl +6 -0
- package/examples/output/term-tools.pl +6 -0
- package/examples/output/trust-flow-provenance-threshold.pl +6 -0
- package/examples/output/turing.pl +12 -0
- package/examples/output/vector-similarity.pl +4 -0
- package/examples/output/vulnerability-impact.pl +20 -0
- package/examples/output/witch.pl +7 -0
- package/examples/output/wolf-goat-cabbage.pl +3 -0
- package/examples/output/zebra.pl +3 -0
- package/examples/path-discovery.pl +45013 -0
- package/examples/peano-arithmetic.pl +31 -0
- package/examples/peasant.pl +30 -0
- package/examples/pendulum-period.pl +50 -0
- package/examples/polynomial.pl +124 -0
- package/examples/proof/age.pl +71 -0
- package/examples/proof/aliases-and-namespaces.pl +78 -0
- package/examples/proof/ancestor.pl +140 -0
- package/examples/proof/animal.pl +68 -0
- package/examples/proof/annotation.pl +80 -0
- package/examples/proof/backward.pl +22 -0
- package/examples/proof/cat-koko.pl +86 -0
- package/examples/proof/data-negotiation.pl +76 -0
- package/examples/proof/derived-rule.pl +43 -0
- package/examples/proof/dog.pl +31 -0
- package/examples/proof/electrical-rc-filter.pl +105 -0
- package/examples/proof/existential-rule.pl +40 -0
- package/examples/proof/floating-point.pl +160 -0
- package/examples/proof/good-cobbler.pl +16 -0
- package/examples/proof/group-inverse-uniqueness.pl +84 -0
- package/examples/proof/list-collection.pl +52 -0
- package/examples/proof/proof-contrapositive.pl +78 -0
- package/examples/proof/socket-age.pl +32 -0
- package/examples/proof/socket-family.pl +59 -0
- package/examples/proof/socrates.pl +38 -0
- package/examples/proof-contrapositive.pl +27 -0
- package/examples/quadratic-formula.pl +54 -0
- package/examples/radioactive-decay.pl +56 -0
- package/examples/reusable-builtins.pl +32 -0
- package/examples/riemann-hypothesis.pl +110 -0
- package/examples/security-incident-correlation.pl +69 -0
- package/examples/service-impact.pl +41 -0
- package/examples/sieve.pl +20 -0
- package/examples/skolem-functions.pl +52 -0
- package/examples/socket-age.pl +39 -0
- package/examples/socket-family.pl +28 -0
- package/examples/socrates.pl +19 -0
- package/examples/statistics-summary.pl +54 -0
- package/examples/superdense-coding.pl +84 -0
- package/examples/term-tools.pl +23 -0
- package/examples/trust-flow-provenance-threshold.pl +40 -0
- package/examples/turing.pl +67 -0
- package/examples/vector-similarity.pl +56 -0
- package/examples/vulnerability-impact.pl +70 -0
- package/examples/witch.pl +38 -0
- package/examples/wolf-goat-cabbage.pl +56 -0
- package/examples/zebra.pl +44 -0
- package/index.d.ts +80 -0
- package/index.js +4 -0
- package/package.json +48 -0
- package/src/bin.js +7 -0
- package/src/builtins/aggregation.js +81 -0
- package/src/builtins/arithmetic.js +208 -0
- package/src/builtins/context.js +42 -0
- package/src/builtins/control.js +34 -0
- package/src/builtins/core.js +78 -0
- package/src/builtins/lists.js +283 -0
- package/src/builtins/registry.js +48 -0
- package/src/builtins/strings.js +234 -0
- package/src/builtins/terms.js +66 -0
- package/src/cli.js +180 -0
- package/src/explain.js +324 -0
- package/src/hash.js +294 -0
- package/src/index.js +47 -0
- package/src/parser.js +428 -0
- package/src/program.js +237 -0
- package/src/solver.js +237 -0
- package/src/term.js +328 -0
- package/test/conformance/README.md +43 -0
- package/test/conformance/cases/001_fact_output.pl +4 -0
- package/test/conformance/cases/002_rule_recursion.pl +7 -0
- package/test/conformance/cases/002_rule_recursion.query +1 -0
- package/test/conformance/cases/003_terms_and_readback.pl +16 -0
- package/test/conformance/cases/003_terms_and_readback.query +1 -0
- package/test/conformance/cases/004_conjunction_and_parentheses.pl +5 -0
- package/test/conformance/cases/004_conjunction_and_parentheses.query +1 -0
- package/test/conformance/cases/005_list_deconstruction.pl +6 -0
- package/test/conformance/cases/005_list_deconstruction.query +1 -0
- package/test/conformance/cases/006_comma_formula_data.pl +4 -0
- package/test/conformance/cases/006_comma_formula_data.query +1 -0
- package/test/conformance/cases/007_anonymous_variables.pl +5 -0
- package/test/conformance/cases/007_anonymous_variables.query +1 -0
- package/test/conformance/cases/008_graphic_atoms.pl +6 -0
- package/test/conformance/cases/008_graphic_atoms.query +1 -0
- package/test/conformance/cases/009_comments_and_whitespace.pl +5 -0
- package/test/conformance/cases/009_comments_and_whitespace.query +1 -0
- package/test/conformance/cases/010_variable_scope_and_reuse.pl +8 -0
- package/test/conformance/cases/010_variable_scope_and_reuse.query +1 -0
- package/test/conformance/cases/011_predicate_arity.pl +6 -0
- package/test/conformance/cases/011_predicate_arity.query +1 -0
- package/test/conformance/cases/012_nested_compound_unification.pl +5 -0
- package/test/conformance/cases/012_nested_compound_unification.query +1 -0
- package/test/conformance/cases/013_multiple_clauses_order.pl +6 -0
- package/test/conformance/cases/013_multiple_clauses_order.query +1 -0
- package/test/conformance/cases/014_failure_filters_answers.pl +7 -0
- package/test/conformance/cases/014_failure_filters_answers.query +1 -0
- package/test/conformance/cases/015_improper_list_unification.pl +6 -0
- package/test/conformance/cases/015_improper_list_unification.query +1 -0
- package/test/conformance/cases/016_zero_arity_compound.pl +4 -0
- package/test/conformance/cases/016_zero_arity_compound.query +1 -0
- package/test/conformance/cases/017_three_step_recursion.pl +8 -0
- package/test/conformance/cases/017_three_step_recursion.query +1 -0
- package/test/conformance/cases/018_quoted_atom_readback.pl +6 -0
- package/test/conformance/cases/018_quoted_atom_readback.query +1 -0
- package/test/conformance/cases/019_parenthesized_three_conjuncts.pl +7 -0
- package/test/conformance/cases/019_parenthesized_three_conjuncts.query +1 -0
- package/test/conformance/cases/020_nested_list_terms.pl +5 -0
- package/test/conformance/cases/020_nested_list_terms.query +1 -0
- package/test/conformance/cases/021_repeated_variable_head.pl +7 -0
- package/test/conformance/cases/022_rule_head_structure.pl +5 -0
- package/test/conformance/cases/023_quoted_escapes_readback.pl +5 -0
- package/test/conformance/cases/024_numeric_literal_readback.pl +6 -0
- package/test/conformance/cases/025_body_parentheses_with_formula_data.pl +5 -0
- package/test/conformance/cases/026_underscore_named_variable_reuse.pl +5 -0
- package/test/conformance/cases/027_default_derived_output.pl +5 -0
- package/test/conformance/cases/028_materialize_focus.pl +5 -0
- package/test/conformance/cases/029_arithmetic_and_comparison.pl +11 -0
- package/test/conformance/cases/029_arithmetic_and_comparison.query +1 -0
- package/test/conformance/cases/030_strings_and_atoms.pl +4 -0
- package/test/conformance/cases/030_strings_and_atoms.query +1 -0
- package/test/conformance/cases/031_lists_aggregation_ordering.pl +10 -0
- package/test/conformance/cases/031_lists_aggregation_ordering.query +1 -0
- package/test/conformance/cases/032_holds_parts.pl +4 -0
- package/test/conformance/cases/033_negation_once_generators.pl +7 -0
- package/test/conformance/cases/033_negation_once_generators.query +1 -0
- package/test/conformance/cases/034_equality_and_inequality.pl +6 -0
- package/test/conformance/cases/034_equality_and_inequality.query +1 -0
- package/test/conformance/cases/035_list_relations.pl +5 -0
- package/test/conformance/cases/035_list_relations.query +1 -0
- package/test/conformance/cases/036_append_splits.pl +3 -0
- package/test/conformance/cases/036_append_splits.query +1 -0
- package/test/conformance/cases/037_matching_and_comparison.pl +7 -0
- package/test/conformance/cases/037_matching_and_comparison.query +1 -0
- package/test/conformance/cases/038_memoize_declaration.pl +8 -0
- package/test/conformance/cases/038_memoize_declaration.query +1 -0
- package/test/conformance/cases/039_numeric_functions.pl +9 -0
- package/test/conformance/cases/039_numeric_functions.query +1 -0
- package/test/conformance/cases/040_between_enumeration.pl +3 -0
- package/test/conformance/cases/040_between_enumeration.query +1 -0
- package/test/conformance/cases/041_smallest_divisor.pl +3 -0
- package/test/conformance/cases/041_smallest_divisor.query +1 -0
- package/test/conformance/cases/042_negation_filter.pl +7 -0
- package/test/conformance/cases/042_negation_filter.query +1 -0
- package/test/conformance/cases/043_once_user_predicate.pl +5 -0
- package/test/conformance/cases/043_once_user_predicate.query +1 -0
- package/test/conformance/cases/044_findall_user_goal.pl +6 -0
- package/test/conformance/cases/044_findall_user_goal.query +1 -0
- package/test/conformance/cases/045_sort_deduplicates_atoms.pl +3 -0
- package/test/conformance/cases/045_sort_deduplicates_atoms.query +1 -0
- package/test/conformance/cases/046_append_bound_prefix_suffix.pl +4 -0
- package/test/conformance/cases/046_append_bound_prefix_suffix.query +1 -0
- package/test/conformance/cases/047_nth0_index_generation.pl +3 -0
- package/test/conformance/cases/047_nth0_index_generation.query +1 -0
- package/test/conformance/cases/048_set_nth0_edges.pl +4 -0
- package/test/conformance/cases/048_set_nth0_edges.query +1 -0
- package/test/conformance/cases/049_select_duplicate_occurrences.pl +3 -0
- package/test/conformance/cases/049_select_duplicate_occurrences.query +1 -0
- package/test/conformance/cases/050_not_member_filter.pl +6 -0
- package/test/conformance/cases/050_not_member_filter.query +1 -0
- package/test/conformance/cases/051_nested_holds_parts.pl +4 -0
- package/test/conformance/cases/052_holds_member.pl +3 -0
- package/test/conformance/cases/053_materialize_excludes_source_fact.pl +6 -0
- package/test/conformance/cases/054_numeric_and_lexical_comparison.pl +5 -0
- package/test/conformance/cases/054_numeric_and_lexical_comparison.query +1 -0
- package/test/conformance/cases/055_string_matching_filters.pl +6 -0
- package/test/conformance/cases/055_string_matching_filters.query +1 -0
- package/test/conformance/cases/056_string_and_atom_concat.pl +3 -0
- package/test/conformance/cases/056_string_and_atom_concat.query +1 -0
- package/test/conformance/cases/057_countall_empty_and_nonempty.pl +4 -0
- package/test/conformance/cases/057_countall_empty_and_nonempty.query +1 -0
- package/test/conformance/cases/058_sumall_numeric_template.pl +5 -0
- package/test/conformance/cases/058_sumall_numeric_template.query +1 -0
- package/test/conformance/cases/059_aggregate_min_template.pl +5 -0
- package/test/conformance/cases/059_aggregate_min_template.query +1 -0
- package/test/conformance/cases/060_aggregate_max_compound_key.pl +5 -0
- package/test/conformance/cases/060_aggregate_max_compound_key.query +1 -0
- package/test/conformance/cases/061_date_difference.pl +4 -0
- package/test/conformance/cases/062_reusable_numeric_builtins.pl +10 -0
- package/test/conformance/cases/063_reusable_list_builtins.pl +11 -0
- package/test/conformance/cases/064_reusable_string_builtins.pl +12 -0
- package/test/conformance/cases/065_reusable_term_control_builtins.pl +11 -0
- package/test/conformance/cases/066_numeric_edges.pl +14 -0
- package/test/conformance/cases/067_list_edges.pl +10 -0
- package/test/conformance/cases/068_list_generation_order.pl +7 -0
- package/test/conformance/cases/069_list_summaries_and_sets.pl +9 -0
- package/test/conformance/cases/070_matches_named_captures.pl +13 -0
- package/test/conformance/cases/071_string_edges.pl +10 -0
- package/test/conformance/cases/072_string_conversions.pl +10 -0
- package/test/conformance/cases/073_term_introspection_edges.pl +10 -0
- package/test/conformance/cases/074_forall_edges.pl +10 -0
- package/test/conformance/cases/075_aggregation_edges.pl +12 -0
- package/test/conformance/cases/076_composed_reusable_builtins.pl +8 -0
- package/test/conformance/cases/077_recursive_path_with_lists.pl +10 -0
- package/test/conformance/cases/078_mutual_recursion_with_arithmetic.pl +7 -0
- package/test/conformance/cases/079_big_integer_arithmetic.pl +8 -0
- package/test/conformance/cases/080_rounding_modes.pl +10 -0
- package/test/conformance/cases/081_zero_safe_numeric_functions.pl +9 -0
- package/test/conformance/cases/082_comparison_semantics.pl +10 -0
- package/test/conformance/cases/083_between_modes_and_empty_ranges.pl +8 -0
- package/test/conformance/cases/084_append_and_select_composition.pl +7 -0
- package/test/conformance/cases/085_nth_and_update_edges.pl +8 -0
- package/test/conformance/cases/086_slicing_pipeline.pl +10 -0
- package/test/conformance/cases/087_sort_reverse_length.pl +8 -0
- package/test/conformance/cases/088_list_summaries_failures.pl +8 -0
- package/test/conformance/cases/089_string_split_join_pipeline.pl +7 -0
- package/test/conformance/cases/090_string_substring_replace_edges.pl +9 -0
- package/test/conformance/cases/091_string_case_and_trim.pl +7 -0
- package/test/conformance/cases/092_scalar_string_conversions.pl +9 -0
- package/test/conformance/cases/093_regex_named_captures_context.pl +8 -0
- package/test/conformance/cases/094_context_holds_enumeration.pl +7 -0
- package/test/conformance/cases/095_term_introspection_roundtrip.pl +8 -0
- package/test/conformance/cases/096_functor_scalar_edges.pl +8 -0
- package/test/conformance/cases/097_control_negation_once_forall.pl +13 -0
- package/test/conformance/cases/098_aggregation_nested_templates.pl +11 -0
- package/test/conformance/cases/099_materialize_multiple_arities.pl +8 -0
- package/test/conformance/cases/100_reusable_builtin_workflow.pl +10 -0
- package/test/conformance/expected/001_fact_output.pl +1 -0
- package/test/conformance/expected/002_rule_recursion.pl +2 -0
- package/test/conformance/expected/003_terms_and_readback.pl +13 -0
- package/test/conformance/expected/004_conjunction_and_parentheses.pl +1 -0
- package/test/conformance/expected/005_list_deconstruction.pl +2 -0
- package/test/conformance/expected/006_comma_formula_data.pl +1 -0
- package/test/conformance/expected/007_anonymous_variables.pl +1 -0
- package/test/conformance/expected/008_graphic_atoms.pl +3 -0
- package/test/conformance/expected/009_comments_and_whitespace.pl +2 -0
- package/test/conformance/expected/010_variable_scope_and_reuse.pl +2 -0
- package/test/conformance/expected/011_predicate_arity.pl +2 -0
- package/test/conformance/expected/012_nested_compound_unification.pl +2 -0
- package/test/conformance/expected/013_multiple_clauses_order.pl +2 -0
- package/test/conformance/expected/014_failure_filters_answers.pl +1 -0
- package/test/conformance/expected/015_improper_list_unification.pl +3 -0
- package/test/conformance/expected/016_zero_arity_compound.pl +1 -0
- package/test/conformance/expected/017_three_step_recursion.pl +3 -0
- package/test/conformance/expected/018_quoted_atom_readback.pl +3 -0
- package/test/conformance/expected/019_parenthesized_three_conjuncts.pl +1 -0
- package/test/conformance/expected/020_nested_list_terms.pl +2 -0
- package/test/conformance/expected/021_repeated_variable_head.pl +2 -0
- package/test/conformance/expected/022_rule_head_structure.pl +2 -0
- package/test/conformance/expected/023_quoted_escapes_readback.pl +2 -0
- package/test/conformance/expected/024_numeric_literal_readback.pl +3 -0
- package/test/conformance/expected/025_body_parentheses_with_formula_data.pl +1 -0
- package/test/conformance/expected/026_underscore_named_variable_reuse.pl +1 -0
- package/test/conformance/expected/027_default_derived_output.pl +3 -0
- package/test/conformance/expected/028_materialize_focus.pl +1 -0
- package/test/conformance/expected/029_arithmetic_and_comparison.pl +9 -0
- package/test/conformance/expected/030_strings_and_atoms.pl +2 -0
- package/test/conformance/expected/031_lists_aggregation_ordering.pl +9 -0
- package/test/conformance/expected/032_holds_parts.pl +3 -0
- package/test/conformance/expected/033_negation_once_generators.pl +2 -0
- package/test/conformance/expected/034_equality_and_inequality.pl +4 -0
- package/test/conformance/expected/035_list_relations.pl +4 -0
- package/test/conformance/expected/036_append_splits.pl +3 -0
- package/test/conformance/expected/037_matching_and_comparison.pl +5 -0
- package/test/conformance/expected/038_memoize_declaration.pl +2 -0
- package/test/conformance/expected/039_numeric_functions.pl +7 -0
- package/test/conformance/expected/040_between_enumeration.pl +3 -0
- package/test/conformance/expected/041_smallest_divisor.pl +1 -0
- package/test/conformance/expected/042_negation_filter.pl +2 -0
- package/test/conformance/expected/043_once_user_predicate.pl +1 -0
- package/test/conformance/expected/044_findall_user_goal.pl +1 -0
- package/test/conformance/expected/045_sort_deduplicates_atoms.pl +1 -0
- package/test/conformance/expected/046_append_bound_prefix_suffix.pl +2 -0
- package/test/conformance/expected/047_nth0_index_generation.pl +1 -0
- package/test/conformance/expected/048_set_nth0_edges.pl +2 -0
- package/test/conformance/expected/049_select_duplicate_occurrences.pl +2 -0
- package/test/conformance/expected/050_not_member_filter.pl +1 -0
- package/test/conformance/expected/051_nested_holds_parts.pl +3 -0
- package/test/conformance/expected/052_holds_member.pl +2 -0
- package/test/conformance/expected/053_materialize_excludes_source_fact.pl +1 -0
- package/test/conformance/expected/054_numeric_and_lexical_comparison.pl +3 -0
- package/test/conformance/expected/055_string_matching_filters.pl +2 -0
- package/test/conformance/expected/056_string_and_atom_concat.pl +1 -0
- package/test/conformance/expected/057_countall_empty_and_nonempty.pl +1 -0
- package/test/conformance/expected/058_sumall_numeric_template.pl +1 -0
- package/test/conformance/expected/059_aggregate_min_template.pl +1 -0
- package/test/conformance/expected/060_aggregate_max_compound_key.pl +1 -0
- package/test/conformance/expected/061_date_difference.pl +2 -0
- package/test/conformance/expected/062_reusable_numeric_builtins.pl +8 -0
- package/test/conformance/expected/063_reusable_list_builtins.pl +9 -0
- package/test/conformance/expected/064_reusable_string_builtins.pl +10 -0
- package/test/conformance/expected/065_reusable_term_control_builtins.pl +6 -0
- package/test/conformance/expected/066_numeric_edges.pl +12 -0
- package/test/conformance/expected/067_list_edges.pl +8 -0
- package/test/conformance/expected/068_list_generation_order.pl +10 -0
- package/test/conformance/expected/069_list_summaries_and_sets.pl +7 -0
- package/test/conformance/expected/070_matches_named_captures.pl +1 -0
- package/test/conformance/expected/071_string_edges.pl +8 -0
- package/test/conformance/expected/072_string_conversions.pl +8 -0
- package/test/conformance/expected/073_term_introspection_edges.pl +8 -0
- package/test/conformance/expected/074_forall_edges.pl +5 -0
- package/test/conformance/expected/075_aggregation_edges.pl +7 -0
- package/test/conformance/expected/076_composed_reusable_builtins.pl +5 -0
- package/test/conformance/expected/077_recursive_path_with_lists.pl +3 -0
- package/test/conformance/expected/078_mutual_recursion_with_arithmetic.pl +7 -0
- package/test/conformance/expected/079_big_integer_arithmetic.pl +6 -0
- package/test/conformance/expected/080_rounding_modes.pl +8 -0
- package/test/conformance/expected/081_zero_safe_numeric_functions.pl +7 -0
- package/test/conformance/expected/082_comparison_semantics.pl +8 -0
- package/test/conformance/expected/083_between_modes_and_empty_ranges.pl +8 -0
- package/test/conformance/expected/084_append_and_select_composition.pl +10 -0
- package/test/conformance/expected/085_nth_and_update_edges.pl +8 -0
- package/test/conformance/expected/086_slicing_pipeline.pl +7 -0
- package/test/conformance/expected/087_sort_reverse_length.pl +6 -0
- package/test/conformance/expected/088_list_summaries_failures.pl +6 -0
- package/test/conformance/expected/089_string_split_join_pipeline.pl +4 -0
- package/test/conformance/expected/090_string_substring_replace_edges.pl +7 -0
- package/test/conformance/expected/091_string_case_and_trim.pl +5 -0
- package/test/conformance/expected/092_scalar_string_conversions.pl +7 -0
- package/test/conformance/expected/093_regex_named_captures_context.pl +5 -0
- package/test/conformance/expected/094_context_holds_enumeration.pl +8 -0
- package/test/conformance/expected/095_term_introspection_roundtrip.pl +6 -0
- package/test/conformance/expected/096_functor_scalar_edges.pl +6 -0
- package/test/conformance/expected/097_control_negation_once_forall.pl +5 -0
- package/test/conformance/expected/098_aggregation_nested_templates.pl +5 -0
- package/test/conformance/expected/099_materialize_multiple_arities.pl +4 -0
- package/test/conformance/expected/100_reusable_builtin_workflow.pl +6 -0
- package/test/run-all.mjs +20 -0
- package/test/run-conformance.mjs +78 -0
- package/test/run-examples.mjs +125 -0
- package/test/run-regression.mjs +612 -0
- package/test/test-style.mjs +94 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
% Chandy-Misra dining philosophers trace adapted from Eyeling dining-philosophers.n3.
|
|
2
|
+
% Requests and sends are derived; KeepFork facts copy forks that are not sent.
|
|
3
|
+
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
5
|
+
materialize(dp_type, 2).
|
|
6
|
+
materialize(dp_in, 2).
|
|
7
|
+
materialize(dp_from, 2).
|
|
8
|
+
materialize(dp_to, 2).
|
|
9
|
+
materialize(dp_fork, 2).
|
|
10
|
+
materialize(dp_philosopher, 2).
|
|
11
|
+
materialize(dp_mealNo, 2).
|
|
12
|
+
materialize(dp_inSlot, 2).
|
|
13
|
+
materialize(dp_usesFork, 2).
|
|
14
|
+
|
|
15
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
16
|
+
left_fork(dp_P1, dp_F51). right_fork(dp_P1, dp_F12).
|
|
17
|
+
left_fork(dp_P2, dp_F12). right_fork(dp_P2, dp_F23).
|
|
18
|
+
left_fork(dp_P3, dp_F23). right_fork(dp_P3, dp_F34).
|
|
19
|
+
left_fork(dp_P4, dp_F34). right_fork(dp_P4, dp_F45).
|
|
20
|
+
left_fork(dp_P5, dp_F45). right_fork(dp_P5, dp_F51).
|
|
21
|
+
|
|
22
|
+
slot(dp_C0, dp_s1, 1). after_sends(dp_C0, dp_C1). after_eat(dp_C1, dp_C2).
|
|
23
|
+
slot(dp_C2, dp_s2, 1). after_sends(dp_C2, dp_C3). after_eat(dp_C3, dp_C4).
|
|
24
|
+
slot(dp_C4, dp_s3, 1). after_sends(dp_C4, dp_C5). after_eat(dp_C5, dp_C6).
|
|
25
|
+
slot(dp_C6, dp_s4, 2). after_sends(dp_C6, dp_C7). after_eat(dp_C7, dp_C8).
|
|
26
|
+
slot(dp_C8, dp_s5, 2). after_sends(dp_C8, dp_C9). after_eat(dp_C9, dp_C10).
|
|
27
|
+
slot(dp_C10, dp_s6, 2). after_sends(dp_C10, dp_C11). after_eat(dp_C11, dp_C12).
|
|
28
|
+
slot(dp_C12, dp_s7, 3). after_sends(dp_C12, dp_C13). after_eat(dp_C13, dp_C14).
|
|
29
|
+
slot(dp_C14, dp_s8, 3). after_sends(dp_C14, dp_C15). after_eat(dp_C15, dp_C16).
|
|
30
|
+
slot(dp_C16, dp_s9, 3). after_sends(dp_C16, dp_C17). after_eat(dp_C17, dp_C18).
|
|
31
|
+
|
|
32
|
+
hungry(dp_C0, dp_P1). hungry(dp_C0, dp_P3).
|
|
33
|
+
hungry(dp_C2, dp_P2). hungry(dp_C2, dp_P4).
|
|
34
|
+
hungry(dp_C4, dp_P5).
|
|
35
|
+
hungry(dp_C6, dp_P1). hungry(dp_C6, dp_P3).
|
|
36
|
+
hungry(dp_C8, dp_P2). hungry(dp_C8, dp_P4).
|
|
37
|
+
hungry(dp_C10, dp_P5).
|
|
38
|
+
hungry(dp_C12, dp_P1). hungry(dp_C12, dp_P3).
|
|
39
|
+
hungry(dp_C14, dp_P2). hungry(dp_C14, dp_P4).
|
|
40
|
+
hungry(dp_C16, dp_P5).
|
|
41
|
+
|
|
42
|
+
start_state(dp_C0, dp_F12, dp_P1, dp_Dirty).
|
|
43
|
+
start_state(dp_C0, dp_F23, dp_P2, dp_Dirty).
|
|
44
|
+
start_state(dp_C0, dp_F34, dp_P3, dp_Dirty).
|
|
45
|
+
start_state(dp_C0, dp_F45, dp_P4, dp_Dirty).
|
|
46
|
+
start_state(dp_C0, dp_F51, dp_P1, dp_Dirty).
|
|
47
|
+
start_state(dp_C2, dp_F12, dp_P1, dp_Dirty).
|
|
48
|
+
start_state(dp_C2, dp_F23, dp_P3, dp_Dirty).
|
|
49
|
+
start_state(dp_C2, dp_F34, dp_P3, dp_Dirty).
|
|
50
|
+
start_state(dp_C2, dp_F45, dp_P4, dp_Dirty).
|
|
51
|
+
start_state(dp_C2, dp_F51, dp_P1, dp_Dirty).
|
|
52
|
+
start_state(dp_C4, dp_F12, dp_P2, dp_Dirty).
|
|
53
|
+
start_state(dp_C4, dp_F23, dp_P2, dp_Dirty).
|
|
54
|
+
start_state(dp_C4, dp_F34, dp_P4, dp_Dirty).
|
|
55
|
+
start_state(dp_C4, dp_F45, dp_P4, dp_Dirty).
|
|
56
|
+
start_state(dp_C4, dp_F51, dp_P1, dp_Dirty).
|
|
57
|
+
start_state(dp_C6, dp_F12, dp_P2, dp_Dirty).
|
|
58
|
+
start_state(dp_C6, dp_F23, dp_P2, dp_Dirty).
|
|
59
|
+
start_state(dp_C6, dp_F34, dp_P4, dp_Dirty).
|
|
60
|
+
start_state(dp_C6, dp_F45, dp_P5, dp_Dirty).
|
|
61
|
+
start_state(dp_C6, dp_F51, dp_P5, dp_Dirty).
|
|
62
|
+
start_state(dp_C8, dp_F12, dp_P1, dp_Dirty).
|
|
63
|
+
start_state(dp_C8, dp_F23, dp_P3, dp_Dirty).
|
|
64
|
+
start_state(dp_C8, dp_F34, dp_P3, dp_Dirty).
|
|
65
|
+
start_state(dp_C8, dp_F45, dp_P5, dp_Dirty).
|
|
66
|
+
start_state(dp_C8, dp_F51, dp_P1, dp_Dirty).
|
|
67
|
+
start_state(dp_C10, dp_F12, dp_P2, dp_Dirty).
|
|
68
|
+
start_state(dp_C10, dp_F23, dp_P2, dp_Dirty).
|
|
69
|
+
start_state(dp_C10, dp_F34, dp_P4, dp_Dirty).
|
|
70
|
+
start_state(dp_C10, dp_F45, dp_P4, dp_Dirty).
|
|
71
|
+
start_state(dp_C10, dp_F51, dp_P1, dp_Dirty).
|
|
72
|
+
start_state(dp_C12, dp_F12, dp_P2, dp_Dirty).
|
|
73
|
+
start_state(dp_C12, dp_F23, dp_P2, dp_Dirty).
|
|
74
|
+
start_state(dp_C12, dp_F34, dp_P4, dp_Dirty).
|
|
75
|
+
start_state(dp_C12, dp_F45, dp_P5, dp_Dirty).
|
|
76
|
+
start_state(dp_C12, dp_F51, dp_P5, dp_Dirty).
|
|
77
|
+
start_state(dp_C14, dp_F12, dp_P1, dp_Dirty).
|
|
78
|
+
start_state(dp_C14, dp_F23, dp_P3, dp_Dirty).
|
|
79
|
+
start_state(dp_C14, dp_F34, dp_P3, dp_Dirty).
|
|
80
|
+
start_state(dp_C14, dp_F45, dp_P5, dp_Dirty).
|
|
81
|
+
start_state(dp_C14, dp_F51, dp_P1, dp_Dirty).
|
|
82
|
+
start_state(dp_C16, dp_F12, dp_P2, dp_Dirty).
|
|
83
|
+
start_state(dp_C16, dp_F23, dp_P2, dp_Dirty).
|
|
84
|
+
start_state(dp_C16, dp_F34, dp_P4, dp_Dirty).
|
|
85
|
+
start_state(dp_C16, dp_F45, dp_P4, dp_Dirty).
|
|
86
|
+
start_state(dp_C16, dp_F51, dp_P1, dp_Dirty).
|
|
87
|
+
keep(dp_C0, dp_F12). keep(dp_C0, dp_F34). keep(dp_C0, dp_F45). keep(dp_C0, dp_F51).
|
|
88
|
+
keep(dp_C2, dp_F45). keep(dp_C2, dp_F51).
|
|
89
|
+
keep(dp_C4, dp_F12). keep(dp_C4, dp_F23). keep(dp_C4, dp_F34).
|
|
90
|
+
keep(dp_C6, dp_F45).
|
|
91
|
+
keep(dp_C8, dp_F51).
|
|
92
|
+
keep(dp_C10, dp_F12). keep(dp_C10, dp_F23). keep(dp_C10, dp_F34).
|
|
93
|
+
keep(dp_C12, dp_F45).
|
|
94
|
+
keep(dp_C14, dp_F51).
|
|
95
|
+
keep(dp_C16, dp_F12). keep(dp_C16, dp_F23). keep(dp_C16, dp_F34).
|
|
96
|
+
|
|
97
|
+
meal_handle(dp_P1, 1, dp_mP1_1). meal_handle(dp_P1, 2, dp_mP1_2). meal_handle(dp_P1, 3, dp_mP1_3).
|
|
98
|
+
meal_handle(dp_P2, 1, dp_mP2_1). meal_handle(dp_P2, 2, dp_mP2_2). meal_handle(dp_P2, 3, dp_mP2_3).
|
|
99
|
+
meal_handle(dp_P3, 1, dp_mP3_1). meal_handle(dp_P3, 2, dp_mP3_2). meal_handle(dp_P3, 3, dp_mP3_3).
|
|
100
|
+
meal_handle(dp_P4, 1, dp_mP4_1). meal_handle(dp_P4, 2, dp_mP4_2). meal_handle(dp_P4, 3, dp_mP4_3).
|
|
101
|
+
meal_handle(dp_P5, 1, dp_mP5_1). meal_handle(dp_P5, 2, dp_mP5_2). meal_handle(dp_P5, 3, dp_mP5_3).
|
|
102
|
+
|
|
103
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
104
|
+
request(C, P, Q, F) :-
|
|
105
|
+
hungry(C, P), left_fork(P, F), start_state(C, F, Q, _Cleanliness), neq(Q, P).
|
|
106
|
+
request(C, P, Q, F) :-
|
|
107
|
+
hungry(C, P), right_fork(P, F), start_state(C, F, Q, _Cleanliness), neq(Q, P).
|
|
108
|
+
|
|
109
|
+
send_fork(C, Q, P, F) :-
|
|
110
|
+
request(C, P, Q, F), start_state(C, F, Q, dp_Dirty).
|
|
111
|
+
|
|
112
|
+
after_send_state(CS, F, P, dp_Clean) :-
|
|
113
|
+
after_sends(C, CS), send_fork(C, _Q, P, F).
|
|
114
|
+
after_send_state(CS, F, H, Cleanliness) :-
|
|
115
|
+
after_sends(C, CS), keep(C, F), start_state(C, F, H, Cleanliness).
|
|
116
|
+
|
|
117
|
+
meal(M, P, N, S) :-
|
|
118
|
+
after_sends(C, CS), slot(C, S, N), hungry(C, P), meal_handle(P, N, M),
|
|
119
|
+
left_fork(P, LF), right_fork(P, RF),
|
|
120
|
+
after_send_state(CS, LF, P, _LeftCleanliness),
|
|
121
|
+
after_send_state(CS, RF, P, _RightCleanliness).
|
|
122
|
+
|
|
123
|
+
dp_type(request(C, P, Q, F), dp_Request) :- request(C, P, Q, F).
|
|
124
|
+
dp_in(request(C, P, Q, F), C) :- request(C, P, Q, F).
|
|
125
|
+
dp_from(request(C, P, Q, F), P) :- request(C, P, Q, F).
|
|
126
|
+
dp_to(request(C, P, Q, F), Q) :- request(C, P, Q, F).
|
|
127
|
+
dp_fork(request(C, P, Q, F), F) :- request(C, P, Q, F).
|
|
128
|
+
|
|
129
|
+
dp_type(send(C, Q, P, F), dp_SendFork) :- send_fork(C, Q, P, F).
|
|
130
|
+
dp_in(send(C, Q, P, F), C) :- send_fork(C, Q, P, F).
|
|
131
|
+
dp_from(send(C, Q, P, F), Q) :- send_fork(C, Q, P, F).
|
|
132
|
+
dp_to(send(C, Q, P, F), P) :- send_fork(C, Q, P, F).
|
|
133
|
+
dp_fork(send(C, Q, P, F), F) :- send_fork(C, Q, P, F).
|
|
134
|
+
|
|
135
|
+
dp_type(M, dp_Meal) :- meal(M, _P, _N, _S).
|
|
136
|
+
dp_philosopher(M, P) :- meal(M, P, _N, _S).
|
|
137
|
+
dp_mealNo(M, N) :- meal(M, _P, N, _S).
|
|
138
|
+
dp_inSlot(M, S) :- meal(M, _P, _N, S).
|
|
139
|
+
dp_usesFork(M, LF) :- meal(M, P, _N, _S), left_fork(P, LF).
|
|
140
|
+
dp_usesFork(M, RF) :- meal(M, P, _N, _S), right_fork(P, RF).
|
package/examples/dog.pl
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
% The output reports only the compliance obligation derived below.
|
|
2
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
3
|
+
materialize(mustHave, 2).
|
|
4
|
+
|
|
5
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
6
|
+
% Dog-license example adapted from Eyeling dog.n3.
|
|
7
|
+
% A subject with more than four dogs must have a dog license.
|
|
8
|
+
|
|
9
|
+
hasDog(alice, dog1).
|
|
10
|
+
hasDog(alice, dog2).
|
|
11
|
+
hasDog(alice, dog3).
|
|
12
|
+
hasDog(alice, dog4).
|
|
13
|
+
hasDog(alice, dog5).
|
|
14
|
+
hasDog(bob, dog6).
|
|
15
|
+
hasDog(bob, dog7).
|
|
16
|
+
|
|
17
|
+
% countall/2 counts all matching dogs for the same subject.
|
|
18
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
19
|
+
dogCount(Subject, Count) :-
|
|
20
|
+
hasDog(Subject, _Any),
|
|
21
|
+
countall(hasDog(Subject, _Dog), Count).
|
|
22
|
+
|
|
23
|
+
mustHave(Subject, dogLicense) :-
|
|
24
|
+
dogCount(Subject, Count),
|
|
25
|
+
gt(Count, 4).
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
% DPV process to ODRL policy view in eyelang.
|
|
2
|
+
|
|
3
|
+
materialize(type, 2).
|
|
4
|
+
materialize(odrl_permission, 2).
|
|
5
|
+
materialize(odrl_assigner, 2).
|
|
6
|
+
materialize(odrl_assignee, 2).
|
|
7
|
+
materialize(odrl_target, 2).
|
|
8
|
+
materialize(odrl_action, 2).
|
|
9
|
+
materialize(odrl_constraint, 2).
|
|
10
|
+
materialize(odrl_leftOperand, 2).
|
|
11
|
+
materialize(odrl_operator, 2).
|
|
12
|
+
materialize(odrl_rightOperand, 2).
|
|
13
|
+
materialize(derived_from_process, 2).
|
|
14
|
+
|
|
15
|
+
process(alpha_care_process).
|
|
16
|
+
data_controller(alpha_care_process, hospital_a).
|
|
17
|
+
recipient(alpha_care_process, research_partner).
|
|
18
|
+
personal_data(alpha_care_process, lab_result).
|
|
19
|
+
processing(alpha_care_process, dpv_use).
|
|
20
|
+
purpose(alpha_care_process, dpv_healthcare).
|
|
21
|
+
legal_basis(alpha_care_process, dpv_consent).
|
|
22
|
+
|
|
23
|
+
represents_process(alpha_policy, alpha_care_process).
|
|
24
|
+
permission_node(alpha_policy, alpha_permission).
|
|
25
|
+
purpose_constraint(alpha_policy, alpha_purpose_constraint).
|
|
26
|
+
basis_constraint(alpha_policy, alpha_basis_constraint).
|
|
27
|
+
|
|
28
|
+
type(Policy, odrl_policy) :- represents_process(Policy, _Process).
|
|
29
|
+
odrl_permission(Policy, Permission) :- permission_node(Policy, Permission).
|
|
30
|
+
type(Permission, odrl_permission) :- permission_node(_Policy, Permission).
|
|
31
|
+
derived_from_process(Permission, Process) :- represents_process(Policy, Process), permission_node(Policy, Permission).
|
|
32
|
+
odrl_assigner(Permission, Controller) :- represents_process(Policy, Process), permission_node(Policy, Permission), data_controller(Process, Controller).
|
|
33
|
+
odrl_assignee(Permission, Recipient) :- represents_process(Policy, Process), permission_node(Policy, Permission), recipient(Process, Recipient).
|
|
34
|
+
odrl_target(Permission, Data) :- represents_process(Policy, Process), permission_node(Policy, Permission), personal_data(Process, Data).
|
|
35
|
+
odrl_action(Permission, Action) :- represents_process(Policy, Process), permission_node(Policy, Permission), processing(Process, Action).
|
|
36
|
+
|
|
37
|
+
odrl_constraint(Permission, Constraint) :- permission_node(Policy, Permission), purpose_constraint(Policy, Constraint).
|
|
38
|
+
odrl_constraint(Permission, Constraint) :- permission_node(Policy, Permission), basis_constraint(Policy, Constraint).
|
|
39
|
+
type(Constraint, odrl_constraint) :- purpose_constraint(_Policy, Constraint).
|
|
40
|
+
type(Constraint, odrl_constraint) :- basis_constraint(_Policy, Constraint).
|
|
41
|
+
odrl_leftOperand(Constraint, dpv_odrl_purpose) :- purpose_constraint(_Policy, Constraint).
|
|
42
|
+
odrl_leftOperand(Constraint, dpv_odrl_legal_basis) :- basis_constraint(_Policy, Constraint).
|
|
43
|
+
odrl_operator(Constraint, odrl_isA) :- purpose_constraint(_Policy, Constraint).
|
|
44
|
+
odrl_operator(Constraint, odrl_isA) :- basis_constraint(_Policy, Constraint).
|
|
45
|
+
odrl_rightOperand(Constraint, Purpose) :- represents_process(Policy, Process), purpose_constraint(Policy, Constraint), purpose(Process, Purpose).
|
|
46
|
+
odrl_rightOperand(Constraint, Basis) :- represents_process(Policy, Process), basis_constraint(Policy, Constraint), legal_basis(Process, Basis).
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
% Memoize bounded paths because surviving-plan metrics reuse route prefixes.
|
|
2
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
3
|
+
materialize(gps_plan, 2).
|
|
4
|
+
|
|
5
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
6
|
+
memoize(path, 9).
|
|
7
|
+
|
|
8
|
+
% Bounded drone corridor planner adapted from Eyeling drone-corridor-planner.n3.
|
|
9
|
+
% A fuel list bounds recursion; duration and cost are summed, belief and comfort
|
|
10
|
+
% are multiplied along the action sequence.
|
|
11
|
+
|
|
12
|
+
fuel(fuel7, [t, t, t, t, t, t, t]).
|
|
13
|
+
|
|
14
|
+
step(state(gent, full, P), state(brugge, mid, P), fly_gent_brugge, 1500.0, 0.006, 0.99, 0.99).
|
|
15
|
+
step(state(gent, B, P), state(brugge, B, P), train_gent_brugge, 1700.0, 0.012, 0.999, 0.995).
|
|
16
|
+
step(state(gent, full, P), state(kortrijk, mid, P), fly_gent_kortrijk, 1600.0, 0.007, 0.99, 0.99).
|
|
17
|
+
step(state(kortrijk, mid, P), state(brugge, low, P), fly_kortrijk_brugge, 1600.0, 0.007, 0.99, 0.99).
|
|
18
|
+
step(state(brugge, mid, P), state(kortrijk, low, P), fly_brugge_kortrijk, 1600.0, 0.007, 0.985, 0.98).
|
|
19
|
+
step(state(kortrijk, B, none), state(kortrijk, B, yes), get_zone_permit_kortrijk, 300.0, 0.001, 0.999, 1.0).
|
|
20
|
+
step(state(brugge, B, none), state(brugge, B, yes), buy_permit_brugge, 450.0, 0.002, 0.98, 1.0).
|
|
21
|
+
step(state(brugge, low, P), state(brugge, full, P), quick_charge_brugge, 600.0, 0.004, 0.999, 0.97).
|
|
22
|
+
step(state(brugge, mid, P), state(brugge, full, P), topup_brugge, 400.0, 0.003, 0.999, 0.98).
|
|
23
|
+
step(state(kortrijk, mid, P), state(kortrijk, full, P), emergency_charge_kortrijk, 500.0, 0.003, 0.999, 0.95).
|
|
24
|
+
step(state(brugge, full, yes), state(oostende, mid, yes), cross_corridor_brugge_oostende, 900.0, 0.004, 0.98, 1.0).
|
|
25
|
+
step(state(brugge, mid, P), state(oostende, low, P), public_coastline_brugge_oostende, 1300.0, 0.006, 0.97, 0.96).
|
|
26
|
+
step(state(brugge, full, P), state(oostende, mid, P), public_coastline_brugge_oostende, 1200.0, 0.006, 0.975, 0.96).
|
|
27
|
+
step(state(kortrijk, full, yes), state(oostende, mid, yes), direct_corridor_kortrijk_oostende, 1100.0, 0.009, 0.955, 0.92).
|
|
28
|
+
|
|
29
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
30
|
+
path(From, To, [Act], Duration, Cost, Belief, Comfort, FuelIn, FuelOut) :-
|
|
31
|
+
step(From, To, Act, Duration, Cost, Belief, Comfort),
|
|
32
|
+
rest(FuelIn, FuelOut).
|
|
33
|
+
|
|
34
|
+
path(From, To, Actions, Duration, Cost, Belief, Comfort, FuelIn, FuelOut) :-
|
|
35
|
+
step(From, Mid, Act, D1, C1, B1, M1),
|
|
36
|
+
rest(FuelIn, FuelMid),
|
|
37
|
+
path(Mid, To, RestActions, D2, C2, B2, M2, FuelMid, FuelOut),
|
|
38
|
+
append([Act], RestActions, Actions),
|
|
39
|
+
add(D1, D2, Duration),
|
|
40
|
+
add(C1, C2, Cost),
|
|
41
|
+
mul(B1, B2, Belief),
|
|
42
|
+
mul(M1, M2, Comfort).
|
|
43
|
+
|
|
44
|
+
surviving_plan(Actions, Duration, Cost, Belief, Comfort, Battery, Permit, FuelLeft) :-
|
|
45
|
+
fuel(fuel7, Fuel),
|
|
46
|
+
path(state(gent, full, none), state(oostende, Battery, Permit), Actions, Duration, Cost, Belief, Comfort, Fuel, FuelLeft),
|
|
47
|
+
gt(Belief, 0.94),
|
|
48
|
+
lt(Cost, 0.03).
|
|
49
|
+
|
|
50
|
+
gps_plan(d1, plan(Actions, Duration, Cost, Belief, Comfort, Battery, Permit, FuelLeft)) :-
|
|
51
|
+
surviving_plan(Actions, Duration, Cost, Belief, Comfort, Battery, Permit, FuelLeft).
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
% Adapted from Eyeling's easter.n3.
|
|
2
|
+
% Gregorian computus for a sample decade, with independent range/window checks.
|
|
3
|
+
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
5
|
+
materialize(easterDate, 2).
|
|
6
|
+
materialize(computusRemainders, 2).
|
|
7
|
+
materialize(legalGregorianWindow, 2).
|
|
8
|
+
|
|
9
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
10
|
+
% Sample years for which the computed Easter date is materialized.
|
|
11
|
+
case(y2026, 2026).
|
|
12
|
+
case(y2027, 2027).
|
|
13
|
+
case(y2028, 2028).
|
|
14
|
+
case(y2029, 2029).
|
|
15
|
+
case(y2030, 2030).
|
|
16
|
+
case(y2031, 2031).
|
|
17
|
+
case(y2032, 2032).
|
|
18
|
+
case(y2033, 2033).
|
|
19
|
+
case(y2034, 2034).
|
|
20
|
+
case(y2035, 2035).
|
|
21
|
+
|
|
22
|
+
% These checks document the legal ranges of intermediate computus values.
|
|
23
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
24
|
+
valid_golden(N) :- between(0, 18, N).
|
|
25
|
+
valid_epact(N) :- between(0, 29, N).
|
|
26
|
+
valid_weekday(N) :- between(0, 6, N).
|
|
27
|
+
legal_easter_date(3, D) :- between(22, 31, D).
|
|
28
|
+
legal_easter_date(4, D) :- between(1, 25, D).
|
|
29
|
+
month_name(3, march).
|
|
30
|
+
month_name(4, april).
|
|
31
|
+
|
|
32
|
+
% Butcher/Meeus-style integer arithmetic, kept explicit for proof readability.
|
|
33
|
+
computus(Case, Year, Month, Day, J, K, Q, R, V, Z) :-
|
|
34
|
+
case(Case, Year),
|
|
35
|
+
mod(Year, 19, J),
|
|
36
|
+
div(Year, 100, K),
|
|
37
|
+
mod(Year, 100, H),
|
|
38
|
+
div(K, 4, M),
|
|
39
|
+
mod(K, 4, N),
|
|
40
|
+
add(K, 8, KP8),
|
|
41
|
+
div(KP8, 25, P),
|
|
42
|
+
sub(K, P, KminusP),
|
|
43
|
+
add(KminusP, 1, KminusPplus1),
|
|
44
|
+
div(KminusPplus1, 3, Q),
|
|
45
|
+
mul(19, J, NineteenJ),
|
|
46
|
+
add(NineteenJ, K, T1),
|
|
47
|
+
sub(T1, M, T2),
|
|
48
|
+
sub(T2, Q, T3),
|
|
49
|
+
add(T3, 15, T4),
|
|
50
|
+
mod(T4, 30, R),
|
|
51
|
+
div(H, 4, S),
|
|
52
|
+
mod(H, 4, U),
|
|
53
|
+
mul(2, N, TwoN),
|
|
54
|
+
mul(2, S, TwoS),
|
|
55
|
+
add(32, TwoN, L1),
|
|
56
|
+
add(L1, TwoS, L2),
|
|
57
|
+
sub(L2, R, L3),
|
|
58
|
+
sub(L3, U, L4),
|
|
59
|
+
mod(L4, 7, V),
|
|
60
|
+
mul(11, R, ElevenR),
|
|
61
|
+
mul(22, V, TwentyTwoV),
|
|
62
|
+
add(J, ElevenR, W1),
|
|
63
|
+
add(W1, TwentyTwoV, W2),
|
|
64
|
+
div(W2, 451, W),
|
|
65
|
+
mul(7, W, SevenW),
|
|
66
|
+
add(R, V, X1),
|
|
67
|
+
sub(X1, SevenW, X2),
|
|
68
|
+
add(X2, 114, X3),
|
|
69
|
+
div(X3, 31, Month),
|
|
70
|
+
mod(X3, 31, Z),
|
|
71
|
+
add(Z, 1, Day).
|
|
72
|
+
|
|
73
|
+
checks_pass(Case) :-
|
|
74
|
+
computus(Case, _Year, Month, Day, J, _K, _Q, R, V, _Z),
|
|
75
|
+
valid_golden(J),
|
|
76
|
+
valid_epact(R),
|
|
77
|
+
valid_weekday(V),
|
|
78
|
+
month_name(Month, _Name),
|
|
79
|
+
legal_easter_date(Month, Day).
|
|
80
|
+
|
|
81
|
+
easterDate(Case, date(Year, MonthName, Day)) :-
|
|
82
|
+
computus(Case, Year, Month, Day, _J, _K, _Q, _R, _V, _Z),
|
|
83
|
+
month_name(Month, MonthName).
|
|
84
|
+
|
|
85
|
+
computusRemainders(Case, remainders(J, R, V)) :-
|
|
86
|
+
computus(Case, _Year, _Month, _Day, J, _K, _Q, R, V, _Z).
|
|
87
|
+
|
|
88
|
+
legalGregorianWindow(Case, true) :-
|
|
89
|
+
checks_pass(Case).
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
% Engineering example: RC low-pass filter sizing.
|
|
2
|
+
%
|
|
3
|
+
% The cutoff frequency is 1 / (2*pi*R*C).
|
|
4
|
+
|
|
5
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
|
+
materialize(type, 2).
|
|
7
|
+
materialize(timeConstant_s, 2).
|
|
8
|
+
materialize(cutoffFrequency_Hz, 2).
|
|
9
|
+
|
|
10
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
11
|
+
component(filter1, resistor_ohm, 10000.0).
|
|
12
|
+
component(filter1, capacitor_f, 0.000001).
|
|
13
|
+
constant(pi, 3.141592653589793).
|
|
14
|
+
|
|
15
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
16
|
+
time_constant(Filter, Tau) :-
|
|
17
|
+
component(Filter, resistor_ohm, R),
|
|
18
|
+
component(Filter, capacitor_f, C),
|
|
19
|
+
mul(R, C, Tau).
|
|
20
|
+
|
|
21
|
+
cutoff_frequency(Filter, Frequency) :-
|
|
22
|
+
time_constant(Filter, Tau),
|
|
23
|
+
constant(pi, Pi),
|
|
24
|
+
mul(2.0, Pi, TwoPi),
|
|
25
|
+
mul(TwoPi, Tau, Denominator),
|
|
26
|
+
div(1.0, Denominator, Frequency).
|
|
27
|
+
|
|
28
|
+
type(Filter, first_order_low_pass) :-
|
|
29
|
+
component(Filter, resistor_ohm, _R),
|
|
30
|
+
component(Filter, capacitor_f, _C).
|
|
31
|
+
|
|
32
|
+
timeConstant_s(Filter, Tau) :-
|
|
33
|
+
time_constant(Filter, Tau).
|
|
34
|
+
|
|
35
|
+
cutoffFrequency_Hz(Filter, Frequency) :-
|
|
36
|
+
cutoff_frequency(Filter, Frequency).
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
% EYE-inspired epidemic policy choice.
|
|
2
|
+
% Policies are evaluated by estimated reproduction risk and social cost.
|
|
3
|
+
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
5
|
+
materialize(riskScore, 2).
|
|
6
|
+
materialize(cost, 2).
|
|
7
|
+
materialize(status, 2).
|
|
8
|
+
materialize(recommendedPolicy, 2).
|
|
9
|
+
materialize(reason, 2).
|
|
10
|
+
|
|
11
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
12
|
+
% Candidate interventions combine vaccination and mask factors.
|
|
13
|
+
policy(no_mandate).
|
|
14
|
+
policy(vaccination_campaign).
|
|
15
|
+
policy(indoor_masks).
|
|
16
|
+
policy(vaccination_and_masks).
|
|
17
|
+
|
|
18
|
+
base_risk(1.40).
|
|
19
|
+
|
|
20
|
+
vaccination_factor(no_mandate, 1.00).
|
|
21
|
+
vaccination_factor(vaccination_campaign, 0.55).
|
|
22
|
+
vaccination_factor(indoor_masks, 1.00).
|
|
23
|
+
vaccination_factor(vaccination_and_masks, 0.55).
|
|
24
|
+
|
|
25
|
+
mask_factor(no_mandate, 1.00).
|
|
26
|
+
mask_factor(vaccination_campaign, 1.00).
|
|
27
|
+
mask_factor(indoor_masks, 0.65).
|
|
28
|
+
mask_factor(vaccination_and_masks, 0.65).
|
|
29
|
+
|
|
30
|
+
policy_cost(no_mandate, 0).
|
|
31
|
+
policy_cost(vaccination_campaign, 3).
|
|
32
|
+
policy_cost(indoor_masks, 2).
|
|
33
|
+
policy_cost(vaccination_and_masks, 5).
|
|
34
|
+
|
|
35
|
+
% Risk multiplies the base reproduction estimate by policy-specific factors.
|
|
36
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
37
|
+
risk_score(P, R) :-
|
|
38
|
+
base_risk(Base),
|
|
39
|
+
vaccination_factor(P, VF),
|
|
40
|
+
mask_factor(P, MF),
|
|
41
|
+
mul(Base, VF, A),
|
|
42
|
+
mul(A, MF, R).
|
|
43
|
+
|
|
44
|
+
acceptable(P) :-
|
|
45
|
+
risk_score(P, R),
|
|
46
|
+
le(R, 0.75).
|
|
47
|
+
|
|
48
|
+
status(P, insufficient_control) :-
|
|
49
|
+
policy(P),
|
|
50
|
+
risk_score(P, R),
|
|
51
|
+
gt(R, 0.75).
|
|
52
|
+
|
|
53
|
+
status(P, acceptable_control) :-
|
|
54
|
+
acceptable(P).
|
|
55
|
+
|
|
56
|
+
% The recommendation is the only candidate below the outbreak threshold.
|
|
57
|
+
recommended(vaccination_and_masks) :-
|
|
58
|
+
acceptable(vaccination_and_masks),
|
|
59
|
+
status(no_mandate, insufficient_control),
|
|
60
|
+
status(vaccination_campaign, insufficient_control),
|
|
61
|
+
status(indoor_masks, insufficient_control).
|
|
62
|
+
|
|
63
|
+
riskScore(P, R) :- risk_score(P, R).
|
|
64
|
+
cost(P, C) :- policy_cost(P, C).
|
|
65
|
+
recommendedPolicy(epidemic_policy, P) :- recommended(P).
|
|
66
|
+
reason(epidemic_policy, "combined vaccination and indoor masks are the only policy below the outbreak threshold") :-
|
|
67
|
+
recommended(vaccination_and_masks).
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
2
|
+
materialize(sameClassBecauseOfSharedMember, 3).
|
|
3
|
+
|
|
4
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
5
|
+
% Equivalence-classes example adapted from Eyeling
|
|
6
|
+
% equivalence-classes-overlap-implies-same-class.n3.
|
|
7
|
+
% The finite class membership facts represent the equivalence closure generated
|
|
8
|
+
% by b~a and b~c; the rule packages every shared-member witness.
|
|
9
|
+
|
|
10
|
+
classMember(class_abc, a).
|
|
11
|
+
classMember(class_abc, b).
|
|
12
|
+
classMember(class_abc, c).
|
|
13
|
+
|
|
14
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
15
|
+
inClassOf(U, X) :-
|
|
16
|
+
classMember(Class, U),
|
|
17
|
+
classMember(Class, X).
|
|
18
|
+
|
|
19
|
+
sameClass(X, Y) :-
|
|
20
|
+
classMember(Class, X),
|
|
21
|
+
classMember(Class, Y).
|
|
22
|
+
|
|
23
|
+
sameClassBecauseOfSharedMember(X, Y, Z) :-
|
|
24
|
+
inClassOf(Z, X),
|
|
25
|
+
inClassOf(Z, Y),
|
|
26
|
+
sameClass(X, Y),
|
|
27
|
+
neq(X, Y).
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
% Eyelet-inspired Eulerian path example using findall/3 and sort/2.
|
|
2
|
+
% The graph is undirected; edges are represented by identifiers so each edge is used once.
|
|
3
|
+
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
5
|
+
materialize(oddVertices, 2).
|
|
6
|
+
materialize(path, 2).
|
|
7
|
+
materialize(edgeCount, 2).
|
|
8
|
+
materialize(reason, 2).
|
|
9
|
+
|
|
10
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
11
|
+
% Edge identifiers let the search remove each physical edge exactly once.
|
|
12
|
+
edge(e12, v1, v2).
|
|
13
|
+
edge(e13, v1, v3).
|
|
14
|
+
edge(e15, v1, v5).
|
|
15
|
+
edge(e16, v1, v6).
|
|
16
|
+
edge(e23, v2, v3).
|
|
17
|
+
edge(e24, v2, v4).
|
|
18
|
+
edge(e26, v2, v6).
|
|
19
|
+
edge(e34, v3, v4).
|
|
20
|
+
edge(e36, v3, v6).
|
|
21
|
+
edge(e45, v4, v5).
|
|
22
|
+
edge(e46, v4, v6).
|
|
23
|
+
|
|
24
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
25
|
+
vertex(V) :- edge(_E, V, _U).
|
|
26
|
+
vertex(V) :- edge(_E, _U, V).
|
|
27
|
+
|
|
28
|
+
incident(V, E) :- edge(E, V, _U).
|
|
29
|
+
incident(V, E) :- edge(E, _U, V).
|
|
30
|
+
|
|
31
|
+
adjacent_by_edge(V, U, E) :- edge(E, V, U).
|
|
32
|
+
adjacent_by_edge(V, U, E) :- edge(E, U, V).
|
|
33
|
+
|
|
34
|
+
select(Item, [Item | Rest], Rest).
|
|
35
|
+
select(Item, [Head | Tail], [Head | Rest]) :-
|
|
36
|
+
select(Item, Tail, Rest).
|
|
37
|
+
|
|
38
|
+
% Eulerian paths start at an odd-degree vertex when exactly two exist.
|
|
39
|
+
odd_degree(V) :-
|
|
40
|
+
findall(E, incident(V, E), Edges),
|
|
41
|
+
length(Edges, Degree),
|
|
42
|
+
mod(Degree, 2, 1).
|
|
43
|
+
|
|
44
|
+
odd_vertices(Odds) :-
|
|
45
|
+
findall(V, odd_degree(V), Raw),
|
|
46
|
+
sort(Raw, Odds).
|
|
47
|
+
|
|
48
|
+
all_edges(Edges) :-
|
|
49
|
+
findall(E, edge(E, _A, _B), Raw),
|
|
50
|
+
sort(Raw, Edges).
|
|
51
|
+
|
|
52
|
+
vertices(Vertices) :-
|
|
53
|
+
findall(V, vertex(V), Raw),
|
|
54
|
+
sort(Raw, Vertices).
|
|
55
|
+
|
|
56
|
+
eulerian_start(Start) :-
|
|
57
|
+
odd_vertices([Start, _End]).
|
|
58
|
+
eulerian_start(Start) :-
|
|
59
|
+
odd_vertices([]),
|
|
60
|
+
vertices([Start | _Rest]).
|
|
61
|
+
|
|
62
|
+
eulerian_path(Path) :-
|
|
63
|
+
eulerian_start(Start),
|
|
64
|
+
all_edges(Edges),
|
|
65
|
+
dfs_euler(Start, [Start], Edges, ReversedPath),
|
|
66
|
+
reverse(ReversedPath, Path).
|
|
67
|
+
|
|
68
|
+
% Depth-first search consumes the remaining edge-id list one edge at a time.
|
|
69
|
+
dfs_euler(_Current, Path, [], Path).
|
|
70
|
+
dfs_euler(Current, Visited, Remaining, Path) :-
|
|
71
|
+
adjacent_by_edge(Current, Next, Edge),
|
|
72
|
+
select(Edge, Remaining, NewRemaining),
|
|
73
|
+
dfs_euler(Next, [Next | Visited], NewRemaining, Path).
|
|
74
|
+
|
|
75
|
+
oddVertices(eulerian_path_case, Odds) :-
|
|
76
|
+
odd_vertices(Odds).
|
|
77
|
+
|
|
78
|
+
path(eulerian_path_case, Path) :-
|
|
79
|
+
once(eulerian_path(Path)).
|
|
80
|
+
|
|
81
|
+
edgeCount(eulerian_path_case, Count) :-
|
|
82
|
+
all_edges(Edges),
|
|
83
|
+
length(Edges, Count).
|
|
84
|
+
|
|
85
|
+
reason(eulerian_path_case, "findall collects graph structure and sort canonicalizes vertices and edges").
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
% EYE-inspired electric-vehicle range worlds.
|
|
2
|
+
% Four simple worlds estimate whether trips fit the available battery.
|
|
3
|
+
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
5
|
+
materialize(safeInWorld, 2).
|
|
6
|
+
materialize(riskyInWorld, 2).
|
|
7
|
+
materialize(reason, 2).
|
|
8
|
+
materialize(status, 2).
|
|
9
|
+
|
|
10
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
11
|
+
trip(city_errand).
|
|
12
|
+
trip(winter_highway).
|
|
13
|
+
trip(heavy_delivery).
|
|
14
|
+
trip(cold_commute).
|
|
15
|
+
|
|
16
|
+
% trip_data(Trip, DistanceKm, SpeedKmh, TemperatureC, PayloadKg, BatteryKWh, BaseKWhPerKm).
|
|
17
|
+
trip_data(city_errand, 40, 45, 20, 100, 30, 0.18).
|
|
18
|
+
trip_data(winter_highway, 260, 115, -5, 400, 60, 0.20).
|
|
19
|
+
trip_data(heavy_delivery, 180, 80, 15, 700, 55, 0.22).
|
|
20
|
+
trip_data(cold_commute, 120, 90, -8, 100, 35, 0.19).
|
|
21
|
+
|
|
22
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
23
|
+
speed_factor(T, 1.20) :- trip_data(T, _, S, _, _, _, _), gt(S, 100).
|
|
24
|
+
speed_factor(T, 1.00) :- trip_data(T, _, S, _, _, _, _), le(S, 100).
|
|
25
|
+
|
|
26
|
+
temperature_factor(T, 1.15) :- trip_data(T, _, _, Temp, _, _, _), lt(Temp, 0).
|
|
27
|
+
temperature_factor(T, 1.00) :- trip_data(T, _, _, Temp, _, _, _), ge(Temp, 0).
|
|
28
|
+
|
|
29
|
+
payload_factor(T, 1.15) :- trip_data(T, _, _, _, P, _, _), gt(P, 500).
|
|
30
|
+
payload_factor(T, 1.08) :- trip_data(T, _, _, _, P, _, _), gt(P, 250), le(P, 500).
|
|
31
|
+
payload_factor(T, 1.00) :- trip_data(T, _, _, _, P, _, _), le(P, 250).
|
|
32
|
+
|
|
33
|
+
base_energy(T, E) :-
|
|
34
|
+
trip_data(T, D, _, _, _, _, B),
|
|
35
|
+
mul(D, B, E).
|
|
36
|
+
|
|
37
|
+
required_energy(T, w1, E) :-
|
|
38
|
+
base_energy(T, E).
|
|
39
|
+
|
|
40
|
+
required_energy(T, w2, E) :-
|
|
41
|
+
base_energy(T, Base),
|
|
42
|
+
speed_factor(T, SF),
|
|
43
|
+
mul(Base, SF, E).
|
|
44
|
+
|
|
45
|
+
required_energy(T, w0, E) :-
|
|
46
|
+
base_energy(T, Base),
|
|
47
|
+
speed_factor(T, SF),
|
|
48
|
+
temperature_factor(T, TF),
|
|
49
|
+
payload_factor(T, PF),
|
|
50
|
+
mul(Base, SF, A),
|
|
51
|
+
mul(A, TF, B),
|
|
52
|
+
mul(B, PF, E).
|
|
53
|
+
|
|
54
|
+
required_energy(T, w3, E) :-
|
|
55
|
+
required_energy(T, w0, W0),
|
|
56
|
+
mul(W0, 1.30, E).
|
|
57
|
+
|
|
58
|
+
safe_in_world(T, W) :-
|
|
59
|
+
trip_data(T, _, _, _, _, Battery, _),
|
|
60
|
+
required_energy(T, W, Required),
|
|
61
|
+
le(Required, Battery).
|
|
62
|
+
|
|
63
|
+
risky_in_world(T, W) :-
|
|
64
|
+
trip_data(T, _, _, _, _, Battery, _),
|
|
65
|
+
required_energy(T, W, Required),
|
|
66
|
+
gt(Required, Battery).
|
|
67
|
+
|
|
68
|
+
safeInWorld(T, W) :- safe_in_world(T, W).
|
|
69
|
+
riskyInWorld(T, W) :- risky_in_world(T, W).
|
|
70
|
+
reason(winter_highway, "cold fast payload trip exceeds battery in physics-aware worlds") :-
|
|
71
|
+
risky_in_world(winter_highway, w0),
|
|
72
|
+
risky_in_world(winter_highway, w2),
|
|
73
|
+
risky_in_world(winter_highway, w3),
|
|
74
|
+
safe_in_world(winter_highway, w1).
|
|
75
|
+
reason(heavy_delivery, "safety buffer turns a physics-safe delivery into a cautious risk") :-
|
|
76
|
+
safe_in_world(heavy_delivery, w0),
|
|
77
|
+
risky_in_world(heavy_delivery, w3).
|
|
78
|
+
status(ev_range_worlds, expected_world_pattern) :-
|
|
79
|
+
safe_in_world(city_errand, w3),
|
|
80
|
+
risky_in_world(winter_highway, w0),
|
|
81
|
+
risky_in_world(heavy_delivery, w3),
|
|
82
|
+
safe_in_world(cold_commute, w3).
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
2
|
+
materialize(is, 2).
|
|
3
|
+
|
|
4
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
5
|
+
% Existential-rule example adapted from Eyeling existential-rule.n3.
|
|
6
|
+
% Eyeling creates blank-node witnesses. eyelang has Herbrand terms only, so the
|
|
7
|
+
% witness is represented explicitly by a deterministic Skolem-style term.
|
|
8
|
+
|
|
9
|
+
type(socrates, human).
|
|
10
|
+
type(plato, human).
|
|
11
|
+
|
|
12
|
+
witness(socrates, sk_0).
|
|
13
|
+
witness(plato, sk_1).
|
|
14
|
+
|
|
15
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
16
|
+
is(Person, Witness) :-
|
|
17
|
+
type(Person, human),
|
|
18
|
+
witness(Person, Witness).
|