tla-ts 0.0.4-dev.4819fb7 → 0.0.4-dev.55f2117

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 (360) hide show
  1. package/README.md +37 -126
  2. package/dist/cli.cjs +1 -1
  3. package/dist/cli.js +1 -1
  4. package/dist/deciders.cjs +366 -0
  5. package/dist/deciders.js +366 -0
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.cts +33 -1
  8. package/dist/index.d.ts +33 -1
  9. package/dist/index.js +1 -1
  10. package/dist/parallel-worker.cjs +1 -4
  11. package/dist/parallel-worker.js +1 -4
  12. package/dist/prove-worker.cjs +9 -0
  13. package/dist/prove-worker.d.cts +9 -0
  14. package/dist/prove-worker.d.ts +9 -0
  15. package/dist/prove-worker.js +9 -0
  16. package/dist/prove.cjs +996 -0
  17. package/dist/prove.js +996 -0
  18. package/dist/run.cjs +45 -0
  19. package/dist/run.js +45 -0
  20. package/dist/tlapm.cjs +10 -0
  21. package/dist/tlapm.js +10 -0
  22. package/dist/transfer.cjs +38 -44
  23. package/dist/transfer.js +38 -44
  24. package/dist/worker.cjs +21 -0
  25. package/dist/worker.js +21 -0
  26. package/package.json +21 -12
  27. package/src/ast.ts +2 -2
  28. package/src/check.ts +8 -7
  29. package/src/{cli-options.ts → cli/options.ts} +1 -1
  30. package/src/{run-cli.ts → cli/run.ts} +302 -100
  31. package/src/cli.ts +1 -1
  32. package/src/codegen.ts +26 -7
  33. package/src/config.ts +2 -2
  34. package/src/environment.ts +9 -9
  35. package/src/errors.ts +89 -30
  36. package/src/evaluate.ts +58 -23
  37. package/src/index.ts +10 -0
  38. package/src/levels.ts +1 -1
  39. package/src/live-check.ts +1 -1
  40. package/src/liveness.ts +1 -1
  41. package/src/{obligation-action.ts → obligations/action.ts} +247 -69
  42. package/src/{obligation-anon.ts → obligations/anon.ts} +49 -47
  43. package/src/obligations/ctx.ts +64 -0
  44. package/src/{obligation-deref.ts → obligations/deref.ts} +51 -92
  45. package/src/{obligation-expression.ts → obligations/expression.ts} +117 -57
  46. package/src/{obligation-format.ts → obligations/format.ts} +7 -8
  47. package/src/{obligation-generate.ts → obligations/generate.ts} +170 -192
  48. package/src/{obligations.ts → obligations/index.ts} +32 -16
  49. package/src/{obligation-levels.ts → obligations/levels.ts} +26 -28
  50. package/src/{obligation-module.ts → obligations/module.ts} +113 -121
  51. package/src/obligations/pickle.ts +98 -0
  52. package/src/obligations/pragma.ts +189 -0
  53. package/src/{obligation-printer.ts → obligations/printer.ts} +22 -80
  54. package/src/{obligation-proof.ts → obligations/proof.ts} +7 -2
  55. package/src/{obligation-source.ts → obligations/source.ts} +154 -99
  56. package/src/obligations/temporal.ts +321 -0
  57. package/src/{obligation-tuples.ts → obligations/tuples.ts} +38 -54
  58. package/src/parallel-worker.ts +4 -20
  59. package/src/parallel.ts +13 -46
  60. package/src/parser.ts +1 -1
  61. package/src/{pcal-ast.ts → pcal/ast.ts} +2 -2
  62. package/src/{pcal-parse.ts → pcal/parse.ts} +3 -3
  63. package/src/{pcal-tokenize.ts → pcal/tokenize.ts} +2 -2
  64. package/src/{pcal-translate.ts → pcal/translate.ts} +2 -2
  65. package/src/{pcal-validate.ts → pcal/validate.ts} +6 -6
  66. package/src/prove/decide-pool.ts +95 -0
  67. package/src/prove/deciders.ts +33 -0
  68. package/src/prove/first-order.ts +78 -0
  69. package/src/prove/isabelle/LICENSE +36 -0
  70. package/src/prove/isabelle/LICENSE-tlapm +26 -0
  71. package/src/prove/isabelle/decide.ts +47 -0
  72. package/src/prove/isabelle/encode.ts +446 -0
  73. package/src/prove/isabelle/isar/inner-syntax.ts +579 -0
  74. package/src/prove/isabelle/isar/method.ts +367 -0
  75. package/src/prove/isabelle/isar/proof.ts +28 -0
  76. package/src/prove/isabelle/isar/statement.ts +57 -0
  77. package/src/prove/isabelle/isar/theory.ts +192 -0
  78. package/src/prove/isabelle/isar/type-check.ts +278 -0
  79. package/src/prove/isabelle/provers/blast/blast.ts +258 -0
  80. package/src/prove/isabelle/provers/blast/branch.ts +322 -0
  81. package/src/prove/isabelle/provers/blast/prove.ts +347 -0
  82. package/src/prove/isabelle/provers/blast/rules.ts +330 -0
  83. package/src/prove/isabelle/provers/blast/state.ts +180 -0
  84. package/src/prove/isabelle/provers/blast/term.ts +546 -0
  85. package/src/prove/isabelle/provers/clasimp.ts +150 -0
  86. package/src/prove/isabelle/provers/classical.ts +389 -0
  87. package/src/prove/isabelle/provers/hypsubst.ts +433 -0
  88. package/src/prove/isabelle/pure/bicompose.ts +174 -0
  89. package/src/prove/isabelle/pure/consts.ts +32 -0
  90. package/src/prove/isabelle/pure/conv.ts +79 -0
  91. package/src/prove/isabelle/pure/drule.ts +264 -0
  92. package/src/prove/isabelle/pure/envir.ts +331 -0
  93. package/src/prove/isabelle/pure/goal.ts +53 -0
  94. package/src/prove/isabelle/pure/interrupt.ts +16 -0
  95. package/src/prove/isabelle/pure/list.ts +12 -0
  96. package/src/prove/isabelle/pure/logic.ts +330 -0
  97. package/src/prove/isabelle/pure/name.ts +98 -0
  98. package/src/prove/isabelle/pure/net.ts +215 -0
  99. package/src/prove/isabelle/pure/object-logic.ts +41 -0
  100. package/src/prove/isabelle/pure/pattern.ts +631 -0
  101. package/src/prove/isabelle/pure/raw-simplifier.ts +338 -0
  102. package/src/prove/isabelle/pure/rewriter.ts +602 -0
  103. package/src/prove/isabelle/pure/search.ts +68 -0
  104. package/src/prove/isabelle/pure/seq.ts +133 -0
  105. package/src/prove/isabelle/pure/simplifier.ts +106 -0
  106. package/src/prove/isabelle/pure/table.ts +201 -0
  107. package/src/prove/isabelle/pure/tactic.ts +168 -0
  108. package/src/prove/isabelle/pure/tactical.ts +264 -0
  109. package/src/prove/isabelle/pure/term-ord.ts +105 -0
  110. package/src/prove/isabelle/pure/term.ts +688 -0
  111. package/src/prove/isabelle/pure/thm.ts +783 -0
  112. package/src/prove/isabelle/pure/type.ts +121 -0
  113. package/src/prove/isabelle/pure/unify.ts +753 -0
  114. package/src/prove/isabelle/pure/variable.ts +25 -0
  115. package/src/prove/isabelle/tla/classical-setup.ts +101 -0
  116. package/src/prove/isabelle/tla/context.ts +74 -0
  117. package/src/prove/isabelle/tla/logic-data.ts +5 -0
  118. package/src/prove/isabelle/tla/logic.ts +215 -0
  119. package/src/prove/isabelle/tla/simpdata.ts +241 -0
  120. package/src/prove/isabelle/tools/intuitionistic.ts +132 -0
  121. package/src/prove/ocaml.ts +22 -0
  122. package/src/prove/prep/action.ts +508 -0
  123. package/src/prove/prep/defs.ts +33 -0
  124. package/src/prove/prep/elab.ts +156 -0
  125. package/src/prove/prep/enabled-axioms.ts +189 -0
  126. package/src/prove/prep/enabled.ts +43 -0
  127. package/src/prove/prep/fingerprint.ts +388 -0
  128. package/src/prove/prep/flatten.ts +70 -0
  129. package/src/prove/prep/level-comparison.ts +529 -0
  130. package/src/prove/prep/md5.ts +67 -0
  131. package/src/prove/prep/pragma.ts +221 -0
  132. package/src/prove/prep/trivial.ts +22 -0
  133. package/src/prove/prove-worker.ts +22 -0
  134. package/src/prove/prove.ts +498 -0
  135. package/src/prove/ptl/decide.ts +68 -0
  136. package/src/prove/ptl/encode.ts +255 -0
  137. package/src/prove/ptl/sat.ts +151 -0
  138. package/src/prove/ptl/tableau.ts +276 -0
  139. package/src/prove/smt/axiomatize.ts +69 -0
  140. package/src/prove/smt/axioms.ts +209 -0
  141. package/src/prove/smt/context.ts +108 -0
  142. package/src/prove/smt/data.ts +636 -0
  143. package/src/prove/smt/encode.ts +164 -0
  144. package/src/prove/smt/extensionality.ts +65 -0
  145. package/src/prove/smt/flatten.ts +112 -0
  146. package/src/prove/smt/format.ts +154 -0
  147. package/src/prove/smt/instances.ts +181 -0
  148. package/src/prove/smt/rewrite.ts +772 -0
  149. package/src/prove/smt/simplify.ts +57 -0
  150. package/src/prove/smt/solver/act-cache.ts +265 -0
  151. package/src/prove/smt/solver/arith-rewriter.ts +962 -0
  152. package/src/prove/smt/solver/array.ts +22 -0
  153. package/src/prove/smt/solver/asserted-formulas.ts +469 -0
  154. package/src/prove/smt/solver/ast-lt.ts +157 -0
  155. package/src/prove/smt/solver/ast-util.ts +91 -0
  156. package/src/prove/smt/solver/ast.ts +1315 -0
  157. package/src/prove/smt/solver/auf-solver.ts +572 -0
  158. package/src/prove/smt/solver/case-split-queue.ts +178 -0
  159. package/src/prove/smt/solver/cg-table.ts +175 -0
  160. package/src/prove/smt/solver/clause.ts +276 -0
  161. package/src/prove/smt/solver/conflict-resolution.ts +343 -0
  162. package/src/prove/smt/solver/context.ts +1292 -0
  163. package/src/prove/smt/solver/ctx-simplify.ts +334 -0
  164. package/src/prove/smt/solver/der.ts +224 -0
  165. package/src/prove/smt/solver/dyn-ack.ts +141 -0
  166. package/src/prove/smt/solver/e-matching.ts +659 -0
  167. package/src/prove/smt/solver/enode.ts +259 -0
  168. package/src/prove/smt/solver/expr-ref.ts +21 -0
  169. package/src/prove/smt/solver/expr-safe-replace.ts +172 -0
  170. package/src/prove/smt/solver/fingerprints.ts +92 -0
  171. package/src/prove/smt/solver/flat-literals.ts +51 -0
  172. package/src/prove/smt/solver/goal.ts +138 -0
  173. package/src/prove/smt/solver/hash.ts +173 -0
  174. package/src/prove/smt/solver/hashtable.ts +166 -0
  175. package/src/prove/smt/solver/internalizer.ts +1381 -0
  176. package/src/prove/smt/solver/lbool.ts +5 -0
  177. package/src/prove/smt/solver/literal.ts +24 -0
  178. package/src/prove/smt/solver/lp/bound-propagator.ts +391 -0
  179. package/src/prove/smt/solver/lp/constraints.ts +78 -0
  180. package/src/prove/smt/solver/lp/containers.ts +296 -0
  181. package/src/prove/smt/solver/lp/core-solver.ts +504 -0
  182. package/src/prove/smt/solver/lp/cross-nested.ts +224 -0
  183. package/src/prove/smt/solver/lp/dep-intervals.ts +642 -0
  184. package/src/prove/smt/solver/lp/dependency.ts +51 -0
  185. package/src/prove/smt/solver/lp/dioph-eq.ts +1181 -0
  186. package/src/prove/smt/solver/lp/explanation.ts +46 -0
  187. package/src/prove/smt/solver/lp/gomory.ts +255 -0
  188. package/src/prove/smt/solver/lp/hnf-cutter.ts +125 -0
  189. package/src/prove/smt/solver/lp/hnf.ts +281 -0
  190. package/src/prove/smt/solver/lp/int-cube.ts +295 -0
  191. package/src/prove/smt/solver/lp/int-solver.ts +514 -0
  192. package/src/prove/smt/solver/lp/lar-solver.ts +816 -0
  193. package/src/prove/smt/solver/lp/lar-term.ts +62 -0
  194. package/src/prove/smt/solver/lp/lp-settings.ts +91 -0
  195. package/src/prove/smt/solver/lp/maximize-term.ts +347 -0
  196. package/src/prove/smt/solver/lp/nex-creator.ts +381 -0
  197. package/src/prove/smt/solver/lp/nex.ts +120 -0
  198. package/src/prove/smt/solver/lp/nla-backoff.ts +43 -0
  199. package/src/prove/smt/solver/lp/nla-basics.ts +398 -0
  200. package/src/prove/smt/solver/lp/nla-core.ts +968 -0
  201. package/src/prove/smt/solver/lp/nla-divisions.ts +332 -0
  202. package/src/prove/smt/solver/lp/nla-emonics.ts +373 -0
  203. package/src/prove/smt/solver/lp/nla-factorization.ts +30 -0
  204. package/src/prove/smt/solver/lp/nla-grobner.ts +904 -0
  205. package/src/prove/smt/solver/lp/nla-horner.ts +126 -0
  206. package/src/prove/smt/solver/lp/nla-intervals.ts +265 -0
  207. package/src/prove/smt/solver/lp/nla-monomial-bounds.ts +715 -0
  208. package/src/prove/smt/solver/lp/nla-monotone.ts +59 -0
  209. package/src/prove/smt/solver/lp/nla-order.ts +307 -0
  210. package/src/prove/smt/solver/lp/nla-patcher.ts +112 -0
  211. package/src/prove/smt/solver/lp/nla-tangents.ts +251 -0
  212. package/src/prove/smt/solver/lp/nla-throttle.ts +85 -0
  213. package/src/prove/smt/solver/lp/nla-types.ts +124 -0
  214. package/src/prove/smt/solver/lp/nla-var-eqs.ts +141 -0
  215. package/src/prove/smt/solver/lp/nra-solver.ts +440 -0
  216. package/src/prove/smt/solver/lp/numeric-pair.ts +65 -0
  217. package/src/prove/smt/solver/lp/pdd-interval.ts +31 -0
  218. package/src/prove/smt/solver/lp/pdd-simplifier.ts +184 -0
  219. package/src/prove/smt/solver/lp/pdd-solver.ts +408 -0
  220. package/src/prove/smt/solver/lp/pdd.ts +971 -0
  221. package/src/prove/smt/solver/lp/random-updater.ts +138 -0
  222. package/src/prove/smt/solver/lp/static-matrix.ts +246 -0
  223. package/src/prove/smt/solver/lp/union-find.ts +96 -0
  224. package/src/prove/smt/solver/mam-compiler.ts +847 -0
  225. package/src/prove/smt/solver/mam-interpreter.ts +400 -0
  226. package/src/prove/smt/solver/maximize-ac-sharing.ts +118 -0
  227. package/src/prove/smt/solver/model-checker.ts +347 -0
  228. package/src/prove/smt/solver/model-evaluator.ts +262 -0
  229. package/src/prove/smt/solver/model-finder.ts +155 -0
  230. package/src/prove/smt/solver/model-generator.ts +97 -0
  231. package/src/prove/smt/solver/model-macro-solver.ts +728 -0
  232. package/src/prove/smt/solver/nlsat/algebraic.ts +1161 -0
  233. package/src/prove/smt/solver/nlsat/atoms.ts +238 -0
  234. package/src/prove/smt/solver/nlsat/evaluator.ts +303 -0
  235. package/src/prove/smt/solver/nlsat/explain.ts +607 -0
  236. package/src/prove/smt/solver/nlsat/interval-set.ts +351 -0
  237. package/src/prove/smt/solver/nlsat/levelwise.ts +737 -0
  238. package/src/prove/smt/solver/nlsat/mpbq.ts +161 -0
  239. package/src/prove/smt/solver/nlsat/polynomial.ts +1722 -0
  240. package/src/prove/smt/solver/nlsat/solver.ts +911 -0
  241. package/src/prove/smt/solver/nlsat/types.ts +43 -0
  242. package/src/prove/smt/solver/nlsat/upolynomial-factorization.ts +648 -0
  243. package/src/prove/smt/solver/nlsat/upolynomial.ts +996 -0
  244. package/src/prove/smt/solver/nnf.ts +469 -0
  245. package/src/prove/smt/solver/pattern-inference.ts +351 -0
  246. package/src/prove/smt/solver/poly-rewriter.ts +477 -0
  247. package/src/prove/smt/solver/propagate-values.ts +83 -0
  248. package/src/prove/smt/solver/proto-model.ts +551 -0
  249. package/src/prove/smt/solver/pull-quant.ts +139 -0
  250. package/src/prove/smt/solver/qe-lite-der.ts +526 -0
  251. package/src/prove/smt/solver/qe-lite-fm.ts +576 -0
  252. package/src/prove/smt/solver/qe-lite.ts +381 -0
  253. package/src/prove/smt/solver/qi-queue.ts +362 -0
  254. package/src/prove/smt/solver/quant-tactics.ts +117 -0
  255. package/src/prove/smt/solver/quantifier-analyzer.ts +562 -0
  256. package/src/prove/smt/solver/quantifier-manager.ts +186 -0
  257. package/src/prove/smt/solver/random-gen.ts +10 -0
  258. package/src/prove/smt/solver/rational.ts +165 -0
  259. package/src/prove/smt/solver/ref-vector.ts +62 -0
  260. package/src/prove/smt/solver/relevancy.ts +247 -0
  261. package/src/prove/smt/solver/rewriter-tpl.ts +1159 -0
  262. package/src/prove/smt/solver/rewriter.ts +843 -0
  263. package/src/prove/smt/solver/rlimit.ts +79 -0
  264. package/src/prove/smt/solver/smtlib-parser.ts +526 -0
  265. package/src/prove/smt/solver/solver.ts +71 -0
  266. package/src/prove/smt/solver/sort.ts +35 -0
  267. package/src/prove/smt/solver/sticky-generations.ts +69 -0
  268. package/src/prove/smt/solver/theory-lra-axioms.ts +340 -0
  269. package/src/prove/smt/solver/theory-lra-bounds.ts +226 -0
  270. package/src/prove/smt/solver/theory-lra-final-check.ts +252 -0
  271. package/src/prove/smt/solver/theory-lra-internalize.ts +476 -0
  272. package/src/prove/smt/solver/theory-lra-model.ts +243 -0
  273. package/src/prove/smt/solver/theory-lra-propagate.ts +405 -0
  274. package/src/prove/smt/solver/theory-lra-state.ts +43 -0
  275. package/src/prove/smt/solver/theory-lra.ts +56 -0
  276. package/src/prove/smt/solver/var-subst.ts +258 -0
  277. package/src/prove/smt/solver/z3-license.txt +10 -0
  278. package/src/prove/smt/table.ts +170 -0
  279. package/src/prove/tlapm/cache.ts +236 -0
  280. package/src/prove/tlapm/ocaml-marshal.ts +166 -0
  281. package/src/prove/tlapm/tlapm.ts +96 -0
  282. package/src/prove/tlaps-module.ts +510 -0
  283. package/src/prove/verdict.ts +18 -0
  284. package/src/prove/zenon/LICENSE +32 -0
  285. package/src/prove/zenon/check/check.ts +105 -0
  286. package/src/prove/zenon/check/definitions.ts +144 -0
  287. package/src/prove/zenon/check/equality.ts +182 -0
  288. package/src/prove/zenon/check/functions.ts +62 -0
  289. package/src/prove/zenon/check/keys.ts +125 -0
  290. package/src/prove/zenon/check/propositional.ts +104 -0
  291. package/src/prove/zenon/check/records.ts +188 -0
  292. package/src/prove/zenon/check/relations.ts +121 -0
  293. package/src/prove/zenon/check/rewrites.ts +224 -0
  294. package/src/prove/zenon/check/sets.ts +302 -0
  295. package/src/prove/zenon/check/terms.ts +127 -0
  296. package/src/prove/zenon/check/tla.ts +126 -0
  297. package/src/prove/zenon/decide.ts +113 -0
  298. package/src/prove/zenon/encode.ts +379 -0
  299. package/src/prove/zenon/eqrel.ts +300 -0
  300. package/src/prove/zenon/equality-rules.ts +435 -0
  301. package/src/prove/zenon/expr.ts +551 -0
  302. package/src/prove/zenon/index-table.ts +350 -0
  303. package/src/prove/zenon/isar-case.ts +513 -0
  304. package/src/prove/zenon/isar.ts +1249 -0
  305. package/src/prove/zenon/limits.ts +15 -0
  306. package/src/prove/zenon/llproof.ts +173 -0
  307. package/src/prove/zenon/mltoll.ts +1566 -0
  308. package/src/prove/zenon/node.ts +297 -0
  309. package/src/prove/zenon/ocaml.ts +169 -0
  310. package/src/prove/zenon/parse.ts +247 -0
  311. package/src/prove/zenon/phrase.ts +191 -0
  312. package/src/prove/zenon/proof.ts +198 -0
  313. package/src/prove/zenon/propositional-rules.ts +387 -0
  314. package/src/prove/zenon/rules.ts +94 -0
  315. package/src/prove/zenon/search.ts +288 -0
  316. package/src/prove/zenon/tla/functions.ts +151 -0
  317. package/src/prove/zenon/tla/llproof.ts +480 -0
  318. package/src/prove/zenon/tla/records.ts +225 -0
  319. package/src/prove/zenon/tla/rewrites.ts +447 -0
  320. package/src/prove/zenon/tla/sets.ts +304 -0
  321. package/src/prove/zenon/tla/terms.ts +162 -0
  322. package/src/prove/zenon/tla/tla.ts +506 -0
  323. package/src/randomization.ts +1 -1
  324. package/src/resolve.ts +1 -1
  325. package/src/runtime.ts +2 -2
  326. package/src/{sany-builtins.ts → sany/builtins.ts} +1 -1
  327. package/src/{sany-generator.ts → sany/generator.ts} +14 -14
  328. package/src/{sany-levels.ts → sany/levels.ts} +2 -2
  329. package/src/{sany-lexer.ts → sany/lexer.ts} +1 -1
  330. package/src/{sany-linter.ts → sany/linter.ts} +1 -1
  331. package/src/{sany-modules.ts → sany/modules.ts} +2 -2
  332. package/src/{sany-parse-error.ts → sany/parse-error.ts} +2 -2
  333. package/src/{sany-report.ts → sany/report.ts} +15 -15
  334. package/src/{sany-selectors.ts → sany/selectors.ts} +3 -3
  335. package/src/{sany-source.ts → sany/source.ts} +6 -6
  336. package/src/{sany-xml.ts → sany/xml.ts} +5 -5
  337. package/src/spec-description.ts +1 -1
  338. package/src/{standard-levels.ts → standard/levels.ts} +1 -1
  339. package/src/{standard-modules.ts → standard/modules.ts} +17 -14
  340. package/src/{standard-ranges.ts → standard/ranges.ts} +1 -1
  341. package/src/state-graph.ts +1 -1
  342. package/src/successors.ts +25 -6
  343. package/src/symmetry.ts +1 -1
  344. package/src/{tlc-messages.ts → tlc/messages.ts} +2 -2
  345. package/src/{tlc-order.ts → tlc/order.ts} +7 -7
  346. package/src/{tlc-random.ts → tlc/random.ts} +58 -35
  347. package/src/{tlc-replay.ts → tlc/replay.ts} +5 -5
  348. package/src/{tlc-module.ts → tlc/tlc-operators.ts} +9 -9
  349. package/src/{tlc-ext.ts → tlc/tlcext-operators.ts} +14 -8
  350. package/src/{tlc-version.ts → tlc/version.ts} +8 -7
  351. package/src/values.ts +81 -36
  352. package/src/worker.ts +65 -0
  353. package/dist/parallel.cjs +0 -12
  354. package/dist/parallel.js +0 -12
  355. package/dist/run-cli.cjs +0 -55
  356. package/dist/run-cli.js +0 -55
  357. package/src/value-sources.ts +0 -29
  358. /package/src/{sany-nodes.ts → sany/nodes.ts} +0 -0
  359. /package/src/{tlc-modules.ts → tlc/jar-data.ts} +0 -0
  360. /package/src/{tlc-summary.ts → tlc/summary.ts} +0 -0
