@stevenvo780/st-lang 4.2.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -1
- package/dist/index.js.map +1 -1
- package/dist/lambda-calc/church.d.ts +8 -0
- package/dist/lambda-calc/church.d.ts.map +1 -0
- package/dist/lambda-calc/church.js +67 -0
- package/dist/lambda-calc/church.js.map +1 -0
- package/dist/lambda-calc/combinators.d.ts +8 -0
- package/dist/lambda-calc/combinators.d.ts.map +1 -0
- package/dist/lambda-calc/combinators.js +24 -0
- package/dist/lambda-calc/combinators.js.map +1 -0
- package/dist/lambda-calc/index.d.ts +8 -0
- package/dist/lambda-calc/index.d.ts.map +1 -0
- package/dist/lambda-calc/index.js +48 -0
- package/dist/lambda-calc/index.js.map +1 -0
- package/dist/lambda-calc/reduce.d.ts +18 -0
- package/dist/lambda-calc/reduce.d.ts.map +1 -0
- package/dist/lambda-calc/reduce.js +174 -0
- package/dist/lambda-calc/reduce.js.map +1 -0
- package/dist/lambda-calc/substitution.d.ts +6 -0
- package/dist/lambda-calc/substitution.d.ts.map +1 -0
- package/dist/lambda-calc/substitution.js +120 -0
- package/dist/lambda-calc/substitution.js.map +1 -0
- package/dist/lambda-calc/types.d.ts +19 -0
- package/dist/lambda-calc/types.d.ts.map +1 -0
- package/dist/lambda-calc/types.js +72 -0
- package/dist/lambda-calc/types.js.map +1 -0
- package/dist/profiles/intuitionistic-nj/formula.d.ts +19 -0
- package/dist/profiles/intuitionistic-nj/formula.d.ts.map +1 -0
- package/dist/profiles/intuitionistic-nj/formula.js +99 -0
- package/dist/profiles/intuitionistic-nj/formula.js.map +1 -0
- package/dist/profiles/intuitionistic-nj/index.d.ts +5 -0
- package/dist/profiles/intuitionistic-nj/index.d.ts.map +1 -0
- package/dist/profiles/intuitionistic-nj/index.js +24 -0
- package/dist/profiles/intuitionistic-nj/index.js.map +1 -0
- package/dist/profiles/intuitionistic-nj/kripke.d.ts +17 -0
- package/dist/profiles/intuitionistic-nj/kripke.d.ts.map +1 -0
- package/dist/profiles/intuitionistic-nj/kripke.js +206 -0
- package/dist/profiles/intuitionistic-nj/kripke.js.map +1 -0
- package/dist/profiles/intuitionistic-nj/prover.d.ts +13 -0
- package/dist/profiles/intuitionistic-nj/prover.d.ts.map +1 -0
- package/dist/profiles/intuitionistic-nj/prover.js +418 -0
- package/dist/profiles/intuitionistic-nj/prover.js.map +1 -0
- package/dist/profiles/intuitionistic-nj/types.d.ts +55 -0
- package/dist/profiles/intuitionistic-nj/types.d.ts.map +1 -0
- package/dist/profiles/intuitionistic-nj/types.js +21 -0
- package/dist/profiles/intuitionistic-nj/types.js.map +1 -0
- package/dist/profiles/many-valued/index.d.ts +39 -0
- package/dist/profiles/many-valued/index.d.ts.map +1 -0
- package/dist/profiles/many-valued/index.js +250 -0
- package/dist/profiles/many-valued/index.js.map +1 -0
- package/dist/profiles/modal-frame-axioms/formula.d.ts +23 -0
- package/dist/profiles/modal-frame-axioms/formula.d.ts.map +1 -0
- package/dist/profiles/modal-frame-axioms/formula.js +158 -0
- package/dist/profiles/modal-frame-axioms/formula.js.map +1 -0
- package/dist/profiles/modal-frame-axioms/index.d.ts +6 -0
- package/dist/profiles/modal-frame-axioms/index.d.ts.map +1 -0
- package/dist/profiles/modal-frame-axioms/index.js +41 -0
- package/dist/profiles/modal-frame-axioms/index.js.map +1 -0
- package/dist/profiles/modal-frame-axioms/systems.d.ts +29 -0
- package/dist/profiles/modal-frame-axioms/systems.d.ts.map +1 -0
- package/dist/profiles/modal-frame-axioms/systems.js +96 -0
- package/dist/profiles/modal-frame-axioms/systems.js.map +1 -0
- package/dist/profiles/modal-frame-axioms/tableau.d.ts +12 -0
- package/dist/profiles/modal-frame-axioms/tableau.d.ts.map +1 -0
- package/dist/profiles/modal-frame-axioms/tableau.js +299 -0
- package/dist/profiles/modal-frame-axioms/tableau.js.map +1 -0
- package/dist/profiles/modal-frame-axioms/types.d.ts +61 -0
- package/dist/profiles/modal-frame-axioms/types.d.ts.map +1 -0
- package/dist/profiles/modal-frame-axioms/types.js +27 -0
- package/dist/profiles/modal-frame-axioms/types.js.map +1 -0
- package/dist/profiles/substructural/index.d.ts +4 -0
- package/dist/profiles/substructural/index.d.ts.map +1 -0
- package/dist/profiles/substructural/index.js +22 -0
- package/dist/profiles/substructural/index.js.map +1 -0
- package/dist/profiles/substructural/prover.d.ts +13 -0
- package/dist/profiles/substructural/prover.d.ts.map +1 -0
- package/dist/profiles/substructural/prover.js +481 -0
- package/dist/profiles/substructural/prover.js.map +1 -0
- package/dist/profiles/substructural/types.d.ts +72 -0
- package/dist/profiles/substructural/types.d.ts.map +1 -0
- package/dist/profiles/substructural/types.js +27 -0
- package/dist/profiles/substructural/types.js.map +1 -0
- package/dist/runtime/abduction/entails.d.ts +21 -0
- package/dist/runtime/abduction/entails.d.ts.map +1 -0
- package/dist/runtime/abduction/entails.js +308 -0
- package/dist/runtime/abduction/entails.js.map +1 -0
- package/dist/runtime/abduction/find.d.ts +18 -0
- package/dist/runtime/abduction/find.d.ts.map +1 -0
- package/dist/runtime/abduction/find.js +202 -0
- package/dist/runtime/abduction/find.js.map +1 -0
- package/dist/runtime/abduction/index.d.ts +4 -0
- package/dist/runtime/abduction/index.d.ts.map +1 -0
- package/dist/runtime/abduction/index.js +26 -0
- package/dist/runtime/abduction/index.js.map +1 -0
- package/dist/runtime/abduction/types.d.ts +78 -0
- package/dist/runtime/abduction/types.d.ts.map +1 -0
- package/dist/runtime/abduction/types.js +23 -0
- package/dist/runtime/abduction/types.js.map +1 -0
- package/dist/runtime/bayesian/factor.d.ts +22 -0
- package/dist/runtime/bayesian/factor.d.ts.map +1 -0
- package/dist/runtime/bayesian/factor.js +249 -0
- package/dist/runtime/bayesian/factor.js.map +1 -0
- package/dist/runtime/bayesian/index.d.ts +3 -0
- package/dist/runtime/bayesian/index.d.ts.map +1 -0
- package/dist/runtime/bayesian/index.js +25 -0
- package/dist/runtime/bayesian/index.js.map +1 -0
- package/dist/runtime/bayesian/inference.d.ts +6 -0
- package/dist/runtime/bayesian/inference.d.ts.map +1 -0
- package/dist/runtime/bayesian/inference.js +260 -0
- package/dist/runtime/bayesian/inference.js.map +1 -0
- package/dist/runtime/bayesian/types.d.ts +19 -0
- package/dist/runtime/bayesian/types.d.ts.map +1 -0
- package/dist/runtime/bayesian/types.js +9 -0
- package/dist/runtime/bayesian/types.js.map +1 -0
- package/dist/runtime/bisimulation/index.d.ts +4 -0
- package/dist/runtime/bisimulation/index.d.ts.map +1 -0
- package/dist/runtime/bisimulation/index.js +21 -0
- package/dist/runtime/bisimulation/index.js.map +1 -0
- package/dist/runtime/bisimulation/operations.d.ts +40 -0
- package/dist/runtime/bisimulation/operations.d.ts.map +1 -0
- package/dist/runtime/bisimulation/operations.js +219 -0
- package/dist/runtime/bisimulation/operations.js.map +1 -0
- package/dist/runtime/bisimulation/paige-tarjan.d.ts +8 -0
- package/dist/runtime/bisimulation/paige-tarjan.d.ts.map +1 -0
- package/dist/runtime/bisimulation/paige-tarjan.js +199 -0
- package/dist/runtime/bisimulation/paige-tarjan.js.map +1 -0
- package/dist/runtime/bisimulation/types.d.ts +26 -0
- package/dist/runtime/bisimulation/types.d.ts.map +1 -0
- package/dist/runtime/bisimulation/types.js +22 -0
- package/dist/runtime/bisimulation/types.js.map +1 -0
- package/dist/runtime/fca/context.d.ts +46 -0
- package/dist/runtime/fca/context.d.ts.map +1 -0
- package/dist/runtime/fca/context.js +155 -0
- package/dist/runtime/fca/context.js.map +1 -0
- package/dist/runtime/fca/implications.d.ts +10 -0
- package/dist/runtime/fca/implications.d.ts.map +1 -0
- package/dist/runtime/fca/implications.js +33 -0
- package/dist/runtime/fca/implications.js.map +1 -0
- package/dist/runtime/fca/index.d.ts +6 -0
- package/dist/runtime/fca/index.d.ts.map +1 -0
- package/dist/runtime/fca/index.js +39 -0
- package/dist/runtime/fca/index.js.map +1 -0
- package/dist/runtime/fca/lattice.d.ts +10 -0
- package/dist/runtime/fca/lattice.d.ts.map +1 -0
- package/dist/runtime/fca/lattice.js +86 -0
- package/dist/runtime/fca/lattice.js.map +1 -0
- package/dist/runtime/fca/next-closure.d.ts +12 -0
- package/dist/runtime/fca/next-closure.d.ts.map +1 -0
- package/dist/runtime/fca/next-closure.js +99 -0
- package/dist/runtime/fca/next-closure.js.map +1 -0
- package/dist/runtime/fca/types.d.ts +31 -0
- package/dist/runtime/fca/types.d.ts.map +1 -0
- package/dist/runtime/fca/types.js +30 -0
- package/dist/runtime/fca/types.js.map +1 -0
- package/dist/runtime/proof-minify/index.d.ts +3 -0
- package/dist/runtime/proof-minify/index.d.ts.map +1 -0
- package/dist/runtime/proof-minify/index.js +13 -0
- package/dist/runtime/proof-minify/index.js.map +1 -0
- package/dist/runtime/proof-minify/minify.d.ts +13 -0
- package/dist/runtime/proof-minify/minify.d.ts.map +1 -0
- package/dist/runtime/proof-minify/minify.js +540 -0
- package/dist/runtime/proof-minify/minify.js.map +1 -0
- package/dist/runtime/proof-minify/types.d.ts +89 -0
- package/dist/runtime/proof-minify/types.d.ts.map +1 -0
- package/dist/runtime/proof-minify/types.js +16 -0
- package/dist/runtime/proof-minify/types.js.map +1 -0
- package/dist/runtime/symbolic-diff/constructors.d.ts +16 -0
- package/dist/runtime/symbolic-diff/constructors.d.ts.map +1 -0
- package/dist/runtime/symbolic-diff/constructors.js +75 -0
- package/dist/runtime/symbolic-diff/constructors.js.map +1 -0
- package/dist/runtime/symbolic-diff/differentiate.d.ts +22 -0
- package/dist/runtime/symbolic-diff/differentiate.d.ts.map +1 -0
- package/dist/runtime/symbolic-diff/differentiate.js +107 -0
- package/dist/runtime/symbolic-diff/differentiate.js.map +1 -0
- package/dist/runtime/symbolic-diff/evaluate.d.ts +3 -0
- package/dist/runtime/symbolic-diff/evaluate.d.ts.map +1 -0
- package/dist/runtime/symbolic-diff/evaluate.js +47 -0
- package/dist/runtime/symbolic-diff/evaluate.js.map +1 -0
- package/dist/runtime/symbolic-diff/index.d.ts +9 -0
- package/dist/runtime/symbolic-diff/index.d.ts.map +1 -0
- package/dist/runtime/symbolic-diff/index.js +34 -0
- package/dist/runtime/symbolic-diff/index.js.map +1 -0
- package/dist/runtime/symbolic-diff/parse.d.ts +16 -0
- package/dist/runtime/symbolic-diff/parse.d.ts.map +1 -0
- package/dist/runtime/symbolic-diff/parse.js +206 -0
- package/dist/runtime/symbolic-diff/parse.js.map +1 -0
- package/dist/runtime/symbolic-diff/simplify.d.ts +11 -0
- package/dist/runtime/symbolic-diff/simplify.d.ts.map +1 -0
- package/dist/runtime/symbolic-diff/simplify.js +214 -0
- package/dist/runtime/symbolic-diff/simplify.js.map +1 -0
- package/dist/runtime/symbolic-diff/stringify.d.ts +3 -0
- package/dist/runtime/symbolic-diff/stringify.d.ts.map +1 -0
- package/dist/runtime/symbolic-diff/stringify.js +69 -0
- package/dist/runtime/symbolic-diff/stringify.js.map +1 -0
- package/dist/runtime/symbolic-diff/types.d.ts +35 -0
- package/dist/runtime/symbolic-diff/types.d.ts.map +1 -0
- package/dist/runtime/symbolic-diff/types.js +9 -0
- package/dist/runtime/symbolic-diff/types.js.map +1 -0
- package/dist/runtime/term-rewriting/critical-pairs.d.ts +38 -0
- package/dist/runtime/term-rewriting/critical-pairs.d.ts.map +1 -0
- package/dist/runtime/term-rewriting/critical-pairs.js +109 -0
- package/dist/runtime/term-rewriting/critical-pairs.js.map +1 -0
- package/dist/runtime/term-rewriting/index.d.ts +9 -0
- package/dist/runtime/term-rewriting/index.d.ts.map +1 -0
- package/dist/runtime/term-rewriting/index.js +38 -0
- package/dist/runtime/term-rewriting/index.js.map +1 -0
- package/dist/runtime/term-rewriting/knuth-bendix.d.ts +29 -0
- package/dist/runtime/term-rewriting/knuth-bendix.d.ts.map +1 -0
- package/dist/runtime/term-rewriting/knuth-bendix.js +196 -0
- package/dist/runtime/term-rewriting/knuth-bendix.js.map +1 -0
- package/dist/runtime/term-rewriting/lpo.d.ts +17 -0
- package/dist/runtime/term-rewriting/lpo.d.ts.map +1 -0
- package/dist/runtime/term-rewriting/lpo.js +158 -0
- package/dist/runtime/term-rewriting/lpo.js.map +1 -0
- package/dist/runtime/term-rewriting/rewrite.d.ts +44 -0
- package/dist/runtime/term-rewriting/rewrite.d.ts.map +1 -0
- package/dist/runtime/term-rewriting/rewrite.js +189 -0
- package/dist/runtime/term-rewriting/rewrite.js.map +1 -0
- package/dist/runtime/term-rewriting/term-utils.d.ts +64 -0
- package/dist/runtime/term-rewriting/term-utils.d.ts.map +1 -0
- package/dist/runtime/term-rewriting/term-utils.js +360 -0
- package/dist/runtime/term-rewriting/term-utils.js.map +1 -0
- package/dist/runtime/term-rewriting/types.d.ts +66 -0
- package/dist/runtime/term-rewriting/types.d.ts.map +1 -0
- package/dist/runtime/term-rewriting/types.js +21 -0
- package/dist/runtime/term-rewriting/types.js.map +1 -0
- package/dist/tests/abduction/abduction.test.d.ts +2 -0
- package/dist/tests/abduction/abduction.test.d.ts.map +1 -0
- package/dist/tests/abduction/abduction.test.js +380 -0
- package/dist/tests/abduction/abduction.test.js.map +1 -0
- package/dist/tests/bayesian/bayesian.test.d.ts +2 -0
- package/dist/tests/bayesian/bayesian.test.d.ts.map +1 -0
- package/dist/tests/bayesian/bayesian.test.js +328 -0
- package/dist/tests/bayesian/bayesian.test.js.map +1 -0
- package/dist/tests/bisimulation/paige-tarjan.test.d.ts +2 -0
- package/dist/tests/bisimulation/paige-tarjan.test.d.ts.map +1 -0
- package/dist/tests/bisimulation/paige-tarjan.test.js +254 -0
- package/dist/tests/bisimulation/paige-tarjan.test.js.map +1 -0
- package/dist/tests/fca/fca.test.d.ts +2 -0
- package/dist/tests/fca/fca.test.d.ts.map +1 -0
- package/dist/tests/fca/fca.test.js +317 -0
- package/dist/tests/fca/fca.test.js.map +1 -0
- package/dist/tests/intuitionistic-nj/nj.test.d.ts +2 -0
- package/dist/tests/intuitionistic-nj/nj.test.d.ts.map +1 -0
- package/dist/tests/intuitionistic-nj/nj.test.js +216 -0
- package/dist/tests/intuitionistic-nj/nj.test.js.map +1 -0
- package/dist/tests/lambda-calc/lambda-calc.test.d.ts +2 -0
- package/dist/tests/lambda-calc/lambda-calc.test.d.ts.map +1 -0
- package/dist/tests/lambda-calc/lambda-calc.test.js +164 -0
- package/dist/tests/lambda-calc/lambda-calc.test.js.map +1 -0
- package/dist/tests/many-valued/many-valued.test.d.ts +2 -0
- package/dist/tests/many-valued/many-valued.test.d.ts.map +1 -0
- package/dist/tests/many-valued/many-valued.test.js +150 -0
- package/dist/tests/many-valued/many-valued.test.js.map +1 -0
- package/dist/tests/modal-frame-axioms/frame-axioms.test.d.ts +2 -0
- package/dist/tests/modal-frame-axioms/frame-axioms.test.d.ts.map +1 -0
- package/dist/tests/modal-frame-axioms/frame-axioms.test.js +236 -0
- package/dist/tests/modal-frame-axioms/frame-axioms.test.js.map +1 -0
- package/dist/tests/proof-minify/minify.test.d.ts +2 -0
- package/dist/tests/proof-minify/minify.test.d.ts.map +1 -0
- package/dist/tests/proof-minify/minify.test.js +281 -0
- package/dist/tests/proof-minify/minify.test.js.map +1 -0
- package/dist/tests/substructural/prover.test.d.ts +2 -0
- package/dist/tests/substructural/prover.test.d.ts.map +1 -0
- package/dist/tests/substructural/prover.test.js +271 -0
- package/dist/tests/substructural/prover.test.js.map +1 -0
- package/dist/tests/symbolic-diff/symbolic-diff.test.d.ts +2 -0
- package/dist/tests/symbolic-diff/symbolic-diff.test.d.ts.map +1 -0
- package/dist/tests/symbolic-diff/symbolic-diff.test.js +278 -0
- package/dist/tests/symbolic-diff/symbolic-diff.test.js.map +1 -0
- package/dist/tests/term-rewriting/critical-pairs.test.d.ts +2 -0
- package/dist/tests/term-rewriting/critical-pairs.test.d.ts.map +1 -0
- package/dist/tests/term-rewriting/critical-pairs.test.js +34 -0
- package/dist/tests/term-rewriting/critical-pairs.test.js.map +1 -0
- package/dist/tests/term-rewriting/knuth-bendix.test.d.ts +2 -0
- package/dist/tests/term-rewriting/knuth-bendix.test.d.ts.map +1 -0
- package/dist/tests/term-rewriting/knuth-bendix.test.js +94 -0
- package/dist/tests/term-rewriting/knuth-bendix.test.js.map +1 -0
- package/dist/tests/term-rewriting/lpo.test.d.ts +2 -0
- package/dist/tests/term-rewriting/lpo.test.d.ts.map +1 -0
- package/dist/tests/term-rewriting/lpo.test.js +57 -0
- package/dist/tests/term-rewriting/lpo.test.js.map +1 -0
- package/dist/tests/term-rewriting/rewrite.test.d.ts +2 -0
- package/dist/tests/term-rewriting/rewrite.test.d.ts.map +1 -0
- package/dist/tests/term-rewriting/rewrite.test.js +56 -0
- package/dist/tests/term-rewriting/rewrite.test.js.map +1 -0
- package/dist/tests/term-rewriting/term-utils.test.d.ts +2 -0
- package/dist/tests/term-rewriting/term-utils.test.d.ts.map +1 -0
- package/dist/tests/term-rewriting/term-utils.test.js +58 -0
- package/dist/tests/term-rewriting/term-utils.test.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// Paige-Tarjan — partition refinement para bisimulación fuerte.
|
|
4
|
+
// ============================================================
|
|
5
|
+
// Complejidad O(m log n) sobre LTS finitos, donde m = |→| y n = |S|.
|
|
6
|
+
//
|
|
7
|
+
// Idea:
|
|
8
|
+
// - Comienza con la partición coarsest compatible con el labelling.
|
|
9
|
+
// - Mantiene una cola de "splitters" (B, a): bloque B y acción a.
|
|
10
|
+
// - Para cada splitter, particiona cada bloque X en
|
|
11
|
+
// X₁ = { s ∈ X | ∃ s -a-> t, t ∈ B }
|
|
12
|
+
// X₂ = X \ X₁
|
|
13
|
+
// y si ambos son no vacíos, reemplaza X y agrega el bloque más pequeño
|
|
14
|
+
// como nuevo splitter (heurística que da el factor log n).
|
|
15
|
+
// - Termina cuando no quedan splitters útiles.
|
|
16
|
+
//
|
|
17
|
+
// La implementación usa un Map de aristas inversas por acción
|
|
18
|
+
// inversa[a][to] = { from : ∃ from -a-> to }
|
|
19
|
+
// para que el split sea proporcional a |a-predecessors|.
|
|
20
|
+
// ============================================================
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.paigeTarjan = paigeTarjan;
|
|
23
|
+
function canonicalLabel(labels) {
|
|
24
|
+
if (!labels || labels.size === 0)
|
|
25
|
+
return '∅';
|
|
26
|
+
return [...labels].sort().join('|');
|
|
27
|
+
}
|
|
28
|
+
function compile(lts) {
|
|
29
|
+
const stateSet = new Set(lts.states);
|
|
30
|
+
const actionSet = new Set();
|
|
31
|
+
const inverse = new Map();
|
|
32
|
+
for (const [from, action, to] of lts.transitions) {
|
|
33
|
+
if (!stateSet.has(from)) {
|
|
34
|
+
throw new Error(`Bisimulation: transición desde estado desconocido "${from}"`);
|
|
35
|
+
}
|
|
36
|
+
if (!stateSet.has(to)) {
|
|
37
|
+
throw new Error(`Bisimulation: transición hacia estado desconocido "${to}"`);
|
|
38
|
+
}
|
|
39
|
+
actionSet.add(action);
|
|
40
|
+
let invA = inverse.get(action);
|
|
41
|
+
if (!invA) {
|
|
42
|
+
invA = new Map();
|
|
43
|
+
inverse.set(action, invA);
|
|
44
|
+
}
|
|
45
|
+
let bucket = invA.get(to);
|
|
46
|
+
if (!bucket) {
|
|
47
|
+
bucket = new Set();
|
|
48
|
+
invA.set(to, bucket);
|
|
49
|
+
}
|
|
50
|
+
bucket.add(from);
|
|
51
|
+
}
|
|
52
|
+
const labelKey = new Map();
|
|
53
|
+
for (const s of lts.states) {
|
|
54
|
+
labelKey.set(s, canonicalLabel(lts.labelling?.[s]));
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
states: [...lts.states],
|
|
58
|
+
actions: [...actionSet],
|
|
59
|
+
inverse,
|
|
60
|
+
labelKey,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Calcula los `a-predecessors` de un conjunto target:
|
|
65
|
+
* pre_a(B) = { s | ∃ s -a-> t, t ∈ B }
|
|
66
|
+
*/
|
|
67
|
+
function preimage(compiled, action, target) {
|
|
68
|
+
const out = new Set();
|
|
69
|
+
const invA = compiled.inverse.get(action);
|
|
70
|
+
if (!invA)
|
|
71
|
+
return out;
|
|
72
|
+
for (const to of target) {
|
|
73
|
+
const froms = invA.get(to);
|
|
74
|
+
if (!froms)
|
|
75
|
+
continue;
|
|
76
|
+
for (const f of froms)
|
|
77
|
+
out.add(f);
|
|
78
|
+
}
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Particiona el LTS según bisimulación fuerte usando Paige-Tarjan.
|
|
83
|
+
* Devuelve la partición canónica donde dos estados están en el mismo bloque
|
|
84
|
+
* sii son fuertemente bisimilares.
|
|
85
|
+
*/
|
|
86
|
+
function paigeTarjan(lts) {
|
|
87
|
+
const compiled = compile(lts);
|
|
88
|
+
// Partición inicial por labelling (refinement compatible con la condición 1).
|
|
89
|
+
const byLabel = new Map();
|
|
90
|
+
for (const s of compiled.states) {
|
|
91
|
+
const k = compiled.labelKey.get(s) ?? '∅';
|
|
92
|
+
let g = byLabel.get(k);
|
|
93
|
+
if (!g) {
|
|
94
|
+
g = new Set();
|
|
95
|
+
byLabel.set(k, g);
|
|
96
|
+
}
|
|
97
|
+
g.add(s);
|
|
98
|
+
}
|
|
99
|
+
const blocks = [];
|
|
100
|
+
const blockOf = new Map();
|
|
101
|
+
for (const members of byLabel.values()) {
|
|
102
|
+
const id = blocks.length;
|
|
103
|
+
blocks.push({ id, members });
|
|
104
|
+
for (const s of members)
|
|
105
|
+
blockOf.set(s, id);
|
|
106
|
+
}
|
|
107
|
+
// Cola de splitters: pares (blockId, action). Usamos una clave canónica para
|
|
108
|
+
// evitar inserciones duplicadas en la cola.
|
|
109
|
+
const pending = [];
|
|
110
|
+
const pendingKey = new Set();
|
|
111
|
+
const enqueue = (bid, a) => {
|
|
112
|
+
const k = `${bid}|${a}`;
|
|
113
|
+
if (pendingKey.has(k))
|
|
114
|
+
return;
|
|
115
|
+
pendingKey.add(k);
|
|
116
|
+
pending.push([bid, a]);
|
|
117
|
+
};
|
|
118
|
+
// Sembrar la cola con todos los pares (bloque inicial, acción).
|
|
119
|
+
for (const b of blocks) {
|
|
120
|
+
for (const a of compiled.actions)
|
|
121
|
+
enqueue(b.id, a);
|
|
122
|
+
}
|
|
123
|
+
let iterations = 0;
|
|
124
|
+
const maxIter = compiled.states.length * compiled.actions.length * 4 + 16;
|
|
125
|
+
while (pending.length > 0) {
|
|
126
|
+
if (iterations++ > maxIter) {
|
|
127
|
+
// Cinturón de seguridad; Paige-Tarjan termina en O(m log n).
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
const head = pending.shift();
|
|
131
|
+
if (!head)
|
|
132
|
+
break;
|
|
133
|
+
const [splitterId, action] = head;
|
|
134
|
+
pendingKey.delete(`${splitterId}|${action}`);
|
|
135
|
+
const splitter = blocks[splitterId];
|
|
136
|
+
if (!splitter)
|
|
137
|
+
continue;
|
|
138
|
+
// pre_action(splitter.members) — estados que pueden alcanzar el splitter
|
|
139
|
+
// vía la acción dada.
|
|
140
|
+
const pre = preimage(compiled, action, splitter.members);
|
|
141
|
+
if (pre.size === 0)
|
|
142
|
+
continue;
|
|
143
|
+
// Agrupar los preimage por bloque actual (para saber qué bloques tocan).
|
|
144
|
+
const touched = new Map();
|
|
145
|
+
for (const s of pre) {
|
|
146
|
+
const bid = blockOf.get(s);
|
|
147
|
+
if (bid === undefined)
|
|
148
|
+
continue;
|
|
149
|
+
let bucket = touched.get(bid);
|
|
150
|
+
if (!bucket) {
|
|
151
|
+
bucket = new Set();
|
|
152
|
+
touched.set(bid, bucket);
|
|
153
|
+
}
|
|
154
|
+
bucket.add(s);
|
|
155
|
+
}
|
|
156
|
+
for (const [bid, inPre] of touched) {
|
|
157
|
+
const block = blocks[bid];
|
|
158
|
+
if (!block)
|
|
159
|
+
continue;
|
|
160
|
+
if (inPre.size === block.members.size)
|
|
161
|
+
continue; // splitter no separa este bloque.
|
|
162
|
+
// Particionar block en (block ∩ pre, block \ pre).
|
|
163
|
+
const outside = new Set();
|
|
164
|
+
for (const s of block.members) {
|
|
165
|
+
if (!inPre.has(s))
|
|
166
|
+
outside.add(s);
|
|
167
|
+
}
|
|
168
|
+
// Nuevo bloque para `outside`; `block` se queda con `inPre`.
|
|
169
|
+
const newId = blocks.length;
|
|
170
|
+
blocks.push({ id: newId, members: outside });
|
|
171
|
+
block.members = inPre;
|
|
172
|
+
for (const s of outside)
|
|
173
|
+
blockOf.set(s, newId);
|
|
174
|
+
// Heurística Paige-Tarjan: encolar el bloque más pequeño como splitter.
|
|
175
|
+
// El más grande "hereda" su antiguo rol en cola sin necesidad de reencolar.
|
|
176
|
+
const smaller = block.members.size <= outside.size ? block.id : newId;
|
|
177
|
+
for (const a of compiled.actions)
|
|
178
|
+
enqueue(smaller, a);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// Compactar: filtrar bloques no vacíos y renumerar.
|
|
182
|
+
const finalBlocks = [];
|
|
183
|
+
const partition = new Map();
|
|
184
|
+
for (const b of blocks) {
|
|
185
|
+
if (b.members.size === 0)
|
|
186
|
+
continue;
|
|
187
|
+
const idx = finalBlocks.length;
|
|
188
|
+
finalBlocks.push([...b.members]);
|
|
189
|
+
for (const s of b.members)
|
|
190
|
+
partition.set(s, idx);
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
partition,
|
|
194
|
+
blocks: finalBlocks,
|
|
195
|
+
numBlocks: finalBlocks.length,
|
|
196
|
+
iterations,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=paige-tarjan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paige-tarjan.js","sourceRoot":"","sources":["../../../src/runtime/bisimulation/paige-tarjan.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,gEAAgE;AAChE,+DAA+D;AAC/D,qEAAqE;AACrE,EAAE;AACF,QAAQ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E,KAAK,CAAC,CAAC;YAE/C,wEAAwE;YACxE,4EAA4E;YAC5E,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;YACtE,KAAK,MAAM,CAAC,IAAI,QAAQ,CAAC,OAAO;gBAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAED,oDAAoD;IACpD,MAAM,WAAW,GAAe,EAAE,CAAC;IACnC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC;YAAE,SAAS;QACnC,MAAM,GAAG,GAAG,WAAW,CAAC,MAAM,CAAC;QAC/B,WAAW,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;QACjC,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO;YAAE,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACnD,CAAC;IAED,OAAO;QACL,SAAS;QACT,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,WAAW,CAAC,MAAM;QAC7B,UAAU;KACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sistema de transiciones etiquetadas.
|
|
3
|
+
* - `states` lista finita de identificadores de estado.
|
|
4
|
+
* - `transitions` triplas [from, action, to] que codifican →.
|
|
5
|
+
* - `labelling` opcional: estado → conjunto de proposiciones atómicas que
|
|
6
|
+
* se cumplen en él. Estados ausentes se tratan como ∅.
|
|
7
|
+
*/
|
|
8
|
+
export interface LTS {
|
|
9
|
+
states: string[];
|
|
10
|
+
transitions: Array<[string, string, string]>;
|
|
11
|
+
labelling?: Record<string, Set<string>>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Resultado de un algoritmo de partition refinement.
|
|
15
|
+
* - `partition` estado → índice de bloque.
|
|
16
|
+
* - `blocks` bloques como listas de estados (índice consistente con partition).
|
|
17
|
+
* - `numBlocks` cardinalidad de la partición final.
|
|
18
|
+
* - `iterations` número de iteraciones de refinamiento ejecutadas.
|
|
19
|
+
*/
|
|
20
|
+
export interface BisimulationResult {
|
|
21
|
+
partition: Map<string, number>;
|
|
22
|
+
blocks: string[][];
|
|
23
|
+
numBlocks: number;
|
|
24
|
+
iterations: number;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/runtime/bisimulation/types.ts"],"names":[],"mappings":"AAoBA;;;;;;GAMG;AACH,MAAM,WAAW,GAAG;IAClB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;CACzC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// Bisimulation — tipos públicos
|
|
4
|
+
// ============================================================
|
|
5
|
+
// Sistema de Transiciones Etiquetadas (LTS, Labelled Transition System):
|
|
6
|
+
// M = (S, Act, →, L)
|
|
7
|
+
// S conjunto finito de estados
|
|
8
|
+
// Act alfabeto de acciones
|
|
9
|
+
// → relación de transición ⊆ S × Act × S
|
|
10
|
+
// L función de etiquetado opcional S → 2^AP (proposiciones atómicas)
|
|
11
|
+
//
|
|
12
|
+
// La bisimulación fuerte ~ es la mayor relación R ⊆ S × S tal que (s, t) ∈ R
|
|
13
|
+
// implica:
|
|
14
|
+
// 1. L(s) = L(t) (mismas etiquetas)
|
|
15
|
+
// 2. ∀ s -a-> s'. ∃ t'. t -a-> t' ∧ (s', t') ∈ R (forward simulation)
|
|
16
|
+
// 3. ∀ t -a-> t'. ∃ s'. s -a-> s' ∧ (s', t') ∈ R (backward simulation)
|
|
17
|
+
//
|
|
18
|
+
// La bisimulación débil ignora τ-transiciones internas y compara cadenas
|
|
19
|
+
// s ⇒ s' ≡ s -τ*-> ·-a-> ·-τ*-> s'
|
|
20
|
+
// ============================================================
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/runtime/bisimulation/types.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,gCAAgC;AAChC,+DAA+D;AAC/D,yEAAyE;AACzE,uBAAuB;AACvB,yCAAyC;AACzC,mCAAmC;AACnC,mDAAmD;AACnD,+EAA+E;AAC/E,EAAE;AACF,6EAA6E;AAC7E,WAAW;AACX,iFAAiF;AACjF,mFAAmF;AACnF,oFAAoF;AACpF,EAAE;AACF,yEAAyE;AACzE,qCAAqC;AACrC,+DAA+D"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { FormalContext } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Construye un contexto formal a partir de listas de objetos, atributos y
|
|
4
|
+
* la lista bruta de incidencias.
|
|
5
|
+
*
|
|
6
|
+
* Valida:
|
|
7
|
+
* - Los identificadores no pueden contener el separador '|'.
|
|
8
|
+
* - No se admiten objetos o atributos duplicados.
|
|
9
|
+
* - Cada incidencia [g, m] debe referirse a objetos/atributos declarados.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createContext(objects: string[], attributes: string[], incidence: Array<[string, string]>): FormalContext;
|
|
12
|
+
/**
|
|
13
|
+
* Indica si el objeto `g` tiene el atributo `m` en el contexto.
|
|
14
|
+
* O(1) gracias a la representación como Set de pares codificados.
|
|
15
|
+
*/
|
|
16
|
+
export declare function hasIncidence(ctx: FormalContext, g: string, m: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Operador polar B → B' (atributos → objetos).
|
|
19
|
+
* Devuelve el conjunto de objetos que poseen TODOS los atributos de `attrs`.
|
|
20
|
+
* Si `attrs` es vacío, el resultado es G (convención: ∀ trivialmente cierto).
|
|
21
|
+
*/
|
|
22
|
+
export declare function derivativeObjects(ctx: FormalContext, attrs: Set<string>): Set<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Operador polar A → A' (objetos → atributos).
|
|
25
|
+
* Devuelve los atributos compartidos por TODOS los objetos de `objs`.
|
|
26
|
+
* Si `objs` es vacío, el resultado es M.
|
|
27
|
+
*/
|
|
28
|
+
export declare function derivativeAttributes(ctx: FormalContext, objs: Set<string>): Set<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Verifica si (extent, intent) es un concepto formal en `ctx`:
|
|
31
|
+
* extent' = intent y intent' = extent.
|
|
32
|
+
*
|
|
33
|
+
* Equivale a verificar la doble clausura, pero se computa directo desde la
|
|
34
|
+
* relación de incidencia, sin acumular intermedios.
|
|
35
|
+
*/
|
|
36
|
+
export declare function isConcept(ctx: FormalContext, extent: Set<string>, intent: Set<string>): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Clausura de Galois sobre intents: B → B'' = (B')'.
|
|
39
|
+
* Idempotente: closeIntent(closeIntent(B)) = closeIntent(B).
|
|
40
|
+
*/
|
|
41
|
+
export declare function closeIntent(ctx: FormalContext, intent: Set<string>): Set<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Clausura sobre extents: A → A'' = (A')'.
|
|
44
|
+
*/
|
|
45
|
+
export declare function closeExtent(ctx: FormalContext, extent: Set<string>): Set<string>;
|
|
46
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/runtime/fca/context.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAQ7C;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EAAE,EACjB,UAAU,EAAE,MAAM,EAAE,EACpB,SAAS,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACjC,aAAa,CAsCf;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,aAAa,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAE9E;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAarF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAavF;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,CAI/F;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAEhF;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAEhF"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// FCA — construcción del contexto y operadores polares de Galois.
|
|
4
|
+
// ============================================================
|
|
5
|
+
// Aquí viven las primitivas de bajo nivel: construir K = (G, M, I) y
|
|
6
|
+
// computar las dos derivaciones A → A' y B → B' que sustentan toda la
|
|
7
|
+
// teoría (definición de concepto, clausura, implicación).
|
|
8
|
+
//
|
|
9
|
+
// Notación interna: codificamos un par (g, m) ∈ I como la cadena
|
|
10
|
+
// "g|m". El delimitador '|' es seguro porque obligamos que ningún
|
|
11
|
+
// identificador lo contenga (createContext lo valida); de lo contrario
|
|
12
|
+
// usaríamos un Map<string, Set<string>>.
|
|
13
|
+
// ============================================================
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.createContext = createContext;
|
|
16
|
+
exports.hasIncidence = hasIncidence;
|
|
17
|
+
exports.derivativeObjects = derivativeObjects;
|
|
18
|
+
exports.derivativeAttributes = derivativeAttributes;
|
|
19
|
+
exports.isConcept = isConcept;
|
|
20
|
+
exports.closeIntent = closeIntent;
|
|
21
|
+
exports.closeExtent = closeExtent;
|
|
22
|
+
const SEP = '|';
|
|
23
|
+
function encode(obj, attr) {
|
|
24
|
+
return `${obj}${SEP}${attr}`;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Construye un contexto formal a partir de listas de objetos, atributos y
|
|
28
|
+
* la lista bruta de incidencias.
|
|
29
|
+
*
|
|
30
|
+
* Valida:
|
|
31
|
+
* - Los identificadores no pueden contener el separador '|'.
|
|
32
|
+
* - No se admiten objetos o atributos duplicados.
|
|
33
|
+
* - Cada incidencia [g, m] debe referirse a objetos/atributos declarados.
|
|
34
|
+
*/
|
|
35
|
+
function createContext(objects, attributes, incidence) {
|
|
36
|
+
const objSet = new Set();
|
|
37
|
+
for (const o of objects) {
|
|
38
|
+
if (o.includes(SEP)) {
|
|
39
|
+
throw new Error(`createContext: objeto "${o}" contiene el separador reservado "${SEP}"`);
|
|
40
|
+
}
|
|
41
|
+
if (objSet.has(o)) {
|
|
42
|
+
throw new Error(`createContext: objeto duplicado "${o}"`);
|
|
43
|
+
}
|
|
44
|
+
objSet.add(o);
|
|
45
|
+
}
|
|
46
|
+
const attrSet = new Set();
|
|
47
|
+
for (const a of attributes) {
|
|
48
|
+
if (a.includes(SEP)) {
|
|
49
|
+
throw new Error(`createContext: atributo "${a}" contiene el separador reservado "${SEP}"`);
|
|
50
|
+
}
|
|
51
|
+
if (attrSet.has(a)) {
|
|
52
|
+
throw new Error(`createContext: atributo duplicado "${a}"`);
|
|
53
|
+
}
|
|
54
|
+
attrSet.add(a);
|
|
55
|
+
}
|
|
56
|
+
const inc = new Set();
|
|
57
|
+
for (const [g, m] of incidence) {
|
|
58
|
+
if (!objSet.has(g)) {
|
|
59
|
+
throw new Error(`createContext: incidencia refiere objeto desconocido "${g}"`);
|
|
60
|
+
}
|
|
61
|
+
if (!attrSet.has(m)) {
|
|
62
|
+
throw new Error(`createContext: incidencia refiere atributo desconocido "${m}"`);
|
|
63
|
+
}
|
|
64
|
+
inc.add(encode(g, m));
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
objects: [...objects],
|
|
68
|
+
attributes: [...attributes],
|
|
69
|
+
incidence: inc,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Indica si el objeto `g` tiene el atributo `m` en el contexto.
|
|
74
|
+
* O(1) gracias a la representación como Set de pares codificados.
|
|
75
|
+
*/
|
|
76
|
+
function hasIncidence(ctx, g, m) {
|
|
77
|
+
return ctx.incidence.has(encode(g, m));
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Operador polar B → B' (atributos → objetos).
|
|
81
|
+
* Devuelve el conjunto de objetos que poseen TODOS los atributos de `attrs`.
|
|
82
|
+
* Si `attrs` es vacío, el resultado es G (convención: ∀ trivialmente cierto).
|
|
83
|
+
*/
|
|
84
|
+
function derivativeObjects(ctx, attrs) {
|
|
85
|
+
const out = new Set();
|
|
86
|
+
for (const g of ctx.objects) {
|
|
87
|
+
let ok = true;
|
|
88
|
+
for (const m of attrs) {
|
|
89
|
+
if (!hasIncidence(ctx, g, m)) {
|
|
90
|
+
ok = false;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (ok)
|
|
95
|
+
out.add(g);
|
|
96
|
+
}
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Operador polar A → A' (objetos → atributos).
|
|
101
|
+
* Devuelve los atributos compartidos por TODOS los objetos de `objs`.
|
|
102
|
+
* Si `objs` es vacío, el resultado es M.
|
|
103
|
+
*/
|
|
104
|
+
function derivativeAttributes(ctx, objs) {
|
|
105
|
+
const out = new Set();
|
|
106
|
+
for (const m of ctx.attributes) {
|
|
107
|
+
let ok = true;
|
|
108
|
+
for (const g of objs) {
|
|
109
|
+
if (!hasIncidence(ctx, g, m)) {
|
|
110
|
+
ok = false;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (ok)
|
|
115
|
+
out.add(m);
|
|
116
|
+
}
|
|
117
|
+
return out;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Verifica si (extent, intent) es un concepto formal en `ctx`:
|
|
121
|
+
* extent' = intent y intent' = extent.
|
|
122
|
+
*
|
|
123
|
+
* Equivale a verificar la doble clausura, pero se computa directo desde la
|
|
124
|
+
* relación de incidencia, sin acumular intermedios.
|
|
125
|
+
*/
|
|
126
|
+
function isConcept(ctx, extent, intent) {
|
|
127
|
+
const intentFromExtent = derivativeAttributes(ctx, extent);
|
|
128
|
+
const extentFromIntent = derivativeObjects(ctx, intent);
|
|
129
|
+
return setsEqual(intentFromExtent, intent) && setsEqual(extentFromIntent, extent);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Clausura de Galois sobre intents: B → B'' = (B')'.
|
|
133
|
+
* Idempotente: closeIntent(closeIntent(B)) = closeIntent(B).
|
|
134
|
+
*/
|
|
135
|
+
function closeIntent(ctx, intent) {
|
|
136
|
+
return derivativeAttributes(ctx, derivativeObjects(ctx, intent));
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Clausura sobre extents: A → A'' = (A')'.
|
|
140
|
+
*/
|
|
141
|
+
function closeExtent(ctx, extent) {
|
|
142
|
+
return derivativeObjects(ctx, derivativeAttributes(ctx, extent));
|
|
143
|
+
}
|
|
144
|
+
// ----------------------------------------------------------------
|
|
145
|
+
// helpers
|
|
146
|
+
// ----------------------------------------------------------------
|
|
147
|
+
function setsEqual(a, b) {
|
|
148
|
+
if (a.size !== b.size)
|
|
149
|
+
return false;
|
|
150
|
+
for (const x of a)
|
|
151
|
+
if (!b.has(x))
|
|
152
|
+
return false;
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/runtime/fca/context.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,kEAAkE;AAClE,+DAA+D;AAC/D,qEAAqE;AACrE,sEAAsE;AACtE,0DAA0D;AAC1D,EAAE;AACF,iEAAiE;AACjE,kEAAkE;AAClE,uEAAuE;AACvE,yCAAyC;AACzC,+DAA+D;;AAmB/D,sCA0CC;AAMD,oCAEC;AAOD,8CAaC;AAOD,oDAaC;AASD,8BAIC;AAMD,kCAEC;AAKD,kCAEC;AArID,MAAM,GAAG,GAAG,GAAG,CAAC;AAEhB,SAAS,MAAM,CAAC,GAAW,EAAE,IAAY;IACvC,OAAO,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,EAAE,CAAC;AAC/B,CAAC;A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AO,KAAK,CAAC;IAC/C,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FormalContext } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Devuelve `true` si en `ctx` la implicación `premise → conclusion` es
|
|
4
|
+
* válida: todo objeto que satisface todos los atributos de `premise`
|
|
5
|
+
* satisface también todos los de `conclusion`.
|
|
6
|
+
*
|
|
7
|
+
* Equivalencia formal: premise → conclusion ⇔ conclusion ⊆ premise''.
|
|
8
|
+
*/
|
|
9
|
+
export declare function impliesAll(ctx: FormalContext, premise: Set<string>, conclusion: Set<string>): boolean;
|
|
10
|
+
//# sourceMappingURL=implications.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implications.d.ts","sourceRoot":"","sources":["../../../src/runtime/fca/implications.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EACpB,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,GACtB,OAAO,CAMT"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// FCA — implicaciones de atributos.
|
|
4
|
+
// ============================================================
|
|
5
|
+
// Una implicación P → C entre subconjuntos de atributos es válida en el
|
|
6
|
+
// contexto K sii todo objeto que tiene todos los atributos de P tiene
|
|
7
|
+
// también todos los atributos de C. Equivale a:
|
|
8
|
+
// P → C válida en K ⇔ C ⊆ P'' (P'' = closeIntent(P))
|
|
9
|
+
// que en términos de extents es: P' ⊆ C'.
|
|
10
|
+
//
|
|
11
|
+
// Esto es la base del cálculo Armstrong/Duquenne-Guigues para bases de
|
|
12
|
+
// implicaciones. Aquí exponemos solo el test de validez puntual; la
|
|
13
|
+
// extracción de la base canónica se deja a un sprint posterior.
|
|
14
|
+
// ============================================================
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.impliesAll = impliesAll;
|
|
17
|
+
const context_1 = require("./context");
|
|
18
|
+
/**
|
|
19
|
+
* Devuelve `true` si en `ctx` la implicación `premise → conclusion` es
|
|
20
|
+
* válida: todo objeto que satisface todos los atributos de `premise`
|
|
21
|
+
* satisface también todos los de `conclusion`.
|
|
22
|
+
*
|
|
23
|
+
* Equivalencia formal: premise → conclusion ⇔ conclusion ⊆ premise''.
|
|
24
|
+
*/
|
|
25
|
+
function impliesAll(ctx, premise, conclusion) {
|
|
26
|
+
const closure = (0, context_1.closeIntent)(ctx, premise);
|
|
27
|
+
for (const m of conclusion) {
|
|
28
|
+
if (!closure.has(m))
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=implications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implications.js","sourceRoot":"","sources":["../../../src/runtime/fca/implications.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,oCAAoC;AACpC,+DAA+D;AAC/D,wEAAwE;AACxE,sEAAsE;AACtE,gDAAgD;AAChD,2DAA2D;AAC3D,0CAA0C;AAC1C,EAAE;AACF,uEAAuE;AACvE,oEAAoE;AACpE,gEAAgE;AAChE,+DAA+D;;AAY/D,gCAUC;AApBD,uCAAwC;AAGxC;;;;;;GAMG;AACH,SAAgB,UAAU,CACxB,GAAkB,EAClB,OAAoB,EACpB,UAAuB;IAEvB,MAAM,OAAO,GAAG,IAAA,qBAAW,EAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1C,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;IACpC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { FormalContext, FormalConcept, HasseLattice } from './types';
|
|
2
|
+
export { createContext, derivativeObjects, derivativeAttributes, isConcept, closeIntent, closeExtent, hasIncidence, } from './context';
|
|
3
|
+
export { allConcepts } from './next-closure';
|
|
4
|
+
export { lattice } from './lattice';
|
|
5
|
+
export { impliesAll } from './implications';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/fca/index.ts"],"names":[],"mappings":"AAsBA,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,GACb,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// ST Formal Concept Analysis — barrel público.
|
|
4
|
+
// ============================================================
|
|
5
|
+
// Marco matemático (Wille 1982, Ganter & Wille 1999) para extraer un
|
|
6
|
+
// retículo de conceptos a partir de una relación binaria objeto-atributo.
|
|
7
|
+
//
|
|
8
|
+
// API mínima:
|
|
9
|
+
// createContext(G, M, I) → FormalContext
|
|
10
|
+
// derivativeObjects(K, B) → B' (objetos)
|
|
11
|
+
// derivativeAttributes(K, A) → A' (atributos)
|
|
12
|
+
// isConcept(K, A, B) → (A, B) ∈ B(K)?
|
|
13
|
+
// closeIntent(K, B) → B'' (clausura Galois sobre atributos)
|
|
14
|
+
// allConcepts(K) → todos los conceptos (Next Closure)
|
|
15
|
+
// lattice(concepts) → diagrama de Hasse (aristas cobertura)
|
|
16
|
+
// impliesAll(K, P, C) → ¿P → C válida en K?
|
|
17
|
+
//
|
|
18
|
+
// Uso típico:
|
|
19
|
+
// const K = createContext(objs, attrs, pairs);
|
|
20
|
+
// const concepts = allConcepts(K);
|
|
21
|
+
// const hasse = lattice(concepts);
|
|
22
|
+
// ============================================================
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.impliesAll = exports.lattice = exports.allConcepts = exports.hasIncidence = exports.closeExtent = exports.closeIntent = exports.isConcept = exports.derivativeAttributes = exports.derivativeObjects = exports.createContext = void 0;
|
|
25
|
+
var context_1 = require("./context");
|
|
26
|
+
Object.defineProperty(exports, "createContext", { enumerable: true, get: function () { return context_1.createContext; } });
|
|
27
|
+
Object.defineProperty(exports, "derivativeObjects", { enumerable: true, get: function () { return context_1.derivativeObjects; } });
|
|
28
|
+
Object.defineProperty(exports, "derivativeAttributes", { enumerable: true, get: function () { return context_1.derivativeAttributes; } });
|
|
29
|
+
Object.defineProperty(exports, "isConcept", { enumerable: true, get: function () { return context_1.isConcept; } });
|
|
30
|
+
Object.defineProperty(exports, "closeIntent", { enumerable: true, get: function () { return context_1.closeIntent; } });
|
|
31
|
+
Object.defineProperty(exports, "closeExtent", { enumerable: true, get: function () { return context_1.closeExtent; } });
|
|
32
|
+
Object.defineProperty(exports, "hasIncidence", { enumerable: true, get: function () { return context_1.hasIncidence; } });
|
|
33
|
+
var next_closure_1 = require("./next-closure");
|
|
34
|
+
Object.defineProperty(exports, "allConcepts", { enumerable: true, get: function () { return next_closure_1.allConcepts; } });
|
|
35
|
+
var lattice_1 = require("./lattice");
|
|
36
|
+
Object.defineProperty(exports, "lattice", { enumerable: true, get: function () { return lattice_1.lattice; } });
|
|
37
|
+
var implications_1 = require("./implications");
|
|
38
|
+
Object.defineProperty(exports, "impliesAll", { enumerable: true, get: function () { return implications_1.impliesAll; } });
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/fca/index.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,+CAA+C;AAC/C,+DAA+D;AAC/D,qEAAqE;AACrE,0EAA0E;AAC1E,EAAE;AACF,cAAc;AACd,kDAAkD;AAClD,mDAAmD;AACnD,qDAAqD;AACrD,mDAAmD;AACnD,2EAA2E;AAC3E,uEAAuE;AACvE,0EAA0E;AAC1E,wDAAwD;AACxD,EAAE;AACF,cAAc;AACd,iDAAiD;AACjD,qCAAqC;AACrC,qCAAqC;AACrC,+DAA+D;;;AAG/D,qCAQmB;AAPjB,wGAAA,aAAa,OAAA;AACb,4GAAA,iBAAiB,OAAA;AACjB,+GAAA,oBAAoB,OAAA;AACpB,oGAAA,SAAS,OAAA;AACT,sGAAA,WAAW,OAAA;AACX,sGAAA,WAAW,OAAA;AACX,uGAAA,YAAY,OAAA;AAEd,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,+CAA4C;AAAnC,0GAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FormalConcept, HasseLattice } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Computa el diagrama de Hasse del concept lattice como lista de aristas
|
|
4
|
+
* de cobertura `[child, parent]` (índices en `concepts`).
|
|
5
|
+
*
|
|
6
|
+
* La orientación es de "específico" a "general":
|
|
7
|
+
* `[i, j]` significa `extent_i ⊊ extent_j` y la inclusión es inmediata.
|
|
8
|
+
*/
|
|
9
|
+
export declare function lattice(concepts: FormalConcept[]): HasseLattice;
|
|
10
|
+
//# sourceMappingURL=lattice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lattice.d.ts","sourceRoot":"","sources":["../../../src/runtime/fca/lattice.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAY3D;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,YAAY,CAyC/D"}
|