tla-ts 0.0.9 → 0.0.10-dev.28c823e4b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (390) hide show
  1. package/README.md +29 -1
  2. package/dist/compile.cjs +23 -0
  3. package/dist/compile.js +23 -0
  4. package/dist/deciders.cjs +28 -28
  5. package/dist/deciders.js +43 -43
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.cts +106 -10
  8. package/dist/index.d.ts +106 -10
  9. package/dist/index.js +1 -1
  10. package/dist/parallel-worker.cjs +1 -1
  11. package/dist/parallel-worker.js +1 -1
  12. package/dist/prove-worker.cjs +1 -1
  13. package/dist/prove-worker.js +1 -1
  14. package/dist/prove.cjs +116 -36
  15. package/dist/prove.js +116 -36
  16. package/dist/run.cjs +143 -31
  17. package/dist/run.js +143 -31
  18. package/dist/tlapm.cjs +2 -2
  19. package/dist/tlapm.js +2 -2
  20. package/dist/transfer.cjs +129 -104
  21. package/dist/transfer.js +129 -104
  22. package/dist/worker.cjs +7 -7
  23. package/dist/worker.js +7 -7
  24. package/package.json +3 -1
  25. package/src/ast.ts +4 -23
  26. package/src/bags.ts +99 -102
  27. package/src/builtins.ts +40 -78
  28. package/src/bundled-modules.ts +1 -8
  29. package/src/check.ts +599 -388
  30. package/src/cli/options.ts +11 -6
  31. package/src/cli/run.ts +0 -2
  32. package/src/cli/runtime-invariants.ts +136 -0
  33. package/src/cli/shared.ts +18 -11
  34. package/src/cli/tlapm.ts +0 -12
  35. package/src/cli/tlc-arguments.ts +640 -0
  36. package/src/cli/tlc-usage.ts +361 -0
  37. package/src/cli/tlc.ts +538 -220
  38. package/src/cli/typescript.ts +23 -0
  39. package/src/cli/xml-exporter.ts +4 -16
  40. package/src/cli.ts +0 -1
  41. package/src/codegen.ts +191 -64
  42. package/src/config.ts +140 -109
  43. package/src/coverage.ts +837 -0
  44. package/src/dependencies.ts +6 -40
  45. package/src/dfid.ts +618 -0
  46. package/src/environment.ts +240 -118
  47. package/src/errors.ts +70 -55
  48. package/src/evaluate.ts +596 -339
  49. package/src/exit-codes.ts +37 -3
  50. package/src/fingerprints.ts +10 -10
  51. package/src/index.ts +3 -0
  52. package/src/instances.ts +79 -11
  53. package/src/java-overrides.ts +4 -19
  54. package/src/json-reader.ts +455 -0
  55. package/src/json.ts +255 -139
  56. package/src/levels.ts +8 -17
  57. package/src/lexer.ts +80 -100
  58. package/src/liveness-checker.ts +82 -119
  59. package/src/liveness.ts +112 -64
  60. package/src/obligations/action.ts +4 -28
  61. package/src/obligations/anonymize.ts +84 -80
  62. package/src/obligations/equality.ts +1 -1
  63. package/src/obligations/expression.ts +2 -19
  64. package/src/obligations/format.ts +1 -9
  65. package/src/obligations/generate.ts +1 -11
  66. package/src/obligations/index.ts +0 -11
  67. package/src/obligations/levels.ts +4 -8
  68. package/src/obligations/module.ts +1 -15
  69. package/src/obligations/normalize.ts +5 -24
  70. package/src/obligations/operators.ts +1 -2
  71. package/src/obligations/pragma.ts +1 -10
  72. package/src/obligations/printer.ts +47 -46
  73. package/src/obligations/proof.ts +1 -5
  74. package/src/obligations/regroup.ts +1 -4
  75. package/src/obligations/simplify.ts +3 -14
  76. package/src/obligations/source.ts +1 -21
  77. package/src/obligations/subexpression.ts +5 -11
  78. package/src/obligations/substitution.ts +1 -3
  79. package/src/obligations/temporal.ts +8 -14
  80. package/src/obligations/tuples.ts +3 -9
  81. package/src/parallel-worker.ts +29 -39
  82. package/src/parallel.ts +53 -44
  83. package/src/parser.ts +565 -282
  84. package/src/pcal/ast.ts +53 -86
  85. package/src/pcal/parse.ts +144 -219
  86. package/src/pcal/tokenize.ts +91 -131
  87. package/src/pcal/translate.ts +83 -130
  88. package/src/pcal/validate.ts +48 -68
  89. package/src/pretty-print.ts +7 -8
  90. package/src/prover/decide-pool.ts +5 -10
  91. package/src/prover/deciders.ts +0 -4
  92. package/src/prover/first-order.ts +0 -11
  93. package/src/prover/isabelle/decide.ts +0 -6
  94. package/src/prover/isabelle/encode.ts +11 -23
  95. package/src/prover/isabelle/isar/inner-syntax.ts +108 -114
  96. package/src/prover/isabelle/isar/method.ts +25 -38
  97. package/src/prover/isabelle/isar/proof.ts +1 -10
  98. package/src/prover/isabelle/isar/statement.ts +1 -6
  99. package/src/prover/isabelle/isar/theory.ts +15 -26
  100. package/src/prover/isabelle/isar/type-check.ts +11 -25
  101. package/src/prover/isabelle/provers/blast/blast.ts +10 -41
  102. package/src/prover/isabelle/provers/blast/branch.ts +1 -32
  103. package/src/prover/isabelle/provers/blast/prove.ts +1 -35
  104. package/src/prover/isabelle/provers/blast/rules.ts +6 -44
  105. package/src/prover/isabelle/provers/blast/state.ts +2 -28
  106. package/src/prover/isabelle/provers/blast/term.ts +9 -36
  107. package/src/prover/isabelle/provers/clasimp.ts +1 -13
  108. package/src/prover/isabelle/provers/classical.ts +14 -42
  109. package/src/prover/isabelle/provers/hypsubst.ts +11 -25
  110. package/src/prover/isabelle/pure/bicompose.ts +16 -13
  111. package/src/prover/isabelle/pure/consts.ts +1 -7
  112. package/src/prover/isabelle/pure/conv.ts +1 -9
  113. package/src/prover/isabelle/pure/drule.ts +24 -40
  114. package/src/prover/isabelle/pure/envir.ts +3 -52
  115. package/src/prover/isabelle/pure/goal.ts +1 -7
  116. package/src/prover/isabelle/pure/interrupt.ts +0 -5
  117. package/src/prover/isabelle/pure/list.ts +0 -3
  118. package/src/prover/isabelle/pure/logic.ts +1 -14
  119. package/src/prover/isabelle/pure/name.ts +2 -9
  120. package/src/prover/isabelle/pure/net.ts +3 -59
  121. package/src/prover/isabelle/pure/object-logic.ts +3 -10
  122. package/src/prover/isabelle/pure/pattern.ts +2 -19
  123. package/src/prover/isabelle/pure/raw-simplifier.ts +13 -49
  124. package/src/prover/isabelle/pure/rewriter.ts +26 -58
  125. package/src/prover/isabelle/pure/search.ts +3 -10
  126. package/src/prover/isabelle/pure/seq.ts +1 -10
  127. package/src/prover/isabelle/pure/simplifier.ts +4 -12
  128. package/src/prover/isabelle/pure/table.ts +1 -31
  129. package/src/prover/isabelle/pure/tactic.ts +12 -22
  130. package/src/prover/isabelle/pure/tactical.ts +6 -12
  131. package/src/prover/isabelle/pure/term-ord.ts +2 -6
  132. package/src/prover/isabelle/pure/term.ts +2 -43
  133. package/src/prover/isabelle/pure/thm.ts +13 -36
  134. package/src/prover/isabelle/pure/type.ts +2 -15
  135. package/src/prover/isabelle/pure/unify.ts +20 -30
  136. package/src/prover/isabelle/pure/variable.ts +3 -7
  137. package/src/prover/isabelle/tla/classical-setup.ts +9 -19
  138. package/src/prover/isabelle/tla/context.ts +8 -16
  139. package/src/prover/isabelle/tla/logic.ts +4 -11
  140. package/src/prover/isabelle/tla/simpdata.ts +46 -34
  141. package/src/prover/isabelle/tools/intuitionistic.ts +1 -10
  142. package/src/prover/ocaml.ts +0 -6
  143. package/src/prover/prep/action.ts +4 -36
  144. package/src/prover/prep/enabled-axioms.ts +12 -19
  145. package/src/prover/prep/fingerprint.ts +0 -16
  146. package/src/prover/prep/level-comparison.ts +8 -12
  147. package/src/prover/prep/md5.ts +0 -2
  148. package/src/prover/prep/methods.ts +9 -36
  149. package/src/prover/prep/normalize.ts +4 -28
  150. package/src/prover/prove-worker.ts +0 -2
  151. package/src/prover/prove.ts +0 -36
  152. package/src/prover/ptl/decide.ts +7 -12
  153. package/src/prover/ptl/encode.ts +14 -36
  154. package/src/prover/ptl/sat.ts +24 -32
  155. package/src/prover/ptl/tableau.ts +12 -26
  156. package/src/prover/smt/axioms.ts +0 -7
  157. package/src/prover/smt/context.ts +19 -26
  158. package/src/prover/smt/data.ts +51 -54
  159. package/src/prover/smt/encode.ts +14 -35
  160. package/src/prover/smt/extensionality.ts +0 -10
  161. package/src/prover/smt/flatten.ts +3 -22
  162. package/src/prover/smt/format.ts +5 -10
  163. package/src/prover/smt/instances.ts +0 -10
  164. package/src/prover/smt/rewrite.ts +66 -101
  165. package/src/prover/smt/solver/act-cache.ts +0 -15
  166. package/src/prover/smt/solver/arith-rewriter.ts +3 -48
  167. package/src/prover/smt/solver/array.ts +1 -3
  168. package/src/prover/smt/solver/asserted-formulas.ts +1 -43
  169. package/src/prover/smt/solver/ast-lt.ts +1 -11
  170. package/src/prover/smt/solver/ast-util.ts +1 -6
  171. package/src/prover/smt/solver/ast.ts +1 -143
  172. package/src/prover/smt/solver/auf-solver.ts +6 -39
  173. package/src/prover/smt/solver/case-split-queue.ts +1 -9
  174. package/src/prover/smt/solver/cg-table.ts +1 -18
  175. package/src/prover/smt/solver/clause.ts +1 -27
  176. package/src/prover/smt/solver/conflict-resolution.ts +0 -9
  177. package/src/prover/smt/solver/context.ts +4 -61
  178. package/src/prover/smt/solver/ctx-simplify.ts +14 -41
  179. package/src/prover/smt/solver/der.ts +2 -21
  180. package/src/prover/smt/solver/dyn-ack.ts +1 -11
  181. package/src/prover/smt/solver/e-matching.ts +3 -34
  182. package/src/prover/smt/solver/enode.ts +1 -21
  183. package/src/prover/smt/solver/expr-ref.ts +1 -5
  184. package/src/prover/smt/solver/expr-safe-replace.ts +0 -5
  185. package/src/prover/smt/solver/fingerprints.ts +1 -12
  186. package/src/prover/smt/solver/flat-literals.ts +1 -9
  187. package/src/prover/smt/solver/goal.ts +2 -14
  188. package/src/prover/smt/solver/hash.ts +0 -8
  189. package/src/prover/smt/solver/hashtable.ts +1 -12
  190. package/src/prover/smt/solver/internalizer.ts +6 -98
  191. package/src/prover/smt/solver/lbool.ts +1 -2
  192. package/src/prover/smt/solver/literal.ts +0 -3
  193. package/src/prover/smt/solver/lp/bound-propagator.ts +8 -26
  194. package/src/prover/smt/solver/lp/constraints.ts +2 -8
  195. package/src/prover/smt/solver/lp/containers.ts +12 -30
  196. package/src/prover/smt/solver/lp/core-solver.ts +10 -31
  197. package/src/prover/smt/solver/lp/cross-nested.ts +6 -20
  198. package/src/prover/smt/solver/lp/dep-intervals.ts +7 -22
  199. package/src/prover/smt/solver/lp/dependency.ts +1 -4
  200. package/src/prover/smt/solver/lp/dioph-eq.ts +12 -98
  201. package/src/prover/smt/solver/lp/explanation.ts +1 -6
  202. package/src/prover/smt/solver/lp/gomory.ts +9 -22
  203. package/src/prover/smt/solver/lp/hnf-cutter.ts +17 -23
  204. package/src/prover/smt/solver/lp/hnf.ts +11 -26
  205. package/src/prover/smt/solver/lp/int-cube.ts +15 -36
  206. package/src/prover/smt/solver/lp/int-solver.ts +4 -34
  207. package/src/prover/smt/solver/lp/lar-solver.ts +32 -81
  208. package/src/prover/smt/solver/lp/lar-term.ts +1 -5
  209. package/src/prover/smt/solver/lp/lp-settings.ts +1 -14
  210. package/src/prover/smt/solver/lp/maximize-term.ts +20 -45
  211. package/src/prover/smt/solver/lp/nex-creator.ts +5 -28
  212. package/src/prover/smt/solver/lp/nex.ts +1 -6
  213. package/src/prover/smt/solver/lp/nla-backoff.ts +1 -4
  214. package/src/prover/smt/solver/lp/nla-basics.ts +5 -30
  215. package/src/prover/smt/solver/lp/nla-core.ts +35 -130
  216. package/src/prover/smt/solver/lp/nla-divisions.ts +32 -42
  217. package/src/prover/smt/solver/lp/nla-emonics.ts +4 -21
  218. package/src/prover/smt/solver/lp/nla-factorization.ts +1 -4
  219. package/src/prover/smt/solver/lp/nla-grobner.ts +15 -69
  220. package/src/prover/smt/solver/lp/nla-horner.ts +3 -11
  221. package/src/prover/smt/solver/lp/nla-intervals.ts +2 -12
  222. package/src/prover/smt/solver/lp/nla-monomial-bounds.ts +16 -41
  223. package/src/prover/smt/solver/lp/nla-monotone.ts +2 -6
  224. package/src/prover/smt/solver/lp/nla-order.ts +2 -13
  225. package/src/prover/smt/solver/lp/nla-patcher.ts +4 -7
  226. package/src/prover/smt/solver/lp/nla-tangents.ts +1 -9
  227. package/src/prover/smt/solver/lp/nla-throttle.ts +1 -6
  228. package/src/prover/smt/solver/lp/nla-types.ts +1 -11
  229. package/src/prover/smt/solver/lp/nla-var-eqs.ts +4 -25
  230. package/src/prover/smt/solver/lp/nra-solver.ts +5 -52
  231. package/src/prover/smt/solver/lp/numeric-pair.ts +1 -4
  232. package/src/prover/smt/solver/lp/pdd-interval.ts +1 -3
  233. package/src/prover/smt/solver/lp/pdd-simplifier.ts +2 -14
  234. package/src/prover/smt/solver/lp/pdd-solver.ts +4 -33
  235. package/src/prover/smt/solver/lp/pdd.ts +7 -70
  236. package/src/prover/smt/solver/lp/random-updater.ts +1 -8
  237. package/src/prover/smt/solver/lp/static-matrix.ts +9 -19
  238. package/src/prover/smt/solver/lp/union-find.ts +1 -6
  239. package/src/prover/smt/solver/mam-compiler.ts +14 -56
  240. package/src/prover/smt/solver/mam-interpreter.ts +1 -21
  241. package/src/prover/smt/solver/maximize-ac-sharing.ts +2 -17
  242. package/src/prover/smt/solver/model-checker.ts +2 -36
  243. package/src/prover/smt/solver/model-evaluator.ts +3 -29
  244. package/src/prover/smt/solver/model-finder.ts +3 -15
  245. package/src/prover/smt/solver/model-generator.ts +1 -12
  246. package/src/prover/smt/solver/model-macro-solver.ts +12 -69
  247. package/src/prover/smt/solver/nlsat/algebraic.ts +55 -151
  248. package/src/prover/smt/solver/nlsat/atoms.ts +5 -19
  249. package/src/prover/smt/solver/nlsat/evaluator.ts +17 -22
  250. package/src/prover/smt/solver/nlsat/explain.ts +3 -47
  251. package/src/prover/smt/solver/nlsat/interval-set.ts +9 -50
  252. package/src/prover/smt/solver/nlsat/levelwise.ts +48 -129
  253. package/src/prover/smt/solver/nlsat/mpbq.ts +3 -14
  254. package/src/prover/smt/solver/nlsat/polynomial.ts +17 -156
  255. package/src/prover/smt/solver/nlsat/solver.ts +7 -67
  256. package/src/prover/smt/solver/nlsat/types.ts +1 -8
  257. package/src/prover/smt/solver/nlsat/upolynomial-factorization.ts +1 -44
  258. package/src/prover/smt/solver/nlsat/upolynomial.ts +11 -92
  259. package/src/prover/smt/solver/nnf.ts +3 -38
  260. package/src/prover/smt/solver/pattern-inference.ts +2 -15
  261. package/src/prover/smt/solver/poly-rewriter.ts +3 -23
  262. package/src/prover/smt/solver/propagate-values.ts +1 -10
  263. package/src/prover/smt/solver/proto-model.ts +3 -48
  264. package/src/prover/smt/solver/pull-quant.ts +1 -12
  265. package/src/prover/smt/solver/qe-lite-der.ts +1 -29
  266. package/src/prover/smt/solver/qe-lite-fm.ts +2 -25
  267. package/src/prover/smt/solver/qe-lite.ts +3 -33
  268. package/src/prover/smt/solver/qi-queue.ts +1 -16
  269. package/src/prover/smt/solver/quant-tactics.ts +5 -22
  270. package/src/prover/smt/solver/quantifier-analyzer.ts +17 -37
  271. package/src/prover/smt/solver/quantifier-manager.ts +1 -8
  272. package/src/prover/smt/solver/random-gen.ts +1 -2
  273. package/src/prover/smt/solver/rational.ts +1 -8
  274. package/src/prover/smt/solver/ref-vector.ts +1 -6
  275. package/src/prover/smt/solver/relevancy.ts +2 -15
  276. package/src/prover/smt/solver/rewriter-tpl.ts +3 -147
  277. package/src/prover/smt/solver/rewriter.ts +3 -85
  278. package/src/prover/smt/solver/rlimit.ts +2 -20
  279. package/src/prover/smt/solver/smtlib-parser.ts +2 -37
  280. package/src/prover/smt/solver/solver.ts +23 -34
  281. package/src/prover/smt/solver/sort.ts +1 -5
  282. package/src/prover/smt/solver/sticky-generations.ts +0 -5
  283. package/src/prover/smt/solver/theory-lra-axioms.ts +3 -24
  284. package/src/prover/smt/solver/theory-lra-bounds.ts +0 -5
  285. package/src/prover/smt/solver/theory-lra-final-check.ts +4 -22
  286. package/src/prover/smt/solver/theory-lra-internalize.ts +1 -27
  287. package/src/prover/smt/solver/theory-lra-model.ts +4 -19
  288. package/src/prover/smt/solver/theory-lra-propagate.ts +1 -15
  289. package/src/prover/smt/solver/theory-lra-state.ts +3 -8
  290. package/src/prover/smt/solver/theory-lra.ts +1 -8
  291. package/src/prover/smt/solver/var-subst.ts +2 -26
  292. package/src/prover/smt/table.ts +0 -8
  293. package/src/prover/tlapm/cache.ts +20 -25
  294. package/src/prover/tlapm/ocaml-marshal.ts +19 -21
  295. package/src/prover/tlapm/tlapm.ts +12 -17
  296. package/src/prover/verdict.ts +0 -2
  297. package/src/prover/zenon/check/check.ts +0 -9
  298. package/src/prover/zenon/check/definitions.ts +5 -15
  299. package/src/prover/zenon/check/equality.ts +0 -8
  300. package/src/prover/zenon/check/functions.ts +0 -4
  301. package/src/prover/zenon/check/keys.ts +0 -7
  302. package/src/prover/zenon/check/propositional.ts +0 -3
  303. package/src/prover/zenon/check/records.ts +0 -5
  304. package/src/prover/zenon/check/relations.ts +0 -13
  305. package/src/prover/zenon/check/rewrites.ts +0 -6
  306. package/src/prover/zenon/check/sets.ts +0 -3
  307. package/src/prover/zenon/check/terms.ts +0 -17
  308. package/src/prover/zenon/check/tla.ts +0 -6
  309. package/src/prover/zenon/decide.ts +0 -12
  310. package/src/prover/zenon/encode.ts +1 -8
  311. package/src/prover/zenon/eqrel.ts +0 -13
  312. package/src/prover/zenon/equality-rules.ts +0 -4
  313. package/src/prover/zenon/expr.ts +1 -26
  314. package/src/prover/zenon/index-table.ts +17 -38
  315. package/src/prover/zenon/isar-case.ts +9 -19
  316. package/src/prover/zenon/isar.ts +1 -29
  317. package/src/prover/zenon/limits.ts +0 -4
  318. package/src/prover/zenon/llproof.ts +0 -9
  319. package/src/prover/zenon/mltoll.ts +54 -76
  320. package/src/prover/zenon/node.ts +1 -11
  321. package/src/prover/zenon/ocaml.ts +1 -17
  322. package/src/prover/zenon/parse.ts +2 -7
  323. package/src/prover/zenon/phrase.ts +1 -11
  324. package/src/prover/zenon/proof.ts +0 -9
  325. package/src/prover/zenon/propositional-rules.ts +0 -5
  326. package/src/prover/zenon/rules.ts +2 -6
  327. package/src/prover/zenon/search.ts +1 -17
  328. package/src/prover/zenon/tla/functions.ts +57 -29
  329. package/src/prover/zenon/tla/llproof.ts +63 -70
  330. package/src/prover/zenon/tla/records.ts +56 -27
  331. package/src/prover/zenon/tla/rewrites.ts +12 -19
  332. package/src/prover/zenon/tla/sets.ts +68 -39
  333. package/src/prover/zenon/tla/terms.ts +0 -6
  334. package/src/prover/zenon/tla/tla.ts +59 -58
  335. package/src/randomization.ts +81 -35
  336. package/src/resolve.ts +12 -112
  337. package/src/runtime.ts +22 -22
  338. package/src/sany/builtins.ts +2 -5
  339. package/src/sany/generator.ts +149 -252
  340. package/src/sany/levels.ts +6 -34
  341. package/src/sany/lexer.ts +41 -61
  342. package/src/sany/linter.ts +1 -9
  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 +495 -155
  351. package/src/simulate.ts +685 -0
  352. package/src/spec-description.ts +176 -69
  353. package/src/standard-definitions.ts +0 -4
  354. package/src/standard-modules.ts +254 -69
  355. package/src/state-graph.ts +50 -24
  356. package/src/subexpressions.ts +69 -52
  357. package/src/substitution-levels.ts +2 -3
  358. package/src/successors.ts +263 -94
  359. package/src/symmetry.ts +33 -25
  360. package/src/tableau.ts +27 -24
  361. package/src/tlc/fingerprint.ts +183 -67
  362. package/src/tlc/jar-data.ts +112 -6
  363. package/src/tlc/messages.ts +110 -44
  364. package/src/tlc/order.ts +37 -60
  365. package/src/tlc/random.ts +33 -45
  366. package/src/tlc/replay.ts +549 -217
  367. package/src/tlc/summary.ts +36 -47
  368. package/src/tlc/tlc-operators.ts +76 -41
  369. package/src/tlc/tlcext-operators.ts +139 -122
  370. package/src/tlc/trace-spec.ts +269 -0
  371. package/src/tlc/value-stream.ts +139 -0
  372. package/src/tlc/version.ts +1 -4
  373. package/src/transfer.ts +22 -25
  374. package/src/typescript/actions.ts +481 -0
  375. package/src/typescript/collections.ts +600 -0
  376. package/src/typescript/compile.ts +65 -0
  377. package/src/typescript/context.ts +94 -0
  378. package/src/typescript/emit.ts +121 -0
  379. package/src/typescript/expressions.ts +496 -0
  380. package/src/typescript/formula.ts +152 -0
  381. package/src/typescript/functions.ts +284 -0
  382. package/src/typescript/model.ts +163 -0
  383. package/src/typescript/names.ts +114 -0
  384. package/src/typescript/program.ts +48 -0
  385. package/src/typescript/properties.ts +139 -0
  386. package/src/typescript/scope.ts +112 -0
  387. package/src/typescript/steps.ts +165 -0
  388. package/src/typescript/types.ts +171 -0
  389. package/src/values.ts +780 -337
  390. package/src/worker.ts +7 -8
