eyeling 1.34.1 → 1.34.3

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.
Files changed (29) hide show
  1. package/README.md +28 -26
  2. package/docs/eyelang-guide.md +6 -21
  3. package/docs/eyelang-language-reference.md +3 -1
  4. package/examples/context-schema-audit.n3 +72 -0
  5. package/examples/eyelang/basic-monadic.pl +16 -2
  6. package/examples/eyelang/output/basic-monadic.pl +1314 -1314
  7. package/examples/eyelang/output/path-discovery.pl +3 -3
  8. package/examples/eyelang/path-discovery.pl +22 -7
  9. package/examples/output/context-schema-audit.md +11 -0
  10. package/lib/eyelang/builtins/registry.js +1 -2
  11. package/package.json +1 -1
  12. package/test/eyelang/conformance/README.md +1 -1
  13. package/examples/eyelang/dense-hamiltonian-cycle.pl +0 -92
  14. package/examples/eyelang/hamiltonian-cycle.pl +0 -55
  15. package/examples/eyelang/n-queens.pl +0 -23
  16. package/examples/eyelang/output/dense-hamiltonian-cycle.pl +0 -4
  17. package/examples/eyelang/output/hamiltonian-cycle.pl +0 -4
  18. package/examples/eyelang/output/n-queens.pl +0 -93
  19. package/examples/eyelang/output/quine-mccluskey.pl +0 -3
  20. package/examples/eyelang/output/sat-dpll.pl +0 -5
  21. package/examples/eyelang/output/traveling-salesman.pl +0 -1
  22. package/examples/eyelang/quine-mccluskey.pl +0 -143
  23. package/examples/eyelang/sat-dpll.pl +0 -80
  24. package/examples/eyelang/traveling-salesman.pl +0 -64
  25. package/lib/eyelang/builtins/search.js +0 -519
  26. package/test/eyelang/conformance/cases/extension/042_n_queens_small.pl +0 -3
  27. package/test/eyelang/conformance/cases/extension/043_cnf_model.pl +0 -3
  28. package/test/eyelang/conformance/expected/extension/042_n_queens_small.out +0 -2
  29. package/test/eyelang/conformance/expected/extension/043_cnf_model.out +0 -1
package/README.md CHANGED
@@ -774,18 +774,19 @@ The Alma RDF Message Log example intentionally keeps the message log as a URL, b
774
774
 
775
775
  ## Built-ins
776
776
 
