gdp-wired 0.48.0 → 0.50.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 (361) hide show
  1. package/README.md +6 -2
  2. package/dist/core/bmc.js +10 -7
  3. package/dist/core/candidate-seeds.d.ts +25 -0
  4. package/dist/core/candidate-seeds.js +90 -0
  5. package/dist/core/check.js +7 -2
  6. package/dist/core/cli.js +3 -0
  7. package/dist/core/count-attempt-work.d.ts +29 -0
  8. package/dist/core/count-attempt-work.js +96 -0
  9. package/dist/core/count-boolean-partition.d.ts +5 -0
  10. package/dist/core/count-boolean-partition.js +47 -0
  11. package/dist/core/count-bounded-quotient.d.ts +2 -0
  12. package/dist/core/count-bounded-quotient.js +13 -0
  13. package/dist/core/count-case-compose.d.ts +20 -0
  14. package/dist/core/count-case-compose.js +289 -0
  15. package/dist/core/count-cases.js +3 -2
  16. package/dist/core/count-cert-rename.d.ts +10 -0
  17. package/dist/core/count-cert-rename.js +69 -0
  18. package/dist/core/count-cert-transport.d.ts +10 -2
  19. package/dist/core/count-cert-transport.js +60 -9
  20. package/dist/core/count-certificate-minimize.d.ts +57 -0
  21. package/dist/core/count-certificate-minimize.js +263 -0
  22. package/dist/core/count-closed-family.d.ts +32 -0
  23. package/dist/core/count-closed-family.js +143 -0
  24. package/dist/core/count-closing-budget.d.ts +10 -0
  25. package/dist/core/count-closing-budget.js +49 -0
  26. package/dist/core/count-closing-needs.d.ts +5 -0
  27. package/dist/core/count-closing-needs.js +9 -0
  28. package/dist/core/count-component-budget.d.ts +5 -0
  29. package/dist/core/count-component-budget.js +9 -0
  30. package/dist/core/count-copy-shape.d.ts +11 -0
  31. package/dist/core/count-copy-shape.js +40 -0
  32. package/dist/core/count-disjoint-funding.d.ts +75 -0
  33. package/dist/core/count-disjoint-funding.js +284 -0
  34. package/dist/core/count-emitter-frame-pool.d.ts +23 -0
  35. package/dist/core/count-emitter-frame-pool.js +87 -0
  36. package/dist/core/count-final-step.d.ts +5 -0
  37. package/dist/core/count-final-step.js +20 -0
  38. package/dist/core/count-fixed-frame.d.ts +4 -0
  39. package/dist/core/count-fixed-frame.js +30 -0
  40. package/dist/core/count-frames.d.ts +25 -0
  41. package/dist/core/count-frames.js +118 -0
  42. package/dist/core/count-frozen-guard.d.ts +2 -0
  43. package/dist/core/count-frozen-guard.js +31 -0
  44. package/dist/core/count-generation-phase.d.ts +7 -0
  45. package/dist/core/count-generation-phase.js +33 -0
  46. package/dist/core/count-guard-composition.d.ts +12 -0
  47. package/dist/core/count-guard-composition.js +48 -0
  48. package/dist/core/count-guard-context.d.ts +11 -0
  49. package/dist/core/count-guard-context.js +50 -0
  50. package/dist/core/count-guard-facts.d.ts +50 -0
  51. package/dist/core/count-guard-facts.js +97 -0
  52. package/dist/core/count-guard-proposals.d.ts +7 -0
  53. package/dist/core/count-guard-proposals.js +106 -0
  54. package/dist/core/count-guard-shape.d.ts +18 -0
  55. package/dist/core/count-guard-shape.js +100 -0
  56. package/dist/core/count-guard-tree.d.ts +17 -0
  57. package/dist/core/count-guard-tree.js +125 -0
  58. package/dist/core/count-leader-facts.d.ts +10 -0
  59. package/dist/core/count-leader-facts.js +52 -0
  60. package/dist/core/count-leader.d.ts +10 -0
  61. package/dist/core/count-leader.js +331 -0
  62. package/dist/core/count-lemma-transport.d.ts +8 -0
  63. package/dist/core/count-lemma-transport.js +47 -0
  64. package/dist/core/count-lifted-budget.d.ts +54 -0
  65. package/dist/core/count-lifted-budget.js +97 -0
  66. package/dist/core/count-lifted-copy.d.ts +3 -0
  67. package/dist/core/count-lifted-copy.js +166 -0
  68. package/dist/core/count-lifted-increment.d.ts +3 -0
  69. package/dist/core/count-lifted-increment.js +146 -0
  70. package/dist/core/count-lifted-load.d.ts +5 -0
  71. package/dist/core/count-lifted-load.js +179 -0
  72. package/dist/core/count-lifted-prerequisite.d.ts +14 -0
  73. package/dist/core/count-lifted-prerequisite.js +53 -0
  74. package/dist/core/count-lifted-replacement.d.ts +3 -0
  75. package/dist/core/count-lifted-replacement.js +540 -0
  76. package/dist/core/count-lifted-shape.d.ts +63 -0
  77. package/dist/core/count-lifted-shape.js +115 -0
  78. package/dist/core/count-lifted-strategy.d.ts +7 -0
  79. package/dist/core/count-lifted-strategy.js +226 -0
  80. package/dist/core/count-lifted-transports.d.ts +32 -0
  81. package/dist/core/count-lifted-transports.js +293 -0
  82. package/dist/core/count-load-shape.d.ts +17 -0
  83. package/dist/core/count-load-shape.js +67 -0
  84. package/dist/core/count-minimal-view.d.ts +26 -0
  85. package/dist/core/count-minimal-view.js +46 -0
  86. package/dist/core/count-operation-observation.d.ts +9 -0
  87. package/dist/core/count-operation-observation.js +22 -0
  88. package/dist/core/count-operation-order.d.ts +5 -0
  89. package/dist/core/count-operation-order.js +4 -0
  90. package/dist/core/count-phase.d.ts +9 -0
  91. package/dist/core/count-phase.js +127 -0
  92. package/dist/core/count-premise-search.d.ts +9 -0
  93. package/dist/core/count-premise-search.js +41 -0
  94. package/dist/core/count-premise-view.d.ts +19 -0
  95. package/dist/core/count-premise-view.js +220 -0
  96. package/dist/core/count-prerequisite-components.d.ts +67 -0
  97. package/dist/core/count-prerequisite-components.js +239 -0
  98. package/dist/core/count-prerequisite-memory.d.ts +24 -0
  99. package/dist/core/count-prerequisite-memory.js +37 -0
  100. package/dist/core/count-prerequisite-plan.d.ts +12 -0
  101. package/dist/core/count-prerequisite-plan.js +88 -0
  102. package/dist/core/count-primitive-budget.d.ts +1 -0
  103. package/dist/core/count-primitive-budget.js +8 -0
  104. package/dist/core/count-project-free.d.ts +3 -0
  105. package/dist/core/count-project-free.js +24 -0
  106. package/dist/core/count-project-witness.d.ts +4 -0
  107. package/dist/core/count-project-witness.js +48 -0
  108. package/dist/core/count-proof-rescope.d.ts +14 -0
  109. package/dist/core/count-proof-rescope.js +71 -0
  110. package/dist/core/count-proof-scope.d.ts +68 -0
  111. package/dist/core/count-proof-scope.js +333 -0
  112. package/dist/core/count-prune-owned-root.d.ts +5 -0
  113. package/dist/core/count-prune-owned-root.js +27 -0
  114. package/dist/core/count-query-context.d.ts +3 -0
  115. package/dist/core/count-query-context.js +7 -0
  116. package/dist/core/count-query.d.ts +15 -0
  117. package/dist/core/count-query.js +59 -0
  118. package/dist/core/count-quorum-leaf.d.ts +9 -0
  119. package/dist/core/count-quorum-leaf.js +38 -0
  120. package/dist/core/count-reachability-budget.d.ts +1 -0
  121. package/dist/core/count-reachability-budget.js +7 -0
  122. package/dist/core/count-reachability-reconcile.d.ts +11 -0
  123. package/dist/core/count-reachability-reconcile.js +19 -0
  124. package/dist/core/count-reachability.d.ts +50 -0
  125. package/dist/core/count-reachability.js +351 -0
  126. package/dist/core/count-rebase-path.d.ts +9 -0
  127. package/dist/core/count-rebase-path.js +68 -0
  128. package/dist/core/count-recipe-context.d.ts +45 -0
  129. package/dist/core/count-recipe-context.js +71 -0
  130. package/dist/core/count-recipe-controller.d.ts +115 -0
  131. package/dist/core/count-recipe-controller.js +417 -0
  132. package/dist/core/count-recipe-graph.d.ts +36 -0
  133. package/dist/core/count-recipe-graph.js +211 -0
  134. package/dist/core/count-recovery/conditional-check-cache.js +3 -2
  135. package/dist/core/count-recovery/conditional-cuts.js +5 -4
  136. package/dist/core/count-recovery/conditional-proof.d.ts +37 -3
  137. package/dist/core/count-recovery/conditional-proof.js +72 -30
  138. package/dist/core/count-recovery/derivability-closure.js +2 -1
  139. package/dist/core/count-recovery/guard-cases.js +2 -1
  140. package/dist/core/count-recovery/reframe-tree.d.ts +2 -0
  141. package/dist/core/count-recovery/reframe-tree.js +24 -0
  142. package/dist/core/count-recovery/replay-linear-skeleton.d.ts +2 -0
  143. package/dist/core/count-recovery/replay-linear-skeleton.js +28 -0
  144. package/dist/core/count-recovery/row-cases.js +2 -1
  145. package/dist/core/count-rejection-budget.d.ts +8 -0
  146. package/dist/core/count-rejection-budget.js +15 -0
  147. package/dist/core/count-replacement.d.ts +5 -0
  148. package/dist/core/count-replacement.js +129 -0
  149. package/dist/core/count-replay-diagnostic.d.ts +21 -0
  150. package/dist/core/count-replay-diagnostic.js +49 -0
  151. package/dist/core/count-replay-skeleton.d.ts +4 -0
  152. package/dist/core/count-replay-skeleton.js +28 -0
  153. package/dist/core/count-rescope-funding.d.ts +3 -0
  154. package/dist/core/count-rescope-funding.js +17 -0
  155. package/dist/core/count-restrictions.d.ts +11 -0
  156. package/dist/core/count-restrictions.js +31 -0
  157. package/dist/core/count-retry-budget.d.ts +67 -0
  158. package/dist/core/count-retry-budget.js +114 -0
  159. package/dist/core/count-retry-round.d.ts +24 -0
  160. package/dist/core/count-retry-round.js +44 -0
  161. package/dist/core/count-row-agreement.d.ts +35 -0
  162. package/dist/core/count-row-agreement.js +270 -0
  163. package/dist/core/count-row-aliases.d.ts +3 -0
  164. package/dist/core/count-row-aliases.js +59 -0
  165. package/dist/core/count-row-composition.d.ts +6 -0
  166. package/dist/core/count-row-composition.js +55 -0
  167. package/dist/core/count-row-copy-linear.d.ts +4 -0
  168. package/dist/core/count-row-copy-linear.js +83 -0
  169. package/dist/core/count-row-copy.d.ts +4 -0
  170. package/dist/core/count-row-copy.js +94 -0
  171. package/dist/core/count-row-policy.d.ts +3 -0
  172. package/dist/core/count-row-policy.js +56 -0
  173. package/dist/core/count-row-reindex.d.ts +11 -0
  174. package/dist/core/count-row-reindex.js +126 -0
  175. package/dist/core/count-row-support.d.ts +9 -0
  176. package/dist/core/count-row-support.js +42 -0
  177. package/dist/core/count-row-symmetry.d.ts +7 -0
  178. package/dist/core/count-row-symmetry.js +100 -0
  179. package/dist/core/count-scope-hyps.d.ts +2 -0
  180. package/dist/core/count-scope-hyps.js +163 -0
  181. package/dist/core/count-scope-row-reuse.d.ts +3 -0
  182. package/dist/core/count-scope-row-reuse.js +92 -0
  183. package/dist/core/count-search-allowance.d.ts +1 -0
  184. package/dist/core/count-search-allowance.js +17 -0
  185. package/dist/core/count-stabilize-tree.d.ts +9 -0
  186. package/dist/core/count-stabilize-tree.js +35 -0
  187. package/dist/core/count-stage-trace.d.ts +8 -0
  188. package/dist/core/count-stage-trace.js +45 -0
  189. package/dist/core/count-strategies.d.ts +16 -0
  190. package/dist/core/count-strategies.js +155 -0
  191. package/dist/core/count-strategy-premises.d.ts +5 -0
  192. package/dist/core/count-strategy-premises.js +14 -0
  193. package/dist/core/count-strategy.d.ts +41 -0
  194. package/dist/core/count-strategy.js +76 -0
  195. package/dist/core/count-support.d.ts +1 -0
  196. package/dist/core/count-support.js +26 -4
  197. package/dist/core/count-tier-budget.d.ts +14 -0
  198. package/dist/core/count-tier-budget.js +64 -0
  199. package/dist/core/count-unwritten-prefix.d.ts +24 -0
  200. package/dist/core/count-unwritten-prefix.js +97 -0
  201. package/dist/core/count-write-shape.d.ts +15 -0
  202. package/dist/core/count-write-shape.js +73 -0
  203. package/dist/core/counted-candidate-seeds.d.ts +12 -0
  204. package/dist/core/counted-candidate-seeds.js +31 -0
  205. package/dist/core/counts.d.ts +37 -13
  206. package/dist/core/counts.js +999 -129
  207. package/dist/core/cycles.js +5 -4
  208. package/dist/core/cyclic.js +11 -10
  209. package/dist/core/data.js +16 -15
  210. package/dist/core/dsl-deadline.d.ts +3 -0
  211. package/dist/core/dsl-deadline.js +27 -0
  212. package/dist/core/dsl.d.ts +32 -2
  213. package/dist/core/dsl.js +202 -64
  214. package/dist/core/evaluation-admission.d.ts +1 -0
  215. package/dist/core/evaluation-admission.js +3 -0
  216. package/dist/core/exists.d.ts +6 -1
  217. package/dist/core/exists.js +53 -10
  218. package/dist/core/field-laws.d.ts +3 -1
  219. package/dist/core/field-laws.js +159 -3
  220. package/dist/core/finite-houdini.d.ts +6 -0
  221. package/dist/core/finite-houdini.js +63 -21
  222. package/dist/core/finite-tiny.js +95 -67
  223. package/dist/core/fixtures/count-completion/paxos-decision.json +1 -0
  224. package/dist/core/fresh.js +5 -1
  225. package/dist/core/infer.js +49 -33
  226. package/dist/core/kind.js +2 -1
  227. package/dist/core/lemma-cuts.js +11 -10
  228. package/dist/core/lift-cli.d.ts +11 -0
  229. package/dist/core/lift-cli.js +113 -0
  230. package/dist/core/linear-admission.d.ts +14 -0
  231. package/dist/core/linear-admission.js +151 -0
  232. package/dist/core/machine.d.ts +5 -2
  233. package/dist/core/machine.js +105 -31
  234. package/dist/core/meter.d.ts +22 -0
  235. package/dist/core/meter.js +34 -0
  236. package/dist/core/nonterm.js +4 -3
  237. package/dist/core/proof-output.d.ts +53 -0
  238. package/dist/core/proof-output.js +38 -0
  239. package/dist/core/prover-row-budget.d.ts +3 -0
  240. package/dist/core/prover-row-budget.js +106 -0
  241. package/dist/core/quorum-laws.d.ts +21 -1
  242. package/dist/core/quorum-laws.js +80 -17
  243. package/dist/core/rationals.js +3 -2
  244. package/dist/core/rejection-discovery.d.ts +34 -0
  245. package/dist/core/rejection-discovery.js +36 -0
  246. package/dist/core/rejection-stage.d.ts +39 -0
  247. package/dist/core/rejection-stage.js +205 -0
  248. package/dist/core/request-quotient.d.ts +8 -0
  249. package/dist/core/request-quotient.js +299 -0
  250. package/dist/core/row-agreement-shape.d.ts +15 -0
  251. package/dist/core/row-agreement-shape.js +68 -0
  252. package/dist/core/runtime-wall.d.ts +2 -0
  253. package/dist/core/search-policy.d.ts +15 -0
  254. package/dist/core/search-policy.js +68 -0
  255. package/dist/core/solver.d.ts +1 -1
  256. package/dist/core/solver.js +40 -6
  257. package/dist/core/step-work.d.ts +12 -0
  258. package/dist/core/step-work.js +14 -0
  259. package/dist/core/strategy-premises.d.ts +8 -0
  260. package/dist/core/strategy-premises.js +64 -0
  261. package/dist/core/system.js +4 -3
  262. package/dist/core/table-admission.d.ts +1 -0
  263. package/dist/core/table-admission.js +3 -0
  264. package/dist/core/trace-clock.d.ts +3 -0
  265. package/dist/core/trace-clock.js +16 -0
  266. package/dist/core/transfer.js +3 -2
  267. package/dist/core/translate.js +16 -3
  268. package/dist/core/wall.d.ts +6 -1
  269. package/dist/core/wall.js +23 -9
  270. package/dist/core/watch.d.ts +1 -1
  271. package/dist/core/watch.js +13 -4
  272. package/dist/core/work-admission.d.ts +164 -0
  273. package/dist/core/work-admission.js +418 -0
  274. package/dist/core/work-amount.d.ts +21 -0
  275. package/dist/core/work-amount.js +80 -0
  276. package/dist/core/work-collections.d.ts +11 -0
  277. package/dist/core/work-collections.js +198 -0
  278. package/dist/core/work-kinds.d.ts +11 -0
  279. package/dist/core/work-kinds.js +9 -0
  280. package/dist/core/work-meter.d.ts +8 -0
  281. package/dist/core/work-meter.js +83 -0
  282. package/dist/core/work-observe.d.ts +12 -0
  283. package/dist/core/work-observe.js +39 -0
  284. package/dist/core/work-profile.d.ts +10 -0
  285. package/dist/core/work-profile.js +21 -0
  286. package/dist/core/work-refusal.d.ts +1 -0
  287. package/dist/core/work-refusal.js +6 -0
  288. package/dist/interchange/format.js +2 -0
  289. package/dist/kernel/cdcl.js +93 -40
  290. package/dist/kernel/epr.js +23 -8
  291. package/dist/kernel/function-instances.d.ts +45 -0
  292. package/dist/kernel/function-instances.js +460 -0
  293. package/dist/kernel/kernel.d.ts +47 -1
  294. package/dist/kernel/kernel.js +417 -68
  295. package/dist/kernel/prove.d.ts +61 -6
  296. package/dist/kernel/prove.js +625 -205
  297. package/dist/kernel/prover-rows.d.ts +1 -0
  298. package/dist/kernel/prover-rows.js +12 -1
  299. package/dist/kernel/reader.d.ts +1 -1
  300. package/dist/kernel/reader.js +57 -12
  301. package/dist/kernel/simplex.js +9 -2
  302. package/dist/lean-kernel/axiom-audit.d.ts +11 -0
  303. package/dist/lean-kernel/axiom-audit.js +50 -0
  304. package/dist/lean-kernel/emit.d.ts +34 -3
  305. package/dist/lean-kernel/emit.js +215 -28
  306. package/dist/lean-kernel/legacy-family-library.d.ts +1 -0
  307. package/dist/lean-kernel/legacy-family-library.js +5 -0
  308. package/dist/lean-kernel/legacy-family-order.d.ts +1 -0
  309. package/dist/lean-kernel/legacy-family-order.js +26 -0
  310. package/dist/lean-kernel/library.js +25 -3
  311. package/dist/lean-kernel/lift/counted-source-data.d.ts +7 -0
  312. package/dist/lean-kernel/lift/counted-source-data.js +78 -0
  313. package/dist/lean-kernel/lift/index.d.ts +82 -0
  314. package/dist/lean-kernel/lift/index.js +116 -0
  315. package/dist/lean-kernel/lift/project.d.ts +4 -0
  316. package/dist/lean-kernel/lift/project.js +15 -0
  317. package/dist/lean-kernel/lift/proof-capture.d.ts +104 -0
  318. package/dist/lean-kernel/lift/proof-capture.js +216 -0
  319. package/dist/lean-kernel/lift/proof-codec.d.ts +28 -0
  320. package/dist/lean-kernel/lift/proof-codec.js +299 -0
  321. package/dist/lean-kernel/lift/proof-counted-source.d.ts +16 -0
  322. package/dist/lean-kernel/lift/proof-counted-source.js +68 -0
  323. package/dist/lean-kernel/lift/proof-frontier.d.ts +19 -0
  324. package/dist/lean-kernel/lift/proof-frontier.js +153 -0
  325. package/dist/lean-kernel/lift/proof-graph.d.ts +17 -0
  326. package/dist/lean-kernel/lift/proof-graph.js +130 -0
  327. package/dist/lean-kernel/lift/proof-parts.d.ts +29 -0
  328. package/dist/lean-kernel/lift/proof-parts.js +131 -0
  329. package/dist/lean-kernel/lift/proof-prelude.d.ts +2 -0
  330. package/dist/lean-kernel/lift/proof-prelude.js +38 -0
  331. package/dist/lean-kernel/lift/proof-witness.d.ts +30 -0
  332. package/dist/lean-kernel/lift/proof-witness.js +283 -0
  333. package/dist/lean-kernel/lift/shape.d.ts +5 -0
  334. package/dist/lean-kernel/lift/shape.js +57 -0
  335. package/dist/lean-kernel/lift/source-projection.d.ts +16 -0
  336. package/dist/lean-kernel/lift/source-projection.js +81 -0
  337. package/dist/lean-kernel/lift/source.d.ts +23 -0
  338. package/dist/lean-kernel/lift/source.js +111 -0
  339. package/dist/lean-kernel/lift/witness-alpha.d.ts +9 -0
  340. package/dist/lean-kernel/lift/witness-alpha.js +31 -0
  341. package/dist/lean-kernel/lift-legacy.d.ts +58 -0
  342. package/dist/lean-kernel/lift-legacy.js +84 -0
  343. package/dist/lean-kernel/lift-names.d.ts +22 -0
  344. package/dist/lean-kernel/lift-names.js +36 -0
  345. package/dist/lean-kernel/lift-simulation/index.d.ts +29 -0
  346. package/dist/lean-kernel/lift-simulation/index.js +352 -0
  347. package/dist/lean-kernel/lift-simulation/shape.d.ts +41 -0
  348. package/dist/lean-kernel/lift-simulation/shape.js +173 -0
  349. package/dist/lean-kernel/lift-special/index.d.ts +36 -0
  350. package/dist/lean-kernel/lift-special/index.js +241 -0
  351. package/dist/lean-kernel/lift-special/structural.d.ts +25 -0
  352. package/dist/lean-kernel/lift-special/structural.js +126 -0
  353. package/dist/lean-kernel/lift-typed/index.d.ts +35 -0
  354. package/dist/lean-kernel/lift-typed/index.js +256 -0
  355. package/dist/lean-kernel/lift-typed/roles.d.ts +17 -0
  356. package/dist/lean-kernel/lift-typed/roles.js +170 -0
  357. package/dist/lean-kernel/lift-typed/shape.d.ts +1 -0
  358. package/dist/lean-kernel/lift-typed/shape.js +12 -0
  359. package/dist/lean-kernel/lift.d.ts +30 -0
  360. package/dist/lean-kernel/lift.js +97 -0
  361. package/package.json +5 -1
