tla-ts 0.0.9-dev.8298a52 → 0.0.10

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 (390) hide show
  1. package/README.md +7 -0
  2. package/dist/compile.cjs +3 -3
  3. package/dist/compile.js +3 -3
  4. package/dist/deciders.cjs +28 -28
  5. package/dist/deciders.js +52 -52
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.cts +71 -10
  8. package/dist/index.d.ts +71 -10
  9. package/dist/index.js +1 -1
  10. package/dist/parallel-worker.cjs +1 -1
  11. package/dist/parallel-worker.js +1 -1
  12. package/dist/prove-worker.cjs +1 -1
  13. package/dist/prove-worker.js +1 -1
  14. package/dist/prove.cjs +116 -36
  15. package/dist/prove.js +116 -36
  16. package/dist/run.cjs +141 -29
  17. package/dist/run.js +143 -31
  18. package/dist/tlapm.cjs +1 -1
  19. package/dist/tlapm.js +2 -2
  20. package/dist/transfer.cjs +128 -103
  21. package/dist/transfer.js +128 -103
  22. package/dist/worker.cjs +7 -7
  23. package/dist/worker.js +7 -7
  24. package/package.json +1 -1
  25. package/src/ast.ts +7 -21
  26. package/src/bags.ts +99 -99
  27. package/src/builtins.ts +44 -75
  28. package/src/bundled-modules.ts +1 -8
  29. package/src/check.ts +539 -276
  30. package/src/cli/options.ts +10 -5
  31. package/src/cli/run.ts +2 -2
  32. package/src/cli/runtime-invariants.ts +135 -0
  33. package/src/cli/shared.ts +20 -9
  34. package/src/cli/tlapm.ts +0 -12
  35. package/src/cli/tlc-arguments.ts +646 -0
  36. package/src/cli/tlc-usage.ts +362 -0
  37. package/src/cli/tlc.ts +525 -216
  38. package/src/cli/typescript.ts +0 -3
  39. package/src/cli/xml-exporter.ts +4 -16
  40. package/src/cli.ts +0 -1
  41. package/src/codegen.ts +191 -64
  42. package/src/config.ts +140 -109
  43. package/src/coverage.ts +837 -0
  44. package/src/dependencies.ts +6 -40
  45. package/src/dfid.ts +618 -0
  46. package/src/environment.ts +237 -119
  47. package/src/errors.ts +56 -56
  48. package/src/evaluate.ts +567 -289
  49. package/src/exit-codes.ts +37 -3
  50. package/src/fingerprints.ts +10 -10
  51. package/src/index.ts +3 -0
  52. package/src/instances.ts +38 -31
  53. package/src/java-overrides.ts +2 -12
  54. package/src/json-reader.ts +456 -0
  55. package/src/json.ts +262 -139
  56. package/src/levels.ts +2 -3
  57. package/src/lexer.ts +17 -26
  58. package/src/liveness-checker.ts +4 -15
  59. package/src/liveness.ts +115 -47
  60. package/src/obligations/action.ts +4 -28
  61. package/src/obligations/anonymize.ts +84 -80
  62. package/src/obligations/equality.ts +1 -1
  63. package/src/obligations/expression.ts +2 -19
  64. package/src/obligations/format.ts +1 -9
  65. package/src/obligations/generate.ts +1 -11
  66. package/src/obligations/index.ts +0 -11
  67. package/src/obligations/levels.ts +4 -8
  68. package/src/obligations/module.ts +1 -15
  69. package/src/obligations/normalize.ts +5 -24
  70. package/src/obligations/operators.ts +1 -2
  71. package/src/obligations/pragma.ts +1 -10
  72. package/src/obligations/printer.ts +47 -46
  73. package/src/obligations/proof.ts +1 -5
  74. package/src/obligations/regroup.ts +1 -4
  75. package/src/obligations/simplify.ts +3 -14
  76. package/src/obligations/source.ts +1 -21
  77. package/src/obligations/subexpression.ts +5 -11
  78. package/src/obligations/substitution.ts +1 -3
  79. package/src/obligations/temporal.ts +8 -14
  80. package/src/obligations/tuples.ts +3 -9
  81. package/src/parallel-worker.ts +24 -33
  82. package/src/parallel.ts +24 -9
  83. package/src/parser.ts +436 -90
  84. package/src/pcal/ast.ts +7 -28
  85. package/src/pcal/parse.ts +11 -39
  86. package/src/pcal/tokenize.ts +4 -20
  87. package/src/pcal/translate.ts +10 -42
  88. package/src/pcal/validate.ts +3 -21
  89. package/src/pretty-print.ts +1 -2
  90. package/src/prover/decide-pool.ts +5 -10
  91. package/src/prover/deciders.ts +0 -4
  92. package/src/prover/first-order.ts +0 -11
  93. package/src/prover/isabelle/decide.ts +0 -6
  94. package/src/prover/isabelle/encode.ts +11 -23
  95. package/src/prover/isabelle/isar/inner-syntax.ts +108 -114
  96. package/src/prover/isabelle/isar/method.ts +25 -38
  97. package/src/prover/isabelle/isar/proof.ts +1 -10
  98. package/src/prover/isabelle/isar/statement.ts +1 -6
  99. package/src/prover/isabelle/isar/theory.ts +15 -26
  100. package/src/prover/isabelle/isar/type-check.ts +11 -25
  101. package/src/prover/isabelle/provers/blast/blast.ts +10 -41
  102. package/src/prover/isabelle/provers/blast/branch.ts +1 -32
  103. package/src/prover/isabelle/provers/blast/prove.ts +1 -35
  104. package/src/prover/isabelle/provers/blast/rules.ts +6 -44
  105. package/src/prover/isabelle/provers/blast/state.ts +2 -28
  106. package/src/prover/isabelle/provers/blast/term.ts +9 -36
  107. package/src/prover/isabelle/provers/clasimp.ts +1 -13
  108. package/src/prover/isabelle/provers/classical.ts +14 -42
  109. package/src/prover/isabelle/provers/hypsubst.ts +11 -25
  110. package/src/prover/isabelle/pure/bicompose.ts +16 -13
  111. package/src/prover/isabelle/pure/consts.ts +1 -7
  112. package/src/prover/isabelle/pure/conv.ts +1 -9
  113. package/src/prover/isabelle/pure/drule.ts +24 -40
  114. package/src/prover/isabelle/pure/envir.ts +3 -52
  115. package/src/prover/isabelle/pure/goal.ts +1 -7
  116. package/src/prover/isabelle/pure/interrupt.ts +0 -5
  117. package/src/prover/isabelle/pure/list.ts +0 -3
  118. package/src/prover/isabelle/pure/logic.ts +1 -14
  119. package/src/prover/isabelle/pure/name.ts +2 -9
  120. package/src/prover/isabelle/pure/net.ts +3 -59
  121. package/src/prover/isabelle/pure/object-logic.ts +3 -10
  122. package/src/prover/isabelle/pure/pattern.ts +2 -19
  123. package/src/prover/isabelle/pure/raw-simplifier.ts +13 -49
  124. package/src/prover/isabelle/pure/rewriter.ts +26 -58
  125. package/src/prover/isabelle/pure/search.ts +3 -10
  126. package/src/prover/isabelle/pure/seq.ts +1 -10
  127. package/src/prover/isabelle/pure/simplifier.ts +4 -12
  128. package/src/prover/isabelle/pure/table.ts +1 -31
  129. package/src/prover/isabelle/pure/tactic.ts +12 -22
  130. package/src/prover/isabelle/pure/tactical.ts +6 -12
  131. package/src/prover/isabelle/pure/term-ord.ts +2 -6
  132. package/src/prover/isabelle/pure/term.ts +2 -43
  133. package/src/prover/isabelle/pure/thm.ts +13 -36
  134. package/src/prover/isabelle/pure/type.ts +2 -15
  135. package/src/prover/isabelle/pure/unify.ts +20 -30
  136. package/src/prover/isabelle/pure/variable.ts +3 -7
  137. package/src/prover/isabelle/tla/classical-setup.ts +9 -19
  138. package/src/prover/isabelle/tla/context.ts +8 -16
  139. package/src/prover/isabelle/tla/logic.ts +4 -11
  140. package/src/prover/isabelle/tla/simpdata.ts +46 -34
  141. package/src/prover/isabelle/tools/intuitionistic.ts +1 -10
  142. package/src/prover/ocaml.ts +0 -6
  143. package/src/prover/prep/action.ts +4 -36
  144. package/src/prover/prep/enabled-axioms.ts +12 -19
  145. package/src/prover/prep/fingerprint.ts +0 -16
  146. package/src/prover/prep/level-comparison.ts +8 -12
  147. package/src/prover/prep/md5.ts +0 -2
  148. package/src/prover/prep/methods.ts +9 -36
  149. package/src/prover/prep/normalize.ts +4 -28
  150. package/src/prover/prove-worker.ts +0 -2
  151. package/src/prover/prove.ts +0 -36
  152. package/src/prover/ptl/decide.ts +7 -12
  153. package/src/prover/ptl/encode.ts +14 -36
  154. package/src/prover/ptl/sat.ts +24 -32
  155. package/src/prover/ptl/tableau.ts +12 -26
  156. package/src/prover/smt/axioms.ts +0 -7
  157. package/src/prover/smt/context.ts +19 -26
  158. package/src/prover/smt/data.ts +51 -54
  159. package/src/prover/smt/encode.ts +14 -35
  160. package/src/prover/smt/extensionality.ts +0 -10
  161. package/src/prover/smt/flatten.ts +3 -22
  162. package/src/prover/smt/format.ts +5 -10
  163. package/src/prover/smt/instances.ts +0 -10
  164. package/src/prover/smt/rewrite.ts +66 -101
  165. package/src/prover/smt/solver/act-cache.ts +0 -15
  166. package/src/prover/smt/solver/arith-rewriter.ts +3 -48
  167. package/src/prover/smt/solver/array.ts +1 -3
  168. package/src/prover/smt/solver/asserted-formulas.ts +1 -43
  169. package/src/prover/smt/solver/ast-lt.ts +1 -11
  170. package/src/prover/smt/solver/ast-util.ts +1 -6
  171. package/src/prover/smt/solver/ast.ts +1 -143
  172. package/src/prover/smt/solver/auf-solver.ts +6 -39
  173. package/src/prover/smt/solver/case-split-queue.ts +1 -9
  174. package/src/prover/smt/solver/cg-table.ts +1 -18
  175. package/src/prover/smt/solver/clause.ts +1 -27
  176. package/src/prover/smt/solver/conflict-resolution.ts +0 -9
  177. package/src/prover/smt/solver/context.ts +4 -61
  178. package/src/prover/smt/solver/ctx-simplify.ts +14 -41
  179. package/src/prover/smt/solver/der.ts +2 -21
  180. package/src/prover/smt/solver/dyn-ack.ts +1 -11
  181. package/src/prover/smt/solver/e-matching.ts +3 -34
  182. package/src/prover/smt/solver/enode.ts +1 -21
  183. package/src/prover/smt/solver/expr-ref.ts +1 -5
  184. package/src/prover/smt/solver/expr-safe-replace.ts +0 -5
  185. package/src/prover/smt/solver/fingerprints.ts +1 -12
  186. package/src/prover/smt/solver/flat-literals.ts +1 -9
  187. package/src/prover/smt/solver/goal.ts +2 -14
  188. package/src/prover/smt/solver/hash.ts +0 -8
  189. package/src/prover/smt/solver/hashtable.ts +1 -12
  190. package/src/prover/smt/solver/internalizer.ts +6 -98
  191. package/src/prover/smt/solver/lbool.ts +1 -2
  192. package/src/prover/smt/solver/literal.ts +0 -3
  193. package/src/prover/smt/solver/lp/bound-propagator.ts +8 -26
  194. package/src/prover/smt/solver/lp/constraints.ts +2 -8
  195. package/src/prover/smt/solver/lp/containers.ts +12 -30
  196. package/src/prover/smt/solver/lp/core-solver.ts +10 -31
  197. package/src/prover/smt/solver/lp/cross-nested.ts +6 -20
  198. package/src/prover/smt/solver/lp/dep-intervals.ts +7 -22
  199. package/src/prover/smt/solver/lp/dependency.ts +1 -4
  200. package/src/prover/smt/solver/lp/dioph-eq.ts +12 -98
  201. package/src/prover/smt/solver/lp/explanation.ts +1 -6
  202. package/src/prover/smt/solver/lp/gomory.ts +9 -22
  203. package/src/prover/smt/solver/lp/hnf-cutter.ts +17 -23
  204. package/src/prover/smt/solver/lp/hnf.ts +11 -26
  205. package/src/prover/smt/solver/lp/int-cube.ts +15 -36
  206. package/src/prover/smt/solver/lp/int-solver.ts +4 -34
  207. package/src/prover/smt/solver/lp/lar-solver.ts +32 -81
  208. package/src/prover/smt/solver/lp/lar-term.ts +1 -5
  209. package/src/prover/smt/solver/lp/lp-settings.ts +1 -14
  210. package/src/prover/smt/solver/lp/maximize-term.ts +20 -45
  211. package/src/prover/smt/solver/lp/nex-creator.ts +5 -28
  212. package/src/prover/smt/solver/lp/nex.ts +1 -6
  213. package/src/prover/smt/solver/lp/nla-backoff.ts +1 -4
  214. package/src/prover/smt/solver/lp/nla-basics.ts +5 -30
  215. package/src/prover/smt/solver/lp/nla-core.ts +35 -130
  216. package/src/prover/smt/solver/lp/nla-divisions.ts +32 -42
  217. package/src/prover/smt/solver/lp/nla-emonics.ts +4 -21
  218. package/src/prover/smt/solver/lp/nla-factorization.ts +1 -4
  219. package/src/prover/smt/solver/lp/nla-grobner.ts +15 -69
  220. package/src/prover/smt/solver/lp/nla-horner.ts +3 -11
  221. package/src/prover/smt/solver/lp/nla-intervals.ts +2 -12
  222. package/src/prover/smt/solver/lp/nla-monomial-bounds.ts +16 -41
  223. package/src/prover/smt/solver/lp/nla-monotone.ts +2 -6
  224. package/src/prover/smt/solver/lp/nla-order.ts +2 -13
  225. package/src/prover/smt/solver/lp/nla-patcher.ts +4 -7
  226. package/src/prover/smt/solver/lp/nla-tangents.ts +1 -9
  227. package/src/prover/smt/solver/lp/nla-throttle.ts +1 -6
  228. package/src/prover/smt/solver/lp/nla-types.ts +1 -11
  229. package/src/prover/smt/solver/lp/nla-var-eqs.ts +4 -25
  230. package/src/prover/smt/solver/lp/nra-solver.ts +5 -52
  231. package/src/prover/smt/solver/lp/numeric-pair.ts +1 -4
  232. package/src/prover/smt/solver/lp/pdd-interval.ts +1 -3
  233. package/src/prover/smt/solver/lp/pdd-simplifier.ts +2 -14
  234. package/src/prover/smt/solver/lp/pdd-solver.ts +4 -33
  235. package/src/prover/smt/solver/lp/pdd.ts +7 -70
  236. package/src/prover/smt/solver/lp/random-updater.ts +1 -8
  237. package/src/prover/smt/solver/lp/static-matrix.ts +9 -19
  238. package/src/prover/smt/solver/lp/union-find.ts +1 -6
  239. package/src/prover/smt/solver/mam-compiler.ts +14 -56
  240. package/src/prover/smt/solver/mam-interpreter.ts +1 -21
  241. package/src/prover/smt/solver/maximize-ac-sharing.ts +2 -17
  242. package/src/prover/smt/solver/model-checker.ts +2 -36
  243. package/src/prover/smt/solver/model-evaluator.ts +3 -29
  244. package/src/prover/smt/solver/model-finder.ts +3 -15
  245. package/src/prover/smt/solver/model-generator.ts +1 -12
  246. package/src/prover/smt/solver/model-macro-solver.ts +12 -69
  247. package/src/prover/smt/solver/nlsat/algebraic.ts +55 -151
  248. package/src/prover/smt/solver/nlsat/atoms.ts +5 -19
  249. package/src/prover/smt/solver/nlsat/evaluator.ts +17 -22
  250. package/src/prover/smt/solver/nlsat/explain.ts +3 -47
  251. package/src/prover/smt/solver/nlsat/interval-set.ts +9 -50
  252. package/src/prover/smt/solver/nlsat/levelwise.ts +48 -129
  253. package/src/prover/smt/solver/nlsat/mpbq.ts +3 -14
  254. package/src/prover/smt/solver/nlsat/polynomial.ts +17 -156
  255. package/src/prover/smt/solver/nlsat/solver.ts +7 -67
  256. package/src/prover/smt/solver/nlsat/types.ts +1 -8
  257. package/src/prover/smt/solver/nlsat/upolynomial-factorization.ts +1 -44
  258. package/src/prover/smt/solver/nlsat/upolynomial.ts +11 -92
  259. package/src/prover/smt/solver/nnf.ts +3 -38
  260. package/src/prover/smt/solver/pattern-inference.ts +2 -15
  261. package/src/prover/smt/solver/poly-rewriter.ts +3 -23
  262. package/src/prover/smt/solver/propagate-values.ts +1 -10
  263. package/src/prover/smt/solver/proto-model.ts +3 -48
  264. package/src/prover/smt/solver/pull-quant.ts +1 -12
  265. package/src/prover/smt/solver/qe-lite-der.ts +1 -29
  266. package/src/prover/smt/solver/qe-lite-fm.ts +2 -25
  267. package/src/prover/smt/solver/qe-lite.ts +3 -33
  268. package/src/prover/smt/solver/qi-queue.ts +1 -16
  269. package/src/prover/smt/solver/quant-tactics.ts +5 -22
  270. package/src/prover/smt/solver/quantifier-analyzer.ts +17 -37
  271. package/src/prover/smt/solver/quantifier-manager.ts +1 -8
  272. package/src/prover/smt/solver/random-gen.ts +1 -2
  273. package/src/prover/smt/solver/rational.ts +1 -8
  274. package/src/prover/smt/solver/ref-vector.ts +1 -6
  275. package/src/prover/smt/solver/relevancy.ts +2 -15
  276. package/src/prover/smt/solver/rewriter-tpl.ts +3 -147
  277. package/src/prover/smt/solver/rewriter.ts +3 -85
  278. package/src/prover/smt/solver/rlimit.ts +2 -20
  279. package/src/prover/smt/solver/smtlib-parser.ts +2 -37
  280. package/src/prover/smt/solver/solver.ts +1 -16
  281. package/src/prover/smt/solver/sort.ts +1 -5
  282. package/src/prover/smt/solver/sticky-generations.ts +0 -5
  283. package/src/prover/smt/solver/theory-lra-axioms.ts +3 -24
  284. package/src/prover/smt/solver/theory-lra-bounds.ts +0 -5
  285. package/src/prover/smt/solver/theory-lra-final-check.ts +4 -22
  286. package/src/prover/smt/solver/theory-lra-internalize.ts +1 -27
  287. package/src/prover/smt/solver/theory-lra-model.ts +4 -19
  288. package/src/prover/smt/solver/theory-lra-propagate.ts +1 -15
  289. package/src/prover/smt/solver/theory-lra-state.ts +3 -8
  290. package/src/prover/smt/solver/theory-lra.ts +1 -8
  291. package/src/prover/smt/solver/var-subst.ts +2 -26
  292. package/src/prover/smt/table.ts +0 -8
  293. package/src/prover/tlapm/cache.ts +20 -25
  294. package/src/prover/tlapm/ocaml-marshal.ts +19 -21
  295. package/src/prover/tlapm/tlapm.ts +12 -17
  296. package/src/prover/verdict.ts +0 -2
  297. package/src/prover/zenon/check/check.ts +0 -9
  298. package/src/prover/zenon/check/definitions.ts +5 -15
  299. package/src/prover/zenon/check/equality.ts +0 -8
  300. package/src/prover/zenon/check/functions.ts +0 -4
  301. package/src/prover/zenon/check/keys.ts +0 -7
  302. package/src/prover/zenon/check/propositional.ts +0 -3
  303. package/src/prover/zenon/check/records.ts +0 -5
  304. package/src/prover/zenon/check/relations.ts +0 -13
  305. package/src/prover/zenon/check/rewrites.ts +0 -6
  306. package/src/prover/zenon/check/sets.ts +0 -3
  307. package/src/prover/zenon/check/terms.ts +0 -17
  308. package/src/prover/zenon/check/tla.ts +0 -6
  309. package/src/prover/zenon/decide.ts +0 -12
  310. package/src/prover/zenon/encode.ts +1 -8
  311. package/src/prover/zenon/eqrel.ts +0 -13
  312. package/src/prover/zenon/equality-rules.ts +0 -4
  313. package/src/prover/zenon/expr.ts +1 -26
  314. package/src/prover/zenon/index-table.ts +17 -38
  315. package/src/prover/zenon/isar-case.ts +9 -19
  316. package/src/prover/zenon/isar.ts +1 -29
  317. package/src/prover/zenon/limits.ts +0 -4
  318. package/src/prover/zenon/llproof.ts +0 -9
  319. package/src/prover/zenon/mltoll.ts +54 -76
  320. package/src/prover/zenon/node.ts +1 -11
  321. package/src/prover/zenon/ocaml.ts +1 -17
  322. package/src/prover/zenon/parse.ts +2 -7
  323. package/src/prover/zenon/phrase.ts +1 -11
  324. package/src/prover/zenon/proof.ts +0 -9
  325. package/src/prover/zenon/propositional-rules.ts +0 -5
  326. package/src/prover/zenon/rules.ts +2 -6
  327. package/src/prover/zenon/search.ts +1 -17
  328. package/src/prover/zenon/tla/functions.ts +57 -29
  329. package/src/prover/zenon/tla/llproof.ts +63 -70
  330. package/src/prover/zenon/tla/records.ts +56 -27
  331. package/src/prover/zenon/tla/rewrites.ts +12 -19
  332. package/src/prover/zenon/tla/sets.ts +68 -39
  333. package/src/prover/zenon/tla/terms.ts +0 -6
  334. package/src/prover/zenon/tla/tla.ts +59 -58
  335. package/src/randomization.ts +84 -35
  336. package/src/resolve.ts +18 -60
  337. package/src/runtime.ts +11 -4
  338. package/src/sany/builtins.ts +3 -4
  339. package/src/sany/generator.ts +119 -169
  340. package/src/sany/levels.ts +6 -30
  341. package/src/sany/lexer.ts +7 -23
  342. package/src/sany/linter.ts +1 -8
  343. package/src/sany/modules.ts +1 -5
  344. package/src/sany/nodes.ts +0 -31
  345. package/src/sany/parse-error.ts +39 -117
  346. package/src/sany/report.ts +29 -63
  347. package/src/sany/selectors.ts +15 -39
  348. package/src/sany/source.ts +1 -17
  349. package/src/sany/xml.ts +13 -63
  350. package/src/search.ts +494 -154
  351. package/src/simulate.ts +694 -0
  352. package/src/spec-description.ts +166 -48
  353. package/src/standard-definitions.ts +2 -3
  354. package/src/standard-modules.ts +264 -68
  355. package/src/state-graph.ts +51 -18
  356. package/src/subexpressions.ts +31 -5
  357. package/src/substitution-levels.ts +2 -3
  358. package/src/successors.ts +264 -74
  359. package/src/symmetry.ts +31 -8
  360. package/src/tableau.ts +27 -24
  361. package/src/tlc/fingerprint.ts +183 -61
  362. package/src/tlc/jar-data.ts +113 -6
  363. package/src/tlc/messages.ts +122 -37
  364. package/src/tlc/order.ts +33 -38
  365. package/src/tlc/random.ts +16 -16
  366. package/src/tlc/replay.ts +563 -211
  367. package/src/tlc/summary.ts +2 -4
  368. package/src/tlc/tlc-operators.ts +81 -36
  369. package/src/tlc/tlcext-operators.ts +138 -117
  370. package/src/tlc/trace-spec.ts +273 -0
  371. package/src/tlc/value-stream.ts +143 -0
  372. package/src/tlc/version.ts +2 -4
  373. package/src/transfer.ts +22 -25
  374. package/src/typescript/actions.ts +8 -21
  375. package/src/typescript/collections.ts +0 -15
  376. package/src/typescript/compile.ts +0 -5
  377. package/src/typescript/context.ts +0 -12
  378. package/src/typescript/emit.ts +0 -1
  379. package/src/typescript/expressions.ts +0 -12
  380. package/src/typescript/formula.ts +4 -12
  381. package/src/typescript/functions.ts +6 -17
  382. package/src/typescript/model.ts +10 -11
  383. package/src/typescript/names.ts +0 -2
  384. package/src/typescript/program.ts +0 -3
  385. package/src/typescript/properties.ts +6 -8
  386. package/src/typescript/scope.ts +0 -5
  387. package/src/typescript/steps.ts +0 -10
  388. package/src/typescript/types.ts +1 -8
  389. package/src/values.ts +793 -267
  390. package/src/worker.ts +7 -8
