@stevenvo780/st-lang 4.12.0 → 4.14.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.
Files changed (97) hide show
  1. package/dist/reasoning/datalog/index.d.ts +131 -0
  2. package/dist/reasoning/datalog/index.d.ts.map +1 -0
  3. package/dist/reasoning/datalog/index.js +706 -0
  4. package/dist/reasoning/datalog/index.js.map +1 -0
  5. package/dist/reasoning/galois-fields/index.d.ts +29 -0
  6. package/dist/reasoning/galois-fields/index.d.ts.map +1 -0
  7. package/dist/reasoning/galois-fields/index.js +522 -0
  8. package/dist/reasoning/galois-fields/index.js.map +1 -0
  9. package/dist/reasoning/hoare-logic/index.d.ts +130 -0
  10. package/dist/reasoning/hoare-logic/index.d.ts.map +1 -0
  11. package/dist/reasoning/hoare-logic/index.js +535 -0
  12. package/dist/reasoning/hoare-logic/index.js.map +1 -0
  13. package/dist/reasoning/lattice/index.d.ts +165 -0
  14. package/dist/reasoning/lattice/index.d.ts.map +1 -0
  15. package/dist/reasoning/lattice/index.js +587 -0
  16. package/dist/reasoning/lattice/index.js.map +1 -0
  17. package/dist/reasoning/model-checking/index.d.ts +113 -0
  18. package/dist/reasoning/model-checking/index.d.ts.map +1 -0
  19. package/dist/reasoning/model-checking/index.js +786 -0
  20. package/dist/reasoning/model-checking/index.js.map +1 -0
  21. package/dist/reasoning/polynomial-ring/index.d.ts +30 -0
  22. package/dist/reasoning/polynomial-ring/index.d.ts.map +1 -0
  23. package/dist/reasoning/polynomial-ring/index.js +797 -0
  24. package/dist/reasoning/polynomial-ring/index.js.map +1 -0
  25. package/dist/reasoning/separation-logic/index.d.ts +190 -0
  26. package/dist/reasoning/separation-logic/index.d.ts.map +1 -0
  27. package/dist/reasoning/separation-logic/index.js +758 -0
  28. package/dist/reasoning/separation-logic/index.js.map +1 -0
  29. package/dist/reasoning/universal-algebra/index.d.ts +196 -0
  30. package/dist/reasoning/universal-algebra/index.d.ts.map +1 -0
  31. package/dist/reasoning/universal-algebra/index.js +865 -0
  32. package/dist/reasoning/universal-algebra/index.js.map +1 -0
  33. package/dist/tests/reasoning/datalog/datalog.test.d.ts +2 -0
  34. package/dist/tests/reasoning/datalog/datalog.test.d.ts.map +1 -0
  35. package/dist/tests/reasoning/datalog/datalog.test.js +333 -0
  36. package/dist/tests/reasoning/datalog/datalog.test.js.map +1 -0
  37. package/dist/tests/reasoning/galois-fields/galois-fields.test.d.ts +2 -0
  38. package/dist/tests/reasoning/galois-fields/galois-fields.test.d.ts.map +1 -0
  39. package/dist/tests/reasoning/galois-fields/galois-fields.test.js +226 -0
  40. package/dist/tests/reasoning/galois-fields/galois-fields.test.js.map +1 -0
  41. package/dist/tests/reasoning/hoare-logic/hoare-logic.test.d.ts +2 -0
  42. package/dist/tests/reasoning/hoare-logic/hoare-logic.test.d.ts.map +1 -0
  43. package/dist/tests/reasoning/hoare-logic/hoare-logic.test.js +340 -0
  44. package/dist/tests/reasoning/hoare-logic/hoare-logic.test.js.map +1 -0
  45. package/dist/tests/reasoning/lattice/lattice.test.d.ts +2 -0
  46. package/dist/tests/reasoning/lattice/lattice.test.d.ts.map +1 -0
  47. package/dist/tests/reasoning/lattice/lattice.test.js +238 -0
  48. package/dist/tests/reasoning/lattice/lattice.test.js.map +1 -0
  49. package/dist/tests/reasoning/model-checking/model-checking.test.d.ts +2 -0
  50. package/dist/tests/reasoning/model-checking/model-checking.test.d.ts.map +1 -0
  51. package/dist/tests/reasoning/model-checking/model-checking.test.js +222 -0
  52. package/dist/tests/reasoning/model-checking/model-checking.test.js.map +1 -0
  53. package/dist/tests/reasoning/polynomial-ring/polynomial-ring.test.d.ts +2 -0
  54. package/dist/tests/reasoning/polynomial-ring/polynomial-ring.test.d.ts.map +1 -0
  55. package/dist/tests/reasoning/polynomial-ring/polynomial-ring.test.js +230 -0
  56. package/dist/tests/reasoning/polynomial-ring/polynomial-ring.test.js.map +1 -0
  57. package/dist/tests/reasoning/separation-logic/separation-logic.test.d.ts +2 -0
  58. package/dist/tests/reasoning/separation-logic/separation-logic.test.d.ts.map +1 -0
  59. package/dist/tests/reasoning/separation-logic/separation-logic.test.js +311 -0
  60. package/dist/tests/reasoning/separation-logic/separation-logic.test.js.map +1 -0
  61. package/dist/tests/reasoning/universal-algebra/universal-algebra.test.d.ts +2 -0
  62. package/dist/tests/reasoning/universal-algebra/universal-algebra.test.d.ts.map +1 -0
  63. package/dist/tests/reasoning/universal-algebra/universal-algebra.test.js +289 -0
  64. package/dist/tests/reasoning/universal-algebra/universal-algebra.test.js.map +1 -0
  65. package/dist/tests/type-theory/lambda-cube/lambda-cube.test.d.ts +2 -0
  66. package/dist/tests/type-theory/lambda-cube/lambda-cube.test.d.ts.map +1 -0
  67. package/dist/tests/type-theory/lambda-cube/lambda-cube.test.js +266 -0
  68. package/dist/tests/type-theory/lambda-cube/lambda-cube.test.js.map +1 -0
  69. package/dist/type-theory/lambda-cube/erase.d.ts +26 -0
  70. package/dist/type-theory/lambda-cube/erase.d.ts.map +1 -0
  71. package/dist/type-theory/lambda-cube/erase.js +68 -0
  72. package/dist/type-theory/lambda-cube/erase.js.map +1 -0
  73. package/dist/type-theory/lambda-cube/examples.d.ts +59 -0
  74. package/dist/type-theory/lambda-cube/examples.d.ts.map +1 -0
  75. package/dist/type-theory/lambda-cube/examples.js +110 -0
  76. package/dist/type-theory/lambda-cube/examples.js.map +1 -0
  77. package/dist/type-theory/lambda-cube/index.d.ts +11 -0
  78. package/dist/type-theory/lambda-cube/index.d.ts.map +1 -0
  79. package/dist/type-theory/lambda-cube/index.js +64 -0
  80. package/dist/type-theory/lambda-cube/index.js.map +1 -0
  81. package/dist/type-theory/lambda-cube/normalize.d.ts +17 -0
  82. package/dist/type-theory/lambda-cube/normalize.d.ts.map +1 -0
  83. package/dist/type-theory/lambda-cube/normalize.js +134 -0
  84. package/dist/type-theory/lambda-cube/normalize.js.map +1 -0
  85. package/dist/type-theory/lambda-cube/rules.d.ts +26 -0
  86. package/dist/type-theory/lambda-cube/rules.d.ts.map +1 -0
  87. package/dist/type-theory/lambda-cube/rules.js +67 -0
  88. package/dist/type-theory/lambda-cube/rules.js.map +1 -0
  89. package/dist/type-theory/lambda-cube/typecheck.d.ts +20 -0
  90. package/dist/type-theory/lambda-cube/typecheck.d.ts.map +1 -0
  91. package/dist/type-theory/lambda-cube/typecheck.js +168 -0
  92. package/dist/type-theory/lambda-cube/typecheck.js.map +1 -0
  93. package/dist/type-theory/lambda-cube/types.d.ts +40 -0
  94. package/dist/type-theory/lambda-cube/types.d.ts.map +1 -0
  95. package/dist/type-theory/lambda-cube/types.js +192 -0
  96. package/dist/type-theory/lambda-cube/types.js.map +1 -0
  97. package/package.json +1 -1
