universal-physics-tensor 0.7.3 → 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 +19 -8
@@ -0,0 +1,284 @@
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
+ const BASES = ['L', 'M', 'T', 'I', 'Theta', 'N', 'J'];
28
+ /** Rationalization failed: a dimension exponent is not a small rational.
29
+ * @public */
30
+ export class RationalizationError extends Error {
31
+ constructor(message) {
32
+ super(message);
33
+ this.name = 'RationalizationError';
34
+ }
35
+ }
36
+ function gcd(a, b) {
37
+ a = Math.abs(a);
38
+ b = Math.abs(b);
39
+ while (b) {
40
+ [a, b] = [b, a % b];
41
+ }
42
+ return a || 1;
43
+ }
44
+ function frac(n, d) {
45
+ if (d === 0)
46
+ throw new RationalizationError('zero denominator');
47
+ if (d < 0) {
48
+ n = -n;
49
+ d = -d;
50
+ }
51
+ const g = gcd(n, d);
52
+ return { n: n / g, d: d / g };
53
+ }
54
+ const MAX_DEN = 720;
55
+ /** Convert a (possibly rational) exponent to an exact fraction by scanning
56
+ * small denominators; throws if none matches within tolerance. */
57
+ function toFrac(x) {
58
+ if (Number.isInteger(x))
59
+ return { n: x, d: 1 };
60
+ for (let d = 2; d <= MAX_DEN; d++) {
61
+ const n = x * d;
62
+ if (Math.abs(n - Math.round(n)) < 1e-9 * Math.max(1, Math.abs(n))) {
63
+ return frac(Math.round(n), d);
64
+ }
65
+ }
66
+ throw new RationalizationError(`dimension exponent ${x} is not a rational with denominator ≤ ${MAX_DEN}`);
67
+ }
68
+ const fAdd = (a, b) => frac(a.n * b.d + b.n * a.d, a.d * b.d);
69
+ const fSub = (a, b) => frac(a.n * b.d - b.n * a.d, a.d * b.d);
70
+ const fMul = (a, b) => frac(a.n * b.n, a.d * b.d);
71
+ const fDiv = (a, b) => {
72
+ if (b.n === 0)
73
+ throw new RationalizationError('division by zero fraction');
74
+ return frac(a.n * b.d, a.d * b.n);
75
+ };
76
+ const fZero = (a) => a.n === 0;
77
+ function lcm(a, b) {
78
+ return Math.abs(a * b) / gcd(a, b);
79
+ }
80
+ // ---------------------------------------------------------------------------
81
+ // Linear algebra: RREF + null-space basis over exact fractions.
82
+ // ---------------------------------------------------------------------------
83
+ /** Reduce `M` (rows × cols of Frac) to RREF in place; return pivot columns. */
84
+ function rref(M, rows, cols) {
85
+ const pivotCols = [];
86
+ let r = 0;
87
+ for (let c = 0; c < cols && r < rows; c++) {
88
+ let p = -1;
89
+ for (let i = r; i < rows; i++) {
90
+ if (!fZero(M[i][c])) {
91
+ p = i;
92
+ break;
93
+ }
94
+ }
95
+ if (p === -1)
96
+ continue;
97
+ [M[r], M[p]] = [M[p], M[r]];
98
+ const pivot = M[r][c];
99
+ for (let j = 0; j < cols; j++)
100
+ M[r][j] = fDiv(M[r][j], pivot);
101
+ for (let i = 0; i < rows; i++) {
102
+ if (i === r || fZero(M[i][c]))
103
+ continue;
104
+ const factor = M[i][c];
105
+ for (let j = 0; j < cols; j++) {
106
+ M[i][j] = fSub(M[i][j], fMul(factor, M[r][j]));
107
+ }
108
+ }
109
+ pivotCols.push(c);
110
+ r++;
111
+ }
112
+ return pivotCols;
113
+ }
114
+ /** Integerize a fraction vector: scale by the LCM of denominators, then
115
+ * normalize the sign so the first nonzero entry is positive. */
116
+ function integerize(vec) {
117
+ let L = 1;
118
+ for (const f of vec)
119
+ if (!fZero(f))
120
+ L = lcm(L, f.d);
121
+ // exact integer: L is a multiple of every denominator.
122
+ const out = vec.map((f) => f.n * (L / f.d));
123
+ const g = out.reduce((acc, x) => (x ? gcd(acc, x) : acc), 0) || 1;
124
+ for (let i = 0; i < out.length; i++)
125
+ out[i] = out[i] / g;
126
+ const firstNonZero = out.find((x) => x !== 0) ?? 0;
127
+ if (firstNonZero < 0)
128
+ for (let i = 0; i < out.length; i++)
129
+ out[i] = -out[i];
130
+ return out;
131
+ }
132
+ /** Null-space basis of the dimension matrix as integer exponent vectors,
133
+ * one per free column (variable). */
134
+ function nullSpace(matrix, rows, cols) {
135
+ const M = matrix.map((row) => row.slice());
136
+ const pivotCols = rref(M, rows, cols);
137
+ const pivotSet = new Set(pivotCols);
138
+ const freeCols = [];
139
+ for (let c = 0; c < cols; c++)
140
+ if (!pivotSet.has(c))
141
+ freeCols.push(c);
142
+ const basis = [];
143
+ for (const f of freeCols) {
144
+ const vec = Array.from({ length: cols }, () => ({ n: 0, d: 1 }));
145
+ vec[f] = { n: 1, d: 1 };
146
+ for (let i = 0; i < pivotCols.length; i++) {
147
+ vec[pivotCols[i]] = fSub({ n: 0, d: 1 }, M[i][f]); // -M[pivotRow_i][f]
148
+ }
149
+ basis.push(integerize(vec));
150
+ }
151
+ return basis;
152
+ }
153
+ function buildMatrix(variables) {
154
+ const spannedBases = [];
155
+ const matrix = [];
156
+ for (const base of BASES) {
157
+ const row = variables.map((v) => toFrac(v.dim[base]));
158
+ if (row.some((f) => !fZero(f))) {
159
+ spannedBases.push(base);
160
+ matrix.push(row);
161
+ }
162
+ }
163
+ return { matrix, spannedBases };
164
+ }
165
+ function formatPiGroup(exponents, order) {
166
+ const parts = [];
167
+ for (const name of order) {
168
+ const e = exponents[name];
169
+ if (e === 0)
170
+ continue;
171
+ parts.push(e === 1 ? name : `${name}^${e}`);
172
+ }
173
+ return parts.join(' · ') || '1';
174
+ }
175
+ /**
176
+ * Enumerate the Buckingham-π groups of a dimensional variable set. Returns
177
+ * the rank, the count n − r, and a null-space basis of dimensionless
178
+ * groups. FORM only — no constants (see module docs).
179
+ *
180
+ * @public
181
+ */
182
+ export function buckinghamPi(variables) {
183
+ if (variables.length === 0) {
184
+ throw new RationalizationError('buckinghamPi requires at least one variable');
185
+ }
186
+ const names = variables.map((v) => v.name);
187
+ if (new Set(names).size !== names.length) {
188
+ throw new RationalizationError(`buckinghamPi requires unique variable names; got [${names.join(', ')}]`);
189
+ }
190
+ const n = variables.length;
191
+ const { matrix, spannedBases } = buildMatrix(variables);
192
+ const rows = matrix.length;
193
+ // Rank via RREF on a copy.
194
+ const rank = rref(matrix.map((r) => r.slice()), rows, n).length;
195
+ const basis = nullSpace(matrix, rows, n);
196
+ const piGroups = basis.map((vec) => {
197
+ const exponents = {};
198
+ for (let j = 0; j < n; j++)
199
+ exponents[names[j]] = vec[j];
200
+ return { exponents, formula: formatPiGroup(exponents, names) };
201
+ });
202
+ const piGroupCount = n - rank;
203
+ const verdict = piGroupCount === 0
204
+ ? 'dimensionally-independent'
205
+ : piGroupCount === 1
206
+ ? 'single-invariant'
207
+ : 'multiple-invariants';
208
+ return {
209
+ variables: names,
210
+ baseDimensions: spannedBases,
211
+ variableCount: n,
212
+ rank,
213
+ piGroupCount,
214
+ piGroups,
215
+ verdict,
216
+ };
217
+ }
218
+ /**
219
+ * Does the governing set fix the target UP TO A DIMENSIONLESS CONSTANT?
220
+ *
221
+ * True iff the governing variables are dimensionally independent and the
222
+ * target's dimension lies in their span — equivalently, the full set has
223
+ * exactly one π-group and the governing set has none. When determined,
224
+ * returns the (possibly rational) monomial exponents such that
225
+ * target = const · Π(governingⱼ ^ monomial[j]). The constant is NOT
226
+ * supplied — dimensional analysis cannot.
227
+ *
228
+ * @public
229
+ */
230
+ export function dimensionallyDetermines(target, governing) {
231
+ const governingNames = governing.map((v) => v.name);
232
+ const governingPi = buckinghamPi(governing.length > 0 ? governing : [target]);
233
+ // A redundancy among the governing variables means the monomial is not
234
+ // unique (any dimensionless governing combo can be folded into the
235
+ // constant) → not determined.
236
+ if (governing.length > 0 && governingPi.piGroupCount > 0) {
237
+ return {
238
+ target: target.name,
239
+ governing: governingNames,
240
+ determined: false,
241
+ reason: 'governing variables are dimensionally dependent ' +
242
+ `(${governingPi.piGroupCount} dimensionless combination(s) among them); ` +
243
+ 'the determining monomial is not unique',
244
+ };
245
+ }
246
+ const full = buckinghamPi([target, ...governing]);
247
+ if (full.piGroupCount !== 1) {
248
+ return {
249
+ target: target.name,
250
+ governing: governingNames,
251
+ determined: false,
252
+ reason: full.piGroupCount === 0
253
+ ? "the target's dimension is not in the span of the governing " +
254
+ 'variables — no dimensionless group exists, so no monomial determines it'
255
+ : `${full.piGroupCount} independent π-groups — the target is fixed ` +
256
+ 'only as a function of several dimensionless ratios (under-constrained)',
257
+ };
258
+ }
259
+ // The single π-group involves the target; solve it for the target.
260
+ const group = full.piGroups[0].exponents;
261
+ const targetExp = group[target.name];
262
+ if (!targetExp) {
263
+ return {
264
+ target: target.name,
265
+ governing: governingNames,
266
+ determined: false,
267
+ reason: 'the sole dimensionless group does not involve the target ' +
268
+ '(the target is dimensionally redundant with the governing set)',
269
+ };
270
+ }
271
+ const monomial = {};
272
+ for (const name of governingNames) {
273
+ monomial[name] = -(group[name] ?? 0) / targetExp;
274
+ }
275
+ return {
276
+ target: target.name,
277
+ governing: governingNames,
278
+ determined: true,
279
+ monomial,
280
+ upToDimensionlessConstant: true,
281
+ reason: 'unique dimensionless group fixes the target up to a dimensionless constant',
282
+ };
283
+ }
284
+ //# sourceMappingURL=buckingham.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buckingham.js","sourceRoot":"","sources":["../../src/dimensional/buckingham.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC;AA2D/D;cACc;AACd,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAYD,SAAS,GAAG,CAAC,CAAS,EAAE,CAAS;IAC/B,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAChB,OAAO,CAAC,EAAE,CAAC;QACT,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED,SAAS,IAAI,CAAC,CAAS,EAAE,CAAS;IAChC,IAAI,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,oBAAoB,CAAC,kBAAkB,CAAC,CAAC;IAChE,IAAI,CAAC,GAAG,CAAC,EA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C,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;IAClD,IAAI,IAAI,CAAC,YAAY,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO;YACL,MAAM,EAAE,MAAM,CAAC,IAAI;YACnB,SAAS,EAAE,cAAc;YACzB,UAAU,EAAE,KAAK;YACjB,MAAM,EACJ,IAAI,CAAC,YAAY,KAAK,CAAC;gBACrB,CAAC,CAAC,6DAA6D;oBAC7D,yEAAyE;gBAC3E,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,8CAA8C;oBAClE,wEAAwE;SAC/E,CAAC;IACJ,CAAC;IAED,mEAAmE;IACnE,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACzC,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO;YACL,MAAM,EAAE,MAAM,CAAC,IAAI;YACnB,SAAS,EAAE,cAAc;YACzB,UAAU,EAAE,KAAK;YACjB,MAAM,EACJ,2DAA2D;gBAC3D,gEAAgE;SACnE,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAA2B,EAAE,CAAC;IAC5C,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;QAClC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;IACnD,CAAC;IAED,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,IAAI;QACnB,SAAS,EAAE,cAAc;QACzB,UAAU,EAAE,IAAI;QAChB,QAAQ;QACR,yBAAyB,EAAE,IAAI;QAC/B,MAAM,EACJ,4EAA4E;KAC/E,CAAC;AACJ,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Dimension-spec parser — turns a human string into a {@link Dimension},
3
+ * so CLI users can declare a quantity's dimensions without TypeScript.
4
+ *
5
+ * Accepts (in priority order):
6
+ * 1. a named dimension — `length`, `time`, `mass`, `velocity`,
7
+ * `acceleration`, `force`, `energy`, `power`, `action`, `frequency`,
8
+ * `temperature`, `entropy`, `charge`, `area`, `dimensionless`;
9
+ * 2. a fundamental constant by name — `hbar`/`ℏ`, `c`, `G`, `k_B`/`kB`,
10
+ * `e` (its SI dimension);
11
+ * 3. explicit base exponents — `L^3.M^-1.T^-2` (bases L M T I Theta/Θ N J,
12
+ * separated by `.`, `*`, or spaces; `^` optional; fractional exponents
13
+ * like `T^1/2` allowed).
14
+ *
15
+ * @module dimensional/dimension-spec
16
+ */
17
+ import type { Dimension } from './types.js';
18
+ /** A bad dimension spec. */
19
+ export declare class DimensionSpecError extends Error {
20
+ constructor(message: string);
21
+ }
22
+ /** Parse a dimension spec string into a {@link Dimension}. @internal */
23
+ export declare function parseDimensionSpec(spec: string): Dimension;
24
+ //# sourceMappingURL=dimension-spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dimension-spec.d.ts","sourceRoot":"","sources":["../../src/dimensional/dimension-spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAmB5C,4BAA4B;AAC5B,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAoED,wEAAwE;AACxE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CA0B1D"}
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Dimension-spec parser — turns a human string into a {@link Dimension},
3
+ * so CLI users can declare a quantity's dimensions without TypeScript.
4
+ *
5
+ * Accepts (in priority order):
6
+ * 1. a named dimension — `length`, `time`, `mass`, `velocity`,
7
+ * `acceleration`, `force`, `energy`, `power`, `action`, `frequency`,
8
+ * `temperature`, `entropy`, `charge`, `area`, `dimensionless`;
9
+ * 2. a fundamental constant by name — `hbar`/`ℏ`, `c`, `G`, `k_B`/`kB`,
10
+ * `e` (its SI dimension);
11
+ * 3. explicit base exponents — `L^3.M^-1.T^-2` (bases L M T I Theta/Θ N J,
12
+ * separated by `.`, `*`, or spaces; `^` optional; fractional exponents
13
+ * like `T^1/2` allowed).
14
+ *
15
+ * @module dimensional/dimension-spec
16
+ */
17
+ import { DIMENSIONLESS, LENGTH, AREA, TIME, FREQUENCY, MASS, VELOCITY, ACCELERATION, FORCE, ENERGY, POWER, ACTION, TEMPERATURE, ENTROPY, CHARGE, } from './types.js';
18
+ /** A bad dimension spec. */
19
+ export class DimensionSpecError extends Error {
20
+ constructor(message) {
21
+ super(message);
22
+ this.name = 'DimensionSpecError';
23
+ }
24
+ }
25
+ const d = (L = 0, M = 0, T = 0, Theta = 0, I = 0) => ({ L, M, T, I, Theta, N: 0, J: 0 });
26
+ /** Named dimensions — matched case-insensitively. */
27
+ const NAMED_DIMS = {
28
+ dimensionless: DIMENSIONLESS,
29
+ length: LENGTH,
30
+ area: AREA,
31
+ time: TIME,
32
+ frequency: FREQUENCY,
33
+ mass: MASS,
34
+ velocity: VELOCITY,
35
+ acceleration: ACCELERATION,
36
+ force: FORCE,
37
+ energy: ENERGY,
38
+ power: POWER,
39
+ action: ACTION,
40
+ temperature: TEMPERATURE,
41
+ entropy: ENTROPY,
42
+ charge: CHARGE,
43
+ };
44
+ /** Fundamental constants by their SI dimension — matched EXACT-case, so
45
+ * `G` (Newton's constant) is never confused with `g` (acceleration). */
46
+ const CONST_DIMS = {
47
+ hbar: ACTION,
48
+ 'ℏ': ACTION,
49
+ c: VELOCITY,
50
+ G: d(3, -1, -2),
51
+ k_B: ENTROPY, // Boltzmann (J/K)
52
+ kB: ENTROPY,
53
+ e: CHARGE, // elementary charge (A·s)
54
+ };
55
+ const BASES = {
56
+ L: 'L',
57
+ M: 'M',
58
+ T: 'T',
59
+ I: 'I',
60
+ THETA: 'Theta',
61
+ 'Θ': 'Theta',
62
+ N: 'N',
63
+ J: 'J',
64
+ };
65
+ function parseExponent(raw) {
66
+ if (raw === '')
67
+ return 1;
68
+ if (raw.includes('/')) {
69
+ const [n, den] = raw.split('/');
70
+ const num = Number(n);
71
+ const dd = Number(den);
72
+ if (!Number.isFinite(num) || !Number.isFinite(dd) || dd === 0) {
73
+ throw new DimensionSpecError(`bad exponent '${raw}'`);
74
+ }
75
+ return num / dd;
76
+ }
77
+ const v = Number(raw);
78
+ if (!Number.isFinite(v))
79
+ throw new DimensionSpecError(`bad exponent '${raw}'`);
80
+ return v;
81
+ }
82
+ /** Parse a dimension spec string into a {@link Dimension}. @internal */
83
+ export function parseDimensionSpec(spec) {
84
+ const s = spec.trim();
85
+ if (!s)
86
+ throw new DimensionSpecError('empty dimension spec');
87
+ // (1) fundamental constant — EXACT case (G ≠ g).
88
+ if (CONST_DIMS[s])
89
+ return CONST_DIMS[s];
90
+ // (2) named dimension — case-insensitive.
91
+ const named = NAMED_DIMS[s.toLowerCase()];
92
+ if (named)
93
+ return named;
94
+ // (3) explicit base exponents.
95
+ const out = d();
96
+ const parts = s.split(/[.*\s]+/).filter(Boolean);
97
+ for (const part of parts) {
98
+ const m = /^([A-Za-zΘ]+)\^?(-?\d+(?:\/\d+)?)?$/.exec(part);
99
+ if (!m)
100
+ throw new DimensionSpecError(`unrecognized dimension term '${part}'`);
101
+ const baseKey = BASES[m[1].toUpperCase()] ?? BASES[m[1]];
102
+ if (!baseKey) {
103
+ throw new DimensionSpecError(`unknown base dimension '${m[1]}' (use L M T I Theta N J, a named ` +
104
+ `dimension, or a constant name)`);
105
+ }
106
+ out[baseKey] += parseExponent(m[2] ?? '');
107
+ }
108
+ return out;
109
+ }
110
+ //# sourceMappingURL=dimension-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dimension-spec.js","sourceRoot":"","sources":["../../src/dimensional/dimension-spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EACL,aAAa,EACb,MAAM,EACN,IA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v0.7-tensor-equation-node-design-note.md`
6
+ * Per `docs/architecture/archive/v0.7-tensor-equation-node-design-note.md`
7
7
  * Phase 0 — extract the 3 invariant checks from
