eyeling 1.32.1 → 1.33.1
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/README.md +87 -16
- package/bin/eyeling.cjs +56 -4
- package/dist/browser/eyeling.browser.js +2 -11
- package/examples/eyelang/INTEGRATION.md +13 -0
- package/examples/eyelang/README.md +628 -0
- package/examples/eyelang/SPEC.md +684 -0
- package/examples/eyelang/access-control-policy.pl +52 -0
- package/examples/eyelang/ackermann.pl +46 -0
- package/examples/eyelang/age.pl +28 -0
- package/examples/eyelang/aliases-and-namespaces.pl +22 -0
- package/examples/eyelang/alignment-demo.pl +44 -0
- package/examples/eyelang/allen-interval-calculus.pl +64 -0
- package/examples/eyelang/ancestor.pl +21 -0
- package/examples/eyelang/animal.pl +21 -0
- package/examples/eyelang/annotation-rdf12.ttl +12 -0
- package/examples/eyelang/annotation.pl +34 -0
- package/examples/eyelang/auroracare.pl +309 -0
- package/examples/eyelang/backward.pl +12 -0
- package/examples/eyelang/basic-monadic.pl +10018 -0
- package/examples/eyelang/bayes-diagnosis.pl +108 -0
- package/examples/eyelang/bayes-therapy.pl +182 -0
- package/examples/eyelang/beam-deflection.pl +50 -0
- package/examples/eyelang/blocks-world-planning.pl +75 -0
- package/examples/eyelang/bmi.pl +232 -0
- package/examples/eyelang/braking-safety-worlds.pl +69 -0
- package/examples/eyelang/buck-converter-design.pl +78 -0
- package/examples/eyelang/cache-performance.pl +54 -0
- package/examples/eyelang/canary-release.pl +49 -0
- package/examples/eyelang/cat-koko.pl +24 -0
- package/examples/eyelang/clinical-trial-screening.pl +92 -0
- package/examples/eyelang/collatz-1000.pl +14 -0
- package/examples/eyelang/combinatorics-findall-sort.pl +37 -0
- package/examples/eyelang/competitive-enzyme-kinetics.pl +78 -0
- package/examples/eyelang/complex-matrix-stability.pl +45 -0
- package/examples/eyelang/complex.pl +121 -0
- package/examples/eyelang/composition-of-injective-functions-is-injective.pl +50 -0
- package/examples/eyelang/context-association.pl +53 -0
- package/examples/eyelang/control-system.pl +72 -0
- package/examples/eyelang/cryptarithmetic-send-more-money.pl +49 -0
- package/examples/eyelang/cyclic-path.pl +16 -0
- package/examples/eyelang/d3-group.pl +100 -0
- package/examples/eyelang/dairy-energy-balance.pl +65 -0
- package/examples/eyelang/data-negotiation.pl +39 -0
- package/examples/eyelang/deep-taxonomy-10.pl +115 -0
- package/examples/eyelang/deep-taxonomy-100.pl +385 -0
- package/examples/eyelang/deep-taxonomy-1000.pl +3085 -0
- package/examples/eyelang/deep-taxonomy-10000.pl +30094 -0
- package/examples/eyelang/deep-taxonomy-100000.pl +300184 -0
- package/examples/eyelang/delfour.pl +281 -0
- package/examples/eyelang/dense-hamiltonian-cycle.pl +92 -0
- package/examples/eyelang/deontic-logic.pl +52 -0
- package/examples/eyelang/derived-backward-rule.pl +30 -0
- package/examples/eyelang/derived-rule.pl +27 -0
- package/examples/eyelang/diamond-property.pl +38 -0
- package/examples/eyelang/dijkstra-findall-sort.pl +44 -0
- package/examples/eyelang/dijkstra-risk-path.pl +86 -0
- package/examples/eyelang/dijkstra.pl +46 -0
- package/examples/eyelang/dining-philosophers.pl +140 -0
- package/examples/eyelang/directional-language.ttl +9 -0
- package/examples/eyelang/dog.pl +25 -0
- package/examples/eyelang/drone-corridor-planner.pl +51 -0
- package/examples/eyelang/easter-computus.pl +89 -0
- package/examples/eyelang/electrical-rc-filter.pl +36 -0
- package/examples/eyelang/epidemic-policy.pl +67 -0
- package/examples/eyelang/equivalence-classes-overlap-implies-same-class.pl +27 -0
- package/examples/eyelang/eulerian-path.pl +85 -0
- package/examples/eyelang/ev-range-worlds.pl +82 -0
- package/examples/eyelang/exact-cover-sudoku.pl +113 -0
- package/examples/eyelang/existential-rule.pl +18 -0
- package/examples/eyelang/exoplanet-validation-worlds.pl +88 -0
- package/examples/eyelang/expression-eval.pl +43 -0
- package/examples/eyelang/eyeling-ackermann.n3 +41 -0
- package/examples/eyelang/eyeling-age-threshold.n3 +12 -0
- package/examples/eyelang/eyeling-alignment-demo.n3 +11 -0
- package/examples/eyelang/eyeling-allen-interval-calculus-small.n3 +13 -0
- package/examples/eyelang/eyeling-backward-recursion.n3 +11 -0
- package/examples/eyelang/eyeling-backward.n3 +10 -0
- package/examples/eyelang/eyeling-basic-monadic-small.n3 +11 -0
- package/examples/eyelang/eyeling-bmi.n3 +10 -0
- package/examples/eyelang/eyeling-cat-koko.n3 +15 -0
- package/examples/eyelang/eyeling-collatz-small.n3 +11 -0
- package/examples/eyelang/eyeling-collection.n3 +11 -0
- package/examples/eyelang/eyeling-complex-arithmetic.n3 +10 -0
- package/examples/eyelang/eyeling-context-association.n3 +11 -0
- package/examples/eyelang/eyeling-control-system-small.n3 +11 -0
- package/examples/eyelang/eyeling-crypto-builtins-extra.n3 +10 -0
- package/examples/eyelang/eyeling-crypto-builtins.n3 +8 -0
- package/examples/eyelang/eyeling-deep-taxonomy-10.n3 +18 -0
- package/examples/eyelang/eyeling-derived-backward-rule-flat.n3 +10 -0
- package/examples/eyelang/eyeling-derived-rule-flat.n3 +9 -0
- package/examples/eyelang/eyeling-digital-product-passport-small.n3 +11 -0
- package/examples/eyelang/eyeling-dijkstra-tiny.n3 +14 -0
- package/examples/eyelang/eyeling-dog-license.n3 +13 -0
- package/examples/eyelang/eyeling-drone-corridor-planner-small.n3 +13 -0
- package/examples/eyelang/eyeling-equals.n3 +8 -0
- package/examples/eyelang/eyeling-equivalence-classes.n3 +11 -0
- package/examples/eyelang/eyeling-euler-identity.n3 +9 -0
- package/examples/eyelang/eyeling-existential-rule.n3 +9 -0
- package/examples/eyelang/eyeling-expression-eval.n3 +11 -0
- package/examples/eyelang/eyeling-family-cousins-extended.n3 +12 -0
- package/examples/eyelang/eyeling-fastpow.n3 +10 -0
- package/examples/eyelang/eyeling-fibonacci.n3 +44 -0
- package/examples/eyelang/eyeling-french-cities-reachability.n3 +22 -0
- package/examples/eyelang/eyeling-goldbach-small.n3 +22 -0
- package/examples/eyelang/eyeling-good-cobbler.n3 +9 -0
- package/examples/eyelang/eyeling-list-builtins.n3 +10 -0
- package/examples/eyelang/eyeling-list-collection-extra.n3 +9 -0
- package/examples/eyelang/eyeling-math-builtins.n3 +9 -0
- package/examples/eyelang/eyeling-string-builtins-extra.n3 +9 -0
- package/examples/eyelang/eyeling-string-builtins.n3 +10 -0
- package/examples/eyelang/eyeling-time-builtins.n3 +11 -0
- package/examples/eyelang/eyeling-time-components-extra.n3 +10 -0
- package/examples/eyelang/eyeling-witch.n3 +10 -0
- package/examples/eyelang/family-cousins.n3 +17 -0
- package/examples/eyelang/family-cousins.pl +65 -0
- package/examples/eyelang/fastpow.pl +53 -0
- package/examples/eyelang/fft8-numeric.pl +83 -0
- package/examples/eyelang/fibonacci.pl +53 -0
- package/examples/eyelang/field-nitrogen-balance.pl +70 -0
- package/examples/eyelang/flandor.pl +296 -0
- package/examples/eyelang/floating-point.pl +23 -0
- package/examples/eyelang/four-color-map.pl +127 -0
- package/examples/eyelang/fundamental-theorem-arithmetic.pl +113 -0
- package/examples/eyelang/gcd-bezout-identity.pl +48 -0
- package/examples/eyelang/gd-step-certified.pl +158 -0
- package/examples/eyelang/gdpr-compliance.pl +69 -0
- package/examples/eyelang/goldbach-1000.pl +185 -0
- package/examples/eyelang/good-cobbler.pl +14 -0
- package/examples/eyelang/gps.pl +152 -0
- package/examples/eyelang/graph-reachability.pl +36 -0
- package/examples/eyelang/gray-code-counter.pl +48 -0
- package/examples/eyelang/greatest-lower-bound-uniqueness.pl +28 -0
- package/examples/eyelang/group-inverse-uniqueness.pl +34 -0
- package/examples/eyelang/hamiltonian-cycle.pl +55 -0
- package/examples/eyelang/hamiltonian-path.pl +49 -0
- package/examples/eyelang/hamming-code.pl +105 -0
- package/examples/eyelang/hanoi.pl +20 -0
- package/examples/eyelang/heat-loss.pl +51 -0
- package/examples/eyelang/heron-theorem.pl +36 -0
- package/examples/eyelang/ideal-gas-law.pl +37 -0
- package/examples/eyelang/illegitimate-reasoning.pl +88 -0
- package/examples/eyelang/kaprekar.pl +32 -0
- package/examples/eyelang/law-of-cosines.pl +31 -0
- package/examples/eyelang/least-squares-regression.pl +81 -0
- package/examples/eyelang/list-collection.pl +33 -0
- package/examples/eyelang/lldm.pl +78 -0
- package/examples/eyelang/manufacturing-quality-control.pl +73 -0
- package/examples/eyelang/matrix.pl +296 -0
- package/examples/eyelang/microgrid-dispatch.pl +85 -0
- package/examples/eyelang/monkey-bananas.pl +45 -0
- package/examples/eyelang/n-queens.pl +23 -0
- package/examples/eyelang/n3-builtins.n3 +28 -0
- package/examples/eyelang/network-sla.pl +48 -0
- package/examples/eyelang/newton-raphson.pl +49 -0
- package/examples/eyelang/nixon-diamond.pl +37 -0
- package/examples/eyelang/odrl-dpv-healthcare-risk-ranked.pl +266 -0
- package/examples/eyelang/odrl-dpv-risk-ranked.pl +320 -0
- package/examples/eyelang/orbital-transfer-design.pl +113 -0
- package/examples/eyelang/output/access-control-policy.pl +2 -0
- package/examples/eyelang/output/ackermann.pl +12 -0
- package/examples/eyelang/output/age.pl +2 -0
- package/examples/eyelang/output/aliases-and-namespaces.pl +5 -0
- package/examples/eyelang/output/alignment-demo.pl +32 -0
- package/examples/eyelang/output/allen-interval-calculus.pl +154 -0
- package/examples/eyelang/output/ancestor.pl +6 -0
- package/examples/eyelang/output/animal.pl +4 -0
- package/examples/eyelang/output/annotation-rdf12.ttl +1 -0
- package/examples/eyelang/output/annotation.pl +4 -0
- package/examples/eyelang/output/auroracare.pl +117 -0
- package/examples/eyelang/output/backward.pl +1 -0
- package/examples/eyelang/output/basic-monadic.pl +1518 -0
- package/examples/eyelang/output/bayes-diagnosis.pl +13 -0
- package/examples/eyelang/output/bayes-therapy.pl +23 -0
- package/examples/eyelang/output/beam-deflection.pl +5 -0
- package/examples/eyelang/output/blocks-world-planning.pl +4 -0
- package/examples/eyelang/output/bmi.pl +32 -0
- package/examples/eyelang/output/braking-safety-worlds.pl +18 -0
- package/examples/eyelang/output/buck-converter-design.pl +6 -0
- package/examples/eyelang/output/cache-performance.pl +4 -0
- package/examples/eyelang/output/canary-release.pl +5 -0
- package/examples/eyelang/output/cat-koko.pl +3 -0
- package/examples/eyelang/output/clinical-trial-screening.pl +9 -0
- package/examples/eyelang/output/collatz-1000.pl +1000 -0
- package/examples/eyelang/output/combinatorics-findall-sort.pl +2 -0
- package/examples/eyelang/output/competitive-enzyme-kinetics.pl +6 -0
- package/examples/eyelang/output/complex-matrix-stability.pl +5 -0
- package/examples/eyelang/output/complex.pl +1 -0
- package/examples/eyelang/output/composition-of-injective-functions-is-injective.pl +2 -0
- package/examples/eyelang/output/context-association.pl +3 -0
- package/examples/eyelang/output/control-system.pl +6 -0
- package/examples/eyelang/output/cryptarithmetic-send-more-money.pl +6 -0
- package/examples/eyelang/output/cyclic-path.pl +16 -0
- package/examples/eyelang/output/d3-group.pl +2 -0
- package/examples/eyelang/output/dairy-energy-balance.pl +13 -0
- package/examples/eyelang/output/data-negotiation.pl +1 -0
- package/examples/eyelang/output/deep-taxonomy-10.pl +16 -0
- package/examples/eyelang/output/deep-taxonomy-100.pl +16 -0
- package/examples/eyelang/output/deep-taxonomy-1000.pl +16 -0
- package/examples/eyelang/output/deep-taxonomy-10000.pl +16 -0
- package/examples/eyelang/output/deep-taxonomy-100000.pl +16 -0
- package/examples/eyelang/output/delfour.pl +31 -0
- package/examples/eyelang/output/dense-hamiltonian-cycle.pl +4 -0
- package/examples/eyelang/output/deontic-logic.pl +4 -0
- package/examples/eyelang/output/derived-backward-rule.pl +3 -0
- package/examples/eyelang/output/derived-rule.pl +2 -0
- package/examples/eyelang/output/diamond-property.pl +4 -0
- package/examples/eyelang/output/dijkstra-findall-sort.pl +2 -0
- package/examples/eyelang/output/dijkstra-risk-path.pl +29 -0
- package/examples/eyelang/output/dijkstra.pl +16 -0
- package/examples/eyelang/output/dining-philosophers.pl +350 -0
- package/examples/eyelang/output/directional-language.ttl +1 -0
- package/examples/eyelang/output/dog.pl +1 -0
- package/examples/eyelang/output/drone-corridor-planner.pl +17 -0
- package/examples/eyelang/output/easter-computus.pl +30 -0
- package/examples/eyelang/output/electrical-rc-filter.pl +3 -0
- package/examples/eyelang/output/epidemic-policy.pl +14 -0
- package/examples/eyelang/output/equivalence-classes-overlap-implies-same-class.pl +18 -0
- package/examples/eyelang/output/eulerian-path.pl +3 -0
- package/examples/eyelang/output/ev-range-worlds.pl +19 -0
- package/examples/eyelang/output/exact-cover-sudoku.pl +3 -0
- package/examples/eyelang/output/existential-rule.pl +2 -0
- package/examples/eyelang/output/exoplanet-validation-worlds.pl +22 -0
- package/examples/eyelang/output/expression-eval.pl +1 -0
- package/examples/eyelang/output/eyeling-ackermann.n3 +12 -0
- package/examples/eyelang/output/eyeling-age-threshold.n3 +4 -0
- package/examples/eyelang/output/eyeling-alignment-demo.n3 +1 -0
- package/examples/eyelang/output/eyeling-allen-interval-calculus-small.n3 +3 -0
- package/examples/eyelang/output/eyeling-backward-recursion.n3 +9 -0
- package/examples/eyelang/output/eyeling-backward.n3 +1 -0
- package/examples/eyelang/output/eyeling-basic-monadic-small.n3 +8 -0
- package/examples/eyelang/output/eyeling-bmi.n3 +2 -0
- package/examples/eyelang/output/eyeling-cat-koko.n3 +3 -0
- package/examples/eyelang/output/eyeling-collatz-small.n3 +3 -0
- package/examples/eyelang/output/eyeling-collection.n3 +1 -0
- package/examples/eyelang/output/eyeling-complex-arithmetic.n3 +5 -0
- package/examples/eyelang/output/eyeling-context-association.n3 +4 -0
- package/examples/eyelang/output/eyeling-control-system-small.n3 +4 -0
- package/examples/eyelang/output/eyeling-crypto-builtins-extra.n3 +3 -0
- package/examples/eyelang/output/eyeling-crypto-builtins.n3 +2 -0
- package/examples/eyelang/output/eyeling-deep-taxonomy-10.n3 +32 -0
- package/examples/eyelang/output/eyeling-derived-backward-rule-flat.n3 +4 -0
- package/examples/eyelang/output/eyeling-derived-rule-flat.n3 +2 -0
- package/examples/eyelang/output/eyeling-digital-product-passport-small.n3 +3 -0
- package/examples/eyelang/output/eyeling-dijkstra-tiny.n3 +9 -0
- package/examples/eyelang/output/eyeling-dog-license.n3 +1 -0
- package/examples/eyelang/output/eyeling-drone-corridor-planner-small.n3 +5 -0
- package/examples/eyelang/output/eyeling-equals.n3 +1 -0
- package/examples/eyelang/output/eyeling-equivalence-classes.n3 +2 -0
- package/examples/eyelang/output/eyeling-euler-identity.n3 +3 -0
- package/examples/eyelang/output/eyeling-existential-rule.n3 +4 -0
- package/examples/eyelang/output/eyeling-expression-eval.n3 +3 -0
- package/examples/eyelang/output/eyeling-family-cousins-extended.n3 +6 -0
- package/examples/eyelang/output/eyeling-fastpow.n3 +4 -0
- package/examples/eyelang/output/eyeling-fibonacci.n3 +6 -0
- package/examples/eyelang/output/eyeling-french-cities-reachability.n3 +25 -0
- package/examples/eyelang/output/eyeling-goldbach-small.n3 +2 -0
- package/examples/eyelang/output/eyeling-good-cobbler.n3 +2 -0
- package/examples/eyelang/output/eyeling-list-builtins.n3 +6 -0
- package/examples/eyelang/output/eyeling-list-collection-extra.n3 +5 -0
- package/examples/eyelang/output/eyeling-math-builtins.n3 +5 -0
- package/examples/eyelang/output/eyeling-string-builtins-extra.n3 +3 -0
- package/examples/eyelang/output/eyeling-string-builtins.n3 +4 -0
- package/examples/eyelang/output/eyeling-time-builtins.n3 +4 -0
- package/examples/eyelang/output/eyeling-time-components-extra.n3 +5 -0
- package/examples/eyelang/output/eyeling-witch.n3 +2 -0
- package/examples/eyelang/output/family-cousins.n3 +8 -0
- package/examples/eyelang/output/family-cousins.pl +28 -0
- package/examples/eyelang/output/fastpow.pl +6 -0
- package/examples/eyelang/output/fft8-numeric.pl +4 -0
- package/examples/eyelang/output/fibonacci.pl +6 -0
- package/examples/eyelang/output/field-nitrogen-balance.pl +21 -0
- package/examples/eyelang/output/flandor.pl +43 -0
- package/examples/eyelang/output/floating-point.pl +9 -0
- package/examples/eyelang/output/four-color-map.pl +3 -0
- package/examples/eyelang/output/fundamental-theorem-arithmetic.pl +9 -0
- package/examples/eyelang/output/gcd-bezout-identity.pl +36 -0
- package/examples/eyelang/output/gd-step-certified.pl +79 -0
- package/examples/eyelang/output/gdpr-compliance.pl +6 -0
- package/examples/eyelang/output/goldbach-1000.pl +667 -0
- package/examples/eyelang/output/good-cobbler.pl +1 -0
- package/examples/eyelang/output/gps.pl +21 -0
- package/examples/eyelang/output/graph-reachability.pl +3 -0
- package/examples/eyelang/output/gray-code-counter.pl +1 -0
- package/examples/eyelang/output/greatest-lower-bound-uniqueness.pl +2 -0
- package/examples/eyelang/output/group-inverse-uniqueness.pl +2 -0
- package/examples/eyelang/output/hamiltonian-cycle.pl +4 -0
- package/examples/eyelang/output/hamiltonian-path.pl +121 -0
- package/examples/eyelang/output/hamming-code.pl +6 -0
- package/examples/eyelang/output/hanoi.pl +1 -0
- package/examples/eyelang/output/heat-loss.pl +5 -0
- package/examples/eyelang/output/heron-theorem.pl +4 -0
- package/examples/eyelang/output/ideal-gas-law.pl +3 -0
- package/examples/eyelang/output/illegitimate-reasoning.pl +15 -0
- package/examples/eyelang/output/kaprekar.pl +8 -0
- package/examples/eyelang/output/law-of-cosines.pl +3 -0
- package/examples/eyelang/output/least-squares-regression.pl +5 -0
- package/examples/eyelang/output/list-collection.pl +3 -0
- package/examples/eyelang/output/lldm.pl +6 -0
- package/examples/eyelang/output/manufacturing-quality-control.pl +6 -0
- package/examples/eyelang/output/matrix.pl +10 -0
- package/examples/eyelang/output/microgrid-dispatch.pl +6 -0
- package/examples/eyelang/output/monkey-bananas.pl +5 -0
- package/examples/eyelang/output/n-queens.pl +93 -0
- package/examples/eyelang/output/n3-builtins.n3 +6 -0
- package/examples/eyelang/output/network-sla.pl +4 -0
- package/examples/eyelang/output/newton-raphson.pl +3 -0
- package/examples/eyelang/output/nixon-diamond.pl +5 -0
- package/examples/eyelang/output/odrl-dpv-healthcare-risk-ranked.pl +42 -0
- package/examples/eyelang/output/odrl-dpv-risk-ranked.pl +120 -0
- package/examples/eyelang/output/orbital-transfer-design.pl +7 -0
- package/examples/eyelang/output/path-discovery.pl +3 -0
- package/examples/eyelang/output/peano-arithmetic.pl +3 -0
- package/examples/eyelang/output/peasant.pl +10 -0
- package/examples/eyelang/output/pendulum-period.pl +4 -0
- package/examples/eyelang/output/polynomial.pl +14 -0
- package/examples/eyelang/output/project-portfolio-optimization.pl +6 -0
- package/examples/eyelang/output/proof-contrapositive.pl +3 -0
- package/examples/eyelang/output/quadratic-formula.pl +6 -0
- package/examples/eyelang/output/quine-mccluskey.pl +3 -0
- package/examples/eyelang/output/radioactive-decay.pl +5 -0
- package/examples/eyelang/output/resilient-city-orchestration.pl +67 -0
- package/examples/eyelang/output/riemann-hypothesis.pl +12 -0
- package/examples/eyelang/output/sat-dpll.pl +5 -0
- package/examples/eyelang/output/security-incident-correlation.pl +3 -0
- package/examples/eyelang/output/service-impact.pl +11 -0
- package/examples/eyelang/output/sieve.pl +1 -0
- package/examples/eyelang/output/skolem-functions.pl +16 -0
- package/examples/eyelang/output/socket-age.pl +1 -0
- package/examples/eyelang/output/socket-family.pl +3 -0
- package/examples/eyelang/output/socrates.n3 +1 -0
- package/examples/eyelang/output/socrates.pl +2 -0
- package/examples/eyelang/output/statistics-summary.pl +4 -0
- package/examples/eyelang/output/sudoku.pl +2 -0
- package/examples/eyelang/output/superdense-coding.pl +6 -0
- package/examples/eyelang/output/traveling-salesman.pl +1 -0
- package/examples/eyelang/output/triple-term.n3 +2 -0
- package/examples/eyelang/output/turing.pl +12 -0
- package/examples/eyelang/output/vector-similarity.pl +4 -0
- package/examples/eyelang/output/witch.pl +7 -0
- package/examples/eyelang/output/wolf-goat-cabbage.pl +3 -0
- package/examples/eyelang/output/zebra.pl +3 -0
- package/examples/eyelang/path-discovery.pl +44998 -0
- package/examples/eyelang/peano-arithmetic.pl +31 -0
- package/examples/eyelang/peasant.pl +30 -0
- package/examples/eyelang/pendulum-period.pl +50 -0
- package/examples/eyelang/polynomial.pl +124 -0
- package/examples/eyelang/project-portfolio-optimization.pl +101 -0
- package/examples/eyelang/proof/age.pl +71 -0
- package/examples/eyelang/proof/aliases-and-namespaces.pl +78 -0
- package/examples/eyelang/proof/ancestor.pl +140 -0
- package/examples/eyelang/proof/animal.pl +68 -0
- package/examples/eyelang/proof/annotation.pl +80 -0
- package/examples/eyelang/proof/backward.pl +22 -0
- package/examples/eyelang/proof/cat-koko.pl +86 -0
- package/examples/eyelang/proof/data-negotiation.pl +76 -0
- package/examples/eyelang/proof/derived-rule.pl +43 -0
- package/examples/eyelang/proof/dog.pl +31 -0
- package/examples/eyelang/proof/electrical-rc-filter.pl +105 -0
- package/examples/eyelang/proof/existential-rule.pl +40 -0
- package/examples/eyelang/proof/floating-point.pl +160 -0
- package/examples/eyelang/proof/good-cobbler.pl +16 -0
- package/examples/eyelang/proof/group-inverse-uniqueness.pl +84 -0
- package/examples/eyelang/proof/list-collection.pl +52 -0
- package/examples/eyelang/proof/proof-contrapositive.pl +78 -0
- package/examples/eyelang/proof/socket-age.pl +32 -0
- package/examples/eyelang/proof/socket-family.pl +59 -0
- package/examples/eyelang/proof/socrates.pl +38 -0
- package/examples/eyelang/proof-contrapositive.pl +27 -0
- package/examples/eyelang/quadratic-formula.pl +54 -0
- package/examples/eyelang/quine-mccluskey.pl +143 -0
- package/examples/eyelang/radioactive-decay.pl +56 -0
- package/examples/eyelang/resilient-city-orchestration.pl +303 -0
- package/examples/eyelang/riemann-hypothesis.pl +110 -0
- package/examples/eyelang/sat-dpll.pl +80 -0
- package/examples/eyelang/security-incident-correlation.pl +69 -0
- package/examples/eyelang/service-impact.pl +41 -0
- package/examples/eyelang/sieve.pl +20 -0
- package/examples/eyelang/skolem-functions.pl +52 -0
- package/examples/eyelang/socket-age.pl +39 -0
- package/examples/eyelang/socket-family.pl +28 -0
- package/examples/eyelang/socrates.n3 +11 -0
- package/examples/eyelang/socrates.pl +19 -0
- package/examples/eyelang/statistics-summary.pl +54 -0
- package/examples/eyelang/sudoku.pl +20 -0
- package/examples/eyelang/superdense-coding.pl +84 -0
- package/examples/eyelang/traveling-salesman.pl +64 -0
- package/examples/eyelang/triple-term.n3 +9 -0
- package/examples/eyelang/turing.pl +67 -0
- package/examples/eyelang/vector-similarity.pl +56 -0
- package/examples/eyelang/witch.pl +38 -0
- package/examples/eyelang/wolf-goat-cabbage.pl +56 -0
- package/examples/eyelang/zebra.pl +44 -0
- package/eyelang.d.ts +92 -0
- package/eyeling-builtins.ttl +1 -1
- package/eyeling.js +2 -11
- package/index.d.ts +50 -2
- package/index.js +95 -1
- package/lib/builtins.js +1 -11
- package/lib/cli.js +1 -0
- package/lib/eyelang/bin.js +7 -0
- package/lib/eyelang/builtins/aggregation.mjs +81 -0
- package/lib/eyelang/builtins/alphametic.mjs +144 -0
- package/lib/eyelang/builtins/arithmetic.mjs +197 -0
- package/lib/eyelang/builtins/control.mjs +22 -0
- package/lib/eyelang/builtins/core.mjs +78 -0
- package/lib/eyelang/builtins/formula.mjs +42 -0
- package/lib/eyelang/builtins/lists.mjs +149 -0
- package/lib/eyelang/builtins/matrix.mjs +226 -0
- package/lib/eyelang/builtins/n3.mjs +483 -0
- package/lib/eyelang/builtins/number-theory.mjs +114 -0
- package/lib/eyelang/builtins/portfolio.mjs +73 -0
- package/lib/eyelang/builtins/registry.mjs +54 -0
- package/lib/eyelang/builtins/search.mjs +579 -0
- package/lib/eyelang/builtins/strings.mjs +41 -0
- package/lib/eyelang/builtins/sudoku.mjs +141 -0
- package/lib/eyelang/cli.mjs +192 -0
- package/lib/eyelang/explain.mjs +324 -0
- package/lib/eyelang/hash.mjs +294 -0
- package/lib/eyelang/index.mjs +48 -0
- package/lib/eyelang/parser.mjs +428 -0
- package/lib/eyelang/program.mjs +244 -0
- package/lib/eyelang/rdf.mjs +747 -0
- package/lib/eyelang/solver.mjs +237 -0
- package/lib/eyelang/term.mjs +328 -0
- package/package.json +12 -3
- package/test/builtins.test.js +15 -2
- package/test/eyelang/conformance/README.md +45 -0
- package/test/eyelang/conformance/cases/core/001_fact_output.pl +4 -0
- package/test/eyelang/conformance/cases/core/001_fact_query.query +1 -0
- package/test/eyelang/conformance/cases/core/002_rule_recursion.pl +7 -0
- package/test/eyelang/conformance/cases/core/002_rule_recursion.query +1 -0
- package/test/eyelang/conformance/cases/core/003_terms_and_readback.pl +16 -0
- package/test/eyelang/conformance/cases/core/003_terms_and_readback.query +1 -0
- package/test/eyelang/conformance/cases/core/004_conjunction_and_parentheses.pl +5 -0
- package/test/eyelang/conformance/cases/core/004_conjunction_and_parentheses.query +1 -0
- package/test/eyelang/conformance/cases/core/005_list_deconstruction.pl +6 -0
- package/test/eyelang/conformance/cases/core/005_list_deconstruction.query +1 -0
- package/test/eyelang/conformance/cases/core/006_comma_formula_data.pl +4 -0
- package/test/eyelang/conformance/cases/core/006_comma_formula_data.query +1 -0
- package/test/eyelang/conformance/cases/core/007_anonymous_variables.pl +5 -0
- package/test/eyelang/conformance/cases/core/007_anonymous_variables.query +1 -0
- package/test/eyelang/conformance/cases/core/008_graphic_atoms.pl +6 -0
- package/test/eyelang/conformance/cases/core/008_graphic_atoms.query +1 -0
- package/test/eyelang/conformance/cases/core/009_comments_and_whitespace.pl +5 -0
- package/test/eyelang/conformance/cases/core/009_comments_and_whitespace.query +1 -0
- package/test/eyelang/conformance/cases/core/010_variable_scope_and_reuse.pl +8 -0
- package/test/eyelang/conformance/cases/core/010_variable_scope_and_reuse.query +1 -0
- package/test/eyelang/conformance/cases/core/011_predicate_arity.pl +6 -0
- package/test/eyelang/conformance/cases/core/011_predicate_arity.query +1 -0
- package/test/eyelang/conformance/cases/core/012_nested_compound_unification.pl +5 -0
- package/test/eyelang/conformance/cases/core/012_nested_compound_unification.query +1 -0
- package/test/eyelang/conformance/cases/core/013_multiple_clauses_order.pl +6 -0
- package/test/eyelang/conformance/cases/core/013_multiple_clauses_order.query +1 -0
- package/test/eyelang/conformance/cases/core/014_failure_filters_answers.pl +7 -0
- package/test/eyelang/conformance/cases/core/014_failure_filters_answers.query +1 -0
- package/test/eyelang/conformance/cases/core/015_improper_list_unification.pl +6 -0
- package/test/eyelang/conformance/cases/core/015_improper_list_unification.query +1 -0
- package/test/eyelang/conformance/cases/core/016_zero_arity_compound.pl +4 -0
- package/test/eyelang/conformance/cases/core/016_zero_arity_compound.query +1 -0
- package/test/eyelang/conformance/cases/core/017_three_step_recursion.pl +8 -0
- package/test/eyelang/conformance/cases/core/017_three_step_recursion.query +1 -0
- package/test/eyelang/conformance/cases/core/018_quoted_atom_readback.pl +6 -0
- package/test/eyelang/conformance/cases/core/018_quoted_atom_readback.query +1 -0
- package/test/eyelang/conformance/cases/core/019_parenthesized_three_conjuncts.pl +7 -0
- package/test/eyelang/conformance/cases/core/019_parenthesized_three_conjuncts.query +1 -0
- package/test/eyelang/conformance/cases/core/020_nested_list_terms.pl +5 -0
- package/test/eyelang/conformance/cases/core/020_nested_list_terms.query +1 -0
- package/test/eyelang/conformance/cases/core/021_repeated_variable_head.pl +7 -0
- package/test/eyelang/conformance/cases/core/022_rule_head_structure.pl +5 -0
- package/test/eyelang/conformance/cases/core/023_quoted_escapes_readback.pl +5 -0
- package/test/eyelang/conformance/cases/core/024_numeric_literal_readback.pl +6 -0
- package/test/eyelang/conformance/cases/core/025_body_parentheses_with_formula_data.pl +5 -0
- package/test/eyelang/conformance/cases/core/026_underscore_named_variable_reuse.pl +5 -0
- package/test/eyelang/conformance/cases/extension/001_default_derived_output.pl +5 -0
- package/test/eyelang/conformance/cases/extension/002_materialize_focus.pl +5 -0
- package/test/eyelang/conformance/cases/extension/003_arithmetic_and_comparison.pl +12 -0
- package/test/eyelang/conformance/cases/extension/003_arithmetic_and_comparison.query +1 -0
- package/test/eyelang/conformance/cases/extension/004_strings_and_atoms.pl +6 -0
- package/test/eyelang/conformance/cases/extension/004_strings_and_atoms.query +1 -0
- package/test/eyelang/conformance/cases/extension/005_lists_aggregation_ordering.pl +10 -0
- package/test/eyelang/conformance/cases/extension/005_lists_aggregation_ordering.query +1 -0
- package/test/eyelang/conformance/cases/extension/006_formula_terms.pl +5 -0
- package/test/eyelang/conformance/cases/extension/006_formula_terms.query +1 -0
- package/test/eyelang/conformance/cases/extension/007_negation_once_generators.pl +7 -0
- package/test/eyelang/conformance/cases/extension/007_negation_once_generators.query +1 -0
- package/test/eyelang/conformance/cases/extension/008_equality_and_inequality.pl +6 -0
- package/test/eyelang/conformance/cases/extension/008_equality_and_inequality.query +1 -0
- package/test/eyelang/conformance/cases/extension/009_list_relations.pl +6 -0
- package/test/eyelang/conformance/cases/extension/009_list_relations.query +1 -0
- package/test/eyelang/conformance/cases/extension/010_append_splits.pl +3 -0
- package/test/eyelang/conformance/cases/extension/010_append_splits.query +1 -0
- package/test/eyelang/conformance/cases/extension/011_matching_and_comparison.pl +7 -0
- package/test/eyelang/conformance/cases/extension/011_matching_and_comparison.query +1 -0
- package/test/eyelang/conformance/cases/extension/012_memoize_declaration.pl +8 -0
- package/test/eyelang/conformance/cases/extension/012_memoize_declaration.query +1 -0
- package/test/eyelang/conformance/cases/extension/013_numeric_functions.pl +9 -0
- package/test/eyelang/conformance/cases/extension/013_numeric_functions.query +1 -0
- package/test/eyelang/conformance/cases/extension/014_between_enumeration.pl +3 -0
- package/test/eyelang/conformance/cases/extension/014_between_enumeration.query +1 -0
- package/test/eyelang/conformance/cases/extension/015_smallest_divisor.pl +3 -0
- package/test/eyelang/conformance/cases/extension/015_smallest_divisor.query +1 -0
- package/test/eyelang/conformance/cases/extension/016_negation_filter.pl +7 -0
- package/test/eyelang/conformance/cases/extension/016_negation_filter.query +1 -0
- package/test/eyelang/conformance/cases/extension/017_once_user_predicate.pl +5 -0
- package/test/eyelang/conformance/cases/extension/017_once_user_predicate.query +1 -0
- package/test/eyelang/conformance/cases/extension/018_findall_user_goal.pl +6 -0
- package/test/eyelang/conformance/cases/extension/018_findall_user_goal.query +1 -0
- package/test/eyelang/conformance/cases/extension/019_sort_deduplicates_atoms.pl +3 -0
- package/test/eyelang/conformance/cases/extension/019_sort_deduplicates_atoms.query +1 -0
- package/test/eyelang/conformance/cases/extension/020_append_bound_prefix_suffix.pl +4 -0
- package/test/eyelang/conformance/cases/extension/020_append_bound_prefix_suffix.query +1 -0
- package/test/eyelang/conformance/cases/extension/021_nth0_index_generation.pl +3 -0
- package/test/eyelang/conformance/cases/extension/021_nth0_index_generation.query +1 -0
- package/test/eyelang/conformance/cases/extension/022_set_nth0_edges.pl +4 -0
- package/test/eyelang/conformance/cases/extension/022_set_nth0_edges.query +1 -0
- package/test/eyelang/conformance/cases/extension/023_select_duplicate_occurrences.pl +3 -0
- package/test/eyelang/conformance/cases/extension/023_select_duplicate_occurrences.query +1 -0
- package/test/eyelang/conformance/cases/extension/024_not_member_filter.pl +6 -0
- package/test/eyelang/conformance/cases/extension/024_not_member_filter.query +1 -0
- package/test/eyelang/conformance/cases/extension/025_is_list_filter.pl +5 -0
- package/test/eyelang/conformance/cases/extension/025_is_list_filter.query +1 -0
- package/test/eyelang/conformance/cases/extension/026_nested_formula_terms.pl +5 -0
- package/test/eyelang/conformance/cases/extension/026_nested_formula_terms.query +1 -0
- package/test/eyelang/conformance/cases/extension/027_materialize_excludes_source_fact.pl +6 -0
- package/test/eyelang/conformance/cases/extension/028_numeric_and_lexical_comparison.pl +5 -0
- package/test/eyelang/conformance/cases/extension/028_numeric_and_lexical_comparison.query +1 -0
- package/test/eyelang/conformance/cases/extension/029_string_matching_filters.pl +6 -0
- package/test/eyelang/conformance/cases/extension/029_string_matching_filters.query +1 -0
- package/test/eyelang/conformance/cases/extension/030_string_and_atom_concat.pl +4 -0
- package/test/eyelang/conformance/cases/extension/030_string_and_atom_concat.query +1 -0
- package/test/eyelang/conformance/cases/extension/031_countall_empty_and_nonempty.pl +4 -0
- package/test/eyelang/conformance/cases/extension/031_countall_empty_and_nonempty.query +1 -0
- package/test/eyelang/conformance/cases/extension/032_sumall_numeric_template.pl +5 -0
- package/test/eyelang/conformance/cases/extension/032_sumall_numeric_template.query +1 -0
- package/test/eyelang/conformance/cases/extension/033_aggregate_min_template.pl +5 -0
- package/test/eyelang/conformance/cases/extension/033_aggregate_min_template.query +1 -0
- package/test/eyelang/conformance/cases/extension/034_aggregate_max_compound_key.pl +5 -0
- package/test/eyelang/conformance/cases/extension/034_aggregate_max_compound_key.query +1 -0
- package/test/eyelang/conformance/cases/extension/035_date_difference.pl +4 -0
- package/test/eyelang/conformance/cases/extension/036_extended_gcd.pl +3 -0
- package/test/eyelang/conformance/cases/extension/037_collatz_trajectory.pl +3 -0
- package/test/eyelang/conformance/cases/extension/038_kaprekar_steps.pl +3 -0
- package/test/eyelang/conformance/cases/extension/039_goldbach_pair.pl +3 -0
- package/test/eyelang/conformance/cases/extension/040_matrix_operations.pl +5 -0
- package/test/eyelang/conformance/cases/extension/041_atom_range_generators.pl +5 -0
- package/test/eyelang/conformance/cases/extension/042_n_queens_small.pl +3 -0
- package/test/eyelang/conformance/cases/extension/043_cnf_model.pl +3 -0
- package/test/eyelang/conformance/cases/extension/044_cover9_filter.pl +6 -0
- package/test/eyelang/conformance/cases/extension/045_alphametic_sum_small.pl +3 -0
- package/test/eyelang/conformance/cases/extension/046_bounded_subset.pl +4 -0
- package/test/eyelang/conformance/expected/core/001_fact_output.out +1 -0
- package/test/eyelang/conformance/expected/core/002_rule_recursion.out +2 -0
- package/test/eyelang/conformance/expected/core/003_terms_and_readback.out +13 -0
- package/test/eyelang/conformance/expected/core/004_conjunction_and_parentheses.out +1 -0
- package/test/eyelang/conformance/expected/core/005_list_deconstruction.out +2 -0
- package/test/eyelang/conformance/expected/core/006_comma_formula_data.out +1 -0
- package/test/eyelang/conformance/expected/core/007_anonymous_variables.out +1 -0
- package/test/eyelang/conformance/expected/core/008_graphic_atoms.out +3 -0
- package/test/eyelang/conformance/expected/core/009_comments_and_whitespace.out +2 -0
- package/test/eyelang/conformance/expected/core/010_variable_scope_and_reuse.out +2 -0
- package/test/eyelang/conformance/expected/core/011_predicate_arity.out +2 -0
- package/test/eyelang/conformance/expected/core/012_nested_compound_unification.out +2 -0
- package/test/eyelang/conformance/expected/core/013_multiple_clauses_order.out +2 -0
- package/test/eyelang/conformance/expected/core/014_failure_filters_answers.out +1 -0
- package/test/eyelang/conformance/expected/core/015_improper_list_unification.out +3 -0
- package/test/eyelang/conformance/expected/core/016_zero_arity_compound.out +1 -0
- package/test/eyelang/conformance/expected/core/017_three_step_recursion.out +3 -0
- package/test/eyelang/conformance/expected/core/018_quoted_atom_readback.out +3 -0
- package/test/eyelang/conformance/expected/core/019_parenthesized_three_conjuncts.out +1 -0
- package/test/eyelang/conformance/expected/core/020_nested_list_terms.out +2 -0
- package/test/eyelang/conformance/expected/core/021_repeated_variable_head.out +2 -0
- package/test/eyelang/conformance/expected/core/022_rule_head_structure.out +2 -0
- package/test/eyelang/conformance/expected/core/023_quoted_escapes_readback.out +2 -0
- package/test/eyelang/conformance/expected/core/024_numeric_literal_readback.out +3 -0
- package/test/eyelang/conformance/expected/core/025_body_parentheses_with_formula_data.out +1 -0
- package/test/eyelang/conformance/expected/core/026_underscore_named_variable_reuse.out +1 -0
- package/test/eyelang/conformance/expected/extension/001_default_derived_output.out +3 -0
- package/test/eyelang/conformance/expected/extension/002_materialize_focus.out +1 -0
- package/test/eyelang/conformance/expected/extension/003_arithmetic_and_comparison.out +10 -0
- package/test/eyelang/conformance/expected/extension/004_strings_and_atoms.out +4 -0
- package/test/eyelang/conformance/expected/extension/005_lists_aggregation_ordering.out +9 -0
- package/test/eyelang/conformance/expected/extension/006_formula_terms.out +4 -0
- package/test/eyelang/conformance/expected/extension/007_negation_once_generators.out +2 -0
- package/test/eyelang/conformance/expected/extension/008_equality_and_inequality.out +4 -0
- package/test/eyelang/conformance/expected/extension/009_list_relations.out +5 -0
- package/test/eyelang/conformance/expected/extension/010_append_splits.out +3 -0
- package/test/eyelang/conformance/expected/extension/011_matching_and_comparison.out +5 -0
- package/test/eyelang/conformance/expected/extension/012_memoize_declaration.out +2 -0
- package/test/eyelang/conformance/expected/extension/013_numeric_functions.out +7 -0
- package/test/eyelang/conformance/expected/extension/014_between_enumeration.out +3 -0
- package/test/eyelang/conformance/expected/extension/015_smallest_divisor.out +1 -0
- package/test/eyelang/conformance/expected/extension/016_negation_filter.out +2 -0
- package/test/eyelang/conformance/expected/extension/017_once_user_predicate.out +1 -0
- package/test/eyelang/conformance/expected/extension/018_findall_user_goal.out +1 -0
- package/test/eyelang/conformance/expected/extension/019_sort_deduplicates_atoms.out +1 -0
- package/test/eyelang/conformance/expected/extension/020_append_bound_prefix_suffix.out +2 -0
- package/test/eyelang/conformance/expected/extension/021_nth0_index_generation.out +1 -0
- package/test/eyelang/conformance/expected/extension/022_set_nth0_edges.out +2 -0
- package/test/eyelang/conformance/expected/extension/023_select_duplicate_occurrences.out +2 -0
- package/test/eyelang/conformance/expected/extension/024_not_member_filter.out +1 -0
- package/test/eyelang/conformance/expected/extension/025_is_list_filter.out +1 -0
- package/test/eyelang/conformance/expected/extension/026_nested_formula_terms.out +6 -0
- package/test/eyelang/conformance/expected/extension/027_materialize_excludes_source_fact.out +1 -0
- package/test/eyelang/conformance/expected/extension/028_numeric_and_lexical_comparison.out +3 -0
- package/test/eyelang/conformance/expected/extension/029_string_matching_filters.out +2 -0
- package/test/eyelang/conformance/expected/extension/030_string_and_atom_concat.out +2 -0
- package/test/eyelang/conformance/expected/extension/031_countall_empty_and_nonempty.out +1 -0
- package/test/eyelang/conformance/expected/extension/032_sumall_numeric_template.out +1 -0
- package/test/eyelang/conformance/expected/extension/033_aggregate_min_template.out +1 -0
- package/test/eyelang/conformance/expected/extension/034_aggregate_max_compound_key.out +1 -0
- package/test/eyelang/conformance/expected/extension/035_date_difference.out +2 -0
- package/test/eyelang/conformance/expected/extension/036_extended_gcd.out +1 -0
- package/test/eyelang/conformance/expected/extension/037_collatz_trajectory.out +1 -0
- package/test/eyelang/conformance/expected/extension/038_kaprekar_steps.out +1 -0
- package/test/eyelang/conformance/expected/extension/039_goldbach_pair.out +2 -0
- package/test/eyelang/conformance/expected/extension/040_matrix_operations.out +3 -0
- package/test/eyelang/conformance/expected/extension/041_atom_range_generators.out +8 -0
- package/test/eyelang/conformance/expected/extension/042_n_queens_small.out +2 -0
- package/test/eyelang/conformance/expected/extension/043_cnf_model.out +1 -0
- package/test/eyelang/conformance/expected/extension/044_cover9_filter.out +2 -0
- package/test/eyelang/conformance/expected/extension/045_alphametic_sum_small.out +4 -0
- package/test/eyelang/conformance/expected/extension/046_bounded_subset.out +5 -0
- package/test/eyelang/run-all.mjs +20 -0
- package/test/eyelang/run-conformance.mjs +80 -0
- package/test/eyelang/run-examples.mjs +126 -0
- package/test/eyelang/run-regression.mjs +640 -0
- package/test/eyelang/test-style.mjs +91 -0
- package/test/eyelang.test.js +58 -0
- package/test/run.js +1 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
% Leg Length Discrepancy Measurement, adapted from Eyeling lldm.n3.
|
|
2
|
+
%
|
|
3
|
+
% The measurement and intermediate geometry are kept in helper predicates so
|
|
4
|
+
% the default relation materialization stays concise. The visible output is
|
|
5
|
+
% the alarm plus the small set of relations explaining why the alarm fired.
|
|
6
|
+
|
|
7
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
8
|
+
materialize(type, 2).
|
|
9
|
+
materialize(lld_left_length_cm, 2).
|
|
10
|
+
materialize(lld_right_length_cm, 2).
|
|
11
|
+
materialize(lld_discrepancy_cm, 2).
|
|
12
|
+
materialize(lld_threshold_cm, 2).
|
|
13
|
+
materialize(lld_reason, 2).
|
|
14
|
+
|
|
15
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
16
|
+
measurement(meas47).
|
|
17
|
+
|
|
18
|
+
% measured landmark coordinates, in centimetres
|
|
19
|
+
val(meas47, p1xCm, 10.1).
|
|
20
|
+
val(meas47, p1yCm, 7.8).
|
|
21
|
+
val(meas47, p2xCm, 45.1).
|
|
22
|
+
val(meas47, p2yCm, 5.6).
|
|
23
|
+
val(meas47, p3xCm, 3.6).
|
|
24
|
+
val(meas47, p3yCm, 29.8).
|
|
25
|
+
val(meas47, p4xCm, 54.7).
|
|
26
|
+
val(meas47, p4yCm, 28.5).
|
|
27
|
+
|
|
28
|
+
% threshold used by the alarm rule, in centimetres
|
|
29
|
+
threshold(meas47, lld_alarm_threshold_cm, 1.25).
|
|
30
|
+
|
|
31
|
+
% geometric intermediate values
|
|
32
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
33
|
+
val(M, dx12Cm, Z) :- measurement(M), val(M, p1xCm, X), val(M, p2xCm, Y), sub(X, Y, Z).
|
|
34
|
+
val(M, dx51Cm, Z) :- measurement(M), val(M, p5xCm, X), val(M, p1xCm, Y), sub(X, Y, Z).
|
|
35
|
+
val(M, dx53Cm, Z) :- measurement(M), val(M, p5xCm, X), val(M, p3xCm, Y), sub(X, Y, Z).
|
|
36
|
+
val(M, dx62Cm, Z) :- measurement(M), val(M, p6xCm, X), val(M, p2xCm, Y), sub(X, Y, Z).
|
|
37
|
+
val(M, dx64Cm, Z) :- measurement(M), val(M, p6xCm, X), val(M, p4xCm, Y), sub(X, Y, Z).
|
|
38
|
+
val(M, dy12Cm, Z) :- measurement(M), val(M, p1yCm, X), val(M, p2yCm, Y), sub(X, Y, Z).
|
|
39
|
+
val(M, dy13Cm, Z) :- measurement(M), val(M, p1yCm, X), val(M, p3yCm, Y), sub(X, Y, Z).
|
|
40
|
+
val(M, dy24Cm, Z) :- measurement(M), val(M, p2yCm, X), val(M, p4yCm, Y), sub(X, Y, Z).
|
|
41
|
+
val(M, dy53Cm, Z) :- measurement(M), val(M, p5yCm, X), val(M, p3yCm, Y), sub(X, Y, Z).
|
|
42
|
+
val(M, dy64Cm, Z) :- measurement(M), val(M, p6yCm, X), val(M, p4yCm, Y), sub(X, Y, Z).
|
|
43
|
+
val(M, cL1, Z) :- measurement(M), val(M, dy12Cm, Y), val(M, dx12Cm, X), div(Y, X, Z).
|
|
44
|
+
val(M, dL3m, Z) :- measurement(M), val(M, cL1, X), div(1, X, Z).
|
|
45
|
+
val(M, cL3, Z) :- measurement(M), val(M, dL3m, X), sub(0, X, Z).
|
|
46
|
+
val(M, pL1x1Cm, Z) :- measurement(M), val(M, cL1, X), val(M, p1xCm, Y), mul(X, Y, Z).
|
|
47
|
+
val(M, pL1x2Cm, Z) :- measurement(M), val(M, cL1, X), val(M, p2xCm, Y), mul(X, Y, Z).
|
|
48
|
+
val(M, pL3x3Cm, Z) :- measurement(M), val(M, cL3, X), val(M, p3xCm, Y), mul(X, Y, Z).
|
|
49
|
+
val(M, pL3x4Cm, Z) :- measurement(M), val(M, cL3, X), val(M, p4xCm, Y), mul(X, Y, Z).
|
|
50
|
+
val(M, dd13Cm, Z) :- measurement(M), val(M, pL1x1Cm, X), val(M, pL3x3Cm, Y), sub(X, Y, Z).
|
|
51
|
+
val(M, ddy13Cm, Z) :- measurement(M), val(M, dd13Cm, X), val(M, dy13Cm, Y), sub(X, Y, Z).
|
|
52
|
+
val(M, dd24Cm, Z) :- measurement(M), val(M, pL1x2Cm, X), val(M, pL3x4Cm, Y), sub(X, Y, Z).
|
|
53
|
+
val(M, ddy24Cm, Z) :- measurement(M), val(M, dd24Cm, X), val(M, dy24Cm, Y), sub(X, Y, Z).
|
|
54
|
+
val(M, ddL13, Z) :- measurement(M), val(M, cL1, X), val(M, cL3, Y), sub(X, Y, Z).
|
|
55
|
+
val(M, pL1dx51Cm, Z) :- measurement(M), val(M, cL1, X), val(M, dx51Cm, Y), mul(X, Y, Z).
|
|
56
|
+
val(M, pL1dx62Cm, Z) :- measurement(M), val(M, cL1, X), val(M, dx62Cm, Y), mul(X, Y, Z).
|
|
57
|
+
val(M, p5xCm, Z) :- measurement(M), val(M, ddy13Cm, X), val(M, ddL13, Y), div(X, Y, Z).
|
|
58
|
+
val(M, p5yCm, Z) :- measurement(M), val(M, pL1dx51Cm, X), val(M, p1yCm, Y), add(X, Y, Z).
|
|
59
|
+
val(M, p6xCm, Z) :- measurement(M), val(M, ddy24Cm, X), val(M, ddL13, Y), div(X, Y, Z).
|
|
60
|
+
val(M, p6yCm, Z) :- measurement(M), val(M, pL1dx62Cm, X), val(M, p2yCm, Y), add(X, Y, Z).
|
|
61
|
+
val(M, sdx53Cm2, Z) :- measurement(M), val(M, dx53Cm, X), pow(X, 2, Z).
|
|
62
|
+
val(M, sdx64Cm2, Z) :- measurement(M), val(M, dx64Cm, X), pow(X, 2, Z).
|
|
63
|
+
val(M, sdy53Cm2, Z) :- measurement(M), val(M, dy53Cm, X), pow(X, 2, Z).
|
|
64
|
+
val(M, sdy64Cm2, Z) :- measurement(M), val(M, dy64Cm, X), pow(X, 2, Z).
|
|
65
|
+
val(M, ssd53Cm2, Z) :- measurement(M), val(M, sdx53Cm2, X), val(M, sdy53Cm2, Y), add(X, Y, Z).
|
|
66
|
+
val(M, ssd64Cm2, Z) :- measurement(M), val(M, sdx64Cm2, X), val(M, sdy64Cm2, Y), add(X, Y, Z).
|
|
67
|
+
val(M, d53Cm, Z) :- measurement(M), val(M, ssd53Cm2, X), pow(X, 0.5, Z).
|
|
68
|
+
val(M, d64Cm, Z) :- measurement(M), val(M, ssd64Cm2, X), pow(X, 0.5, Z).
|
|
69
|
+
val(M, dCm, Z) :- measurement(M), val(M, d53Cm, X), val(M, d64Cm, Y), sub(X, Y, Z).
|
|
70
|
+
|
|
71
|
+
% concise output layer
|
|
72
|
+
type(M, lld_alarm) :- measurement(M), val(M, dCm, D), threshold(M, lld_alarm_threshold_cm, T), sub(0, T, NegT), lt(D, NegT).
|
|
73
|
+
type(M, lld_alarm) :- measurement(M), val(M, dCm, D), threshold(M, lld_alarm_threshold_cm, T), gt(D, T).
|
|
74
|
+
lld_left_length_cm(M, L) :- type(M, lld_alarm), val(M, d53Cm, L).
|
|
75
|
+
lld_right_length_cm(M, R) :- type(M, lld_alarm), val(M, d64Cm, R).
|
|
76
|
+
lld_discrepancy_cm(M, D) :- type(M, lld_alarm), val(M, dCm, D).
|
|
77
|
+
lld_threshold_cm(M, T) :- type(M, lld_alarm), threshold(M, lld_alarm_threshold_cm, T).
|
|
78
|
+
lld_reason(M, "discrepancy below negative threshold") :- type(M, lld_alarm).
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
% Representative example: manufacturing quality-control capability.
|
|
2
|
+
%
|
|
3
|
+
% The rules compute process capability indices from measurement summaries and
|
|
4
|
+
% classify production lines using a practical Cpk threshold.
|
|
5
|
+
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
|
+
materialize(cpk, 2).
|
|
8
|
+
materialize(status, 2).
|
|
9
|
+
materialize(reason, 2).
|
|
10
|
+
|
|
11
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
12
|
+
run(line7_shift_a).
|
|
13
|
+
run(line8_shift_b).
|
|
14
|
+
|
|
15
|
+
spec(line7_shift_a, lower_mm, 10.0).
|
|
16
|
+
spec(line7_shift_a, upper_mm, 10.2).
|
|
17
|
+
summary(line7_shift_a, mean_mm, 10.12).
|
|
18
|
+
summary(line7_shift_a, sigma_mm, 0.04).
|
|
19
|
+
|
|
20
|
+
spec(line8_shift_b, lower_mm, 10.0).
|
|
21
|
+
spec(line8_shift_b, upper_mm, 10.2).
|
|
22
|
+
summary(line8_shift_b, mean_mm, 10.1).
|
|
23
|
+
summary(line8_shift_b, sigma_mm, 0.02).
|
|
24
|
+
|
|
25
|
+
capability_threshold(cpk, 1.33).
|
|
26
|
+
|
|
27
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
28
|
+
upper_margin_mm(Run, Margin) :-
|
|
29
|
+
spec(Run, upper_mm, Upper),
|
|
30
|
+
summary(Run, mean_mm, Mean),
|
|
31
|
+
sub(Upper, Mean, Margin).
|
|
32
|
+
|
|
33
|
+
lower_margin_mm(Run, Margin) :-
|
|
34
|
+
summary(Run, mean_mm, Mean),
|
|
35
|
+
spec(Run, lower_mm, Lower),
|
|
36
|
+
sub(Mean, Lower, Margin).
|
|
37
|
+
|
|
38
|
+
nearest_spec_margin_mm(Run, Margin) :-
|
|
39
|
+
upper_margin_mm(Run, UpperMargin),
|
|
40
|
+
lower_margin_mm(Run, LowerMargin),
|
|
41
|
+
min(UpperMargin, LowerMargin, Margin).
|
|
42
|
+
|
|
43
|
+
three_sigma_mm(Run, ThreeSigma) :-
|
|
44
|
+
summary(Run, sigma_mm, Sigma),
|
|
45
|
+
mul(3.0, Sigma, ThreeSigma).
|
|
46
|
+
|
|
47
|
+
cpk(Run, Cpk) :-
|
|
48
|
+
nearest_spec_margin_mm(Run, Margin),
|
|
49
|
+
three_sigma_mm(Run, ThreeSigma),
|
|
50
|
+
div(Margin, ThreeSigma, Cpk).
|
|
51
|
+
|
|
52
|
+
capable(Run) :-
|
|
53
|
+
cpk(Run, Cpk),
|
|
54
|
+
capability_threshold(cpk, Threshold),
|
|
55
|
+
ge(Cpk, Threshold).
|
|
56
|
+
|
|
57
|
+
needs_adjustment(Run) :-
|
|
58
|
+
cpk(Run, Cpk),
|
|
59
|
+
capability_threshold(cpk, Threshold),
|
|
60
|
+
lt(Cpk, Threshold).
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
status(Run, capable_process) :-
|
|
64
|
+
capable(Run).
|
|
65
|
+
|
|
66
|
+
status(Run, needs_process_adjustment) :-
|
|
67
|
+
needs_adjustment(Run).
|
|
68
|
+
|
|
69
|
+
reason(Run, "Cpk meets the production capability threshold") :-
|
|
70
|
+
capable(Run).
|
|
71
|
+
|
|
72
|
+
reason(Run, "Cpk is below the production capability threshold") :-
|
|
73
|
+
needs_adjustment(Run).
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
% Matrix operations example, adapted from Eyelet's input/matrix.pl.
|
|
2
|
+
%
|
|
3
|
+
% The operations and sample cases follow the Trealla output reference from
|
|
4
|
+
% Eyelet: determinant, inversion, triangular inversion, multiplication, sum,
|
|
5
|
+
% and Cholesky decomposition. Results are derived by generic matrix rules, not
|
|
6
|
+
% asserted as output facts.
|
|
7
|
+
|
|
8
|
+
% --- small list helpers -----------------------------------------------------
|
|
9
|
+
|
|
10
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
11
|
+
materialize(result, 2).
|
|
12
|
+
materialize(checksConsistentWithTreallaReference, 2).
|
|
13
|
+
|
|
14
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
15
|
+
nth0(0, [H|_T], H).
|
|
16
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
17
|
+
nth0(N, [_H|T], V) :-
|
|
18
|
+
gt(N, 0),
|
|
19
|
+
sub(N, 1, N1),
|
|
20
|
+
nth0(N1, T, V).
|
|
21
|
+
|
|
22
|
+
flatten_matrix([], []).
|
|
23
|
+
flatten_matrix([Row|Rows], Flat) :-
|
|
24
|
+
flatten_matrix(Rows, Tail),
|
|
25
|
+
append(Row, Tail, Flat).
|
|
26
|
+
|
|
27
|
+
list0(0, []).
|
|
28
|
+
list0(N, [0|T]) :-
|
|
29
|
+
gt(N, 0),
|
|
30
|
+
sub(N, 1, N1),
|
|
31
|
+
list0(N1, T).
|
|
32
|
+
|
|
33
|
+
take(0, Rest, [], Rest).
|
|
34
|
+
take(N, [H|T], [H|Row], Rest) :-
|
|
35
|
+
gt(N, 0),
|
|
36
|
+
sub(N, 1, N1),
|
|
37
|
+
take(N1, T, Row, Rest).
|
|
38
|
+
|
|
39
|
+
identify_rows([], _N, []).
|
|
40
|
+
identify_rows(Elems, N, [Row|Rows]) :-
|
|
41
|
+
take(N, Elems, Row, Rest),
|
|
42
|
+
identify_rows(Rest, N, Rows).
|
|
43
|
+
|
|
44
|
+
get_v(I, J, N, Flat, V) :-
|
|
45
|
+
mul(I, N, IN),
|
|
46
|
+
add(IN, J, E),
|
|
47
|
+
nth0(E, Flat, V).
|
|
48
|
+
|
|
49
|
+
set_v(I, J, N, Flat, NewFlat, V) :-
|
|
50
|
+
mul(I, N, IN),
|
|
51
|
+
add(IN, J, E),
|
|
52
|
+
set_nth0(E, Flat, V, NewFlat).
|
|
53
|
+
|
|
54
|
+
% --- basic matrix operations ------------------------------------------------
|
|
55
|
+
|
|
56
|
+
row_sum([], [], []).
|
|
57
|
+
row_sum([A|As], [B|Bs], [C|Cs]) :-
|
|
58
|
+
add(A, B, C),
|
|
59
|
+
row_sum(As, Bs, Cs).
|
|
60
|
+
|
|
61
|
+
matrix_sum([[], []], []).
|
|
62
|
+
matrix_sum([[RowA|RowsA], [RowB|RowsB]], [Row|Rows]) :-
|
|
63
|
+
row_sum(RowA, RowB, Row),
|
|
64
|
+
matrix_sum([RowsA, RowsB], Rows).
|
|
65
|
+
|
|
66
|
+
row_diff([], [], []).
|
|
67
|
+
row_diff([A|As], [B|Bs], [C|Cs]) :-
|
|
68
|
+
sub(A, B, C),
|
|
69
|
+
row_diff(As, Bs, Cs).
|
|
70
|
+
|
|
71
|
+
matrix_diff([], [], []).
|
|
72
|
+
matrix_diff([RowA|RowsA], [RowB|RowsB], [Row|Rows]) :-
|
|
73
|
+
row_diff(RowA, RowB, Row),
|
|
74
|
+
matrix_diff(RowsA, RowsB, Rows).
|
|
75
|
+
|
|
76
|
+
row_mult_scal([], _V, []).
|
|
77
|
+
row_mult_scal([A|As], V, [B|Bs]) :-
|
|
78
|
+
mul(A, V, B),
|
|
79
|
+
row_mult_scal(As, V, Bs).
|
|
80
|
+
|
|
81
|
+
matrix_mult_scal([], _V, []).
|
|
82
|
+
matrix_mult_scal([Row|Rows], V, [Scaled|ScaledRows]) :-
|
|
83
|
+
row_mult_scal(Row, V, Scaled),
|
|
84
|
+
matrix_mult_scal(Rows, V, ScaledRows).
|
|
85
|
+
|
|
86
|
+
row_div_scal([], _V, []).
|
|
87
|
+
row_div_scal([A|As], V, [B|Bs]) :-
|
|
88
|
+
div(A, V, B),
|
|
89
|
+
row_div_scal(As, V, Bs).
|
|
90
|
+
|
|
91
|
+
matrix_div_scal([], _V, []).
|
|
92
|
+
matrix_div_scal([Row|Rows], V, [Scaled|ScaledRows]) :-
|
|
93
|
+
row_div_scal(Row, V, Scaled),
|
|
94
|
+
matrix_div_scal(Rows, V, ScaledRows).
|
|
95
|
+
|
|
96
|
+
transpose_matrix([], []).
|
|
97
|
+
transpose_matrix([[]|_Rows], []).
|
|
98
|
+
transpose_matrix(Matrix, [Column|Columns]) :-
|
|
99
|
+
first_column(Matrix, Column, Rest),
|
|
100
|
+
transpose_matrix(Rest, Columns).
|
|
101
|
+
|
|
102
|
+
first_column([], [], []).
|
|
103
|
+
first_column([[H|T]|Rows], [H|Hs], [T|Ts]) :-
|
|
104
|
+
first_column(Rows, Hs, Ts).
|
|
105
|
+
|
|
106
|
+
dot_product([], [], 0).
|
|
107
|
+
dot_product([X|Xs], [Y|Ys], D) :-
|
|
108
|
+
dot_product(Xs, Ys, Rest),
|
|
109
|
+
mul(X, Y, XY),
|
|
110
|
+
add(XY, Rest, D).
|
|
111
|
+
|
|
112
|
+
row_multiply(_Transposed, [], []).
|
|
113
|
+
row_multiply(Transposed, [Row|Rows], [OutRow|OutRows]) :-
|
|
114
|
+
row_multiply_columns(Transposed, Row, OutRow),
|
|
115
|
+
row_multiply(Transposed, Rows, OutRows).
|
|
116
|
+
|
|
117
|
+
row_multiply_columns([], _Row, []).
|
|
118
|
+
row_multiply_columns([Column|Columns], Row, [D|Ds]) :-
|
|
119
|
+
dot_product(Row, Column, D),
|
|
120
|
+
row_multiply_columns(Columns, Row, Ds).
|
|
121
|
+
|
|
122
|
+
matrix_multiply([X, Y], M) :-
|
|
123
|
+
transpose_matrix(Y, T),
|
|
124
|
+
row_multiply(T, X, M).
|
|
125
|
+
|
|
126
|
+
% --- Cholesky decomposition -------------------------------------------------
|
|
127
|
+
|
|
128
|
+
cholesky_decomposition(A, L) :-
|
|
129
|
+
flatten_matrix(A, FlatA),
|
|
130
|
+
length(FlatA, FlatLen),
|
|
131
|
+
list0(FlatLen, Work0),
|
|
132
|
+
length(A, N),
|
|
133
|
+
cholesky_i(0, N, FlatA, Work0, Work),
|
|
134
|
+
identify_rows(Work, N, L).
|
|
135
|
+
|
|
136
|
+
cholesky_i(I, N, _A, L, L) :-
|
|
137
|
+
ge(I, N).
|
|
138
|
+
cholesky_i(I, N, A, L, LOut) :-
|
|
139
|
+
lt(I, N),
|
|
140
|
+
cholesky_j(0, I, N, A, L, L1),
|
|
141
|
+
add(I, 1, I1),
|
|
142
|
+
cholesky_i(I1, N, A, L1, LOut).
|
|
143
|
+
|
|
144
|
+
cholesky_j(J, I, N, A, L, LOut) :-
|
|
145
|
+
eq(J, I),
|
|
146
|
+
cholesky_k(0, I, I, N, 0, S, L),
|
|
147
|
+
get_v(I, I, N, A, Aii),
|
|
148
|
+
sub(Aii, S, V2),
|
|
149
|
+
pow(V2, 0.5, V),
|
|
150
|
+
set_v(I, I, N, L, LOut, V).
|
|
151
|
+
cholesky_j(J, I, N, A, L, LOut) :-
|
|
152
|
+
lt(J, I),
|
|
153
|
+
cholesky_k(0, J, I, N, 0, S, L),
|
|
154
|
+
get_v(I, J, N, A, Aij),
|
|
155
|
+
get_v(J, J, N, L, Ljj),
|
|
156
|
+
sub(Aij, S, Numerator),
|
|
157
|
+
div(Numerator, Ljj, V),
|
|
158
|
+
set_v(I, J, N, L, L1, V),
|
|
159
|
+
add(J, 1, J1),
|
|
160
|
+
cholesky_j(J1, I, N, A, L1, LOut).
|
|
161
|
+
|
|
162
|
+
cholesky_k(K, J, _I, _N, S, S, _L) :-
|
|
163
|
+
ge(K, J).
|
|
164
|
+
cholesky_k(K, J, I, N, S0, S, L) :-
|
|
165
|
+
lt(K, J),
|
|
166
|
+
get_v(I, K, N, L, Lik),
|
|
167
|
+
get_v(J, K, N, L, Ljk),
|
|
168
|
+
mul(Lik, Ljk, Product),
|
|
169
|
+
add(S0, Product, S1),
|
|
170
|
+
add(K, 1, K1),
|
|
171
|
+
cholesky_k(K1, J, I, N, S1, S, L).
|
|
172
|
+
|
|
173
|
+
% --- determinant and inversion ---------------------------------------------
|
|
174
|
+
|
|
175
|
+
get_diagonal(Matrix, Diagonal) :-
|
|
176
|
+
length(Matrix, N),
|
|
177
|
+
get_diag(0, N, Matrix, Diagonal).
|
|
178
|
+
|
|
179
|
+
get_diag(I, N, _Matrix, []) :-
|
|
180
|
+
ge(I, N).
|
|
181
|
+
get_diag(I, N, Matrix, [V|Vs]) :-
|
|
182
|
+
lt(I, N),
|
|
183
|
+
nth0(I, Matrix, Row),
|
|
184
|
+
nth0(I, Row, V),
|
|
185
|
+
add(I, 1, I1),
|
|
186
|
+
get_diag(I1, N, Matrix, Vs).
|
|
187
|
+
|
|
188
|
+
prod_list([], 1).
|
|
189
|
+
prod_list([A|As], P) :-
|
|
190
|
+
prod_list(As, P0),
|
|
191
|
+
mul(A, P0, P).
|
|
192
|
+
|
|
193
|
+
determinant(A, Det) :-
|
|
194
|
+
cholesky_decomposition(A, L),
|
|
195
|
+
get_diagonal(L, Diagonal),
|
|
196
|
+
prod_list(Diagonal, DetL),
|
|
197
|
+
mul(DetL, DetL, Det).
|
|
198
|
+
|
|
199
|
+
matrix_inv_triang(L, Inv) :-
|
|
200
|
+
length(L, N),
|
|
201
|
+
build_inv_rows(0, N, L, [], Inv).
|
|
202
|
+
|
|
203
|
+
build_inv_rows(I, N, _L, _Previous, []) :-
|
|
204
|
+
ge(I, N).
|
|
205
|
+
build_inv_rows(I, N, L, Previous, [Row|Rows]) :-
|
|
206
|
+
lt(I, N),
|
|
207
|
+
build_inv_row(0, N, I, L, Previous, Row),
|
|
208
|
+
append(Previous, [Row], NextPrevious),
|
|
209
|
+
add(I, 1, I1),
|
|
210
|
+
build_inv_rows(I1, N, L, NextPrevious, Rows).
|
|
211
|
+
|
|
212
|
+
build_inv_row(J, N, _I, _L, _Previous, []) :-
|
|
213
|
+
ge(J, N).
|
|
214
|
+
build_inv_row(J, N, I, L, Previous, [V|Vs]) :-
|
|
215
|
+
lt(J, N),
|
|
216
|
+
lower_inverse_value(I, J, N, L, Previous, V),
|
|
217
|
+
add(J, 1, J1),
|
|
218
|
+
build_inv_row(J1, N, I, L, Previous, Vs).
|
|
219
|
+
|
|
220
|
+
lower_inverse_value(I, J, _N, _L, _Previous, 0) :-
|
|
221
|
+
gt(J, I).
|
|
222
|
+
lower_inverse_value(I, J, N, L, _Previous, V) :-
|
|
223
|
+
eq(I, J),
|
|
224
|
+
nth0(I, L, Row),
|
|
225
|
+
nth0(I, Row, Diagonal),
|
|
226
|
+
div(1.0, Diagonal, V).
|
|
227
|
+
lower_inverse_value(I, J, N, L, Previous, V) :-
|
|
228
|
+
lt(J, I),
|
|
229
|
+
sum_lower_inverse(J, I, J, N, L, Previous, 0, Sum),
|
|
230
|
+
neg(Sum, NegSum),
|
|
231
|
+
nth0(I, L, Row),
|
|
232
|
+
nth0(I, Row, Diagonal),
|
|
233
|
+
div(NegSum, Diagonal, V).
|
|
234
|
+
|
|
235
|
+
sum_lower_inverse(K, I, _J, _N, _L, _Previous, Sum, Sum) :-
|
|
236
|
+
ge(K, I).
|
|
237
|
+
sum_lower_inverse(K, I, J, N, L, Previous, Sum0, Sum) :-
|
|
238
|
+
lt(K, I),
|
|
239
|
+
nth0(I, L, RowI),
|
|
240
|
+
nth0(K, RowI, Lik),
|
|
241
|
+
nth0(K, Previous, InvRowK),
|
|
242
|
+
nth0(J, InvRowK, InvKj),
|
|
243
|
+
mul(Lik, InvKj, Product),
|
|
244
|
+
add(Sum0, Product, Sum1),
|
|
245
|
+
add(K, 1, K1),
|
|
246
|
+
sum_lower_inverse(K1, I, J, N, L, Previous, Sum1, Sum).
|
|
247
|
+
|
|
248
|
+
matrix_inversion(A, B) :-
|
|
249
|
+
cholesky_decomposition(A, L),
|
|
250
|
+
matrix_inv_triang(L, LI),
|
|
251
|
+
transpose_matrix(LI, LIT),
|
|
252
|
+
matrix_multiply([LIT, LI], B).
|
|
253
|
+
|
|
254
|
+
% --- sample cases mirroring Eyelet's Trealla reference output ---------------
|
|
255
|
+
|
|
256
|
+
case(det3, determinant, [[2, -1, 0], [-1, 2, -1], [0, -1, 2]]).
|
|
257
|
+
case(inv3, matrix_inversion, [[2, -1, 0], [-1, 2, -1], [0, -1, 2]]).
|
|
258
|
+
case(inv4, matrix_inversion, [[18, 22, 54, 42], [22, 70, 86, 62], [54, 86, 174, 134], [42, 62, 134, 106]]).
|
|
259
|
+
case(invtri3, matrix_inv_triang, [[2, 0, 0], [-1, 2, 0], [0, -1, 2]]).
|
|
260
|
+
case(mul_small, matrix_multiply, [[[1, 2], [3, 4], [5, 6]], [[1, 1, 1], [1, 1, 1]]]).
|
|
261
|
+
case(mul_identity_check, matrix_multiply, [[[18, 22, 54, 42], [22, 70, 86, 62], [54, 86, 174, 134], [42, 62, 134, 106]], [[2.515624999999984, 0.4843749999999933, -1.296874999999973, 0.3593749999999767], [0.4843749999999933, 0.1406249999999978, -0.3281249999999918, 0.1406249999999936], [-1.296874999999973, -0.3281249999999918, 1.015624999999971, -0.5781249999999781], [0.3593749999999767, 0.1406249999999936, -0.5781249999999781, 0.5156249999999853]]]).
|
|
262
|
+
case(sum_small, matrix_sum, [[[1, 2], [3, 4], [5, 6]], [[1, 2], [3, 4], [5, 6]]]).
|
|
263
|
+
case(chol3, cholesky_decomposition, [[25, 15, -5], [15, 18, 0], [-5, 0, 11]]).
|
|
264
|
+
case(chol4, cholesky_decomposition, [[18, 22, 54, 42], [22, 70, 86, 62], [54, 86, 174, 134], [42, 62, 134, 106]]).
|
|
265
|
+
|
|
266
|
+
result(Case, determinant(Matrix, Det)) :-
|
|
267
|
+
case(Case, determinant, Matrix),
|
|
268
|
+
determinant(Matrix, Det).
|
|
269
|
+
|
|
270
|
+
result(Case, matrix_inversion(Matrix, Inverse)) :-
|
|
271
|
+
case(Case, matrix_inversion, Matrix),
|
|
272
|
+
matrix_inversion(Matrix, Inverse).
|
|
273
|
+
|
|
274
|
+
result(Case, matrix_inv_triang(Matrix, Inverse)) :-
|
|
275
|
+
case(Case, matrix_inv_triang, Matrix),
|
|
276
|
+
matrix_inv_triang(Matrix, Inverse).
|
|
277
|
+
|
|
278
|
+
result(Case, matrix_multiply(Inputs, Product)) :-
|
|
279
|
+
case(Case, matrix_multiply, Inputs),
|
|
280
|
+
matrix_multiply(Inputs, Product).
|
|
281
|
+
|
|
282
|
+
result(Case, matrix_sum(Inputs, Sum)) :-
|
|
283
|
+
case(Case, matrix_sum, Inputs),
|
|
284
|
+
matrix_sum(Inputs, Sum).
|
|
285
|
+
|
|
286
|
+
result(Case, cholesky_decomposition(Matrix, L)) :-
|
|
287
|
+
case(Case, cholesky_decomposition, Matrix),
|
|
288
|
+
cholesky_decomposition(Matrix, L).
|
|
289
|
+
|
|
290
|
+
checksConsistentWithTreallaReference(matrix, true) :-
|
|
291
|
+
determinant([[2, -1, 0], [-1, 2, -1], [0, -1, 2]], Det),
|
|
292
|
+
gt(Det, 3.9999),
|
|
293
|
+
lt(Det, 4.0001),
|
|
294
|
+
matrix_multiply([[[1, 2], [3, 4], [5, 6]], [[1, 1, 1], [1, 1, 1]]], [[3, 3, 3], [7, 7, 7], [11, 11, 11]]),
|
|
295
|
+
matrix_sum([[[1, 2], [3, 4], [5, 6]], [[1, 2], [3, 4], [5, 6]]], [[2, 4], [6, 8], [10, 12]]),
|
|
296
|
+
cholesky_decomposition([[25, 15, -5], [15, 18, 0], [-5, 0, 11]], [[5.0, 0, 0], [3.0, 3.0, 0], [-1.0, 1.0, 3.0]]).
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
% Representative example: microgrid dispatch planning.
|
|
2
|
+
%
|
|
3
|
+
% The rules compute renewable supply, reserve-aware battery dispatch, remaining
|
|
4
|
+
% grid import, and a concise feasibility report for a campus microgrid interval.
|
|
5
|
+
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
|
+
materialize(renewablePower_kW, 2).
|
|
8
|
+
materialize(batteryDispatch_kW, 2).
|
|
9
|
+
materialize(gridImport_kW, 2).
|
|
10
|
+
materialize(reserveAfterDispatch_kW, 2).
|
|
11
|
+
materialize(status, 2).
|
|
12
|
+
materialize(reason, 2).
|
|
13
|
+
|
|
14
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
15
|
+
site(campus_interval_17).
|
|
16
|
+
|
|
17
|
+
load_kW(campus_interval_17, 620.0).
|
|
18
|
+
solar_kW(campus_interval_17, 180.0).
|
|
19
|
+
wind_kW(campus_interval_17, 90.0).
|
|
20
|
+
battery_max_discharge_kW(campus_interval_17, 320.0).
|
|
21
|
+
required_battery_reserve_kW(campus_interval_17, 80.0).
|
|
22
|
+
grid_contract_limit_kW(campus_interval_17, 150.0).
|
|
23
|
+
|
|
24
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
25
|
+
renewable_kW(Site, Renewable) :-
|
|
26
|
+
solar_kW(Site, Solar),
|
|
27
|
+
wind_kW(Site, Wind),
|
|
28
|
+
add(Solar, Wind, Renewable).
|
|
29
|
+
|
|
30
|
+
net_deficit_kW(Site, Deficit) :-
|
|
31
|
+
load_kW(Site, Load),
|
|
32
|
+
renewable_kW(Site, Renewable),
|
|
33
|
+
sub(Load, Renewable, Deficit).
|
|
34
|
+
|
|
35
|
+
reserve_aware_battery_limit_kW(Site, Limit) :-
|
|
36
|
+
battery_max_discharge_kW(Site, MaxDischarge),
|
|
37
|
+
required_battery_reserve_kW(Site, Reserve),
|
|
38
|
+
sub(MaxDischarge, Reserve, Limit).
|
|
39
|
+
|
|
40
|
+
battery_dispatch_kW(Site, Dispatch) :-
|
|
41
|
+
net_deficit_kW(Site, Deficit),
|
|
42
|
+
reserve_aware_battery_limit_kW(Site, Limit),
|
|
43
|
+
min(Deficit, Limit, Dispatch).
|
|
44
|
+
|
|
45
|
+
grid_import_kW(Site, Import) :-
|
|
46
|
+
net_deficit_kW(Site, Deficit),
|
|
47
|
+
battery_dispatch_kW(Site, Dispatch),
|
|
48
|
+
sub(Deficit, Dispatch, Import).
|
|
49
|
+
|
|
50
|
+
battery_reserve_after_dispatch_kW(Site, ReserveLeft) :-
|
|
51
|
+
battery_max_discharge_kW(Site, MaxDischarge),
|
|
52
|
+
battery_dispatch_kW(Site, Dispatch),
|
|
53
|
+
sub(MaxDischarge, Dispatch, ReserveLeft).
|
|
54
|
+
|
|
55
|
+
contract_ok(Site) :-
|
|
56
|
+
grid_import_kW(Site, Import),
|
|
57
|
+
grid_contract_limit_kW(Site, Limit),
|
|
58
|
+
le(Import, Limit).
|
|
59
|
+
|
|
60
|
+
reserve_ok(Site) :-
|
|
61
|
+
battery_reserve_after_dispatch_kW(Site, ReserveLeft),
|
|
62
|
+
required_battery_reserve_kW(Site, Required),
|
|
63
|
+
ge(ReserveLeft, Required).
|
|
64
|
+
|
|
65
|
+
stable_dispatch(Site) :-
|
|
66
|
+
contract_ok(Site),
|
|
67
|
+
reserve_ok(Site).
|
|
68
|
+
|
|
69
|
+
renewablePower_kW(Site, Renewable) :-
|
|
70
|
+
renewable_kW(Site, Renewable).
|
|
71
|
+
|
|
72
|
+
batteryDispatch_kW(Site, Dispatch) :-
|
|
73
|
+
battery_dispatch_kW(Site, Dispatch).
|
|
74
|
+
|
|
75
|
+
gridImport_kW(Site, Import) :-
|
|
76
|
+
grid_import_kW(Site, Import).
|
|
77
|
+
|
|
78
|
+
reserveAfterDispatch_kW(Site, ReserveLeft) :-
|
|
79
|
+
battery_reserve_after_dispatch_kW(Site, ReserveLeft).
|
|
80
|
+
|
|
81
|
+
status(Site, stable_dispatch) :-
|
|
82
|
+
stable_dispatch(Site).
|
|
83
|
+
|
|
84
|
+
reason(Site, "battery dispatch covers the deficit while preserving reserve and grid contract limits") :-
|
|
85
|
+
stable_dispatch(Site).
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
% Monkey and bananas planning problem, adapted from Eyelet's
|
|
2
|
+
% input/monkey-bananas.pl.
|
|
3
|
+
%
|
|
4
|
+
% A state is [bananas_location, monkey_location, box_location, on_box,
|
|
5
|
+
% has_bananas]. The selected output searches bounded move lists and derives successful
|
|
6
|
+
% plans.
|
|
7
|
+
|
|
8
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
9
|
+
materialize(plan, 2).
|
|
10
|
+
materialize(solved, 2).
|
|
11
|
+
|
|
12
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
13
|
+
memoize(reachable, 3).
|
|
14
|
+
|
|
15
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
16
|
+
plan(Moves) :-
|
|
17
|
+
candidate_plan(Moves),
|
|
18
|
+
initial_state(I),
|
|
19
|
+
goal_state(G),
|
|
20
|
+
reachable(I, Moves, G).
|
|
21
|
+
|
|
22
|
+
candidate_plan([_, _, _]).
|
|
23
|
+
candidate_plan([_, _, _, _]).
|
|
24
|
+
candidate_plan([_, _, _, _, _]).
|
|
25
|
+
|
|
26
|
+
reachable(S, [], S).
|
|
27
|
+
reachable(S1, [M|L], S3) :-
|
|
28
|
+
legal_move(S1, M, S2),
|
|
29
|
+
reachable(S2, L, S3).
|
|
30
|
+
|
|
31
|
+
initial_state([loc1, loc2, loc3, n, n]).
|
|
32
|
+
goal_state([_, _, _, _, y]).
|
|
33
|
+
|
|
34
|
+
legal_move([B, M, M, n, H], climb_on, [B, M, M, y, H]).
|
|
35
|
+
legal_move([B, M, M, y, H], climb_off, [B, M, M, n, H]).
|
|
36
|
+
legal_move([B, B, B, y, n], grab, [B, B, B, y, y]).
|
|
37
|
+
legal_move([B, M, M, n, H], push(X), [B, X, X, n, H]) :-
|
|
38
|
+
member(X, [loc1, loc2, loc3]),
|
|
39
|
+
neq(X, M).
|
|
40
|
+
legal_move([B, M, L, n, H], go(X), [B, X, L, n, H]) :-
|
|
41
|
+
member(X, [loc1, loc2, loc3]),
|
|
42
|
+
neq(X, M).
|
|
43
|
+
|
|
44
|
+
plan(monkeyBananas, Moves) :- plan(Moves).
|
|
45
|
+
solved(monkeyBananas, true) :- plan(_Moves).
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
% N-queens search without cut.
|
|
2
|
+
%
|
|
3
|
+
% A solution is represented as a list of column numbers. The list position is
|
|
4
|
+
% the row, so [1, 5, 8, ...] means row 1 uses column 1, row 2 uses column 5,
|
|
5
|
+
% and so on. Columns are selected from a finite list, which guarantees that no
|
|
6
|
+
% two queens share a column.
|
|
7
|
+
%
|
|
8
|
+
% The two diagonal sets are carried as accumulator lists. A queen at
|
|
9
|
+
% row Row/column Q occupies the down diagonal Row + Q and the up diagonal
|
|
10
|
+
% Row - Q. Rejecting repeats in those two lists enforces the remaining
|
|
11
|
+
% N-queens constraints declaratively, without cut or destructive update.
|
|
12
|
+
|
|
13
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
14
|
+
materialize(solution, 2).
|
|
15
|
+
materialize(solved, 2).
|
|
16
|
+
|
|
17
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
18
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
19
|
+
queens(N, Qs) :-
|
|
20
|
+
n_queens(N, Qs).
|
|
21
|
+
|
|
22
|
+
solution(nQueens8, Qs) :- queens(8, Qs).
|
|
23
|
+
solved(nQueens8, true) :- queens(8, _Qs).
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
@prefix : <http://example.com/> .
|
|
2
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#> .
|
|
3
|
+
@prefix string: <http://www.w3.org/2000/10/swap/string#> .
|
|
4
|
+
@prefix list: <http://www.w3.org/2000/10/swap/list#> .
|
|
5
|
+
|
|
6
|
+
:alice :score 2 ; :bonus 3 ; :name "Alice" .
|
|
7
|
+
:bob :score 1 ; :bonus 1 ; :name "Bob" .
|
|
8
|
+
|
|
9
|
+
{ ?person :score ?score .
|
|
10
|
+
?person :bonus ?bonus .
|
|
11
|
+
(?score ?bonus) math:sum ?total .
|
|
12
|
+
?total math:greaterThan 4 .
|
|
13
|
+
?person :name ?name .
|
|
14
|
+
?name string:startsWith "Al" .
|
|
15
|
+
(?name " total " ?total) string:concatenation ?label .
|
|
16
|
+
} => {
|
|
17
|
+
?person :total ?total .
|
|
18
|
+
?person :label ?label .
|
|
19
|
+
} .
|
|
20
|
+
|
|
21
|
+
{ ?person :status :passing . } <= {
|
|
22
|
+
?person :total ?total .
|
|
23
|
+
?total math:notLessThan 5 .
|
|
24
|
+
} .
|
|
25
|
+
|
|
26
|
+
{ (:red :green :blue) list:member ?colour . } => {
|
|
27
|
+
?colour :kind :colour .
|
|
28
|
+
} .
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
% Technology example: network path SLA check.
|
|
2
|
+
%
|
|
3
|
+
% The path latency is the sum of link delays plus jitter. The path is compliant
|
|
4
|
+
% when the resulting end-to-end latency stays below the SLA limit.
|
|
5
|
+
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
|
+
materialize(endToEndLatency_ms, 2).
|
|
8
|
+
materialize(slaLimit_ms, 2).
|
|
9
|
+
materialize(status, 2).
|
|
10
|
+
materialize(reason, 2).
|
|
11
|
+
|
|
12
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
13
|
+
path(edge_path, [link_a, link_b, link_c]).
|
|
14
|
+
link_latency(link_a, 12.0).
|
|
15
|
+
link_latency(link_b, 18.0).
|
|
16
|
+
link_latency(link_c, 9.0).
|
|
17
|
+
jitter(edge_path, 8.0).
|
|
18
|
+
sla(edge_path, maximum_latency_ms, 50.0).
|
|
19
|
+
|
|
20
|
+
latency_sum([], 0.0).
|
|
21
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
22
|
+
latency_sum([Link|Links], Total) :-
|
|
23
|
+
link_latency(Link, LinkLatency),
|
|
24
|
+
latency_sum(Links, Rest),
|
|
25
|
+
add(LinkLatency, Rest, Total).
|
|
26
|
+
|
|
27
|
+
end_to_end_latency(Path, Latency) :-
|
|
28
|
+
path(Path, Links),
|
|
29
|
+
latency_sum(Links, LinkLatency),
|
|
30
|
+
jitter(Path, Jitter),
|
|
31
|
+
add(LinkLatency, Jitter, Latency).
|
|
32
|
+
|
|
33
|
+
sla_compliant(Path) :-
|
|
34
|
+
end_to_end_latency(Path, Latency),
|
|
35
|
+
sla(Path, maximum_latency_ms, Maximum),
|
|
36
|
+
lt(Latency, Maximum).
|
|
37
|
+
|
|
38
|
+
endToEndLatency_ms(Path, Latency) :-
|
|
39
|
+
end_to_end_latency(Path, Latency).
|
|
40
|
+
|
|
41
|
+
slaLimit_ms(Path, Maximum) :-
|
|
42
|
+
sla(Path, maximum_latency_ms, Maximum).
|
|
43
|
+
|
|
44
|
+
status(Path, sla_compliant) :-
|
|
45
|
+
sla_compliant(Path).
|
|
46
|
+
|
|
47
|
+
reason(Path, "path latency including jitter is below the SLA limit") :-
|
|
48
|
+
sla_compliant(Path).
|