universal-physics-tensor 0.7.2 → 0.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 (293) hide show
  1. package/README.md +147 -109
  2. package/bin/upt.mjs +508 -0
  3. package/dist/bridges/be23-planckian-confrontation.d.ts +162 -0
  4. package/dist/bridges/be23-planckian-confrontation.d.ts.map +1 -0
  5. package/dist/bridges/be23-planckian-confrontation.js +196 -0
  6. package/dist/bridges/be23-planckian-confrontation.js.map +1 -0
  7. package/dist/bridges/be36-gw170817-confrontation.d.ts +111 -0
  8. package/dist/bridges/be36-gw170817-confrontation.d.ts.map +1 -0
  9. package/dist/bridges/be36-gw170817-confrontation.js +100 -0
  10. package/dist/bridges/be36-gw170817-confrontation.js.map +1 -0
  11. package/dist/bridges/bridge-equations.d.ts +129 -0
  12. package/dist/bridges/bridge-equations.d.ts.map +1 -0
  13. package/dist/bridges/bridge-equations.js +130 -0
  14. package/dist/bridges/bridge-equations.js.map +1 -0
  15. package/dist/bridges/catalog-adapter.d.ts +1 -1
  16. package/dist/bridges/catalog-adapter.js +1 -1
  17. package/dist/bridges/confrontation-coverage.d.ts +67 -0
  18. package/dist/bridges/confrontation-coverage.d.ts.map +1 -0
  19. package/dist/bridges/confrontation-coverage.js +83 -0
  20. package/dist/bridges/confrontation-coverage.js.map +1 -0
  21. package/dist/bridges/equations/_be-helpers.d.ts +2 -1
  22. package/dist/bridges/equations/_be-helpers.d.ts.map +1 -1
  23. package/dist/bridges/equations/be-12-coherence-length.d.ts +1 -1
  24. package/dist/bridges/equations/be-13-einstein-trace.d.ts +2 -2
  25. package/dist/bridges/equations/be-13-einstein-trace.js +1 -1
  26. package/dist/bridges/equations/be-14-ryu-takayanagi.d.ts +2 -2
  27. package/dist/bridges/equations/be-15-emergence.d.ts +19 -5
  28. package/dist/bridges/equations/be-15-emergence.d.ts.map +1 -1
  29. package/dist/bridges/equations/be-15-emergence.js +18 -4
  30. package/dist/bridges/equations/be-15-emergence.js.map +1 -1
  31. package/dist/bridges/equations/be-16-landauer.d.ts +1 -1
  32. package/dist/bridges/equations/be-17-einstein-cartan.d.ts +1 -1
  33. package/dist/bridges/equations/be-18-higgs-mass.d.ts +1 -1
  34. package/dist/bridges/equations/be-19-quantum-bounce.d.ts +1 -1
  35. package/dist/bridges/equations/be-20-vacuum-energy.d.ts +4 -4
  36. package/dist/bridges/equations/be-20-vacuum-energy.d.ts.map +1 -1
  37. package/dist/bridges/equations/be-20-vacuum-energy.js +4 -2
  38. package/dist/bridges/equations/be-20-vacuum-energy.js.map +1 -1
  39. package/dist/bridges/equations/be-22-topological-entanglement.d.ts +1 -1
  40. package/dist/bridges/equations/be-23-syk-planckian.d.ts +1 -1
  41. package/dist/bridges/equations/be-24-foerster-fret.d.ts +1 -1
  42. package/dist/bridges/equations/be-25-iit-phi.d.ts +1 -1
  43. package/dist/bridges/equations/be-25-orch-or.d.ts +13 -1
  44. package/dist/bridges/equations/be-25-orch-or.d.ts.map +1 -1
  45. package/dist/bridges/equations/be-25-orch-or.js +12 -0
  46. package/dist/bridges/equations/be-25-orch-or.js.map +1 -1
  47. package/dist/bridges/equations/be-26-dna-tunneling.d.ts +2 -2
  48. package/dist/bridges/equations/be-26-dna-tunneling.js +1 -1
  49. package/dist/bridges/equations/be-27-effective-temperature.d.ts +1 -1
  50. package/dist/bridges/equations/be-28-onsager-entropy-production.d.ts +1 -1
  51. package/dist/bridges/equations/be-29-jarzynski.d.ts +1 -1
  52. package/dist/bridges/equations/be-30-flm-first-law.d.ts +2 -2
  53. package/dist/bridges/equations/be-31-causal-set-bd.d.ts +1 -1
  54. package/dist/bridges/equations/be-32-quantum-reference-frame.d.ts +1 -1
  55. package/dist/bridges/equations/be-33-hertz-millis.d.ts +1 -1
  56. package/dist/bridges/equations/be-34-kibble-zurek.d.ts +1 -1
  57. package/dist/bridges/equations/be-35-conformal-bootstrap.d.ts +1 -1
  58. package/dist/bridges/equations/be-36-gw-speed-bound.d.ts +12 -5
  59. package/dist/bridges/equations/be-36-gw-speed-bound.d.ts.map +1 -1
  60. package/dist/bridges/equations/be-36-gw-speed-bound.js +11 -4
  61. package/dist/bridges/equations/be-36-gw-speed-bound.js.map +1 -1
  62. package/dist/bridges/equations/be-38-mond.d.ts +1 -1
  63. package/dist/bridges/equations/be-39-asymptotic-safety.d.ts +2 -2
  64. package/dist/bridges/equations/be-40-composite-higgs.d.ts +1 -1
  65. package/dist/bridges/equations/be-41-swampland.d.ts +1 -1
  66. package/dist/bridges/equations/be-43-er-epr.d.ts +1 -1
  67. package/dist/bridges/equations/be-44-soft-hair.d.ts +1 -1
  68. package/dist/bridges/equations/be-45-tcc.d.ts +1 -1
  69. package/dist/bridges/equations/be-46-multiverse-measure.d.ts +1 -1
  70. package/dist/bridges/equations/be-47-bbn-dark-sector.d.ts +1 -1
  71. package/dist/bridges/equations/be-48-grw-localization.d.ts +1 -1
  72. package/dist/bridges/equations/be-49-quantum-darwinism.d.ts +1 -1
  73. package/dist/bridges/equations/be-50-wheeler-feynman.d.ts +1 -1
  74. package/dist/bridges/index.d.ts +10 -7
  75. package/dist/bridges/index.d.ts.map +1 -1
  76. package/dist/bridges/index.js +47 -34
  77. package/dist/bridges/index.js.map +1 -1
  78. package/dist/bridges/membership.d.ts +44 -0
  79. package/dist/bridges/membership.d.ts.map +1 -0
  80. package/dist/bridges/membership.js +59 -0
  81. package/dist/bridges/membership.js.map +1 -0
  82. package/dist/bridges/rejected.d.ts +40 -0
  83. package/dist/bridges/rejected.d.ts.map +1 -0
  84. package/dist/bridges/rejected.js +81 -0
  85. package/dist/bridges/rejected.js.map +1 -0
  86. package/dist/composition/bridge-analysis.d.ts +189 -0
  87. package/dist/composition/bridge-analysis.d.ts.map +1 -0
  88. package/dist/composition/bridge-analysis.js +445 -0
  89. package/dist/composition/bridge-analysis.js.map +1 -0
  90. package/dist/composition/bridge-prediction.d.ts +95 -0
  91. package/dist/composition/bridge-prediction.d.ts.map +1 -0
  92. package/dist/composition/bridge-prediction.js +0 -0
  93. package/dist/composition/bridge-prediction.js.map +1 -0
  94. package/dist/composition/catalog-graph.d.ts +20 -0
  95. package/dist/composition/catalog-graph.d.ts.map +1 -0
  96. package/dist/composition/catalog-graph.js +39 -0
  97. package/dist/composition/catalog-graph.js.map +1 -0
  98. package/dist/composition/compose-surface.d.ts +12 -0
  99. package/dist/composition/compose-surface.d.ts.map +1 -0
  100. package/dist/composition/compose-surface.js +10 -0
  101. package/dist/composition/compose-surface.js.map +1 -0
  102. package/dist/composition/compose-symbolic.d.ts +75 -0
  103. package/dist/composition/compose-symbolic.d.ts.map +1 -0
  104. package/dist/composition/compose-symbolic.js +157 -0
  105. package/dist/composition/compose-symbolic.js.map +1 -0
  106. package/dist/composition/compose.d.ts +110 -0
  107. package/dist/composition/compose.d.ts.map +1 -0
  108. package/dist/composition/compose.js +231 -0
  109. package/dist/composition/compose.js.map +1 -0
  110. package/dist/composition/consistency.d.ts +24 -0
  111. package/dist/composition/consistency.d.ts.map +1 -0
  112. package/dist/composition/consistency.js +26 -0
  113. package/dist/composition/consistency.js.map +1 -0
  114. package/dist/composition/discovery.d.ts +104 -0
  115. package/dist/composition/discovery.d.ts.map +1 -0
  116. package/dist/composition/discovery.js +165 -0
  117. package/dist/composition/discovery.js.map +1 -0
  118. package/dist/composition/edge.d.ts +139 -0
  119. package/dist/composition/edge.d.ts.map +1 -0
  120. package/dist/composition/edge.js +72 -0
  121. package/dist/composition/edge.js.map +1 -0
  122. package/dist/composition/edges/calibration.d.ts +107 -0
  123. package/dist/composition/edges/calibration.d.ts.map +1 -0
  124. package/dist/composition/edges/calibration.js +373 -0
  125. package/dist/composition/edges/calibration.js.map +1 -0
  126. package/dist/composition/edges/catalog-full.d.ts +299 -0
  127. package/dist/composition/edges/catalog-full.d.ts.map +1 -0
  128. package/dist/composition/edges/catalog-full.js +989 -0
  129. package/dist/composition/edges/catalog-full.js.map +1 -0
  130. package/dist/composition/edges/catalog-tranche.d.ts +112 -0
  131. package/dist/composition/edges/catalog-tranche.d.ts.map +1 -0
  132. package/dist/composition/edges/catalog-tranche.js +241 -0
  133. package/dist/composition/edges/catalog-tranche.js.map +1 -0
  134. package/dist/composition/enumerate.d.ts +67 -0
  135. package/dist/composition/enumerate.d.ts.map +1 -0
  136. package/dist/composition/enumerate.js +78 -0
  137. package/dist/composition/enumerate.js.map +1 -0
  138. package/dist/composition/explain.d.ts +102 -0
  139. package/dist/composition/explain.d.ts.map +1 -0
  140. package/dist/composition/explain.js +244 -0
  141. package/dist/composition/explain.js.map +1 -0
  142. package/dist/composition/expr-eval.d.ts +33 -0
  143. package/dist/composition/expr-eval.d.ts.map +1 -0
  144. package/dist/composition/expr-eval.js +95 -0
  145. package/dist/composition/expr-eval.js.map +1 -0
  146. package/dist/composition/expr-simplify.d.ts +60 -0
  147. package/dist/composition/expr-simplify.d.ts.map +1 -0
  148. package/dist/composition/expr-simplify.js +330 -0
  149. package/dist/composition/expr-simplify.js.map +1 -0
  150. package/dist/composition/expr-subst.d.ts +29 -0
  151. package/dist/composition/expr-subst.d.ts.map +1 -0
  152. package/dist/composition/expr-subst.js +60 -0
  153. package/dist/composition/expr-subst.js.map +1 -0
  154. package/dist/composition/identifiability.d.ts +103 -0
  155. package/dist/composition/identifiability.d.ts.map +1 -0
  156. package/dist/composition/identifiability.js +148 -0
  157. package/dist/composition/identifiability.js.map +1 -0
  158. package/dist/composition/index.d.ts +37 -0
  159. package/dist/composition/index.d.ts.map +1 -0
  160. package/dist/composition/index.js +27 -0
  161. package/dist/composition/index.js.map +1 -0
  162. package/dist/composition/quantities.d.ts +297 -0
  163. package/dist/composition/quantities.d.ts.map +1 -0
  164. package/dist/composition/quantities.js +1017 -0
  165. package/dist/composition/quantities.js.map +1 -0
  166. package/dist/composition/quantity.d.ts +59 -0
  167. package/dist/composition/quantity.d.ts.map +1 -0
  168. package/dist/composition/quantity.js +36 -0
  169. package/dist/composition/quantity.js.map +1 -0
  170. package/dist/composition/retrodiction.d.ts +94 -0
  171. package/dist/composition/retrodiction.d.ts.map +1 -0
  172. package/dist/composition/retrodiction.js +171 -0
  173. package/dist/composition/retrodiction.js.map +1 -0
  174. package/dist/composition/symbolic-constants.d.ts +33 -0
  175. package/dist/composition/symbolic-constants.d.ts.map +1 -0
  176. package/dist/composition/symbolic-constants.js +50 -0
  177. package/dist/composition/symbolic-constants.js.map +1 -0
  178. package/dist/composition/uncertainty.d.ts +45 -0
  179. package/dist/composition/uncertainty.d.ts.map +1 -0
  180. package/dist/composition/uncertainty.js +59 -0
  181. package/dist/composition/uncertainty.js.map +1 -0
  182. package/dist/core/axes-registry.d.ts +1 -1
  183. package/dist/core/axes-registry.js +1 -1
  184. package/dist/core/cell.d.ts +0 -8
  185. package/dist/core/cell.d.ts.map +1 -1
  186. package/dist/core/cell.js +1 -1
  187. package/dist/core/cell.js.map +1 -1
  188. package/dist/core/constants.d.ts +15 -1
  189. package/dist/core/constants.d.ts.map +1 -1
  190. package/dist/core/constants.js +15 -1
  191. package/dist/core/constants.js.map +1 -1
  192. package/dist/core/flux-rules.d.ts +10 -13
  193. package/dist/core/flux-rules.d.ts.map +1 -1
  194. package/dist/core/flux-rules.js +19 -10
  195. package/dist/core/flux-rules.js.map +1 -1
  196. package/dist/core/labeled-tensor.d.ts +80 -1
  197. package/dist/core/labeled-tensor.d.ts.map +1 -1
  198. package/dist/core/labeled-tensor.js +263 -17
  199. package/dist/core/labeled-tensor.js.map +1 -1
  200. package/dist/core/universal-index.d.ts +1 -1
  201. package/dist/core/universal-index.js +1 -1
  202. package/dist/dimensional/buckingham.d.ts +103 -0
  203. package/dist/dimensional/buckingham.d.ts.map +1 -0
  204. package/dist/dimensional/buckingham.js +284 -0
  205. package/dist/dimensional/buckingham.js.map +1 -0
  206. package/dist/dimensional/dimension-spec.d.ts +24 -0
  207. package/dist/dimensional/dimension-spec.d.ts.map +1 -0
  208. package/dist/dimensional/dimension-spec.js +110 -0
  209. package/dist/dimensional/dimension-spec.js.map +1 -0
  210. package/dist/dimensional/field-equation-helpers.d.ts +1 -1
  211. package/dist/dimensional/field-equation-helpers.js +1 -1
  212. package/dist/dimensional/friedmann-equation.d.ts +1 -1
  213. package/dist/dimensional/friedmann-equation.js +1 -1
  214. package/dist/dimensional/gauge-field.d.ts +1 -1
  215. package/dist/dimensional/gauge-field.js +1 -1
  216. package/dist/dimensional/klein-gordon-equation.d.ts +8 -5
  217. package/dist/dimensional/klein-gordon-equation.d.ts.map +1 -1
  218. package/dist/dimensional/klein-gordon-equation.js +8 -5
  219. package/dist/dimensional/klein-gordon-equation.js.map +1 -1
  220. package/dist/dimensional/tensor-trace.d.ts +1 -1
  221. package/dist/dimensional/tensor-trace.js +1 -1
  222. package/dist/dimensional/validator.d.ts +13 -3
  223. package/dist/dimensional/validator.d.ts.map +1 -1
  224. package/dist/dimensional/validator.js +129 -42
  225. package/dist/dimensional/validator.js.map +1 -1
  226. package/dist/index.d.ts +32 -2
  227. package/dist/index.d.ts.map +1 -1
  228. package/dist/index.js +63 -2
  229. package/dist/index.js.map +1 -1
  230. package/dist/numerical/be37-covariant-eikonal.d.ts.map +1 -1
  231. package/dist/numerical/be37-covariant-eikonal.js +15 -18
  232. package/dist/numerical/be37-covariant-eikonal.js.map +1 -1
  233. package/dist/numerical/curvature-lowering-helpers.d.ts +7 -13
  234. package/dist/numerical/curvature-lowering-helpers.d.ts.map +1 -1
  235. package/dist/numerical/curvature-lowering-helpers.js +1 -1
  236. package/dist/numerical/curvature-lowering-helpers.js.map +1 -1
  237. package/dist/numerical/derivative-lowering.d.ts +2 -1
  238. package/dist/numerical/derivative-lowering.d.ts.map +1 -1
  239. package/dist/numerical/formula-dimension.d.ts +40 -0
  240. package/dist/numerical/formula-dimension.d.ts.map +1 -0
  241. package/dist/numerical/formula-dimension.js +199 -0
  242. package/dist/numerical/formula-dimension.js.map +1 -0
  243. package/dist/numerical/formula-mathts.d.ts +27 -0
  244. package/dist/numerical/formula-mathts.d.ts.map +1 -0
  245. package/dist/numerical/formula-mathts.js +98 -0
  246. package/dist/numerical/formula-mathts.js.map +1 -0
  247. package/dist/numerical/formula-registry.d.ts +30 -0
  248. package/dist/numerical/formula-registry.d.ts.map +1 -0
  249. package/dist/numerical/formula-registry.js +88 -0
  250. package/dist/numerical/formula-registry.js.map +1 -0
  251. package/dist/numerical/formula.d.ts +75 -0
  252. package/dist/numerical/formula.d.ts.map +1 -0
  253. package/dist/numerical/formula.js +275 -0
  254. package/dist/numerical/formula.js.map +1 -0
  255. package/dist/numerical/geometrized.d.ts +51 -0
  256. package/dist/numerical/geometrized.d.ts.map +1 -0
  257. package/dist/numerical/geometrized.js +66 -0
  258. package/dist/numerical/geometrized.js.map +1 -0
  259. package/dist/numerical/gl4-integrator.d.ts +8 -6
  260. package/dist/numerical/gl4-integrator.d.ts.map +1 -1
  261. package/dist/numerical/gl4-integrator.js +6 -6
  262. package/dist/numerical/gl4-integrator.js.map +1 -1
  263. package/dist/numerical/klein-gordon.d.ts +145 -0
  264. package/dist/numerical/klein-gordon.d.ts.map +1 -0
  265. package/dist/numerical/klein-gordon.js +145 -0
  266. package/dist/numerical/klein-gordon.js.map +1 -0
  267. package/dist/numerical/kretschmann.d.ts +43 -12
  268. package/dist/numerical/kretschmann.d.ts.map +1 -1
  269. package/dist/numerical/kretschmann.js +116 -29
  270. package/dist/numerical/kretschmann.js.map +1 -1
  271. package/dist/numerical/lowering.d.ts +18 -0
  272. package/dist/numerical/lowering.d.ts.map +1 -1
  273. package/dist/numerical/lowering.js +54 -42
  274. package/dist/numerical/lowering.js.map +1 -1
  275. package/dist/numerical/null-ic.d.ts +1 -1
  276. package/dist/numerical/null-ic.d.ts.map +1 -1
  277. package/dist/numerical/null-ic.js +3 -2
  278. package/dist/numerical/null-ic.js.map +1 -1
  279. package/dist/numerical/painleve-gullstrand-metric.d.ts +18 -6
  280. package/dist/numerical/painleve-gullstrand-metric.d.ts.map +1 -1
  281. package/dist/numerical/painleve-gullstrand-metric.js +31 -16
  282. package/dist/numerical/painleve-gullstrand-metric.js.map +1 -1
  283. package/dist/numerical/perihelion-finder.d.ts +4 -3
  284. package/dist/numerical/perihelion-finder.d.ts.map +1 -1
  285. package/dist/numerical/perihelion-finder.js +5 -4
  286. package/dist/numerical/perihelion-finder.js.map +1 -1
  287. package/dist/numerical/types.d.ts +6 -3
  288. package/dist/numerical/types.d.ts.map +1 -1
  289. package/dist/numerical/weyl-lowering.d.ts +4 -4
  290. package/dist/numerical/weyl-lowering.d.ts.map +1 -1
  291. package/dist/numerical/weyl-lowering.js +14 -1
  292. package/dist/numerical/weyl-lowering.js.map +1 -1
  293. package/package.json +21 -4