@@ -1,10 +1,4 @@
1
- // Ported from Isabelle2025's Pure/goal.ML (init), Pure/Isar/method.ML (insert_tac, finish) and the
2
- // terminal proof of Pure/Isar/proof.ML. Copyright (c) 1986-2025 University of Cambridge,
3
- // Technische Universitaet Muenchen, and contributors, see LICENSE.
4
- //
5
- // The goal of show "C" is C ==> #C, and using assms makes the assumptions its facts.
6
- // Goal.conjunction_tac, which METHOD runs first, changes nothing here: tlapm's goals have no Pure
7
- // conjunctions.
1
+ // Ported from Isabelle2025's Pure/goal.ML, Pure/Isar/method.ML and Pure/Isar/proof.ML. Copyright (c) 1986-2025 University of Cambridge, Technische Universitaet Muenchen, and contributors, see LICENSE.
8
2
 
9
3
  import { compIncr, forallIntrVars, protectI, revcutRl } from "../pure/drule";
10
4
  import { normHhf } from "../pure/simplifier";
@@ -15,14 +9,11 @@ import { resolveTac } from "../pure/tactic";
15
9
  import { assume, instantiate, type Thm } from "../pure/thm";
16
10
  import type { Statement } from "./statement";
17
11
 
18
- // Goal.init: C ==> #C.
19
12
  export const initGoal = (statement: Statement) =>
