universal-physics-tensor 10.0.0 → 11.0.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 (720) hide show
  1. package/README.md +4 -3
  2. package/bin/upt.mjs +13 -1
  3. package/data/atlas/atlas.json +25 -25
  4. package/data/atlas/atlas.jsonld +1 -1
  5. package/data/atlas/diffusion.json +6 -6
  6. package/data/atlas/oscillators.json +7 -7
  7. package/data/atlas/waves.json +14 -14
  8. package/data/atlas/witness-results.json +11 -11
  9. package/data/bridge-catalog.json +371 -228
  10. package/data/bridge-catalog.schema.json +45 -7
  11. package/dist/atlas/applicability.d.ts.map +1 -1
  12. package/dist/atlas/applicability.js +21 -15
  13. package/dist/atlas/applicability.js.map +1 -1
  14. package/dist/atlas/benchmark/hybrid-retrieval.d.ts +9 -1
  15. package/dist/atlas/benchmark/hybrid-retrieval.d.ts.map +1 -1
  16. package/dist/atlas/benchmark/hybrid-retrieval.js +15 -13
  17. package/dist/atlas/benchmark/hybrid-retrieval.js.map +1 -1
  18. package/dist/atlas/benchmark/loader.js +2 -2
  19. package/dist/atlas/benchmark/loader.js.map +1 -1
  20. package/dist/atlas/benchmark/stats.d.ts +2 -2
  21. package/dist/atlas/benchmark/stats.d.ts.map +1 -1
  22. package/dist/atlas/benchmark/stats.js +15 -7
  23. package/dist/atlas/benchmark/stats.js.map +1 -1
  24. package/dist/atlas/catalog-formal-ref.d.ts +26 -3
  25. package/dist/atlas/catalog-formal-ref.d.ts.map +1 -1
  26. package/dist/atlas/catalog-formal-ref.js +52 -5
  27. package/dist/atlas/catalog-formal-ref.js.map +1 -1
  28. package/dist/atlas/chain-pipeline.d.ts.map +1 -1
  29. package/dist/atlas/chain-pipeline.js +7 -8
  30. package/dist/atlas/chain-pipeline.js.map +1 -1
  31. package/dist/atlas/diffusion/bridges-closure.d.ts +0 -4
  32. package/dist/atlas/diffusion/bridges-closure.d.ts.map +1 -1
  33. package/dist/atlas/diffusion/bridges-closure.js +8 -12
  34. package/dist/atlas/diffusion/bridges-closure.js.map +1 -1
  35. package/dist/atlas/diffusion/bridges.d.ts.map +1 -1
  36. package/dist/atlas/diffusion/bridges.js +27 -39
  37. package/dist/atlas/diffusion/bridges.js.map +1 -1
  38. package/dist/atlas/diffusion/dimensions.d.ts +6 -14
  39. package/dist/atlas/diffusion/dimensions.d.ts.map +1 -1
  40. package/dist/atlas/diffusion/dimensions.js +8 -16
  41. package/dist/atlas/diffusion/dimensions.js.map +1 -1
  42. package/dist/atlas/diffusion/models.d.ts +3 -3
  43. package/dist/atlas/diffusion/models.d.ts.map +1 -1
  44. package/dist/atlas/diffusion/models.js +5 -10
  45. package/dist/atlas/diffusion/models.js.map +1 -1
  46. package/dist/atlas/diffusion/numerics.d.ts +16 -4
  47. package/dist/atlas/diffusion/numerics.d.ts.map +1 -1
  48. package/dist/atlas/diffusion/numerics.js +38 -24
  49. package/dist/atlas/diffusion/numerics.js.map +1 -1
  50. package/dist/atlas/link-prediction.d.ts +106 -3
  51. package/dist/atlas/link-prediction.d.ts.map +1 -1
  52. package/dist/atlas/link-prediction.js +212 -66
  53. package/dist/atlas/link-prediction.js.map +1 -1
  54. package/dist/atlas/oscillators/bridges-coarse.d.ts.map +1 -1
  55. package/dist/atlas/oscillators/bridges-coarse.js +7 -11
  56. package/dist/atlas/oscillators/bridges-coarse.js.map +1 -1
  57. package/dist/atlas/oscillators/bridges-exact.d.ts.map +1 -1
  58. package/dist/atlas/oscillators/bridges-exact.js +6 -7
  59. package/dist/atlas/oscillators/bridges-exact.js.map +1 -1
  60. package/dist/atlas/oscillators/bridges-limits.d.ts +3 -16
  61. package/dist/atlas/oscillators/bridges-limits.d.ts.map +1 -1
  62. package/dist/atlas/oscillators/bridges-limits.js +23 -34
  63. package/dist/atlas/oscillators/bridges-limits.js.map +1 -1
  64. package/dist/atlas/oscillators/dimensions.d.ts +9 -21
  65. package/dist/atlas/oscillators/dimensions.d.ts.map +1 -1
  66. package/dist/atlas/oscillators/dimensions.js +9 -21
  67. package/dist/atlas/oscillators/dimensions.js.map +1 -1
  68. package/dist/atlas/oscillators/limit-witnesses.d.ts +2 -2
  69. package/dist/atlas/oscillators/limit-witnesses.d.ts.map +1 -1
  70. package/dist/atlas/oscillators/limit-witnesses.js +17 -15
  71. package/dist/atlas/oscillators/limit-witnesses.js.map +1 -1
  72. package/dist/atlas/oscillators/models.d.ts.map +1 -1
  73. package/dist/atlas/oscillators/models.js +2 -6
  74. package/dist/atlas/oscillators/models.js.map +1 -1
  75. package/dist/atlas/oscillators/pendulum-motion.d.ts +29 -6
  76. package/dist/atlas/oscillators/pendulum-motion.d.ts.map +1 -1
  77. package/dist/atlas/oscillators/pendulum-motion.js +60 -40
  78. package/dist/atlas/oscillators/pendulum-motion.js.map +1 -1
  79. package/dist/atlas/oscillators/phase-translation.d.ts +0 -11
  80. package/dist/atlas/oscillators/phase-translation.d.ts.map +1 -1
  81. package/dist/atlas/oscillators/phase-translation.js +3 -4
  82. package/dist/atlas/oscillators/phase-translation.js.map +1 -1
  83. package/dist/atlas/oscillators/position-translation.d.ts +68 -7
  84. package/dist/atlas/oscillators/position-translation.d.ts.map +1 -1
  85. package/dist/atlas/oscillators/position-translation.js +123 -12
  86. package/dist/atlas/oscillators/position-translation.js.map +1 -1
  87. package/dist/atlas/oscillators/rejections.d.ts +0 -2
  88. package/dist/atlas/oscillators/rejections.d.ts.map +1 -1
  89. package/dist/atlas/oscillators/rejections.js +0 -7
  90. package/dist/atlas/oscillators/rejections.js.map +1 -1
  91. package/dist/atlas/physjs-entries.generated.d.ts +25 -24
  92. package/dist/atlas/physjs-entries.generated.d.ts.map +1 -1
  93. package/dist/atlas/physjs-entries.generated.js +25 -24
  94. package/dist/atlas/physjs-entries.generated.js.map +1 -1
  95. package/dist/atlas/physjs-ref.d.ts +34 -31
  96. package/dist/atlas/physjs-ref.d.ts.map +1 -1
  97. package/dist/atlas/physjs-ref.js +55 -53
  98. package/dist/atlas/physjs-ref.js.map +1 -1
  99. package/dist/atlas/physjs-reviewed.d.ts +1 -1
  100. package/dist/atlas/physjs-reviewed.js +15 -15
  101. package/dist/atlas/physjs-reviewed.js.map +1 -1
  102. package/dist/atlas/poster/statements.d.ts +0 -19
  103. package/dist/atlas/poster/statements.d.ts.map +1 -1
  104. package/dist/atlas/poster/statements.js +1 -1
  105. package/dist/atlas/poster/statements.js.map +1 -1
  106. package/dist/atlas/proof-target.d.ts +1 -1
  107. package/dist/atlas/proof-target.js +1 -1
  108. package/dist/atlas/proof-target.js.map +1 -1
  109. package/dist/atlas/regime.d.ts +1 -1
  110. package/dist/atlas/regime.d.ts.map +1 -1
  111. package/dist/atlas/regime.js +1 -1
  112. package/dist/atlas/regime.js.map +1 -1
  113. package/dist/atlas/text-overlap.d.ts +23 -0
  114. package/dist/atlas/text-overlap.d.ts.map +1 -0
  115. package/dist/atlas/text-overlap.js +41 -0
  116. package/dist/atlas/text-overlap.js.map +1 -0
  117. package/dist/atlas/waves/bridges-closure.d.ts.map +1 -1
  118. package/dist/atlas/waves/bridges-closure.js +2 -6
  119. package/dist/atlas/waves/bridges-closure.js.map +1 -1
  120. package/dist/atlas/waves/bridges.d.ts.map +1 -1
  121. package/dist/atlas/waves/bridges.js +32 -48
  122. package/dist/atlas/waves/bridges.js.map +1 -1
  123. package/dist/atlas/waves/models.d.ts +5 -6
  124. package/dist/atlas/waves/models.d.ts.map +1 -1
  125. package/dist/atlas/waves/models.js +7 -13
  126. package/dist/atlas/waves/models.js.map +1 -1
  127. package/dist/atlas/waves/numerics.d.ts.map +1 -1
  128. package/dist/atlas/waves/numerics.js +10 -3
  129. package/dist/atlas/waves/numerics.js.map +1 -1
  130. package/dist/atlas/witness-numeric.d.ts +30 -0
  131. package/dist/atlas/witness-numeric.d.ts.map +1 -1
  132. package/dist/atlas/witness-numeric.js +53 -0
  133. package/dist/atlas/witness-numeric.js.map +1 -1
  134. package/dist/atlas/witness-specs.d.ts.map +1 -1
  135. package/dist/atlas/witness-specs.js +19 -0
  136. package/dist/atlas/witness-specs.js.map +1 -1
  137. package/dist/atlas/witness-symbolic.d.ts +75 -3
  138. package/dist/atlas/witness-symbolic.d.ts.map +1 -1
  139. package/dist/atlas/witness-symbolic.js +116 -10
  140. package/dist/atlas/witness-symbolic.js.map +1 -1
  141. package/dist/bridges/catalog-load.d.ts.map +1 -1
  142. package/dist/bridges/catalog-load.js +13 -8
  143. package/dist/bridges/catalog-load.js.map +1 -1
  144. package/dist/bridges/catalog-types.d.ts +26 -2
  145. package/dist/bridges/catalog-types.d.ts.map +1 -1
  146. package/dist/bridges/catalog-types.js +11 -1
  147. package/dist/bridges/catalog-types.js.map +1 -1
  148. package/dist/bridges/evaluation-errors.d.ts +31 -1
  149. package/dist/bridges/evaluation-errors.d.ts.map +1 -1
  150. package/dist/bridges/evaluation-errors.js +20 -2
  151. package/dist/bridges/evaluation-errors.js.map +1 -1
  152. package/dist/bridges/evaluator-inputs.d.ts.map +1 -1
  153. package/dist/bridges/evaluator-inputs.js +7 -5
  154. package/dist/bridges/evaluator-inputs.js.map +1 -1
  155. package/dist/bridges/evaluators.d.ts.map +1 -1
  156. package/dist/bridges/evaluators.js +27 -12
  157. package/dist/bridges/evaluators.js.map +1 -1
  158. package/dist/bridges/expr-parse.d.ts +11 -0
  159. package/dist/bridges/expr-parse.d.ts.map +1 -1
  160. package/dist/bridges/expr-parse.js +14 -5
  161. package/dist/bridges/expr-parse.js.map +1 -1
  162. package/dist/bridges/holds.d.ts +35 -3
  163. package/dist/bridges/holds.d.ts.map +1 -1
  164. package/dist/bridges/holds.js +117 -23
  165. package/dist/bridges/holds.js.map +1 -1
  166. package/dist/bridges/notices.d.ts.map +1 -1
  167. package/dist/bridges/notices.js +5 -5
  168. package/dist/bridges/notices.js.map +1 -1
  169. package/dist/bridges/relation-eval.d.ts +4 -4
  170. package/dist/bridges/relation-eval.d.ts.map +1 -1
  171. package/dist/bridges/relation-eval.js +15 -16
  172. package/dist/bridges/relation-eval.js.map +1 -1
  173. package/dist/bridges/sensitivity.d.ts.map +1 -1
  174. package/dist/bridges/sensitivity.js +3 -3
  175. package/dist/bridges/sensitivity.js.map +1 -1
  176. package/dist/bridges/validity.d.ts +33 -0
  177. package/dist/bridges/validity.d.ts.map +1 -0
  178. package/dist/bridges/validity.js +67 -0
  179. package/dist/bridges/validity.js.map +1 -0
  180. package/dist/canonical/entries/atomic.js +1 -3
  181. package/dist/canonical/entries/atomic.js.map +1 -1
  182. package/dist/canonical/entries/condensed-matter.d.ts.map +1 -1
  183. package/dist/canonical/entries/condensed-matter.js +4 -5
  184. package/dist/canonical/entries/condensed-matter.js.map +1 -1
  185. package/dist/canonical/entries/dimensional-classics.d.ts.map +1 -1
  186. package/dist/canonical/entries/dimensional-classics.js +3 -4
  187. package/dist/canonical/entries/dimensional-classics.js.map +1 -1
  188. package/dist/canonical/entries/electromagnetism.d.ts.map +1 -1
  189. package/dist/canonical/entries/electromagnetism.js +4 -10
  190. package/dist/canonical/entries/electromagnetism.js.map +1 -1
  191. package/dist/canonical/entries/fluids-waves.d.ts.map +1 -1
  192. package/dist/canonical/entries/fluids-waves.js +3 -7
  193. package/dist/canonical/entries/fluids-waves.js.map +1 -1
  194. package/dist/canonical/entries/mechanics.d.ts.map +1 -1
  195. package/dist/canonical/entries/mechanics.js +4 -6
  196. package/dist/canonical/entries/mechanics.js.map +1 -1
  197. package/dist/canonical/entries/nonmonomial.d.ts.map +1 -1
  198. package/dist/canonical/entries/nonmonomial.js +9 -17
  199. package/dist/canonical/entries/nonmonomial.js.map +1 -1
  200. package/dist/canonical/entries/relativity.d.ts.map +1 -1
  201. package/dist/canonical/entries/relativity.js +6 -6
  202. package/dist/canonical/entries/relativity.js.map +1 -1
  203. package/dist/canonical/entries/thermo-nuclear-cosmo.d.ts.map +1 -1
  204. package/dist/canonical/entries/thermo-nuclear-cosmo.js +6 -10
  205. package/dist/canonical/entries/thermo-nuclear-cosmo.js.map +1 -1
  206. package/dist/canonical/fixed-points.d.ts +94 -0
  207. package/dist/canonical/fixed-points.d.ts.map +1 -0
  208. package/dist/canonical/fixed-points.js +81 -0
  209. package/dist/canonical/fixed-points.js.map +1 -0
  210. package/dist/canonical/linkage.d.ts.map +1 -1
  211. package/dist/canonical/linkage.js +25 -44
  212. package/dist/canonical/linkage.js.map +1 -1
  213. package/dist/canonical/normal-form.d.ts.map +1 -1
  214. package/dist/canonical/normal-form.js +5 -11
  215. package/dist/canonical/normal-form.js.map +1 -1
  216. package/dist/canonical/structural.d.ts +21 -21
  217. package/dist/canonical/structural.d.ts.map +1 -1
  218. package/dist/canonical/structural.js +40 -19
  219. package/dist/canonical/structural.js.map +1 -1
  220. package/dist/cases/brownian-sphere.d.ts +3 -3
  221. package/dist/cases/brownian-sphere.d.ts.map +1 -1
  222. package/dist/cases/brownian-sphere.js +6 -5
  223. package/dist/cases/brownian-sphere.js.map +1 -1
  224. package/dist/cases/damped-resonator.d.ts.map +1 -1
  225. package/dist/cases/damped-resonator.js +6 -9
  226. package/dist/cases/damped-resonator.js.map +1 -1
  227. package/dist/cases/kepler-rv.d.ts +1 -1
  228. package/dist/cases/kepler-rv.d.ts.map +1 -1
  229. package/dist/cases/kepler-rv.js +3 -2
  230. package/dist/cases/kepler-rv.js.map +1 -1
  231. package/dist/cases/lumped-cooling.d.ts +8 -3
  232. package/dist/cases/lumped-cooling.d.ts.map +1 -1
  233. package/dist/cases/lumped-cooling.js +21 -23
  234. package/dist/cases/lumped-cooling.js.map +1 -1
  235. package/dist/cases/quadrature.d.ts +7 -9
  236. package/dist/cases/quadrature.d.ts.map +1 -1
  237. package/dist/cases/quadrature.js +28 -32
  238. package/dist/cases/quadrature.js.map +1 -1
  239. package/dist/cases/resistor-noise.js +4 -4
  240. package/dist/cases/resistor-noise.js.map +1 -1
  241. package/dist/cases/skin-depth.d.ts +0 -4
  242. package/dist/cases/skin-depth.d.ts.map +1 -1
  243. package/dist/cases/skin-depth.js +3 -7
  244. package/dist/cases/skin-depth.js.map +1 -1
  245. package/dist/cli/args.d.ts +23 -1
  246. package/dist/cli/args.d.ts.map +1 -1
  247. package/dist/cli/args.js +30 -8
  248. package/dist/cli/args.js.map +1 -1
  249. package/dist/cli/bindings.d.ts.map +1 -1
  250. package/dist/cli/bindings.js +5 -4
  251. package/dist/cli/bindings.js.map +1 -1
  252. package/dist/cli/command.d.ts +8 -1
  253. package/dist/cli/command.d.ts.map +1 -1
  254. package/dist/cli/command.js.map +1 -1
  255. package/dist/cli/commands/_atlas-map.d.ts +0 -9
  256. package/dist/cli/commands/_atlas-map.d.ts.map +1 -1
  257. package/dist/cli/commands/_atlas-map.js +8 -18
  258. package/dist/cli/commands/_atlas-map.js.map +1 -1
  259. package/dist/cli/commands/_atlas-route.d.ts.map +1 -1
  260. package/dist/cli/commands/_atlas-route.js +6 -2
  261. package/dist/cli/commands/_atlas-route.js.map +1 -1
  262. package/dist/cli/commands/_discovery-opts.d.ts.map +1 -1
  263. package/dist/cli/commands/_discovery-opts.js +8 -9
  264. package/dist/cli/commands/_discovery-opts.js.map +1 -1
  265. package/dist/cli/commands/atlas.d.ts.map +1 -1
  266. package/dist/cli/commands/atlas.js +8 -5
  267. package/dist/cli/commands/atlas.js.map +1 -1
  268. package/dist/cli/commands/audit.d.ts.map +1 -1
  269. package/dist/cli/commands/audit.js +8 -1
  270. package/dist/cli/commands/audit.js.map +1 -1
  271. package/dist/cli/commands/axes.d.ts.map +1 -1
  272. package/dist/cli/commands/axes.js +20 -1
  273. package/dist/cli/commands/axes.js.map +1 -1
  274. package/dist/cli/commands/confront.d.ts.map +1 -1
  275. package/dist/cli/commands/confront.js +8 -14
  276. package/dist/cli/commands/confront.js.map +1 -1
  277. package/dist/cli/commands/derive.d.ts.map +1 -1
  278. package/dist/cli/commands/derive.js +22 -22
  279. package/dist/cli/commands/derive.js.map +1 -1
  280. package/dist/cli/commands/discover.d.ts.map +1 -1
  281. package/dist/cli/commands/discover.js +6 -2
  282. package/dist/cli/commands/discover.js.map +1 -1
  283. package/dist/cli/commands/eval.d.ts.map +1 -1
  284. package/dist/cli/commands/eval.js +1 -0
  285. package/dist/cli/commands/eval.js.map +1 -1
  286. package/dist/cli/commands/evaluate.d.ts.map +1 -1
  287. package/dist/cli/commands/evaluate.js +65 -37
  288. package/dist/cli/commands/evaluate.js.map +1 -1
  289. package/dist/cli/commands/explain.d.ts.map +1 -1
  290. package/dist/cli/commands/explain.js +2 -1
  291. package/dist/cli/commands/explain.js.map +1 -1
  292. package/dist/cli/commands/ground.d.ts.map +1 -1
  293. package/dist/cli/commands/ground.js +1 -0
  294. package/dist/cli/commands/ground.js.map +1 -1
  295. package/dist/cli/commands/map.d.ts.map +1 -1
  296. package/dist/cli/commands/map.js +75 -5
  297. package/dist/cli/commands/map.js.map +1 -1
  298. package/dist/cli/commands/metric.d.ts.map +1 -1
  299. package/dist/cli/commands/metric.js +12 -9
  300. package/dist/cli/commands/metric.js.map +1 -1
  301. package/dist/cli/commands/path.d.ts +10 -0
  302. package/dist/cli/commands/path.d.ts.map +1 -1
  303. package/dist/cli/commands/path.js +25 -3
  304. package/dist/cli/commands/path.js.map +1 -1
  305. package/dist/cli/commands/probe.d.ts.map +1 -1
  306. package/dist/cli/commands/probe.js +59 -16
  307. package/dist/cli/commands/probe.js.map +1 -1
  308. package/dist/cli/commands/regime.d.ts.map +1 -1
  309. package/dist/cli/commands/regime.js +1 -0
  310. package/dist/cli/commands/regime.js.map +1 -1
  311. package/dist/cli/commands/retrieve.d.ts.map +1 -1
  312. package/dist/cli/commands/retrieve.js +1 -0
  313. package/dist/cli/commands/retrieve.js.map +1 -1
  314. package/dist/cli/commands/search.d.ts.map +1 -1
  315. package/dist/cli/commands/search.js +1 -0
  316. package/dist/cli/commands/search.js.map +1 -1
  317. package/dist/cli/commands/symbolic.d.ts.map +1 -1
  318. package/dist/cli/commands/symbolic.js +19 -28
  319. package/dist/cli/commands/symbolic.js.map +1 -1
  320. package/dist/cli/commands/testplan.d.ts.map +1 -1
  321. package/dist/cli/commands/testplan.js +4 -2
  322. package/dist/cli/commands/testplan.js.map +1 -1
  323. package/dist/cli/expr-print.d.ts +0 -2
  324. package/dist/cli/expr-print.d.ts.map +1 -1
  325. package/dist/cli/expr-print.js +7 -31
  326. package/dist/cli/expr-print.js.map +1 -1
  327. package/dist/cli/main.d.ts +7 -0
  328. package/dist/cli/main.d.ts.map +1 -1
  329. package/dist/cli/main.js +18 -3
  330. package/dist/cli/main.js.map +1 -1
  331. package/dist/cli/numeric-flag.d.ts +12 -0
  332. package/dist/cli/numeric-flag.d.ts.map +1 -0
  333. package/dist/cli/numeric-flag.js +44 -0
  334. package/dist/cli/numeric-flag.js.map +1 -0
  335. package/dist/cli/output.d.ts +20 -0
  336. package/dist/cli/output.d.ts.map +1 -1
  337. package/dist/cli/output.js +15 -0
  338. package/dist/cli/output.js.map +1 -1
  339. package/dist/cli/record-reach.js +2 -2
  340. package/dist/cli/record-reach.js.map +1 -1
  341. package/dist/cli/record-tables.d.ts.map +1 -1
  342. package/dist/cli/record-tables.js +6 -5
  343. package/dist/cli/record-tables.js.map +1 -1
  344. package/dist/cli/record.d.ts +1 -5
  345. package/dist/cli/record.d.ts.map +1 -1
  346. package/dist/cli/record.js +9 -8
  347. package/dist/cli/record.js.map +1 -1
  348. package/dist/cli/search-index.d.ts.map +1 -1
  349. package/dist/cli/search-index.js +7 -6
  350. package/dist/cli/search-index.js.map +1 -1
  351. package/dist/cli/statuses.d.ts +0 -2
  352. package/dist/cli/statuses.d.ts.map +1 -1
  353. package/dist/cli/statuses.js +0 -7
  354. package/dist/cli/statuses.js.map +1 -1
  355. package/dist/cli/stored-results.d.ts +7 -0
  356. package/dist/cli/stored-results.d.ts.map +1 -0
  357. package/dist/cli/stored-results.js +23 -0
  358. package/dist/cli/stored-results.js.map +1 -0
  359. package/dist/cli/version.d.ts.map +1 -1
  360. package/dist/cli/version.js +7 -5
  361. package/dist/cli/version.js.map +1 -1
  362. package/dist/cli-api.d.ts +34 -5
  363. package/dist/cli-api.d.ts.map +1 -1
  364. package/dist/cli-api.js +28 -4
  365. package/dist/cli-api.js.map +1 -1
  366. package/dist/composition/algebraic-equivalence.d.ts +43 -0
  367. package/dist/composition/algebraic-equivalence.d.ts.map +1 -0
  368. package/dist/composition/algebraic-equivalence.js +115 -0
  369. package/dist/composition/algebraic-equivalence.js.map +1 -0
  370. package/dist/composition/axes.d.ts +0 -6
  371. package/dist/composition/axes.d.ts.map +1 -1
  372. package/dist/composition/axes.js +6 -6
  373. package/dist/composition/axes.js.map +1 -1
  374. package/dist/composition/axis-audit.d.ts +47 -20
  375. package/dist/composition/axis-audit.d.ts.map +1 -1
  376. package/dist/composition/axis-audit.js +82 -9
  377. package/dist/composition/axis-audit.js.map +1 -1
  378. package/dist/composition/bridge-analysis.d.ts +17 -0
  379. package/dist/composition/bridge-analysis.d.ts.map +1 -1
  380. package/dist/composition/bridge-analysis.js +102 -55
  381. package/dist/composition/bridge-analysis.js.map +1 -1
  382. package/dist/composition/canonical-compare.d.ts +40 -0
  383. package/dist/composition/canonical-compare.d.ts.map +1 -1
  384. package/dist/composition/canonical-compare.js +122 -24
  385. package/dist/composition/canonical-compare.js.map +1 -1
  386. package/dist/composition/canonical-graph.d.ts +1 -1
  387. package/dist/composition/canonical-graph.d.ts.map +1 -1
  388. package/dist/composition/canonical-graph.js +9 -36
  389. package/dist/composition/canonical-graph.js.map +1 -1
  390. package/dist/composition/canonical-json.js +2 -2
  391. package/dist/composition/canonical-json.js.map +1 -1
  392. package/dist/composition/catalog-graph.d.ts.map +1 -1
  393. package/dist/composition/catalog-graph.js +2 -5
  394. package/dist/composition/catalog-graph.js.map +1 -1
  395. package/dist/composition/chain-candidate.d.ts +8 -0
  396. package/dist/composition/chain-candidate.d.ts.map +1 -1
  397. package/dist/composition/chain-candidate.js +9 -2
  398. package/dist/composition/chain-candidate.js.map +1 -1
  399. package/dist/composition/chain-match.d.ts +6 -3
  400. package/dist/composition/chain-match.d.ts.map +1 -1
  401. package/dist/composition/chain-match.js +4 -1
  402. package/dist/composition/chain-match.js.map +1 -1
  403. package/dist/composition/chain-result.d.ts.map +1 -1
  404. package/dist/composition/chain-result.js +2 -14
  405. package/dist/composition/chain-result.js.map +1 -1
  406. package/dist/composition/compose-symbolic.d.ts.map +1 -1
  407. package/dist/composition/compose-symbolic.js +3 -2
  408. package/dist/composition/compose-symbolic.js.map +1 -1
  409. package/dist/composition/compose.d.ts.map +1 -1
  410. package/dist/composition/compose.js +13 -5
  411. package/dist/composition/compose.js.map +1 -1
  412. package/dist/composition/composition-recovery.d.ts.map +1 -1
  413. package/dist/composition/composition-recovery.js +4 -7
  414. package/dist/composition/composition-recovery.js.map +1 -1
  415. package/dist/composition/discovery.d.ts +56 -0
  416. package/dist/composition/discovery.d.ts.map +1 -1
  417. package/dist/composition/discovery.js +114 -60
  418. package/dist/composition/discovery.js.map +1 -1
  419. package/dist/composition/edge.d.ts +21 -2
  420. package/dist/composition/edge.d.ts.map +1 -1
  421. package/dist/composition/edge.js +23 -1
  422. package/dist/composition/edge.js.map +1 -1
  423. package/dist/composition/enumerate.d.ts.map +1 -1
  424. package/dist/composition/enumerate.js +18 -3
  425. package/dist/composition/enumerate.js.map +1 -1
  426. package/dist/composition/evaluate-relation.d.ts +35 -11
  427. package/dist/composition/evaluate-relation.d.ts.map +1 -1
  428. package/dist/composition/evaluate-relation.js +60 -39
  429. package/dist/composition/evaluate-relation.js.map +1 -1
  430. package/dist/composition/explain.d.ts +3 -12
  431. package/dist/composition/explain.d.ts.map +1 -1
  432. package/dist/composition/explain.js +7 -20
  433. package/dist/composition/explain.js.map +1 -1
  434. package/dist/composition/expr-eval.d.ts.map +1 -1
  435. package/dist/composition/expr-eval.js +2 -11
  436. package/dist/composition/expr-eval.js.map +1 -1
  437. package/dist/composition/expr-simplify.d.ts +16 -0
  438. package/dist/composition/expr-simplify.d.ts.map +1 -1
  439. package/dist/composition/expr-simplify.js +15 -20
  440. package/dist/composition/expr-simplify.js.map +1 -1
  441. package/dist/composition/formula-shape.d.ts +23 -4
  442. package/dist/composition/formula-shape.d.ts.map +1 -1
  443. package/dist/composition/formula-shape.js +57 -17
  444. package/dist/composition/formula-shape.js.map +1 -1
  445. package/dist/composition/graph-structure.d.ts +98 -0
  446. package/dist/composition/graph-structure.d.ts.map +1 -0
  447. package/dist/composition/graph-structure.js +167 -0
  448. package/dist/composition/graph-structure.js.map +1 -0
  449. package/dist/composition/graph-viz-svg.d.ts.map +1 -1
  450. package/dist/composition/graph-viz-svg.js +1 -1
  451. package/dist/composition/graph-viz-svg.js.map +1 -1
  452. package/dist/composition/graph-viz.d.ts.map +1 -1
  453. package/dist/composition/graph-viz.js +8 -37
  454. package/dist/composition/graph-viz.js.map +1 -1
  455. package/dist/composition/identifiability.d.ts +91 -4
  456. package/dist/composition/identifiability.d.ts.map +1 -1
  457. package/dist/composition/identifiability.js +363 -6
  458. package/dist/composition/identifiability.js.map +1 -1
  459. package/dist/composition/index.d.ts +8 -4
  460. package/dist/composition/index.d.ts.map +1 -1
  461. package/dist/composition/index.js +3 -2
  462. package/dist/composition/index.js.map +1 -1
  463. package/dist/composition/mathts-quiet.d.ts +4 -3
  464. package/dist/composition/mathts-quiet.d.ts.map +1 -1
  465. package/dist/composition/mathts-quiet.js +4 -3
  466. package/dist/composition/mathts-quiet.js.map +1 -1
  467. package/dist/composition/mathts-scalar-symbols.d.ts.map +1 -1
  468. package/dist/composition/mathts-scalar-symbols.js +2 -1
  469. package/dist/composition/mathts-scalar-symbols.js.map +1 -1
  470. package/dist/composition/probe/corpus.d.ts +4 -2
  471. package/dist/composition/probe/corpus.d.ts.map +1 -1
  472. package/dist/composition/probe/corpus.js +20 -9
  473. package/dist/composition/probe/corpus.js.map +1 -1
  474. package/dist/composition/probe/dataset.d.ts +17 -0
  475. package/dist/composition/probe/dataset.d.ts.map +1 -1
  476. package/dist/composition/probe/dataset.js +95 -50
  477. package/dist/composition/probe/dataset.js.map +1 -1
  478. package/dist/composition/probe/experiment-design.d.ts +5 -1
  479. package/dist/composition/probe/experiment-design.d.ts.map +1 -1
  480. package/dist/composition/probe/experiment-design.js +44 -24
  481. package/dist/composition/probe/experiment-design.js.map +1 -1
  482. package/dist/composition/probe/falsify.d.ts.map +1 -1
  483. package/dist/composition/probe/falsify.js +2 -0
  484. package/dist/composition/probe/falsify.js.map +1 -1
  485. package/dist/composition/probe/fit.d.ts +6 -0
  486. package/dist/composition/probe/fit.d.ts.map +1 -1
  487. package/dist/composition/probe/fit.js +46 -22
  488. package/dist/composition/probe/fit.js.map +1 -1
  489. package/dist/composition/probe/frontier.d.ts.map +1 -1
  490. package/dist/composition/probe/frontier.js +33 -15
  491. package/dist/composition/probe/frontier.js.map +1 -1
  492. package/dist/composition/probe/generator.d.ts +27 -1
  493. package/dist/composition/probe/generator.d.ts.map +1 -1
  494. package/dist/composition/probe/generator.js +53 -30
  495. package/dist/composition/probe/generator.js.map +1 -1
  496. package/dist/composition/probe/index.d.ts +14 -0
  497. package/dist/composition/probe/index.d.ts.map +1 -1
  498. package/dist/composition/probe/index.js +6 -0
  499. package/dist/composition/probe/index.js.map +1 -1
  500. package/dist/composition/probe/limits.d.ts +24 -1
  501. package/dist/composition/probe/limits.d.ts.map +1 -1
  502. package/dist/composition/probe/limits.js +53 -11
  503. package/dist/composition/probe/limits.js.map +1 -1
  504. package/dist/composition/probe/pipeline.d.ts.map +1 -1
  505. package/dist/composition/probe/pipeline.js +10 -4
  506. package/dist/composition/probe/pipeline.js.map +1 -1
  507. package/dist/composition/probe/power-law.d.ts +121 -0
  508. package/dist/composition/probe/power-law.d.ts.map +1 -0
  509. package/dist/composition/probe/power-law.js +255 -0
  510. package/dist/composition/probe/power-law.js.map +1 -0
  511. package/dist/composition/probe/problem.d.ts +7 -4
  512. package/dist/composition/probe/problem.d.ts.map +1 -1
  513. package/dist/composition/probe/problem.js +177 -49
  514. package/dist/composition/probe/problem.js.map +1 -1
  515. package/dist/composition/probe/report.js +1 -1
  516. package/dist/composition/probe/report.js.map +1 -1
  517. package/dist/composition/probe/residual.d.ts +6 -1
  518. package/dist/composition/probe/residual.d.ts.map +1 -1
  519. package/dist/composition/probe/residual.js +9 -7
  520. package/dist/composition/probe/residual.js.map +1 -1
  521. package/dist/composition/probe/structure.d.ts +82 -17
  522. package/dist/composition/probe/structure.d.ts.map +1 -1
  523. package/dist/composition/probe/structure.js +129 -55
  524. package/dist/composition/probe/structure.js.map +1 -1
  525. package/dist/composition/probe/study.d.ts +31 -9
  526. package/dist/composition/probe/study.d.ts.map +1 -1
  527. package/dist/composition/probe/study.js +236 -181
  528. package/dist/composition/probe/study.js.map +1 -1
  529. package/dist/composition/probe/t-tail.d.ts +17 -0
  530. package/dist/composition/probe/t-tail.d.ts.map +1 -0
  531. package/dist/composition/probe/t-tail.js +32 -0
  532. package/dist/composition/probe/t-tail.js.map +1 -0
  533. package/dist/composition/probe/types.d.ts +3 -0
  534. package/dist/composition/probe/types.d.ts.map +1 -1
  535. package/dist/composition/probe/types.js.map +1 -1
  536. package/dist/composition/proposed-bridges.d.ts +41 -10
  537. package/dist/composition/proposed-bridges.d.ts.map +1 -1
  538. package/dist/composition/proposed-bridges.js +100 -55
  539. package/dist/composition/proposed-bridges.js.map +1 -1
  540. package/dist/composition/quantity-clusters.d.ts +48 -0
  541. package/dist/composition/quantity-clusters.d.ts.map +1 -0
  542. package/dist/composition/quantity-clusters.js +98 -0
  543. package/dist/composition/quantity-clusters.js.map +1 -0
  544. package/dist/composition/rational-exponent.d.ts +40 -0
  545. package/dist/composition/rational-exponent.d.ts.map +1 -0
  546. package/dist/composition/rational-exponent.js +65 -0
  547. package/dist/composition/rational-exponent.js.map +1 -0
  548. package/dist/composition/representative-values.d.ts +22 -0
  549. package/dist/composition/representative-values.d.ts.map +1 -1
  550. package/dist/composition/representative-values.js +23 -0
  551. package/dist/composition/representative-values.js.map +1 -1
  552. package/dist/composition/retrodiction.d.ts.map +1 -1
  553. package/dist/composition/retrodiction.js +2 -1
  554. package/dist/composition/retrodiction.js.map +1 -1
  555. package/dist/composition/user-equation.d.ts.map +1 -1
  556. package/dist/composition/user-equation.js +2 -2
  557. package/dist/composition/user-equation.js.map +1 -1
  558. package/dist/core/assignment.d.ts +19 -0
  559. package/dist/core/assignment.d.ts.map +1 -0
  560. package/dist/core/assignment.js +19 -0
  561. package/dist/core/assignment.js.map +1 -0
  562. package/dist/core/compare.d.ts +32 -0
  563. package/dist/core/compare.d.ts.map +1 -0
  564. package/dist/core/compare.js +46 -0
  565. package/dist/core/compare.js.map +1 -0
  566. package/dist/core/constants.d.ts +30 -30
  567. package/dist/core/constants.d.ts.map +1 -1
  568. package/dist/core/constants.js +47 -30
  569. package/dist/core/constants.js.map +1 -1
  570. package/dist/core/data-file.d.ts +7 -0
  571. package/dist/core/data-file.d.ts.map +1 -1
  572. package/dist/core/data-file.js +17 -0
  573. package/dist/core/data-file.js.map +1 -1
  574. package/dist/core/format.d.ts +36 -0
  575. package/dist/core/format.d.ts.map +1 -0
  576. package/dist/core/format.js +39 -0
  577. package/dist/core/format.js.map +1 -0
  578. package/dist/core/hash.d.ts +14 -0
  579. package/dist/core/hash.d.ts.map +1 -0
  580. package/dist/core/hash.js +17 -0
  581. package/dist/core/hash.js.map +1 -0
  582. package/dist/core/json-schema.d.ts +2 -0
  583. package/dist/core/json-schema.d.ts.map +1 -1
  584. package/dist/core/json-schema.js +14 -13
  585. package/dist/core/json-schema.js.map +1 -1
  586. package/dist/core/labeled-tensor.d.ts.map +1 -1
  587. package/dist/core/labeled-tensor.js +0 -8
  588. package/dist/core/labeled-tensor.js.map +1 -1
  589. package/dist/core/mathts-read.d.ts +25 -0
  590. package/dist/core/mathts-read.d.ts.map +1 -0
  591. package/dist/core/mathts-read.js +51 -0
  592. package/dist/core/mathts-read.js.map +1 -0
  593. package/dist/core/tensor.d.ts.map +1 -1
  594. package/dist/core/tensor.js +24 -0
  595. package/dist/core/tensor.js.map +1 -1
  596. package/dist/core/types.d.ts +5 -5
  597. package/dist/diff/bridge-gradient.d.ts +19 -6
  598. package/dist/diff/bridge-gradient.d.ts.map +1 -1
  599. package/dist/diff/bridge-gradient.js +19 -11
  600. package/dist/diff/bridge-gradient.js.map +1 -1
  601. package/dist/diff/bridge-specs.d.ts.map +1 -1
  602. package/dist/diff/bridge-specs.js +3 -0
  603. package/dist/diff/bridge-specs.js.map +1 -1
  604. package/dist/dimensional/algebra.d.ts +18 -0
  605. package/dist/dimensional/algebra.d.ts.map +1 -1
  606. package/dist/dimensional/algebra.js +41 -1
  607. package/dist/dimensional/algebra.js.map +1 -1
  608. package/dist/dimensional/ast-builders.d.ts +7 -0
  609. package/dist/dimensional/ast-builders.d.ts.map +1 -1
  610. package/dist/dimensional/ast-builders.js +11 -0
  611. package/dist/dimensional/ast-builders.js.map +1 -1
  612. package/dist/dimensional/ast-leaves.d.ts +81 -0
  613. package/dist/dimensional/ast-leaves.d.ts.map +1 -0
  614. package/dist/dimensional/ast-leaves.js +146 -0
  615. package/dist/dimensional/ast-leaves.js.map +1 -0
  616. package/dist/dimensional/buckingham.d.ts.map +1 -1
  617. package/dist/dimensional/buckingham.js +15 -27
  618. package/dist/dimensional/buckingham.js.map +1 -1
  619. package/dist/dimensional/constant-rows.js +9 -9
  620. package/dist/dimensional/constant-rows.js.map +1 -1
  621. package/dist/dimensional/dimension-inference.d.ts.map +1 -1
  622. package/dist/dimensional/dimension-inference.js +1 -2
  623. package/dist/dimensional/dimension-inference.js.map +1 -1
  624. package/dist/dimensional/errors.d.ts +1 -1
  625. package/dist/dimensional/errors.d.ts.map +1 -1
  626. package/dist/dimensional/errors.js +1 -15
  627. package/dist/dimensional/errors.js.map +1 -1
  628. package/dist/dimensional/exact-scale.d.ts +0 -17
  629. package/dist/dimensional/exact-scale.d.ts.map +1 -1
  630. package/dist/dimensional/exact-scale.js +8 -8
  631. package/dist/dimensional/exact-scale.js.map +1 -1
  632. package/dist/dimensional/gauge-field.d.ts.map +1 -1
  633. package/dist/dimensional/gauge-field.js +2 -2
  634. package/dist/dimensional/gauge-field.js.map +1 -1
  635. package/dist/dimensional/hyphen-names.d.ts +12 -2
  636. package/dist/dimensional/hyphen-names.d.ts.map +1 -1
  637. package/dist/dimensional/hyphen-names.js +44 -19
  638. package/dist/dimensional/hyphen-names.js.map +1 -1
  639. package/dist/dimensional/metric.d.ts.map +1 -1
  640. package/dist/dimensional/metric.js +0 -1
  641. package/dist/dimensional/metric.js.map +1 -1
  642. package/dist/dimensional/symbolic-constants.d.ts +9 -0
  643. package/dist/dimensional/symbolic-constants.d.ts.map +1 -1
  644. package/dist/dimensional/symbolic-constants.js +13 -1
  645. package/dist/dimensional/symbolic-constants.js.map +1 -1
  646. package/dist/dimensional/types.d.ts +36 -0
  647. package/dist/dimensional/types.d.ts.map +1 -1
  648. package/dist/dimensional/types.js +45 -7
  649. package/dist/dimensional/types.js.map +1 -1
  650. package/dist/dimensional/unit-data.js +2 -2
  651. package/dist/dimensional/unit-data.js.map +1 -1
  652. package/dist/index.d.ts +9 -3
  653. package/dist/index.d.ts.map +1 -1
  654. package/dist/index.js +10 -4
  655. package/dist/index.js.map +1 -1
  656. package/dist/numerical/christoffel-flat.d.ts.map +1 -1
  657. package/dist/numerical/christoffel-flat.js +3 -2
  658. package/dist/numerical/christoffel-flat.js.map +1 -1
  659. package/dist/numerical/covariant-eikonal.d.ts.map +1 -1
  660. package/dist/numerical/covariant-eikonal.js +34 -11
  661. package/dist/numerical/covariant-eikonal.js.map +1 -1
  662. package/dist/numerical/curvature-lowering-helpers.js +3 -2
  663. package/dist/numerical/curvature-lowering-helpers.js.map +1 -1
  664. package/dist/numerical/errors.d.ts.map +1 -1
  665. package/dist/numerical/errors.js +0 -3
  666. package/dist/numerical/errors.js.map +1 -1
  667. package/dist/numerical/finite-difference.d.ts +22 -0
  668. package/dist/numerical/finite-difference.d.ts.map +1 -0
  669. package/dist/numerical/finite-difference.js +27 -0
  670. package/dist/numerical/finite-difference.js.map +1 -0
  671. package/dist/numerical/geodesic-integrator.d.ts.map +1 -1
  672. package/dist/numerical/geodesic-integrator.js +22 -14
  673. package/dist/numerical/geodesic-integrator.js.map +1 -1
  674. package/dist/numerical/geometrized.d.ts.map +1 -1
  675. package/dist/numerical/geometrized.js +0 -1
  676. package/dist/numerical/geometrized.js.map +1 -1
  677. package/dist/numerical/mathts-engine.d.ts.map +1 -1
  678. package/dist/numerical/mathts-engine.js +10 -24
  679. package/dist/numerical/mathts-engine.js.map +1 -1
  680. package/dist/numerical/metric-inverse.d.ts.map +1 -1
  681. package/dist/numerical/metric-inverse.js +83 -46
  682. package/dist/numerical/metric-inverse.js.map +1 -1
  683. package/dist/numerical/null-ray-integrator.d.ts +2 -1
  684. package/dist/numerical/null-ray-integrator.d.ts.map +1 -1
  685. package/dist/numerical/null-ray-integrator.js +12 -12
  686. package/dist/numerical/null-ray-integrator.js.map +1 -1
  687. package/dist/numerical/painleve-gullstrand-metric.js +2 -2
  688. package/dist/numerical/painleve-gullstrand-metric.js.map +1 -1
  689. package/dist/numerical/perihelion-finder.d.ts +0 -36
  690. package/dist/numerical/perihelion-finder.d.ts.map +1 -1
  691. package/dist/numerical/perihelion-finder.js +41 -87
  692. package/dist/numerical/perihelion-finder.js.map +1 -1
  693. package/dist/numerical/quadrature.d.ts.map +1 -1
  694. package/dist/numerical/quadrature.js +8 -10
  695. package/dist/numerical/quadrature.js.map +1 -1
  696. package/dist/numerical/rk4-trajectory.d.ts +10 -0
  697. package/dist/numerical/rk4-trajectory.d.ts.map +1 -0
  698. package/dist/numerical/rk4-trajectory.js +37 -0
  699. package/dist/numerical/rk4-trajectory.js.map +1 -0
  700. package/dist/numerical/schwarzschild.d.ts +14 -0
  701. package/dist/numerical/schwarzschild.d.ts.map +1 -0
  702. package/dist/numerical/schwarzschild.js +17 -0
  703. package/dist/numerical/schwarzschild.js.map +1 -0
  704. package/dist/numerical/spacetime-metrics.d.ts +12 -0
  705. package/dist/numerical/spacetime-metrics.d.ts.map +1 -1
  706. package/dist/numerical/spacetime-metrics.js +72 -56
  707. package/dist/numerical/spacetime-metrics.js.map +1 -1
  708. package/dist/numerical/statistics.d.ts +24 -0
  709. package/dist/numerical/statistics.d.ts.map +1 -0
  710. package/dist/numerical/statistics.js +52 -0
  711. package/dist/numerical/statistics.js.map +1 -0
  712. package/dist/numerical/tensor-engine.d.ts +21 -0
  713. package/dist/numerical/tensor-engine.d.ts.map +1 -1
  714. package/dist/numerical/tensor-engine.js +12 -0
  715. package/dist/numerical/tensor-engine.js.map +1 -1
  716. package/dist/relations/regime.d.ts +10 -0
  717. package/dist/relations/regime.d.ts.map +1 -1
  718. package/dist/relations/regime.js +18 -1
  719. package/dist/relations/regime.js.map +1 -1
  720. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"representative-values.js","sourceRoot":"","sources":["../../src/composition/representative-values.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAUH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAE9B;IACF,2EAA2E;IAC3E,aAAa,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,gCAAgC,EAAE;IAC3E,uBAAuB,EAAE;QACvB,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,gEAAgE;KACzE;IACD,mBAAmB,EAAE;QACnB,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,0CAA0C;KACnD;IAED,2EAA2E;IAC3E,yBAAyB,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE;IAC5E,oBAAoB,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,wBAAwB,EAAE;IACzE,0BAA0B,EAAE;QAC1B,KAAK,EAAE,OAAO;QACd,MAAM,EAAE,uBAAuB;KAChC;IACD,gBAAgB,EAAE;QAChB,KAAK,EAAE,OAAO;QACd,MAAM,EAAE,sDAAsD;KAC/D;IAED,2EAA2E;IAC3E,aAAa,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE;IAC3D,gBAAgB,EAAE;QAChB,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,4DAA4D;KACrE;IAED,2EAA2E;IAC3E,iBAAiB,EAAE;QACjB,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,mCAAmC;KAC5C;IACD,yBAAyB,EAAE;QACzB,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,iEAAiE;KAC1E;IACD,eAAe,EAAE;QACf,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,+DAA+D;KACxE;IACD,eAAe,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE;IAC/D,2EAA2E;IAC3E,8EAA8E;IAC9E,8EAA8E;IAC9E,6DAA6D;IAC7D,oBAAoB,EAAE;QACpB,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,mEAAmE;KAC5E;IACD,aAAa,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,uCAAuC,EAAE;IAEpF,2EAA2E;IAC3E,aAAa,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE;CAC7D,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAY;IAEZ,OAAO,qBAAqB,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC","sourcesContent":["/**\n * Order-of-magnitude representative values for the discovery falsifier.\n *\n * The discovery loop (`discovery.ts`) vets a hypothesised identification a≡b,\n * but its numeric check (`retrodict`) runs from a single anchor and cannot\n * evaluate the quantities a dimensional coincidence \"unlocks\" — so it never\n * contradicts them, and they surface as `promising` (e.g.\n * `landauer-erasure-energy ≟ planck-mass-energy`, ~30 orders apart). The graph\n * structurally CANNOT supply the magnitudes that would falsify these.\n *\n * This table injects that missing ground truth: a sourced, order-of-magnitude\n * value for quantities that have a WELL-DEFINED physical scale. Two classes are\n * deliberately ABSENT:\n * - generic quantities (`mass`, `energy`, `length`, …) — no single scale (the\n * discovery gate now reads these from the graph at the anchor instead, see\n * `discovery.ts`); and\n * - speculative-physics quantities with no agreed scale (`dark-fermion-mass`,\n * `scalar-field-value`, `inflation-hubble-energy`, `boundary-length`, the\n * time-dependent `coarsening-length`) — a value would be fabrication, so the\n * gate correctly abstains on them.\n * When a value is absent the gate abstains; it never false-rejects on unknowns.\n *\n * Values are order-of-magnitude estimates (good to ~1 order), each carrying its\n * provenance. Nothing here is fabricated; coarse by design. When the canonical-\n * equation registry lands it can supply these centrally and this table folds in.\n *\n * INTERNAL — surfaced via `upt discover`.\n *\n * @module composition/representative-values\n */\n\n/** A sourced order-of-magnitude value for one quantity. @internal */\nexport interface RepresentativeValue {\n /** Order-of-magnitude value in the quantity's SI unit (good to ~1 order). */\n readonly value: number;\n /** Provenance — how the estimate is obtained (a citation or a one-liner). */\n readonly source: string;\n}\n\n/**\n * Scale-specific quantities only. Keyed by the canonical quantity name used in\n * the composition graph. Generic quantities are intentionally omitted.\n *\n * @internal\n */\nexport const REPRESENTATIVE_VALUES: Readonly<\n Record<string, RepresentativeValue>\n> = {\n // ── frequencies / rates [s^-1] ──────────────────────────────────────────\n 'hubble-rate': { value: 2.2e-18, source: 'H0 ≈ 67 km/s/Mpc (Planck 2018)' },\n 'grw-localization-rate': {\n value: 1e-16,\n source: 'GRW collapse rate λ ≈ 10^-16 s^-1 (Ghirardi–Rimini–Weber 1986)',\n },\n 'attempt-frequency': {\n value: 1e13,\n source: 'Debye/phonon attempt frequency ~10^13 Hz',\n },\n\n // ── energies [J] ────────────────────────────────────────────────────────\n 'landauer-erasure-energy': { value: 2.9e-21, source: 'kT·ln2 at T = 300 K' },\n 'planck-mass-energy': { value: 1.96e9, source: 'm_P·c² (m_P = √(ℏc/G))' },\n 'vacuum-expectation-value': {\n value: 3.94e-8,\n source: 'Higgs VEV v ≈ 246 GeV',\n },\n 'barrier-height': {\n value: 3.2e-20,\n source: 'BE-26 Löwdin DNA proton-transfer barrier V−E ~0.2 eV',\n },\n\n // ── masses [kg] ─────────────────────────────────────────────────────────\n 'planck-mass': { value: 2.176e-8, source: 'm_P = √(ℏc/G)' },\n 'tunneling-mass': {\n value: 1.673e-27,\n source: 'BE-26 tunneling particle is the proton, m_p = 1.673e-27 kg',\n },\n\n // ── lengths [m] ─────────────────────────────────────────────────────────\n 'foerster-radius': {\n value: 5e-9,\n source: 'typical FRET Förster radius ~5 nm',\n },\n 'donor-acceptor-distance': {\n value: 5e-9,\n source: 'BE-24 FRET donor–acceptor separation ~5 nm (same regime as R_0)',\n },\n 'barrier-width': {\n value: 1e-10,\n source: 'BE-26 DNA H-bond proton-tunneling distance ~1 Å (Löwdin 1963)',\n },\n 'planck-length': { value: 1.616e-35, source: 'ℓ_P = √(ℏG/c³)' },\n // Canonical-graph atomic length scales — sourced so the gate compares real\n // magnitudes instead of falling back to the {mass: M_sun} anchor, which makes\n // a 1/mass quantity like the Compton wavelength absurdly small (~10⁻⁷³ m) and\n // produces a spurious clash against the (fixed) Bohr radius.\n 'compton-wavelength': {\n value: 2.426e-12,\n source: 'electron Compton wavelength λ_C = h/(m_e c) = 2.43e-12 m (CODATA)',\n },\n 'bohr-radius': { value: 5.292e-11, source: 'Bohr radius a_0 = 5.29e-11 m (CODATA)' },\n\n // ── times [s] ───────────────────────────────────────────────────────────\n 'planck-time': { value: 5.39e-44, source: 't_P = √(ℏG/c⁵)' },\n};\n\n/**\n * The sourced order-of-magnitude value for `name`, or `undefined` when the\n * quantity has no well-defined representative scale (the gate then abstains).\n *\n * @internal\n */\nexport function representativeValue(\n name: string,\n): RepresentativeValue | undefined {\n return REPRESENTATIVE_VALUES[name];\n}\n"]}
