@polintpro/proposit-core 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +521 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/core/ArgumentEngine.d.ts +41 -0
- package/dist/lib/core/ArgumentEngine.d.ts.map +1 -0
- package/dist/lib/core/ArgumentEngine.js +408 -0
- package/dist/lib/core/ArgumentEngine.js.map +1 -0
- package/dist/lib/core/ExpressionManager.d.ts +19 -0
- package/dist/lib/core/ExpressionManager.d.ts.map +1 -0
- package/dist/lib/core/ExpressionManager.js +352 -0
- package/dist/lib/core/ExpressionManager.js.map +1 -0
- package/dist/lib/core/PremiseManager.d.ts +110 -0
- package/dist/lib/core/PremiseManager.d.ts.map +1 -0
- package/dist/lib/core/PremiseManager.js +541 -0
- package/dist/lib/core/PremiseManager.js.map +1 -0
- package/dist/lib/core/VariableManager.d.ts +17 -0
- package/dist/lib/core/VariableManager.d.ts.map +1 -0
- package/dist/lib/core/VariableManager.js +40 -0
- package/dist/lib/core/VariableManager.js.map +1 -0
- package/dist/lib/core/evaluation/shared.d.ts +6 -0
- package/dist/lib/core/evaluation/shared.d.ts.map +1 -0
- package/dist/lib/core/evaluation/shared.js +23 -0
- package/dist/lib/core/evaluation/shared.js.map +1 -0
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +4 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/schemata/argument.d.ts +9 -0
- package/dist/lib/schemata/argument.d.ts.map +1 -0
- package/dist/lib/schemata/argument.js +9 -0
- package/dist/lib/schemata/argument.js.map +1 -0
- package/dist/lib/schemata/index.d.ts +4 -0
- package/dist/lib/schemata/index.d.ts.map +1 -0
- package/dist/lib/schemata/index.js +4 -0
- package/dist/lib/schemata/index.js.map +1 -0
- package/dist/lib/schemata/propositional.d.ts +107 -0
- package/dist/lib/schemata/propositional.d.ts.map +1 -0
- package/dist/lib/schemata/propositional.js +77 -0
- package/dist/lib/schemata/propositional.js.map +1 -0
- package/dist/lib/schemata/shared.d.ts +4 -0
- package/dist/lib/schemata/shared.d.ts.map +1 -0
- package/dist/lib/schemata/shared.js +6 -0
- package/dist/lib/schemata/shared.js.map +1 -0
- package/dist/lib/types/evaluation.d.ts +108 -0
- package/dist/lib/types/evaluation.d.ts.map +1 -0
- package/dist/lib/types/evaluation.js +2 -0
- package/dist/lib/types/evaluation.js.map +1 -0
- package/dist/lib/utils/collections.d.ts +6 -0
- package/dist/lib/utils/collections.d.ts.map +1 -0
- package/dist/lib/utils/collections.js +18 -0
- package/dist/lib/utils/collections.js.map +1 -0
- package/dist/lib/utils.d.ts +10 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +31 -0
- package/dist/lib/utils.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { getOrCreate } from "../utils/collections";
|
|
2
|
+
export class ExpressionManager {
|
|
3
|
+
expressions;
|
|
4
|
+
childExpressionIdsByParentId;
|
|
5
|
+
childPositionsByParentId;
|
|
6
|
+
constructor(initialExpressions = []) {
|
|
7
|
+
this.expressions = new Map();
|
|
8
|
+
this.childExpressionIdsByParentId = new Map();
|
|
9
|
+
this.childPositionsByParentId = new Map();
|
|
10
|
+
this.loadInitialExpressions(initialExpressions);
|
|
11
|
+
}
|
|
12
|
+
toArray() {
|
|
13
|
+
return Array.from(this.expressions.values());
|
|
14
|
+
}
|
|
15
|
+
addExpression(expression) {
|
|
16
|
+
if (this.expressions.has(expression.id)) {
|
|
17
|
+
throw new Error(`Expression with ID "${expression.id}" already exists.`);
|
|
18
|
+
}
|
|
19
|
+
if (expression.parentId === expression.id) {
|
|
20
|
+
throw new Error(`Expression "${expression.id}" cannot be its own parent.`);
|
|
21
|
+
}
|
|
22
|
+
if (expression.type === "operator" &&
|
|
23
|
+
(expression.operator === "implies" ||
|
|
24
|
+
expression.operator === "iff") &&
|
|
25
|
+
expression.parentId !== null) {
|
|
26
|
+
throw new Error(`Operator expression "${expression.id}" with "${expression.operator}" must be a root expression (parentId must be null).`);
|
|
27
|
+
}
|
|
28
|
+
if (expression.parentId !== null) {
|
|
29
|
+
const parent = this.expressions.get(expression.parentId);
|
|
30
|
+
if (!parent) {
|
|
31
|
+
throw new Error(`Parent expression "${expression.parentId}" does not exist.`);
|
|
32
|
+
}
|
|
33
|
+
if (parent.type !== "operator" && parent.type !== "formula") {
|
|
34
|
+
throw new Error(`Parent expression "${expression.parentId}" is not an operator expression.`);
|
|
35
|
+
}
|
|
36
|
+
if (parent.type === "operator") {
|
|
37
|
+
this.assertChildLimit(parent.operator, expression.parentId);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const childCount = this.childExpressionIdsByParentId.get(expression.parentId)
|
|
41
|
+
?.size ?? 0;
|
|
42
|
+
if (childCount >= 1) {
|
|
43
|
+
throw new Error(`Formula expression "${expression.parentId}" can only have one child.`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (expression.position !== null) {
|
|
48
|
+
const occupiedPositions = getOrCreate(this.childPositionsByParentId, expression.parentId, () => new Set());
|
|
49
|
+
if (occupiedPositions.has(expression.position)) {
|
|
50
|
+
throw new Error(`Position ${expression.position} is already used under parent "${expression.parentId}".`);
|
|
51
|
+
}
|
|
52
|
+
occupiedPositions.add(expression.position);
|
|
53
|
+
}
|
|
54
|
+
this.expressions.set(expression.id, expression);
|
|
55
|
+
getOrCreate(this.childExpressionIdsByParentId, expression.parentId, () => new Set()).add(expression.id);
|
|
56
|
+
}
|
|
57
|
+
removeExpression(expressionId) {
|
|
58
|
+
const target = this.expressions.get(expressionId);
|
|
59
|
+
if (!target) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const parentId = target.parentId;
|
|
63
|
+
const toRemove = new Set();
|
|
64
|
+
const stack = [expressionId];
|
|
65
|
+
while (stack.length > 0) {
|
|
66
|
+
const currentId = stack.pop();
|
|
67
|
+
if (!currentId || toRemove.has(currentId)) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
toRemove.add(currentId);
|
|
71
|
+
const children = this.childExpressionIdsByParentId.get(currentId);
|
|
72
|
+
if (!children) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
for (const childId of children) {
|
|
76
|
+
stack.push(childId);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
for (const id of toRemove) {
|
|
80
|
+
const expression = this.expressions.get(id);
|
|
81
|
+
if (!expression) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
this.expressions.delete(id);
|
|
85
|
+
this.childExpressionIdsByParentId
|
|
86
|
+
.get(expression.parentId)
|
|
87
|
+
?.delete(id);
|
|
88
|
+
if (expression.position !== null) {
|
|
89
|
+
this.childPositionsByParentId
|
|
90
|
+
.get(expression.parentId)
|
|
91
|
+
?.delete(expression.position);
|
|
92
|
+
}
|
|
93
|
+
this.childExpressionIdsByParentId.delete(id);
|
|
94
|
+
this.childPositionsByParentId.delete(id);
|
|
95
|
+
}
|
|
96
|
+
this.collapseIfNeeded(parentId);
|
|
97
|
+
return target;
|
|
98
|
+
}
|
|
99
|
+
collapseIfNeeded(operatorId) {
|
|
100
|
+
if (operatorId === null)
|
|
101
|
+
return;
|
|
102
|
+
const operator = this.expressions.get(operatorId);
|
|
103
|
+
if (!operator)
|
|
104
|
+
return;
|
|
105
|
+
if (operator.type === "formula") {
|
|
106
|
+
const children = this.getChildExpressions(operatorId);
|
|
107
|
+
if (children.length === 0) {
|
|
108
|
+
const grandparentId = operator.parentId;
|
|
109
|
+
this.expressions.delete(operatorId);
|
|
110
|
+
this.childExpressionIdsByParentId
|
|
111
|
+
.get(grandparentId)
|
|
112
|
+
?.delete(operatorId);
|
|
113
|
+
if (operator.position !== null) {
|
|
114
|
+
this.childPositionsByParentId
|
|
115
|
+
.get(grandparentId)
|
|
116
|
+
?.delete(operator.position);
|
|
117
|
+
}
|
|
118
|
+
this.childExpressionIdsByParentId.delete(operatorId);
|
|
119
|
+
this.childPositionsByParentId.delete(operatorId);
|
|
120
|
+
this.collapseIfNeeded(grandparentId);
|
|
121
|
+
}
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (operator.type !== "operator")
|
|
125
|
+
return;
|
|
126
|
+
const children = this.getChildExpressions(operatorId);
|
|
127
|
+
if (children.length === 0) {
|
|
128
|
+
const grandparentId = operator.parentId;
|
|
129
|
+
const grandparentPosition = operator.position;
|
|
130
|
+
this.expressions.delete(operatorId);
|
|
131
|
+
this.childExpressionIdsByParentId
|
|
132
|
+
.get(grandparentId)
|
|
133
|
+
?.delete(operatorId);
|
|
134
|
+
if (grandparentPosition !== null) {
|
|
135
|
+
this.childPositionsByParentId
|
|
136
|
+
.get(grandparentId)
|
|
137
|
+
?.delete(grandparentPosition);
|
|
138
|
+
}
|
|
139
|
+
this.childExpressionIdsByParentId.delete(operatorId);
|
|
140
|
+
this.childPositionsByParentId.delete(operatorId);
|
|
141
|
+
this.collapseIfNeeded(grandparentId);
|
|
142
|
+
}
|
|
143
|
+
else if (children.length === 1) {
|
|
144
|
+
const child = children[0];
|
|
145
|
+
const grandparentId = operator.parentId;
|
|
146
|
+
const grandparentPosition = operator.position;
|
|
147
|
+
// Promote the surviving child into the operator's slot in the grandparent.
|
|
148
|
+
const promoted = {
|
|
149
|
+
...child,
|
|
150
|
+
parentId: grandparentId,
|
|
151
|
+
position: grandparentPosition,
|
|
152
|
+
};
|
|
153
|
+
this.expressions.set(child.id, promoted);
|
|
154
|
+
// Replace the operator with the promoted child in the grandparent's child-id set.
|
|
155
|
+
this.childExpressionIdsByParentId
|
|
156
|
+
.get(grandparentId)
|
|
157
|
+
?.delete(operatorId);
|
|
158
|
+
getOrCreate(this.childExpressionIdsByParentId, grandparentId, () => new Set()).add(child.id);
|
|
159
|
+
// The grandparent's position set is unchanged: grandparentPosition was
|
|
160
|
+
// already tracked for the operator and continues to be occupied by the
|
|
161
|
+
// promoted child.
|
|
162
|
+
// Remove the operator's own tracking entries.
|
|
163
|
+
this.childExpressionIdsByParentId.delete(operatorId);
|
|
164
|
+
this.childPositionsByParentId.delete(operatorId);
|
|
165
|
+
this.expressions.delete(operatorId);
|
|
166
|
+
// The grandparent's child count is unchanged; no further recursion needed.
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
hasVariableReference(variableId) {
|
|
170
|
+
for (const expression of this.expressions.values()) {
|
|
171
|
+
if (expression.type === "variable" &&
|
|
172
|
+
expression.variableId === variableId) {
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
getExpression(expressionId) {
|
|
179
|
+
return this.expressions.get(expressionId);
|
|
180
|
+
}
|
|
181
|
+
getChildExpressions(parentId) {
|
|
182
|
+
const childIds = this.childExpressionIdsByParentId.get(parentId);
|
|
183
|
+
if (!childIds || childIds.size === 0) {
|
|
184
|
+
return [];
|
|
185
|
+
}
|
|
186
|
+
const children = [];
|
|
187
|
+
for (const childId of childIds) {
|
|
188
|
+
const child = this.expressions.get(childId);
|
|
189
|
+
if (child) {
|
|
190
|
+
children.push(child);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return children.sort((a, b) => {
|
|
194
|
+
if (a.position === null && b.position === null) {
|
|
195
|
+
return a.id.localeCompare(b.id);
|
|
196
|
+
}
|
|
197
|
+
if (a.position === null) {
|
|
198
|
+
return 1;
|
|
199
|
+
}
|
|
200
|
+
if (b.position === null) {
|
|
201
|
+
return -1;
|
|
202
|
+
}
|
|
203
|
+
return a.position - b.position;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
loadInitialExpressions(initialExpressions) {
|
|
207
|
+
if (initialExpressions.length === 0) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const pending = new Map(initialExpressions.map((expression) => [expression.id, expression]));
|
|
211
|
+
let progressed = true;
|
|
212
|
+
while (pending.size > 0 && progressed) {
|
|
213
|
+
progressed = false;
|
|
214
|
+
for (const [id, expression] of Array.from(pending.entries())) {
|
|
215
|
+
if (expression.parentId !== null &&
|
|
216
|
+
!this.expressions.has(expression.parentId)) {
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
this.addExpression(expression);
|
|
220
|
+
pending.delete(id);
|
|
221
|
+
progressed = true;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (pending.size > 0) {
|
|
225
|
+
const unresolved = Array.from(pending.keys()).join(", ");
|
|
226
|
+
throw new Error(`Could not resolve parent relationships for expressions: ${unresolved}.`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
assertChildLimit(operator, parentId) {
|
|
230
|
+
const childCount = this.childExpressionIdsByParentId.get(parentId)?.size ?? 0;
|
|
231
|
+
if (operator === "not" && childCount >= 1) {
|
|
232
|
+
throw new Error(`Operator expression "${parentId}" with "not" can only have one child.`);
|
|
233
|
+
}
|
|
234
|
+
if ((operator === "implies" || operator === "iff") && childCount >= 2) {
|
|
235
|
+
throw new Error(`Operator expression "${parentId}" with "${operator}" can only have two children.`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
reparent(expressionId, newParentId, newPosition) {
|
|
239
|
+
const expression = this.expressions.get(expressionId);
|
|
240
|
+
// Detach from old parent.
|
|
241
|
+
this.childExpressionIdsByParentId
|
|
242
|
+
.get(expression.parentId)
|
|
243
|
+
?.delete(expressionId);
|
|
244
|
+
if (expression.position !== null) {
|
|
245
|
+
this.childPositionsByParentId
|
|
246
|
+
.get(expression.parentId)
|
|
247
|
+
?.delete(expression.position);
|
|
248
|
+
}
|
|
249
|
+
// Replace the stored value (expressions are immutable value objects).
|
|
250
|
+
const updated = {
|
|
251
|
+
...expression,
|
|
252
|
+
parentId: newParentId,
|
|
253
|
+
position: newPosition,
|
|
254
|
+
};
|
|
255
|
+
this.expressions.set(expressionId, updated);
|
|
256
|
+
// Attach to new parent.
|
|
257
|
+
getOrCreate(this.childExpressionIdsByParentId, newParentId, () => new Set()).add(expressionId);
|
|
258
|
+
if (newPosition !== null) {
|
|
259
|
+
getOrCreate(this.childPositionsByParentId, newParentId, () => new Set()).add(newPosition);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
insertExpression(expression, leftNodeId, rightNodeId) {
|
|
263
|
+
// 1. At least one child node must be provided.
|
|
264
|
+
if (leftNodeId === undefined && rightNodeId === undefined) {
|
|
265
|
+
throw new Error(`insertExpression requires at least one of leftNodeId or rightNodeId.`);
|
|
266
|
+
}
|
|
267
|
+
// 2. The new expression's ID must not already exist.
|
|
268
|
+
if (this.expressions.has(expression.id)) {
|
|
269
|
+
throw new Error(`Expression with ID "${expression.id}" already exists.`);
|
|
270
|
+
}
|
|
271
|
+
// 3. An expression cannot be its own parent.
|
|
272
|
+
if (expression.parentId === expression.id) {
|
|
273
|
+
throw new Error(`Expression "${expression.id}" cannot be its own parent.`);
|
|
274
|
+
}
|
|
275
|
+
// 4. Left and right nodes must be distinct.
|
|
276
|
+
if (leftNodeId !== undefined &&
|
|
277
|
+
rightNodeId !== undefined &&
|
|
278
|
+
leftNodeId === rightNodeId) {
|
|
279
|
+
throw new Error(`leftNodeId and rightNodeId must be different.`);
|
|
280
|
+
}
|
|
281
|
+
// 5. The left node must exist if provided.
|
|
282
|
+
const leftNode = leftNodeId !== undefined
|
|
283
|
+
? this.expressions.get(leftNodeId)
|
|
284
|
+
: undefined;
|
|
285
|
+
if (leftNodeId !== undefined && !leftNode) {
|
|
286
|
+
throw new Error(`Expression "${leftNodeId}" does not exist.`);
|
|
287
|
+
}
|
|
288
|
+
// 6. The right node must exist if provided.
|
|
289
|
+
const rightNode = rightNodeId !== undefined
|
|
290
|
+
? this.expressions.get(rightNodeId)
|
|
291
|
+
: undefined;
|
|
292
|
+
if (rightNodeId !== undefined && !rightNode) {
|
|
293
|
+
throw new Error(`Expression "${rightNodeId}" does not exist.`);
|
|
294
|
+
}
|
|
295
|
+
// 7. The "not" operator is unary and cannot take two children.
|
|
296
|
+
if (expression.type === "operator" &&
|
|
297
|
+
expression.operator === "not" &&
|
|
298
|
+
leftNodeId !== undefined &&
|
|
299
|
+
rightNodeId !== undefined) {
|
|
300
|
+
throw new Error(`Operator expression "${expression.id}" with "not" can only have one child.`);
|
|
301
|
+
}
|
|
302
|
+
// 7b. A formula expression is also unary and cannot take two children.
|
|
303
|
+
if (expression.type === "formula" &&
|
|
304
|
+
leftNodeId !== undefined &&
|
|
305
|
+
rightNodeId !== undefined) {
|
|
306
|
+
throw new Error(`Formula expression "${expression.id}" can only have one child.`);
|
|
307
|
+
}
|
|
308
|
+
// 8. The left node must not be an implies/iff expression (which must remain a root).
|
|
309
|
+
if (leftNode?.type === "operator" &&
|
|
310
|
+
(leftNode.operator === "implies" || leftNode.operator === "iff")) {
|
|
311
|
+
throw new Error(`Expression "${leftNodeId}" with "${leftNode.operator}" cannot be subordinated (it must remain a root expression).`);
|
|
312
|
+
}
|
|
313
|
+
// 9. The right node must not be an implies/iff expression (which must remain a root).
|
|
314
|
+
if (rightNode?.type === "operator" &&
|
|
315
|
+
(rightNode.operator === "implies" || rightNode.operator === "iff")) {
|
|
316
|
+
throw new Error(`Expression "${rightNodeId}" with "${rightNode.operator}" cannot be subordinated (it must remain a root expression).`);
|
|
317
|
+
}
|
|
318
|
+
// The anchor is the node whose current tree slot the new expression will inherit.
|
|
319
|
+
const anchor = (leftNode ?? rightNode);
|
|
320
|
+
// 10. implies/iff expressions may only be inserted at the root of the tree.
|
|
321
|
+
if (expression.type === "operator" &&
|
|
322
|
+
(expression.operator === "implies" ||
|
|
323
|
+
expression.operator === "iff") &&
|
|
324
|
+
anchor.parentId !== null) {
|
|
325
|
+
throw new Error(`Operator expression "${expression.id}" with "${expression.operator}" must be a root expression (parentId must be null).`);
|
|
326
|
+
}
|
|
327
|
+
const anchorParentId = anchor.parentId;
|
|
328
|
+
const anchorPosition = anchor.position;
|
|
329
|
+
// Reparent rightNode first in case it is a descendant of leftNode.
|
|
330
|
+
if (rightNodeId !== undefined) {
|
|
331
|
+
this.reparent(rightNodeId, expression.id, 1);
|
|
332
|
+
}
|
|
333
|
+
if (leftNodeId !== undefined) {
|
|
334
|
+
this.reparent(leftNodeId, expression.id, 0);
|
|
335
|
+
}
|
|
336
|
+
// Store the new expression in the freed anchor slot.
|
|
337
|
+
const stored = {
|
|
338
|
+
...expression,
|
|
339
|
+
parentId: anchorParentId,
|
|
340
|
+
position: anchorPosition,
|
|
341
|
+
};
|
|
342
|
+
this.expressions.set(expression.id, stored);
|
|
343
|
+
getOrCreate(this.childExpressionIdsByParentId, anchorParentId, () => new Set()).add(expression.id);
|
|
344
|
+
if (anchorPosition !== null) {
|
|
345
|
+
getOrCreate(this.childPositionsByParentId, anchorParentId, () => new Set()).add(anchorPosition);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
// ---------------------------------------------------------------------------
|
|
350
|
+
// PremiseManager
|
|
351
|
+
// ---------------------------------------------------------------------------
|
|
352
|
+
//# sourceMappingURL=ExpressionManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpressionManager.js","sourceRoot":"","sources":["../../../src/lib/core/ExpressionManager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAElD,MAAM,OAAO,iBAAiB;IAClB,WAAW,CAAuC;IAClD,4BAA4B,CAAiC;IAC7D,wBAAwB,CAAiC;IAEjE,YAAY,qBAAiD,EAAE;QAC3D,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,EAAE,CAAA;QAC5B,IAAI,CAAC,4BAA4B,GAAG,IAAI,GAAG,EAAE,CAAA;QAC7C,IAAI,CAAC,wBAAwB,GAAG,IAAI,GAAG,EAAE,CAAA;QAEzC,IAAI,CAAC,sBAAsB,CAAC,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I,WAAW,KAAK,SAAS,EAAE,CAAC;YAC5B,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;QAChD,CAAC;QACD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC3B,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;QAC/C,CAAC;QAED,qDAAqD;QACrD,MAAM,MAAM,GAAG;YACX,GAAG,UAAU;YACb,QAAQ,EAAE,cAAc;YACxB,QAAQ,EAAE,cAAc;SACC,CAAA;QAC7B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;QAC3C,WAAW,CACP,IAAI,CAAC,4BAA4B,EACjC,cAAc,EACd,GAAG,EAAE,CAAC,IAAI,GAAG,EAAE,CAClB,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;QACpB,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;YAC1B,WAAW,CACP,IAAI,CAAC,wBAAwB,EAC7B,cAAc,EACd,GAAG,EAAE,CAAC,IAAI,GAAG,EAAE,CAClB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;QACzB,CAAC;IACL,CAAC;CACJ;AAED,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { TArgument, TPremise, TPropositionalExpression, TPropositionalVariable } from "../schemata";
|
|
2
|
+
import type { TPremiseEvaluationResult, TValidationResult, TVariableAssignment } from "../types/evaluation";
|
|
3
|
+
export declare class PremiseManager {
|
|
4
|
+
private id;
|
|
5
|
+
private title;
|
|
6
|
+
private rootExpressionId;
|
|
7
|
+
private variables;
|
|
8
|
+
private expressions;
|
|
9
|
+
private expressionsByVariableId;
|
|
10
|
+
private argument;
|
|
11
|
+
constructor(id: string, argument: TArgument, title?: string);
|
|
12
|
+
/**
|
|
13
|
+
* Registers a propositional variable for use within this premise.
|
|
14
|
+
*
|
|
15
|
+
* @throws If `variable.symbol` is already in use within this premise.
|
|
16
|
+
* @throws If `variable.id` already exists within this premise.
|
|
17
|
+
* @throws If the variable does not belong to this premise's argument.
|
|
18
|
+
*/
|
|
19
|
+
addVariable(variable: TPropositionalVariable): void;
|
|
20
|
+
/**
|
|
21
|
+
* Removes a variable from this premise's registry and returns it, or
|
|
22
|
+
* `undefined` if it was not found.
|
|
23
|
+
*
|
|
24
|
+
* @throws If any expression in this premise still references the variable.
|
|
25
|
+
*/
|
|
26
|
+
removeVariable(variableId: string): TPropositionalVariable | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Adds an expression to this premise's tree.
|
|
29
|
+
*
|
|
30
|
+
* If the expression has `parentId: null` it becomes the root; only one
|
|
31
|
+
* root is permitted per premise. If `parentId` is non-null the parent
|
|
32
|
+
* must already exist within this premise.
|
|
33
|
+
*
|
|
34
|
+
* All other structural rules (`implies`/`iff` root-only, child limits,
|
|
35
|
+
* position uniqueness) are enforced by the underlying `ExpressionManager`.
|
|
36
|
+
*
|
|
37
|
+
* @throws If the premise already has a root expression and this one is also a root.
|
|
38
|
+
* @throws If the expression's parent does not exist in this premise.
|
|
39
|
+
* @throws If the expression is a variable reference and the variable has not been registered.
|
|
40
|
+
* @throws If the expression does not belong to this argument.
|
|
41
|
+
*/
|
|
42
|
+
addExpression(expression: TPropositionalExpression): void;
|
|
43
|
+
/**
|
|
44
|
+
* Removes an expression and its entire descendant subtree, then collapses
|
|
45
|
+
* any ancestor operators with fewer than two children (same semantics as
|
|
46
|
+
* before). Returns the removed root expression, or `undefined` if not
|
|
47
|
+
* found.
|
|
48
|
+
*
|
|
49
|
+
* `rootExpressionId` is recomputed after every removal because operator
|
|
50
|
+
* collapse can silently promote a new expression into the root slot.
|
|
51
|
+
*/
|
|
52
|
+
removeExpression(expressionId: string): TPropositionalExpression | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Splices a new expression between existing nodes in the tree. The new
|
|
55
|
+
* expression inherits the tree slot of the anchor node
|
|
56
|
+
* (`leftNodeId ?? rightNodeId`).
|
|
57
|
+
*
|
|
58
|
+
* `rootExpressionId` is recomputed after every insertion because the
|
|
59
|
+
* anchor may have been the root.
|
|
60
|
+
*
|
|
61
|
+
* See `ArgumentEngine.insertExpression` for the full contract; the same
|
|
62
|
+
* rules apply here.
|
|
63
|
+
*
|
|
64
|
+
* @throws If the expression does not belong to this argument.
|
|
65
|
+
* @throws If the expression is a variable reference and the variable has not been registered.
|
|
66
|
+
*/
|
|
67
|
+
insertExpression(expression: TPropositionalExpression, leftNodeId?: string, rightNodeId?: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* Returns an expression by ID, or `undefined` if not found in this
|
|
70
|
+
* premise.
|
|
71
|
+
*/
|
|
72
|
+
getExpression(id: string): TPropositionalExpression | undefined;
|
|
73
|
+
getId(): string;
|
|
74
|
+
getTitle(): string | undefined;
|
|
75
|
+
getRootExpressionId(): string | undefined;
|
|
76
|
+
getRootExpression(): TPropositionalExpression | undefined;
|
|
77
|
+
getVariables(): TPropositionalVariable[];
|
|
78
|
+
getExpressions(): TPropositionalExpression[];
|
|
79
|
+
getChildExpressions(parentId: string | null): TPropositionalExpression[];
|
|
80
|
+
getPremiseType(): "inference" | "constraint";
|
|
81
|
+
validateEvaluability(): TValidationResult;
|
|
82
|
+
evaluate(assignment: TVariableAssignment, options?: {
|
|
83
|
+
strictUnknownKeys?: boolean;
|
|
84
|
+
requireExactCoverage?: boolean;
|
|
85
|
+
}): TPremiseEvaluationResult;
|
|
86
|
+
/**
|
|
87
|
+
* Returns a human-readable string of this premise's expression tree using
|
|
88
|
+
* standard logical notation (∧ ∨ ¬ → ↔). Missing operands are rendered
|
|
89
|
+
* as `(?)`. Returns an empty string when the premise has no expressions.
|
|
90
|
+
*/
|
|
91
|
+
toDisplayString(): string;
|
|
92
|
+
/**
|
|
93
|
+
* Returns a serialisable snapshot of this premise conforming to
|
|
94
|
+
* `TPremise`. `variables` contains only the variables that are actually
|
|
95
|
+
* referenced by expressions in this premise. `type` is derived from the
|
|
96
|
+
* root expression: `"inference"` if the root is an `implies` or `iff`
|
|
97
|
+
* operator, `"constraint"` otherwise (including when the premise is empty).
|
|
98
|
+
*/
|
|
99
|
+
toData(): TPremise;
|
|
100
|
+
/**
|
|
101
|
+
* Re-reads the single root from ExpressionManager after any operation
|
|
102
|
+
* that may have caused operator collapse to silently change the root.
|
|
103
|
+
*/
|
|
104
|
+
private syncRootExpressionId;
|
|
105
|
+
private collectSubtree;
|
|
106
|
+
private assertBelongsToArgument;
|
|
107
|
+
private renderExpression;
|
|
108
|
+
private operatorSymbol;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=PremiseManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PremiseManager.d.ts","sourceRoot":"","sources":["../../../src/lib/core/PremiseManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,SAAS,EAET,QAAQ,EACR,wBAAwB,EACxB,sBAAsB,EACzB,MAAM,aAAa,CAAA;AAGpB,OAAO,KAAK,EACR,wBAAwB,EAGxB,iBAAiB,EACjB,mBAAmB,EACtB,MAAM,qBAAqB,CAAA;AAU5B,qBAAa,cAAc;IACvB,OAAO,CAAC,EAAE,CAAQ;IAClB,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,gBAAgB,CAAoB;IAC5C,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,WAAW,CAAmB;IACtC,OAAO,CAAC,uBAAuB,CAAiC;IAChE,OAAO,CAAC,QAAQ,CAAW;gBAEf,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,MAAM;IAU3D;;;;;;OAMG;IACI,WAAW,CAAC,QAAQ,EAAE,sBAAsB,GAAG,IAAI;IAQ1D;;;;;OAKG;IACI,cAAc,CACjB,UAAU,EAAE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