8
8
  * `validateEinsteinFieldEquation` so future field equations get
9
9
  * them for free, instead of copy-pasting the predicate bodies.
@@ -3,7 +3,7 @@
3
3
  * (`EinsteinFieldEquationNode`, and future `MaxwellEquationNode`,
4
4
  * `KleinGordonEquationNode`, etc.).
5
5
  *
6
- * Per `docs/architecture/v0.7-tensor-equation-node-design-note.md`
6
+ * Per `docs/architecture/archive/v0.7-tensor-equation-node-design-note.md`
7
7
  * Phase 0 — extract the 3 invariant checks from
8
8
  * `validateEinsteinFieldEquation` so future field equations get
9
9
  * them for free, instead of copy-pasting the predicate bodies.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Friedmann equation AST node — modified-cosmology predicate.
3
3
  *
4
- * Per `docs/architecture/v0.7-be-x-reencoding-design-note.md`
4
+ * Per `docs/architecture/archive/v0.7-be-x-reencoding-design-note.md`
5
5
  * §"BE-19 — `FriedmannEquationNode` for modified-Friedmann
6
6
  * predicates". Fourth of four BE-X structural re-encodings in the
7
7
  * v0.7-series follow-up to the v0.6.0 deferred-bridges list.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Friedmann equation AST node — modified-cosmology predicate.