20
13
  instantiate([{ variable: mkVar("A", 0, propT), term: statement.conclusion }], protectI);
21
14
 
22
- // Assumption.assume: an assumption in hhf normal form.
23
15
  export const getFacts = (limits: Limits, statement: Statement) =>
24
16
  statement.assumptions.map((assumption) => normHhf(limits, assume(assumption)));
25
17
 
26
- // Method.insert_tac: each fact becomes a premise of the goal, in order.
27
18
  export const insertTac = (limits: Limits, facts: readonly Thm[], index: number): Tactic =>
28
19
  every(facts.map((fact) => resolveTac(limits, [compIncr(forallIntrVars(fact), revcutRl)])(index)));
@@ -1,9 +1,4 @@
1
- // Ported from the statement handling of Isabelle2025's Pure/Isar/expression.ML
2
- // (prep_full_context_statement). Copyright (c) 1986-2025 University of Cambridge, Technische
3
- // Universitaet Muenchen, and contributors, see LICENSE.
4
- //
5
- // Reads a lemma's fixes, assumes and shows: each proposition is parsed with the variables fixed
6
- // before it, and all of them are type checked together.
1
+ // Ported from Isabelle2025's Pure/Isar/expression.ML. Copyright (c) 1986-2025 University of Cambridge, Technische Universitaet Muenchen, and contributors, see LICENSE.
7
2
 
