@stevenvo780/autologic 1.0.0 → 2.0.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/atoms/coreference.d.ts +7 -2
- package/dist/atoms/coreference.d.ts.map +1 -1
- package/dist/atoms/coreference.js +93 -2
- package/dist/atoms/coreference.js.map +1 -1
- package/dist/discourse/markers-es.d.ts.map +1 -1
- package/dist/discourse/markers-es.js +3 -1
- package/dist/discourse/markers-es.js.map +1 -1
- package/dist/discourse/pattern-detector.d.ts.map +1 -1
- package/dist/discourse/pattern-detector.js +9 -3
- package/dist/discourse/pattern-detector.js.map +1 -1
- package/dist/discourse/role-classifier.d.ts.map +1 -1
- package/dist/discourse/role-classifier.js +44 -11
- package/dist/discourse/role-classifier.js.map +1 -1
- package/dist/formula/argument-builder.d.ts +18 -0
- package/dist/formula/argument-builder.d.ts.map +1 -0
- package/dist/formula/argument-builder.js +259 -0
- package/dist/formula/argument-builder.js.map +1 -0
- package/dist/formula/index.d.ts +7 -1
- package/dist/formula/index.d.ts.map +1 -1
- package/dist/formula/index.js +25 -7
- package/dist/formula/index.js.map +1 -1
- package/dist/formula/propositional.d.ts +2 -0
- package/dist/formula/propositional.d.ts.map +1 -1
- package/dist/formula/propositional.js +77 -53
- package/dist/formula/propositional.js.map +1 -1
- package/dist/generator/st-emitter.d.ts +1 -0
- package/dist/generator/st-emitter.d.ts.map +1 -1
- package/dist/generator/st-emitter.js +4 -12
- package/dist/generator/st-emitter.js.map +1 -1
- package/dist/segmenter/clause-splitter.d.ts.map +1 -1
- package/dist/segmenter/clause-splitter.js +56 -6
- package/dist/segmenter/clause-splitter.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildCrossSentenceDerivations = buildCrossSentenceDerivations;
|
|
4
|
+
const connectors_1 = require("./connectors");
|
|
5
|
+
const coreference_1 = require("../atoms/coreference");
|
|
6
|
+
const keyword_extractor_1 = require("../atoms/keyword-extractor");
|
|
7
|
+
/**
|
|
8
|
+
* Enriquece las fórmulas per-sentence con derivaciones cross-sentence.
|
|
9
|
+
*/
|
|
10
|
+
function buildCrossSentenceDerivations(perSentenceFormulas, sentences, atomEntries, detectedPatterns) {
|
|
11
|
+
const extra = [];
|
|
12
|
+
let labelCounter = perSentenceFormulas.length + 1;
|
|
13
|
+
// Clasificar fórmulas existentes
|
|
14
|
+
const conditionals = perSentenceFormulas.filter(f => f.stType === 'axiom' && f.formula.includes(connectors_1.ST_OPERATORS.implication));
|
|
15
|
+
const simpleAxioms = perSentenceFormulas.filter(f => f.stType === 'axiom' && !f.formula.includes(connectors_1.ST_OPERATORS.implication) &&
|
|
16
|
+
!f.formula.includes(connectors_1.ST_OPERATORS.biconditional));
|
|
17
|
+
const negationAxioms = simpleAxioms.filter(f => f.formula.startsWith('!') || f.formula.startsWith('!('));
|
|
18
|
+
const positiveAxioms = simpleAxioms.filter(f => !f.formula.startsWith('!') && !f.formula.startsWith('!('));
|
|
19
|
+
const disjunctions = perSentenceFormulas.filter(f => f.stType === 'axiom' && f.formula.includes(connectors_1.ST_OPERATORS.disjunction)
|
|
20
|
+
&& !f.formula.includes(connectors_1.ST_OPERATORS.implication));
|
|
21
|
+
const existingDerives = perSentenceFormulas.filter(f => f.stType === 'derive');
|
|
22
|
+
// Si ya hay derives, no duplicar
|
|
23
|
+
if (existingDerives.length > 0)
|
|
24
|
+
return extra;
|
|
25
|
+
// ── Modus Ponens: A→B, A ⊢ B ──────────────────
|
|
26
|
+
if (detectedPatterns.includes('modus_ponens') || conditionals.length > 0) {
|
|
27
|
+
for (const cond of conditionals) {
|
|
28
|
+
const parsed = parseImplication(cond.formula);
|
|
29
|
+
if (!parsed)
|
|
30
|
+
continue;
|
|
31
|
+
// Buscar un axioma que unifique con el antecedente
|
|
32
|
+
const matchingPremise = findMatchingAxiom(parsed.antecedent, positiveAxioms, atomEntries);
|
|
33
|
+
if (matchingPremise) {
|
|
34
|
+
// Buscar si ya hay conclusión explícita
|
|
35
|
+
const conclusionSentences = sentences.filter(s => s.clauses.some(c => c.role === 'conclusion'));
|
|
36
|
+
extra.push({
|
|
37
|
+
formula: parsed.consequent,
|
|
38
|
+
stType: 'derive',
|
|
39
|
+
label: `mp_${labelCounter++}`,
|
|
40
|
+
sourceText: `Modus Ponens: de ${cond.label} y ${matchingPremise.label}`,
|
|
41
|
+
sourceSentence: cond.sourceSentence,
|
|
42
|
+
comment: `Modus Ponens: ${parsed.antecedent} → ${parsed.consequent}, ${parsed.antecedent} ⊢ ${parsed.consequent}`,
|
|
43
|
+
});
|
|
44
|
+
// Solo una derivación MP por condicional
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// ── Modus Tollens: A→B, ¬B ⊢ ¬A ──────────────
|
|
50
|
+
if (detectedPatterns.includes('modus_tollens') ||
|
|
51
|
+
(conditionals.length > 0 && negationAxioms.length > 0)) {
|
|
52
|
+
for (const cond of conditionals) {
|
|
53
|
+
const parsed = parseImplication(cond.formula);
|
|
54
|
+
if (!parsed)
|
|
55
|
+
continue;
|
|
56
|
+
// Buscar ¬B entre los axiomas de negación
|
|
57
|
+
const negConsequent = stripNegation(parsed.consequent);
|
|
58
|
+
if (!negConsequent)
|
|
59
|
+
continue;
|
|
60
|
+
const matchingNeg = negationAxioms.find(a => {
|
|
61
|
+
const stripped = stripNegation(a.formula);
|
|
62
|
+
return stripped !== null && atomsUnify(stripped, parsed.consequent, atomEntries);
|
|
63
|
+
});
|
|
64
|
+
// También buscar si el axioma negado es directamente ¬(consequent)
|
|
65
|
+
const matchingNeg2 = negationAxioms.find(a => {
|
|
66
|
+
const innerAtom = extractNegatedAtom(a.formula);
|
|
67
|
+
return innerAtom !== null && atomsUnify(innerAtom, parsed.consequent, atomEntries);
|
|
68
|
+
});
|
|
69
|
+
const foundNeg = matchingNeg || matchingNeg2;
|
|
70
|
+
if (foundNeg) {
|
|
71
|
+
extra.push({
|
|
72
|
+
formula: `${connectors_1.ST_OPERATORS.negation}(${parsed.antecedent})`,
|
|
73
|
+
stType: 'derive',
|
|
74
|
+
label: `mt_${labelCounter++}`,
|
|
75
|
+
sourceText: `Modus Tollens: de ${cond.label} y ${foundNeg.label}`,
|
|
76
|
+
sourceSentence: cond.sourceSentence,
|
|
77
|
+
comment: `Modus Tollens: ${parsed.antecedent}→${parsed.consequent}, ¬${parsed.consequent} ⊢ ¬${parsed.antecedent}`,
|
|
78
|
+
});
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// ── Silogismo Hipotético: A→B, B→C ⊢ A→C ─────
|
|
84
|
+
if (detectedPatterns.includes('hypothetical_syllogism') || conditionals.length >= 2) {
|
|
85
|
+
const chains = findConditionalChains(conditionals, atomEntries);
|
|
86
|
+
for (const chain of chains) {
|
|
87
|
+
extra.push({
|
|
88
|
+
formula: `${chain.start} ${connectors_1.ST_OPERATORS.implication} ${chain.end}`,
|
|
89
|
+
stType: 'derive',
|
|
90
|
+
label: `hs_${labelCounter++}`,
|
|
91
|
+
sourceText: `Silogismo Hipotético: cadena de ${chain.labels.join(', ')}`,
|
|
92
|
+
sourceSentence: conditionals[0].sourceSentence,
|
|
93
|
+
comment: `Silogismo Hipotético: ${chain.start} → ... → ${chain.end}`,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// ── Silogismo Disyuntivo: A∨B, ¬A ⊢ B ────────
|
|
98
|
+
if (detectedPatterns.includes('disjunctive_syllogism') ||
|
|
99
|
+
(disjunctions.length > 0 && negationAxioms.length > 0)) {
|
|
100
|
+
for (const disj of disjunctions) {
|
|
101
|
+
const parts = disj.formula.split(` ${connectors_1.ST_OPERATORS.disjunction} `).map(s => s.trim());
|
|
102
|
+
if (parts.length < 2)
|
|
103
|
+
continue;
|
|
104
|
+
for (const negAxiom of negationAxioms) {
|
|
105
|
+
const negated = extractNegatedAtom(negAxiom.formula);
|
|
106
|
+
if (!negated)
|
|
107
|
+
continue;
|
|
108
|
+
const negIdx = parts.findIndex(p => atomsUnify(p, negated, atomEntries));
|
|
109
|
+
if (negIdx >= 0) {
|
|
110
|
+
const remaining = parts.filter((_, i) => i !== negIdx).join(` ${connectors_1.ST_OPERATORS.disjunction} `);
|
|
111
|
+
extra.push({
|
|
112
|
+
formula: remaining,
|
|
113
|
+
stType: 'derive',
|
|
114
|
+
label: `ds_${labelCounter++}`,
|
|
115
|
+
sourceText: `Silogismo Disyuntivo: de ${disj.label} y ${negAxiom.label}`,
|
|
116
|
+
sourceSentence: disj.sourceSentence,
|
|
117
|
+
comment: `Silogismo Disyuntivo: ${disj.formula}, ${negAxiom.formula} ⊢ ${remaining}`,
|
|
118
|
+
});
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// ── Cadena condicional con MP final ────────────
|
|
125
|
+
// Si tenemos A→B, B→C, C→D y además A, derivar D
|
|
126
|
+
if (conditionals.length >= 2 && positiveAxioms.length > 0) {
|
|
127
|
+
const chains = findConditionalChains(conditionals, atomEntries);
|
|
128
|
+
for (const chain of chains) {
|
|
129
|
+
const matchingStart = findMatchingAxiom(chain.start, positiveAxioms, atomEntries);
|
|
130
|
+
if (matchingStart && extra.every(e => e.formula !== chain.end)) {
|
|
131
|
+
extra.push({
|
|
132
|
+
formula: chain.end,
|
|
133
|
+
stType: 'derive',
|
|
134
|
+
label: `chain_${labelCounter++}`,
|
|
135
|
+
sourceText: `Cadena + MP: de ${chain.labels.join(', ')} y ${matchingStart.label}`,
|
|
136
|
+
sourceSentence: conditionals[conditionals.length - 1].sourceSentence,
|
|
137
|
+
comment: `Cadena condicional + Modus Ponens: ${chain.start} → ... → ${chain.end}, ${chain.start} ⊢ ${chain.end}`,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return extra;
|
|
143
|
+
}
|
|
144
|
+
// ══════════════════════════════════════════════════════════════
|
|
145
|
+
// Utilidades internas
|
|
146
|
+
// ══════════════════════════════════════════════════════════════
|
|
147
|
+
/** Parsea "A -> B" en { antecedent, consequent } */
|
|
148
|
+
function parseImplication(formula) {
|
|
149
|
+
const idx = formula.indexOf(` ${connectors_1.ST_OPERATORS.implication} `);
|
|
150
|
+
if (idx < 0)
|
|
151
|
+
return null;
|
|
152
|
+
const antecedent = formula.slice(0, idx).trim();
|
|
153
|
+
const consequent = formula.slice(idx + ` ${connectors_1.ST_OPERATORS.implication} `.length).trim();
|
|
154
|
+
if (!antecedent || !consequent)
|
|
155
|
+
return null;
|
|
156
|
+
return { antecedent, consequent };
|
|
157
|
+
}
|
|
158
|
+
/** Extrae el átomo dentro de una negación: "!(X)" → "X", "!X" → "X" */
|
|
159
|
+
function extractNegatedAtom(formula) {
|
|
160
|
+
const trimmed = formula.trim();
|
|
161
|
+
// "!(ATOM)" pattern
|
|
162
|
+
const match1 = trimmed.match(/^!\((.+)\)$/);
|
|
163
|
+
if (match1)
|
|
164
|
+
return match1[1].trim();
|
|
165
|
+
// "!ATOM" pattern
|
|
166
|
+
const match2 = trimmed.match(/^!(\w+)$/);
|
|
167
|
+
if (match2)
|
|
168
|
+
return match2[1].trim();
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
/** Remueve negación si existe, retorna null si no es negación */
|
|
172
|
+
function stripNegation(formula) {
|
|
173
|
+
const inner = extractNegatedAtom(formula);
|
|
174
|
+
return inner;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Verifica si dos expresiones atómicas se "unifican" (son el mismo concepto).
|
|
178
|
+
* Usa similitud de stems para manejar variaciones morfológicas.
|
|
179
|
+
*/
|
|
180
|
+
function atomsUnify(a, b, atomEntries) {
|
|
181
|
+
// Igualdad directa
|
|
182
|
+
if (a === b)
|
|
183
|
+
return true;
|
|
184
|
+
// Normalizar quitando paréntesis externos
|
|
185
|
+
const na = a.replace(/^\(|\)$/g, '').trim();
|
|
186
|
+
const nb = b.replace(/^\(|\)$/g, '').trim();
|
|
187
|
+
if (na === nb)
|
|
188
|
+
return true;
|
|
189
|
+
// Buscar los textos originales de los átomos
|
|
190
|
+
const textA = atomEntries.find(e => e.id === na)?.text;
|
|
191
|
+
const textB = atomEntries.find(e => e.id === nb)?.text;
|
|
192
|
+
if (textA && textB) {
|
|
193
|
+
const stemsA = (0, keyword_extractor_1.bagOfStems)(textA, 'es');
|
|
194
|
+
const stemsB = (0, keyword_extractor_1.bagOfStems)(textB, 'es');
|
|
195
|
+
return (0, coreference_1.diceSimilarity)(stemsA, stemsB) >= 0.5;
|
|
196
|
+
}
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Busca un axioma simple que unifique con un átomo/fórmula dado.
|
|
201
|
+
*/
|
|
202
|
+
function findMatchingAxiom(target, axioms, atomEntries) {
|
|
203
|
+
// Match exacto primero
|
|
204
|
+
const exact = axioms.find(a => a.formula === target);
|
|
205
|
+
if (exact)
|
|
206
|
+
return exact;
|
|
207
|
+
// Match por unificación
|
|
208
|
+
for (const axiom of axioms) {
|
|
209
|
+
if (atomsUnify(axiom.formula, target, atomEntries)) {
|
|
210
|
+
return axiom;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Encuentra cadenas de condicionales: A→B, B→C → chain(A, C)
|
|
217
|
+
*/
|
|
218
|
+
function findConditionalChains(conditionals, atomEntries) {
|
|
219
|
+
const parsed = conditionals
|
|
220
|
+
.map(c => ({ ...parseImplication(c.formula), label: c.label }))
|
|
221
|
+
.filter(p => p.antecedent && p.consequent);
|
|
222
|
+
if (parsed.length < 2)
|
|
223
|
+
return [];
|
|
224
|
+
const chains = [];
|
|
225
|
+
// Buscar cadenas empezando por cada condicional
|
|
226
|
+
for (let i = 0; i < parsed.length; i++) {
|
|
227
|
+
let current = parsed[i];
|
|
228
|
+
const chain = [current.label];
|
|
229
|
+
let end = current.consequent;
|
|
230
|
+
for (let j = 0; j < parsed.length; j++) {
|
|
231
|
+
if (j === i || chain.includes(parsed[j].label))
|
|
232
|
+
continue;
|
|
233
|
+
if (atomsUnify(end, parsed[j].antecedent, atomEntries)) {
|
|
234
|
+
chain.push(parsed[j].label);
|
|
235
|
+
end = parsed[j].consequent;
|
|
236
|
+
j = -1; // restart search for next link
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (chain.length >= 2) {
|
|
240
|
+
chains.push({
|
|
241
|
+
start: parsed[i].antecedent,
|
|
242
|
+
end,
|
|
243
|
+
labels: chain,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
// Deduplicar: quedarse con la cadena más larga para cada par start→end
|
|
248
|
+
const seen = new Set();
|
|
249
|
+
return chains
|
|
250
|
+
.sort((a, b) => b.labels.length - a.labels.length)
|
|
251
|
+
.filter(c => {
|
|
252
|
+
const key = `${c.start}->${c.end}`;
|
|
253
|
+
if (seen.has(key))
|
|
254
|
+
return false;
|
|
255
|
+
seen.add(key);
|
|
256
|
+
return true;
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=argument-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"argument-builder.js","sourceRoot":"","sources":["../../src/formula/argument-builder.ts"],"names":[],"mappings":";;AAoBA,sEAmKC;AA1KD,6CAA4C;AAC5C,sDAAsD;AACtD,kEAAwD;AAExD;;GAEG;AACH,SAAgB,6BAA6B,CAC3C,mBAAmC,EACnC,SAA6B,EAC7B,WAAwB,EACxB,gBAA0B;IAE1B,MAAM,KAAK,GAAmB,EAAE,CAAC;IACjC,IAAI,YAAY,GAAG,mBAAmB,CAAC,MAAM,GAAG,CAAC,CAAC;IAElD,iCAAiC;IACjC,MAAM,YAAY,GAAG,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,GAAG,EAAU,CAAC;IAC/B,OAAO,MAAM;SACV,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;SACjD,MAAM,CAAC,CAAC,CAAC,EAAE;QACV,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC;QACnC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;QAChC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/formula/index.d.ts
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Formula — Orquestador de construcción de fórmulas
|
|
3
|
+
*
|
|
4
|
+
* Pipeline:
|
|
5
|
+
* 1. Construir fórmulas per-sentence (según perfil lógico)
|
|
6
|
+
* 2. Enriquecer con derivaciones cross-sentence (argument-builder)
|
|
3
7
|
*/
|
|
4
8
|
export { buildPropositional } from './propositional';
|
|
5
9
|
export { buildFirstOrder } from './first-order';
|
|
6
10
|
export { buildModal } from './modal';
|
|
7
11
|
export { buildTemporal } from './temporal';
|
|
12
|
+
export { buildCrossSentenceDerivations } from './argument-builder';
|
|
8
13
|
export { roleToOperator, profileSupportsOperator, ST_OPERATORS } from './connectors';
|
|
9
14
|
import type { AnalyzedSentence, AtomEntry, FormulaEntry, LogicProfile } from '../types';
|
|
10
15
|
/**
|
|
11
16
|
* Construye fórmulas ST según el perfil lógico seleccionado.
|
|
12
|
-
* Delega al builder específico del perfil
|
|
17
|
+
* Delega al builder específico del perfil, luego enriquece
|
|
18
|
+
* con derivaciones cross-sentence.
|
|
13
19
|
*/
|
|
14
20
|
export declare function buildFormulas(sentences: AnalyzedSentence[], atomEntries: AtomEntry[], profile: LogicProfile, detectedPatterns: string[]): FormulaEntry[];
|
|
15
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/formula/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/formula/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAErF,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAOxF;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,gBAAgB,EAAE,EAC7B,WAAW,EAAE,SAAS,EAAE,EACxB,OAAO,EAAE,YAAY,EACrB,gBAAgB,EAAE,MAAM,EAAE,GACzB,YAAY,EAAE,CA0ChB"}
|
package/dist/formula/index.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ST_OPERATORS = exports.profileSupportsOperator = exports.roleToOperator = exports.buildTemporal = exports.buildModal = exports.buildFirstOrder = exports.buildPropositional = void 0;
|
|
3
|
+
exports.ST_OPERATORS = exports.profileSupportsOperator = exports.roleToOperator = exports.buildCrossSentenceDerivations = exports.buildTemporal = exports.buildModal = exports.buildFirstOrder = exports.buildPropositional = void 0;
|
|
4
4
|
exports.buildFormulas = buildFormulas;
|
|
5
5
|
/**
|
|
6
6
|
* Formula — Orquestador de construcción de fórmulas
|
|
7
|
+
*
|
|
8
|
+
* Pipeline:
|
|
9
|
+
* 1. Construir fórmulas per-sentence (según perfil lógico)
|
|
10
|
+
* 2. Enriquecer con derivaciones cross-sentence (argument-builder)
|
|
7
11
|
*/
|
|
8
12
|
var propositional_1 = require("./propositional");
|
|
9
13
|
Object.defineProperty(exports, "buildPropositional", { enumerable: true, get: function () { return propositional_1.buildPropositional; } });
|
|
@@ -13,6 +17,8 @@ var modal_1 = require("./modal");
|
|
|
13
17
|
Object.defineProperty(exports, "buildModal", { enumerable: true, get: function () { return modal_1.buildModal; } });
|
|
14
18
|
var temporal_1 = require("./temporal");
|
|
15
19
|
Object.defineProperty(exports, "buildTemporal", { enumerable: true, get: function () { return temporal_1.buildTemporal; } });
|
|
20
|
+
var argument_builder_1 = require("./argument-builder");
|
|
21
|
+
Object.defineProperty(exports, "buildCrossSentenceDerivations", { enumerable: true, get: function () { return argument_builder_1.buildCrossSentenceDerivations; } });
|
|
16
22
|
var connectors_1 = require("./connectors");
|
|
17
23
|
Object.defineProperty(exports, "roleToOperator", { enumerable: true, get: function () { return connectors_1.roleToOperator; } });
|
|
18
24
|
Object.defineProperty(exports, "profileSupportsOperator", { enumerable: true, get: function () { return connectors_1.profileSupportsOperator; } });
|
|
@@ -21,29 +27,41 @@ const propositional_2 = require("./propositional");
|
|
|
21
27
|
const first_order_2 = require("./first-order");
|
|
22
28
|
const modal_2 = require("./modal");
|
|
23
29
|
const temporal_2 = require("./temporal");
|
|
30
|
+
const argument_builder_2 = require("./argument-builder");
|
|
24
31
|
/**
|
|
25
32
|
* Construye fórmulas ST según el perfil lógico seleccionado.
|
|
26
|
-
* Delega al builder específico del perfil
|
|
33
|
+
* Delega al builder específico del perfil, luego enriquece
|
|
34
|
+
* con derivaciones cross-sentence.
|
|
27
35
|
*/
|
|
28
36
|
function buildFormulas(sentences, atomEntries, profile, detectedPatterns) {
|
|
37
|
+
// ── Paso 1: fórmulas per-sentence ─────────────
|
|
38
|
+
let perSentence;
|
|
29
39
|
switch (profile) {
|
|
30
40
|
case 'classical.propositional':
|
|
31
41
|
case 'intuitionistic.propositional':
|
|
32
42
|
case 'paraconsistent.belnap':
|
|
33
43
|
case 'arithmetic':
|
|
34
44
|
case 'probabilistic.basic':
|
|
35
|
-
|
|
45
|
+
perSentence = (0, propositional_2.buildPropositional)(sentences, atomEntries, detectedPatterns);
|
|
46
|
+
break;
|
|
36
47
|
case 'classical.first_order':
|
|
37
48
|
case 'aristotelian.syllogistic':
|
|
38
|
-
|
|
49
|
+
perSentence = (0, first_order_2.buildFirstOrder)(sentences, atomEntries, detectedPatterns);
|
|
50
|
+
break;
|
|
39
51
|
case 'modal.k':
|
|
40
52
|
case 'epistemic.s5':
|
|
41
53
|
case 'deontic.standard':
|
|
42
|
-
|
|
54
|
+
perSentence = (0, modal_2.buildModal)(sentences, atomEntries, profile);
|
|
55
|
+
break;
|
|
43
56
|
case 'temporal.ltl':
|
|
44
|
-
|
|
57
|
+
perSentence = (0, temporal_2.buildTemporal)(sentences, atomEntries);
|
|
58
|
+
break;
|
|
45
59
|
default:
|
|
46
|
-
|
|
60
|
+
perSentence = (0, propositional_2.buildPropositional)(sentences, atomEntries, detectedPatterns);
|
|
61
|
+
break;
|
|
47
62
|
}
|
|
63
|
+
// ── Paso 2: derivaciones cross-sentence ───────
|
|
64
|
+
const crossDerives = (0, argument_builder_2.buildCrossSentenceDerivations)(perSentence, sentences, atomEntries, detectedPatterns);
|
|
65
|
+
return [...perSentence, ...crossDerives];
|
|
48
66
|
}
|
|
49
67
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formula/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formula/index.ts"],"names":[],"mappings":";;;AA0BA,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AAS,EAAE,WAAW,EAAE,gBAAgB,CAAC,CAAC;YAC3E,MAAM;IACV,CAAC;IAED,iDAAiD;IACjD,MAAM,YAAY,GAAG,IAAA,gDAA6B,EAChD,WAAW,EACX,SAAS,EACT,WAAW,EACX,gBAAgB,CACjB,CAAC;IAEF,OAAO,CAAC,GAAG,WAAW,EAAE,GAAG,YAAY,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
* Propositional Formula Builder
|
|
3
3
|
*
|
|
4
4
|
* Construye fórmulas de lógica proposicional a partir de átomos con roles.
|
|
5
|
+
* Genera fórmulas reales con conectivos: →, ∧, ∨, ¬, ↔
|
|
5
6
|
*/
|
|
6
7
|
import type { AnalyzedSentence, AtomEntry, FormulaEntry } from '../types';
|
|
7
8
|
/**
|
|
8
9
|
* Construye fórmulas proposicionales para un conjunto de oraciones.
|
|
10
|
+
* Cada oración se procesa según su tipo detectado.
|
|
9
11
|
*/
|
|
10
12
|
export declare function buildPropositional(sentences: AnalyzedSentence[], atomEntries: AtomEntry[], detectedPatterns: string[]): FormulaEntry[];
|
|
11
13
|
//# sourceMappingURL=propositional.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"propositional.d.ts","sourceRoot":"","sources":["../../src/formula/propositional.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"propositional.d.ts","sourceRoot":"","sources":["../../src/formula/propositional.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,YAAY,EAAmB,MAAM,UAAU,CAAC;AAG3F;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,gBAAgB,EAAE,EAC7B,WAAW,EAAE,SAAS,EAAE,EACxB,gBAAgB,EAAE,MAAM,EAAE,GACzB,YAAY,EAAE,CAiBhB"}
|
|
@@ -4,56 +4,68 @@ exports.buildPropositional = buildPropositional;
|
|
|
4
4
|
const connectors_1 = require("./connectors");
|
|
5
5
|
/**
|
|
6
6
|
* Construye fórmulas proposicionales para un conjunto de oraciones.
|
|
7
|
+
* Cada oración se procesa según su tipo detectado.
|
|
7
8
|
*/
|
|
8
9
|
function buildPropositional(sentences, atomEntries, detectedPatterns) {
|
|
9
10
|
const formulas = [];
|
|
10
11
|
let labelCounter = 1;
|
|
12
|
+
// Construir mapa global de cláusula-texto → atomId
|
|
13
|
+
const globalClauseAtomMap = buildGlobalAtomMap(sentences, atomEntries);
|
|
11
14
|
for (let sIdx = 0; sIdx < sentences.length; sIdx++) {
|
|
12
15
|
const sentence = sentences[sIdx];
|
|
13
|
-
const
|
|
14
|
-
// Buscar átomos que pertenecen a cláusulas de esta oración
|
|
15
|
-
const clauseIdxs = sentence.clauses.map((_, i) => i);
|
|
16
|
-
// Heurística: mapear por índice global de cláusula
|
|
17
|
-
return true; // procesamos todos y filtramos por contexto
|
|
18
|
-
});
|
|
19
|
-
const builtFormulas = buildSentenceFormulas(sentence, atomEntries, sIdx, labelCounter, detectedPatterns);
|
|
16
|
+
const builtFormulas = buildSentenceFormulas(sentence, atomEntries, globalClauseAtomMap, sIdx, labelCounter, detectedPatterns);
|
|
20
17
|
formulas.push(...builtFormulas);
|
|
21
18
|
labelCounter += builtFormulas.length;
|
|
22
19
|
}
|
|
23
20
|
return formulas;
|
|
24
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Construye un mapa global de texto-cláusula → atomId.
|
|
24
|
+
*/
|
|
25
|
+
function buildGlobalAtomMap(sentences, atomEntries) {
|
|
26
|
+
const map = new Map();
|
|
27
|
+
// Recopilar todas las cláusulas con su índice global
|
|
28
|
+
let globalIdx = 0;
|
|
29
|
+
for (const sentence of sentences) {
|
|
30
|
+
for (const clause of sentence.clauses) {
|
|
31
|
+
// Buscar átomo por texto exacto
|
|
32
|
+
const exactMatch = atomEntries.find(a => a.text === clause.text);
|
|
33
|
+
if (exactMatch) {
|
|
34
|
+
map.set(clause.text, exactMatch.id);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
// Buscar por inclusión
|
|
38
|
+
const partialMatch = atomEntries.find(a => a.text.includes(clause.text) || clause.text.includes(a.text));
|
|
39
|
+
if (partialMatch) {
|
|
40
|
+
map.set(clause.text, partialMatch.id);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// Buscar por índice de cláusula fuente
|
|
44
|
+
const bySource = atomEntries.find(a => a.sourceClause === globalIdx);
|
|
45
|
+
if (bySource) {
|
|
46
|
+
map.set(clause.text, bySource.id);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
globalIdx++;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return map;
|
|
54
|
+
}
|
|
25
55
|
/**
|
|
26
56
|
* Construye fórmulas para una oración individual.
|
|
27
57
|
*/
|
|
28
|
-
function buildSentenceFormulas(sentence, allAtoms, sentenceIdx, labelStart, patterns) {
|
|
58
|
+
function buildSentenceFormulas(sentence, allAtoms, globalMap, sentenceIdx, labelStart, patterns) {
|
|
29
59
|
const clauses = sentence.clauses;
|
|
30
60
|
if (clauses.length === 0)
|
|
31
61
|
return [];
|
|
32
|
-
// Obtener átomos para esta oración (por texto de cláusula)
|
|
33
|
-
const clauseAtomMap = new Map();
|
|
34
|
-
for (const atom of allAtoms) {
|
|
35
|
-
// Mapear texto de cláusula → atom ID
|
|
36
|
-
const matchClause = clauses.find(c => c.text === atom.text || c.text.includes(atom.text) || atom.text.includes(c.text));
|
|
37
|
-
if (matchClause) {
|
|
38
|
-
clauseAtomMap.set(matchClause.text, atom.id);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
// Fallback: asignar átomos por orden si no hay match textual
|
|
42
|
-
if (clauseAtomMap.size === 0) {
|
|
43
|
-
clauses.forEach((c, i) => {
|
|
44
|
-
const atom = allAtoms[i];
|
|
45
|
-
if (atom)
|
|
46
|
-
clauseAtomMap.set(c.text, atom.id);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
62
|
const formulas = [];
|
|
50
63
|
let label = labelStart;
|
|
51
64
|
switch (sentence.type) {
|
|
52
65
|
case 'conditional': {
|
|
53
66
|
let conditionClauses = clauses.filter(c => c.role === 'condition');
|
|
54
67
|
let consequentClauses = clauses.filter(c => c.role === 'consequent' || c.role === 'conclusion' || c.role === 'assertion');
|
|
55
|
-
// Fallback: si no hay cláusula explícita de condición
|
|
56
|
-
// usar la primera cláusula que no sea consequent como condición
|
|
68
|
+
// Fallback: si no hay cláusula explícita de condición, inferir por posición
|
|
57
69
|
if (conditionClauses.length === 0 && clauses.length >= 2) {
|
|
58
70
|
const nonConsequent = clauses.filter(c => c.role !== 'consequent' && c.role !== 'conclusion');
|
|
59
71
|
if (nonConsequent.length > 0) {
|
|
@@ -62,8 +74,8 @@ function buildSentenceFormulas(sentence, allAtoms, sentenceIdx, labelStart, patt
|
|
|
62
74
|
}
|
|
63
75
|
}
|
|
64
76
|
if (conditionClauses.length > 0 && consequentClauses.length > 0) {
|
|
65
|
-
const antecedent =
|
|
66
|
-
const consequent =
|
|
77
|
+
const antecedent = resolveAtom(conditionClauses[0].text, globalMap, allAtoms);
|
|
78
|
+
const consequent = resolveAtom(consequentClauses[0].text, globalMap, allAtoms);
|
|
67
79
|
// Aplicar negación si hay modificadores
|
|
68
80
|
const antStr = applyModifiers(antecedent, conditionClauses[0].modifiers.map(m => m.type));
|
|
69
81
|
const consStr = applyModifiers(consequent, consequentClauses[0].modifiers.map(m => m.type));
|
|
@@ -80,8 +92,8 @@ function buildSentenceFormulas(sentence, allAtoms, sentenceIdx, labelStart, patt
|
|
|
80
92
|
}
|
|
81
93
|
case 'biconditional': {
|
|
82
94
|
if (clauses.length >= 2) {
|
|
83
|
-
const left =
|
|
84
|
-
const right =
|
|
95
|
+
const left = resolveAtom(clauses[0].text, globalMap, allAtoms);
|
|
96
|
+
const right = resolveAtom(clauses[1].text, globalMap, allAtoms);
|
|
85
97
|
formulas.push({
|
|
86
98
|
formula: `${left} ${connectors_1.ST_OPERATORS.biconditional} ${right}`,
|
|
87
99
|
stType: 'axiom',
|
|
@@ -94,7 +106,7 @@ function buildSentenceFormulas(sentence, allAtoms, sentenceIdx, labelStart, patt
|
|
|
94
106
|
break;
|
|
95
107
|
}
|
|
96
108
|
case 'conjunction': {
|
|
97
|
-
const atoms = clauses.map(c =>
|
|
109
|
+
const atoms = clauses.map(c => resolveAtom(c.text, globalMap, allAtoms));
|
|
98
110
|
if (atoms.length >= 2) {
|
|
99
111
|
const formula = atoms.join(` ${connectors_1.ST_OPERATORS.conjunction} `);
|
|
100
112
|
formulas.push({
|
|
@@ -106,10 +118,20 @@ function buildSentenceFormulas(sentence, allAtoms, sentenceIdx, labelStart, patt
|
|
|
106
118
|
comment: `Conjunción: "${sentence.original}"`,
|
|
107
119
|
});
|
|
108
120
|
}
|
|
121
|
+
else if (atoms.length === 1) {
|
|
122
|
+
formulas.push({
|
|
123
|
+
formula: atoms[0],
|
|
124
|
+
stType: 'axiom',
|
|
125
|
+
label: `hecho_${label}`,
|
|
126
|
+
sourceText: sentence.original,
|
|
127
|
+
sourceSentence: sentenceIdx,
|
|
128
|
+
comment: `Hecho: "${sentence.original}"`,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
109
131
|
break;
|
|
110
132
|
}
|
|
111
133
|
case 'disjunction': {
|
|
112
|
-
const atoms = clauses.map(c =>
|
|
134
|
+
const atoms = clauses.map(c => resolveAtom(c.text, globalMap, allAtoms));
|
|
113
135
|
if (atoms.length >= 2) {
|
|
114
136
|
const formula = atoms.join(` ${connectors_1.ST_OPERATORS.disjunction} `);
|
|
115
137
|
formulas.push({
|
|
@@ -125,7 +147,7 @@ function buildSentenceFormulas(sentence, allAtoms, sentenceIdx, labelStart, patt
|
|
|
125
147
|
}
|
|
126
148
|
case 'negation': {
|
|
127
149
|
if (clauses.length > 0) {
|
|
128
|
-
const atom =
|
|
150
|
+
const atom = resolveAtom(clauses[0].text, globalMap, allAtoms);
|
|
129
151
|
formulas.push({
|
|
130
152
|
formula: `${connectors_1.ST_OPERATORS.negation}(${atom})`,
|
|
131
153
|
stType: 'axiom',
|
|
@@ -138,12 +160,12 @@ function buildSentenceFormulas(sentence, allAtoms, sentenceIdx, labelStart, patt
|
|
|
138
160
|
break;
|
|
139
161
|
}
|
|
140
162
|
case 'complex': {
|
|
141
|
-
// Oraciones complejas con premisas y conclusiones
|
|
163
|
+
// Oraciones complejas con premisas y conclusiones explícitas
|
|
142
164
|
const premiseClauses = clauses.filter(c => c.role === 'premise');
|
|
143
165
|
const conclusionClauses = clauses.filter(c => c.role === 'conclusion');
|
|
144
166
|
// Generar axiomas para premisas
|
|
145
167
|
for (const pClause of premiseClauses) {
|
|
146
|
-
const atom =
|
|
168
|
+
const atom = resolveAtom(pClause.text, globalMap, allAtoms);
|
|
147
169
|
const atomStr = applyModifiers(atom, pClause.modifiers.map(m => m.type));
|
|
148
170
|
formulas.push({
|
|
149
171
|
formula: atomStr,
|
|
@@ -157,10 +179,7 @@ function buildSentenceFormulas(sentence, allAtoms, sentenceIdx, labelStart, patt
|
|
|
157
179
|
// Generar derivaciones para conclusiones
|
|
158
180
|
if (conclusionClauses.length > 0 && premiseClauses.length > 0) {
|
|
159
181
|
for (const cClause of conclusionClauses) {
|
|
160
|
-
const atom =
|
|
161
|
-
const premiseLabels = formulas
|
|
162
|
-
.filter(f => f.stType === 'axiom')
|
|
163
|
-
.map(f => f.label);
|
|
182
|
+
const atom = resolveAtom(cClause.text, globalMap, allAtoms);
|
|
164
183
|
formulas.push({
|
|
165
184
|
formula: atom,
|
|
166
185
|
stType: 'derive',
|
|
@@ -176,10 +195,9 @@ function buildSentenceFormulas(sentence, allAtoms, sentenceIdx, labelStart, patt
|
|
|
176
195
|
default: {
|
|
177
196
|
// Aserción simple o tipo no manejado arriba
|
|
178
197
|
for (const clause of clauses) {
|
|
179
|
-
const atom =
|
|
198
|
+
const atom = resolveAtom(clause.text, globalMap, allAtoms);
|
|
180
199
|
const atomStr = applyModifiers(atom, clause.modifiers.map(m => m.type));
|
|
181
200
|
const isConclusion = clause.role === 'conclusion';
|
|
182
|
-
const isPremise = clause.role === 'premise' || clause.role === 'assertion';
|
|
183
201
|
formulas.push({
|
|
184
202
|
formula: atomStr,
|
|
185
203
|
stType: isConclusion ? 'derive' : 'axiom',
|
|
@@ -198,25 +216,31 @@ function buildSentenceFormulas(sentence, allAtoms, sentenceIdx, labelStart, patt
|
|
|
198
216
|
return formulas;
|
|
199
217
|
}
|
|
200
218
|
/**
|
|
201
|
-
*
|
|
219
|
+
* Resuelve el ID de átomo para un texto de cláusula.
|
|
220
|
+
* Usa el mapa global, luego busca en todos los átomos.
|
|
202
221
|
*/
|
|
203
|
-
function
|
|
204
|
-
// Buscar en el mapa
|
|
205
|
-
const
|
|
206
|
-
if (
|
|
207
|
-
return
|
|
208
|
-
//
|
|
209
|
-
for (const [text, id] of
|
|
222
|
+
function resolveAtom(clauseText, globalMap, allAtoms) {
|
|
223
|
+
// 1. Buscar en el mapa global (ya resuelto)
|
|
224
|
+
const fromMap = globalMap.get(clauseText);
|
|
225
|
+
if (fromMap)
|
|
226
|
+
return fromMap;
|
|
227
|
+
// 2. Match parcial en mapa global
|
|
228
|
+
for (const [text, id] of globalMap) {
|
|
210
229
|
if (clauseText.includes(text) || text.includes(clauseText)) {
|
|
211
230
|
return id;
|
|
212
231
|
}
|
|
213
232
|
}
|
|
214
|
-
// Buscar en todos los átomos
|
|
233
|
+
// 3. Buscar en todos los átomos por texto
|
|
215
234
|
const atomMatch = allAtoms.find(a => a.text === clauseText || a.text.includes(clauseText) || clauseText.includes(a.text));
|
|
216
235
|
if (atomMatch)
|
|
217
236
|
return atomMatch.id;
|
|
218
|
-
// Fallback: generar ID del texto
|
|
219
|
-
return clauseText
|
|
237
|
+
// 4. Fallback: generar ID del texto
|
|
238
|
+
return clauseText
|
|
239
|
+
.normalize('NFD').replace(/[\u0300-\u036f]/g, '')
|
|
240
|
+
.replace(/[^a-zA-Z0-9\s]/g, '')
|
|
241
|
+
.replace(/\s+/g, '_')
|
|
242
|
+
.toUpperCase()
|
|
243
|
+
.slice(0, 30) || 'ATOM';
|
|
220
244
|
}
|
|
221
245
|
/**
|
|
222
246
|
* Aplica modificadores lógicos a una fórmula atómica.
|