tla-ts 0.0.9 → 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 +29 -1
  2. package/dist/compile.cjs +23 -0
  3. package/dist/compile.js +23 -0
  4. package/dist/deciders.cjs +28 -28
  5. package/dist/deciders.js +43 -43
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.cts +72 -10
  8. package/dist/index.d.ts +72 -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 +143 -31
  17. package/dist/run.js +143 -31
  18. package/dist/tlapm.cjs +2 -2
  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 +3 -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 +576 -300
  30. package/src/cli/options.ts +11 -6
  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 +538 -220
  38. package/src/cli/typescript.ts +23 -0
  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 +240 -118
  47. package/src/errors.ts +70 -55
  48. package/src/evaluate.ts +630 -297
  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 +79 -11
  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 +10 -18
  59. package/src/liveness.ts +121 -49
  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 +29 -39
  82. package/src/parallel.ts +29 -13
  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 +23 -34
  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 +267 -77
  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 +481 -0
  375. package/src/typescript/collections.ts +600 -0
  376. package/src/typescript/compile.ts +65 -0
  377. package/src/typescript/context.ts +94 -0
  378. package/src/typescript/emit.ts +121 -0
  379. package/src/typescript/expressions.ts +496 -0
  380. package/src/typescript/formula.ts +152 -0
  381. package/src/typescript/functions.ts +284 -0
  382. package/src/typescript/model.ts +163 -0
  383. package/src/typescript/names.ts +114 -0
  384. package/src/typescript/program.ts +48 -0
  385. package/src/typescript/properties.ts +139 -0
  386. package/src/typescript/scope.ts +112 -0
  387. package/src/typescript/steps.ts +165 -0
  388. package/src/typescript/types.ts +171 -0
  389. package/src/values.ts +826 -276
  390. package/src/worker.ts +7 -8
@@ -27,9 +27,7 @@ import {
27
27
  type ThmOrAssumpDefNode,
28
28
  } from "./nodes";
29
29
 
30
- // A port of the levelCheck methods of SANY's semantic nodes: the levels, weights and Leibniz flags
31
- // its XMLExporter writes, and the level errors it reports. Each check returns what SANY's returns,
32
- // which is whether the node is free of level errors, or true for the nodes that ignore that.
30
+ // A port of the levelCheck methods of SANY's semantic nodes.
33
31
 
34
32
  type AnyDefNode = OpDefNode | ThmOrAssumpDefNode;
35
33
 
@@ -72,7 +70,6 @@ const addArgLevelParams = (
72
70
  });
73
71
  };
74
72
 
75
- // SetOfLevelConstraints.put keeps the lowest bound.
76
73
  const putLevelConstraint = (target: Map<SymbolNode, number>, param: SymbolNode, level: number) => {
77
74
  target.set(param, Math.min(level, target.get(param) ?? TEMPORAL_LEVEL));
78
75
  };