8
3
  import { typargsOf } from "../pure/consts";
9
4
  import type { Term } from "../pure/term";
@@ -1,12 +1,3 @@
1
- // Reads the outer syntax of the theories tlapm writes (Isabelle.thy_temp in isabelle.ml): the
2
- // header, the constants it declares, and one lemma with its proof.
3
- //
4
- // theory NAME imports Constant Zenon begin
5
- // consts "name" :: type ...
6
- // lemma NAME: fixes ... assumes NAME: "prop" ... shows "prop" (is "PROP ?NAME")
7
- // proof - show "PROP ?NAME" [using assms] by METHOD [METHOD] qed
8
- // end
9
-
10
1
  import { TlaIsabelleError } from "../../../errors";
11
2
 
12
3
  export type OuterToken =
@@ -24,13 +15,11 @@ export interface TheoryText {
24
15
  readonly elements: readonly StatementElement[];
25
16
  readonly shows: string;
26
17
  readonly isUsingAssms: boolean;
27
- // The method of by, then the terminal method if there is one, as outer tokens.
28
18
  readonly method: readonly OuterToken[];
29
19
  }
30
20
 
31
21
  const isWordChar = (char: string) => /[A-Za-z0-9_'.]/.test(char);
32
22
 
33
- // Outer strings unescape \" and \\; symbols such as \<in> stay as they are.
34
23
  const readString = (text: string, start: number): [string, number] => {
35
24
  let result = "";
36
25
  let position = start + 1;
@@ -120,62 +109,62 @@ export const parseTheory = (text: string): TheoryText => {
120
109
  if (peek()?.kind !== "symbol" || peek().text !== symbol) throw syntaxError();
121
110
  position += 1;
122
111
  };
123
- const name = () => {
112
+ const expectName = () => {
124
113
  const token = peek();
125
114
  if (token?.kind !== "word" || KEYWORDS.has(token.text)) throw syntaxError();
126
115
  position += 1;
127
116
  return token.text;
128
117
  };
129
- const string = () => {
118
+ const expectString = () => {
130
119
  const token = peek();
131
120
  if (token?.kind !== "string") throw syntaxError();
132
121
  position += 1;
133
122
  return token.text;
134
123
  };
135
- const nameOrString = () => (peek()?.kind === "string" ? string() : name());
124
+ const expectNameOrString = () => (peek()?.kind === "string" ? expectString() : expectName());
136
125
 
137
126
  expectWord("theory");
138
- const theoryName = name();
127
+ const theoryName = expectName();
139
128
  expectWord("imports");
140
- while (!isWord("begin")) name();
129
+ while (!isWord("begin")) expectName();
141
130
  expectWord("begin");
142
131
  const consts: { name: string; type: string }[] = [];
143
132
  if (isWord("consts")) {
144
133
  position += 1;
145
134
  while (peek()?.kind === "string") {
146
- const constName = string();
135
+ const constName = expectString();
147
136
  expectSymbol(":");
148
137
  expectSymbol(":");
149
- consts.push({ name: constName, type: nameOrString() });
138
+ consts.push({ name: constName, type: expectNameOrString() });
150
139
  }
151
140
  }
152
141
  expectWord("lemma");
153
- name();
142
+ expectName();
154
143
  expectSymbol(":");
155
144
  const elements: StatementElement[] = [];
156
145
  while (isWord("fixes") || isWord("assumes")) {
157
146
  if (isWord("fixes")) {
158
147
  position += 1;
159
- const names = [name()];
160
- while (peek()?.kind === "word" && !KEYWORDS.has(peek().text)) names.push(name());
148
+ const names = [expectName()];
149
+ while (peek()?.kind === "word" && !KEYWORDS.has(peek().text)) names.push(expectName());
161
150
  elements.push({ kind: "fixes", names });
162
151
  } else {
163
152
  position += 1;
164
- const assumption = name();
153
+ const assumption = expectName();
165
154
  expectSymbol(":");
166
- elements.push({ kind: "assumes", name: assumption, prop: string() });
155
+ elements.push({ kind: "assumes", name: assumption, prop: expectString() });
167
156
  }
168
157
  }
169
158
  expectWord("shows");
170
- const shows = string();
159
+ const shows = expectString();
171
160
  expectSymbol("(");
172
161
  expectWord("is");
173
- string();
162
+ expectString();
174
163
  expectSymbol(")");
175
164
  expectWord("proof");
176
165
  expectSymbol("-");
177
166
  expectWord("show");
178
- string();
167
+ expectString();
179
168
  const isUsingAssms = isWord("using");
180
169
  if (isUsingAssms) {
181
170
  position += 1;
@@ -1,10 +1,4 @@
1
- // Ported from Isabelle2025's Pure/type_infer_context.ML, Pure/type_infer.ML (fixate) and the
2
- // abbreviation expansion of Pure/consts.ML. Copyright (c) 1986-2025 University of Cambridge,
3
- // Technische Universitaet Muenchen, and contributors, see LICENSE.
4
- //
5
- // Resolves the names of parsed propositions and infers their types together, as
6
- // Syntax.check_props does for the statement of a lemma: a free variable has one type across all
7
- // of them, and type parameters that stay open become the type variables 'a, 'b, and so on.
1
+ // Ported from Isabelle2025's Pure/type_infer_context.ML, Pure/type_infer.ML and Pure/consts.ML. Copyright (c) 1986-2025 University of Cambridge, Technische Universitaet Muenchen, and contributors, see LICENSE.
8
2
 
9
3
  import { TlaIsabelleError } from "../../../errors";
10
4
  import { bumpString } from "../pure/name";
@@ -29,18 +23,15 @@ import {
29
23
  import type { ConstInfo } from "../tla/logic";
30
24
  import type { Ast } from "./inner-syntax";
31
25
 
32
- // The name a type parameter carries until it is fixed, as Type_Infer.param does.
33
26
  const PARAM_NAME = "?'a";
34
27
 
35
28
  interface NameScope {
36
29
  readonly consts: ReadonlyMap<string, ConstInfo>;
37
- // The constant an unqualified name stands for.
38
30
  readonly constNames: ReadonlyMap<string, string>;
39
31
  }
40
32
 
41
33
  export interface PropToCheck {
42
34
  readonly ast: Ast;
43
- // The variables fixed where the proposition appears.
44
35
  readonly fixed: ReadonlySet<string>;
45
36
  }
46
37
 
@@ -50,7 +41,7 @@ interface Inference {
50
41
  nextParam: number;
51
42
  }
52
43
 
53
- const freshParam = (inference: Inference) => {
44
+ const createParam = (inference: Inference) => {
54
45
  const param = mkTVar(PARAM_NAME, inference.nextParam);
55
46
  inference.nextParam += 1;
56
47
  return param;
@@ -118,7 +109,6 @@ const unify = (inference: Inference, left: Typ, right: Typ) => {
118
109
  throw new TlaIsabelleError("ERROR", "Type unification failed");
119
110
  };
120
111
 
121
- // A constant's declared type with fresh parameters for its type variables.
122
112
  const instantiateScheme = (inference: Inference, type: Typ) => {
123
113
  const params = new Map<string, Typ>();
124
114
  const instantiate = (current: Typ): Typ => {
@@ -126,20 +116,19 @@ const instantiateScheme = (inference: Inference, type: Typ) => {
126
116
  const key = current.kind === "TFree" ? current.name : `${current.name}.${current.index}`;
127
117
  const known = params.get(key);
128
118
  if (known !== undefined) return known;
129
- const param = freshParam(inference);
119
+ const param = createParam(inference);
130
120
  params.set(key, param);
131
121
  return param;
132
122
  };
133
123
  return instantiate(type);
134
124
  };
135
125
 
136
- const constType = (scope: NameScope, name: string) => {
126
+ const getConstType = (scope: NameScope, name: string) => {
137
127
  const info = scope.consts.get(name);
138
128
  if (info === undefined) throw new TlaIsabelleError("ERROR", `Undeclared constant: ${name}`);
139
129
  return info.type;
140
130
  };
141
131
 
142
- // Builds the term with parameter types and infers its type, constraining the parameters.
143
132
  const elaborate = (
144
133
  scope: NameScope,
145
134
  inference: Inference,
@@ -153,27 +142,27 @@ const elaborate = (
153
142
  if (index >= 0) return [mkBound(index), bound[index].type];
154
143
  const constant = fixed.has(ast.name) ? undefined : scope.constNames.get(ast.name);
155
144
  if (constant !== undefined) {
156
- const type = instantiateScheme(inference, constType(scope, constant));
145
+ const type = instantiateScheme(inference, getConstType(scope, constant));
157
146
  return [mkConst(constant, type), type];
158
147
  }
159
148
  const known = inference.freeTypes.get(ast.name);
160
- const type = known ?? freshParam(inference);
149
+ const type = known ?? createParam(inference);
161
150
  if (known === undefined) inference.freeTypes.set(ast.name, type);
162
151
  return [mkFree(ast.name, type), type];
163
152
  }
164
153
  case "const": {
165
- const type = instantiateScheme(inference, constType(scope, ast.name));
154
+ const type = instantiateScheme(inference, getConstType(scope, ast.name));
166
155
  return [mkConst(ast.name, type), type];
167
156
  }
168
157
  case "app": {
169
158
  const [fun, funType] = elaborate(scope, inference, fixed, bound, ast.fun);
170
159
  const [arg, argType] = elaborate(scope, inference, fixed, bound, ast.arg);
171
- const result = freshParam(inference);
160
+ const result = createParam(inference);
172
161
  unify(inference, funType, funT(argType, result));
173
162
  return [mkApp(fun, arg), result];
174
163
  }
175
164
  case "abs": {
176
- const type = ast.type ?? freshParam(inference);
165
+ const type = ast.type ?? createParam(inference);
177
166
  const [body, bodyType] = elaborate(
178
167
  scope,
179
168
  inference,
@@ -211,7 +200,6 @@ const instantiateMatched = (type: Typ, instantiation: ReadonlyMap<string, Typ>):
211
200
  )
212
201
  : (instantiation.get(type.kind === "TFree" ? type.name : `${type.name}.${type.index}`) ?? type);
213
202
 
214
- // Consts.certify with normalize: unfolds abbreviations and applies them to their arguments.
215
203
  const expandAbbreviations = (scope: NameScope, term: Term): Term => {
216
204
  const [head, args] = stripComb(term);
217
205
  const expandedArgs = args.map((arg) => expandAbbreviations(scope, arg));
@@ -244,9 +232,7 @@ export const checkProps = (scope: NameScope, props: readonly PropToCheck[]): Ter
244
232
  mapTypes((type) => normalize(inference, type), term),
245
233
  ),
246
234
  );
247
- // Type_Infer.fixate: the parameters left open become type variables named in order of their
248
- // first appearance.
249
- const params = expanded.reduce(
235
+ const params = expanded.reduce<number[]>(
250
236
  (result, term) =>
251
237
  foldTypes(
252
238
  (type, state: number[]) =>
@@ -261,7 +247,7 @@ export const checkProps = (scope: NameScope, props: readonly PropToCheck[]): Ter
261
247
  term,
262
248
  result,
263
249
  ),
264
- [] as number[],
250
+ [],
265
251
  );
266
252
  const names = new Map<number, string>();
267
253
  params.reduce((name, param) => {
@@ -1,10 +1,4 @@
1
- // Ported from Isabelle2025's Provers/blast.ML. Copyright (c) 1986-2025 University of Cambridge,
2
- // Technische Universitaet Muenchen, and contributors, see LICENSE.
3
- //
4
- // Paulson's generic tableau prover with proof reconstruction. It converts subgoal 1 to
5
- // prototerms, Skolemizing its parameters, searches for a tableau proof with the claset's rules,
6
- // and replays the proof with Isabelle tactics, so the kernel checks every result. Blast ignores
7
- // the claset's wrappers and the elimination rules whose conclusion is not a formula variable.
1
+ // Ported from Isabelle2025's Provers/blast.ML. Copyright (c) 1986-2025 University of Cambridge, Technische Universitaet Muenchen, and contributors, see LICENSE.
8
2
 
9
3
  import { TlaIsabelleError } from "../../../../errors";
10
4
  import { selectGoal } from "../../pure/goal";
@@ -36,9 +30,7 @@ import {
36
30
  mkBlastFree,
37
31
  mkBlastSkolem,
38
32
  mkBlastVar,
39
- mkGoal,
40
- stripBlastImpConcl,
41
- stripBlastImpPrems,
33
+ splitGoalPrems,
42
34
  type BlastTerm,
43
35
  type VarEntry,
44
36
  type VarRef,
@@ -46,10 +38,8 @@ import {
46
38
 
47
39
  export type { BlastContext } from "./state";
48
40
 
49
- // Blast's depth_limit configuration option.
50
41
  const DEPTH_LIMIT = 20;
51
42
 
52
- // TRANS: the subgoal has no translation, such as one applying an unknown to a non-parameter.
53
43
  class Trans extends Error {}
54
44
 
55
45
  const isTermError = (error: unknown) =>
@@ -73,22 +63,20 @@ const discardForalls = (term: Term): Term =>
73
63
  interface SubgoalVar {
74
64
  readonly key: string;
75
65
  readonly ref: VarRef;
76
- // The parameters the variable is applied to.
77
66
  readonly bounds: readonly number[];
78
67
  }
79
68
 
80
- // Translates a subgoal, Skolemizing all its parameters.
81
69
  const fromSubgoal = (state: BlastState, term: Term): BlastTerm => {
82
70
  const vars: SubgoalVar[] = [];
83
71
  const tvars: VarEntry[] = [];
84
- const from = (level: number, current: Term): BlastTerm => {
72
+ const convert = (level: number, current: Term): BlastTerm => {
85
73
  const [head, args] = stripComb(current);
86
74
  const apply = (blastHead: BlastTerm) =>
87
75
  listBlastComb(
88
76
  blastHead,
89
- args.map((arg) => from(level, arg)),
77
+ args.map((arg) => convert(level, arg)),
90
78
  );
91
- const bounds = () =>
79
+ const getBounds = () =>
92
80
  args.map((arg) => {
93
81
  if (arg.kind !== "Bound")
94
82
  throw new Trans("Function unknown's argument not a bound variable");
@@ -106,11 +94,11 @@ const fromSubgoal = (state: BlastState, term: Term): BlastTerm => {
106
94
  const key = `${head.name}.${head.index}`;
107
95
  const known = vars.find((entry) => entry.key === key);
108
96
  if (known === undefined) {
109
- const entry = { key, ref: { value: undefined }, bounds: bounds() };
97
+ const entry = { key, ref: { value: undefined }, bounds: getBounds() };
110
98
  vars.unshift(entry);
111
99
  return mkBlastVar(entry.ref);
112
100
  }
113
- const argBounds = bounds();
101
+ const argBounds = getBounds();
114
102
  if (
115
103
  known.bounds.length === argBounds.length &&
116
104
  known.bounds.every((bound, index) => bound === argBounds[index])
@@ -120,13 +108,13 @@ const fromSubgoal = (state: BlastState, term: Term): BlastTerm => {
120
108
  }
121
109
  case "Abs":
122
110
  if (args.length > 0) throw new Trans("argument not in normal form");
123
- return mkBlastAbs(head.name, from(level + 1, head.body));
111
+ return mkBlastAbs(head.name, convert(level + 1, head.body));
124
112
  case "App":
125
113
  throw new Trans("strip_comb");
126
114
  }
127
115
  };
128
116
  const npars = stripParams(term).length;
129
- let result = from(0, discardForalls(term));
117
+ let result = convert(0, discardForalls(term));
130
118
  for (let index = 0; index < npars; index += 1) {
131
119
  const args = vars.filter((entry) => !entry.bounds.includes(index)).map((entry) => entry.ref);
132
120
  result = blastSubstBound(mkBlastSkolem(gensym(state, "T"), args), result);
@@ -141,8 +129,6 @@ interface EveryTrail {
141
129
  readonly next: EveryTrail | undefined;
142
130
  }
143
131
 
144
- // EVERY, as a loop: Isabelle's EVY and evyBack call each other in tail position, so backtracking
145
- // over a long reconstruction must not grow the stack.
146
132
  const everyTac =
147
133
  (tactics: readonly Tactic[]): Tactic =>
148
134
  (start) => {
@@ -189,7 +175,6 @@ const initBranch = (terms: readonly BlastTerm[], lim: number): Branch => ({
189
175
  lim,
190
176
  });
191
177
 
192
- // The tableau engine and proof reconstruction on subgoal 1, with depth limit lim.
193
178
  const rawBlast =
194
179
  (context: BlastContext, lim: number): Tactic =>
195
180
  (goalState) => {
@@ -210,27 +195,13 @@ const rawBlast =
210
195
  };
211
196
  try {
212
197
  const skoprem = fromSubgoal(state, destImplies(goalState.prop)[0]);
213
- const trueprop = context.data.trueprop;
214
- return prove(
215
- state,
216
- [
217
- initBranch(
218
- [
219
- mkGoal(stripBlastImpConcl(trueprop, skoprem)),
220
- ...stripBlastImpPrems(trueprop, skoprem),
221
- ],
222
- lim,
223
- ),
224
- ],
225
- cont,
226
- );
198
+ return prove(state, [initBranch(splitGoalPrems(context.data.trueprop, skoprem), lim)], cont);
227
199
  } catch (error) {
228
200
  if (isBacktrackTo(error, undefined) || error instanceof Trans) return emptySeq;
229
201
  throw error;
230
202
  }
231
203
  };
232
204
 
233
- // Blast.depth_tac: blast with a fixed depth limit.
234
205
  export const blastDepthTac =
235
206
  (context: BlastContext, limit: number): GoalTactic =>
236
207
  (index) =>
@@ -238,7 +209,6 @@ export const blastDepthTac =
238
209
  thenTac(atomizePremsTac(context.limits, context.data.atomize)(1), rawBlast(context, limit)),
239
210
  )(index);
240
211
 
241
- // Search.DEEPEN (1, lim) from depth m on goal 1.
242
212
  const deepen =
243
213
  (context: BlastContext, limit: number, depth: number): Tactic =>
244
214
  (state): Seq<Thm> =>
@@ -246,7 +216,6 @@ const deepen =
246
216
  ? emptySeq
247
217
  : orElse(rawBlast(context, depth), deepen(context, limit, depth + 1))(state);
248
218
 
249
- // Blast.blast_tac: iterative deepening up to the depth limit.
250
219
  export const blastTac =
251
220
  (context: BlastContext): GoalTactic =>
252
221
  (index) =>
@@ -1,8 +1,4 @@
1
- // Ported from Isabelle2025's Provers/blast.ML. Copyright (c) 1986-2025 University of Cambridge,
2
- // Technische Universitaet Muenchen, and contributors, see LICENSE.
3
- //
4
- // Operations on branches: naive substitution for equalities, closing a branch by complementary
5
- // literals, and the pruning of choice points.
1
+ // Ported from Isabelle2025's Provers/blast.ML. Copyright (c) 1986-2025 University of Cambridge, Technische Universitaet Muenchen, and contributors, see LICENSE.
6
2
 
7
3
  import { orElseGoal, thenGoal, type GoalTactic } from "../../pure/tactical";
8
4
  import { assumeTac, eqAssumeTac, ematchTac } from "../../pure/tactic";
@@ -33,7 +29,6 @@ import {
33
29
  const negate = (state: BlastState, term: BlastTerm) =>
34
30
  mkBlastApp(mkBlastConst(state.context.data.notName), term);
35
31
 
36
- // Converts a *Goal* to an ordinary negation.
37
32
  export const negOfGoal = (state: BlastState, term: BlastTerm) => {
38
33
  const goal = destConstApp(term, GOAL_NAME);
39
34
  return goal === undefined ? term : negate(state, goal);
@@ -44,15 +39,12 @@ const negOfGoal2 = (state: BlastState, formula: Formula): Formula => ({
44
39
  md: formula.md,
45
40
  });
46
41
 
47
- // Converts the goals to negations in the safe parts of a branch. They could have been moved there
48
- // from the literals by an equality substitution.
49
42
  export const negOfGoals = (state: BlastState, pairs: readonly Level[]): Level[] =>
50
43
  pairs.map((level) => ({
51
44
  safe: level.safe.map((formula) => negOfGoal2(state, formula)),
52
45
  unsafe: level.unsafe,
53
46
  }));
54
47
 
55
- // Replaces the atomic term old by new, returning the very same term where nothing changes.
56
48
  const substAtomic = (old: BlastTerm, replacement: BlastTerm, term: BlastTerm): BlastTerm => {
57
49
  if (term.kind === "Var" && term.ref.value !== undefined)
58
50
  return substAtomic(old, replacement, term.ref.value);
@@ -68,7 +60,6 @@ const substAtomic = (old: BlastTerm, replacement: BlastTerm, term: BlastTerm): B
68
60
  return blastAconv(term, old) ? replacement : term;
69
61
  };
70
62
 
71
- // Eta-contracts a term from outside, just enough to reduce it to an atom.
72
63
  const etaContractAtom = (term: BlastTerm): BlastTerm => {
73
64
  if (term.kind !== "Abs") return term;
74
65
  const body = etaContract2(term.body);
@@ -82,10 +73,6 @@ const etaContractAtom = (term: BlastTerm): BlastTerm => {
82
73
  const etaContract2 = (term: BlastTerm): BlastTerm =>
83
74
  term.kind === "App" ? mkBlastApp(term.fun, etaContractAtom(term.arg)) : etaContractAtom(term);
84
75
 
85
- // Can term occur in other? Does not examine the arguments of Skolem terms, which substitution does
86
- // not affect, and is reflexive because hyp_subst_tac fails on x = x. No variables may occur in
87
- // other except the arguments of a Skolem term, so that no equation that could be instantiated to
88
- // a cycle is deleted.
89
76
  const substOccur = (term: BlastTerm, other: BlastTerm) => {
90
77
  const vars = term.kind === "Skolem" ? term.args : [];
91
78
  const occEq = (current: BlastTerm): boolean => blastAconv(term, current) || occ(current);
@@ -106,8 +93,6 @@ const substOccur = (term: BlastTerm, other: BlastTerm) => {
106
93
  return occEq(other);
107
94
  };
108
95
 
109
- // Takes apart an equality and orients it to eliminate a Skolem term or a free variable, or gives
110
- // undefined (DEST_EQ) if it has no substitutable side.
111
96
  const orientEquality = (state: BlastState, term: BlastTerm): [BlastTerm, BlastTerm] | undefined => {
112
97
  if (
113
98
  term.kind !== "App" ||
@@ -132,9 +117,6 @@ interface Substituted {
132
117
  readonly kept: readonly Formula[];
133
118
  }
134
119
 
135
- // Substitutes through the branch if the formula is an equality with a substitutable variable.
136
- // Moves the affected formulae and literals back to the safe formulae, but it is not clear where
137
- // they should go: this could make proofs fail.
138
120
  export const equalSubst = (
139
121
  state: BlastState,
140
122
  formula: BlastTerm,
@@ -184,10 +166,8 @@ export const equalSubst = (
184
166
  };
185
167
  };
186
168
 
187
- // Tries to unify complementary literals, giving the tactic that closes the branch.
188
169
  const eAssumeTac = (state: BlastState) => orElseGoal(eqAssumeTac, assumeTac(state.context.limits));
189
170
 
190
- // contr_tac: trying eq_contr_tac first increases the effort, slowing reconstruction.
191
171
  const eContrTac = (state: BlastState) =>
192
172
  thenGoal(ematchTac(state.context.limits, [state.context.data.notE]), eAssumeTac(state));
193
173
 
@@ -215,7 +195,6 @@ export const tryClose = (
215
195
  return undefined;
216
196
  };
217
197
 
218
- // Were there Skolem terms in the premise? Must not chase variables.
219
198
  const hasSkolem = (term: BlastTerm): boolean => {
220
199
  switch (term.kind) {
221
200
  case "Skolem":
@@ -229,12 +208,9 @@ const hasSkolem = (term: BlastTerm): boolean => {
229
208
  }
230
209
  };
231
210
 
232
- // Attaches the may-duplicate flag to new formulae: those with Skolem terms may be duplicated.
233
211
  export const joinMd = (md: boolean, terms: readonly BlastTerm[]): Formula[] =>
234
212
  terms.map((term) => ({ term, md: hasSkolem(term) || md }));
235
213
 
236
- // Whether any of the last count assignments of the trail below top occurs in vars or their
237
- // instantiations.
238
214
  const clashVar = (state: BlastState, vars: readonly BlastTerm[], count: number, top: number) => {
239
215
  if (vars.length === 0) return false;
240
216
  for (
@@ -249,9 +225,6 @@ const clashVar = (state: BlastState, vars: readonly BlastTerm[], count: number,
249
225
  return false;
250
226
  };
251
227
 
252
- // Deletes the choice points for goals the latest inference proved, provided no variable of the
253
- // next branch was updated. nbrs is the number of branches just before closing this one. Does not
254
- // prune at the very end, to allow backtracking over bad proofs.
255
228
  export const prune = (
256
229
  state: BlastState,
257
230
  nbrs: number,
@@ -275,8 +248,6 @@ export const prune = (
275
248
  export const nextVars = (brs: readonly Branch[]) =>
276
249
  brs.length === 0 ? [] : brs[0].vars.map((ref) => mkBlastVar(ref));
277
250
 
278
- // Adds the literal, handling *Goal* and detecting duplicates. A new *Goal* turns the other goals
279
- // into negations.
280
251
  export const addLit = (state: BlastState, term: BlastTerm, lits: readonly BlastTerm[]) => {
281
252
  const goal = destConstApp(term, GOAL_NAME);
282
253
  if (goal === undefined) return insTerm(term, lits);
@@ -297,10 +268,8 @@ export const addLit = (state: BlastState, term: BlastTerm, lits: readonly BlastT
297
268
  ];
298
269
  };
299
270
 
300
- // The penalty for a branching factor: log2 seems a little too severe.
301
271
  export const log4 = (count: number): number => (count < 4 ? 0 : 1 + log4(Math.floor(count / 4)));
302
272
 
303
- // Whether term might be an instance of pattern, to detect recursive rules such as transitivity.
304
273
  export const match = (state: BlastState, pattern: BlastTerm, term: BlastTerm): boolean => {
305
274
  if (pattern.kind === "Var") return true;
306
275
  if (pattern.kind === "Const" && term.kind === "Const") {