tla-ts 0.0.9-dev.8298a52 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (390) hide show
  1. package/README.md +7 -0
  2. package/dist/compile.cjs +3 -3
  3. package/dist/compile.js +3 -3
  4. package/dist/deciders.cjs +28 -28
  5. package/dist/deciders.js +52 -52
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.cts +71 -10
  8. package/dist/index.d.ts +71 -10
  9. package/dist/index.js +1 -1
  10. package/dist/parallel-worker.cjs +1 -1
  11. package/dist/parallel-worker.js +1 -1
  12. package/dist/prove-worker.cjs +1 -1
  13. package/dist/prove-worker.js +1 -1
  14. package/dist/prove.cjs +116 -36
  15. package/dist/prove.js +116 -36
  16. package/dist/run.cjs +141 -29
  17. package/dist/run.js +143 -31
  18. package/dist/tlapm.cjs +1 -1
  19. package/dist/tlapm.js +2 -2
  20. package/dist/transfer.cjs +128 -103
  21. package/dist/transfer.js +128 -103
  22. package/dist/worker.cjs +7 -7
  23. package/dist/worker.js +7 -7
  24. package/package.json +1 -1
  25. package/src/ast.ts +7 -21
  26. package/src/bags.ts +99 -99
  27. package/src/builtins.ts +44 -75
  28. package/src/bundled-modules.ts +1 -8
  29. package/src/check.ts +539 -276
  30. package/src/cli/options.ts +10 -5
  31. package/src/cli/run.ts +2 -2
  32. package/src/cli/runtime-invariants.ts +135 -0
  33. package/src/cli/shared.ts +20 -9
  34. package/src/cli/tlapm.ts +0 -12
  35. package/src/cli/tlc-arguments.ts +646 -0
  36. package/src/cli/tlc-usage.ts +362 -0
  37. package/src/cli/tlc.ts +525 -216
  38. package/src/cli/typescript.ts +0 -3
  39. package/src/cli/xml-exporter.ts +4 -16
  40. package/src/cli.ts +0 -1
  41. package/src/codegen.ts +191 -64
  42. package/src/config.ts +140 -109
  43. package/src/coverage.ts +837 -0
  44. package/src/dependencies.ts +6 -40
  45. package/src/dfid.ts +618 -0
  46. package/src/environment.ts +237 -119
  47. package/src/errors.ts +56 -56
  48. package/src/evaluate.ts +567 -289
  49. package/src/exit-codes.ts +37 -3
  50. package/src/fingerprints.ts +10 -10
  51. package/src/index.ts +3 -0
  52. package/src/instances.ts +38 -31
  53. package/src/java-overrides.ts +2 -12
  54. package/src/json-reader.ts +456 -0
  55. package/src/json.ts +262 -139
  56. package/src/levels.ts +2 -3
  57. package/src/lexer.ts +17 -26
  58. package/src/liveness-checker.ts +4 -15
  59. package/src/liveness.ts +115 -47
  60. package/src/obligations/action.ts +4 -28
  61. package/src/obligations/anonymize.ts +84 -80
  62. package/src/obligations/equality.ts +1 -1
  63. package/src/obligations/expression.ts +2 -19
  64. package/src/obligations/format.ts +1 -9
  65. package/src/obligations/generate.ts +1 -11
  66. package/src/obligations/index.ts +0 -11
  67. package/src/obligations/levels.ts +4 -8
  68. package/src/obligations/module.ts +1 -15
  69. package/src/obligations/normalize.ts +5 -24
  70. package/src/obligations/operators.ts +1 -2
  71. package/src/obligations/pragma.ts +1 -10
  72. package/src/obligations/printer.ts +47 -46
  73. package/src/obligations/proof.ts +1 -5
  74. package/src/obligations/regroup.ts +1 -4
  75. package/src/obligations/simplify.ts +3 -14
  76. package/src/obligations/source.ts +1 -21
  77. package/src/obligations/subexpression.ts +5 -11
  78. package/src/obligations/substitution.ts +1 -3
  79. package/src/obligations/temporal.ts +8 -14
  80. package/src/obligations/tuples.ts +3 -9
  81. package/src/parallel-worker.ts +24 -33
  82. package/src/parallel.ts +24 -9
  83. package/src/parser.ts +436 -90
  84. package/src/pcal/ast.ts +7 -28
  85. package/src/pcal/parse.ts +11 -39
  86. package/src/pcal/tokenize.ts +4 -20
  87. package/src/pcal/translate.ts +10 -42
  88. package/src/pcal/validate.ts +3 -21
  89. package/src/pretty-print.ts +1 -2
  90. package/src/prover/decide-pool.ts +5 -10
  91. package/src/prover/deciders.ts +0 -4
  92. package/src/prover/first-order.ts +0 -11
  93. package/src/prover/isabelle/decide.ts +0 -6
  94. package/src/prover/isabelle/encode.ts +11 -23
  95. package/src/prover/isabelle/isar/inner-syntax.ts +108 -114
  96. package/src/prover/isabelle/isar/method.ts +25 -38
  97. package/src/prover/isabelle/isar/proof.ts +1 -10
  98. package/src/prover/isabelle/isar/statement.ts +1 -6
  99. package/src/prover/isabelle/isar/theory.ts +15 -26
  100. package/src/prover/isabelle/isar/type-check.ts +11 -25
  101. package/src/prover/isabelle/provers/blast/blast.ts +10 -41
  102. package/src/prover/isabelle/provers/blast/branch.ts +1 -32
  103. package/src/prover/isabelle/provers/blast/prove.ts +1 -35
  104. package/src/prover/isabelle/provers/blast/rules.ts +6 -44
  105. package/src/prover/isabelle/provers/blast/state.ts +2 -28
  106. package/src/prover/isabelle/provers/blast/term.ts +9 -36
  107. package/src/prover/isabelle/provers/clasimp.ts +1 -13
  108. package/src/prover/isabelle/provers/classical.ts +14 -42
  109. package/src/prover/isabelle/provers/hypsubst.ts +11 -25
  110. package/src/prover/isabelle/pure/bicompose.ts +16 -13
  111. package/src/prover/isabelle/pure/consts.ts +1 -7
  112. package/src/prover/isabelle/pure/conv.ts +1 -9
  113. package/src/prover/isabelle/pure/drule.ts +24 -40
  114. package/src/prover/isabelle/pure/envir.ts +3 -52
  115. package/src/prover/isabelle/pure/goal.ts +1 -7
  116. package/src/prover/isabelle/pure/interrupt.ts +0 -5
  117. package/src/prover/isabelle/pure/list.ts +0 -3
  118. package/src/prover/isabelle/pure/logic.ts +1 -14
  119. package/src/prover/isabelle/pure/name.ts +2 -9
  120. package/src/prover/isabelle/pure/net.ts +3 -59
  121. package/src/prover/isabelle/pure/object-logic.ts +3 -10
  122. package/src/prover/isabelle/pure/pattern.ts +2 -19
  123. package/src/prover/isabelle/pure/raw-simplifier.ts +13 -49
  124. package/src/prover/isabelle/pure/rewriter.ts +26 -58
  125. package/src/prover/isabelle/pure/search.ts +3 -10
  126. package/src/prover/isabelle/pure/seq.ts +1 -10
  127. package/src/prover/isabelle/pure/simplifier.ts +4 -12
  128. package/src/prover/isabelle/pure/table.ts +1 -31
  129. package/src/prover/isabelle/pure/tactic.ts +12 -22
  130. package/src/prover/isabelle/pure/tactical.ts +6 -12
  131. package/src/prover/isabelle/pure/term-ord.ts +2 -6
  132. package/src/prover/isabelle/pure/term.ts +2 -43
  133. package/src/prover/isabelle/pure/thm.ts +13 -36
  134. package/src/prover/isabelle/pure/type.ts +2 -15
  135. package/src/prover/isabelle/pure/unify.ts +20 -30
  136. package/src/prover/isabelle/pure/variable.ts +3 -7
  137. package/src/prover/isabelle/tla/classical-setup.ts +9 -19
  138. package/src/prover/isabelle/tla/context.ts +8 -16
  139. package/src/prover/isabelle/tla/logic.ts +4 -11
  140. package/src/prover/isabelle/tla/simpdata.ts +46 -34
  141. package/src/prover/isabelle/tools/intuitionistic.ts +1 -10
  142. package/src/prover/ocaml.ts +0 -6
  143. package/src/prover/prep/action.ts +4 -36
  144. package/src/prover/prep/enabled-axioms.ts +12 -19
  145. package/src/prover/prep/fingerprint.ts +0 -16
  146. package/src/prover/prep/level-comparison.ts +8 -12
  147. package/src/prover/prep/md5.ts +0 -2
  148. package/src/prover/prep/methods.ts +9 -36
  149. package/src/prover/prep/normalize.ts +4 -28
  150. package/src/prover/prove-worker.ts +0 -2
  151. package/src/prover/prove.ts +0 -36
  152. package/src/prover/ptl/decide.ts +7 -12
  153. package/src/prover/ptl/encode.ts +14 -36
  154. package/src/prover/ptl/sat.ts +24 -32
  155. package/src/prover/ptl/tableau.ts +12 -26
  156. package/src/prover/smt/axioms.ts +0 -7
  157. package/src/prover/smt/context.ts +19 -26
  158. package/src/prover/smt/data.ts +51 -54
  159. package/src/prover/smt/encode.ts +14 -35
  160. package/src/prover/smt/extensionality.ts +0 -10
  161. package/src/prover/smt/flatten.ts +3 -22
  162. package/src/prover/smt/format.ts +5 -10
  163. package/src/prover/smt/instances.ts +0 -10
  164. package/src/prover/smt/rewrite.ts +66 -101
  165. package/src/prover/smt/solver/act-cache.ts +0 -15
  166. package/src/prover/smt/solver/arith-rewriter.ts +3 -48
  167. package/src/prover/smt/solver/array.ts +1 -3
  168. package/src/prover/smt/solver/asserted-formulas.ts +1 -43
  169. package/src/prover/smt/solver/ast-lt.ts +1 -11
  170. package/src/prover/smt/solver/ast-util.ts +1 -6
  171. package/src/prover/smt/solver/ast.ts +1 -143
  172. package/src/prover/smt/solver/auf-solver.ts +6 -39
  173. package/src/prover/smt/solver/case-split-queue.ts +1 -9
  174. package/src/prover/smt/solver/cg-table.ts +1 -18
  175. package/src/prover/smt/solver/clause.ts +1 -27
  176. package/src/prover/smt/solver/conflict-resolution.ts +0 -9
  177. package/src/prover/smt/solver/context.ts +4 -61
  178. package/src/prover/smt/solver/ctx-simplify.ts +14 -41
  179. package/src/prover/smt/solver/der.ts +2 -21
  180. package/src/prover/smt/solver/dyn-ack.ts +1 -11
  181. package/src/prover/smt/solver/e-matching.ts +3 -34
  182. package/src/prover/smt/solver/enode.ts +1 -21
  183. package/src/prover/smt/solver/expr-ref.ts +1 -5
  184. package/src/prover/smt/solver/expr-safe-replace.ts +0 -5
  185. package/src/prover/smt/solver/fingerprints.ts +1 -12
  186. package/src/prover/smt/solver/flat-literals.ts +1 -9
  187. package/src/prover/smt/solver/goal.ts +2 -14
  188. package/src/prover/smt/solver/hash.ts +0 -8
  189. package/src/prover/smt/solver/hashtable.ts +1 -12
  190. package/src/prover/smt/solver/internalizer.ts +6 -98
  191. package/src/prover/smt/solver/lbool.ts +1 -2
  192. package/src/prover/smt/solver/literal.ts +0 -3
  193. package/src/prover/smt/solver/lp/bound-propagator.ts +8 -26
  194. package/src/prover/smt/solver/lp/constraints.ts +2 -8
  195. package/src/prover/smt/solver/lp/containers.ts +12 -30
  196. package/src/prover/smt/solver/lp/core-solver.ts +10 -31
  197. package/src/prover/smt/solver/lp/cross-nested.ts +6 -20
  198. package/src/prover/smt/solver/lp/dep-intervals.ts +7 -22
  199. package/src/prover/smt/solver/lp/dependency.ts +1 -4
  200. package/src/prover/smt/solver/lp/dioph-eq.ts +12 -98
  201. package/src/prover/smt/solver/lp/explanation.ts +1 -6
  202. package/src/prover/smt/solver/lp/gomory.ts +9 -22
  203. package/src/prover/smt/solver/lp/hnf-cutter.ts +17 -23
  204. package/src/prover/smt/solver/lp/hnf.ts +11 -26
  205. package/src/prover/smt/solver/lp/int-cube.ts +15 -36
  206. package/src/prover/smt/solver/lp/int-solver.ts +4 -34
  207. package/src/prover/smt/solver/lp/lar-solver.ts +32 -81
  208. package/src/prover/smt/solver/lp/lar-term.ts +1 -5
  209. package/src/prover/smt/solver/lp/lp-settings.ts +1 -14
  210. package/src/prover/smt/solver/lp/maximize-term.ts +20 -45
  211. package/src/prover/smt/solver/lp/nex-creator.ts +5 -28
  212. package/src/prover/smt/solver/lp/nex.ts +1 -6
  213. package/src/prover/smt/solver/lp/nla-backoff.ts +1 -4
  214. package/src/prover/smt/solver/lp/nla-basics.ts +5 -30
  215. package/src/prover/smt/solver/lp/nla-core.ts +35 -130
  216. package/src/prover/smt/solver/lp/nla-divisions.ts +32 -42
  217. package/src/prover/smt/solver/lp/nla-emonics.ts +4 -21
  218. package/src/prover/smt/solver/lp/nla-factorization.ts +1 -4
  219. package/src/prover/smt/solver/lp/nla-grobner.ts +15 -69
  220. package/src/prover/smt/solver/lp/nla-horner.ts +3 -11
  221. package/src/prover/smt/solver/lp/nla-intervals.ts +2 -12
  222. package/src/prover/smt/solver/lp/nla-monomial-bounds.ts +16 -41
  223. package/src/prover/smt/solver/lp/nla-monotone.ts +2 -6
  224. package/src/prover/smt/solver/lp/nla-order.ts +2 -13
  225. package/src/prover/smt/solver/lp/nla-patcher.ts +4 -7
  226. package/src/prover/smt/solver/lp/nla-tangents.ts +1 -9
  227. package/src/prover/smt/solver/lp/nla-throttle.ts +1 -6
  228. package/src/prover/smt/solver/lp/nla-types.ts +1 -11
  229. package/src/prover/smt/solver/lp/nla-var-eqs.ts +4 -25
  230. package/src/prover/smt/solver/lp/nra-solver.ts +5 -52
  231. package/src/prover/smt/solver/lp/numeric-pair.ts +1 -4
  232. package/src/prover/smt/solver/lp/pdd-interval.ts +1 -3
  233. package/src/prover/smt/solver/lp/pdd-simplifier.ts +2 -14
  234. package/src/prover/smt/solver/lp/pdd-solver.ts +4 -33
  235. package/src/prover/smt/solver/lp/pdd.ts +7 -70
  236. package/src/prover/smt/solver/lp/random-updater.ts +1 -8
  237. package/src/prover/smt/solver/lp/static-matrix.ts +9 -19
  238. package/src/prover/smt/solver/lp/union-find.ts +1 -6
  239. package/src/prover/smt/solver/mam-compiler.ts +14 -56
  240. package/src/prover/smt/solver/mam-interpreter.ts +1 -21
  241. package/src/prover/smt/solver/maximize-ac-sharing.ts +2 -17
  242. package/src/prover/smt/solver/model-checker.ts +2 -36
  243. package/src/prover/smt/solver/model-evaluator.ts +3 -29
  244. package/src/prover/smt/solver/model-finder.ts +3 -15
  245. package/src/prover/smt/solver/model-generator.ts +1 -12
  246. package/src/prover/smt/solver/model-macro-solver.ts +12 -69
  247. package/src/prover/smt/solver/nlsat/algebraic.ts +55 -151
  248. package/src/prover/smt/solver/nlsat/atoms.ts +5 -19
  249. package/src/prover/smt/solver/nlsat/evaluator.ts +17 -22
  250. package/src/prover/smt/solver/nlsat/explain.ts +3 -47
  251. package/src/prover/smt/solver/nlsat/interval-set.ts +9 -50
  252. package/src/prover/smt/solver/nlsat/levelwise.ts +48 -129
  253. package/src/prover/smt/solver/nlsat/mpbq.ts +3 -14
  254. package/src/prover/smt/solver/nlsat/polynomial.ts +17 -156
  255. package/src/prover/smt/solver/nlsat/solver.ts +7 -67
  256. package/src/prover/smt/solver/nlsat/types.ts +1 -8
  257. package/src/prover/smt/solver/nlsat/upolynomial-factorization.ts +1 -44
  258. package/src/prover/smt/solver/nlsat/upolynomial.ts +11 -92
  259. package/src/prover/smt/solver/nnf.ts +3 -38
  260. package/src/prover/smt/solver/pattern-inference.ts +2 -15
  261. package/src/prover/smt/solver/poly-rewriter.ts +3 -23
  262. package/src/prover/smt/solver/propagate-values.ts +1 -10
  263. package/src/prover/smt/solver/proto-model.ts +3 -48
  264. package/src/prover/smt/solver/pull-quant.ts +1 -12
  265. package/src/prover/smt/solver/qe-lite-der.ts +1 -29
  266. package/src/prover/smt/solver/qe-lite-fm.ts +2 -25
  267. package/src/prover/smt/solver/qe-lite.ts +3 -33
  268. package/src/prover/smt/solver/qi-queue.ts +1 -16
  269. package/src/prover/smt/solver/quant-tactics.ts +5 -22
  270. package/src/prover/smt/solver/quantifier-analyzer.ts +17 -37
  271. package/src/prover/smt/solver/quantifier-manager.ts +1 -8
  272. package/src/prover/smt/solver/random-gen.ts +1 -2
  273. package/src/prover/smt/solver/rational.ts +1 -8
  274. package/src/prover/smt/solver/ref-vector.ts +1 -6
  275. package/src/prover/smt/solver/relevancy.ts +2 -15
  276. package/src/prover/smt/solver/rewriter-tpl.ts +3 -147
  277. package/src/prover/smt/solver/rewriter.ts +3 -85
  278. package/src/prover/smt/solver/rlimit.ts +2 -20
  279. package/src/prover/smt/solver/smtlib-parser.ts +2 -37
  280. package/src/prover/smt/solver/solver.ts +1 -16
  281. package/src/prover/smt/solver/sort.ts +1 -5
  282. package/src/prover/smt/solver/sticky-generations.ts +0 -5
  283. package/src/prover/smt/solver/theory-lra-axioms.ts +3 -24
  284. package/src/prover/smt/solver/theory-lra-bounds.ts +0 -5
  285. package/src/prover/smt/solver/theory-lra-final-check.ts +4 -22
  286. package/src/prover/smt/solver/theory-lra-internalize.ts +1 -27
  287. package/src/prover/smt/solver/theory-lra-model.ts +4 -19
  288. package/src/prover/smt/solver/theory-lra-propagate.ts +1 -15
  289. package/src/prover/smt/solver/theory-lra-state.ts +3 -8
  290. package/src/prover/smt/solver/theory-lra.ts +1 -8
  291. package/src/prover/smt/solver/var-subst.ts +2 -26
  292. package/src/prover/smt/table.ts +0 -8
  293. package/src/prover/tlapm/cache.ts +20 -25
  294. package/src/prover/tlapm/ocaml-marshal.ts +19 -21
  295. package/src/prover/tlapm/tlapm.ts +12 -17
  296. package/src/prover/verdict.ts +0 -2
  297. package/src/prover/zenon/check/check.ts +0 -9
  298. package/src/prover/zenon/check/definitions.ts +5 -15
  299. package/src/prover/zenon/check/equality.ts +0 -8
  300. package/src/prover/zenon/check/functions.ts +0 -4
  301. package/src/prover/zenon/check/keys.ts +0 -7
  302. package/src/prover/zenon/check/propositional.ts +0 -3
  303. package/src/prover/zenon/check/records.ts +0 -5
  304. package/src/prover/zenon/check/relations.ts +0 -13
  305. package/src/prover/zenon/check/rewrites.ts +0 -6
  306. package/src/prover/zenon/check/sets.ts +0 -3
  307. package/src/prover/zenon/check/terms.ts +0 -17
  308. package/src/prover/zenon/check/tla.ts +0 -6
  309. package/src/prover/zenon/decide.ts +0 -12
  310. package/src/prover/zenon/encode.ts +1 -8
  311. package/src/prover/zenon/eqrel.ts +0 -13
  312. package/src/prover/zenon/equality-rules.ts +0 -4
  313. package/src/prover/zenon/expr.ts +1 -26
  314. package/src/prover/zenon/index-table.ts +17 -38
  315. package/src/prover/zenon/isar-case.ts +9 -19
  316. package/src/prover/zenon/isar.ts +1 -29
  317. package/src/prover/zenon/limits.ts +0 -4
  318. package/src/prover/zenon/llproof.ts +0 -9
  319. package/src/prover/zenon/mltoll.ts +54 -76
  320. package/src/prover/zenon/node.ts +1 -11
  321. package/src/prover/zenon/ocaml.ts +1 -17
  322. package/src/prover/zenon/parse.ts +2 -7
  323. package/src/prover/zenon/phrase.ts +1 -11
  324. package/src/prover/zenon/proof.ts +0 -9
  325. package/src/prover/zenon/propositional-rules.ts +0 -5
  326. package/src/prover/zenon/rules.ts +2 -6
  327. package/src/prover/zenon/search.ts +1 -17
  328. package/src/prover/zenon/tla/functions.ts +57 -29
  329. package/src/prover/zenon/tla/llproof.ts +63 -70
  330. package/src/prover/zenon/tla/records.ts +56 -27
  331. package/src/prover/zenon/tla/rewrites.ts +12 -19
  332. package/src/prover/zenon/tla/sets.ts +68 -39
  333. package/src/prover/zenon/tla/terms.ts +0 -6
  334. package/src/prover/zenon/tla/tla.ts +59 -58
  335. package/src/randomization.ts +84 -35
  336. package/src/resolve.ts +18 -60
  337. package/src/runtime.ts +11 -4
  338. package/src/sany/builtins.ts +3 -4
  339. package/src/sany/generator.ts +119 -169
  340. package/src/sany/levels.ts +6 -30
  341. package/src/sany/lexer.ts +7 -23
  342. package/src/sany/linter.ts +1 -8
  343. package/src/sany/modules.ts +1 -5
  344. package/src/sany/nodes.ts +0 -31
  345. package/src/sany/parse-error.ts +39 -117
  346. package/src/sany/report.ts +29 -63
  347. package/src/sany/selectors.ts +15 -39
  348. package/src/sany/source.ts +1 -17
  349. package/src/sany/xml.ts +13 -63
  350. package/src/search.ts +494 -154
  351. package/src/simulate.ts +694 -0
  352. package/src/spec-description.ts +166 -48
  353. package/src/standard-definitions.ts +2 -3
  354. package/src/standard-modules.ts +264 -68
  355. package/src/state-graph.ts +51 -18
  356. package/src/subexpressions.ts +31 -5
  357. package/src/substitution-levels.ts +2 -3
  358. package/src/successors.ts +264 -74
  359. package/src/symmetry.ts +31 -8
  360. package/src/tableau.ts +27 -24
  361. package/src/tlc/fingerprint.ts +183 -61
  362. package/src/tlc/jar-data.ts +113 -6
  363. package/src/tlc/messages.ts +122 -37
  364. package/src/tlc/order.ts +33 -38
  365. package/src/tlc/random.ts +16 -16
  366. package/src/tlc/replay.ts +563 -211
  367. package/src/tlc/summary.ts +2 -4
  368. package/src/tlc/tlc-operators.ts +81 -36
  369. package/src/tlc/tlcext-operators.ts +138 -117
  370. package/src/tlc/trace-spec.ts +273 -0
  371. package/src/tlc/value-stream.ts +143 -0
  372. package/src/tlc/version.ts +2 -4
  373. package/src/transfer.ts +22 -25
  374. package/src/typescript/actions.ts +8 -21
  375. package/src/typescript/collections.ts +0 -15
  376. package/src/typescript/compile.ts +0 -5
  377. package/src/typescript/context.ts +0 -12
  378. package/src/typescript/emit.ts +0 -1
  379. package/src/typescript/expressions.ts +0 -12
  380. package/src/typescript/formula.ts +4 -12
  381. package/src/typescript/functions.ts +6 -17
  382. package/src/typescript/model.ts +10 -11
  383. package/src/typescript/names.ts +0 -2
  384. package/src/typescript/program.ts +0 -3
  385. package/src/typescript/properties.ts +6 -8
  386. package/src/typescript/scope.ts +0 -5
  387. package/src/typescript/steps.ts +0 -10
  388. package/src/typescript/types.ts +1 -8
  389. package/src/values.ts +793 -267
  390. package/src/worker.ts +7 -8
