kibi-cli 2.39.0 → 2.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-register-foundation.js +2 -2
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +33 -9
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +15 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +4 -0
- package/dist/commands/migrate-plan-record.d.ts +18 -0
- package/dist/commands/migrate-plan-record.d.ts.map +1 -0
- package/dist/commands/migrate-plan-record.js +112 -0
- package/dist/commands/migrate.d.ts +11 -2
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +53 -7
- package/dist/commands/prove.d.ts.map +1 -1
- package/dist/commands/prove.js +18 -3
- package/dist/commands/sync/manifest.d.ts.map +1 -1
- package/dist/commands/sync/manifest.js +17 -4
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +8 -0
- package/dist/commands/telemetry.d.ts.map +1 -1
- package/dist/commands/telemetry.js +12 -2
- package/dist/extractors/symbol-title-match.d.ts +31 -0
- package/dist/extractors/symbol-title-match.d.ts.map +1 -0
- package/dist/extractors/symbol-title-match.js +133 -0
- package/dist/extractors/symbols-coordinator.d.ts.map +1 -1
- package/dist/extractors/symbols-coordinator.js +81 -12
- package/dist/operations/bootstrap/discovery-evidence.js +2 -2
- package/dist/operations/bootstrap/guidance-actions.d.ts.map +1 -1
- package/dist/operations/bootstrap/guidance-actions.js +12 -1
- package/dist/operations/bootstrap/plugin-offers.d.ts +7 -1
- package/dist/operations/bootstrap/plugin-offers.d.ts.map +1 -1
- package/dist/operations/bootstrap/plugin-offers.js +73 -3
- package/dist/operations/modeling/logic-modeling.d.ts.map +1 -1
- package/dist/operations/modeling/logic-modeling.js +2 -1
- package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
- package/dist/operations/modeling/model-requirement.js +2 -1
- package/dist/operations/mutation/symbol-refresh.d.ts +2 -0
- package/dist/operations/mutation/symbol-refresh.d.ts.map +1 -1
- package/dist/operations/mutation/symbol-refresh.js +6 -1
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +7 -0
- package/dist/operations/planning/compile-intent.d.ts.map +1 -1
- package/dist/operations/planning/compile-intent.js +2 -1
- package/dist/operations/proof/claim-bindings.d.ts +11 -0
- package/dist/operations/proof/claim-bindings.d.ts.map +1 -1
- package/dist/operations/proof/claim-bindings.js +144 -1
- package/dist/operations/proof/code-certificates.d.ts +10 -3
- package/dist/operations/proof/code-certificates.d.ts.map +1 -1
- package/dist/operations/proof/code-certificates.js +65 -13
- package/dist/operations/proof/code-languages.d.ts +104 -0
- package/dist/operations/proof/code-languages.d.ts.map +1 -0
- package/dist/operations/proof/code-languages.js +119 -0
- package/dist/operations/proof/code-models.d.ts +2 -0
- package/dist/operations/proof/code-models.d.ts.map +1 -1
- package/dist/operations/proof/code-models.js +11 -5
- package/dist/operations/proof/code-runner.d.ts +12 -9
- package/dist/operations/proof/code-runner.d.ts.map +1 -1
- package/dist/operations/proof/code-runner.js +81 -38
- package/dist/operations/proof/code-scope.d.ts +8 -0
- package/dist/operations/proof/code-scope.d.ts.map +1 -1
- package/dist/operations/proof/code-scope.js +30 -1
- package/dist/operations/proof/explain.d.ts +13 -0
- package/dist/operations/proof/explain.d.ts.map +1 -1
- package/dist/operations/proof/explain.js +66 -0
- package/dist/operations/proof/ingest-proof.d.ts +2 -0
- package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
- package/dist/operations/proof/ingest-proof.js +1 -0
- package/dist/operations/proof/java-package-shadow.d.ts +14 -0
- package/dist/operations/proof/java-package-shadow.d.ts.map +1 -0
- package/dist/operations/proof/java-package-shadow.js +389 -0
- package/dist/operations/proof/prolog-evaluator.d.ts +14 -0
- package/dist/operations/proof/prolog-evaluator.d.ts.map +1 -0
- package/dist/operations/proof/prolog-evaluator.js +247 -0
- package/dist/operations/proof/prolog-source-reader.d.ts +20 -0
- package/dist/operations/proof/prolog-source-reader.d.ts.map +1 -0
- package/dist/operations/proof/prolog-source-reader.js +1123 -0
- package/dist/operations/proof/source-code-readers.d.ts +6 -0
- package/dist/operations/proof/source-code-readers.d.ts.map +1 -1
- package/dist/operations/proof/source-code-readers.js +879 -75
- package/dist/plugins/approved-source-analyzers.generated.d.ts +13 -35
- package/dist/plugins/approved-source-analyzers.generated.d.ts.map +1 -1
- package/dist/plugins/approved-source-analyzers.generated.js +13 -35
- package/dist/plugins/plugin-install-check.d.ts +21 -0
- package/dist/plugins/plugin-install-check.d.ts.map +1 -0
- package/dist/plugins/plugin-install-check.js +62 -0
- package/dist/plugins/proof-reference-extractors.d.ts +20 -0
- package/dist/plugins/proof-reference-extractors.d.ts.map +1 -0
- package/dist/plugins/proof-reference-extractors.js +104 -0
- package/dist/plugins/reference-language-suggestion.d.ts +51 -0
- package/dist/plugins/reference-language-suggestion.d.ts.map +1 -0
- package/dist/plugins/reference-language-suggestion.js +277 -0
- package/dist/plugins/registry.d.ts.map +1 -1
- package/dist/plugins/registry.js +3 -1
- package/dist/plugins/source-analysis-service.d.ts.map +1 -1
- package/dist/plugins/source-analysis-service.js +4 -0
- package/dist/plugins/source-change-analysis.d.ts +26 -1
- package/dist/plugins/source-change-analysis.d.ts.map +1 -1
- package/dist/plugins/source-change-analysis.js +77 -5
- package/dist/plugins/source-classification.d.ts.map +1 -1
- package/dist/plugins/source-classification.js +23 -3
- package/dist/public/operations/catalog.d.ts +32 -7
- package/dist/public/operations/catalog.d.ts.map +1 -1
- package/dist/public/operations/check-executor.d.ts.map +1 -1
- package/dist/public/operations/check-executor.js +3 -0
- package/dist/public/operations/evidence-floor.d.ts +8 -0
- package/dist/public/operations/evidence-floor.d.ts.map +1 -1
- package/dist/public/operations/evidence-floor.js +19 -1
- package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
- package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
- package/dist/public/operations/specs/check-rules.generated.js +2 -1
- package/dist/public/operations/specs/check.d.ts +1 -1
- package/dist/public/operations/specs/mutation-schemas.d.ts +31 -6
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
- package/dist/public/operations/specs/reporting.d.ts +8 -0
- package/dist/public/operations/specs/reporting.d.ts.map +1 -1
- package/dist/public/operations/specs/reporting.js +26 -3
- package/dist/public/operations/specs/semantic.d.ts.map +1 -1
- package/dist/public/operations/specs/semantic.js +2 -1
- package/dist/public/operations/specs/upsert.d.ts +31 -6
- package/dist/public/operations/specs/upsert.d.ts.map +1 -1
- package/dist/public/operations/symbol-coordinates-check.d.ts +11 -0
- package/dist/public/operations/symbol-coordinates-check.d.ts.map +1 -0
- package/dist/public/operations/symbol-coordinates-check.js +66 -0
- package/dist/public/proof-protocol.d.ts +31 -6
- package/dist/public/proof-protocol.d.ts.map +1 -1
- package/dist/public/proof-protocol.js +45 -15
- package/dist/public/proof-sources.d.ts +4 -2
- package/dist/public/proof-sources.d.ts.map +1 -1
- package/dist/public/proof-sources.js +43 -4
- package/dist/public/skills/kibi-usage/SKILL.md +6 -3
- package/dist/public/skills/kibi-usage/resources/prolog-proofs.md +207 -0
- package/dist/public/skills/kibi-usage/resources/proof.md +44 -3
- package/dist/schemas/entity.schema.json +34 -6
- package/dist/traceability/analysis-gate.d.ts +3 -1
- package/dist/traceability/analysis-gate.d.ts.map +1 -1
- package/dist/traceability/analysis-gate.js +9 -1
- package/dist/traceability/staged-file-coverage.d.ts.map +1 -1
- package/dist/traceability/staged-file-coverage.js +7 -2
- package/dist/traceability/symbol-extract.d.ts +17 -0
- package/dist/traceability/symbol-extract.d.ts.map +1 -1
- package/dist/traceability/symbol-extract.js +69 -15
- package/dist/traceability/validate.d.ts.map +1 -1
- package/dist/traceability/validate.js +5 -7
- package/dist/utils/first-sentence.d.ts +9 -0
- package/dist/utils/first-sentence.d.ts.map +1 -0
- package/dist/utils/first-sentence.js +52 -0
- package/dist/utils/rule-registry.generated.d.ts +6 -0
- package/dist/utils/rule-registry.generated.d.ts.map +1 -1
- package/dist/utils/rule-registry.generated.js +7 -0
- package/package.json +5 -5
- package/src/public/operations/check-executor.ts +8 -0
- package/src/public/operations/evidence-floor.ts +29 -1
- package/src/public/operations/specs/check-rules.generated.ts +2 -1
- package/src/public/operations/specs/reporting.ts +38 -3
- package/src/public/operations/specs/semantic.ts +2 -1
- package/src/public/operations/symbol-coordinates-check.ts +79 -0
- package/src/public/proof-protocol-types.d.ts +22 -5
- package/src/public/proof-protocol.ts +78 -19
- package/src/public/proof-sources.ts +51 -3
- package/src/public/skills/kibi-usage/SKILL.md +6 -3
- package/src/public/skills/kibi-usage/resources/prolog-proofs.md +207 -0
- package/src/public/skills/kibi-usage/resources/proof.md +44 -3
- package/src/schemas/entity.schema.json +34 -6
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Kibi — repo-local, per-branch, queryable long-term memory for software projects
|
|
3
|
+
Copyright (C) 2026 Piotr Franczyk
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU Affero General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* The SWI-Prolog evaluator behind the code proof kinds. Kibi runs it with the
|
|
20
|
+
* SWI-Prolog it resolves for its own engine (KIBI_SWIPL, the bundled runtime,
|
|
21
|
+
* then swipl on PATH). It loads the file a symbol names (a module, or a plain
|
|
22
|
+
* file into user) and reads a predicate named by its indicator: a domain is
|
|
23
|
+
* the distinct solutions of one argument (`arg`, or the only one), a value is
|
|
24
|
+
* the single number such a solution holds, a rule predicate is called once
|
|
25
|
+
* per row and decides it by success or failure, and a transition table lists
|
|
26
|
+
* every solution as an edge. The plan is the last command-line argument; the
|
|
27
|
+
* answer is the last line of output, in the JSON the JavaScript and Python
|
|
28
|
+
* evaluators print.
|
|
29
|
+
*/
|
|
30
|
+
// implements REQ-kibi-multilingual-code-proofs
|
|
31
|
+
export const PROLOG_EVALUATOR = String.raw `
|
|
32
|
+
:- module(kibi_proof_evaluator, []).
|
|
33
|
+
:- use_module(library(http/json)).
|
|
34
|
+
:- use_module(library(apply)).
|
|
35
|
+
:- use_module(library(lists)).
|
|
36
|
+
:- use_module(library(pairs)).
|
|
37
|
+
|
|
38
|
+
:- initialization(main, main).
|
|
39
|
+
|
|
40
|
+
:- dynamic loaded_module/2.
|
|
41
|
+
|
|
42
|
+
main :-
|
|
43
|
+
current_prolog_flag(argv, Argv),
|
|
44
|
+
last(Argv, PlanText),
|
|
45
|
+
atom_json_dict(PlanText, Plan, [value_string_as(string)]),
|
|
46
|
+
( catch(run(Plan, Out), Error, (failure_text(Error, Text), failed(Plan, Text, Out)))
|
|
47
|
+
-> true
|
|
48
|
+
; failed(Plan, "the evaluation failed", Out)
|
|
49
|
+
),
|
|
50
|
+
nl,
|
|
51
|
+
json_write_dict(current_output, Out, [width(0)]),
|
|
52
|
+
nl.
|
|
53
|
+
|
|
54
|
+
failed(Plan, Text, _{error: Text}) :- Plan.mode == "export", !.
|
|
55
|
+
failed(_, Text, _{ok: false, error: Text}).
|
|
56
|
+
|
|
57
|
+
failure_text(kibi(Text), Text) :- !.
|
|
58
|
+
failure_text(Error, Text) :-
|
|
59
|
+
catch('$messages':translate_message(Error, Lines, []), _, fail),
|
|
60
|
+
!,
|
|
61
|
+
with_output_to(string(Raw), print_message_lines(current_output, '', Lines)),
|
|
62
|
+
split_string(Raw, "", "\n ", [Text]).
|
|
63
|
+
failure_text(Error, Text) :- format(string(Text), "~q", [Error]).
|
|
64
|
+
|
|
65
|
+
refuse(Format, Args) :- format(string(Text), Format, Args), throw(kibi(Text)).
|
|
66
|
+
|
|
67
|
+
% The module a file defines, loaded once; user for a plain file.
|
|
68
|
+
module_of(File, Module) :- loaded_module(File, Module), !.
|
|
69
|
+
module_of(File, Module) :-
|
|
70
|
+
atom_string(Path, File),
|
|
71
|
+
load_files(user:Path, [if(not_loaded), silent(true)]),
|
|
72
|
+
absolute_file_name(Path, Absolute, [file_type(prolog), access(read)]),
|
|
73
|
+
( module_property(Defined, file(Absolute)) -> Module = Defined ; Module = user ),
|
|
74
|
+
assertz(loaded_module(File, Module)).
|
|
75
|
+
|
|
76
|
+
% A predicate indicator: Name/Arity, Name//Arity (a DCG rule) or Module:Indicator.
|
|
77
|
+
indicator(Text, Default, Module, Name, Arity) :-
|
|
78
|
+
catch(term_string(Term, Text), _, refuse("~s is not a predicate indicator Name/Arity", [Text])),
|
|
79
|
+
indicator_term(Term, Text, Default, Module, Name, Arity).
|
|
80
|
+
|
|
81
|
+
indicator_term(Module:Term, Text, _, Found, Name, Arity) :- atom(Module), !,
|
|
82
|
+
indicator_term(Term, Text, Module, Found, Name, Arity).
|
|
83
|
+
indicator_term(Name/Arity, _, Module, Module, Name, Arity) :- atom(Name), integer(Arity), Arity >= 0, !.
|
|
84
|
+
indicator_term(Name//Rule, _, Module, Module, Name, Arity) :- atom(Name), integer(Rule), Rule >= 0, !,
|
|
85
|
+
Arity is Rule + 2.
|
|
86
|
+
indicator_term(_, Text, _, _, _, _) :- refuse("~s is not a predicate indicator Name/Arity", [Text]).
|
|
87
|
+
|
|
88
|
+
% The goal behind a reference, after checking the predicate is defined.
|
|
89
|
+
predicate(Ref, Module, Head, Name, Arity) :-
|
|
90
|
+
module_of(Ref.file, Default),
|
|
91
|
+
indicator(Ref.export, Default, Module, Name, Arity),
|
|
92
|
+
functor(Head, Name, Arity),
|
|
93
|
+
( predicate_property(Module:Head, defined) -> true
|
|
94
|
+
; refuse("~s is not defined in ~s", [Ref.export, Ref.file])
|
|
95
|
+
).
|
|
96
|
+
|
|
97
|
+
% The argument a reference projects its solutions on: arg, or the only one.
|
|
98
|
+
projected(Ref, Arity, Index) :-
|
|
99
|
+
( get_dict(arg, Ref, Index)
|
|
100
|
+
-> ( integer(Index), Index >= 1, Index =< Arity -> true
|
|
101
|
+
; refuse("arg ~w is not an argument of ~s", [Index, Ref.export])
|
|
102
|
+
)
|
|
103
|
+
; Arity =:= 1
|
|
104
|
+
-> Index = 1
|
|
105
|
+
; Arity =:= 0
|
|
106
|
+
-> refuse("~s takes no argument to list", [Ref.export])
|
|
107
|
+
; refuse("~s has ~w arguments; set arg to the one that names each member", [Ref.export, Arity])
|
|
108
|
+
).
|
|
109
|
+
|
|
110
|
+
limit_solutions(100000).
|
|
111
|
+
|
|
112
|
+
% The distinct solutions of a reference's projected argument, in order.
|
|
113
|
+
values(Ref, Values) :-
|
|
114
|
+
predicate(Ref, Module, Head, _, Arity),
|
|
115
|
+
projected(Ref, Arity, Index),
|
|
116
|
+
arg(Index, Head, Value),
|
|
117
|
+
limit_solutions(Limit),
|
|
118
|
+
Over is Limit + 1,
|
|
119
|
+
findall(Value, limit(Over, Module:Head), All),
|
|
120
|
+
length(All, Count),
|
|
121
|
+
( Count > Limit -> refuse("~s has more than ~w solutions", [Ref.export, Limit]) ; true ),
|
|
122
|
+
( member(Open, All), \+ ground(Open)
|
|
123
|
+
-> refuse("a solution of ~s leaves argument ~w unbound", [Ref.export, Index])
|
|
124
|
+
; true
|
|
125
|
+
),
|
|
126
|
+
list_to_set(All, Values).
|
|
127
|
+
|
|
128
|
+
text(Value, Text) :- string(Value), !, Text = Value.
|
|
129
|
+
text(Value, Text) :- atom(Value), !, atom_string(Value, Text).
|
|
130
|
+
text(Value, Text) :- number(Value), !, number_string(Value, Text).
|
|
131
|
+
text(Value, Text) :- format(string(Text), "~q", [Value]).
|
|
132
|
+
|
|
133
|
+
run(Plan, Out) :- Plan.mode == "export", !, export(Plan, Out).
|
|
134
|
+
run(Plan, _{ok: true, model: Model}) :- Plan.mode == "table", !, table(Plan, Model).
|
|
135
|
+
run(Plan, _{ok: true, model: Model}) :- Plan.mode == "machine", !, machine(Plan, Model).
|
|
136
|
+
run(Plan, _{ok: true, model: Model}) :- Plan.mode == "pattern", !, pattern(Plan.pattern, Model).
|
|
137
|
+
run(Plan, _) :- refuse("unknown plan mode ~w", [Plan.mode]).
|
|
138
|
+
|
|
139
|
+
% A domain lists its members; a value is the single number a constant holds.
|
|
140
|
+
export(Plan, Out) :-
|
|
141
|
+
values(Plan.ref, Values),
|
|
142
|
+
( Plan.want == "scalar"
|
|
143
|
+
-> ( Values = [Number], number(Number)
|
|
144
|
+
-> Out = _{scalar: Number}
|
|
145
|
+
; Values = [Other]
|
|
146
|
+
-> refuse("~s holds ~q, not a number", [Plan.ref.export, Other])
|
|
147
|
+
; length(Values, Count),
|
|
148
|
+
refuse("~s has ~w solutions, not the single value of a constant", [Plan.ref.export, Count])
|
|
149
|
+
)
|
|
150
|
+
; length(Values, Count),
|
|
151
|
+
maplist(text, Values, Members),
|
|
152
|
+
Out = _{count: Count, members: Members}
|
|
153
|
+
).
|
|
154
|
+
|
|
155
|
+
domain(Ref, Values) :- get_dict(values, Ref, Texts), !, maplist(atom_string, Values, Texts).
|
|
156
|
+
domain(Ref, Values) :- values(Ref, Values).
|
|
157
|
+
|
|
158
|
+
table(Plan, _{domains: Domains, predicates: Predicates}) :-
|
|
159
|
+
dict_pairs(Plan.domains, _, DomainRefs),
|
|
160
|
+
findall(Type-Values, (member(Type-Ref, DomainRefs), domain(Ref, Values)), Typed),
|
|
161
|
+
findall(Type-Texts, (member(Type-Values, Typed), maplist(text, Values, Texts)), DomainTexts),
|
|
162
|
+
dict_pairs(Domains, _, DomainTexts),
|
|
163
|
+
dict_pairs(Plan.predicates, _, PredicateRefs),
|
|
164
|
+
foldl(predicate_table(Typed, Plan.limit), PredicateRefs, []-0, Reversed-_),
|
|
165
|
+
reverse(Reversed, Rows),
|
|
166
|
+
dict_pairs(Predicates, _, Rows).
|
|
167
|
+
|
|
168
|
+
predicate_table(Typed, Limit, Name-Ref, Done-Used, [Name-Rows|Done]-Total) :-
|
|
169
|
+
predicate(Ref, Module, Head, _, Arity),
|
|
170
|
+
length(Ref.arg_types, Types),
|
|
171
|
+
( Types =:= Arity -> true
|
|
172
|
+
; refuse("~s takes ~w arguments, but the predicate ~w has ~w argument types", [Ref.export, Arity, Name, Types])
|
|
173
|
+
),
|
|
174
|
+
findall(Values,
|
|
175
|
+
( member(TypeText, Ref.arg_types),
|
|
176
|
+
atom_string(Type, TypeText),
|
|
177
|
+
( memberchk(Type-Values, Typed) -> true
|
|
178
|
+
; refuse("no domain for argument type ~s of ~w", [TypeText, Name])
|
|
179
|
+
)
|
|
180
|
+
),
|
|
181
|
+
Lists),
|
|
182
|
+
foldl([List, P0, P]>>(length(List, L), P is P0 * L), Lists, 1, Count),
|
|
183
|
+
Total is Used + Count,
|
|
184
|
+
( Total > Limit -> refuse("the predicate tables need more than ~w calls", [Limit]) ; true ),
|
|
185
|
+
findall(Row, (maplist(member, Tuple, Lists), row(Module, Head, Tuple, Row)), Rows).
|
|
186
|
+
|
|
187
|
+
row(Module, Head, Tuple, Row) :-
|
|
188
|
+
copy_term(Head, Goal),
|
|
189
|
+
Goal =.. [_|Tuple],
|
|
190
|
+
maplist(text, Tuple, Args),
|
|
191
|
+
catch(( once(Module:Goal) -> Row = _{args: Args, value: true} ; Row = _{args: Args, value: false} ),
|
|
192
|
+
Error,
|
|
193
|
+
( failure_text(Error, Text), Row = _{args: Args, error: Text} )).
|
|
194
|
+
|
|
195
|
+
% A transition table: Name/2 facts (from, to), Name/3 facts (from, event,
|
|
196
|
+
% to), or with state and event domains a Name/3 next-state predicate Kibi
|
|
197
|
+
% calls on every state and event.
|
|
198
|
+
machine(Plan, Model) :-
|
|
199
|
+
Ref = Plan.transitions,
|
|
200
|
+
predicate(Ref, Module, Head, _, Arity),
|
|
201
|
+
( get_dict(domains, Plan, Domains)
|
|
202
|
+
-> ( Arity =:= 3 -> true ; refuse("~s must take a state, an event and the next state", [Ref.export]) ),
|
|
203
|
+
values(Domains.state, States0),
|
|
204
|
+
values(Domains.event, Events),
|
|
205
|
+
findall(From-To,
|
|
206
|
+
( member(From, States0), member(Event, Events),
|
|
207
|
+
Head =.. [_, From, Event, To],
|
|
208
|
+
catch(Module:Head, _, fail)
|
|
209
|
+
),
|
|
210
|
+
Edges)
|
|
211
|
+
; Arity =:= 2
|
|
212
|
+
-> Head =.. [_, From, To],
|
|
213
|
+
findall(From-To, Module:Head, Edges),
|
|
214
|
+
States0 = []
|
|
215
|
+
; Arity =:= 3
|
|
216
|
+
-> Head =.. [_, From, _, To],
|
|
217
|
+
findall(From-To, Module:Head, Edges),
|
|
218
|
+
States0 = []
|
|
219
|
+
; refuse("~s is not a transition table Name/2 or Name/3", [Ref.export])
|
|
220
|
+
),
|
|
221
|
+
( member(Edge, Edges), \+ ground(Edge) -> refuse("a transition of ~s leaves a state unbound", [Ref.export]) ; true ),
|
|
222
|
+
findall(Text, (member(State, States0), text(State, Text)), Listed),
|
|
223
|
+
findall([FromText, ToText], (member(F-T, Edges), text(F, FromText), text(T, ToText)), Pairs0),
|
|
224
|
+
sort(Pairs0, Pairs),
|
|
225
|
+
findall(S, (member([A, B], Pairs), member(S, [A, B])), Ends),
|
|
226
|
+
append(Listed, Ends, AllStates),
|
|
227
|
+
sort(AllStates, StateTexts),
|
|
228
|
+
Base = _{states: StateTexts, transitions: Pairs},
|
|
229
|
+
( get_dict(initial, Plan, Initial), Initial \== null
|
|
230
|
+
-> values(Initial, InitialValues),
|
|
231
|
+
maplist(text, InitialValues, InitialTexts0),
|
|
232
|
+
sort(InitialTexts0, InitialTexts),
|
|
233
|
+
Model = Base.put(initial, InitialTexts)
|
|
234
|
+
; Model = Base
|
|
235
|
+
).
|
|
236
|
+
|
|
237
|
+
% A pattern constant: the single atom or string a Name/1 fact holds.
|
|
238
|
+
pattern(Ref, _{type: "string", value: Text}) :-
|
|
239
|
+
values(Ref, Values),
|
|
240
|
+
( Values = [Value], (atom(Value) ; string(Value))
|
|
241
|
+
-> text(Value, Text)
|
|
242
|
+
; Values = [Other]
|
|
243
|
+
-> refuse("~s holds ~q, not an atom or a string", [Ref.export, Other])
|
|
244
|
+
; length(Values, Count),
|
|
245
|
+
refuse("~s has ~w solutions, not the single pattern of a constant", [Ref.export, Count])
|
|
246
|
+
).
|
|
247
|
+
`;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SWI-Prolog reader behind the `references` reader for `.pl` and `.plt`
|
|
3
|
+
* files and the `prolog` source reader. It reads terms with read_term/3 and
|
|
4
|
+
* runs none of the project's code: operators come from the file's own op/3
|
|
5
|
+
* directives and module export lists, those of project modules it loads
|
|
6
|
+
* (read from their module header) and those of the SWI-Prolog libraries it
|
|
7
|
+
* loads. `references` mode walks clause bodies and directives through
|
|
8
|
+
* control constructs and meta-predicate arguments (the file's own
|
|
9
|
+
* meta_predicate declarations and SWI-Prolog's), the goals ~@ calls in
|
|
10
|
+
* format strings and message lines, and the bodies of clauses
|
|
11
|
+
* asserted from literal terms, and reports every place it cannot read
|
|
12
|
+
* statically: a variable called as a goal or closure, a goal qualified by a
|
|
13
|
+
* variable module, a clause asserted from data, conditional compilation, a
|
|
14
|
+
* term_expansion or goal_expansion clause in the files or in a project file
|
|
15
|
+
* they load (expansion can produce any clause), and an include of a file
|
|
16
|
+
* outside the files read. `terms` mode lists one argument of every fact with
|
|
17
|
+
* a given functor, in file order.
|
|
18
|
+
*/
|
|
19
|
+
export declare const PROLOG_SOURCE_READER: string;
|
|
20
|
+
//# sourceMappingURL=prolog-source-reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prolog-source-reader.d.ts","sourceRoot":"","sources":["../../../src/operations/proof/prolog-source-reader.ts"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;;GAiBG;AAEH,eAAO,MAAM,oBAAoB,QA8jChC,CAAC"}
|