tla-ts 0.0.4-dev.4c0ab96 → 0.0.4-dev.55f2117

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 (359) hide show
  1. package/README.md +37 -126
  2. package/dist/cli.cjs +1 -1
  3. package/dist/cli.js +1 -1
  4. package/dist/deciders.cjs +366 -0
  5. package/dist/deciders.js +366 -0
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.cts +33 -1
  8. package/dist/index.d.ts +33 -1
  9. package/dist/index.js +1 -1
  10. package/dist/parallel-worker.cjs +1 -4
  11. package/dist/parallel-worker.js +1 -4
  12. package/dist/prove-worker.cjs +9 -0
  13. package/dist/prove-worker.d.cts +9 -0
  14. package/dist/prove-worker.d.ts +9 -0
  15. package/dist/prove-worker.js +9 -0
  16. package/dist/prove.cjs +996 -0
  17. package/dist/prove.js +996 -0
  18. package/dist/run.cjs +45 -0
  19. package/dist/run.js +45 -0
  20. package/dist/tlapm.cjs +10 -0
  21. package/dist/tlapm.js +10 -0
  22. package/dist/transfer.cjs +38 -44
  23. package/dist/transfer.js +38 -44
  24. package/dist/worker.cjs +21 -0
  25. package/dist/worker.js +21 -0
  26. package/package.json +21 -12
  27. package/src/ast.ts +2 -2
  28. package/src/check.ts +7 -7
  29. package/src/{cli-options.ts → cli/options.ts} +1 -1
  30. package/src/{run-cli.ts → cli/run.ts} +293 -91
  31. package/src/cli.ts +1 -1
  32. package/src/config.ts +2 -2
  33. package/src/environment.ts +9 -9
  34. package/src/errors.ts +89 -30
  35. package/src/evaluate.ts +32 -11
  36. package/src/index.ts +10 -0
  37. package/src/levels.ts +1 -1
  38. package/src/live-check.ts +1 -1
  39. package/src/liveness.ts +1 -1
  40. package/src/{obligation-action.ts → obligations/action.ts} +247 -69
  41. package/src/{obligation-anon.ts → obligations/anon.ts} +49 -47
  42. package/src/obligations/ctx.ts +64 -0
  43. package/src/{obligation-deref.ts → obligations/deref.ts} +51 -92
  44. package/src/{obligation-expression.ts → obligations/expression.ts} +117 -57
  45. package/src/{obligation-format.ts → obligations/format.ts} +7 -8
  46. package/src/{obligation-generate.ts → obligations/generate.ts} +170 -192
  47. package/src/{obligations.ts → obligations/index.ts} +32 -16
  48. package/src/{obligation-levels.ts → obligations/levels.ts} +26 -28
  49. package/src/{obligation-module.ts → obligations/module.ts} +113 -121
  50. package/src/obligations/pickle.ts +98 -0
  51. package/src/obligations/pragma.ts +189 -0
  52. package/src/{obligation-printer.ts → obligations/printer.ts} +22 -80
  53. package/src/{obligation-proof.ts → obligations/proof.ts} +7 -2
  54. package/src/{obligation-source.ts → obligations/source.ts} +154 -99
  55. package/src/obligations/temporal.ts +321 -0
  56. package/src/{obligation-tuples.ts → obligations/tuples.ts} +38 -54
  57. package/src/parallel-worker.ts +4 -20
  58. package/src/parallel.ts +13 -46
  59. package/src/parser.ts +1 -1
  60. package/src/{pcal-ast.ts → pcal/ast.ts} +2 -2
  61. package/src/{pcal-parse.ts → pcal/parse.ts} +3 -3
  62. package/src/{pcal-tokenize.ts → pcal/tokenize.ts} +2 -2
  63. package/src/{pcal-translate.ts → pcal/translate.ts} +2 -2
  64. package/src/{pcal-validate.ts → pcal/validate.ts} +6 -6
  65. package/src/prove/decide-pool.ts +95 -0
  66. package/src/prove/deciders.ts +33 -0
  67. package/src/prove/first-order.ts +78 -0
  68. package/src/prove/isabelle/LICENSE +36 -0
  69. package/src/prove/isabelle/LICENSE-tlapm +26 -0
  70. package/src/prove/isabelle/decide.ts +47 -0
  71. package/src/prove/isabelle/encode.ts +446 -0
  72. package/src/prove/isabelle/isar/inner-syntax.ts +579 -0
  73. package/src/prove/isabelle/isar/method.ts +367 -0
  74. package/src/prove/isabelle/isar/proof.ts +28 -0
  75. package/src/prove/isabelle/isar/statement.ts +57 -0
  76. package/src/prove/isabelle/isar/theory.ts +192 -0
  77. package/src/prove/isabelle/isar/type-check.ts +278 -0
  78. package/src/prove/isabelle/provers/blast/blast.ts +258 -0
  79. package/src/prove/isabelle/provers/blast/branch.ts +322 -0
  80. package/src/prove/isabelle/provers/blast/prove.ts +347 -0
  81. package/src/prove/isabelle/provers/blast/rules.ts +330 -0
  82. package/src/prove/isabelle/provers/blast/state.ts +180 -0
  83. package/src/prove/isabelle/provers/blast/term.ts +546 -0
  84. package/src/prove/isabelle/provers/clasimp.ts +150 -0
  85. package/src/prove/isabelle/provers/classical.ts +389 -0
  86. package/src/prove/isabelle/provers/hypsubst.ts +433 -0
  87. package/src/prove/isabelle/pure/bicompose.ts +174 -0
  88. package/src/prove/isabelle/pure/consts.ts +32 -0
  89. package/src/prove/isabelle/pure/conv.ts +79 -0
  90. package/src/prove/isabelle/pure/drule.ts +264 -0
  91. package/src/prove/isabelle/pure/envir.ts +331 -0
  92. package/src/prove/isabelle/pure/goal.ts +53 -0
  93. package/src/prove/isabelle/pure/interrupt.ts +16 -0
  94. package/src/prove/isabelle/pure/list.ts +12 -0
  95. package/src/prove/isabelle/pure/logic.ts +330 -0
  96. package/src/prove/isabelle/pure/name.ts +98 -0
  97. package/src/prove/isabelle/pure/net.ts +215 -0
  98. package/src/prove/isabelle/pure/object-logic.ts +41 -0
  99. package/src/prove/isabelle/pure/pattern.ts +631 -0
  100. package/src/prove/isabelle/pure/raw-simplifier.ts +338 -0
  101. package/src/prove/isabelle/pure/rewriter.ts +602 -0
  102. package/src/prove/isabelle/pure/search.ts +68 -0
  103. package/src/prove/isabelle/pure/seq.ts +133 -0
  104. package/src/prove/isabelle/pure/simplifier.ts +106 -0
  105. package/src/prove/isabelle/pure/table.ts +201 -0
  106. package/src/prove/isabelle/pure/tactic.ts +168 -0
  107. package/src/prove/isabelle/pure/tactical.ts +264 -0
  108. package/src/prove/isabelle/pure/term-ord.ts +105 -0
  109. package/src/prove/isabelle/pure/term.ts +688 -0
  110. package/src/prove/isabelle/pure/thm.ts +783 -0
  111. package/src/prove/isabelle/pure/type.ts +121 -0
  112. package/src/prove/isabelle/pure/unify.ts +753 -0
  113. package/src/prove/isabelle/pure/variable.ts +25 -0
  114. package/src/prove/isabelle/tla/classical-setup.ts +101 -0
  115. package/src/prove/isabelle/tla/context.ts +74 -0
  116. package/src/prove/isabelle/tla/logic-data.ts +5 -0
  117. package/src/prove/isabelle/tla/logic.ts +215 -0
  118. package/src/prove/isabelle/tla/simpdata.ts +241 -0
  119. package/src/prove/isabelle/tools/intuitionistic.ts +132 -0
  120. package/src/prove/ocaml.ts +22 -0
  121. package/src/prove/prep/action.ts +508 -0
  122. package/src/prove/prep/defs.ts +33 -0
  123. package/src/prove/prep/elab.ts +156 -0
  124. package/src/prove/prep/enabled-axioms.ts +189 -0
  125. package/src/prove/prep/enabled.ts +43 -0
  126. package/src/prove/prep/fingerprint.ts +388 -0
  127. package/src/prove/prep/flatten.ts +70 -0
  128. package/src/prove/prep/level-comparison.ts +529 -0
  129. package/src/prove/prep/md5.ts +67 -0
  130. package/src/prove/prep/pragma.ts +221 -0
  131. package/src/prove/prep/trivial.ts +22 -0
  132. package/src/prove/prove-worker.ts +22 -0
  133. package/src/prove/prove.ts +498 -0
  134. package/src/prove/ptl/decide.ts +68 -0
  135. package/src/prove/ptl/encode.ts +255 -0
  136. package/src/prove/ptl/sat.ts +151 -0
  137. package/src/prove/ptl/tableau.ts +276 -0
  138. package/src/prove/smt/axiomatize.ts +69 -0
  139. package/src/prove/smt/axioms.ts +209 -0
  140. package/src/prove/smt/context.ts +108 -0
  141. package/src/prove/smt/data.ts +636 -0
  142. package/src/prove/smt/encode.ts +164 -0
  143. package/src/prove/smt/extensionality.ts +65 -0
  144. package/src/prove/smt/flatten.ts +112 -0
  145. package/src/prove/smt/format.ts +154 -0
  146. package/src/prove/smt/instances.ts +181 -0
  147. package/src/prove/smt/rewrite.ts +772 -0
  148. package/src/prove/smt/simplify.ts +57 -0
  149. package/src/prove/smt/solver/act-cache.ts +265 -0
  150. package/src/prove/smt/solver/arith-rewriter.ts +962 -0
  151. package/src/prove/smt/solver/array.ts +22 -0
  152. package/src/prove/smt/solver/asserted-formulas.ts +469 -0
  153. package/src/prove/smt/solver/ast-lt.ts +157 -0
  154. package/src/prove/smt/solver/ast-util.ts +91 -0
  155. package/src/prove/smt/solver/ast.ts +1315 -0
  156. package/src/prove/smt/solver/auf-solver.ts +572 -0
  157. package/src/prove/smt/solver/case-split-queue.ts +178 -0
  158. package/src/prove/smt/solver/cg-table.ts +175 -0
  159. package/src/prove/smt/solver/clause.ts +276 -0
  160. package/src/prove/smt/solver/conflict-resolution.ts +343 -0
  161. package/src/prove/smt/solver/context.ts +1292 -0
  162. package/src/prove/smt/solver/ctx-simplify.ts +334 -0
  163. package/src/prove/smt/solver/der.ts +224 -0
  164. package/src/prove/smt/solver/dyn-ack.ts +141 -0
  165. package/src/prove/smt/solver/e-matching.ts +659 -0
  166. package/src/prove/smt/solver/enode.ts +259 -0
  167. package/src/prove/smt/solver/expr-ref.ts +21 -0
  168. package/src/prove/smt/solver/expr-safe-replace.ts +172 -0
  169. package/src/prove/smt/solver/fingerprints.ts +92 -0
  170. package/src/prove/smt/solver/flat-literals.ts +51 -0
  171. package/src/prove/smt/solver/goal.ts +138 -0
  172. package/src/prove/smt/solver/hash.ts +173 -0
  173. package/src/prove/smt/solver/hashtable.ts +166 -0
  174. package/src/prove/smt/solver/internalizer.ts +1381 -0
  175. package/src/prove/smt/solver/lbool.ts +5 -0
  176. package/src/prove/smt/solver/literal.ts +24 -0
  177. package/src/prove/smt/solver/lp/bound-propagator.ts +391 -0
  178. package/src/prove/smt/solver/lp/constraints.ts +78 -0
  179. package/src/prove/smt/solver/lp/containers.ts +296 -0
  180. package/src/prove/smt/solver/lp/core-solver.ts +504 -0
  181. package/src/prove/smt/solver/lp/cross-nested.ts +224 -0
  182. package/src/prove/smt/solver/lp/dep-intervals.ts +642 -0
  183. package/src/prove/smt/solver/lp/dependency.ts +51 -0
  184. package/src/prove/smt/solver/lp/dioph-eq.ts +1181 -0
  185. package/src/prove/smt/solver/lp/explanation.ts +46 -0
  186. package/src/prove/smt/solver/lp/gomory.ts +255 -0
  187. package/src/prove/smt/solver/lp/hnf-cutter.ts +125 -0
  188. package/src/prove/smt/solver/lp/hnf.ts +281 -0
  189. package/src/prove/smt/solver/lp/int-cube.ts +295 -0
  190. package/src/prove/smt/solver/lp/int-solver.ts +514 -0
  191. package/src/prove/smt/solver/lp/lar-solver.ts +816 -0
  192. package/src/prove/smt/solver/lp/lar-term.ts +62 -0
  193. package/src/prove/smt/solver/lp/lp-settings.ts +91 -0
  194. package/src/prove/smt/solver/lp/maximize-term.ts +347 -0
  195. package/src/prove/smt/solver/lp/nex-creator.ts +381 -0
  196. package/src/prove/smt/solver/lp/nex.ts +120 -0
  197. package/src/prove/smt/solver/lp/nla-backoff.ts +43 -0
  198. package/src/prove/smt/solver/lp/nla-basics.ts +398 -0
  199. package/src/prove/smt/solver/lp/nla-core.ts +968 -0
  200. package/src/prove/smt/solver/lp/nla-divisions.ts +332 -0
  201. package/src/prove/smt/solver/lp/nla-emonics.ts +373 -0
  202. package/src/prove/smt/solver/lp/nla-factorization.ts +30 -0
  203. package/src/prove/smt/solver/lp/nla-grobner.ts +904 -0
  204. package/src/prove/smt/solver/lp/nla-horner.ts +126 -0
  205. package/src/prove/smt/solver/lp/nla-intervals.ts +265 -0
  206. package/src/prove/smt/solver/lp/nla-monomial-bounds.ts +715 -0
  207. package/src/prove/smt/solver/lp/nla-monotone.ts +59 -0
  208. package/src/prove/smt/solver/lp/nla-order.ts +307 -0
  209. package/src/prove/smt/solver/lp/nla-patcher.ts +112 -0
  210. package/src/prove/smt/solver/lp/nla-tangents.ts +251 -0
  211. package/src/prove/smt/solver/lp/nla-throttle.ts +85 -0
  212. package/src/prove/smt/solver/lp/nla-types.ts +124 -0
  213. package/src/prove/smt/solver/lp/nla-var-eqs.ts +141 -0
  214. package/src/prove/smt/solver/lp/nra-solver.ts +440 -0
  215. package/src/prove/smt/solver/lp/numeric-pair.ts +65 -0
  216. package/src/prove/smt/solver/lp/pdd-interval.ts +31 -0
  217. package/src/prove/smt/solver/lp/pdd-simplifier.ts +184 -0
  218. package/src/prove/smt/solver/lp/pdd-solver.ts +408 -0
  219. package/src/prove/smt/solver/lp/pdd.ts +971 -0
  220. package/src/prove/smt/solver/lp/random-updater.ts +138 -0
  221. package/src/prove/smt/solver/lp/static-matrix.ts +246 -0
  222. package/src/prove/smt/solver/lp/union-find.ts +96 -0
  223. package/src/prove/smt/solver/mam-compiler.ts +847 -0
  224. package/src/prove/smt/solver/mam-interpreter.ts +400 -0
  225. package/src/prove/smt/solver/maximize-ac-sharing.ts +118 -0
  226. package/src/prove/smt/solver/model-checker.ts +347 -0
  227. package/src/prove/smt/solver/model-evaluator.ts +262 -0
  228. package/src/prove/smt/solver/model-finder.ts +155 -0
  229. package/src/prove/smt/solver/model-generator.ts +97 -0
  230. package/src/prove/smt/solver/model-macro-solver.ts +728 -0
  231. package/src/prove/smt/solver/nlsat/algebraic.ts +1161 -0
  232. package/src/prove/smt/solver/nlsat/atoms.ts +238 -0
  233. package/src/prove/smt/solver/nlsat/evaluator.ts +303 -0
  234. package/src/prove/smt/solver/nlsat/explain.ts +607 -0
  235. package/src/prove/smt/solver/nlsat/interval-set.ts +351 -0
  236. package/src/prove/smt/solver/nlsat/levelwise.ts +737 -0
  237. package/src/prove/smt/solver/nlsat/mpbq.ts +161 -0
  238. package/src/prove/smt/solver/nlsat/polynomial.ts +1722 -0
  239. package/src/prove/smt/solver/nlsat/solver.ts +911 -0
  240. package/src/prove/smt/solver/nlsat/types.ts +43 -0
  241. package/src/prove/smt/solver/nlsat/upolynomial-factorization.ts +648 -0
  242. package/src/prove/smt/solver/nlsat/upolynomial.ts +996 -0
  243. package/src/prove/smt/solver/nnf.ts +469 -0
  244. package/src/prove/smt/solver/pattern-inference.ts +351 -0
  245. package/src/prove/smt/solver/poly-rewriter.ts +477 -0
  246. package/src/prove/smt/solver/propagate-values.ts +83 -0
  247. package/src/prove/smt/solver/proto-model.ts +551 -0
  248. package/src/prove/smt/solver/pull-quant.ts +139 -0
  249. package/src/prove/smt/solver/qe-lite-der.ts +526 -0
  250. package/src/prove/smt/solver/qe-lite-fm.ts +576 -0
  251. package/src/prove/smt/solver/qe-lite.ts +381 -0
  252. package/src/prove/smt/solver/qi-queue.ts +362 -0
  253. package/src/prove/smt/solver/quant-tactics.ts +117 -0
  254. package/src/prove/smt/solver/quantifier-analyzer.ts +562 -0
  255. package/src/prove/smt/solver/quantifier-manager.ts +186 -0
  256. package/src/prove/smt/solver/random-gen.ts +10 -0
  257. package/src/prove/smt/solver/rational.ts +165 -0
  258. package/src/prove/smt/solver/ref-vector.ts +62 -0
  259. package/src/prove/smt/solver/relevancy.ts +247 -0
  260. package/src/prove/smt/solver/rewriter-tpl.ts +1159 -0
  261. package/src/prove/smt/solver/rewriter.ts +843 -0
  262. package/src/prove/smt/solver/rlimit.ts +79 -0
  263. package/src/prove/smt/solver/smtlib-parser.ts +526 -0
  264. package/src/prove/smt/solver/solver.ts +71 -0
  265. package/src/prove/smt/solver/sort.ts +35 -0
  266. package/src/prove/smt/solver/sticky-generations.ts +69 -0
  267. package/src/prove/smt/solver/theory-lra-axioms.ts +340 -0
  268. package/src/prove/smt/solver/theory-lra-bounds.ts +226 -0
  269. package/src/prove/smt/solver/theory-lra-final-check.ts +252 -0
  270. package/src/prove/smt/solver/theory-lra-internalize.ts +476 -0
  271. package/src/prove/smt/solver/theory-lra-model.ts +243 -0
  272. package/src/prove/smt/solver/theory-lra-propagate.ts +405 -0
  273. package/src/prove/smt/solver/theory-lra-state.ts +43 -0
  274. package/src/prove/smt/solver/theory-lra.ts +56 -0
  275. package/src/prove/smt/solver/var-subst.ts +258 -0
  276. package/src/prove/smt/solver/z3-license.txt +10 -0
  277. package/src/prove/smt/table.ts +170 -0
  278. package/src/prove/tlapm/cache.ts +236 -0
  279. package/src/prove/tlapm/ocaml-marshal.ts +166 -0
  280. package/src/prove/tlapm/tlapm.ts +96 -0
  281. package/src/prove/tlaps-module.ts +510 -0
  282. package/src/prove/verdict.ts +18 -0
  283. package/src/prove/zenon/LICENSE +32 -0
  284. package/src/prove/zenon/check/check.ts +105 -0
  285. package/src/prove/zenon/check/definitions.ts +144 -0
  286. package/src/prove/zenon/check/equality.ts +182 -0
  287. package/src/prove/zenon/check/functions.ts +62 -0
  288. package/src/prove/zenon/check/keys.ts +125 -0
  289. package/src/prove/zenon/check/propositional.ts +104 -0
  290. package/src/prove/zenon/check/records.ts +188 -0
  291. package/src/prove/zenon/check/relations.ts +121 -0
  292. package/src/prove/zenon/check/rewrites.ts +224 -0
  293. package/src/prove/zenon/check/sets.ts +302 -0
  294. package/src/prove/zenon/check/terms.ts +127 -0
  295. package/src/prove/zenon/check/tla.ts +126 -0
  296. package/src/prove/zenon/decide.ts +113 -0
  297. package/src/prove/zenon/encode.ts +379 -0
  298. package/src/prove/zenon/eqrel.ts +300 -0
  299. package/src/prove/zenon/equality-rules.ts +435 -0
  300. package/src/prove/zenon/expr.ts +551 -0
  301. package/src/prove/zenon/index-table.ts +350 -0
  302. package/src/prove/zenon/isar-case.ts +513 -0
  303. package/src/prove/zenon/isar.ts +1249 -0
  304. package/src/prove/zenon/limits.ts +15 -0
  305. package/src/prove/zenon/llproof.ts +173 -0
  306. package/src/prove/zenon/mltoll.ts +1566 -0
  307. package/src/prove/zenon/node.ts +297 -0
  308. package/src/prove/zenon/ocaml.ts +169 -0
  309. package/src/prove/zenon/parse.ts +247 -0
  310. package/src/prove/zenon/phrase.ts +191 -0
  311. package/src/prove/zenon/proof.ts +198 -0
  312. package/src/prove/zenon/propositional-rules.ts +387 -0
  313. package/src/prove/zenon/rules.ts +94 -0
  314. package/src/prove/zenon/search.ts +288 -0
  315. package/src/prove/zenon/tla/functions.ts +151 -0
  316. package/src/prove/zenon/tla/llproof.ts +480 -0
  317. package/src/prove/zenon/tla/records.ts +225 -0
  318. package/src/prove/zenon/tla/rewrites.ts +447 -0
  319. package/src/prove/zenon/tla/sets.ts +304 -0
  320. package/src/prove/zenon/tla/terms.ts +162 -0
  321. package/src/prove/zenon/tla/tla.ts +506 -0
  322. package/src/randomization.ts +1 -1
  323. package/src/resolve.ts +1 -1
  324. package/src/runtime.ts +2 -2
  325. package/src/{sany-builtins.ts → sany/builtins.ts} +1 -1
  326. package/src/{sany-generator.ts → sany/generator.ts} +14 -14
  327. package/src/{sany-levels.ts → sany/levels.ts} +2 -2
  328. package/src/{sany-lexer.ts → sany/lexer.ts} +1 -1
  329. package/src/{sany-linter.ts → sany/linter.ts} +1 -1
  330. package/src/{sany-modules.ts → sany/modules.ts} +2 -2
  331. package/src/{sany-parse-error.ts → sany/parse-error.ts} +2 -2
  332. package/src/{sany-report.ts → sany/report.ts} +15 -15
  333. package/src/{sany-selectors.ts → sany/selectors.ts} +3 -3
  334. package/src/{sany-source.ts → sany/source.ts} +6 -6
  335. package/src/{sany-xml.ts → sany/xml.ts} +5 -5
  336. package/src/spec-description.ts +1 -1
  337. package/src/{standard-levels.ts → standard/levels.ts} +1 -1
  338. package/src/{standard-modules.ts → standard/modules.ts} +12 -12
  339. package/src/{standard-ranges.ts → standard/ranges.ts} +1 -1
  340. package/src/state-graph.ts +1 -1
  341. package/src/successors.ts +1 -1
  342. package/src/symmetry.ts +1 -1
  343. package/src/{tlc-messages.ts → tlc/messages.ts} +2 -2
  344. package/src/{tlc-order.ts → tlc/order.ts} +7 -7
  345. package/src/{tlc-random.ts → tlc/random.ts} +3 -3
  346. package/src/{tlc-replay.ts → tlc/replay.ts} +5 -5
  347. package/src/{tlc-module.ts → tlc/tlc-operators.ts} +9 -9
  348. package/src/{tlc-ext.ts → tlc/tlcext-operators.ts} +14 -8
  349. package/src/values.ts +1 -1
  350. package/src/worker.ts +65 -0
  351. package/dist/parallel.cjs +0 -12
  352. package/dist/parallel.js +0 -12
  353. package/dist/run-cli.cjs +0 -55
  354. package/dist/run-cli.js +0 -55
  355. package/src/value-sources.ts +0 -29
  356. /package/src/{sany-nodes.ts → sany/nodes.ts} +0 -0
  357. /package/src/{tlc-modules.ts → tlc/jar-data.ts} +0 -0
  358. /package/src/{tlc-summary.ts → tlc/summary.ts} +0 -0
  359. /package/src/{tlc-version.ts → tlc/version.ts} +0 -0
