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,54 @@
1
+ import { type CountStrategyOptions } from './count-strategy.js';
2
+ import { type WorkAmount } from './work-amount.js';
3
+ import { type CountFundingOwners } from './count-disjoint-funding.js';
4
+ export type LiftedWorkSlice = Readonly<{
5
+ kind: 'case' | 'leaf';
6
+ key: string;
7
+ caseKey?: string;
8
+ allocation: WorkAmount;
9
+ scopeId: number;
10
+ rootEpoch: number;
11
+ }>;
12
+ export type LiftedWorkSliceObserver = (slice: LiftedWorkSlice) => void;
13
+ export type LiftedWorkTraceEvent = Readonly<{
14
+ stage: 'start';
15
+ slice: LiftedWorkSlice;
16
+ }> | Readonly<{
17
+ stage: 'end';
18
+ slice: LiftedWorkSlice;
19
+ used: WorkAmount;
20
+ completed: boolean;
21
+ error?: unknown;
22
+ }>;
23
+ export type LiftedWorkTrace = (event: LiftedWorkTraceEvent) => void;
24
+ export declare function withLiftedWorkSliceObservation<T>(observe: LiftedWorkSliceObserver, run: () => T): T;
25
+ export type LiftedLeasePlan = Readonly<{
26
+ original: WorkAmount;
27
+ leaf: WorkAmount;
28
+ operation: WorkAmount;
29
+ cases: Readonly<Record<string, WorkAmount>>;
30
+ observe?: LiftedWorkSliceObserver;
31
+ trace?: LiftedWorkTrace;
32
+ owners?: CountFundingOwners;
33
+ }>;
34
+ export type LiftedWorkBudget = Readonly<{
35
+ workAllowance: number;
36
+ leafUnits: number;
37
+ caseUnits: number;
38
+ full: boolean;
39
+ lease?: LiftedLeasePlan;
40
+ }>;
41
+ export declare function liftedWorkBudget(workAllowance: number, full?: boolean): LiftedWorkBudget;
42
+ export declare const liftedDeadline: (now: number, parent: number, units: number) => number;
43
+ export declare function liftedLeafUntil(until: number, options: CountStrategyOptions, legacy?: number): number;
44
+ export declare function liftedCaseUntil(until: number, budget: LiftedWorkBudget, frame?: boolean): number;
45
+ export declare function liftedWorkLeaseBudget(original: WorkAmount, overrides?: {
46
+ leaf?: WorkAmount;
47
+ cases?: Readonly<Record<string, WorkAmount>>;
48
+ observe?: LiftedWorkSliceObserver;
49
+ trace?: LiftedWorkTrace;
50
+ owners?: CountFundingOwners;
51
+ }): LiftedWorkBudget;
52
+ export declare function withLiftedLeaf<T>(until: number, options: CountStrategyOptions, legacy: number, key: string, run: (until: number) => T): T;
53
+ export declare function withLiftedCase<T>(until: number, budget: LiftedWorkBudget, frame: boolean, key: string, run: (until: number) => T): T;
54
+ export declare function liftedLeaseOptions(budget: LiftedWorkBudget, caseKey: string): Pick<CountStrategyOptions, 'leafUnits' | 'leafWork' | 'caseKey' | 'workSliceObserver' | 'workSliceTrace' | 'workOwners'>;
@@ -0,0 +1,97 @@
1
+ // W is the original enclosing CLOCK-unit allowance, not a remaining case share.
2
+ // Divide once: every local leaf uses W/120, every operation uses W/30, and
3
+ // both are clipped to the caller's absolute endpoint. Legacy search is exact.
4
+ import { completeWorkProfile } from "./work-profile.js";
5
+ import { strategyLeafUnits } from "./count-strategy.js";
6
+ import { clock } from "../kernel/prove.js";
7
+ import { countPrimitiveUnits } from "./count-primitive-budget.js";
8
+ import { workShare, workSub } from "./work-amount.js";
9
+ import { remainingAdmittedWork, workAdmissionSnapshot, workLedger } from "./work-admission.js";
10
+ let sliceObserver;
11
+ export function withLiftedWorkSliceObservation(observe, run) { const prior = sliceObserver; sliceObserver = observe; try {
12
+ return run();
13
+ }
14
+ finally {
15
+ sliceObserver = prior;
16
+ } }
17
+ export function liftedWorkBudget(workAllowance, full = completeWorkProfile.enabled) {
18
+ if (full && (!Number.isFinite(workAllowance) || workAllowance < 0))
19
+ throw new RangeError('invalid lifted work allowance');
20
+ return Object.freeze({ workAllowance, leafUnits: full ? strategyLeafUnits(workAllowance) : 500, caseUnits: full ? workAllowance / 30 : 2000, full });
21
+ }
22
+ export const liftedDeadline = (now, parent, units) => Math.min(parent, now + Math.max(0, units));
23
+ export function liftedLeafUntil(until, options, legacy = 500) {
24
+ return liftedDeadline(clock(), until, countPrimitiveUnits(legacy, options.leafUnits));
25
+ }
26
+ export function liftedCaseUntil(until, budget, frame = false) {
27
+ return liftedDeadline(clock(), until, countPrimitiveUnits(frame ? 500 : 2000, budget.caseUnits));
28
+ }
29
+ // Explicit opt-in. These amounts are RAW work from the original grant, never
30
+ // decoded from clock(), remaining capacity or a telemetry display. Infinity is
31
+ // only the legacy-until sentinel inside a live exact child scope.
32
+ export function liftedWorkLeaseBudget(original, overrides = {}) {
33
+ if (!completeWorkProfile.enabled)
34
+ throw new Error('lifted work leases require FULL accounting');
35
+ const valid = (amount) => { if (amount.den <= 0n || amount.num < 0n)
36
+ throw new RangeError('invalid lifted work grant'); };
37
+ valid(original);
38
+ const leaf = overrides.leaf ?? workShare(original, 1n, 120n), operation = workShare(original, 1n, 30n), cases = Object.freeze({ ...overrides.cases });
39
+ valid(leaf);
40
+ for (const amount of Object.values(cases))
41
+ valid(amount);
42
+ return Object.freeze({ workAllowance: Infinity, leafUnits: Infinity, caseUnits: Infinity, full: true, lease: Object.freeze({ original, leaf, operation, cases, observe: overrides.observe, trace: overrides.trace, owners: overrides.owners }) });
43
+ }
44
+ function withLiftedSlice(kind, key, allocation, observe, run, caseKey, trace) {
45
+ if (!key)
46
+ throw new Error('lifted work slice requires a stable key');
47
+ if (!completeWorkProfile.enabled || remainingAdmittedWork() === null)
48
+ throw new Error('lifted work slice requires an inherited FULL endpoint');
49
+ const state = {};
50
+ try {
51
+ return workLedger.withBudget(allocation, () => {
52
+ const snapshot = workAdmissionSnapshot(), scope = snapshot.activeEndpoints.at(-1);
53
+ const slice = { kind, key, caseKey, allocation, scopeId: scope.id, rootEpoch: snapshot.rootEpoch };
54
+ if (!trace) {
55
+ observe?.(slice);
56
+ sliceObserver?.(slice);
57
+ return run(Infinity);
58
+ }
59
+ state.receipt = { slice, before: workLedger.actual(), completed: false };
60
+ trace({ stage: 'start', slice });
61
+ observe?.(slice);
62
+ sliceObserver?.(slice);
63
+ const result = run(Infinity);
64
+ state.receipt.completed = true;
65
+ return result;
66
+ });
67
+ }
68
+ catch (error) {
69
+ if (state.receipt) {
70
+ state.receipt.error = error;
71
+ state.receipt.completed = false;
72
+ }
73
+ throw error;
74
+ }
75
+ finally {
76
+ const receipt = state.receipt;
77
+ // Finish bookkeeping after the expired local slice has unwound, but inside
78
+ // its real parent/round. If that parent cannot pay, its hard stop wins.
79
+ // `used` is exact work inside the physical slice, not its exit metadata.
80
+ if (receipt)
81
+ trace({ stage: 'end', slice: receipt.slice, used: workSub(workLedger.actual(), receipt.before), completed: receipt.completed, ...(!receipt.completed ? { error: receipt.error } : {}) });
82
+ }
83
+ }
84
+ export function withLiftedLeaf(until, options, legacy, key, run) {
85
+ if (options.workOwners)
86
+ return options.workOwners.leaf(key, () => run(Infinity), options.caseKey);
87
+ return options.leafWork === undefined ? run(liftedLeafUntil(until, options, legacy)) : withLiftedSlice('leaf', key, options.leafWork, options.workSliceObserver, run, options.caseKey, options.workSliceTrace);
88
+ }
89
+ export function withLiftedCase(until, budget, frame, key, run) {
90
+ const plan = budget.lease;
91
+ if (plan?.owners)
92
+ return plan.owners.case(key, () => run(Infinity));
93
+ return plan === undefined ? run(liftedCaseUntil(until, budget, frame)) : withLiftedSlice('case', key, plan.cases[key] ?? plan.operation, plan.observe, run, undefined, plan.trace);
94
+ }
95
+ export function liftedLeaseOptions(budget, caseKey) {
96
+ return { leafUnits: budget.leafUnits, ...(budget.lease ? { leafWork: budget.lease.leaf, caseKey, workSliceObserver: budget.lease.observe, workSliceTrace: budget.lease.trace, workOwners: budget.lease.owners } : {}) };
97
+ }
@@ -0,0 +1,3 @@
1
+ import { type Law, type Machine } from './machine.js';
2
+ import { type CountRequestBuilder, type CountStrategyOptions, type CountStrategyProof } from './count-strategy.js';
3
+ export declare function proveLiftedCountCopy(m: Machine, family: Law[], law: Law, until: number, requestFor: CountRequestBuilder, observe?: (event: Record<string, unknown>) => void, options?: CountStrategyOptions): CountStrategyProof | undefined;
@@ -0,0 +1,166 @@
1
+ import { liftedLeafUntil, withLiftedLeaf } from "./count-lifted-budget.js";
2
+ import { FrameFactPool } from "./count-emitter-frame-pool.js";
3
+ // A row-copy STEP proposal from discovered source/target roles and the lifted
4
+ // law's own tuples. All transports are ordinary checked per-key linear facts.
5
+ import { atMost, n, not, same, walkOnce, x } from "./machine.js";
6
+ import { check, checkMC, countedObligations, frameOk, framePath, mcGoal, substE } from "../kernel/kernel.js";
7
+ import { deferIntermediateCountChecks } from "./count-strategy.js";
8
+ import { discoverLiftedCountGuard } from "./count-lifted-shape.js";
9
+ import { discoverCountRowCopy } from "./count-copy-shape.js";
10
+ import { proposeLiftedTransports } from "./count-lifted-transports.js";
11
+ import { countsForReads } from "./count-facts.js";
12
+ import { countFrameConditions, fixedCountFrameCase, ownCountLawInstance } from "./count-frames.js";
13
+ import { fullRate, fullWork, late, rowsAt, withDeadline } from "../kernel/prove.js";
14
+ import { growCdcl } from "../kernel/cdcl.js";
15
+ import { add, k, scale, solve } from "./solver.js";
16
+ import { countGuardTree } from "./count-guard-tree.js";
17
+ import { inlineFrozenGuard } from "./count-frozen-guard.js";
18
+ import { guardLinearFact } from "./count-guard-facts.js";
19
+ import { rebasePath } from "./count-rebase-path.js";
20
+ import { replayLinearSkeleton } from "./count-replay-skeleton.js";
21
+ import { stabilizeGuardedTree } from "./count-stabilize-tree.js";
22
+ const json = (value) => JSON.stringify(value);
23
+ export function proveLiftedCountCopy(m, family, law, until, requestFor, observe, options = {}) {
24
+ if (!family.includes(law))
25
+ return;
26
+ return withDeadline(until, () => {
27
+ const deferred = deferIntermediateCountChecks(options), accepts = (...args) => deferred || check(...args);
28
+ const shape = discoverLiftedCountGuard(m, law, family), choice = fixedCountFrameCase(m), copy = shape && choice && discoverCountRowCopy(m, shape.countShape, choice);
29
+ if (!shape || !choice || !copy || !m.pre || late(until))
30
+ return;
31
+ const stopped = {}, decline = (reason) => { observe?.({ stage: 'copy-decline', reason }); throw stopped; };
32
+ let framePool;
33
+ try {
34
+ const from = x(copy.from), to = x(copy.to), a = x(law.forall + '#'), b = x(law.keys[0]), transportRegions = proposeLiftedTransports(m, family, law, choice.value);
35
+ if (transportRegions?.length !== 4)
36
+ return decline('transport-plan');
37
+ const tuples = transportRegions[0].tuples, instances = ownCountLawInstance(law, {});
38
+ instances[law.name] = tuples.flat();
39
+ const packet = (terms) => countedObligations(m, family, { [law.name]: { [law.name]: terms } }, family.indexOf(law)).at(-1);
40
+ const step = packet(instances[law.name]), reads = requestFor(step.goal, step.decls).reads, counts = countsForReads(step.decls, reads);
41
+ if (!counts)
42
+ return decline('counts');
43
+ const targetMaps = new Set(shape.countMaps), postReads = reads.filter(read => read[1].endsWith('#') && targetMaps.has(read[1].slice(0, -1)));
44
+ const read = (map, key) => reads.find(r => r[1] === map && json(r[2]) === json(key))?.[0] ?? decline('missing-copy-read');
45
+ const bound = m.counts?.[shape.origin.rowCount]?.below;
46
+ if (!bound)
47
+ return decline('bound');
48
+ let prefix = 'rowCopy$';
49
+ const scope = json([m, family, reads]);
50
+ while (scope.includes(prefix))
51
+ prefix = '$' + prefix;
52
+ const caseInsts = transportRegions.map((region, i) => postReads.flatMap(([post, map, key], j) => {
53
+ const vars = Object.fromEntries([law.forall + '#', ...law.keys].map((name, index) => [name, region.activeTuple[index]])), targetKey = substE(key, { vars, maps: {}, flags: {} });
54
+ const relation = region.relations.find(relation => relation.post[1] === map && json(relation.post[2]) === json(key) && relation.target?.[1] === map.slice(0, -1) && json(relation.target[2]) === json(targetKey));
55
+ if (!relation?.target || relation.kind === 'zero')
56
+ return decline('unmatched-copy-transport');
57
+ const pre = read(relation.target[1], relation.target[2]), forward = { wit: prefix + i + '$' + j, below: bound, terms: [[1, post], [-1, pre]], unit: 0 };
58
+ return relation.kind === 'equality' ? [forward, { ...forward, wit: forward.wit + '$reverse', terms: [[1, pre], [-1, post]] }] : [forward];
59
+ }));
60
+ observe?.({ stage: 'copy-match', regions: transportRegions.length, tuples: tuples.length, relations: caseInsts.map(group => group.length) });
61
+ const unique = new Map();
62
+ for (const group of caseInsts)
63
+ for (let i = 0; i < group.length; i++) {
64
+ const inst = group[i], key = json(inst.terms), old = unique.get(key);
65
+ if (old)
66
+ group[i] = old;
67
+ else
68
+ unique.set(key, inst);
69
+ }
70
+ const request = { reads, insts: [], picks: [] }, goal = mcGoal(step.goal.hyps, step.decls, request);
71
+ if (!goal)
72
+ return decline('encoding');
73
+ const countMaps = new Set(step.decls.map(decl => decl.map)), scalarHyps = step.goal.hyps.filter(hyp => { let counted = false; walkOnce(hyp, (node) => { if (node.op === 'get' && countMaps.has(node.map))
74
+ counted = true; }); return !counted; }), caseHyps = tuples.map(tuple => packet(tuple).goal.hyps);
75
+ const frames = [], lins = [], facts = new Map(), linearCases = new Set(), composed = new Map(), roots = new Map();
76
+ const active = inlineFrozenGuard(m.step.flags ?? {}, copy.guard), domain = { op: 'and', xs: [a, b, from, to].flatMap(row => [{ op: '<', a: row, b: bound }, { op: '<', a: row, b: n(shape.origin.width) }]) };
77
+ const ask = (path, index, frame = false, stage = 'case') => {
78
+ if (late(until))
79
+ return;
80
+ if (frame)
81
+ for (const [post, map, key] of postReads) {
82
+ const cut = { post, pre: read(map.slice(0, -1), key), when: [...path.values()].map(atom => atom.holds ? atom.lin : add(scale(atom.lin, -1), k(1))) };
83
+ if (options.emitterFramePool) {
84
+ (framePool ??= new FrameFactPool(counts, frames, until)).offer(cut);
85
+ }
86
+ else if (frameOk(counts, cut))
87
+ frames.push(cut);
88
+ }
89
+ const root = framePath(frames, [], path, [], lins), view = mcGoal(stage === 'fact' ? scalarHyps : caseHyps[index], step.decls, request), before = fullWork(), remember = (tree) => { roots.set(tree, new Map(root)); return tree; };
90
+ return withLiftedLeaf(until, options, 500, 'leaf:copy:' + stage + ':' + index, deadline => {
91
+ if (!view)
92
+ return;
93
+ const cached = composed.get(index);
94
+ if (cached && stage === 'linear-composed') {
95
+ const end = options.leafWork ? deadline : liftedLeafUntil(deadline, options, 25), tree = rebasePath(goal, cached.tree, cached.path, root, end, goal) ?? replayLinearSkeleton(goal, cached.tree, root, end, { deferCheck: deferred });
96
+ if (tree && accepts(goal, tree, root)) {
97
+ observe?.({ stage, index, reused: true, units: (fullWork() - before) / fullRate });
98
+ return remember(tree);
99
+ }
100
+ }
101
+ const direct = solve(rowsAt(view, root), 1000);
102
+ if (direct.kind === 'refuted') {
103
+ const tree = rebasePath(view, { leaf: direct.steps }, root, root, deadline, goal);
104
+ if (tree && !late(until))
105
+ return remember(tree);
106
+ }
107
+ const result = growCdcl(view, root, { nodes: 0, until: deadline }), tree = 'tree' in result ? rebasePath(view, result.tree, root, root, deadline, goal) : undefined;
108
+ observe?.({ stage, index, checked: !!tree, units: (fullWork() - before) / fullRate, ...(!('tree' in result) ? { outcome: result.stuck, witness: result.witness } : {}) });
109
+ if (!tree || late(until))
110
+ return;
111
+ if (stage === 'linear-composed' && accepts(goal, tree, root))
112
+ composed.set(index, { tree, path: root });
113
+ return remember(tree);
114
+ });
115
+ };
116
+ const transport = (path, index) => {
117
+ if (!linearCases.has(index)) {
118
+ for (const inst of caseInsts[index]) {
119
+ const dependencies = new Set();
120
+ for (const [, id] of inst.terms) {
121
+ const count = reads.find(read => read[0] === id);
122
+ if (count[1].endsWith('#'))
123
+ walkOnce(count[2], (node) => { if (node.op === 'var')
124
+ dependencies.add(node.name); });
125
+ }
126
+ const when = [m.pre, domain, active];
127
+ if (dependencies.has(law.forall + '#'))
128
+ when.push(index >= 2 ? same(a, to) : not(same(a, to)));
129
+ if (dependencies.has(law.keys[0]))
130
+ when.push(index % 2 ? same(b, to) : not(same(b, to)));
131
+ const key = json([inst.terms, when]);
132
+ if (facts.has(key))
133
+ continue;
134
+ const before = fullWork(), fact = withLiftedLeaf(until, options, 100, 'leaf:copy:transport:' + index, end => guardLinearFact(step.decls, reads, { name: 'row copy transport', kind: 'ordinary-copy', when, terms: inst.terms }, end, event => { if (event.outcome !== 'proof' && event.outcome !== 'proposal')
135
+ observe?.({ stage: 'copy-transport-failure', index, witness: event.witness, outcome: event.outcome }); }, 'grow', { deferCheck: deferred }));
136
+ observe?.({ stage: 'copy-transport', index, constructed: !!fact, checked: !!fact && fact.status !== 'unchecked', deferred: fact?.status === 'unchecked', units: (fullWork() - before) / fullRate });
137
+ if (!fact)
138
+ return;
139
+ facts.set(key, fact.cut);
140
+ lins.push(fact.cut);
141
+ }
142
+ linearCases.add(index);
143
+ }
144
+ return ask(path, index, false, 'linear-composed');
145
+ };
146
+ const split = countGuardTree(until), regions = (path) => split.condition(same(a, to), path, p => split.condition(same(b, to), p, q => transport(q, 3), q => transport(q, 2)), p => split.condition(same(b, to), p, q => transport(q, 1), q => transport(q, 0)));
147
+ const copies = (path) => split.condition(atMost(to, from), path, regions, regions);
148
+ const run = (path) => split.rows(countFrameConditions(choice), path, p => split.condition(domain, p, q => split.condition(active, q, copies, q => ask(q, 0, true)), q => ask(q, 0)), p => ask(p, 0));
149
+ const tree = split.condition(m.pre, new Map(), run, path => ask(path, 0, false, 'outside-pre'));
150
+ if (!tree)
151
+ return decline('tree');
152
+ const stable = stabilizeGuardedTree(goal, tree, frames, lins, roots, until, { deferCheck: deferred });
153
+ if (!stable.tree || late(until))
154
+ return decline('stabilization');
155
+ if (framePool)
156
+ observe?.({ stage: 'emitter-frame-pool', emitter: 'copy', ...framePool.stats() });
157
+ const cert = { ...request, frames, lins, tree: stable.tree };
158
+ return (options.deferToComposition || checkMC(step.goal.hyps, step.decls, cert)) && !late(until) ? { instances, certs: { [step.goal.name]: cert }, ...(deferred ? { status: 'unchecked' } : {}) } : undefined;
159
+ }
160
+ catch (error) {
161
+ if (error === stopped)
162
+ return;
163
+ throw error;
164
+ }
165
+ });
166
+ }
@@ -0,0 +1,3 @@
1
+ import { type Law, type Machine } from './machine.js';
2
+ import { type CountRequestBuilder, type CountStrategyOptions, type CountStrategyProof } from './count-strategy.js';
3
+ export declare function proveLiftedCountIncrement(m: Machine, family: Law[], law: Law, until: number, requestFor: CountRequestBuilder, observe?: (event: Record<string, unknown>) => void, options?: CountStrategyOptions): CountStrategyProof | undefined;
@@ -0,0 +1,146 @@
1
+ import { withLiftedLeaf } from "./count-lifted-budget.js";
2
+ import { FrameFactPool } from "./count-emitter-frame-pool.js";
3
+ // Conditional threshold-increment STEP proposal. Role discovery and the
4
+ // family's no-quorum premise select witnesses; only the native checker accepts.
5
+ import { all, atMost, get, less, n, plus, times, walkOnce, x } from "./machine.js";
6
+ import { checkMC, countedObligations, frameOk, framePath, mcGoal } from "../kernel/kernel.js";
7
+ import { deferIntermediateCountChecks } from "./count-strategy.js";
8
+ import { discoverLiftedCountGuard, discoverLiftedCountOperation } from "./count-lifted-shape.js";
9
+ import { discoverCountGuardShape } from "./count-guard-shape.js";
10
+ import { discoverLiftedCountPrerequisites } from "./count-lifted-prerequisite.js";
11
+ import { countFrameConditions, fixedCountFrameCase, ownCountLawInstance } from "./count-frames.js";
12
+ import { countsForReads } from "./count-facts.js";
13
+ import { matchLiftedCountBodies } from "./count-lifted-transports.js";
14
+ import { fullRate, fullWork, late, withDeadline } from "../kernel/prove.js";
15
+ import { growCdcl } from "../kernel/cdcl.js";
16
+ import { add, k, scale } from "./solver.js";
17
+ import { countGuardTree } from "./count-guard-tree.js";
18
+ import { inlineFrozenGuard } from "./count-frozen-guard.js";
19
+ import { minimalTransportView, minimalViewFirst } from "./count-minimal-view.js";
20
+ import { copyQueryContext } from "./count-query-context.js";
21
+ import { stabilizeGuardedTree } from "./count-stabilize-tree.js";
22
+ const json = (value) => JSON.stringify(value);
23
+ export function proveLiftedCountIncrement(m, family, law, until, requestFor, observe, options = {}) {
24
+ if (!family.includes(law))
25
+ return;
26
+ return withDeadline(until, () => {
27
+ const deferred = deferIntermediateCountChecks(options);
28
+ const shape = discoverLiftedCountGuard(m, law, family), choice = fixedCountFrameCase(m), operation = shape && choice && discoverLiftedCountOperation(m, shape, choice.value);
29
+ if (!shape || !choice || operation?.kind !== 'threshold-increment' || !('write' in operation) || !m.pre || late(until)) {
30
+ observe?.({ stage: 'increment-decline', reason: 'shape-or-operation' });
31
+ return;
32
+ }
33
+ const write = operation.write;
34
+ if (write.increment !== 1) {
35
+ observe?.({ stage: 'increment-decline', reason: 'nonincrement-write' });
36
+ return;
37
+ }
38
+ const stopped = {}, decline = (reason) => { observe?.({ stage: 'increment-decline', reason }); throw stopped; };
39
+ let framePool;
40
+ try {
41
+ const lower = discoverLiftedCountPrerequisites(m, law, family).flatMap(prerequisite => {
42
+ const found = discoverCountGuardShape(m, prerequisite.law, family);
43
+ if (!found || found.rowMap !== shape.origin.rowCount || found.memberField !== shape.countShape.memberField || found.thresholdField !== shape.countShape.thresholdField)
44
+ return [];
45
+ return [{ law: prerequisite.law, shape: found }];
46
+ });
47
+ if (lower.length !== 1)
48
+ return decline('no-unique-guarded-vote-premise');
49
+ const premise = lower[0], twins = new Set(shape.origin.twins.map(twin => twin.row)), votes = shape.countMaps.filter(map => map !== shape.origin.rowCount && !twins.has(map));
50
+ if (votes.length !== 1)
51
+ return decline('disabled-count');
52
+ const vote = votes[0], a = x(law.forall + '#'), b = x(law.keys[0]), actor = x(write.source), rowMap = shape.origin.rowCount;
53
+ let prefix = 'increment$';
54
+ const scope = json([m, family]);
55
+ while (scope.includes(prefix))
56
+ prefix = '$' + prefix;
57
+ const labels = Array.from({ length: 7 }, (_, index) => prefix + 'w' + index), instances = ownCountLawInstance(law, { [premise.law.name]: [actor, a, actor, b] });
58
+ const ownFlags = options.slicedLemmas ? (() => {
59
+ const ownFlags = new Set(), flagQueue = [write.guard];
60
+ walkOnce([m.pre, m.assume], (node) => { if (node.op === 'flag')
61
+ flagQueue.push(node.name); });
62
+ while (flagQueue.length) {
63
+ const name = flagQueue.pop();
64
+ if (ownFlags.has(name))
65
+ continue;
66
+ ownFlags.add(name);
67
+ walkOnce(m.step.flags?.[name], (node) => { if (node.op === 'flag')
68
+ flagQueue.push(node.name); });
69
+ }
70
+ observe?.({ stage: 'own-operation-flags', names: [...ownFlags].filter(name => m.step.flags?.[name]?.op === 'all').sort() });
71
+ return ownFlags;
72
+ })() : undefined;
73
+ for (const [name, flag] of Object.entries(m.step.flags ?? {}))
74
+ if (flag.op === 'all' && (!ownFlags || ownFlags.has(name)))
75
+ instances['?' + name] = labels.map(x);
76
+ const step = countedObligations(m, family, { [law.name]: instances }, family.indexOf(law)).at(-1), reads = [...requestFor(step.goal, step.decls).reads];
77
+ const bind = (map, key) => { const old = reads.find(read => read[1] === map && json(read[2]) === json(key)); if (old)
78
+ return old[0]; const id = prefix + 'r' + reads.length; reads.push([id, map, key]); return id; };
79
+ const pair = (left, right) => plus(times(shape.origin.width, left), right);
80
+ const row = countsForReads(step.decls, [[prefix + 'row', rowMap, actor]])?.[0], used = new Set();
81
+ walkOnce([m.pre, m.assume, m.step.flags?.[write.guard]], (node) => { if (node.op === 'get')
82
+ used.add(node.map); });
83
+ const aliases = Object.entries(m.counts ?? {}).filter(([map, definition]) => !definition.base && used.has(map)).flatMap(([map]) => { const count = countsForReads(step.decls, [[prefix + 'alias', map, n(0)]])?.[0]; return row && count && matchLiftedCountBodies(row, count) ? [map] : []; });
84
+ if (aliases.length !== 1)
85
+ return decline('no-unique-actor-row-count');
86
+ const S = bind(write.inputCount, n(0)), X = bind(aliases[0], n(0)), R = bind(rowMap, actor), V = bind(vote, actor), TA = bind(premise.shape.voteMap, pair(actor, a)), TB = bind(premise.shape.voteMap, pair(actor, b));
87
+ const beforeA = bind(vote, a), beforeB = bind(vote, b), afterA = bind(vote + '#', a), afterB = bind(vote + '#', b), counts = countsForReads(step.decls, reads), bound = counts?.find(count => count.v === S)?.below;
88
+ if (!counts || !bound)
89
+ return decline('count-reads');
90
+ const vectors = [[[1, X], [-1, R]], [[1, R], [-1, X]], [[1, S], [-1, V]], [[1, S], [-1, TA]], [[1, S], [-1, TB]], [[1, afterA], [-1, beforeA]], [[1, afterB], [-1, beforeB]]];
91
+ const insts = vectors.map((terms, index) => ({ wit: labels[index], below: bound, terms, unit: 0 })), request = { reads, insts, picks: [] }, goal = mcGoal(step.goal.hyps, step.decls, request);
92
+ if (!goal)
93
+ return decline('encoding');
94
+ const frames = [], roots = new Map();
95
+ observe?.({ stage: 'increment-premise', premise: premise.law.name, rowAlias: aliases[0], instances: insts.length });
96
+ const ask = (path, stage, index) => {
97
+ if (late(until))
98
+ return;
99
+ const root = framePath(frames, [], path), started = fullWork();
100
+ return withLiftedLeaf(until, options, 500, 'leaf:increment:' + stage + (index === undefined ? '' : ':' + index), end => {
101
+ const minimal = index === undefined ? { goal: mcGoal(copyQueryContext(step.goal.hyps, root, counts, insts, []), step.decls, { reads, insts: [], picks: [] }), path: root } : minimalTransportView(step.goal.hyps, step.decls, reads, insts, [insts[index]], root);
102
+ if (!minimal?.goal)
103
+ return;
104
+ const result = minimalViewFirst(goal, minimal.goal, root, end, growCdcl, minimal.path, { deferCheck: deferred }), tree = result.tree;
105
+ observe?.({ stage, index, checked: !!tree, hyps: minimal.goal.hyps.length, leafCap: late(end), units: (fullWork() - started) / fullRate, minimal: result.minimalKind, fullFallback: result.fallback, minimalUnits: result.minimalUnits, fallbackUnits: result.fallbackUnits, ...(result.witness ? { witness: result.witness } : {}) });
106
+ if (!tree || late(end))
107
+ return;
108
+ roots.set(tree, new Map(root));
109
+ return tree;
110
+ });
111
+ };
112
+ const frame = (path, every = false) => { for (const read of reads.filter(read => read[1].endsWith('#') && (every || read[1] !== vote + '#'))) {
113
+ const before = reads.find(old => old[1] === read[1].slice(0, -1) && json(old[2]) === json(read[2]));
114
+ if (!before)
115
+ continue;
116
+ const cut = { post: read[0], pre: before[0], when: [...path.values()].map(atom => atom.holds ? atom.lin : add(scale(atom.lin, -1), k(1))) };
117
+ if (options.emitterFramePool) {
118
+ (framePool ??= new FrameFactPool(counts, frames, until)).offer(cut);
119
+ }
120
+ else if (frameOk(counts, cut))
121
+ frames.push(cut);
122
+ } };
123
+ const split = countGuardTree(until, { yesFirst: true }), factRow = (index) => add(...insts[index].terms.map(([coefficient, id]) => ({ [id]: coefficient })));
124
+ const fact = (index, path, next) => split.rows([factRow(index)], path, next, branch => ask(branch, 'count-fact', index));
125
+ const finish = (path) => split.condition({ op: '=', a, b: actor }, path, left => fact(2, left, p => split.condition({ op: '=', a: b, b: actor }, p, q => ask(q, 'both-actor'), q => fact(6, q, r => ask(r, 'left-actor')))), left => fact(5, left, p => split.condition({ op: '=', a: b, b: actor }, p, q => fact(2, q, r => ask(r, 'right-actor')), q => fact(6, q, r => ask(r, 'neither-actor')))));
126
+ const term = (row, index, path, next) => split.condition(atMost(get(shape.countShape.thresholdField, row), get(shape.countShape.memberField, actor)), path, next, branch => fact(index, branch, p => ask(p, 'term-contradiction')));
127
+ const domain = all(...[a, b, actor].flatMap(row => [less(row, bound), less(row, n(shape.origin.width))])), active = inlineFrozenGuard(m.step.flags ?? {}, write.guard);
128
+ const run = (path) => split.rows(countFrameConditions(choice), path, p => split.condition(domain, p, q => { frame(q); return split.condition(active, q, r => fact(0, r, s => fact(1, s, t => term(a, 3, t, u => term(b, 4, u, finish)))), r => { frame(r, true); return ask(r, 'inactive'); }); }, q => ask(q, 'outside-domain')), p => ask(p, 'outside-operation'));
129
+ const tree = split.condition(m.pre, new Map(), run, path => ask(path, 'outside-pre'));
130
+ if (!tree)
131
+ return decline('tree');
132
+ const stable = stabilizeGuardedTree(goal, tree, frames, [], roots, until, { deferCheck: deferred });
133
+ if (!stable.tree || late(until))
134
+ return decline('stabilization');
135
+ if (framePool)
136
+ observe?.({ stage: 'emitter-frame-pool', emitter: 'increment', ...framePool.stats() });
137
+ const cert = { ...request, frames, tree: stable.tree };
138
+ return (options.deferToComposition || checkMC(step.goal.hyps, step.decls, cert)) && !late(until) ? { instances, certs: { [step.goal.name]: cert }, ...(deferred ? { status: 'unchecked' } : {}) } : undefined;
139
+ }
140
+ catch (error) {
141
+ if (error === stopped)
142
+ return;
143
+ throw error;
144
+ }
145
+ });
146
+ }
@@ -0,0 +1,5 @@
1
+ import { type Law, type Machine } from './machine.js';
2
+ import { type CountRequestBuilder, type CountStrategyProof, type CountStrategyOptions } from './count-strategy.js';
3
+ import { type Goal, type Path, type Tree } from '../kernel/kernel.js';
4
+ export declare function rebaseLiftedLoadCandidate(view: Goal, tree: Tree, root: Path, until: number, goal: Goal, options?: CountStrategyOptions): Tree | undefined;
5
+ export declare function proveLiftedCountLoad(m: Machine, family: Law[], law: Law, until: number, requestFor: CountRequestBuilder, observe?: (event: Record<string, unknown>) => void, options?: CountStrategyOptions): CountStrategyProof | undefined;