universal-physics-tensor 0.4.5

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 (299) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +377 -0
  3. package/dist/bridges/equations/be-11-decoherence-master.d.ts +83 -0
  4. package/dist/bridges/equations/be-11-decoherence-master.d.ts.map +1 -0
  5. package/dist/bridges/equations/be-11-decoherence-master.js +116 -0
  6. package/dist/bridges/equations/be-11-decoherence-master.js.map +1 -0
  7. package/dist/bridges/equations/be-12-coherence-length.d.ts +80 -0
  8. package/dist/bridges/equations/be-12-coherence-length.d.ts.map +1 -0
  9. package/dist/bridges/equations/be-12-coherence-length.js +128 -0
  10. package/dist/bridges/equations/be-12-coherence-length.js.map +1 -0
  11. package/dist/bridges/equations/be-13-einstein-trace.d.ts +89 -0
  12. package/dist/bridges/equations/be-13-einstein-trace.d.ts.map +1 -0
  13. package/dist/bridges/equations/be-13-einstein-trace.js +143 -0
  14. package/dist/bridges/equations/be-13-einstein-trace.js.map +1 -0
  15. package/dist/bridges/equations/be-14-ryu-takayanagi.d.ts +67 -0
  16. package/dist/bridges/equations/be-14-ryu-takayanagi.d.ts.map +1 -0
  17. package/dist/bridges/equations/be-14-ryu-takayanagi.js +112 -0
  18. package/dist/bridges/equations/be-14-ryu-takayanagi.js.map +1 -0
  19. package/dist/bridges/equations/be-15-emergence.d.ts +164 -0
  20. package/dist/bridges/equations/be-15-emergence.d.ts.map +1 -0
  21. package/dist/bridges/equations/be-15-emergence.js +204 -0
  22. package/dist/bridges/equations/be-15-emergence.js.map +1 -0
  23. package/dist/bridges/equations/be-16-landauer.d.ts +180 -0
  24. package/dist/bridges/equations/be-16-landauer.d.ts.map +1 -0
  25. package/dist/bridges/equations/be-16-landauer.js +206 -0
  26. package/dist/bridges/equations/be-16-landauer.js.map +1 -0
  27. package/dist/bridges/equations/be-17-einstein-cartan.d.ts +245 -0
  28. package/dist/bridges/equations/be-17-einstein-cartan.d.ts.map +1 -0
  29. package/dist/bridges/equations/be-17-einstein-cartan.js +304 -0
  30. package/dist/bridges/equations/be-17-einstein-cartan.js.map +1 -0
  31. package/dist/bridges/equations/be-18-higgs-mass.d.ts +65 -0
  32. package/dist/bridges/equations/be-18-higgs-mass.d.ts.map +1 -0
  33. package/dist/bridges/equations/be-18-higgs-mass.js +86 -0
  34. package/dist/bridges/equations/be-18-higgs-mass.js.map +1 -0
  35. package/dist/bridges/equations/be-19-quantum-bounce.d.ts +72 -0
  36. package/dist/bridges/equations/be-19-quantum-bounce.d.ts.map +1 -0
  37. package/dist/bridges/equations/be-19-quantum-bounce.js +151 -0
  38. package/dist/bridges/equations/be-19-quantum-bounce.js.map +1 -0
  39. package/dist/bridges/equations/be-20-vacuum-energy.d.ts +72 -0
  40. package/dist/bridges/equations/be-20-vacuum-energy.d.ts.map +1 -0
  41. package/dist/bridges/equations/be-20-vacuum-energy.js +115 -0
  42. package/dist/bridges/equations/be-20-vacuum-energy.js.map +1 -0
  43. package/dist/bridges/equations/be-21-kss-bound.d.ts +72 -0
  44. package/dist/bridges/equations/be-21-kss-bound.d.ts.map +1 -0
  45. package/dist/bridges/equations/be-21-kss-bound.js +103 -0
  46. package/dist/bridges/equations/be-21-kss-bound.js.map +1 -0
  47. package/dist/bridges/equations/be-22-topological-entanglement.d.ts +90 -0
  48. package/dist/bridges/equations/be-22-topological-entanglement.d.ts.map +1 -0
  49. package/dist/bridges/equations/be-22-topological-entanglement.js +123 -0
  50. package/dist/bridges/equations/be-22-topological-entanglement.js.map +1 -0
  51. package/dist/bridges/equations/be-23-syk-planckian.d.ts +89 -0
  52. package/dist/bridges/equations/be-23-syk-planckian.d.ts.map +1 -0
  53. package/dist/bridges/equations/be-23-syk-planckian.js +155 -0
  54. package/dist/bridges/equations/be-23-syk-planckian.js.map +1 -0
  55. package/dist/bridges/equations/be-24-foerster-fret.d.ts +81 -0
  56. package/dist/bridges/equations/be-24-foerster-fret.d.ts.map +1 -0
  57. package/dist/bridges/equations/be-24-foerster-fret.js +121 -0
  58. package/dist/bridges/equations/be-24-foerster-fret.js.map +1 -0
  59. package/dist/bridges/equations/be-25-iit-phi.d.ts +220 -0
  60. package/dist/bridges/equations/be-25-iit-phi.d.ts.map +1 -0
  61. package/dist/bridges/equations/be-25-iit-phi.js +259 -0
  62. package/dist/bridges/equations/be-25-iit-phi.js.map +1 -0
  63. package/dist/bridges/equations/be-25-orch-or.d.ts +78 -0
  64. package/dist/bridges/equations/be-25-orch-or.d.ts.map +1 -0
  65. package/dist/bridges/equations/be-25-orch-or.js +121 -0
  66. package/dist/bridges/equations/be-25-orch-or.js.map +1 -0
  67. package/dist/bridges/equations/be-26-dna-tunneling.d.ts +75 -0
  68. package/dist/bridges/equations/be-26-dna-tunneling.d.ts.map +1 -0
  69. package/dist/bridges/equations/be-26-dna-tunneling.js +138 -0
  70. package/dist/bridges/equations/be-26-dna-tunneling.js.map +1 -0
  71. package/dist/bridges/equations/be-27-effective-temperature.d.ts +81 -0
  72. package/dist/bridges/equations/be-27-effective-temperature.d.ts.map +1 -0
  73. package/dist/bridges/equations/be-27-effective-temperature.js +120 -0
  74. package/dist/bridges/equations/be-27-effective-temperature.js.map +1 -0
  75. package/dist/bridges/equations/be-28-onsager-entropy-production.d.ts +175 -0
  76. package/dist/bridges/equations/be-28-onsager-entropy-production.d.ts.map +1 -0
  77. package/dist/bridges/equations/be-28-onsager-entropy-production.js +203 -0
  78. package/dist/bridges/equations/be-28-onsager-entropy-production.js.map +1 -0
  79. package/dist/bridges/equations/be-29-jarzynski.d.ts +86 -0
  80. package/dist/bridges/equations/be-29-jarzynski.d.ts.map +1 -0
  81. package/dist/bridges/equations/be-29-jarzynski.js +132 -0
  82. package/dist/bridges/equations/be-29-jarzynski.js.map +1 -0
  83. package/dist/bridges/equations/be-30-flm-first-law.d.ts +93 -0
  84. package/dist/bridges/equations/be-30-flm-first-law.d.ts.map +1 -0
  85. package/dist/bridges/equations/be-30-flm-first-law.js +109 -0
  86. package/dist/bridges/equations/be-30-flm-first-law.js.map +1 -0
  87. package/dist/bridges/equations/be-31-causal-set-bd.d.ts +96 -0
  88. package/dist/bridges/equations/be-31-causal-set-bd.d.ts.map +1 -0
  89. package/dist/bridges/equations/be-31-causal-set-bd.js +133 -0
  90. package/dist/bridges/equations/be-31-causal-set-bd.js.map +1 -0
  91. package/dist/bridges/equations/be-32-quantum-reference-frame.d.ts +113 -0
  92. package/dist/bridges/equations/be-32-quantum-reference-frame.d.ts.map +1 -0
  93. package/dist/bridges/equations/be-32-quantum-reference-frame.js +155 -0
  94. package/dist/bridges/equations/be-32-quantum-reference-frame.js.map +1 -0
  95. package/dist/bridges/equations/be-33-hertz-millis.d.ts +77 -0
  96. package/dist/bridges/equations/be-33-hertz-millis.d.ts.map +1 -0
  97. package/dist/bridges/equations/be-33-hertz-millis.js +113 -0
  98. package/dist/bridges/equations/be-33-hertz-millis.js.map +1 -0
  99. package/dist/bridges/equations/be-34-kibble-zurek.d.ts +76 -0
  100. package/dist/bridges/equations/be-34-kibble-zurek.d.ts.map +1 -0
  101. package/dist/bridges/equations/be-34-kibble-zurek.js +139 -0
  102. package/dist/bridges/equations/be-34-kibble-zurek.js.map +1 -0
  103. package/dist/bridges/equations/be-35-conformal-bootstrap.d.ts +117 -0
  104. package/dist/bridges/equations/be-35-conformal-bootstrap.d.ts.map +1 -0
  105. package/dist/bridges/equations/be-35-conformal-bootstrap.js +167 -0
  106. package/dist/bridges/equations/be-35-conformal-bootstrap.js.map +1 -0
  107. package/dist/bridges/equations/be-36-gw-speed-bound.d.ts +77 -0
  108. package/dist/bridges/equations/be-36-gw-speed-bound.d.ts.map +1 -0
  109. package/dist/bridges/equations/be-36-gw-speed-bound.js +107 -0
  110. package/dist/bridges/equations/be-36-gw-speed-bound.js.map +1 -0
  111. package/dist/bridges/equations/be-37-shapiro-delay.d.ts +260 -0
  112. package/dist/bridges/equations/be-37-shapiro-delay.d.ts.map +1 -0
  113. package/dist/bridges/equations/be-37-shapiro-delay.js +429 -0
  114. package/dist/bridges/equations/be-37-shapiro-delay.js.map +1 -0
  115. package/dist/bridges/equations/be-38-mond.d.ts +86 -0
  116. package/dist/bridges/equations/be-38-mond.d.ts.map +1 -0
  117. package/dist/bridges/equations/be-38-mond.js +122 -0
  118. package/dist/bridges/equations/be-38-mond.js.map +1 -0
  119. package/dist/bridges/equations/be-39-asymptotic-safety.d.ts +106 -0
  120. package/dist/bridges/equations/be-39-asymptotic-safety.d.ts.map +1 -0
  121. package/dist/bridges/equations/be-39-asymptotic-safety.js +155 -0
  122. package/dist/bridges/equations/be-39-asymptotic-safety.js.map +1 -0
  123. package/dist/bridges/equations/be-40-composite-higgs.d.ts +81 -0
  124. package/dist/bridges/equations/be-40-composite-higgs.d.ts.map +1 -0
  125. package/dist/bridges/equations/be-40-composite-higgs.js +149 -0
  126. package/dist/bridges/equations/be-40-composite-higgs.js.map +1 -0
  127. package/dist/bridges/equations/be-41-swampland.d.ts +67 -0
  128. package/dist/bridges/equations/be-41-swampland.d.ts.map +1 -0
  129. package/dist/bridges/equations/be-41-swampland.js +109 -0
  130. package/dist/bridges/equations/be-41-swampland.js.map +1 -0
  131. package/dist/bridges/equations/be-42-hawking-temperature.d.ts +67 -0
  132. package/dist/bridges/equations/be-42-hawking-temperature.d.ts.map +1 -0
  133. package/dist/bridges/equations/be-42-hawking-temperature.js +109 -0
  134. package/dist/bridges/equations/be-42-hawking-temperature.js.map +1 -0
  135. package/dist/bridges/equations/be-43-er-epr.d.ts +73 -0
  136. package/dist/bridges/equations/be-43-er-epr.d.ts.map +1 -0
  137. package/dist/bridges/equations/be-43-er-epr.js +114 -0
  138. package/dist/bridges/equations/be-43-er-epr.js.map +1 -0
  139. package/dist/bridges/equations/be-44-soft-hair.d.ts +151 -0
  140. package/dist/bridges/equations/be-44-soft-hair.d.ts.map +1 -0
  141. package/dist/bridges/equations/be-44-soft-hair.js +185 -0
  142. package/dist/bridges/equations/be-44-soft-hair.js.map +1 -0
  143. package/dist/bridges/equations/be-45-tcc.d.ts +116 -0
  144. package/dist/bridges/equations/be-45-tcc.d.ts.map +1 -0
  145. package/dist/bridges/equations/be-45-tcc.js +157 -0
  146. package/dist/bridges/equations/be-45-tcc.js.map +1 -0
  147. package/dist/bridges/equations/be-46-multiverse-measure.d.ts +163 -0
  148. package/dist/bridges/equations/be-46-multiverse-measure.d.ts.map +1 -0
  149. package/dist/bridges/equations/be-46-multiverse-measure.js +198 -0
  150. package/dist/bridges/equations/be-46-multiverse-measure.js.map +1 -0
  151. package/dist/bridges/equations/be-47-bbn-dark-sector.d.ts +72 -0
  152. package/dist/bridges/equations/be-47-bbn-dark-sector.d.ts.map +1 -0
  153. package/dist/bridges/equations/be-47-bbn-dark-sector.js +121 -0
  154. package/dist/bridges/equations/be-47-bbn-dark-sector.js.map +1 -0
  155. package/dist/bridges/equations/be-48-grw-localization.d.ts +84 -0
  156. package/dist/bridges/equations/be-48-grw-localization.d.ts.map +1 -0
  157. package/dist/bridges/equations/be-48-grw-localization.js +107 -0
  158. package/dist/bridges/equations/be-48-grw-localization.js.map +1 -0
  159. package/dist/bridges/equations/be-49-quantum-darwinism.d.ts +97 -0
  160. package/dist/bridges/equations/be-49-quantum-darwinism.d.ts.map +1 -0
  161. package/dist/bridges/equations/be-49-quantum-darwinism.js +129 -0
  162. package/dist/bridges/equations/be-49-quantum-darwinism.js.map +1 -0
  163. package/dist/bridges/equations/be-50-wheeler-feynman.d.ts +120 -0
  164. package/dist/bridges/equations/be-50-wheeler-feynman.d.ts.map +1 -0
  165. package/dist/bridges/equations/be-50-wheeler-feynman.js +151 -0
  166. package/dist/bridges/equations/be-50-wheeler-feynman.js.map +1 -0
  167. package/dist/bridges/gravitational-lensing.d.ts +52 -0
  168. package/dist/bridges/gravitational-lensing.d.ts.map +1 -0
  169. package/dist/bridges/gravitational-lensing.js +48 -0
  170. package/dist/bridges/gravitational-lensing.js.map +1 -0
  171. package/dist/bridges/index.d.ts +104 -0
  172. package/dist/bridges/index.d.ts.map +1 -0
  173. package/dist/bridges/index.js +1663 -0
  174. package/dist/bridges/index.js.map +1 -0
  175. package/dist/bridges/perihelion-precession.d.ts +62 -0
  176. package/dist/bridges/perihelion-precession.d.ts.map +1 -0
  177. package/dist/bridges/perihelion-precession.js +68 -0
  178. package/dist/bridges/perihelion-precession.js.map +1 -0
  179. package/dist/core/tensor.d.ts +135 -0
  180. package/dist/core/tensor.d.ts.map +1 -0
  181. package/dist/core/tensor.js +376 -0
  182. package/dist/core/tensor.js.map +1 -0
  183. package/dist/core/types.d.ts +131 -0
  184. package/dist/core/types.d.ts.map +1 -0
  185. package/dist/core/types.js +25 -0
  186. package/dist/core/types.js.map +1 -0
  187. package/dist/dimensional/algebra.d.ts +34 -0
  188. package/dist/dimensional/algebra.d.ts.map +1 -0
  189. package/dist/dimensional/algebra.js +90 -0
  190. package/dist/dimensional/algebra.js.map +1 -0
  191. package/dist/dimensional/bridge-check.d.ts +48 -0
  192. package/dist/dimensional/bridge-check.d.ts.map +1 -0
  193. package/dist/dimensional/bridge-check.js +137 -0
  194. package/dist/dimensional/bridge-check.js.map +1 -0
  195. package/dist/dimensional/connection-validators.d.ts +53 -0
  196. package/dist/dimensional/connection-validators.d.ts.map +1 -0
  197. package/dist/dimensional/connection-validators.js +84 -0
  198. package/dist/dimensional/connection-validators.js.map +1 -0
  199. package/dist/dimensional/connection.d.ts +40 -0
  200. package/dist/dimensional/connection.d.ts.map +1 -0
  201. package/dist/dimensional/connection.js +81 -0
  202. package/dist/dimensional/connection.js.map +1 -0
  203. package/dist/dimensional/constants.d.ts +30 -0
  204. package/dist/dimensional/constants.d.ts.map +1 -0
  205. package/dist/dimensional/constants.js +31 -0
  206. package/dist/dimensional/constants.js.map +1 -0
  207. package/dist/dimensional/errors.d.ts +161 -0
  208. package/dist/dimensional/errors.d.ts.map +1 -0
  209. package/dist/dimensional/errors.js +254 -0
  210. package/dist/dimensional/errors.js.map +1 -0
  211. package/dist/dimensional/fresh-label.d.ts +26 -0
  212. package/dist/dimensional/fresh-label.d.ts.map +1 -0
  213. package/dist/dimensional/fresh-label.js +31 -0
  214. package/dist/dimensional/fresh-label.js.map +1 -0
  215. package/dist/dimensional/metric-validators.d.ts +124 -0
  216. package/dist/dimensional/metric-validators.d.ts.map +1 -0
  217. package/dist/dimensional/metric-validators.js +141 -0
  218. package/dist/dimensional/metric-validators.js.map +1 -0
  219. package/dist/dimensional/metric.d.ts +67 -0
  220. package/dist/dimensional/metric.d.ts.map +1 -0
  221. package/dist/dimensional/metric.js +177 -0
  222. package/dist/dimensional/metric.js.map +1 -0
  223. package/dist/dimensional/tensor.d.ts +153 -0
  224. package/dist/dimensional/tensor.d.ts.map +1 -0
  225. package/dist/dimensional/tensor.js +138 -0
  226. package/dist/dimensional/tensor.js.map +1 -0
  227. package/dist/dimensional/types.d.ts +50 -0
  228. package/dist/dimensional/types.d.ts.map +1 -0
  229. package/dist/dimensional/types.js +66 -0
  230. package/dist/dimensional/types.js.map +1 -0
  231. package/dist/dimensional/validator.d.ts +84 -0
  232. package/dist/dimensional/validator.d.ts.map +1 -0
  233. package/dist/dimensional/validator.js +505 -0
  234. package/dist/dimensional/validator.js.map +1 -0
  235. package/dist/index.d.ts +25 -0
  236. package/dist/index.d.ts.map +1 -0
  237. package/dist/index.js +37 -0
  238. package/dist/index.js.map +1 -0
  239. package/dist/numerical/be37-covariant-eikonal.d.ts +90 -0
  240. package/dist/numerical/be37-covariant-eikonal.d.ts.map +1 -0
  241. package/dist/numerical/be37-covariant-eikonal.js +79 -0
  242. package/dist/numerical/be37-covariant-eikonal.js.map +1 -0
  243. package/dist/numerical/connection-lowering-helpers.d.ts +107 -0
  244. package/dist/numerical/connection-lowering-helpers.d.ts.map +1 -0
  245. package/dist/numerical/connection-lowering-helpers.js +315 -0
  246. package/dist/numerical/connection-lowering-helpers.js.map +1 -0
  247. package/dist/numerical/engine-registry.d.ts +50 -0
  248. package/dist/numerical/engine-registry.d.ts.map +1 -0
  249. package/dist/numerical/engine-registry.js +82 -0
  250. package/dist/numerical/engine-registry.js.map +1 -0
  251. package/dist/numerical/errors.d.ts +28 -0
  252. package/dist/numerical/errors.d.ts.map +1 -0
  253. package/dist/numerical/errors.js +39 -0
  254. package/dist/numerical/errors.js.map +1 -0
  255. package/dist/numerical/float64-engine.d.ts +53 -0
  256. package/dist/numerical/float64-engine.d.ts.map +1 -0
  257. package/dist/numerical/float64-engine.js +638 -0
  258. package/dist/numerical/float64-engine.js.map +1 -0
  259. package/dist/numerical/geodesic-integrator.d.ts +62 -0
  260. package/dist/numerical/geodesic-integrator.d.ts.map +1 -0
  261. package/dist/numerical/geodesic-integrator.js +103 -0
  262. package/dist/numerical/geodesic-integrator.js.map +1 -0
  263. package/dist/numerical/grid-field.d.ts +24 -0
  264. package/dist/numerical/grid-field.d.ts.map +1 -0
  265. package/dist/numerical/grid-field.js +2 -0
  266. package/dist/numerical/grid-field.js.map +1 -0
  267. package/dist/numerical/index.d.ts +80 -0
  268. package/dist/numerical/index.d.ts.map +1 -0
  269. package/dist/numerical/index.js +75 -0
  270. package/dist/numerical/index.js.map +1 -0
  271. package/dist/numerical/lowering.d.ts +48 -0
  272. package/dist/numerical/lowering.d.ts.map +1 -0
  273. package/dist/numerical/lowering.js +443 -0
  274. package/dist/numerical/lowering.js.map +1 -0
  275. package/dist/numerical/mathts-engine.d.ts +55 -0
  276. package/dist/numerical/mathts-engine.d.ts.map +1 -0
  277. package/dist/numerical/mathts-engine.js +164 -0
  278. package/dist/numerical/mathts-engine.js.map +1 -0
  279. package/dist/numerical/metric-inverse.d.ts +31 -0
  280. package/dist/numerical/metric-inverse.d.ts.map +1 -0
  281. package/dist/numerical/metric-inverse.js +68 -0
  282. package/dist/numerical/metric-inverse.js.map +1 -0
  283. package/dist/numerical/null-ray-integrator.d.ts +13 -0
  284. package/dist/numerical/null-ray-integrator.d.ts.map +1 -0
  285. package/dist/numerical/null-ray-integrator.js +53 -0
  286. package/dist/numerical/null-ray-integrator.js.map +1 -0
  287. package/dist/numerical/pderiv.d.ts +43 -0
  288. package/dist/numerical/pderiv.d.ts.map +1 -0
  289. package/dist/numerical/pderiv.js +121 -0
  290. package/dist/numerical/pderiv.js.map +1 -0
  291. package/dist/numerical/tensor-engine.d.ts +114 -0
  292. package/dist/numerical/tensor-engine.d.ts.map +1 -0
  293. package/dist/numerical/tensor-engine.js +64 -0
  294. package/dist/numerical/tensor-engine.js.map +1 -0
  295. package/dist/numerical/types.d.ts +37 -0
  296. package/dist/numerical/types.d.ts.map +1 -0
  297. package/dist/numerical/types.js +8 -0
  298. package/dist/numerical/types.js.map +1 -0
  299. package/package.json +72 -0
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Per-kind validation for v0.3.0 metric-layer AST nodes.
3
+ *
4
+ * Mirrors the pattern of `validateTensorSymbol` in tensor.ts: each
5
+ * validator is a pure function returning a local `{dim, freeIndices}`
6
+ * carrier that validator.ts merges into its InferContext accumulator.
7
+ *
8
+ * Per docs/specification/Part-VIII-Metric-Layer.md §VIII.2-§VIII.4.
9
+ *
10
+ * @module dimensional/metric-validators
11
+ */
12
+ import { divide } from './algebra.js';
13
+ import { InvalidMetricRankError, MetricSignatureError, InvalidKroneckerRankError, KroneckerVarianceError, PartialDerivativeIndexVarianceError, IndexLabelCollisionError, } from './errors.js';
14
+ /** Parse / validate a metric signature string like '+,-,-,-' or '+,+,+'. */
15
+ function isValidSignature(signature) {
16
+ if (signature.length === 0)
17
+ return false;
18
+ const parts = signature.split(',');
19
+ return parts.every((p) => p === '+' || p === '-');
20
+ }
21
+ /**
22
+ * Symbolic structural check for InverseMetricInconsistencyWarning: a
23
+ * both-lower metric and a both-upper metric should have all-lower and
24
+ * all-upper index variance respectively. Returns a warning note when the
25
+ * structure is wrong, else null. The numerical residual check lives in
26
+ * src/numerical/metric-inverse.ts.
27
+ */
28
+ export function checkInverseMetricStructure(gLower, gUpper) {
29
+ const lowerOk = gLower.indices.every((i) => i.variance === 'lower');
30
+ const upperOk = gUpper.indices.every((i) => i.variance === 'upper');
31
+ if (!lowerOk || !upperOk) {
32
+ return `InverseMetricInconsistencyWarning: "${gLower.name}" / "${gUpper.name}" `
33
+ + `do not form a lower/upper inverse pair`;
34
+ }
35
+ return null;
36
+ }
37
+ /**
38
+ * Validate a metric-tensor node. Rejects:
39
+ * - rank ≠ 2 → InvalidMetricRankError
40
+ * - mixed-variance indices → MetricSignatureError
41
+ * - duplicate index labels (e.g., g_μμ) → MetricSignatureError
42
+ * - malformed/empty signature string → MetricSignatureError
43
+ *
44
+ * Per Part-VIII §VIII.2.
45
+ */
46
+ export function validateMetricTensor(node) {
47
+ if (node.indices.length !== 2) {
48
+ throw new InvalidMetricRankError(node.name, node.indices.length);
49
+ }
50
+ const [a, b] = node.indices;
51
+ if (a.variance !== b.variance) {
52
+ throw new MetricSignatureError(node.name, `mixed-variance indices ('${a.variance}' vs '${b.variance}') are not allowed; ` +
53
+ `use raise() / lower() helpers to traverse variance, or kronecker-delta for δ^μ_ν`);
54
+ }
55
+ if (a.label === b.label) {
56
+ throw new MetricSignatureError(node.name, `duplicate index label '${a.label}'; a metric's two indices must have distinct labels`);
57
+ }
58
+ if (!isValidSignature(node.signature)) {
59
+ throw new MetricSignatureError(node.name, `signature '${node.signature}' is malformed; expected '+,-,-,-' or '+,+,+' format`);
60
+ }
61
+ const freeIndices = new Map();
62
+ for (const idx of node.indices) {
63
+ freeIndices.set(idx.label, {
64
+ upper: idx.variance === 'upper' ? 1 : 0,
65
+ lower: idx.variance === 'lower' ? 1 : 0,
66
+ });
67
+ }
68
+ return { dim: node.dim, freeIndices };
69
+ }
70
+ /**
71
+ * Validate a kronecker-delta node. Rejects:
72
+ * - rank ≠ 2 → InvalidKroneckerRankError
73
+ * - same-variance indices (both upper or both lower) → KroneckerVarianceError
74
+ * - duplicate index labels (e.g., δ^μ_μ, a trace) → IndexLabelCollisionError
75
+ *
76
+ * Per Part-VIII §VIII.3.
77
+ */
78
+ export function validateKroneckerDelta(node) {
79
+ if (node.indices.length !== 2) {
80
+ throw new InvalidKroneckerRankError(node.indices.length);
81
+ }
82
+ const [a, b] = node.indices;
83
+ if (a.variance === b.variance) {
84
+ throw new KroneckerVarianceError(a.variance);
85
+ }
86
+ if (a.label === b.label) {
87
+ // δ^μ_μ is a trace (a contraction), not a free-index expression. v0.3.0
88
+ // doesn't yet auto-evaluate kronecker traces; reject as a label collision
89
+ // to surface the ambiguity to the caller (same semantic as v0.2.0
90
+ // tensor-symbol duplicate-label rejection).
91
+ throw new IndexLabelCollisionError(a.label, 2, ['kronecker-delta-trace']);
92
+ }
93
+ const freeIndices = new Map();
94
+ for (const idx of node.indices) {
95
+ freeIndices.set(idx.label, {
96
+ upper: idx.variance === 'upper' ? 1 : 0,
97
+ lower: idx.variance === 'lower' ? 1 : 0,
98
+ });
99
+ }
100
+ return { dim: node.dim, freeIndices };
101
+ }
102
+ /**
103
+ * Validate a tensor-partial-derivative node.
104
+ *
105
+ * Pure-function module-cycle-free pattern (matches `computeContraction`):
106
+ * recursion is injected via the `validateChild` callback. The caller
107
+ * (validator.ts's `infer()` dispatch) supplies a resolver that returns
108
+ * `{dim, freeIndices, role?}` for each child (the `of` and `wrt` operands).
109
+ *
110
+ * Per Part-VIII §VIII.4. Throws:
111
+ * - PartialDerivativeIndexVarianceError if wrtIndex.variance !== 'lower'
112
+ * - IndexLabelCollisionError if wrtIndex.label collides with `of`'s free indices
113
+ */
114
+ export function validatePartialDerivative(node, validateChild) {
115
+ if (node.wrtIndex.variance !== 'lower') {
116
+ throw new PartialDerivativeIndexVarianceError(node.wrtIndex.label);
117
+ }
118
+ const ofResult = validateChild(node.of);
119
+ const wrtResult = validateChild(node.wrt);
120
+ // Per §VIII.4: discard wrt's own free indices (the operator's index is
121
+ // wrtIndex, not wrt's own indices).
122
+ if (ofResult.freeIndices.has(node.wrtIndex.label)) {
123
+ throw new IndexLabelCollisionError(node.wrtIndex.label, 2, [
124
+ 'tensor-partial-derivative.wrtIndex',
125
+ 'of.freeIndices',
126
+ ]);
127
+ }
128
+ // Output freeIndices = of.freeIndices ∪ {wrtIndex.label: lower}.
129
+ const freeIndices = new Map();
130
+ for (const [label, counts] of ofResult.freeIndices) {
131
+ freeIndices.set(label, counts);
132
+ }
133
+ freeIndices.set(node.wrtIndex.label, { upper: 0, lower: 1 });
134
+ // Output dim = divide(of.dim, wrt.dim).
135
+ const dim = divide(ofResult.dim, wrtResult.dim);
136
+ // Role: pass through of.role if present; default to 'field' otherwise
137
+ // (Design §13 Q1 locked decision).
138
+ const role = ofResult.role ?? 'field';
139
+ return { dim, freeIndices, role };
140
+ }
141
+ //# sourceMappingURL=metric-validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metric-validators.js","sourceRoot":"","sources":["../../src/dimensional/metric-validators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,mCAAmC,EACnC,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAuBrB,4EAA4E;AAC5E,SAAS,gBAAgB,CAAC,SAAiB;IACzC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACzC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;AACpD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CACzC,MAAwB,EACxB,MAAwB;IAExB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;IACpE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,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,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IAE7D,wCAAwC;IACxC,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;IAEhD,sEAAsE;IACtE,mCAAmC;IACnC,MAAM,IAAI,GAAS,QAAQ,CAAC,IAAI,IAAI,OAAO,CAAC;IAE5C,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AACpC,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * User-facing constructors and ergonomic helpers for v0.3.0 metric-layer
3
+ * AST nodes. The substantive logic (alpha-conversion) lives in raise() /
4
+ * lower() (added in Task 8 — this file's initial revision contains only
5
+ * the trivial constructors).
6
+ *
7
+ * Per docs/specification/Part-VIII-Metric-Layer.md §VIII.5 (raise/lower
8
+ * contract) and §VIII.1 (grammar).
9
+ *
10
+ * @module dimensional/metric
11
+ */
12
+ import type { Dimension } from './types.js';
13
+ import type { TensorIndex } from './tensor.js';
14
+ import type { TensorProductNode } from './tensor.js';
15
+ import type { MetricTensorNode, KroneckerDeltaNode, TensorPartialDerivativeNode, CovariantIndex } from './metric-validators.js';
16
+ import type { ExprNode } from './validator.js';
17
+ /**
18
+ * Construct a metric-tensor node.
19
+ *
20
+ * @param name Symbolic name of the metric (e.g. `'g'`).
21
+ * @param indices Exactly two TensorIndex entries (rank-2 requirement).
22
+ * @param dim Physical dimension of the metric components.
23
+ * @param signature Comma-separated `'+'`/`'-'` signs (e.g. `'+,-,-,-'`).
24
+ * @param derivativeStrategy Optional v0.4.0 hint for the numerical engine:
25
+ * how to compute ∂g for Christoffel / ∇_μ. `'zero'` = constant metric
26
+ * (∂g=0, Γ=0, ∇_μ=∂_μ); `'supplied'` = caller provides ∂g components;
27
+ * `'computed'` = engine auto-differentiates the metric function (default).
28
+ * Omit to leave the field absent (engine defaults to `'computed'`).
29
+ */
30
+ export declare function metric(name: string, indices: ReadonlyArray<TensorIndex>, dim: Dimension, signature: string, derivativeStrategy?: 'computed' | 'zero' | 'supplied'): MetricTensorNode;
31
+ /**
32
+ * Construct a Kronecker delta δ^upperLabel_lowerLabel.
33
+ * Parameter order: upper first, lower second (canonical δ^μ_ν).
34
+ * dim defaults to DIMENSIONLESS (Design §13 Q3 locked).
35
+ */
36
+ export declare function kronecker(upperLabel: string, lowerLabel: string, dim?: Dimension): KroneckerDeltaNode;
37
+ /**
38
+ * Construct a tensor-partial-derivative. wrtIndex.variance MUST be 'lower'
39
+ * — TypeScript enforces this via the CovariantIndex type.
40
+ */
41
+ export declare function pderiv(of: ExprNode, wrt: ExprNode, wrtIndex: CovariantIndex): TensorPartialDerivativeNode;
42
+ /**
43
+ * Raise an index of `operand` via the inverse metric `gInverse`.
44
+ *
45
+ * Internal alpha-conversion: one of `gInverse`'s labels is renamed to
46
+ * match `label` (so the Einstein-summation contraction picks it up);
47
+ * the other is renamed to a fresh label that doesn't collide with any
48
+ * free index in `operand`. The fresh label becomes the resulting
49
+ * tensor-product's only new free index.
50
+ *
51
+ * Per Part-VIII §VIII.5 (raise/lower contract).
52
+ *
53
+ * Throws:
54
+ * - MetricSignatureError if gInverse isn't both-upper
55
+ * - RaiseLowerInvalidLabelError if label is absent or already upper in operand
56
+ */
57
+ export declare function raise(operand: ExprNode, gInverse: MetricTensorNode, label: string): TensorProductNode;
58
+ /**
59
+ * Lower an index of `operand` via the covariant metric `g`.
60
+ * Symmetric to raise(). Per Part-VIII §VIII.5.
61
+ *
62
+ * Throws:
63
+ * - MetricSignatureError if g isn't both-lower
64
+ * - RaiseLowerInvalidLabelError if label is absent or already lower in operand
65
+ */
66
+ export declare function lower(operand: ExprNode, g: MetricTensorNode, label: string): TensorProductNode;
67
+ //# sourceMappingURL=metric.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metric.d.ts","sourceRoot":"","sources":["../../src/dimensional/metric.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,2BAA2B,EAC3B,cAAc,EACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI/C;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,EACnC,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,MAAM,EACjB,kBAAkB,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,UAAU,GACpD,gBAAgB,CAWlB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,GAAG,GAAE,SAAyB,GAC7B,kBAAkB,CASpB;AAED;;;GAGG;AACH,wBAAgB,MAAM,CACpB,EAAE,EAAE,QAAQ,EACZ,GAAG,EAAE,QAAQ,EACb,QAAQ,EAAE,cAAc,GACvB,2BAA2B,CAE7B;AA6BD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CACnB,OAAO,EAAE,QAAQ,EACjB,QAAQ,EAAE,gBAAgB,EAC1B,KAAK,EAAE,MAAM,GACZ,iBAAiB,CA+CnB;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CACnB,OAAO,EAAE,QAAQ,EACjB,CAAC,EAAE,gBAAgB,EACnB,KAAK,EAAE,MAAM,GACZ,iBAAiB,CA6CnB"}
@@ -0,0 +1,177 @@
1
+ /**
2
+ * User-facing constructors and ergonomic helpers for v0.3.0 metric-layer
3
+ * AST nodes. The substantive logic (alpha-conversion) lives in raise() /
4
+ * lower() (added in Task 8 — this file's initial revision contains only
5
+ * the trivial constructors).
6
+ *
7
+ * Per docs/specification/Part-VIII-Metric-Layer.md §VIII.5 (raise/lower
8
+ * contract) and §VIII.1 (grammar).
9
+ *
10
+ * @module dimensional/metric
11
+ */
12
+ import { DIMENSIONLESS } from './types.js';
13
+ import { freshLabel } from './fresh-label.js';
14
+ import { validate } from './validator.js';
15
+ import { MetricSignatureError, UPTError } from './errors.js';
16
+ /**
17
+ * Construct a metric-tensor node.
18
+ *
19
+ * @param name Symbolic name of the metric (e.g. `'g'`).
20
+ * @param indices Exactly two TensorIndex entries (rank-2 requirement).
21
+ * @param dim Physical dimension of the metric components.
22
+ * @param signature Comma-separated `'+'`/`'-'` signs (e.g. `'+,-,-,-'`).
23
+ * @param derivativeStrategy Optional v0.4.0 hint for the numerical engine:
24
+ * how to compute ∂g for Christoffel / ∇_μ. `'zero'` = constant metric
25
+ * (∂g=0, Γ=0, ∇_μ=∂_μ); `'supplied'` = caller provides ∂g components;
26
+ * `'computed'` = engine auto-differentiates the metric function (default).
27
+ * Omit to leave the field absent (engine defaults to `'computed'`).
28
+ */
29
+ export function metric(name, indices, dim, signature, derivativeStrategy) {
30
+ const node = { kind: 'metric-tensor', name, indices, signature, dim };
31
+ if (derivativeStrategy !== undefined)
32
+ node.derivativeStrategy = derivativeStrategy;
33
+ return node;
34
+ }
35
+ /**
36
+ * Construct a Kronecker delta δ^upperLabel_lowerLabel.
37
+ * Parameter order: upper first, lower second (canonical δ^μ_ν).
38
+ * dim defaults to DIMENSIONLESS (Design §13 Q3 locked).
39
+ */
40
+ export function kronecker(upperLabel, lowerLabel, dim = DIMENSIONLESS) {
41
+ return {
42
+ kind: 'kronecker-delta',
43
+ indices: [
44
+ { label: upperLabel, variance: 'upper' },
45
+ { label: lowerLabel, variance: 'lower' },
46
+ ],
47
+ dim,
48
+ };
49
+ }
50
+ /**
51
+ * Construct a tensor-partial-derivative. wrtIndex.variance MUST be 'lower'
52
+ * — TypeScript enforces this via the CovariantIndex type.
53
+ */
54
+ export function pderiv(of, wrt, wrtIndex) {
55
+ return { kind: 'tensor-partial-derivative', of, wrt, wrtIndex };
56
+ }
57
+ /** Thrown by raise() / lower() when the operand's label is absent or has
58
+ * the wrong variance for the requested operation. Private to this module
59
+ * (not part of the public error surface per Design §6). */
60
+ class RaiseLowerInvalidLabelError extends UPTError {
61
+ constructor(message) {
62
+ super(message);
63
+ this.name = 'RaiseLowerInvalidLabelError';
64
+ Object.setPrototypeOf(this, RaiseLowerInvalidLabelError.prototype);
65
+ }
66
+ }
67
+ /**
68
+ * Collect free-index labels from an ExprNode by calling validate(). Returns
69
+ * a map from label → variance (whichever side has count > 0). Note: this
70
+ * performs a full subtree validation on `operand`; cost is acceptable for
71
+ * typical raise/lower call sites (operand is a small subtree).
72
+ */
73
+ function collectFreeIndexLabels(node) {
74
+ const result = validate(node);
75
+ const labels = new Map();
76
+ for (const [label, counts] of result.freeIndices) {
77
+ if (counts.upper > 0)
78
+ labels.set(label, 'upper');
79
+ else if (counts.lower > 0)
80
+ labels.set(label, 'lower');
81
+ }
82
+ return labels;
83
+ }
84
+ /**
85
+ * Raise an index of `operand` via the inverse metric `gInverse`.
86
+ *
87
+ * Internal alpha-conversion: one of `gInverse`'s labels is renamed to
88
+ * match `label` (so the Einstein-summation contraction picks it up);
89
+ * the other is renamed to a fresh label that doesn't collide with any
90
+ * free index in `operand`. The fresh label becomes the resulting
91
+ * tensor-product's only new free index.
92
+ *
93
+ * Per Part-VIII §VIII.5 (raise/lower contract).
94
+ *
95
+ * Throws:
96
+ * - MetricSignatureError if gInverse isn't both-upper
97
+ * - RaiseLowerInvalidLabelError if label is absent or already upper in operand
98
+ */
99
+ export function raise(operand, gInverse, label) {
100
+ if (gInverse.indices[0].variance !== 'upper' ||
101
+ gInverse.indices[1].variance !== 'upper') {
102
+ throw new MetricSignatureError(gInverse.name, `raise() requires both indices of the inverse metric to have variance 'upper'`);
103
+ }
104
+ const operandLabels = collectFreeIndexLabels(operand);
105
+ const operandVariance = operandLabels.get(label);
106
+ if (operandVariance === undefined) {
107
+ throw new RaiseLowerInvalidLabelError(`raise(): label '${label}' is not a free index of the operand. ` +
108
+ `Operand free indices: ${Array.from(operandLabels.keys()).join(', ') || '(none)'}.`);
109
+ }
110
+ if (operandVariance === 'upper') {
111
+ throw new RaiseLowerInvalidLabelError(`raise(): label '${label}' is already 'upper' in the operand. ` +
112
+ `Use lower() to lower it, or pick a different label.`);
113
+ }
114
+ // Alpha-conversion: rename gInverse[0] → label (the dummy that contracts);
115
+ // gInverse[1] → freshLabel(gInverse[1].label, operand-free-labels).
116
+ const taken = new Set(operandLabels.keys());
117
+ taken.add(label);
118
+ const renamed = freshLabel(gInverse.indices[1].label, taken);
119
+ const renamedGInverse = {
120
+ kind: 'metric-tensor',
121
+ name: gInverse.name,
122
+ indices: [
123
+ { label, variance: 'upper' },
124
+ { label: renamed, variance: 'upper' },
125
+ ],
126
+ signature: gInverse.signature,
127
+ dim: gInverse.dim,
128
+ };
129
+ if (gInverse.derivativeStrategy !== undefined) {
130
+ renamedGInverse.derivativeStrategy =
131
+ gInverse.derivativeStrategy;
132
+ }
133
+ return { kind: 'tensor-product', args: [renamedGInverse, operand] };
134
+ }
135
+ /**
136
+ * Lower an index of `operand` via the covariant metric `g`.
137
+ * Symmetric to raise(). Per Part-VIII §VIII.5.
138
+ *
139
+ * Throws:
140
+ * - MetricSignatureError if g isn't both-lower
141
+ * - RaiseLowerInvalidLabelError if label is absent or already lower in operand
142
+ */
143
+ export function lower(operand, g, label) {
144
+ if (g.indices[0].variance !== 'lower' ||
145
+ g.indices[1].variance !== 'lower') {
146
+ throw new MetricSignatureError(g.name, `lower() requires both indices of the metric to have variance 'lower'`);
147
+ }
148
+ const operandLabels = collectFreeIndexLabels(operand);
149
+ const operandVariance = operandLabels.get(label);
150
+ if (operandVariance === undefined) {
151
+ throw new RaiseLowerInvalidLabelError(`lower(): label '${label}' is not a free index of the operand. ` +
152
+ `Operand free indices: ${Array.from(operandLabels.keys()).join(', ') || '(none)'}.`);
153
+ }
154
+ if (operandVariance === 'lower') {
155
+ throw new RaiseLowerInvalidLabelError(`lower(): label '${label}' is already 'lower' in the operand. ` +
156
+ `Use raise() to raise it, or pick a different label.`);
157
+ }
158
+ const taken = new Set(operandLabels.keys());
159
+ taken.add(label);
160
+ const renamed = freshLabel(g.indices[1].label, taken);
161
+ const renamedG = {
162
+ kind: 'metric-tensor',
163
+ name: g.name,
164
+ indices: [
165
+ { label, variance: 'lower' },
166
+ { label: renamed, variance: 'lower' },
167
+ ],
168
+ signature: g.signature,
169
+ dim: g.dim,
170
+ };
171
+ if (g.derivativeStrategy !== undefined) {
172
+ renamedG.derivativeStrategy =
173
+ g.derivativeStrategy;
174
+ }
175
+ return { kind: 'tensor-product', args: [renamedG, operand] };
176
+ }
177
+ //# sourceMappingURL=metric.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metric.js","sourceRoot":"","sources":["../../src/dimensional/metric.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAU9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE7D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,MAAM,CACpB,IAAY,EACZ,OAAmC,EACnC,GAAc,EACd,SAAiB,EACjB,kBAAqD;IAErD,MAAM,IAAI,GAON,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;IAC7D,IAAI,kBAAkB,KAAK,SAAS;QAAE,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;IACnF,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM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C,IAAI,EAAE,CAAC,CAAC;IAC5C,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACjB,MAAM,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAEtD,MAAM,QAAQ,GAAqB;QACjC,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,OAAO,EAAE;YACP,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE;YAC5B,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE;SACtC;QACD,SAAS,EAAE,CAAC,CAAC,SAAS;QACtB,GAAG,EAAE,CAAC,CAAC,GAAG;KACX,CAAC;IACF,IAAI,CAAC,CAAC,kBAAkB,KAAK,SAAS,EAAE,CAAC;QACtC,QAAgE,CAAC,kBAAkB;YAClF,CAAC,CAAC,kBAAkB,CAAC;IACzB,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Tensor AST node types and helpers — v0.2.0 algebra layer.
3
+ *
4
+ * Adds the two new ExprNode discriminated-union variants:
5
+ * - 'tensor-symbol': a named tensor with variance-typed indices
6
+ * - 'tensor-product': Einstein-summation product over tensor and scalar operands
7
+ *
8
+ * Per docs/specification/Part-VII-Tensor-Algebra.md §VII.1 and §VII.4.
9
+ *
10
+ * @module dimensional/tensor
11
+ */
12
+ import type { Dimension } from './types.js';
13
+ import type { ExprNode } from './validator.js';
14
+ export type Variance = 'upper' | 'lower';
15
+ export type Role = 'coordinate' | 'field' | 'constant';
16
+ export interface TensorIndex {
17
+ readonly label: string;
18
+ readonly variance: Variance;
19
+ }
20
+ export interface TensorSymbolNode {
21
+ readonly kind: 'tensor-symbol';
22
+ readonly name: string;
23
+ readonly indices: ReadonlyArray<TensorIndex>;
24
+ readonly dim: Dimension;
25
+ /**
26
+ * Semantic classification of the tensor, used by v0.3.0+ work
27
+ * (e.g., partial-derivative dispatch). Defaults to 'field' when
28
+ * omitted. v0.2.0 treats this as structural metadata only —
29
+ * no validator behavior depends on it. Per Part-VII §VII.8.
30
+ */
31
+ readonly role?: Role;
32
+ /**
33
+ * v0.3.5 numerical backend: which differentiation strategy the numerical
34
+ * pderiv dispatcher uses when this symbol is the `of` operand of a
35
+ * tensor-partial-derivative. Defaults to 'symbolic' when omitted — so
36
+ * every v0.3.0/v0.3.1 AST is a valid v0.3.5 AST. See v0.3.5-Design.md §6.
37
+ */
38
+ readonly numericalForm?: 'symbolic' | 'numerical-fn' | 'grid';
39
+ }
40
+ export interface TensorProductNode {
41
+ readonly kind: 'tensor-product';
42
+ readonly args: ReadonlyArray<ExprNode>;
43
+ }
44
+ /**
45
+ * The kind tags this module contributes to the ExprNode union. Used by
46
+ * validator.ts to compose the full discriminated union via re-export.
47
+ */
48
+ export type TensorExprNode = TensorSymbolNode | TensorProductNode;
49
+ /**
50
+ * Result shape returned by `validateTensorSymbol`. A minimal carrier for
51
+ * the inferred per-component dimension plus the free-indices map built
52
+ * from the declared indices. The validator's `infer()` adapts this back
53
+ * into its `Dimension | null` return shape and merges `freeIndices` into
54
+ * the outer accumulator.
55
+ */
56
+ export interface TensorSymbolValidationResult {
57
+ readonly dim: Dimension;
58
+ readonly freeIndices: Map<string, {
59
+ upper: number;
60
+ lower: number;
61
+ }>;
62
+ }
63
+ /**
64
+ * Validate a tensor-symbol node. Builds the freeIndices map from the
65
+ * declared indices, with one upper / one lower count per label.
66
+ *
67
+ * Throws `DuplicateIndexLabelError` if the indices list contains the same
68
+ * label more than once (e.g., T^μ_μ_μ). Per Part-VII §VII.4
69
+ * (repeated-dummy-label-in-tensor-symbol-rejected TENSOR-RULE).
70
+ *
71
+ * The function is pure: no I/O, no shared state, total over its input
72
+ * (modulo the documented throw). Callers (validator.ts `infer()`) thread
73
+ * the returned freeIndices map up into their accumulator.
74
+ */
75
+ export declare function validateTensorSymbol(node: TensorSymbolNode): TensorSymbolValidationResult;
76
+ /**
77
+ * Result of a tensor-product contraction over a set of operands.
78
+ *
79
+ * Re-exported as part of v0.2.0's TensorJS forward-compatibility contract
80
+ * (§14.2 of v0.2.0-Design.md). The future mathjs / TensorJS numerical
81
+ * backend will call `computeContraction` with the same operand list, pair
82
+ * the returned `contractionPairs` with its own einsum-pattern compiler,
83
+ * and multiply concrete numerical tensors using its dimensions.
84
+ */
85
+ export interface ContractionResult {
86
+ /** Resulting per-component dimension (product of operand dims). */
87
+ readonly dim: Dimension;
88
+ /** Free indices remaining after Einstein contraction. */
89
+ readonly freeIndices: Map<string, {
90
+ upper: number;
91
+ lower: number;
92
+ }>;
93
+ /** Labels that were contracted (one upper + one lower pair per entry). */
94
+ readonly contractionPairs: ReadonlyArray<{
95
+ label: string;
96
+ }>;
97
+ }
98
+ /**
99
+ * Per-child validation result the caller of `computeContraction` must
100
+ * supply through the `validateChild` callback. Mirrors the local-Map
101
+ * convention pioneered by `validateTensorSymbol`: the child reports its
102
+ * inferred dimension plus a map of label → {upper, lower} counts that
103
+ * `computeContraction` merges and reduces.
104
+ */
105
+ export interface ChildValidationResult {
106
+ readonly dim: Dimension;
107
+ readonly freeIndices: Map<string, {
108
+ upper: number;
109
+ lower: number;
110
+ }>;
111
+ }
112
+ /**
113
+ * Pure function that computes the dimension, free-indices map, and
114
+ * contraction pairs for a tensor-product over the given operands.
115
+ *
116
+ * The function is pure and module-cycle-free: it does NOT import
117
+ * `validator.ts`. Recursion is injected via the `validateChild` callback
118
+ * — the caller (typically validator.ts's `infer()` dispatch) supplies a
119
+ * resolver that returns `{dim, freeIndices}` for each child node. The
120
+ * caller is responsible for handling all `ExprNode` kinds in its callback
121
+ * (scalars, tensor-symbols, nested tensor-products, etc.).
122
+ *
123
+ * Critically, the per-child freeIndices maps returned by `validateChild`
124
+ * MUST be local to that child (not shared mutable state). This is what
125
+ * makes nested tensor-products safe: an inner tensor-product reports its
126
+ * post-contraction residual free indices as a local map, and the outer
127
+ * call merges those without ever touching shared accumulator state.
128
+ *
129
+ * Re-exported for the future mathjs backend per v0.2.0-Design.md §14.2.
130
+ *
131
+ * **v0.2.0 limitation — implicit identity metric.** The contraction
132
+ * mechanism here assumes one upper index `μ` paired with one lower index
133
+ * `μ` annihilate (Kronecker delta convention). v0.3.0's metric layer
134
+ * will introduce explicit g_μν / g^μν for raising and lowering — at
135
+ * which point this function's hard-coded pairing rule must generalize
136
+ * to "find labels with mismatched variance, raise/lower via the metric,
137
+ * then contract." Forward-compat callers should NOT assume the v0.2.0
138
+ * rule is permanent.
139
+ *
140
+ * Throws:
141
+ * - IndexLabelCollisionError if any label appears > 2 times total.
142
+ * - VarianceMismatchError if a label appears twice with same variance.
143
+ */
144
+ export declare function computeContraction(args: ReadonlyArray<ExprNode>, validateChild: (node: ExprNode) => ChildValidationResult): ContractionResult;
145
+ /** Construct a tensor-symbol node. */
146
+ export declare function tsym(name: string, indices: ReadonlyArray<TensorIndex>, dim: Dimension, role?: Role, numericalForm?: 'symbolic' | 'numerical-fn' | 'grid'): TensorSymbolNode;
147
+ /** Scale a tensor by a scalar coefficient. Returns a tensor-product. */
148
+ export declare function scale(scalar: ExprNode, tensor: ExprNode): TensorProductNode;
149
+ /** Contract any number of operands. Returns a tensor-product. */
150
+ export declare function contract(...args: ExprNode[]): TensorProductNode;
151
+ /** Tensor sum via op '+'. Validator enforces matching free indices. */
152
+ export declare function tsum(...args: ExprNode[]): ExprNode;
153
+ //# sourceMappingURL=tensor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tensor.d.ts","sourceRoot":"","sources":["../../src/dimensional/tensor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAO5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAg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