@@ -114,6 +114,56 @@ export class RankPreservationError extends UPTError {
114
114
  Object.setPrototypeOf(this, RankPreservationError.prototype);
115
115
  }
116
116
  }
117
+ /**
118
+ * Thrown by the `LabeledTensor` constructor when an explicit `axisOrder` is
119
+ * not a valid permutation of the label keys (wrong length, a key that is not a
120
+ * label, or a duplicate). Distinct from `LabeledTensorConstructionError` (which
121
+ * means label-count ≠ tensor-rank) so a consumer never reads a rank-mismatch
122
+ * field on an order error.
123
+ *
124
+ * @public
125
+ */
126
+ export class AxisOrderError extends UPTError {
127
+ axisOrder;
128
+ labelKeys;
129
+ constructor(axisOrder, labelKeys) {
130
+ super(`LabeledTensor: axisOrder [${axisOrder.join(', ')}] is not a permutation ` +
131
+ `of the label keys [${labelKeys.join(', ')}] (it must list every label ` +
132
+ `key exactly once, in engine-axis order).`);
133
+ this.name = 'AxisOrderError';
134
+ this.axisOrder = axisOrder;
135
+ this.labelKeys = labelKeys;
136
+ Object.setPrototypeOf(this, AxisOrderError.prototype);
137
+ }
138
+ }
139
+ /**
140
+ * Thrown by `mergeAxes` when the request is malformed: fewer than two keys, an
141
+ * unknown key, keys that are not a contiguous run of engine-axis positions, or a
142
+ * merged key/id that collides with a surviving axis.
143
+ *
144
+ * @public
145
+ */
146
+ export class AxisMergeError extends UPTError {
147
+ constructor(message) {
148
+ super(`LabeledTensor.mergeAxes: ${message}`);
149
+ this.name = 'AxisMergeError';
150
+ Object.setPrototypeOf(this, AxisMergeError.prototype);
151
+ }
152
+ }
153
+ /**
154
+ * Thrown by `splitAxis` when the request is malformed: an unknown key, fewer
155
+ * than two parts, a non-positive/non-integer part size, a size product that
156
+ * does not match the original axis size, or a part key/id that collides.
157
+ *
158
+ * @public
159
+ */
160
+ export class AxisSplitError extends UPTError {
161
+ constructor(message) {
162
+ super(`LabeledTensor.splitAxis: ${message}`);
163
+ this.name = 'AxisSplitError';
164
+ Object.setPrototypeOf(this, AxisSplitError.prototype);
165
+ }
166
+ }
117
167
  // ---------------------------------------------------------------------------
