universal-physics-tensor 0.21.0 → 0.23.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 (70) hide show
  1. package/README.md +13 -12
  2. package/bin/upt.mjs +83 -4
  3. package/dist/canonical/canonical-equation.d.ts +79 -0
  4. package/dist/canonical/canonical-equation.d.ts.map +1 -0
  5. package/dist/canonical/canonical-equation.js +2 -0
  6. package/dist/canonical/canonical-equation.js.map +1 -0
  7. package/dist/canonical/dimensional-fields.d.ts +7 -0
  8. package/dist/canonical/dimensional-fields.d.ts.map +1 -0
  9. package/dist/canonical/dimensional-fields.js +31 -0
  10. package/dist/canonical/dimensional-fields.js.map +1 -0
  11. package/dist/canonical/entries/_l1-build.d.ts +22 -0
  12. package/dist/canonical/entries/_l1-build.d.ts.map +1 -0
  13. package/dist/canonical/entries/_l1-build.js +26 -0
  14. package/dist/canonical/entries/_l1-build.js.map +1 -0
  15. package/dist/canonical/entries/dimensional-classics.d.ts +11 -0
  16. package/dist/canonical/entries/dimensional-classics.d.ts.map +1 -0
  17. package/dist/canonical/entries/dimensional-classics.js +194 -0
  18. package/dist/canonical/entries/dimensional-classics.js.map +1 -0
  19. package/dist/canonical/entries/l1-gravity-thermo.d.ts +12 -0
  20. package/dist/canonical/entries/l1-gravity-thermo.d.ts.map +1 -0
  21. package/dist/canonical/entries/l1-gravity-thermo.js +165 -0
  22. package/dist/canonical/entries/l1-gravity-thermo.js.map +1 -0
  23. package/dist/canonical/entries/l1-quantum-em.d.ts +10 -0
  24. package/dist/canonical/entries/l1-quantum-em.d.ts.map +1 -0
  25. package/dist/canonical/entries/l1-quantum-em.js +141 -0
  26. package/dist/canonical/entries/l1-quantum-em.js.map +1 -0
  27. package/dist/canonical/entries/relativity.d.ts +14 -0
  28. package/dist/canonical/entries/relativity.d.ts.map +1 -0
  29. package/dist/canonical/entries/relativity.js +188 -0
  30. package/dist/canonical/entries/relativity.js.map +1 -0
  31. package/dist/canonical/linkage.d.ts +27 -0
  32. package/dist/canonical/linkage.d.ts.map +1 -0
  33. package/dist/canonical/linkage.js +139 -0
  34. package/dist/canonical/linkage.js.map +1 -0
  35. package/dist/canonical/normal-form.d.ts +31 -0
  36. package/dist/canonical/normal-form.d.ts.map +1 -0
  37. package/dist/canonical/normal-form.js +137 -0
  38. package/dist/canonical/normal-form.js.map +1 -0
  39. package/dist/canonical/registry.d.ts +26 -0
  40. package/dist/canonical/registry.d.ts.map +1 -0
  41. package/dist/canonical/registry.js +46 -0
  42. package/dist/canonical/registry.js.map +1 -0
  43. package/dist/canonical/seed-l-layer.d.ts +20 -0
  44. package/dist/canonical/seed-l-layer.d.ts.map +1 -0
  45. package/dist/canonical/seed-l-layer.js +39 -0
  46. package/dist/canonical/seed-l-layer.js.map +1 -0
  47. package/dist/composition/discovery.d.ts +50 -6
  48. package/dist/composition/discovery.d.ts.map +1 -1
  49. package/dist/composition/discovery.js +102 -10
  50. package/dist/composition/discovery.js.map +1 -1
  51. package/dist/composition/representative-values.d.ts +52 -0
  52. package/dist/composition/representative-values.d.ts.map +1 -0
  53. package/dist/composition/representative-values.js +91 -0
  54. package/dist/composition/representative-values.js.map +1 -0
  55. package/dist/composition/retrodiction.d.ts +13 -0
  56. package/dist/composition/retrodiction.d.ts.map +1 -1
  57. package/dist/composition/retrodiction.js +7 -1
  58. package/dist/composition/retrodiction.js.map +1 -1
  59. package/dist/composition/symbolic-constants.d.ts.map +1 -1
  60. package/dist/composition/symbolic-constants.js +15 -1
  61. package/dist/composition/symbolic-constants.js.map +1 -1
  62. package/dist/core/constants.d.ts +6 -0
  63. package/dist/core/constants.d.ts.map +1 -1
  64. package/dist/core/constants.js +6 -0
  65. package/dist/core/constants.js.map +1 -1
  66. package/dist/index.d.ts +7 -1
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +15 -1
  69. package/dist/index.js.map +1 -1
  70. package/package.json +1 -1