@@ -1,5 +1,4 @@
1
- // A port of tlapm's obligation generation (Proof.Gen and Module.Gen): leaf proofs become obligations
2
- // whose context is everything the proof may use at that point.
1
+ // A port of tlapm's obligation generation (Proof.Gen and Module.Gen).
3
2
 
4
3
  import { TlapmBugError, TlaProofError } from "../errors";
5
4
  import { isEqualExpr } from "./equality";
@@ -40,7 +39,6 @@ const isAnonymous = (step: StepNumber | undefined) => step?.kind === "Named" &&
40
39
  export const getTrue = (from: { location?: Locus }) =>
41
40
  at({ kind: "Internal", builtin: "TRUE" }, from);
42
41
 
43
- // Each visible fact of the sequent, shifted past the hypotheses after it.
44
42
  const getAssumedFacts = (offset: number, sequent: Sequent) =>
45
43
  sequent.context.flatMap((hyp, index) =>
46
44
  hyp.kind === "Fact" && hyp.visibility === "Visible"
@@ -60,8 +58,6 @@ const getStepDefinition = (step: Step, body: Expr, time: Time): Hyp => {
60
58
  };
61
59
  };
62
60
 
63
- // The proof of an assertion leaves the always scope when the assertion assumes a fact that holds
64
- // only now.
65
61
  export const proveAssertion = (context: Hyp[], sequent: Sequent, step: Step, time: Time) => {
66
62
  const visibility: Visibility = isAnonymous(step.step) ? "Visible" : "Hidden";
67
63
  const hyps = sequent.context.map((hyp): Hyp =>
@@ -101,8 +97,6 @@ export const useAssertion = (
101
97
  };
102
98
  };
103
99
 
104
- // A cited step or definition keeps the scope it was proved in, and any other fact takes the
105
- // current one.
106
100
  const getFactTime = (context: Hyp[], fact: Expr, time: Time): Time => {
107
101
  if (fact.kind !== "Ix") return time;
108
102
  const hyp = context[context.length - fact.index];
@@ -157,7 +151,6 @@ const setExpression = (
157
151
  return result;
158
152
  };
159
153
 
160
- // The lines of tlapm's --toolbox and --line options, which select the proofs to generate.
161
154
  export interface LineRange {
162
155
  start: number;
163
156
  end: number;
@@ -363,7 +356,6 @@ export const createGenerator = (inputFiles: Set<string>, lines: LineRange, onWar
363
356
  return [sequent.context, generated.obligations ?? []];
364
357
  };
365
358
 
366
- // The definitions go first, then each fact on its own, shifting the facts after it.
367
359
  const mutate = (
368
360
  context: Hyp[],
369
361
  mode: "Use" | "Hide",
@@ -384,7 +376,6 @@ export const createGenerator = (inputFiles: Set<string>, lines: LineRange, onWar
384
376
  return [last, [...first, ...others]];
385
377
  };
386
378
 
387
- // collect: a QED's obligations come before its sibling steps', and a step's own before its proof's.
388
379
  const collect = (proof: Proof): Obligation[] => {
389
380
  const obligations: Obligation[] = [];
390
381
  const visitProof = (item: Proof) => {
@@ -403,7 +394,6 @@ export const createGenerator = (inputFiles: Set<string>, lines: LineRange, onWar
403
394
  return obligations;
404
395
  };
405
396
 
406
- // Module.Gen.generate.
407
397
  const generateModule = (
408
398
  context: Hyp[],
409
399
  module: Mule,
@@ -1,5 +1,3 @@
1
- // Generates the proof obligations tlapm prints for a module, in tlapm's order and layout.
2
-
3
1
  import { TlaProofError, TlaSyntaxError, type SyntaxFailure } from "../errors";
4
2
  import { createAnonymizer } from "./anonymize";
5
3
  import {
@@ -120,7 +118,6 @@ const parseSource = (source: string): Module | SyntaxFailure[] => {
120
118
  return isSyntaxFailure(parsed) ? [parsed] : parsed;
121
119
  };
122
120
 
123
- // Module.Save.parse_file warns when a module's name differs from its file's, then renames it.
124
121
  const loadMule = (
125
122
  input: ObligationSource,
126
123
  counter: Counter,
@@ -151,7 +148,6 @@ const loadMule = (
151
148
  return { ...mule, name };
152
149
  };
153
150
 
154
- // Module.Dep.schedule: dependencies first, visiting modules and their dependencies by name.
155
151
  const schedule = (modules: Map<string, Mule>) => {
156
152
  const dependencies = new Map(
157
153
  [...modules].map(([name, module]) => [name, getDependencies(module).dependencies]),
@@ -220,8 +216,6 @@ export const formatSummary = (result: ModuleObligations) => {
220
216
  ].join("\n");
221
217
  };
222
218
 
223
- // Each main module is one file given to tlapm. They load into one context and report in schedule
224
- // order, each numbering its obligations from 1.
225
219
  export const getObligations = (
226
220
  mains: ObligationSource[],
227
221
  loadModule: (name: string) => ObligationSource | undefined,
@@ -238,9 +232,7 @@ export const getObligations = (
238
232
  };
239
233
  modules.set(module.name, module);
240
234
  });
241
- // Module.Save.complete_load: breadth first from every known module, by name.
242
235
  const queue = [...modules.values()].sort((left, right) => compareNames(left.name, right.name));
243
- // A missing module is fine only if some loaded module declares it as a submodule.
244
236
  const requested = new Map<string, Locus | undefined>();
245
237
  const found = new Set<string>();
246
238
  for (let index = 0; index < queue.length; index++) {
@@ -249,7 +241,6 @@ export const getObligations = (
249
241
  found.add(name);
250
242
  if (!modules.has(name)) modules.set(name, submodule);
251
243
  });
252
- // A file named like a standard module replaces it, and is read again for each module citing it.
253
244
  for (const name of result.dependencies) {
254
245
  if (modules.has(name) && !STANDARD_MODULES.has(name)) continue;
255
246
  const input = loadModule(name);
@@ -292,14 +283,12 @@ export const getObligations = (
292
283
  module.isStandard ? module : flatten(modules, module, new Set()),
293
284
  );
294
285
  const generateModule = createGenerator(new Set(mains.map((main) => main.file)), lines, onWarning);
295
- // Instances see each module as flattened, and as normalized once its turn has come.
296
286
  const normalized = new Map(order.map((module) => [module.name, module]));
297
287
  return order.flatMap((module): ModuleObligations[] => {
298
288
  if (module.isStandard) return [];
299
289
  const result = normalize(pipeline, normalized, undefined, module);
300
290
  if (!module.isImportant) return [];
301
291
  const generated = generateModule([], result);
302
- // tlapm numbers the obligations, then drops the omitted ones and those outside the lines.
303
292
  const obligations = generated.obligations.flatMap((obligation, index): PrintedObligation[] => {
304
293
  const location = obligation.location;
305
294
  if (
@@ -1,5 +1,4 @@
1
- // Expr.Levels: the level of an expression (0 constant, 1 state, 2 action, 3 temporal, 4 undefined),
2
- // the weights of an operator's arguments, and the declared names the level depends on.
1
+ // A port of tlapm's Expr.Levels.
3
2
 
4
3
  import { TlaProofError, TlapmBugError } from "../errors";
5
4
  import {
@@ -114,15 +113,14 @@ export const LEVEL_NUMBERS: Record<Level, number> = {
114
113
  Unknown: 0,
115
114
  };
116
115
 
117
- const union = (sets: Set<string>[]) => new Set(sets.flatMap((set) => [...set]));
116
+ const getUnion = (sets: Set<string>[]) => new Set(sets.flatMap((set) => [...set]));
118
117
 
119
118
  const combineLevels = (infos: LevelInfo[]): LevelInfo => ({
120
119
  level: Math.max(0, ...infos.map((info) => info.level)),
121
120
  weights: [],
122
- params: union(infos.map((info) => info.params)),
121
+ params: getUnion(infos.map((info) => info.params)),
123
122
  });
124
123
 
125
- // The level of each hypothesis depends only on the scope before it.
126
124
  const hypLevels = new WeakMap<Scope, LevelInfo>();
127
125
 
128
126
  const computeHypLevel = (scope: Scope): LevelInfo => {
@@ -170,7 +168,7 @@ const applyOperator = (operator: LevelInfo, args: LevelInfo[]): LevelInfo => {
170
168
  return {
171
169
  level: Math.max(operator.level, ...weighted.map((arg) => arg.level)),
172
170
  weights: [],
173
- params: union([operator.params, ...weighted.map((arg) => arg.params)]),
171
+ params: getUnion([operator.params, ...weighted.map((arg) => arg.params)]),
174
172
  };
175
173
  };
176
174
 
@@ -205,8 +203,6 @@ export const getLevelInfo = (scope: Scope | undefined, expression: Expr): LevelI
205
203
  }
206
204
  case "Apply": {
207
205
  const operator = expression.operator;
208
- // The action frontend commutes a prime onto an operator, and tlapm keeps the level that
209
- // the application had.
210
206
  if (isBuiltinApply(operator, "Prime") && operator.args.length === 1) {
211
207
  return recurse({ ...expression, operator: operator.args[0] });
212
208
  }
@@ -1,5 +1,4 @@
1
- // tlapm's module units, with the standard modules, flattening EXTENDS (Module.Flatten), the
2
- // modules a module depends on (Module.Dep), and substitution in units (Module.Subst).
1
+ // A port of tlapm's Module.Standard, Module.Flatten, Module.Dep and Module.Subst.
3
2
 
4
3
  import { TlaProofError, TlapmBugError } from "../errors";
5
4
  import {
@@ -54,8 +53,6 @@ type ModuleUnitCore =
54
53
  | { kind: "Mutate"; mode: "Use" | "Hide"; usable: Usable }
55
54
  | { kind: "Anoninst"; instance: InstanceDefinition; isLocal: boolean };
56
55
 
57
- // depth is the size of the context the module was normalized in, which instantiation shifts
58
- // its body by.
59
56
  export interface Mule {
60
57
  name: string;
61
58
  extendees: string[];
@@ -156,7 +153,6 @@ const getStandardModule = (name: string, body: ModuleUnit[]): Mule => ({
156
153
  isStandard: true,
157
154
  });
158
155
 
159
- // Module.Standard.initctx, apart from $TLAPM, whose Builtins! names no module of the corpora uses.
160
156
  export const STANDARD_MODULES = new Map(
161
157
  [
162
158
  getStandardModule("Naturals", NATURALS),
@@ -251,8 +247,6 @@ const getNamedFact = (name: string, expression: Expr, location: Locus | undefine
251
247
  getFact({ kind: "Ix", index: 1, location }, "Hidden", "Always", location),
252
248
  ];
253
249
 
254
- // Module.Flatten.exports: what an extending module sees, with local definitions inlined like
255
- // builtins and proofs omitted.
256
250
  const getExports = (module: Mule): ModuleUnit[] =>
257
251
  module.body.flatMap((unit): ModuleUnit[] => {
258
252
  switch (unit.kind) {
@@ -271,7 +265,6 @@ const getExports = (module: Mule): ModuleUnit[] =>
271
265
  }
272
266
  });
273
267
 
274
- // tlapm recurses on a module that extends itself until the stack overflows.
275
268
  export const flatten = (
276
269
  modules: Map<string, Mule>,
277
270
  module: Mule,
@@ -295,8 +288,6 @@ export const flatten = (
295
288
  };
296
289
  };
297
290
 
298
- // Module.Dep.external_deps: the modules a module extends or instantiates, including those of its
299
- // submodules.
300
291
  export const getDependencies = (module: Mule) => {
301
292
  const dependencies = new Map<string, Locus | undefined>();
302
293
  const addDependency = (name: string, location: Locus | undefined) => {
@@ -308,7 +299,6 @@ export const getDependencies = (module: Mule) => {
308
299
  );
309
300
  const locals = new Set<string>();
310
301
  const submodules = new Map<string, Mule>();
311
- // Every INSTANCE definition inside a value, such as one in a LET.
312
302
  const addInstances = (value: unknown) => {
313
303
  if (typeof value !== "object" || value === null) return;
314
304
  if ("instance" in value && isInstanceDefinition(value.instance)) {
@@ -316,7 +306,6 @@ export const getDependencies = (module: Mule) => {
316
306
  }
317
307
  Object.values(value).forEach(addInstances);
318
308
  };
319
- // Leaves out the proofs of theorems.
320
309
  const visit = (unit: ModuleUnit) => {
321
310
  if (unit.kind !== "Submod") {
322
311
  addInstances(unit.kind === "Theorem" ? unit.sequent : unit);
@@ -357,8 +346,6 @@ const substituteUsable = (substitution: Substitution, usable: Usable): Usable =>
357
346
  }),
358
347
  });
359
348
 
360
- // Module.Subst.app_modunit. Instantiated theorems carry omitted proofs, which a substitution leaves
361
- // alone.
362
349
  const substituteUnit = (
363
350
  substitution: Substitution,
364
351
  unit: ModuleUnit,
@@ -417,7 +404,6 @@ const substituteUnit = (
417
404
  export const substituteUnits = (substitution: Substitution, units: ModuleUnit[]) =>
418
405
  mapAccumulate(substitution, units, substituteUnit)[1];
419
406
 
420
- // A named theorem binds its name as a proof definition, which its statement shifts past.
421
407
  export const bindTheoremName = (
422
408
  name: string | undefined,
423
409
  sequent: Sequent,
@@ -1,5 +1,4 @@
1
- // A port of tlapm's Module.Elab: normalization anonymizes a module unit by unit and expands each
2
- // instance into the units of the module it instantiates.
1
+ // A port of tlapm's Module.Elab.
3
2
 
4
3
  import { TlaProofError, TlapmBugError } from "../errors";
5
4
  import { lambdify } from "./action";
@@ -48,8 +47,6 @@ import {
48
47
  } from "./substitution";
49
48
  import { getScopeTime } from "./temporal";
50
49
 
51
- // latestModules is the module context of the latest anonymization of an axiom, theorem or USE,
52
- // which tlapm's anonymizer keeps using for the instances inside later definitions.
53
50
  export interface Pipeline {
54
51
  anonymizer: Anonymizer;
55
52
  simplify: ReturnType<typeof createSimplifier>;
@@ -92,9 +89,6 @@ const lambdifyUnit = (pipeline: Pipeline, scope: Scope | undefined, unit: Module
92
89
  return { ...unit, definition: { ...definition, body } };
93
90
  };
94
91
 
95
- // lambdify_enabled_cdot: the ENABLED and \cdot of each definition and theorem statement bind
96
- // their variables before instantiation substitutes for them. A theorem that cannot be lambdified
97
- // states TRUE.
98
92
  const lambdifyUnits = (
99
93
  pipeline: Pipeline,
100
94
  scope: Scope | undefined,
@@ -109,7 +103,6 @@ const lambdifyUnits = (
109
103
  return [adjoinAll(current, getUnitHyps(lambdified)), lambdified];
110
104
  });
111
105
 
112
- // apply_subst: each parameter declaration of the instancee gives way to its substitute.
113
106
  const applyParameters = (units: ModuleUnit[], substitutes: Map<string, Expr>) => {
114
107
  const body: ModuleUnit[] = [];
115
108
  let size = 0;
@@ -142,8 +135,6 @@ const applyParameters = (units: ModuleUnit[], substitutes: Map<string, Expr>) =>
142
135
  return body;
143
136
  };
144
137
 
145
- // resub_for: references to the instancee's own units become applications to the instance
146
- // arguments, which the definitions now bind themselves.
147
138
  const getLocalSubstitution = (
148
139
  count: number,
149
140
  argumentCount: number,
@@ -171,8 +162,6 @@ const addParameters = (expression: Expr, args: string[]): Expr => {
171
162
  : at({ kind: "Lambda", params, body: expression }, expression);
172
163
  };
173
164
 
174
- // localize: names the instancee's units under the instance name, salting its local definitions, and
175
- // abstracts each over the instance arguments.
176
165
  const localize = (
177
166
  pipeline: Pipeline,
178
167
  units: ModuleUnit[],
@@ -195,7 +184,7 @@ const localize = (
195
184
  while (rest.length > 0) {
196
185
  const [unit, ...tail] = rest;
197
186
  rest = tail;
198
- const localized = (expression: Expr) =>
187
+ const localizeExpr = (expression: Expr) =>
199
188
  addParameters(
200
189
  substituteExpr(getLocalSubstitution(size, argumentCount, location), expression),
201
190
  instance.args,
@@ -214,7 +203,7 @@ const localize = (
214
203
  definition: {
215
204
  ...definition,
216
205
  name: getLocalizedName(name),
217
- body: localized(definition.body),
206
+ body: localizeExpr(definition.body),
218
207
  },
219
208
  whereDefined: unit.isLocal ? "Builtin" : unit.whereDefined,
220
209
  isLocal: unit.isLocal || isLocal,
@@ -229,7 +218,7 @@ const localize = (
229
218
  const axiom: ModuleUnit = {
230
219
  ...unit,
231
220
  name: unit.name === undefined ? undefined : getLocalizedName(unit.name),
232
- expression: localized(unit.expression),
221
+ expression: localizeExpr(unit.expression),
233
222
  };
234
223
  body.push(axiom);
235
224
  size += getHypSize(axiom);
@@ -239,7 +228,7 @@ const localize = (
239
228
  complain(
240
229
  `${getAtPrefix(location)}Warning: Instancing produces parametric theorems.\nSuch theorems will be forcibly hidden and cannot be cited.\n(This warning appears at-most once per INSTANCE declaration.)`,
241
230
  );
242
- const expression = localized(at(exprifySequent(unit.sequent), unit));
231
+ const expression = localizeExpr(at(exprifySequent(unit.sequent), unit));
243
232
  body.push({
244
233
  ...unit,
245
234
  name: unit.name === undefined ? undefined : getLocalizedName(unit.name),
@@ -264,8 +253,6 @@ const localize = (
264
253
  return body;
265
254
  };
266
255
 
267
- // localize_axioms: an axiom becomes a hypothesis of each theorem after it, and a named one also a
268
- // definition.
269
256
  const localizeAxioms = (units: ModuleUnit[]) => {
270
257
  const body: ModuleUnit[] = [];
271
258
  let rest = units;
@@ -321,7 +308,6 @@ const getParameters = (module: Mule) =>
321
308
  ),
322
309
  );
323
310
 
324
- // Module.Elab.instantiate: the units of an instantiated module, in the context of the instance.
325
311
  const instantiate = (
326
312
  pipeline: Pipeline,
327
313
  modules: Map<string, Mule>,
@@ -387,7 +373,6 @@ const instantiate = (
387
373
  );
388
374
  };
389
375
 
390
- // make_defs: the definitions among the units an INSTANCE inside a LET or DEFINE stands for.
391
376
  export const expandInstance = (
392
377
  pipeline: Pipeline,
393
378
  scope: Scope | undefined,
@@ -426,9 +411,6 @@ export const expandInstance = (
426
411
  return definitions;
427
412
  };
428
413
 
429
- // Module.Elab.normalize: anonymizes each unit in the context of the ones before it, expands
430
- // instances, merges repeated definitions, and simplifies the proofs of important modules. The
431
- // result also joins the modules that later instances can name.
432
414
  export const normalize = (
433
415
  pipeline: Pipeline,
434
416
  modules: Map<string, Mule>,
@@ -443,7 +425,6 @@ export const normalize = (
443
425
  };
444
426
  const isRedundant = (name: string | undefined) =>
445
427
  name !== undefined && findNamed(current, name) !== undefined;
446
- // Instantiated units arrive anonymized.
447
428
  const queue = module.body.map((unit) => ({ unit, isAnonymized: false }));
448
429
  for (let index = 0; index < queue.length; index++) {
449
430
  const unit = queue[index].unit;
@@ -1,4 +1,4 @@
1
- // tlapm's Optable: each operator's precedence range and fixity, by every spelling it has.
1
+ // A port of tlapm's Optable.
2
2
 
3
3
  import type { Builtin } from "./expression";
4
4
 
@@ -113,7 +113,6 @@ const OPERATORS: [string, number, number, Fixity, string[]][] = [
113
113
  ["\\propto", 5, 5, "InfixNon", []],
114
114
  ];
115
115
 
116
- // OCaml's Hashtbl.find returns the most recent binding, so later aliases win over earlier names.
117
116
  const OPERATOR_TABLE = new Map<string, Operator>();
118
117
  for (const [name, low, high, fixity, aliases] of OPERATORS) {
119
118
  const operator = { name, low, high, fixity };
@@ -1,5 +1,4 @@
1
- // tlapm's method pragmas: the new (*{ by (prover:"zenon"; timeout:@) }*) after a definition, which
2
- // E_parser.read_new_method reads into a Bpragma, and the old (*{ by (zenon) }*) of Method_prs.
1
+ // A port of tlapm's E_parser.read_new_method and Method_prs.
3
2
 
4
3
  type PragmaValue =
5
4
  | { kind: "Default" }
@@ -37,7 +36,6 @@ const skipBlanks = (lines: string[], position: Position) => {
37
36
  }
38
37
  };
39
38
 
40
- // Where the pragma after start opens, past blanks and line ends.
41
39
  export const findPragma = (lines: string[], start: Position) => {
42
40
  const position = { ...start };
43
41
  skipBlanks(lines, position);
@@ -84,7 +82,6 @@ const getValue = (token: Token | undefined): PragmaValue | undefined => {
84
82
  return isPunct(token, "@") ? { kind: "Default" } : undefined;
85
83
  };
86
84
 
87
- // The methods of Method_prs's old pragma syntax, by the name Method.prover_meth_of_tac gives them.
88
85
  const OLD_METHODS = new Map([
89
86
  ["smt", "smt"],
90
87
  ["cvc3", "cvc4"],
@@ -113,16 +110,12 @@ const OLD_METHODS = new Map([
113
110
  ["trivial", "trivial"],
114
111
  ]);
115
112
 
116
- // An old-style method, with the tactic an isabelle method takes and the timeout in seconds an
117
- // isabelle or zenon method may take.
118
113
  export interface OldMethod {
119
114
  name: string;
120
115
  tactic?: string;
121
116
  timeout?: number;
122
117
  }
123
118
 
124
- // Method_prs.read_method: the (*{ by (zenon) }*) after a BY, OBVIOUS, proof step, theorem, or
125
- // axiom, which names one method, isabelle with a tactic, or zenon with a timeout and a fallback.
126
119
  export const readOldMethod = (lines: string[], start: Position) => {
127
120
  const tokens = tokenizePragma(lines, start);
128
121
  if (!tokens) return undefined;
@@ -162,8 +155,6 @@ export const readOldMethod = (lines: string[], start: Position) => {
162
155
  return index === tokens.length ? method : undefined;
163
156
  };
164
157
 
165
- // read_new_method: by (hint: value; ...), repeated, where a value is a string, a number, or @ for
166
- // the argument the definition is applied to.
167
158
  export const readNewMethod = (lines: string[], start: Position) => {
168
159
  const tokens = tokenizePragma(lines, start);
169
160
  if (!tokens) return undefined;