gdp-wired 0.47.0 → 0.49.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 (420) hide show
  1. package/README.md +17 -6
  2. package/dist/core/bmc.js +10 -7
  3. package/dist/core/carry.d.ts +15 -0
  4. package/dist/core/carry.js +651 -0
  5. package/dist/core/check.js +7 -2
  6. package/dist/core/cli.d.ts +3 -1
  7. package/dist/core/cli.js +28 -8
  8. package/dist/core/count-attempt-work.d.ts +29 -0
  9. package/dist/core/count-attempt-work.js +96 -0
  10. package/dist/core/count-boolean-partition.d.ts +5 -0
  11. package/dist/core/count-boolean-partition.js +47 -0
  12. package/dist/core/count-bounded-quotient.d.ts +2 -0
  13. package/dist/core/count-bounded-quotient.js +13 -0
  14. package/dist/core/count-case-compose.d.ts +20 -0
  15. package/dist/core/count-case-compose.js +289 -0
  16. package/dist/core/count-cases.d.ts +24 -0
  17. package/dist/core/count-cases.js +321 -0
  18. package/dist/core/count-cert-grow.d.ts +4 -0
  19. package/dist/core/count-cert-grow.js +37 -0
  20. package/dist/core/count-cert-rename.d.ts +10 -0
  21. package/dist/core/count-cert-rename.js +69 -0
  22. package/dist/core/count-cert-transport.d.ts +11 -0
  23. package/dist/core/count-cert-transport.js +109 -0
  24. package/dist/core/count-certificate-minimize.d.ts +57 -0
  25. package/dist/core/count-certificate-minimize.js +263 -0
  26. package/dist/core/count-closed-family.d.ts +32 -0
  27. package/dist/core/count-closed-family.js +143 -0
  28. package/dist/core/count-closing-budget.d.ts +10 -0
  29. package/dist/core/count-closing-budget.js +49 -0
  30. package/dist/core/count-closing-needs.d.ts +5 -0
  31. package/dist/core/count-closing-needs.js +9 -0
  32. package/dist/core/count-completion.d.ts +9 -0
  33. package/dist/core/count-completion.js +27 -0
  34. package/dist/core/count-component-budget.d.ts +5 -0
  35. package/dist/core/count-component-budget.js +9 -0
  36. package/dist/core/count-copy-shape.d.ts +11 -0
  37. package/dist/core/count-copy-shape.js +40 -0
  38. package/dist/core/count-cubes.d.ts +8 -0
  39. package/dist/core/count-cubes.js +69 -0
  40. package/dist/core/count-demand.d.ts +37 -0
  41. package/dist/core/count-demand.js +361 -0
  42. package/dist/core/count-disjoint-funding.d.ts +75 -0
  43. package/dist/core/count-disjoint-funding.js +284 -0
  44. package/dist/core/count-emitter-frame-pool.d.ts +23 -0
  45. package/dist/core/count-emitter-frame-pool.js +87 -0
  46. package/dist/core/count-facts.d.ts +52 -0
  47. package/dist/core/count-facts.js +247 -0
  48. package/dist/core/count-final-step.d.ts +5 -0
  49. package/dist/core/count-final-step.js +20 -0
  50. package/dist/core/count-fixed-frame.d.ts +4 -0
  51. package/dist/core/count-fixed-frame.js +30 -0
  52. package/dist/core/count-focus-proof.d.ts +8 -0
  53. package/dist/core/count-focus-proof.js +140 -0
  54. package/dist/core/count-focused.d.ts +22 -0
  55. package/dist/core/count-focused.js +676 -0
  56. package/dist/core/count-frames.d.ts +25 -0
  57. package/dist/core/count-frames.js +118 -0
  58. package/dist/core/count-frozen-guard.d.ts +2 -0
  59. package/dist/core/count-frozen-guard.js +31 -0
  60. package/dist/core/count-generation-phase.d.ts +7 -0
  61. package/dist/core/count-generation-phase.js +33 -0
  62. package/dist/core/count-guard-composition.d.ts +12 -0
  63. package/dist/core/count-guard-composition.js +48 -0
  64. package/dist/core/count-guard-context.d.ts +11 -0
  65. package/dist/core/count-guard-context.js +50 -0
  66. package/dist/core/count-guard-facts.d.ts +50 -0
  67. package/dist/core/count-guard-facts.js +97 -0
  68. package/dist/core/count-guard-proposals.d.ts +7 -0
  69. package/dist/core/count-guard-proposals.js +106 -0
  70. package/dist/core/count-guard-shape.d.ts +18 -0
  71. package/dist/core/count-guard-shape.js +100 -0
  72. package/dist/core/count-guard-tree.d.ts +17 -0
  73. package/dist/core/count-guard-tree.js +125 -0
  74. package/dist/core/count-leader-facts.d.ts +10 -0
  75. package/dist/core/count-leader-facts.js +52 -0
  76. package/dist/core/count-leader.d.ts +10 -0
  77. package/dist/core/count-leader.js +331 -0
  78. package/dist/core/count-lemma-transport.d.ts +8 -0
  79. package/dist/core/count-lemma-transport.js +47 -0
  80. package/dist/core/count-lifted-budget.d.ts +54 -0
  81. package/dist/core/count-lifted-budget.js +97 -0
  82. package/dist/core/count-lifted-copy.d.ts +3 -0
  83. package/dist/core/count-lifted-copy.js +166 -0
  84. package/dist/core/count-lifted-increment.d.ts +3 -0
  85. package/dist/core/count-lifted-increment.js +146 -0
  86. package/dist/core/count-lifted-load.d.ts +5 -0
  87. package/dist/core/count-lifted-load.js +179 -0
  88. package/dist/core/count-lifted-prerequisite.d.ts +14 -0
  89. package/dist/core/count-lifted-prerequisite.js +53 -0
  90. package/dist/core/count-lifted-replacement.d.ts +3 -0
  91. package/dist/core/count-lifted-replacement.js +540 -0
  92. package/dist/core/count-lifted-shape.d.ts +63 -0
  93. package/dist/core/count-lifted-shape.js +115 -0
  94. package/dist/core/count-lifted-strategy.d.ts +7 -0
  95. package/dist/core/count-lifted-strategy.js +226 -0
  96. package/dist/core/count-lifted-transports.d.ts +32 -0
  97. package/dist/core/count-lifted-transports.js +293 -0
  98. package/dist/core/count-load-shape.d.ts +17 -0
  99. package/dist/core/count-load-shape.js +67 -0
  100. package/dist/core/count-minimal-view.d.ts +26 -0
  101. package/dist/core/count-minimal-view.js +46 -0
  102. package/dist/core/count-operation-observation.d.ts +9 -0
  103. package/dist/core/count-operation-observation.js +22 -0
  104. package/dist/core/count-operation-order.d.ts +5 -0
  105. package/dist/core/count-operation-order.js +4 -0
  106. package/dist/core/count-phase.d.ts +9 -0
  107. package/dist/core/count-phase.js +127 -0
  108. package/dist/core/count-premise-search.d.ts +9 -0
  109. package/dist/core/count-premise-search.js +41 -0
  110. package/dist/core/count-premise-view.d.ts +19 -0
  111. package/dist/core/count-premise-view.js +220 -0
  112. package/dist/core/count-prerequisite-components.d.ts +67 -0
  113. package/dist/core/count-prerequisite-components.js +239 -0
  114. package/dist/core/count-prerequisite-memory.d.ts +24 -0
  115. package/dist/core/count-prerequisite-memory.js +37 -0
  116. package/dist/core/count-prerequisite-plan.d.ts +12 -0
  117. package/dist/core/count-prerequisite-plan.js +88 -0
  118. package/dist/core/count-primitive-budget.d.ts +1 -0
  119. package/dist/core/count-primitive-budget.js +8 -0
  120. package/dist/core/count-project-free.d.ts +3 -0
  121. package/dist/core/count-project-free.js +24 -0
  122. package/dist/core/count-project-witness.d.ts +4 -0
  123. package/dist/core/count-project-witness.js +48 -0
  124. package/dist/core/count-proof-rescope.d.ts +14 -0
  125. package/dist/core/count-proof-rescope.js +71 -0
  126. package/dist/core/count-proof-scope.d.ts +68 -0
  127. package/dist/core/count-proof-scope.js +333 -0
  128. package/dist/core/count-prune-owned-root.d.ts +5 -0
  129. package/dist/core/count-prune-owned-root.js +27 -0
  130. package/dist/core/count-query-context.d.ts +3 -0
  131. package/dist/core/count-query-context.js +7 -0
  132. package/dist/core/count-query.d.ts +15 -0
  133. package/dist/core/count-query.js +59 -0
  134. package/dist/core/count-quorum-leaf.d.ts +9 -0
  135. package/dist/core/count-quorum-leaf.js +38 -0
  136. package/dist/core/count-ranges.d.ts +5 -0
  137. package/dist/core/count-ranges.js +65 -0
  138. package/dist/core/count-reachability-budget.d.ts +1 -0
  139. package/dist/core/count-reachability-budget.js +7 -0
  140. package/dist/core/count-reachability-reconcile.d.ts +11 -0
  141. package/dist/core/count-reachability-reconcile.js +19 -0
  142. package/dist/core/count-reachability.d.ts +50 -0
  143. package/dist/core/count-reachability.js +351 -0
  144. package/dist/core/count-rebase-path.d.ts +9 -0
  145. package/dist/core/count-rebase-path.js +68 -0
  146. package/dist/core/count-recipe-context.d.ts +45 -0
  147. package/dist/core/count-recipe-context.js +71 -0
  148. package/dist/core/count-recipe-controller.d.ts +115 -0
  149. package/dist/core/count-recipe-controller.js +417 -0
  150. package/dist/core/count-recipe-graph.d.ts +36 -0
  151. package/dist/core/count-recipe-graph.js +211 -0
  152. package/dist/core/count-recovery/action-guard.d.ts +5 -0
  153. package/dist/core/count-recovery/action-guard.js +51 -0
  154. package/dist/core/count-recovery/boolean-core.d.ts +16 -0
  155. package/dist/core/count-recovery/boolean-core.js +258 -0
  156. package/dist/core/count-recovery/carried-case.d.ts +2 -0
  157. package/dist/core/count-recovery/carried-case.js +24 -0
  158. package/dist/core/count-recovery/conditional-check-cache.d.ts +23 -0
  159. package/dist/core/count-recovery/conditional-check-cache.js +131 -0
  160. package/dist/core/count-recovery/conditional-cuts.d.ts +6 -0
  161. package/dist/core/count-recovery/conditional-cuts.js +319 -0
  162. package/dist/core/count-recovery/conditional-proof.d.ts +53 -0
  163. package/dist/core/count-recovery/conditional-proof.js +348 -0
  164. package/dist/core/count-recovery/derivability-closure.d.ts +14 -0
  165. package/dist/core/count-recovery/derivability-closure.js +534 -0
  166. package/dist/core/count-recovery/empty-count-source.d.ts +2 -0
  167. package/dist/core/count-recovery/empty-count-source.js +40 -0
  168. package/dist/core/count-recovery/field-bound-lemmas.d.ts +23 -0
  169. package/dist/core/count-recovery/field-bound-lemmas.js +640 -0
  170. package/dist/core/count-recovery/field-case.d.ts +5 -0
  171. package/dist/core/count-recovery/field-case.js +89 -0
  172. package/dist/core/count-recovery/field-demand.d.ts +46 -0
  173. package/dist/core/count-recovery/field-demand.js +47 -0
  174. package/dist/core/count-recovery/field-only.d.ts +3 -0
  175. package/dist/core/count-recovery/field-only.js +18 -0
  176. package/dist/core/count-recovery/fold-path.d.ts +6 -0
  177. package/dist/core/count-recovery/fold-path.js +35 -0
  178. package/dist/core/count-recovery/frame-lemmas.d.ts +9 -0
  179. package/dist/core/count-recovery/frame-lemmas.js +120 -0
  180. package/dist/core/count-recovery/guard-cases.d.ts +12 -0
  181. package/dist/core/count-recovery/guard-cases.js +139 -0
  182. package/dist/core/count-recovery/key-closure.d.ts +14 -0
  183. package/dist/core/count-recovery/key-closure.js +62 -0
  184. package/dist/core/count-recovery/leaf-allowance.d.ts +4 -0
  185. package/dist/core/count-recovery/leaf-allowance.js +7 -0
  186. package/dist/core/count-recovery/lift-count-proxies.d.ts +6 -0
  187. package/dist/core/count-recovery/lift-count-proxies.js +175 -0
  188. package/dist/core/count-recovery/live-dependencies.d.ts +6 -0
  189. package/dist/core/count-recovery/live-dependencies.js +76 -0
  190. package/dist/core/count-recovery/member-inclusions.d.ts +11 -0
  191. package/dist/core/count-recovery/member-inclusions.js +168 -0
  192. package/dist/core/count-recovery/member-premises.d.ts +29 -0
  193. package/dist/core/count-recovery/member-premises.js +114 -0
  194. package/dist/core/count-recovery/natural-cases.d.ts +6 -0
  195. package/dist/core/count-recovery/natural-cases.js +59 -0
  196. package/dist/core/count-recovery/ops.d.ts +6 -0
  197. package/dist/core/count-recovery/ops.js +8 -0
  198. package/dist/core/count-recovery/pre-state-source.d.ts +8 -0
  199. package/dist/core/count-recovery/pre-state-source.js +18 -0
  200. package/dist/core/count-recovery/rebase-path.d.ts +9 -0
  201. package/dist/core/count-recovery/rebase-path.js +70 -0
  202. package/dist/core/count-recovery/reframe-tree.d.ts +2 -0
  203. package/dist/core/count-recovery/reframe-tree.js +24 -0
  204. package/dist/core/count-recovery/rename-proof.d.ts +2 -0
  205. package/dist/core/count-recovery/rename-proof.js +102 -0
  206. package/dist/core/count-recovery/replay-linear-skeleton.d.ts +2 -0
  207. package/dist/core/count-recovery/replay-linear-skeleton.js +28 -0
  208. package/dist/core/count-recovery/row-cases.d.ts +16 -0
  209. package/dist/core/count-recovery/row-cases.js +292 -0
  210. package/dist/core/count-recovery/scalar-guards.d.ts +7 -0
  211. package/dist/core/count-recovery/scalar-guards.js +291 -0
  212. package/dist/core/count-recovery/source-memo.d.ts +12 -0
  213. package/dist/core/count-recovery/source-memo.js +67 -0
  214. package/dist/core/count-rejection-budget.d.ts +8 -0
  215. package/dist/core/count-rejection-budget.js +15 -0
  216. package/dist/core/count-replacement.d.ts +5 -0
  217. package/dist/core/count-replacement.js +129 -0
  218. package/dist/core/count-replay-diagnostic.d.ts +21 -0
  219. package/dist/core/count-replay-diagnostic.js +49 -0
  220. package/dist/core/count-replay-skeleton.d.ts +4 -0
  221. package/dist/core/count-replay-skeleton.js +28 -0
  222. package/dist/core/count-rescope-funding.d.ts +3 -0
  223. package/dist/core/count-rescope-funding.js +17 -0
  224. package/dist/core/count-restrictions.d.ts +11 -0
  225. package/dist/core/count-restrictions.js +31 -0
  226. package/dist/core/count-retry-budget.d.ts +67 -0
  227. package/dist/core/count-retry-budget.js +114 -0
  228. package/dist/core/count-retry-round.d.ts +24 -0
  229. package/dist/core/count-retry-round.js +44 -0
  230. package/dist/core/count-row-agreement.d.ts +35 -0
  231. package/dist/core/count-row-agreement.js +270 -0
  232. package/dist/core/count-row-aliases.d.ts +3 -0
  233. package/dist/core/count-row-aliases.js +59 -0
  234. package/dist/core/count-row-composition.d.ts +6 -0
  235. package/dist/core/count-row-composition.js +55 -0
  236. package/dist/core/count-row-copy-linear.d.ts +4 -0
  237. package/dist/core/count-row-copy-linear.js +83 -0
  238. package/dist/core/count-row-copy.d.ts +4 -0
  239. package/dist/core/count-row-copy.js +94 -0
  240. package/dist/core/count-row-policy.d.ts +3 -0
  241. package/dist/core/count-row-policy.js +56 -0
  242. package/dist/core/count-row-reindex.d.ts +11 -0
  243. package/dist/core/count-row-reindex.js +126 -0
  244. package/dist/core/count-row-support.d.ts +9 -0
  245. package/dist/core/count-row-support.js +42 -0
  246. package/dist/core/count-row-symmetry.d.ts +7 -0
  247. package/dist/core/count-row-symmetry.js +100 -0
  248. package/dist/core/count-scope-hyps.d.ts +2 -0
  249. package/dist/core/count-scope-hyps.js +163 -0
  250. package/dist/core/count-scope-row-reuse.d.ts +3 -0
  251. package/dist/core/count-scope-row-reuse.js +92 -0
  252. package/dist/core/count-search-allowance.d.ts +1 -0
  253. package/dist/core/count-search-allowance.js +17 -0
  254. package/dist/core/count-select.d.ts +16 -0
  255. package/dist/core/count-select.js +24 -0
  256. package/dist/core/count-stabilize-tree.d.ts +9 -0
  257. package/dist/core/count-stabilize-tree.js +35 -0
  258. package/dist/core/count-stage-trace.d.ts +8 -0
  259. package/dist/core/count-stage-trace.js +45 -0
  260. package/dist/core/count-strategies.d.ts +16 -0
  261. package/dist/core/count-strategies.js +155 -0
  262. package/dist/core/count-strategy-premises.d.ts +5 -0
  263. package/dist/core/count-strategy-premises.js +14 -0
  264. package/dist/core/count-strategy.d.ts +41 -0
  265. package/dist/core/count-strategy.js +76 -0
  266. package/dist/core/count-support.d.ts +598 -0
  267. package/dist/core/count-support.js +2081 -0
  268. package/dist/core/count-tier-budget.d.ts +14 -0
  269. package/dist/core/count-tier-budget.js +64 -0
  270. package/dist/core/count-unions.d.ts +2 -0
  271. package/dist/core/count-unions.js +139 -0
  272. package/dist/core/count-unwritten-prefix.d.ts +24 -0
  273. package/dist/core/count-unwritten-prefix.js +97 -0
  274. package/dist/core/count-witness-flags.d.ts +9 -0
  275. package/dist/core/count-witness-flags.js +37 -0
  276. package/dist/core/count-write-frames.d.ts +12 -0
  277. package/dist/core/count-write-frames.js +206 -0
  278. package/dist/core/count-write-shape.d.ts +15 -0
  279. package/dist/core/count-write-shape.js +73 -0
  280. package/dist/core/counts.d.ts +49 -7
  281. package/dist/core/counts.js +1679 -165
  282. package/dist/core/cycles.js +5 -4
  283. package/dist/core/cyclic.js +11 -10
  284. package/dist/core/data.js +16 -15
  285. package/dist/core/dsl-deadline.d.ts +3 -0
  286. package/dist/core/dsl-deadline.js +27 -0
  287. package/dist/core/dsl.d.ts +59 -6
  288. package/dist/core/dsl.js +459 -112
  289. package/dist/core/effect.js +8 -1
  290. package/dist/core/evaluation-admission.d.ts +1 -0
  291. package/dist/core/evaluation-admission.js +3 -0
  292. package/dist/core/exists.d.ts +7 -2
  293. package/dist/core/exists.js +131 -24
  294. package/dist/core/extract-check.d.ts +7 -1
  295. package/dist/core/extract-check.js +130 -13
  296. package/dist/core/extract-read.d.ts +22 -8
  297. package/dist/core/extract-read.js +29 -11
  298. package/dist/core/extract-shapes.js +122 -41
  299. package/dist/core/extract-standalone.js +53 -9
  300. package/dist/core/extract.js +9 -3
  301. package/dist/core/field-laws.d.ts +4 -0
  302. package/dist/core/field-laws.js +238 -0
  303. package/dist/core/finite-frontiers.d.ts +5 -0
  304. package/dist/core/finite-frontiers.js +116 -0
  305. package/dist/core/finite-houdini.d.ts +58 -0
  306. package/dist/core/finite-houdini.js +502 -0
  307. package/dist/core/finite-model.d.ts +13 -0
  308. package/dist/core/finite-model.js +68 -0
  309. package/dist/core/finite-tiny.d.ts +72 -0
  310. package/dist/core/finite-tiny.js +1080 -0
  311. package/dist/core/fixtures/count-completion/paxos-decision.json +1 -0
  312. package/dist/core/fresh.js +5 -1
  313. package/dist/core/infer.d.ts +1 -1
  314. package/dist/core/infer.js +76 -38
  315. package/dist/core/kind.js +2 -1
  316. package/dist/core/laws.d.ts +2 -1
  317. package/dist/core/laws.js +47 -14
  318. package/dist/core/lemma-cuts.d.ts +38 -0
  319. package/dist/core/lemma-cuts.js +366 -0
  320. package/dist/core/linear-admission.d.ts +14 -0
  321. package/dist/core/linear-admission.js +151 -0
  322. package/dist/core/machine.d.ts +44 -4
  323. package/dist/core/machine.js +342 -63
  324. package/dist/core/meter.d.ts +22 -0
  325. package/dist/core/meter.js +34 -0
  326. package/dist/core/mutate.d.ts +55 -0
  327. package/dist/core/mutate.js +210 -0
  328. package/dist/core/native-domain.d.ts +6 -0
  329. package/dist/core/native-domain.js +114 -0
  330. package/dist/core/native-law.d.ts +3 -0
  331. package/dist/core/native-law.js +174 -0
  332. package/dist/core/nonterm.js +4 -3
  333. package/dist/core/prover-row-budget.d.ts +3 -0
  334. package/dist/core/prover-row-budget.js +106 -0
  335. package/dist/core/quorum-laws.d.ts +25 -0
  336. package/dist/core/quorum-laws.js +263 -0
  337. package/dist/core/rationals.js +3 -2
  338. package/dist/core/rejection-discovery.d.ts +34 -0
  339. package/dist/core/rejection-discovery.js +36 -0
  340. package/dist/core/rejection-stage.d.ts +39 -0
  341. package/dist/core/rejection-stage.js +205 -0
  342. package/dist/core/relational.js +10 -2
  343. package/dist/core/relevance.d.ts +4 -0
  344. package/dist/core/relevance.js +79 -0
  345. package/dist/core/request-quotient.d.ts +8 -0
  346. package/dist/core/request-quotient.js +299 -0
  347. package/dist/core/row-agreement-shape.d.ts +15 -0
  348. package/dist/core/row-agreement-shape.js +68 -0
  349. package/dist/core/runtime-wall.d.ts +5 -0
  350. package/dist/core/runtime-wall.js +4 -0
  351. package/dist/core/sample-step.d.ts +16 -0
  352. package/dist/core/sample-step.js +28 -0
  353. package/dist/core/search-policy.d.ts +15 -0
  354. package/dist/core/search-policy.js +68 -0
  355. package/dist/core/solver.d.ts +1 -1
  356. package/dist/core/solver.js +40 -6
  357. package/dist/core/source-check.d.ts +44 -0
  358. package/dist/core/source-check.js +126 -0
  359. package/dist/core/source-diagnostic.d.ts +1 -0
  360. package/dist/core/source-diagnostic.js +34 -0
  361. package/dist/core/step-work.d.ts +12 -0
  362. package/dist/core/step-work.js +14 -0
  363. package/dist/core/strategy-premises.d.ts +8 -0
  364. package/dist/core/strategy-premises.js +64 -0
  365. package/dist/core/support-budget.d.ts +2 -0
  366. package/dist/core/support-budget.js +6 -0
  367. package/dist/core/system.js +6 -3
  368. package/dist/core/table-admission.d.ts +1 -0
  369. package/dist/core/table-admission.js +3 -0
  370. package/dist/core/trace-clock.d.ts +3 -0
  371. package/dist/core/trace-clock.js +16 -0
  372. package/dist/core/transfer.js +3 -2
  373. package/dist/core/translate.js +16 -3
  374. package/dist/core/wall.d.ts +11 -0
  375. package/dist/core/wall.js +37 -0
  376. package/dist/core/watch.d.ts +1 -1
  377. package/dist/core/watch.js +15 -2
  378. package/dist/core/work-admission.d.ts +164 -0
  379. package/dist/core/work-admission.js +418 -0
  380. package/dist/core/work-amount.d.ts +21 -0
  381. package/dist/core/work-amount.js +80 -0
  382. package/dist/core/work-collections.d.ts +11 -0
  383. package/dist/core/work-collections.js +198 -0
  384. package/dist/core/work-kinds.d.ts +11 -0
  385. package/dist/core/work-kinds.js +9 -0
  386. package/dist/core/work-meter.d.ts +8 -0
  387. package/dist/core/work-meter.js +83 -0
  388. package/dist/core/work-observe.d.ts +12 -0
  389. package/dist/core/work-observe.js +39 -0
  390. package/dist/core/work-profile.d.ts +10 -0
  391. package/dist/core/work-profile.js +21 -0
  392. package/dist/core/work-refusal.d.ts +1 -0
  393. package/dist/core/work-refusal.js +6 -0
  394. package/dist/interchange/format.js +2 -0
  395. package/dist/kernel/cdcl.d.ts +4 -0
  396. package/dist/kernel/cdcl.js +109 -41
  397. package/dist/kernel/epr.js +23 -8
  398. package/dist/kernel/kernel.d.ts +56 -0
  399. package/dist/kernel/kernel.js +466 -64
  400. package/dist/kernel/model-sequence.d.ts +2 -2
  401. package/dist/kernel/model-sequence.js +4 -3
  402. package/dist/kernel/model-values.d.ts +2 -0
  403. package/dist/kernel/model-values.js +60 -0
  404. package/dist/kernel/prove.d.ts +59 -3
  405. package/dist/kernel/prove.js +524 -130
  406. package/dist/kernel/prover-rows.d.ts +30 -0
  407. package/dist/kernel/prover-rows.js +125 -0
  408. package/dist/kernel/reader.d.ts +1 -1
  409. package/dist/kernel/reader.js +57 -12
  410. package/dist/kernel/simplex.js +9 -2
  411. package/dist/lean-kernel/emit.d.ts +47 -2
  412. package/dist/lean-kernel/emit.js +270 -36
  413. package/dist/lean-kernel/lean-terms.d.ts +1 -0
  414. package/dist/lean-kernel/lean-terms.js +13 -5
  415. package/dist/lean-kernel/legacy-family-library.d.ts +1 -0
  416. package/dist/lean-kernel/legacy-family-library.js +5 -0
  417. package/dist/lean-kernel/library.js +4 -0
  418. package/dist/lean-kernel/qalpha.d.ts +7 -0
  419. package/dist/lean-kernel/qalpha.js +40 -0
  420. package/package.json +5 -1