@@ -0,0 +1,139 @@
1
+ import { validate } from '../dimensional/validator.js';
2
+ import { evalExpr } from '../composition/expr-eval.js';
3
+ import { CONSTANTS } from '../composition/symbolic-constants.js';
4
+ import { BRIDGE_RHS_BY_ID } from '../bridges/rhs-registry.js';
5
+ import { CANONICAL_EQUATIONS, canonicalById } from './registry.js';
6
+ import { structurallyEqual } from './normal-form.js';
7
+ const dimEqual = (a, b) => a.L === b.L &&
8
+ a.M === b.M &&
9
+ a.T === b.T &&
10
+ a.I === b.I &&
11
+ a.Theta === b.Theta &&
12
+ a.N === b.N &&
13
+ a.J === b.J;
14
+ const isDimensionless = (d) => d.L === 0 &&
15
+ d.M === 0 &&
16
+ d.T === 0 &&
17
+ d.I === 0 &&
18
+ d.Theta === 0 &&
19
+ d.N === 0 &&
20
+ d.J === 0;
21
+ /**
22
+ * Collect leaves `evalExpr` can't resolve (not a registered constant, not a
23
+ * numeric literal), split into physical `vars` (non-dimensionless — varied
24
+ * across samples) and `dimless` (dimensionless — held fixed: they ARE the
25
+ * constant factor "up to" which recovery is measured).
26
+ */
27
+ function collectLeaves(node, vars, dimless) {
28
+ switch (node.kind) {
29
+ case 'symbol':
30
+ if (!(node.name in CONSTANTS) && Number.isNaN(Number(node.name))) {
31
+ (isDimensionless(node.dim) ? dimless : vars).add(node.name);
32
+ }
33
+ return;
34
+ case 'op':
35
+ for (const a of node.args)
36
+ collectLeaves(a, vars, dimless);
37
+ return;
38
+ case 'transcendental':
39
+ collectLeaves(node.arg, vars, dimless);
40
+ return;
41
+ case 'abs':
42
+ collectLeaves(node.arg, vars, dimless);
43
+ return;
44
+ default:
45
+ return;
46
+ }
47
+ }
48
+ const SAMPLE_FACTORS = [1, 2, 3];
49
+ /** Best-effort check that two ASTs agree up to a constant ratio. */
50
+ function numericalRecovery(canon, bridge) {
51
+ const vars = new Set();
52
+ const dimless = new Set();
53
+ collectLeaves(canon, vars, dimless);
54
+ collectLeaves(bridge, vars, dimless);
55
+ const names = [...vars].sort();
56
+ const ratios = [];
57
+ for (const s of SAMPLE_FACTORS) {
58
+ const values = {};
59
+ names.forEach((n, i) => {
60
+ values[n] = (1.3 + 0.7 * i) * s; // distinct positive samples
61
+ });
62
+ // Hold unresolved dimensionless leaves fixed — recovery is "up to" them.
63
+ for (const n of dimless)
64
+ values[n] = 1;
65
+ let cv;
66
+ let bv;
67
+ try {
68
+ cv = evalExpr(canon, values);
69
+ bv = evalExpr(bridge, values);
70
+ }
71
+ catch {
72
+ return { tested: false, maxRelErr: NaN };
73
+ }
74
+ // Guard cv===0 too: with cv===0 the ratio is 0 at every sample, so the
75
+ // relative-spread denominator r0===0 ⇒ NaN — a false "tested" result.
76
+ if (!Number.isFinite(cv) || !Number.isFinite(bv) || bv === 0 || cv === 0) {
77
+ return { tested: false, maxRelErr: NaN };
78
+ }
79
+ ratios.push(cv / bv);
80
+ }
81
+ const r0 = ratios[0];
82
+ const maxRelErr = Math.max(...ratios.map((r) => Math.abs((r - r0) / r0)));
83
+ return { tested: true, maxRelErr };
84
+ }
85
+ /** Compare one canonical entry against one bridge. */
86
+ export function classifyLinkage(canonicalId, bridgeId) {
87
+ const canon = canonicalById(canonicalId);
88
+ const bridgeRhs = BRIDGE_RHS_BY_ID.get(bridgeId);
89
+ const base = { canonicalId, bridgeId };
90
+ if (!canon || !bridgeRhs || !canon.scalarAst) {
91
+ return {
92
+ ...base,
93
+ dimMatch: false,
94
+ structuralMatch: false,
95
+ recovery: null,
96
+ classification: 'unrelated',
97
+ };
98
+ }
99
+ const bridgeDim = validate(bridgeRhs);
100
+ const dimMatch = bridgeDim.ok &&
101
+ bridgeDim.inferredDimension != null &&
102
+ dimEqual(bridgeDim.inferredDimension, canon.dimensional.target.dim);
103
+ const structuralMatch = structurallyEqual(canon.scalarAst, bridgeRhs);
104
+ const recovery = structuralMatch
105
+ ? numericalRecovery(canon.scalarAst, bridgeRhs)
106
+ : null;
107
+ let classification;
108
+ if (structuralMatch) {
109
+ classification =
110
+ canon.restatesBridge === String(bridgeId)
111
+ ? 'restates-canonical'
112
+ : 'recovers';
113
+ }
114
+ else if (dimMatch) {
115
+ classification = 'dimensional-only';
116
+ }
117
+ else {
118
+ classification = 'unrelated';
119
+ }
120
+ return { ...base, dimMatch, structuralMatch, recovery, classification };
121
+ }
122
+ /**
123
+ * Scan every canonical entry (with a scalar-AST) against every bridge RHS, and
124
+ * return the non-`unrelated` results — the physicist's linkage worklist.
125
+ */
126
+ export function scanLinkages() {
127
+ const results = [];
128
+ for (const ce of CANONICAL_EQUATIONS) {
129
+ if (!ce.scalarAst)
130
+ continue;
131
+ for (const bridgeId of BRIDGE_RHS_BY_ID.keys()) {
132
+ const r = classifyLinkage(ce.id, bridgeId);
133
+ if (r.classification !== 'unrelated')
134
+ results.push(r);
135
+ }
136
+ }
137
+ return results;
138
+ }
139
+ //# sourceMappingURL=linkage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linkage.js","sourceRoot":"","sources":["../../src/canonical/linkage.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AA2BrD,MAAM,QAAQ,GAAG,CAAC,CAAY,EAAE,CAAY,EAAW,EAAE,CACvD,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IACX,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IACX,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IACX,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IACX,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;IACnB,CAAC,CAAC,CAAC,KAAK,CAAC,CAA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3
+ * multiplicative factors** — the hash the F4 circularity guard uses to decide
4
+ * whether a bridge's RHS and a canonical equation encode the same relation.
5
+ *
6
+ * Two expressions hash equal when they differ only by:
7
+ * - dimensionless multiplicative CONSTANTS (numeric literals + registered
8
+ * named constants: ln2, 4π, …),
9
+ * - product nesting (`(a·b)·c` vs `a·b·c`),
10
+ * - commutative reordering of `*` / `+` operands.
11
+ *
12
+ * They hash DIFFERENT when an exponent differs (T⁴ ≠ T), the non-dimensionless
13
+ * factor set differs, OR a dimensionless **stub** differs. A dimensionless
14
+ * symbol that is NOT a recognized constant is a STUB for an unknown
15
+ * dimensionless quantity (e.g. `ln⟨exp(−βW)⟩` in BE-29) — it is kept as a
16
+ * distinct structural token, so Jarzynski's `ln⟨e^−βW⟩` and Landauer's `ln2`
17
+ * no longer collapse to the same form ("up to a *constant*" must not absorb a
18
+ * differing functional). Sums keep every term; `^` keeps its exponent; `/`
19
+ * keeps the numerator/denominator split.
20
+ *
21
+ * @module canonical/normal-form
22
+ */
23
+ import type { ExprNode } from '../dimensional/validator.js';
24
+ /**
25
+ * The normalized structural form of `node`. Equal strings ⇒ same relation up to
26
+ * dimensionless multiplicative factors.
27
+ */
28
+ export declare function normalForm(node: ExprNode): string;
29
+ /** Whether two scalar ASTs are the same relation up to dimensionless factors. */
30
+ export declare function structurallyEqual(a: ExprNode, b: ExprNode): boolean;
31
+ //# sourceMappingURL=normal-form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normal-form.d.ts","sourceRoot":"","sources":["../../src/canonical/normal-form.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AA6E5D;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CA0DjD;AAED,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,GAAG,OAAO,CAEnE"}
@@ -0,0 +1,137 @@
1
+ import { CONSTANTS } from '../composition/symbolic-constants.js';
2
+ const isDimensionless = (d) => d.L === 0 &&
3
+ d.M === 0 &&
4
+ d.T === 0 &&
5
+ d.I === 0 &&
6
+ d.Theta === 0 &&
7
+ d.N === 0 &&
8
+ d.J === 0;
9
+ /** Token for a node that carries no structural content (a dimensionless factor). */
10
+ const UNIT = '1';
11
+ /**
12
+ * Spelled-out dimensionless numeric constants some encoders write as a named
13
+ * symbol rather than a literal — genuine constants the eval `CONSTANTS`
14
+ * registry happens not to list (it carries only `ln2`/`4pi`/`8pi`). The
15
+ * `\d*pi` pattern covers `pi`/`2pi`/`6pi`/…; `ln_2_constant` is BE-16's spelling
16
+ * of `ln 2`. These stay droppable; everything else dimensionless-and-named is a
17
+ * PARAMETER stub (`alpha`, `lambda`, `g_dark`, `ln⟨e^−βW⟩`, …) and is kept.
18
+ */
19
+ const NAMED_DIMENSIONLESS_CONSTANTS = new Set(['ln_2_constant']);
20
+ const PI_MULTIPLE = /^\d*pi$/;
21
+ /**
22
+ * A dimensionless symbol is a droppable "up to a constant" factor only when it
23
+ * is a numeric literal (`2`, `-1`, `0.5`), a registered named constant
24
+ * (`ln2`, `4pi`, …), or a spelled-out numeric constant (`6pi`, `ln_2_constant`).
25
+ * Any OTHER dimensionless symbol is a stub for an unknown dimensionless quantity
26
+ * (a parameter or a functional like `ln⟨exp(−βW)⟩`) and is structural —
27
+ * dropping it would conflate distinct interiors.
28
+ */
29
+ function isDroppableConstant(name) {
30
+ return (name in CONSTANTS ||
31
+ Number.isFinite(Number(name)) ||
32
+ NAMED_DIMENSIONLESS_CONSTANTS.has(name) ||
33
+ PI_MULTIPLE.test(name));
34
+ }
35
+ /**
36
+ * Full structural serialization that NEVER drops dimensionless factors — used
37
+ * for `^` exponents, which are structural (T⁴ ≠ T) and must not be treated
38
+ * "up to dimensionless factors". Commutative operands are still sorted so the
39
+ * exponent comparison is robust to reordering.
40
+ */
41
+ function rawForm(node) {
42
+ switch (node.kind) {
43
+ case 'symbol':
44
+ return `s:${node.name}`;
45
+ case 'op': {
46
+ const parts = node.args.map(rawForm);
47
+ if (node.op === '*' || node.op === '+')
48
+ parts.sort();
49
+ return `${node.op}(${parts.join(',')})`;
50
+ }
51
+ case 'transcendental':
52
+ return `${node.fn}[${rawForm(node.arg)}]`;
53
+ case 'abs':
54
+ return `abs[${rawForm(node.arg)}]`;
55
+ default:
56
+ return `${node.kind}:${JSON.stringify(node)}`;
57
+ }
58
+ }
59
+ /** Collect the factors of a (possibly nested) `*` product. */
60
+ function flattenProduct(node, out) {
61
+ if (node.kind === 'op' && node.op === '*') {
62
+ for (const a of node.args)
63
+ flattenProduct(a, out);
64
+ }
65
+ else {
66
+ out.push(node);
67
+ }
68
+ }
69
+ /**
70
+ * The normalized structural form of `node`. Equal strings ⇒ same relation up to
71
+ * dimensionless multiplicative factors.
72
+ */
73
+ export function normalForm(node) {
74
+ switch (node.kind) {
75
+ case 'symbol':
76
+ // A non-dimensionless symbol is structural. A dimensionless symbol is a
77
+ // droppable factor ONLY when it is a recognized constant; otherwise it is
78
+ // a stub for an unknown dimensionless quantity and is kept (tagged) so two
79
+ // different stubs do not collapse to the same form.
80
+ if (!isDimensionless(node.dim))
81
+ return `sym:${node.name}`;
82
+ return isDroppableConstant(node.name) ? UNIT : `stub:${node.name}`;
83
+ case 'op': {
84
+ switch (node.op) {
85
+ case '*': {
86
+ const factors = [];
87
+ flattenProduct(node, factors);
88
+ const kept = factors
89
+ .map(normalForm)
90
+ .filter((f) => f !== UNIT) // drop dimensionless factors
91
+ .sort();
92
+ if (kept.length === 0)
93
+ return UNIT;
94
+ if (kept.length === 1)
95
+ return kept[0];
96
+ return `*(${kept.join(',')})`;
97
+ }
98
+ case '/': {
99
+ const num = normalForm(node.args[0]);
100
+ const den = normalForm(node.args[1]);
101
+ if (den === UNIT)
102
+ return num; // ÷ dimensionless ⇒ the numerator
103
+ return `/(${num},${den})`;
104
+ }
105
+ case '^': {
106
+ // The exponent is structural (T⁴ ≠ T) and must NOT be reduced
107
+ // "up to dimensionless factors" — serialize it with rawForm so a
108
+ // dimensionless exponent is never dropped (symmetric for direct
109
+ // symbols and op sub-expressions alike).
110
+ const base = normalForm(node.args[0]);
111
+ return `^(${base},${rawForm(node.args[1])})`;
112
+ }
113
+ case '+':
114
+ case '-': {
115
+ const parts = node.args.map(normalForm);
116
+ if (node.op === '+')
117
+ parts.sort();
118
+ return `${node.op}(${parts.join(',')})`;
119
+ }
120
+ default:
121
+ return `op:${JSON.stringify(node)}`;
122
+ }
123
+ }
124
+ case 'transcendental':
125
+ return `${node.fn}(${normalForm(node.arg)})`;
126
+ case 'abs':
127
+ return `abs(${normalForm(node.arg)})`;
128
+ default:
129
+ // integral / derivative / tensor arms: compare structurally by kind+shape.
130
+ return `${node.kind}:${JSON.stringify(node)}`;
131
+ }
132
+ }
133
+ /** Whether two scalar ASTs are the same relation up to dimensionless factors. */
134
+ export function structurallyEqual(a, b) {
135
+ return normalForm(a) === normalForm(b);
136
+ }
137
+ //# sourceMappingURL=normal-form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normal-form.js","sourceRoot":"","sources":["../../src/canonical/normal-form.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAEjE,MAAM,eAAe,GAAG,CAAC,CAAY,EAAW,EAAE,CAChD,CAAC,CAAC,CAAC,KAAK,CAAC;IACT,CAAC,CAAC,CAAC,KAAK,CAAC;IACT,CAAC,CAAC,CAAC,KAAK,CAAC;IACT,CAAC,CAAC,CAAC,KAAK,CAAC;IACT,CAAC,CAAC,KAAK,KAAK,CAAC;IACb,CAAC,CAAC,CAAC,KAAK,CAAC;IACT,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAEZ,oFAAoF;AACpF,MAAM,IAAI,GAAG,GAAG,CAAC;AAEjB;;;;;;;GAOG;AACH,MAAM,6BAA6B,GAAG,I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AO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;QAExC;YACE,2EAA2E;YAC3E,OAAO,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;IAClD,CAAC;AACH,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,iBAAiB,CAAC,CAAW,EAAE,CAAW;IACxD,OAAO,UAAU,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The canonical-equation registry — the queryable index of the L-layer.
3
+ * Seeded incrementally by `entries/*` modules (Tasks 2,4,5,9); this file owns
4
+ * the assembled array, the id map, and the accessors.
5
+ *
6
+ * @module canonical/registry
7
+ */
8
+ import type { CanonicalEquation, CanonicalDomain } from './canonical-equation.js';
9
+ /** Every canonical equation in the registry. */
10
+ export declare const CANONICAL_EQUATIONS: readonly CanonicalEquation[];
11
+ /** Id → entry. */
12
+ export declare const CANONICAL_BY_ID: Readonly<Record<string, CanonicalEquation>>;
13
+ /** The entry with id `id`, or `undefined`. */
14
+ export declare function canonicalById(id: string): CanonicalEquation | undefined;
15
+ /** Every entry in `domain`. */
16
+ export declare function canonicalByDomain(domain: CanonicalDomain): readonly CanonicalEquation[];
17
+ /** Catalog bridge ids (string form) that at least one canonical entry names as
18
+ * a `partnerBridges` / `restatesBridge` correspondence. */
19
+ export declare function partneredBridgeIds(): Set<string>;
20
+ /**
21
+ * Catalog bridges with NO canonical correspondence partner yet — the explicit,
22
+ * logged coverage gap (review finding F2). Sorted by numeric id. The count is
23
+ * pinned by a test so shrinking it (adding a partner) is a deliberate act.
24
+ */
25
+ export declare function bridgesWithoutCanonicalPartner(): string[];
26
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/canonical/registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAOlF,gDAAgD;AAChD,eAAO,MAAM,mBAAmB,EAAE,SAAS,iBAAiB,EAK3D,CAAC;AAEF,kBAAkB;AAClB,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CACT,CAAC;AAEhE,8CAA8C;AAC9C,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAEvE;AAED,+BAA+B;AAC/B,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,eAAe,GACtB,SAAS,iBAAiB,EAAE,CAE9B;AAED;4DAC4D;AAC5D,wBAAgB,kBAAkB,IAAI,GAAG,CAAC,MAAM,CAAC,CAOhD;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,IAAI,MAAM,EAAE,CAKzD"}
@@ -0,0 +1,46 @@
1
+ import { BRIDGE_EQUATIONS } from '../bridges/index.js';
2
+ import { DIMENSIONAL_CLASSICS } from './entries/dimensional-classics.js';
3
+ import { L1_GRAVITY_THERMO } from './entries/l1-gravity-thermo.js';
4
+ import { L1_QUANTUM_EM } from './entries/l1-quantum-em.js';
5
+ import { RELATIVITY } from './entries/relativity.js';
6
+ /** Every canonical equation in the registry. */
7
+ export const CANONICAL_EQUATIONS = [
8
+ ...DIMENSIONAL_CLASSICS,
9
+ ...L1_GRAVITY_THERMO,
10
+ ...L1_QUANTUM_EM,
11
+ ...RELATIVITY,
12
+ ];
13
+ /** Id → entry. */
14
+ export const CANONICAL_BY_ID = Object.fromEntries(CANONICAL_EQUATIONS.map((e) => [e.id, e]));
15
+ /** The entry with id `id`, or `undefined`. */
16
+ export function canonicalById(id) {
17
+ return CANONICAL_BY_ID[id];
18
+ }
19
+ /** Every entry in `domain`. */
20
+ export function canonicalByDomain(domain) {
21
+ return CANONICAL_EQUATIONS.filter((e) => e.domain === domain);
22
+ }
23
+ /** Catalog bridge ids (string form) that at least one canonical entry names as
24
+ * a `partnerBridges` / `restatesBridge` correspondence. */
25
+ export function partneredBridgeIds() {
26
+ const ids = new Set();
27
+ for (const e of CANONICAL_EQUATIONS) {
28
+ for (const b of e.partnerBridges)
29
+ ids.add(b);
30
+ if (e.restatesBridge)
31
+ ids.add(e.restatesBridge);
32
+ }
33
+ return ids;
34
+ }
35
+ /**
36
+ * Catalog bridges with NO canonical correspondence partner yet — the explicit,
37
+ * logged coverage gap (review finding F2). Sorted by numeric id. The count is
38
+ * pinned by a test so shrinking it (adding a partner) is a deliberate act.
39
+ */
40
+ export function bridgesWithoutCanonicalPartner() {
41
+ const partnered = partneredBridgeIds();
42
+ return BRIDGE_EQUATIONS.map((b) => String(b.id))
43
+ .filter((id) => !partnered.has(id))
44
+ .sort((a, b) => Number(a) - Number(b));
45
+ }
46
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/canonical/registry.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,gDAAgD;AAChD,MAAM,CAAC,MAAM,mBAAmB,GAAiC;IAC/D,GAAG,oBAAoB;IACvB,GAAG,iBAAiB;IACpB,GAAG,aAAa;IAChB,GAAG,UAAU;CACd,CAAC;AAEF,kBAAkB;AAClB,MAAM,CAAC,MAAM,eAAe,GAC1B,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhE,8CAA8C;AAC9C,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,OAAO,eAAe,CAAC,EAAE,CAAC,CAAC;AAC7B,CAAC;AAED,+BAA+B;AAC/B,MAAM,UAAU,iBAAiB,CAC/B,MAAuB;IAEvB,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;AAChE,CAAC;AAED;4DAC4D;AAC5D,MAAM,UAAU,kBAAkB;IAChC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,KAAK,MAAM,CAAC,IAAI,mBAAmB,EAAE,CAAC;QACpC,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,cAAc;YAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC7C,IAAI,CAAC,CAAC,cAAc;YAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,8BAA8B;IAC5C,MAAM,SAAS,GAAG,kBAAkB,EAAE,CAAC;IACvC,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SAC7C,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;SAClC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Seed the canonical-equation registry into the tensor's L-layer (Π = L + B + E)
3
+ * via the existing `addLaw` path. `canonicalToLaw` maps a registry entry onto the
4
+ * `PhysicalLaw` shape; `seedCanonicalLaws` adds them all and returns the count.
5
+ *
6
+ * @module canonical/seed-l-layer
7
+ */
8
+ import type { CanonicalEquation } from './canonical-equation.js';
9
+ import type { PhysicalLaw, TensorConfig } from '../core/types.js';
10
+ import { UniversalTensor } from '../core/tensor.js';
11
+ /** A `TensorConfig` whose axes cover every regime the canonical registry uses,
12
+ * so `seedCanonicalLaws` never trips axis-membership validation. */
13
+ export declare const CANONICAL_TENSOR_CONFIG: TensorConfig;
14
+ /** Map a canonical entry onto the `PhysicalLaw` shape the L-layer consumes.
15
+ * Canonical laws are ground truth → `confidence: 1`. Regime axes map to the
16
+ * law's single-valued axis arrays (empty when the regime leaves an axis open). */
17
+ export declare function canonicalToLaw(ce: CanonicalEquation): PhysicalLaw;
18
+ /** Seed every canonical equation into `t`'s L-layer. Returns the count added. */
19
+ export declare function seedCanonicalLaws(t: UniversalTensor): number;
20
+ //# sourceMappingURL=seed-l-layer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed-l-layer.d.ts","sourceRoot":"","sources":["../../src/canonical/seed-l-layer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD;qEACqE;AACrE,eAAO,MAAM,uBAAuB,EAAE,YAMrC,CAAC;AAEF;;mFAEmF;AACnF,wBAAgB,cAAc,CAAC,EAAE,EAAE,iBAAiB,GAAG,WAAW,CAejE;AAED,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,eAAe,GAAG,MAAM,CAM5D"}
@@ -0,0 +1,39 @@
1
+ import { CANONICAL_EQUATIONS } from './registry.js';
2
+ /** A `TensorConfig` whose axes cover every regime the canonical registry uses,
3
+ * so `seedCanonicalLaws` never trips axis-membership validation. */
4
+ export const CANONICAL_TENSOR_CONFIG = {
5
+ rank: 6,
6
+ scales: ['quantum', 'mesoscopic', 'classical', 'cosmological'],
7
+ forces: ['gravitational', 'electromagnetic', 'weak', 'strong', 'emergent'],
8
+ symmetries: ['poincare', 'gauge', 'conformal', 'susy', 'emergent'],
9
+ informationMeasures: ['vonNeumann', 'shannon', 'kolmogorov', 'quantumDiscord'],
10
+ };
11
+ /** Map a canonical entry onto the `PhysicalLaw` shape the L-layer consumes.
12
+ * Canonical laws are ground truth → `confidence: 1`. Regime axes map to the
13
+ * law's single-valued axis arrays (empty when the regime leaves an axis open). */
14
+ export function canonicalToLaw(ce) {
15
+ const r = ce.regime;
16
+ return {
17
+ id: ce.id,
18
+ name: ce.name,
19
+ equation: ce.formula_latex,
20
+ scales: r.scale ? [r.scale] : [],
21
+ forces: r.force ? [r.force] : [],
22
+ symmetries: r.symmetry ? [r.symmetry] : [],
23
+ confidence: 1,
24
+ informationMeasures: r.information ? [r.information] : undefined,
25
+ dimensions: r.dimension !== undefined ? [r.dimension] : undefined,
26
+ topologies: r.topology !== undefined ? [r.topology] : undefined,
27
+ references: [...ce.references],
28
+ };
29
+ }
30
+ /** Seed every canonical equation into `t`'s L-layer. Returns the count added. */
31
+ export function seedCanonicalLaws(t) {
32
+ let added = 0;
33
+ for (const ce of CANONICAL_EQUATIONS) {
34
+ if (t.addLaw(canonicalToLaw(ce)))
35
+ added++;
36
+ }
37
+ return added;
38
+ }
39
+ //# sourceMappingURL=seed-l-layer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed-l-layer.js","sourceRoot":"","sources":["../../src/canonical/seed-l-layer.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD;qEACqE;AACrE,MAAM,CAAC,MAAM,uBAAuB,GAAiB;IACnD,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC,SAAS,EAAE,YAAY,E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EAAE,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC;KAC/B,CAAC;AACJ,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,iBAAiB,CAAC,CAAkB;IAClD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,EAAE,IAAI,mBAAmB,EAAE,CAAC;QACrC,IAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;YAAE,KAAK,EAAE,CAAC;IAC5C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -35,6 +35,7 @@
35
35
  import type { BridgeEdge } from './edge.js';