3
3
  *
4
- * Per `docs/architecture/v0.7-be-x-reencoding-design-note.md`
4
+ * Per `docs/architecture/archive/v0.7-be-x-reencoding-design-note.md`
5
5
  * §"BE-19 — `FriedmannEquationNode` for modified-Friedmann
6
6
  * predicates". Fourth of four BE-X structural re-encodings in the
7
7
  * v0.7-series follow-up to the v0.6.0 deferred-bridges list.
@@ -35,7 +35,7 @@
35
35
  * `src/dimensional/klein-gordon-equation.ts` (field-equation-helpers
36
36
  * pattern, Phase 1 of TensorEquationNode generalization).
37
37
  *
38
- * @see docs/architecture/v0.7-be-x-reencoding-design-note.md §BE-50
38
+ * @see docs/architecture/archive/v0.7-be-x-reencoding-design-note.md §BE-50
39
39
  * @see src/bridges/equations/be-50-wheeler-feynman.ts
40
40
  * @module dimensional/gauge-field
41
41
  */
@@ -35,7 +35,7 @@
35
35
  * `src/dimensional/klein-gordon-equation.ts` (field-equation-helpers
36
36
  * pattern, Phase 1 of TensorEquationNode generalization).
37
37
  *
38
- * @see docs/architecture/v0.7-be-x-reencoding-design-note.md §BE-50
38
+ * @see docs/architecture/archive/v0.7-be-x-reencoding-design-note.md §BE-50
39
39
  * @see src/bridges/equations/be-50-wheeler-feynman.ts