777
- Eyeling implements SWAP-style built-ins for the N3 engine across these namespaces. The authoritative machine-readable catalog is [`eyeling-builtins.ttl`](eyeling-builtins.ttl); this README lists the public names so users do not need to infer support from examples.
778
-
779
- | Namespace | Built-ins |
780
- |---|---|
781
- | `crypto:` | `sha`, `md5`, `sha256`, `sha512` |
782
- | `math:` | `equalTo`, `notEqualTo`, `greaterThan`, `lessThan`, `notLessThan`, `notGreaterThan`, `sum`, `product`, `difference`, `quotient`, `integerQuotient`, `remainder`, `rounded`, `exponentiation`, `absoluteValue`, `acos`, `asin`, `atan`, `sin`, `cos`, `tan`, `sinh`, `cosh`, `tanh`, `degrees`, `negation` |
783
- | `time:` | `day`, `hour`, `minute`, `month`, `second`, `timeZone`, `year`, `localTime` |
784
- | `list:` | `append`, `first`, `rest`, `iterate`, `last`, `memberAt`, `remove`, `member`, `in`, `length`, `notMember`, `reverse`, `sort`, `map`, `firstRest` |
785
- | `rdf:` | `first`, `rest` |
786
- | `log:` | `equalTo`, `notEqualTo`, `conjunction`, `conclusion`, `content`, `semantics`, `semanticsOrError`, `parsedAsN3`, `rawType`, `dtlit`, `langlit`, `implies`, `impliedBy`, `query`, `includes`, `notIncludes`, `collectAllIn`, `forAllIn`, `skolem`, `uri`, `trace`, `outputString` |
787
- | `string:` | `concatenation`, `contains`, `containsIgnoringCase`, `endsWith`, `startsWith`, `equalIgnoringCase`, `notEqualIgnoringCase`, `greaterThan`, `lessThan`, `notGreaterThan`, `notLessThan`, `matches`, `notMatches`, `replace`, `scrape`, `format`, `length`, `charAt`, `setCharAt` |
788
- | `dt:` | `datatype`, `lexicalForm`, `language`, `validForDatatype`, `invalidForDatatype`, `sameValueAs`, `differentValueFrom`, `canonicalLiteral` |
777
+ Eyeling implements **104 public SWAP-style built-in predicates** for the N3 engine across these namespaces. The authoritative machine-readable catalog is [`eyeling-builtins.ttl`](eyeling-builtins.ttl); this README lists the public names so users do not need to infer support from examples or internal dispatch code.
778
+
779
+ | Namespace | Count | Built-ins |
780
+ |---|---:|---|
781
+ | `crypto:` | 4 | `sha`, `md5`, `sha256`, `sha512` |
782
+ | `math:` | 26 | `equalTo`, `notEqualTo`, `greaterThan`, `lessThan`, `notLessThan`, `notGreaterThan`, `sum`, `product`, `difference`, `quotient`, `integerQuotient`, `remainder`, `rounded`, `exponentiation`, `absoluteValue`, `acos`, `asin`, `atan`, `sin`, `cos`, `tan`, `sinh`, `cosh`, `tanh`, `degrees`, `negation` |
783
+ | `time:` | 8 | `day`, `hour`, `minute`, `month`, `second`, `timeZone`, `year`, `localTime` |
784
+ | `list:` | 15 | `append`, `first`, `rest`, `iterate`, `last`, `memberAt`, `remove`, `member`, `in`, `length`, `notMember`, `reverse`, `sort`, `map`, `firstRest` |
785
+ | `rdf:` | 2 | `first`, `rest` |
786
+ | `log:` | 22 | `equalTo`, `notEqualTo`, `conjunction`, `conclusion`, `content`, `semantics`, `semanticsOrError`, `parsedAsN3`, `rawType`, `dtlit`, `langlit`, `implies`, `impliedBy`, `query`, `includes`, `notIncludes`, `collectAllIn`, `forAllIn`, `skolem`, `uri`, `trace`, `outputString` |
787
+ | `string:` | 19 | `concatenation`, `contains`, `containsIgnoringCase`, `endsWith`, `startsWith`, `equalIgnoringCase`, `notEqualIgnoringCase`, `greaterThan`, `lessThan`, `notGreaterThan`, `notLessThan`, `matches`, `notMatches`, `replace`, `scrape`, `format`, `length`, `charAt`, `setCharAt` |
788
+ | `dt:` | 8 | `datatype`, `lexicalForm`, `language`, `validForDatatype`, `invalidForDatatype`, `sameValueAs`, `differentValueFrom`, `canonicalLiteral` |
789
+ | **Total** | **104** | |
789
790
 
790
791
  The catalog marks each built-in with a coarse kind: `ex:Test`, `ex:Function`, `ex:Relation`, `ex:Generator`, `ex:IO`, `ex:Meta`, or `ex:SideEffect`.
791
792
 
@@ -818,20 +819,20 @@ Formula-aware built-ins make Eyeling useful for meta-reasoning. `log:includes`,
818
819
 
819
820
  ### eyelang built-ins
820
821
 