@@ -1,21 +1,21 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import { basename } from "node:path";
3
- import type { Module } from "./ast";
4
- import { TlaSyntaxError, PcalRuntimeError, TlaSanyFatalError } from "./errors";
5
- import { extractModule, parseSanyModule } from "./parser";
6
- import { createPcalParams } from "./pcal-ast";
7
- import { createPcalSession } from "./pcal-parse";
8
- import { validatePcalModule } from "./pcal-validate";
9
- import { generateSanySpecification, type SanySpecification } from "./sany-generator";
10
- import { checkModuleLevels } from "./sany-levels";
11
- import { getSany174LexicalError } from "./sany-lexer";
12
- import { lintSanyModule } from "./sany-linter";
13
- import { getSanyStandardModules } from "./sany-modules";
14
- import { formatSanyLocation, type SanyMessage } from "./sany-nodes";
15
- import { getUnboxedSource } from "./sany-source";
16
- import type { TlcVersion } from "./tlc-version";
3
+ import type { Module } from "../ast";
4
+ import { TlaSyntaxError, PcalRuntimeError, TlaSanyFatalError } from "../errors";
5
+ import { extractModule, parseSanyModule } from "../parser";
6
+ import { createPcalParams } from "../pcal/ast";
7
+ import { createPcalSession } from "../pcal/parse";
8
+ import { validatePcalModule } from "../pcal/validate";
9
+ import { generateSanySpecification, type SanySpecification } from "./generator";
10
+ import { checkModuleLevels } from "./levels";
11
+ import { getSany174LexicalError } from "./lexer";
12
+ import { lintSanyModule } from "./linter";
13
+ import { getSanyStandardModules } from "./modules";
14
+ import { formatSanyLocation, type SanyMessage } from "./nodes";
15
+ import { getUnboxedSource } from "./source";
16
+ import type { TlcVersion } from "../tlc/version";
17
17
 