@@ -0,0 +1,98 @@
1
+ // Tla_parser.pickle: renames an identifier that some backend would reject.
2
+
3
+ import { TlapmBugError } from "../errors";
4
+
5
+ const CHARACTER_NAMES: Record<string, string> = {
6
+ "!": "excl_",
7
+ "#": "hash_",
8
+ $: "doll_",
9
+ "%": "perc_",
10
+ "&": "ampe_",
11
+ "'": "quot_",
12
+ "(": "lpar_",
13
+ ")": "rpar_",
14
+ "*": "star_",
15
+ "+": "plus_",
16
+ "-": "dash_",
17
+ ".": "peri_",
18
+ "/": "slas_",
19
+ ":": "colo_",
20
+ "<": "less_",
21
+ "=": "equa_",
22
+ ">": "more_",
23
+ "?": "ques_",
24
+ "@": "atsi_",
25
+ "[": "lbrk_",
26
+ "\\": "bksl_",
27
+ "]": "rbrk_",
28
+ "^": "care_",
29
+ _: "unde_",
30
+ "|": "vert_",
31
+ "~": "tild_",
32
+ };
33
+
34
+ // isabelle_tlaplus_keys, then Isabelle_keywords.v, then other_keys.
35
+ const FORBIDDEN = new Set(
36
+ [
37
+ "All Append Bijections Case CaseArm CaseOther Char Choice EnumFuncSet Ex Fcn FuncSet INTER Id",
38
+ "Image Injections Injective InjectiveOn Int Inverse Len Let Monotonic Nat Nibble Not PeanoAxioms",
39
+ "Pred Product Range Seq String Succ Surjections Surjective TYPE Trueprop Zero abs addElt addnat",
40
+ "all antisymmetric any aprop arbitrary args arith_add asms bAll bChoice bEx boolify c cap cargs",
41
+ "case_arm case_arms cases_conj cases_equal cases_forall cases_implies char cidts classes cond",
42
+ "conj conjunction converse cs cup default diff diffnat disj div divmodNat divmod_rel domrng",
43
+ "domrngs dummy dummy_pattern dvd emptySeq eq equivalence except extend fapply float_const",
44
+ "float_token fun geq gfp greater id idt idts iff imp in index infinity irreflexive isAFcn isASeq",
45
+ "isBool isNeg isPos itself leq less letbind letbinds lfp logic longid minus mod mult multnat",
46
+ "natInterval num num_const oneArg prod prop psubset psupset pttrn pttrns reflexive rel_comp",
47
+ "rel_domain rel_image rel_range setOfAll setOfPairs setminus sgn sort sort_constraint struct",
48
+ "subsetOf subseteq symmetric term tid tpl transitive tvar type types upair upto var xcpt xnum",
49
+ "xstr",
50
+ "ML ML_command ML_export ML_file ML_file_debug ML_file_no_debug ML_prf ML_val ROOTS_file",
51
+ "SML_export SML_file SML_file_debug SML_file_no_debug SML_import abbreviation abbrevs alias also",
52
+ "and apply apply_end assume assumes attribute_setup axiomatization back begin bibtex_file binder",
53
+ "bundle by case chapter class class_deps code_datatype compile_generated_files consider",
54
+ "constrains consts context corollary declaration declare default_sort defer define defines",
55
+ "definition done end experiment export_files export_generated_files export_prefix external_file",
56
+ "external_files extract extract_type finally find_consts find_theorems fix fixes for from",
57
+ "full_prf generate_file global_interpretation guess have help hence hide_class hide_const",
58
+ "hide_fact hide_type if imports in include includes including infix infixl infixr instance",
59
+ "instantiation interpret interpretation is judgment keywords lemma lemmas let local_setup locale",
60
+ "locale_deps method_setup moreover named_theorems next no_notation no_syntax no_translations",
61
+ "no_type_notation nonterminal notation note notepad notes obtain obtains oops open opening oracle",
62
+ "output overloaded overloading paragraph parse_ast_translation parse_translation pervasive prefer",
63
+ "premises presume prf print_ML_antiquotations print_abbrevs print_antiquotations",
64
+ "print_ast_translation print_attributes print_bundles print_cases print_classes print_codesetup",
65
+ "print_commands print_context print_definitions print_defn_rules print_facts print_interps",
66
+ "print_locale print_locales print_methods print_options print_rules print_simpset print_state",
67
+ "print_statement print_syntax print_term_bindings print_theorems print_theory print_trans_rules",
68
+ "print_translation private proof prop proposition qed qualified realizability realizers rewrites",
69
+ "schematic_goal section setup show shows simproc_setup sorry structure subclass subgoal sublocale",
70
+ "subparagraph subsection subsubsection supply syntax syntax_declaration term text text_raw then",
71
+ "theorem theory thm thm_deps thm_oracles thus thy_deps translations txt typ type_alias",
72
+ "type_notation type_synonym typed_print_translation typedecl ultimately unbundle unchecked",
73
+ "unfolding unused_thms using welcome when where with write",
74
+ "O max status",
75
+ ]
76
+ .join(" ")
77
+ .split(" "),
78
+ );
79
+
80
+ const isLetter = (character: string) => /^[A-Za-z]$/.test(character);
81
+
82
+ const getCharacterName = (character: string) => {
83
+ if (/^[A-Za-z0-9]$/.test(character)) return undefined;
84
+ const name = CHARACTER_NAMES[character];
85
+ if (name === undefined) throw new TlapmBugError();
86
+ return name;
87
+ };
88
+
89
+ export const pickle = (name: string) => {
90
+ const characters = [...name];
91
+ const isPlain =
92
+ isLetter(characters[0] ?? "") &&
93
+ isLetter(characters.at(-1) ?? "") &&
94
+ characters.every((character) => getCharacterName(character) === undefined) &&
95
+ !FORBIDDEN.has(name);
96
+ if (isPlain) return name;
97
+ return `a_${characters.map((character) => getCharacterName(character) ?? character).join("")}a`;
98
+ };
@@ -0,0 +1,189 @@
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.
3
+
4
+ type PragmaValue =
5
+ | { kind: "Default" }
6
+ | { kind: "String"; value: string }
7
+ | { kind: "Float"; value: number };
8
+
9
+ export interface PragmaSetting {
10
+ hint: string;
11
+ value: PragmaValue;
12
+ }
13
+
14
+ interface Position {
15
+ line: number;
16
+ column: number;
17
+ }
18
+
19
+ type Token =
20
+ | { kind: "Ident"; text: string }
21
+ | { kind: "String"; text: string }
22
+ | { kind: "Number"; text: string }
23
+ | { kind: "Punct"; text: string };
24
+
25
+ const PUNCTUATION = ["(", ")", ";", ":", "@", ","];
26
+
27
+ const isBlank = (character: string | undefined) =>
28
+ character === " " || character === "\r" || character === "\t";
29
+
30
+ // The tokens of the pragma that starts at position, after blanks and line ends.
31
+ const tokenizePragma = (lines: string[], start: Position) => {
32
+ const position = { ...start };
33
+ const skipBlanks = () => {
34
+ while (position.line < lines.length) {
35
+ const line = lines[position.line];
36
+ while (isBlank(line[position.column])) position.column++;
37
+ if (position.column < line.length) return;
38
+ position.line++;
39
+ position.column = 0;
40
+ }
41
+ };
42
+ skipBlanks();
43
+ if (!(lines[position.line] ?? "").startsWith("(*{", position.column)) return undefined;
44
+ position.column += 3;
45
+ const tokens: Token[] = [];
46
+ for (skipBlanks(); position.line < lines.length; skipBlanks()) {
47
+ const rest = lines[position.line].slice(position.column);
48
+ if (rest.startsWith("}*)")) return tokens;
49
+ const match =
50
+ /^[A-Za-z_][A-Za-z0-9_]*/.exec(rest) ??
51
+ /^\d+(\.\d+)?/.exec(rest) ??
52
+ /^"(\\.|[^"\\])*"/.exec(rest);
53
+ if (match) {
54
+ const text = match[0];
55
+ tokens.push(
56
+ text.startsWith('"')
57
+ ? { kind: "String", text: JSON.parse(text) }
58
+ : /^\d/.test(text)
59
+ ? { kind: "Number", text }
60
+ : { kind: "Ident", text },
61
+ );
62
+ position.column += text.length;
63
+ continue;
64
+ }
65
+ if (!PUNCTUATION.includes(rest[0])) return undefined;
66
+ tokens.push({ kind: "Punct", text: rest[0] });
67
+ position.column++;
68
+ }
69
+ return undefined;
70
+ };
71
+
72
+ const isPunct = (token: Token | undefined, text: string) =>
73
+ token?.kind === "Punct" && token.text === text;
74
+
75
+ const getValue = (token: Token | undefined): PragmaValue | undefined => {
76
+ if (token?.kind === "String") return { kind: "String", value: token.text };
77
+ if (token?.kind === "Number") return { kind: "Float", value: Number.parseFloat(token.text) };
78
+ return isPunct(token, "@") ? { kind: "Default" } : undefined;
79
+ };
80
+
81
+ // The methods of Method_prs's old pragma syntax, by the name Method.prover_meth_of_tac gives them.
82
+ const OLD_METHODS = new Map([
83
+ ["smt", "smt"],
84
+ ["cvc3", "cvc4"],
85
+ ["yices", "yices"],
86
+ ["z3", "z3"],
87
+ ["cooper", "cooper"],
88
+ ["presburger", "cooper"],
89
+ ["fail", "fail"],
90
+ ["smt2lib", "smt"],
91
+ ["smt2z3", "z3"],
92
+ ["smt3", "smt"],
93
+ ["z33", "z3"],
94
+ ["cvc33", "cvc4"],
95
+ ["yices3", "yices"],
96
+ ["verit", "verit"],
97
+ ["zipper", "zipper"],
98
+ ["spass", "spass"],
99
+ ["tptp", "tptp"],
100
+ ["ls4", "ls4"],
101
+ ["expandenabled", "expandenabled"],
102
+ ["expandcdot", "expandcdot"],
103
+ ["autouse", "autouse"],
104
+ ["lambdify", "lambdify"],
105
+ ["enabledaxioms", "enabledaxioms"],
106
+ ["levelcomparison", "levelcomparison"],
107
+ ["trivial", "trivial"],
108
+ ]);
109
+
110
+ // An old-style method, with the tactic an isabelle method takes and the timeout in seconds an
111
+ // isabelle or zenon method may take.
112
+ export interface OldMethod {
113
+ name: string;
114
+ tactic?: string;
115
+ timeout?: number;
116
+ }
117
+
118
+ // Method_prs.read_method: the (*{ by (zenon) }*) after a BY, OBVIOUS, proof step, theorem, or
119
+ // axiom, which names one method, isabelle with a tactic, or zenon with a timeout and a fallback.
120
+ export const readOldMethod = (lines: string[], start: Position) => {
121
+ const tokens = tokenizePragma(lines, start);
122
+ if (!tokens) return undefined;
123
+ let index = 0;
124
+ const readTimeout = () => {
125
+ const token = tokens[index];
126
+ if (token?.kind !== "Number") return {};
127
+ index++;
128
+ return { timeout: Number.parseFloat(token.text) };
129
+ };
130
+ const readMethod = (): OldMethod | undefined => {
131
+ if (!isPunct(tokens[index], "(")) return undefined;
132
+ index++;
133
+ const name = tokens[index++];
134
+ if (name?.kind !== "Ident") return undefined;
135
+ const method = ((): OldMethod | undefined => {
136
+ if (name.text === "isabelle") {
137
+ const tactic = tokens[index];
138
+ if (tactic?.kind !== "String") return undefined;
139
+ index++;
140
+ return { name: name.text, tactic: tactic.text, ...readTimeout() };
141
+ }
142
+ if (name.text === "zenon") {
143
+ const timeout = readTimeout();
144
+ if (isPunct(tokens[index], "(") && !readMethod()) return undefined;
145
+ return { name: name.text, ...timeout };
146
+ }
147
+ const known = OLD_METHODS.get(name.text);
148
+ return known === undefined ? undefined : { name: known };
149
+ })();
150
+ if (!method || !isPunct(tokens[index], ")")) return undefined;
151
+ index++;
152
+ return method;
153
+ };
154
+ if (tokens[index]?.kind !== "Ident" || tokens[index++].text !== "by") return undefined;
155
+ const method = readMethod();
156
+ return index === tokens.length ? method : undefined;
157
+ };
158
+
159
+ // read_new_method: by (hint: value; ...), repeated, where a value is a string, a number, or @ for
160
+ // the argument the definition is applied to.
161
+ export const readNewMethod = (lines: string[], start: Position) => {
162
+ const tokens = tokenizePragma(lines, start);
163
+ if (!tokens) return undefined;
164
+ let index = 0;
165
+ const groups: PragmaSetting[][] = [];
166
+ while (index < tokens.length) {
167
+ const keyword = tokens[index++];
168
+ if (keyword.kind !== "Ident" || (keyword.text !== "by" && keyword.text !== "set")) {
169
+ return undefined;
170
+ }
171
+ if (!isPunct(tokens[index], "(")) return undefined;
172
+ index++;
173
+ const settings: PragmaSetting[] = [];
174
+ for (;;) {
175
+ const hint = tokens[index++];
176
+ if (hint?.kind !== "Ident" || !isPunct(tokens[index], ":")) return undefined;
177
+ index++;
178
+ const value = getValue(tokens[index++]);
179
+ if (!value) return undefined;
180
+ settings.push({ hint: hint.text, value });
181
+ if (isPunct(tokens[index], ")")) break;
182
+ if (!isPunct(tokens[index], ";")) return undefined;
183
+ index++;
184
+ }
185
+ index++;
186
+ groups.push(settings);
187
+ }
188
+ return groups;
189
+ };
@@ -1,7 +1,7 @@
1
1
  // A port of tlapm's obligation printer: E_fmt with Fmtutil's minimal parenthesization, the