40
40
  * @module dimensional/gauge-field
41
41
  */
@@ -2,7 +2,7 @@
2
2
  * Klein-Gordon scalar field equation AST node.
3
3
  *
4
4
  * Phase 1 of the TensorEquationNode<LHS, RHS> generalization
5
- * (`docs/architecture/v0.7-tensor-equation-node-design-note.md`).
5
+ * (`docs/architecture/archive/v0.7-tensor-equation-node-design-note.md`).
6
6
  * First new field-equation node to use the Phase 0 field-equation
7
7
  * helpers shipped in commit `5cd860a`.
8
8
  *
@@ -28,10 +28,13 @@
28
28
  * structure; both sides carry the trivial `'scalar'` marker.
29
29
  *
30
30
  * Note: this is a PREDICATE node like EinsteinFieldEquationNode —
31
- * not a value-producing expression. Numerical evaluation of the
32
- * wave-operator action on a specific field is out of scope
33
- * (would require a separate `lowerKleinGordon` step like the
34
- * curvature pipeline).
31
+ * not a value-producing expression. Numerical content for the free-
32
+ * field plane-wave sector lives in `src/numerical/klein-gordon.ts`
33
+ * (`evaluateKGDispersionResidual`, `verifyKleinGordonPlaneWave`
34
+ * the SI dispersion relation ω² = c²k² + (mc²/ℏ)²). A full FD
35
+ * wave-operator evaluator `□φ` on coordinate grids (a separate
36
+ * `lowerKleinGordon` step like the curvature pipeline) remains
37
+ * out of scope / future work.
35
38
  *
