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
@@ -1,3 +1,4 @@
1
+ import { searchNow as countedSearchNow } from "./wall.js";
1
2
  // Untrusted proof compression. Turn repeated forced splits into independently checked conditional cuts.
2
3
  // No search, protocol vocabulary, new facts or proof-budget changes: failed transport/check returns no proposal.
3
4
  import { n, plus, times, x } from "./machine.js";
@@ -74,7 +75,7 @@ const proofPath = (when, cut) => {
74
75
  };
75
76
  // Unlike widen, transport never calls a solver when a row is missing.
76
77
  function transport(from, to, tree, before, after, until, missing) {
77
- if (performance.now() >= until)
78
+ if (countedSearchNow() >= until)
78
79
  return undefined;
79
80
  if ('split' in tree) {
80
81
  const known = decide(tree.split, after);
@@ -127,7 +128,7 @@ class ObservedPath extends Map {
127
128
  has(key) { this.observed.add(key); return super.has(key); }
128
129
  }
129
130
  function dependencies(g, t, path, facts, atoms, until) {
130
- if (performance.now() >= until)
131
+ if (countedSearchNow() >= until)
131
132
  return false;
132
133
  if ('split' in t)
133
134
  return dependencies(g, t.yes, put(path, t.split, true), facts, atoms, until)
@@ -176,7 +177,7 @@ function scopeCondition(lin) {
176
177
  }
177
178
  // Candidate construction only. Call shareLemmaCuts or the containing machine checker before admission.
178
179
  export function proposeLemmaCuts(goal, tree, options = {}) {
179
- const started = performance.now(), root = options.path ?? new Map(), until = options.until ?? Infinity;
180
+ const started = countedSearchNow(), root = options.path ?? new Map(), until = options.until ?? Infinity;
180
181
  const sizes = new WeakMap(), repeats = new Map();
181
182
  const measure = (t) => {
182
183
  if ('leaf' in t) {
@@ -271,7 +272,7 @@ export function proposeLemmaCuts(goal, tree, options = {}) {
271
272
  return { when, cut: t.split, tree: proof, slice };
272
273
  };
273
274
  const visit = (t, original, real) => {
274
- if (performance.now() >= until)
275
+ if (countedSearchNow() >= until)
275
276
  return undefined;
276
277
  if ('leaf' in t) {
277
278
  const copy = { ...t };
@@ -290,8 +291,8 @@ export function proposeLemmaCuts(goal, tree, options = {}) {
290
291
  found = usable;
291
292
  }
292
293
  if (found === undefined) {
293
- const begun = performance.now(), lemma = makeLemma(t, original, real);
294
- options.trace?.({ stage: 'lemma', produced: !!lemma, nodes: sizes.get(t.no) ?? 0, ms: performance.now() - begun, when: lemma?.when.length ?? -1, hyps: lemma?.slice?.length ?? -1 });
294
+ const begun = countedSearchNow(), lemma = makeLemma(t, original, real);
295
+ options.trace?.({ stage: 'lemma', produced: !!lemma, nodes: sizes.get(t.no) ?? 0, ms: countedSearchNow() - begun, when: lemma?.when.length ?? -1, hyps: lemma?.slice?.length ?? -1 });
295
296
  if (lemma) {
296
297
  const key = keyOf(lemma.when, lemma.cut);
297
298
  found = shared.get(key);
@@ -345,21 +346,21 @@ export function proposeLemmaCuts(goal, tree, options = {}) {
345
346
  const count = (t) => 'leaf' in t ? 1 : 1 + count(t.yes) + count(t.no);
346
347
  const after = count(out) + lemmas.reduce((n, l) => n + count(l.tree), 0);
347
348
  const workBefore = before * Math.max(1, goal.hyps.length), workAfter = count(out) * Math.max(1, scoped.hyps.length) + lemmas.reduce((n, l) => n + count(l.tree) * Math.max(1, l.slice?.length ?? scoped.hyps.length), 0);
348
- if (workAfter >= workBefore || performance.now() >= until) {
349
+ if (workAfter >= workBefore || countedSearchNow() >= until) {
349
350
  options.trace?.({ stage: 'not-cheaper-or-expired', before, after, workBefore, workAfter });
350
351
  return undefined;
351
352
  }
352
- return { goal: scoped, tree: out, lemmas, stats: { before, after, cuts: lemmas.length, sourceHyps: goal.hyps.length, lemmaHyps: lemmas.reduce((n, l) => n + (l.slice?.length ?? scoped.hyps.length), 0), mainNodes: count(out), checkMs: 0, buildMs: performance.now() - started } };
353
+ return { goal: scoped, tree: out, lemmas, stats: { before, after, cuts: lemmas.length, sourceHyps: goal.hyps.length, lemmaHyps: lemmas.reduce((n, l) => n + (l.slice?.length ?? scoped.hyps.length), 0), mainNodes: count(out), checkMs: 0, buildMs: countedSearchNow() - started } };
353
354
  }
354
355
  export function shareLemmaCuts(goal, tree, options = {}) {
355
356
  const proposed = proposeLemmaCuts(goal, tree, options);
356
357
  if (!proposed)
357
358
  return undefined;
358
- const start = performance.now(), checked = checkGoalLemmas(proposed.goal, proposed.tree, proposed.lemmas);
359
+ const start = countedSearchNow(), checked = checkGoalLemmas(proposed.goal, proposed.tree, proposed.lemmas);
359
360
  if (!checked) {
360
361
  options?.trace?.({ stage: 'kernel-rejected' });
361
362
  return undefined;
362
363
  }
363
- proposed.stats.checkMs = performance.now() - start;
364
+ proposed.stats.checkMs = countedSearchNow() - start;
364
365
  return proposed;
365
366
  }
@@ -0,0 +1,11 @@
1
+ export interface LiftArguments {
2
+ capsule: string;
3
+ source: string;
4
+ out?: string;
5
+ sha256?: string;
6
+ emitOnly: boolean;
7
+ json: boolean;
8
+ timeoutMs: number;
9
+ }
10
+ export declare function parseLiftArguments(argv: string[]): LiftArguments;
11
+ export declare function liftMain(argv: string[]): Promise<number>;
@@ -0,0 +1,113 @@
1
+ // Node-only command adapter. The capsule is data, never an executable module.
2
+ import { createHash } from 'node:crypto';
3
+ import { spawnSync } from 'node:child_process';
4
+ import { readFileSync, writeFileSync, lstatSync, realpathSync } from 'node:fs';
5
+ import { basename, isAbsolute, join, resolve, sep } from 'node:path';
6
+ import { lift } from "../lean-kernel/lift.js";
7
+ import { auditLiftLog, gate } from "../lean-kernel/axiom-audit.js";
8
+ export function parseLiftArguments(argv) {
9
+ const positional = [], seen = new Set();
10
+ const options = { capsule: '', source: '', emitOnly: false, json: false, timeoutMs: 1_800_000 };
11
+ for (let i = 0; i < argv.length; i++) {
12
+ const a = argv[i];
13
+ if (!a.startsWith('--')) {
14
+ positional.push(a);
15
+ continue;
16
+ }
17
+ if (seen.has(a))
18
+ throw Error('duplicate lift option: ' + a);
19
+ seen.add(a);
20
+ if (a === '--emit-only')
21
+ options.emitOnly = true;
22
+ else if (a === '--json')
23
+ options.json = true;
24
+ else if (a === '--out' || a === '--sha256' || a === '--timeout-ms') {
25
+ const value = argv[++i];
26
+ if (!value || value.startsWith('--'))
27
+ throw Error('missing value for ' + a);
28
+ if (a === '--out')
29
+ options.out = value;
30
+ else if (a === '--sha256') {
31
+ if (!/^[a-f0-9]{64}$/.test(value))
32
+ throw Error('invalid capsule SHA-256');
33
+ options.sha256 = value;
34
+ }
35
+ else {
36
+ const n = Number(value);
37
+ if (!Number.isSafeInteger(n) || n < 1 || n > 7_200_000)
38
+ throw Error('invalid lift timeout');
39
+ options.timeoutMs = n;
40
+ }
41
+ }
42
+ else
43
+ throw Error('unknown lift option: ' + a);
44
+ }
45
+ if (positional.length !== 2)
46
+ throw Error('usage: gdp-wired lift <capsule> <source.json> [--out DIR] [--emit-only] [--sha256 HASH] [--timeout-ms N] [--json]');
47
+ options.capsule = positional[0];
48
+ options.source = positional[1];
49
+ return options;
50
+ }
51
+ const sha = (data) => createHash('sha256').update(data).digest('hex');
52
+ function verifyFiles(directory, files) {
53
+ if (!files || typeof files !== 'object' || !Object.keys(files).length)
54
+ throw Error('missing emitted file hashes');
55
+ const realRoot = realpathSync(directory);
56
+ for (const [name, digest] of Object.entries(files)) {
57
+ const path = resolve(directory, name);
58
+ if (isAbsolute(name) || !path.startsWith(directory + sep) || !/^[a-f0-9]{64}$/.test(digest))
59
+ throw Error('invalid emitted path/hash: ' + name);
60
+ const stat = lstatSync(path);
61
+ if (!stat.isFile() || stat.isSymbolicLink() || !realpathSync(path).startsWith(realRoot + sep) || sha(readFileSync(path)) !== digest)
62
+ throw Error('emitted file changed: ' + name);
63
+ }
64
+ }
65
+ export async function liftMain(argv) {
66
+ let output;
67
+ try {
68
+ const args = parseLiftArguments(argv);
69
+ output = resolve(args.out ?? basename(args.source).replace(/\.json$/, '') + '.lift');
70
+ const manifest = lift(resolve(args.capsule), resolve(args.source), output, { expectedManifestSha256: args.sha256 });
71
+ if (args.emitOnly) {
72
+ console.log(args.json ? JSON.stringify(manifest) : `EMITTED_NOT_CHECKED: ${output}`);
73
+ return 0;
74
+ }
75
+ const emission = readFileSync(join(output, 'EMITTED.json'));
76
+ verifyFiles(output, manifest.files);
77
+ const commands = [];
78
+ const run = (label, command) => {
79
+ const result = spawnSync(command[0], command.slice(1), { cwd: output, env: { ...process.env, GDP_LEAN_NATIVE: '0' }, encoding: 'utf8', timeout: args.timeoutMs, maxBuffer: 32 * 1024 * 1024, killSignal: 'SIGKILL' });
80
+ const stdout = result.stdout ?? '', stderr = result.stderr ?? '';
81
+ writeFileSync(join(output, label + '.stdout.log'), stdout, { flag: 'wx' });
82
+ writeFileSync(join(output, label + '.stderr.log'), stderr, { flag: 'wx' });
83
+ if (result.error || result.signal || result.status !== 0)
84
+ throw Error(`${label} failed: ${result.error?.message ?? result.signal ?? result.status}`);
85
+ commands.push({ command, exitCode: result.status, stdoutSha256: sha(stdout), stderrSha256: sha(stderr) });
86
+ return stdout + '\n' + stderr;
87
+ };
88
+ const build = run('lift-build', ['lake', 'build']);
89
+ const buildErrors = gate(build, [], false);
90
+ if (buildErrors.length || /\berror:/.test(build))
91
+ throw Error(buildErrors.join('; ') || 'Lean build reported an error');
92
+ const log = run('lift-root', ['lake', 'env', 'lean', 'BapaProof.lean']);
93
+ const declarations = manifest;
94
+ const sourceTheorems = declarations.sourceProjection?.sourceTheorems;
95
+ if (!sourceTheorems?.length)
96
+ throw Error('missing original source theorem coverage');
97
+ const required = declarations.requiredTheorems ?? [declarations.familyTheorem, ...sourceTheorems];
98
+ const axioms = auditLiftLog(log, [readFileSync(join(output, 'BapaProof.lean'), 'utf8')], required);
99
+ verifyFiles(output, manifest.files);
100
+ if (sha(readFileSync(join(output, 'EMITTED.json'))) !== sha(emission))
101
+ throw Error('emission manifest changed during Lean execution');
102
+ const receipt = { schema: 'gdp-lift-check/v1', status: 'SOURCE_CHECKED', scope: 'provided source machine and laws', emissionSha256: sha(emission), files: manifest.files, commands, checkedTheorems: axioms };
103
+ writeFileSync(join(output, 'LIFT-CHECKED.json'), JSON.stringify(receipt, null, 2) + '\n', { flag: 'wx' });
104
+ console.log(args.json ? JSON.stringify(receipt) : `SOURCE_CHECKED: ${sourceTheorems.join(', ')}\n${output}`);
105
+ return 0;
106
+ }
107
+ catch (error) {
108
+ console.error(`gdp-wired lift: ${error instanceof Error ? error.message : String(error)}`);
109
+ if (output)
110
+ console.error(`No source acceptance. Any partial output is retained at ${output}.`);
111
+ return 2;
112
+ }
113
+ }
@@ -0,0 +1,14 @@
1
+ import { type Lin } from './solver.js';
2
+ export declare function fundedAdd(...inputs: Lin[]): Lin;
3
+ export declare const fundedSub: (a: Lin, b: Lin) => Lin;
4
+ export declare const fundedScale: (a: Lin, factor: number) => Lin;
5
+ export declare const fundedVariable: (name: string) => Lin;
6
+ export declare function fundedConstant(value: number): Lin;
7
+ export declare function admittedLinearProduct(a: Lin, b: Lin, keyOf: (p: string, q: string) => string | undefined, site: string, safeIntegers: boolean): Lin | undefined;
8
+ export declare function everyLinearCell(lin: Lin, test: (key: string, value: number) => boolean, site: string): boolean;
9
+ export declare function visitLinearCells(lin: Lin, visit: (key: string, value: number) => void, site: string): void;
10
+ export declare function admittedLinearSub(a: Lin, b: Lin, site: string): Lin;
11
+ export declare function admittedLinearAdd(a: Lin, b: Lin, site: string): Lin;
12
+ export declare function admittedLinearScale(a: Lin, factor: number, site: string): Lin;
13
+ export declare function admittedLinearCopy(a: Lin, site: string): Lin;
14
+ export declare function admittedLinearVariable(name: string, coefficient: number, site: string): Lin;
@@ -0,0 +1,151 @@
1
+ // Owned two-phase coefficient production. Discovery and output are DISTINCT
2
+ // physical cell operations; zero/cancelled inputs still cost discovery work.
3
+ // Domain: synchronous ordinary data records, no Proxy/exotic prototype. Native
4
+ // own-key enumeration still needs a candidate-specific M1/M3 summary; this
5
+ // module alone does not close the global SIZE/ORDER gate.
6
+ import { add, scale, sub, v } from "./solver.js";
7
+ import { completeWorkProfile } from "./work-profile.js";
8
+ import { BudgetExpired, startWork, withAdmittedChunk } from "./work-admission.js";
9
+ function emitOwned(plan, keepZero, site) {
10
+ // The plan is local and owns primitive values, never references input cells.
11
+ // Map.size and array.length below are intrinsic metadata of owned containers.
12
+ const output = [], iterator = plan.entries(), size = plan.size;
13
+ let nonzero = 0;
14
+ for (let i = 0; i < size; i++) {
15
+ startWork('tableCells', 1, `${site}:select`);
16
+ const entry = iterator.next();
17
+ if (entry.done)
18
+ throw new Error('coefficient plan changed during selection');
19
+ if (entry.value[1] !== 0)
20
+ nonzero++;
21
+ if (keepZero || entry.value[1] !== 0)
22
+ output.push({ key: entry.value[0], value: entry.value[1], charge: entry.value[1] === 0 ? 0 : 1 });
23
+ }
24
+ return withAdmittedChunk('tableCells', nonzero, lease => {
25
+ // This producer cannot return a partial row. Refuse before creating any
26
+ // output coefficient, then let finally retire the unused reservation.
27
+ if (lease.granted !== nonzero)
28
+ throw new BudgetExpired(`${site}:emit`);
29
+ const out = Object.create(null);
30
+ for (let i = 0; i < output.length; i++) {
31
+ const entry = output[i];
32
+ // Occupancy is cached metadata, not a repeated coefficient read. A zero
33
+ // representation entry is no nonzero emission; start(0) validates life.
34
+ lease.start(entry.charge);
35
+ out[entry.key] = entry.value;
36
+ }
37
+ return out;
38
+ }, `${site}:emit`);
39
+ }
40
+ function discover(inputs, keepZero, site) {
41
+ const plan = new Map();
42
+ for (const { lin, factor } of inputs) {
43
+ const prototype = Object.getPrototypeOf(lin);
44
+ if (prototype !== null && prototype !== Object.prototype)
45
+ throw new TypeError('coefficient input must be an ordinary data record');
46
+ for (const key in lin) {
47
+ startWork('tableCells', 1, `${site}:input`);
48
+ const descriptor = Object.getOwnPropertyDescriptor(lin, key);
49
+ if (!descriptor || !('value' in descriptor) || typeof descriptor.value !== 'number')
50
+ throw new TypeError('coefficient input must have own numeric data cells');
51
+ // This is the first cell lookup/arithmetic/accumulation, after start.
52
+ const value = descriptor.value;
53
+ plan.set(key, plan.has(key) ? plan.get(key) + value * factor : value * factor);
54
+ }
55
+ }
56
+ return emitOwned(plan, keepZero, site);
57
+ }
58
+ export function fundedAdd(...inputs) {
59
+ if (!completeWorkProfile.enabled)
60
+ return add(...inputs);
61
+ const plan = [];
62
+ for (let i = 0; i < inputs.length; i++) {
63
+ startWork('ticks', 1, 'linear add operand');
64
+ plan.push({ lin: inputs[i], factor: 1 });
65
+ }
66
+ return discover(plan, false, 'linear:add');
67
+ }
68
+ export const fundedSub = (a, b) => admittedLinearSub(a, b, 'linear:sub');
69
+ export const fundedScale = (a, factor) => admittedLinearScale(a, factor, 'linear:scale');
70
+ export const fundedVariable = (name) => admittedLinearVariable(name, 1, 'linear:variable');
71
+ export function fundedConstant(value) {
72
+ if (!completeWorkProfile.enabled)
73
+ return value === 0 ? {} : { 1: value };
74
+ startWork('tableCells', 1, 'linear:constant:input');
75
+ const plan = new Map();
76
+ if (value !== 0)
77
+ plan.set('1', value);
78
+ return emitOwned(plan, false, 'linear:constant');
79
+ }
80
+ export function admittedLinearProduct(a, b, keyOf, site, safeIntegers) {
81
+ const plan = new Map();
82
+ for (const p in a)
83
+ for (const q in b) {
84
+ startWork('tableCells', 1, `${site}:left`);
85
+ const ad = Object.getOwnPropertyDescriptor(a, p);
86
+ if (!ad || !('value' in ad) || typeof ad.value !== 'number')
87
+ throw new TypeError('product input must have numeric data cells');
88
+ const cp = ad.value;
89
+ startWork('tableCells', 1, `${site}:right`);
90
+ const bd = Object.getOwnPropertyDescriptor(b, q);
91
+ if (!bd || !('value' in bd) || typeof bd.value !== 'number')
92
+ throw new TypeError('product input must have numeric data cells');
93
+ const cq = bd.value, key = keyOf(p, q);
94
+ if (key === undefined)
95
+ return undefined;
96
+ const value = (plan.get(key) ?? 0) + cp * cq;
97
+ if (safeIntegers && ![cp, cq, cp * cq, value].every(Number.isSafeInteger))
98
+ return undefined;
99
+ plan.set(key, value);
100
+ }
101
+ return emitOwned(plan, false, site);
102
+ }
103
+ export function everyLinearCell(lin, test, site) {
104
+ if (!completeWorkProfile.enabled)
105
+ return Object.entries(lin).every(([key, value]) => test(key, value));
106
+ for (const key in lin) {
107
+ if (completeWorkProfile.enabled)
108
+ startWork('tableCells', 1, site);
109
+ const descriptor = Object.getOwnPropertyDescriptor(lin, key);
110
+ if (!descriptor || !('value' in descriptor) || typeof descriptor.value !== 'number')
111
+ throw new TypeError('coefficient input must have numeric data cells');
112
+ if (!test(key, descriptor.value))
113
+ return false;
114
+ }
115
+ return true;
116
+ }
117
+ export function visitLinearCells(lin, visit, site) {
118
+ if (!completeWorkProfile.enabled) {
119
+ for (const [key, value] of Object.entries(lin))
120
+ visit(key, value);
121
+ return;
122
+ }
123
+ for (const key in lin) {
124
+ if (completeWorkProfile.enabled)
125
+ startWork('tableCells', 1, `${site}:visit`);
126
+ const descriptor = Object.getOwnPropertyDescriptor(lin, key);
127
+ if (!descriptor || !('value' in descriptor) || typeof descriptor.value !== 'number')
128
+ throw new TypeError('coefficient input must have numeric data cells');
129
+ visit(key, descriptor.value);
130
+ }
131
+ }
132
+ export function admittedLinearSub(a, b, site) {
133
+ return completeWorkProfile.enabled ? discover([{ lin: a, factor: 1 }, { lin: b, factor: -1 }], false, site) : sub(a, b);
134
+ }
135
+ export function admittedLinearAdd(a, b, site) {
136
+ return completeWorkProfile.enabled ? discover([{ lin: a, factor: 1 }, { lin: b, factor: 1 }], false, site) : add(a, b);
137
+ }
138
+ export function admittedLinearScale(a, factor, site) {
139
+ return completeWorkProfile.enabled ? discover([{ lin: a, factor }], false, site) : scale(a, factor);
140
+ }
141
+ export function admittedLinearCopy(a, site) {
142
+ return completeWorkProfile.enabled ? discover([{ lin: a, factor: 1 }], true, site) : a;
143
+ }
144
+ export function admittedLinearVariable(name, coefficient, site) {
145
+ if (!completeWorkProfile.enabled)
146
+ return coefficient === 1 ? v(name) : { [name]: coefficient };
147
+ startWork('tableCells', 1, `${site}:construct`);
148
+ const plan = new Map();
149
+ plan.set(name, coefficient);
150
+ return emitOwned(plan, true, site);
151
+ }
@@ -3,7 +3,8 @@ export declare const lcg: (x: number) => number;
3
3
  export type Rand = (k: number) => number;
4
4
  export declare const seeded: (seed: number) => Rand;
5
5
  export declare const walk: (t: unknown, f: (o: Record<string, unknown>) => void) => void;
6
- export declare const walkOnce: (t: unknown, f: (o: object) => void) => void;
6
+ export declare const hasFinite: (value: unknown) => boolean;
7
+ export declare const walkOnce: (t: unknown, f: (o: object) => void, before?: () => void) => void;
7
8
  export type E = {
8
9
  op: 'var';
9
10
  name: string;
@@ -62,6 +63,7 @@ export type C = {
62
63
  keys?: string[];
63
64
  c: C;
64
65
  witness?: E;
66
+ finite?: string;
65
67
  };
66
68
  export type Machine = {
67
69
  name: string;
@@ -207,6 +209,7 @@ export type Law = {
207
209
  holds: C;
208
210
  forall?: string;
209
211
  keys?: string[];
212
+ finite?: string;
210
213
  stated?: C;
211
214
  some?: string[];
212
215
  witness?: SomeWitness;
@@ -295,7 +298,7 @@ export type Compiled = {
295
298
  head?: number;
296
299
  };
297
300
  fork: (st: State) => State;
298
- step: (params: object, st: State, input: object) => State & {
301
+ step: (params: object, st: State, input: object, finiteCheck?: () => void) => State & {
299
302
  head?: number;
300
303
  };
301
304
  cells?: (params: object, st: State, input: object, tick: () => void) => Record<string, Map<number, number>>;