@@ -0,0 +1,21 @@
1
+ export type ReplayDiagnosticContext = Readonly<{
2
+ passId?: number;
3
+ closingAttempt?: number;
4
+ member?: string;
5
+ obligation?: string;
6
+ route?: string;
7
+ repairUsed?: boolean;
8
+ }>;
9
+ export type ReplayDiagnosticEvent = Readonly<{
10
+ kind: string;
11
+ context?: ReplayDiagnosticContext;
12
+ [key: string]: unknown;
13
+ }>;
14
+ export declare const countReplayDiagnostic: {
15
+ on?: (event: ReplayDiagnosticEvent) => void;
16
+ observerFailures: number;
17
+ };
18
+ export declare function replayCertificateId(certificate: object): number | undefined;
19
+ export declare function replayPassId(pass: object): number | undefined;
20
+ export declare function withReplayDiagnosticContext<T>(context: ReplayDiagnosticContext, run: () => T): T;
21
+ export declare function emitReplayDiagnostic(event: ReplayDiagnosticEvent): void;
@@ -0,0 +1,49 @@
1
+ export const countReplayDiagnostic = { observerFailures: 0 };
2
+ let current = {};
3
+ const passIds = new WeakMap(), certificateIds = new WeakMap();
4
+ let nextPass = 0, nextCertificate = 0;
5
+ export function replayCertificateId(certificate) {
6
+ if (!countReplayDiagnostic.on)
7
+ return undefined;
8
+ let id = certificateIds.get(certificate);
9
+ if (id === undefined) {
10
+ id = ++nextCertificate;
11
+ certificateIds.set(certificate, id);
12
+ }
13
+ return id;
14
+ }
15
+ export function replayPassId(pass) {
16
+ if (!countReplayDiagnostic.on)
17
+ return undefined;
18
+ let id = passIds.get(pass);
19
+ if (id === undefined) {
20
+ id = ++nextPass;
21
+ passIds.set(pass, id);
22
+ }
23
+ return id;
24
+ }
25
+ export function withReplayDiagnosticContext(context, run) {
26
+ if (!countReplayDiagnostic.on)
27
+ return run();
28
+ const old = current;
29
+ current = { ...old, ...context };
30
+ try {
31
+ return run();
32
+ }
33
+ finally {
34
+ current = old;
35
+ }
36
+ }
37
+ export function emitReplayDiagnostic(event) {
38
+ const observer = countReplayDiagnostic.on;
39
+ if (!observer)
40
+ return;
41
+ // Diagnostics cannot turn a proof refusal into success, renew any allowance,
42
+ // or replace an original allocator exception with a serialization exception.
43
+ try {
44
+ observer({ ...event, context: { ...current, ...event.context } });
45
+ }
46
+ catch {
47
+ countReplayDiagnostic.observerFailures++;
48
+ }
49
+ }
@@ -0,0 +1,4 @@
1
+ import { type Goal, type Path, type Tree } from '../kernel/kernel.js';
2
+ export declare function replayLinearSkeleton(goal: Goal, hint: Tree, root: Path, until: number, options?: {
3
+ deferCheck?: boolean;
4
+ }): Tree | undefined;
@@ -0,0 +1,28 @@
1
+ // An untrusted proof supplies split hints only. Every replacement leaf is
2
+ // proved from the original goal/path by the ordinary linear solver/checker.
3
+ import { canon, check } from "../kernel/kernel.js";
4
+ import { late, rowsAt } from "../kernel/prove.js";
5
+ import { solve } from "./solver.js";
6
+ export function replayLinearSkeleton(goal, hint, root, until, options = {}) {
7
+ const go = (tree, path) => {
8
+ if (late(until))
9
+ return;
10
+ if ('leaf' in tree) {
11
+ const result = solve(rowsAt(goal, path), 2000);
12
+ if (result.kind !== 'refuted')
13
+ return;
14
+ const out = { leaf: result.steps };
15
+ return options.deferCheck || check(goal, out, path) ? out : undefined;
16
+ }
17
+ const id = canon(tree.split), known = path.get(id)?.holds;
18
+ if (known !== undefined)
19
+ return go(known ? tree.yes : tree.no, path);
20
+ const yes = go(tree.yes, new Map(path).set(id, { lin: tree.split, holds: true }));
21
+ if (!yes)
22
+ return;
23
+ const no = go(tree.no, new Map(path).set(id, { lin: tree.split, holds: false }));
24
+ return no ? { split: tree.split, yes, no } : undefined;
25
+ };
26
+ const tree = go(hint, root);
27
+ return tree && (options.deferCheck || check(goal, tree, root)) ? tree : undefined;
28
+ }
@@ -0,0 +1,3 @@
1
+ import { type CountRescopeOptions } from './count-proof-rescope.js';
2
+ import { type WorkLedger } from './work-admission.js';
3
+ export declare function countRescopeFunding(bank?: WorkLedger): CountRescopeOptions;
@@ -0,0 +1,17 @@
1
+ import { workLedger } from "./work-admission.js";
2
+ import { compareWork, zeroWork } from "./work-amount.js";
3
+ export function countRescopeFunding(bank = workLedger) {
4
+ const owner = bank.currentScope(), rootEpoch = bank.snapshot().rootEpoch;
5
+ return {
6
+ retainUncheckedOffer: true,
7
+ allowFullFallback: () => {
8
+ if (!owner || owner.kind === 'root' || !bank.inBudget())
9
+ return false;
10
+ const active = bank.snapshot();
11
+ if (active.rootEpoch !== rootEpoch || !active.activeEndpoints.some(scope => scope.id === owner.id))
12
+ return false;
13
+ const left = bank.available();
14
+ return left !== null && compareWork(left, zeroWork) > 0;
15
+ }
16
+ };
17
+ }
@@ -0,0 +1,11 @@
1
+ import { type Machine } from './machine.js';
2
+ export type Restriction = {
3
+ base: string;
4
+ input: string;
5
+ positive: string;
6
+ negative: string;
7
+ };
8
+ export declare function restrictedCounts(m: Machine, selected?: readonly string[], cap?: number, memberKey?: string): {
9
+ machine: Machine;
10
+ entries: Restriction[];
11
+ };
@@ -0,0 +1,31 @@
1
+ // Fresh conservative count definitions for opt-in proof strategies.
2
+ // Pure definitions only: original fields, transitions and counts are unchanged.
3
+ import { get, n, not, x } from "./machine.js";
4
+ import { substE } from "../kernel/kernel.js";
5
+ export function restrictedCounts(m, selected = Object.keys(m.counts ?? {}), cap = 32, memberKey) {
6
+ if (!Number.isSafeInteger(cap) || cap < 0 || cap > 128)
7
+ throw Error('invalid restricted-count cap');
8
+ const entries = [], added = {}, occupied = new Set([...Object.keys(m.counts ?? {}), ...Object.keys(m.maps ?? {}), ...(m.inputMaps ?? []), ...Object.keys(m.state)]);
9
+ for (const base of new Set(selected)) {
10
+ const source = m.counts?.[base];
11
+ if (!source)
12
+ continue;
13
+ if (memberKey && memberKey !== source.key && JSON.stringify(source).includes(JSON.stringify(memberKey)))
14
+ throw Error('restricted-count binder capture');
15
+ const definition = memberKey && memberKey !== source.key ? { ...source, key: memberKey, body: substE(source.body, { vars: { [source.key]: x(memberKey) }, maps: {}, flags: {} }) } : source;
16
+ for (const input of new Set(m.inputMaps ?? [])) {
17
+ if (entries.length >= cap)
18
+ break;
19
+ const positive = `${base}$restricted$${input}`, negative = `${positive}$not`;
20
+ if (occupied.has(positive) || occupied.has(negative))
21
+ throw Error('restricted-count name collision');
22
+ occupied.add(positive);
23
+ occupied.add(negative);
24
+ const guard = { op: '<', a: n(0), b: get(input, x(definition.key)) };
25
+ added[positive] = { ...definition, body: { op: 'if', c: guard, then: definition.body, else: n(0) } };
26
+ added[negative] = { ...definition, body: { op: 'if', c: not(guard), then: definition.body, else: n(0) } };
27
+ entries.push({ base, input, positive, negative });
28
+ }
29
+ }
30
+ return { machine: entries.length ? { ...m, counts: { ...m.counts, ...added } } : m, entries };
31
+ }
@@ -0,0 +1,67 @@
1
+ import { type WorkLedger } from './work-admission.js';
2
+ import { type WorkAmount } from './work-amount.js';
3
+ export declare const countRetryFuel = 6;
4
+ export type CountAttemptResult = 'unfinished' | 'proposal' | 'decline' | 'hard-cap';
5
+ export declare class CountAttemptTickets {
6
+ private left;
7
+ private active;
8
+ private ended;
9
+ private runs;
10
+ constructor(retries?: number);
11
+ start(): boolean;
12
+ finish(result: CountAttemptResult): void;
13
+ snapshot(): Readonly<{
14
+ remaining: number;
15
+ started: number;
16
+ active: boolean;
17
+ terminal: boolean;
18
+ }>;
19
+ }
20
+ export type CountSlice = Readonly<{
21
+ key: string;
22
+ allocation: WorkAmount;
23
+ scopeId: number;
24
+ rootEpoch: number;
25
+ caseKey?: string;
26
+ physicalKey?: string;
27
+ }>;
28
+ export type CountAttemptStop = Readonly<{
29
+ kind: 'soft-slice';
30
+ key: string;
31
+ allocation: WorkAmount;
32
+ scopeId: number;
33
+ rootEpoch: number;
34
+ caseKey?: string;
35
+ physicalKey?: string;
36
+ }> | Readonly<{
37
+ kind: 'hard-cap';
38
+ reason: 'unclassified' | 'enclosing-limit' | 'scope-entry';
39
+ error: unknown;
40
+ }>;
41
+ export declare function countAttemptStop(error: unknown, slices: readonly CountSlice[], bank?: WorkLedger): CountAttemptStop;
42
+ export type CountRetryKey = Readonly<{
43
+ key: string;
44
+ allocation: WorkAmount;
45
+ used: WorkAmount;
46
+ }>;
47
+ export type CountRetryHeadroom = Readonly<{
48
+ scope: string;
49
+ remaining: WorkAmount;
50
+ }>;
51
+ export type CountRetryFunding = Readonly<{
52
+ key: string;
53
+ amount: WorkAmount;
54
+ }>;
55
+ export type CountRetryPlan = Readonly<{
56
+ kind: 'admitted';
57
+ need: WorkAmount;
58
+ keys: readonly CountRetryKey[];
59
+ funding?: readonly CountRetryFunding[];
60
+ rootEpoch: number;
61
+ }> | Readonly<{
62
+ kind: 'refused';
63
+ reason: 'hard-cap' | 'unknown-key' | 'changed-slice' | 'headroom' | 'missing-root';
64
+ scope?: string;
65
+ need?: WorkAmount;
66
+ }>;
67
+ export declare function planCountRetry(keys: readonly CountRetryKey[], stop: CountAttemptStop, headrooms: readonly CountRetryHeadroom[], bank?: WorkLedger): CountRetryPlan;
@@ -0,0 +1,114 @@
1
+ // Section46 admission metadata, not proof authority. The inventory is fixed per
2
+ // pass; no result can mint another recipe instance or replenish its tickets.
3
+ import { workLedger } from "./work-admission.js";
4
+ import { compareWork, workAdd, workAmount, workShare } from "./work-amount.js";
5
+ export const countRetryFuel = 6;
6
+ export class CountAttemptTickets {
7
+ left;
8
+ active = false;
9
+ ended = false;
10
+ runs = 0;
11
+ constructor(retries = countRetryFuel) {
12
+ if (!Number.isSafeInteger(retries) || retries < 0 || retries > countRetryFuel)
13
+ throw new RangeError('invalid retry fuel');
14
+ this.left = retries + 1;
15
+ }
16
+ start() {
17
+ if (this.active || this.ended || this.left === 0)
18
+ return false;
19
+ this.left--;
20
+ this.runs++;
21
+ this.active = true;
22
+ return true;
23
+ }
24
+ finish(result) {
25
+ if (!this.active)
26
+ throw new Error('attempt result without a started ticket');
27
+ this.active = false;
28
+ if (result !== 'unfinished' || this.left === 0)
29
+ this.ended = true;
30
+ }
31
+ snapshot() {
32
+ return Object.freeze({ remaining: this.left, started: this.runs, active: this.active, terminal: this.ended });
33
+ }
34
+ }
35
+ export function countAttemptStop(error, slices, bank = workLedger) {
36
+ if (slices.length > 64 || !bank.inBudget())
37
+ return { kind: 'hard-cap', reason: 'unclassified', error };
38
+ const refusal = bank.capacityRefusal(error);
39
+ if (!refusal)
40
+ return { kind: 'hard-cap', reason: 'unclassified', error };
41
+ if (refusal.reason === 'scope-entry')
42
+ return { kind: 'hard-cap', reason: 'scope-entry', error };
43
+ // An equally limiting enclosing scope wins over a soft slice. Never infer a
44
+ // slice from phase text, a clock subtraction, or the last event observed.
45
+ if (refusal.limiting.length === 1 && refusal.limiting[0].kind === 'scope') {
46
+ const rootEpoch = bank.snapshot().rootEpoch;
47
+ const matches = slices.filter(slice => slice.scopeId === refusal.limiting[0].id && slice.rootEpoch === rootEpoch);
48
+ if (matches.length === 1 && validAmount(matches[0].allocation, true)) {
49
+ const slice = matches[0];
50
+ return { kind: 'soft-slice', key: slice.key, allocation: slice.allocation, scopeId: slice.scopeId, rootEpoch: slice.rootEpoch, ...(slice.caseKey !== undefined ? { caseKey: slice.caseKey } : {}), ...(slice.physicalKey !== undefined ? { physicalKey: slice.physicalKey } : {}) };
51
+ }
52
+ }
53
+ return { kind: 'hard-cap', reason: 'enclosing-limit', error };
54
+ }
55
+ const numericLimit = 1n << 4096n;
56
+ const validAmount = (a, positive = false) => a.den > 0n && a.den <= numericLimit && a.num <= numericLimit && (positive ? a.num > 0n : a.num >= 0n);
57
+ export function planCountRetry(keys, stop, headrooms, bank = workLedger) {
58
+ // Preparation is paid separately, before the atomic admission decision.
59
+ // Refusing a prepared round starts no strategy body or ticket.
60
+ bank.start('ticks', 1, 'count retry metadata header');
61
+ if (keys.length === 0 || keys.length > 64 || headrooms.length > 64)
62
+ throw new RangeError('unbounded retry metadata');
63
+ const names = new Set();
64
+ for (let i = 0; i < keys.length; i++) {
65
+ bank.start('ticks', 1, 'count retry key validation');
66
+ const key = keys[i];
67
+ if (!key.key || key.key.length > 256 || names.has(key.key) || !validAmount(key.allocation, true) || !validAmount(key.used))
68
+ throw new RangeError('invalid retry key');
69
+ names.add(key.key);
70
+ }
71
+ for (let i = 0; i < headrooms.length; i++) {
72
+ bank.start('ticks', 1, 'count retry ancestor validation');
73
+ if (!validAmount(headrooms[i].remaining))
74
+ throw new RangeError('invalid retry headroom');
75
+ }
76
+ if (stop.kind !== 'soft-slice')
77
+ return { kind: 'refused', reason: 'hard-cap' };
78
+ let raised;
79
+ for (let i = 0; i < keys.length; i++) {
80
+ bank.start('ticks', 1, 'count retry key selection');
81
+ if (keys[i].key === stop.key)
82
+ raised = keys[i];
83
+ }
84
+ if (!raised)
85
+ return { kind: 'refused', reason: 'unknown-key' };
86
+ if (compareWork(raised.allocation, stop.allocation) !== 0)
87
+ return { kind: 'refused', reason: 'changed-slice' };
88
+ const next = [], funding = [];
89
+ let need = workAmount(0n);
90
+ for (let i = 0; i < keys.length; i++) {
91
+ bank.start('ticks', 1, 'count retry allowance preparation');
92
+ const key = keys[i];
93
+ const allocation = key === raised ? workShare(key.allocation, 2n, 1n) : key.allocation;
94
+ // D F4(a): funding for repeated work is not a new per-key cap. In
95
+ // particular aggregate leaf use must not enlarge every individual leaf.
96
+ const contribution = key === raised ? allocation : compareWork(key.allocation, key.used) < 0 ? key.used : key.allocation;
97
+ next.push(Object.freeze({ key: key.key, allocation, used: workAmount(0n) }));
98
+ funding.push(Object.freeze({ key: key.key, amount: contribution }));
99
+ need = workAdd(need, contribution);
100
+ }
101
+ const live = bank.available();
102
+ if (live === null || !bank.inBudget() || stop.rootEpoch !== bank.snapshot().rootEpoch)
103
+ return { kind: 'refused', reason: 'missing-root', need };
104
+ for (let i = 0; i < headrooms.length; i++) {
105
+ bank.start('ticks', 1, 'count retry ancestor comparison');
106
+ const boundary = headrooms[i];
107
+ if (compareWork(need, boundary.remaining) > 0)
108
+ return { kind: 'refused', reason: 'headroom', scope: boundary.scope, need };
109
+ }
110
+ const remaining = bank.available();
111
+ if (compareWork(need, remaining) > 0)
112
+ return { kind: 'refused', reason: 'headroom', scope: 'effective-ledger', need };
113
+ return Object.freeze({ kind: 'admitted', need, keys: Object.freeze(next), funding: Object.freeze(funding), rootEpoch: stop.rootEpoch });
114
+ }
@@ -0,0 +1,24 @@
1
+ import { type WorkLedger } from './work-admission.js';
2
+ import { CountAttemptTickets, type CountAttemptStop, type CountRetryPlan, type CountSlice } from './count-retry-budget.js';
3
+ export type CountRoundValue<T> = Readonly<{
4
+ kind: 'proposal';
5
+ value: T;
6
+ }> | Readonly<{
7
+ kind: 'decline';
8
+ reason: string;
9
+ }>;
10
+ export type CountRoundResult<T> = CountRoundValue<T> | Readonly<{
11
+ kind: 'unfinished';
12
+ stop: CountAttemptStop;
13
+ }> | Readonly<{
14
+ kind: 'hard-cap';
15
+ stop: CountAttemptStop;
16
+ }> | Readonly<{
17
+ kind: 'not-started';
18
+ reason: string;
19
+ }>;
20
+ export declare function runCountRetryRound<T>(plan: CountRetryPlan, tickets: CountAttemptTickets, run: () => CountRoundValue<T>, options?: {
21
+ bank?: WorkLedger;
22
+ slices?: readonly CountSlice[];
23
+ eligible?: () => boolean;
24
+ }): CountRoundResult<T>;
@@ -0,0 +1,44 @@
1
+ // Atomic admission of a prepared retry. Metadata preparation is already paid;
2
+ // this boundary does not start a ticket or a callback when the live bank refuses.
3
+ import { BudgetExpired, workLedger } from "./work-admission.js";
4
+ import { countAttemptStop } from "./count-retry-budget.js";
5
+ export function runCountRetryRound(plan, tickets, run, options = {}) {
6
+ if (plan.kind === 'refused')
7
+ return { kind: 'not-started', reason: plan.reason };
8
+ const bank = options.bank ?? workLedger;
9
+ if (!bank.inBudget() || plan.rootEpoch !== bank.snapshot().rootEpoch)
10
+ return { kind: 'not-started', reason: 'missing-root' };
11
+ if (tickets.snapshot().terminal || tickets.snapshot().active)
12
+ return { kind: 'not-started', reason: 'tickets' };
13
+ try {
14
+ bank.checkAmount(plan.need, 'count retry admission');
15
+ }
16
+ catch (error) {
17
+ if (error instanceof BudgetExpired)
18
+ return { kind: 'not-started', reason: 'headroom' };
19
+ throw error;
20
+ }
21
+ return bank.withBudget(plan.need, () => {
22
+ if (options.eligible && !options.eligible())
23
+ return { kind: 'not-started', reason: 'ineligible' };
24
+ // Ticket commitment and user code are inside the already funded round. Any
25
+ // failure of this bookkeeping quantum is hard and starts no user callback.
26
+ bank.start('ticks', 1, 'count retry ticket commitment');
27
+ if (!tickets.start())
28
+ return { kind: 'not-started', reason: 'tickets' };
29
+ try {
30
+ const value = run();
31
+ tickets.finish(value.kind);
32
+ return value;
33
+ }
34
+ catch (error) {
35
+ if (!(error instanceof BudgetExpired)) {
36
+ tickets.finish('hard-cap');
37
+ throw error;
38
+ }
39
+ const stop = countAttemptStop(error, options.slices ?? [], bank);
40
+ tickets.finish(stop.kind === 'soft-slice' ? 'unfinished' : 'hard-cap');
41
+ return stop.kind === 'soft-slice' ? { kind: 'unfinished', stop } : { kind: 'hard-cap', stop };
42
+ }
43
+ });
44
+ }
@@ -0,0 +1,35 @@
1
+ import { type E, type Law, type Machine } from './machine.js';
2
+ import { type RowAgreementShape } from './row-agreement-shape.js';
3
+ import { type CountRequestBuilder, type CountStrategyOptions, type CountStrategyProof } from './count-strategy.js';
4
+ import { type CountCert, type Goal, type Instances, type Path } from '../kernel/kernel.js';
5
+ export declare function rowAgreementWrittenKeys(m: Machine, shape: RowAgreementShape): string[];
6
+ export type RowAgreementTrace = {
7
+ stage: 'leaf';
8
+ outcome: string;
9
+ goal: Goal;
10
+ path: Path;
11
+ hyps?: number;
12
+ units?: number;
13
+ wallMs?: number;
14
+ witness?: Record<string, number>;
15
+ method?: 'linear' | 'cdcl' | 'symmetry';
16
+ symmetryEnabled?: boolean;
17
+ };
18
+ export type RowAgreementOptions = CountStrategyOptions & {
19
+ premiseScoped?: boolean;
20
+ observe?: (trace: RowAgreementTrace) => void;
21
+ seedInstances?: Instances;
22
+ onlySeededPremises?: boolean;
23
+ witnessFlags?: boolean;
24
+ fastClosure?: boolean;
25
+ symmetryReuse?: boolean;
26
+ diagonalFirst?: boolean;
27
+ sparseOwn?: boolean;
28
+ operationPath?: boolean;
29
+ diagonalAlias?: boolean;
30
+ framePremisesOnly?: boolean;
31
+ ownRows?: E[];
32
+ premiseRows?: E[];
33
+ };
34
+ export declare function proposeRowAgreementInitial(m: Machine, family: Law[], law: Law, until: number, requestFor: CountRequestBuilder): CountCert | undefined;
35
+ export declare function proveRowAgreementCase(m: Machine, family: Law[], law: Law, shape: RowAgreementShape, until: number, requestFor: CountRequestBuilder, options?: RowAgreementOptions): CountStrategyProof | undefined;