@stevenvo780/st-lang 2.7.1 → 2.8.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/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/profiles/classical/cdcl.d.ts +34 -0
- package/dist/profiles/classical/cdcl.d.ts.map +1 -0
- package/dist/profiles/classical/cdcl.js +843 -0
- package/dist/profiles/classical/cdcl.js.map +1 -0
- package/dist/profiles/classical/dpll.d.ts +11 -1
- package/dist/profiles/classical/dpll.d.ts.map +1 -1
- package/dist/profiles/classical/dpll.js +54 -17
- package/dist/profiles/classical/dpll.js.map +1 -1
- package/dist/profiles/classical/first-order.d.ts.map +1 -1
- package/dist/profiles/classical/first-order.js +20 -10
- package/dist/profiles/classical/first-order.js.map +1 -1
- package/dist/profiles/classical/parallel-sat.d.ts +62 -0
- package/dist/profiles/classical/parallel-sat.d.ts.map +1 -0
- package/dist/profiles/classical/parallel-sat.js +630 -0
- package/dist/profiles/classical/parallel-sat.js.map +1 -0
- package/dist/profiles/classical/propositional.d.ts.map +1 -1
- package/dist/profiles/classical/propositional.js +35 -19
- package/dist/profiles/classical/propositional.js.map +1 -1
- package/dist/profiles/classical/sat-preprocess.d.ts +17 -0
- package/dist/profiles/classical/sat-preprocess.d.ts.map +1 -0
- package/dist/profiles/classical/sat-preprocess.js +372 -0
- package/dist/profiles/classical/sat-preprocess.js.map +1 -0
- package/dist/profiles/classical/undecidability-detector.d.ts +13 -0
- package/dist/profiles/classical/undecidability-detector.d.ts.map +1 -0
- package/dist/profiles/classical/undecidability-detector.js +277 -0
- package/dist/profiles/classical/undecidability-detector.js.map +1 -0
- package/dist/profiles/paraconsistent/belnap.d.ts.map +1 -1
- package/dist/profiles/paraconsistent/belnap.js +4 -2
- package/dist/profiles/paraconsistent/belnap.js.map +1 -1
- package/dist/profiles/shared/tableau-engine.d.ts.map +1 -1
- package/dist/profiles/shared/tableau-engine.js +3 -1
- package/dist/profiles/shared/tableau-engine.js.map +1 -1
- package/dist/runtime/formula-factory.d.ts.map +1 -1
- package/dist/runtime/formula-factory.js +3 -2
- package/dist/runtime/formula-factory.js.map +1 -1
- package/dist/runtime/interpreter.d.ts +9 -0
- package/dist/runtime/interpreter.d.ts.map +1 -1
- package/dist/runtime/interpreter.js +116 -5
- package/dist/runtime/interpreter.js.map +1 -1
- package/dist/tests/benchmark-cdcl.test.d.ts +2 -0
- package/dist/tests/benchmark-cdcl.test.d.ts.map +1 -0
- package/dist/tests/benchmark-cdcl.test.js +172 -0
- package/dist/tests/benchmark-cdcl.test.js.map +1 -0
- package/dist/tests/limits.test.js +11 -4
- package/dist/tests/limits.test.js.map +1 -1
- package/dist/tests/parallel-sat.test.d.ts +2 -0
- package/dist/tests/parallel-sat.test.d.ts.map +1 -0
- package/dist/tests/parallel-sat.test.js +351 -0
- package/dist/tests/parallel-sat.test.js.map +1 -0
- package/dist/tests/stress-cdcl.test.d.ts +2 -0
- package/dist/tests/stress-cdcl.test.d.ts.map +1 -0
- package/dist/tests/stress-cdcl.test.js +792 -0
- package/dist/tests/stress-cdcl.test.js.map +1 -0
- package/dist/tests/stress-extreme.test.d.ts +2 -0
- package/dist/tests/stress-extreme.test.d.ts.map +1 -0
- package/dist/tests/stress-extreme.test.js +1005 -0
- package/dist/tests/stress-extreme.test.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// SAT Preprocessing — Simplification before solving
|
|
4
|
+
// Implements: Subsumption Elimination, Self-Subsuming Resolution,
|
|
5
|
+
// Bounded Variable Elimination, Failed Literal Probing
|
|
6
|
+
// ============================================================
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.preprocess = preprocess;
|
|
9
|
+
/**
|
|
10
|
+
* Check if clause A subsumes clause B (A ⊂ B as sets).
|
|
11
|
+
* If A subsumes B, B is redundant and can be removed.
|
|
12
|
+
*/
|
|
13
|
+
function subsumes(a, b) {
|
|
14
|
+
if (a.length >= b.length)
|
|
15
|
+
return false;
|
|
16
|
+
let ai = 0;
|
|
17
|
+
for (let bi = 0; bi < b.length && ai < a.length; bi++) {
|
|
18
|
+
if (a[ai] === b[bi])
|
|
19
|
+
ai++;
|
|
20
|
+
}
|
|
21
|
+
return ai === a.length;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Subsumption Elimination:
|
|
25
|
+
* If clause A ⊂ clause B, remove B (it's redundant).
|
|
26
|
+
*/
|
|
27
|
+
function subsumptionElimination(clauses) {
|
|
28
|
+
// Sort clauses by length for efficient checking
|
|
29
|
+
const sorted = clauses.slice().sort((a, b) => a.length - b.length);
|
|
30
|
+
const removed = new Uint8Array(sorted.length);
|
|
31
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
32
|
+
if (removed[i])
|
|
33
|
+
continue;
|
|
34
|
+
for (let j = i + 1; j < sorted.length; j++) {
|
|
35
|
+
if (removed[j])
|
|
36
|
+
continue;
|
|
37
|
+
if (subsumes(sorted[i], sorted[j])) {
|
|
38
|
+
removed[j] = 1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const result = [];
|
|
43
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
44
|
+
if (!removed[i])
|
|
45
|
+
result.push(sorted[i]);
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Remove duplicate literals within each clause and sort them.
|
|
51
|
+
* Also removes tautological clauses (containing both x and -x).
|
|
52
|
+
*/
|
|
53
|
+
function normalizeClauses(clauses) {
|
|
54
|
+
const result = [];
|
|
55
|
+
for (const clause of clauses) {
|
|
56
|
+
const sorted = Array.from(clause).sort((a, b) => Math.abs(a) - Math.abs(b) || a - b);
|
|
57
|
+
// Remove duplicates and check for tautology
|
|
58
|
+
const deduped = [];
|
|
59
|
+
let tautology = false;
|
|
60
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
61
|
+
if (i > 0 && sorted[i] === sorted[i - 1])
|
|
62
|
+
continue;
|
|
63
|
+
// Check for complementary literals
|
|
64
|
+
if (i > 0 && sorted[i] === -sorted[i - 1]) {
|
|
65
|
+
tautology = true;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
deduped.push(sorted[i]);
|
|
69
|
+
}
|
|
70
|
+
if (!tautology) {
|
|
71
|
+
result.push(new Int32Array(deduped));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Remove duplicate clauses using signature hashing.
|
|
78
|
+
*/
|
|
79
|
+
function removeDuplicateClauses(clauses) {
|
|
80
|
+
const seen = new Set();
|
|
81
|
+
const result = [];
|
|
82
|
+
for (const c of clauses) {
|
|
83
|
+
const key = c.join(',');
|
|
84
|
+
if (!seen.has(key)) {
|
|
85
|
+
seen.add(key);
|
|
86
|
+
result.push(c);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Self-Subsuming Resolution:
|
|
93
|
+
* If resolving A with B produces a clause that subsumes A, replace A with the resolvent.
|
|
94
|
+
* Example: {P, Q, R} resolved with {¬P, Q} → {Q, R} which subsumes {P, Q, R}
|
|
95
|
+
*/
|
|
96
|
+
function selfSubsumingResolution(clauses) {
|
|
97
|
+
const result = clauses.slice();
|
|
98
|
+
let changed = true;
|
|
99
|
+
let iterations = 0;
|
|
100
|
+
const maxIterations = 3; // Limit passes to prevent excessive computation
|
|
101
|
+
while (changed && iterations < maxIterations) {
|
|
102
|
+
changed = false;
|
|
103
|
+
iterations++;
|
|
104
|
+
for (let i = 0; i < result.length; i++) {
|
|
105
|
+
const ci = result[i];
|
|
106
|
+
if (ci.length === 0)
|
|
107
|
+
continue;
|
|
108
|
+
for (let j = 0; j < result.length; j++) {
|
|
109
|
+
if (i === j)
|
|
110
|
+
continue;
|
|
111
|
+
const cj = result[j];
|
|
112
|
+
if (cj.length === 0 || cj.length > ci.length)
|
|
113
|
+
continue;
|
|
114
|
+
// Try to resolve cj against ci on some literal
|
|
115
|
+
for (let li = 0; li < ci.length; li++) {
|
|
116
|
+
const lit = ci[li];
|
|
117
|
+
// Check if cj contains -lit and all other literals of cj are in ci
|
|
118
|
+
let hasNegLit = false;
|
|
119
|
+
let allOthersInCi = true;
|
|
120
|
+
for (let lj = 0; lj < cj.length; lj++) {
|
|
121
|
+
if (cj[lj] === -lit) {
|
|
122
|
+
hasNegLit = true;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
// Check if this literal is also in ci
|
|
126
|
+
let found = false;
|
|
127
|
+
for (let lk = 0; lk < ci.length; lk++) {
|
|
128
|
+
if (ci[lk] === cj[lj]) {
|
|
129
|
+
found = true;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (!found) {
|
|
134
|
+
allOthersInCi = false;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (hasNegLit && allOthersInCi) {
|
|
140
|
+
// Self-subsumption: remove lit from ci
|
|
141
|
+
const newClause = [];
|
|
142
|
+
for (let lk = 0; lk < ci.length; lk++) {
|
|
143
|
+
if (ci[lk] !== lit)
|
|
144
|
+
newClause.push(ci[lk]);
|
|
145
|
+
}
|
|
146
|
+
result[i] = new Int32Array(newClause);
|
|
147
|
+
changed = true;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Bounded Variable Elimination (BVE):
|
|
158
|
+
* If a variable appears few times, resolve all its positive clauses against
|
|
159
|
+
* negative clauses and check if the result is smaller.
|
|
160
|
+
*/
|
|
161
|
+
function boundedVariableElimination(clauses, numVars) {
|
|
162
|
+
const eliminated = new Set();
|
|
163
|
+
let current = clauses.slice();
|
|
164
|
+
const MAX_GROWTH = 0; // Only eliminate if it doesn't increase clause count
|
|
165
|
+
for (let v = 1; v <= numVars; v++) {
|
|
166
|
+
const posClauses = [];
|
|
167
|
+
const negClauses = [];
|
|
168
|
+
for (let ci = 0; ci < current.length; ci++) {
|
|
169
|
+
for (let li = 0; li < current[ci].length; li++) {
|
|
170
|
+
if (current[ci][li] === v) {
|
|
171
|
+
posClauses.push(ci);
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
if (current[ci][li] === -v) {
|
|
175
|
+
negClauses.push(ci);
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// Skip if too many resolvents would be created
|
|
181
|
+
if (posClauses.length * negClauses.length >
|
|
182
|
+
posClauses.length + negClauses.length + MAX_GROWTH) {
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
// Generate all resolvents
|
|
186
|
+
const resolvents = [];
|
|
187
|
+
const tooLarge = false;
|
|
188
|
+
for (const pi of posClauses) {
|
|
189
|
+
for (const ni of negClauses) {
|
|
190
|
+
const resolvent = resolve(current[pi], current[ni], v);
|
|
191
|
+
if (resolvent === null)
|
|
192
|
+
continue; // tautology
|
|
193
|
+
resolvents.push(resolvent);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (tooLarge)
|
|
197
|
+
continue;
|
|
198
|
+
// Only eliminate if result has fewer or equal clauses
|
|
199
|
+
if (resolvents.length <= posClauses.length + negClauses.length) {
|
|
200
|
+
// Remove old clauses and add resolvents
|
|
201
|
+
const toRemove = new Set([...posClauses, ...negClauses]);
|
|
202
|
+
const newClauses = [];
|
|
203
|
+
for (let ci = 0; ci < current.length; ci++) {
|
|
204
|
+
if (!toRemove.has(ci))
|
|
205
|
+
newClauses.push(current[ci]);
|
|
206
|
+
}
|
|
207
|
+
newClauses.push(...resolvents);
|
|
208
|
+
current = newClauses;
|
|
209
|
+
eliminated.add(v);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return { clauses: current, eliminated };
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Resolve two clauses on variable v.
|
|
216
|
+
* Returns null if the resolvent is a tautology.
|
|
217
|
+
*/
|
|
218
|
+
function resolve(a, b, v) {
|
|
219
|
+
const lits = new Set();
|
|
220
|
+
for (let i = 0; i < a.length; i++) {
|
|
221
|
+
const l = a[i];
|
|
222
|
+
if (l !== v && l !== -v)
|
|
223
|
+
lits.add(l);
|
|
224
|
+
}
|
|
225
|
+
for (let i = 0; i < b.length; i++) {
|
|
226
|
+
const l = b[i];
|
|
227
|
+
if (l !== v && l !== -v) {
|
|
228
|
+
if (lits.has(-l))
|
|
229
|
+
return null; // tautology
|
|
230
|
+
lits.add(l);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return new Int32Array(Array.from(lits).sort((a, b) => a - b));
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Failed Literal Probing:
|
|
237
|
+
* For each unassigned variable, assume it's true and propagate.
|
|
238
|
+
* If conflict → the variable must be false (and vice versa).
|
|
239
|
+
*/
|
|
240
|
+
function failedLiteralProbing(clauses, numVars) {
|
|
241
|
+
const forced = [];
|
|
242
|
+
for (let v = 1; v <= numVars; v++) {
|
|
243
|
+
// Try v = true
|
|
244
|
+
const trueResult = probeAssignment(clauses, numVars, v);
|
|
245
|
+
// Try v = false
|
|
246
|
+
const falseResult = probeAssignment(clauses, numVars, -v);
|
|
247
|
+
if (trueResult === 'conflict' && falseResult === 'conflict') {
|
|
248
|
+
// Both conflict → UNSAT, but we handle this later
|
|
249
|
+
return { forcedLiterals: forced, clauses };
|
|
250
|
+
}
|
|
251
|
+
if (trueResult === 'conflict') {
|
|
252
|
+
forced.push(-v);
|
|
253
|
+
}
|
|
254
|
+
else if (falseResult === 'conflict') {
|
|
255
|
+
forced.push(v);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// Apply forced literals
|
|
259
|
+
let current = clauses;
|
|
260
|
+
for (const lit of forced) {
|
|
261
|
+
current = applyLiteral(current, lit);
|
|
262
|
+
}
|
|
263
|
+
return { forcedLiterals: forced, clauses: current };
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Probe: assign a literal and run unit propagation.
|
|
267
|
+
* Returns 'conflict' if a conflict is found, 'ok' otherwise.
|
|
268
|
+
*/
|
|
269
|
+
function probeAssignment(clauses, numVars, lit) {
|
|
270
|
+
let current = applyLiteral(clauses, lit);
|
|
271
|
+
// Run simple unit propagation
|
|
272
|
+
let changed = true;
|
|
273
|
+
while (changed) {
|
|
274
|
+
changed = false;
|
|
275
|
+
for (const c of current) {
|
|
276
|
+
if (c.length === 0)
|
|
277
|
+
return 'conflict';
|
|
278
|
+
if (c.length === 1) {
|
|
279
|
+
current = applyLiteral(current, c[0]);
|
|
280
|
+
changed = true;
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return 'ok';
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Apply a literal assignment to a clause set.
|
|
289
|
+
* Removes satisfied clauses and shrinks clauses containing -lit.
|
|
290
|
+
*/
|
|
291
|
+
function applyLiteral(clauses, lit) {
|
|
292
|
+
const result = [];
|
|
293
|
+
for (const c of clauses) {
|
|
294
|
+
let satisfied = false;
|
|
295
|
+
const remaining = [];
|
|
296
|
+
for (let i = 0; i < c.length; i++) {
|
|
297
|
+
if (c[i] === lit) {
|
|
298
|
+
satisfied = true;
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
if (c[i] !== -lit)
|
|
302
|
+
remaining.push(c[i]);
|
|
303
|
+
}
|
|
304
|
+
if (!satisfied) {
|
|
305
|
+
result.push(new Int32Array(remaining));
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return result;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Main preprocessing pipeline.
|
|
312
|
+
* Applies simplifications in order of effectiveness.
|
|
313
|
+
*/
|
|
314
|
+
function preprocess(clauses, numVars) {
|
|
315
|
+
// Step 0: normalize and deduplicate
|
|
316
|
+
let current = normalizeClauses(clauses);
|
|
317
|
+
current = removeDuplicateClauses(current);
|
|
318
|
+
// Check trivial cases
|
|
319
|
+
for (const c of current) {
|
|
320
|
+
if (c.length === 0) {
|
|
321
|
+
return { clauses: current, forcedLiterals: [], eliminated: false, trivialUnsat: true };
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
const initialCount = current.length;
|
|
325
|
+
const allForced = [];
|
|
326
|
+
// Step 1: extract unit clauses
|
|
327
|
+
let changed = true;
|
|
328
|
+
while (changed) {
|
|
329
|
+
changed = false;
|
|
330
|
+
for (let i = 0; i < current.length; i++) {
|
|
331
|
+
if (current[i].length === 1) {
|
|
332
|
+
const lit = current[i][0];
|
|
333
|
+
allForced.push(lit);
|
|
334
|
+
current = applyLiteral(current, lit);
|
|
335
|
+
changed = true;
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
// Step 2: subsumption elimination
|
|
341
|
+
current = subsumptionElimination(current);
|
|
342
|
+
// Step 3: self-subsuming resolution
|
|
343
|
+
current = selfSubsumingResolution(current);
|
|
344
|
+
// Step 4: Bounded Variable Elimination (only for small formulas to avoid blowup)
|
|
345
|
+
if (numVars <= 500) {
|
|
346
|
+
const bve = boundedVariableElimination(current, numVars);
|
|
347
|
+
current = bve.clauses;
|
|
348
|
+
}
|
|
349
|
+
// Step 5: Failed Literal Probing (only for moderate sizes)
|
|
350
|
+
if (numVars <= 200) {
|
|
351
|
+
const flp = failedLiteralProbing(current, numVars);
|
|
352
|
+
allForced.push(...flp.forcedLiterals);
|
|
353
|
+
current = flp.clauses;
|
|
354
|
+
}
|
|
355
|
+
// Final normalization
|
|
356
|
+
current = normalizeClauses(current);
|
|
357
|
+
current = removeDuplicateClauses(current);
|
|
358
|
+
current = subsumptionElimination(current);
|
|
359
|
+
// Check for empty clause after all preprocessing
|
|
360
|
+
for (const c of current) {
|
|
361
|
+
if (c.length === 0) {
|
|
362
|
+
return { clauses: current, forcedLiterals: allForced, eliminated: true, trivialUnsat: true };
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return {
|
|
366
|
+
clauses: current,
|
|
367
|
+
forcedLiterals: allForced,
|
|
368
|
+
eliminated: current.length < initialCount,
|
|
369
|
+
trivialUnsat: false,
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
//# sourceMappingURL=sat-preprocess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sat-preprocess.js","sourceRoot":"","sources":["../../../src/profiles/classical/sat-preprocess.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,oDAAoD;AACpD,kEAAkE;AAClE,uDAAuD;AACvD,+DAA+D;;AA0U/D,gCAmEC;AA/XD;;;GAGG;AACH,SAAS,QAAQ,CAAC,CAAS,EAAE,CAAS;IACpC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACvC,IAAI,EAAE,GAAG,CAAC,CAAC;IACX,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,MAAM,IAAI,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC;QACtD,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YAAE,EAAE,EAAE,CAAC;IAC5B,CAAC;IACD,OAAO,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC;AACzB,CAAC;AAED;;;GAGG;AACH,SAAS,sBAAsB,CAAC,OAAiB;IAC/C,gDAAgD;IAChD,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE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,KAAK,CAAC,EAAE,CAAC;YACnB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;QAC/F,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE,OAAO;QAChB,cAAc,EAAE,SAAS;QACzB,UAAU,EAAE,OAAO,CAAC,MAAM,GAAG,YAAY;QACzC,YAAY,EAAE,KAAK;KACpB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Formula } from '../../types';
|
|
2
|
+
export interface UndecidabilityWarning {
|
|
3
|
+
pattern: string;
|
|
4
|
+
description: string;
|
|
5
|
+
severity: 'info' | 'warning' | 'critical';
|
|
6
|
+
suggestion: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Analyze a first-order formula for known undecidable or computationally
|
|
10
|
+
* intractable patterns. Returns warnings if any are detected.
|
|
11
|
+
*/
|
|
12
|
+
export declare function detectUndecidable(formula: Formula): UndecidabilityWarning[];
|
|
13
|
+
//# sourceMappingURL=undecidability-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"undecidability-detector.d.ts","sourceRoot":"","sources":["../../../src/profiles/classical/undecidability-detector.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;IAC1C,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,qBAAqB,EAAE,CAqF3E"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// FOL Undecidability Detector
|
|
4
|
+
// Detects patterns known to be undecidable in first-order logic,
|
|
5
|
+
// provides meaningful warnings to users.
|
|
6
|
+
// ============================================================
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.detectUndecidable = detectUndecidable;
|
|
9
|
+
/**
|
|
10
|
+
* Analyze a first-order formula for known undecidable or computationally
|
|
11
|
+
* intractable patterns. Returns warnings if any are detected.
|
|
12
|
+
*/
|
|
13
|
+
function detectUndecidable(formula) {
|
|
14
|
+
const warnings = [];
|
|
15
|
+
// 1. Quantifier alternation depth
|
|
16
|
+
const altDepth = quantifierAlternationDepth(formula);
|
|
17
|
+
if (altDepth >= 3) {
|
|
18
|
+
warnings.push({
|
|
19
|
+
pattern: 'quantifier_alternation',
|
|
20
|
+
description: `Alternación de cuantificadores de profundidad ${altDepth} (∀∃∀...) detectada. ` +
|
|
21
|
+
`La satisfacibilidad de fórmulas con alternación profunda es computacionalmente extrema.`,
|
|
22
|
+
severity: altDepth >= 4 ? 'critical' : 'warning',
|
|
23
|
+
suggestion: 'Considere reducir la alternación de cuantificadores o usar fragmentos decidibles (∃*, ∀∃*, Bernays-Schönfinkel).',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
// 2. Nested quantifiers depth
|
|
27
|
+
const nestDepth = quantifierNestingDepth(formula);
|
|
28
|
+
if (nestDepth >= 5) {
|
|
29
|
+
warnings.push({
|
|
30
|
+
pattern: 'deep_quantifier_nesting',
|
|
31
|
+
description: `Anidamiento de cuantificadores de profundidad ${nestDepth}. ` +
|
|
32
|
+
`El tableau puede requerir tiempo exponencial.`,
|
|
33
|
+
severity: nestDepth >= 8 ? 'critical' : 'warning',
|
|
34
|
+
suggestion: 'Simplifique la fórmula reduciendo niveles de anidamiento cuantificado.',
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
// 3. Self-reference patterns (Gödel-like)
|
|
38
|
+
if (hasSelfReference(formula)) {
|
|
39
|
+
warnings.push({
|
|
40
|
+
pattern: 'goedel_self_reference',
|
|
41
|
+
description: `Posible auto-referencia detectada (patrón similar a la sentencia de Gödel). ` +
|
|
42
|
+
`No existe algoritmo que pueda decidir todas las fórmulas auto-referenciales (Gödel, 1931).`,
|
|
43
|
+
severity: 'critical',
|
|
44
|
+
suggestion: 'Las fórmulas auto-referenciales son inherentemente indecidibles en aritmética formal.',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
// 4. Function symbols with deep nesting (potential infinity)
|
|
48
|
+
const fnDepth = functionNestingDepth(formula);
|
|
49
|
+
if (fnDepth >= 4) {
|
|
50
|
+
warnings.push({
|
|
51
|
+
pattern: 'deep_function_nesting',
|
|
52
|
+
description: `Funciones anidadas de profundidad ${fnDepth} con cuantificadores. ` +
|
|
53
|
+
`Esto puede generar infinitos términos durante la instanciación.`,
|
|
54
|
+
severity: fnDepth >= 6 ? 'critical' : 'warning',
|
|
55
|
+
suggestion: 'Limite la profundidad de términos funcionales o use skolemización temprana.',
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
// 5. Monadic vs polyadic predicates
|
|
59
|
+
const predicateArities = collectPredicateArities(formula);
|
|
60
|
+
const hasPolyadic = Array.from(predicateArities.values()).some((a) => a >= 3);
|
|
61
|
+
if (hasPolyadic && altDepth >= 2) {
|
|
62
|
+
warnings.push({
|
|
63
|
+
pattern: 'polyadic_with_alternation',
|
|
64
|
+
description: `Predicados con aridad ≥3 combinados con alternación de cuantificadores. ` +
|
|
65
|
+
`Este fragmento es generalmente indecidible (Church, 1936).`,
|
|
66
|
+
severity: 'warning',
|
|
67
|
+
suggestion: 'El fragmento monádico (aridad 1) de FOL es decidible. Considere reducir la aridad de predicados.',
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
// 6. Detect potential infinite domain requirements
|
|
71
|
+
if (requiresInfiniteDomain(formula)) {
|
|
72
|
+
warnings.push({
|
|
73
|
+
pattern: 'infinite_domain',
|
|
74
|
+
description: `La fórmula parece requerir un dominio infinito para ser satisfacible. ` +
|
|
75
|
+
`Solo la búsqueda en dominios finitos es decidible.`,
|
|
76
|
+
severity: 'info',
|
|
77
|
+
suggestion: 'ST buscará modelos en dominios finitos crecientes. Si es válida solo en dominios infinitos, el tableau puede no terminar.',
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return warnings;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Count the maximum quantifier alternation depth.
|
|
84
|
+
* ∀∃ = 1, ∀∃∀ = 2, ∀∃∀∃ = 3, etc.
|
|
85
|
+
*/
|
|
86
|
+
function quantifierAlternationDepth(f) {
|
|
87
|
+
let maxDepth = 0;
|
|
88
|
+
function walk(node, lastQ, depth) {
|
|
89
|
+
if (node.kind === 'forall' || node.kind === 'exists') {
|
|
90
|
+
const currentQ = node.kind;
|
|
91
|
+
const newDepth = lastQ !== '' && lastQ !== currentQ ? depth + 1 : depth;
|
|
92
|
+
maxDepth = Math.max(maxDepth, newDepth);
|
|
93
|
+
if (node.args) {
|
|
94
|
+
for (const arg of node.args) {
|
|
95
|
+
walk(arg, currentQ, newDepth);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// Also check body (second arg for forall/exists)
|
|
99
|
+
if (node.args && node.args.length >= 2) {
|
|
100
|
+
walk(node.args[1], currentQ, newDepth);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
if (node.args) {
|
|
105
|
+
for (const arg of node.args) {
|
|
106
|
+
walk(arg, lastQ, depth);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
walk(f, '', 0);
|
|
112
|
+
return maxDepth;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Count the maximum quantifier nesting depth.
|
|
116
|
+
*/
|
|
117
|
+
function quantifierNestingDepth(f) {
|
|
118
|
+
let maxDepth = 0;
|
|
119
|
+
function walk(node, depth) {
|
|
120
|
+
if (node.kind === 'forall' || node.kind === 'exists') {
|
|
121
|
+
const newDepth = depth + 1;
|
|
122
|
+
maxDepth = Math.max(maxDepth, newDepth);
|
|
123
|
+
if (node.args) {
|
|
124
|
+
for (const arg of node.args) {
|
|
125
|
+
walk(arg, newDepth);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
if (node.args) {
|
|
131
|
+
for (const arg of node.args) {
|
|
132
|
+
walk(arg, depth);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
walk(f, 0);
|
|
138
|
+
return maxDepth;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Detect self-referential patterns in formulas.
|
|
142
|
+
* Looks for predicates that reference their own derivability
|
|
143
|
+
* or formulas that encode their own truth conditions.
|
|
144
|
+
*/
|
|
145
|
+
function hasSelfReference(f) {
|
|
146
|
+
// Collect all predicate names
|
|
147
|
+
const predicates = new Set();
|
|
148
|
+
const atoms = new Set();
|
|
149
|
+
function collectNames(node) {
|
|
150
|
+
if (node.kind === 'predicate' && node.name) {
|
|
151
|
+
predicates.add(node.name);
|
|
152
|
+
}
|
|
153
|
+
if (node.kind === 'atom' && node.name) {
|
|
154
|
+
atoms.add(node.name);
|
|
155
|
+
}
|
|
156
|
+
if (node.args) {
|
|
157
|
+
for (const arg of node.args) {
|
|
158
|
+
collectNames(arg);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
collectNames(f);
|
|
163
|
+
// Check for names that suggest self-reference
|
|
164
|
+
const selfRefPatterns = [
|
|
165
|
+
/^(provable|derivable|demostrable)/i,
|
|
166
|
+
/^(truth|verdad|true_of)/i,
|
|
167
|
+
/^(goedel|godel|diagonal)/i,
|
|
168
|
+
/^(halts?|termina)/i,
|
|
169
|
+
/^(self|auto|reflexi)/i,
|
|
170
|
+
];
|
|
171
|
+
for (const name of [...predicates, ...atoms]) {
|
|
172
|
+
for (const pattern of selfRefPatterns) {
|
|
173
|
+
if (pattern.test(name))
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Calculate maximum function symbol nesting depth.
|
|
181
|
+
*/
|
|
182
|
+
function functionNestingDepth(f) {
|
|
183
|
+
let maxDepth = 0;
|
|
184
|
+
function walk(node, depth) {
|
|
185
|
+
if (node.kind === 'fn_call') {
|
|
186
|
+
const newDepth = depth + 1;
|
|
187
|
+
maxDepth = Math.max(maxDepth, newDepth);
|
|
188
|
+
if (node.args) {
|
|
189
|
+
for (const arg of node.args) {
|
|
190
|
+
walk(arg, newDepth);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
else if (node.kind === 'predicate') {
|
|
195
|
+
// Reset depth for predicate arguments
|
|
196
|
+
if (node.args) {
|
|
197
|
+
for (const arg of node.args) {
|
|
198
|
+
walk(arg, 0);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
if (node.args) {
|
|
204
|
+
for (const arg of node.args) {
|
|
205
|
+
walk(arg, depth);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
walk(f, 0);
|
|
211
|
+
return maxDepth;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Collect predicate arities.
|
|
215
|
+
*/
|
|
216
|
+
function collectPredicateArities(f) {
|
|
217
|
+
const arities = new Map();
|
|
218
|
+
function walk(node) {
|
|
219
|
+
if (node.kind === 'predicate' && node.name && node.args) {
|
|
220
|
+
const arity = node.args.length;
|
|
221
|
+
const existing = arities.get(node.name);
|
|
222
|
+
if (existing === undefined || arity > existing) {
|
|
223
|
+
arities.set(node.name, arity);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (node.args) {
|
|
227
|
+
for (const arg of node.args) {
|
|
228
|
+
walk(arg);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
walk(f);
|
|
233
|
+
return arities;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Detect if a formula likely requires an infinite domain.
|
|
237
|
+
* Patterns: ∀x∃y(y ≠ x), successor axioms, induction schemas.
|
|
238
|
+
*/
|
|
239
|
+
function requiresInfiniteDomain(f) {
|
|
240
|
+
// Look for ∀x∃y patterns where y depends on x
|
|
241
|
+
let hasForallExists = false;
|
|
242
|
+
let hasDisequalityPattern = false;
|
|
243
|
+
function walk(node, inForall) {
|
|
244
|
+
if (node.kind === 'forall') {
|
|
245
|
+
if (node.args) {
|
|
246
|
+
for (const arg of node.args) {
|
|
247
|
+
walk(arg, true);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
else if (node.kind === 'exists' && inForall) {
|
|
252
|
+
hasForallExists = true;
|
|
253
|
+
if (node.args) {
|
|
254
|
+
for (const arg of node.args) {
|
|
255
|
+
walk(arg, inForall);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
// Check for inequality-like patterns
|
|
261
|
+
if (node.kind === 'not') {
|
|
262
|
+
if (node.args?.[0]?.kind === 'atom' || node.args?.[0]?.kind === 'predicate') {
|
|
263
|
+
if (hasForallExists)
|
|
264
|
+
hasDisequalityPattern = true;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (node.args) {
|
|
268
|
+
for (const arg of node.args) {
|
|
269
|
+
walk(arg, inForall);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
walk(f, false);
|
|
275
|
+
return hasForallExists && hasDisequalityPattern;
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=undecidability-detector.js.map
|