@stevenvo780/st-lang 2.6.1 → 2.7.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.
Files changed (72) hide show
  1. package/dist/ast/nodes.d.ts +18 -1
  2. package/dist/ast/nodes.d.ts.map +1 -1
  3. package/dist/lexer/lexer.d.ts +2 -1
  4. package/dist/lexer/lexer.d.ts.map +1 -1
  5. package/dist/lexer/lexer.js +4 -2
  6. package/dist/lexer/lexer.js.map +1 -1
  7. package/dist/lexer/tokens.d.ts +17 -0
  8. package/dist/lexer/tokens.d.ts.map +1 -1
  9. package/dist/lexer/tokens.js +58 -21
  10. package/dist/lexer/tokens.js.map +1 -1
  11. package/dist/parser/parser.d.ts +4 -1
  12. package/dist/parser/parser.d.ts.map +1 -1
  13. package/dist/parser/parser.js +86 -2
  14. package/dist/parser/parser.js.map +1 -1
  15. package/dist/profiles/classical/dpll.d.ts +10 -0
  16. package/dist/profiles/classical/dpll.d.ts.map +1 -0
  17. package/dist/profiles/classical/dpll.js +446 -0
  18. package/dist/profiles/classical/dpll.js.map +1 -0
  19. package/dist/profiles/classical/first-order.d.ts +1 -0
  20. package/dist/profiles/classical/first-order.d.ts.map +1 -1
  21. package/dist/profiles/classical/first-order.js +35 -0
  22. package/dist/profiles/classical/first-order.js.map +1 -1
  23. package/dist/profiles/classical/propositional.d.ts +6 -1
  24. package/dist/profiles/classical/propositional.d.ts.map +1 -1
  25. package/dist/profiles/classical/propositional.js +434 -38
  26. package/dist/profiles/classical/propositional.js.map +1 -1
  27. package/dist/profiles/paraconsistent/belnap.d.ts.map +1 -1
  28. package/dist/profiles/paraconsistent/belnap.js +151 -3
  29. package/dist/profiles/paraconsistent/belnap.js.map +1 -1
  30. package/dist/profiles/shared/tableau-engine.d.ts.map +1 -1
  31. package/dist/profiles/shared/tableau-engine.js +49 -22
  32. package/dist/profiles/shared/tableau-engine.js.map +1 -1
  33. package/dist/runtime/educational-notes.d.ts +27 -0
  34. package/dist/runtime/educational-notes.d.ts.map +1 -0
  35. package/dist/runtime/educational-notes.js +100 -0
  36. package/dist/runtime/educational-notes.js.map +1 -0
  37. package/dist/runtime/format.d.ts.map +1 -1
  38. package/dist/runtime/format.js +4 -0
  39. package/dist/runtime/format.js.map +1 -1
  40. package/dist/runtime/formula-factory.d.ts +26 -0
  41. package/dist/runtime/formula-factory.d.ts.map +1 -0
  42. package/dist/runtime/formula-factory.js +67 -0
  43. package/dist/runtime/formula-factory.js.map +1 -0
  44. package/dist/runtime/interpreter.d.ts +41 -0
  45. package/dist/runtime/interpreter.d.ts.map +1 -1
  46. package/dist/runtime/interpreter.js +1039 -246
  47. package/dist/runtime/interpreter.js.map +1 -1
  48. package/dist/tests/arithmetic.test.js +2 -1
  49. package/dist/tests/arithmetic.test.js.map +1 -1
  50. package/dist/tests/examples.test.js +12 -1
  51. package/dist/tests/examples.test.js.map +1 -1
  52. package/dist/tests/exhaustive-matrix.test.js +1 -1
  53. package/dist/tests/exhaustive-matrix.test.js.map +1 -1
  54. package/dist/tests/limits.test.js +17 -4
  55. package/dist/tests/limits.test.js.map +1 -1
  56. package/dist/tests/result-bindings.test.d.ts +2 -0
  57. package/dist/tests/result-bindings.test.d.ts.map +1 -0
  58. package/dist/tests/result-bindings.test.js +59 -0
  59. package/dist/tests/result-bindings.test.js.map +1 -0
  60. package/dist/tests/stress-hardware.test.d.ts +2 -0
  61. package/dist/tests/stress-hardware.test.d.ts.map +1 -0
  62. package/dist/tests/stress-hardware.test.js +673 -0
  63. package/dist/tests/stress-hardware.test.js.map +1 -0
  64. package/dist/tests/v1-features.test.js +1 -1
  65. package/dist/tests/v1-features.test.js.map +1 -1
  66. package/dist/types/index.d.ts +1 -1
  67. package/dist/types/index.d.ts.map +1 -1
  68. package/dist/utils/memo.d.ts +3 -0
  69. package/dist/utils/memo.d.ts.map +1 -1
  70. package/dist/utils/memo.js +30 -0
  71. package/dist/utils/memo.js.map +1 -1
  72. package/package.json +2 -1