@@ -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;
@@ -0,0 +1,179 @@
1
+ import { liftedLeafUntil, withLiftedLeaf } from "./count-lifted-budget.js";
2
+ import { FrameFactPool } from "./count-emitter-frame-pool.js";
3
+ // Generic marked-load STEP proposer. Every premise comes from structural
4
+ // discovery in the caller's family; no saved certificate or named law is used.
5
+ import { all, atMost, get, n, not, same, x } from "./machine.js";
6
+ import { countsForReads } from "./count-facts.js";
7
+ import { ownCountLawInstance, fixedCountFrameCase } from "./count-frames.js";
8
+ import { deferIntermediateCountChecks } from "./count-strategy.js";
9
+ import { discoverLiftedCountGuard } from "./count-lifted-shape.js";
10
+ import { discoverCountRowLoad } from "./count-load-shape.js";
11
+ import { proposeLiftedTransports } from "./count-lifted-transports.js";
12
+ import { canon, check, checkMC, countedObligations, frameOk, framePath, linear, mcGoal } from "../kernel/kernel.js";
13
+ import { add, env, k, scale, solve, sub } from "./solver.js";
14
+ import { growCdcl } from "../kernel/cdcl.js";
15
+ import { fullRate, fullWork, late, rowsAt, withDeadline } from "../kernel/prove.js";
16
+ import { countGuardTree } from "./count-guard-tree.js";
17
+ import { inlineFrozenGuard } from "./count-frozen-guard.js";
18
+ import { rebasePath } from "./count-rebase-path.js";
19
+ import { replayLinearSkeleton } from "./count-replay-skeleton.js";
20
+ import { checkedReversePrefix, UnwrittenCountPrefix } from "./count-unwritten-prefix.js";
21
+ import { copyQueryContext } from "./count-query-context.js";
22
+ import { stabilizeGuardedTree } from "./count-stabilize-tree.js";
23
+ const json = (value) => JSON.stringify(value);
24
+ // Untrusted minimal-to-full transport. The independent opt-in is default off;
25
+ // C2 and general deferral alone retain the pre-G1 checked replay call.
26
+ export function rebaseLiftedLoadCandidate(view, tree, root, until, goal, options = {}) {
27
+ return rebasePath(view, tree, root, root, until, goal) ?? (env.GDP_COUNT_G1_OWNED_DEFER === '1'
28
+ ? replayLinearSkeleton(goal, tree, root, until, { deferCheck: deferIntermediateCountChecks(options) })
29
+ : replayLinearSkeleton(goal, tree, root, until));
30
+ }
31
+ export function proveLiftedCountLoad(m, family, law, until, requestFor, observe, options = {}) {
32
+ if (!family.includes(law))
33
+ return;
34
+ return withDeadline(until, () => {
35
+ const deferred = deferIntermediateCountChecks(options), accepts = (...args) => deferred || check(...args);
36
+ const shape = discoverLiftedCountGuard(m, law, family), choice = fixedCountFrameCase(m), load = shape && choice && discoverCountRowLoad(m, shape, family, choice);
37
+ if (!shape || !choice || !load || !m.pre || late(until))
38
+ return;
39
+ const stopped = {}, decline = (reason) => { observe?.({ stage: 'load-decline', reason }); throw stopped; };
40
+ let framePool;
41
+ try {
42
+ const a = x(law.forall + '#'), b = x(law.keys[0]), written = x(load.written), endpoints = [a, b, written];
43
+ const instances = ownCountLawInstance(law, {});
44
+ for (const premise of load.phaseLaws)
45
+ instances[premise.name] = endpoints;
46
+ const packet = () => countedObligations(m, family, { [law.name]: instances }, family.indexOf(law)).at(-1);
47
+ const bootstrap = packet(), reads = requestFor(bootstrap.goal, bootstrap.decls).reads, maps = new Set(shape.countMaps), post = reads.filter(read => read[1].endsWith('#') && maps.has(read[1].slice(0, -1)));
48
+ const rowName = shape.origin.rowCount, twins = new Set(shape.origin.twins.map(t => t.row)), disabled = shape.countMaps.filter(map => map !== rowName && !twins.has(map));
49
+ if (disabled.length !== 1)
50
+ return decline('disabled-count');
51
+ const voteName = disabled[0], transport = proposeLiftedTransports(m, family, law, choice.value);
52
+ const loaded = transport?.filter(region => region.name === 'load-both' || region.name.endsWith('-marked')), neither = transport?.find(region => region.name === 'load-neither');
53
+ if (!loaded?.length || !neither)
54
+ return decline('transport-plan');
55
+ const key = (read) => json(read.post.slice(1));
56
+ const zeros = loaded[0].relations.filter(relation => relation.kind === 'zero' && twins.has(relation.post[1].slice(0, -1)) && loaded.every(region => region.relations.some(other => other.kind === 'zero' && key(other) === key(relation))));
57
+ const subsets = neither.relations.filter(relation => relation.kind === 'upper' && relation.post[1] === voteName + '#' && relation.target?.[1] === rowName + '#' && json(relation.post[2]) === json(relation.target[2]));
58
+ if (!zeros.length || subsets.length !== 2)
59
+ return decline('transport-coverage');
60
+ observe?.({ stage: 'load-match', zeroRelations: zeros.length, subsetRelations: subsets.length, regions: transport.length });
61
+ const find = (map, key) => reads.find(read => read[1] === map && json(read[2]) === json(key))?.[0] ?? decline('missing-count-read');
62
+ const counts0 = countsForReads(bootstrap.decls, reads), bound = counts0?.find(count => count.v === find(rowName + '#', a))?.below;
63
+ if (!bound)
64
+ return decline('row-bound');
65
+ let prefixName = 'markedLoad$';
66
+ const scope = json([m, family, reads]);
67
+ while (scope.includes(prefixName))
68
+ prefixName = '$' + prefixName;
69
+ const insts = [], loadWitnesses = [];
70
+ const put = (terms, isLoad = false) => { const wit = prefixName + insts.length; insts.push({ wit, below: bound, terms, unit: 0 }); if (isLoad)
71
+ loadWitnesses.push(wit); };
72
+ for (const relation of subsets)
73
+ put([[1, find(relation.post[1], relation.post[2])], [-1, find(relation.target[1], relation.target[2])]]);
74
+ for (const relation of zeros)
75
+ put([[1, find(relation.post[1], relation.post[2])]], true);
76
+ instances[load.law.name] = loadWitnesses.flatMap(wit => [a, x(wit), b, x(wit)]);
77
+ const step = packet(), again = requestFor(step.goal, step.decls);
78
+ if (json(reads) !== json(again.reads))
79
+ return decline('read-layout-drift');
80
+ const request = { reads, insts, picks: [] }, goal = mcGoal(step.goal.hyps, step.decls, request), counts = countsForReads(step.decls, reads);
81
+ if (!goal || !counts)
82
+ return decline('encoding');
83
+ const frames = [], lins = [], prefix = new UnwrittenCountPrefix(step.decls, reads, [same(x(choice.name), n(choice.value)), m.pre], written, bound, 'cdcl', { leafUnits: options.leafUnits });
84
+ const prefixFact = (postId, preId, rows, sign) => {
85
+ if (late(until))
86
+ return;
87
+ const positive = sign === 1 ? postId : preId, negative = sign === 1 ? preId : postId, opposite = lins.find(cut => cut.pos.length === 1 && cut.neg.length === 1 && cut.pos[0][0] === 1 && cut.neg[0][0] === 1 && cut.pos[0][1] === negative && cut.neg[0][1] === positive);
88
+ const run = (end) => opposite && checkedReversePrefix(counts, opposite) || prefix.prove(postId, preId, rows, sign, end);
89
+ return options.leafWork ? withLiftedLeaf(until, options, 60, 'leaf:load:prefix', run) : run(until);
90
+ };
91
+ for (const endpoint of [a, b])
92
+ for (const sign of [1, -1]) {
93
+ const cut = prefixFact(find(rowName + '#', endpoint), find(rowName, endpoint), [endpoint], sign);
94
+ if (cut)
95
+ lins.push(cut);
96
+ }
97
+ for (const endpoint of [a, b]) {
98
+ const cut = prefixFact(find(voteName + '#', endpoint), find(voteName, endpoint), [endpoint], 1);
99
+ if (cut)
100
+ lins.push(cut);
101
+ }
102
+ const reused = new Map(), roots = new Map();
103
+ const ask = (path, stage, frame = false) => {
104
+ if (late(until))
105
+ return;
106
+ if (stage === 'neither-written')
107
+ for (const [postId, map, key] of post) {
108
+ if (map === rowName + '#')
109
+ continue;
110
+ const rows = key.op === 'add' && key.a.op === 'mul' ? [key.a.a, key.b] : [key];
111
+ for (const sign of map === voteName + '#' ? [1] : [1, -1]) {
112
+ const cut = prefixFact(postId, find(map.slice(0, -1), key), rows, sign);
113
+ if (cut && !lins.some(old => json(old) === json(cut)))
114
+ lins.push(cut);
115
+ }
116
+ }
117
+ if (frame)
118
+ for (const [postId, map, key] of post) {
119
+ const pre = reads.find(read => read[1] === map.slice(0, -1) && json(read[2]) === json(key));
120
+ if (pre) {
121
+ const cut = { post: postId, pre: pre[0], when: [...path.values()].map(atom => atom.holds ? atom.lin : add(scale(atom.lin, -1), k(1))) };
122
+ if (options.emitterFramePool) {
123
+ (framePool ??= new FrameFactPool(counts, frames, until)).offer(cut);
124
+ }
125
+ else if (frameOk(counts, cut))
126
+ frames.push(cut);
127
+ }
128
+ }
129
+ const root = framePath(frames, [], path, [], lins), before = fullWork(), remember = (tree) => { roots.set(tree, new Map(root)); return tree; };
130
+ return withLiftedLeaf(until, options, 500, 'leaf:load:' + stage, deadline => {
131
+ const direct = solve(rowsAt(goal, root), 500);
132
+ if (direct.kind === 'refuted')
133
+ return remember({ leaf: direct.steps });
134
+ const cached = reused.get(stage);
135
+ if (cached) {
136
+ const end = options.leafWork ? deadline : liftedLeafUntil(deadline, options, 25), tree = rebasePath(cached.goal, cached.tree, cached.path, root, end, goal) ?? replayLinearSkeleton(goal, cached.tree, root, end, { deferCheck: deferred });
137
+ if (tree && accepts(goal, tree, root))
138
+ return remember(tree);
139
+ }
140
+ const selected = stage === 'both-written' || stage.endsWith('-loaded') ? insts.filter(inst => inst.terms.length === 1) : stage.endsWith('-empty') ? insts.filter(inst => inst.terms.length === 2 && inst.terms[0][1] === find(voteName + '#', stage.startsWith('a-written') ? b : a)) : [];
141
+ let searchRoot = root;
142
+ if (stage.endsWith('-loaded')) {
143
+ const other = stage.startsWith('a-written') ? b : a, order = sub(linear(other, path), linear(written, path)), drop = new Set([canon(order), canon(scale(order, -1))]);
144
+ searchRoot = framePath(frames, [], new Map([...path].filter(([, atom]) => !drop.has(canon(atom.lin)))), [], lins);
145
+ }
146
+ const hyps = copyQueryContext(step.goal.hyps, searchRoot, counts, insts, selected), view = mcGoal(hyps, step.decls, { ...request, insts: selected });
147
+ if (!view)
148
+ return;
149
+ const result = growCdcl(view, searchRoot, { nodes: 0, until: deadline }), candidate = 'tree' in result ? rebaseLiftedLoadCandidate(view, result.tree, searchRoot, deadline, goal, options) : undefined;
150
+ const general = candidate && accepts(goal, candidate, searchRoot) ? candidate : undefined, lift = general && (searchRoot === root ? general : rebasePath(goal, general, searchRoot, root, deadline, goal) ?? replayLinearSkeleton(goal, general, root, deadline, { deferCheck: deferred }));
151
+ observe?.({ stage, checked: !!lift, units: (fullWork() - before) / fullRate, ...(!('tree' in result) ? { outcome: result.stuck, witness: result.witness } : {}) });
152
+ if (general && !reused.has(stage))
153
+ reused.set(stage, { tree: general, path: searchRoot, goal });
154
+ return lift && accepts(goal, lift, root) && !late(until) ? remember(lift) : undefined;
155
+ });
156
+ };
157
+ const split = countGuardTree(until, { yesFirst: true }), marked = (row, path, stage) => split.condition(atMost(n(load.marker.value), get(load.marker.map, row)), path, p => ask(p, stage + '-loaded'), p => ask(p, stage + '-empty', true));
158
+ const regions = (path) => split.condition(same(a, written), path, p => split.condition(same(b, written), p, q => ask(q, 'both-written'), q => marked(b, q, 'a-written')), p => split.condition(same(b, written), p, q => marked(a, q, 'b-written'), q => ask(q, 'neither-written', true)));
159
+ const domain = all(m.pre, ...endpoints.flatMap(row => [{ op: '<', a: row, b: bound }, atMost(row, n(shape.origin.width - 1))])), active = inlineFrozenGuard(m.step.flags ?? {}, load.guard);
160
+ const inactive = (path) => split.condition(all(...choice.values.filter(value => value !== choice.value).map(value => not(same(x(choice.name), n(value))))), path, p => ask(p, 'inactive', true), p => ask(p, 'inactive-operation-contradiction'));
161
+ const tree = split.condition(domain, new Map(), path => split.condition(active, path, regions, inactive), path => ask(path, 'outside-domain'));
162
+ if (!tree)
163
+ return decline('tree');
164
+ const stable = stabilizeGuardedTree(goal, tree, frames, lins, roots, until, { deferCheck: deferred });
165
+ observe?.({ stage: 'load-stabilize', completed: !!stable.tree, rebased: stable.rebased, failed: stable.failed, phasePremises: load.phaseLaws.length });
166
+ if (!stable.tree || late(until))
167
+ return;
168
+ if (framePool)
169
+ observe?.({ stage: 'emitter-frame-pool', emitter: 'load', ...framePool.stats() });
170
+ const cert = { ...request, frames, lins, tree: stable.tree };
171
+ return (options.deferToComposition || checkMC(step.goal.hyps, step.decls, cert)) && !late(until) ? { instances, certs: { [step.goal.name]: cert }, ...(deferred ? { status: 'unchecked' } : {}) } : undefined;
172
+ }
173
+ catch (error) {
174
+ if (error === stopped)
175
+ return;
176
+ throw error;
177
+ }
178
+ });
179
+ }
@@ -0,0 +1,14 @@
1
+ import { type C, type Law, type Machine } from './machine.js';
2
+ import { type Count } from '../kernel/kernel.js';
3
+ export type LiftedCountPrerequisite = {
4
+ law: Law;
5
+ disabledMap: string;
6
+ voteMap: string;
7
+ kind: 'diagonal' | 'threshold-factor';
8
+ disabled: Count;
9
+ votes: Count;
10
+ threshold?: C;
11
+ bodyNodes: number;
12
+ };
13
+ export declare function liftedCountBodySize(value: unknown): number;
14
+ export declare function discoverLiftedCountPrerequisites(m: Machine, law: Law, family: readonly Law[]): LiftedCountPrerequisite[];
@@ -0,0 +1,53 @@
1
+ // Untrusted F15 scheduling proposal. A factor match supplies an existing law,
2
+ // never a count inequality, a proof, or permission to bypass native checking.
3
+ import { all, get, ite, less, n, plus, times, x } from "./machine.js";
4
+ import { countsForReads } from "./count-facts.js";
5
+ import { discoverCountGuardShape } from "./count-guard-shape.js";
6
+ import { discoverLiftedCountGuard } from "./count-lifted-shape.js";
7
+ import { matchLiftedCountBodies } from "./count-lifted-transports.js";
8
+ import { substE } from "../kernel/kernel.js";
9
+ const json = (value) => JSON.stringify(value);
10
+ export function liftedCountBodySize(value) {
11
+ if (!value || typeof value !== 'object')
12
+ return 0;
13
+ if (Array.isArray(value))
14
+ return value.reduce((sum, child) => sum + liftedCountBodySize(child), 0);
15
+ return ('op' in value ? 1 : 0) + Object.values(value).reduce((sum, child) => sum + liftedCountBodySize(child), 0);
16
+ }
17
+ const atoms = (c) => c.op === 'and' ? c.xs.flatMap(atoms) : [c];
18
+ export function discoverLiftedCountPrerequisites(m, law, family) {
19
+ const shape = discoverLiftedCountGuard(m, law, family);
20
+ if (!shape || !law.forall)
21
+ return [];
22
+ const twins = new Set(shape.origin.twins.map(twin => twin.row)), disabledMaps = shape.countMaps.filter(map => map !== shape.origin.rowCount && !twins.has(map));
23
+ if (disabledMaps.length !== 1)
24
+ return [];
25
+ const disabledMap = disabledMaps[0], row = x(law.forall), decls = Object.entries(m.counts ?? {}).map(([map, definition]) => ({ ...definition, map }));
26
+ const raw = countsForReads(decls, [['disabled', disabledMap, row]])?.[0];
27
+ if (!raw)
28
+ return [];
29
+ let member = 'prerequisite$member';
30
+ const scope = json([m, law]);
31
+ while (scope.includes(member))
32
+ member = '$' + member;
33
+ const canonical = (count) => ({ ...count, key: member, body: substE(count.body, { vars: { [count.key]: x(member) }, maps: {}, flags: {} }) });
34
+ const disabled = canonical(raw), bodyNodes = liftedCountBodySize(raw.body);
35
+ return family.flatMap(candidate => {
36
+ const guard = discoverCountGuardShape(m, candidate, family);
37
+ if (!guard || guard.rowMap !== shape.origin.rowCount || guard.width !== shape.origin.width)
38
+ return [];
39
+ const rawVotes = countsForReads(decls, [['votes', guard.voteMap, plus(times(guard.width, row), row)]])?.[0];
40
+ if (!rawVotes)
41
+ return [];
42
+ const votes = canonical(rawVotes), base = { law: candidate, disabledMap, voteMap: guard.voteMap, disabled, votes, bodyNodes };
43
+ if (matchLiftedCountBodies(disabled, votes))
44
+ return [{ ...base, kind: 'diagonal' }];
45
+ if (votes.body.op !== 'if' || json(votes.body.then) !== json(n(1)) || json(votes.body.else) !== json(n(0)))
46
+ return [];
47
+ const threshold = less(get(guard.memberField, x(member)), get(guard.thresholdField, row)), parts = atoms(votes.body.c);
48
+ if (parts.filter(part => json(part) === json(threshold)).length !== 1)
49
+ return [];
50
+ const residual = { ...votes, body: ite(all(...parts.filter(part => json(part) !== json(threshold))), n(1), n(0)) };
51
+ return matchLiftedCountBodies(disabled, residual) ? [{ ...base, kind: 'threshold-factor', threshold }] : [];
52
+ });
53
+ }
@@ -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 proveLiftedCountReplacement(m: Machine, family: Law[], law: Law, until: number, requestFor: CountRequestBuilder, observe?: (event: Record<string, unknown>) => void, options?: CountStrategyOptions): CountStrategyProof | undefined;