@stevenvo780/st-lang 4.11.0 → 4.12.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/proof-systems/fol-prover-advanced/index.d.ts +7 -0
- package/dist/proof-systems/fol-prover-advanced/index.d.ts.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/index.js +34 -0
- package/dist/proof-systems/fol-prover-advanced/index.js.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/ordering.d.ts +34 -0
- package/dist/proof-systems/fol-prover-advanced/ordering.d.ts.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/ordering.js +197 -0
- package/dist/proof-systems/fol-prover-advanced/ordering.js.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/prover.d.ts +22 -0
- package/dist/proof-systems/fol-prover-advanced/prover.d.ts.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/prover.js +219 -0
- package/dist/proof-systems/fol-prover-advanced/prover.js.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/resolve.d.ts +43 -0
- package/dist/proof-systems/fol-prover-advanced/resolve.d.ts.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/resolve.js +297 -0
- package/dist/proof-systems/fol-prover-advanced/resolve.js.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/subsumption.d.ts +28 -0
- package/dist/proof-systems/fol-prover-advanced/subsumption.d.ts.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/subsumption.js +172 -0
- package/dist/proof-systems/fol-prover-advanced/subsumption.js.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/types.d.ts +68 -0
- package/dist/proof-systems/fol-prover-advanced/types.d.ts.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/types.js +12 -0
- package/dist/proof-systems/fol-prover-advanced/types.js.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/unify.d.ts +15 -0
- package/dist/proof-systems/fol-prover-advanced/unify.d.ts.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/unify.js +144 -0
- package/dist/proof-systems/fol-prover-advanced/unify.js.map +1 -0
- package/dist/reasoning/combinatorics/basic-counts.d.ts +6 -0
- package/dist/reasoning/combinatorics/basic-counts.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/basic-counts.js +82 -0
- package/dist/reasoning/combinatorics/basic-counts.js.map +1 -0
- package/dist/reasoning/combinatorics/bigint-helpers.d.ts +5 -0
- package/dist/reasoning/combinatorics/bigint-helpers.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/bigint-helpers.js +8 -0
- package/dist/reasoning/combinatorics/bigint-helpers.js.map +1 -0
- package/dist/reasoning/combinatorics/burnside.d.ts +15 -0
- package/dist/reasoning/combinatorics/burnside.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/burnside.js +91 -0
- package/dist/reasoning/combinatorics/burnside.js.map +1 -0
- package/dist/reasoning/combinatorics/generating-functions.d.ts +12 -0
- package/dist/reasoning/combinatorics/generating-functions.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/generating-functions.js +67 -0
- package/dist/reasoning/combinatorics/generating-functions.js.map +1 -0
- package/dist/reasoning/combinatorics/generators.d.ts +5 -0
- package/dist/reasoning/combinatorics/generators.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/generators.js +111 -0
- package/dist/reasoning/combinatorics/generators.js.map +1 -0
- package/dist/reasoning/combinatorics/inclusion-exclusion.d.ts +8 -0
- package/dist/reasoning/combinatorics/inclusion-exclusion.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/inclusion-exclusion.js +45 -0
- package/dist/reasoning/combinatorics/inclusion-exclusion.js.map +1 -0
- package/dist/reasoning/combinatorics/index.d.ts +10 -0
- package/dist/reasoning/combinatorics/index.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/index.js +44 -0
- package/dist/reasoning/combinatorics/index.js.map +1 -0
- package/dist/reasoning/combinatorics/partitions.d.ts +4 -0
- package/dist/reasoning/combinatorics/partitions.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/partitions.js +90 -0
- package/dist/reasoning/combinatorics/partitions.js.map +1 -0
- package/dist/reasoning/combinatorics/permutations.d.ts +6 -0
- package/dist/reasoning/combinatorics/permutations.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/permutations.js +124 -0
- package/dist/reasoning/combinatorics/permutations.js.map +1 -0
- package/dist/reasoning/combinatorics/set-partitions.d.ts +3 -0
- package/dist/reasoning/combinatorics/set-partitions.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/set-partitions.js +46 -0
- package/dist/reasoning/combinatorics/set-partitions.js.map +1 -0
- package/dist/reasoning/combinatorics/special-numbers.d.ts +7 -0
- package/dist/reasoning/combinatorics/special-numbers.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/special-numbers.js +128 -0
- package/dist/reasoning/combinatorics/special-numbers.js.map +1 -0
- package/dist/reasoning/constructive-analysis/cauchy.d.ts +51 -0
- package/dist/reasoning/constructive-analysis/cauchy.d.ts.map +1 -0
- package/dist/reasoning/constructive-analysis/cauchy.js +77 -0
- package/dist/reasoning/constructive-analysis/cauchy.js.map +1 -0
- package/dist/reasoning/constructive-analysis/compact.d.ts +35 -0
- package/dist/reasoning/constructive-analysis/compact.d.ts.map +1 -0
- package/dist/reasoning/constructive-analysis/compact.js +61 -0
- package/dist/reasoning/constructive-analysis/compact.js.map +1 -0
- package/dist/reasoning/constructive-analysis/continuity.d.ts +62 -0
- package/dist/reasoning/constructive-analysis/continuity.d.ts.map +1 -0
- package/dist/reasoning/constructive-analysis/continuity.js +112 -0
- package/dist/reasoning/constructive-analysis/continuity.js.map +1 -0
- package/dist/reasoning/constructive-analysis/index.d.ts +24 -0
- package/dist/reasoning/constructive-analysis/index.d.ts.map +1 -0
- package/dist/reasoning/constructive-analysis/index.js +36 -0
- package/dist/reasoning/constructive-analysis/index.js.map +1 -0
- package/dist/reasoning/constructive-analysis/integral.d.ts +31 -0
- package/dist/reasoning/constructive-analysis/integral.d.ts.map +1 -0
- package/dist/reasoning/constructive-analysis/integral.js +59 -0
- package/dist/reasoning/constructive-analysis/integral.js.map +1 -0
- package/dist/reasoning/constructive-analysis/ivt.d.ts +41 -0
- package/dist/reasoning/constructive-analysis/ivt.d.ts.map +1 -0
- package/dist/reasoning/constructive-analysis/ivt.js +115 -0
- package/dist/reasoning/constructive-analysis/ivt.js.map +1 -0
- package/dist/reasoning/constructive-reals/index.d.ts +23 -0
- package/dist/reasoning/constructive-reals/index.d.ts.map +1 -1
- package/dist/reasoning/constructive-reals/index.js +52 -1
- package/dist/reasoning/constructive-reals/index.js.map +1 -1
- package/dist/reasoning/linear-algebra/index.d.ts +69 -0
- package/dist/reasoning/linear-algebra/index.d.ts.map +1 -0
- package/dist/reasoning/linear-algebra/index.js +859 -0
- package/dist/reasoning/linear-algebra/index.js.map +1 -0
- package/dist/reasoning/set-theory/hf-functions.d.ts +35 -0
- package/dist/reasoning/set-theory/hf-functions.d.ts.map +1 -0
- package/dist/reasoning/set-theory/hf-functions.js +147 -0
- package/dist/reasoning/set-theory/hf-functions.js.map +1 -0
- package/dist/reasoning/set-theory/hf-sets.d.ts +79 -0
- package/dist/reasoning/set-theory/hf-sets.d.ts.map +1 -0
- package/dist/reasoning/set-theory/hf-sets.js +338 -0
- package/dist/reasoning/set-theory/hf-sets.js.map +1 -0
- package/dist/reasoning/set-theory/index.d.ts +7 -0
- package/dist/reasoning/set-theory/index.d.ts.map +1 -0
- package/dist/reasoning/set-theory/index.js +44 -0
- package/dist/reasoning/set-theory/index.js.map +1 -0
- package/dist/reasoning/set-theory/zfc-axioms.d.ts +59 -0
- package/dist/reasoning/set-theory/zfc-axioms.d.ts.map +1 -0
- package/dist/reasoning/set-theory/zfc-axioms.js +245 -0
- package/dist/reasoning/set-theory/zfc-axioms.js.map +1 -0
- package/dist/tests/proof-systems/fol-prover-advanced/prover.test.d.ts +2 -0
- package/dist/tests/proof-systems/fol-prover-advanced/prover.test.d.ts.map +1 -0
- package/dist/tests/proof-systems/fol-prover-advanced/prover.test.js +253 -0
- package/dist/tests/proof-systems/fol-prover-advanced/prover.test.js.map +1 -0
- package/dist/tests/reasoning/combinatorics/combinatorics.test.d.ts +2 -0
- package/dist/tests/reasoning/combinatorics/combinatorics.test.d.ts.map +1 -0
- package/dist/tests/reasoning/combinatorics/combinatorics.test.js +256 -0
- package/dist/tests/reasoning/combinatorics/combinatorics.test.js.map +1 -0
- package/dist/tests/reasoning/constructive-analysis/constructive-analysis.test.d.ts +2 -0
- package/dist/tests/reasoning/constructive-analysis/constructive-analysis.test.d.ts.map +1 -0
- package/dist/tests/reasoning/constructive-analysis/constructive-analysis.test.js +174 -0
- package/dist/tests/reasoning/constructive-analysis/constructive-analysis.test.js.map +1 -0
- package/dist/tests/reasoning/linear-algebra/linear-algebra.test.d.ts +2 -0
- package/dist/tests/reasoning/linear-algebra/linear-algebra.test.d.ts.map +1 -0
- package/dist/tests/reasoning/linear-algebra/linear-algebra.test.js +369 -0
- package/dist/tests/reasoning/linear-algebra/linear-algebra.test.js.map +1 -0
- package/dist/tests/reasoning/set-theory/hf-functions.test.d.ts +2 -0
- package/dist/tests/reasoning/set-theory/hf-functions.test.d.ts.map +1 -0
- package/dist/tests/reasoning/set-theory/hf-functions.test.js +122 -0
- package/dist/tests/reasoning/set-theory/hf-functions.test.js.map +1 -0
- package/dist/tests/reasoning/set-theory/hf-sets.test.d.ts +2 -0
- package/dist/tests/reasoning/set-theory/hf-sets.test.d.ts.map +1 -0
- package/dist/tests/reasoning/set-theory/hf-sets.test.js +177 -0
- package/dist/tests/reasoning/set-theory/hf-sets.test.js.map +1 -0
- package/dist/tests/reasoning/set-theory/zfc-axioms.test.d.ts +2 -0
- package/dist/tests/reasoning/set-theory/zfc-axioms.test.d.ts.map +1 -0
- package/dist/tests/reasoning/set-theory/zfc-axioms.test.js +56 -0
- package/dist/tests/reasoning/set-theory/zfc-axioms.test.js.map +1 -0
- package/dist/tests/tooling/doc-gen/doc-gen.test.d.ts +2 -0
- package/dist/tests/tooling/doc-gen/doc-gen.test.d.ts.map +1 -0
- package/dist/tests/tooling/doc-gen/doc-gen.test.js +350 -0
- package/dist/tests/tooling/doc-gen/doc-gen.test.js.map +1 -0
- package/dist/tests/tooling/test-harness/test-harness.test.d.ts +2 -0
- package/dist/tests/tooling/test-harness/test-harness.test.d.ts.map +1 -0
- package/dist/tests/tooling/test-harness/test-harness.test.js +208 -0
- package/dist/tests/tooling/test-harness/test-harness.test.js.map +1 -0
- package/dist/tooling/doc-gen/extract.d.ts +13 -0
- package/dist/tooling/doc-gen/extract.d.ts.map +1 -0
- package/dist/tooling/doc-gen/extract.js +379 -0
- package/dist/tooling/doc-gen/extract.js.map +1 -0
- package/dist/tooling/doc-gen/generate.d.ts +9 -0
- package/dist/tooling/doc-gen/generate.d.ts.map +1 -0
- package/dist/tooling/doc-gen/generate.js +116 -0
- package/dist/tooling/doc-gen/generate.js.map +1 -0
- package/dist/tooling/doc-gen/index.d.ts +7 -0
- package/dist/tooling/doc-gen/index.d.ts.map +1 -0
- package/dist/tooling/doc-gen/index.js +39 -0
- package/dist/tooling/doc-gen/index.js.map +1 -0
- package/dist/tooling/doc-gen/jsdoc.d.ts +31 -0
- package/dist/tooling/doc-gen/jsdoc.d.ts.map +1 -0
- package/dist/tooling/doc-gen/jsdoc.js +140 -0
- package/dist/tooling/doc-gen/jsdoc.js.map +1 -0
- package/dist/tooling/doc-gen/render.d.ts +29 -0
- package/dist/tooling/doc-gen/render.d.ts.map +1 -0
- package/dist/tooling/doc-gen/render.js +206 -0
- package/dist/tooling/doc-gen/render.js.map +1 -0
- package/dist/tooling/doc-gen/types.d.ts +51 -0
- package/dist/tooling/doc-gen/types.d.ts.map +1 -0
- package/dist/tooling/doc-gen/types.js +10 -0
- package/dist/tooling/doc-gen/types.js.map +1 -0
- package/dist/tooling/test-harness/combinators.d.ts +14 -0
- package/dist/tooling/test-harness/combinators.d.ts.map +1 -0
- package/dist/tooling/test-harness/combinators.js +122 -0
- package/dist/tooling/test-harness/combinators.js.map +1 -0
- package/dist/tooling/test-harness/coverage.d.ts +3 -0
- package/dist/tooling/test-harness/coverage.d.ts.map +1 -0
- package/dist/tooling/test-harness/coverage.js +32 -0
- package/dist/tooling/test-harness/coverage.js.map +1 -0
- package/dist/tooling/test-harness/generators.d.ts +6 -0
- package/dist/tooling/test-harness/generators.d.ts.map +1 -0
- package/dist/tooling/test-harness/generators.js +66 -0
- package/dist/tooling/test-harness/generators.js.map +1 -0
- package/dist/tooling/test-harness/index.d.ts +7 -0
- package/dist/tooling/test-harness/index.d.ts.map +1 -0
- package/dist/tooling/test-harness/index.js +27 -0
- package/dist/tooling/test-harness/index.js.map +1 -0
- package/dist/tooling/test-harness/mutation.d.ts +4 -0
- package/dist/tooling/test-harness/mutation.d.ts.map +1 -0
- package/dist/tooling/test-harness/mutation.js +28 -0
- package/dist/tooling/test-harness/mutation.js.map +1 -0
- package/dist/tooling/test-harness/snapshot.d.ts +5 -0
- package/dist/tooling/test-harness/snapshot.d.ts.map +1 -0
- package/dist/tooling/test-harness/snapshot.js +86 -0
- package/dist/tooling/test-harness/snapshot.js.map +1 -0
- package/dist/tooling/test-harness/types.d.ts +32 -0
- package/dist/tooling/test-harness/types.d.ts.map +1 -0
- package/dist/tooling/test-harness/types.js +3 -0
- package/dist/tooling/test-harness/types.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hereditarily finite sets (the universe Vω).
|
|
4
|
+
*
|
|
5
|
+
* Every HF set is built from the empty set in finitely many steps using
|
|
6
|
+
* pairing and union. Equality is extensional: two sets are equal iff they
|
|
7
|
+
* have the same elements, regardless of order or repetition.
|
|
8
|
+
*
|
|
9
|
+
* Internally we keep elements as a plain array; the canonical form (used
|
|
10
|
+
* for hashing/equality) deduplicates and orders by a recursive serialization.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.EMPTY = void 0;
|
|
14
|
+
exports.canonicalize = canonicalize;
|
|
15
|
+
exports.setEquals = setEquals;
|
|
16
|
+
exports.isElement = isElement;
|
|
17
|
+
exports.isSubset = isSubset;
|
|
18
|
+
exports.cardinality = cardinality;
|
|
19
|
+
exports.canonicalSet = canonicalSet;
|
|
20
|
+
exports.singleton = singleton;
|
|
21
|
+
exports.pair = pair;
|
|
22
|
+
exports.union = union;
|
|
23
|
+
exports.unionFamily = unionFamily;
|
|
24
|
+
exports.intersection = intersection;
|
|
25
|
+
exports.difference = difference;
|
|
26
|
+
exports.powerSet = powerSet;
|
|
27
|
+
exports.orderedPair = orderedPair;
|
|
28
|
+
exports.fst = fst;
|
|
29
|
+
exports.snd = snd;
|
|
30
|
+
exports.cartesianProduct = cartesianProduct;
|
|
31
|
+
exports.succ = succ;
|
|
32
|
+
exports.nat = nat;
|
|
33
|
+
exports.isTransitive = isTransitive;
|
|
34
|
+
exports.isOrdinal = isOrdinal;
|
|
35
|
+
const makeSet = (elements) => ({
|
|
36
|
+
kind: 'set',
|
|
37
|
+
elements
|
|
38
|
+
});
|
|
39
|
+
exports.EMPTY = makeSet([]);
|
|
40
|
+
/**
|
|
41
|
+
* Canonical identifier for an HF set. Two HF sets are extensionally equal
|
|
42
|
+
* iff their canonicalize() outputs are identical strings.
|
|
43
|
+
*
|
|
44
|
+
* Implementation: every distinct extensional set is mapped to a compact
|
|
45
|
+
* integer ID via Hopcroft-style interning. The returned string is the
|
|
46
|
+
* literal `'#<id>'`. This avoids the exponential blowup that the naive
|
|
47
|
+
* recursive "{e1,e2,...}" serialization would have on deeply nested
|
|
48
|
+
* sets like von Neumann ordinals nat(n) (whose canonical string grows
|
|
49
|
+
* as Θ(2^n)). The interning table is a module-level singleton; since
|
|
50
|
+
* HFSet is structurally immutable in practice this is safe.
|
|
51
|
+
*/
|
|
52
|
+
const internByKey = new Map();
|
|
53
|
+
const idByObject = new WeakMap();
|
|
54
|
+
function canonicalize(x) {
|
|
55
|
+
const cached = idByObject.get(x);
|
|
56
|
+
if (cached !== undefined) {
|
|
57
|
+
return cached;
|
|
58
|
+
}
|
|
59
|
+
let key;
|
|
60
|
+
if (x.elements.length === 0) {
|
|
61
|
+
key = '0';
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const childIds = x.elements.map(canonicalize);
|
|
65
|
+
const unique = Array.from(new Set(childIds));
|
|
66
|
+
unique.sort();
|
|
67
|
+
key = unique.join(',');
|
|
68
|
+
}
|
|
69
|
+
let id = internByKey.get(key);
|
|
70
|
+
if (id === undefined) {
|
|
71
|
+
id = `#${internByKey.size.toString(36)}`;
|
|
72
|
+
internByKey.set(key, id);
|
|
73
|
+
}
|
|
74
|
+
idByObject.set(x, id);
|
|
75
|
+
return id;
|
|
76
|
+
}
|
|
77
|
+
function setEquals(a, b) {
|
|
78
|
+
return canonicalize(a) === canonicalize(b);
|
|
79
|
+
}
|
|
80
|
+
function isElement(x, A) {
|
|
81
|
+
const target = canonicalize(x);
|
|
82
|
+
for (const e of A.elements) {
|
|
83
|
+
if (canonicalize(e) === target) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
function isSubset(a, b) {
|
|
90
|
+
for (const e of a.elements) {
|
|
91
|
+
if (!isElement(e, b)) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Cardinality is the number of *distinct* elements (after canonical dedup).
|
|
99
|
+
* `a.elements` may contain syntactic duplicates if the set was built by
|
|
100
|
+
* hand; we count once per equivalence class.
|
|
101
|
+
*/
|
|
102
|
+
function cardinality(a) {
|
|
103
|
+
const seen = new Set();
|
|
104
|
+
for (const e of a.elements) {
|
|
105
|
+
seen.add(canonicalize(e));
|
|
106
|
+
}
|
|
107
|
+
return seen.size;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Returns the canonical representative of a set: same elements, deduplicated
|
|
111
|
+
* and ordered. Useful when consumers want a stable shape.
|
|
112
|
+
*/
|
|
113
|
+
function canonicalSet(a) {
|
|
114
|
+
const seen = new Map();
|
|
115
|
+
for (const e of a.elements) {
|
|
116
|
+
const key = canonicalize(e);
|
|
117
|
+
if (!seen.has(key)) {
|
|
118
|
+
seen.set(key, canonicalSet(e));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const sortedKeys = Array.from(seen.keys()).sort();
|
|
122
|
+
const ordered = [];
|
|
123
|
+
for (const k of sortedKeys) {
|
|
124
|
+
const value = seen.get(k);
|
|
125
|
+
if (value !== undefined) {
|
|
126
|
+
ordered.push(value);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return makeSet(ordered);
|
|
130
|
+
}
|
|
131
|
+
function singleton(x) {
|
|
132
|
+
return makeSet([x]);
|
|
133
|
+
}
|
|
134
|
+
function pair(a, b) {
|
|
135
|
+
if (setEquals(a, b)) {
|
|
136
|
+
return makeSet([a]);
|
|
137
|
+
}
|
|
138
|
+
return makeSet([a, b]);
|
|
139
|
+
}
|
|
140
|
+
function union(a, b) {
|
|
141
|
+
const seen = new Map();
|
|
142
|
+
for (const e of a.elements) {
|
|
143
|
+
seen.set(canonicalize(e), e);
|
|
144
|
+
}
|
|
145
|
+
for (const e of b.elements) {
|
|
146
|
+
const key = canonicalize(e);
|
|
147
|
+
if (!seen.has(key)) {
|
|
148
|
+
seen.set(key, e);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return makeSet(Array.from(seen.values()));
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Generalized union: union of every element of `sets`. If `sets` is the
|
|
155
|
+
* family {A1, A2, ...} returns A1 ∪ A2 ∪ ... (Axiom of Union).
|
|
156
|
+
*/
|
|
157
|
+
function unionFamily(sets) {
|
|
158
|
+
const family = Array.isArray(sets) ? sets : sets.elements;
|
|
159
|
+
let acc = exports.EMPTY;
|
|
160
|
+
for (const s of family) {
|
|
161
|
+
acc = union(acc, s);
|
|
162
|
+
}
|
|
163
|
+
return acc;
|
|
164
|
+
}
|
|
165
|
+
function intersection(a, b) {
|
|
166
|
+
const out = [];
|
|
167
|
+
const seen = new Set();
|
|
168
|
+
for (const e of a.elements) {
|
|
169
|
+
const key = canonicalize(e);
|
|
170
|
+
if (!seen.has(key) && isElement(e, b)) {
|
|
171
|
+
seen.add(key);
|
|
172
|
+
out.push(e);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return makeSet(out);
|
|
176
|
+
}
|
|
177
|
+
function difference(a, b) {
|
|
178
|
+
const out = [];
|
|
179
|
+
const seen = new Set();
|
|
180
|
+
for (const e of a.elements) {
|
|
181
|
+
const key = canonicalize(e);
|
|
182
|
+
if (!seen.has(key) && !isElement(e, b)) {
|
|
183
|
+
seen.add(key);
|
|
184
|
+
out.push(e);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return makeSet(out);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Power set: set of all subsets. For a set of cardinality n returns a set
|
|
191
|
+
* of cardinality 2^n. Implementation is the classic bitmask enumeration
|
|
192
|
+
* over the canonical element list.
|
|
193
|
+
*/
|
|
194
|
+
function powerSet(a) {
|
|
195
|
+
const canonical = canonicalSet(a);
|
|
196
|
+
const xs = canonical.elements;
|
|
197
|
+
const n = xs.length;
|
|
198
|
+
const total = 1 << n;
|
|
199
|
+
const subsets = [];
|
|
200
|
+
for (let mask = 0; mask < total; mask++) {
|
|
201
|
+
const sub = [];
|
|
202
|
+
for (let i = 0; i < n; i++) {
|
|
203
|
+
if ((mask & (1 << i)) !== 0) {
|
|
204
|
+
const element = xs[i];
|
|
205
|
+
if (element !== undefined) {
|
|
206
|
+
sub.push(element);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
subsets.push(makeSet(sub));
|
|
211
|
+
}
|
|
212
|
+
return makeSet(subsets);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Kuratowski ordered pair: ⟨a, b⟩ := { {a}, {a, b} }.
|
|
216
|
+
* Recovers `fst` and `snd` correctly even when a = b.
|
|
217
|
+
*/
|
|
218
|
+
function orderedPair(a, b) {
|
|
219
|
+
const left = singleton(a);
|
|
220
|
+
const right = pair(a, b);
|
|
221
|
+
return pair(left, right);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Extracts the first component of a Kuratowski pair. Returns null if the
|
|
225
|
+
* input is not shaped like an ordered pair.
|
|
226
|
+
*/
|
|
227
|
+
function fst(p) {
|
|
228
|
+
if (p.elements.length === 0 || p.elements.length > 2) {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
const first = p.elements[0];
|
|
232
|
+
if (first === undefined || first.elements.length === 0) {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
// The singleton {a} sits inside p; its sole element is a.
|
|
236
|
+
for (const member of p.elements) {
|
|
237
|
+
if (member.elements.length === 1) {
|
|
238
|
+
const candidate = member.elements[0];
|
|
239
|
+
if (candidate !== undefined) {
|
|
240
|
+
return candidate;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
function snd(p) {
|
|
247
|
+
if (p.elements.length === 0 || p.elements.length > 2) {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
const a = fst(p);
|
|
251
|
+
if (a === null) {
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
// Look for the {a, b} side. If p = {{a}}, then b = a.
|
|
255
|
+
for (const member of p.elements) {
|
|
256
|
+
if (member.elements.length === 2) {
|
|
257
|
+
const m0 = member.elements[0];
|
|
258
|
+
const m1 = member.elements[1];
|
|
259
|
+
if (m0 === undefined || m1 === undefined) {
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
if (setEquals(m0, a)) {
|
|
263
|
+
return m1;
|
|
264
|
+
}
|
|
265
|
+
if (setEquals(m1, a)) {
|
|
266
|
+
return m0;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
// Degenerate pair ⟨a, a⟩ = {{a}}.
|
|
271
|
+
return a;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Cartesian product A × B = { ⟨a, b⟩ : a ∈ A, b ∈ B }.
|
|
275
|
+
*/
|
|
276
|
+
function cartesianProduct(a, b) {
|
|
277
|
+
const ca = canonicalSet(a);
|
|
278
|
+
const cb = canonicalSet(b);
|
|
279
|
+
const out = [];
|
|
280
|
+
const seen = new Set();
|
|
281
|
+
for (const x of ca.elements) {
|
|
282
|
+
for (const y of cb.elements) {
|
|
283
|
+
const pp = orderedPair(x, y);
|
|
284
|
+
const key = canonicalize(pp);
|
|
285
|
+
if (!seen.has(key)) {
|
|
286
|
+
seen.add(key);
|
|
287
|
+
out.push(pp);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return makeSet(out);
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Von Neumann natural number: 0 := ∅, succ(n) := n ∪ {n}.
|
|
295
|
+
* Therefore n = {0, 1, ..., n-1}.
|
|
296
|
+
*/
|
|
297
|
+
function succ(n) {
|
|
298
|
+
return union(n, singleton(n));
|
|
299
|
+
}
|
|
300
|
+
function nat(n) {
|
|
301
|
+
if (!Number.isInteger(n) || n < 0) {
|
|
302
|
+
throw new RangeError('nat(n): n debe ser entero no negativo');
|
|
303
|
+
}
|
|
304
|
+
let acc = exports.EMPTY;
|
|
305
|
+
for (let i = 0; i < n; i++) {
|
|
306
|
+
acc = succ(acc);
|
|
307
|
+
}
|
|
308
|
+
return acc;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Transitive: every element of x is also a subset of x.
|
|
312
|
+
* Required by the von Neumann ordinal definition.
|
|
313
|
+
*/
|
|
314
|
+
function isTransitive(x) {
|
|
315
|
+
for (const e of x.elements) {
|
|
316
|
+
if (!isSubset(e, x)) {
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return true;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Von Neumann ordinal: transitive set, well-ordered by ∈. On HF sets
|
|
324
|
+
* (where every membership chain terminates by Foundation) this collapses
|
|
325
|
+
* to: x is transitive and every element of x is also transitive.
|
|
326
|
+
*/
|
|
327
|
+
function isOrdinal(x) {
|
|
328
|
+
if (!isTransitive(x)) {
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
for (const e of x.elements) {
|
|
332
|
+
if (!isTransitive(e)) {
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return true;
|
|
337
|
+
}
|
|
338
|
+
//# sourceMappingURL=hf-sets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hf-sets.js","sourceRoot":"","sources":["../../../src/reasoning/set-theory/hf-sets.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AA6BH,oCAqBC;AAED,8BAEC;AAED,8BAQC;AAED,4BAOC;AAOD,kCAMC;AAMD,oCAiBC;AAED,8BAEC;AAED,oBAKC;AAED,sBAYC;AAMD,kCAOC;AAED,oCAWC;AAED,gCAWC;AAOD,4BAmBC;AAMD,kCAIC;AAMD,kBAkBC;AAED,kBA0BC;AAKD,4CAgBC;AAMD,oBAEC;AAED,kBASC;AAMD,oCAOC;AAOD,8BAUC;AApUD,MAAM,OAAO,GAAG,CAAC,QAA8B,EAAS,EAAE,CAAC,CAAC;IAC1D,IAAI,EAAE,KAAK;IACX,QAAQ;CACT,CAAC,CAAC;AAEU,QAAA,KAAK,GAAU,OAAO,CAAC,EAAE,CAAC,CAAC;AAExC;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;AAC9C,MAAM,UAAU,GAAG,IAAI,OAAO,EAAiB,CAAC;AAEhD,SAAgB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|
1
|
+
export { EMPTY, canonicalize, canonicalSet, cardinality, cartesianProduct, difference, fst, intersection, isElement, isOrdinal, isSubset, isTransitive, nat, orderedPair, pair, powerSet, setEquals, singleton, snd, succ, union, unionFamily } from './hf-sets';
|
|
2
|
+
export type { HFSet } from './hf-sets';
|
|
3
|
+
export { EMPTY_FUNCTION, applyHF, composeHF, isBijective, isInjective, isSurjective, isValidFunction, makeFunction } from './hf-functions';
|
|
4
|
+
export type { HFFunction } from './hf-functions';
|
|
5
|
+
export { checkAllAxioms, checkExtensionality, checkFoundation, checkInfinity, checkPairing, checkPowerSet, checkUnion } from './zfc-axioms';
|
|
6
|
+
export type { ZFCAxiomCheck } from './zfc-axioms';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/reasoning/set-theory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,GAAG,EACH,YAAY,EACZ,SAAS,EACT,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,GAAG,EACH,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,SAAS,EACT,GAAG,EACH,IAAI,EACJ,KAAK,EACL,WAAW,EACZ,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EACL,cAAc,EACd,OAAO,EACP,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,YAAY,EACb,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,aAAa,EACb,UAAU,EACX,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkUnion = exports.checkPowerSet = exports.checkPairing = exports.checkInfinity = exports.checkFoundation = exports.checkExtensionality = exports.checkAllAxioms = exports.makeFunction = exports.isValidFunction = exports.isSurjective = exports.isInjective = exports.isBijective = exports.composeHF = exports.applyHF = exports.EMPTY_FUNCTION = exports.unionFamily = exports.union = exports.succ = exports.snd = exports.singleton = exports.setEquals = exports.powerSet = exports.pair = exports.orderedPair = exports.nat = exports.isTransitive = exports.isSubset = exports.isOrdinal = exports.isElement = exports.intersection = exports.fst = exports.difference = exports.cartesianProduct = exports.cardinality = exports.canonicalSet = exports.canonicalize = exports.EMPTY = void 0;
|
|
4
|
+
var hf_sets_1 = require("./hf-sets");
|
|
5
|
+
Object.defineProperty(exports, "EMPTY", { enumerable: true, get: function () { return hf_sets_1.EMPTY; } });
|
|
6
|
+
Object.defineProperty(exports, "canonicalize", { enumerable: true, get: function () { return hf_sets_1.canonicalize; } });
|
|
7
|
+
Object.defineProperty(exports, "canonicalSet", { enumerable: true, get: function () { return hf_sets_1.canonicalSet; } });
|
|
8
|
+
Object.defineProperty(exports, "cardinality", { enumerable: true, get: function () { return hf_sets_1.cardinality; } });
|
|
9
|
+
Object.defineProperty(exports, "cartesianProduct", { enumerable: true, get: function () { return hf_sets_1.cartesianProduct; } });
|
|
10
|
+
Object.defineProperty(exports, "difference", { enumerable: true, get: function () { return hf_sets_1.difference; } });
|
|
11
|
+
Object.defineProperty(exports, "fst", { enumerable: true, get: function () { return hf_sets_1.fst; } });
|
|
12
|
+
Object.defineProperty(exports, "intersection", { enumerable: true, get: function () { return hf_sets_1.intersection; } });
|
|
13
|
+
Object.defineProperty(exports, "isElement", { enumerable: true, get: function () { return hf_sets_1.isElement; } });
|
|
14
|
+
Object.defineProperty(exports, "isOrdinal", { enumerable: true, get: function () { return hf_sets_1.isOrdinal; } });
|
|
15
|
+
Object.defineProperty(exports, "isSubset", { enumerable: true, get: function () { return hf_sets_1.isSubset; } });
|
|
16
|
+
Object.defineProperty(exports, "isTransitive", { enumerable: true, get: function () { return hf_sets_1.isTransitive; } });
|
|
17
|
+
Object.defineProperty(exports, "nat", { enumerable: true, get: function () { return hf_sets_1.nat; } });
|
|
18
|
+
Object.defineProperty(exports, "orderedPair", { enumerable: true, get: function () { return hf_sets_1.orderedPair; } });
|
|
19
|
+
Object.defineProperty(exports, "pair", { enumerable: true, get: function () { return hf_sets_1.pair; } });
|
|
20
|
+
Object.defineProperty(exports, "powerSet", { enumerable: true, get: function () { return hf_sets_1.powerSet; } });
|
|
21
|
+
Object.defineProperty(exports, "setEquals", { enumerable: true, get: function () { return hf_sets_1.setEquals; } });
|
|
22
|
+
Object.defineProperty(exports, "singleton", { enumerable: true, get: function () { return hf_sets_1.singleton; } });
|
|
23
|
+
Object.defineProperty(exports, "snd", { enumerable: true, get: function () { return hf_sets_1.snd; } });
|
|
24
|
+
Object.defineProperty(exports, "succ", { enumerable: true, get: function () { return hf_sets_1.succ; } });
|
|
25
|
+
Object.defineProperty(exports, "union", { enumerable: true, get: function () { return hf_sets_1.union; } });
|
|
26
|
+
Object.defineProperty(exports, "unionFamily", { enumerable: true, get: function () { return hf_sets_1.unionFamily; } });
|
|
27
|
+
var hf_functions_1 = require("./hf-functions");
|
|
28
|
+
Object.defineProperty(exports, "EMPTY_FUNCTION", { enumerable: true, get: function () { return hf_functions_1.EMPTY_FUNCTION; } });
|
|
29
|
+
Object.defineProperty(exports, "applyHF", { enumerable: true, get: function () { return hf_functions_1.applyHF; } });
|
|
30
|
+
Object.defineProperty(exports, "composeHF", { enumerable: true, get: function () { return hf_functions_1.composeHF; } });
|
|
31
|
+
Object.defineProperty(exports, "isBijective", { enumerable: true, get: function () { return hf_functions_1.isBijective; } });
|
|
32
|
+
Object.defineProperty(exports, "isInjective", { enumerable: true, get: function () { return hf_functions_1.isInjective; } });
|
|
33
|
+
Object.defineProperty(exports, "isSurjective", { enumerable: true, get: function () { return hf_functions_1.isSurjective; } });
|
|
34
|
+
Object.defineProperty(exports, "isValidFunction", { enumerable: true, get: function () { return hf_functions_1.isValidFunction; } });
|
|
35
|
+
Object.defineProperty(exports, "makeFunction", { enumerable: true, get: function () { return hf_functions_1.makeFunction; } });
|
|
36
|
+
var zfc_axioms_1 = require("./zfc-axioms");
|
|
37
|
+
Object.defineProperty(exports, "checkAllAxioms", { enumerable: true, get: function () { return zfc_axioms_1.checkAllAxioms; } });
|
|
38
|
+
Object.defineProperty(exports, "checkExtensionality", { enumerable: true, get: function () { return zfc_axioms_1.checkExtensionality; } });
|
|
39
|
+
Object.defineProperty(exports, "checkFoundation", { enumerable: true, get: function () { return zfc_axioms_1.checkFoundation; } });
|
|
40
|
+
Object.defineProperty(exports, "checkInfinity", { enumerable: true, get: function () { return zfc_axioms_1.checkInfinity; } });
|
|
41
|
+
Object.defineProperty(exports, "checkPairing", { enumerable: true, get: function () { return zfc_axioms_1.checkPairing; } });
|
|
42
|
+
Object.defineProperty(exports, "checkPowerSet", { enumerable: true, get: function () { return zfc_axioms_1.checkPowerSet; } });
|
|
43
|
+
Object.defineProperty(exports, "checkUnion", { enumerable: true, get: function () { return zfc_axioms_1.checkUnion; } });
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/reasoning/set-theory/index.ts"],"names":[],"mappings":";;;AAAA,qCAuBmB;AAtBjB,gGAAA,KAAK,OAAA;AACL,uGAAA,YAAY,OAAA;AACZ,uGAAA,YAAY,OAAA;AACZ,sGAAA,WAAW,OAAA;AACX,2GAAA,gBAAgB,OAAA;AAChB,qGAAA,UAAU,OAAA;AACV,8FAAA,GAAG,OAAA;AACH,uGAAA,YAAY,OAAA;AACZ,oGAAA,SAAS,OAAA;AACT,oGAAA,SAAS,OAAA;AACT,mGAAA,QAAQ,OAAA;AACR,uGAAA,YAAY,OAAA;AACZ,8FAAA,GAAG,OAAA;AACH,sGAAA,WAAW,OAAA;AACX,+FAAA,IAAI,OAAA;AACJ,mGAAA,QAAQ,OAAA;AACR,oGAAA,SAAS,OAAA;AACT,oGAAA,SAAS,OAAA;AACT,8FAAA,GAAG,OAAA;AACH,+FAAA,IAAI,OAAA;AACJ,gGAAA,KAAK,OAAA;AACL,sGAAA,WAAW,OAAA;AAIb,+CASwB;AARtB,8GAAA,cAAc,OAAA;AACd,uGAAA,OAAO,OAAA;AACP,yGAAA,SAAS,OAAA;AACT,2GAAA,WAAW,OAAA;AACX,2GAAA,WAAW,OAAA;AACX,4GAAA,YAAY,OAAA;AACZ,+GAAA,eAAe,OAAA;AACf,4GAAA,YAAY,OAAA;AAId,2CAQsB;AAPpB,4GAAA,cAAc,OAAA;AACd,iHAAA,mBAAmB,OAAA;AACnB,6GAAA,eAAe,OAAA;AACf,2GAAA,aAAa,OAAA;AACb,0GAAA,YAAY,OAAA;AACZ,2GAAA,aAAa,OAAA;AACb,wGAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sanity checks of selected ZFC axioms restricted to the Vω fragment.
|
|
3
|
+
*
|
|
4
|
+
* Most axioms hold on Vω: extensionality, pairing, union, power set,
|
|
5
|
+
* foundation, separation, replacement. Infinity FAILS on Vω because Vω
|
|
6
|
+
* is exactly the universe of hereditarily finite sets — there is no
|
|
7
|
+
* infinite set inside it.
|
|
8
|
+
*
|
|
9
|
+
* The "check" functions verify on a sample of HF sets. They return
|
|
10
|
+
* `holds = false` plus a counterexample when violated.
|
|
11
|
+
*/
|
|
12
|
+
import { HFSet } from './hf-sets';
|
|
13
|
+
export interface ZFCAxiomCheck {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly holds: boolean;
|
|
16
|
+
readonly note?: string;
|
|
17
|
+
readonly counterexample?: ReadonlyArray<HFSet>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Axiom of Extensionality: ∀A ∀B (A = B ↔ ∀x (x ∈ A ↔ x ∈ B)).
|
|
21
|
+
* Our canonicalization implements extensionality directly, so we verify
|
|
22
|
+
* agreement on a sample plus the contrapositive on intentionally distinct
|
|
23
|
+
* sets.
|
|
24
|
+
*/
|
|
25
|
+
export declare function checkExtensionality(): ZFCAxiomCheck;
|
|
26
|
+
/**
|
|
27
|
+
* Axiom of Pairing: ∀a ∀b ∃P (a ∈ P ∧ b ∈ P ∧ ∀x (x ∈ P → x = a ∨ x = b)).
|
|
28
|
+
*/
|
|
29
|
+
export declare function checkPairing(_samples?: number): ZFCAxiomCheck;
|
|
30
|
+
/**
|
|
31
|
+
* Axiom of Union: for any family F there exists ⋃F such that x ∈ ⋃F iff
|
|
32
|
+
* x ∈ A for some A ∈ F.
|
|
33
|
+
*/
|
|
34
|
+
export declare function checkUnion(_samples?: number): ZFCAxiomCheck;
|
|
35
|
+
/**
|
|
36
|
+
* Axiom of Power Set: ∀A ∃P (∀x (x ∈ P ↔ x ⊆ A)). Sample over small sets
|
|
37
|
+
* to keep |P(A)| = 2^|A| manageable.
|
|
38
|
+
*/
|
|
39
|
+
export declare function checkPowerSet(_samples?: number): ZFCAxiomCheck;
|
|
40
|
+
/**
|
|
41
|
+
* Axiom of Infinity: ∃I (∅ ∈ I ∧ ∀x (x ∈ I → succ(x) ∈ I)). This is
|
|
42
|
+
* exactly what fails on Vω: there is no HF set closed under successor,
|
|
43
|
+
* because successor strictly increases rank and HF sets have finite rank.
|
|
44
|
+
*
|
|
45
|
+
* We "witness" the failure by attempting a closure construction: start
|
|
46
|
+
* with ∅, repeatedly add successors, and observe that the inductive set
|
|
47
|
+
* cannot terminate inside Vω. Programmatically we cap the search depth
|
|
48
|
+
* and report holds=false with the partial witness.
|
|
49
|
+
*/
|
|
50
|
+
export declare function checkInfinity(): ZFCAxiomCheck;
|
|
51
|
+
/**
|
|
52
|
+
* Axiom of Foundation (Regularity): every nonempty set A has an element
|
|
53
|
+
* disjoint from A. On HF sets this holds automatically because the
|
|
54
|
+
* membership relation is well-founded by construction (no cycles, no
|
|
55
|
+
* infinite descending chains).
|
|
56
|
+
*/
|
|
57
|
+
export declare function checkFoundation(_samples?: number): ZFCAxiomCheck;
|
|
58
|
+
export declare function checkAllAxioms(): ZFCAxiomCheck[];
|
|
59
|
+
//# sourceMappingURL=zfc-axioms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zfc-axioms.d.ts","sourceRoot":"","sources":["../../../src/reasoning/set-theory/zfc-axioms.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAIL,KAAK,EAWN,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;CAChD;AAkCD;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,aAAa,CAyBnD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,SAAI,GAAG,aAAa,CAexD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,QAAQ,SAAI,GAAG,aAAa,CAiCtD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,SAAI,GAAG,aAAa,CAsBzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,IAAI,aAAa,CA2B7C;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,SAAI,GAAG,aAAa,CAsB3D;AAED,wBAAgB,cAAc,IAAI,aAAa,EAAE,CAShD"}
|