eyelang 0.5.1 → 0.5.2
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 +7 -7
- package/book-assets/cli-observation-loop.svg +1 -1
- package/book-assets/example-landscape.svg +1 -1
- package/book-assets/laboratory-progression.svg +1 -1
- package/book-assets/part-4-craft.svg +1 -1
- package/book-assets/rdf-adapter-pipeline.svg +3 -3
- package/book-assets/reference-navigation.svg +1 -1
- package/book-assets/review-lenses.svg +1 -1
- package/book-assets/title-page.svg +2 -2
- package/conformance-report.md +1 -1
- package/examples/book/README.md +4 -4
- package/examples/book/chapter-01/01-parent.pl +1 -1
- package/examples/book/chapter-01/02-child.pl +1 -1
- package/examples/book/chapter-02/01-measurement.pl +1 -1
- package/examples/book/chapter-02/02-label.pl +1 -1
- package/examples/book/chapter-03/01-eligible.pl +1 -1
- package/examples/book/chapter-03/02-adult.pl +1 -1
- package/examples/book/chapter-03/03-can_enter.pl +1 -1
- package/examples/book/chapter-03/04-high_score.pl +1 -1
- package/examples/book/chapter-03/05-parent.pl +1 -1
- package/examples/book/chapter-03/06-ancestor.pl +1 -1
- package/examples/book/chapter-03/07-different.pl +1 -1
- package/examples/book/chapter-03/08-has_parent.pl +1 -1
- package/examples/book/chapter-03/09-program.pl +1 -1
- package/examples/book/chapter-03/10-closed.pl +1 -1
- package/examples/book/chapter-03/11-p.pl +1 -1
- package/examples/book/chapter-04/01-path.pl +1 -1
- package/examples/book/chapter-05/01-first.pl +1 -1
- package/examples/book/chapter-05/02-reverse_acc.pl +1 -1
- package/examples/book/chapter-06/01-next.pl +1 -1
- package/examples/book/chapter-06/02-safe_reading.pl +1 -1
- package/examples/book/chapter-06/03-square.pl +1 -1
- package/examples/book/chapter-06/04-factorial.pl +1 -1
- package/examples/book/chapter-07/01-allowed.pl +1 -1
- package/examples/book/chapter-07/02-all_tests_pass.pl +1 -1
- package/examples/book/chapter-08/01-findall.pl +1 -1
- package/examples/book/chapter-08/02-outgoing_costs.pl +1 -1
- package/examples/book/chapter-08/03-best_route.pl +1 -1
- package/examples/book/chapter-09/01-functor.pl +1 -1
- package/examples/book/chapter-09/02-normalized.pl +1 -1
- package/examples/book/chapter-09/03-message.pl +1 -1
- package/examples/book/chapter-10/01-plan.pl +1 -1
- package/examples/book/chapter-11/01-why.pl +1 -1
- package/examples/book/chapter-12/01-invalid_probability.pl +1 -1
- package/examples/book/chapter-12/02-invalid_assignment.pl +1 -1
- package/examples/book/chapter-14/01-heating.pl +1 -1
- package/examples/book/chapter-15/01-rdf.pl +1 -1
- package/examples/book/chapter-16/01-socket.pl +1 -1
- package/examples/book/chapter-16/02-socket-2.pl +1 -1
- package/examples/book/chapter-17/01-path.pl +1 -1
- package/examples/book/chapter-17/02-adult.pl +1 -1
- package/examples/book/chapter-17/03-bad_member.pl +1 -1
- package/examples/book/chapter-17/04-item.pl +1 -1
- package/examples/book/chapter-18/01-routeable.pl +1 -1
- package/examples/book/chapter-18/02-routeable-2.pl +1 -1
- package/examples/book/chapter-18/03-prefix.pl +1 -1
- package/examples/book/chapter-18/04-candidate_pair.pl +1 -1
- package/examples/book/chapter-18/05-compatible_pair.pl +1 -1
- package/examples/book/chapter-19/01-factorial.pl +1 -1
- package/examples/book/chapter-19/02-invalid_limits.pl +1 -1
- package/examples/book/chapter-20/01-connected.pl +1 -1
- package/examples/book/chapter-20/02-within_thermal_limits.pl +1 -1
- package/examples/book/chapter-20/03-search.pl +1 -1
- package/examples/book/chapter-21/01-grandparent.pl +1 -1
- package/examples/book/chapter-21/02-loop_edge.pl +1 -1
- package/examples/book/chapter-21/03-eligible.pl +1 -1
- package/examples/book/chapter-21/04-grows.pl +1 -1
- package/examples/book/chapter-22/01-tree.pl +1 -1
- package/examples/book/chapter-22/02-tree_member.pl +1 -1
- package/examples/book/chapter-22/03-mirror.pl +1 -1
- package/examples/book/chapter-22/04-evaluate.pl +1 -1
- package/examples/book/chapter-22/05-lookup.pl +1 -1
- package/examples/book/chapter-22/06-simplify.pl +1 -1
- package/examples/book/chapter-23/01-adult.pl +1 -1
- package/examples/book/chapter-23/02-adult-2.pl +1 -1
- package/examples/book/chapter-23/03-can_board.pl +1 -1
- package/examples/book/chapter-23/04-traveler_in_good_standing.pl +1 -1
- package/examples/book/chapter-23/05-connection.pl +1 -1
- package/examples/book/chapter-23/06-rail_connection.pl +1 -1
- package/examples/book/chapter-23/07-sum_numbers.pl +1 -1
- package/examples/book/chapter-23/08-sum_numbers_acc.pl +1 -1
- package/examples/book/chapter-24/01-simple_path.pl +1 -1
- package/examples/book/chapter-24/02-reachable.pl +1 -1
- package/examples/book/chapter-24/03-best_plan.pl +1 -1
- package/examples/book/chapter-25/01-person.pl +1 -1
- package/examples/book/chapter-25/02-active_badge.pl +1 -1
- package/examples/book/chapter-25/03-in_good_standing.pl +1 -1
- package/examples/book/chapter-25/04-incompatible_status.pl +1 -1
- package/examples/book/chapter-26/01-mortal.pl +1 -1
- package/examples/book/chapter-26/02-triple.pl +1 -1
- package/examples/book/chapter-26/03-edge.pl +1 -1
- package/examples/book/chapter-27/01-natural.pl +1 -1
- package/examples/book/chapter-27/02-list_length.pl +1 -1
- package/examples/book/chapter-27/03-reverse_acc.pl +1 -1
- package/examples/book/chapter-28/01-program.pl +1 -1
- package/examples/book/chapter-28/02-triangle.pl +1 -1
- package/examples/book/chapter-28/03-rectangle.pl +1 -1
- package/examples/book/chapter-28/04-preserves_combine.pl +1 -1
- package/examples/book/chapter-29/01-noncommuting_pair.pl +1 -1
- package/examples/book/chapter-32/01-eligible.pl +1 -1
- package/examples/book/chapter-32/02-eligible-2.pl +1 -1
- package/examples/book/chapter-33/01-assigned_badge.pl +1 -1
- package/examples/book/chapter-33/02-source_role.pl +1 -1
- package/examples/book/chapter-33/03-chosen_pair.pl +1 -1
- package/examples/book/chapter-33/04-path.pl +1 -1
- package/examples/book/chapter-33/05-unregistered.pl +1 -1
- package/examples/book/chapter-33/06-step.pl +1 -1
- package/examples/book/chapter-33/07-depends.pl +1 -1
- package/examples/book/chapter-33/08-within_limit.pl +1 -1
- package/examples/book/chapter-33/09-invalid_badge_assignment.pl +1 -1
- package/examples/book/chapter-33/10-theory_version.pl +1 -1
- package/examples/book/chapter-34/01-travel_status.pl +1 -1
- package/examples/book/chapter-34/02-require_route.pl +1 -1
- package/examples/book/chapter-34/03-regional_total.pl +1 -1
- package/examples/book/chapter-35/01-term_shape.pl +1 -1
- package/examples/book/chapter-36/01-program.pl +1 -1
- package/examples/book/chapter-36/02-program-2.pl +1 -1
- package/examples/book/chapter-36/03-program-3.pl +1 -1
- package/examples/book/chapter-37/01-write_event.pl +1 -1
- package/examples/book/chapter-38/01-city.pl +1 -1
- package/examples/cdcl-sat-solver.pl +2 -2
- package/examples/collatz-1000.pl +1 -1
- package/examples/equality-saturation.pl +1 -1
- package/examples/existential-rule.pl +1 -1
- package/examples/herbrand-semantics.pl +1 -1
- package/examples/herbrand-witnesses.pl +1 -1
- package/examples/iso-integer-arithmetic.pl +1 -1
- package/examples/knowledge-engineering-alignment-flow.pl +1 -1
- package/examples/language.pl +2 -2
- package/examples/law-of-cosines.pl +1 -1
- package/examples/linear-logic-resources.pl +1 -1
- package/examples/markov-logic-network.pl +1 -1
- package/examples/matrix-noncommutativity.pl +1 -1
- package/examples/partial-evaluator.pl +1 -1
- package/examples/peano-calculus.pl +1 -1
- package/examples/prime-range.pl +1 -1
- package/examples/register-allocation.pl +1 -1
- package/examples/route-planning.pl +1 -1
- package/examples/sat-solver-dpll.pl +1 -1
- package/examples/symbolic-derivative.pl +1 -1
- package/examples/term-tools.pl +1 -1
- package/examples/trust-flow-provenance-threshold.pl +1 -1
- package/examples/vector-similarity.pl +1 -1
- package/examples/web-names.pl +1 -1
- package/examples/workplace-compliance.pl +1 -1
- package/index.d.ts +68 -68
- package/index.js +1 -1
- package/package.json +2 -2
- package/playground.html +10 -10
- package/src/cli.js +4 -4
- package/src/explain.js +4 -4
- package/src/index.js +4 -4
- package/src/iso.js +1 -1
- package/src/library.js +7 -7
- package/src/parser.js +1 -1
- package/src/playground-worker.js +2 -2
- package/src/solver.js +4 -4
- package/src/term.js +1 -1
- package/test/conformance/README.md +6 -6
- package/test/conformance/THIRD_PARTY.md +4 -4
- package/test/conformance/cases/iso/logtalk_abolish.pl +1 -1
- package/test/conformance/cases/iso/logtalk_arg_unification.pl +1 -1
- package/test/conformance/cases/iso/logtalk_assert_order.pl +1 -1
- package/test/conformance/cases/iso/logtalk_atom_chars.pl +1 -1
- package/test/conformance/cases/iso/logtalk_atom_codes.pl +1 -1
- package/test/conformance/cases/iso/logtalk_atom_concat.pl +1 -1
- package/test/conformance/cases/iso/logtalk_atom_length.pl +1 -1
- package/test/conformance/cases/iso/logtalk_bagof.pl +1 -1
- package/test/conformance/cases/iso/logtalk_char_code.pl +1 -1
- package/test/conformance/cases/iso/logtalk_clause.pl +1 -1
- package/test/conformance/cases/iso/logtalk_compare_standard_order.pl +1 -1
- package/test/conformance/cases/iso/logtalk_copy_term_semantics.pl +1 -1
- package/test/conformance/cases/iso/logtalk_current_predicate.pl +1 -1
- package/test/conformance/cases/iso/logtalk_current_streams.pl +1 -1
- package/test/conformance/cases/iso/logtalk_findall.pl +1 -1
- package/test/conformance/cases/iso/logtalk_number_chars.pl +1 -1
- package/test/conformance/cases/iso/logtalk_number_codes.pl +1 -1
- package/test/conformance/cases/iso/logtalk_occurs_check.pl +1 -1
- package/test/conformance/cases/iso/logtalk_once.pl +1 -1
- package/test/conformance/cases/iso/logtalk_operators.pl +1 -1
- package/test/conformance/cases/iso/logtalk_prolog_flags.pl +1 -1
- package/test/conformance/cases/iso/logtalk_repeat.pl +1 -1
- package/test/conformance/cases/iso/logtalk_retract.pl +1 -1
- package/test/conformance/cases/iso/logtalk_setof.pl +1 -1
- package/test/conformance/cases/iso/logtalk_sub_atom.pl +1 -1
- package/test/conformance/cases/iso/logtalk_term_comparison.pl +1 -1
- package/test/conformance/cases/iso/logtalk_term_variables.pl +1 -1
- package/test/conformance/cases/iso/logtalk_univ.pl +1 -1
- package/test/conformance/cases/strings/064_reusable_string_builtins.pl +3 -3
- package/test/conformance/cases/strings/071_string_edges.pl +1 -1
- package/test/conformance/errors/iso/logtalk_abolish_arity_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_abolish_bad_indicator.pl +1 -1
- package/test/conformance/errors/iso/logtalk_abolish_name_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_abolish_negative_arity.pl +1 -1
- package/test/conformance/errors/iso/logtalk_abolish_unbound.pl +1 -1
- package/test/conformance/errors/iso/logtalk_abolish_unbound_arity.pl +1 -1
- package/test/conformance/errors/iso/logtalk_arg_index_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_arg_number.pl +1 -1
- package/test/conformance/errors/iso/logtalk_asserta_bad_body.pl +1 -1
- package/test/conformance/errors/iso/logtalk_asserta_noncallable.pl +1 -1
- package/test/conformance/errors/iso/logtalk_assertz_noncallable.pl +1 -1
- package/test/conformance/errors/iso/logtalk_atom_chars_atom_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_atom_chars_character_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_atom_chars_improper.pl +1 -1
- package/test/conformance/errors/iso/logtalk_atom_chars_list_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_atom_chars_unbound.pl +1 -1
- package/test/conformance/errors/iso/logtalk_atom_codes_atom_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_atom_codes_bad_code.pl +1 -1
- package/test/conformance/errors/iso/logtalk_atom_codes_integer_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_atom_codes_list_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_atom_codes_unbound.pl +1 -1
- package/test/conformance/errors/iso/logtalk_atom_concat_left_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_atom_concat_right_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_atom_concat_unbound.pl +1 -1
- package/test/conformance/errors/iso/logtalk_atom_concat_whole_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_atom_length_atom_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_atom_length_integer_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_atom_length_negative.pl +1 -1
- package/test/conformance/errors/iso/logtalk_atom_length_unbound.pl +1 -1
- package/test/conformance/errors/iso/logtalk_bagof_improper.pl +1 -1
- package/test/conformance/errors/iso/logtalk_bagof_nonlist.pl +1 -1
- package/test/conformance/errors/iso/logtalk_char_code_character_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_char_code_integer_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_char_code_negative.pl +1 -1
- package/test/conformance/errors/iso/logtalk_char_code_number_character.pl +1 -1
- package/test/conformance/errors/iso/logtalk_char_code_unbound.pl +1 -1
- package/test/conformance/errors/iso/logtalk_clause_noncallable_body.pl +1 -1
- package/test/conformance/errors/iso/logtalk_clause_noncallable_head.pl +1 -1
- package/test/conformance/errors/iso/logtalk_compare_order_domain.pl +1 -1
- package/test/conformance/errors/iso/logtalk_compare_order_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_current_flag_compound.pl +1 -1
- package/test/conformance/errors/iso/logtalk_current_flag_name_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_current_flag_unknown.pl +1 -1
- package/test/conformance/errors/iso/logtalk_current_input_bad_stream.pl +1 -1
- package/test/conformance/errors/iso/logtalk_current_op_bad_specifier.pl +1 -1
- package/test/conformance/errors/iso/logtalk_current_op_high_priority.pl +1 -1
- package/test/conformance/errors/iso/logtalk_current_output_bad_stream.pl +1 -1
- package/test/conformance/errors/iso/logtalk_current_predicate_bad_name.pl +1 -1
- package/test/conformance/errors/iso/logtalk_current_predicate_negative_arity.pl +1 -1
- package/test/conformance/errors/iso/logtalk_current_predicate_scalar.pl +1 -1
- package/test/conformance/errors/iso/logtalk_findall_improper.pl +1 -1
- package/test/conformance/errors/iso/logtalk_findall_nonlist.pl +1 -1
- package/test/conformance/errors/iso/logtalk_functor_arity_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_functor_compound_name.pl +1 -1
- package/test/conformance/errors/iso/logtalk_functor_float_name.pl +1 -1
- package/test/conformance/errors/iso/logtalk_number_chars_character_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_number_chars_list_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_number_chars_number_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_number_chars_partial.pl +1 -1
- package/test/conformance/errors/iso/logtalk_number_chars_syntax.pl +1 -1
- package/test/conformance/errors/iso/logtalk_number_chars_unbound.pl +1 -1
- package/test/conformance/errors/iso/logtalk_number_codes_bad_code.pl +1 -1
- package/test/conformance/errors/iso/logtalk_number_codes_list_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_number_codes_number_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_number_codes_partial.pl +1 -1
- package/test/conformance/errors/iso/logtalk_number_codes_syntax.pl +1 -1
- package/test/conformance/errors/iso/logtalk_number_codes_unbound.pl +1 -1
- package/test/conformance/errors/iso/logtalk_once_noncallable.pl +1 -1
- package/test/conformance/errors/iso/logtalk_once_unbound.pl +1 -1
- package/test/conformance/errors/iso/logtalk_op_bad_specifier.pl +1 -1
- package/test/conformance/errors/iso/logtalk_op_high_priority.pl +1 -1
- package/test/conformance/errors/iso/logtalk_op_negative_priority.pl +1 -1
- package/test/conformance/errors/iso/logtalk_op_priority_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_op_unbound_name.pl +1 -1
- package/test/conformance/errors/iso/logtalk_op_unbound_priority.pl +1 -1
- package/test/conformance/errors/iso/logtalk_op_unbound_specifier.pl +1 -1
- package/test/conformance/errors/iso/logtalk_retract_unbound.pl +1 -1
- package/test/conformance/errors/iso/logtalk_retract_unbound_head.pl +1 -1
- package/test/conformance/errors/iso/logtalk_set_flag_name_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_set_flag_unbound_name.pl +1 -1
- package/test/conformance/errors/iso/logtalk_set_flag_unbound_value.pl +1 -1
- package/test/conformance/errors/iso/logtalk_set_flag_unknown.pl +1 -1
- package/test/conformance/errors/iso/logtalk_set_flag_value.pl +1 -1
- package/test/conformance/errors/iso/logtalk_setof_nonlist.pl +1 -1
- package/test/conformance/errors/iso/logtalk_sub_atom_before_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_sub_atom_negative.pl +1 -1
- package/test/conformance/errors/iso/logtalk_sub_atom_result_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_sub_atom_source_type.pl +1 -1
- package/test/conformance/errors/iso/logtalk_sub_atom_unbound.pl +1 -1
- package/test/conformance/errors/iso/logtalk_term_variables_improper.pl +1 -1
- package/test/conformance/errors/iso/logtalk_term_variables_nonlist.pl +1 -1
- package/test/conformance/errors/iso/logtalk_univ_head_compound.pl +1 -1
- package/test/conformance/errors/iso/logtalk_univ_head_float.pl +1 -1
- package/test/conformance/errors/iso/logtalk_univ_head_integer.pl +1 -1
- package/test/conformance/errors/iso/logtalk_univ_single_compound.pl +1 -1
- package/test/conformance/expected/strings/064_reusable_string_builtins.pl +1 -1
- package/test/run-conformance-report.mjs +4 -4
- package/test/run-conformance.mjs +3 -3
- package/test/run-playground.mjs +3 -3
- package/test/run-rdf-tools.mjs +15 -15
- package/test/run-regression.mjs +35 -35
- package/the-art-of-eyelang.md +136 -136
- package/tools/README.md +2 -2
- package/tools/extract-book-examples.mjs +4 -4
- package/tools/pl-to-rdf.mjs +2 -2
- package/tools/rdf-codec.mjs +8 -8
- package/tools/rdf-to-pl.mjs +9 -9
- package/why-eyelang.md +47 -47
package/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface EyelangStats {
|
|
2
2
|
[key: string]: number;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
export interface
|
|
5
|
+
export interface EyelangRunOptions {
|
|
6
6
|
/** A host-supplied goal, expressed as Prolog text or a parsed term. */
|
|
7
|
-
goal?: string |
|
|
7
|
+
goal?: string | EyelangTerm;
|
|
8
8
|
/** Host-supplied goals, executed in order. */
|
|
9
|
-
goals?: Array<string |
|
|
9
|
+
goals?: Array<string | EyelangTerm>;
|
|
10
10
|
proof?: boolean;
|
|
11
11
|
why?: boolean;
|
|
12
12
|
explain?: boolean;
|
|
@@ -23,9 +23,9 @@ export interface EyeLangRunOptions {
|
|
|
23
23
|
[key: string]: unknown;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export interface
|
|
26
|
+
export interface EyelangRunResult {
|
|
27
27
|
stdout: string;
|
|
28
|
-
stats:
|
|
28
|
+
stats: EyelangStats;
|
|
29
29
|
haltCode: number | null;
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -37,25 +37,25 @@ export class StreamManager {
|
|
|
37
37
|
currentOutput: number;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export interface
|
|
40
|
+
export interface EyelangSourcePart {
|
|
41
41
|
text?: string;
|
|
42
42
|
source?: string;
|
|
43
43
|
filename?: string;
|
|
44
44
|
baseDir?: string;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
export interface
|
|
48
|
-
head:
|
|
49
|
-
body:
|
|
47
|
+
export interface EyelangClause {
|
|
48
|
+
head: EyelangTerm;
|
|
49
|
+
body: EyelangTerm[];
|
|
50
50
|
index?: number;
|
|
51
51
|
filename?: string;
|
|
52
52
|
clauseNumber?: number;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
export interface
|
|
55
|
+
export interface EyelangPredicateGroup {
|
|
56
56
|
name: string;
|
|
57
57
|
arity: number;
|
|
58
|
-
clauses:
|
|
58
|
+
clauses: EyelangClause[];
|
|
59
59
|
argIndexes: unknown[];
|
|
60
60
|
demandIndexes: Map<string, unknown>;
|
|
61
61
|
rejectedDemandIndexes: Set<string>;
|
|
@@ -65,42 +65,42 @@ export interface EyeLangPredicateGroup {
|
|
|
65
65
|
negationStratum: number | null;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
export type
|
|
68
|
+
export type EyelangTerm = Term | { type: string; name: string; args?: EyelangTerm[]; arity?: number };
|
|
69
69
|
|
|
70
70
|
export class Term {
|
|
71
|
-
constructor(type: string, name?: unknown, args?:
|
|
71
|
+
constructor(type: string, name?: unknown, args?: EyelangTerm[]);
|
|
72
72
|
type: string;
|
|
73
73
|
name: string;
|
|
74
|
-
args:
|
|
74
|
+
args: EyelangTerm[];
|
|
75
75
|
get arity(): number;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
export class Env {
|
|
79
|
-
constructor(bindings?: Iterable<readonly [string,
|
|
80
|
-
bindings: Map<string,
|
|
79
|
+
constructor(bindings?: Iterable<readonly [string, EyelangTerm]> | null);
|
|
80
|
+
bindings: Map<string, EyelangTerm>;
|
|
81
81
|
clone(): Env;
|
|
82
82
|
has(name: string): boolean;
|
|
83
|
-
get(name: string):
|
|
84
|
-
bind(name: string, term:
|
|
83
|
+
get(name: string): EyelangTerm | undefined;
|
|
84
|
+
bind(name: string, term: EyelangTerm): void;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
export class Program {
|
|
88
|
-
constructor(clauses?:
|
|
89
|
-
clauses:
|
|
90
|
-
groups: Map<string,
|
|
88
|
+
constructor(clauses?: EyelangClause[], options?: EyelangRunOptions);
|
|
89
|
+
clauses: EyelangClause[];
|
|
90
|
+
groups: Map<string, EyelangPredicateGroup>;
|
|
91
91
|
negationDependencies: Array<{ from: string; to: string; negative: boolean }>;
|
|
92
92
|
negationStratificationErrors: Array<{ from: string; to: string }>;
|
|
93
93
|
stratifiedNegation: boolean;
|
|
94
|
-
static parse(source: string, options?:
|
|
95
|
-
static parseSources(sources?: Array<string |
|
|
96
|
-
makeGroup(name: string, arity: number):
|
|
97
|
-
indexClause(clause:
|
|
98
|
-
findGroup(name: string, arity: number):
|
|
94
|
+
static parse(source: string, options?: EyelangRunOptions): Program;
|
|
95
|
+
static parseSources(sources?: Array<string | EyelangSourcePart>, options?: EyelangRunOptions): Program;
|
|
96
|
+
makeGroup(name: string, arity: number): EyelangPredicateGroup;
|
|
97
|
+
indexClause(clause: EyelangClause): void;
|
|
98
|
+
findGroup(name: string, arity: number): EyelangPredicateGroup | null;
|
|
99
99
|
markRecursivePredicates(): void;
|
|
100
100
|
analyzeNegationStratification(): Array<{ from: string; to: string }>;
|
|
101
101
|
assertStratifiedNegation(): true;
|
|
102
102
|
isStratifiedNegation(): boolean;
|
|
103
|
-
groupHasRule(group:
|
|
103
|
+
groupHasRule(group: EyelangPredicateGroup): boolean;
|
|
104
104
|
sourceFactLines(predicateKeys?: Set<string> | null): Set<string>;
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -109,13 +109,13 @@ export interface BuiltinDefinition {
|
|
|
109
109
|
arity: number;
|
|
110
110
|
handler: BuiltinHandler;
|
|
111
111
|
deterministic: boolean;
|
|
112
|
-
ready: ((goal:
|
|
112
|
+
ready: ((goal: EyelangTerm, env: Env) => boolean) | null;
|
|
113
113
|
fallbackWhenNotReady: boolean;
|
|
114
|
-
shouldUse: ((context: { solver: Solver; goal:
|
|
114
|
+
shouldUse: ((context: { solver: Solver; goal: EyelangTerm; env: Env }) => boolean) | null;
|
|
115
115
|
eyeLangLibrary: boolean;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
export type BuiltinHandler = (context: { solver: Solver; goal:
|
|
118
|
+
export type BuiltinHandler = (context: { solver: Solver; goal: EyelangTerm; env: Env }) => Iterable<Env>;
|
|
119
119
|
|
|
120
120
|
export class BuiltinRegistry {
|
|
121
121
|
constructor();
|
|
@@ -126,7 +126,7 @@ export class BuiltinRegistry {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
export class Solver {
|
|
129
|
-
constructor(program: Program, options?:
|
|
129
|
+
constructor(program: Program, options?: EyelangRunOptions);
|
|
130
130
|
program: Program;
|
|
131
131
|
registry: BuiltinRegistry;
|
|
132
132
|
maxDepth: number;
|
|
@@ -134,10 +134,10 @@ export class Solver {
|
|
|
134
134
|
solutionsSeen: number;
|
|
135
135
|
active: unknown[];
|
|
136
136
|
memo: Map<string, unknown>;
|
|
137
|
-
stats:
|
|
137
|
+
stats: EyelangStats;
|
|
138
138
|
cloneForInnerGoal(solutionLimit?: number): Solver;
|
|
139
|
-
solve(goals:
|
|
140
|
-
activeVariant(goal:
|
|
139
|
+
solve(goals: EyelangTerm | EyelangTerm[], env?: Env, depth?: number): Iterable<Env>;
|
|
140
|
+
activeVariant(goal: EyelangTerm, env: Env): boolean;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
export const VAR: 'var';
|
|
@@ -151,44 +151,44 @@ export function atom(name: string): Term;
|
|
|
151
151
|
export function stringTerm(value: string): Term;
|
|
152
152
|
export function numberTerm(value: string | number): Term;
|
|
153
153
|
/** Construct a compound term; an empty argument list is canonicalized to atom(name). */
|
|
154
|
-
export function compound(name: string, args?:
|
|
154
|
+
export function compound(name: string, args?: EyelangTerm[]): Term;
|
|
155
155
|
export function emptyList(): Term;
|
|
156
|
-
export function cons(head:
|
|
157
|
-
export function deref(term:
|
|
158
|
-
export function isScalar(term:
|
|
159
|
-
export function isEmptyList(term:
|
|
160
|
-
export function isCons(term:
|
|
161
|
-
export function isConjunction(term:
|
|
162
|
-
export function unify(left:
|
|
163
|
-
export function cloneTerm(term:
|
|
164
|
-
export function freshTerm(term:
|
|
165
|
-
export function copyResolved(term:
|
|
166
|
-
export function termIsGround(term:
|
|
167
|
-
export function termToString(term:
|
|
168
|
-
export function lexicalValue(term:
|
|
169
|
-
export function properListItems(list:
|
|
170
|
-
export function listFromItems(items:
|
|
171
|
-
export function flattenConjunction(goal:
|
|
172
|
-
export function termSignature(term:
|
|
173
|
-
export function variantTerms(left:
|
|
174
|
-
export function compareTerms(left:
|
|
156
|
+
export function cons(head: EyelangTerm, tail: EyelangTerm): Term;
|
|
157
|
+
export function deref(term: EyelangTerm, env: Env): EyelangTerm;
|
|
158
|
+
export function isScalar(term: EyelangTerm | null | undefined): boolean;
|
|
159
|
+
export function isEmptyList(term: EyelangTerm | null | undefined): boolean;
|
|
160
|
+
export function isCons(term: EyelangTerm | null | undefined): boolean;
|
|
161
|
+
export function isConjunction(term: EyelangTerm | null | undefined): boolean;
|
|
162
|
+
export function unify(left: EyelangTerm, right: EyelangTerm, env: Env): boolean;
|
|
163
|
+
export function cloneTerm(term: EyelangTerm): Term;
|
|
164
|
+
export function freshTerm(term: EyelangTerm, suffix: string | number): Term;
|
|
165
|
+
export function copyResolved(term: EyelangTerm, env: Env): Term;
|
|
166
|
+
export function termIsGround(term: EyelangTerm, env?: Env): boolean;
|
|
167
|
+
export function termToString(term: EyelangTerm, env?: Env, quoteStrings?: boolean): string;
|
|
168
|
+
export function lexicalValue(term: EyelangTerm, env: Env): string | null;
|
|
169
|
+
export function properListItems(list: EyelangTerm, env: Env): EyelangTerm[] | null;
|
|
170
|
+
export function listFromItems(items: EyelangTerm[], start?: number, end?: number, tail?: EyelangTerm): Term;
|
|
171
|
+
export function flattenConjunction(goal: EyelangTerm): EyelangTerm[];
|
|
172
|
+
export function termSignature(term: EyelangTerm | null | undefined): string | null;
|
|
173
|
+
export function variantTerms(left: EyelangTerm, leftEnv: Env, right: EyelangTerm, rightEnv: Env, pairs?: Map<string, string>, reverse?: Map<string, string>): boolean;
|
|
174
|
+
export function compareTerms(left: EyelangTerm, right: EyelangTerm): number;
|
|
175
175
|
export function isDecimalInteger(text: string | null | undefined): boolean;
|
|
176
176
|
export function compareIntegerText(left: string, right: string): number;
|
|
177
177
|
export function parseFiniteNumber(text: string | null | undefined): number | null;
|
|
178
178
|
export function numberTextFromDouble(value: number): string | null;
|
|
179
179
|
export function compareNumberText(left: string, right: string): number;
|
|
180
180
|
|
|
181
|
-
export function makeProgram(source: string, options?:
|
|
182
|
-
export function parseClauses(source: string, options?:
|
|
183
|
-
export function parseProgramText(source: string, options?:
|
|
184
|
-
export function parseGoalText(source: string):
|
|
181
|
+
export function makeProgram(source: string, options?: EyelangRunOptions): Program;
|
|
182
|
+
export function parseClauses(source: string, options?: EyelangRunOptions): EyelangClause[];
|
|
183
|
+
export function parseProgramText(source: string, options?: EyelangRunOptions): EyelangClause[];
|
|
184
|
+
export function parseGoalText(source: string): EyelangTerm;
|
|
185
185
|
export function createDefaultRegistry(): BuiltinRegistry;
|
|
186
|
-
export function
|
|
186
|
+
export function createEyelangRegistry(): BuiltinRegistry;
|
|
187
187
|
export function getDefaultRegistry(): BuiltinRegistry;
|
|
188
|
-
export function
|
|
188
|
+
export function getEyelangRegistry(): BuiltinRegistry;
|
|
189
189
|
export class PrologError extends Error {
|
|
190
190
|
formal: string;
|
|
191
|
-
culprit:
|
|
191
|
+
culprit: EyelangTerm | null;
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
export class HaltSignal extends Error {
|
|
@@ -196,10 +196,10 @@ export class HaltSignal extends Error {
|
|
|
196
196
|
code: number;
|
|
197
197
|
constructor(code?: number);
|
|
198
198
|
}
|
|
199
|
-
export function run(source: string | Program, options?:
|
|
200
|
-
export function whyProof(program: Program, goal:
|
|
201
|
-
export function whyNoProof(goal:
|
|
202
|
-
export function explainProof(program: Program, goal:
|
|
199
|
+
export function run(source: string | Program, options?: EyelangRunOptions): EyelangRunResult;
|
|
200
|
+
export function whyProof(program: Program, goal: EyelangTerm, options?: EyelangRunOptions): { ok: boolean; text: string };
|
|
201
|
+
export function whyNoProof(goal: EyelangTerm): string;
|
|
202
|
+
export function explainProof(program: Program, goal: EyelangTerm, options?: EyelangRunOptions): { ok: boolean; text: string };
|
|
203
203
|
|
|
204
204
|
declare const eyelang: {
|
|
205
205
|
VAR: typeof VAR;
|
|
@@ -247,9 +247,9 @@ declare const eyelang: {
|
|
|
247
247
|
parseClauses: typeof parseClauses;
|
|
248
248
|
parseProgramText: typeof parseProgramText;
|
|
249
249
|
createDefaultRegistry: typeof createDefaultRegistry;
|
|
250
|
-
|
|
250
|
+
createEyelangRegistry: typeof createEyelangRegistry;
|
|
251
251
|
getDefaultRegistry: typeof getDefaultRegistry;
|
|
252
|
-
|
|
252
|
+
getEyelangRegistry: typeof getEyelangRegistry;
|
|
253
253
|
run: typeof run;
|
|
254
254
|
whyProof: typeof whyProof;
|
|
255
255
|
whyNoProof: typeof whyNoProof;
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.5.
|
|
7
|
-
"description": "
|
|
6
|
+
"version": "0.5.2",
|
|
7
|
+
"description": "Eyelang turns facts and rules into answers and proofs.",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./index.js",
|
|
10
10
|
"types": "./index.d.ts",
|
package/playground.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
6
|
<link rel="icon" type="image/png" href="eyelang-logo.png">
|
|
7
|
-
<title>
|
|
7
|
+
<title>Eyelang Playground</title>
|
|
8
8
|
<style>
|
|
9
9
|
:root {
|
|
10
10
|
color-scheme: light dark;
|
|
@@ -353,8 +353,8 @@
|
|
|
353
353
|
</head>
|
|
354
354
|
<body>
|
|
355
355
|
<header>
|
|
356
|
-
<h1>The
|
|
357
|
-
<p>Run
|
|
356
|
+
<h1>The Eyelang Playground</h1>
|
|
357
|
+
<p>Run Eyelang programs in your browser with syntax coloring, examples, proofs, and shareable editor links.</p>
|
|
358
358
|
</header>
|
|
359
359
|
|
|
360
360
|
<main>
|
|
@@ -371,7 +371,7 @@
|
|
|
371
371
|
<details>
|
|
372
372
|
<summary id="advanced-heading">⚙ Advanced configuration</summary>
|
|
373
373
|
<div class="toolbar" aria-label="URL loader">
|
|
374
|
-
<label for="source-url">Load
|
|
374
|
+
<label for="source-url">Load Eyelang from URL</label>
|
|
375
375
|
<input id="source-url" type="url" placeholder="https://example.org/program.pl">
|
|
376
376
|
<button id="load-url" type="button">Load from URL</button>
|
|
377
377
|
</div>
|
|
@@ -385,7 +385,7 @@
|
|
|
385
385
|
<label><input id="stats" type="checkbox"> Show stats</label>
|
|
386
386
|
</div>
|
|
387
387
|
<div class="panel-body">
|
|
388
|
-
<p class="hint">Enter any
|
|
388
|
+
<p class="hint">Enter any Eyelang file URL and click “Load from URL”. Background knowledge is prepended when the program runs.</p>
|
|
389
389
|
</div>
|
|
390
390
|
</details>
|
|
391
391
|
</section>
|
|
@@ -393,14 +393,14 @@
|
|
|
393
393
|
<section aria-labelledby="editor-heading">
|
|
394
394
|
<div class="editor-shell">
|
|
395
395
|
<div class="editor-label">
|
|
396
|
-
<strong id="editor-heading">Editable
|
|
396
|
+
<strong id="editor-heading">Editable Eyelang program</strong>
|
|
397
397
|
<span id="source-name" class="hint">custom program</span>
|
|
398
398
|
</div>
|
|
399
399
|
<div class="editor">
|
|
400
400
|
<div id="line-numbers" class="line-numbers" aria-hidden="true"><div class="line-numbers-inner"></div></div>
|
|
401
401
|
<div id="error-line-marker" class="error-line-marker" aria-hidden="true"></div>
|
|
402
402
|
<pre id="highlight" aria-hidden="true"><code></code></pre>
|
|
403
|
-
<textarea id="source" spellcheck="false" autocapitalize="off" autocomplete="off" aria-label="Editable
|
|
403
|
+
<textarea id="source" spellcheck="false" autocapitalize="off" autocomplete="off" aria-label="Editable Eyelang source"></textarea>
|
|
404
404
|
</div>
|
|
405
405
|
</div>
|
|
406
406
|
<div class="toolbar button-row">
|
|
@@ -432,7 +432,7 @@
|
|
|
432
432
|
</main>
|
|
433
433
|
|
|
434
434
|
<footer>
|
|
435
|
-
Powered by <a href="https://github.com/eyereasoner/eyelang">
|
|
435
|
+
Powered by <a href="https://github.com/eyereasoner/eyelang">Eyelang</a>.
|
|
436
436
|
</footer>
|
|
437
437
|
|
|
438
438
|
<script type="module">
|
|
@@ -953,7 +953,7 @@
|
|
|
953
953
|
clearSyntaxError();
|
|
954
954
|
output.textContent = '';
|
|
955
955
|
elapsed.textContent = 'Running…';
|
|
956
|
-
setStatus('Running
|
|
956
|
+
setStatus('Running Eyelang…');
|
|
957
957
|
runButton.disabled = true;
|
|
958
958
|
stopButton.disabled = false;
|
|
959
959
|
|
|
@@ -1150,7 +1150,7 @@
|
|
|
1150
1150
|
'Content-Type': 'application/json',
|
|
1151
1151
|
},
|
|
1152
1152
|
body: JSON.stringify({
|
|
1153
|
-
description: '
|
|
1153
|
+
description: 'Eyelang playground share',
|
|
1154
1154
|
public: false,
|
|
1155
1155
|
files,
|
|
1156
1156
|
}),
|
package/src/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Command-line interface for
|
|
1
|
+
// Command-line interface for Eyelang.
|
|
2
2
|
// It loads programs from files, URLs, or stdin, then runs requested goals.
|
|
3
3
|
import fs from 'node:fs/promises';
|
|
4
4
|
import path from 'node:path';
|
|
@@ -137,7 +137,7 @@ async function runDefault(engine, program, options) {
|
|
|
137
137
|
const queriedKeys = new Set(goals.map((goal) => `${goal.name}/${goal.arity}`));
|
|
138
138
|
const facts = program.sourceFactLines(queriedKeys);
|
|
139
139
|
const lines = new Set();
|
|
140
|
-
const registry = engine.
|
|
140
|
+
const registry = engine.getEyelangRegistry();
|
|
141
141
|
const explanation = options.proof ? await loadExplanation() : null;
|
|
142
142
|
const solver = new engine.Solver(program, {
|
|
143
143
|
registry,
|
|
@@ -181,8 +181,8 @@ Usage:
|
|
|
181
181
|
eyelang [options] [file-or-url.pl|- ...]
|
|
182
182
|
|
|
183
183
|
Input:
|
|
184
|
-
file-or-url.pl Read an
|
|
185
|
-
- Read an
|
|
184
|
+
file-or-url.pl Read an Eyelang program from a local file or http(s) URL.
|
|
185
|
+
- Read an Eyelang program from standard input.
|
|
186
186
|
|
|
187
187
|
Options:
|
|
188
188
|
-h, --help Show this help text and exit.
|
package/src/explain.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Eyelang proof output helpers.
|
|
2
2
|
// The explanation printer replays a successful goal against the program and emits
|
|
3
|
-
// ordinary
|
|
3
|
+
// ordinary Eyelang facts with nested proof terms. Explanations are therefore both
|
|
4
4
|
// human-readable and machine-readable.
|
|
5
5
|
import { ATOM, COMPOUND, Env, Term, VAR, deref, flattenConjunction, freshTerm, termToString, unify, variantTerms } from './term.js';
|
|
6
6
|
import { selectClauseCandidates } from './program.js';
|
|
7
|
-
import {
|
|
7
|
+
import { getEyelangRegistry } from './library.js';
|
|
8
8
|
import { Solver, nextFreshId } from './solver.js';
|
|
9
9
|
|
|
10
10
|
export function whyProof(program, goal, options = {}) {
|
|
11
11
|
const maxDepth = options.maxDepth ?? 256;
|
|
12
|
-
const registry = options.registry ??
|
|
12
|
+
const registry = options.registry ?? getEyelangRegistry();
|
|
13
13
|
const env = options.env ?? new Env();
|
|
14
14
|
for (const proof of proveGoalAll(program, goal, env, 0, maxDepth, registry, [])) {
|
|
15
15
|
return { ok: true, text: renderWhyFacts(goal, proof.node, proof.env) };
|
package/src/index.js
CHANGED
|
@@ -12,8 +12,8 @@ export {
|
|
|
12
12
|
PrologError,
|
|
13
13
|
} from './iso.js';
|
|
14
14
|
export {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
createEyelangRegistry,
|
|
16
|
+
getEyelangRegistry,
|
|
17
17
|
} from './library.js';
|
|
18
18
|
export { StreamManager } from './io.js';
|
|
19
19
|
|
|
@@ -22,14 +22,14 @@ import { Program } from './program.js';
|
|
|
22
22
|
import { Solver } from './solver.js';
|
|
23
23
|
import { whyNoProof, whyProof } from './explain.js';
|
|
24
24
|
import { HaltSignal, PrologError } from './iso.js';
|
|
25
|
-
import {
|
|
25
|
+
import { getEyelangRegistry } from './library.js';
|
|
26
26
|
import { parseGoalText } from './parser.js';
|
|
27
27
|
|
|
28
28
|
export function run(source, options = {}) {
|
|
29
29
|
const includeWhy = options.proof === true || options.why === true || options.explain === true;
|
|
30
30
|
const parseOptions = { ...options, sourceMetadata: includeWhy };
|
|
31
31
|
let program = source instanceof Program ? source : Program.parse(source, parseOptions);
|
|
32
|
-
const runOptions = options.registry ? options : { ...options, registry:
|
|
32
|
+
const runOptions = options.registry ? options : { ...options, registry: getEyelangRegistry() };
|
|
33
33
|
const output = [];
|
|
34
34
|
const solver = new Solver(program, {
|
|
35
35
|
...runOptions,
|
package/src/iso.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Built-ins in
|
|
1
|
+
// Built-ins in Eyelang's documented ISO compatibility profile. This is a
|
|
2
2
|
// deliberately incomplete profile, not the complete standard environment.
|
|
3
3
|
import {
|
|
4
4
|
ATOM, COMPOUND, NUMBER, STRING, VAR, Env,
|
package/src/library.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Eyelang library implemented entirely as native JavaScript builtins.
|
|
2
2
|
// The single registry is shared by Node, embedders, and the browser playground.
|
|
3
3
|
import {
|
|
4
4
|
ATOM,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
} from './iso.js';
|
|
35
35
|
|
|
36
36
|
// Numeric builtins for integer-preserving arithmetic, floating point functions, comparisons, and ranges.
|
|
37
|
-
// The code keeps BigInt paths where possible so large
|
|
37
|
+
// The code keeps BigInt paths where possible so large Eyelang integers remain exact.
|
|
38
38
|
|
|
39
39
|
const unaryNames = ['tan', 'asin', 'acos'];
|
|
40
40
|
const binaryNames = ['atan2'];
|
|
@@ -461,7 +461,7 @@ function contextFromGroups(groups) {
|
|
|
461
461
|
function numericText(text) {
|
|
462
462
|
return isDecimalInteger(text) || parseFiniteNumber(text) != null;
|
|
463
463
|
}
|
|
464
|
-
// Native
|
|
464
|
+
// Native Eyelang library relations.
|
|
465
465
|
// These predicates used to be parsed from bundled Prolog source. Keeping them
|
|
466
466
|
// in the builtin registry removes startup parsing, avoids browser module/cache
|
|
467
467
|
// duplication, and gives the hot list/aggregation paths direct JavaScript
|
|
@@ -998,7 +998,7 @@ function integerArgument(term, env) {
|
|
|
998
998
|
return BigInt(resolved.name);
|
|
999
999
|
}
|
|
1000
1000
|
|
|
1001
|
-
export function
|
|
1001
|
+
export function createEyelangRegistry() {
|
|
1002
1002
|
const registry = new BuiltinRegistry();
|
|
1003
1003
|
registry.eyeLangLibrary = true;
|
|
1004
1004
|
for (const mod of [
|
|
@@ -1012,14 +1012,14 @@ export function createEyeLangRegistry() {
|
|
|
1012
1012
|
}
|
|
1013
1013
|
for (const definition of registry.defs.values()) definition.eyeLangLibrary = true;
|
|
1014
1014
|
// ISO definitions take precedence where names overlap and remain identifiable
|
|
1015
|
-
// as ISO rather than
|
|
1015
|
+
// as ISO rather than Eyelang-library predicates.
|
|
1016
1016
|
isoBuiltins.register(registry);
|
|
1017
1017
|
return registry;
|
|
1018
1018
|
}
|
|
1019
1019
|
|
|
1020
1020
|
let eyeLangRegistry = null;
|
|
1021
1021
|
|
|
1022
|
-
export function
|
|
1023
|
-
if (eyeLangRegistry == null) eyeLangRegistry =
|
|
1022
|
+
export function getEyelangRegistry() {
|
|
1023
|
+
if (eyeLangRegistry == null) eyeLangRegistry = createEyelangRegistry();
|
|
1024
1024
|
return eyeLangRegistry;
|
|
1025
1025
|
}
|
package/src/parser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Tokenizer and recursive-descent parser for the
|
|
1
|
+
// Tokenizer and recursive-descent parser for the Eyelang source language.
|
|
2
2
|
// It preserves the compact Prolog-like syntax while producing Term objects for the solver.
|
|
3
3
|
import { atom, compound, cons, emptyList, numberTerm, stringTerm, variable } from './term.js';
|
|
4
4
|
|
package/src/playground-worker.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Keep this module free of Node-only imports: it is fetched directly by the
|
|
3
3
|
// browser and is also exercised by test/run-playground.mjs.
|
|
4
4
|
import { run } from './index.js?playground=20260803c';
|
|
5
|
-
import {
|
|
5
|
+
import { createEyelangRegistry } from './library.js?playground=20260803c';
|
|
6
6
|
|
|
7
|
-
const registry =
|
|
7
|
+
const registry = createEyelangRegistry();
|
|
8
8
|
|
|
9
9
|
export function executePlaygroundRequest(data, now = defaultNow) {
|
|
10
10
|
const started = now();
|
package/src/solver.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
// Depth-first
|
|
1
|
+
// Depth-first Eyelang solver with builtin dispatch, memoization, and guarded recursion handling.
|
|
2
2
|
// Most semantic decisions still flow through unification; optimizations only select candidates earlier.
|
|
3
3
|
import {
|
|
4
4
|
COMPOUND, Env, compound, copyResolved, deref, flattenConjunction, freshTerm,
|
|
5
5
|
numberTerm, numberTextFromDouble, termIsGround, termToString, unify, variantTerms,
|
|
6
6
|
} from './term.js';
|
|
7
7
|
import { PrologError } from './iso.js';
|
|
8
|
-
import {
|
|
8
|
+
import { getEyelangRegistry } from './library.js';
|
|
9
9
|
import { selectClauseCandidates, selectClauseCandidatesForValues, selectGroundClauseCandidates } from './program.js';
|
|
10
10
|
import { StreamManager } from './io.js';
|
|
11
11
|
|
|
@@ -17,7 +17,7 @@ export function nextFreshId() {
|
|
|
17
17
|
|
|
18
18
|
export class Solver {
|
|
19
19
|
constructor(program, options = {}) {
|
|
20
|
-
this.registry = options.registry ??
|
|
20
|
+
this.registry = options.registry ?? getEyelangRegistry();
|
|
21
21
|
this.program = program;
|
|
22
22
|
this.mutableProgram = program.mutable === true;
|
|
23
23
|
this.programRevision = this.program.revision ?? 0;
|
|
@@ -196,7 +196,7 @@ export class Solver {
|
|
|
196
196
|
continue;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
//
|
|
199
|
+
// Eyelang normally solves left-to-right, but ready deterministic builtins can
|
|
200
200
|
// be run early as pure filters. Stop at internal sentinels so rule-body
|
|
201
201
|
// active guards are released before the caller's remaining goals are seen.
|
|
202
202
|
const selectedIndex = selectReadyDeterministicBuiltin(goals, env, this.registry);
|
package/src/term.js
CHANGED
|
@@ -187,7 +187,7 @@ function occurs(variableName, term, env) {
|
|
|
187
187
|
|
|
188
188
|
export function unify(left, right, env) {
|
|
189
189
|
// Iterative unification avoids deep JavaScript recursion on long lists or
|
|
190
|
-
// deeply nested compounds. The occurs check gives
|
|
190
|
+
// deeply nested compounds. The occurs check gives Eyelang finite-tree
|
|
191
191
|
// unification: a variable cannot be bound to a term containing itself.
|
|
192
192
|
// Bindings are written into the supplied Env.
|
|
193
193
|
const stack = [[left, right]];
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Eyelang profile conformance suite
|
|
2
2
|
|
|
3
|
-
This directory contains executable tests for the
|
|
3
|
+
This directory contains executable tests for the Eyelang implementation and
|
|
4
4
|
reasoner.
|
|
5
|
-
[*The Art of
|
|
5
|
+
[*The Art of Eyelang*](../../the-art-of-eyelang.md) is the reference for the
|
|
6
6
|
supported ISO Prolog profile, built-ins, extensions, and reasoner behavior.
|
|
7
7
|
|
|
8
8
|
The suite is intentionally file-based. Exact standard output, errors, warnings,
|
|
9
9
|
and proof output test the behavior of the JavaScript implementation.
|
|
10
10
|
|
|
11
|
-
“Conformance” here means conformance to
|
|
11
|
+
“Conformance” here means conformance to Eyelang's documented ISO compatibility
|
|
12
12
|
profile and implementation extensions. The default registry covers the exact
|
|
13
13
|
predicate indicators listed in Appendix B of the book across the supported
|
|
14
14
|
ISO/IEC 13211-1:1995 standard families. This suite is still not an independent certification of
|
|
15
15
|
every processor requirement, lexical edge, option combination, or prescribed
|
|
16
16
|
error precedence. Cases under `iso/` identify standards-derived behavior;
|
|
17
|
-
other directories cover
|
|
17
|
+
other directories cover Eyelang host contracts and extensions.
|
|
18
18
|
|
|
19
19
|
All conformance files live under topic directories such as `arithmetic/`, `lists/`, `syntax/`, or `variables/`; new top-level numbered files should not be added. The report uses those directories as coverage categories.
|
|
20
20
|
|
|
21
21
|
A normal positive case consists of:
|
|
22
22
|
|
|
23
23
|
- `conformance/cases/<name>.pl` — input program;
|
|
24
|
-
- `conformance/expected/<name>.pl` — exact expected standard output, stored as
|
|
24
|
+
- `conformance/expected/<name>.pl` — exact expected standard output, stored as Eyelang-readable facts.
|
|
25
25
|
|
|
26
26
|
Expected-error cases consist of:
|
|
27
27
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
Selected standard term, atom, character, collection, control, and conversion
|
|
6
6
|
cases under `iso/` are adapted from the `tests/prolog` backend Prolog conformance suite in
|
|
7
7
|
[Logtalk](https://github.com/LogtalkDotOrg/logtalk3). Each adapted file
|
|
8
|
-
identifies its upstream test names. The cases were rewritten for
|
|
8
|
+
identifies its upstream test names. The cases were rewritten for Eyelang's
|
|
9
9
|
file-based query and exact-output harness and are therefore modified from the
|
|
10
10
|
upstream files.
|
|
11
11
|
|
|
@@ -27,7 +27,7 @@ Selected lexical, term, numeric, comment, and operator cases under `iso/` are
|
|
|
27
27
|
adapted from `tests-pl/iso-conformity-tests.pl` in
|
|
28
28
|
[Scryer Prolog](https://github.com/mthom/scryer-prolog). Each adapted file
|
|
29
29
|
identifies the corresponding upstream test numbers. The cases were rewritten
|
|
30
|
-
for
|
|
30
|
+
for Eyelang's file-based query and exact-output harness.
|
|
31
31
|
|
|
32
32
|
BSD 3-Clause License
|
|
33
33
|
|
|
@@ -64,7 +64,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
64
64
|
Selected standard-core cases under `iso/` are adapted from the numbered tests
|
|
65
65
|
in [`tests/tests`](https://github.com/trealla-prolog/trealla/tree/main/tests/tests)
|
|
66
66
|
in Trealla Prolog. Each adapted file identifies its upstream test file. The
|
|
67
|
-
cases were rewritten for
|
|
67
|
+
cases were rewritten for Eyelang's query and exact-output harness.
|
|
68
68
|
|
|
69
69
|
MIT License
|
|
70
70
|
|
|
@@ -95,7 +95,7 @@ Selected standard-core operator and finite-tree unification cases under `iso/`
|
|
|
95
95
|
are adapted from `tests/core/test_op.pl` and
|
|
96
96
|
`tests/core/test_occurs_check.pl` in
|
|
97
97
|
[SWI-Prolog](https://github.com/SWI-Prolog/swipl-devel). Each adapted file
|
|
98
|
-
identifies its upstream source. The cases were rewritten for
|
|
98
|
+
identifies its upstream source. The cases were rewritten for Eyelang's query and
|
|
99
99
|
exact-output harness.
|
|
100
100
|
|
|
101
101
|
BSD 2-Clause License
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
% Adapted from Logtalk iso_abolish_1_01 and eddbali_abolish_1_06.
|
|
2
|
-
% Modified for
|
|
2
|
+
% Modified for Eyelang's conformance harness. See test/conformance/THIRD_PARTY.md.
|
|
3
3
|
:- dynamic(foo/1).
|
|
4
4
|
foo(a).
|
|
5
5
|
%% goal: abolish_result
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
% Adapted from Logtalk iso_arg_3_01 through 07, eddbali_arg_3_15, and
|
|
2
|
-
% lgt_arg_3_17 through 19. Modified for
|
|
2
|
+
% lgt_arg_3_17 through 19. Modified for Eyelang's conformance harness.
|
|
3
3
|
% See test/conformance/THIRD_PARTY.md.
|
|
4
4
|
%% goal: arg_results(X0, X1, X2, X3)
|
|
5
5
|
|