tla-ts 0.0.4-dev.702eb98 → 0.0.4-dev.7714e32

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 (382) hide show
  1. package/README.md +32 -6
  2. package/dist/cli.cjs +1 -1
  3. package/dist/cli.js +1 -1
  4. package/dist/deciders.cjs +27 -27
  5. package/dist/deciders.js +34 -34
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.cts +12 -14
  8. package/dist/index.d.ts +12 -14
  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 +516 -25
  15. package/dist/prove.js +518 -27
  16. package/dist/run.cjs +45 -0
  17. package/dist/run.js +45 -0
  18. package/dist/tlapm.cjs +2 -2
  19. package/dist/tlapm.js +2 -2
  20. package/dist/transfer.cjs +76 -86
  21. package/dist/transfer.js +73 -83
  22. package/dist/worker.cjs +6 -6
  23. package/dist/worker.js +6 -6
  24. package/package.json +1 -1
  25. package/src/ast.ts +2 -2
  26. package/src/bags.ts +22 -23
  27. package/src/builtins.ts +16 -8
  28. package/src/check.ts +131 -1154
  29. package/src/{cli-options.ts → cli/options.ts} +54 -9
  30. package/src/cli/run.ts +63 -0
  31. package/src/cli/shared.ts +106 -0
  32. package/src/cli/tlapm.ts +374 -0
  33. package/src/{run-cli.ts → cli/tlc.ts} +112 -761
  34. package/src/cli/xml-exporter.ts +221 -0
  35. package/src/cli.ts +1 -1
  36. package/src/codegen.ts +17 -15
  37. package/src/config.ts +5 -5
  38. package/src/dependencies.ts +4 -6
  39. package/src/environment.ts +55 -60
  40. package/src/errors.ts +12 -36
  41. package/src/evaluate.ts +81 -101
  42. package/src/exit-codes.ts +1 -1
  43. package/src/fingerprints.ts +3 -3
  44. package/src/index.ts +2 -2
  45. package/src/instances.ts +56 -46
  46. package/src/java-overrides.ts +79 -41
  47. package/src/json.ts +31 -36
  48. package/src/levels.ts +10 -13
  49. package/src/{live-check.ts → liveness-checker.ts} +169 -142
  50. package/src/liveness.ts +38 -34
  51. package/src/obligations/action.ts +58 -105
  52. package/src/obligations/{anon.ts → anonymize.ts} +44 -52
  53. package/src/obligations/equality.ts +260 -0
  54. package/src/obligations/expression.ts +42 -530
  55. package/src/obligations/format.ts +7 -8
  56. package/src/obligations/generate.ts +93 -783
  57. package/src/obligations/index.ts +23 -23
  58. package/src/obligations/levels.ts +38 -44
  59. package/src/obligations/module.ts +106 -729
  60. package/src/obligations/normalize.ts +554 -0
  61. package/src/obligations/operators.ts +176 -0
  62. package/src/obligations/pragma.ts +35 -29
  63. package/src/obligations/printer.ts +98 -209
  64. package/src/obligations/proof.ts +0 -1
  65. package/src/obligations/regroup.ts +100 -0
  66. package/src/obligations/simplify.ts +668 -0
  67. package/src/obligations/source.ts +92 -192
  68. package/src/obligations/{deref.ts → subexpression.ts} +82 -113
  69. package/src/obligations/substitution.ts +261 -0
  70. package/src/obligations/temporal.ts +32 -30
  71. package/src/obligations/tuples.ts +37 -53
  72. package/src/parallel-worker.ts +37 -33
  73. package/src/parallel.ts +30 -24
  74. package/src/parser.ts +67 -74
  75. package/src/{pcal-ast.ts → pcal/ast.ts} +2 -17
  76. package/src/{pcal-parse.ts → pcal/parse.ts} +28 -64
  77. package/src/{pcal-tokenize.ts → pcal/tokenize.ts} +10 -39
  78. package/src/{pcal-translate.ts → pcal/translate.ts} +30 -109
  79. package/src/{pcal-validate.ts → pcal/validate.ts} +10 -20
  80. package/src/{prove → prover}/decide-pool.ts +14 -19
  81. package/src/{prove → prover}/deciders.ts +7 -1
  82. package/src/{obligations/pickle.ts → prover/first-order.ts} +79 -4
  83. package/src/{prove → prover}/isabelle/decide.ts +3 -6
  84. package/src/{prove → prover}/isabelle/encode.ts +106 -138
  85. package/src/{prove → prover}/isabelle/isar/inner-syntax.ts +1 -1
  86. package/src/{prove → prover}/isabelle/isar/method.ts +3 -3
  87. package/src/{prove → prover}/isabelle/isar/type-check.ts +1 -1
  88. package/src/{prove → prover}/isabelle/provers/blast/blast.ts +1 -1
  89. package/src/{prove → prover}/isabelle/provers/blast/branch.ts +1 -1
  90. package/src/{prove → prover}/isabelle/provers/blast/term.ts +3 -4
  91. package/src/{prove → prover}/isabelle/provers/clasimp.ts +1 -1
  92. package/src/{prove → prover}/isabelle/provers/classical.ts +3 -3
  93. package/src/{prove → prover}/isabelle/provers/hypsubst.ts +1 -9
  94. package/src/{prove → prover}/isabelle/pure/conv.ts +1 -1
  95. package/src/{prove → prover}/isabelle/pure/drule.ts +2 -2
  96. package/src/{prove → prover}/isabelle/pure/envir.ts +3 -35
  97. package/src/{prove → prover}/isabelle/pure/logic.ts +4 -76
  98. package/src/{prove → prover}/isabelle/pure/name.ts +1 -13
  99. package/src/{prove → prover}/isabelle/pure/net.ts +2 -49
  100. package/src/{prove → prover}/isabelle/pure/pattern.ts +3 -22
  101. package/src/{prove → prover}/isabelle/pure/raw-simplifier.ts +3 -18
  102. package/src/{prove → prover}/isabelle/pure/seq.ts +0 -23
  103. package/src/{prove → prover}/isabelle/pure/simplifier.ts +2 -8
  104. package/src/{prove → prover}/isabelle/pure/table.ts +1 -8
  105. package/src/{prove → prover}/isabelle/pure/tactic.ts +5 -113
  106. package/src/{prove → prover}/isabelle/pure/tactical.ts +1 -84
  107. package/src/{prove → prover}/isabelle/pure/term-ord.ts +1 -55
  108. package/src/{prove → prover}/isabelle/pure/term.ts +8 -128
  109. package/src/{prove → prover}/isabelle/pure/thm.ts +4 -27
  110. package/src/{prove → prover}/isabelle/pure/type.ts +0 -12
  111. package/src/{prove → prover}/isabelle/pure/unify.ts +1 -1
  112. package/src/{prove → prover}/isabelle/tla/classical-setup.ts +1 -1
  113. package/src/{prove → prover}/ocaml.ts +1 -1
  114. package/src/{prove → prover}/prep/action.ts +54 -66
  115. package/src/{prove → prover}/prep/enabled-axioms.ts +2 -2
  116. package/src/{prove → prover}/prep/fingerprint.ts +3 -3
  117. package/src/{prove → prover}/prep/level-comparison.ts +15 -38
  118. package/src/{prove → prover}/prep/md5.ts +2 -9
  119. package/src/{prove/prep/pragma.ts → prover/prep/methods.ts} +4 -4
  120. package/src/prover/prep/normalize.ts +309 -0
  121. package/src/{prove → prover}/prove-worker.ts +4 -11
  122. package/src/prover/prove.ts +492 -0
  123. package/src/{prove → prover}/ptl/encode.ts +19 -31
  124. package/src/{prove → prover}/smt/axioms.ts +78 -79
  125. package/src/{prove → prover}/smt/data.ts +16 -45
  126. package/src/{prove → prover}/smt/encode.ts +134 -28
  127. package/src/{prove → prover}/smt/extensionality.ts +14 -12
  128. package/src/{prove → prover}/smt/flatten.ts +3 -18
  129. package/src/{prove → prover}/smt/format.ts +14 -3
  130. package/src/{prove → prover}/smt/instances.ts +4 -5
  131. package/src/{prove → prover}/smt/rewrite.ts +41 -59
  132. package/src/{prove → prover}/smt/solver/ast-util.ts +0 -56
  133. package/src/{prove → prover}/smt/solver/case-split-queue.ts +1 -1
  134. package/src/{prove → prover}/smt/solver/enode.ts +1 -1
  135. package/src/{prove → prover}/smt/solver/lp/dep-intervals.ts +0 -14
  136. package/src/{prove → prover}/smt/solver/model-macro-solver.ts +1 -1
  137. package/src/{prove → prover}/smt/solver/nlsat/algebraic.ts +3 -3
  138. package/src/{prove → prover}/smt/solver/nlsat/atoms.ts +1 -1
  139. package/src/{prove → prover}/smt/solver/nlsat/explain.ts +1 -1
  140. package/src/{prove → prover}/smt/solver/nlsat/interval-set.ts +1 -1
  141. package/src/{prove → prover}/smt/solver/nlsat/levelwise.ts +4 -7
  142. package/src/{prove → prover}/smt/solver/nlsat/polynomial.ts +4 -4
  143. package/src/{prove → prover}/smt/solver/nlsat/upolynomial.ts +2 -2
  144. package/src/{prove → prover}/smt/solver/pattern-inference.ts +1 -1
  145. package/src/{prove → prover}/smt/solver/relevancy.ts +2 -2
  146. package/src/{prove → prover}/smt/solver/rewriter.ts +1 -1
  147. package/src/{prove → prover}/smt/solver/solver.ts +2 -2
  148. package/src/prover/tlapm/cache.ts +236 -0
  149. package/src/prover/tlapm/ocaml-marshal.ts +166 -0
  150. package/src/{prove → prover}/tlapm/tlapm.ts +1 -2
  151. package/src/prover/verdict.ts +13 -0
  152. package/src/{prove → prover}/zenon/decide.ts +5 -11
  153. package/src/{prove → prover}/zenon/encode.ts +40 -106
  154. package/src/{prove → prover}/zenon/eqrel.ts +1 -1
  155. package/src/{prove → prover}/zenon/equality-rules.ts +1 -1
  156. package/src/{prove → prover}/zenon/expr.ts +2 -2
  157. package/src/{prove → prover}/zenon/index-table.ts +1 -1
  158. package/src/{prove → prover}/zenon/isar.ts +1 -1
  159. package/src/{prove → prover}/zenon/llproof.ts +1 -1
  160. package/src/{prove → prover}/zenon/mltoll.ts +1 -1
  161. package/src/{prove → prover}/zenon/node.ts +1 -1
  162. package/src/{prove → prover}/zenon/search.ts +1 -1
  163. package/src/{prove → prover}/zenon/tla/terms.ts +1 -20
  164. package/src/{prove → prover}/zenon/tla/tla.ts +1 -1
  165. package/src/randomization.ts +19 -24
  166. package/src/resolve.ts +15 -22
  167. package/src/runtime.ts +8 -8
  168. package/src/{sany-builtins.ts → sany/builtins.ts} +1 -1
  169. package/src/{sany-generator.ts → sany/generator.ts} +38 -55
  170. package/src/{sany-levels.ts → sany/levels.ts} +45 -48
  171. package/src/{sany-lexer.ts → sany/lexer.ts} +2 -3
  172. package/src/{sany-linter.ts → sany/linter.ts} +1 -1
  173. package/src/{sany-modules.ts → sany/modules.ts} +2 -2
  174. package/src/{sany-nodes.ts → sany/nodes.ts} +2 -2
  175. package/src/{sany-parse-error.ts → sany/parse-error.ts} +2 -2
  176. package/src/{sany-report.ts → sany/report.ts} +16 -17
  177. package/src/{sany-selectors.ts → sany/selectors.ts} +3 -5
  178. package/src/{sany-source.ts → sany/source.ts} +6 -7
  179. package/src/{sany-xml.ts → sany/xml.ts} +5 -6
  180. package/src/search.ts +969 -0
  181. package/src/spec-description.ts +26 -20
  182. package/src/{standard-levels.ts → standard-definitions.ts} +118 -2
  183. package/src/standard-modules.ts +16 -20
  184. package/src/state-graph.ts +9 -8
  185. package/src/substitution-levels.ts +2 -2
  186. package/src/successors.ts +16 -19
  187. package/src/symmetry.ts +1 -1
  188. package/src/tableau.ts +6 -7
  189. package/src/tlc/fingerprint.ts +214 -0
  190. package/src/{tlc-messages.ts → tlc/messages.ts} +119 -7
  191. package/src/{tlc-order.ts → tlc/order.ts} +7 -7
  192. package/src/{tlc-random.ts → tlc/random.ts} +3 -213
  193. package/src/{tlc-replay.ts → tlc/replay.ts} +40 -36
  194. package/src/{tlc-module.ts → tlc/tlc-operators.ts} +9 -9
  195. package/src/{tlc-ext.ts → tlc/tlcext-operators.ts} +30 -25
  196. package/src/transfer.ts +32 -32
  197. package/src/values.ts +72 -67
  198. package/src/worker.ts +1 -4
  199. package/dist/run-cli.cjs +0 -38
  200. package/dist/run-cli.js +0 -38
  201. package/src/canonical.ts +0 -40
  202. package/src/obligations/ctx.ts +0 -64
  203. package/src/prove/prep/defs.ts +0 -27
  204. package/src/prove/prep/elab.ts +0 -156
  205. package/src/prove/prep/enabled.ts +0 -43
  206. package/src/prove/prep/flatten.ts +0 -70
  207. package/src/prove/prep/trivial.ts +0 -22
  208. package/src/prove/prove.ts +0 -417
  209. package/src/prove/smt/axiomatize.ts +0 -69
  210. package/src/prove/smt/simplify.ts +0 -57
  211. package/src/prove/verdict.ts +0 -13
  212. package/src/standard-ranges.ts +0 -116
  213. package/src/value-sources.ts +0 -29
  214. /package/src/{prove → prover}/isabelle/LICENSE +0 -0
  215. /package/src/{prove → prover}/isabelle/LICENSE-tlapm +0 -0
  216. /package/src/{prove → prover}/isabelle/isar/proof.ts +0 -0
  217. /package/src/{prove → prover}/isabelle/isar/statement.ts +0 -0
  218. /package/src/{prove → prover}/isabelle/isar/theory.ts +0 -0
  219. /package/src/{prove → prover}/isabelle/provers/blast/prove.ts +0 -0
  220. /package/src/{prove → prover}/isabelle/provers/blast/rules.ts +0 -0
  221. /package/src/{prove → prover}/isabelle/provers/blast/state.ts +0 -0
  222. /package/src/{prove → prover}/isabelle/pure/bicompose.ts +0 -0
  223. /package/src/{prove → prover}/isabelle/pure/consts.ts +0 -0
  224. /package/src/{prove → prover}/isabelle/pure/goal.ts +0 -0
  225. /package/src/{prove → prover}/isabelle/pure/interrupt.ts +0 -0
  226. /package/src/{prove → prover}/isabelle/pure/list.ts +0 -0
  227. /package/src/{prove → prover}/isabelle/pure/object-logic.ts +0 -0
  228. /package/src/{prove → prover}/isabelle/pure/rewriter.ts +0 -0
  229. /package/src/{prove → prover}/isabelle/pure/search.ts +0 -0
  230. /package/src/{prove → prover}/isabelle/pure/variable.ts +0 -0
  231. /package/src/{prove → prover}/isabelle/tla/context.ts +0 -0
  232. /package/src/{prove → prover}/isabelle/tla/logic-data.ts +0 -0
  233. /package/src/{prove → prover}/isabelle/tla/logic.ts +0 -0
  234. /package/src/{prove → prover}/isabelle/tla/simpdata.ts +0 -0
  235. /package/src/{prove → prover}/isabelle/tools/intuitionistic.ts +0 -0
  236. /package/src/{prove → prover}/ptl/decide.ts +0 -0
  237. /package/src/{prove → prover}/ptl/sat.ts +0 -0
  238. /package/src/{prove → prover}/ptl/tableau.ts +0 -0
  239. /package/src/{prove → prover}/smt/context.ts +0 -0
  240. /package/src/{prove → prover}/smt/solver/act-cache.ts +0 -0
  241. /package/src/{prove → prover}/smt/solver/arith-rewriter.ts +0 -0
  242. /package/src/{prove → prover}/smt/solver/array.ts +0 -0
  243. /package/src/{prove → prover}/smt/solver/asserted-formulas.ts +0 -0
  244. /package/src/{prove → prover}/smt/solver/ast-lt.ts +0 -0
  245. /package/src/{prove → prover}/smt/solver/ast.ts +0 -0
  246. /package/src/{prove → prover}/smt/solver/auf-solver.ts +0 -0
  247. /package/src/{prove → prover}/smt/solver/cg-table.ts +0 -0
  248. /package/src/{prove → prover}/smt/solver/clause.ts +0 -0
  249. /package/src/{prove → prover}/smt/solver/conflict-resolution.ts +0 -0
  250. /package/src/{prove → prover}/smt/solver/context.ts +0 -0
  251. /package/src/{prove → prover}/smt/solver/ctx-simplify.ts +0 -0
  252. /package/src/{prove → prover}/smt/solver/der.ts +0 -0
  253. /package/src/{prove → prover}/smt/solver/dyn-ack.ts +0 -0
  254. /package/src/{prove → prover}/smt/solver/e-matching.ts +0 -0
  255. /package/src/{prove → prover}/smt/solver/expr-ref.ts +0 -0
  256. /package/src/{prove → prover}/smt/solver/expr-safe-replace.ts +0 -0
  257. /package/src/{prove → prover}/smt/solver/fingerprints.ts +0 -0
  258. /package/src/{prove → prover}/smt/solver/flat-literals.ts +0 -0
  259. /package/src/{prove → prover}/smt/solver/goal.ts +0 -0
  260. /package/src/{prove → prover}/smt/solver/hash.ts +0 -0
  261. /package/src/{prove → prover}/smt/solver/hashtable.ts +0 -0
  262. /package/src/{prove → prover}/smt/solver/internalizer.ts +0 -0
  263. /package/src/{prove → prover}/smt/solver/lbool.ts +0 -0
  264. /package/src/{prove → prover}/smt/solver/literal.ts +0 -0
  265. /package/src/{prove → prover}/smt/solver/lp/bound-propagator.ts +0 -0
  266. /package/src/{prove → prover}/smt/solver/lp/constraints.ts +0 -0
  267. /package/src/{prove → prover}/smt/solver/lp/containers.ts +0 -0
  268. /package/src/{prove → prover}/smt/solver/lp/core-solver.ts +0 -0
  269. /package/src/{prove → prover}/smt/solver/lp/cross-nested.ts +0 -0
  270. /package/src/{prove → prover}/smt/solver/lp/dependency.ts +0 -0
  271. /package/src/{prove → prover}/smt/solver/lp/dioph-eq.ts +0 -0
  272. /package/src/{prove → prover}/smt/solver/lp/explanation.ts +0 -0
  273. /package/src/{prove → prover}/smt/solver/lp/gomory.ts +0 -0
  274. /package/src/{prove → prover}/smt/solver/lp/hnf-cutter.ts +0 -0
  275. /package/src/{prove → prover}/smt/solver/lp/hnf.ts +0 -0
  276. /package/src/{prove → prover}/smt/solver/lp/int-cube.ts +0 -0
  277. /package/src/{prove → prover}/smt/solver/lp/int-solver.ts +0 -0
  278. /package/src/{prove → prover}/smt/solver/lp/lar-solver.ts +0 -0
  279. /package/src/{prove → prover}/smt/solver/lp/lar-term.ts +0 -0
  280. /package/src/{prove → prover}/smt/solver/lp/lp-settings.ts +0 -0
  281. /package/src/{prove → prover}/smt/solver/lp/maximize-term.ts +0 -0
  282. /package/src/{prove → prover}/smt/solver/lp/nex-creator.ts +0 -0
  283. /package/src/{prove → prover}/smt/solver/lp/nex.ts +0 -0
  284. /package/src/{prove → prover}/smt/solver/lp/nla-backoff.ts +0 -0
  285. /package/src/{prove → prover}/smt/solver/lp/nla-basics.ts +0 -0
  286. /package/src/{prove → prover}/smt/solver/lp/nla-core.ts +0 -0
  287. /package/src/{prove → prover}/smt/solver/lp/nla-divisions.ts +0 -0
  288. /package/src/{prove → prover}/smt/solver/lp/nla-emonics.ts +0 -0
  289. /package/src/{prove → prover}/smt/solver/lp/nla-factorization.ts +0 -0
  290. /package/src/{prove → prover}/smt/solver/lp/nla-grobner.ts +0 -0
  291. /package/src/{prove → prover}/smt/solver/lp/nla-horner.ts +0 -0
  292. /package/src/{prove → prover}/smt/solver/lp/nla-intervals.ts +0 -0
  293. /package/src/{prove → prover}/smt/solver/lp/nla-monomial-bounds.ts +0 -0
  294. /package/src/{prove → prover}/smt/solver/lp/nla-monotone.ts +0 -0
  295. /package/src/{prove → prover}/smt/solver/lp/nla-order.ts +0 -0
  296. /package/src/{prove → prover}/smt/solver/lp/nla-patcher.ts +0 -0
  297. /package/src/{prove → prover}/smt/solver/lp/nla-tangents.ts +0 -0
  298. /package/src/{prove → prover}/smt/solver/lp/nla-throttle.ts +0 -0
  299. /package/src/{prove → prover}/smt/solver/lp/nla-types.ts +0 -0
  300. /package/src/{prove → prover}/smt/solver/lp/nla-var-eqs.ts +0 -0
  301. /package/src/{prove → prover}/smt/solver/lp/nra-solver.ts +0 -0
  302. /package/src/{prove → prover}/smt/solver/lp/numeric-pair.ts +0 -0
  303. /package/src/{prove → prover}/smt/solver/lp/pdd-interval.ts +0 -0
  304. /package/src/{prove → prover}/smt/solver/lp/pdd-simplifier.ts +0 -0
  305. /package/src/{prove → prover}/smt/solver/lp/pdd-solver.ts +0 -0
  306. /package/src/{prove → prover}/smt/solver/lp/pdd.ts +0 -0
  307. /package/src/{prove → prover}/smt/solver/lp/random-updater.ts +0 -0
  308. /package/src/{prove → prover}/smt/solver/lp/static-matrix.ts +0 -0
  309. /package/src/{prove → prover}/smt/solver/lp/union-find.ts +0 -0
  310. /package/src/{prove → prover}/smt/solver/mam-compiler.ts +0 -0
  311. /package/src/{prove → prover}/smt/solver/mam-interpreter.ts +0 -0
  312. /package/src/{prove → prover}/smt/solver/maximize-ac-sharing.ts +0 -0
  313. /package/src/{prove → prover}/smt/solver/model-checker.ts +0 -0
  314. /package/src/{prove → prover}/smt/solver/model-evaluator.ts +0 -0
  315. /package/src/{prove → prover}/smt/solver/model-finder.ts +0 -0
  316. /package/src/{prove → prover}/smt/solver/model-generator.ts +0 -0
  317. /package/src/{prove → prover}/smt/solver/nlsat/evaluator.ts +0 -0
  318. /package/src/{prove → prover}/smt/solver/nlsat/mpbq.ts +0 -0
  319. /package/src/{prove → prover}/smt/solver/nlsat/solver.ts +0 -0
  320. /package/src/{prove → prover}/smt/solver/nlsat/types.ts +0 -0
  321. /package/src/{prove → prover}/smt/solver/nlsat/upolynomial-factorization.ts +0 -0
  322. /package/src/{prove → prover}/smt/solver/nnf.ts +0 -0
  323. /package/src/{prove → prover}/smt/solver/poly-rewriter.ts +0 -0
  324. /package/src/{prove → prover}/smt/solver/propagate-values.ts +0 -0
  325. /package/src/{prove → prover}/smt/solver/proto-model.ts +0 -0
  326. /package/src/{prove → prover}/smt/solver/pull-quant.ts +0 -0
  327. /package/src/{prove → prover}/smt/solver/qe-lite-der.ts +0 -0
  328. /package/src/{prove → prover}/smt/solver/qe-lite-fm.ts +0 -0
  329. /package/src/{prove → prover}/smt/solver/qe-lite.ts +0 -0
  330. /package/src/{prove → prover}/smt/solver/qi-queue.ts +0 -0
  331. /package/src/{prove → prover}/smt/solver/quant-tactics.ts +0 -0
  332. /package/src/{prove → prover}/smt/solver/quantifier-analyzer.ts +0 -0
  333. /package/src/{prove → prover}/smt/solver/quantifier-manager.ts +0 -0
  334. /package/src/{prove → prover}/smt/solver/random-gen.ts +0 -0
  335. /package/src/{prove → prover}/smt/solver/rational.ts +0 -0
  336. /package/src/{prove → prover}/smt/solver/ref-vector.ts +0 -0
  337. /package/src/{prove → prover}/smt/solver/rewriter-tpl.ts +0 -0
  338. /package/src/{prove → prover}/smt/solver/rlimit.ts +0 -0
  339. /package/src/{prove → prover}/smt/solver/smtlib-parser.ts +0 -0
  340. /package/src/{prove → prover}/smt/solver/sort.ts +0 -0
  341. /package/src/{prove → prover}/smt/solver/sticky-generations.ts +0 -0
  342. /package/src/{prove → prover}/smt/solver/theory-lra-axioms.ts +0 -0
  343. /package/src/{prove → prover}/smt/solver/theory-lra-bounds.ts +0 -0
  344. /package/src/{prove → prover}/smt/solver/theory-lra-final-check.ts +0 -0
  345. /package/src/{prove → prover}/smt/solver/theory-lra-internalize.ts +0 -0
  346. /package/src/{prove → prover}/smt/solver/theory-lra-model.ts +0 -0
  347. /package/src/{prove → prover}/smt/solver/theory-lra-propagate.ts +0 -0
  348. /package/src/{prove → prover}/smt/solver/theory-lra-state.ts +0 -0
  349. /package/src/{prove → prover}/smt/solver/theory-lra.ts +0 -0
  350. /package/src/{prove → prover}/smt/solver/var-subst.ts +0 -0
  351. /package/src/{prove → prover}/smt/solver/z3-license.txt +0 -0
  352. /package/src/{prove → prover}/smt/table.ts +0 -0
  353. /package/src/{prove → prover}/tlaps-module.ts +0 -0
  354. /package/src/{prove → prover}/zenon/LICENSE +0 -0
  355. /package/src/{prove → prover}/zenon/check/check.ts +0 -0
  356. /package/src/{prove → prover}/zenon/check/definitions.ts +0 -0
  357. /package/src/{prove → prover}/zenon/check/equality.ts +0 -0
  358. /package/src/{prove → prover}/zenon/check/functions.ts +0 -0
  359. /package/src/{prove → prover}/zenon/check/keys.ts +0 -0
  360. /package/src/{prove → prover}/zenon/check/propositional.ts +0 -0
  361. /package/src/{prove → prover}/zenon/check/records.ts +0 -0
  362. /package/src/{prove → prover}/zenon/check/relations.ts +0 -0
  363. /package/src/{prove → prover}/zenon/check/rewrites.ts +0 -0
  364. /package/src/{prove → prover}/zenon/check/sets.ts +0 -0
  365. /package/src/{prove → prover}/zenon/check/terms.ts +0 -0
  366. /package/src/{prove → prover}/zenon/check/tla.ts +0 -0
  367. /package/src/{prove → prover}/zenon/isar-case.ts +0 -0
  368. /package/src/{prove → prover}/zenon/limits.ts +0 -0
  369. /package/src/{prove → prover}/zenon/ocaml.ts +0 -0
  370. /package/src/{prove → prover}/zenon/parse.ts +0 -0
  371. /package/src/{prove → prover}/zenon/phrase.ts +0 -0
  372. /package/src/{prove → prover}/zenon/proof.ts +0 -0
  373. /package/src/{prove → prover}/zenon/propositional-rules.ts +0 -0
  374. /package/src/{prove → prover}/zenon/rules.ts +0 -0
  375. /package/src/{prove → prover}/zenon/tla/functions.ts +0 -0
  376. /package/src/{prove → prover}/zenon/tla/llproof.ts +0 -0
  377. /package/src/{prove → prover}/zenon/tla/records.ts +0 -0
  378. /package/src/{prove → prover}/zenon/tla/rewrites.ts +0 -0
  379. /package/src/{prove → prover}/zenon/tla/sets.ts +0 -0
  380. /package/src/{tlc-modules.ts → tlc/jar-data.ts} +0 -0
  381. /package/src/{tlc-summary.ts → tlc/summary.ts} +0 -0
  382. /package/src/{tlc-version.ts → tlc/version.ts} +0 -0