821
- The eyelang engine has its own built-in registry under `lib/eyelang/builtins/`. These are separate from the N3 namespaces above and are called as ordinary eyelang predicates. See the [eyelang language reference](docs/eyelang-language-reference.md#9-standard-built-in-predicates) for the portable profile. The bundled implementation currently registers 68 name/arity entries across 66 predicate names:
822
-
823
- | Family | Built-ins |
824
- |---|---|
825
- | Core and host | `eq/2`, `neq/2`, `local_time/1`, `difference/3` |
826
- | Arithmetic and comparison | `neg/2`, `abs/2`, `sin/2`, `cos/2`, `asin/2`, `acos/2`, `rounded/2`, `log/2`, `add/3`, `sub/3`, `mul/3`, `div/3`, `mod/3`, `min/3`, `pow/3`, `lt/2`, `gt/2`, `le/2`, `ge/2`, `between/3`, `smallest_divisor_from/3` |
827
- | Strings | `str_concat/3`, `contains/2`, `matches/2`, `matches/3`, `not_matches/2` |
828
- | Lists | `append/3`, `nth0/3`, `set_nth0/4`, `rest/2`, `member/2`, `select/3`, `not_member/2`, `reverse/2`, `length/2`, `sort/2` |
829
- | Aggregation | `findall/3`, `countall/2`, `sumall/3`, `aggregate_min/5`, `aggregate_max/5` |
830
- | Control | `not/1`, `once/1` |
831
- | Context terms | `holds/2`, `holds/3` |
832
- | Search and optimization helpers | `n_queens/2`, `weighted_hamiltonian_cycle/4`, `weighted_hamiltonian_path/4`, `hamiltonian_cycle/3`, `fixed_length_cycle/4`, `bounded_path/5`, `cnf_model/3`, `qm_prime_implicants/4`, `qm_minimal_cover/4` |
833
- | Numeric extension helpers | `extended_gcd/5`, `collatz_trajectory/2`, `kaprekar_steps/2`, `goldbach_pair/3` |
834
- | Matrix helpers | `matrix_sum/2`, `matrix_multiply/2`, `cholesky_decomposition/2`, `determinant/2`, `matrix_inv_triang/2`, `matrix_inversion/2` |
822
+ The eyelang engine has its own built-in registry under `lib/eyelang/builtins/`. These are separate from the N3 namespaces above and are called as ordinary eyelang predicates. See the [eyelang language reference](docs/eyelang-language-reference.md#9-standard-built-in-predicates) for the portable profile. The bundled implementation currently registers 59 name/arity entries across 57 predicate names:
823
+
824
+ | Family | Count | Built-ins |
825
+ |---|---:|---|
826
+ | Core and host | 4 | `eq/2`, `neq/2`, `local_time/1`, `difference/3` |
827
+ | Arithmetic and comparison | 21 | `neg/2`, `abs/2`, `sin/2`, `cos/2`, `asin/2`, `acos/2`, `rounded/2`, `log/2`, `add/3`, `sub/3`, `mul/3`, `div/3`, `mod/3`, `min/3`, `pow/3`, `lt/2`, `gt/2`, `le/2`, `ge/2`, `between/3`, `smallest_divisor_from/3` |
828
+ | Strings | 5 | `str_concat/3`, `contains/2`, `matches/2`, `matches/3`, `not_matches/2` |
829
+ | Lists | 10 | `append/3`, `nth0/3`, `set_nth0/4`, `rest/2`, `member/2`, `select/3`, `not_member/2`, `reverse/2`, `length/2`, `sort/2` |
830
+ | Aggregation | 5 | `findall/3`, `countall/2`, `sumall/3`, `aggregate_min/5`, `aggregate_max/5` |
831
+ | Control | 2 | `not/1`, `once/1` |
832
+ | Context terms | 2 | `holds/2`, `holds/3` |
833
+ | Numeric extension helpers | 4 | `extended_gcd/5`, `collatz_trajectory/2`, `kaprekar_steps/2`, `goldbach_pair/3` |
834
+ | Matrix helpers | 6 | `matrix_sum/2`, `matrix_multiply/2`, `cholesky_decomposition/2`, `determinant/2`, `matrix_inv_triang/2`, `matrix_inversion/2` |
835
+ | **Total** | **59** | |
835
836
 
836
837
  ## Custom built-ins
837
838
 
@@ -1128,6 +1129,7 @@ The repository contains more than two hundred N3 examples under `examples/`, eye
1128
1129
  | `examples/string-builtins-tests.n3` | String built-ins. |
1129
1130
  | `examples/math-builtins-tests.n3` | Numeric built-ins. |
1130
1131
  | `examples/rdf-messages.n3` | RDF Message Log replay. |
1132
+ | `examples/context-schema-audit.n3` | Quoted-context schema validation with `log:includes` and list arity checks. |
1131
1133
 
1132
1134
  ### Running all examples through tests
1133
1135
 
@@ -240,7 +240,7 @@ The CLI is output-oriented and uses `materialize/2` to decide what to print. Emb
240
240
  Add `-s` or `--stats` when you want lightweight solver counters on stderr without changing stdout:
241
241
 
242
242
  ```sh
243
- eyeling --engine eyelang -s examples/eyelang/n-queens.pl
243
+ eyeling --engine eyelang -s examples/eyelang/observability-log-correlation.pl
244
244
  ```
245
245
 
246
246
  The playground has matching `--stats` and `--proof` checkboxes, so browser runs can show the same counters or explanations like the CLI.
@@ -250,18 +250,7 @@ The playground has matching `--stats` and `--proof` checkboxes, so browser runs
250
250
 
251
251
  eyelang builtins are registered by name and arity in small modules under [`lib/eyelang/builtins`](../lib/eyelang/builtins). This keeps the runtime portable to Node.js and the browser while giving each builtin family a clear boundary. Builtins are enabled by normal predicate calls.
252
252
 
253
- The core builtin families cover unification, arithmetic, comparison, dates, strings, lists, aggregation, context terms, and search control. Additional reusable finite-search helpers are available only where bundled examples need them to avoid large amounts of repetitive generate-and-test code. These helpers are deliberately general relations rather than shortcuts tied to a particular example name. For example:
254
-
255
- ```prolog
256
- answer(Queens) :-
257
- n_queens(8, Queens).
258
-
259
- best(Cycle, Cost) :-
260
- cities(Cities),
261
- weighted_hamiltonian_cycle(edge, Cities, Cycle, Cost).
262
- ```
263
-
264
- The reusable search and numeric helpers include `n_queens/2`, Hamiltonian path/cycle helpers, `bounded_path/5`, `cnf_model/3`, Quine-McCluskey helpers, number-theory helpers such as `extended_gcd/5`, and matrix helpers such as `matrix_multiply/2`. These helpers are extension builtins of this implementation; [the eyelang language reference](eyelang-language-reference.md) defines the portable core and standard builtin profile. The complete bundled implementation list is kept in the top-level [README built-ins section](../README.md#built-ins-1), and the regression suite checks that table against the actual runtime registry.
253
+ The builtin families cover unification, arithmetic, comparison, dates, strings, lists, aggregation, context terms, search control, number-theory helpers, and matrix helpers. The previous finite-search helper module has been removed because those predicates were too example-specific to be reusable. Examples that are still practical with ordinary relations and reusable list/arithmetic builtins have been rewritten in that style; only the examples that depended on non-portable shortcuts were dropped. The complete bundled implementation list is kept in the top-level [README built-ins section](../README.md#built-ins-1), and the regression suite checks that table against the actual runtime registry.
265
254
 
266
255
  To add a builtin, create or extend a module with `register(registry)` and call `registry.add(name, arity, handler, options)`. The default registry is assembled in [`lib/eyelang/builtins/registry.js`](../lib/eyelang/builtins/registry.js). Builtins that are only safe for specific argument modes should provide a `ready` predicate and `fallbackWhenNotReady: true`, so user-defined clauses remain visible until the builtin is applicable.
267
256
 
@@ -300,6 +289,8 @@ Use `holds/2` when you want to match the member term directly, for example `name
300
289
 
301
290
  `matches/3` can create context data from named regular-expression captures, which is useful when text logs or messages need to become facts before later rules inspect them with `holds/2` or `holds/3`. See [`observability-log-correlation.pl`](../examples/eyelang/observability-log-correlation.pl) for a complete log-correlation example.
302
291
 
292
+ The N3 counterpart of the context schema audit lives at [`examples/context-schema-audit.n3`](../examples/context-schema-audit.n3) with golden output in [`examples/output/context-schema-audit.md`](../examples/output/context-schema-audit.md).
293
+
303
294
 
304
295
  ## Example catalog
305
296
 
@@ -318,7 +309,7 @@ The repository includes examples for recursion, graph reachability, finite searc
318
309
  | [`annotation.pl`](../examples/eyelang/annotation.pl) | Derives facts from quoted annotation data. | [`output/annotation.pl`](../examples/eyelang/output/annotation.pl) |
319
310
  | [`auroracare.pl`](../examples/eyelang/auroracare.pl) | Evaluates purpose-based medical data access scenarios. | [`output/auroracare.pl`](../examples/eyelang/output/auroracare.pl) |
320
311
  | [`backward.pl`](../examples/eyelang/backward.pl) | Shows a backward-rule pattern as a goal-directed numeric rule. | [`output/backward.pl`](../examples/eyelang/output/backward.pl) |
321
- | [`basic-monadic.pl`](../examples/eyelang/basic-monadic.pl) | Runs a monadic benchmark over generated inputs. | [`output/basic-monadic.pl`](../examples/eyelang/output/basic-monadic.pl) |
312
+ | [`basic-monadic.pl`](../examples/eyelang/basic-monadic.pl) | Runs the basic monadic benchmark with explicit indexed edge joins instead of specialized search builtins. | [`output/basic-monadic.pl`](../examples/eyelang/output/basic-monadic.pl) |
322
313
  | [`bayes-diagnosis.pl`](../examples/eyelang/bayes-diagnosis.pl) | Computes scaled Bayesian diagnosis posteriors. | [`output/bayes-diagnosis.pl`](../examples/eyelang/output/bayes-diagnosis.pl) |
323
314
  | [`bayes-therapy.pl`](../examples/eyelang/bayes-therapy.pl) | Ranks therapies using Bayesian disease likelihoods. | [`output/bayes-therapy.pl`](../examples/eyelang/output/bayes-therapy.pl) |
324
315
  | [`beam-deflection.pl`](../examples/eyelang/beam-deflection.pl) | Computes cantilever beam deflection. | [`output/beam-deflection.pl`](../examples/eyelang/output/beam-deflection.pl) |
@@ -349,7 +340,6 @@ The repository includes examples for recursion, graph reachability, finite searc
349
340
  | [`deep-taxonomy-10000.pl`](../examples/eyelang/deep-taxonomy-10000.pl) | Stress-tests recursive taxonomy depth 10000. | [`output/deep-taxonomy-10000.pl`](../examples/eyelang/output/deep-taxonomy-10000.pl) |
350
341
  | [`deep-taxonomy-100000.pl`](../examples/eyelang/deep-taxonomy-100000.pl) | Stress-tests recursive taxonomy depth 100000. | [`output/deep-taxonomy-100000.pl`](../examples/eyelang/output/deep-taxonomy-100000.pl) |
351
342
  | [`delfour.pl`](../examples/eyelang/delfour.pl) | Derives shopping and authorization recommendations. | [`output/delfour.pl`](../examples/eyelang/output/delfour.pl) |
352
- | [`dense-hamiltonian-cycle.pl`](../examples/eyelang/dense-hamiltonian-cycle.pl) | Searches a dense Hamiltonian cycle with aggregate minimization. | [`output/dense-hamiltonian-cycle.pl`](../examples/eyelang/output/dense-hamiltonian-cycle.pl) |
353
343
  | [`deontic-logic.pl`](../examples/eyelang/deontic-logic.pl) | Reports obligations, prohibitions, and violations. | [`output/deontic-logic.pl`](../examples/eyelang/output/deontic-logic.pl) |
354
344
  | [`derived-backward-rule.pl`](../examples/eyelang/derived-backward-rule.pl) | Derives an inverse-property backward rule from rule data. | [`output/derived-backward-rule.pl`](../examples/eyelang/output/derived-backward-rule.pl) |
355
345
  | [`derived-rule.pl`](../examples/eyelang/derived-rule.pl) | Derives conclusions from rule data. | [`output/derived-rule.pl`](../examples/eyelang/output/derived-rule.pl) |
@@ -389,7 +379,6 @@ The repository includes examples for recursion, graph reachability, finite searc
389
379
  | [`gray-code-counter.pl`](../examples/eyelang/gray-code-counter.pl) | Generates Gray-code counter states. | [`output/gray-code-counter.pl`](../examples/eyelang/output/gray-code-counter.pl) |
390
380
  | [`greatest-lower-bound-uniqueness.pl`](../examples/eyelang/greatest-lower-bound-uniqueness.pl) | Shows uniqueness of greatest lower bounds in a finite order instance. | [`output/greatest-lower-bound-uniqueness.pl`](../examples/eyelang/output/greatest-lower-bound-uniqueness.pl) |
391
381
  | [`group-inverse-uniqueness.pl`](../examples/eyelang/group-inverse-uniqueness.pl) | Shows uniqueness of inverses in a finite group instance. | [`output/group-inverse-uniqueness.pl`](../examples/eyelang/output/group-inverse-uniqueness.pl) |
392
- | [`hamiltonian-cycle.pl`](../examples/eyelang/hamiltonian-cycle.pl) | Finds a Hamiltonian cycle. | [`output/hamiltonian-cycle.pl`](../examples/eyelang/output/hamiltonian-cycle.pl) |
393
382
  | [`hamiltonian-path.pl`](../examples/eyelang/hamiltonian-path.pl) | Finds a Hamiltonian path. | [`output/hamiltonian-path.pl`](../examples/eyelang/output/hamiltonian-path.pl) |
394
383
  | [`hamming-code.pl`](../examples/eyelang/hamming-code.pl) | Corrects a single-bit Hamming word. | [`output/hamming-code.pl`](../examples/eyelang/output/hamming-code.pl) |
395
384
  | [`hanoi.pl`](../examples/eyelang/hanoi.pl) | Derives the Towers of Hanoi moves. | [`output/hanoi.pl`](../examples/eyelang/output/hanoi.pl) |
@@ -407,7 +396,6 @@ The repository includes examples for recursion, graph reachability, finite searc
407
396
  | [`matrix.pl`](../examples/eyelang/matrix.pl) | Runs matrix operations over sample inputs. | [`output/matrix.pl`](../examples/eyelang/output/matrix.pl) |
408
397
  | [`microgrid-dispatch.pl`](../examples/eyelang/microgrid-dispatch.pl) | Plans microgrid dispatch and reserve. | [`output/microgrid-dispatch.pl`](../examples/eyelang/output/microgrid-dispatch.pl) |
409
398
  | [`monkey-bananas.pl`](../examples/eyelang/monkey-bananas.pl) | Solves the monkey-and-bananas puzzle. | [`output/monkey-bananas.pl`](../examples/eyelang/output/monkey-bananas.pl) |
410
- | [`n-queens.pl`](../examples/eyelang/n-queens.pl) | Searches for N-queens placements. | [`output/n-queens.pl`](../examples/eyelang/output/n-queens.pl) |
411
399
  | [`network-sla.pl`](../examples/eyelang/network-sla.pl) | Checks network path SLA compliance. | [`output/network-sla.pl`](../examples/eyelang/output/network-sla.pl) |
412
400
  | [`newton-raphson.pl`](../examples/eyelang/newton-raphson.pl) | Finds roots by Newton-Raphson iteration. | [`output/newton-raphson.pl`](../examples/eyelang/output/newton-raphson.pl) |
413
401
  | [`nixon-diamond.pl`](../examples/eyelang/nixon-diamond.pl) | Reports the classic Nixon-diamond conflict. | [`output/nixon-diamond.pl`](../examples/eyelang/output/nixon-diamond.pl) |
@@ -423,10 +411,8 @@ The repository includes examples for recursion, graph reachability, finite searc
423
411
  | [`polynomial.pl`](../examples/eyelang/polynomial.pl) | Finds complex integer polynomial roots. | [`output/polynomial.pl`](../examples/eyelang/output/polynomial.pl) |
424
412
  | [`proof-contrapositive.pl`](../examples/eyelang/proof-contrapositive.pl) | Models proof by contrapositive. | [`output/proof-contrapositive.pl`](../examples/eyelang/output/proof-contrapositive.pl) |
425
413
  | [`quadratic-formula.pl`](../examples/eyelang/quadratic-formula.pl) | Solves sample quadratic equations. | [`output/quadratic-formula.pl`](../examples/eyelang/output/quadratic-formula.pl) |
426
- | [`quine-mccluskey.pl`](../examples/eyelang/quine-mccluskey.pl) | Minimizes Boolean terms with Quine-McCluskey. | [`output/quine-mccluskey.pl`](../examples/eyelang/output/quine-mccluskey.pl) |
427
414
  | [`radioactive-decay.pl`](../examples/eyelang/radioactive-decay.pl) | Computes radioactive decay over time. | [`output/radioactive-decay.pl`](../examples/eyelang/output/radioactive-decay.pl) |
428
415
  | [`riemann-hypothesis.pl`](../examples/eyelang/riemann-hypothesis.pl) | Checks a finite catalogue of non-trivial zeta zeros against the Riemann-hypothesis condition. | [`output/riemann-hypothesis.pl`](../examples/eyelang/output/riemann-hypothesis.pl) |
429
- | [`sat-dpll.pl`](../examples/eyelang/sat-dpll.pl) | Solves a finite SAT instance. | [`output/sat-dpll.pl`](../examples/eyelang/output/sat-dpll.pl) |
430
416
  | [`security-incident-correlation.pl`](../examples/eyelang/security-incident-correlation.pl) | Correlates security incidents across signals. | [`output/security-incident-correlation.pl`](../examples/eyelang/output/security-incident-correlation.pl) |
431
417
  | [`service-impact.pl`](../examples/eyelang/service-impact.pl) | Analyzes service impact over cyclic dependencies. | [`output/service-impact.pl`](../examples/eyelang/output/service-impact.pl) |
432
418
  | [`sieve.pl`](../examples/eyelang/sieve.pl) | Enumerates primes with a sieve-style program. | [`output/sieve.pl`](../examples/eyelang/output/sieve.pl) |
@@ -436,7 +422,6 @@ The repository includes examples for recursion, graph reachability, finite searc
436
422
  | [`socrates.pl`](../examples/eyelang/socrates.pl) | Derives that Socrates is mortal. | [`output/socrates.pl`](../examples/eyelang/output/socrates.pl) |
437
423
  | [`statistics-summary.pl`](../examples/eyelang/statistics-summary.pl) | Computes population statistics for a sample. | [`output/statistics-summary.pl`](../examples/eyelang/output/statistics-summary.pl) |
438
424
  | [`superdense-coding.pl`](../examples/eyelang/superdense-coding.pl) | Models superdense-coding bit transmission. | [`output/superdense-coding.pl`](../examples/eyelang/output/superdense-coding.pl) |
439
- | [`traveling-salesman.pl`](../examples/eyelang/traveling-salesman.pl) | Finds an optimal traveling-salesman tour. | [`output/traveling-salesman.pl`](../examples/eyelang/output/traveling-salesman.pl) |
440
425
  | [`trust-flow-provenance-threshold.pl`](../examples/eyelang/trust-flow-provenance-threshold.pl) | Classifies message trust from provenance confidence scores. | [`output/trust-flow-provenance-threshold.pl`](../examples/eyelang/output/trust-flow-provenance-threshold.pl) |
441
426
  | [`turing.pl`](../examples/eyelang/turing.pl) | Simulates a binary-increment Turing machine. | [`output/turing.pl`](../examples/eyelang/output/turing.pl) |
442
427
  | [`vector-similarity.pl`](../examples/eyelang/vector-similarity.pl) | Computes dot product, norm, and cosine similarity. | [`output/vector-similarity.pl`](../examples/eyelang/output/vector-similarity.pl) |
@@ -498,7 +483,7 @@ eyeling --engine eyelang --help
498
483
  Useful profiling smoke test:
499
484
 
500
485
  ```sh
501
- eyeling --engine eyelang -s examples/eyelang/n-queens.pl > /dev/null
486
+ eyeling --engine eyelang -s examples/eyelang/observability-log-correlation.pl > /dev/null
502
487
  ```
503
488
 
504
489
  For a release:
@@ -450,6 +450,8 @@ The first goal can yield `holds((name(alice, "Alice"), knows(alice, bob)), name(
450
450
 
451
451
  `holds/3` is the appropriate form for schema-style introspection because it exposes the predicate name and all arguments without assuming a fixed arity. For example, a single rule can inspect `heartbeat`, `source(sensor17)`, `temperature(sensor17, 38)`, and `signature(sensor17, sha256, Hash, Time)` as `heartbeat/0`, `source/1`, `temperature/2`, and `signature/4`; see [`context-schema-audit.pl`](../examples/eyelang/context-schema-audit.pl).
452
452
 
453
+ The N3 example [`context-schema-audit.n3`](../examples/context-schema-audit.n3) shows the same idea in quoted graph form: members are encoded as predicates with RDF-list argument objects, then `log:includes` and `list:length` expose `Name + Arity` for schema checking.
454
+
453
455
  ### 9.10 Search control
454
456
 
455
457
  | Built-in | Meaning |
@@ -471,7 +473,7 @@ An extension built-in SHOULD obey the same surface-language discipline as standa
471
473
  - it SHOULD document its intended modes, especially which arguments must be ground before it runs deterministically;
472
474
  - it MUST NOT change the meaning of ordinary facts, rules, unification, or standard built-ins.
473
475
 
474
- For example, an implementation may include extension modules for number-theory algorithms, graph search, or matrix operations. Those modules may be valuable and may make example programs much faster, but their predicate names, arities, algorithms, and modes are implementation-defined unless they are separately standardized.
476
+ For example, an implementation may include extension modules for number-theory algorithms, matrix operations, or host-specific integrations. Those modules may be valuable and may make example programs much faster, but their predicate names, arities, algorithms, and modes are implementation-defined unless they are separately standardized.
475
477
 
476
478
  An implementation that provides explanation output SHOULD make extension built-ins explainable at least as opaque successful or failed built-in calls, so that proof traces do not incorrectly report "no clauses" for a host-provided relation.
477
479
 
@@ -0,0 +1,72 @@
1
+ # Context schema audit
2
+ #
3
+ # This is the N3 counterpart of the eyelang context-schema-audit example. Each
4
+ # message carries a quoted context graph whose members encode an event name as
5
+ # the predicate and its arguments as an RDF list. A generic rule uses
6
+ # log:includes to inspect those quoted contexts, list:length to compute arity,
7
+ # and schema rules to flag unexpected or wrong-arity members.
8
+
9
+ @prefix log: <http://www.w3.org/2000/10/swap/log#>.
10
+ @prefix list: <http://www.w3.org/2000/10/swap/list#>.
11
+ @prefix math: <http://www.w3.org/2000/10/swap/math#>.
12
+ @prefix : <http://example.org/#>.
13
+
14
+ :msg_ok :context {
15
+ :entry :heartbeat ().
16
+ :entry :source (:sensor17).
17
+ :entry :temperature (:sensor17 38).
18
+ :entry :gps (:sensor17 51 4).
19
+ :entry :signature (:sensor17 :sha256 "9f86d081" "2026-06-18T09:30:00Z").
20
+ }.
21
+
22
+ :msg_bad :context {
23
+ :entry :heartbeat ().
24
+ :entry :source (:sensor18).
25
+ :entry :temperature (:sensor18 99).
26
+ :entry :gps (:sensor18 51).
27
+ :entry :tampered (:sensor18).
28
+ }.
29
+
30
+ :heartbeat :allowedArity 0.
31
+ :source :allowedArity 1.
32
+ :temperature :allowedArity 2.
33
+ :gps :allowedArity 3.
34
+ :signature :allowedArity 4.
35
+
36
+ {
37
+ ?Message :context ?Context.
38
+ ?Context log:includes { :entry ?Name ?Args }.
39
+ ?Args list:length ?Arity.
40
+ }
41
+ =>
42
+ {
43
+ ?Message :contextShape (?Name ?Arity).
44
+ }.
45
+
46
+ {
47
+ ?Message :contextShape (?Name ?Arity).
48
+ ?Name :allowedArity ?AllowedArity.
49
+ ?Arity math:notEqualTo ?AllowedArity.
50
+ }
51
+ =>
52
+ {
53
+ ?Message :schemaViolation (?Name ?Arity).
54
+ }.
55
+
56
+ {
57
+ ?Message :contextShape (?Name ?Arity).
58
+ 1 log:notIncludes { ?Name :allowedArity ?AnyArity. }.
59
+ }
60
+ =>
61
+ {
62
+ ?Message :schemaViolation (?Name ?Arity).
63
+ }.
64
+
65
+ {
66
+ :msg_bad :schemaViolation (:gps 2).
67
+ :msg_bad :schemaViolation (:tampered 1).
68
+ }
69
+ =>
70
+ {
71
+ :report log:outputString "# Context schema audit\n\n## Source files\n\n- [N3 rules](../context-schema-audit.n3)\n\n## Entailment\nThe audit inspects quoted message contexts and finds two schema violations in `msg_bad`: `gps/2` should have arity 3, and `tampered/1` is not an allowed context member.\n\n## Explanation\nEach context member is encoded as a quoted triple whose predicate is the member name and whose object is the argument list. The generic audit rule uses `log:includes` to bind the member name and argument list, then `list:length` to compute the arity. Allowed shapes are declared once as `:allowedArity` facts, so the same rule can validate zero-, unary-, binary-, ternary-, and four-argument members without writing a separate rule per predicate.\n".
72
+ }.
@@ -10014,5 +10014,19 @@ edge(i48, i89, i48).
10014
10014
  edge(i26, i42, i54).
10015
10015
 
10016
10016
  % Derivation rules: each rule below contributes one logical step toward the displayed results.
10017
- cycle(R, Cycle) :-
10018
- fixed_length_cycle(edge, 10, R, Cycle).
10017
+ %
10018
+ % Keep this example independent from specialized search builtins by spelling out the
10019
+ % ten-edge monadic benchmark directly. The left-to-right shape binds the next
10020
+ % node before the next edge lookup, so the ordinary predicate indexes can keep the
10021
+ % query finite and selective.
10022
+ cycle(R, [D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D0]) :-
10023
+ edge(D0, R, D1),
10024
+ edge(D1, R, D2),
10025
+ edge(D2, R, D3),
10026
+ edge(D3, R, D4),
10027
+ edge(D4, R, D5),
10028
+ edge(D5, R, D6),
10029
+ edge(D6, R, D7),
10030
+ edge(D7, R, D8),
10031
+ edge(D8, R, D9),
10032
+ edge(D9, R, D0).