18
- export interface SanyReport {
18
+ interface SanyReport {
19
19
  text: string;
20
20
  isFailed: boolean;
21
21
  // The specification SANY analyzes, which has errors when SANY rejects it.
@@ -1,5 +1,5 @@
1
- import type { Expression } from "./ast";
2
- import type { TlcVersion } from "./tlc-version";
1
+ import type { Expression } from "../ast";
2
+ import type { TlcVersion } from "../tlc/version";
3
3
  import {
4
4
  CONSTANT_DECL_KIND,
5
5
  getContextSymbol,
@@ -19,7 +19,7 @@ import {
19
19
  type SubstInNode,
20
20
  type SymbolNode,
21
21
  type ThmOrAssumpDefNode,
22
- } from "./sany-nodes";
22
+ } from "./nodes";
23
23
 
24
24
  // A port of SANY's Generator.selectorToNode, which turns a name such as Op(a)!lab(b)!:!2 into the
25
25
  // semantic node it names, following the Subexpression algorithm of SANY's Subexpression.tla.
@@ -1,9 +1,9 @@
1
- import type { Expression, SourceLocation, SourceRange } from "./ast";
2
- import { TlaSyntaxError } from "./errors";
3
- import { readAtAsIdentifier, tokenize, type Token } from "./lexer";
4
- import { getTabStop } from "./sany-lexer";
5
- import { getSanyParseError } from "./sany-parse-error";
6
- import type { SanyLocation } from "./sany-nodes";
1
+ import type { Expression, SourceLocation, SourceRange } from "../ast";
2
+ import { TlaSyntaxError } from "../errors";
3
+ import { readAtAsIdentifier, tokenize, type Token } from "../lexer";
4
+ import { getTabStop } from "./lexer";
5
+ import { getSanyParseError } from "./parse-error";
6
+ import type { SanyLocation } from "./nodes";
7
7
 
8
8
  // The tokens of one file, to find the locations SANY gives to names, brackets and parentheses that
9
9
  // the syntax tree of tla-ts leaves out, and the comments SANY attaches to definitions.
@@ -1,7 +1,7 @@
1
- import { TlaJavaException, TlaUnsupportedError } from "./errors";
2
- import { setExitCode } from "./exit-codes";
3
- import type { TlcVersion } from "./tlc-version";
4
- import type { SanySpecification } from "./sany-generator";
1
+ import { TlaJavaException, TlaUnsupportedError } from "../errors";
2
+ import { setExitCode } from "../exit-codes";
3
+ import type { TlcVersion } from "../tlc/version";
4
+ import type { SanySpecification } from "./generator";
5
5
  import {
6
6
  CONSTANT_DECL_KIND,
7
7
  VARIABLE_DECL_KIND,
@@ -23,7 +23,7 @@ import {
23
23
  type ProofPartNode,
24
24
  type InstanceNode,
25
25
  type UseOrHideNode,
26
- } from "./sany-nodes";
26
+ } from "./nodes";
27
27
 
28
28
  // XMLExporterExitCode, and the status Java exits with on an exception that nothing catches.
29
29
  export const XML_EXPORT_EXIT_CODE = {
@@ -24,7 +24,7 @@ import {
24
24
  import { TEMPORAL_LEVEL } from "./levels";
25
25
  import { getLevel } from "./liveness";
26
26
  import { createRecord, createSet, createTuple, formatValue, type Value } from "./values";
27
- import type { TlcVersion } from "./tlc-version";
27
+ import type { TlcVersion } from "./tlc/version";
28
28
 
29
29
  export interface SpecAction {
30
30
  name: string;
@@ -1,4 +1,4 @@
1
- import type { OperatorLevels } from "./levels";
1
+ import type { OperatorLevels } from "../levels";
2
2
 
3
3
  type Signature =
4
4
  | [string, number, number[], number[], number[]]
@@ -1,4 +1,4 @@
1
- import { TlaEvaluationError, TlaModuleError } from "./errors";
1
+ import { TlaEvaluationError, TlaModuleError } from "../errors";
2
2
  import {
3
3
  createOverflowError,
4
4
  defineArithmetic,
@@ -16,15 +16,15 @@ import {
16
16
  getValue,
17
17
  isOutOfRange,
18
18
  overrideWithJava,
19
- } from "./builtins";
20
- import type { Builtin, BuiltinArgument } from "./evaluate";
21
- import type { CheckerRuntime } from "./runtime";
22
- import { createBagsOperators } from "./bags";
23
- import { createJsonOperators, type FileSystem } from "./json";
24
- import { createRandomizationOperators } from "./randomization";
25
- import { createPossibleOperators, createTlcExtOperators } from "./tlc-ext";
26
- import { createTlcOperators } from "./tlc-module";
27
- import { TLC_JAVA_METHODS } from "./tlc-modules";
19
+ } from "../builtins";
20
+ import type { Builtin, BuiltinArgument } from "../evaluate";
21
+ import type { CheckerRuntime } from "../runtime";
22
+ import { createBagsOperators } from "../bags";
23
+ import { createJsonOperators, type FileSystem } from "../json";
24
+ import { createRandomizationOperators } from "../randomization";
25
+ import { createPossibleOperators, createTlcExtOperators } from "../tlc/tlcext-operators";
26
+ import { createTlcOperators } from "../tlc/tlc-operators";
27
+ import { TLC_JAVA_METHODS } from "../tlc/jar-data";
28
28
  import {
29
29
  createSet,
30
30
  describeKind,
@@ -56,8 +56,8 @@ import {
56
56
  type SetValue,
57
57
  type Value,
58
58
  rankString,
59
- } from "./values";
60
- import type { TlcVersion } from "./tlc-version";
59
+ } from "../values";
60
+ import type { TlcVersion } from "../tlc/version";
61
61
 
62
62
  interface StandardModule {
63
63
  extends: string[];
@@ -1,4 +1,4 @@
1
- import type { SourceRange } from "./ast";
1
+ import type { SourceRange } from "../ast";
2
2
 
3
3
  // Where the modules in TLC's tla2sany/StandardModules define the operators that tla-ts implements
4
4
  // natively, which SANY reports when a spec defines one of them again.
@@ -1,6 +1,6 @@
1
1
  // A port of TLC's -dump writers, tlc2.util.StateWriter and tlc2.util.DotStateWriter.
2
2
 
3
- import type { TlcVersion } from "./tlc-version";
3
+ import type { TlcVersion } from "./tlc/version";
4
4
 
5
5
  export interface StateDump {
6
6
  path: string;
package/src/successors.ts CHANGED
@@ -38,7 +38,7 @@ import {
38
38
  type State,
39
39
  } from "./evaluate";
40
40
  import { mapChildren } from "./instances";
41
- import { isAssignedShortcut, LITERAL_KINDS, replayEnabled } from "./tlc-replay";
41
+ import { isAssignedShortcut, LITERAL_KINDS, replayEnabled } from "./tlc/replay";
42
42
  import {
43
43
  formatValue,
44
44
  getStreamedElements,
package/src/symmetry.ts CHANGED
@@ -2,7 +2,7 @@ import type { Expression } from "./ast";
2
2
  import type { Substitution } from "./config";
3
3
  import { TlaConfigError, TlaEvaluationError, UNEXPECTED_EXCEPTION } from "./errors";
4
4
  import { EXIT_STATUS, setExitCode } from "./exit-codes";
5
- import { MESSAGE_CODE } from "./tlc-messages";
5
+ import { MESSAGE_CODE } from "./tlc/messages";
6
6
  import { evaluate, type Environment } from "./evaluate";
7
7
  import {
8
8
  compareValues,
@@ -1,5 +1,5 @@
1
- import { STACK_OVERFLOW_MESSAGE, TlaModuleError, type TlaEvaluationError } from "./errors";
2
- import type { TlcVersion } from "./tlc-version";
1
+ import { STACK_OVERFLOW_MESSAGE, TlaModuleError, type TlaEvaluationError } from "../errors";
2
+ import type { TlcVersion } from "./version";
3
3
 
4
4
  // TLC's codes for the messages it prints, from tlc2.output.EC.
5
5
  export const MESSAGE_CODE = {
@@ -1,11 +1,11 @@
1
1
  // TLC orders strings and model values by when it first interned their text, and compares a
2
2
  // state's variables in the order of SANY's symbol table. This reproduces both orders.
3
- import type { Module, SourceLocation } from "./ast";
4
- import type { ConfigValue, ModelConfig } from "./config";
5
- import { createMissingModuleError } from "./errors";
6
- import { tokenize, type Token } from "./lexer";
7
- import { extractModule, parseModule } from "./parser";
8
- import { isBefore } from "./resolve";
3
+ import type { Module, SourceLocation } from "../ast";
4
+ import type { ConfigValue, ModelConfig } from "../config";
5
+ import { createMissingModuleError } from "../errors";
6
+ import { tokenize, type Token } from "../lexer";
7
+ import { extractModule, parseModule } from "../parser";
8
+ import { isBefore } from "../resolve";
9
9
  import {
10
10
  SANY_BUILTINS,
11
11
  SANY_NODE_NAMES,
@@ -14,7 +14,7 @@ import {
14
14
  TLC_RUNTIME_STRINGS,
15
15
  TLC_STARTUP_STRINGS,
16
16
  USER_STANDARD_MODULES,
17
- } from "./tlc-modules";
17
+ } from "./jar-data";
18
18
 
19
19
  type SymbolKind = "builtin" | "constant" | "variable" | "definition" | "theorem" | "module";
20
20
 
@@ -1,5 +1,5 @@
1
- import { TlaEvaluationError } from "./errors";
2
- import type { TlcVersion } from "./tlc-version";
1
+ import { TlaEvaluationError } from "../errors";
2
+ import type { TlcVersion } from "./version";
3
3
  import {
4
4
  createRecord,
5
5
  createSortedFunction,
@@ -12,7 +12,7 @@ import {
12
12
  toFiniteFunction,
13
13
  toFiniteSet,
14
14
  type Value,
15
- } from "./values";
15
+ } from "../values";
16
16
 
17
17
  export interface JavaRandom {
18
18
  setSeed: (seed: bigint) => void;
@@ -1,5 +1,5 @@
1
- import type { Expression, SourceLocation } from "./ast";
2
- import { TlaEvaluationError } from "./errors";
1
+ import type { Expression, SourceLocation } from "../ast";
2
+ import { TlaEvaluationError } from "../errors";
3
3
  import {
4
4
  bindDefinitions,
5
5
  bindLazyArguments,
@@ -19,8 +19,8 @@ import {
19
19
  type Scope,
20
20
  type State,
21
21
  toUnspecifiedSubscriptError,
22
- } from "./evaluate";
23
- import { getStreamedElements, isTlcEnumerable, setTrace, valuesEqual, type Value } from "./values";
22
+ } from "../evaluate";
23
+ import { getStreamedElements, isTlcEnumerable, setTrace, valuesEqual, type Value } from "../values";
24
24
 
25
25
  // When TLC fails to compute the initial states or the successors of a state, it computes them
26
26
  // again with its CallStackTool, which records each node it visits, and prints where the failure
@@ -28,7 +28,7 @@ import { getStreamedElements, isTlcEnumerable, setTrace, valuesEqual, type Value
28
28
  // Tool.getNextStates do, in their order and with their nesting, so that it records the nodes TLC
29
29
  // records. It evaluates the other expressions with an environment that records the nodes too.
30
30
 
31
- export interface ReplayAction {
31
+ interface ReplayAction {
32
32
  expression: Expression;
33
33
  scope: Scope | undefined;
34
34
  }
@@ -1,7 +1,7 @@
1
- import { TlaModuleError } from "./errors";
2
- import { EXIT_STATUS } from "./exit-codes";
3
- import type { Builtin, Context } from "./evaluate";
4
- import { prettyPrint } from "./pretty-print";
1
+ import { TlaModuleError } from "../errors";
2
+ import { EXIT_STATUS } from "../exit-codes";
3
+ import type { Builtin, Context } from "../evaluate";
4
+ import { prettyPrint } from "../pretty-print";
5
5
  import {
6
6
  defineConstant,
7
7
  defineHigherOrderOperator,
@@ -16,10 +16,10 @@ import {
16
16
  getThunk,
17
17
  getValue,
18
18
  overrideWithJava,
19
- } from "./builtins";
20
- import { getNamedRegisters, NAMED_REGISTER_PREFIX, type CheckerRuntime } from "./runtime";
21
- import { createActionRecord, setTlcValue } from "./tlc-ext";
22
- import { getRandomElement } from "./tlc-random";
19
+ } from "../builtins";
20
+ import { getNamedRegisters, NAMED_REGISTER_PREFIX, type CheckerRuntime } from "../runtime";
21
+ import { createActionRecord, setTlcValue } from "./tlcext-operators";
22
+ import { getRandomElement } from "./random";
23
23
  import {
24
24
  ANY_SET,
25
25
  createFunction,
@@ -32,7 +32,7 @@ import {
32
32
  toFiniteSet,
33
33
  type Value,
34
34
  rankString,
35
- } from "./values";
35
+ } from "../values";
36
36
 
37
37
  const padTime = (value: number) => String(value).padStart(2, "0");
38
38
 
@@ -7,18 +7,24 @@ import {
7
7
  getOperator,
8
8
  getThunk,
9
9
  getValue,
10
- } from "./builtins";
11
- import { TlaEvaluationError, TlaModuleError, TlaUnsupportedError } from "./errors";
12
- import { getTlcFingerprint } from "./tlc-random";
13
- import { formatNestedMessage } from "./tlc-messages";
14
- import { evaluate, expectBoolean, getDefinition, type Builtin, type Environment } from "./evaluate";
15
- import { getChildren, isLocallyResolved, type Definition, type Expression } from "./ast";
10
+ } from "../builtins";
11
+ import { TlaEvaluationError, TlaModuleError, TlaUnsupportedError } from "../errors";
12
+ import { getTlcFingerprint } from "./random";
13
+ import { formatNestedMessage } from "./messages";
14
+ import {
15
+ evaluate,
16
+ expectBoolean,
17
+ getDefinition,
18
+ type Builtin,
19
+ type Environment,
20
+ } from "../evaluate";
21
+ import { getChildren, isLocallyResolved, type Definition, type Expression } from "../ast";
16
22
  import {
17
23
  getNamedRegisters,
18
24
  getPossibleCounts,
19
25
  NAMED_REGISTER_PREFIX,
20
26
  type CheckerRuntime,
21
- } from "./runtime";
27
+ } from "../runtime";
22
28
  import {
23
29
  applyFunction,
24
30
  createModelValue,
@@ -33,7 +39,7 @@ import {
33
39
  toFiniteSet,
34
40
  valuesEqual,
35
41
  type Value,
36
- } from "./values";
42
+ } from "../values";
37
43
 
38
44
  const OVERRIDE_PARAMETERS =
39
45
  "tlc2.tool.impl.Tool,tla2sany.semantic.ExprOrOpArgNode[],tlc2.util.Context,tlc2.tool.TLCState,tlc2.tool.TLCState,int,tlc2.tool.coverage.CostModel";
package/src/values.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { TlaEvaluationError, TlaModuleError } from "./errors";
2
2
  import { prettyPrint } from "./pretty-print";
3
- import type { TlcVersion } from "./tlc-version";
3
+ import type { TlcVersion } from "./tlc/version";
4
4
 
5
5
  export interface ModelValue {
6
6
  kind: "ModelValue";
package/src/worker.ts ADDED
@@ -0,0 +1,65 @@
1
+ // Worker threads as Web Workers, or as Node's worker_threads where there are none.
2
+
3
+ const WORKER_THREADS_MODULE = "node:worker_threads";
4
+
5
+ export interface Port {
6
+ postMessage: (message: unknown, transfer?: unknown[]) => void;
7
+ addEventListener: (type: "message", listener: (event: { data: unknown }) => void) => void;
8
+ removeEventListener?: (type: "message", listener: (event: { data: unknown }) => void) => void;
9
+ start?: () => void;
10
+ }
11
+
12
+ export interface WorkerHandle {
13
+ postMessage: (message: unknown, transfer?: unknown[]) => void;
14
+ terminate: () => void;
15
+ }
16
+
17
+ interface WebWorker {
18
+ postMessage: (message: unknown, transfer?: unknown[]) => void;
19
+ addEventListener: (type: string, listener: (event: { data: unknown }) => void) => void;
20
+ terminate: () => void;
21
+ }
22
+
23
+ declare const Worker: new (url: URL, options: { type: "module" }) => WebWorker;
24
+
25
+ // Whether this runtime runs workers: Web Workers, or Node's.
26
+ export const isWorkerSupported = () =>
27
+ typeof Worker === "function" ||
28
+ (typeof process !== "undefined" && process.versions?.node !== undefined);
29
+
30
+ // Starts the worker at url, which the caller writes as new URL("./name.js", import.meta.url) for
31
+ // bundlers to find. onError receives what the worker threw.
32
+ export const spawnWorker = async (
33
+ url: URL,
34
+ onMessage: (message: unknown) => void,
35
+ onError: (error: unknown) => void,
36
+ ): Promise<WorkerHandle> => {
37
+ if (typeof Worker === "function") {
38
+ const worker = new Worker(url, { type: "module" });
39
+ worker.addEventListener("message", (event) => onMessage(event.data));
40
+ worker.addEventListener("error", onError);
41
+ return worker;
42
+ }
43
+ const threads: typeof import("node:worker_threads") = await import(
44
+ /* @vite-ignore */ /* webpackIgnore: true */ WORKER_THREADS_MODULE
45
+ );
46
+ const worker = new threads.Worker(url);
47
+ worker.on("message", onMessage);
48
+ worker.on("error", onError);
49
+ return {
50
+ postMessage: (message, transfer) =>
51
+ worker.postMessage(message, transfer as Parameters<typeof worker.postMessage>[1]),
52
+ terminate: () => void worker.terminate(),
53
+ };
54
+ };
55
+
56
+ // The port a worker receives its messages on and posts its own to.
57
+ export const getParentPort = async () => {
58
+ if (typeof (globalThis as { postMessage?: unknown }).postMessage === "function") {
59
+ return globalThis as unknown as Port;
60
+ }
61
+ const threads: typeof import("node:worker_threads") = await import(
62
+ /* @vite-ignore */ /* webpackIgnore: true */ WORKER_THREADS_MODULE
63
+ );
64
+ return threads.parentPort as unknown as Port;
65
+ };
package/dist/parallel.cjs DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * @license tla-ts
3
- *
4
- * Copyright (c) Aiden Bai
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- */
9
- const e=require("./transfer.cjs"),t=async e=>{if(typeof Worker==`function`){let t=new Worker(new URL(`./parallel-worker.js`,require("url").pathToFileURL(__filename).href),{type:`module`});return t.addEventListener(`message`,t=>e(t.data)),t.addEventListener(`error`,()=>e({type:`abort`})),t}let t=new(await(import(
10
- /* @vite-ignore */
11
- /* webpackIgnore: true */
12
- `node:worker_threads`))).Worker(new URL(`./parallel-worker.js`,require("url").pathToFileURL(__filename).href));return t.on(`message`,e),t.on(`error`,()=>e({type:`abort`})),{postMessage:(e,n)=>t.postMessage(e,n),terminate:()=>void t.terminate()}},n=async n=>{let r=typeof n.config==`string`?e.Q(n.config,n.version):n.config,i=n.onPrint??console.log,a={count:0},o=e=>[e.kind,`name`in e?e.name:``,`count`in e?e.count:``,`text`in e?e.text:``].join(` `),s=/* @__PURE__ */ new Set,c=e=>{s.add(o(e)),n.onProgress?.(e)},l=()=>{let t={count:a.count};return e.l({...n,config:r,onPrint:e=>t.count-->0?void 0:i(e),onProgress:e=>{s.has(o(e))||n.onProgress?.(e)}})},u=n.workers??1;if(u<2||typeof SharedArrayBuffer!=`function`||n.dump!==void 0||r.view!==void 0||r.postconditions.length>0||r.possible.length>0)return l();let d=/* @__PURE__ */ new Map,f=e=>{let t=n.loadModule?.(e);return d.set(e,t),t},p=/* @__PURE__ */ new Map,m=e=>{let t=n.loadClass?.(e);return p.set(e,t),t};e.X(e.x(n.source,r,f)),e.Z(n.version);let h=e.Y(),g=e.y(r,{source:n.source,loadModule:f,loadClass:m,print:e=>{a.count++,i(e)},files:{readFile:n.readFile,writeFile:n.writeFile},isTool:n.isTool,isTraceRecorded:n.isTraceRecorded,isSanyReported:n.isSanyReported,isWarningEnabled:n.isWarningEnabled,version:n.version});e.p(g,r,c);let _=g.environment,v=e.u(r,_,()=>e.S(n.source,f),c);if(e.d(g.assumptions,_)||!v||v.spec.init===void 0||v.spec.next===void 0||v.properties.liveness.length>0||e.P(_))return l();let y=e.K(),b={fingerprints:e.i()},x=/* @__PURE__ */ new Int32Array(2),S=Array.from({length:u},e.n),C={generatedStates:0,distinctStates:0,queuedStates:0,depth:0,initialStates:void 0,outDegrees:Array.from({length:32},()=>0)},w=[],T=()=>({status:`success`,violation:void 0,failure:void 0,...C,fingerprintDistance:e.g(C.distinctStates,C.generatedStates,()=>{let e=new BigInt64Array(C.distinctStates);return w.reduce((t,n)=>(e.set(n,t),t+n.length),0),e})}),E=t=>{let n=[];for(let r of e.F(t,_,v.spec.scope))if(e.f(C.generatedStates,c),y(r),C.generatedStates++,e.c(v.getFingerprintState(r),x),e.s(b.fingerprints)&&(b.fingerprints=e.a(b.fingerprints)),e.o(b.fingerprints,x[0],x[1])){if(v.findViolatedInvariant(r)||v.findFailedInitialPredicate(r))return!1;if(v.satisfiesConstraints(r)){if(!S[n.length%u].encode(r))return!1;n.push(r),C.distinctStates++}}return w.push(BigInt64Array.from(n,e=>_.runtime.getFingerprint(e))),!0};c({kind:`initial-states-started`});try{if(!E(v.spec.init))return l()}catch(t){if(!(t instanceof e.ct))throw t;return l()}if(e.Y()!==h)return l();if(C.depth=C.generatedStates===0?0:1,C.initialStates={generated:C.generatedStates,distinct:C.distinctStates},c({kind:`initial-states-computed`,initialStates:C.initialStates}),C.distinctStates===0)return T();let D=[],O={count:u,resolve:e=>{}},k=e=>{D.push(e),(e.type===`abort`||D.length===O.count)&&O.resolve(D.splice(0))},A=e=>new Promise(t=>{O.count=e,O.resolve=t}),j=A(u),M=new Int32Array(new SharedArrayBuffer(u*4)),N=new Int32Array(new SharedArrayBuffer(u*4)),P=await Promise.all(Array.from({length:u},()=>t(k))),F=()=>P.forEach(e=>e.terminate()),I=/* @__PURE__ */ new Map,L=(e,t)=>{let n=e<t?`${e}:${t}`:`${t}:${e}`,r=I.get(n)??new MessageChannel;return I.set(n,r),e<t?r.port1:r.port2};P.forEach((e,t)=>{let i=Array.from({length:u},(e,n)=>n===t?void 0:L(t,n)),a=S[t].finish(),o={type:`start`,source:n.source,config:r,modules:[...d],classes:[...p],index:t,ports:i,seed:a,isTool:n.isTool,isTraceRecorded:n.isTraceRecorded,isWarningEnabled:n.isWarningEnabled,version:n.version,fingerprints:b.fingerprints,requests:M,remaining:N};e.postMessage(o,[...i.filter(e=>e!==void 0),a.words.buffer])});let R=e=>e.some(e=>e.type===`abort`),z=e=>P.forEach(t=>t.postMessage(e)),B=async t=>{let n=t.filter(e=>e.type===`paused`).length;if(n===0||R(t))return t;b.fingerprints=e.a(b.fingerprints);let r=A(n);return z({type:`resize`,fingerprints:b.fingerprints}),[...t.filter(e=>e.type!==`paused`),...await B(await r)]};if(R(await j))return F(),l();for(let e=1;;e++){let t=A(u);M.forEach((e,t)=>Atomics.store(M,t,0)),z({type:`level`,level:e});let n=await B(await t);if(R(n))return F(),l();let r=n.flatMap(e=>e.type===`level`?[e]:[]),i=r.reduce((e,t)=>e+t.added,0);if(C.generatedStates+=r.reduce((e,t)=>e+t.generated,0),C.distinctStates+=i,r.forEach(e=>{e.outDegrees.forEach((e,t)=>C.outDegrees[t]+=e),w.push(e.fingerprints)}),i===0)return F(),T();C.depth++}};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
package/dist/parallel.js DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * @license tla-ts
3
- *
4
- * Copyright (c) Aiden Bai
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- */
9
- import{F as e,K as t,P as n,Q as r,S as i,X as ee,Y as a,Z as o,a as s,c,ct as te,d as l,f as u,g as d,i as f,l as p,n as ne,o as m,p as re,s as ie,u as ae,x as h,y as g}from"./transfer.js";const _=async e=>{if(typeof Worker==`function`){let t=new Worker(new URL(`./parallel-worker.js`,import.meta.url),{type:`module`});return t.addEventListener(`message`,t=>e(t.data)),t.addEventListener(`error`,()=>e({type:`abort`})),t}let t=new(await(import(
10
- /* @vite-ignore */
11
- /* webpackIgnore: true */
12
- `node:worker_threads`))).Worker(new URL(`./parallel-worker.js`,import.meta.url));return t.on(`message`,e),t.on(`error`,()=>e({type:`abort`})),{postMessage:(e,n)=>t.postMessage(e,n),terminate:()=>void t.terminate()}},v=async v=>{let y=typeof v.config==`string`?r(v.config,v.version):v.config,b=v.onPrint??console.log,x={count:0},S=e=>[e.kind,`name`in e?e.name:``,`count`in e?e.count:``,`text`in e?e.text:``].join(` `),C=/* @__PURE__ */ new Set,w=e=>{C.add(S(e)),v.onProgress?.(e)},T=()=>{let e={count:x.count};return p({...v,config:y,onPrint:t=>e.count-->0?void 0:b(t),onProgress:e=>{C.has(S(e))||v.onProgress?.(e)}})},E=v.workers??1;if(E<2||typeof SharedArrayBuffer!=`function`||v.dump!==void 0||y.view!==void 0||y.postconditions.length>0||y.possible.length>0)return T();let D=/* @__PURE__ */ new Map,O=e=>{let t=v.loadModule?.(e);return D.set(e,t),t},k=/* @__PURE__ */ new Map,A=e=>{let t=v.loadClass?.(e);return k.set(e,t),t};ee(h(v.source,y,O)),o(v.version);let oe=a(),j=g(y,{source:v.source,loadModule:O,loadClass:A,print:e=>{x.count++,b(e)},files:{readFile:v.readFile,writeFile:v.writeFile},isTool:v.isTool,isTraceRecorded:v.isTraceRecorded,isSanyReported:v.isSanyReported,isWarningEnabled:v.isWarningEnabled,version:v.version});re(j,y,w);let M=j.environment,N=ae(y,M,()=>i(v.source,O),w);if(l(j.assumptions,M)||!N||N.spec.init===void 0||N.spec.next===void 0||N.properties.liveness.length>0||n(M))return T();let P=t(),F={fingerprints:f()},I=/* @__PURE__ */ new Int32Array(2),L=Array.from({length:E},ne),R={generatedStates:0,distinctStates:0,queuedStates:0,depth:0,initialStates:void 0,outDegrees:Array.from({length:32},()=>0)},z=[],B=()=>({status:`success`,violation:void 0,failure:void 0,...R,fingerprintDistance:d(R.distinctStates,R.generatedStates,()=>{let e=new BigInt64Array(R.distinctStates);return z.reduce((t,n)=>(e.set(n,t),t+n.length),0),e})}),V=t=>{let n=[];for(let r of e(t,M,N.spec.scope))if(u(R.generatedStates,w),P(r),R.generatedStates++,c(N.getFingerprintState(r),I),ie(F.fingerprints)&&(F.fingerprints=s(F.fingerprints)),m(F.fingerprints,I[0],I[1])){if(N.findViolatedInvariant(r)||N.findFailedInitialPredicate(r))return!1;if(N.satisfiesConstraints(r)){if(!L[n.length%E].encode(r))return!1;n.push(r),R.distinctStates++}}return z.push(BigInt64Array.from(n,e=>M.runtime.getFingerprint(e))),!0};w({kind:`initial-states-started`});try{if(!V(N.spec.init))return T()}catch(e){if(!(e instanceof te))throw e;return T()}if(a()!==oe)return T();if(R.depth=R.generatedStates===0?0:1,R.initialStates={generated:R.generatedStates,distinct:R.distinctStates},w({kind:`initial-states-computed`,initialStates:R.initialStates}),R.distinctStates===0)return B();let H=[],U={count:E,resolve:e=>{}},W=e=>{H.push(e),(e.type===`abort`||H.length===U.count)&&U.resolve(H.splice(0))},G=e=>new Promise(t=>{U.count=e,U.resolve=t}),K=G(E),q=new Int32Array(new SharedArrayBuffer(E*4)),se=new Int32Array(new SharedArrayBuffer(E*4)),J=await Promise.all(Array.from({length:E},()=>_(W))),Y=()=>J.forEach(e=>e.terminate()),X=/* @__PURE__ */ new Map,ce=(e,t)=>{let n=e<t?`${e}:${t}`:`${t}:${e}`,r=X.get(n)??new MessageChannel;return X.set(n,r),e<t?r.port1:r.port2};J.forEach((e,t)=>{let n=Array.from({length:E},(e,n)=>n===t?void 0:ce(t,n)),r=L[t].finish(),i={type:`start`,source:v.source,config:y,modules:[...D],classes:[...k],index:t,ports:n,seed:r,isTool:v.isTool,isTraceRecorded:v.isTraceRecorded,isWarningEnabled:v.isWarningEnabled,version:v.version,fingerprints:F.fingerprints,requests:q,remaining:se};e.postMessage(i,[...n.filter(e=>e!==void 0),r.words.buffer])});let Z=e=>e.some(e=>e.type===`abort`),Q=e=>J.forEach(t=>t.postMessage(e)),$=async e=>{let t=e.filter(e=>e.type===`paused`).length;if(t===0||Z(e))return e;F.fingerprints=s(F.fingerprints);let n=G(t);return Q({type:`resize`,fingerprints:F.fingerprints}),[...e.filter(e=>e.type!==`paused`),...await $(await n)]};if(Z(await K))return Y(),T();for(let e=1;;e++){let t=G(E);q.forEach((e,t)=>Atomics.store(q,t,0)),Q({type:`level`,level:e});let n=await $(await t);if(Z(n))return Y(),T();let r=n.flatMap(e=>e.type===`level`?[e]:[]),i=r.reduce((e,t)=>e+t.added,0);if(R.generatedStates+=r.reduce((e,t)=>e+t.generated,0),R.distinctStates+=i,r.forEach(e=>{e.outDegrees.forEach((e,t)=>R.outDegrees[t]+=e),z.push(e.fingerprints)}),i===0)return Y(),B();R.depth++}};export{v as t};