package/src/runtime.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { createJavaRandom, getTlcFingerprint, type JavaRandom } from "./tlc-random";
1
+ import { getTlcFingerprint } from "./tlc/fingerprint";
2
+ import { createJavaRandom, type JavaRandom } from "./tlc/random";
2
3
  import { createFunction, createRecord, type Value } from "./values";
3
- import type { TlcVersion } from "./tlc-version";
4
+ import type { TlcVersion } from "./tlc/version";
4
5
 
5
6
  export interface CheckerRuntime {
6
7
  getLevel: (state: (Value | undefined)[]) => number;
@@ -22,7 +23,6 @@ export interface CheckerRuntime {
22
23
  // TLC's -tool, under which the message of an error that TLC raises with a code holds the
23
24
  // code's markers, which AssertError compares with.
24
25
  isTool: boolean;
25
- // The TLC whose messages tla-ts reproduces.
26
26
  version: TlcVersion;
27
27
  seed: bigint;
28
28
  isSeen: (state: Value[]) => boolean;
@@ -46,8 +46,8 @@ export interface CheckerRuntime {
46
46
  // its Random with the fingerprint of each state it expands, XORed with the seed, so a state's
47
47
  // successors are the same whatever order the workers expand states in.
48
48
  export const createRuntime = (checkDeadlock: boolean, seed = 0n): CheckerRuntime => {
49
- const startup = createJavaRandom(seed);
50
- const worker = { random: createJavaRandom(seed), state: undefined as Value[] | undefined };
49
+ const startupRandom = createJavaRandom(seed);
50
+ const worker = { random: createJavaRandom(seed), seededState: undefined as Value[] | undefined };
51
51
  const phase = { isStartup: false };
52
52
  const runtime: CheckerRuntime = {
53
53
  getLevel: () => 0,
@@ -60,10 +60,10 @@ export const createRuntime = (checkDeadlock: boolean, seed = 0n): CheckerRuntime
60
60
  getFingerprint: getTlcFingerprint,
61
61
  getRandom: () => {
62
62
  const state = phase.isStartup ? undefined : runtime.getCurrentState();
63
- if (state === undefined) return startup;
64
- if (state !== worker.state) {
63
+ if (state === undefined) return startupRandom;
64
+ if (state !== worker.seededState) {
65
65
  worker.random.setSeed(runtime.getFingerprint(state) ^ BigInt.asUintN(64, seed));
66
- worker.state = state;
66
+ worker.seededState = state;
67
67
  }
68
68
  return worker.random;
69
69
  },
@@ -1,4 +1,4 @@
1
- import type { FormalParamNode, LevelFields, OpDefNode, SanyLocation } from "./sany-nodes";
1
+ import type { FormalParamNode, LevelFields, OpDefNode, SanyLocation } from "./nodes";
2
2
 
3
3
  // tla2sany.semantic.BuiltInOperators: name, arity, level, maximum argument levels and argument
4
4
  // weights. SANY leaves the levels of "." and \neg unset.
@@ -1,5 +1,5 @@
1
- import { TEMPORAL_LEVEL } from "./levels";
2
- import type { TlcVersion } from "./tlc-version";
1
+ import { TEMPORAL_LEVEL } from "../levels";
2
+ import type { TlcVersion } from "../tlc/version";
3
3
  import type {
4
4
  AssumeProve,
5
5
  Assumption,
@@ -18,18 +18,18 @@ import type {
18
18
  SourceLocation,
19
19
  Theorem,
20
20
  UseOrHide,
21
- } from "./ast";
22
- import { getChildren } from "./ast";
21
+ } from "../ast";
22
+ import { getChildren } from "../ast";
23
23
  import {
24
24
  TlaMissingModuleError,
25
25
  TlaSanyFatalError,
26
26
  TlaSyntaxError,
27
27
  TlaUnsupportedError,
28
- } from "./errors";
29
- import { parseSanyModule } from "./parser";
30
- import { BUILTIN_LOCATION, createBuiltins, createLevelFields } from "./sany-builtins";
31
- import { getSany174LexicalError } from "./sany-lexer";
32
- import { getSanyParseError } from "./sany-parse-error";
28
+ } from "../errors";
29
+ import { parseSanyModule } from "../parser";
30
+ import { BUILTIN_LOCATION, createBuiltins, createLevelFields } from "./builtins";
31
+ import { getSany174LexicalError } from "./lexer";
32
+ import { getSanyParseError } from "./parse-error";
33
33
  import {
34
34
  addSanyMessage,
35
35
  CONSTANT_DECL_KIND,
@@ -73,13 +73,13 @@ import {
73
73
  type TheoremNode,
74
74
  type ThmOrAssumpDefNode,
75
75
  type UseOrHideNode,
76
- } from "./sany-nodes";
76
+ } from "./nodes";
77
77
  import {
78
78
  createSelectorResolver,
79
79
  getSelectorItems,
80
80
  isGeneralId,
81
81
  type SelectorItem,
82
- } from "./sany-selectors";
82
+ } from "./selectors";
83
83
  import {
84
84
  createSourceFile,
85
85
  findNameTokens,
@@ -99,8 +99,8 @@ import {
99
99
  isToken,
100
100
  type SourceFile,
101
101
  type TokenSpan,
102
- } from "./sany-source";
103
- import { SANY_OPERATOR_SYNONYMS } from "./tlc-modules";
102
+ } from "./source";
103
+ import { SANY_OPERATOR_SYNONYMS } from "../tlc/jar-data";
104
104
 
105
105
  const SYNONYMS = new Map(
106
106
  SANY_OPERATOR_SYNONYMS.flatMap(([canonical, ...synonyms]) =>
@@ -161,7 +161,7 @@ export interface SanySpecification {
161
161
  messages: SanyMessage[];
162
162
  }
163
163
 
164
- export interface SanyGenerationOptions {
164
+ interface SanyGenerationOptions {
165
165
  // The name of the root module's file, which SANY requires to match the module's name.
166
166
  rootFileName?: string;
167
167
  // The path of the root module's file as SANY's caller gives it, which SANY names when it cannot
@@ -271,6 +271,15 @@ const isInternalInstance = (module: Module, name: string) => {
271
271
  return false;
272
272
  };
273
273
 
274
+ type LetUnit =
275
+ | { kind: "Recursive"; declarations: Declaration[] }
276
+ | { kind: "Instance"; instance: Instance }
277
+ | { kind: "Definition"; definition: Definition };
278
+
279
+ // The decimal digits of a numeral such as \hFF, which SANY keeps at any size.
280
+ const getNumeralDigits = (text: string) =>
281
+ BigInt(text.startsWith("\\") ? `0${text.slice(1).replace(/^h/i, "x")}` : text).toString();
282
+
274
283
  // An entry of SANY's LS stack: the labels of a definition, theorem or label and the parameters
275
284
  // bound within it around the expression being generated.
276
285
  interface LabelScope {
@@ -542,11 +551,8 @@ export const generateSanySpecification = (
542
551
  path.pop();
543
552
  order.push(name);
544
553
  };
545
- // SpecObj.loadSpec: SANY resolves the first name it finds unresolved searching from the root,
546
- // each module's extended modules before the modules they import, and the instantiated modules
547
- // only once it has resolved every extended module. SANY resolves a name in the context of the
548
- // module that names it, so a module another module loaded is unresolved until SANY reaches it
549
- // from this one.
554
+ // SpecObj.loadSpec: SANY resolves the first unresolved name it finds from the root, every
555
+ // extended module before any instantiated one, each in the context of the module that names it.
550
556
  const resolutions = new Set<string>();
551
557
  const isResolved = (importer: string, name: string) => resolutions.has(`${importer} ${name}`);
552
558
  const findUnresolved = (
@@ -1402,7 +1408,7 @@ export const generateSanySpecification = (
1402
1408
  return {
1403
1409
  ...createLevelFields(getId()),
1404
1410
  kind: "Numeral",
1405
- value: getNumeralValue(expression.text ?? String(expression.value)),
1411
+ value: getNumeralDigits(expression.text ?? String(expression.value)),
1406
1412
  location,
1407
1413
  };
1408
1414
  case "Decimal": {
@@ -1913,7 +1919,6 @@ export const generateSanySpecification = (
1913
1919
  if (node.operator.name === "$NonRecursiveFcnSpec") node.unbounded = undefined;
1914
1920
  };
1915
1921
 
1916
- // The module's operators declared in RECURSIVE statements.
1917
1922
  const recursiveDeclarations: OpDefNode[] = [];
1918
1923
  const processRecursive = (declarations: Declaration[]) => {
1919
1924
  if (state.unresolvedSum === 0) state.recursiveSectionCount++;
@@ -1985,12 +1990,13 @@ export const generateSanySpecification = (
1985
1990
  });
1986
1991
  // Generator.checkSubstitutionForCorrectArity, which SANY locates in its builtins for the
1987
1992
  // nullOpArg it substitutes after an error.
1988
- const checkArity = (target: OpDeclNode, expr: ExprOrOpArgNode) => {
1989
- const arity = expr.kind === "OpArg" ? getSymbolArity(expr.op) : 0;
1990
- const isNullOpArg = target.arity > 0 && expr.kind === "OpAppl" && expr.isNull === true;
1993
+ const checkArity = (target: OpDeclNode, substitute: ExprOrOpArgNode) => {
1994
+ const arity = substitute.kind === "OpArg" ? getSymbolArity(substitute.op) : 0;
1995
+ const isNullOpArg =
1996
+ target.arity > 0 && substitute.kind === "OpAppl" && substitute.isNull === true;
1991
1997
  if (arity !== target.arity && !isNullOpArg) {
1992
1998
  addError(
1993
- expr.location,
1999
+ substitute.location,
1994
2000
  `An operator must be substituted for symbol '${target.name}', and it must have arity ${target.arity}.`,
1995
2001
  );
1996
2002
  }
@@ -2012,11 +2018,11 @@ export const generateSanySpecification = (
2012
2018
  );
2013
2019
  return;
2014
2020
  }
2015
- const expr =
2021
+ const substitute =
2016
2022
  target.arity === 0
2017
2023
  ? generateExpression(substitution.expression)
2018
2024
  : generateOperatorArgument(substitution.expression, target);
2019
- checkArity(target, expr);
2025
+ checkArity(target, substitute);
2020
2026
  const existing = substs.find((subst) => subst.op.name === target.name);
2021
2027
  if (existing && !existing.isImplicit) {
2022
2028
  addError(
@@ -2024,9 +2030,9 @@ export const generateSanySpecification = (
2024
2030
  `Multiple substitutions for symbol '${target.name}' in substitution.`,
2025
2031
  );
2026
2032
  } else if (existing) {
2027
- existing.expr = expr;
2033
+ existing.expr = substitute;
2028
2034
  existing.isImplicit = false;
2029
- } else substs.push({ op: target, expr, isImplicit: false });
2035
+ } else substs.push({ op: target, expr: substitute, isImplicit: false });
2030
2036
  });
2031
2037
  // TLC 1.7.4's SANY checks the arity of only the substitutions that the INSTANCE writes.
2032
2038
  substs
@@ -2215,8 +2221,8 @@ export const generateSanySpecification = (
2215
2221
  return symbol;
2216
2222
  };
2217
2223
  const isOriginParameterFree = symbol.module === undefined || isParameterFree(symbol.module);
2218
- const node = !isInstanceeParameterFree
2219
- ? isOriginParameterFree
2224
+ const node =
2225
+ isInstanceeParameterFree || isOriginParameterFree
2220
2226
  ? isLocal
2221
2227
  ? copyFrom(symbol.module, symbol.body)
2222
2228
  : reuse()
@@ -2224,10 +2230,7 @@ export const generateSanySpecification = (
2224
2230
  currentModule,
2225
2231
  symbol.body &&
2226
2232
  createSubstIn("SubstIn", substs, symbol.body, instanceeModule, location),
2227
- )
2228
- : isLocal
2229
- ? copyFrom(symbol.module, symbol.body)
2230
- : reuse();
2233
+ );
2231
2234
  currentModule.definitions.push(node);
2232
2235
  setRecursionFields(node);
2233
2236
  });
@@ -3106,23 +3109,3 @@ export const generateSanySpecification = (
3106
3109
  });
3107
3110
  return { root: modules[modules.length - 1], modules, messages };
3108
3111
  };
3109
-
3110
- type LetUnit =
3111
- | { kind: "Recursive"; declarations: Declaration[] }
3112
- | { kind: "Instance"; instance: Instance }
3113
- | { kind: "Definition"; definition: Definition };
3114
-
3115
- const getNumeralValue = (text: string) => {
3116
- const lower = text.toLowerCase();
3117
- const radix = lower.startsWith("\\b")
3118
- ? 2
3119
- : lower.startsWith("\\o")
3120
- ? 8
3121
- : lower.startsWith("\\h")
3122
- ? 16
3123
- : 10;
3124
- const digits = radix === 10 ? lower : lower.slice(2);
3125
- return [...digits]
3126
- .reduce((value, digit) => value * BigInt(radix) + BigInt(parseInt(digit, radix)), 0n)
3127
- .toString();
3128
- };
@@ -1,4 +1,4 @@
1
- import { ACTION_LEVEL, CONSTANT_LEVEL, TEMPORAL_LEVEL, VARIABLE_LEVEL } from "./levels";
1
+ import { ACTION_LEVEL, CONSTANT_LEVEL, TEMPORAL_LEVEL, VARIABLE_LEVEL } from "../levels";
2
2
  import {
3
3
  addSanyMessage,
4
4
  CONSTANT_DECL_KIND,
@@ -25,7 +25,7 @@ import {
25
25
  type Subst,
26
26
  type SymbolNode,
27
27
  type ThmOrAssumpDefNode,
28
- } from "./sany-nodes";
28
+ } from "./nodes";
29
29
 
30
30
  // A port of the levelCheck methods of SANY's semantic nodes: the levels, weights and Leibniz flags
31
31
  // its XMLExporter writes, and the level errors it reports. Each check returns what SANY's returns,
@@ -50,16 +50,16 @@ const addAll = <Item>(target: Set<Item>, source: Iterable<Item>) => {
50
50
  for (const item of source) target.add(item);
51
51
  };
52
52
 
53
- const getArgLevelKey = (op: SymbolNode, index: number, param: SymbolNode) =>
54
- `${op.id}:${index}:${param.id}`;
53
+ const getArgLevelKey = (operator: SymbolNode, index: number, param: SymbolNode) =>
54
+ `${operator.id}:${index}:${param.id}`;
55
55
 
56
56
  const addArgLevelParam = (
57
57
  target: Map<string, ArgLevelParam>,
58
- op: SymbolNode,
58
+ operator: SymbolNode,
59
59
  index: number,
60
60
  param: SymbolNode,
61
61
  ) => {
62
- target.set(getArgLevelKey(op, index, param), { op, index, param });
62
+ target.set(getArgLevelKey(operator, index, param), { op: operator, index, param });
63
63
  };
64
64
 
65
65
  const addArgLevelParams = (
@@ -172,22 +172,22 @@ const getSubstitute = (symbol: SymbolNode, substs: Subst[]) =>
172
172
 
173
173
  // Subst.paramSet and Subst.allParamSet.
174
174
  const getSubstitutedParams = (param: SymbolNode, substs: Subst[], isAll: boolean) => {
175
- const expr = getSubstitute(param, substs);
176
- if (expr === undefined) return new Set([param]);
177
- return isAll ? expr.allParams : expr.levelParams;
175
+ const substitute = getSubstitute(param, substs);
176
+ if (substitute === undefined) return new Set([param]);
177
+ return isAll ? substitute.allParams : substitute.levelParams;
178
178
  };
179
179
 
180
180
  // Subst.getSubALPSet.
181
181
  const getSubstitutedArgLevelParams = (source: Map<string, ArgLevelParam>, substs: Subst[]) => {
182
182
  const result = new Map<string, ArgLevelParam>();
183
183
  source.forEach((argLevelParam, key) => {
184
- const expr = getSubstitute(argLevelParam.op, substs);
185
- if (expr === undefined) {
184
+ const substitute = getSubstitute(argLevelParam.op, substs);
185
+ if (substitute === undefined) {
186
186
  result.set(key, argLevelParam);
187
187
  return;
188
188
  }
189
- if (expr.kind !== "OpArg" || !isParam(expr.op)) return;
190
- const operator = expr.op;
189
+ if (substitute.kind !== "OpArg" || !isParam(substitute.op)) return;
190
+ const operator = substitute.op;
191
191
  getSubstitutedParams(argLevelParam.param, substs, false).forEach((param) =>
192
192
  addArgLevelParam(result, operator, argLevelParam.index, param),
193
193
  );
@@ -224,10 +224,10 @@ const getSubstitutedLevelConstraints = (
224
224
  );
225
225
  });
226
226
  body.argLevelParams.forEach((argLevelParam) => {
227
- const expr = getSubstitute(argLevelParam.op, substs);
228
- if (expr?.kind !== "OpArg" || expr.op.kind !== "OpDef") return;
229
- checkLevel(expr.op, iteration, check);
230
- const level = getMaxLevel(expr.op, argLevelParam.index);
227
+ const substitute = getSubstitute(argLevelParam.op, substs);
228
+ if (substitute?.kind !== "OpArg" || substitute.op.kind !== "OpDef") return;
229
+ checkLevel(substitute.op, iteration, check);
230
+ const level = getMaxLevel(substitute.op, argLevelParam.index);
231
231
  getSubstitutedParams(argLevelParam.param, substs, false).forEach((substituted) =>
232
232
  putLevelConstraint(result, substituted, level),
233
233
  );
@@ -244,22 +244,26 @@ const getSubstitutedArgLevelConstraints = (
244
244
  ) => {
245
245
  const result = new Map<string, ArgLevelConstraint>();
246
246
  body.argLevelConstraints.forEach((constraint) => {
247
- const expr = getSubstitute(constraint.param, substs);
248
- if (expr === undefined) {
247
+ const substitute = getSubstitute(constraint.param, substs);
248
+ if (substitute === undefined) {
249
249
  putArgLevelConstraint(result, constraint.param, constraint.position, constraint.level);
250
- } else if (expr.kind === "OpArg" && isParam(expr.op)) {
251
- putArgLevelConstraint(result, expr.op, constraint.position, constraint.level);
250
+ } else if (substitute.kind === "OpArg" && isParam(substitute.op)) {
251
+ putArgLevelConstraint(result, substitute.op, constraint.position, constraint.level);
252
252
  }
253
253
  });
254
254
  body.argLevelParams.forEach((argLevelParam) => {
255
- const paramExpr = getSubstitute(argLevelParam.param, substs);
256
- if (paramExpr === undefined) return;
257
- const opExpr = getSubstitute(argLevelParam.op, substs);
255
+ const paramSubstitute = getSubstitute(argLevelParam.param, substs);
256
+ if (paramSubstitute === undefined) return;
257
+ const operatorSubstitute = getSubstitute(argLevelParam.op, substs);
258
258
  const operator =
259
- opExpr === undefined ? argLevelParam.op : opExpr.kind === "OpArg" ? opExpr.op : undefined;
259
+ operatorSubstitute === undefined
260
+ ? argLevelParam.op
261
+ : operatorSubstitute.kind === "OpArg"
262
+ ? operatorSubstitute.op
263
+ : undefined;
260
264
  if (operator === undefined || !isParam(operator)) return;
261
- checkLevel(paramExpr, iteration, check);
262
- putArgLevelConstraint(result, operator, argLevelParam.index, paramExpr.level);
265
+ checkLevel(paramSubstitute, iteration, check);
266
+ putArgLevelConstraint(result, operator, argLevelParam.index, paramSubstitute.level);
263
267
  });
264
268
  return result;
265
269
  };
@@ -836,26 +840,6 @@ const checkTemporalProof = (proof: ProofNode | undefined, check: LevelCheck) =>
836
840
  });
837
841
  };
838
842
 
839
- // Subst.getSubLCSet, getSubALCSet and getSubALPSet for the body of an instantiation.
840
- const constrainSubstitution = (
841
- node: LevelFields,
842
- body: ConstraintSource,
843
- substs: Subst[],
844
- isConstant: boolean,
845
- iteration: number,
846
- check: LevelCheck,
847
- ) => {
848
- node.levelConstraints = getSubstitutedLevelConstraints(
849
- body,
850
- substs,
851
- isConstant,
852
- iteration,
853
- check,
854
- );
855
- node.argLevelConstraints = getSubstitutedArgLevelConstraints(body, substs, iteration, check);
856
- node.argLevelParams = getSubstitutedArgLevelParams(body.argLevelParams, substs);
857
- };
858
-
859
843
  // InstanceNode.levelCheck.
860
844
  const checkInstance = (node: InstanceNode, iteration: number, check: LevelCheck) => {
861
845
  if (node.levelChecked >= iteration) return node.levelCorrect;
@@ -1114,7 +1098,20 @@ const checkLevel = (node: SemanticNode, iteration: number, check: LevelCheck): b
1114
1098
  });
1115
1099
  }
1116
1100
  const isConstant = isConstantModule(node.instantiatedModule, check);
1117
- constrainSubstitution(node, body, node.substs, isConstant, iteration, check);
1101
+ node.levelConstraints = getSubstitutedLevelConstraints(
1102
+ body,
1103
+ node.substs,
1104
+ isConstant,
1105
+ iteration,
1106
+ check,
1107
+ );
1108
+ node.argLevelConstraints = getSubstitutedArgLevelConstraints(
1109
+ body,
1110
+ node.substs,
1111
+ iteration,
1112
+ check,
1113
+ );
1114
+ node.argLevelParams = getSubstitutedArgLevelParams(body.argLevelParams, node.substs);
1118
1115
  return node.levelCorrect;
1119
1116
  }
1120
1117
  case "Instance":
@@ -1,4 +1,4 @@
1
- import { TlaError } from "./errors";
1
+ import { TlaError } from "../errors";
2
2
 
3
3
  // An emulation of the token manager that JavaCC generates for SANY's grammar, javacc/tla+.jj: the
4
4
  // tokens it produces, their kinds in TLAplusParserConstants order, and their positions.
@@ -228,8 +228,7 @@ const KIND_INDEXES = new Map(
228
228
  KIND_NAMES.map((name, kind): [string, number] => [name, kind]).reverse(),
229
229
  );
230
230
 
231
- // The kind named name. The anonymous infix operators share the name "infix", which no caller
232
- // looks up.
231
+ // The anonymous infix operators share the name "infix", which no caller looks up.
233
232
  export const getKind = (name: string) => {
234
233
  const kind = KIND_INDEXES.get(name);
235
234
  if (kind === undefined) throw new TlaError(`Unknown SANY token kind ${name}`);
@@ -5,7 +5,7 @@ import {
5
5
  type OpApplNode,
6
6
  type SanyMessage,
7
7
  type SemanticNode,
8
- } from "./sany-nodes";
8
+ } from "./nodes";
9
9
 
10
10
  // A port of SANY's tla2sany.linter.Linter, which warns about a record field named like a
11
11
  // definition or declaration of the module.
@@ -1,5 +1,5 @@
1
- import type { TlcVersion } from "./tlc-version";
2
- import { REAL_TIME, REALS, TOOLBOX } from "./bundled-modules";
1
+ import type { TlcVersion } from "../tlc/version";
2
+ import { REAL_TIME, REALS, TOOLBOX } from "../bundled-modules";
3
3
 
4
4
  const BAGS = `----------------------------- MODULE Bags --------------------------------
5
5
  (**************************************************************************)
@@ -344,7 +344,7 @@ export type LevelNode = ExprOrOpArgNode | AssumeProveNode | NewSymbNode;
344
344
 
345
345
  export type ProofPartNode = ProofNode | DefStepNode;
346
346
 
347
- export type TopLevelNode = InstanceNode | AssumeNode | TheoremNode | UseOrHideNode;
347
+ type TopLevelNode = InstanceNode | AssumeNode | TheoremNode | UseOrHideNode;
348
348
 
349
349
  export type SemanticNode = SymbolNode | LevelNode | TopLevelNode | ProofPartNode;
350
350
 
@@ -362,7 +362,7 @@ interface HashtableEntry {
362
362
  value: SymbolNode;
363
363
  }
364
364
 
365
- export interface JavaHashtable {
365
+ interface JavaHashtable {
366
366
  buckets: HashtableEntry[][];
367
367
  count: number;
368
368
  threshold: number;
@@ -1,5 +1,5 @@
1
- import { createSanyLexer, escapeLexeme, getKind, type SanyToken } from "./sany-lexer";
2
- import { SANY_OPERATOR_SYNONYMS } from "./tlc-modules";
1
+ import { createSanyLexer, escapeLexeme, getKind, type SanyToken } from "./lexer";
2
+ import { SANY_OPERATOR_SYNONYMS } from "../tlc/jar-data";
3
3
 
4
4
  // The report SANY's parser, TLAplusParser, gives for a module it fails to parse. This interprets
5
5
  // the grammar of javacc/tla+.jj the way the code JavaCC generates from it runs: the productions,
@@ -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.
@@ -35,7 +35,6 @@ export interface SanyReportOptions {
35
35
  // tla2sany.xml.XMLExporter runs SANY with its validAstSettings, which neither lint the modules
36
36
  // nor validate their PlusCal, and prints only SANY's errors.
37
37
  isXmlExport?: boolean;
38
- // The TLC whose SANY to reproduce.
39
38
  version?: TlcVersion;
40
39
  // The modules TLC adds to the root module's EXTENDS for its post conditions.
41
40
  rootExtendees?: string[];
@@ -119,7 +118,7 @@ export const getSanyModuleName = (text: string, version?: TlcVersion) =>
119
118
  // in the rest.
120
119
  export const getSanyReport = (
121
120
  rootPath: string,
122
- loadModule: (name: string) => string | undefined = () => undefined,
121
+ loadModule: (name: string) => string | undefined,
123
122
  options: SanyReportOptions = {},
124
123
  ): SanyReport => {
125
124
  const rootName = basename(rootPath, ".tla");
@@ -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.
@@ -86,7 +86,6 @@ const getNameParts = (name: string) => {
86
86
  return parts.some((part) => part.length === 0) ? [name] : parts;
87
87
  };
88
88
 
89
- // The selector of a name, an application of a name or a subexpression reference.
90
89
  export const getSelectorItems = (expression: Expression): SelectorItem[] | undefined => {
91
90
  switch (expression.kind) {
92
91
  case "Identifier":
@@ -174,7 +173,6 @@ const isSymbol = (node: LevelNode | SymbolNode): node is SymbolNode =>
174
173
  node.kind === "ThmOrAssumpDef" ||
175
174
  node.kind === "Module";
176
175
 
177
- // The symbols a quantifier binds: its bounded ones if it has any, else its unbounded ones.
178
176
  const getQuantifierSymbols = (node: OpApplNode) =>
179
177
  (node.bounded?.length ?? 0) > 0 ? (node.bounded ?? []).flat() : (node.unbounded ?? []);
180
178
 
@@ -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.
@@ -230,7 +230,6 @@ export const getPreComments = (file: SourceFile, index: number) => {
230
230
  return comments;
231
231
  };
232
232
 
233
- // The identifier tokens with the given names, in order, between two token indexes.
234
233
  export const findNameTokens = (file: SourceFile, start: number, end: number, names: string[]) => {
235
234
  const found: number[] = [];
236
235
  for (let index = start; index < end && found.length < names.length; index++) {
@@ -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 = {
@@ -386,7 +386,6 @@ const unboxBackslashStarComment = (text: string) => {
386
386
  };
387
387
 
388
388
  export interface XmlExportOptions {
389
- // The TLC whose XMLExporter to reproduce.
390
389
  version: TlcVersion;
391
390
  // -r: only the root module, and only the declarations and definitions a module makes itself.
392
391
  isRestricted: boolean;