package/src/resolve.ts CHANGED
@@ -22,8 +22,7 @@ import {
22
22
  } from "./ast";
23
23
  import { formatRange, TlaSyntaxError, type SanyError } from "./errors";
24
24
 
25
- // The kinds of symbol SANY tells apart when it binds a name twice. A parameter is also a bound name,
26
- // and a NEW symbol has a kind for each level.
25
+ // A parameter is also a bound name, and a NEW symbol has a kind for each level.
27
26
  export type SymbolKind =
28
27
  | "Builtin"
29
28
  | "Constant"
@@ -34,8 +33,7 @@ export type SymbolKind =
34
33
  | "Parameter"
35
34
  | `New${NewSymbol["level"]}`;
36
35
 
37
- // range is where SANY reports the symbol, and two symbols at one range are one node to SANY. params
38
- // holds the arity of each parameter of a defined operator.
36
+ // Two symbols at one range are one node to SANY.
39
37
  interface Binding {
40
38
  kind: SymbolKind;
41
39
  arity: number;
@@ -49,8 +47,6 @@ export interface ModuleSymbol extends Binding {
49
47
 
50
48
  export type Symbols = Map<string, ModuleSymbol>;
51
49
 
52
- // A named theorem or proof step whose parts a name such as foo!lab or <1>2!1 selects. isInProof
53
- // holds while SANY analyzes the proof of the theorem or step.
54
50
  interface Goal {
55
51
  statement: Expression | AssumeProve;
56
52
  isSuffices: boolean;
@@ -68,13 +64,11 @@ interface LocalName extends Binding {
68
64
  isNonFact?: boolean;
69
65
  }
70
66
 
71
- // A name the module binds, from position on.
72
67
  interface ModuleBinding extends Binding {
73
68
  position: SourceLocation;
74
69
  isPending?: boolean;
75
70
  }
76
71
 
77
- // What SANY reports while it goes on analyzing a unit of a module, and the scope it analyzes it in.
78
72
  interface Unit {
79
73
  imported: Symbols;
80
74
  getInstance: (instance: Instance) => InstancedModule;
@@ -87,15 +81,11 @@ interface Unit {
87
81
  bindings: Map<string, ModuleBinding>;
88
82
  errors: SanyError[];
89
83
  warnings: SanyError[];
90
- // In a definition, a named theorem, or a numbered step.
91
84
  hasLabelScope: boolean;
92
- // In the scope of a NEW in a nested ASSUME.
93
85
  isLabelForbidden: boolean;
94
86
  isInExcept: boolean;
95
- // The names bound since the innermost definition, label, or step, which a label must take.
96
87
  labelParams: string[];
97
88
  labels: Set<string>;
98
- // In a definition generated for a LET INSTANCE, or a subexpression analyzed where it is defined.
99
89
  isGenerated: boolean;
100
90
  }
101
91
 
@@ -114,8 +104,6 @@ type Reference = Expression & { kind: "Identifier" | "Apply" | "Subexpression" }
114
104
 
115
105
  export const LOCAL_RESOLUTION = { kind: "Local" } as const;
116
106
 
117
- // The subexpressions that names select, and for a name that selects none, the error SANY reports and
118
- // the arguments it analyzes before it.
119
107
  export const selections = new WeakSet<Expression>();
120
108
  export const selectionErrors = new WeakMap<Expression, SelectionError>();
121
109
 
@@ -151,8 +139,6 @@ const lookupLocal = (scope: LocalName | undefined, name: string) => {
151
139
  return undefined;
152
140
  };
153
141
 
154
- // A name the module binds before the unit and before the range, which a copy of a subexpression
155
- // that a reference selects keeps from its definition.
156
142
  const getModuleBinding = (name: string, unit: Unit, range: SourceRange | undefined) => {
157
143
  const binding = unit.bindings.get(name);
158
144
  return binding &&
@@ -165,8 +151,7 @@ const getModuleBinding = (name: string, unit: Unit, range: SourceRange | undefin
165
151
  const isSameRange = (left: SourceRange | undefined, right: SourceRange | undefined) =>
166
152
  left !== undefined && right !== undefined && formatRange(left) === formatRange(right);
167
153
 
168
- // SymbolTable.addSymbol: rejects redefining a built-in, a bound name, or a symbol of another kind
169
- // or arity, and warns of any other duplicate. A symbol SANY never sees, such as a generated one, binds.
154
+ // A symbol SANY never sees, such as a generated one, binds.
170
155
  const isBindable = (name: string, current: Binding | undefined, added: Binding, unit: Unit) => {
171
156
  if (current === undefined) return true;
172
157
  if (isSameRange(current.range, added.range)) return false;
@@ -214,7 +199,6 @@ const bindName = (
214
199
  ? { ...added, name, parent: scope }
215
200
  : scope;
216
201
 
217
- // Binds the names of a module from the unit on.
218
202
  const bindModuleName = (name: string, added: Binding, unit: Unit) => {
219
203
  if (isBindable(name, unit.bindings.get(name), added, unit)) {
220
204
  unit.bindings.set(name, { ...added, position: unit.location });
@@ -276,7 +260,6 @@ const findSymbol = (name: string, unit: Unit): ModuleSymbol | undefined => {
276
260
  const findBinding = (name: string, scope: LocalName | undefined, unit: Unit): Binding | undefined =>
277
261
  lookupLocal(scope, name) ?? findSymbol(name, unit);
278
262
 
279
- // SANY reports a name at the range of its text.
280
263
  const getNameRange = (location: SourceLocation, name: string): SourceRange => ({
281
264
  module: location.range?.module ?? "",
282
265
  start: location,
@@ -315,8 +298,6 @@ export const getOperandIndex = (operand: number | "<<" | ">>", count: number) =>
315
298
  return count === 2 ? 1 : -1;
316
299
  };
317
300
 
318
- // The parts of a name such as F(x)!l(y), each with its own arguments. counts holds the number each
319
- // part takes, when a part before the last takes some.
320
301
  export const getNameSelectors = (
321
302
  name: string,
322
303
  args: Expression[],
@@ -343,8 +324,6 @@ const getBoundSets = (bounds: Bound[]) =>
343
324
  .filter((bound, index) => index === 0 || bounds[index - 1].set !== bound.set)
344
325
  .map((bound) => bound.set);
345
326
 
346
- // The names a binder binds, its body, and the sets it binds them to, which a selector such as !1
347
- // chooses from.
348
327
  export const getBinder = (
349
328
  expression: Expression,
350
329
  ): { names: string[]; body: Expression; sets: Expression[] } | undefined => {
@@ -387,7 +366,6 @@ export const getBinder = (
387
366
  }
388
367
  };
389
368
 
390
- // The operands that a selector such as !1 chooses from, where they do not depend on bound names.
391
369
  export const getOperands = (expression: Expression): Expression[] | undefined => {
392
370
  switch (expression.kind) {
393
371
  case "Apply":
@@ -482,10 +460,9 @@ const getOperandName = (operand: number | "<<" | ">>") =>
482
460
 
483
461
  const SCOPE_MESSAGE = "within the scope of a declaration\n from outside that declaration's scope.";
484
462
 
485
- // Generator.selectorToNode for a name that selects part of a theorem or step. A part in the scope of
486
- // a NEW in its ASSUME may be selected only within the proof of the theorem, or only after the proof
487
- // of a SUFFICES step. A label takes its own arguments, and an operand must exist, unless the part
488
- // selected depends on bound names. A fact may select an ASSUME/PROVE or a NEW clause.
463
+ // A part in the scope of a NEW in its ASSUME may be selected only within the theorem's proof, or
464
+ // only after the proof of a SUFFICES step. A label takes its own arguments, and an operand must
465
+ // exist, unless the part selected depends on bound names.
489
466
  const checkSelection = (
490
467
  reference: Reference,
491
468
  selectors: Selector[],
@@ -689,7 +666,6 @@ const checkLabel = (label: LabelExpression, scope: LocalName | undefined, unit:
689
666
  unit.labels.add(label.name);
690
667
  };
691
668
 
692
- // Checks a name that selects part of a theorem or step, and tells whether it is one.
693
669
  const checkReference = (
694
670
  expression: Expression,
695
671
  scope: LocalName | undefined,
@@ -796,10 +772,9 @@ const markRecursiveConstructions = (expression: Expression, name: string): void
796
772
  getChildren(expression).forEach((child) => markRecursiveConstructions(child, name));
797
773
  };
798
774
 
799
- // Generator.processOperator binds the parameters, reports a name already bound unless a RECURSIVE
800
- // declaration of this level awaits the definition, analyzes the body, and then binds the name.
801
- // processFunction binds the bound names before it looks up the name, and binds the name only where
802
- // nothing else does. recursive holds the declarations of this level. Tells whether to bind the name.
775
+ // SANY binds the parameters, reports a name already bound unless a RECURSIVE declaration of this
776
+ // level awaits the definition, analyzes the body, and then binds the name. A function binds the
777
+ // bound names before it looks up the name, and binds the name only where nothing else does.
803
778
  const resolveDefinition = (
804
779
  definition: Definition,
805
780
  scope: LocalName | undefined,
@@ -928,8 +903,8 @@ const findInstance = (name: string, scope: LocalName | undefined, unit: Unit) =>
928
903
  return binding?.kind === "Instance" ? { name: prefix, arity: binding.arity } : undefined;
929
904
  };
930
905
 
931
- // Generator.selectorToNode reports an INSTANCE given the wrong number of arguments at its name,
932
- // as in K!C or K(1, 2)!C, and goes on without analyzing them. Tells whether it reports one.
906
+ // SANY reports an INSTANCE given the wrong number of arguments at its name, as in K!C or
907
+ // K(1, 2)!C, and goes on without analyzing them.
933
908
  const isInstanceArityReported = (
934
909
  expression: Expression,
935
910
  scope: LocalName | undefined,
@@ -955,9 +930,7 @@ const isInstanceArityReported = (
955
930
  return true;
956
931
  };
957
932
 
958
- // Generator.generateExprOrOpArg analyzes an argument as an expression, unless a defined operator
959
- // takes an operator in its place, which a name, a built-in operator, or a LAMBDA of the parameter's
960
- // arity must give. OpDefNode#match then reports each argument that gives no such operator, or one
933
+ // OpDefNode#match reports each argument that gives no operator of the parameter's arity, or one
961
934
  // whose own parameters take operators. tla-ts lets an operator whose parameters it does not know
962
935
  // take any argument.
963
936
  const resolveApply = (
@@ -1063,13 +1036,11 @@ const resolveApply = (
1063
1036
  });
1064
1037
  };
1065
1038
 
1066
- // An argument may name an operator that takes arguments of its own.
1067
1039
  const resolveArgument = (arg: Expression, scope: LocalName | undefined, unit: Unit) => {
1068
1040
  if (arg.kind === "Identifier") getSymbolArity(arg, arg.name, scope, unit);
1069
1041
  else resolveExpression(arg, scope, unit);
1070
1042
  };
1071
1043
 
1072
- // Reports the error of a name that selects nothing, after the arguments SANY analyzes before it.
1073
1044
  const isSelectionReported = (expression: Expression, scope: LocalName | undefined, unit: Unit) => {
1074
1045
  const failed = selectionErrors.get(expression);
1075
1046
  if (!failed) return false;
@@ -1245,9 +1216,8 @@ const resolveExpression = (
1245
1216
  }
1246
1217
  };
1247
1218
 
1248
- // Generator.generateUseOrHide looks up a fact that is a name as it looks up a name in an expression,
1249
- // except that the name may select an ASSUME/PROVE or a NEW clause or name a theorem or assumption,
1250
- // and analyzes any other fact as an expression.
1219
+ // A fact that is a name may also select an ASSUME/PROVE or a NEW clause or name a theorem or
1220
+ // assumption. SANY analyzes any other fact as an expression.
1251
1221
  const checkFacts = (facts: Fact[], scope: LocalName | undefined, unit: Unit) =>
1252
1222
  facts.forEach((fact) => {
1253
1223
  if (
@@ -1314,8 +1284,6 @@ const resolveStatement = (
1314
1284
  return scope;
1315
1285
  };
1316
1286
 
1317
- // SANY resolves the expressions of a proof, while its facts and DEF clauses may also name
1318
- // theorems, assumptions, and modules.
1319
1287
  const resolveProof = (proof: Proof | undefined, scope: LocalName | undefined, outer: Unit) => {
1320
1288
  const unit = outer.hasLabelScope ? { ...outer, hasLabelScope: false } : outer;
1321
1289
  if (proof?.kind === "By") checkFacts(proof.facts, scope, unit);
@@ -1440,16 +1408,12 @@ const resolveTheorem = (theorem: Theorem, unit: Unit) => {
1440
1408
  if (goal) goal.isInProof = false;
1441
1409
  };
1442
1410
 
1443
- // The declarations of the module an INSTANCE instantiates, the names the INSTANCE adds, and the
1444
- // module that instantiates it.
1445
1411
  interface InstancedModule {
1446
1412
  declarations: Declaration[];
1447
1413
  symbols: Symbols;
1448
1414
  instancer: string;
1449
1415
  }
1450
1416
 
1451
- // What SANY reports at a location as it links a module, such as a conflict between the modules it
1452
- // extends.
1453
1417
  export interface ModuleReport {
1454
1418
  location: SourceLocation;
1455
1419
  errors: SanyError[];
@@ -1459,13 +1423,10 @@ export interface ModuleReport {
1459
1423
  export interface ModuleUnit {
1460
1424
  imported: Symbols;
1461
1425
  getInstance: (instance: Instance) => InstancedModule;
1462
- // The built-in operators and the names of the enclosing and extended modules.
1463
1426
  bound: Symbols;
1464
1427
  definitions: Map<string, Definition>;
1465
1428
  getKey: (definition: Definition) => string;
1466
- // The names each INSTANCE adds.
1467
1429
  instanced: Map<Instance, Symbols>;
1468
- // The theorems and assumptions the extended and instantiated modules export.
1469
1430
  facts: Set<string>;
1470
1431
  reports: ModuleReport[];
1471
1432
  warnings: SanyError[];
@@ -1579,7 +1540,6 @@ const resolveInstance = (instance: Instance, scope: LocalName | undefined, unit:
1579
1540
  );
1580
1541
  };
1581
1542
 
1582
- // tla-ts reports what SANY goes on after with an INSTANCE of the module.
1583
1543
  export const resolveSubstitutions = (
1584
1544
  instance: Instance,
1585
1545
  declarations: Declaration[],
@@ -1612,10 +1572,9 @@ export const resolveSubstitutions = (
1612
1572
  });
1613
1573
  };
1614
1574
 
1615
- // SANY reports the errors of every unit it checks, in the order of the units in the module, after
1616
- // the warnings it reports for the spec. A unit reports to its lists what SANY goes on after, and
1617
- // throws the error that stops it. An error tla-ts cannot word as SANY does yields to the errors the
1618
- // unit reported before it. Returns the errors.
1575
+ // SANY reports the errors of every unit in the order of the units, after the warnings. A unit
1576
+ // reports what SANY goes on after, and throws the error that stops it. An error tla-ts cannot
1577
+ // word as SANY does yields to the errors the unit reported before it.
1619
1578
  export const collectSemanticErrors = (
1620
1579
  units: {
1621
1580
  location: SourceLocation;
@@ -1658,8 +1617,7 @@ export const collectSemanticErrors = (
1658
1617
  return errors;
1659
1618
  };
1660
1619
 
1661
- // SANY binds the names of a module in the order of its units, and reports a RECURSIVE declaration
1662
- // that no definition follows at the end. Returns the errors.
1620
+ // SANY reports a RECURSIVE declaration that no definition follows at the end.
1663
1621
  export const resolveModule = (module: Module, unit: ModuleUnit) => {
1664
1622
  const symbols = createSymbols(module, unit.imported);
1665
1623
  const facts = new Set([
package/src/runtime.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { getTlcFingerprint } from "./tlc/fingerprint";
2
2
  import { createJavaRandom, type JavaRandom } from "./tlc/random";
3
3
  import { createFunction, createRecord, type Value } from "./values";
4
+ import type { SpecAction } from "./spec-description";
4
5
  import type { TlcVersion } from "./tlc/version";
5
6
 
6
7
  export interface CheckerRuntime {
@@ -8,14 +9,16 @@ export interface CheckerRuntime {
8
9
  getBehavior: (state: Value[]) => Value[][];
9
10
  getSpecification: () => Value;
10
11
  counterExample: Value | undefined;
12
+ deferred: ((next: Value[]) => void) | undefined;
11
13
  setLivenessSource: (index: number | undefined) => void;
12
14
  getCurrentState: () => Value[] | undefined;
13
15
  getFingerprint: (state: Value[]) => bigint;
14
16
  getRandom: () => JavaRandom;
17
+ getSimulationValue:
18
+ | ((key: string, state: (Value | undefined)[] | undefined) => Value | undefined)
19
+ | undefined;
15
20
  evaluateAtStartup: <Result>(evaluate: () => Result) => Result;
16
- pause: () => void;
17
- // Prints a warning TLC raises while it evaluates, with its message code. TLC prints each
18
- // distinct warning once.
21
+ pause: (() => void) | undefined;
19
22
  warn: (code: number, text: string) => void;
20
23
  // TLC's -nowarning turns the warnings off, and with them the shortcut that evaluates the rest
21
24
  // of an action once it assigns every variable, since that shortcut skips a warning.
@@ -26,6 +29,7 @@ export interface CheckerRuntime {
26
29
  version: TlcVersion;
27
30
  seed: bigint;
28
31
  isSeen: (state: Value[]) => boolean;
32
+ getSuccessorAction: (state: Value[], next: Value[]) => SpecAction | undefined;
29
33
  generatedStates: number;
30
34
  distinctStates: number;
31
35
  initialStates: number;
@@ -54,10 +58,13 @@ export const createRuntime = (checkDeadlock: boolean, seed = 0n): CheckerRuntime
54
58
  getBehavior: () => [],
55
59
  getSpecification: () => createRecord([]),
56
60
  counterExample: undefined,
61
+ deferred: undefined,
57
62
  isSeen: () => false,
63
+ getSuccessorAction: () => undefined,
58
64
  setLivenessSource: () => {},
59
65
  getCurrentState: () => undefined,
60
66
  getFingerprint: getTlcFingerprint,
67
+ getSimulationValue: undefined,
61
68
  getRandom: () => {
62
69
  const state = phase.isStartup ? undefined : runtime.getCurrentState();
63
70
  if (state === undefined) return startupRandom;
@@ -76,7 +83,7 @@ export const createRuntime = (checkDeadlock: boolean, seed = 0n): CheckerRuntime
76
83
  phase.isStartup = wasStartup;
77
84
  }
78
85
  },
79
- pause: () => {},
86
+ pause: undefined,
80
87
  warn: () => {},
81
88
  isWarningEnabled: true,
82
89
  isTool: false,
@@ -1,7 +1,7 @@
1
1
  import type { FormalParamNode, LevelFields, OpDefNode, SanyLocation } from "./nodes";
2
2
 
3
- // tla2sany.semantic.BuiltInOperators: name, arity, level, maximum argument levels and argument
4
- // weights. SANY leaves the levels of "." and \neg unset.
3
+ // Name, arity, level, maximum argument levels and argument weights. SANY leaves the levels of
4
+ // "." and \neg unset.
5
5
  const BUILTIN_OPERATORS: [string, number, number, number[] | undefined, number[] | undefined][] = [
6
6
  ["STRING", 0, 0, [], []],
7
7
  ["FALSE", 0, 0, [], []],
@@ -98,8 +98,7 @@ export const createLevelFields = (id: number): LevelFields => ({
98
98
  argLevelConstraints: new Map(),
99
99
  });
100
100
 
101
- // The builtin operators in the order SANY adds them to its global context. OpDefNode's constructor
102
- // for a builtin numbers the operator, then its phony parameters.
101
+ // SANY's order: OpDefNode's constructor numbers each builtin, then its phony parameters.
103
102
  export const createBuiltins = (getId: () => number) =>
104
103
  BUILTIN_OPERATORS.map(([name, arity, level, maxLevels, weights]): OpDefNode => {
105
104
  const id = getId();