2
2
  // operator table in Optable, and the identifier renaming in Ctx.
3
3
 
4
- import { TlaProofError } from "./errors";
4
+ import { TlaProofError } from "../errors";
5
5
  import {
6
6
  getHypName,
7
7
  type Bound,
@@ -13,8 +13,9 @@ import {
13
13
  type Selector,
14
14
  type Sequent,
15
15
  type Shape,
16
- } from "./obligation-expression";
17
- import { format, formatDelimited, renderDoc, text, type Doc } from "./obligation-format";
16
+ } from "./expression";
17
+ import { createContext, getBoundName, popNames, pushName, withNames } from "./ctx";
18
+ import { format, formatDelimited, renderDoc, text, type Doc } from "./format";
18
19
 
19
20
  export type Fixity = "Nonfix" | "Prefix" | "Postfix" | "InfixLeft" | "InfixNon" | "InfixRight";
20
21
 
@@ -189,59 +190,6 @@ const getStandardForm = (builtin: Builtin): Operator => {
189
190
  return name ? lookupOperator(name) : getNonfix(builtin);
190
191
  };
191
192
 
192
- interface Ident {
193
- rep: string;
194
- salt: number;
195
- }
196
-
197
- const getIdentName = (ident: Ident) =>
198
- ident.salt === 0 ? ident.rep : `${ident.rep}_${ident.salt}`;
199
-
200
- // Ctx as a mutable stack: printing binds and unbinds names in strict nesting order.
201
- interface Context {
202
- stack: Ident[];
203
- idents: Map<string, Ident[]>;
204
- defined: Map<string, number>;
205
- }
206
-
207
- const createContext = (): Context => ({ stack: [], idents: new Map(), defined: new Map() });
208
-
209
- const pushName = (context: Context, rep: string) => {
210
- const previous = context.idents.get(rep)?.at(-1);
211
- let ident: Ident = previous ? { rep, salt: previous.salt + 1 } : { rep, salt: 0 };
212
- while (context.defined.has(getIdentName(ident))) ident = { rep, salt: ident.salt + 1 };
213
- context.stack.push(ident);
214
- const idents = context.idents.get(rep);
215
- if (idents) idents.push(ident);
216
- else context.idents.set(rep, [ident]);
217
- const key = getIdentName(ident);
218
- context.defined.set(key, (context.defined.get(key) ?? 0) + 1);
219
- return key;
220
- };
221
-
222
- const popNames = (context: Context, count: number) => {
223
- for (let index = 0; index < count; index++) {
224
- const ident = context.stack.pop();
225
- if (!ident) return;
226
- context.idents.get(ident.rep)?.pop();
227
- const key = getIdentName(ident);
228
- const remaining = (context.defined.get(key) ?? 1) - 1;
229
- if (remaining === 0) context.defined.delete(key);
230
- else context.defined.set(key, remaining);
231
- }
232
- };
233
-
234
- const withNames = <Result>(
235
- context: Context,
236
- names: string[],
237
- body: (idents: string[]) => Result,
238
- ) => {
239
- const idents = names.map((name) => pushName(context, name));
240
- const result = body(idents);
241
- popNames(context, names.length);
242
- return result;
243
- };
244
-
245
193
  type Assoc = "Left" | "Non" | "Right";
