@stevenvo780/st-lang 0.3.0 → 0.4.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/README.md +86 -0
- package/dist/api.d.ts +7 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +20 -19
- package/dist/api.js.map +1 -1
- package/dist/ast/nodes.d.ts +1 -0
- package/dist/ast/nodes.d.ts.map +1 -1
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +116 -182
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/lexer/lexer.d.ts +3 -0
- package/dist/lexer/lexer.d.ts.map +1 -1
- package/dist/lexer/lexer.js +15 -7
- package/dist/lexer/lexer.js.map +1 -1
- package/dist/lexer/tokens.d.ts +4 -0
- package/dist/lexer/tokens.d.ts.map +1 -1
- package/dist/lexer/tokens.js +28 -21
- package/dist/lexer/tokens.js.map +1 -1
- package/dist/parser/parser.d.ts +4 -0
- package/dist/parser/parser.d.ts.map +1 -1
- package/dist/parser/parser.js +107 -23
- package/dist/parser/parser.js.map +1 -1
- package/dist/profiles/classical/first-order.d.ts +7 -2
- package/dist/profiles/classical/first-order.d.ts.map +1 -1
- package/dist/profiles/classical/first-order.js +144 -29
- package/dist/profiles/classical/first-order.js.map +1 -1
- package/dist/profiles/classical/propositional.d.ts +1 -0
- package/dist/profiles/classical/propositional.d.ts.map +1 -1
- package/dist/profiles/classical/propositional.js +175 -61
- package/dist/profiles/classical/propositional.js.map +1 -1
- package/dist/profiles/interface.d.ts.map +1 -1
- package/dist/profiles/modal/k.d.ts +11 -3
- package/dist/profiles/modal/k.d.ts.map +1 -1
- package/dist/profiles/modal/k.js +305 -11
- package/dist/profiles/modal/k.js.map +1 -1
- package/dist/profiles/paraconsistent/belnap.d.ts +17 -1
- package/dist/profiles/paraconsistent/belnap.d.ts.map +1 -1
- package/dist/profiles/paraconsistent/belnap.js +195 -11
- package/dist/profiles/paraconsistent/belnap.js.map +1 -1
- package/dist/protocol/handler.d.ts.map +1 -1
- package/dist/protocol/handler.js +208 -22
- package/dist/protocol/handler.js.map +1 -1
- package/dist/repl/repl.d.ts.map +1 -1
- package/dist/repl/repl.js +9 -6
- package/dist/repl/repl.js.map +1 -1
- package/dist/runtime/interpreter.d.ts +4 -2
- package/dist/runtime/interpreter.d.ts.map +1 -1
- package/dist/runtime/interpreter.js +86 -48
- package/dist/runtime/interpreter.js.map +1 -1
- package/dist/tests/cli.test.d.ts +1 -1
- package/dist/tests/cli.test.d.ts.map +1 -1
- package/dist/tests/cli.test.js +112 -115
- package/dist/tests/cli.test.js.map +1 -1
- package/dist/tests/core.test.d.ts +1 -1
- package/dist/tests/core.test.d.ts.map +1 -1
- package/dist/tests/core.test.js +175 -174
- package/dist/tests/core.test.js.map +1 -1
- package/dist/tests/engines.test.d.ts +2 -0
- package/dist/tests/engines.test.d.ts.map +1 -0
- package/dist/tests/engines.test.js +81 -0
- package/dist/tests/engines.test.js.map +1 -0
- package/dist/tests/parser.test.d.ts +1 -1
- package/dist/tests/parser.test.d.ts.map +1 -1
- package/dist/tests/parser.test.js +162 -165
- package/dist/tests/parser.test.js.map +1 -1
- package/dist/tests/philosophy.test.d.ts +2 -0
- package/dist/tests/philosophy.test.d.ts.map +1 -0
- package/dist/tests/philosophy.test.js +588 -0
- package/dist/tests/philosophy.test.js.map +1 -0
- package/dist/text-layer/compiler.d.ts +5 -9
- package/dist/text-layer/compiler.d.ts.map +1 -1
- package/dist/text-layer/compiler.js +6 -4
- package/dist/text-layer/compiler.js.map +1 -1
- package/dist/types/index.d.ts +10 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +24 -7
- package/dist/tests/runner.d.ts +0 -6
- package/dist/tests/runner.d.ts.map +0 -1
- package/dist/tests/runner.js +0 -69
- package/dist/tests/runner.js.map +0 -1
package/dist/profiles/modal/k.js
CHANGED
|
@@ -1,38 +1,332 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// ============================================================
|
|
3
|
-
// ST Modal K —
|
|
3
|
+
// ST Modal K — Labeled Tableau v3 (Gamma-Watchers)
|
|
4
|
+
// ============================================================
|
|
5
|
+
// Motor completo de tableau etiquetado para lógica modal K.
|
|
6
|
+
// Resuelve el problema del Axioma K mediante el patrón
|
|
7
|
+
// Gamma-Watcher: las reglas gamma se registran como observadores
|
|
8
|
+
// permanentes que se re-instancian cuando Delta crea mundos nuevos.
|
|
4
9
|
// ============================================================
|
|
5
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
11
|
exports.ModalK = void 0;
|
|
7
12
|
const propositional_1 = require("../classical/propositional");
|
|
13
|
+
const MAX_DEPTH = 200;
|
|
14
|
+
// ── Eliminación de implies/biconditional ────────────────────
|
|
15
|
+
// toNNF conserva implies/biconditional en caso no-negado.
|
|
16
|
+
// El tableau necesita que todo sea and/or/not/atom/modal.
|
|
17
|
+
function eliminateConnectives(f) {
|
|
18
|
+
const args = (f.args || []).map(eliminateConnectives);
|
|
19
|
+
switch (f.kind) {
|
|
20
|
+
case 'implies':
|
|
21
|
+
// A -> B ≡ ¬A ∨ B
|
|
22
|
+
return { kind: 'or', args: [{ kind: 'not', args: [args[0]] }, args[1]] };
|
|
23
|
+
case 'biconditional':
|
|
24
|
+
// A <-> B ≡ (A ∧ B) ∨ (¬A ∧ ¬B)
|
|
25
|
+
return {
|
|
26
|
+
kind: 'or',
|
|
27
|
+
args: [
|
|
28
|
+
{ kind: 'and', args: [args[0], args[1]] },
|
|
29
|
+
{ kind: 'and', args: [{ kind: 'not', args: [args[0]] }, { kind: 'not', args: [args[1]] }] },
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
case 'modal_necessity':
|
|
33
|
+
case 'modal_possibility':
|
|
34
|
+
return { ...f, args };
|
|
35
|
+
case 'not':
|
|
36
|
+
return { ...f, args };
|
|
37
|
+
case 'and':
|
|
38
|
+
case 'or':
|
|
39
|
+
return { ...f, args };
|
|
40
|
+
default:
|
|
41
|
+
return f;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** NNF completo: primero elimina implies/biconditional, luego aplica toNNF */
|
|
45
|
+
function fullNNF(f) {
|
|
46
|
+
return (0, propositional_1.toNNF)(eliminateConnectives(f));
|
|
47
|
+
}
|
|
48
|
+
// ── Utilidades ──────────────────────────────────────────────
|
|
49
|
+
function formulaEqual(a, b) {
|
|
50
|
+
if (a.kind !== b.kind)
|
|
51
|
+
return false;
|
|
52
|
+
if (a.kind === 'atom' && b.kind === 'atom')
|
|
53
|
+
return a.name === b.name;
|
|
54
|
+
const aa = a.args || [];
|
|
55
|
+
const bb = b.args || [];
|
|
56
|
+
if (aa.length !== bb.length)
|
|
57
|
+
return false;
|
|
58
|
+
return aa.every((ai, i) => formulaEqual(ai, bb[i]));
|
|
59
|
+
}
|
|
60
|
+
function formulaHash(f) {
|
|
61
|
+
// Hash propio que SÍ maneja operadores modales (formulaToString no lo hace)
|
|
62
|
+
switch (f.kind) {
|
|
63
|
+
case 'atom': return f.name || '?';
|
|
64
|
+
case 'not': return `!${formulaHash((f.args || [])[0])}`;
|
|
65
|
+
case 'and': return `(${formulaHash((f.args || [])[0])} & ${formulaHash((f.args || [])[1])})`;
|
|
66
|
+
case 'or': return `(${formulaHash((f.args || [])[0])} | ${formulaHash((f.args || [])[1])})`;
|
|
67
|
+
case 'implies': return `(${formulaHash((f.args || [])[0])} -> ${formulaHash((f.args || [])[1])})`;
|
|
68
|
+
case 'biconditional': return `(${formulaHash((f.args || [])[0])} <-> ${formulaHash((f.args || [])[1])})`;
|
|
69
|
+
case 'modal_necessity': return `[](${formulaHash((f.args || [])[0])})`;
|
|
70
|
+
case 'modal_possibility': return `<>(${formulaHash((f.args || [])[0])})`;
|
|
71
|
+
case 'forall': return `A${f.variable}(${formulaHash((f.args || [])[0])})`;
|
|
72
|
+
case 'exists': return `E${f.variable}(${formulaHash((f.args || [])[0])})`;
|
|
73
|
+
case 'predicate': return `${f.name}(${(f.args || []).map(formulaHash).join(',')})`;
|
|
74
|
+
default: return f.kind;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function nodeKey(n) {
|
|
78
|
+
return `${n.world}:${formulaHash(n.formula)}`;
|
|
79
|
+
}
|
|
80
|
+
function cloneBranch(b) {
|
|
81
|
+
return {
|
|
82
|
+
literals: [...b.literals],
|
|
83
|
+
pending: [...b.pending],
|
|
84
|
+
accessibility: new Map(Array.from(b.accessibility.entries()).map(([k, v]) => [k, new Set(v)])),
|
|
85
|
+
gammaWatchers: [...b.gammaWatchers],
|
|
86
|
+
processed: new Set(b.processed),
|
|
87
|
+
worldCounter: b.worldCounter,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function classify(f) {
|
|
91
|
+
switch (f.kind) {
|
|
92
|
+
case 'and': return 'alfa';
|
|
93
|
+
case 'or': return 'beta';
|
|
94
|
+
case 'implies': return 'beta'; // A->B = !A | B en NNF, pero si llega, tratar como beta
|
|
95
|
+
case 'modal_possibility': return 'delta';
|
|
96
|
+
case 'modal_necessity': return 'gamma';
|
|
97
|
+
default: return 'literal';
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// ── Motor principal ─────────────────────────────────────────
|
|
8
101
|
class ModalK {
|
|
9
102
|
name = 'modal.k';
|
|
10
|
-
description = 'Logica modal K
|
|
103
|
+
description = 'Logica modal K — Labeled Tableau v3 (Gamma-Watchers)';
|
|
11
104
|
checkWellFormed(formula) {
|
|
12
|
-
|
|
105
|
+
const diags = [];
|
|
106
|
+
const walk = (f) => {
|
|
107
|
+
if (f.kind === 'atom' && !f.name)
|
|
108
|
+
diags.push({ severity: 'error', message: 'Atomo sin nombre' });
|
|
109
|
+
f.args?.forEach(walk);
|
|
110
|
+
};
|
|
111
|
+
walk(formula);
|
|
112
|
+
return diags;
|
|
13
113
|
}
|
|
14
114
|
checkValid(formula) {
|
|
115
|
+
const negated = fullNNF({ kind: 'not', args: [formula] });
|
|
116
|
+
const closed = this.tableau(negated);
|
|
15
117
|
return {
|
|
16
|
-
status: '
|
|
17
|
-
output:
|
|
18
|
-
|
|
118
|
+
status: closed ? 'valid' : 'invalid',
|
|
119
|
+
output: closed
|
|
120
|
+
? `${(0, propositional_1.formulaToString)(formula)} es VALIDA en K`
|
|
121
|
+
: `${(0, propositional_1.formulaToString)(formula)} NO es valida en K`,
|
|
122
|
+
diagnostics: [],
|
|
19
123
|
formula,
|
|
20
124
|
};
|
|
21
125
|
}
|
|
22
126
|
checkSatisfiable(formula) {
|
|
23
|
-
|
|
127
|
+
const nnf = fullNNF(formula);
|
|
128
|
+
const closed = this.tableau(nnf);
|
|
129
|
+
return {
|
|
130
|
+
status: !closed ? 'satisfiable' : 'unsatisfiable',
|
|
131
|
+
output: !closed ? 'Satisfacible' : 'Insatisfacible',
|
|
132
|
+
diagnostics: [],
|
|
133
|
+
formula,
|
|
134
|
+
};
|
|
24
135
|
}
|
|
25
136
|
prove(goal, theory) {
|
|
26
|
-
|
|
137
|
+
const axiomNodes = Array.from(theory.axioms.values())
|
|
138
|
+
.map(a => ({ formula: fullNNF(a), world: 'w0' }));
|
|
139
|
+
const negGoal = { formula: fullNNF({ kind: 'not', args: [goal] }), world: 'w0' };
|
|
140
|
+
const allNodes = [...axiomNodes, negGoal];
|
|
141
|
+
const branch = this.makeBranch(allNodes);
|
|
142
|
+
const closed = this.expand(branch, 0);
|
|
143
|
+
return {
|
|
144
|
+
status: closed ? 'provable' : 'refutable',
|
|
145
|
+
output: closed ? 'Demostrado por tableau' : 'No demostrable',
|
|
146
|
+
diagnostics: [],
|
|
147
|
+
formula: goal,
|
|
148
|
+
};
|
|
27
149
|
}
|
|
28
150
|
derive(goal, premises, theory) {
|
|
29
|
-
|
|
151
|
+
const formulas = premises
|
|
152
|
+
.map(p => theory.axioms.get(p))
|
|
153
|
+
.filter((f) => !!f);
|
|
154
|
+
const nodes = [
|
|
155
|
+
...formulas.map(f => ({ formula: fullNNF(f), world: 'w0' })),
|
|
156
|
+
{ formula: fullNNF({ kind: 'not', args: [goal] }), world: 'w0' },
|
|
157
|
+
];
|
|
158
|
+
const branch = this.makeBranch(nodes);
|
|
159
|
+
const closed = this.expand(branch, 0);
|
|
160
|
+
return {
|
|
161
|
+
status: closed ? 'provable' : 'refutable',
|
|
162
|
+
output: closed ? 'Derivacion valida' : 'Derivacion no valida',
|
|
163
|
+
diagnostics: [],
|
|
164
|
+
formula: goal,
|
|
165
|
+
};
|
|
30
166
|
}
|
|
31
167
|
countermodel(formula) {
|
|
32
|
-
return
|
|
168
|
+
return this.checkValid(formula);
|
|
33
169
|
}
|
|
34
170
|
explain(formula) {
|
|
35
|
-
return {
|
|
171
|
+
return {
|
|
172
|
+
status: 'unknown',
|
|
173
|
+
output: `Modal K — Labeled Tableau v3`,
|
|
174
|
+
diagnostics: [],
|
|
175
|
+
formula,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
// ── Punto de entrada del tableau ──────────────────────────
|
|
179
|
+
tableau(formula) {
|
|
180
|
+
const branch = this.makeBranch([{ formula, world: 'w0' }]);
|
|
181
|
+
return this.expand(branch, 0);
|
|
182
|
+
}
|
|
183
|
+
makeBranch(nodes) {
|
|
184
|
+
return {
|
|
185
|
+
literals: [],
|
|
186
|
+
pending: [...nodes],
|
|
187
|
+
accessibility: new Map([['w0', new Set()]]),
|
|
188
|
+
gammaWatchers: [],
|
|
189
|
+
processed: new Set(),
|
|
190
|
+
worldCounter: 1,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
// ── Expansión del tableau ─────────────────────────────────
|
|
194
|
+
expand(branch, depth) {
|
|
195
|
+
if (depth > MAX_DEPTH)
|
|
196
|
+
return false;
|
|
197
|
+
// 1. Procesar todos los literales primero
|
|
198
|
+
while (true) {
|
|
199
|
+
const litIdx = branch.pending.findIndex(n => classify(n.formula) === 'literal');
|
|
200
|
+
if (litIdx === -1)
|
|
201
|
+
break;
|
|
202
|
+
const node = branch.pending.splice(litIdx, 1)[0];
|
|
203
|
+
// Comprobar cierre
|
|
204
|
+
if (this.closes(branch, node))
|
|
205
|
+
return true;
|
|
206
|
+
branch.literals.push(node);
|
|
207
|
+
}
|
|
208
|
+
// 2. Buscar siguiente regla por prioridad: alfa → delta → gamma → beta
|
|
209
|
+
const priorities = ['alfa', 'delta', 'gamma', 'beta'];
|
|
210
|
+
for (const priority of priorities) {
|
|
211
|
+
const idx = branch.pending.findIndex(n => {
|
|
212
|
+
const t = classify(n.formula);
|
|
213
|
+
if (t !== priority)
|
|
214
|
+
return false;
|
|
215
|
+
if (priority === 'gamma')
|
|
216
|
+
return true; // Gamma siempre se puede intentar
|
|
217
|
+
const key = nodeKey(n);
|
|
218
|
+
return !branch.processed.has(key);
|
|
219
|
+
});
|
|
220
|
+
if (idx === -1)
|
|
221
|
+
continue;
|
|
222
|
+
const node = branch.pending.splice(idx, 1)[0];
|
|
223
|
+
const key = nodeKey(node);
|
|
224
|
+
switch (priority) {
|
|
225
|
+
case 'alfa':
|
|
226
|
+
return this.applyAlfa(branch, node, key, depth);
|
|
227
|
+
case 'delta':
|
|
228
|
+
return this.applyDelta(branch, node, key, depth);
|
|
229
|
+
case 'gamma':
|
|
230
|
+
return this.applyGamma(branch, node, key, depth);
|
|
231
|
+
case 'beta':
|
|
232
|
+
return this.applyBeta(branch, node, key, depth);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
// Sin más reglas que aplicar: rama abierta
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
// ── Regla Alfa (conjunción) ───────────────────────────────
|
|
239
|
+
applyAlfa(branch, node, key, depth) {
|
|
240
|
+
branch.processed.add(key);
|
|
241
|
+
const args = node.formula.args || [];
|
|
242
|
+
if (args.length < 2)
|
|
243
|
+
return this.expand(branch, depth + 1);
|
|
244
|
+
branch.pending.push({ formula: args[0], world: node.world }, { formula: args[1], world: node.world });
|
|
245
|
+
return this.expand(branch, depth + 1);
|
|
246
|
+
}
|
|
247
|
+
// ── Regla Delta (posibilidad: crea mundo nuevo) ───────────
|
|
248
|
+
applyDelta(branch, node, key, depth) {
|
|
249
|
+
branch.processed.add(key);
|
|
250
|
+
const inner = (node.formula.args || [])[0];
|
|
251
|
+
if (!inner)
|
|
252
|
+
return this.expand(branch, depth + 1);
|
|
253
|
+
const newWorld = `w${branch.worldCounter++}`;
|
|
254
|
+
// Establecer accesibilidad: sourceWorld → newWorld
|
|
255
|
+
if (!branch.accessibility.has(node.world)) {
|
|
256
|
+
branch.accessibility.set(node.world, new Set());
|
|
257
|
+
}
|
|
258
|
+
branch.accessibility.get(node.world).add(newWorld);
|
|
259
|
+
branch.accessibility.set(newWorld, new Set());
|
|
260
|
+
// Agregar la subfórmula en el mundo nuevo
|
|
261
|
+
branch.pending.push({ formula: inner, world: newWorld });
|
|
262
|
+
// ★ Clave: Re-instanciar TODOS los gamma-watchers del mundo fuente
|
|
263
|
+
for (const watcher of branch.gammaWatchers) {
|
|
264
|
+
if (watcher.sourceWorld === node.world) {
|
|
265
|
+
const instKey = `gamma-inst:${newWorld}:${formulaHash(watcher.innerFormula)}`;
|
|
266
|
+
if (!branch.processed.has(instKey)) {
|
|
267
|
+
branch.processed.add(instKey);
|
|
268
|
+
branch.pending.push({ formula: watcher.innerFormula, world: newWorld });
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return this.expand(branch, depth + 1);
|
|
273
|
+
}
|
|
274
|
+
// ── Regla Gamma (necesidad: instanciar en mundos accesibles) ──
|
|
275
|
+
applyGamma(branch, node, _key, depth) {
|
|
276
|
+
const inner = (node.formula.args || [])[0];
|
|
277
|
+
if (!inner)
|
|
278
|
+
return this.expand(branch, depth + 1);
|
|
279
|
+
// Registrar como gamma-watcher permanente (si no existe ya)
|
|
280
|
+
const watcherExists = branch.gammaWatchers.some(w => w.sourceWorld === node.world && formulaEqual(w.innerFormula, inner));
|
|
281
|
+
if (!watcherExists) {
|
|
282
|
+
branch.gammaWatchers.push({ innerFormula: inner, sourceWorld: node.world });
|
|
283
|
+
}
|
|
284
|
+
// Instanciar en todos los mundos accesibles existentes
|
|
285
|
+
const accessibleWorlds = branch.accessibility.get(node.world) || new Set();
|
|
286
|
+
let addedAny = false;
|
|
287
|
+
for (const targetWorld of accessibleWorlds) {
|
|
288
|
+
const instKey = `gamma-inst:${targetWorld}:${formulaHash(inner)}`;
|
|
289
|
+
if (!branch.processed.has(instKey)) {
|
|
290
|
+
branch.processed.add(instKey);
|
|
291
|
+
branch.pending.push({ formula: inner, world: targetWorld });
|
|
292
|
+
addedAny = true;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
// Gamma se descarta del pending (ya registrada como watcher)
|
|
296
|
+
// No se marca en processed como los demás, porque es re-usable
|
|
297
|
+
if (addedAny) {
|
|
298
|
+
return this.expand(branch, depth + 1);
|
|
299
|
+
}
|
|
300
|
+
// Si no se agregó nada, continuar con el siguiente pending
|
|
301
|
+
return this.expand(branch, depth + 1);
|
|
302
|
+
}
|
|
303
|
+
// ── Regla Beta (disyunción: bifurca) ──────────────────────
|
|
304
|
+
applyBeta(branch, node, key, depth) {
|
|
305
|
+
branch.processed.add(key);
|
|
306
|
+
const args = node.formula.args || [];
|
|
307
|
+
if (args.length < 2)
|
|
308
|
+
return this.expand(branch, depth + 1);
|
|
309
|
+
// Bifurcar: ambas ramas deben cerrarse para que el tableau cierre
|
|
310
|
+
const branchLeft = cloneBranch(branch);
|
|
311
|
+
branchLeft.pending.push({ formula: args[0], world: node.world });
|
|
312
|
+
const branchRight = cloneBranch(branch);
|
|
313
|
+
branchRight.pending.push({ formula: args[1], world: node.world });
|
|
314
|
+
return this.expand(branchLeft, depth + 1) && this.expand(branchRight, depth + 1);
|
|
315
|
+
}
|
|
316
|
+
// ── Detección de cierre (contradicción) ───────────────────
|
|
317
|
+
closes(branch, node) {
|
|
318
|
+
const f = node.formula;
|
|
319
|
+
const w = node.world;
|
|
320
|
+
// Caso 1: node = !A, buscar A en literals
|
|
321
|
+
if (f.kind === 'not' && f.args?.[0]) {
|
|
322
|
+
const target = f.args[0];
|
|
323
|
+
return branch.literals.some(lit => lit.world === w && formulaEqual(lit.formula, target));
|
|
324
|
+
}
|
|
325
|
+
// Caso 2: node = A, buscar !A en literals
|
|
326
|
+
return branch.literals.some(lit => lit.world === w
|
|
327
|
+
&& lit.formula.kind === 'not'
|
|
328
|
+
&& lit.formula.args?.[0] !== undefined
|
|
329
|
+
&& formulaEqual(lit.formula.args[0], f));
|
|
36
330
|
}
|
|
37
331
|
}
|
|
38
332
|
exports.ModalK = ModalK;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"k.js","sourceRoot":"","sources":["../../../src/profiles/modal/k.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,wCAAwC;AACxC,+DAA+D;;;AAK/D,8DAA6D;AAE7D,MAAa,MAAM;IACjB,IAAI,GAAG,SAAS,CAAC;IACjB,WAAW,GAAG,4DAA4D,CAAC;IAE3E,eAAe,CAAC,OAAgB;QAC9B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,UAAU,CAAC,OAAgB;QACzB,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,iDAAiD,IAAA,+BAAe,EAAC,OAAO,CAAC,EAAE;YACnF,WAAW,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,4CAA4C,EAAE,CAAC;YAC7F,OAAO;SACR,CAAC;IACJ,CAAC;IAED,gBAAgB,CAAC,OAAgB;QAC/B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,2BAA2B,EAAE,WAAW,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC;IACvJ,CAAC;IAED,KAAK,CAAC,IAAa,EAAE,MAAc;QACjC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,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,IAAI,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAC5D,CAAC;QACJ,CAAC;QAED,0CAA0C;QAC1C,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CACzB,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC;eACjB,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,KAAK;eAC1B,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,SAAS;eACnC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAC1C,CAAC;IACJ,CAAC;CACF;AAnRD,wBAmRC"}
|
|
@@ -1,13 +1,29 @@
|
|
|
1
|
-
import { Formula,
|
|
1
|
+
import { Formula, RunResult, Theory, LogicProfile, Diagnostic } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Valores de verdad en la lógica de Belnap (A4):
|
|
4
|
+
* T: True (Solo verdad)
|
|
5
|
+
* F: False (Solo falsedad)
|
|
6
|
+
* B: Both (Verdadero y Falso - Inconsistente)
|
|
7
|
+
* N: None (Ni Verdadero ni Falso - Indeterminado)
|
|
8
|
+
*/
|
|
9
|
+
export type BelnapValue = 'T' | 'F' | 'B' | 'N';
|
|
2
10
|
export declare class ParaconsistentBelnap implements LogicProfile {
|
|
3
11
|
name: string;
|
|
4
12
|
description: string;
|
|
5
13
|
checkWellFormed(formula: Formula): Diagnostic[];
|
|
14
|
+
/**
|
|
15
|
+
* En Belnap, una fórmula es válida si siempre evalúa a un valor "designado" (T o B).
|
|
16
|
+
*/
|
|
6
17
|
checkValid(formula: Formula): RunResult;
|
|
7
18
|
checkSatisfiable(formula: Formula): RunResult;
|
|
8
19
|
prove(goal: Formula, theory: Theory): RunResult;
|
|
9
20
|
derive(goal: Formula, premises: string[], theory: Theory): RunResult;
|
|
10
21
|
countermodel(formula: Formula): RunResult;
|
|
11
22
|
explain(formula: Formula): RunResult;
|
|
23
|
+
private conjoin;
|
|
24
|
+
private evaluateBelnap;
|
|
25
|
+
private generateBelnapTable;
|
|
26
|
+
private collectAtoms;
|
|
27
|
+
private generateBelnapValuations;
|
|
12
28
|
}
|
|
13
29
|
//# sourceMappingURL=belnap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"belnap.d.ts","sourceRoot":"","sources":["../../../src/profiles/paraconsistent/belnap.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,OAAO,
|
|
1
|
+
{"version":3,"file":"belnap.d.ts","sourceRoot":"","sources":["../../../src/profiles/paraconsistent/belnap.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,OAAO,EACP,SAAS,EACT,MAAM,EACN,YAAY,EACZ,UAAU,EAGX,MAAM,aAAa,CAAC;AAGrB;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAiChD,qBAAa,oBAAqB,YAAW,YAAY;IACvD,IAAI,SAA2B;IAC/B,WAAW,SAAmE;IAE9E,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,EAAE;IAe/C;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS;IA0BvC,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS;IAgB7C,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS;IAiB/C,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS;IAoBpE,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS;IAuBzC,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS;IASpC,OAAO,CAAC,OAAO;IAMf,OAAO,CAAC,cAAc;IAyBtB,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,wBAAwB;CAWjC"}
|
|
@@ -1,38 +1,222 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// ============================================================
|
|
3
|
-
// ST
|
|
3
|
+
// ST Belnap — Motor Paraconsistente de 4 Valores
|
|
4
4
|
// ============================================================
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ParaconsistentBelnap = void 0;
|
|
7
7
|
const propositional_1 = require("../classical/propositional");
|
|
8
|
+
const VALUES = ['T', 'F', 'B', 'N'];
|
|
9
|
+
/**
|
|
10
|
+
* Semántica de Belnap (Lattice-based):
|
|
11
|
+
* Negación: intercambia T/F, mantiene B/N.
|
|
12
|
+
* And: Mínimo en el retículo de información.
|
|
13
|
+
* Or: Máximo en el retículo de información.
|
|
14
|
+
*/
|
|
15
|
+
const BELNAP_NOT = {
|
|
16
|
+
T: 'F',
|
|
17
|
+
F: 'T',
|
|
18
|
+
B: 'B',
|
|
19
|
+
N: 'N',
|
|
20
|
+
};
|
|
21
|
+
// Orden de información (Truth lattice): F < B,N < T
|
|
22
|
+
// Para simplificar, usamos una matriz de resultados
|
|
23
|
+
const BELNAP_AND = {
|
|
24
|
+
T: { T: 'T', F: 'F', B: 'B', N: 'N' },
|
|
25
|
+
F: { T: 'F', F: 'F', B: 'F', N: 'F' },
|
|
26
|
+
B: { T: 'B', F: 'F', B: 'B', N: 'F' },
|
|
27
|
+
N: { T: 'N', F: 'F', B: 'F', N: 'N' },
|
|
28
|
+
};
|
|
29
|
+
const BELNAP_OR = {
|
|
30
|
+
T: { T: 'T', F: 'T', B: 'T', N: 'T' },
|
|
31
|
+
F: { T: 'T', F: 'F', B: 'B', N: 'N' },
|
|
32
|
+
B: { T: 'T', F: 'B', B: 'B', N: 'T' },
|
|
33
|
+
N: { T: 'T', F: 'N', B: 'T', N: 'N' },
|
|
34
|
+
};
|
|
8
35
|
class ParaconsistentBelnap {
|
|
9
36
|
name = 'paraconsistent.belnap';
|
|
10
|
-
description = 'Logica paraconsistente Belnap
|
|
37
|
+
description = 'Logica paraconsistente de Belnap (4-valued: T, F, Both, None)';
|
|
11
38
|
checkWellFormed(formula) {
|
|
12
|
-
|
|
39
|
+
// Reutilizamos la validación proposicional, ya que la sintaxis es idéntica
|
|
40
|
+
const diags = [];
|
|
41
|
+
const check = (f) => {
|
|
42
|
+
if (f.kind === 'atom' && !f.name) {
|
|
43
|
+
diags.push({ severity: 'error', message: 'Atomo sin nombre' });
|
|
44
|
+
}
|
|
45
|
+
if (f.args) {
|
|
46
|
+
for (const arg of f.args)
|
|
47
|
+
check(arg);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
check(formula);
|
|
51
|
+
return diags;
|
|
13
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* En Belnap, una fórmula es válida si siempre evalúa a un valor "designado" (T o B).
|
|
55
|
+
*/
|
|
14
56
|
checkValid(formula) {
|
|
57
|
+
const tt = this.generateBelnapTable(formula);
|
|
58
|
+
const designated = new Set(['T', 'B']);
|
|
59
|
+
const isTautology = tt.rows.every((r) => designated.has(String(r.result)));
|
|
60
|
+
if (isTautology) {
|
|
61
|
+
return {
|
|
62
|
+
status: 'valid',
|
|
63
|
+
output: `${(0, propositional_1.formulaToString)(formula)} es una tautologia en Belnap (siempre designada T/B)`,
|
|
64
|
+
truthTable: tt,
|
|
65
|
+
diagnostics: [],
|
|
66
|
+
formula,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const cm = tt.rows.find((r) => !designated.has(String(r.result)));
|
|
15
70
|
return {
|
|
16
|
-
status: '
|
|
17
|
-
output:
|
|
18
|
-
|
|
71
|
+
status: 'invalid',
|
|
72
|
+
output: `${(0, propositional_1.formulaToString)(formula)} no es valida en Belnap`,
|
|
73
|
+
truthTable: tt,
|
|
74
|
+
model: cm ? { type: 'propositional', valuation: cm.valuation } : undefined,
|
|
75
|
+
diagnostics: [],
|
|
19
76
|
formula,
|
|
20
77
|
};
|
|
21
78
|
}
|
|
22
79
|
checkSatisfiable(formula) {
|
|
23
|
-
|
|
80
|
+
const tt = this.generateBelnapTable(formula);
|
|
81
|
+
const designated = new Set(['T', 'B']);
|
|
82
|
+
const isSatisfiable = tt.rows.some((r) => designated.has(String(r.result)));
|
|
83
|
+
return {
|
|
84
|
+
status: isSatisfiable ? 'satisfiable' : 'unsatisfiable',
|
|
85
|
+
output: isSatisfiable
|
|
86
|
+
? `${(0, propositional_1.formulaToString)(formula)} es satisfacible en Belnap`
|
|
87
|
+
: `${(0, propositional_1.formulaToString)(formula)} es una contradiccion en Belnap (nunca designada)`,
|
|
88
|
+
truthTable: tt,
|
|
89
|
+
diagnostics: [],
|
|
90
|
+
formula,
|
|
91
|
+
};
|
|
24
92
|
}
|
|
25
93
|
prove(goal, theory) {
|
|
26
|
-
|
|
94
|
+
// Para prove en Belnap, verificamos si la inferencia es válida (preservación de valores designados)
|
|
95
|
+
const axioms = Array.from(theory.axioms.values());
|
|
96
|
+
const tt = this.generateBelnapTable({ kind: 'implies', args: [this.conjoin(axioms), goal] });
|
|
97
|
+
const designated = new Set(['T', 'B']);
|
|
98
|
+
const isProvable = tt.rows.every((r) => designated.has(String(r.result)));
|
|
99
|
+
return {
|
|
100
|
+
status: isProvable ? 'provable' : 'refutable',
|
|
101
|
+
output: isProvable
|
|
102
|
+
? `${(0, propositional_1.formulaToString)(goal)} se sigue de la teoria en Belnap`
|
|
103
|
+
: `${(0, propositional_1.formulaToString)(goal)} no es demostrable en Belnap`,
|
|
104
|
+
diagnostics: [],
|
|
105
|
+
formula: goal,
|
|
106
|
+
};
|
|
27
107
|
}
|
|
28
108
|
derive(goal, premises, theory) {
|
|
29
|
-
|
|
109
|
+
const premiseFormulas = premises
|
|
110
|
+
.map((p) => theory.axioms.get(p) || theory.theorems.get(p))
|
|
111
|
+
.filter((f) => f !== undefined);
|
|
112
|
+
const tt = this.generateBelnapTable({
|
|
113
|
+
kind: 'implies',
|
|
114
|
+
args: [this.conjoin(premiseFormulas), goal],
|
|
115
|
+
});
|
|
116
|
+
const designated = new Set(['T', 'B']);
|
|
117
|
+
const isProvable = tt.rows.every((r) => designated.has(String(r.result)));
|
|
118
|
+
return {
|
|
119
|
+
status: isProvable ? 'provable' : 'refutable',
|
|
120
|
+
output: isProvable ? `Derivacion exitosa en Belnap` : `No se puede derivar en Belnap`,
|
|
121
|
+
diagnostics: [],
|
|
122
|
+
formula: goal,
|
|
123
|
+
};
|
|
30
124
|
}
|
|
31
125
|
countermodel(formula) {
|
|
32
|
-
|
|
126
|
+
const tt = this.generateBelnapTable(formula);
|
|
127
|
+
const designated = new Set(['T', 'B']);
|
|
128
|
+
const cm = tt.rows.find((r) => !designated.has(String(r.result)));
|
|
129
|
+
if (cm) {
|
|
130
|
+
return {
|
|
131
|
+
status: 'invalid',
|
|
132
|
+
output: `Contramodelo encontrado en Belnap`,
|
|
133
|
+
model: { type: 'propositional', valuation: cm.valuation },
|
|
134
|
+
diagnostics: [],
|
|
135
|
+
formula,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
status: 'valid',
|
|
140
|
+
output: `No hay contramodelo en Belnap (tautologia)`,
|
|
141
|
+
diagnostics: [],
|
|
142
|
+
formula,
|
|
143
|
+
};
|
|
33
144
|
}
|
|
34
145
|
explain(formula) {
|
|
35
|
-
return {
|
|
146
|
+
return {
|
|
147
|
+
status: 'unknown',
|
|
148
|
+
output: `Logica de Belnap (4-valores): ${(0, propositional_1.formulaToString)(formula)}`,
|
|
149
|
+
diagnostics: [],
|
|
150
|
+
formula,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
conjoin(formulas) {
|
|
154
|
+
if (formulas.length === 0)
|
|
155
|
+
return { kind: 'atom', name: 'T' }; // Top
|
|
156
|
+
if (formulas.length === 1)
|
|
157
|
+
return formulas[0];
|
|
158
|
+
return { kind: 'and', args: [formulas[0], this.conjoin(formulas.slice(1))] };
|
|
159
|
+
}
|
|
160
|
+
evaluateBelnap(f, v) {
|
|
161
|
+
const args = f.args || [];
|
|
162
|
+
switch (f.kind) {
|
|
163
|
+
case 'atom':
|
|
164
|
+
return f.name ? (v[f.name] ?? 'N') : 'N';
|
|
165
|
+
case 'not':
|
|
166
|
+
return args[0] ? BELNAP_NOT[this.evaluateBelnap(args[0], v)] : 'N';
|
|
167
|
+
case 'and':
|
|
168
|
+
return args[0] && args[1]
|
|
169
|
+
? BELNAP_AND[this.evaluateBelnap(args[0], v)][this.evaluateBelnap(args[1], v)]
|
|
170
|
+
: 'N';
|
|
171
|
+
case 'or':
|
|
172
|
+
return args[0] && args[1]
|
|
173
|
+
? BELNAP_OR[this.evaluateBelnap(args[0], v)][this.evaluateBelnap(args[1], v)]
|
|
174
|
+
: 'N';
|
|
175
|
+
case 'implies':
|
|
176
|
+
// Implicación en Belnap (A -> B es !A | B)
|
|
177
|
+
return args[0] && args[1]
|
|
178
|
+
? BELNAP_OR[BELNAP_NOT[this.evaluateBelnap(args[0], v)]][this.evaluateBelnap(args[1], v)]
|
|
179
|
+
: 'N';
|
|
180
|
+
default:
|
|
181
|
+
return 'N';
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
generateBelnapTable(formula) {
|
|
185
|
+
const atoms = Array.from(this.collectAtoms(formula)).sort();
|
|
186
|
+
const rows = this.generateBelnapValuations(atoms).map((v) => ({
|
|
187
|
+
valuation: v,
|
|
188
|
+
result: this.evaluateBelnap(formula, v),
|
|
189
|
+
}));
|
|
190
|
+
return {
|
|
191
|
+
variables: atoms,
|
|
192
|
+
rows,
|
|
193
|
+
isTautology: rows.every((r) => new Set(['T', 'B']).has(String(r.result))),
|
|
194
|
+
isSatisfiable: rows.some((r) => new Set(['T', 'B']).has(String(r.result))),
|
|
195
|
+
isContradiction: rows.every((r) => !new Set(['T', 'B']).has(String(r.result))),
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
collectAtoms(f) {
|
|
199
|
+
const atoms = new Set();
|
|
200
|
+
const walk = (node) => {
|
|
201
|
+
if (node.kind === 'atom' && node.name)
|
|
202
|
+
atoms.add(node.name);
|
|
203
|
+
if (node.args)
|
|
204
|
+
node.args.forEach(walk);
|
|
205
|
+
};
|
|
206
|
+
walk(f);
|
|
207
|
+
return atoms;
|
|
208
|
+
}
|
|
209
|
+
generateBelnapValuations(atoms) {
|
|
210
|
+
if (atoms.length === 0)
|
|
211
|
+
return [{}];
|
|
212
|
+
const sub = this.generateBelnapValuations(atoms.slice(1));
|
|
213
|
+
const result = [];
|
|
214
|
+
for (const v of sub) {
|
|
215
|
+
for (const val of VALUES) {
|
|
216
|
+
result.push({ ...v, [atoms[0]]: val });
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return result;
|
|
36
220
|
}
|
|
37
221
|
}
|
|
38
222
|
exports.ParaconsistentBelnap = ParaconsistentBelnap;
|