118
168
  // canonicalLabelOrder — Risk 2 mitigation
119
169
  // ---------------------------------------------------------------------------
@@ -129,6 +179,24 @@ export class RankPreservationError extends UPTError {
129
179
  export function canonicalLabelOrder(labels) {
130
180
  return Object.keys(labels).sort();
131
181
  }
182
+ /**
183
+ * True iff `order` lists exactly the members of `keys`, each once (same length,
184
+ * no duplicates, no foreign entries). Used to validate an explicit `axisOrder`.
185
+ *
186
+ * @internal
187
+ */
188
+ function isPermutationOf(order, keys) {
189
+ if (order.length !== keys.length)
190
+ return false;
191
+ const seen = new Set();
192
+ const keySet = new Set(keys);
193
+ for (const k of order) {
194
+ if (!keySet.has(k) || seen.has(k))
195
+ return false;
196
+ seen.add(k);
197
+ }
198
+ return true;
199
+ }
132
200
  // ---------------------------------------------------------------------------
133
201
  // LabeledTensor (wrapper class)
134
202
  // ---------------------------------------------------------------------------
@@ -146,14 +214,42 @@ export class LabeledTensor {
146
214
  tensor;
147
215
  engine;
148
216
  labels;
149
- constructor(tensor, engine, labels) {
150
- const labelCount = Object.keys(labels).length;
151
- if (labelCount !== tensor.shape.length) {
152
- throw new LabeledTensorConstructionError(labelCount, tensor.shape.length);
217
+ /**
218
+ * The label keys in ENGINE-AXIS order: `axisOrder[i]` is the key of engine
219
+ * axis `i`. This is the AUTHORITATIVE label↔axis mapping — consumers must use
220
+ * it (or {@link axisOf}) rather than re-deriving position by sorting keys,
221
+ * because `transpose` / `contract` can leave the engine axes in a non-sorted
222
+ * order. Defaults to `canonicalLabelOrder(labels)` (sorted) when not supplied.
223
+ */
224
+ axisOrder;
225
+ constructor(tensor, engine, labels, axisOrder) {
226
+ const labelKeys = Object.keys(labels);
227
+ if (labelKeys.length !== tensor.shape.length) {
228
+ throw new LabeledTensorConstructionError(labelKeys.length, tensor.shape.length);
229
+ }
230
+ const order = axisOrder ?? canonicalLabelOrder(labels);
231
+ // Validate `order` is a permutation of the label keys: same length, every
232
+ // entry is a label key, no duplicates.
233
+ if (order.length !== labelKeys.length || !isPermutationOf(order, labelKeys)) {
234
+ throw new AxisOrderError(order, labelKeys);
153
235
  }
154
236
  this.tensor = tensor;
155
237
  this.engine = engine;
156
238
  this.labels = labels;
239
+ this.axisOrder = order;
240
+ }
241
+ /**
242
+ * Engine-axis position of a label key (the inverse of {@link axisOrder}).
243
+ * Throws if the key is not a label.
244
+ *
245
+ * @public
246
+ */
247
+ axisOf(key) {
248
+ const axis = this.axisOrder.indexOf(key);
249
+ if (axis === -1) {
250
+ throw new UPTError(`LabeledTensor.axisOf: '${key}' is not a label key.`);
251
+ }
252
+ return axis;
157
253
  }
158
254
  /**
159
255
  * Identity-aware contraction (Decision #3): match labels by
@@ -174,8 +270,11 @@ export class LabeledTensor {
174
270
  throw new UPTError(`LabeledTensor.contract: engine mismatch (${this.engine.name} vs ` +
175
271
  `${other.engine.name}). Both operands must share an engine.`);
176
272
  }
177
- const leftOrder = canonicalLabelOrder(this.labels);
178
- const rightOrder = canonicalLabelOrder(other.labels);
273
+ // Map labels → ENGINE axis positions via each operand's authoritative
274
+ // axisOrder (NOT sorted key order — an operand may carry a non-sorted order
275
+ // from a prior transpose/contract).
276
+ const leftOrder = this.axisOrder;
277
+ const rightOrder = other.axisOrder;
179
278
  // Build id → (operand, axis-position) sites.
180
279
  const sites = new Map();
181
280
  leftOrder.forEach((key, axis) => {
@@ -194,18 +293,33 @@ export class LabeledTensor {
194
293
  const contractions = [];
195
294
  const free = [];
196
295
  const resultLabels = {};
296
+ // The result's engine-axis order: the result key of each free axis, pushed
297
+ // in the SAME order the free axes enter `spec.free` (which is the order the
298
+ // engine emits result axes). Kept exactly parallel to `free` so it is always
299
+ // a valid permutation of `Object.keys(resultLabels)`.
300
+ const resultAxisOrder = [];
197
301
  for (const [id, occurrences] of sites) {
198
302
  if (occurrences.length === 1) {
199
303
  // Free axis on exactly one operand. Carry through.
200
304
  const o = occurrences[0];
201
305
  free.push({ operand: o.operand, axis: o.axis });
202
- // Preserve the original label key if no collision; otherwise
203
- // suffix with operand index (rare only when both operands
204
- // use the same string key for *different* ids).
205
- const key = resultLabels[o.key] ? `${o.key}_${o.operand}` : o.key;
306
+ // Preserve the original label key; on collision (both operands use the
307
+ // same string key for *different* ids) suffix until a FREE key is found
308
+ // (`x` `x_0`/`x_1` `x_0_0`…), so result keys stay UNIQUE and
309
+ // resultAxisOrder remains a valid permutation (Eve Y1: guarding only the
310
+ // unsuffixed key could overwrite an existing suffixed key).
311
+ let key = o.key;
312
+ if (resultLabels[key] !== undefined) {
313
+ let n = 0;
314
+ do {
315
+ key = `${o.key}_${o.operand}${n === 0 ? '' : `_${n}`}`;
316
+ n++;
317
+ } while (resultLabels[key] !== undefined);
318
+ }
206
319
  resultLabels[key] = o.operand === 0
207
320
  ? this.labels[o.key]
208
321
  : other.labels[o.key];
322
+ resultAxisOrder.push(key);
209
323
  }
210
324
  else if (occurrences.length === 2) {
211
325
  const [a, b] = occurrences;
@@ -227,7 +341,7 @@ export class LabeledTensor {
227
341
  }
228
342
  const spec = { contractions, free };
229
343
  const resultTensor = this.engine.einsum(spec, this.tensor, other.tensor);
230
- return new LabeledTensor(resultTensor, this.engine, resultLabels);
344
+ return new LabeledTensor(resultTensor, this.engine, resultLabels, resultAxisOrder);
231
345
  }
232
346
  /**
233
347
  * Reorder axes per the given permutation of label keys. The new
@@ -237,12 +351,14 @@ export class LabeledTensor {
237
351
  * @public
238
352
  */
239
353
  transpose(newKeyOrder) {
240
- const currentOrder = canonicalLabelOrder(this.labels);
241
- if (newKeyOrder.length !== currentOrder.length) {
354
+ // Permutation is computed against the CURRENT engine-axis order
355
+ // (`this.axisOrder`), NOT the sorted key order — `this.axisOrder` may
356
+ // already be non-sorted (e.g. a contract result, or a prior transpose).
357
+ if (newKeyOrder.length !== this.axisOrder.length) {
242
358
  throw new UPTError(`LabeledTensor.transpose: new key order has ${newKeyOrder.length} ` +
243
- `entries but tensor has ${currentOrder.length} axes.`);
359
+ `entries but tensor has ${this.axisOrder.length} axes.`);
244
360
  }
245
- const currentIndex = new Map(currentOrder.map((k, i) => [k, i]));
361
+ const currentIndex = new Map(this.axisOrder.map((k, i) => [k, i]));
246
362
  const perm = [];
247
363
  for (const key of newKeyOrder) {
248
364
  const pos = currentIndex.get(key);
@@ -252,7 +368,9 @@ export class LabeledTensor {
252
368
  perm.push(pos);
253
369
  }
254
370
  const transposedTensor = this.engine.transpose(this.tensor, perm);
255
- return new LabeledTensor(transposedTensor, this.engine, this.labels);
371
+ // The result's engine axis i is the old axis perm[i] = newKeyOrder[i], so
372
+ // the new axisOrder IS newKeyOrder.
373
+ return new LabeledTensor(transposedTensor, this.engine, this.labels, [...newKeyOrder]);
256
374
  }
257
375
  /**
258
376
  * Per-axis size change. Rank must be preserved (Decision #5);
@@ -269,7 +387,135 @@ export class LabeledTensor {
269
387
  throw new RankPreservationError(this.tensor.shape.length, shape.length);
270
388
  }
271
389
  const reshapedTensor = this.engine.reshape(this.tensor, shape);
272
- return new LabeledTensor(reshapedTensor, this.engine, this.labels);
390
+ // Rank-preserving size change never reorders axes — carry axisOrder through.
391
+ return new LabeledTensor(reshapedTensor, this.engine, this.labels, this.axisOrder);
392
+ }
393
+ /**
394
+ * Fuse a CONTIGUOUS run of engine axes (named by `keys`) into ONE axis
395
+ * carrying the caller-supplied `merged` label. Rank R → R − (keys.length − 1).
396
+ *
397
+ * The keys must occupy a gapless consecutive run of engine-axis positions
398
+ * (`engine.reshape` fuses STORAGE-adjacent axes only) — `transpose` them
399
+ * adjacent first otherwise. The fused axis spans the merged axes in ENGINE
400
+ * order; the order `keys` are listed does not matter (the merged axis is
401
+ * opaque). The caller owns the merged axis's identity — no composite-id is
402
+ * synthesized.
403
+ *
404
+ * @public
405
+ */
406
+ mergeAxes(keys, merged) {
407
+ if (keys.length < 2) {
408
+ throw new AxisMergeError(`need at least 2 keys to merge, got ${keys.length}.`);
409
+ }
410
+ if (new Set(keys).size !== keys.length) {
411
+ throw new AxisMergeError(`keys ${JSON.stringify(keys)} contain a duplicate.`);
412
+ }
413
+ const positions = [];
414
+ for (const k of keys) {
415
+ const p = this.axisOrder.indexOf(k);
416
+ if (p === -1)
417
+ throw new AxisMergeError(`'${k}' is not a label key.`);
418
+ positions.push(p);
419
+ }
420
+ const sorted = [...positions].sort((a, b) => a - b);
421
+ const lo = sorted[0];
422
+ const hi = sorted[sorted.length - 1];
423
+ if (new Set(sorted).size !== sorted.length || hi - lo !== sorted.length - 1) {
424
+ throw new AxisMergeError(`keys ${JSON.stringify(keys)} are not a contiguous run of engine axes ` +
425
+ `(positions ${JSON.stringify(positions)}); transpose them adjacent first.`);
426
+ }
427
+ // Surviving keys = axes outside the merged run. (A merged key may safely
428
+ // REUSE one of the consumed keys' names — those are not surviving.)
429
+ const survivingKeys = this.axisOrder.filter((_, i) => i < lo || i > hi);
430
+ if (survivingKeys.includes(merged.key)) {
431
+ throw new AxisMergeError(`merged key '${merged.key}' collides with a surviving label key.`);
432
+ }
433
+ for (const k of survivingKeys) {
434
+ if (this.labels[k].id === merged.index.id) {
435
+ throw new AxisMergeError(`merged id '${merged.index.id}' collides with surviving axis '${k}'.`);
436
+ }
437
+ }
438
+ const shape = this.tensor.shape;
439
+ let mergedSize = 1;
440
+ for (let i = lo; i <= hi; i++)
441
+ mergedSize *= shape[i];
442
+ const newShape = [...shape.slice(0, lo), mergedSize, ...shape.slice(hi + 1)];
443
+ const newLabels = {};
444
+ for (const k of survivingKeys)
445
+ newLabels[k] = this.labels[k];
446
+ newLabels[merged.key] = merged.index;
447
+ const newAxisOrder = [
448
+ ...this.axisOrder.slice(0, lo),
449
+ merged.key,
450
+ ...this.axisOrder.slice(hi + 1),
451
+ ];
452
+ const reshaped = this.engine.reshape(this.tensor, newShape);
453
+ return new LabeledTensor(reshaped, this.engine, newLabels, newAxisOrder);
454
+ }
455
+ /**
456
+ * Split ONE engine axis (named `key`) into several, each carrying a
457
+ * caller-supplied sub-label whose sizes multiply to the original axis size.
458
+ * Rank R → R + (parts.length − 1). The parts occupy the split axis's position
459
+ * in `parts` order. Inverse of {@link mergeAxes}.
460
+ *
461
+ * @public
462
+ */
463
+ splitAxis(key, parts) {
464
+ const p = this.axisOrder.indexOf(key);
465
+ if (p === -1)
466
+ throw new AxisSplitError(`'${key}' is not a label key.`);
467
+ if (parts.length < 2) {
468
+ throw new AxisSplitError(`need at least 2 parts to split into, got ${parts.length}.`);
469
+ }
470
+ let product = 1;
471
+ for (const part of parts) {
472
+ if (!Number.isInteger(part.size) || part.size <= 0) {
473
+ throw new AxisSplitError(`part '${part.key}' size must be a positive integer, got ${part.size}.`);
474
+ }
475
+ product *= part.size;
476
+ }
477
+ const axisSize = this.tensor.shape[p];
478
+ if (product !== axisSize) {
479
+ throw new AxisSplitError(`part sizes multiply to ${product} but axis '${key}' has size ${axisSize}.`);
480
+ }
481
+ const survivingKeys = this.axisOrder.filter((k) => k !== key);
482
+ const seen = new Set();
483
+ const seenIds = new Set();
484
+ for (const part of parts) {
485
+ if (survivingKeys.includes(part.key)) {
486
+ throw new AxisSplitError(`part key '${part.key}' collides with a surviving label key.`);
487
+ }
488
+ if (seen.has(part.key))
489
+ throw new AxisSplitError(`duplicate part key '${part.key}'.`);
490
+ seen.add(part.key);
491
+ // Both parts SURVIVE, so two parts sharing one id would build a tensor
492
+ // that `contract` later rejects as IdentityConflictError — fail here at
493
+ // the malformed call instead (Eve Y1). (mergeAxes has no analogue: its
494
+ // merged id replaces consumed axes, so reusing a consumed id is legal.)
495
+ if (seenIds.has(part.index.id)) {
496
+ throw new AxisSplitError(`two parts share id '${part.index.id}'.`);
497
+ }
498
+ seenIds.add(part.index.id);
499
+ for (const k of survivingKeys) {
500
+ if (this.labels[k].id === part.index.id) {
501
+ throw new AxisSplitError(`part id '${part.index.id}' collides with surviving axis '${k}'.`);
502
+ }
503
+ }
504
+ }
505
+ const shape = this.tensor.shape;
506
+ const newShape = [...shape.slice(0, p), ...parts.map((pt) => pt.size), ...shape.slice(p + 1)];
507
+ const newLabels = {};
508
+ for (const k of survivingKeys)
509
+ newLabels[k] = this.labels[k];
510
+ for (const part of parts)
511
+ newLabels[part.key] = part.index;
512
+ const newAxisOrder = [
513
+ ...this.axisOrder.slice(0, p),
514
+ ...parts.map((pt) => pt.key),
515
+ ...this.axisOrder.slice(p + 1),
516
+ ];
517
+ const reshaped = this.engine.reshape(this.tensor, newShape);
518
+ return new LabeledTensor(reshaped, this.engine, newLabels, newAxisOrder);
273
519
  }
274
520
  }
275
521
  //# sourceMappingURL=labeled-tensor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"labeled-tensor.js","sourceRoot":"","sources":["../../src/core/labeled-tensor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD,8EAA8E;AAC9E,qEAAqE;AACrE,8BAA8B;AAC9B,8EAA8E;AAE9E;;;;;;GAMG;AACH,MAAM,OAAO,8BAA+B,SAAQ,QAAQ;IAC1C,UAAU,CAAS;IACnB,UAAU,CAAS;IACnC,YAAY,UAAkB,EAAE,UAAkB;QAChD,KAAK,CACH,oCAAoC,UAAU,eAAe;YAC7D,kBAAkB,UAAU,yCAAyC;YACrE,2BAA2B,CAC5B,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC;QAC7C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU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GAAG,CAAC,CAAC;SAC/B,CAAC;QAEF,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC5D,OAAO,IAAI,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;IAC3E,CAAC;CACF"}
@@ -15,7 +15,7 @@
15
15
  *
16
16
  * Design: `docs/planning/v0.7-Proposal-1-Design.md` Decisions #2,
17
17
  * #4, #10. Empirical census at
18
- * `docs/architecture/v0.7-p1-baseline.md`.
18
+ * `docs/architecture/archive/v0.7-p1-baseline.md`.
19
19
  *
20
20
  * Per Eve verification (proposals doc has ZERO `prime` / `arrow`
21
21
  * mentions), v0.7.0 ships only the §2.2 sketch fields:
@@ -15,7 +15,7 @@
15
15
  *
16
16
  * Design: `docs/planning/v0.7-Proposal-1-Design.md` Decisions #2,
17
17
  * #4, #10. Empirical census at
18
- * `docs/architecture/v0.7-p1-baseline.md`.
18
+ * `docs/architecture/archive/v0.7-p1-baseline.md`.
19
19
  *
20
20
  * Per Eve verification (proposals doc has ZERO `prime` / `arrow`
21
21
  * mentions), v0.7.0 ships only the §2.2 sketch fields:
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Buckingham-π enumerator (build target 1 of
3
+ * docs/planning/Bridge-Inference-Epistemics-Note.md — the principled
4
+ * primitive for the classifier's EXACTLY-DETERMINED case).
5
+ *
6
+ * Given a set of dimensional variables presumed to obey one
7
+ * dimensionally-homogeneous relation, the Buckingham-π theorem says that
8
+ * relation re-expresses as F(π₁,…,π_{n−r}) = 0, where each πᵢ is a
9
+ * dimensionless power-product of the variables and there are exactly
10
+ * n − r of them (n = variables, r = rank of the dimension matrix). The
11
+ * π-groups are a basis of the NULL SPACE of the dimension matrix.
12
+ *
13
+ * THE HONEST BOUNDARY (enforced by the result types — there is no value
14
+ * or constant field anywhere): this returns the FORM only. It yields the
15
+ * π-groups and, for a target, the monomial that determines it UP TO A
16
+ * DIMENSIONLESS CONSTANT (the 2π, the ½, α). It does NOT and cannot
17
+ * supply that constant, nor the function F. That boundary is exactly what
18
+ * separates dimensional analysis from numerology — see the epistemics
19
+ * note.
20
+ *
21
+ * Computation is EXACT (rational arithmetic), not floating Gaussian
22
+ * elimination: physics dimension exponents are small rationals, and the
23
+ * null-space basis must be exact to be trustworthy.
24
+ *
25
+ * @module dimensional/buckingham
26
+ */
27
+ import type { Dimension } from './types.js';
28
+ /** A named physical quantity with a dimension — the enumerator's input.
29
+ * Structurally satisfied by a composition `Quantity`. @public */
30
+ export interface DimensionalVariable {
31
+ readonly name: string;
32
+ readonly dim: Dimension;
33
+ }
34
+ /** A dimensionless power-product of the input variables (integer
35
+ * exponents; the conventional form). No value — π-groups carry FORM,
36
+ * not magnitude. @public */
37
+ export interface PiGroup {
38
+ /** Integer exponent of each variable in this dimensionless product. */
39
+ readonly exponents: Readonly<Record<string, number>>;
40
+ /** Display form, e.g. `period^2 · gravity · length^-1`. */
41
+ readonly formula: string;
42
+ }
43
+ /** The dimensional closure of a variable set. @public */
44
+ export type BuckinghamVerdict = 'dimensionally-independent' | 'single-invariant' | 'multiple-invariants';
45
+ /** Result of {@link buckinghamPi}. @public */
46
+ export interface BuckinghamResult {
47
+ readonly variables: readonly string[];
48
+ /** Base SI dimensions actually spanned by the inputs. */
49
+ readonly baseDimensions: readonly string[];
50
+ /** n — the number of variables. */
51
+ readonly variableCount: number;
52
+ /** r — the rank of the dimension matrix. */
53
+ readonly rank: number;
54
+ /** n − r — the number of independent dimensionless groups. */
55
+ readonly piGroupCount: number;
56
+ readonly piGroups: readonly PiGroup[];
57
+ readonly verdict: BuckinghamVerdict;
58
+ }
59
+ /** Result of {@link dimensionallyDetermines}. @public */
60
+ export interface DimensionalDeterminationResult {
61
+ readonly target: string;
62
+ readonly governing: readonly string[];
63
+ /** True iff the target is fixed by the governing variables UP TO A
64
+ * DIMENSIONLESS CONSTANT (unique monomial). */
65
+ readonly determined: boolean;
66
+ /**
67
+ * When determined: target = const · Π(governingⱼ ^ monomial[j]). The
68
+ * exponents may be rational (e.g. 0.5 for a √ law). Always read with
69
+ * `upToDimensionlessConstant` — the leading constant is NOT supplied.
70
+ */
71
+ readonly monomial?: Readonly<Record<string, number>>;
72
+ /** Always true when `monomial` is present — a standing reminder. */
73
+ readonly upToDimensionlessConstant?: true;
74
+ /** Plain-language reason for the verdict. */
75
+ readonly reason: string;
76
+ }
77
+ /** Rationalization failed: a dimension exponent is not a small rational.
78
+ * @public */
79
+ export declare class RationalizationError extends Error {
80
+ constructor(message: string);
81
+ }
82
+ /**
83
+ * Enumerate the Buckingham-π groups of a dimensional variable set. Returns
84
+ * the rank, the count n − r, and a null-space basis of dimensionless
85
+ * groups. FORM only — no constants (see module docs).
86
+ *
87
+ * @public
88
+ */
89
+ export declare function buckinghamPi(variables: readonly DimensionalVariable[]): BuckinghamResult;
90
+ /**
91
+ * Does the governing set fix the target UP TO A DIMENSIONLESS CONSTANT?
92
+ *
93
+ * True iff the governing variables are dimensionally independent and the
94
+ * target's dimension lies in their span — equivalently, the full set has
95
+ * exactly one π-group and the governing set has none. When determined,
96
+ * returns the (possibly rational) monomial exponents such that
97
+ * target = const · Π(governingⱼ ^ monomial[j]). The constant is NOT
98
+ * supplied — dimensional analysis cannot.
99
+ *
100
+ * @public
101
+ */
102
+ export declare function dimensionallyDetermines(target: DimensionalVariable, governing: readonly DimensionalVariable[]): DimensionalDeterminationResult;
103
+ //# sourceMappingURL=buckingham.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buckingham.d.ts","sourceRoot":"","sources":["../../src/dimensional/buckingham.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAI5C;kEACkE;AAClE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,C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