246
194
 
247
195
  type Minimal =
@@ -419,9 +367,7 @@ const createPrinter = (hyps: Hyp[] = []) => {
419
367
  const getIndexName = (index: number) => {
420
368
  if (index < 0) return `#$$${Math.abs(index)}`;
421
369
  if (index === 0) return "#$0";
422
- if (index <= context.stack.length) {
423
- return getIdentName(context.stack[context.stack.length - index]);
424
- }
370
+ if (index <= context.stack.length) return getBoundName(context, index);
425
371
  const hyp = hyps[hyps.length - (index - context.stack.length)];
426
372
  if (hyp) return getHypName(hyp) ?? "??? FACT ???";
427
373
  return `#$${index}`;
@@ -532,8 +478,9 @@ const createPrinter = (hyps: Hyp[] = []) => {
532
478
  ),
533
479
  );
534
480
  case "List": {
535
- if (expression.bullet === "Refs" && expression.items.length === 0)
481
+ if (expression.bullet === "Refs" && expression.items.length === 0) {
536
482
  return atom(format("TRUE"));
483
+ }
537
484
  if (expression.bullet === "Refs" && expression.items.length === 1) {
538
485
  return formatExpr(expression.items[0]);
539
486
  }
@@ -657,23 +604,17 @@ const createPrinter = (hyps: Hyp[] = []) => {
657
604
  case "Tuple":
658
605
  return atom(format("@[<b2><<%a>>@]", formatDelimited(expression.elements, printExpr)));
659
606
  case "Rect":
607
+ case "Record": {
608
+ const separator = expression.kind === "Rect" ? ":" : "|->";
660
609
  return atom(
661
610
  format(
662
611
  "@[<b1>[%a]@]",
663
612
  formatDelimited(expression.fields, (field) =>
664
- format("@[<h>%s : %a@]", field.name, printExpr(field.value)),
665
- ),
666
- ),
667
- );
668
- case "Record":
669
- return atom(
670
- format(
671
- "@[<b1>[%a]@]",
672
- formatDelimited(expression.fields, (field) =>
673
- format("@[<h>%s |-> %a@]", field.name, printExpr(field.value)),
613
+ format(`@[<h>%s ${separator} %a@]`, field.name, printExpr(field.value)),
674
614
  ),
675
615
  ),
676
616
  );
617
+ }
677
618
  case "Except":
678
619
  return atom(
679
620
  format(
@@ -772,12 +713,13 @@ const createPrinter = (hyps: Hyp[] = []) => {
772
713
  return atom(format(pattern, form.label, printMinimal(inner)));
773
714
  }
774
715
  const namesDoc = formatDelimited(names, text);
775
- if (inner.kind === "Atm")
776
- return atom(format("%s(%a)::%a", form.label, namesDoc, printMinimal(inner)));
777
- if (inner.kind === "Big") {
778
- return atom(format("%s(%a)::(%a)", form.label, namesDoc, printMinimal(inner)));
779
- }
780
- return atom(format("(%s(%a):: %a)", form.label, namesDoc, printMinimal(inner)));
716
+ const pattern =
717
+ inner.kind === "Atm"
718
+ ? "%s(%a)::%a"
719
+ : inner.kind === "Big"
720
+ ? "%s(%a)::(%a)"
721
+ : "(%s(%a):: %a)";
722
+ return atom(format(pattern, form.label, namesDoc, printMinimal(inner)));
781
723
  }
782
724
  }
783
725
  };
@@ -883,7 +825,7 @@ const createPrinter = (hyps: Hyp[] = []) => {
883
825
  export const printExpression = (hyps: Hyp[], expression: Expr) =>
884
826
  createPrinter(hyps).printExpr(expression);
885
827
 
886
- export const formatObligation = (sequent: Sequent) => {
887
- const printer = createPrinter();
888
- return renderDoc(format("@[<b0>%a@]", printer.printSequent(sequent))).trimEnd();
889
- };
828
+ export const printSequent = (sequent: Sequent) => createPrinter().printSequent(sequent);
829
+
830
+ export const formatObligation = (sequent: Sequent) =>
831
+ renderDoc(format("@[<b0>%a@]", printSequent(sequent))).trimEnd();
@@ -1,6 +1,7 @@
1
1
  // tlapm's proof IR (P_t).
2
2
 
3
- import type { Bound, Defn, Expr, Locus, Sequent } from "./obligation-expression";
3
+ import type { Bound, Defn, Expr, Locus, Sequent } from "./expression";
4
+ import type { OldMethod } from "./pragma";
4
5
 
5
6
  export type StepNumber =
6
7
  | { kind: "Named"; level: number; label: string; isAnonymous: boolean }
@@ -23,17 +24,21 @@ export type ObligationKind =
23
24
  | { kind: "Error"; message: string }
24
25
  | { kind: "Omitted"; omission: Omission };
25
26
 
27
+ // method is the one an old-style pragma names, which keeps find_meth from choosing.
26
28
  export interface Obligation {
27
29
  sequent: Sequent;
28
30
  location: Locus | undefined;
29
31
  kind: ObligationKind;
32
+ method?: OldMethod;
30
33
  }
31
34
 
35
+ // useLocation is where a USE step comes from, so find_meth can tell apart the facts of each BY.
32
36
  interface ProofProps {
33
37
  location?: Locus;
34
38
  step?: StepNumber;
35
- isSuppressed?: boolean;
36
39
  obligations?: Obligation[];
40
+ method?: OldMethod;
41
+ useLocation?: Locus;
37
42
  }
38
43
 
39
44
  export type Proof = ProofCore & ProofProps;