36
36
  import type { QuantityIdentification } from './compose.js';
37
37
  import type { LinkCandidate } from './bridge-analysis.js';
38
+ import type { RepresentativeValue } from './representative-values.js';
38
39
  /** A candidate after vetting against the inference suite. @hypothesis */
39
40
  export interface VettedCandidate {
40
41
  readonly a: string;
@@ -65,15 +66,45 @@ export interface VettedCandidate {
65
66
  * falsification, when `numericallyConsistent` is false). Sorted. */
66
67
  readonly inconsistentNodes: readonly string[];
67
68
  /**
68
- * - `contradictory` — breaks numerical consistency (a falsification).
69
- * - `promising` — consistent AND connects disconnected physics AND
70
- * unlocks ≥1 quantity. Worth physicist review.
71
- * - `inert` — consistent but structurally/numerically idle (a
72
- * dimensional coincidence with no consequence).
69
+ * Orders of magnitude between the representative values of a and b
70
+ * (`|log10|va| − log10|vb||`), or `null` when either has no representative
71
+ * value (the gate abstained — see `magnitudeChecked`).
73
72
  */
74
- readonly verdict: 'promising' | 'inert' | 'contradictory';
73
+ readonly ordersApart: number | null;
74
+ /** Both endpoints had a representative value, so the magnitude gate ran. */
75
+ readonly magnitudeChecked: boolean;
76
+ /** The magnitude gate read at least one endpoint value from the graph at
77
+ * the anchor (no static table entry) rather than the sourced table. */
78
+ readonly magnitudeUsedAnchor: boolean;
79
+ /**
80
+ * One endpoint name's hyphen-token set is a strict subset of the other's
81
+ * (`mass` ⊂ `reference-mass`) — a generic↔specific identification of the
82
+ * same KIND. Near-tautological (identifying a generic quantity with one of
83
+ * its own specializations), so it is barred from `promising`.
84
+ */
85
+ readonly subsuming: boolean;
86
+ /**
87
+ * - `magnitude-clash` — representative values differ by more than the
88
+ * threshold N orders (an independent falsification the
89
+ * single-anchor graph cannot make). Checked first.
90
+ * - `contradictory` — breaks numerical consistency (a graph falsification).
91
+ * - `promising` — consistent AND connects disconnected physics AND
92
+ * unlocks ≥1 quantity. Worth physicist review.
93
+ * - `inert` — consistent but structurally/numerically idle (a
94
+ * dimensional coincidence with no consequence).
95
+ */
96
+ readonly verdict: 'promising' | 'inert' | 'contradictory' | 'magnitude-clash';
75
97
  /** Composite ranking score (higher = more worth review). */
76
98
  readonly score: number;
99
+ /**
100
+ * Standard-physics domains whose canonical equation has a TARGET of this
101
+ * candidate's dimension (Sub-project C). Informational context — an empty
102
+ * list means no canonical equation targets this dimension.
103
+ */
104
+ readonly canonicalKinds: readonly string[];
105
+ /** At least one endpoint name is a quantity a canonical equation uses
106
+ * (weak name-based prior; informational). */
107
+ readonly touchesCanonical: boolean;
77
108
  }