1
+ {"version":3,"file":"representative-values.js","sourceRoot":"","sources":["../../src/composition/representative-values.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAiBH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,EAAuB;IACpD,MAAM,KAAK,GAAG,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E;QACzB,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,iEAAiE;KAC1E;IACD,eAAe,EAAE;QACf,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,+DAA+D;KACxE;IACD,eAAe,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE;IAC/D,2EAA2E;IAC3E,8EAA8E;IAC9E,8EAA8E;IAC9E,6DAA6D;IAC7D,oBAAoB,EAAE;QACpB,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,mEAAmE;KAC5E;IACD,aAAa,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,uCAAuC,EAAE;IAEpF,2EAA2E;IAC3E,aAAa,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE;CAC7D,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAY;IAEZ,OAAO,qBAAqB,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC","sourcesContent":["/**\n * Order-of-magnitude representative values for the discovery falsifier.\n *\n * The discovery loop (`discovery.ts`) vets a hypothesised identification a≡b,\n * but its numeric check (`retrodict`) runs from a single anchor and cannot\n * evaluate the quantities a dimensional coincidence \"unlocks\" — so it never\n * contradicts them, and they surface as `promising` (e.g.\n * `landauer-erasure-energy ≟ planck-mass-energy`, ~30 orders apart). The graph\n * structurally CANNOT supply the magnitudes that would falsify these.\n *\n * This table injects that missing ground truth: a sourced, order-of-magnitude\n * value for quantities that have a WELL-DEFINED physical scale. Two classes are\n * deliberately ABSENT:\n * - generic quantities (`mass`, `energy`, `length`, …) — no single scale (the\n * discovery gate now reads these from the graph at the anchor instead, see\n * `discovery.ts`); and\n * - speculative-physics quantities with no agreed scale (`dark-fermion-mass`,\n * `scalar-field-value`, `inflation-hubble-energy`, `boundary-length`, the\n * time-dependent `coarsening-length`) — a value would be fabrication, so the\n * gate correctly abstains on them.\n * When a value is absent the gate abstains; it never false-rejects on unknowns.\n *\n * Values are order-of-magnitude estimates (good to ~1 order), each carrying its\n * provenance. Nothing here is fabricated; coarse by design. When the canonical-\n * equation registry lands it can supply these centrally and this table folds in.\n *\n * INTERNAL — surfaced via `upt discover`.\n *\n * @module composition/representative-values\n */\n\n/** A sourced order-of-magnitude value for one quantity. @internal */\nexport interface RepresentativeValue {\n /** Order-of-magnitude value in the quantity's SI unit (good to ~1 order). */\n readonly value: number;\n /** Provenance — how the estimate is obtained (a citation or a one-liner). */\n readonly source: string;\n /**\n * The value's stated uncertainty, as a standard deviation in decades of `log10|value|`.\n * Absent means {@link DEFAULT_SIGMA_DECADES}, the table's \"good to about one order\"; a row\n * states another only with a source for it. The graded magnitude gate\n * (`discovery.ts`, `magnitudeP`) reads it; the verdict threshold does not.\n */\n readonly sigmaDecades?: number;\n}\n\n/**\n * The σ in decades a representative value carries when its row states none: one decade, the\n * precision this table has always claimed (\"good to ~1 order\"). Not a per-row measurement.\n *\n * @internal\n */\nexport const DEFAULT_SIGMA_DECADES = 1;\n\n/**\n * The σ in decades of a representative value: its own `sigmaDecades`, else the default. A stated\n * σ that is not a finite number > 0 is refused with a `RangeError` naming the row's source: σ = 0\n * would make the falsifier's strength 0 (certain) and a negative or NaN σ would make it NaN.\n *\n * @internal\n */\nexport function sigmaDecadesOf(rv: RepresentativeValue): number {\n const sigma = rv.sigmaDecades;\n if (sigma === undefined) return DEFAULT_SIGMA_DECADES;\n if (!(Number.isFinite(sigma) && sigma > 0)) {\n throw new RangeError(\n `representative value sigmaDecades ${String(sigma)} (source: ${rv.source}) must be a finite number > 0 decades`,\n );\n }\n return sigma;\n}\n\n/**\n * Scale-specific quantities only. Keyed by the canonical quantity name used in\n * the composition graph. Generic quantities are intentionally omitted.\n *\n * @internal\n */\nexport const REPRESENTATIVE_VALUES: Readonly<\n Record<string, RepresentativeValue>\n> = {\n // ── frequencies / rates [s^-1] ──────────────────────────────────────────\n 'hubble-rate': { value: 2.2e-18, source: 'H0 ≈ 67 km/s/Mpc (Planck 2018)' },\n 'grw-localization-rate': {\n value: 1e-16,\n source: 'GRW collapse rate λ ≈ 10^-16 s^-1 (Ghirardi–Rimini–Weber 1986)',\n },\n 'attempt-frequency': {\n value: 1e13,\n source: 'Debye/phonon attempt frequency ~10^13 Hz',\n },\n\n // ── energies [J] ────────────────────────────────────────────────────────\n 'landauer-erasure-energy': { value: 2.9e-21, source: 'kT·ln2 at T = 300 K' },\n 'planck-mass-energy': { value: 1.96e9, source: 'm_P·c² (m_P = √(ℏc/G))' },\n 'vacuum-expectation-value': {\n value: 3.94e-8,\n source: 'Higgs VEV v ≈ 246 GeV',\n },\n 'barrier-height': {\n value: 3.2e-20,\n source: 'BE-26 Löwdin DNA proton-transfer barrier V−E ~0.2 eV',\n },\n\n // ── masses [kg] ─────────────────────────────────────────────────────────\n 'planck-mass': { value: 2.176e-8, source: 'm_P = √(ℏc/G)' },\n 'tunneling-mass': {\n value: 1.673e-27,\n source: 'BE-26 tunneling particle is the proton, m_p = 1.673e-27 kg',\n },\n\n // ── lengths [m] ─────────────────────────────────────────────────────────\n 'foerster-radius': {\n value: 5e-9,\n source: 'typical FRET Förster radius ~5 nm',\n },\n 'donor-acceptor-distance': {\n value: 5e-9,\n source: 'BE-24 FRET donor–acceptor separation ~5 nm (same regime as R_0)',\n },\n 'barrier-width': {\n value: 1e-10,\n source: 'BE-26 DNA H-bond proton-tunneling distance ~1 Å (Löwdin 1963)',\n },\n 'planck-length': { value: 1.616e-35, source: 'ℓ_P = √(ℏG/c³)' },\n // Canonical-graph atomic length scales — sourced so the gate compares real\n // magnitudes instead of falling back to the {mass: M_sun} anchor, which makes\n // a 1/mass quantity like the Compton wavelength absurdly small (~10⁻⁷³ m) and\n // produces a spurious clash against the (fixed) Bohr radius.\n 'compton-wavelength': {\n value: 2.426e-12,\n source: 'electron Compton wavelength λ_C = h/(m_e c) = 2.43e-12 m (CODATA)',\n },\n 'bohr-radius': { value: 5.292e-11, source: 'Bohr radius a_0 = 5.29e-11 m (CODATA)' },\n\n // ── times [s] ───────────────────────────────────────────────────────────\n 'planck-time': { value: 5.39e-44, source: 't_P = √(ℏG/c⁵)' },\n};\n\n/**\n * The sourced order-of-magnitude value for `name`, or `undefined` when the\n * quantity has no well-defined representative scale (the gate then abstains).\n *\n * @internal\n */\nexport function representativeValue(\n name: string,\n): RepresentativeValue | undefined {\n return REPRESENTATIVE_VALUES[name];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"retrodiction.d.ts","sourceRoot":"","sources":["../../src/composition/retrodiction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAM5C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAqB3D,gDAAgD;AAChD,MAAM,MAAM,mBAAmB,GAC3B,YAAY,GACZ,cAAc,GACd,QAAQ,GACR,eAAe,CAAC;AAEpB,kEAAkE;AAClE,MAAM,WAAW,sBAAsB;IACrC,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,uCAAuC;AACvC,MAAM,WAAW,mBAAmB;IAClC,0EAA0E;IAC1E,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,sBAAsB,EAAE,CAAC;IAC7D,iEAAiE;IACjE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,mEAAmE;IACnE,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACvD,qEAAqE;IACrE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CACtC;AAED,4EAA4E;AAC5E,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;;O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AM,CAAC;IAC9B,yDAAyD;IACzD,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC;AAgBD;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,SAAS,UAAU,EAAE,EAC5B,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC7C,MAAM,EAAE,SAAS,sBAAsB,EAAE,GACxC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CA+CrB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,SAAS,UAAU,EAAE,EAC5B,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC7C,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,mBAAwB,GAC7B,kBAAkB,CAyEpB;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,SAAS,UAAU,EAAE,EAC5B,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC7C,IAAI,GAAE,mBAAwB,GAC7B,kBAAkB,CA2BpB"}
@@ -33,6 +33,7 @@ import { CoefficientUnsetError, evaluateEdge } from './edge.js';
33
33
  import { DomainViolationError } from '../bridges/evaluation-errors.js';
34
34
  import { CarrierSignError } from '../bridges/carrier-sign.js';
35
35
  import { FormulaError } from '../numerical/formula-contract.js';
36
+ import { meanOf } from '../numerical/statistics.js';
36
37
  import { QUANTITY_IDENTIFICATIONS } from './compose.js';
37
38
  import { conventionFactor } from '../dimensional/unit-convention.js';
38
39
  import { classifyAll } from './identifiability.js';
@@ -201,7 +202,7 @@ export function retrodictNode(edges, groundTruth, target, opts = {}) {
201
202
  };
202
203
  const ref = opts.references?.[target];
203
204
  if (ref !== undefined && predictions.length >= 1) {
204
- const mean = predictions.reduce((a, p) => a + p.value, 0) / predictions.length;
205
+ const mean = meanOf(predictions.map((p) => p.value));
205
206
  const referenceRelError = Math.abs(mean - ref) / (Math.abs(ref) || 1);
206
207
  return {
207
208
  ...result,
@@ -1 +1 @@
1
- {"version":3,"file":"retrodiction.js","sourceRoot":"","sources":["../../src/composition/retrodiction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,IAAgB,EAAE,MAAmC;IAC7E,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO;QAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAE,CAAC;IACnE,MAAM,KAAK,GAAG,0BAA0B,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC;IACvE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,SAAS;YAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CA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KAAK,EAAE,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC,CAAC;IAE1E,MAAM,cAAc,GAAG,UAAU;SAC9B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,iBAAiB,CAAC;SAC9C,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACxB,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACvE,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,cAAc,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAExE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAChC,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC,EAAE,IAAI,CAAC,CAC3C,CAAC;IAEF,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,YAAY,CAAC,CAAC,MAAM,CAAC;IAC5E,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CACjC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,cAAc,CACpC,CAAC,MAAM,CAAC;IAET,OAAO;QACL,OAAO;QACP,OAAO,EAAE,UAAU,GAAG,YAAY;QAClC,UAAU;QACV,YAAY;QACZ,aAAa,EAAE,YAAY,KAAK,CAAC;KAClC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Retrodiction harness (Consequence 2 of\n * docs/planning/Bridge-Inference-Epistemics-Note.md, designed in\n * docs/planning/Retrodiction-Harness-Design-Note.md).\n *\n * The framework's own falsification benchmark. Mask a quantity the graph\n * can compute, recompute it from ground-truth inputs via EACH independent\n * derivation, and check the predictions agree. This operationalizes the\n * identifiability classifier's OVER-DETERMINED verdict: the surplus\n * derivations of an over-determined node are PREDICTED to be consistency\n * constraints; the harness evaluates them and checks that numerically.\n *\n * - consistent — ≥2 derivations agree within tolerance.\n * - inconsistent — ≥2 derivations DISAGREE (a falsification: two\n * encodings of one quantity-name are not the same\n * physics).\n * - single — exactly one derivation fired (recovered, no check).\n * - unrecoverable — no derivation fired from the ground truth.\n *\n * \"Mask\" = compute source values over the graph with every edge INTO the\n * target removed (the classifier's target-removed closure — so the node\n * is genuinely hidden, never read back through its own derivation).\n * Forward evaluation honors `QUANTITY_IDENTIFICATIONS` and is\n * domain-checked (an edge that refuses its domain contributes no\n * prediction). The consistency check needs no external truth and is the\n * re-runnable core; an optional `references` map adds external-value\n * scoring. Pass bar pre-registered in the design note (spread ≤ 1e-6).\n *\n * @module composition/retrodiction\n */\n\nimport type { BridgeEdge } from './edge.js';\nimport { CANONICAL_GROUP_PREFACTORS } from './canonical-prefactors.js';\nimport { CoefficientUnsetError, evaluateEdge } from './edge.js';\nimport { DomainViolationError } from '../bridges/evaluation-errors.js';\nimport { CarrierSignError } from '../bridges/carrier-sign.js';\nimport { FormulaError } from '../numerical/formula-contract.js';\nimport type { QuantityIdentification } from './compose.js';\nimport { QUANTITY_IDENTIFICATIONS } from './compose.js';\nimport { conventionFactor } from '../dimensional/unit-convention.js';\nimport { classifyAll } from './identifiability.js';\n\n/**\n * Source values, plus a dimensionless group the edge multiplies when the\n * ground truth names it. The group is not a source: Buckingham cannot see\n * it, and a missing group is the unset coefficient, not a missing input.\n */\nfunction evaluationInputs(edge: BridgeEdge, values: ReadonlyMap<string, number>): Record<string, number> {\n const inputs: Record<string, number> = {};\n for (const s of edge.sources) inputs[s.name] = values.get(s.name)!;\n const group = CANONICAL_GROUP_PREFACTORS.find((g) => g.id === edge.id);\n if (group !== undefined) {\n const g = values.get(group.group);\n if (g !== undefined) inputs[group.group] = g;\n }\n return inputs;\n}\n\n/** Outcome of retrodicting one node. @public */\nexport type RetrodictionOutcome =\n | 'consistent'\n | 'inconsistent'\n | 'single'\n | 'unrecoverable';\n\n/** One derivation's recovered value for a masked node. @public */\nexport interface RetrodictionPrediction {\n /** The edge id that produced this value. */\n readonly edge: string;\n readonly value: number;\n}\n\n/** Options for the harness. @public */\nexport interface RetrodictionOptions {\n /** Identifications honored in forward evaluation (default registered). */\n readonly identifications?: readonly QuantityIdentification[];\n /** Relative-spread tolerance for `consistent` (default 1e-6). */\n readonly tolerance?: number;\n /** External (textbook) values to score recovered nodes against. */\n readonly references?: Readonly<Record<string, number>>;\n /** Relative-error tolerance for reference scoring (default 1e-3). */\n readonly referenceTolerance?: number;\n}\n\n/** One refused edge in a retrodiction, with the kind of refusal. @public */\nexport interface RetrodictionRefusal {\n readonly edge: string;\n /**\n * `domain`: the validity domain rejected the point. `coefficient-unset`: the edge has no\n * sourced prefactor, whatever the values. `carrier-sign`: the carrier charge and the\n * mobility had opposite signs. `formula`: the relation's formula did not evaluate at the\n * point (a 0/0, say). Four facts, kept apart (AGENTS law 4).\n */\n readonly kind: 'domain' | 'coefficient-unset' | 'carrier-sign' | 'formula';\n readonly reason: string;\n}\n\n/** The result of retrodicting one node. @public */\nexport interface RetrodictionResult {\n readonly target: string;\n readonly outcome: RetrodictionOutcome;\n /** Recovered values, one per derivation that fired. */\n readonly predictions: readonly RetrodictionPrediction[];\n /** (max − min)/|mean| across predictions; 0 when fewer than two. */\n readonly relativeSpread: number;\n readonly tolerance: number;\n /**\n * Edges that refused the supplied values. `kind` keeps the refusals apart (AGENTS law 4):\n * `domain`, `carrier-sign` and `formula` are the point (the edge does not fire there);\n * `coefficient-unset` is the edge's own state (no sourced prefactor), whatever the values.\n */\n readonly refusals?: readonly RetrodictionRefusal[];\n /** `outcome !== 'inconsistent'` — the falsification gate. */\n readonly pass: boolean;\n /** Supplied external value, when scored. */\n readonly referenceValue?: number;\n /** |mean(predictions) − reference| / |reference|, when scored. */\n readonly referenceRelError?: number;\n readonly referencePass?: boolean;\n}\n\n/** Aggregate report across the swept nodes. @public */\nexport interface RetrodictionReport {\n readonly results: readonly RetrodictionResult[];\n /** Nodes with ≥2 derivations (consistent + inconsistent). */\n readonly checked: number;\n readonly consistent: number;\n readonly inconsistent: number;\n /** The headline gate: no inconsistent node was found. */\n readonly allConsistent: boolean;\n}\n\n/** The refusal an evaluator error is, or `undefined` when it is not a refusal at all. */\nfunction refusalKind(err: unknown): RetrodictionRefusal['kind'] | undefined {\n if (err instanceof DomainViolationError) return 'domain';\n if (err instanceof CoefficientUnsetError) return 'coefficient-unset';\n if (err instanceof CarrierSignError) return 'carrier-sign';\n if (err instanceof FormulaError) return 'formula';\n return undefined;\n}\n\n/** True when the error says the edge does not fire here (or at all, for an unset coefficient). */\nfunction refusesThePoint(err: unknown): boolean {\n return refusalKind(err) !== undefined;\n}\n\n/**\n * Monotone forward EVALUATION: propagate values from `groundTruth` through\n * the graph (domain-checked; identifications supply identified names;\n * non-finite or domain-refused edges do not fire). Each node is assigned\n * the value of the first edge that fires for it.\n *\n * Exported `@internal` so the discovery magnitude-gate can read a quantity's\n * value AT THE REGISTERED ANCHOR when the static representative-value table\n * has no entry for it (graph-derived quantities like `schwarzschild-radius`).\n *\n * @internal\n */\nexport function forwardEvaluate(\n edges: readonly BridgeEdge[],\n groundTruth: Readonly<Record<string, number>>,\n idents: readonly QuantityIdentification[],\n): Map<string, number> {\n // Finite-seed guard (matches the computed-value guard below and the\n // library-wide finiteness discipline): a NaN/∞ seed would propagate silently\n // through the graph and spoof downstream magnitude/consistency checks.\n for (const [name, v] of Object.entries(groundTruth)) {\n if (!Number.isFinite(v)) {\n throw new TypeError(\n `forwardEvaluate: ground-truth seed '${name}' must be a finite number, got ${v}.`,\n );\n }\n }\n const values = new Map<string, number>(Object.entries(groundTruth));\n let changed = true;\n while (changed) {\n changed = false;\n for (const id of idents) {\n const fromVal = values.get(id.from);\n if (fromVal !== undefined && !values.has(id.to)) {\n const converted = fromVal * conventionFactor(id.from, id.to);\n if (Number.isFinite(converted)) {\n values.set(id.to, converted);\n changed = true;\n }\n }\n }\n for (const e of edges) {\n if (values.has(e.target.name)) continue;\n if (!e.sources.every((s) => values.has(s.name))) continue;\n const inputs = evaluationInputs(e, values);\n let v: number;\n try {\n v = evaluateEdge(e, inputs);\n } catch (err) {\n // The edge refusing this point (a domain miss, opposite carrier signs, a formula\n // that has no finite value there) or an unset coefficient is \"the edge does not\n // fire\". Anything else (an alias conflict, a TypeError in an evaluator) is a\n // different fact and is not hidden as a non-derivation (9.0.0 audit §4 C6).\n if (!refusesThePoint(err)) throw err;\n continue;\n }\n if (Number.isFinite(v)) {\n values.set(e.target.name, v);\n changed = true;\n }\n }\n }\n return values;\n}\n\n/**\n * Retrodict one node: mask it (source values from the target-removed\n * graph), recover it via each incoming edge, and score the spread.\n *\n * @public\n */\nexport function retrodictNode(\n edges: readonly BridgeEdge[],\n groundTruth: Readonly<Record<string, number>>,\n target: string,\n opts: RetrodictionOptions = {},\n): RetrodictionResult {\n const idents = opts.identifications ?? QUANTITY_IDENTIFICATIONS;\n const tolerance = opts.tolerance ?? 1e-6;\n\n // Masked source values: never let the target be assigned (so no\n // derivation reads it back — circular self-support excluded).\n const edgesMinusIntoTarget = edges.filter((e) => e.target.name !== target);\n const values = forwardEvaluate(edgesMinusIntoTarget, groundTruth, idents);\n\n const predictions: RetrodictionPrediction[] = [];\n const refusals: RetrodictionRefusal[] = [];\n for (const e of edges) {\n if (e.target.name !== target) continue;\n if (!e.sources.every((s) => values.has(s.name))) continue;\n const inputs = evaluationInputs(e, values);\n let v: number;\n try {\n v = evaluateEdge(e, inputs);\n } catch (err) {\n // A refusal of the point or an unset coefficient is a recorded refusal of\n // this edge, under its own kind. Any other error (an alias conflict, a\n // TypeError in an evaluator) is a different fact and propagates instead of\n // reading as \"unrecoverable\" (§4 C6).\n const kind = refusalKind(err);\n if (kind === undefined) throw err;\n refusals.push({ edge: e.id, kind, reason: (err as Error).message });\n continue;\n }\n if (Number.isFinite(v)) predictions.push({ edge: e.id, value: v });\n }\n\n let relativeSpread = 0;\n if (predictions.length >= 2) {\n const vals = predictions.map((p) => p.value);\n const max = Math.max(...vals);\n const min = Math.min(...vals);\n // Normalize the (max − min) span by the largest MAGNITUDE, not the mean:\n // opposite-sign predictions (e.g. +6 and −6) cancel in the mean → a ~0\n // denominator → spurious Infinity, even though the true relative spread is\n // finite (12/6 = 2). `maxAbs === 0` only when every value is 0 (max = min),\n // so the span is 0 too.\n const maxAbs = Math.max(...vals.map(Math.abs));\n relativeSpread = maxAbs > 0 ? (max - min) / maxAbs : 0;\n }\n\n let outcome: RetrodictionOutcome;\n if (predictions.length === 0) outcome = 'unrecoverable';\n else if (predictions.length === 1) outcome = 'single';\n else outcome = relativeSpread <= tolerance ? 'consistent' : 'inconsistent';\n\n const result: RetrodictionResult = {\n target,\n outcome,\n predictions,\n relativeSpread,\n tolerance,\n ...(refusals.length > 0 ? { refusals } : {}),\n pass: outcome !== 'inconsistent',\n };\n\n const ref = opts.references?.[target];\n if (ref !== undefined && predictions.length >= 1) {\n const mean =\n predictions.reduce((a, p) => a + p.value, 0) / predictions.length;\n const referenceRelError = Math.abs(mean - ref) / (Math.abs(ref) || 1);\n return {\n ...result,\n referenceValue: ref,\n referenceRelError,\n referencePass: referenceRelError <= (opts.referenceTolerance ?? 1e-3),\n };\n }\n\n return result;\n}\n\n/**\n * Sweep the graph: retrodict every over-determined node (the classifier\n * is the feeder), plus any node with a supplied reference value. Returns\n * the per-node results and the headline `allConsistent` gate.\n *\n * @public\n */\nexport function retrodict(\n edges: readonly BridgeEdge[],\n groundTruth: Readonly<Record<string, number>>,\n opts: RetrodictionOptions = {},\n): RetrodictionReport {\n const idents = opts.identifications ?? QUANTITY_IDENTIFICATIONS;\n const known = Object.keys(groundTruth);\n const classified = classifyAll(edges, known, { identifications: idents });\n\n const overDetermined = classified\n .filter((r) => r.verdict === 'over-determined')\n .map((r) => r.target);\n const refTargets = opts.references ? Object.keys(opts.references) : [];\n const targets = [...new Set([...overDetermined, ...refTargets])].sort();\n\n const results = targets.map((t) =>\n retrodictNode(edges, groundTruth, t, opts),\n );\n\n const consistent = results.filter((r) => r.outcome === 'consistent').length;\n const inconsistent = results.filter(\n (r) => r.outcome === 'inconsistent',\n ).length;\n\n return {\n results,\n checked: consistent + inconsistent,\n consistent,\n inconsistent,\n allConsistent: inconsistent === 0,\n };\n}\n"]}
1
+ {"version":3,"file":"retrodiction.js","sourceRoot":"","sources":["../../src/composition/retrodiction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,IAAgB,EAAE,MAAmC;IAC7E,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO;QAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAE,CAAC;IACnE,MAAM,KAAK,GAAG,0BAA0B,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAA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AAY,KAAK,CAAC;KAClC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Retrodiction harness (Consequence 2 of\n * docs/planning/Bridge-Inference-Epistemics-Note.md, designed in\n * docs/planning/Retrodiction-Harness-Design-Note.md).\n *\n * The framework's own falsification benchmark. Mask a quantity the graph\n * can compute, recompute it from ground-truth inputs via EACH independent\n * derivation, and check the predictions agree. This operationalizes the\n * identifiability classifier's OVER-DETERMINED verdict: the surplus\n * derivations of an over-determined node are PREDICTED to be consistency\n * constraints; the harness evaluates them and checks that numerically.\n *\n * - consistent — ≥2 derivations agree within tolerance.\n * - inconsistent — ≥2 derivations DISAGREE (a falsification: two\n * encodings of one quantity-name are not the same\n * physics).\n * - single — exactly one derivation fired (recovered, no check).\n * - unrecoverable — no derivation fired from the ground truth.\n *\n * \"Mask\" = compute source values over the graph with every edge INTO the\n * target removed (the classifier's target-removed closure — so the node\n * is genuinely hidden, never read back through its own derivation).\n * Forward evaluation honors `QUANTITY_IDENTIFICATIONS` and is\n * domain-checked (an edge that refuses its domain contributes no\n * prediction). The consistency check needs no external truth and is the\n * re-runnable core; an optional `references` map adds external-value\n * scoring. Pass bar pre-registered in the design note (spread ≤ 1e-6).\n *\n * @module composition/retrodiction\n */\n\nimport type { BridgeEdge } from './edge.js';\nimport { CANONICAL_GROUP_PREFACTORS } from './canonical-prefactors.js';\nimport { CoefficientUnsetError, evaluateEdge } from './edge.js';\nimport { DomainViolationError } from '../bridges/evaluation-errors.js';\nimport { CarrierSignError } from '../bridges/carrier-sign.js';\nimport { FormulaError } from '../numerical/formula-contract.js';\nimport { meanOf } from '../numerical/statistics.js';\nimport type { QuantityIdentification } from './compose.js';\nimport { QUANTITY_IDENTIFICATIONS } from './compose.js';\nimport { conventionFactor } from '../dimensional/unit-convention.js';\nimport { classifyAll } from './identifiability.js';\n\n/**\n * Source values, plus a dimensionless group the edge multiplies when the\n * ground truth names it. The group is not a source: Buckingham cannot see\n * it, and a missing group is the unset coefficient, not a missing input.\n */\nfunction evaluationInputs(edge: BridgeEdge, values: ReadonlyMap<string, number>): Record<string, number> {\n const inputs: Record<string, number> = {};\n for (const s of edge.sources) inputs[s.name] = values.get(s.name)!;\n const group = CANONICAL_GROUP_PREFACTORS.find((g) => g.id === edge.id);\n if (group !== undefined) {\n const g = values.get(group.group);\n if (g !== undefined) inputs[group.group] = g;\n }\n return inputs;\n}\n\n/** Outcome of retrodicting one node. @public */\nexport type RetrodictionOutcome =\n | 'consistent'\n | 'inconsistent'\n | 'single'\n | 'unrecoverable';\n\n/** One derivation's recovered value for a masked node. @public */\nexport interface RetrodictionPrediction {\n /** The edge id that produced this value. */\n readonly edge: string;\n readonly value: number;\n}\n\n/** Options for the harness. @public */\nexport interface RetrodictionOptions {\n /** Identifications honored in forward evaluation (default registered). */\n readonly identifications?: readonly QuantityIdentification[];\n /** Relative-spread tolerance for `consistent` (default 1e-6). */\n readonly tolerance?: number;\n /** External (textbook) values to score recovered nodes against. */\n readonly references?: Readonly<Record<string, number>>;\n /** Relative-error tolerance for reference scoring (default 1e-3). */\n readonly referenceTolerance?: number;\n}\n\n/** One refused edge in a retrodiction, with the kind of refusal. @public */\nexport interface RetrodictionRefusal {\n readonly edge: string;\n /**\n * `domain`: the validity domain rejected the point. `coefficient-unset`: the edge has no\n * sourced prefactor, whatever the values. `carrier-sign`: the carrier charge and the\n * mobility had opposite signs. `formula`: the relation's formula did not evaluate at the\n * point (a 0/0, say). Four facts, kept apart (AGENTS law 4).\n */\n readonly kind: 'domain' | 'coefficient-unset' | 'carrier-sign' | 'formula';\n readonly reason: string;\n}\n\n/** The result of retrodicting one node. @public */\nexport interface RetrodictionResult {\n readonly target: string;\n readonly outcome: RetrodictionOutcome;\n /** Recovered values, one per derivation that fired. */\n readonly predictions: readonly RetrodictionPrediction[];\n /** (max − min)/|mean| across predictions; 0 when fewer than two. */\n readonly relativeSpread: number;\n readonly tolerance: number;\n /**\n * Edges that refused the supplied values. `kind` keeps the refusals apart (AGENTS law 4):\n * `domain`, `carrier-sign` and `formula` are the point (the edge does not fire there);\n * `coefficient-unset` is the edge's own state (no sourced prefactor), whatever the values.\n */\n readonly refusals?: readonly RetrodictionRefusal[];\n /** `outcome !== 'inconsistent'` — the falsification gate. */\n readonly pass: boolean;\n /** Supplied external value, when scored. */\n readonly referenceValue?: number;\n /** |mean(predictions) − reference| / |reference|, when scored. */\n readonly referenceRelError?: number;\n readonly referencePass?: boolean;\n}\n\n/** Aggregate report across the swept nodes. @public */\nexport interface RetrodictionReport {\n readonly results: readonly RetrodictionResult[];\n /** Nodes with ≥2 derivations (consistent + inconsistent). */\n readonly checked: number;\n readonly consistent: number;\n readonly inconsistent: number;\n /** The headline gate: no inconsistent node was found. */\n readonly allConsistent: boolean;\n}\n\n/** The refusal an evaluator error is, or `undefined` when it is not a refusal at all. */\nfunction refusalKind(err: unknown): RetrodictionRefusal['kind'] | undefined {\n if (err instanceof DomainViolationError) return 'domain';\n if (err instanceof CoefficientUnsetError) return 'coefficient-unset';\n if (err instanceof CarrierSignError) return 'carrier-sign';\n if (err instanceof FormulaError) return 'formula';\n return undefined;\n}\n\n/** True when the error says the edge does not fire here (or at all, for an unset coefficient). */\nfunction refusesThePoint(err: unknown): boolean {\n return refusalKind(err) !== undefined;\n}\n\n/**\n * Monotone forward EVALUATION: propagate values from `groundTruth` through\n * the graph (domain-checked; identifications supply identified names;\n * non-finite or domain-refused edges do not fire). Each node is assigned\n * the value of the first edge that fires for it.\n *\n * Exported `@internal` so the discovery magnitude-gate can read a quantity's\n * value AT THE REGISTERED ANCHOR when the static representative-value table\n * has no entry for it (graph-derived quantities like `schwarzschild-radius`).\n *\n * @internal\n */\nexport function forwardEvaluate(\n edges: readonly BridgeEdge[],\n groundTruth: Readonly<Record<string, number>>,\n idents: readonly QuantityIdentification[],\n): Map<string, number> {\n // Finite-seed guard (matches the computed-value guard below and the\n // library-wide finiteness discipline): a NaN/∞ seed would propagate silently\n // through the graph and spoof downstream magnitude/consistency checks.\n for (const [name, v] of Object.entries(groundTruth)) {\n if (!Number.isFinite(v)) {\n throw new TypeError(\n `forwardEvaluate: ground-truth seed '${name}' must be a finite number, got ${v}.`,\n );\n }\n }\n const values = new Map<string, number>(Object.entries(groundTruth));\n let changed = true;\n while (changed) {\n changed = false;\n for (const id of idents) {\n const fromVal = values.get(id.from);\n if (fromVal !== undefined && !values.has(id.to)) {\n const converted = fromVal * conventionFactor(id.from, id.to);\n if (Number.isFinite(converted)) {\n values.set(id.to, converted);\n changed = true;\n }\n }\n }\n for (const e of edges) {\n if (values.has(e.target.name)) continue;\n if (!e.sources.every((s) => values.has(s.name))) continue;\n const inputs = evaluationInputs(e, values);\n let v: number;\n try {\n v = evaluateEdge(e, inputs);\n } catch (err) {\n // The edge refusing this point (a domain miss, opposite carrier signs, a formula\n // that has no finite value there) or an unset coefficient is \"the edge does not\n // fire\". Anything else (an alias conflict, a TypeError in an evaluator) is a\n // different fact and is not hidden as a non-derivation (9.0.0 audit §4 C6).\n if (!refusesThePoint(err)) throw err;\n continue;\n }\n if (Number.isFinite(v)) {\n values.set(e.target.name, v);\n changed = true;\n }\n }\n }\n return values;\n}\n\n/**\n * Retrodict one node: mask it (source values from the target-removed\n * graph), recover it via each incoming edge, and score the spread.\n *\n * @public\n */\nexport function retrodictNode(\n edges: readonly BridgeEdge[],\n groundTruth: Readonly<Record<string, number>>,\n target: string,\n opts: RetrodictionOptions = {},\n): RetrodictionResult {\n const idents = opts.identifications ?? QUANTITY_IDENTIFICATIONS;\n const tolerance = opts.tolerance ?? 1e-6;\n\n // Masked source values: never let the target be assigned (so no\n // derivation reads it back — circular self-support excluded).\n const edgesMinusIntoTarget = edges.filter((e) => e.target.name !== target);\n const values = forwardEvaluate(edgesMinusIntoTarget, groundTruth, idents);\n\n const predictions: RetrodictionPrediction[] = [];\n const refusals: RetrodictionRefusal[] = [];\n for (const e of edges) {\n if (e.target.name !== target) continue;\n if (!e.sources.every((s) => values.has(s.name))) continue;\n const inputs = evaluationInputs(e, values);\n let v: number;\n try {\n v = evaluateEdge(e, inputs);\n } catch (err) {\n // A refusal of the point or an unset coefficient is a recorded refusal of\n // this edge, under its own kind. Any other error (an alias conflict, a\n // TypeError in an evaluator) is a different fact and propagates instead of\n // reading as \"unrecoverable\" (§4 C6).\n const kind = refusalKind(err);\n if (kind === undefined) throw err;\n refusals.push({ edge: e.id, kind, reason: (err as Error).message });\n continue;\n }\n if (Number.isFinite(v)) predictions.push({ edge: e.id, value: v });\n }\n\n let relativeSpread = 0;\n if (predictions.length >= 2) {\n const vals = predictions.map((p) => p.value);\n const max = Math.max(...vals);\n const min = Math.min(...vals);\n // Normalize the (max − min) span by the largest MAGNITUDE, not the mean:\n // opposite-sign predictions (e.g. +6 and −6) cancel in the mean → a ~0\n // denominator → spurious Infinity, even though the true relative spread is\n // finite (12/6 = 2). `maxAbs === 0` only when every value is 0 (max = min),\n // so the span is 0 too.\n const maxAbs = Math.max(...vals.map(Math.abs));\n relativeSpread = maxAbs > 0 ? (max - min) / maxAbs : 0;\n }\n\n let outcome: RetrodictionOutcome;\n if (predictions.length === 0) outcome = 'unrecoverable';\n else if (predictions.length === 1) outcome = 'single';\n else outcome = relativeSpread <= tolerance ? 'consistent' : 'inconsistent';\n\n const result: RetrodictionResult = {\n target,\n outcome,\n predictions,\n relativeSpread,\n tolerance,\n ...(refusals.length > 0 ? { refusals } : {}),\n pass: outcome !== 'inconsistent',\n };\n\n const ref = opts.references?.[target];\n if (ref !== undefined && predictions.length >= 1) {\n const mean = meanOf(predictions.map((p) => p.value));\n const referenceRelError = Math.abs(mean - ref) / (Math.abs(ref) || 1);\n return {\n ...result,\n referenceValue: ref,\n referenceRelError,\n referencePass: referenceRelError <= (opts.referenceTolerance ?? 1e-3),\n };\n }\n\n return result;\n}\n\n/**\n * Sweep the graph: retrodict every over-determined node (the classifier\n * is the feeder), plus any node with a supplied reference value. Returns\n * the per-node results and the headline `allConsistent` gate.\n *\n * @public\n */\nexport function retrodict(\n edges: readonly BridgeEdge[],\n groundTruth: Readonly<Record<string, number>>,\n opts: RetrodictionOptions = {},\n): RetrodictionReport {\n const idents = opts.identifications ?? QUANTITY_IDENTIFICATIONS;\n const known = Object.keys(groundTruth);\n const classified = classifyAll(edges, known, { identifications: idents });\n\n const overDetermined = classified\n .filter((r) => r.verdict === 'over-determined')\n .map((r) => r.target);\n const refTargets = opts.references ? Object.keys(opts.references) : [];\n const targets = [...new Set([...overDetermined, ...refTargets])].sort();\n\n const results = targets.map((t) =>\n retrodictNode(edges, groundTruth, t, opts),\n );\n\n const consistent = results.filter((r) => r.outcome === 'consistent').length;\n const inconsistent = results.filter(\n (r) => r.outcome === 'inconsistent',\n ).length;\n\n return {\n results,\n checked: consistent + inconsistent,\n consistent,\n inconsistent,\n allConsistent: inconsistent === 0,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"user-equation.d.ts","sourceRoot":"","sources":["../../src/composition/user-equation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAOH,OAAO,EAA8B,KAAK,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAI5F,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAKzD,oFAAoF;AACpF,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,iEAAiE;IACjE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAiBD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,oFAAoF;AACpF,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAKjC;;;;;;;;;;;GAWG;AACH,wBAAg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,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,EAC3C,OAAO,CAAC,EAAE,0BAA0B,GACnC,OAAO,CAAC,gBAAgB,CAAC,CAgI3B"}
@@ -21,7 +21,7 @@
21
21
  import { getFormulaParser, parsePhysics } from '../numerical/formula-registry.js';
22
22
  import { formulaSymbolDimension } from '../numerical/formula-dimension.js';
23
23
  import { CONSTANT_SPELLINGS } from '../dimensional/dimension-spec.js';
24
- import { CONSTANTS } from '../dimensional/symbolic-constants.js';
24
+ import { CONSTANTS, isRegisteredConstant } from '../dimensional/symbolic-constants.js';
25
25
  import { formulaNameDimensions } from '../dimensional/formula-names.js';
26
26
  import { naturalNote, naturalPowers } from '../dimensional/natural-units.js';
27
27
  import { aliasesForTarget, editDistance } from './aliases.js';
@@ -131,7 +131,7 @@ export async function parseUserEquation(equation, catalogNames) {
131
131
  // No parse tree, so no subtraction was read: the hyphen hint needs the parsed variables.
132
132
  throw new UserEquationError(`could not parse the right-hand side '${rhs}': ${e.message}`);
133
133
  }
134
- const sources = variables.filter((v) => !Object.prototype.hasOwnProperty.call(CONSTANTS, v));
134
+ const sources = variables.filter((v) => !isRegisteredConstant(v));
135
135
  // An all-constant right-hand side (the Planck length) is an equation about a catalog quantity
136
136
  // only when its target is one; otherwise it names nothing to check (persona finding W5).
137
137
  const targetIsCatalog = names !== undefined && resolveQuantityName(target, names) !== null;
@@ -1 +1 @@
1
- {"version":3,"file":"user-equation.js","sourceRoot":"","sources":["../../src/composition/user-equation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAA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;QACV,YAAY;QACZ,eAAe;QACf,UAAU;QACV,KAAK;QACL,aAAa,EAAE,CAAC,GAAG,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,cAAc,CAAC;QAC9D,YAAY;QACZ,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;KAC3D,CAAC;AACJ,CAAC","sourcesContent":["/**\n * User-equation injection — turn a free-form `TARGET = EXPR` string into a graph\n * junction (a target quantity + its source quantities), resolve the user's\n * symbols onto the catalog vocabulary, suggest near-misses, and report where the\n * injected junction lands in a built {@link VizModel}.\n *\n * Free-form means no dimensions: source quantities are the RHS's free variables\n * — extracted by the MathTS expression parser via {@link getFormulaParser},\n * which already drops constants like `pi`/`tau`, numbers, and functions —\n * minus the physics {@link CONSTANTS}. Multi-word quantities may be typed with\n * underscores **or** the catalog's own hyphens (`planck-length`): before parse,\n * {@link rewriteCatalogHyphens} rewrites kebab catalog names to underscores so\n * `-` is not read as subtraction (persona finding W2). Resolution still tries\n * the literal form first, then the `_`↔`-` swap.\n *\n * Pure: no file I/O. The injected junction is rendered as an `extraJunction`\n * (status `'user'`) and is never written into the catalog.\n *\n * @module composition/user-equation\n */\n\nimport { getFormulaParser, parsePhysics } from '../numerical/formula-registry.js';\nimport { formulaSymbolDimension } from '../numerical/formula-dimension.js';\nimport { CONSTANT_SPELLINGS } from '../dimensional/dimension-spec.js';\nimport { CONSTANTS } from '../dimensional/symbolic-constants.js';\nimport { formulaNameDimensions } from '../dimensional/formula-names.js';\nimport { naturalNote, naturalPowers, type UnitMode } from '../dimensional/natural-units.js';\nimport { aliasesForTarget, editDistance } from './aliases.js';\nimport { resolveQuantityName } from '../dimensional/formula-names.js';\nimport { CATALOG_GRAPH } from './catalog-graph.js';\nimport type { VizModel, VizJunction } from './graph-viz.js';\nimport type { Dimension } from '../dimensional/types.js';\nimport { DIMENSIONLESS } from '../dimensional/types.js';\nimport { equals } from '../dimensional/algebra.js';\nimport { inferUnknownDimension } from '../dimensional/dimension-inference.js';\n\n/** Thrown when a user equation cannot be parsed into a target + sources. @public */\nexport class UserEquationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'UserEquationError';\n }\n}\n\n/**\n * A parsed user equation: the target quantity and its source quantities, as\n * written (underscores preserved; constants/numbers/functions removed).\n *\n * @public\n */\nexport interface UserEquation {\n readonly target: string;\n readonly sources: readonly string[];\n /** The original `TARGET = EXPR` text, for the junction label. */\n readonly text: string;\n}\n\n/**\n * Parse `TARGET = EXPR` into `{ target, sources }`. The target is the text left\n * of the first `=`; the sources are the RHS's free variables minus the physics\n * constants.\n *\n * Uses the active formula parser (MathTS when installed, built-in otherwise) to\n * extract the RHS's free variables.\n *\n * @throws {UserEquationError} on a missing `=`, an empty target, an unparseable\n * RHS, or an RHS with no source quantities.\n * @public\n */\n/** Upper bound on user `--equation` text to keep hint computation bounded. */\nconst MAX_USER_EQUATION_LEN = 8192;\n\nimport { rewriteCatalogHyphens } from '../dimensional/hyphen-names.js';\n/** Rewrite a catalog hyphenated name to underscores before the expression parse. */\nexport { rewriteCatalogHyphens };\n\n/** A hyphen-joined run of names, `a-b` or `a-b-c`, not the exponent of `1e-5`. */\nconst HYPHEN_RUN = /(?<![A-Za-z0-9_.])[A-Za-z_][A-Za-z0-9_]*(?:-[A-Za-z0-9_]+)+/g;\n\n/**\n * When the parse read a hyphen-joined run (`thermal-mass`) as a subtraction of\n * its pieces, and the run read as one name is a catalog quantity, tell the user\n * `-` is arithmetic here and to use underscores. Persona finding I2.\n *\n * Decided from the parse, not from an error's text: `variables` are the free\n * variables the formula parser read from `rhs`. The parser has no hyphenated\n * identifier, so a run whose underscored name is not a variable and whose\n * pieces are was parsed as a subtraction.\n *\n * @internal\n */\nexport function hyphenSubtractHint(\n rhs: string,\n variables: readonly string[],\n catalogNames: ReadonlySet<string>,\n): string | null {\n const read = new Set(variables);\n const split = (rhs.match(HYPHEN_RUN) ?? []).filter(\n (run) =>\n !read.has(run.replace(/-/g, '_')) &&\n run.split('-').some((piece) => read.has(piece)) &&\n resolveQuantityName(run, catalogNames) !== null,\n );\n if (split.length === 0) return null;\n const example = split.sort((a, b) => b.length - a.length)[0]!;\n return (\n `'-' is arithmetic here; multi-word catalog names use underscores ` +\n `(${example} → ${example.replace(/-/g, '_')})`\n );\n}\n\n/**\n * Spellings that must not be a bare `e`. Constant aliases come from\n * {@link CONSTANT_SPELLINGS}. `1-eccentricity^2` is the perihelion factor\n * `one_minus_e_sq`.\n */\nfunction rewriteFormulaSpellings(text: string): string {\n let out = text;\n for (const { names } of CONSTANT_SPELLINGS) {\n const canonical = names[0]!;\n for (const alias of names.slice(1)) {\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(alias)) continue;\n out = out.replace(new RegExp(`(?<![A-Za-z0-9_])${alias}(?![A-Za-z0-9_])`, 'g'), canonical);\n }\n }\n return out.replace(\n /(?<![A-Za-z0-9_])1\\s*-\\s*eccentricity\\s*(?:\\^|\\*\\*)\\s*2(?![A-Za-z0-9_])/g,\n 'one_minus_e_sq',\n );\n}\n\n/** Options for {@link analyzeUserEquation}. @internal */\nexport interface AnalyzeUserEquationOptions {\n /**\n * Bind a one-letter token that is itself a catalog quantity (`a`, `r`, …).\n * Default false: the match is reported and not applied. The alias `T` →\n * `temperature` is not a one-letter catalog name and still binds.\n */\n readonly bindShortNames?: boolean;\n /** Reconcile a dimension difference by powers of c, ħ, and (geometrized) G. */\n readonly units?: Exclude<UnitMode, 'si'>;\n}\n\nfunction withFormulaNames(catalog: ReadonlyMap<string, Dimension>): Map<string, Dimension> {\n const out = new Map(catalog);\n for (const [name, dim] of formulaNameDimensions()) {\n if (!out.has(name)) out.set(name, dim);\n }\n return out;\n}\n\nexport async function parseUserEquation(\n equation: string,\n catalogNames?: ReadonlySet<string> | Iterable<string>,\n): Promise<UserEquation> {\n if (equation.length > MAX_USER_EQUATION_LEN) {\n throw new UserEquationError(\n `equation exceeds ${MAX_USER_EQUATION_LEN} characters (${equation.length})`,\n );\n }\n // Materialized once: an iterator (`map.keys()`) would be spent by the first use.\n const names = catalogNames === undefined ? undefined : new Set(catalogNames);\n const spelled = rewriteFormulaSpellings(equation);\n const rewritten = names === undefined ? spelled : rewriteCatalogHyphens(spelled, names);\n const eqIdx = rewritten.indexOf('=');\n if (eqIdx < 0) {\n throw new UserEquationError(\n `equation must be \"TARGET = EXPR\" (no \"=\" found in '${equation}')`,\n );\n }\n const target = rewritten.slice(0, eqIdx).trim();\n if (!target) throw new UserEquationError('equation has an empty target (left of \"=\")');\n const rhs = rewritten.slice(eqIdx + 1).trim();\n if (!rhs) throw new UserEquationError('equation has an empty right-hand side');\n\n let variables: readonly string[];\n try {\n const parser = await getFormulaParser();\n ({ variables } = parser.parse(rhs));\n } catch (e) {\n // No parse tree, so no subtraction was read: the hyphen hint needs the parsed variables.\n throw new UserEquationError(`could not parse the right-hand side '${rhs}': ${(e as Error).message}`);\n }\n const sources = variables.filter(\n (v) => !Object.prototype.hasOwnProperty.call(CONSTANTS, v),\n );\n // An all-constant right-hand side (the Planck length) is an equation about a catalog quantity\n // only when its target is one; otherwise it names nothing to check (persona finding W5).\n const targetIsCatalog = names !== undefined && resolveQuantityName(target, names) !== null;\n if (sources.length === 0 && !targetIsCatalog) {\n throw new UserEquationError(\n `no source quantities in '${rhs}' (only constants/numbers?)`,\n );\n }\n return { target, sources, text: rewritten.trim() };\n}\n\n/** Normalize for comparison: lowercase, `_`/`-` unified. */\nconst normalizeForCompare = (s: string): string => s.toLowerCase().replace(/[_-]/g, '-');\n\n/** The shortest name that counts as contained in another for the \"did you mean?\" ranking. */\nconst MIN_CONTAINED = 3;\n\n/**\n * The one \"did you mean?\" ranking, shared by {@link suggestQuantities} and\n * {@link suggestByDimension}: edit distance first, then containment (one name\n * inside the other), then length, then name. Edit distance leads so a one-edit\n * typo beats a substring: `hawkng-temperature` → `hawking-temperature` before\n * `temperature` (persona finding N5). `gate` keeps a candidate only if one name\n * contains the other (the contained one at least three characters long) or the\n * distance is small against the query length; the\n * dimension-based caller passes `false`, because there the dimension is the evidence.\n */\nfunction rankByName(name: string, candidates: Iterable<string>, gate: boolean): string[] {\n const needle = normalizeForCompare(name);\n // Without the gate, short catalog names (`a`, `nu`) are spurious \"matches\" for any typo.\n const maxDist = Math.max(1, Math.ceil(needle.length / 2));\n // A contained name counts only from MIN_CONTAINED characters: every one-letter name occurs inside\n // a long input (`schrodinger-equation` holds a, g, q, r), and that is not nearness (audit I5).\n const within = (outer: string, inner: string): boolean => inner.length >= MIN_CONTAINED && outer.includes(inner);\n return [...candidates]\n .map((cand) => {\n const hay = normalizeForCompare(cand);\n const contains = within(hay, needle) || within(needle, hay) ? 0 : 1;\n return { cand, contains, dist: editDistance(needle, hay) };\n })\n .filter((s) => !gate || s.contains === 0 || s.dist <= maxDist)\n .sort(\n (x, y) =>\n x.dist - y.dist ||\n x.contains - y.contains ||\n x.cand.length - y.cand.length ||\n x.cand.localeCompare(y.cand),\n )\n .map((s) => s.cand);\n}\n\n/**\n * Up to `k` catalog names most similar to `name` — the \"did you mean?\" set for an\n * unmatched user symbol. Ranked by edit distance first, then containment, then\n * length (the shared ranking of `upt map` and `upt explain`).\n *\n * @public\n */\nexport function suggestQuantities(\n name: string,\n catalogNames: Iterable<string>,\n k = 5,\n): string[] {\n return rankByName(name, catalogNames, true).slice(0, k);\n}\n\n/**\n * Catalog quantity names whose dimension equals `dim`, capped at `k` — the\n * dimension-based \"did you mean?\" set once an unknown symbol's dimension has\n * been inferred. With `near` (the unknown symbol) they are ranked by the same\n * edit-distance ranking as {@link suggestQuantities}, so `lenght` lists `length`\n * first (persona finding N2); without it they are sorted by name.\n *\n * @public\n */\nexport function suggestByDimension(\n dim: Dimension,\n catalogDims: ReadonlyMap<string, Dimension>,\n k = 5,\n near?: string,\n): string[] {\n const same = [...catalogDims.entries()].filter(([, d]) => equals(d, dim)).map(([name]) => name);\n return (near === undefined ? same.sort() : rankByName(near, same, false)).slice(0, k);\n}\n\n/**\n * Where the injected user junction landed, computed from a built `VizModel`.\n *\n * @public\n */\nexport interface EquationLanding {\n readonly isolated: boolean;\n /** Junctions in the user equation's connected component (including itself). */\n readonly clusterSize: number;\n /** The component holds a law/established junction (anchored to known physics). */\n readonly anchored: boolean;\n /** User-equation quantities that also appear in a neighbouring junction. */\n readonly sharedQuantities: readonly string[];\n /** Other junction ids in the user equation's component. */\n readonly connectedJunctionIds: readonly string[];\n}\n\n/**\n * Describe where `userJunctionId` sits in `model`: its component, the junctions it\n * connects to, and the quantities that link it to them.\n *\n * @public\n */\nexport function equationLanding(model: VizModel, userJunctionId: string): EquationLanding {\n const cluster = model.clusters.find((c) => c.junctionIds.includes(userJunctionId));\n const self = model.junctions.find((j) => j.id === userJunctionId);\n if (!cluster || !self) {\n return { isolated: true, clusterSize: 1, anchored: false, sharedQuantities: [], connectedJunctionIds: [] };\n }\n const connectedJunctionIds = cluster.junctionIds.filter((id) => id !== userJunctionId);\n const selfQuantities = new Set([...self.sources, self.target]);\n const neighbourQuantities = new Set<string>();\n for (const j of model.junctions) {\n if (j.id === userJunctionId || !cluster.junctionIds.includes(j.id)) continue;\n for (const qn of [...j.sources, j.target]) neighbourQuantities.add(qn);\n }\n const sharedQuantities = [...selfQuantities].filter((qn) => neighbourQuantities.has(qn)).sort();\n return {\n isolated: cluster.size === 1,\n clusterSize: cluster.size,\n anchored: cluster.anchored,\n sharedQuantities,\n connectedJunctionIds,\n };\n}\n\n/**\n * One or two lines summarising `connects to:` (persona findings W3 / I3).\n * Dumping ~100 edge ids next to a correct pendulum equation made shared\n * `length`/`temperature` look like a physics claim. Rank by overlap with the\n * user's shared quantities first, then textbook/law over bridges, then name.\n * When the list is long, state the structural caveat explicitly.\n *\n * @internal\n */\nexport function formatConnectedSummary(\n model: VizModel,\n landing: EquationLanding,\n maxShow = 5,\n): readonly string[] {\n const ids = landing.connectedJunctionIds;\n if (ids.length === 0) return [];\n const shared = new Set(landing.sharedQuantities);\n const byId = new Map(model.junctions.map((j) => [j.id, j]));\n const tier = (id: string): number =>\n id.startsWith('CE-') || id.startsWith('law-') ? 0 : id.startsWith('be-') ? 1 : 2;\n const overlap = (id: string): number => {\n const j = byId.get(id);\n if (!j) return 0;\n let n = 0;\n for (const qn of [...j.sources, j.target]) if (shared.has(qn)) n++;\n return n;\n };\n const ranked = [...ids].sort(\n (a, b) => overlap(b) - overlap(a) || tier(a) - tier(b) || a.localeCompare(b),\n );\n const shown = ranked.slice(0, maxShow);\n const more = ranked.length - shown.length;\n if (more <= 0) {\n return [` nearest equations: ${shown.join(', ')}`];\n }\n return [\n ` nearest equations: ${shown.join(', ')} (+${more} more)`,\n ' (shared-quantity connectivity, not a physics claim)',\n ];\n}\n\n/** A \"did you mean?\" suggestion for an unmatched symbol. */\nexport interface EquationHint {\n readonly name: string;\n readonly suggestions: readonly string[];\n /** True when the suggestions come from the symbol's INFERRED dimension. */\n readonly byDimension: boolean;\n /**\n * Registered constants that carry the symbol's inferred dimension (`sigma` → `sigma_sb`,\n * persona finding L5). Present only when a dimension was inferred and it is not dimensionless.\n */\n readonly constants?: readonly string[];\n}\n\n/** A one-letter user name bound to a catalog quantity (persona finding W6). */\nexport interface ShortBinding {\n readonly name: string;\n readonly quantity: string;\n readonly dim: Dimension;\n /**\n * Present and false when a one-letter catalog name was recognised and not\n * applied. Omitted when the name was bound.\n */\n readonly bound?: false;\n}\n\n/**\n * Full analysis of a user equation against a catalog name→dimension map: the\n * `user` junction (for the graph), the dimensional verdict (RHS dimension vs the\n * target's catalog dimension), and \"did you mean?\" hints (dimension-based when a\n * single unknown's dimension can be inferred, else name-similarity).\n *\n * Physics constants (`hbar`, `c`, `k_B`, …) are supplied to the parser with\n * their real dimensions (from `CONSTANTS`) so the dimensional check is correct.\n *\n * @public\n */\nexport interface EquationAnalysis {\n readonly junction: VizJunction;\n /** Set when the RHS is not dimensionally well-formed (then dims are null). */\n readonly parseError: string | null;\n readonly rhsDimension: Dimension | null;\n readonly targetDimension: Dimension | null;\n /** rhsDimension === targetDimension; null when unknowable or parse failed. */\n readonly consistent: boolean | null;\n readonly hints: readonly EquationHint[];\n /**\n * One-letter names that resolved to a catalog quantity. A one-letter name is the likeliest to\n * mean something else: the catalog's `a` is perihelion's semi-major axis, a length, and the\n * Unruh formula's `a` is an acceleration (persona finding W6).\n */\n readonly shortBindings: readonly ShortBinding[];\n /**\n * RHS names given a dimensionless placeholder because they did not resolve.\n * The reported RHS dimension treats them as dimensionless, so it is not a\n * check of the formula until they are bound.\n */\n readonly placeholders: readonly string[];\n /** Set when `--natural` / `--geometrized` reconciled the two dimensions. */\n readonly naturalNote?: string;\n}\n\n/**\n * Parse + dimensionally analyze a user `TARGET = EXPR` against `catalogDims`\n * (catalog quantity name → dimension). Throws {@link UserEquationError} on a\n * structurally malformed equation; reports a dimensional malformation via\n * `parseError`.\n *\n * @public\n */\nexport async function analyzeUserEquation(\n equation: string,\n catalogDims: ReadonlyMap<string, Dimension>,\n options?: AnalyzeUserEquationOptions,\n): Promise<EquationAnalysis> {\n const dimsIn = withFormulaNames(catalogDims);\n const catalogNames = new Set(dimsIn.keys());\n const bindShort = options?.bindShortNames === true;\n // W2: rewrite catalog kebabs before either parser sees `-` as subtraction.\n const eq = await parseUserEquation(equation, catalogNames);\n const literalShort = (n: string): string | null =>\n n.length === 1 && catalogNames.has(n) ? n : null;\n const resolveCatalog = (n: string): string | null => {\n if (!bindShort && literalShort(n) !== null) return null;\n return resolveQuantityName(n, catalogNames);\n };\n // Evaluate keys are aliases of this target's sources. `R` is reflectance\n // on radiation-pressure and is not a global name.\n const aliasMap = aliasesForTarget(CATALOG_GRAPH, resolveCatalog(eq.target) ?? '');\n const resolve = (n: string): string | null => {\n if (!bindShort && literalShort(n) !== null) return null;\n return resolveQuantityName(n, catalogNames, aliasMap);\n };\n\n // dims for parsePhysics: physics constants carry their REAL dimensions; matched\n // sources their catalog dimension; the (≤1) unmatched source a DIMENSIONLESS\n // placeholder so the RHS still parses.\n const dims: Record<string, Dimension> = {};\n for (const [name, c] of Object.entries(CONSTANTS)) dims[name] = c.dim;\n for (const s of eq.sources) {\n const r = resolve(s);\n dims[s] = r ? (dimsIn.get(r) as Dimension) : (formulaSymbolDimension(s) ?? DIMENSIONLESS);\n }\n // Use the rewritten equation's RHS (eq.text) so planck-length has already\n // become planck_length before dimensional parse.\n const rhsText = eq.text.slice(eq.text.indexOf('=') + 1);\n\n let rhsDimension: Dimension | null = null;\n let exprForInference: import('../dimensional/validator.js').ExprNode | null = null;\n let parseError: string | null = null;\n try {\n const parsed = await parsePhysics(rhsText, dims);\n rhsDimension = parsed.dimension;\n exprForInference = parsed.expr;\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n // The formula parser already read this right-hand side (parseUserEquation), so its variables are the tree's.\n const { variables } = (await getFormulaParser()).parse(rhsText);\n const hint = hyphenSubtractHint(rhsText, variables, catalogNames);\n parseError = hint ? `${msg}. ${hint}` : msg;\n }\n\n const resolvedTarget = resolve(eq.target);\n const targetDimension = resolvedTarget ? (dimsIn.get(resolvedTarget) as Dimension) : null;\n\n const placeholders = eq.sources.filter((s) => !resolve(s));\n const hints: EquationHint[] = [];\n if (exprForInference) {\n const unmatchedSources = placeholders.filter((s) => bindShort || literalShort(s) === null);\n const totalUnmatched = placeholders.length + (resolvedTarget ? 0 : 1);\n for (const s of unmatchedSources) {\n let byDim: string[] | null = null;\n let constants: string[] = [];\n if (targetDimension && totalUnmatched === 1) {\n const inferred = inferUnknownDimension(exprForInference, s, targetDimension);\n if (inferred) {\n byDim = suggestByDimension(inferred, dimsIn, 5, s);\n if (!equals(inferred, DIMENSIONLESS)) {\n constants = Object.entries(CONSTANTS)\n .filter(([, c]) => equals(c.dim, inferred))\n .map(([name]) => name)\n .sort();\n }\n }\n }\n const withConstants = constants.length > 0 ? { constants } : {};\n hints.push(\n byDim\n ? { name: s, suggestions: byDim, byDimension: true, ...withConstants }\n : { name: s, suggestions: suggestQuantities(s, catalogNames, 5), byDimension: false, ...withConstants },\n );\n }\n if (!resolvedTarget && (bindShort || literalShort(eq.target) === null)) {\n hints.push({ name: eq.target, suggestions: suggestQuantities(eq.target, catalogNames, 5), byDimension: false });\n }\n }\n\n const declined = eq.sources\n .filter((s) => !bindShort && literalShort(s) !== null)\n .map((s) => ({ name: s, quantity: s, dim: dimsIn.get(s) as Dimension, bound: false as const }));\n const declinedTarget =\n !bindShort && literalShort(eq.target) !== null\n ? [{ name: eq.target, quantity: eq.target, dim: dimsIn.get(eq.target) as Dimension, bound: false as const }]\n : [];\n const boundShort = eq.sources\n .filter((s) => s.length === 1 && resolve(s) !== null)\n .map((s) => ({ name: s, quantity: resolve(s)!, dim: dimsIn.get(resolve(s)!) as Dimension }));\n\n let consistent = rhsDimension && targetDimension ? equals(rhsDimension, targetDimension) : null;\n let natural: string | undefined;\n if (\n consistent === false &&\n rhsDimension &&\n targetDimension &&\n options?.units !== undefined &&\n (hints.length === 0)\n ) {\n const powers = naturalPowers(rhsDimension, targetDimension, options.units);\n const note = powers === null ? null : naturalNote(powers, options.units);\n if (note) {\n consistent = true;\n natural = note;\n }\n }\n\n return {\n junction: {\n id: 'user-equation',\n label: eq.text,\n status: 'user',\n sources: eq.sources.map((s) => resolve(s) ?? s),\n target: resolvedTarget ?? eq.target,\n },\n parseError,\n rhsDimension,\n targetDimension,\n consistent,\n hints,\n shortBindings: [...declined, ...boundShort, ...declinedTarget],\n placeholders,\n ...(natural === undefined ? {} : { naturalNote: natural }),\n };\n}\n"]}
1
+ {"version":3,"file":"user-equation.js","sourceRoot":"","sources":["../../src/composition/user-equation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,o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AAU;QACV,KAAK;QACL,aAAa,EAAE,CAAC,GAAG,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,cAAc,CAAC;QAC9D,YAAY;QACZ,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;KAC3D,CAAC;AACJ,CAAC","sourcesContent":["/**\n * User-equation injection — turn a free-form `TARGET = EXPR` string into a graph\n * junction (a target quantity + its source quantities), resolve the user's\n * symbols onto the catalog vocabulary, suggest near-misses, and report where the\n * injected junction lands in a built {@link VizModel}.\n *\n * Free-form means no dimensions: source quantities are the RHS's free variables\n * — extracted by the MathTS expression parser via {@link getFormulaParser},\n * which already drops constants like `pi`/`tau`, numbers, and functions —\n * minus the physics {@link CONSTANTS}. Multi-word quantities may be typed with\n * underscores **or** the catalog's own hyphens (`planck-length`): before parse,\n * {@link rewriteCatalogHyphens} rewrites kebab catalog names to underscores so\n * `-` is not read as subtraction (persona finding W2). Resolution still tries\n * the literal form first, then the `_`↔`-` swap.\n *\n * Pure: no file I/O. The injected junction is rendered as an `extraJunction`\n * (status `'user'`) and is never written into the catalog.\n *\n * @module composition/user-equation\n */\n\nimport { getFormulaParser, parsePhysics } from '../numerical/formula-registry.js';\nimport { formulaSymbolDimension } from '../numerical/formula-dimension.js';\nimport { CONSTANT_SPELLINGS } from '../dimensional/dimension-spec.js';\nimport { CONSTANTS, isRegisteredConstant } from '../dimensional/symbolic-constants.js';\nimport { formulaNameDimensions } from '../dimensional/formula-names.js';\nimport { naturalNote, naturalPowers, type UnitMode } from '../dimensional/natural-units.js';\nimport { aliasesForTarget, editDistance } from './aliases.js';\nimport { resolveQuantityName } from '../dimensional/formula-names.js';\nimport { CATALOG_GRAPH } from './catalog-graph.js';\nimport type { VizModel, VizJunction } from './graph-viz.js';\nimport type { Dimension } from '../dimensional/types.js';\nimport { DIMENSIONLESS } from '../dimensional/types.js';\nimport { equals } from '../dimensional/algebra.js';\nimport { inferUnknownDimension } from '../dimensional/dimension-inference.js';\n\n/** Thrown when a user equation cannot be parsed into a target + sources. @public */\nexport class UserEquationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'UserEquationError';\n }\n}\n\n/**\n * A parsed user equation: the target quantity and its source quantities, as\n * written (underscores preserved; constants/numbers/functions removed).\n *\n * @public\n */\nexport interface UserEquation {\n readonly target: string;\n readonly sources: readonly string[];\n /** The original `TARGET = EXPR` text, for the junction label. */\n readonly text: string;\n}\n\n/**\n * Parse `TARGET = EXPR` into `{ target, sources }`. The target is the text left\n * of the first `=`; the sources are the RHS's free variables minus the physics\n * constants.\n *\n * Uses the active formula parser (MathTS when installed, built-in otherwise) to\n * extract the RHS's free variables.\n *\n * @throws {UserEquationError} on a missing `=`, an empty target, an unparseable\n * RHS, or an RHS with no source quantities.\n * @public\n */\n/** Upper bound on user `--equation` text to keep hint computation bounded. */\nconst MAX_USER_EQUATION_LEN = 8192;\n\nimport { rewriteCatalogHyphens } from '../dimensional/hyphen-names.js';\n/** Rewrite a catalog hyphenated name to underscores before the expression parse. */\nexport { rewriteCatalogHyphens };\n\n/** A hyphen-joined run of names, `a-b` or `a-b-c`, not the exponent of `1e-5`. */\nconst HYPHEN_RUN = /(?<![A-Za-z0-9_.])[A-Za-z_][A-Za-z0-9_]*(?:-[A-Za-z0-9_]+)+/g;\n\n/**\n * When the parse read a hyphen-joined run (`thermal-mass`) as a subtraction of\n * its pieces, and the run read as one name is a catalog quantity, tell the user\n * `-` is arithmetic here and to use underscores. Persona finding I2.\n *\n * Decided from the parse, not from an error's text: `variables` are the free\n * variables the formula parser read from `rhs`. The parser has no hyphenated\n * identifier, so a run whose underscored name is not a variable and whose\n * pieces are was parsed as a subtraction.\n *\n * @internal\n */\nexport function hyphenSubtractHint(\n rhs: string,\n variables: readonly string[],\n catalogNames: ReadonlySet<string>,\n): string | null {\n const read = new Set(variables);\n const split = (rhs.match(HYPHEN_RUN) ?? []).filter(\n (run) =>\n !read.has(run.replace(/-/g, '_')) &&\n run.split('-').some((piece) => read.has(piece)) &&\n resolveQuantityName(run, catalogNames) !== null,\n );\n if (split.length === 0) return null;\n const example = split.sort((a, b) => b.length - a.length)[0]!;\n return (\n `'-' is arithmetic here; multi-word catalog names use underscores ` +\n `(${example} → ${example.replace(/-/g, '_')})`\n );\n}\n\n/**\n * Spellings that must not be a bare `e`. Constant aliases come from\n * {@link CONSTANT_SPELLINGS}. `1-eccentricity^2` is the perihelion factor\n * `one_minus_e_sq`.\n */\nfunction rewriteFormulaSpellings(text: string): string {\n let out = text;\n for (const { names } of CONSTANT_SPELLINGS) {\n const canonical = names[0]!;\n for (const alias of names.slice(1)) {\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(alias)) continue;\n out = out.replace(new RegExp(`(?<![A-Za-z0-9_])${alias}(?![A-Za-z0-9_])`, 'g'), canonical);\n }\n }\n return out.replace(\n /(?<![A-Za-z0-9_])1\\s*-\\s*eccentricity\\s*(?:\\^|\\*\\*)\\s*2(?![A-Za-z0-9_])/g,\n 'one_minus_e_sq',\n );\n}\n\n/** Options for {@link analyzeUserEquation}. @internal */\nexport interface AnalyzeUserEquationOptions {\n /**\n * Bind a one-letter token that is itself a catalog quantity (`a`, `r`, …).\n * Default false: the match is reported and not applied. The alias `T` →\n * `temperature` is not a one-letter catalog name and still binds.\n */\n readonly bindShortNames?: boolean;\n /** Reconcile a dimension difference by powers of c, ħ, and (geometrized) G. */\n readonly units?: Exclude<UnitMode, 'si'>;\n}\n\nfunction withFormulaNames(catalog: ReadonlyMap<string, Dimension>): Map<string, Dimension> {\n const out = new Map(catalog);\n for (const [name, dim] of formulaNameDimensions()) {\n if (!out.has(name)) out.set(name, dim);\n }\n return out;\n}\n\nexport async function parseUserEquation(\n equation: string,\n catalogNames?: ReadonlySet<string> | Iterable<string>,\n): Promise<UserEquation> {\n if (equation.length > MAX_USER_EQUATION_LEN) {\n throw new UserEquationError(\n `equation exceeds ${MAX_USER_EQUATION_LEN} characters (${equation.length})`,\n );\n }\n // Materialized once: an iterator (`map.keys()`) would be spent by the first use.\n const names = catalogNames === undefined ? undefined : new Set(catalogNames);\n const spelled = rewriteFormulaSpellings(equation);\n const rewritten = names === undefined ? spelled : rewriteCatalogHyphens(spelled, names);\n const eqIdx = rewritten.indexOf('=');\n if (eqIdx < 0) {\n throw new UserEquationError(\n `equation must be \"TARGET = EXPR\" (no \"=\" found in '${equation}')`,\n );\n }\n const target = rewritten.slice(0, eqIdx).trim();\n if (!target) throw new UserEquationError('equation has an empty target (left of \"=\")');\n const rhs = rewritten.slice(eqIdx + 1).trim();\n if (!rhs) throw new UserEquationError('equation has an empty right-hand side');\n\n let variables: readonly string[];\n try {\n const parser = await getFormulaParser();\n ({ variables } = parser.parse(rhs));\n } catch (e) {\n // No parse tree, so no subtraction was read: the hyphen hint needs the parsed variables.\n throw new UserEquationError(`could not parse the right-hand side '${rhs}': ${(e as Error).message}`);\n }\n const sources = variables.filter((v) => !isRegisteredConstant(v));\n // An all-constant right-hand side (the Planck length) is an equation about a catalog quantity\n // only when its target is one; otherwise it names nothing to check (persona finding W5).\n const targetIsCatalog = names !== undefined && resolveQuantityName(target, names) !== null;\n if (sources.length === 0 && !targetIsCatalog) {\n throw new UserEquationError(\n `no source quantities in '${rhs}' (only constants/numbers?)`,\n );\n }\n return { target, sources, text: rewritten.trim() };\n}\n\n/** Normalize for comparison: lowercase, `_`/`-` unified. */\nconst normalizeForCompare = (s: string): string => s.toLowerCase().replace(/[_-]/g, '-');\n\n/** The shortest name that counts as contained in another for the \"did you mean?\" ranking. */\nconst MIN_CONTAINED = 3;\n\n/**\n * The one \"did you mean?\" ranking, shared by {@link suggestQuantities} and\n * {@link suggestByDimension}: edit distance first, then containment (one name\n * inside the other), then length, then name. Edit distance leads so a one-edit\n * typo beats a substring: `hawkng-temperature` → `hawking-temperature` before\n * `temperature` (persona finding N5). `gate` keeps a candidate only if one name\n * contains the other (the contained one at least three characters long) or the\n * distance is small against the query length; the\n * dimension-based caller passes `false`, because there the dimension is the evidence.\n */\nfunction rankByName(name: string, candidates: Iterable<string>, gate: boolean): string[] {\n const needle = normalizeForCompare(name);\n // Without the gate, short catalog names (`a`, `nu`) are spurious \"matches\" for any typo.\n const maxDist = Math.max(1, Math.ceil(needle.length / 2));\n // A contained name counts only from MIN_CONTAINED characters: every one-letter name occurs inside\n // a long input (`schrodinger-equation` holds a, g, q, r), and that is not nearness (audit I5).\n const within = (outer: string, inner: string): boolean => inner.length >= MIN_CONTAINED && outer.includes(inner);\n return [...candidates]\n .map((cand) => {\n const hay = normalizeForCompare(cand);\n const contains = within(hay, needle) || within(needle, hay) ? 0 : 1;\n return { cand, contains, dist: editDistance(needle, hay) };\n })\n .filter((s) => !gate || s.contains === 0 || s.dist <= maxDist)\n .sort(\n (x, y) =>\n x.dist - y.dist ||\n x.contains - y.contains ||\n x.cand.length - y.cand.length ||\n x.cand.localeCompare(y.cand),\n )\n .map((s) => s.cand);\n}\n\n/**\n * Up to `k` catalog names most similar to `name` — the \"did you mean?\" set for an\n * unmatched user symbol. Ranked by edit distance first, then containment, then\n * length (the shared ranking of `upt map` and `upt explain`).\n *\n * @public\n */\nexport function suggestQuantities(\n name: string,\n catalogNames: Iterable<string>,\n k = 5,\n): string[] {\n return rankByName(name, catalogNames, true).slice(0, k);\n}\n\n/**\n * Catalog quantity names whose dimension equals `dim`, capped at `k` — the\n * dimension-based \"did you mean?\" set once an unknown symbol's dimension has\n * been inferred. With `near` (the unknown symbol) they are ranked by the same\n * edit-distance ranking as {@link suggestQuantities}, so `lenght` lists `length`\n * first (persona finding N2); without it they are sorted by name.\n *\n * @public\n */\nexport function suggestByDimension(\n dim: Dimension,\n catalogDims: ReadonlyMap<string, Dimension>,\n k = 5,\n near?: string,\n): string[] {\n const same = [...catalogDims.entries()].filter(([, d]) => equals(d, dim)).map(([name]) => name);\n return (near === undefined ? same.sort() : rankByName(near, same, false)).slice(0, k);\n}\n\n/**\n * Where the injected user junction landed, computed from a built `VizModel`.\n *\n * @public\n */\nexport interface EquationLanding {\n readonly isolated: boolean;\n /** Junctions in the user equation's connected component (including itself). */\n readonly clusterSize: number;\n /** The component holds a law/established junction (anchored to known physics). */\n readonly anchored: boolean;\n /** User-equation quantities that also appear in a neighbouring junction. */\n readonly sharedQuantities: readonly string[];\n /** Other junction ids in the user equation's component. */\n readonly connectedJunctionIds: readonly string[];\n}\n\n/**\n * Describe where `userJunctionId` sits in `model`: its component, the junctions it\n * connects to, and the quantities that link it to them.\n *\n * @public\n */\nexport function equationLanding(model: VizModel, userJunctionId: string): EquationLanding {\n const cluster = model.clusters.find((c) => c.junctionIds.includes(userJunctionId));\n const self = model.junctions.find((j) => j.id === userJunctionId);\n if (!cluster || !self) {\n return { isolated: true, clusterSize: 1, anchored: false, sharedQuantities: [], connectedJunctionIds: [] };\n }\n const connectedJunctionIds = cluster.junctionIds.filter((id) => id !== userJunctionId);\n const selfQuantities = new Set([...self.sources, self.target]);\n const neighbourQuantities = new Set<string>();\n for (const j of model.junctions) {\n if (j.id === userJunctionId || !cluster.junctionIds.includes(j.id)) continue;\n for (const qn of [...j.sources, j.target]) neighbourQuantities.add(qn);\n }\n const sharedQuantities = [...selfQuantities].filter((qn) => neighbourQuantities.has(qn)).sort();\n return {\n isolated: cluster.size === 1,\n clusterSize: cluster.size,\n anchored: cluster.anchored,\n sharedQuantities,\n connectedJunctionIds,\n };\n}\n\n/**\n * One or two lines summarising `connects to:` (persona findings W3 / I3).\n * Dumping ~100 edge ids next to a correct pendulum equation made shared\n * `length`/`temperature` look like a physics claim. Rank by overlap with the\n * user's shared quantities first, then textbook/law over bridges, then name.\n * When the list is long, state the structural caveat explicitly.\n *\n * @internal\n */\nexport function formatConnectedSummary(\n model: VizModel,\n landing: EquationLanding,\n maxShow = 5,\n): readonly string[] {\n const ids = landing.connectedJunctionIds;\n if (ids.length === 0) return [];\n const shared = new Set(landing.sharedQuantities);\n const byId = new Map(model.junctions.map((j) => [j.id, j]));\n const tier = (id: string): number =>\n id.startsWith('CE-') || id.startsWith('law-') ? 0 : id.startsWith('be-') ? 1 : 2;\n const overlap = (id: string): number => {\n const j = byId.get(id);\n if (!j) return 0;\n let n = 0;\n for (const qn of [...j.sources, j.target]) if (shared.has(qn)) n++;\n return n;\n };\n const ranked = [...ids].sort(\n (a, b) => overlap(b) - overlap(a) || tier(a) - tier(b) || a.localeCompare(b),\n );\n const shown = ranked.slice(0, maxShow);\n const more = ranked.length - shown.length;\n if (more <= 0) {\n return [` nearest equations: ${shown.join(', ')}`];\n }\n return [\n ` nearest equations: ${shown.join(', ')} (+${more} more)`,\n ' (shared-quantity connectivity, not a physics claim)',\n ];\n}\n\n/** A \"did you mean?\" suggestion for an unmatched symbol. */\nexport interface EquationHint {\n readonly name: string;\n readonly suggestions: readonly string[];\n /** True when the suggestions come from the symbol's INFERRED dimension. */\n readonly byDimension: boolean;\n /**\n * Registered constants that carry the symbol's inferred dimension (`sigma` → `sigma_sb`,\n * persona finding L5). Present only when a dimension was inferred and it is not dimensionless.\n */\n readonly constants?: readonly string[];\n}\n\n/** A one-letter user name bound to a catalog quantity (persona finding W6). */\nexport interface ShortBinding {\n readonly name: string;\n readonly quantity: string;\n readonly dim: Dimension;\n /**\n * Present and false when a one-letter catalog name was recognised and not\n * applied. Omitted when the name was bound.\n */\n readonly bound?: false;\n}\n\n/**\n * Full analysis of a user equation against a catalog name→dimension map: the\n * `user` junction (for the graph), the dimensional verdict (RHS dimension vs the\n * target's catalog dimension), and \"did you mean?\" hints (dimension-based when a\n * single unknown's dimension can be inferred, else name-similarity).\n *\n * Physics constants (`hbar`, `c`, `k_B`, …) are supplied to the parser with\n * their real dimensions (from `CONSTANTS`) so the dimensional check is correct.\n *\n * @public\n */\nexport interface EquationAnalysis {\n readonly junction: VizJunction;\n /** Set when the RHS is not dimensionally well-formed (then dims are null). */\n readonly parseError: string | null;\n readonly rhsDimension: Dimension | null;\n readonly targetDimension: Dimension | null;\n /** rhsDimension === targetDimension; null when unknowable or parse failed. */\n readonly consistent: boolean | null;\n readonly hints: readonly EquationHint[];\n /**\n * One-letter names that resolved to a catalog quantity. A one-letter name is the likeliest to\n * mean something else: the catalog's `a` is perihelion's semi-major axis, a length, and the\n * Unruh formula's `a` is an acceleration (persona finding W6).\n */\n readonly shortBindings: readonly ShortBinding[];\n /**\n * RHS names given a dimensionless placeholder because they did not resolve.\n * The reported RHS dimension treats them as dimensionless, so it is not a\n * check of the formula until they are bound.\n */\n readonly placeholders: readonly string[];\n /** Set when `--natural` / `--geometrized` reconciled the two dimensions. */\n readonly naturalNote?: string;\n}\n\n/**\n * Parse + dimensionally analyze a user `TARGET = EXPR` against `catalogDims`\n * (catalog quantity name → dimension). Throws {@link UserEquationError} on a\n * structurally malformed equation; reports a dimensional malformation via\n * `parseError`.\n *\n * @public\n */\nexport async function analyzeUserEquation(\n equation: string,\n catalogDims: ReadonlyMap<string, Dimension>,\n options?: AnalyzeUserEquationOptions,\n): Promise<EquationAnalysis> {\n const dimsIn = withFormulaNames(catalogDims);\n const catalogNames = new Set(dimsIn.keys());\n const bindShort = options?.bindShortNames === true;\n // W2: rewrite catalog kebabs before either parser sees `-` as subtraction.\n const eq = await parseUserEquation(equation, catalogNames);\n const literalShort = (n: string): string | null =>\n n.length === 1 && catalogNames.has(n) ? n : null;\n const resolveCatalog = (n: string): string | null => {\n if (!bindShort && literalShort(n) !== null) return null;\n return resolveQuantityName(n, catalogNames);\n };\n // Evaluate keys are aliases of this target's sources. `R` is reflectance\n // on radiation-pressure and is not a global name.\n const aliasMap = aliasesForTarget(CATALOG_GRAPH, resolveCatalog(eq.target) ?? '');\n const resolve = (n: string): string | null => {\n if (!bindShort && literalShort(n) !== null) return null;\n return resolveQuantityName(n, catalogNames, aliasMap);\n };\n\n // dims for parsePhysics: physics constants carry their REAL dimensions; matched\n // sources their catalog dimension; the (≤1) unmatched source a DIMENSIONLESS\n // placeholder so the RHS still parses.\n const dims: Record<string, Dimension> = {};\n for (const [name, c] of Object.entries(CONSTANTS)) dims[name] = c.dim;\n for (const s of eq.sources) {\n const r = resolve(s);\n dims[s] = r ? (dimsIn.get(r) as Dimension) : (formulaSymbolDimension(s) ?? DIMENSIONLESS);\n }\n // Use the rewritten equation's RHS (eq.text) so planck-length has already\n // become planck_length before dimensional parse.\n const rhsText = eq.text.slice(eq.text.indexOf('=') + 1);\n\n let rhsDimension: Dimension | null = null;\n let exprForInference: import('../dimensional/validator.js').ExprNode | null = null;\n let parseError: string | null = null;\n try {\n const parsed = await parsePhysics(rhsText, dims);\n rhsDimension = parsed.dimension;\n exprForInference = parsed.expr;\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n // The formula parser already read this right-hand side (parseUserEquation), so its variables are the tree's.\n const { variables } = (await getFormulaParser()).parse(rhsText);\n const hint = hyphenSubtractHint(rhsText, variables, catalogNames);\n parseError = hint ? `${msg}. ${hint}` : msg;\n }\n\n const resolvedTarget = resolve(eq.target);\n const targetDimension = resolvedTarget ? (dimsIn.get(resolvedTarget) as Dimension) : null;\n\n const placeholders = eq.sources.filter((s) => !resolve(s));\n const hints: EquationHint[] = [];\n if (exprForInference) {\n const unmatchedSources = placeholders.filter((s) => bindShort || literalShort(s) === null);\n const totalUnmatched = placeholders.length + (resolvedTarget ? 0 : 1);\n for (const s of unmatchedSources) {\n let byDim: string[] | null = null;\n let constants: string[] = [];\n if (targetDimension && totalUnmatched === 1) {\n const inferred = inferUnknownDimension(exprForInference, s, targetDimension);\n if (inferred) {\n byDim = suggestByDimension(inferred, dimsIn, 5, s);\n if (!equals(inferred, DIMENSIONLESS)) {\n constants = Object.entries(CONSTANTS)\n .filter(([, c]) => equals(c.dim, inferred))\n .map(([name]) => name)\n .sort();\n }\n }\n }\n const withConstants = constants.length > 0 ? { constants } : {};\n hints.push(\n byDim\n ? { name: s, suggestions: byDim, byDimension: true, ...withConstants }\n : { name: s, suggestions: suggestQuantities(s, catalogNames, 5), byDimension: false, ...withConstants },\n );\n }\n if (!resolvedTarget && (bindShort || literalShort(eq.target) === null)) {\n hints.push({ name: eq.target, suggestions: suggestQuantities(eq.target, catalogNames, 5), byDimension: false });\n }\n }\n\n const declined = eq.sources\n .filter((s) => !bindShort && literalShort(s) !== null)\n .map((s) => ({ name: s, quantity: s, dim: dimsIn.get(s) as Dimension, bound: false as const }));\n const declinedTarget =\n !bindShort && literalShort(eq.target) !== null\n ? [{ name: eq.target, quantity: eq.target, dim: dimsIn.get(eq.target) as Dimension, bound: false as const }]\n : [];\n const boundShort = eq.sources\n .filter((s) => s.length === 1 && resolve(s) !== null)\n .map((s) => ({ name: s, quantity: resolve(s)!, dim: dimsIn.get(resolve(s)!) as Dimension }));\n\n let consistent = rhsDimension && targetDimension ? equals(rhsDimension, targetDimension) : null;\n let natural: string | undefined;\n if (\n consistent === false &&\n rhsDimension &&\n targetDimension &&\n options?.units !== undefined &&\n (hints.length === 0)\n ) {\n const powers = naturalPowers(rhsDimension, targetDimension, options.units);\n const note = powers === null ? null : naturalNote(powers, options.units);\n if (note) {\n consistent = true;\n natural = note;\n }\n }\n\n return {\n junction: {\n id: 'user-equation',\n label: eq.text,\n status: 'user',\n sources: eq.sources.map((s) => resolve(s) ?? s),\n target: resolvedTarget ?? eq.target,\n },\n parseError,\n rhsDimension,\n targetDimension,\n consistent,\n hints,\n shortBindings: [...declined, ...boundShort, ...declinedTarget],\n placeholders,\n ...(natural === undefined ? {} : { naturalNote: natural }),\n };\n}\n"]}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * One split of a `name=value` token.
3
+ *
4
+ * Every reader of such tokens (the CLI bindings, an evaluator's `key=value`
5
+ * arguments, a metric's parameters, a discovery anchor) splits on the first
6
+ * `=` and refuses a token with no `=` or an empty name. The split is here,
7
+ * once; what a null means (usage error, unit error, metric refusal) and what
8
+ * an empty value means stay with the caller.
9
+ *
10
+ * @module core/assignment
11
+ */
12
+ /** A `name=value` token split on its first `=`. `raw` may be empty (`mass=`). @internal */
13
+ export interface SplitAssignment {
14
+ readonly name: string;
15
+ readonly raw: string;
16
+ }
17
+ /** `token` split on its first `=`, or null when it has no `=` or an empty name. @internal */
18
+ export declare function splitAssignment(token: string): SplitAssignment | null;
19
+ //# sourceMappingURL=assignment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assignment.d.ts","sourceRoot":"","sources":["../../src/core/assignment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,2FAA2F;AAC3F,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,6FAA6F;AAC7F,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAIrE"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * One split of a `name=value` token.
3
+ *
4
+ * Every reader of such tokens (the CLI bindings, an evaluator's `key=value`
5
+ * arguments, a metric's parameters, a discovery anchor) splits on the first
6
+ * `=` and refuses a token with no `=` or an empty name. The split is here,
7
+ * once; what a null means (usage error, unit error, metric refusal) and what
8
+ * an empty value means stay with the caller.
9
+ *
10
+ * @module core/assignment
11
+ */
12
+ /** `token` split on its first `=`, or null when it has no `=` or an empty name. @internal */
13
+ export function splitAssignment(token) {
14
+ const eq = token.indexOf('=');
15
+ if (eq <= 0)
16
+ return null;
17
+ return { name: token.slice(0, eq), raw: token.slice(eq + 1) };
18
+ }
19
+ //# sourceMappingURL=assignment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assignment.js","sourceRoot":"","sources":["../../src/core/assignment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH,6FAA6F;AAC7F,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,EAAE,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACzB,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;AAChE,CAAC","sourcesContent":["/**\n * One split of a `name=value` token.\n *\n * Every reader of such tokens (the CLI bindings, an evaluator's `key=value`\n * arguments, a metric's parameters, a discovery anchor) splits on the first\n * `=` and refuses a token with no `=` or an empty name. The split is here,\n * once; what a null means (usage error, unit error, metric refusal) and what\n * an empty value means stay with the caller.\n *\n * @module core/assignment\n */\n\n/** A `name=value` token split on its first `=`. `raw` may be empty (`mass=`). @internal */\nexport interface SplitAssignment {\n readonly name: string;\n readonly raw: string;\n}\n\n/** `token` split on its first `=`, or null when it has no `=` or an empty name. @internal */\nexport function splitAssignment(token: string): SplitAssignment | null {\n const eq = token.indexOf('=');\n if (eq <= 0) return null;\n return { name: token.slice(0, eq), raw: token.slice(eq + 1) };\n}\n"]}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Numeric and string comparisons the layers above share.
3
+ *
4
+ * Two quotients state how far a value is from a reference; three predicates
5
+ * decide agreement in the product form `|a − b| ≤ tol · scale`, which is the
6
+ * form the sites that migrated here used, so a verdict at a tolerance
7
+ * boundary does not move by an ulp. The codepoint order is the sort that
8
+ * `a < b ? -1 : a > b ? 1 : 0` spelled at ten sites; it is not
9
+ * `localeCompare`, and a sort that used `localeCompare` keeps it.
10
+ *
11
+ * @module core/compare
12
+ */
13
+ /** `|value − ref| / max(|ref|, floor)`: the relative difference against a reference, with a floor for a reference near zero. @internal */
14
+ export declare function relDiff(value: number, ref: number, floor?: number): number;
15
+ /** `|a − b| / max(|a|, |b|, floor)`: the relative difference of two values neither of which is the reference. @internal */
16
+ export declare function symmetricRelDiff(a: number, b: number, floor?: number): number;
17
+ /** `|value − ref| ≤ tol · max(|ref|, floor)`: agreement relative to the reference. @internal */
18
+ export declare function withinRel(value: number, ref: number, tol: number, floor?: number): boolean;
19
+ /**
20
+ * `|value − ref| ≤ tol · max(1, |ref|)`: relative far from one, absolute near
21
+ * zero. The form a stored number written to a few significant digits is
22
+ * checked against the computed one with.
23
+ * @internal
24
+ */
25
+ export declare function withinMixed(value: number, ref: number, tol: number): boolean;
26
+ /** `|a − b| ≤ tol · max(|a|, |b|, floor)`: agreement of two values neither of which is the reference. @internal */
27
+ export declare function withinSymmetric(a: number, b: number, tol: number, floor?: number): boolean;
28
+ /** The UTF-16 code-unit order of two strings: −1, 0 or 1. Not `localeCompare`. @internal */
29
+ export declare function compareCodepoint(a: string, b: string): number;
30
+ /** A comparator over records, by a string key in codepoint order. @internal */
31
+ export declare function byKey<T>(key: (item: T) => string): (a: T, b: T) => number;
32
+ //# sourceMappingURL=compare.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../src/core/compare.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,0IAA0I;AAC1I,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,MAAM,CAErE;AAED,2HAA2H;AAC3H,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,MAAM,CAExE;AAED,gGAAgG;AAChG,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,OAAO,CAErF;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAE5E;AAED,mHAAmH;AACnH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,OAAO,CAErF;AAED,4FAA4F;AAC5F,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED,+EAA+E;AAC/E,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,CAEzE"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Numeric and string comparisons the layers above share.
3
+ *
4
+ * Two quotients state how far a value is from a reference; three predicates
5
+ * decide agreement in the product form `|a − b| ≤ tol · scale`, which is the
6
+ * form the sites that migrated here used, so a verdict at a tolerance
7
+ * boundary does not move by an ulp. The codepoint order is the sort that
8
+ * `a < b ? -1 : a > b ? 1 : 0` spelled at ten sites; it is not
9
+ * `localeCompare`, and a sort that used `localeCompare` keeps it.
10
+ *
11
+ * @module core/compare
12
+ */
13
+ /** `|value − ref| / max(|ref|, floor)`: the relative difference against a reference, with a floor for a reference near zero. @internal */
14
+ export function relDiff(value, ref, floor = 0) {
15
+ return Math.abs(value - ref) / Math.max(Math.abs(ref), floor);
16
+ }
17
+ /** `|a − b| / max(|a|, |b|, floor)`: the relative difference of two values neither of which is the reference. @internal */
18
+ export function symmetricRelDiff(a, b, floor = 0) {
19
+ return Math.abs(a - b) / Math.max(Math.abs(a), Math.abs(b), floor);
20
+ }
21
+ /** `|value − ref| ≤ tol · max(|ref|, floor)`: agreement relative to the reference. @internal */
22
+ export function withinRel(value, ref, tol, floor = 0) {
23
+ return Math.abs(value - ref) <= tol * Math.max(Math.abs(ref), floor);
24
+ }
25
+ /**
26
+ * `|value − ref| ≤ tol · max(1, |ref|)`: relative far from one, absolute near
27
+ * zero. The form a stored number written to a few significant digits is
28
+ * checked against the computed one with.
29
+ * @internal
30
+ */
31
+ export function withinMixed(value, ref, tol) {
32
+ return Math.abs(value - ref) <= tol * Math.max(1, Math.abs(ref));
33
+ }
34
+ /** `|a − b| ≤ tol · max(|a|, |b|, floor)`: agreement of two values neither of which is the reference. @internal */
35
+ export function withinSymmetric(a, b, tol, floor = 1) {
36
+ return Math.abs(a - b) <= tol * Math.max(Math.abs(a), Math.abs(b), floor);
37
+ }
38
+ /** The UTF-16 code-unit order of two strings: −1, 0 or 1. Not `localeCompare`. @internal */
39
+ export function compareCodepoint(a, b) {
40
+ return a < b ? -1 : a > b ? 1 : 0;
41
+ }
42
+ /** A comparator over records, by a string key in codepoint order. @internal */
43
+ export function byKey(key) {
44
+ return (a, b) => compareCodepoint(key(a), key(b));
45
+ }
46
+ //# sourceMappingURL=compare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compare.js","sourceRoot":"","sources":["../../src/core/compare.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,0IAA0I;AAC1I,MAAM,UAAU,OAAO,CAAC,KAAa,EAAE,GAAW,EAAE,KAAK,GAAG,CAAC;IAC3D,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;AAChE,CAAC;AAED,2HAA2H;AAC3H,MAAM,UAAU,gBAAgB,CAAC,CAAS,EAAE,CAAS,EAAE,KAAK,GAAG,CAAC;IAC9D,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AACrE,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,SAAS,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW,EAAE,KAAK,GAAG,CAAC;IAC1E,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;AACvE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW;IACjE,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AACnE,CAAC;AAED,mHAAmH;AACnH,MAAM,UAAU,eAAe,CAAC,CAAS,EAAE,CAAS,EAAE,GAAW,EAAE,KAAK,GAAG,CAAC;IAC1E,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AAC5E,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,gBAAgB,CAAC,CAAS,EAAE,CAAS;IACnD,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,KAAK,CAAI,GAAwB;IAC/C,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC","sourcesContent":["/**\n * Numeric and string comparisons the layers above share.\n *\n * Two quotients state how far a value is from a reference; three predicates\n * decide agreement in the product form `|a − b| ≤ tol · scale`, which is the\n * form the sites that migrated here used, so a verdict at a tolerance\n * boundary does not move by an ulp. The codepoint order is the sort that\n * `a < b ? -1 : a > b ? 1 : 0` spelled at ten sites; it is not\n * `localeCompare`, and a sort that used `localeCompare` keeps it.\n *\n * @module core/compare\n */\n\n/** `|value − ref| / max(|ref|, floor)`: the relative difference against a reference, with a floor for a reference near zero. @internal */\nexport function relDiff(value: number, ref: number, floor = 0): number {\n return Math.abs(value - ref) / Math.max(Math.abs(ref), floor);\n}\n\n/** `|a − b| / max(|a|, |b|, floor)`: the relative difference of two values neither of which is the reference. @internal */\nexport function symmetricRelDiff(a: number, b: number, floor = 0): number {\n return Math.abs(a - b) / Math.max(Math.abs(a), Math.abs(b), floor);\n}\n\n/** `|value − ref| ≤ tol · max(|ref|, floor)`: agreement relative to the reference. @internal */\nexport function withinRel(value: number, ref: number, tol: number, floor = 0): boolean {\n return Math.abs(value - ref) <= tol * Math.max(Math.abs(ref), floor);\n}\n\n/**\n * `|value − ref| ≤ tol · max(1, |ref|)`: relative far from one, absolute near\n * zero. The form a stored number written to a few significant digits is\n * checked against the computed one with.\n * @internal\n */\nexport function withinMixed(value: number, ref: number, tol: number): boolean {\n return Math.abs(value - ref) <= tol * Math.max(1, Math.abs(ref));\n}\n\n/** `|a − b| ≤ tol · max(|a|, |b|, floor)`: agreement of two values neither of which is the reference. @internal */\nexport function withinSymmetric(a: number, b: number, tol: number, floor = 1): boolean {\n return Math.abs(a - b) <= tol * Math.max(Math.abs(a), Math.abs(b), floor);\n}\n\n/** The UTF-16 code-unit order of two strings: −1, 0 or 1. Not `localeCompare`. @internal */\nexport function compareCodepoint(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n\n/** A comparator over records, by a string key in codepoint order. @internal */\nexport function byKey<T>(key: (item: T) => string): (a: T, b: T) => number {\n return (a, b) => compareCodepoint(key(a), key(b));\n}\n"]}