@@ -0,0 +1,587 @@
1
+ "use strict";
2
+ /**
3
+ * Finite lattice theory.
4
+ *
5
+ * A lattice is a poset (P, ≤) in which every pair of elements has both
6
+ * a least upper bound (join, ∨) and a greatest lower bound (meet, ∧).
7
+ *
8
+ * This module focuses on **finite** lattices: given the carrier set and
9
+ * a `leq` predicate, we derive join/meet exhaustively (O(n^3) per pair
10
+ * via direct search). That is enough for the structural checks
11
+ * downstream — distributivity, modularity, complementation, Heyting
12
+ * implication — which are themselves O(n^3) or O(n^4) and not meant
13
+ * for n ≫ 100.
14
+ *
15
+ * Notable theorems used:
16
+ * - Dedekind: a lattice is **modular** iff it has no sublattice
17
+ * isomorphic to the pentagon N5.
18
+ * - Birkhoff: a lattice is **distributive** iff it has no sublattice
19
+ * isomorphic to N5 *or* to the diamond M3.
20
+ *
21
+ * Equality of carrier elements is decided by *antisymmetry of leq*:
22
+ * `a === b` whenever `leq(a,b) && leq(b,a)`. This lets callers use
23
+ * structural elements like `Set<string>` without supplying their own
24
+ * equality predicate.
25
+ */
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports._indexOfElement = void 0;
28
+ exports.isLattice = isLattice;
29
+ exports.makeLattice = makeLattice;
30
+ exports.isDistributive = isDistributive;
31
+ exports.isModular = isModular;
32
+ exports.complement = complement;
33
+ exports.isComplemented = isComplemented;
34
+ exports.isBoolean = isBoolean;
35
+ exports.relativeComplement = relativeComplement;
36
+ exports.isHeyting = isHeyting;
37
+ exports.atoms = atoms;
38
+ exports.coatoms = coatoms;
39
+ exports.containsPentagon = containsPentagon;
40
+ exports.containsDiamond = containsDiamond;
41
+ exports.dedekindAnalysis = dedekindAnalysis;
42
+ exports.powerSetLattice = powerSetLattice;
43
+ exports.divisibilityLattice = divisibilityLattice;
44
+ exports.chain = chain;
45
+ exports.pentagonN5 = pentagonN5;
46
+ exports.diamondM3 = diamondM3;
47
+ const eq = (leq, a, b) => leq(a, b) && leq(b, a);
48
+ const indexOf = (L, x) => {
49
+ for (let i = 0; i < L.elements.length; i++) {
50
+ if (eq(L.leq, L.elements[i], x))
51
+ return i;
52
+ }
53
+ return -1;
54
+ };
55
+ exports._indexOfElement = indexOf;
56
+ /**
57
+ * Compute least upper bound of a,b within `elements` under `leq`,
58
+ * or null if it does not exist or is not unique.
59
+ */
60
+ function computeJoin(elements, leq, a, b) {
61
+ const upper = [];
62
+ for (const x of elements) {
63
+ if (leq(a, x) && leq(b, x))
64
+ upper.push(x);
65
+ }
66
+ if (upper.length === 0)
67
+ return null;
68
+ // Find unique minimum of `upper` under leq.
69
+ let candidate = null;
70
+ for (const u of upper) {
71
+ if (upper.every((v) => leq(u, v))) {
72
+ if (candidate !== null && !eq(leq, candidate, u))
73
+ return null;
74
+ candidate = u;
75
+ }
76
+ }
77
+ return candidate;
78
+ }
79
+ function computeMeet(elements, leq, a, b) {
80
+ const lower = [];
81
+ for (const x of elements) {
82
+ if (leq(x, a) && leq(x, b))
83
+ lower.push(x);
84
+ }
85
+ if (lower.length === 0)
86
+ return null;
87
+ let candidate = null;
88
+ for (const u of lower) {
89
+ if (lower.every((v) => leq(v, u))) {
90
+ if (candidate !== null && !eq(leq, candidate, u))
91
+ return null;
92
+ candidate = u;
93
+ }
94
+ }
95
+ return candidate;
96
+ }
97
+ /**
98
+ * Check that (elements, leq) forms a lattice: poset axioms plus
99
+ * existence of join/meet for every pair.
100
+ */
101
+ function isLattice(elements, leq) {
102
+ // Reflexivity
103
+ for (const a of elements)
104
+ if (!leq(a, a))
105
+ return false;
106
+ // Antisymmetry (assuming elements are pairwise distinct under === or
107
+ // under structural identity provided by the caller).
108
+ for (let i = 0; i < elements.length; i++) {
109
+ for (let j = i + 1; j < elements.length; j++) {
110
+ const a = elements[i];
111
+ const b = elements[j];
112
+ if (leq(a, b) && leq(b, a))
113
+ return false;
114
+ }
115
+ }
116
+ // Transitivity
117
+ for (const a of elements) {
118
+ for (const b of elements) {
119
+ for (const c of elements) {
120
+ if (leq(a, b) && leq(b, c) && !leq(a, c))
121
+ return false;
122
+ }
123
+ }
124
+ }
125
+ // Join + meet existence
126
+ for (const a of elements) {
127
+ for (const b of elements) {
128
+ if (computeJoin(elements, leq, a, b) === null)
129
+ return false;
130
+ if (computeMeet(elements, leq, a, b) === null)
131
+ return false;
132
+ }
133
+ }
134
+ return true;
135
+ }
136
+ /**
137
+ * Build a FiniteLattice from carrier + order. Returns null if the
138
+ * structure is not a lattice (missing/non-unique join or meet, or
139
+ * the order itself is malformed).
140
+ */
141
+ function makeLattice(elements, leq) {
142
+ if (elements.length === 0)
143
+ return null;
144
+ if (!isLattice(elements, leq))
145
+ return null;
146
+ const els = elements.slice();
147
+ const joinTable = new Map();
148
+ const meetTable = new Map();
149
+ for (let i = 0; i < els.length; i++) {
150
+ for (let j = 0; j < els.length; j++) {
151
+ const a = els[i];
152
+ const b = els[j];
153
+ const j2 = computeJoin(els, leq, a, b);
154
+ const m2 = computeMeet(els, leq, a, b);
155
+ if (j2 === null || m2 === null)
156
+ return null;
157
+ joinTable.set(`${i}|${j}`, j2);
158
+ meetTable.set(`${i}|${j}`, m2);
159
+ }
160
+ }
161
+ const lookup = (x) => {
162
+ for (let i = 0; i < els.length; i++) {
163
+ if (eq(leq, els[i], x))
164
+ return i;
165
+ }
166
+ return -1;
167
+ };
168
+ const join = (a, b) => {
169
+ const i = lookup(a);
170
+ const j = lookup(b);
171
+ if (i < 0 || j < 0)
172
+ throw new Error('join: element not in lattice');
173
+ return joinTable.get(`${i}|${j}`);
174
+ };
175
+ const meet = (a, b) => {
176
+ const i = lookup(a);
177
+ const j = lookup(b);
178
+ if (i < 0 || j < 0)
179
+ throw new Error('meet: element not in lattice');
180
+ return meetTable.get(`${i}|${j}`);
181
+ };
182
+ // Top: an element ≥ every element.
183
+ let top = null;
184
+ for (const t of els) {
185
+ if (els.every((x) => leq(x, t))) {
186
+ top = t;
187
+ break;
188
+ }
189
+ }
190
+ let bottom = null;
191
+ for (const t of els) {
192
+ if (els.every((x) => leq(t, x))) {
193
+ bottom = t;
194
+ break;
195
+ }
196
+ }
197
+ if (top === null || bottom === null)
198
+ return null;
199
+ return {
200
+ elements: els,
201
+ leq,
202
+ join,
203
+ meet,
204
+ top,
205
+ bottom,
206
+ };
207
+ }
208
+ /**
209
+ * Distributive: a ∧ (b ∨ c) = (a ∧ b) ∨ (a ∧ c) for all a,b,c.
210
+ */
211
+ function isDistributive(L) {
212
+ for (const a of L.elements) {
213
+ for (const b of L.elements) {
214
+ for (const c of L.elements) {
215
+ const lhs = L.meet(a, L.join(b, c));
216
+ const rhs = L.join(L.meet(a, b), L.meet(a, c));
217
+ if (!eq(L.leq, lhs, rhs))
218
+ return false;
219
+ }
220
+ }
221
+ }
222
+ return true;
223
+ }
224
+ /**
225
+ * Modular: a ≤ c ⇒ a ∨ (b ∧ c) = (a ∨ b) ∧ c.
226
+ */
227
+ function isModular(L) {
228
+ for (const a of L.elements) {
229
+ for (const b of L.elements) {
230
+ for (const c of L.elements) {
231
+ if (!L.leq(a, c))
232
+ continue;
233
+ const lhs = L.join(a, L.meet(b, c));
234
+ const rhs = L.meet(L.join(a, b), c);
235
+ if (!eq(L.leq, lhs, rhs))
236
+ return false;
237
+ }
238
+ }
239
+ }
240
+ return true;
241
+ }
242
+ /**
243
+ * Find a complement of `a`: some x with a ∨ x = ⊤ and a ∧ x = ⊥.
244
+ * Returns the first match (lattice may have multiple), or null.
245
+ */
246
+ function complement(L, a) {
247
+ for (const x of L.elements) {
248
+ if (eq(L.leq, L.join(a, x), L.top) && eq(L.leq, L.meet(a, x), L.bottom)) {
249
+ return x;
250
+ }
251
+ }
252
+ return null;
253
+ }
254
+ /**
255
+ * Complemented: every element has at least one complement.
256
+ */
257
+ function isComplemented(L) {
258
+ for (const a of L.elements) {
259
+ if (complement(L, a) === null)
260
+ return false;
261
+ }
262
+ return true;
263
+ }
264
+ /**
265
+ * Boolean lattice: distributive + complemented.
266
+ * In finite Boolean lattices, complements are automatically unique.
267
+ */
268
+ function isBoolean(L) {
269
+ return isDistributive(L) && isComplemented(L);
270
+ }
271
+ /**
272
+ * Relative pseudo-complement of `a` with respect to `b`: the largest
273
+ * x such that a ∧ x ≤ b. Equivalently the Heyting implication a ⇒ b.
274
+ * Returns null if no largest x exists.
275
+ */
276
+ function relativeComplement(L, a, b) {
277
+ const candidates = [];
278
+ for (const x of L.elements) {
279
+ if (L.leq(L.meet(a, x), b))
280
+ candidates.push(x);
281
+ }
282
+ if (candidates.length === 0)
283
+ return null;
284
+ let max = null;
285
+ for (const u of candidates) {
286
+ if (candidates.every((v) => L.leq(v, u))) {
287
+ if (max !== null && !eq(L.leq, max, u))
288
+ return null;
289
+ max = u;
290
+ }
291
+ }
292
+ return max;
293
+ }
294
+ /**
295
+ * Heyting algebra: distributive lattice in which every pair (a,b)
296
+ * has a relative pseudo-complement a ⇒ b.
297
+ *
298
+ * In finite lattices, distributivity is equivalent to existence of
299
+ * relative pseudo-complements, so any finite distributive lattice is
300
+ * automatically Heyting. We still check both for clarity.
301
+ */
302
+ function isHeyting(L) {
303
+ if (!isDistributive(L))
304
+ return false;
305
+ for (const a of L.elements) {
306
+ for (const b of L.elements) {
307
+ if (relativeComplement(L, a, b) === null)
308
+ return false;
309
+ }
310
+ }
311
+ return true;
312
+ }
313
+ /**
314
+ * Atoms: elements that cover ⊥ (i.e. ⊥ < a with no element strictly
315
+ * between).
316
+ */
317
+ function atoms(L) {
318
+ const res = [];
319
+ for (const a of L.elements) {
320
+ if (eq(L.leq, a, L.bottom))
321
+ continue;
322
+ let covers = true;
323
+ for (const x of L.elements) {
324
+ if (eq(L.leq, x, L.bottom) || eq(L.leq, x, a))
325
+ continue;
326
+ if (L.leq(L.bottom, x) && L.leq(x, a)) {
327
+ covers = false;
328
+ break;
329
+ }
330
+ }
331
+ if (covers)
332
+ res.push(a);
333
+ }
334
+ return res;
335
+ }
336
+ /**
337
+ * Coatoms: elements covered by ⊤.
338
+ */
339
+ function coatoms(L) {
340
+ const res = [];
341
+ for (const a of L.elements) {
342
+ if (eq(L.leq, a, L.top))
343
+ continue;
344
+ let covers = true;
345
+ for (const x of L.elements) {
346
+ if (eq(L.leq, x, L.top) || eq(L.leq, x, a))
347
+ continue;
348
+ if (L.leq(a, x) && L.leq(x, L.top)) {
349
+ covers = false;
350
+ break;
351
+ }
352
+ }
353
+ if (covers)
354
+ res.push(a);
355
+ }
356
+ return res;
357
+ }
358
+ /**
359
+ * Detect a sublattice isomorphic to the pentagon N5.
360
+ *
361
+ * N5 is the 5-element lattice on {⊥, a, b, c, ⊤} with:
362
+ * - ⊥ < a < c < ⊤ (a chain of length 3)
363
+ * - ⊥ < b < ⊤ (b incomparable to both a and c)
364
+ * - a ∧ b = ⊥, a ∨ b = ⊤, c ∧ b = ⊥, c ∨ b = ⊤.
365
+ *
366
+ * Equivalent to: there exist 5 distinct elements x0 < x1 < x2 and y,
367
+ * with y incomparable to x1 and to x2 minus x0, top = x2 ∨ y,
368
+ * bottom = x0 ∧ y, and y ∨ x1 = y ∨ x2, y ∧ x1 = y ∧ x2.
369
+ */
370
+ function containsPentagon(L) {
371
+ const els = L.elements;
372
+ for (const x0 of els) {
373
+ for (const x1 of els) {
374
+ // Strict x0 < x1.
375
+ if (eq(L.leq, x0, x1) || !L.leq(x0, x1))
376
+ continue;
377
+ for (const x2 of els) {
378
+ // Strict x1 < x2.
379
+ if (eq(L.leq, x1, x2) || !L.leq(x1, x2))
380
+ continue;
381
+ for (const y of els) {
382
+ // y distinct from x0, x1, x2 and incomparable to x1 and x2.
383
+ if (eq(L.leq, y, x0) ||
384
+ eq(L.leq, y, x1) ||
385
+ eq(L.leq, y, x2) ||
386
+ L.leq(y, x1) ||
387
+ L.leq(x1, y) ||
388
+ L.leq(y, x2) ||
389
+ L.leq(x2, y)) {
390
+ continue;
391
+ }
392
+ // Check N5 closure:
393
+ // y ∧ x1 = y ∧ x2 = x0
394
+ // y ∨ x1 = y ∨ x2 (this is the pentagon's top)
395
+ const m1 = L.meet(y, x1);
396
+ const m2 = L.meet(y, x2);
397
+ const j1 = L.join(y, x1);
398
+ const j2 = L.join(y, x2);
399
+ if (eq(L.leq, m1, x0) && eq(L.leq, m2, x0) && eq(L.leq, j1, j2)) {
400
+ return true;
401
+ }
402
+ }
403
+ }
404
+ }
405
+ }
406
+ return false;
407
+ }
408
+ /**
409
+ * Detect a sublattice isomorphic to the diamond M3.
410
+ *
411
+ * M3 is the 5-element lattice with one bottom, one top, and three
412
+ * mutually incomparable elements between, each pair joining to ⊤
413
+ * and meeting to ⊥.
414
+ */
415
+ function containsDiamond(L) {
416
+ const els = L.elements;
417
+ for (let i = 0; i < els.length; i++) {
418
+ for (let j = i + 1; j < els.length; j++) {
419
+ for (let k = j + 1; k < els.length; k++) {
420
+ const a = els[i];
421
+ const b = els[j];
422
+ const c = els[k];
423
+ // pairwise incomparable
424
+ if (L.leq(a, b) || L.leq(b, a))
425
+ continue;
426
+ if (L.leq(a, c) || L.leq(c, a))
427
+ continue;
428
+ if (L.leq(b, c) || L.leq(c, b))
429
+ continue;
430
+ const jab = L.join(a, b);
431
+ const jac = L.join(a, c);
432
+ const jbc = L.join(b, c);
433
+ const mab = L.meet(a, b);
434
+ const mac = L.meet(a, c);
435
+ const mbc = L.meet(b, c);
436
+ if (!eq(L.leq, jab, jac) || !eq(L.leq, jac, jbc))
437
+ continue;
438
+ if (!eq(L.leq, mab, mac) || !eq(L.leq, mac, mbc))
439
+ continue;
440
+ // join must be strictly above each, meet strictly below.
441
+ if (eq(L.leq, jab, a) || eq(L.leq, jab, b) || eq(L.leq, jab, c))
442
+ continue;
443
+ if (eq(L.leq, mab, a) || eq(L.leq, mab, b) || eq(L.leq, mab, c))
444
+ continue;
445
+ return true;
446
+ }
447
+ }
448
+ }
449
+ return false;
450
+ }
451
+ /**
452
+ * Dedekind / Birkhoff structural analysis. By the two classical
453
+ * theorems:
454
+ * modular ⇔ pentagon-free
455
+ * distributive ⇔ pentagon-free AND diamond-free
456
+ * We compute both algebraically and by sublattice search; the result
457
+ * agrees on well-formed finite lattices.
458
+ */
459
+ function dedekindAnalysis(L) {
460
+ const pentagonFree = !containsPentagon(L);
461
+ const diamondFree = !containsDiamond(L);
462
+ // We rely on the algebraic checks as the source of truth; the
463
+ // sublattice flags are reported alongside for diagnostic use.
464
+ return {
465
+ distributive: isDistributive(L),
466
+ modular: isModular(L),
467
+ pentagonFree,
468
+ diamondFree,
469
+ };
470
+ }
471
+ // ---------------------------------------------------------------------------
472
+ // Pre-built lattices
473
+ // ---------------------------------------------------------------------------
474
+ /**
475
+ * Power set lattice 2^S ordered by inclusion. For |S|=n this has
476
+ * 2^n elements; keep n small (≤ 6).
477
+ */
478
+ function powerSetLattice(baseElements) {
479
+ const base = Array.from(new Set(baseElements));
480
+ const n = base.length;
481
+ const subsets = [];
482
+ for (let mask = 0; mask < 1 << n; mask++) {
483
+ const s = new Set();
484
+ for (let i = 0; i < n; i++) {
485
+ if (mask & (1 << i))
486
+ s.add(base[i]);
487
+ }
488
+ subsets.push(s);
489
+ }
490
+ const leq = (a, b) => {
491
+ for (const x of a)
492
+ if (!b.has(x))
493
+ return false;
494
+ return true;
495
+ };
496
+ const L = makeLattice(subsets, leq);
497
+ if (L === null)
498
+ throw new Error('powerSetLattice: failed to build');
499
+ return L;
500
+ }
501
+ /**
502
+ * Divisors of n ordered by divisibility. (Lattice for any positive n.)
503
+ */
504
+ function divisibilityLattice(n) {
505
+ if (!Number.isInteger(n) || n < 1) {
506
+ throw new Error('divisibilityLattice: n must be a positive integer');
507
+ }
508
+ const divs = [];
509
+ for (let d = 1; d <= n; d++) {
510
+ if (n % d === 0)
511
+ divs.push(d);
512
+ }
513
+ const leq = (a, b) => b % a === 0;
514
+ const L = makeLattice(divs, leq);
515
+ if (L === null)
516
+ throw new Error('divisibilityLattice: failed to build');
517
+ return L;
518
+ }
519
+ /**
520
+ * Chain of n elements 0 < 1 < ... < n-1.
521
+ */
522
+ function chain(n) {
523
+ if (!Number.isInteger(n) || n < 1) {
524
+ throw new Error('chain: n must be ≥ 1');
525
+ }
526
+ const els = [];
527
+ for (let i = 0; i < n; i++)
528
+ els.push(i);
529
+ const leq = (a, b) => a <= b;
530
+ const L = makeLattice(els, leq);
531
+ if (L === null)
532
+ throw new Error('chain: failed to build');
533
+ return L;
534
+ }
535
+ /**
536
+ * Pentagon N5: the classical non-modular 5-element lattice.
537
+ *
538
+ * Hasse diagram:
539
+ * T
540
+ * / \
541
+ * c b
542
+ * | |
543
+ * a |
544
+ * \ /
545
+ * B
546
+ */
547
+ function pentagonN5() {
548
+ const els = ['B', 'a', 'c', 'b', 'T'];
549
+ const order = {
550
+ B: ['B', 'a', 'c', 'b', 'T'],
551
+ a: ['a', 'c', 'T'],
552
+ c: ['c', 'T'],
553
+ b: ['b', 'T'],
554
+ T: ['T'],
555
+ };
556
+ const leq = (x, y) => (order[x] ?? []).includes(y);
557
+ const L = makeLattice(els, leq);
558
+ if (L === null)
559
+ throw new Error('pentagonN5: failed to build');
560
+ return L;
561
+ }
562
+ /**
563
+ * Diamond M3: modular but not distributive 5-element lattice.
564
+ *
565
+ * Hasse diagram:
566
+ * T
567
+ * / | \
568
+ * a b c
569
+ * \ | /
570
+ * B
571
+ */
572
+ function diamondM3() {
573
+ const els = ['B', 'a', 'b', 'c', 'T'];
574
+ const order = {
575
+ B: ['B', 'a', 'b', 'c', 'T'],
576
+ a: ['a', 'T'],
577
+ b: ['b', 'T'],
578
+ c: ['c', 'T'],
579
+ T: ['T'],
580
+ };
581
+ const leq = (x, y) => (order[x] ?? []).includes(y);
582
+ const L = makeLattice(els, leq);
583
+ if (L === null)
584
+ throw new Error('diamondM3: failed to build');
585
+ return L;
586
+ }
587
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/reasoning/lattice/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAuEH,8BA4BC;AAOD,kCA8DC;AAKD,wCAWC;AAKD,8BAYC;AAMD,gCAOC;AAKD,wCAKC;AAMD,8BAEC;AAOD,gDAcC;AAUD,8BAQC;AAMD,sBAeC;AAKD,0BAeC;AAcD,4CAqCC;AASD,0CA4BC;AAiBD,4CAWC;AAUD,0CAkBC;AAKD,kDAYC;AAKD,sBAUC;AAcD,gCAaC;AAYD,8BAaC;AAjhBD,MAAM,EAAE,GAAG,CAAI,GAA4B,EAAE,CAAI,EAAE,CAAI,EAAW,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE5F,MAAM,OAAO,GAAG,CAAI,CAAmB,EAAE,CAAI,EAAU,EAAE;IACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC,CAAC;AA6gBkB,kCAAe;AA3gBnC;;;GAGG;AACH,SAAS,WAAW,CAClB,QAA0B,EAC1B,GAA4B,EAC5B,CAAI,EACJ,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