78
109
  /** Options for the discovery loop. @internal */
79
110
  export interface DiscoveryOptions {
@@ -84,6 +115,19 @@ export interface DiscoveryOptions {
84
115
  readonly groundTruth?: Readonly<Record<string, number>>;
85
116
  /** Extra identifications honored as the baseline (default registered). */
86
117
  readonly identifications?: readonly QuantityIdentification[];
118
+ /**
119
+ * Max orders of magnitude two identified quantities may differ before the
120
+ * identification is falsified as a `magnitude-clash`. Default 3 — generous
121
+ * enough for O(1) dimensionless prefactors and unit-convention slack, strict
122
+ * enough to kill the scale-clash decoys.
123
+ */
124
+ readonly maxOrdersOfMagnitude?: number;
125
+ /**
126
+ * Sourced order-of-magnitude values for the gate (default
127
+ * `REPRESENTATIVE_VALUES`). Injectable for testing and so the future
128
+ * canonical-equation registry can supply them centrally.
129
+ */
130
+ readonly representativeValues?: Readonly<Record<string, RepresentativeValue>>;
87
131
  }
88
132
  /**
89
133
  * Vet one link candidate by hypothesizing the identification a≡b and
@@ -1 +1 @@
1
- {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/composition/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAK3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,yEAAyE;AACzE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9C;;;;OAIG;IACH,QAAQ,CAAC,qBAAqB,EAAE,OAAO,CAAC;IACxC;yEACqE;IACrE,QAAQ,CAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9C;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,GAAG,eAAe,CAAC;IAC1D,4DAA4D;IAC5D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,gDAAgD;AAChD,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACxD,0EAA0E;IAC1E,QAAQ,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