@stevenvo780/st-lang 0.4.0 → 0.5.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/api.d.ts +6 -2
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +101 -1
- package/dist/api.js.map +1 -1
- package/dist/profiles/aristotelian/syllogistic.d.ts +13 -0
- package/dist/profiles/aristotelian/syllogistic.d.ts.map +1 -0
- package/dist/profiles/aristotelian/syllogistic.js +364 -0
- package/dist/profiles/aristotelian/syllogistic.js.map +1 -0
- package/dist/profiles/deontic/standard.d.ts +10 -0
- package/dist/profiles/deontic/standard.d.ts.map +1 -0
- package/dist/profiles/deontic/standard.js +74 -0
- package/dist/profiles/deontic/standard.js.map +1 -0
- package/dist/profiles/epistemic/s5.d.ts +10 -0
- package/dist/profiles/epistemic/s5.d.ts.map +1 -0
- package/dist/profiles/epistemic/s5.js +70 -0
- package/dist/profiles/epistemic/s5.js.map +1 -0
- package/dist/profiles/index.d.ts +13 -0
- package/dist/profiles/index.d.ts.map +1 -0
- package/dist/profiles/index.js +58 -0
- package/dist/profiles/index.js.map +1 -0
- package/dist/profiles/intuitionistic/propositional.d.ts +14 -0
- package/dist/profiles/intuitionistic/propositional.d.ts.map +1 -0
- package/dist/profiles/intuitionistic/propositional.js +377 -0
- package/dist/profiles/intuitionistic/propositional.js.map +1 -0
- package/dist/profiles/modal/k.d.ts +8 -19
- package/dist/profiles/modal/k.d.ts.map +1 -1
- package/dist/profiles/modal/k.js +49 -320
- package/dist/profiles/modal/k.js.map +1 -1
- package/dist/profiles/probabilistic/basic.d.ts +17 -0
- package/dist/profiles/probabilistic/basic.d.ts.map +1 -0
- package/dist/profiles/probabilistic/basic.js +295 -0
- package/dist/profiles/probabilistic/basic.js.map +1 -0
- package/dist/profiles/shared/base-profile.d.ts +19 -0
- package/dist/profiles/shared/base-profile.d.ts.map +1 -0
- package/dist/profiles/shared/base-profile.js +129 -0
- package/dist/profiles/shared/base-profile.js.map +1 -0
- package/dist/profiles/shared/tableau-engine.d.ts +66 -0
- package/dist/profiles/shared/tableau-engine.d.ts.map +1 -0
- package/dist/profiles/shared/tableau-engine.js +439 -0
- package/dist/profiles/shared/tableau-engine.js.map +1 -0
- package/dist/profiles/temporal/ltl.d.ts +10 -0
- package/dist/profiles/temporal/ltl.d.ts.map +1 -0
- package/dist/profiles/temporal/ltl.js +75 -0
- package/dist/profiles/temporal/ltl.js.map +1 -0
- package/dist/protocol/handler.d.ts.map +1 -1
- package/dist/protocol/handler.js +81 -0
- package/dist/protocol/handler.js.map +1 -1
- package/dist/runtime/interpreter.d.ts +1 -0
- package/dist/runtime/interpreter.d.ts.map +1 -1
- package/dist/runtime/interpreter.js +2 -19
- package/dist/runtime/interpreter.js.map +1 -1
- package/dist/tests/philosophy.test.js.map +1 -1
- package/dist/tests/profiles.test.d.ts +2 -0
- package/dist/tests/profiles.test.d.ts.map +1 -0
- package/dist/tests/profiles.test.js +250 -0
- package/dist/tests/profiles.test.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// ST Deontic Standard — KD sobre BaseTableauProfile
|
|
4
|
+
// ============================================================
|
|
5
|
+
// O(φ) = [](φ) — obligación
|
|
6
|
+
// P(φ) = <>(φ) — permisión
|
|
7
|
+
// F(φ) = [](!φ) — prohibición
|
|
8
|
+
// Axioma D: O(φ) → P(φ) — serialidad
|
|
9
|
+
// ============================================================
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.DeonticStandard = void 0;
|
|
12
|
+
const propositional_1 = require("../classical/propositional");
|
|
13
|
+
const base_profile_1 = require("../shared/base-profile");
|
|
14
|
+
const tableau_engine_1 = require("../shared/tableau-engine");
|
|
15
|
+
class DeonticStandard extends base_profile_1.BaseTableauProfile {
|
|
16
|
+
name = 'deontic.standard';
|
|
17
|
+
description = 'Lógica deóntica estándar (KD) — obligación (O/[]), permisión (P/<>), prohibición (F/[]!)';
|
|
18
|
+
frameRules = tableau_engine_1.FRAME_KD;
|
|
19
|
+
formatFormula(f) {
|
|
20
|
+
return deonticToString(f);
|
|
21
|
+
}
|
|
22
|
+
explainSystem() {
|
|
23
|
+
return [
|
|
24
|
+
'Operadores deónticos:',
|
|
25
|
+
' O(φ) = [](φ) — "Es obligatorio que φ"',
|
|
26
|
+
' P(φ) = <>(φ) — "Está permitido que φ"',
|
|
27
|
+
' F(φ) = [](!φ) — "Está prohibido que φ"',
|
|
28
|
+
'',
|
|
29
|
+
'Sistema: KD (K + axioma D)',
|
|
30
|
+
' Axioma K: O(φ→ψ) → (O(φ)→O(ψ))',
|
|
31
|
+
' Axioma D: O(φ) → P(φ) — "lo obligatorio es permisible"',
|
|
32
|
+
' Serialidad: todo mundo tiene al menos un mundo accesible',
|
|
33
|
+
].join('\n');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.DeonticStandard = DeonticStandard;
|
|
37
|
+
function deonticToString(f) {
|
|
38
|
+
switch (f.kind) {
|
|
39
|
+
case 'modal_necessity': {
|
|
40
|
+
const inner = (f.args || [])[0];
|
|
41
|
+
if (!inner)
|
|
42
|
+
return 'O(?)';
|
|
43
|
+
if (inner.kind === 'not' && inner.args?.[0]) {
|
|
44
|
+
return `F(${deonticToString(inner.args[0])})`;
|
|
45
|
+
}
|
|
46
|
+
return `O(${deonticToString(inner)})`;
|
|
47
|
+
}
|
|
48
|
+
case 'modal_possibility': {
|
|
49
|
+
const inner = (f.args || [])[0];
|
|
50
|
+
return inner ? `P(${deonticToString(inner)})` : 'P(?)';
|
|
51
|
+
}
|
|
52
|
+
case 'atom':
|
|
53
|
+
return f.name || '?';
|
|
54
|
+
case 'not': {
|
|
55
|
+
const inner = (f.args || [])[0];
|
|
56
|
+
if (!inner)
|
|
57
|
+
return '¬?';
|
|
58
|
+
if (inner.kind === 'atom')
|
|
59
|
+
return `¬${deonticToString(inner)}`;
|
|
60
|
+
return `¬(${deonticToString(inner)})`;
|
|
61
|
+
}
|
|
62
|
+
case 'and':
|
|
63
|
+
return `(${deonticToString((f.args || [])[0])} ∧ ${deonticToString((f.args || [])[1])})`;
|
|
64
|
+
case 'or':
|
|
65
|
+
return `(${deonticToString((f.args || [])[0])} ∨ ${deonticToString((f.args || [])[1])})`;
|
|
66
|
+
case 'implies':
|
|
67
|
+
return `(${deonticToString((f.args || [])[0])} → ${deonticToString((f.args || [])[1])})`;
|
|
68
|
+
case 'biconditional':
|
|
69
|
+
return `(${deonticToString((f.args || [])[0])} ↔ ${deonticToString((f.args || [])[1])})`;
|
|
70
|
+
default:
|
|
71
|
+
return (0, propositional_1.formulaToString)(f);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=standard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standard.js","sourceRoot":"","sources":["../../../src/profiles/deontic/standard.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Formula } from '../../types';
|
|
2
|
+
import { BaseTableauProfile } from '../shared/base-profile';
|
|
3
|
+
export declare class EpistemicS5 extends BaseTableauProfile {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
frameRules: import("../shared/tableau-engine").FrameRules;
|
|
7
|
+
formatFormula(f: Formula): string;
|
|
8
|
+
explainSystem(): string;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=s5.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s5.d.ts","sourceRoot":"","sources":["../../../src/profiles/epistemic/s5.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAG5D,qBAAa,WAAY,SAAQ,kBAAkB;IACjD,IAAI,SAAkB;IACtB,WAAW,SAAgF;IAC3F,UAAU,gDAAY;IAEtB,aAAa,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM;IAIjC,aAAa,IAAI,MAAM;CAexB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// ST Epistemic S5 — S5 sobre BaseTableauProfile
|
|
4
|
+
// ============================================================
|
|
5
|
+
// K(φ) = [](φ) — conocimiento
|
|
6
|
+
// B(φ) = <>(φ) — creencia
|
|
7
|
+
// S5 = K + T + 4 + B (relación de accesibilidad universal)
|
|
8
|
+
// ============================================================
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.EpistemicS5 = void 0;
|
|
11
|
+
const propositional_1 = require("../classical/propositional");
|
|
12
|
+
const base_profile_1 = require("../shared/base-profile");
|
|
13
|
+
const tableau_engine_1 = require("../shared/tableau-engine");
|
|
14
|
+
class EpistemicS5 extends base_profile_1.BaseTableauProfile {
|
|
15
|
+
name = 'epistemic.s5';
|
|
16
|
+
description = 'Lógica epistémica S5 — conocimiento (K/[]), creencia (B/<>), introspección';
|
|
17
|
+
frameRules = tableau_engine_1.FRAME_S5;
|
|
18
|
+
formatFormula(f) {
|
|
19
|
+
return epistemicToString(f);
|
|
20
|
+
}
|
|
21
|
+
explainSystem() {
|
|
22
|
+
return [
|
|
23
|
+
'Operadores epistémicos:',
|
|
24
|
+
' K(φ) = [](φ) — "el agente sabe que φ"',
|
|
25
|
+
' B(φ) = <>(φ) — "el agente cree que φ"',
|
|
26
|
+
'',
|
|
27
|
+
'Sistema: S5 (K + T + 4 + B)',
|
|
28
|
+
' Axioma K: K(φ→ψ) → (Kφ→Kψ) — distribución',
|
|
29
|
+
' Axioma T: Kφ → φ — veridicidad (lo sabido es verdad)',
|
|
30
|
+
' Axioma 4: Kφ → KKφ — introspección positiva',
|
|
31
|
+
' Axioma B: φ → K¬K¬φ — introspección negativa',
|
|
32
|
+
'',
|
|
33
|
+
' Relación de accesibilidad: universal (equivalencia)',
|
|
34
|
+
].join('\n');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.EpistemicS5 = EpistemicS5;
|
|
38
|
+
function epistemicToString(f) {
|
|
39
|
+
switch (f.kind) {
|
|
40
|
+
case 'modal_necessity': {
|
|
41
|
+
const inner = (f.args || [])[0];
|
|
42
|
+
return inner ? `K(${epistemicToString(inner)})` : 'K(?)';
|
|
43
|
+
}
|
|
44
|
+
case 'modal_possibility': {
|
|
45
|
+
const inner = (f.args || [])[0];
|
|
46
|
+
return inner ? `B(${epistemicToString(inner)})` : 'B(?)';
|
|
47
|
+
}
|
|
48
|
+
case 'atom':
|
|
49
|
+
return f.name || '?';
|
|
50
|
+
case 'not': {
|
|
51
|
+
const inner = (f.args || [])[0];
|
|
52
|
+
if (!inner)
|
|
53
|
+
return '¬?';
|
|
54
|
+
if (inner.kind === 'atom')
|
|
55
|
+
return `¬${epistemicToString(inner)}`;
|
|
56
|
+
return `¬(${epistemicToString(inner)})`;
|
|
57
|
+
}
|
|
58
|
+
case 'and':
|
|
59
|
+
return `(${epistemicToString((f.args || [])[0])} ∧ ${epistemicToString((f.args || [])[1])})`;
|
|
60
|
+
case 'or':
|
|
61
|
+
return `(${epistemicToString((f.args || [])[0])} ∨ ${epistemicToString((f.args || [])[1])})`;
|
|
62
|
+
case 'implies':
|
|
63
|
+
return `(${epistemicToString((f.args || [])[0])} → ${epistemicToString((f.args || [])[1])})`;
|
|
64
|
+
case 'biconditional':
|
|
65
|
+
return `(${epistemicToString((f.args || [])[0])} ↔ ${epistemicToString((f.args || [])[1])})`;
|
|
66
|
+
default:
|
|
67
|
+
return (0, propositional_1.formulaToString)(f);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=s5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s5.js","sourceRoot":"","sources":["../../../src/profiles/epistemic/s5.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ClassicalPropositional } from './classical/propositional';
|
|
2
|
+
import { ClassicalFirstOrder } from './classical/first-order';
|
|
3
|
+
import { ModalK } from './modal/k';
|
|
4
|
+
import { ParaconsistentBelnap } from './paraconsistent/belnap';
|
|
5
|
+
import { DeonticStandard } from './deontic/standard';
|
|
6
|
+
import { EpistemicS5 } from './epistemic/s5';
|
|
7
|
+
import { AristotelianSyllogistic } from './aristotelian/syllogistic';
|
|
8
|
+
import { IntuitionisticPropositional } from './intuitionistic/propositional';
|
|
9
|
+
import { TemporalLTL } from './temporal/ltl';
|
|
10
|
+
import { ProbabilisticBasic } from './probabilistic/basic';
|
|
11
|
+
export { ClassicalPropositional, ClassicalFirstOrder, ModalK, ParaconsistentBelnap, DeonticStandard, EpistemicS5, AristotelianSyllogistic, IntuitionisticPropositional, TemporalLTL, ProbabilisticBasic, };
|
|
12
|
+
export { registry, ProfileRegistry } from './interface';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/profiles/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAwB3D,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,MAAM,EACN,oBAAoB,EACpB,eAAe,EACf,WAAW,EACX,uBAAuB,EACvB,2BAA2B,EAC3B,WAAW,EACX,kBAAkB,GACnB,CAAC;AACF,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// ST Profiles — Barrel de registro automático
|
|
4
|
+
// ============================================================
|
|
5
|
+
// Este archivo importa y registra todos los perfiles built-in.
|
|
6
|
+
// Para añadir un nuevo perfil, simplemente impórtalo aquí y
|
|
7
|
+
// llama a registry.register(new MiPerfil()).
|
|
8
|
+
//
|
|
9
|
+
// Los perfiles externos pueden usar registerProfile() de la API
|
|
10
|
+
// pública sin modificar este archivo.
|
|
11
|
+
// ============================================================
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.ProfileRegistry = exports.registry = exports.ProbabilisticBasic = exports.TemporalLTL = exports.IntuitionisticPropositional = exports.AristotelianSyllogistic = exports.EpistemicS5 = exports.DeonticStandard = exports.ParaconsistentBelnap = exports.ModalK = exports.ClassicalFirstOrder = exports.ClassicalPropositional = void 0;
|
|
14
|
+
const interface_1 = require("./interface");
|
|
15
|
+
// ── Built-in profiles ─────────────────────────────────────────
|
|
16
|
+
const propositional_1 = require("./classical/propositional");
|
|
17
|
+
Object.defineProperty(exports, "ClassicalPropositional", { enumerable: true, get: function () { return propositional_1.ClassicalPropositional; } });
|
|
18
|
+
const first_order_1 = require("./classical/first-order");
|
|
19
|
+
Object.defineProperty(exports, "ClassicalFirstOrder", { enumerable: true, get: function () { return first_order_1.ClassicalFirstOrder; } });
|
|
20
|
+
const k_1 = require("./modal/k");
|
|
21
|
+
Object.defineProperty(exports, "ModalK", { enumerable: true, get: function () { return k_1.ModalK; } });
|
|
22
|
+
const belnap_1 = require("./paraconsistent/belnap");
|
|
23
|
+
Object.defineProperty(exports, "ParaconsistentBelnap", { enumerable: true, get: function () { return belnap_1.ParaconsistentBelnap; } });
|
|
24
|
+
const standard_1 = require("./deontic/standard");
|
|
25
|
+
Object.defineProperty(exports, "DeonticStandard", { enumerable: true, get: function () { return standard_1.DeonticStandard; } });
|
|
26
|
+
const s5_1 = require("./epistemic/s5");
|
|
27
|
+
Object.defineProperty(exports, "EpistemicS5", { enumerable: true, get: function () { return s5_1.EpistemicS5; } });
|
|
28
|
+
const syllogistic_1 = require("./aristotelian/syllogistic");
|
|
29
|
+
Object.defineProperty(exports, "AristotelianSyllogistic", { enumerable: true, get: function () { return syllogistic_1.AristotelianSyllogistic; } });
|
|
30
|
+
const propositional_2 = require("./intuitionistic/propositional");
|
|
31
|
+
Object.defineProperty(exports, "IntuitionisticPropositional", { enumerable: true, get: function () { return propositional_2.IntuitionisticPropositional; } });
|
|
32
|
+
const ltl_1 = require("./temporal/ltl");
|
|
33
|
+
Object.defineProperty(exports, "TemporalLTL", { enumerable: true, get: function () { return ltl_1.TemporalLTL; } });
|
|
34
|
+
const basic_1 = require("./probabilistic/basic");
|
|
35
|
+
Object.defineProperty(exports, "ProbabilisticBasic", { enumerable: true, get: function () { return basic_1.ProbabilisticBasic; } });
|
|
36
|
+
// Registro idempotente
|
|
37
|
+
const builtins = [
|
|
38
|
+
propositional_1.ClassicalPropositional,
|
|
39
|
+
first_order_1.ClassicalFirstOrder,
|
|
40
|
+
k_1.ModalK,
|
|
41
|
+
belnap_1.ParaconsistentBelnap,
|
|
42
|
+
standard_1.DeonticStandard,
|
|
43
|
+
s5_1.EpistemicS5,
|
|
44
|
+
syllogistic_1.AristotelianSyllogistic,
|
|
45
|
+
propositional_2.IntuitionisticPropositional,
|
|
46
|
+
ltl_1.TemporalLTL,
|
|
47
|
+
basic_1.ProbabilisticBasic,
|
|
48
|
+
];
|
|
49
|
+
for (const Profile of builtins) {
|
|
50
|
+
const instance = new Profile();
|
|
51
|
+
if (!interface_1.registry.has(instance.name)) {
|
|
52
|
+
interface_1.registry.register(instance);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
var interface_2 = require("./interface");
|
|
56
|
+
Object.defineProperty(exports, "registry", { enumerable: true, get: function () { return interface_2.registry; } });
|
|
57
|
+
Object.defineProperty(exports, "ProfileRegistry", { enumerable: true, get: function () { return interface_2.ProfileRegistry; } });
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/profiles/index.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,8CAA8C;AAC9C,+DAA+D;AAC/D,+DAA+D;AAC/D,4DAA4D;AAC5D,6CAA6C;AAC7C,EAAE;AACF,gEAAgE;AAChE,sCAAsC;AACtC,+DAA+D;;;AAE/D,2CAAuC;AAEvC,iEAAiE;AACjE,6DAAmE;AAkCjE,uGAlCO,sCAAsB,OAkCP;AAjCxB,yDAA8D;AAkC5D,oGAlCO,iCAAmB,OAkCP;AAjCrB,iCAAmC;AAkCjC,uFAlCO,UAAM,OAkCP;AAjCR,oDAA+D;AAkC7D,qGAlCO,6BAAoB,OAkCP;AAjCtB,iDAAqD;AAkCnD,gGAlCO,0BAAe,OAkCP;AAjCjB,uCAA6C;AAkC3C,4FAlCO,gBAAW,OAkCP;AAjCb,4DAAqE;AAkCnE,wGAlCO,qCAAuB,OAkCP;AAjCzB,kEAA6E;AAkC3E,4GAlCO,2CAA2B,OAkCP;AAjC7B,wCAA6C;AAkC3C,4FAlCO,iBAAW,OAkCP;AAjCb,iDAA2D;AAkCzD,mGAlCO,0BAAkB,OAkCP;AAhCpB,uBAAuB;AACvB,MAAM,QAAQ,GAAG;IACf,sCAAsB;IACtB,iCAAmB;IACnB,UAAM;IACN,6BAAoB;IACpB,0BAAe;IACf,gBAAW;IACX,qCAAuB;IACvB,2CAA2B;IAC3B,iBAAW;IACX,0BAAkB;CACnB,CAAC;AAEF,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;IAC/B,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAE,CAAC;IAC/B,IAAI,CAAC,oBAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACjC,oBAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC;AAeD,yCAAwD;AAA/C,qGAAA,QAAQ,OAAA;AAAE,4GAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Formula } from '../../types';
|
|
2
|
+
import type { RunResult, Theory, Diagnostic, LogicProfile } from '../../types';
|
|
3
|
+
export declare class IntuitionisticPropositional implements LogicProfile {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
checkWellFormed(formula: Formula): Diagnostic[];
|
|
7
|
+
checkValid(formula: Formula): RunResult;
|
|
8
|
+
checkSatisfiable(formula: Formula): RunResult;
|
|
9
|
+
prove(goal: Formula, theory: Theory): RunResult;
|
|
10
|
+
derive(goal: Formula, premises: string[], theory: Theory): RunResult;
|
|
11
|
+
countermodel(formula: Formula): RunResult;
|
|
12
|
+
explain(formula: Formula): RunResult;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=propositional.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propositional.d.ts","sourceRoot":"","sources":["../../../src/profiles/intuitionistic/propositional.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA6P/E,qBAAa,2BAA4B,YAAW,YAAY;IAC9D,IAAI,SAAkC;IACtC,WAAW,SACmF;IAE9F,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,EAAE;IAkB/C,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS;IAavC,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS;IAa7C,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS;IAQ/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;IAwBzC,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS;CA6BrC"}
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// ST Intuitionistic Propositional — Kripke directo
|
|
4
|
+
// ============================================================
|
|
5
|
+
// Lógica intuicionista (IPC): sin ley del tercero excluido,
|
|
6
|
+
// sin doble negación eliminación.
|
|
7
|
+
//
|
|
8
|
+
// Implementación: enumeración exhaustiva de modelos Kripke
|
|
9
|
+
// finitos (preórdenes con persistencia de átomos).
|
|
10
|
+
// Para fórmulas proposicionales con n átomos, generamos todos
|
|
11
|
+
// los preórdenes de tamaño ≤ k y todas las valuaciones
|
|
12
|
+
// persistentes, verificando si la fórmula se fuerza en la raíz.
|
|
13
|
+
//
|
|
14
|
+
// Corrección: IPC es completa respecto a frames finitos
|
|
15
|
+
// (teorema de completitud de Kripke).
|
|
16
|
+
// ============================================================
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.IntuitionisticPropositional = void 0;
|
|
19
|
+
const propositional_1 = require("../classical/propositional");
|
|
20
|
+
// ── Recolectar átomos ───────────────────────────────────────
|
|
21
|
+
function collectAtoms(f) {
|
|
22
|
+
const atoms = new Set();
|
|
23
|
+
const walk = (node) => {
|
|
24
|
+
if (node.kind === 'atom' && node.name)
|
|
25
|
+
atoms.add(node.name);
|
|
26
|
+
node.args?.forEach(walk);
|
|
27
|
+
};
|
|
28
|
+
walk(f);
|
|
29
|
+
return atoms;
|
|
30
|
+
}
|
|
31
|
+
// ── Forzar (forcing) intuicionista ──────────────────────────
|
|
32
|
+
function forces(model, w, f) {
|
|
33
|
+
switch (f.kind) {
|
|
34
|
+
case 'atom':
|
|
35
|
+
return model.val.get(w)?.has(f.name || '') || false;
|
|
36
|
+
case 'not': {
|
|
37
|
+
// ¬φ se fuerza en w sii NO existe v ≥ w tal que v ⊩ φ
|
|
38
|
+
const inner = (f.args || [])[0];
|
|
39
|
+
if (!inner)
|
|
40
|
+
return true;
|
|
41
|
+
for (const v of reachable(model, w)) {
|
|
42
|
+
if (forces(model, v, inner))
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
case 'and': {
|
|
48
|
+
const args = f.args || [];
|
|
49
|
+
return args.every((a) => forces(model, w, a));
|
|
50
|
+
}
|
|
51
|
+
case 'or': {
|
|
52
|
+
const args = f.args || [];
|
|
53
|
+
return args.some((a) => forces(model, w, a));
|
|
54
|
+
}
|
|
55
|
+
case 'implies': {
|
|
56
|
+
// φ→ψ se fuerza en w sii para todo v ≥ w, si v ⊩ φ entonces v ⊩ ψ
|
|
57
|
+
const args = f.args || [];
|
|
58
|
+
if (args.length < 2)
|
|
59
|
+
return true;
|
|
60
|
+
for (const v of reachable(model, w)) {
|
|
61
|
+
if (forces(model, v, args[0]) && !forces(model, v, args[1]))
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
case 'biconditional': {
|
|
67
|
+
const args = f.args || [];
|
|
68
|
+
if (args.length < 2)
|
|
69
|
+
return true;
|
|
70
|
+
const impl1 = { kind: 'implies', args: [args[0], args[1]] };
|
|
71
|
+
const impl2 = { kind: 'implies', args: [args[1], args[0]] };
|
|
72
|
+
return forces(model, w, impl1) && forces(model, w, impl2);
|
|
73
|
+
}
|
|
74
|
+
// Modal: interpretar □ como universal en accesibles, ◇ como existencial
|
|
75
|
+
case 'modal_necessity': {
|
|
76
|
+
const inner = (f.args || [])[0];
|
|
77
|
+
if (!inner)
|
|
78
|
+
return true;
|
|
79
|
+
for (const v of reachable(model, w)) {
|
|
80
|
+
if (!forces(model, v, inner))
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
case 'modal_possibility': {
|
|
86
|
+
const inner = (f.args || [])[0];
|
|
87
|
+
if (!inner)
|
|
88
|
+
return false;
|
|
89
|
+
for (const v of reachable(model, w)) {
|
|
90
|
+
if (forces(model, v, inner))
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
default:
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/** Cierre transitivo-reflexivo desde w */
|
|
100
|
+
function reachable(model, w) {
|
|
101
|
+
const visited = new Set();
|
|
102
|
+
const queue = [w];
|
|
103
|
+
while (queue.length > 0) {
|
|
104
|
+
const current = queue.shift();
|
|
105
|
+
if (visited.has(current))
|
|
106
|
+
continue;
|
|
107
|
+
visited.add(current);
|
|
108
|
+
for (const next of model.access.get(current) || []) {
|
|
109
|
+
queue.push(next);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return Array.from(visited);
|
|
113
|
+
}
|
|
114
|
+
// ── Generador de modelos Kripke finitos ─────────────────────
|
|
115
|
+
/**
|
|
116
|
+
* Genera todos los preórdenes (reflexivos + transitivos)
|
|
117
|
+
* sobre {0, ..., n-1} y todas las valuaciones persistentes
|
|
118
|
+
* de los átomos dados.
|
|
119
|
+
*
|
|
120
|
+
* Para IPC proposicional con pocos átomos, 3 mundos son
|
|
121
|
+
* suficientes para refutar cualquier no-teorema.
|
|
122
|
+
*/
|
|
123
|
+
function* generateModels(atoms, maxWorlds) {
|
|
124
|
+
const n = Math.min(maxWorlds, 4); // Limitar a 4 mundos máx
|
|
125
|
+
for (let size = 1; size <= n; size++) {
|
|
126
|
+
const worlds = Array.from({ length: size }, (_, i) => i);
|
|
127
|
+
// Generar todos los subconjuntos de aristas (sin incluir reflexivas, que siempre van)
|
|
128
|
+
const pairs = [];
|
|
129
|
+
for (let i = 0; i < size; i++) {
|
|
130
|
+
for (let j = 0; j < size; j++) {
|
|
131
|
+
if (i !== j)
|
|
132
|
+
pairs.push([i, j]);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const edgeCombinations = 1 << pairs.length;
|
|
136
|
+
for (let edgeMask = 0; edgeMask < edgeCombinations; edgeMask++) {
|
|
137
|
+
// Construir relación de accesibilidad
|
|
138
|
+
const access = new Map();
|
|
139
|
+
for (const w of worlds)
|
|
140
|
+
access.set(w, new Set([w])); // Reflexividad
|
|
141
|
+
for (let b = 0; b < pairs.length; b++) {
|
|
142
|
+
if (edgeMask & (1 << b)) {
|
|
143
|
+
access.get(pairs[b][0]).add(pairs[b][1]);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// Cerrar transitivamente
|
|
147
|
+
transitiveClosure(access, worlds);
|
|
148
|
+
// Generar todas las valuaciones persistentes
|
|
149
|
+
yield* generatePersistentValuations(worlds, access, atoms);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function transitiveClosure(access, worlds) {
|
|
154
|
+
let changed = true;
|
|
155
|
+
while (changed) {
|
|
156
|
+
changed = false;
|
|
157
|
+
for (const w of worlds) {
|
|
158
|
+
const acc = access.get(w);
|
|
159
|
+
const toAdd = [];
|
|
160
|
+
for (const v of acc) {
|
|
161
|
+
for (const u of access.get(v) || []) {
|
|
162
|
+
if (!acc.has(u))
|
|
163
|
+
toAdd.push(u);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
for (const u of toAdd) {
|
|
167
|
+
acc.add(u);
|
|
168
|
+
changed = true;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function* generatePersistentValuations(worlds, access, atoms) {
|
|
174
|
+
const upwardSets = computeUpwardSets(worlds, access);
|
|
175
|
+
const atomCount = atoms.length;
|
|
176
|
+
// Cada átomo elige uno de los upward-closed sets
|
|
177
|
+
const total = Math.pow(upwardSets.length, atomCount);
|
|
178
|
+
for (let i = 0; i < total; i++) {
|
|
179
|
+
const val = new Map();
|
|
180
|
+
for (const w of worlds)
|
|
181
|
+
val.set(w, new Set());
|
|
182
|
+
let idx = i;
|
|
183
|
+
for (let a = 0; a < atomCount; a++) {
|
|
184
|
+
const setIdx = idx % upwardSets.length;
|
|
185
|
+
idx = Math.floor(idx / upwardSets.length);
|
|
186
|
+
const truthWorlds = upwardSets[setIdx];
|
|
187
|
+
for (const w of truthWorlds) {
|
|
188
|
+
val.get(w).add(atoms[a]);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
yield { worlds, access, val };
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function computeUpwardSets(worlds, access) {
|
|
195
|
+
// Un conjunto S es upward-closed si w∈S y wRv implica v∈S
|
|
196
|
+
const n = worlds.length;
|
|
197
|
+
const result = [];
|
|
198
|
+
const total = 1 << n;
|
|
199
|
+
for (let mask = 0; mask < total; mask++) {
|
|
200
|
+
const set = worlds.filter((_, i) => mask & (1 << i));
|
|
201
|
+
let upward = true;
|
|
202
|
+
for (const w of set) {
|
|
203
|
+
for (const v of access.get(w) || []) {
|
|
204
|
+
if (!(mask & (1 << v))) {
|
|
205
|
+
upward = false;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (!upward)
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
if (upward)
|
|
213
|
+
result.push(set);
|
|
214
|
+
}
|
|
215
|
+
return result;
|
|
216
|
+
}
|
|
217
|
+
// ── Verificación de validez ─────────────────────────────────
|
|
218
|
+
/** ¿Es φ válida en IPC? (forzada en la raíz de todo modelo Kripke finito) */
|
|
219
|
+
function isIPCValid(formula) {
|
|
220
|
+
const atoms = Array.from(collectAtoms(formula));
|
|
221
|
+
const maxWorlds = atoms.length <= 2 ? 4 : 3;
|
|
222
|
+
for (const model of generateModels(atoms, maxWorlds)) {
|
|
223
|
+
if (!forces(model, 0, formula))
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
/** ¿Es φ satisfacible en IPC? */
|
|
229
|
+
function isIPCSatisfiable(formula) {
|
|
230
|
+
const atoms = Array.from(collectAtoms(formula));
|
|
231
|
+
const maxWorlds = atoms.length <= 2 ? 4 : 3;
|
|
232
|
+
for (const model of generateModels(atoms, maxWorlds)) {
|
|
233
|
+
if (forces(model, 0, formula))
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
// ── Profile ─────────────────────────────────────────────────
|
|
239
|
+
class IntuitionisticPropositional {
|
|
240
|
+
name = 'intuitionistic.propositional';
|
|
241
|
+
description = 'Lógica intuicionista proposicional — sin tercero excluido, sin doble negación eliminación';
|
|
242
|
+
checkWellFormed(formula) {
|
|
243
|
+
const diags = [];
|
|
244
|
+
const walk = (f) => {
|
|
245
|
+
if (f.kind === 'atom' && !f.name) {
|
|
246
|
+
diags.push({ severity: 'error', message: 'Átomo sin nombre' });
|
|
247
|
+
}
|
|
248
|
+
if (f.kind === 'modal_necessity' || f.kind === 'modal_possibility') {
|
|
249
|
+
diags.push({
|
|
250
|
+
severity: 'warning',
|
|
251
|
+
message: 'Los operadores modales □/◇ no forman parte de la lógica intuicionista',
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
f.args?.forEach(walk);
|
|
255
|
+
};
|
|
256
|
+
walk(formula);
|
|
257
|
+
return diags;
|
|
258
|
+
}
|
|
259
|
+
checkValid(formula) {
|
|
260
|
+
const valid = isIPCValid(formula);
|
|
261
|
+
const fStr = (0, propositional_1.formulaToString)(formula);
|
|
262
|
+
return {
|
|
263
|
+
status: valid ? 'valid' : 'invalid',
|
|
264
|
+
output: valid
|
|
265
|
+
? `${fStr} es VÁLIDA intuicionistamente`
|
|
266
|
+
: `${fStr} NO es válida intuicionistamente`,
|
|
267
|
+
diagnostics: [],
|
|
268
|
+
formula,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
checkSatisfiable(formula) {
|
|
272
|
+
const sat = isIPCSatisfiable(formula);
|
|
273
|
+
const fStr = (0, propositional_1.formulaToString)(formula);
|
|
274
|
+
return {
|
|
275
|
+
status: sat ? 'satisfiable' : 'unsatisfiable',
|
|
276
|
+
output: sat
|
|
277
|
+
? `${fStr} es SATISFACIBLE intuicionistamente`
|
|
278
|
+
: `${fStr} es INSATISFACIBLE intuicionistamente`,
|
|
279
|
+
diagnostics: [],
|
|
280
|
+
formula,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
prove(goal, theory) {
|
|
284
|
+
const axioms = Array.from(theory.axioms.values());
|
|
285
|
+
if (axioms.length === 0)
|
|
286
|
+
return this.checkValid(goal);
|
|
287
|
+
const conj = axioms.reduce((a, b) => ({ kind: 'and', args: [a, b] }));
|
|
288
|
+
const impl = { kind: 'implies', args: [conj, goal] };
|
|
289
|
+
return this.checkValid(impl);
|
|
290
|
+
}
|
|
291
|
+
derive(goal, premises, theory) {
|
|
292
|
+
const fs = [];
|
|
293
|
+
for (const n of premises) {
|
|
294
|
+
const f = theory.axioms.get(n) || theory.theorems.get(n);
|
|
295
|
+
if (!f) {
|
|
296
|
+
return {
|
|
297
|
+
status: 'error',
|
|
298
|
+
output: `Premisa no encontrada: ${n}`,
|
|
299
|
+
diagnostics: [{ severity: 'error', message: `'${n}' no definida` }],
|
|
300
|
+
formula: goal,
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
fs.push(f);
|
|
304
|
+
}
|
|
305
|
+
if (fs.length === 0)
|
|
306
|
+
return this.checkValid(goal);
|
|
307
|
+
const conj = fs.reduce((a, b) => ({ kind: 'and', args: [a, b] }));
|
|
308
|
+
const impl = { kind: 'implies', args: [conj, goal] };
|
|
309
|
+
return this.checkValid(impl);
|
|
310
|
+
}
|
|
311
|
+
countermodel(formula) {
|
|
312
|
+
const atoms = Array.from(collectAtoms(formula));
|
|
313
|
+
const maxWorlds = atoms.length <= 2 ? 4 : 3;
|
|
314
|
+
const fStr = (0, propositional_1.formulaToString)(formula);
|
|
315
|
+
for (const model of generateModels(atoms, maxWorlds)) {
|
|
316
|
+
if (!forces(model, 0, formula)) {
|
|
317
|
+
const desc = describeModel(model);
|
|
318
|
+
return {
|
|
319
|
+
status: 'invalid',
|
|
320
|
+
output: `Contramodelo intuicionista para ${fStr}:\n${desc}`,
|
|
321
|
+
diagnostics: [],
|
|
322
|
+
formula,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return {
|
|
327
|
+
status: 'valid',
|
|
328
|
+
output: `No existe contramodelo — ${fStr} es válida intuicionistamente`,
|
|
329
|
+
diagnostics: [],
|
|
330
|
+
formula,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
explain(formula) {
|
|
334
|
+
const fStr = (0, propositional_1.formulaToString)(formula);
|
|
335
|
+
const valid = isIPCValid(formula);
|
|
336
|
+
let explanation = `Fórmula: ${fStr}\n\n`;
|
|
337
|
+
explanation += [
|
|
338
|
+
'Sistema: Lógica Intuicionista Proposicional (IPC)',
|
|
339
|
+
'',
|
|
340
|
+
'Rechazos clave vs. clásica:',
|
|
341
|
+
' ✗ P ∨ ¬P — Tercero excluido (LEM)',
|
|
342
|
+
' ✗ ¬¬P → P — Doble negación eliminación (DNE)',
|
|
343
|
+
' ✗ ((P→Q)→P) → P — Ley de Peirce',
|
|
344
|
+
'',
|
|
345
|
+
'Aceptados en IPC:',
|
|
346
|
+
' ✓ P → ¬¬P — Doble negación introducción',
|
|
347
|
+
' ✓ (P→Q) → (¬Q→¬P) — Contraposición',
|
|
348
|
+
' ✓ (P ∧ ¬P) → Q — Ex falso quodlibet',
|
|
349
|
+
'',
|
|
350
|
+
'Semántica: Kripke con preórdenes (reflexivo + transitivo)',
|
|
351
|
+
' Los átomos son persistentes (monótonos)',
|
|
352
|
+
' Implementación: enumeración de modelos finitos',
|
|
353
|
+
].join('\n');
|
|
354
|
+
explanation += `\n\nEstatus: ${valid ? 'VÁLIDA' : 'NO válida'} intuicionistamente`;
|
|
355
|
+
return {
|
|
356
|
+
status: valid ? 'valid' : 'invalid',
|
|
357
|
+
output: explanation,
|
|
358
|
+
diagnostics: [],
|
|
359
|
+
formula,
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
exports.IntuitionisticPropositional = IntuitionisticPropositional;
|
|
364
|
+
// ── Utilidades ──────────────────────────────────────────────
|
|
365
|
+
function describeModel(model) {
|
|
366
|
+
const lines = [];
|
|
367
|
+
lines.push(`Mundos: {${model.worlds.join(', ')}}`);
|
|
368
|
+
for (const w of model.worlds) {
|
|
369
|
+
const acc = Array.from(model.access.get(w) || []).filter((v) => v !== w);
|
|
370
|
+
if (acc.length > 0)
|
|
371
|
+
lines.push(` ${w} → {${acc.join(', ')}}`);
|
|
372
|
+
const atoms = Array.from(model.val.get(w) || []);
|
|
373
|
+
lines.push(` V(${w}) = {${atoms.join(', ')}}`);
|
|
374
|
+
}
|
|
375
|
+
return lines.join('\n');
|
|
376
|
+
}
|
|
377
|
+
//# sourceMappingURL=propositional.js.map
|