@@ -0,0 +1,673 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * ST Hardware Stress Tests
5
+ * ========================
6
+ * Objetivo: que muera el PC antes que el lenguaje.
7
+ * Cada test valida que ST maneje cargas extremas sin:
8
+ * - Stack overflow
9
+ * - Infinite loops / hangs
10
+ * - OOM sin control (debe fallar con mensaje, no con crash)
11
+ * - Resultados incorrectos bajo presión
12
+ *
13
+ * Categorías:
14
+ * 1. Bitset Evaluation (propositional, saturar BigInt)
15
+ * 2. Hash-Consing / DAG (ataque de fórmulas fractales)
16
+ * 3. Tableau Engine (explosión de ramas)
17
+ * 4. FOL (explosión de cuantificadores)
18
+ * 5. Arithmetic (recursión profunda, loops masivos)
19
+ * 6. Belnap (4-valued bitset bajo presión)
20
+ * 7. Multi-profile whiplash (cambios rápidos de perfil)
21
+ */
22
+ const vitest_1 = require("vitest");
23
+ const interpreter_1 = require("../runtime/interpreter");
24
+ const formula_factory_1 = require("../runtime/formula-factory");
25
+ (0, vitest_1.afterEach)(() => {
26
+ formula_factory_1.FormulaFactory.clear();
27
+ });
28
+ function run(source) {
29
+ const interp = new interpreter_1.Interpreter();
30
+ return interp.execute(source, '<stress>');
31
+ }
32
+ /** Strip diacritics for accent-insensitive comparison */
33
+ function stripAccents(s) {
34
+ return s.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
35
+ }
36
+ // ============================================================
37
+ // 1. BITSET PROPOSITIONAL — SATURAR EVALUACIÓN VECTORIZADA
38
+ // ============================================================
39
+ (0, vitest_1.describe)('Stress: Bitset Propositional', () => {
40
+ (0, vitest_1.it)('20 atoms — maximum truth table materialization (1M rows)', () => {
41
+ const atoms = Array.from({ length: 20 }, (_, i) => `V${i}`);
42
+ const formula = atoms.join(' & ');
43
+ const source = `
44
+ logic classical.propositional
45
+ truth_table ${formula}
46
+ `;
47
+ const out = run(source);
48
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
49
+ (0, vitest_1.expect)(out.stdout).toContain('valuaciones analizadas');
50
+ }, 30000);
51
+ (0, vitest_1.it)('20 atoms — tautology check via bitset (instant)', () => {
52
+ const atoms = Array.from({ length: 20 }, (_, i) => `P${i}`);
53
+ const tautology = atoms.map((a) => `(${a} | !${a})`).join(' & ');
54
+ const source = `
55
+ logic classical.propositional
56
+ check valid ${tautology}
57
+ `;
58
+ const out = run(source);
59
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
60
+ (0, vitest_1.expect)(stripAccents(out.stdout).toUpperCase()).toContain('VALIDA');
61
+ }, 10000);
62
+ (0, vitest_1.it)('26 atoms — validity check without materialization', () => {
63
+ // 2^26 = 67M combinations — bitset should handle this without creating rows
64
+ const atoms = Array.from({ length: 26 }, (_, i) => `X${i}`);
65
+ const tautology = atoms.map((a) => `(${a} | !${a})`).join(' & ');
66
+ const source = `
67
+ logic classical.propositional
68
+ check valid ${tautology}
69
+ `;
70
+ const out = run(source);
71
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
72
+ (0, vitest_1.expect)(stripAccents(out.stdout).toUpperCase()).toContain('VALIDA');
73
+ }, 15000);
74
+ (0, vitest_1.it)('26 atoms — satisfiability (instant contradiction detection)', () => {
75
+ const atoms = Array.from({ length: 26 }, (_, i) => `Z${i}`);
76
+ const contradiction = atoms.map((a) => `(${a} & !${a})`).join(' | ');
77
+ const source = `
78
+ logic classical.propositional
79
+ check satisfiable ${contradiction}
80
+ `;
81
+ const out = run(source);
82
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
83
+ (0, vitest_1.expect)(out.stdout).toContain('INSATISFACIBLE');
84
+ }, 15000);
85
+ (0, vitest_1.it)('countermodel for non-tautology with 15 atoms (instant)', () => {
86
+ const atoms = Array.from({ length: 15 }, (_, i) => `M${i}`);
87
+ // M0 & M1 & ... & M14 is satisfiable but not a tautology
88
+ const formula = atoms.join(' & ');
89
+ const source = `
90
+ logic classical.propositional
91
+ countermodel ${formula}
92
+ `;
93
+ const out = run(source);
94
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
95
+ // Should find a countermodel quickly
96
+ }, 10000);
97
+ (0, vitest_1.it)('XOR chain with 14 atoms — complex bitset evaluation', () => {
98
+ const atoms = Array.from({ length: 14 }, (_, i) => `Q${i}`);
99
+ let formula = atoms[0];
100
+ for (let i = 1; i < atoms.length; i++) {
101
+ formula = `(${formula} ^ ${atoms[i]})`;
102
+ }
103
+ const source = `
104
+ logic classical.propositional
105
+ check satisfiable ${formula}
106
+ `;
107
+ const out = run(source);
108
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
109
+ }, 15000);
110
+ (0, vitest_1.it)('deeply nested implications (20 levels, bitset fast path)', () => {
111
+ let formula = 'Z';
112
+ for (let i = 0; i < 20; i++) {
113
+ formula = `(P${i} -> ${formula})`;
114
+ }
115
+ const source = `
116
+ logic classical.propositional
117
+ check valid ${formula}
118
+ `;
119
+ const out = run(source);
120
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
121
+ }, 15000);
122
+ });
123
+ // ============================================================
124
+ // 2. HASH-CONSING / DAG — ATAQUE FRACTAL DE FORMULAS
125
+ // ============================================================
126
+ (0, vitest_1.describe)('Stress: Hash-Consing / Formula Sharing', () => {
127
+ (0, vitest_1.it)('exponential formula doubling (8 iterations = 4^8 theoretical nodes)', () => {
128
+ // Each iteration quadruples the formula: f = (f | f) & (f | f)
129
+ // Tests that the engine handles formula growth gracefully
130
+ const source = `
131
+ logic classical.propositional
132
+ let f = A
133
+ for i in {1,2,3,4,5,6,7,8} {
134
+ set f = (f | f) & (f | f)
135
+ }
136
+ check satisfiable f
137
+ `;
138
+ const out = run(source);
139
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
140
+ (0, vitest_1.expect)(out.stdout).toContain('SATISFACIBLE');
141
+ }, 10000);
142
+ (0, vitest_1.it)('100 axioms sharing same subformulas', () => {
143
+ const axioms = Array.from({ length: 100 }, (_, i) => `axiom a${i} = (P -> Q) & (Q -> R) & (R -> S${i})`).join('\n');
144
+ const source = `
145
+ logic classical.propositional
146
+ ${axioms}
147
+ check valid (P -> Q)
148
+ `;
149
+ const out = run(source);
150
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
151
+ }, 10000);
152
+ (0, vitest_1.it)('deep chain of biconditionals (20 levels, bitset fast path)', () => {
153
+ const atoms = Array.from({ length: 20 }, (_, i) => `B${i}`);
154
+ let formula = atoms[0];
155
+ for (let i = 1; i < atoms.length; i++) {
156
+ formula = `(${formula} <-> ${atoms[i]})`;
157
+ }
158
+ const source = `
159
+ logic classical.propositional
160
+ check satisfiable ${formula}
161
+ `;
162
+ const out = run(source);
163
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
164
+ }, 15000);
165
+ });
166
+ // ============================================================
167
+ // 3. TABLEAU ENGINE — EXPLOSIÓN DE RAMAS
168
+ // ============================================================
169
+ (0, vitest_1.describe)('Stress: Tableau Engine', () => {
170
+ (0, vitest_1.it)('modal K — 30 levels of diamond nesting', () => {
171
+ let formula = 'P';
172
+ for (let i = 0; i < 30; i++) {
173
+ formula = `<>(${formula})`;
174
+ }
175
+ const source = `
176
+ logic modal.k
177
+ check satisfiable ${formula}
178
+ `;
179
+ const out = run(source);
180
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
181
+ }, 20000);
182
+ (0, vitest_1.it)('modal S5 — validity of axiom 5 with deep nesting', () => {
183
+ const source = `
184
+ logic epistemic.s5
185
+ check valid (<>P -> []<>P)
186
+ `;
187
+ const out = run(source);
188
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
189
+ }, 10000);
190
+ (0, vitest_1.it)('deontic — 20 levels of obligation nesting', () => {
191
+ let formula = 'A';
192
+ for (let i = 0; i < 20; i++) {
193
+ formula = `O(${formula})`;
194
+ }
195
+ const source = `
196
+ logic deontic.standard
197
+ check valid ${formula} -> ${formula}
198
+ `;
199
+ const out = run(source);
200
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
201
+ }, 15000);
202
+ (0, vitest_1.it)('temporal — nested G/F/X operators', () => {
203
+ const source = `
204
+ logic temporal.ltl
205
+ check satisfiable G(P -> F(X(Q)))
206
+ `;
207
+ const out = run(source);
208
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
209
+ }, 15000);
210
+ (0, vitest_1.it)('intuitionistic — Peirce law is NOT valid', () => {
211
+ const source = `
212
+ logic intuitionistic.propositional
213
+ check valid (((P -> Q) -> P) -> P)
214
+ `;
215
+ const out = run(source);
216
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
217
+ (0, vitest_1.expect)(out.stdout.toLowerCase()).toContain('no es');
218
+ }, 10000);
219
+ });
220
+ // ============================================================
221
+ // 4. FOL — EXPLOSIÓN DE CUANTIFICADORES
222
+ // ============================================================
223
+ (0, vitest_1.describe)('Stress: First-Order Logic', () => {
224
+ (0, vitest_1.it)('valid universal instantiation with 5 constants', () => {
225
+ const source = `
226
+ logic classical.first_order
227
+ check valid (forall x P(x)) -> (P(a) & P(b) & P(c) & P(d) & P(e))
228
+ `;
229
+ const out = run(source);
230
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
231
+ (0, vitest_1.expect)(stripAccents(out.stdout).toUpperCase()).toContain('VALIDA');
232
+ }, 15000);
233
+ (0, vitest_1.it)('existential from specific — P(a) -> exists x P(x)', () => {
234
+ const source = `
235
+ logic classical.first_order
236
+ check valid (P(a) -> exists x P(x))
237
+ `;
238
+ const out = run(source);
239
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
240
+ (0, vitest_1.expect)(stripAccents(out.stdout).toUpperCase()).toContain('VALIDA');
241
+ }, 10000);
242
+ (0, vitest_1.it)('Barbara syllogism (forall x (P(x)->Q(x))) & P(a) -> Q(a)', () => {
243
+ const source = `
244
+ logic classical.first_order
245
+ check valid ((forall x (P(x) -> Q(x))) -> (P(a) -> Q(a)))
246
+ `;
247
+ const out = run(source);
248
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
249
+ (0, vitest_1.expect)(stripAccents(out.stdout).toUpperCase()).toContain('VALIDA');
250
+ }, 15000);
251
+ (0, vitest_1.it)('nested quantifiers — forall x exists y is satisfiable (does not hang)', () => {
252
+ const source = `
253
+ logic classical.first_order
254
+ check satisfiable forall x exists y R(x,y)
255
+ `;
256
+ const out = run(source);
257
+ // Should complete without hanging. May return satisfiable or hit depth limit.
258
+ (0, vitest_1.expect)([0, 3]).toContain(out.exitCode);
259
+ }, 20000);
260
+ (0, vitest_1.it)('invalid formula correctly detected — exists -> forall', () => {
261
+ const source = `
262
+ logic classical.first_order
263
+ check valid (exists x P(x)) -> (forall x P(x))
264
+ `;
265
+ const out = run(source);
266
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
267
+ (0, vitest_1.expect)(out.stdout.toLowerCase()).toContain('no es');
268
+ }, 15000);
269
+ (0, vitest_1.it)('derivation with 10 axioms in FOL', () => {
270
+ const axioms = Array.from({ length: 9 }, (_, i) => `axiom a${i} = forall x (P${i}(x) -> P${i + 1}(x))`).join('\n');
271
+ const source = `
272
+ logic classical.first_order
273
+ ${axioms}
274
+ axiom base = P0(a)
275
+ derive P9(a) from {a0, a1, a2, a3, a4, a5, a6, a7, a8, base}
276
+ `;
277
+ const out = run(source);
278
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
279
+ }, 20000);
280
+ });
281
+ // ============================================================
282
+ // 5. ARITHMETIC — RECURSIÓN Y LOOPS MASIVOS
283
+ // ============================================================
284
+ (0, vitest_1.describe)('Stress: Arithmetic & Recursion', () => {
285
+ (0, vitest_1.it)('500 iterations of set x = x + 1', () => {
286
+ let setLines = '';
287
+ for (let i = 0; i < 500; i++) {
288
+ setLines += ` set x = x + 1\n`;
289
+ }
290
+ const source = `
291
+ logic arithmetic
292
+ let x = 0
293
+ ${setLines}
294
+ print x
295
+ `;
296
+ const out = run(source);
297
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
298
+ (0, vitest_1.expect)(out.stdout).toContain('500');
299
+ }, 15000);
300
+ (0, vitest_1.it)('recursive function hitting call depth limit gracefully', () => {
301
+ const source = `
302
+ logic arithmetic
303
+ fn infinite(N) {
304
+ let m = N + 1
305
+ return infinite(m)
306
+ }
307
+ let r = infinite(1)
308
+ `;
309
+ const out = run(source);
310
+ // Should not crash — should report a recursion/call limit error
311
+ (0, vitest_1.expect)(out.diagnostics.some((d) => d.message.includes('recursión') ||
312
+ d.message.includes('recursion') ||
313
+ d.message.includes('Límite') ||
314
+ d.message.includes('llamadas'))).toBe(true);
315
+ }, 15000);
316
+ (0, vitest_1.it)('nested for loops (10x10x10 = 1000 iterations)', () => {
317
+ const source = `
318
+ logic arithmetic
319
+ let count = 0
320
+ for i in {1,2,3,4,5,6,7,8,9,10} {
321
+ for j in {1,2,3,4,5,6,7,8,9,10} {
322
+ for k in {1,2,3,4,5,6,7,8,9,10} {
323
+ set count = count + 1
324
+ }
325
+ }
326
+ }
327
+ print count
328
+ `;
329
+ const out = run(source);
330
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
331
+ (0, vitest_1.expect)(out.stdout).toContain('1000');
332
+ }, 30000);
333
+ (0, vitest_1.it)('factorial(10) via recursion', () => {
334
+ const source = `
335
+ logic arithmetic
336
+ fn factorial(N) {
337
+ if valid N <= 1 {
338
+ return 1
339
+ }
340
+ let prev = N - 1
341
+ let res = factorial(prev)
342
+ return N * res
343
+ }
344
+ let f10 = factorial(10)
345
+ print f10
346
+ `;
347
+ const out = run(source);
348
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
349
+ // 10! = 3628800
350
+ (0, vitest_1.expect)(out.stdout).toContain('3628800');
351
+ }, 10000);
352
+ (0, vitest_1.it)('fibonacci(12) via recursion', () => {
353
+ const source = `
354
+ logic arithmetic
355
+ fn fib(N) {
356
+ if valid N <= 0 { return 0 }
357
+ if valid N <= 1 { return 1 }
358
+ let a = N - 1
359
+ let b = N - 2
360
+ let ra = fib(a)
361
+ let rb = fib(b)
362
+ return ra + rb
363
+ }
364
+ let f12 = fib(12)
365
+ print f12
366
+ `;
367
+ const out = run(source);
368
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
369
+ // fib(12) = 144
370
+ (0, vitest_1.expect)(out.stdout).toContain('144');
371
+ }, 30000);
372
+ (0, vitest_1.it)('division by zero does not crash', () => {
373
+ const source = `
374
+ logic arithmetic
375
+ axiom bad = 10 / 0
376
+ explain 10 / 0
377
+ `;
378
+ const out = run(source);
379
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
380
+ (0, vitest_1.expect)(out.diagnostics.some((d) => d.message.includes('División por cero'))).toBe(true);
381
+ }, 5000);
382
+ });
383
+ // ============================================================
384
+ // 6. BELNAP 4-VALUED — BITSET UNDER PRESSURE
385
+ // ============================================================
386
+ (0, vitest_1.describe)('Stress: Belnap Paraconsistent', () => {
387
+ (0, vitest_1.it)('8 atoms — Belnap truth table (4^8 = 65K rows via bitset)', () => {
388
+ const atoms = Array.from({ length: 8 }, (_, i) => `B${i}`);
389
+ const formula = atoms.join(' & ');
390
+ const source = `
391
+ logic paraconsistent.belnap
392
+ check valid ${formula}
393
+ `;
394
+ const out = run(source);
395
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
396
+ }, 30000);
397
+ (0, vitest_1.it)('Belnap EFQ is NOT valid (P & !P) -> Q', () => {
398
+ const source = `
399
+ logic paraconsistent.belnap
400
+ check valid (P & !P) -> Q
401
+ `;
402
+ const out = run(source);
403
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
404
+ (0, vitest_1.expect)(stripAccents(out.stdout).toLowerCase()).toContain('no es valida');
405
+ }, 10000);
406
+ (0, vitest_1.it)('8 atoms — Belnap satisfiability', () => {
407
+ const atoms = Array.from({ length: 8 }, (_, i) => `C${i}`);
408
+ const formula = atoms.map((a) => `(${a} | !${a})`).join(' & ');
409
+ const source = `
410
+ logic paraconsistent.belnap
411
+ check satisfiable ${formula}
412
+ `;
413
+ const out = run(source);
414
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
415
+ }, 15000);
416
+ });
417
+ // ============================================================
418
+ // 7. MULTI-PROFILE WHIPLASH — CAMBIOS RÁPIDOS DE PERFIL
419
+ // ============================================================
420
+ (0, vitest_1.describe)('Stress: Multi-Profile Whiplash', () => {
421
+ (0, vitest_1.it)('rapid profile switching (10 profiles in one program)', () => {
422
+ const source = `
423
+ logic classical.propositional
424
+ check valid (P -> P)
425
+
426
+ logic modal.k
427
+ check valid [](P -> P)
428
+
429
+ logic deontic.standard
430
+ check valid O(P) -> O(P)
431
+
432
+ logic temporal.ltl
433
+ check satisfiable G(P -> F(Q))
434
+
435
+ logic epistemic.s5
436
+ check satisfiable K(P) & !P
437
+
438
+ logic paraconsistent.belnap
439
+ check satisfiable P & !P
440
+
441
+ logic intuitionistic.propositional
442
+ check valid (P -> P)
443
+
444
+ logic classical.first_order
445
+ check valid (forall x P(x)) -> P(a)
446
+
447
+ logic arithmetic
448
+ explain 2 + 3
449
+
450
+ logic probabilistic.basic
451
+ check satisfiable Pr(A) = 0.5
452
+ `;
453
+ const out = run(source);
454
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
455
+ (0, vitest_1.expect)(out.results.length).toBeGreaterThanOrEqual(10);
456
+ }, 15000);
457
+ (0, vitest_1.it)('all profiles produce correct results', () => {
458
+ const source = `
459
+ logic classical.propositional
460
+ check valid (P | !P)
461
+ `;
462
+ const out1 = run(source);
463
+ (0, vitest_1.expect)(out1.results[0].status).toBe('valid');
464
+ const source2 = `
465
+ logic paraconsistent.belnap
466
+ check valid (P | !P)
467
+ `;
468
+ const out2 = run(source2);
469
+ // Belnap: P | !P is NOT valid (fails for Both value)
470
+ (0, vitest_1.expect)(out2.results[0].status).not.toBe('valid');
471
+ }, 10000);
472
+ });
473
+ // ============================================================
474
+ // 8. COMBINADO — PRUEBA OMEGA FINAL
475
+ // ============================================================
476
+ (0, vitest_1.describe)('Stress: Omega Final', () => {
477
+ (0, vitest_1.it)('theory with 50 axioms + derivation chain', () => {
478
+ const axioms = Array.from({ length: 49 }, (_, i) => `axiom a${i} = P${i} -> P${i + 1}`).join('\n');
479
+ const source = `
480
+ logic classical.propositional
481
+ ${axioms}
482
+ axiom base = P0
483
+ derive P49 from {${Array.from({ length: 49 }, (_, i) => `a${i}`).join(', ')}, base}
484
+ `;
485
+ const out = run(source);
486
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
487
+ (0, vitest_1.expect)(out.stdout).toContain('[derive]');
488
+ }, 30000);
489
+ (0, vitest_1.it)('proof block with complex premise set', () => {
490
+ const source = `
491
+ logic classical.propositional
492
+ axiom a1 = P -> Q
493
+ axiom a2 = Q -> R
494
+ axiom a3 = R -> S
495
+ axiom a4 = S -> T
496
+ axiom base = P
497
+ prove T from {a1, a2, a3, a4, base}
498
+ `;
499
+ const out = run(source);
500
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
501
+ }, 10000);
502
+ (0, vitest_1.it)('massive theory render (50 axioms + 50 theorems)', () => {
503
+ const decls = Array.from({ length: 50 }, (_, i) => `axiom a${i} = P${i} -> Q${i}`).join('\n') +
504
+ '\n' +
505
+ Array.from({ length: 50 }, (_, i) => `theorem t${i} = Q${i} -> R${i}`).join('\n');
506
+ const source = `
507
+ logic classical.propositional
508
+ ${decls}
509
+ render theory
510
+ `;
511
+ const out = run(source);
512
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
513
+ (0, vitest_1.expect)(out.stdout).toContain('Render');
514
+ }, 10000);
515
+ });
516
+ // ============================================================
517
+ // 9. DPLL SAT SOLVER — BEYOND 26 ATOM WALL
518
+ // ============================================================
519
+ (0, vitest_1.describe)('Stress: DPLL SAT Solver', () => {
520
+ (0, vitest_1.it)('30 atoms — validity via DPLL (tautology)', () => {
521
+ const atoms = Array.from({ length: 30 }, (_, i) => `D${i}`);
522
+ const tautology = atoms.map((a) => `(${a} | !${a})`).join(' & ');
523
+ const source = `
524
+ logic classical.propositional
525
+ check valid ${tautology}
526
+ `;
527
+ const out = run(source);
528
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
529
+ (0, vitest_1.expect)(stripAccents(out.stdout).toUpperCase()).toContain('VALIDA');
530
+ }, 30000);
531
+ (0, vitest_1.it)('30 atoms — satisfiability via DPLL (conjunction)', () => {
532
+ const atoms = Array.from({ length: 30 }, (_, i) => `S${i}`);
533
+ const formula = atoms.join(' & ');
534
+ const source = `
535
+ logic classical.propositional
536
+ check satisfiable ${formula}
537
+ `;
538
+ const out = run(source);
539
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
540
+ (0, vitest_1.expect)(out.stdout).toContain('SATISFACIBLE');
541
+ }, 30000);
542
+ (0, vitest_1.it)('30 atoms — unsatisfiable conjunction via DPLL', () => {
543
+ // C0 & !C0 & C1 & ... — immediately unsatisfiable
544
+ const atoms = Array.from({ length: 30 }, (_, i) => `C${i}`);
545
+ const formula = atoms.join(' & ') + ' & !C0';
546
+ const source = `
547
+ logic classical.propositional
548
+ check satisfiable ${formula}
549
+ `;
550
+ const out = run(source);
551
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
552
+ (0, vitest_1.expect)(out.stdout).toContain('INSATISFACIBLE');
553
+ }, 30000);
554
+ (0, vitest_1.it)('50 atoms — satisfiability via DPLL (simple conjunction)', () => {
555
+ const atoms = Array.from({ length: 50 }, (_, i) => `V${i}`);
556
+ const formula = atoms.join(' & ');
557
+ const source = `
558
+ logic classical.propositional
559
+ check satisfiable ${formula}
560
+ `;
561
+ const out = run(source);
562
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
563
+ (0, vitest_1.expect)(out.stdout).toContain('SATISFACIBLE');
564
+ }, 30000);
565
+ (0, vitest_1.it)('50 atoms — tautology via DPLL', () => {
566
+ // Each atom ORed with its negation — tautology
567
+ const atoms = Array.from({ length: 50 }, (_, i) => `T${i}`);
568
+ const tautology = atoms.map((a) => `(${a} | !${a})`).join(' & ');
569
+ const source = `
570
+ logic classical.propositional
571
+ check valid ${tautology}
572
+ `;
573
+ const out = run(source);
574
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
575
+ (0, vitest_1.expect)(stripAccents(out.stdout).toUpperCase()).toContain('VALIDA');
576
+ }, 30000);
577
+ (0, vitest_1.it)('countermodel with 26 atoms (previously capped at 18)', () => {
578
+ const atoms = Array.from({ length: 26 }, (_, i) => `M${i}`);
579
+ // Conjunction of all atoms is not a tautology — countermodel exists
580
+ const formula = atoms.join(' & ');
581
+ const source = `
582
+ logic classical.propositional
583
+ countermodel ${formula}
584
+ `;
585
+ const out = run(source);
586
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
587
+ (0, vitest_1.expect)(out.stdout).toContain('Contramodelo');
588
+ }, 15000);
589
+ (0, vitest_1.it)('countermodel with 30 atoms via DPLL', () => {
590
+ const atoms = Array.from({ length: 30 }, (_, i) => `N${i}`);
591
+ const formula = atoms.join(' & ');
592
+ const source = `
593
+ logic classical.propositional
594
+ countermodel ${formula}
595
+ `;
596
+ const out = run(source);
597
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
598
+ (0, vitest_1.expect)(out.stdout).toContain('Contramodelo');
599
+ }, 30000);
600
+ (0, vitest_1.it)('pigeonhole(4,3) — 12 variables, hard for naive but resoluble', () => {
601
+ // Encode: 4 pigeons, 3 holes
602
+ // Each pigeon must be in some hole: OR_j P_{i,j}
603
+ // No two pigeons in same hole: NOT(P_{i,j} AND P_{k,j}) for i != k
604
+ const clauses = [];
605
+ for (let i = 0; i < 4; i++) {
606
+ clauses.push(`(P${i}H0 | P${i}H1 | P${i}H2)`);
607
+ }
608
+ for (let j = 0; j < 3; j++) {
609
+ for (let i = 0; i < 4; i++) {
610
+ for (let k = i + 1; k < 4; k++) {
611
+ clauses.push(`!(P${i}H${j} & P${k}H${j})`);
612
+ }
613
+ }
614
+ }
615
+ const formula = clauses.join(' & ');
616
+ const source = `
617
+ logic classical.propositional
618
+ check satisfiable ${formula}
619
+ `;
620
+ const out = run(source);
621
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
622
+ // Pigeonhole(4,3) is unsatisfiable
623
+ (0, vitest_1.expect)(out.stdout).toContain('INSATISFACIBLE');
624
+ }, 30000);
625
+ });
626
+ // ============================================================
627
+ // 10. PROFILE-AWARE LEXER — CONTEXTUAL KEYWORDS
628
+ // ============================================================
629
+ (0, vitest_1.describe)('Stress: Profile-Aware Lexer', () => {
630
+ (0, vitest_1.it)('`next` is a valid identifier in arithmetic profile', () => {
631
+ const source = `
632
+ logic arithmetic
633
+ let next = 5
634
+ let until = 10
635
+ let result = next + until
636
+ explain result
637
+ `;
638
+ const out = run(source);
639
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
640
+ (0, vitest_1.expect)(out.stdout).toContain('15');
641
+ }, 10000);
642
+ (0, vitest_1.it)('`next` is still a temporal keyword in temporal.ltl', () => {
643
+ const source = `
644
+ logic temporal.ltl
645
+ check satisfiable next P
646
+ `;
647
+ const out = run(source);
648
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
649
+ }, 10000);
650
+ (0, vitest_1.it)('`until` is a valid identifier in classical.propositional', () => {
651
+ const source = `
652
+ logic classical.propositional
653
+ let until = P & Q
654
+ check valid until -> P
655
+ `;
656
+ const out = run(source);
657
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
658
+ (0, vitest_1.expect)(stripAccents(out.stdout).toUpperCase()).toContain('VALIDA');
659
+ }, 10000);
660
+ (0, vitest_1.it)('multi-profile file still works with temporal keywords', () => {
661
+ const source = `
662
+ logic classical.propositional
663
+ check valid (P | !P)
664
+
665
+ logic temporal.ltl
666
+ check satisfiable next P
667
+ check satisfiable P until Q
668
+ `;
669
+ const out = run(source);
670
+ (0, vitest_1.expect)(out.exitCode).toBe(0);
671
+ }, 10000);
672
+ });
673
+ //# sourceMappingURL=stress-hardware.test.js.map