36
39
  * @module dimensional/klein-gordon-equation
37
40
  */
@@ -1 +1 @@
1
- {"version":3,"file":"klein-gordon-equation.d.ts","sourceRoot":"","sources":["../../src/dimensional/klein-gordon-equation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;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CAAC;AAO5C;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC9B,qCAAqC;IACrC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,wDAAwD;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8CAA8C;IAC9C,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,IAAI,EAAE,uBAAuB,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;CACnC;AAED;;;;;GAKG;AACH,MAAM,WAAW,mCAAmC;IAClD,yDAAyD;IACzD,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,gDAAgD;IAChD,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrE;AAsBD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,uBAAuB,GAC5B,mCAAmC,CAgErC"}
@@ -2,7 +2,7 @@
2
2
  * Klein-Gordon scalar field equation AST node.
3
3
  *
4
4
  * Phase 1 of the TensorEquationNode<LHS, RHS> generalization
5
- * (`docs/architecture/v0.7-tensor-equation-node-design-note.md`).
5
+ * (`docs/architecture/archive/v0.7-tensor-equation-node-design-note.md`).
6
6
  * First new field-equation node to use the Phase 0 field-equation
7
7
  * helpers shipped in commit `5cd860a`.
8
8
  *
@@ -28,10 +28,13 @@
28
28
  * structure; both sides carry the trivial `'scalar'` marker.
29
29
  *
30
30
  * Note: this is a PREDICATE node like EinsteinFieldEquationNode —
31
- * not a value-producing expression. Numerical evaluation of the
32
- * wave-operator action on a specific field is out of scope
33
- * (would require a separate `lowerKleinGordon` step like the
34
- * curvature pipeline).
31
+ * not a value-producing expression. Numerical content for the free-
32
+ * field plane-wave sector lives in `src/numerical/klein-gordon.ts`
33
+ * (`evaluateKGDispersionResidual`, `verifyKleinGordonPlaneWave`
34
+ * the SI dispersion relation ω² = c²k² + (mc²/ℏ)²). A full FD
35
+ * wave-operator evaluator `□φ` on coordinate grids (a separate
36
+ * `lowerKleinGordon` step like the curvature pipeline) remains
37
+ * out of scope / future work.
35
38
  *
36
39
  * @module dimensional/klein-gordon-equation
37
40
  */
@@ -1 +1 @@
1
- {"version":3,"file":"klein-gordon-equation.js","sourceRoot":"","sources":["../../src/dimensional/klein-gordon-equation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAGH,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AA0DrC,0DAA0D;AAC1D,MAAM,wBAAwB,GAAc;IAC1C,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,SAAS,sBAAsB,CAAC,QAAmB;IACjD,OAAO;QACL,CAAC,EAAE,QAAQ,CAAC,CAAC,GAAG,wBAAwB,CAAC,CAAC;QAC1C,CAAC,EAAE,QAAQ,CAAC,CAAC,GAAG,wBAAwB,CAAC,CAAC;QAC1C,CAAC,EAAE,QAAQ,CAAC,CAAC,GAAG,wBAAwB,CAAC,CAAC;QAC1C,CAAC,EAAE,QAAQ,CAAC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
2
  * TensorTraceNode — structural tensor-trace operator for rank-2 tensors.
3
3
  *
4
- * Per `docs/architecture/v0.7-be-x-reencoding-design-note.md` §"BE-13 —
4
+ * Per `docs/architecture/archive/v0.7-be-x-reencoding-design-note.md` §"BE-13 —
5
5
  * TensorTraceNode for the Einstein trace". First of four BE-X re-encoding
6
6
  * primitives planned for the v0.7 sprint.
7
7
  *
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * TensorTraceNode — structural tensor-trace operator for rank-2 tensors.
3
3
  *
4
- * Per `docs/architecture/v0.7-be-x-reencoding-design-note.md` §"BE-13 —
4
+ * Per `docs/architecture/archive/v0.7-be-x-reencoding-design-note.md` §"BE-13 —
5
5
  * TensorTraceNode for the Einstein trace". First of four BE-X re-encoding
6
6
  * primitives planned for the v0.7 sprint.
7
7
  *
@@ -2,9 +2,11 @@
2
2
  * Validator: walks an ExprNode tree and infers / checks SI dimensions.
3
3
  *
4
4
  * Honest-claude scope notes:
5
- * - This MVP does NOT track tensor index structure (rank, contractions).
6
- * Bridge Eq 17's index-rank mismatch from the spec cannot be caught here.
7
- * Tier 4.5 follow-up see README.
5
+ * - Tensor index structure IS tracked: tensor-symbol / tensor-product
6
+ * nodes carry free-index (upper/lower) signatures, contraction is
7
+ * enforced, and `validateEquation` now checks valence homogeneity
8
+ * across '=' (so the spec's Bridge Eq 17 rank mismatch — a tensor
9
+ * equated to a scalar — is caught even when the SI dimensions agree).
8
10
  * - Special functions (log, exp, trig) are out of scope; their arguments
9
11
  * must be dimensionless but the validator does not yet enforce that.
10
12
  *
@@ -36,6 +38,14 @@ export type ExprNode = {
36
38
  kind: 'derivative';
37
39
  of: ExprNode;
38
40
  wrt: ExprNode;
41
+ } | {
42
+ kind: 'dirac-delta';
43
+ arg: ExprNode;
44
+ } | {
45
+ kind: 'variational-derivative';
46
+ functional: ExprNode;
47
+ field: ExprNode;
48
+ over: ExprNode;
39
49
  } | TensorSymbolNode | TensorProductNode | MetricTensorNode | KroneckerDeltaNode | TensorPartialDerivativeNode | CovariantDerivativeNode | RiemannTensorNode | RicciTensorNode | EinsteinTensorNode | BianchiResidualNode | KillingVectorNode | ConservedChargeNode | StressEnergyTensorNode | CosmologicalConstantNode | EinsteinFieldEquationNode | WeylTensorNode | KretschmannScalarNode;
40
50
  export type { TensorSymbolNode, TensorProductNode } from './tensor.js';
41
51
  export type { MetricTensorNode, KroneckerDeltaNode, TensorPartialDerivativeNode, } from './metric-validators.js';