@@ -89,7 +86,6 @@ const putLevelConstraints = (
89
86
 
90
87
  const getArgLevelConstraintKey = (param: SymbolNode, position: number) => `${param.id}:${position}`;
91
88
 
92
- // SetOfArgLevelConstraints.put keeps the highest bound.
93
89
  const putArgLevelConstraint = (
94
90
  target: Map<string, ArgLevelConstraint>,
95
91
  param: SymbolNode,
@@ -129,7 +125,6 @@ const mergeLevels = (node: LevelFields, part: LevelFields) => {
129
125
  addArgLevelParams(node.argLevelParams, part.argLevelParams);
130
126
  };
131
127
 
132
- // ArgLevelParam.occur.
133
128
  const isOccurring = (argLevelParam: ArgLevelParam, symbols: SymbolNode[]) =>
134
129
  symbols.includes(argLevelParam.op) || symbols.includes(argLevelParam.param);
135
130
 
@@ -170,14 +165,12 @@ const getBoundSymbols = (node: OpApplNode) => [
170
165
  const getSubstitute = (symbol: SymbolNode, substs: Subst[]) =>
171
166
  substs.find((subst) => subst.op === symbol)?.expr;
172
167
 
173
- // Subst.paramSet and Subst.allParamSet.
174
168
  const getSubstitutedParams = (param: SymbolNode, substs: Subst[], isAll: boolean) => {
175
169
  const substitute = getSubstitute(param, substs);
176
170
  if (substitute === undefined) return new Set([param]);
177
171
  return isAll ? substitute.allParams : substitute.levelParams;
178
172
  };
179
173
 
180
- // Subst.getSubALPSet.
181
174
  const getSubstitutedArgLevelParams = (source: Map<string, ArgLevelParam>, substs: Subst[]) => {
182
175
  const result = new Map<string, ArgLevelParam>();
183
176
  source.forEach((argLevelParam, key) => {
@@ -201,7 +194,6 @@ interface ConstraintSource {
201
194
  argLevelParams: Map<string, ArgLevelParam>;
202
195
  }
203
196
 
204
- // Subst.getSubLCSet.
205
197
  const getSubstitutedLevelConstraints = (
206
198
  body: ConstraintSource,
207
199
  substs: Subst[],
@@ -235,7 +227,6 @@ const getSubstitutedLevelConstraints = (
235
227
  return result;
236
228
  };
237
229
 
238
- // Subst.getSubALCSet.
239
230
  const getSubstitutedArgLevelConstraints = (
240
231
  body: ConstraintSource,
241
232
  substs: Subst[],
@@ -268,7 +259,6 @@ const getSubstitutedArgLevelConstraints = (
268
259
  return result;
269
260
  };
270
261
 
271
- // ModuleNode.isConstant.
272
262
  const isConstantModule = (module: ModuleNode, check: LevelCheck) => {
273
263
  if (getDeclarations(module, VARIABLE_DECL_KIND).length > 0) return false;
274
264
  checkModuleLevels(module, check);
@@ -278,7 +268,6 @@ const isConstantModule = (module: ModuleNode, check: LevelCheck) => {
278
268
  return module.topLevel.every((node) => node.kind !== "Theorem" || node.level === CONSTANT_LEVEL);
279
269
  };
280
270
 
281
- // The parts of OpDefNode.levelCheck and ThmOrAssumpDefNode.levelCheck that follow the body's.
282
271
  const checkDefinitionBody = (node: AnyDefNode, params: FormalParamNode[], body: LevelFields) => {
283
272
  node.minMaxLevel = params.map((param) =>
284
273
  Array.from(
@@ -323,8 +312,6 @@ const checkDefinitionBody = (node: AnyDefNode, params: FormalParamNode[], body:
323
312
  );
324
313
  };
325
314
 
326
- // The checks of OpApplNode.levelCheck that compare the levels of the arguments of a defined
327
- // operator with the levels it allows.
328
315
  const checkArguments = (
329
316
  node: OpApplNode,
330
317
  operator: AnyDefNode,
@@ -395,7 +382,6 @@ const checkArguments = (
395
382
  });
396
383
  };
397
384
 
398
- // The level constraints OpApplNode.levelCheck derives for an application of a defined operator.
399
385
  const constrainArguments = (
400
386
  node: OpApplNode,
401
387
  operator: AnyDefNode,
@@ -532,8 +518,6 @@ const constrainArguments = (
532
518
  });
533
519
  };
534
520
 
535
- // The operators OpApplNode.levelCheck rejects with both temporal and action arguments, and how its
536
- // message names them.
537
521
  const LOGICAL_OPERATOR_NAMES = new Map([
538
522
  ["\\land", "\\land"],
539
523
  ["\\lor", "\\lor"],
@@ -543,9 +527,7 @@ const LOGICAL_OPERATOR_NAMES = new Map([
543
527
  ["$DisjList", "Disjunction list"],
544
528
  ]);
545
529
 
546
- // The checks at the end of OpApplNode.levelCheck of the temporal operators and quantifiers. TLC
547
- // 1.7.4's SANY reports these errors but leaves the node level-correct, so an operator applied to it
548
- // still checks its level.
530
+ // TLC 1.7.4's SANY reports these errors but leaves the node level-correct.
549
531
  const checkTemporalApplication = (node: OpApplNode, check: LevelCheck) => {
550
532
  const addTemporalError = (location: SanyLocation, text: string) => {
551
533
  addError(check, location, text);
@@ -710,8 +692,8 @@ const checkTheoremDefinition = (node: ThmOrAssumpDefNode, iteration: number, che
710
692
  return node.levelCorrect;
711
693
  };
712
694
 
713
- // ModuleNode.levelCheck: the definitions of each recursive section are checked twice, the second
714
- // time with the highest level and the parameters of the section's recursive operators.
695
+ // SANY checks the definitions of each recursive section twice, the second time with the highest
696
+ // level and the parameters of the section's recursive operators.
715
697
  export const checkModuleLevels = (module: ModuleNode, check: LevelCheck) => {
716
698
  if (module.isLevelChecked) return module.levelCorrect;
717
699
  module.isLevelChecked = true;
@@ -796,7 +778,6 @@ export const checkModuleLevels = (module: ModuleNode, check: LevelCheck) => {
796
778
  return module.levelCorrect;
797
779
  };
798
780
 
799
- // LevelNode.levelCheckSubnodes, which skips modules.
800
781
  const checkSubnodes = (
801
782
  node: LevelFields,
802
783
  subnodes: SemanticNode[],
@@ -816,8 +797,6 @@ const checkSubnodes = (
816
797
  return node.levelCorrect;
817
798
  };
818
799
 
819
- // TheoremNode.LevelCheckTemporal: the steps of the proof of a temporal theorem that must be
820
- // constant.
821
800
  const checkTemporalProof = (proof: ProofNode | undefined, check: LevelCheck) => {
822
801
  if (proof?.kind !== "NonLeafProof") return;
823
802
  proof.steps.forEach((step) => {
@@ -840,7 +819,6 @@ const checkTemporalProof = (proof: ProofNode | undefined, check: LevelCheck) =>
840
819
  });
841
820
  };
842
821
 
843
- // InstanceNode.levelCheck.
844
822
  const checkInstance = (node: InstanceNode, iteration: number, check: LevelCheck) => {
845
823
  if (node.levelChecked >= iteration) return node.levelCorrect;
846
824
  node.levelChecked = iteration;
@@ -1121,7 +1099,6 @@ const checkLevel = (node: SemanticNode, iteration: number, check: LevelCheck): b
1121
1099
  node.levelChecked = iteration;
1122
1100
  const isBodyCorrect = checkLevel(node.body, iteration, check);
1123
1101
  const isDefinitionCorrect = !node.definition || checkLevel(node.definition, iteration, check);
1124
- // AssumeNode's getters return its expression's levels.
1125
1102
  node.level = node.body.level;
1126
1103
  shareLevels(node, node.body);
1127
1104
  if (node.level !== CONSTANT_LEVEL) {
@@ -1134,8 +1111,8 @@ const checkLevel = (node: SemanticNode, iteration: number, check: LevelCheck): b
1134
1111
  return isBodyCorrect && isDefinitionCorrect;
1135
1112
  }
1136
1113
  case "Theorem": {
1137
- // TheoremNode declares its own levelChecked, so levelCheckSubnodes still runs on the
1138
- // theorem's definition, or its statement when it has none, and its proof.
1114
+ // TheoremNode declares its own levelChecked, so levelCheckSubnodes still runs on its definition,
1115
+ // or its statement when it has none, and its proof.
1139
1116
  if (node.levelChecked >= iteration) return true;
1140
1117
  const isCorrect = checkSubnodes(
1141
1118
  node,
@@ -1191,7 +1168,6 @@ const checkLevel = (node: SemanticNode, iteration: number, check: LevelCheck): b
1191
1168
  node.goal.level,
1192
1169
  );
1193
1170
  [node.goal, ...node.assumptions].forEach((part) => mergeLevels(node, part));
1194
- // LevelNode.addTemporalLevelConstraintToConstants.
1195
1171
  if (node.levelCorrect) {
1196
1172
  node.levelParams.forEach((param) => {
1197
1173
  if (param.kind === "OpDecl" && param.declKind === CONSTANT_DECL_KIND) {
package/src/sany/lexer.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { TlaError } from "../errors";
2
2
 
3
- // An emulation of the token manager that JavaCC generates for SANY's grammar, javacc/tla+.jj: the
4
- // tokens it produces, their kinds in TLAplusParserConstants order, and their positions.
3
+ // An emulation of the token manager that JavaCC generates for SANY's grammar, javacc/tla+.jj.
5
4
 
6
5
  export interface SanyToken {
7
6
  kind: number;
@@ -11,8 +10,7 @@ export interface SanyToken {
11
10
  next: SanyToken | undefined;
12
11
  }
13
12
 
14
- // The token kinds, in the order of TLAplusParserConstants, each with the literal images that
15
- // produce it. JavaCC breaks a tie between matches of the same length by this order.
13
+ // In TLAplusParserConstants order, by which JavaCC breaks a tie between matches of one length.
16
14
  const KINDS: [string, ...string[]][] = [
17
15
  ["EOF"],
18
16
  ["BEGIN_PRAGMA", "--->"],
@@ -261,7 +259,6 @@ const BAND_PATTERNS = getJunctionPatterns(String.raw`\.\/\\`);
261
259
  const BOR_PATTERNS = getJunctionPatterns(String.raw`\.\\\/`);
262
260
  const STEP = String.raw`<(?:[0-9]+|\+|\*)>`;
263
261
 
264
- // The tokens of the SPEC lexical state that are not literals, with their kinds.
265
262
  const SPEC_PATTERNS: [string, RegExp[]][] = [
266
263
  ["_BM0", [BEGIN_MODULE]],
267
264
  ["SEPARATOR", [/----+/y]],
@@ -278,7 +275,6 @@ const SPEC_PATTERNS: [string, RegExp[]][] = [
278
275
  ["UnnumberedStepLexeme", [new RegExp(String.raw`${STEP}(?:\*\.*|-\.*|\.+)`, "y")]],
279
276
  ];
280
277
 
281
- // The tokens of the DEFAULT and PRAGMA lexical states, which skip every other character.
282
278
  const DEFAULT_PATTERNS: [string, RegExp[]][] = [
283
279
  ["BEGIN_PRAGMA", [/--->/y]],
284
280
  ["_BM1", [BEGIN_MODULE]],
@@ -296,7 +292,6 @@ const getMatchLength = (pattern: RegExp, source: string, offset: number) => {
296
292
  return pattern.exec(source)?.[0].length ?? 0;
297
293
  };
298
294
 
299
- // The longest match at offset, the earliest kind among matches of that length.
300
295
  const matchPatterns = (patterns: [string, RegExp[]][], source: string, offset: number) =>
301
296
  patterns
302
297
  .map(([name, regexes]) => ({
@@ -329,8 +324,6 @@ const matchSpecToken = (source: string, offset: number) => {
329
324
 
330
325
  export const getTabStop = (column: number) => column + 8 - (column % 8);
331
326
 
332
- // SimpleCharStream.UpdateLineColumn: the line and column of each character, with tabs stopping
333
- // at multiples of 8.
334
327
  const getPositions = (source: string) => {
335
328
  const lines: number[] = [];
336
329
  const columns: number[] = [];
@@ -360,7 +353,6 @@ const getPositions = (source: string) => {
360
353
  return { lines, columns };
361
354
  };
362
355
 
363
- // The characters of a string literal that a string literal could still continue.
364
356
  const STRING_PREFIX = /"(?:[^"\n\r\\]|\\[ntrf\\"])*\\?/y;
365
357
  const LITERAL_PREFIXES = new Set(
366
358
  [...LITERALS.keys()].flatMap((image) =>
@@ -368,7 +360,6 @@ const LITERAL_PREFIXES = new Set(
368
360
  ),
369
361
  );
370
362
 
371
- // The characters JavaCC's token manager reads at offset while some token could still continue.
372
363
  const getTokenPrefix = (source: string, offset: number) => {
373
364
  let length = 0;
374
365
  while (LITERAL_PREFIXES.has(source.slice(offset, offset + length + 1))) length++;
@@ -378,9 +369,6 @@ const getTokenPrefix = (source: string, offset: number) => {
378
369
  );
379
370
  };
380
371
 
381
- // A lazy token stream over source, which returns SANY's message for the TokenMgrError JavaCC's
382
- // token manager throws at a character no token continues with, or at the end of the file in a
383
- // comment.
384
372
  export const createSanyLexer = (source: string) => {
385
373
  const positions = getPositions(source);
386
374
  const state = { offset: 0, mode: "DEFAULT" };
@@ -393,8 +381,8 @@ export const createSanyLexer = (source: string) => {
393
381
  });
394
382
  // JavaCC places the end of the file at the file's last character.
395
383
  const getEndOfFile = () => createToken(getKind("EOF"), source.length - 1, 0);
396
- // The lexer read the characters from start to end, and TLAplusParser.parse reports the end of
397
- // the file in a token that starts on an earlier line as an open comment.
384
+ // TLAplusParser.parse reports the end of the file in a token that starts on an earlier line as an
385
+ // open comment.
398
386
  const getLexicalError = (start: number, end: number, after: string) => {
399
387
  const index = end - 1;
400
388
  const line = positions.lines[index];
@@ -407,8 +395,7 @@ export const createSanyLexer = (source: string) => {
407
395
  ? formatLexicalError(line + 1, 0, undefined, after)
408
396
  : formatLexicalError(line, column + 1, undefined, after);
409
397
  };
410
- // A comment is a chain of MORE matches, which restarts after each nested comment bracket, and the
411
- // end of the file right after a bracket ends the token stream.
398
+ // The end of the file right after a nested comment bracket ends the token stream.
412
399
  const skipComment = () => {
413
400
  const start = state.offset;
414
401
  if (source.startsWith("\\*", start)) {
@@ -481,7 +468,6 @@ export const createSanyLexer = (source: string) => {
481
468
  return getNextToken;
482
469
  };
483
470
 
484
- // JavaCC's TokenMgrError.addEscapes, which escapes the characters of a lexical error's message.
485
471
  const LEXEME_ESCAPES = new Map([
486
472
  ["\b", "\\b"],
487
473
  ["\t", "\\t"],
@@ -502,8 +488,6 @@ export const escapeLexeme = (text: string) =>
502
488
  (character === "\0" ? "" : `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`),
503
489
  );
504
490
 
505
- // TokenMgrError.LexicalError: the character the lexer stopped at, or the end of the file, and the
506
- // characters of the token it had read.
507
491
  export const formatLexicalError = (
508
492
  line: number,
509
493
  column: number,
@@ -512,8 +496,8 @@ export const formatLexicalError = (
512
496
  ) =>
513
497
  `Lexical error at line ${line}, column ${column}. Encountered: ${character === undefined ? "<EOF> " : `"${escapeLexeme(character)}" (${character.charCodeAt(0)}), `}after : "${escapeLexeme(after)}"`;
514
498
 
515
- // TLC 1.7.4's lexer, which JavaCC generated without UNICODE_INPUT, reads a character past U+00FF
516
- // outside a comment by its low byte, and stops at one whose low byte is below 0x80.
499
+ // TLC 1.7.4's lexer, generated without UNICODE_INPUT, reads a character past U+00FF outside a
500
+ // comment by its low byte, and stops at one whose low byte is below 0x80.
517
501
  export const getSany174LexicalError = (source: string) => {
518
502
  const readToken = createSanyLexer(source);
519
503
  for (
@@ -7,10 +7,8 @@ import {
7
7
  type SemanticNode,
8
8
  } from "./nodes";
9
9
 
10
- // A port of SANY's tla2sany.linter.Linter, which warns about a record field named like a
11
- // definition or declaration of the module.
10
+ // A port of SANY's tla2sany.linter.Linter.
12
11
 
13
- // SemanticNode.getChildren.
14
12
  const getChildren = (node: SemanticNode): (SemanticNode | undefined)[] => {
15
13
  switch (node.kind) {
16
14
  case "OpAppl":
@@ -35,7 +33,6 @@ const getChildren = (node: SemanticNode): (SemanticNode | undefined)[] => {
35
33
  }
36
34
  };
37
35
 
38
- // Operators whose values are sets of values that a record field may range over.
39
36
  const SET_OPERATORS = new Map([
40
37
  ["Integers", "Int"],
41
38
  ["Naturals", "Nat"],
@@ -43,8 +40,6 @@ const SET_OPERATORS = new Map([
43
40
  ["Reals", "Reals"],
44
41
  ]);
45
42
 
46
- // Linter.isBuiltFromDeclarations: whether an expression applies a declared or bound symbol, BOOLEAN
47
- // or a standard set of numbers, directly or through the definitions it applies.
48
43
  const isBuiltFromDeclarations = (node: SemanticNode | undefined) => {
49
44
  const visited = new Set<SemanticNode>();
50
45
  const visit = (current: SemanticNode | undefined): boolean => {
@@ -83,7 +78,6 @@ const getDomain = (record: OpApplNode) =>
83
78
  .sort(),
84
79
  ]);
85
80
 
86
- // ModuleNode.getExtendedModuleSet(true).
87
81
  const getExtendedModules = (module: ModuleNode, found = new Set<ModuleNode>()) => {
88
82
  module.extendees.forEach((extendee) => {
89
83
  if (found.has(extendee)) return;
@@ -93,7 +87,6 @@ const getExtendedModules = (module: ModuleNode, found = new Set<ModuleNode>()) =
93
87
  return found;
94
88
  };
95
89
 
96
- // Linter.lintRecords: the warnings for the records of a module.
97
90
  export const lintSanyModule = (module: ModuleNode): SanyMessage[] => {
98
91
  const linted = module.records.map((record) => ({
99
92
  domain: getDomain(record),
@@ -156,8 +156,7 @@ CopiesIn(e, B) ==
156
156
  5 Dec 98 : Initial version.
157
157
  `;
158
158
 
159
- // The standard modules of SANY's tla2sany/StandardModules (tla2tools.jar 2026.10.28), verbatim,
160
- // since the XML that SANY exports locates every node of them and keeps their comments.
159
+ // Verbatim from tla2tools.jar 2026.10.28, since SANY's XML locates every node and keeps comments.
161
160
  export const SANY_STANDARD_MODULES = new Map([
162
161
  ["Bags", BAGS],
163
162
  [
@@ -1289,8 +1288,6 @@ _TLCTrace ==
1289
1288
  ],
1290
1289
  ]);
1291
1290
 
1292
- // The standard modules of TLC 1.7.4's tla2tools.jar, which has none of the later ones and older
1293
- // Bags, Randomization and Toolbox modules.
1294
1291
  export const SANY_174_STANDARD_MODULES = new Map([
1295
1292
  ...[...SANY_STANDARD_MODULES].filter(([name]) =>
1296
1293
  ["FiniteSets", "Integers", "Naturals", "RealTime", "Reals", "Sequences", "TLC"].includes(name),
@@ -1393,6 +1390,5 @@ _TEPosition ==
1393
1390
  ],
1394
1391
  ]);
1395
1392
 
1396
- // The standard modules of the SANY of a TLC.
1397
1393
  export const getSanyStandardModules = (version: TlcVersion = "master") =>
1398
1394
  version === "1.7.4" ? SANY_174_STANDARD_MODULES : SANY_STANDARD_MODULES;
package/src/sany/nodes.ts CHANGED
@@ -1,6 +1,3 @@
1
- // The semantic nodes of SANY's tla2sany.semantic package that its XMLExporter writes out, with the
2
- // fields that the export and SANY's level checking read.
3
-
4
1
  export interface SanyLocation {
5
2
  file: string;
6
3
  beginLine: number;
@@ -9,27 +6,21 @@ export interface SanyLocation {
9
6
  endColumn: number;
10
7
  }
11
8
 
12
- // An error or warning SANY reports, with the location its message names. A location of undefined
13
- // is SANY's unknown location, and one that is just a module name stands for the whole module.
14
9
  export interface SanyMessage {
15
10
  location: SanyLocation | string | undefined;
16
11
  text: string;
17
12
  isWarning: boolean;
18
- // The ErrorCode SANY files a message under, where another check files the same text.
19
13
  code?: string;
20
14
  }
21
15
 
22
- // Errors.addMessage: SANY keeps one copy of each message, and after TLC 1.7.4 one for each code.
23
16
  export const addSanyMessage = (messages: SanyMessage[], message: SanyMessage) => {
24
17
  const key = JSON.stringify(message);
25
18
  if (!messages.some((candidate) => JSON.stringify(candidate) === key)) messages.push(message);
26
19
  };
27
20
 
28
- // Location.toString.
29
21
  export const formatSanyLocation = (location: SanyMessage["location"]) => {
30
22
  if (location === undefined) return "Unknown location";
31
23
  if (typeof location === "string") return `In module ${location}`;
32
- // Location.toString names only the module of a location at line 0, column 0.
33
24
  if (
34
25
  location.beginLine === 0 &&
35
26
  location.beginColumn === 0 &&
@@ -41,23 +32,18 @@ export const formatSanyLocation = (location: SanyMessage["location"]) => {
41
32
  return `line ${location.beginLine}, col ${location.beginColumn} to line ${location.endLine}, col ${location.endColumn} of module ${location.file}`;
42
33
  };
43
34
 
44
- // SANY's ArgLevelParam: the level of argument index of operator op depends on param.
45
35
  export interface ArgLevelParam {
46
36
  op: SymbolNode;
47
37
  index: number;
48
38
  param: SymbolNode;
49
39
  }
50
40
 
51
- // SANY's ParamAndPosition with its level in a SetOfArgLevelConstraints: the argument at position of
52
- // operator param must be allowed a level of at least level.
53
41
  export interface ArgLevelConstraint {
54
42
  param: SymbolNode;
55
43
  position: number;
56
44
  level: number;
57
45
  }
58
46
 
59
- // The fields of SANY's LevelNode. levelChecked is 0 until levelCheck runs, and SANY exports a level
60
- // only for the nodes it has level-checked.
61
47
  export interface LevelFields {
62
48
  id: number;
63
49
  levelChecked: number;
@@ -67,12 +53,10 @@ export interface LevelFields {
67
53
  nonLeibnizParams: Set<SymbolNode>;
68
54
  argLevelParams: Map<string, ArgLevelParam>;
69
55
  levelCorrect: boolean;
70
- // SetOfLevelConstraints: the highest level each parameter may have.
71
56
  levelConstraints: Map<SymbolNode, number>;
72
57
  argLevelConstraints: Map<string, ArgLevelConstraint>;
73
58
  }
74
59
 
75
- // SANY's kinds of declared symbols, from tla2sany.semantic.ASTConstants.
76
60
  export const CONSTANT_DECL_KIND = 2;
77
61
  export const VARIABLE_DECL_KIND = 3;
78
62
  export const NEW_CONSTANT_KIND = 24;
@@ -117,7 +101,6 @@ export interface OpDefNode extends LevelFields {
117
101
  maxLevels: number[];
118
102
  minMaxLevel: number[][] | undefined;
119
103
  labels: Map<string, LabelNode>;
120
- // The DEFINE, USE, HIDE or INSTANCE step that a NumberedProofStep definition names.
121
104
  step: ProofStepNode | undefined;
122
105
  }
123
106
 
@@ -154,7 +137,6 @@ export interface ModuleNode {
154
137
  argLevelParams: Map<string, ArgLevelParam>;
155
138
  levelConstraints: Map<SymbolNode, number>;
156
139
  argLevelConstraints: Map<string, ArgLevelConstraint>;
157
- // ModuleNode.getRecords: the record constructors and sets of records generated for the module.
158
140
  records: OpApplNode[];
159
141
  }
160
142
 
@@ -169,9 +151,7 @@ export interface OpApplNode extends LevelFields {
169
151
  tupleOrs: boolean[] | undefined;
170
152
  ranges: ExprNode[];
171
153
  location: SanyLocation;
172
- // Generator.nullOAN, whose operator, nullODN, has no kind that the XMLExporter can export.
173
154
  isNull?: boolean;
174
- // The null that SANY generates for an operator it cannot resolve.
175
155
  isAbsent?: boolean;
176
156
  }
177
157
 
@@ -272,8 +252,6 @@ export interface TheoremNode extends LevelFields {
272
252
  location: SanyLocation;
273
253
  }
274
254
 
275
- // A fact of a BY, USE or HIDE: an expression, an ASSUME/PROVE or NEW clause, a module, or the
276
- // definition of a module instance.
277
255
  export type FactNode = LevelNode | ModuleNode | OpDefNode;
278
256
 
279
257
  export interface LeafProofNode extends LevelFields {
@@ -348,9 +326,6 @@ type TopLevelNode = InstanceNode | AssumeNode | TheoremNode | UseOrHideNode;
348
326
 
349
327
  export type SemanticNode = SymbolNode | LevelNode | TopLevelNode | ProofPartNode;
350
328
 
351
- // SANY's Context: a java.util.Hashtable from names to symbols, whose iteration order SANY's lists
352
- // of constants, variables and instantiated definitions follow, and the symbols in the order they
353
- // were added.
354
329
  export interface Context {
355
330
  table: JavaHashtable;
356
331
  symbols: SymbolNode[];
@@ -368,7 +343,6 @@ interface JavaHashtable {
368
343
  threshold: number;
369
344
  }
370
345
 
371
- // java.lang.String.hashCode, over UTF-16 code units.
372
346
  const getJavaHash = (text: string) => {
373
347
  let hash = 0;
374
348
  for (let index = 0; index < text.length; index++) {
@@ -377,7 +351,6 @@ const getJavaHash = (text: string) => {
377
351
  return hash;
378
352
  };
379
353
 
380
- // A java.util.Hashtable with its default capacity of 11 and load factor of 0.75.
381
354
  const createJavaHashtable = (): JavaHashtable => ({
382
355
  buckets: Array.from({ length: 11 }, () => []),
383
356
  count: 0,
@@ -417,7 +390,6 @@ const putHashtableValue = (table: JavaHashtable, key: string, value: SymbolNode,
417
390
  table.count++;
418
391
  };
419
392
 
420
- // The values in the order of Hashtable.elements(), from the last bucket to the first.
421
393
  export const getHashtableValues = (table: JavaHashtable) =>
422
394
  table.buckets.toReversed().flatMap((bucket) => bucket.map((entry) => entry.value));
423
395
 
@@ -442,14 +414,11 @@ export const getContextSymbol = (context: Context, name: string) =>
442
414
  export const getContextModule = (context: Context, name: string) =>
443
415
  getHashtableValue(context.table, MODULE_KEY_PREFIX + name, name);
444
416
 
445
- // ModuleNode.getOpDefs: the definitions in the order they joined the context, without builtins
446
- // and module instances.
447
417
  export const getOpDefs = (module: ModuleNode) =>
448
418
  module.context.symbols.filter(
449
419
  (symbol): symbol is OpDefNode => symbol.kind === "OpDef" && symbol.defKind === "UserDefined",
450
420
  );
451
421
 
452
- // ModuleNode.getConstantDecls and getVariableDecls reverse the Hashtable's order.
453
422
  export const getDeclarations = (module: ModuleNode, declKind: number) =>
454
423
  getHashtableValues(module.context.table)
455
424
  .filter(