tla-ts 0.0.4-dev.4c0ab96 → 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 (359) 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 +7 -7
  29. package/src/{cli-options.ts → cli/options.ts} +1 -1
  30. package/src/{run-cli.ts → cli/run.ts} +293 -91
  31. package/src/cli.ts +1 -1
  32. package/src/config.ts +2 -2
  33. package/src/environment.ts +9 -9
  34. package/src/errors.ts +89 -30
  35. package/src/evaluate.ts +32 -11
  36. package/src/index.ts +10 -0
  37. package/src/levels.ts +1 -1
  38. package/src/live-check.ts +1 -1
  39. package/src/liveness.ts +1 -1
  40. package/src/{obligation-action.ts → obligations/action.ts} +247 -69
  41. package/src/{obligation-anon.ts → obligations/anon.ts} +49 -47
  42. package/src/obligations/ctx.ts +64 -0
  43. package/src/{obligation-deref.ts → obligations/deref.ts} +51 -92
  44. package/src/{obligation-expression.ts → obligations/expression.ts} +117 -57
  45. package/src/{obligation-format.ts → obligations/format.ts} +7 -8
  46. package/src/{obligation-generate.ts → obligations/generate.ts} +170 -192
  47. package/src/{obligations.ts → obligations/index.ts} +32 -16
  48. package/src/{obligation-levels.ts → obligations/levels.ts} +26 -28
  49. package/src/{obligation-module.ts → obligations/module.ts} +113 -121
  50. package/src/obligations/pickle.ts +98 -0
  51. package/src/obligations/pragma.ts +189 -0
  52. package/src/{obligation-printer.ts → obligations/printer.ts} +22 -80
  53. package/src/{obligation-proof.ts → obligations/proof.ts} +7 -2
  54. package/src/{obligation-source.ts → obligations/source.ts} +154 -99
  55. package/src/obligations/temporal.ts +321 -0
  56. package/src/{obligation-tuples.ts → obligations/tuples.ts} +38 -54
  57. package/src/parallel-worker.ts +4 -20
  58. package/src/parallel.ts +13 -46
  59. package/src/parser.ts +1 -1
  60. package/src/{pcal-ast.ts → pcal/ast.ts} +2 -2
  61. package/src/{pcal-parse.ts → pcal/parse.ts} +3 -3
  62. package/src/{pcal-tokenize.ts → pcal/tokenize.ts} +2 -2
  63. package/src/{pcal-translate.ts → pcal/translate.ts} +2 -2
  64. package/src/{pcal-validate.ts → pcal/validate.ts} +6 -6
  65. package/src/prove/decide-pool.ts +95 -0
  66. package/src/prove/deciders.ts +33 -0
  67. package/src/prove/first-order.ts +78 -0
  68. package/src/prove/isabelle/LICENSE +36 -0
  69. package/src/prove/isabelle/LICENSE-tlapm +26 -0
  70. package/src/prove/isabelle/decide.ts +47 -0
  71. package/src/prove/isabelle/encode.ts +446 -0
  72. package/src/prove/isabelle/isar/inner-syntax.ts +579 -0
  73. package/src/prove/isabelle/isar/method.ts +367 -0
  74. package/src/prove/isabelle/isar/proof.ts +28 -0
  75. package/src/prove/isabelle/isar/statement.ts +57 -0
  76. package/src/prove/isabelle/isar/theory.ts +192 -0
  77. package/src/prove/isabelle/isar/type-check.ts +278 -0
  78. package/src/prove/isabelle/provers/blast/blast.ts +258 -0
  79. package/src/prove/isabelle/provers/blast/branch.ts +322 -0
  80. package/src/prove/isabelle/provers/blast/prove.ts +347 -0
  81. package/src/prove/isabelle/provers/blast/rules.ts +330 -0
  82. package/src/prove/isabelle/provers/blast/state.ts +180 -0
  83. package/src/prove/isabelle/provers/blast/term.ts +546 -0
  84. package/src/prove/isabelle/provers/clasimp.ts +150 -0
  85. package/src/prove/isabelle/provers/classical.ts +389 -0
  86. package/src/prove/isabelle/provers/hypsubst.ts +433 -0
  87. package/src/prove/isabelle/pure/bicompose.ts +174 -0
  88. package/src/prove/isabelle/pure/consts.ts +32 -0
  89. package/src/prove/isabelle/pure/conv.ts +79 -0
  90. package/src/prove/isabelle/pure/drule.ts +264 -0
  91. package/src/prove/isabelle/pure/envir.ts +331 -0
  92. package/src/prove/isabelle/pure/goal.ts +53 -0
  93. package/src/prove/isabelle/pure/interrupt.ts +16 -0
  94. package/src/prove/isabelle/pure/list.ts +12 -0
  95. package/src/prove/isabelle/pure/logic.ts +330 -0
  96. package/src/prove/isabelle/pure/name.ts +98 -0
  97. package/src/prove/isabelle/pure/net.ts +215 -0
  98. package/src/prove/isabelle/pure/object-logic.ts +41 -0
  99. package/src/prove/isabelle/pure/pattern.ts +631 -0
  100. package/src/prove/isabelle/pure/raw-simplifier.ts +338 -0
  101. package/src/prove/isabelle/pure/rewriter.ts +602 -0
  102. package/src/prove/isabelle/pure/search.ts +68 -0
  103. package/src/prove/isabelle/pure/seq.ts +133 -0
  104. package/src/prove/isabelle/pure/simplifier.ts +106 -0
  105. package/src/prove/isabelle/pure/table.ts +201 -0
  106. package/src/prove/isabelle/pure/tactic.ts +168 -0
  107. package/src/prove/isabelle/pure/tactical.ts +264 -0
  108. package/src/prove/isabelle/pure/term-ord.ts +105 -0
  109. package/src/prove/isabelle/pure/term.ts +688 -0
  110. package/src/prove/isabelle/pure/thm.ts +783 -0
  111. package/src/prove/isabelle/pure/type.ts +121 -0
  112. package/src/prove/isabelle/pure/unify.ts +753 -0
  113. package/src/prove/isabelle/pure/variable.ts +25 -0
  114. package/src/prove/isabelle/tla/classical-setup.ts +101 -0
  115. package/src/prove/isabelle/tla/context.ts +74 -0
  116. package/src/prove/isabelle/tla/logic-data.ts +5 -0
  117. package/src/prove/isabelle/tla/logic.ts +215 -0
  118. package/src/prove/isabelle/tla/simpdata.ts +241 -0
  119. package/src/prove/isabelle/tools/intuitionistic.ts +132 -0
  120. package/src/prove/ocaml.ts +22 -0
  121. package/src/prove/prep/action.ts +508 -0
  122. package/src/prove/prep/defs.ts +33 -0
  123. package/src/prove/prep/elab.ts +156 -0
  124. package/src/prove/prep/enabled-axioms.ts +189 -0
  125. package/src/prove/prep/enabled.ts +43 -0
  126. package/src/prove/prep/fingerprint.ts +388 -0
  127. package/src/prove/prep/flatten.ts +70 -0
  128. package/src/prove/prep/level-comparison.ts +529 -0
  129. package/src/prove/prep/md5.ts +67 -0
  130. package/src/prove/prep/pragma.ts +221 -0
  131. package/src/prove/prep/trivial.ts +22 -0
  132. package/src/prove/prove-worker.ts +22 -0
  133. package/src/prove/prove.ts +498 -0
  134. package/src/prove/ptl/decide.ts +68 -0
  135. package/src/prove/ptl/encode.ts +255 -0
  136. package/src/prove/ptl/sat.ts +151 -0
  137. package/src/prove/ptl/tableau.ts +276 -0
  138. package/src/prove/smt/axiomatize.ts +69 -0
  139. package/src/prove/smt/axioms.ts +209 -0
  140. package/src/prove/smt/context.ts +108 -0
  141. package/src/prove/smt/data.ts +636 -0
  142. package/src/prove/smt/encode.ts +164 -0
  143. package/src/prove/smt/extensionality.ts +65 -0
  144. package/src/prove/smt/flatten.ts +112 -0
  145. package/src/prove/smt/format.ts +154 -0
  146. package/src/prove/smt/instances.ts +181 -0
  147. package/src/prove/smt/rewrite.ts +772 -0
  148. package/src/prove/smt/simplify.ts +57 -0
  149. package/src/prove/smt/solver/act-cache.ts +265 -0
  150. package/src/prove/smt/solver/arith-rewriter.ts +962 -0
  151. package/src/prove/smt/solver/array.ts +22 -0
  152. package/src/prove/smt/solver/asserted-formulas.ts +469 -0
  153. package/src/prove/smt/solver/ast-lt.ts +157 -0
  154. package/src/prove/smt/solver/ast-util.ts +91 -0
  155. package/src/prove/smt/solver/ast.ts +1315 -0
  156. package/src/prove/smt/solver/auf-solver.ts +572 -0
  157. package/src/prove/smt/solver/case-split-queue.ts +178 -0
  158. package/src/prove/smt/solver/cg-table.ts +175 -0
  159. package/src/prove/smt/solver/clause.ts +276 -0
  160. package/src/prove/smt/solver/conflict-resolution.ts +343 -0
  161. package/src/prove/smt/solver/context.ts +1292 -0
  162. package/src/prove/smt/solver/ctx-simplify.ts +334 -0
  163. package/src/prove/smt/solver/der.ts +224 -0
  164. package/src/prove/smt/solver/dyn-ack.ts +141 -0
  165. package/src/prove/smt/solver/e-matching.ts +659 -0
  166. package/src/prove/smt/solver/enode.ts +259 -0
  167. package/src/prove/smt/solver/expr-ref.ts +21 -0
  168. package/src/prove/smt/solver/expr-safe-replace.ts +172 -0
  169. package/src/prove/smt/solver/fingerprints.ts +92 -0
  170. package/src/prove/smt/solver/flat-literals.ts +51 -0
  171. package/src/prove/smt/solver/goal.ts +138 -0
  172. package/src/prove/smt/solver/hash.ts +173 -0
  173. package/src/prove/smt/solver/hashtable.ts +166 -0
  174. package/src/prove/smt/solver/internalizer.ts +1381 -0
  175. package/src/prove/smt/solver/lbool.ts +5 -0
  176. package/src/prove/smt/solver/literal.ts +24 -0
  177. package/src/prove/smt/solver/lp/bound-propagator.ts +391 -0
  178. package/src/prove/smt/solver/lp/constraints.ts +78 -0
  179. package/src/prove/smt/solver/lp/containers.ts +296 -0
  180. package/src/prove/smt/solver/lp/core-solver.ts +504 -0
  181. package/src/prove/smt/solver/lp/cross-nested.ts +224 -0
  182. package/src/prove/smt/solver/lp/dep-intervals.ts +642 -0
  183. package/src/prove/smt/solver/lp/dependency.ts +51 -0
  184. package/src/prove/smt/solver/lp/dioph-eq.ts +1181 -0
  185. package/src/prove/smt/solver/lp/explanation.ts +46 -0
  186. package/src/prove/smt/solver/lp/gomory.ts +255 -0
  187. package/src/prove/smt/solver/lp/hnf-cutter.ts +125 -0
  188. package/src/prove/smt/solver/lp/hnf.ts +281 -0
  189. package/src/prove/smt/solver/lp/int-cube.ts +295 -0
  190. package/src/prove/smt/solver/lp/int-solver.ts +514 -0
  191. package/src/prove/smt/solver/lp/lar-solver.ts +816 -0
  192. package/src/prove/smt/solver/lp/lar-term.ts +62 -0
  193. package/src/prove/smt/solver/lp/lp-settings.ts +91 -0
  194. package/src/prove/smt/solver/lp/maximize-term.ts +347 -0
  195. package/src/prove/smt/solver/lp/nex-creator.ts +381 -0
  196. package/src/prove/smt/solver/lp/nex.ts +120 -0
  197. package/src/prove/smt/solver/lp/nla-backoff.ts +43 -0
  198. package/src/prove/smt/solver/lp/nla-basics.ts +398 -0
  199. package/src/prove/smt/solver/lp/nla-core.ts +968 -0
  200. package/src/prove/smt/solver/lp/nla-divisions.ts +332 -0
  201. package/src/prove/smt/solver/lp/nla-emonics.ts +373 -0
  202. package/src/prove/smt/solver/lp/nla-factorization.ts +30 -0
  203. package/src/prove/smt/solver/lp/nla-grobner.ts +904 -0
  204. package/src/prove/smt/solver/lp/nla-horner.ts +126 -0
  205. package/src/prove/smt/solver/lp/nla-intervals.ts +265 -0
  206. package/src/prove/smt/solver/lp/nla-monomial-bounds.ts +715 -0
  207. package/src/prove/smt/solver/lp/nla-monotone.ts +59 -0
  208. package/src/prove/smt/solver/lp/nla-order.ts +307 -0
  209. package/src/prove/smt/solver/lp/nla-patcher.ts +112 -0
  210. package/src/prove/smt/solver/lp/nla-tangents.ts +251 -0
  211. package/src/prove/smt/solver/lp/nla-throttle.ts +85 -0
  212. package/src/prove/smt/solver/lp/nla-types.ts +124 -0
  213. package/src/prove/smt/solver/lp/nla-var-eqs.ts +141 -0
  214. package/src/prove/smt/solver/lp/nra-solver.ts +440 -0
  215. package/src/prove/smt/solver/lp/numeric-pair.ts +65 -0
  216. package/src/prove/smt/solver/lp/pdd-interval.ts +31 -0
  217. package/src/prove/smt/solver/lp/pdd-simplifier.ts +184 -0
  218. package/src/prove/smt/solver/lp/pdd-solver.ts +408 -0
  219. package/src/prove/smt/solver/lp/pdd.ts +971 -0
  220. package/src/prove/smt/solver/lp/random-updater.ts +138 -0
  221. package/src/prove/smt/solver/lp/static-matrix.ts +246 -0
  222. package/src/prove/smt/solver/lp/union-find.ts +96 -0
  223. package/src/prove/smt/solver/mam-compiler.ts +847 -0
  224. package/src/prove/smt/solver/mam-interpreter.ts +400 -0
  225. package/src/prove/smt/solver/maximize-ac-sharing.ts +118 -0
  226. package/src/prove/smt/solver/model-checker.ts +347 -0
  227. package/src/prove/smt/solver/model-evaluator.ts +262 -0
  228. package/src/prove/smt/solver/model-finder.ts +155 -0
  229. package/src/prove/smt/solver/model-generator.ts +97 -0
  230. package/src/prove/smt/solver/model-macro-solver.ts +728 -0
  231. package/src/prove/smt/solver/nlsat/algebraic.ts +1161 -0
  232. package/src/prove/smt/solver/nlsat/atoms.ts +238 -0
  233. package/src/prove/smt/solver/nlsat/evaluator.ts +303 -0
  234. package/src/prove/smt/solver/nlsat/explain.ts +607 -0
  235. package/src/prove/smt/solver/nlsat/interval-set.ts +351 -0
  236. package/src/prove/smt/solver/nlsat/levelwise.ts +737 -0
  237. package/src/prove/smt/solver/nlsat/mpbq.ts +161 -0
  238. package/src/prove/smt/solver/nlsat/polynomial.ts +1722 -0
  239. package/src/prove/smt/solver/nlsat/solver.ts +911 -0
  240. package/src/prove/smt/solver/nlsat/types.ts +43 -0
  241. package/src/prove/smt/solver/nlsat/upolynomial-factorization.ts +648 -0
  242. package/src/prove/smt/solver/nlsat/upolynomial.ts +996 -0
  243. package/src/prove/smt/solver/nnf.ts +469 -0
  244. package/src/prove/smt/solver/pattern-inference.ts +351 -0
  245. package/src/prove/smt/solver/poly-rewriter.ts +477 -0
  246. package/src/prove/smt/solver/propagate-values.ts +83 -0
  247. package/src/prove/smt/solver/proto-model.ts +551 -0
  248. package/src/prove/smt/solver/pull-quant.ts +139 -0
  249. package/src/prove/smt/solver/qe-lite-der.ts +526 -0
  250. package/src/prove/smt/solver/qe-lite-fm.ts +576 -0
  251. package/src/prove/smt/solver/qe-lite.ts +381 -0
  252. package/src/prove/smt/solver/qi-queue.ts +362 -0
  253. package/src/prove/smt/solver/quant-tactics.ts +117 -0
  254. package/src/prove/smt/solver/quantifier-analyzer.ts +562 -0
  255. package/src/prove/smt/solver/quantifier-manager.ts +186 -0
  256. package/src/prove/smt/solver/random-gen.ts +10 -0
  257. package/src/prove/smt/solver/rational.ts +165 -0
  258. package/src/prove/smt/solver/ref-vector.ts +62 -0
  259. package/src/prove/smt/solver/relevancy.ts +247 -0
  260. package/src/prove/smt/solver/rewriter-tpl.ts +1159 -0
  261. package/src/prove/smt/solver/rewriter.ts +843 -0
  262. package/src/prove/smt/solver/rlimit.ts +79 -0
  263. package/src/prove/smt/solver/smtlib-parser.ts +526 -0
  264. package/src/prove/smt/solver/solver.ts +71 -0
  265. package/src/prove/smt/solver/sort.ts +35 -0
  266. package/src/prove/smt/solver/sticky-generations.ts +69 -0
  267. package/src/prove/smt/solver/theory-lra-axioms.ts +340 -0
  268. package/src/prove/smt/solver/theory-lra-bounds.ts +226 -0
  269. package/src/prove/smt/solver/theory-lra-final-check.ts +252 -0
  270. package/src/prove/smt/solver/theory-lra-internalize.ts +476 -0
  271. package/src/prove/smt/solver/theory-lra-model.ts +243 -0
  272. package/src/prove/smt/solver/theory-lra-propagate.ts +405 -0
  273. package/src/prove/smt/solver/theory-lra-state.ts +43 -0
  274. package/src/prove/smt/solver/theory-lra.ts +56 -0
  275. package/src/prove/smt/solver/var-subst.ts +258 -0
  276. package/src/prove/smt/solver/z3-license.txt +10 -0
  277. package/src/prove/smt/table.ts +170 -0
  278. package/src/prove/tlapm/cache.ts +236 -0
  279. package/src/prove/tlapm/ocaml-marshal.ts +166 -0
  280. package/src/prove/tlapm/tlapm.ts +96 -0
  281. package/src/prove/tlaps-module.ts +510 -0
  282. package/src/prove/verdict.ts +18 -0
  283. package/src/prove/zenon/LICENSE +32 -0
  284. package/src/prove/zenon/check/check.ts +105 -0
  285. package/src/prove/zenon/check/definitions.ts +144 -0
  286. package/src/prove/zenon/check/equality.ts +182 -0
  287. package/src/prove/zenon/check/functions.ts +62 -0
  288. package/src/prove/zenon/check/keys.ts +125 -0
  289. package/src/prove/zenon/check/propositional.ts +104 -0
  290. package/src/prove/zenon/check/records.ts +188 -0
  291. package/src/prove/zenon/check/relations.ts +121 -0
  292. package/src/prove/zenon/check/rewrites.ts +224 -0
  293. package/src/prove/zenon/check/sets.ts +302 -0
  294. package/src/prove/zenon/check/terms.ts +127 -0
  295. package/src/prove/zenon/check/tla.ts +126 -0
  296. package/src/prove/zenon/decide.ts +113 -0
  297. package/src/prove/zenon/encode.ts +379 -0
  298. package/src/prove/zenon/eqrel.ts +300 -0
  299. package/src/prove/zenon/equality-rules.ts +435 -0
  300. package/src/prove/zenon/expr.ts +551 -0
  301. package/src/prove/zenon/index-table.ts +350 -0
  302. package/src/prove/zenon/isar-case.ts +513 -0
  303. package/src/prove/zenon/isar.ts +1249 -0
  304. package/src/prove/zenon/limits.ts +15 -0
  305. package/src/prove/zenon/llproof.ts +173 -0
  306. package/src/prove/zenon/mltoll.ts +1566 -0
  307. package/src/prove/zenon/node.ts +297 -0
  308. package/src/prove/zenon/ocaml.ts +169 -0
  309. package/src/prove/zenon/parse.ts +247 -0
  310. package/src/prove/zenon/phrase.ts +191 -0
  311. package/src/prove/zenon/proof.ts +198 -0
  312. package/src/prove/zenon/propositional-rules.ts +387 -0
  313. package/src/prove/zenon/rules.ts +94 -0
  314. package/src/prove/zenon/search.ts +288 -0
  315. package/src/prove/zenon/tla/functions.ts +151 -0
  316. package/src/prove/zenon/tla/llproof.ts +480 -0
  317. package/src/prove/zenon/tla/records.ts +225 -0
  318. package/src/prove/zenon/tla/rewrites.ts +447 -0
  319. package/src/prove/zenon/tla/sets.ts +304 -0
  320. package/src/prove/zenon/tla/terms.ts +162 -0
  321. package/src/prove/zenon/tla/tla.ts +506 -0
  322. package/src/randomization.ts +1 -1
  323. package/src/resolve.ts +1 -1
  324. package/src/runtime.ts +2 -2
  325. package/src/{sany-builtins.ts → sany/builtins.ts} +1 -1
  326. package/src/{sany-generator.ts → sany/generator.ts} +14 -14
  327. package/src/{sany-levels.ts → sany/levels.ts} +2 -2
  328. package/src/{sany-lexer.ts → sany/lexer.ts} +1 -1
  329. package/src/{sany-linter.ts → sany/linter.ts} +1 -1
  330. package/src/{sany-modules.ts → sany/modules.ts} +2 -2
  331. package/src/{sany-parse-error.ts → sany/parse-error.ts} +2 -2
  332. package/src/{sany-report.ts → sany/report.ts} +15 -15
  333. package/src/{sany-selectors.ts → sany/selectors.ts} +3 -3
  334. package/src/{sany-source.ts → sany/source.ts} +6 -6
  335. package/src/{sany-xml.ts → sany/xml.ts} +5 -5
  336. package/src/spec-description.ts +1 -1
  337. package/src/{standard-levels.ts → standard/levels.ts} +1 -1
  338. package/src/{standard-modules.ts → standard/modules.ts} +12 -12
  339. package/src/{standard-ranges.ts → standard/ranges.ts} +1 -1
  340. package/src/state-graph.ts +1 -1
  341. package/src/successors.ts +1 -1
  342. package/src/symmetry.ts +1 -1
  343. package/src/{tlc-messages.ts → tlc/messages.ts} +2 -2
  344. package/src/{tlc-order.ts → tlc/order.ts} +7 -7
  345. package/src/{tlc-random.ts → tlc/random.ts} +3 -3
  346. package/src/{tlc-replay.ts → tlc/replay.ts} +5 -5
  347. package/src/{tlc-module.ts → tlc/tlc-operators.ts} +9 -9
  348. package/src/{tlc-ext.ts → tlc/tlcext-operators.ts} +14 -8
  349. package/src/values.ts +1 -1
  350. package/src/worker.ts +65 -0
  351. package/dist/parallel.cjs +0 -12
  352. package/dist/parallel.js +0 -12
  353. package/dist/run-cli.cjs +0 -55
  354. package/dist/run-cli.js +0 -55
  355. package/src/value-sources.ts +0 -29
  356. /package/src/{sany-nodes.ts → sany/nodes.ts} +0 -0
  357. /package/src/{tlc-modules.ts → tlc/jar-data.ts} +0 -0
  358. /package/src/{tlc-summary.ts → tlc/summary.ts} +0 -0
  359. /package/src/{tlc-version.ts → tlc/version.ts} +0 -0
@@ -1,33 +1,38 @@
1
1
  // A port of tlapm's proof simplification (Proof.Simplify) and obligation generation (Proof.Gen):
2
2
  // leaf proofs become obligations whose context is everything the proof may use at that point.
3
3
 
4
- import { TlapmBugError, TlaProofError } from "./errors";
4
+ import { TlapmBugError, TlaProofError } from "../errors";
5
5
  import {
6
6
  applyBuiltin,
7
7
  at,
8
8
  consSubstitution,
9
9
  exprifySequent,
10
10
  getErrorNote,
11
+ getFact,
12
+ isBuiltinApply,
11
13
  isEqualExpr,
12
14
  mapAccumulate,
15
+ mapChildren,
13
16
  normalizeApply,
14
17
  shift,
15
18
  shiftExpr,
16
19
  substituteBounds,
17
20
  substituteExpr,
21
+ stripProps,
18
22
  type Bound,
19
23
  type Builtin,
20
24
  type Expr,
21
25
  type Hyp,
22
26
  type Locus,
23
- type ObligationWarning,
27
+ type Warn,
24
28
  type Sequent,
29
+ type Time,
25
30
  type Visibility,
26
- mapChildren,
27
- stripProps,
28
- } from "./obligation-expression";
29
- import { format, renderDoc, type Doc } from "./obligation-format";
30
- import { printExpression } from "./obligation-printer";
31
+ } from "./expression";
32
+ import { format, renderDoc, type Doc } from "./format";
33
+ import { printExpression } from "./printer";
34
+ import type { OldMethod } from "./pragma";
35
+ import { getScopeTime } from "./temporal";
31
36
  import {
32
37
  getStepName,
33
38
  getUnique,
@@ -39,7 +44,7 @@ import {
39
44
  type StepNumber,
40
45
  type UseDef,
41
46
  type Usable,
42
- } from "./obligation-proof";
47
+ } from "./proof";
43
48
 
44
49
  const AT_NOWHERE: Expr = { kind: "At", isExcept: false };
45
50
 
@@ -47,7 +52,7 @@ const AT_NOWHERE: Expr = { kind: "At", isExcept: false };
47
52
  const getProps = (from: Step) => ({
48
53
  location: from.location,
49
54
  step: from.step,
50
- isSuppressed: from.isSuppressed,
55
+ method: from.method,
51
56
  });
52
57
 
53
58
  const isAnonymous = (step: StepNumber | undefined) => step?.kind === "Named" && step.isAnonymous;
@@ -60,10 +65,7 @@ const isBinary = (
60
65
  expression: Expr,
61
66
  builtin: Builtin,
62
67
  ): expression is Extract<Expr, { kind: "Apply" }> =>
63
- expression.kind === "Apply" &&
64
- expression.operator.kind === "Internal" &&
65
- expression.operator.builtin === builtin &&
66
- expression.args.length === 2;
68
+ isBuiltinApply(expression, builtin) && expression.args.length === 2;
67
69
 
68
70
  const getMessage = (pattern: string, ...args: (string | Doc)[]) =>
69
71
  renderDoc(format(pattern, ...args));
@@ -101,43 +103,37 @@ const getAssumedFacts = (offset: number, sequent: Sequent) =>
101
103
  : [],
102
104
  );
103
105
 
104
- const getStepDefinition = (step: Step, body: Expr): Hyp => {
106
+ const getStepDefinition = (step: Step, body: Expr, time: Time): Hyp => {
105
107
  if (!step.step) throw new TlapmBugError();
106
108
  return {
107
109
  kind: "Defn",
108
110
  definition: { kind: "Operator", name: getStepName(step.step), body, location: step.location },
109
- whereDefined: "Proof",
111
+ whereDefined: { kind: "Proof", time },
110
112
  visibility: "Visible",
111
113
  isLocal: true,
112
114
  location: step.location,
113
115
  };
114
116
  };
115
117
 
116
- const proveAssertion = (context: Hyp[], sequent: Sequent, step: Step) => {
118
+ // The proof of an assertion leaves the always scope when the assertion assumes a fact that holds
119
+ // only now.
120
+ const proveAssertion = (context: Hyp[], sequent: Sequent, step: Step, time: Time) => {
117
121
  const visibility: Visibility = isAnonymous(step.step) ? "Visible" : "Hidden";
118
122
  const hyps = sequent.context.map((hyp): Hyp =>
119
123
  hyp.kind === "Fact" ? { ...hyp, visibility } : hyp,
120
124
  );
121
125
  const body = at({ kind: "List", bullet: "Refs", items: getAssumedFacts(2, sequent) }, step);
126
+ const scopeTime = getScopeTime(sequent.context, time);
122
127
  return {
123
128
  context: [
124
129
  ...context,
125
130
  ...hyps,
126
- {
127
- kind: "Fact",
128
- expression: getTrue(step),
129
- visibility: "Hidden",
130
- location: step.location,
131
- },
132
- getStepDefinition(step, body),
133
- {
134
- kind: "Fact",
135
- expression: at({ kind: "Ix", index: 1 }, step),
136
- visibility: "Hidden",
137
- location: step.location,
138
- },
139
- ] satisfies Hyp[],
131
+ getFact(getTrue(step), "Hidden", time, step.location),
132
+ getStepDefinition(step, body, scopeTime),
133
+ getFact(at({ kind: "Ix", index: 1 }, step), "Hidden", scopeTime, step.location),
134
+ ],
140
135
  active: shiftExpr(3, sequent.active),
136
+ time: scopeTime,
141
137
  };
142
138
  };
143
139
 
@@ -147,23 +143,30 @@ const useAssertion = (
147
143
  goal: Expr,
148
144
  sequent: Sequent,
149
145
  step: Step,
146
+ time: Time,
150
147
  ) => {
151
148
  const visibility: Visibility = isSuffices || isAnonymous(step.step) ? "Visible" : "Hidden";
152
149
  return {
153
150
  context: [
154
151
  ...context,
155
- getStepDefinition(step, at(exprifySequent(sequent), step)),
156
- {
157
- kind: "Fact",
158
- expression: at({ kind: "Ix", index: 1 }, step),
159
- visibility,
160
- location: step.location,
161
- },
162
- ] satisfies Hyp[],
152
+ getStepDefinition(step, at(exprifySequent(sequent), step), time),
153
+ getFact(at({ kind: "Ix", index: 1 }, step), visibility, time, step.location),
154
+ ],
163
155
  active: shiftExpr(2, goal),
164
156
  };
165
157
  };
166
158
 
159
+ // A cited step or definition keeps the scope it was proved in, and any other fact takes the
160
+ // current one.
161
+ const getFactTime = (context: Hyp[], fact: Expr, time: Time): Time => {
162
+ if (fact.kind !== "Ix") return time;
163
+ const hyp = context[context.length - fact.index];
164
+ if (hyp?.kind === "Fact") return hyp.time;
165
+ return hyp?.kind === "Defn" && typeof hyp.whereDefined === "object"
166
+ ? hyp.whereDefined.time
167
+ : "Always";
168
+ };
169
+
167
170
  const setDefinition = (visibility: Visibility, context: Hyp[], def: UseDef): Hyp[] => {
168
171
  if (def.kind !== "Dx") throw new TlaProofError(`Unknown definition ${def.name}`);
169
172
  const index = context.length - def.index;
@@ -174,15 +177,13 @@ const setDefinition = (visibility: Visibility, context: Hyp[], def: UseDef): Hyp
174
177
  };
175
178
 
176
179
  const isDomainMatch = (fact: Expr, domain: Expr) =>
177
- fact.kind === "Apply" &&
178
- fact.operator.kind === "Internal" &&
179
- fact.operator.builtin === "Mem" &&
180
+ isBuiltinApply(fact, "Mem") &&
180
181
  fact.args[0]?.kind === "Ix" &&
181
182
  fact.args[0].index === 0 &&
182
183
  isEqualExpr(domain, fact.args[1]);
183
184
 
184
185
  const setExpression = (
185
- onWarning: (warning: ObligationWarning) => void,
186
+ onWarning: Warn,
186
187
  visibility: Visibility,
187
188
  fact: Expr,
188
189
  context: Hyp[],
@@ -196,7 +197,9 @@ const setExpression = (
196
197
  if (hyp.kind === "Fact" && isEqualExpr(hyp.expression, current)) {
197
198
  isFound = true;
198
199
  result[index] = { ...hyp, visibility };
199
- } else if (hyp.kind === "Fresh" && hyp.domain && isDomainMatch(current, hyp.domain)) {
200
+ continue;
201
+ }
202
+ if (hyp.kind === "Fresh" && hyp.domain && isDomainMatch(current, hyp.domain)) {
200
203
  isFound = true;
201
204
  result[index] = { ...hyp, domainVisibility: visibility };
202
205
  }
@@ -215,18 +218,6 @@ export interface LineRange {
215
218
  end: number;
216
219
  }
217
220
 
218
- export interface Generator {
219
- generate: (sequent: Sequent, proof: Proof) => Proof;
220
- collect: (proof: Proof) => Obligation[];
221
- mutate: (
222
- context: Hyp[],
223
- mode: "Use" | "Hide",
224
- usable: Usable,
225
- location: Locus | undefined,
226
- ) => [Hyp[], Obligation[]];
227
- simplify: (context: Hyp[], goal: Expr, proof: Proof) => Proof;
228
- }
229
-
230
221
  // The bounds after a witnessed one, where a ditto takes the witnessed domain.
231
222
  const getRemainingBounds = (first: Bound, rest: Bound[]): Bound[] => {
232
223
  const shifted = substituteBounds(shift(1), rest)[1];
@@ -243,7 +234,7 @@ const getRemainingBounds = (first: Bound, rest: Bound[]): Bound[] => {
243
234
 
244
235
  // A WITNESS proves each membership and subset it relies on, then the goal from them.
245
236
  const getWitnessProof = (step: Step, aux: Expr[]): Proof => {
246
- if (step.isSuppressed || aux.length === 0) return { kind: "Obvious", ...getProps(step) };
237
+ if (aux.length === 0) return { kind: "Obvious", ...getProps(step) };
247
238
  const steps = aux.map((item, index): Step => {
248
239
  const active = shiftExpr(2 * index + 2, item);
249
240
  return {
@@ -254,6 +245,7 @@ const getWitnessProof = (step: Step, aux: Expr[]): Proof => {
254
245
  usable: { facts: [shiftExpr(3, active)], defs: [] },
255
246
  isOnly: false,
256
247
  location: item.location,
248
+ method: step.method,
257
249
  },
258
250
  location: item.location,
259
251
  };
@@ -262,11 +254,13 @@ const getWitnessProof = (step: Step, aux: Expr[]): Proof => {
262
254
  at({ kind: "Ix", index: 2 * aux.length + 2 }, step),
263
255
  ...aux.map((_item, index) => at({ kind: "Ix", index: 2 * (aux.length - index) }, step)),
264
256
  ];
257
+ // tlapm removes the method from the QED.
265
258
  const qedProof: Proof = {
266
259
  kind: "By",
267
260
  usable: { facts, defs: [] },
268
261
  isOnly: true,
269
262
  ...getProps(step),
263
+ method: undefined,
270
264
  };
271
265
  return {
272
266
  kind: "Steps",
@@ -278,9 +272,9 @@ const getWitnessProof = (step: Step, aux: Expr[]): Proof => {
278
272
 
279
273
  const obligate = (
280
274
  sequent: Sequent,
281
- from: { location?: Locus },
275
+ from: { location?: Locus; method?: OldMethod },
282
276
  kind: ObligationKind,
283
- ): Obligation => ({ sequent, location: from.location, kind });
277
+ ): Obligation => ({ sequent, location: from.location, kind, method: from.method });
284
278
 
285
279
  export interface ProofSummary {
286
280
  total: number;
@@ -297,17 +291,8 @@ export const joinSummaries = (left: ProofSummary, right: ProofSummary): ProofSum
297
291
  });
298
292
 
299
293
  const getStepSummary = (step: Step): ProofSummary => {
300
- switch (step.kind) {
301
- case "Use":
302
- return { ...EMPTY_SUMMARY, total: step.obligations?.length ?? 0 };
303
- case "Assert":
304
- case "Suffices":
305
- case "Pcase":
306
- case "Pick":
307
- return getProofSummary(step.proof);
308
- default:
309
- return EMPTY_SUMMARY;
310
- }
294
+ if (step.kind === "Use") return { ...EMPTY_SUMMARY, total: step.obligations?.length ?? 0 };
295
+ return "proof" in step ? getProofSummary(step.proof) : EMPTY_SUMMARY;
311
296
  };
312
297
 
313
298
  export const getProofSummary = (proof: Proof): ProofSummary => {
@@ -334,9 +319,9 @@ export const createGenerator = (
334
319
  counter: Counter,
335
320
  inputFiles: Set<string>,
336
321
  lines: LineRange,
337
- onWarning: (warning: ObligationWarning) => void,
338
- ): Generator => {
339
- const generate = (sequent: Sequent, proof: Proof): Proof => {
322
+ onWarning: Warn,
323
+ ) => {
324
+ const generate = (sequent: Sequent, proof: Proof, time: Time): Proof => {
340
325
  const location = proof.location;
341
326
  if (
342
327
  !location ||
@@ -361,14 +346,17 @@ export const createGenerator = (
361
346
  case "By":
362
347
  throw new TlaProofError("Proof.Gen.generate");
363
348
  case "Steps": {
364
- const [inner, steps] = mapAccumulate(sequent, proof.steps, generateStep);
365
- const qedProof = generate(inner, proof.qed.proof);
349
+ const [inner, steps] = mapAccumulate({ sequent, time }, proof.steps, (state, step) => {
350
+ const [next, generated, nextTime] = generateStep(state.sequent, step, state.time);
351
+ return [{ sequent: next, time: nextTime }, generated];
352
+ });
353
+ const qedProof = generate(inner.sequent, proof.qed.proof, inner.time);
366
354
  return { ...proof, steps, qed: { ...proof.qed, proof: qedProof } };
367
355
  }
368
356
  }
369
357
  };
370
358
 
371
- const generateStep = (sequent: Sequent, step: Step): [Sequent, Step] => {
359
+ const generateStep = (sequent: Sequent, step: Step, time: Time): [Sequent, Step, Time] => {
372
360
  switch (step.kind) {
373
361
  case "Forget": {
374
362
  const count = sequent.context.length;
@@ -377,7 +365,7 @@ export const createGenerator = (
377
365
  ? { ...hyp, visibility: "Hidden" }
378
366
  : hyp,
379
367
  );
380
- return [{ ...sequent, context }, step];
368
+ return [{ ...sequent, context }, step, time];
381
369
  }
382
370
  case "Use": {
383
371
  const usable = step.usable;
@@ -388,11 +376,20 @@ export const createGenerator = (
388
376
  {
389
377
  context: [
390
378
  ...sequent.context,
391
- { kind: "Fact", expression: fact, visibility: "Visible", location: fact.location },
379
+ {
380
+ ...getFact(
381
+ fact,
382
+ "Visible",
383
+ getFactTime(sequent.context, fact, time),
384
+ fact.location,
385
+ ),
386
+ useLocation: step.useLocation,
387
+ },
392
388
  ],
393
389
  active: shiftExpr(1, sequent.active),
394
390
  },
395
391
  { ...step, obligations: [obligation] },
392
+ time,
396
393
  ];
397
394
  }
398
395
  if (usable.facts.length > 0)
@@ -401,7 +398,7 @@ export const createGenerator = (
401
398
  (current, def) => setDefinition("Visible", current, def),
402
399
  sequent.context,
403
400
  );
404
- return [{ ...sequent, context }, step];
401
+ return [{ ...sequent, context }, step, time];
405
402
  }
406
403
  case "Hide": {
407
404
  const hidden = step.usable.defs.reduce(
@@ -412,7 +409,7 @@ export const createGenerator = (
412
409
  (current, fact) => setExpression(onWarning, "Hidden", fact, current),
413
410
  hidden,
414
411
  );
415
- return [{ ...sequent, context }, step];
412
+ return [{ ...sequent, context }, step, time];
416
413
  }
417
414
  case "Define":
418
415
  return [
@@ -431,22 +428,27 @@ export const createGenerator = (
431
428
  active: shiftExpr(step.definitions.length, sequent.active),
432
429
  },
433
430
  step,
431
+ time,
434
432
  ];
435
433
  case "Assert": {
436
- const proof = generate(proveAssertion(sequent.context, step.sequent, step), step.proof);
434
+ const inner = proveAssertion(sequent.context, step.sequent, step, time);
435
+ const proof = generate(inner, step.proof, inner.time);
437
436
  const generated: Step = { ...step, proof };
438
437
  return [
439
- useAssertion(false, sequent.context, sequent.active, step.sequent, generated),
438
+ useAssertion(false, sequent.context, sequent.active, step.sequent, generated, time),
440
439
  generated,
440
+ time,
441
441
  ];
442
442
  }
443
443
  case "Suffices": {
444
444
  const proof = generate(
445
- useAssertion(true, sequent.context, sequent.active, step.sequent, step),
445
+ useAssertion(true, sequent.context, sequent.active, step.sequent, step, time),
446
446
  step.proof,
447
+ time,
447
448
  );
448
449
  const generated: Step = { ...step, proof };
449
- return [proveAssertion(sequent.context, step.sequent, generated), generated];
450
+ const next = proveAssertion(sequent.context, step.sequent, generated, time);
451
+ return [next, generated, next.time];
450
452
  }
451
453
  default:
452
454
  throw new TlaProofError("Proof.Gen.gen_step");
@@ -463,8 +465,9 @@ export const createGenerator = (
463
465
  const [sequent, generated] = generateStep(
464
466
  { context, active: { ...AT_NOWHERE, location } },
465
467
  mode === "Use"
466
- ? { kind: "Use", usable, isOnly: false, location, step }
468
+ ? { kind: "Use", usable, isOnly: false, location, step, useLocation: location }
467
469
  : { kind: "Hide", usable, location, step },
470
+ "Always",
468
471
  );
469
472
  return [sequent.context, generated.obligations ?? []];
470
473
  };
@@ -499,19 +502,11 @@ export const createGenerator = (
499
502
  item.steps.forEach(visitStep);
500
503
  return;
501
504
  }
502
- if (item.obligations && !item.isSuppressed) obligations.push(...item.obligations);
505
+ if (item.obligations) obligations.push(...item.obligations);
503
506
  };
504
507
  const visitStep = (step: Step) => {
505
- if (step.kind === "Use" && step.obligations && !step.isSuppressed)
506
- obligations.push(...step.obligations);
507
- if (
508
- step.kind === "Assert" ||
509
- step.kind === "Suffices" ||
510
- step.kind === "Pcase" ||
511
- step.kind === "Pick"
512
- ) {
513
- visitProof(step.proof);
514
- }
508
+ if (step.kind === "Use" && step.obligations) obligations.push(...step.obligations);
509
+ if ("proof" in step) visitProof(step.proof);
515
510
  };
516
511
  visitProof(proof);
517
512
  return obligations;
@@ -540,15 +535,9 @@ export const createGenerator = (
540
535
 
541
536
  const renumberStep = (level: number, step: Step): Step => {
542
537
  const renumbered: Step = { ...step, step: renumberNumber(level, step.step) };
543
- switch (renumbered.kind) {
544
- case "Assert":
545
- case "Suffices":
546
- case "Pcase":
547
- case "Pick":
548
- return { ...renumbered, proof: renumber(level + 1, renumbered.proof) };
549
- default:
550
- return renumbered;
551
- }
538
+ return "proof" in renumbered
539
+ ? { ...renumbered, proof: renumber(level + 1, renumbered.proof) }
540
+ : renumbered;
552
541
  };
553
542
 
554
543
  const exposeConnective = (context: Hyp[], goal: Expr): Expr => {
@@ -562,11 +551,7 @@ export const createGenerator = (
562
551
  const operator: Expr = { ...body, location: goal.location };
563
552
  return exposeConnective(context, at(normalizeApply(operator, goal.args), operator));
564
553
  }
565
- if (
566
- goal.kind === "Apply" &&
567
- goal.operator.kind === "Internal" &&
568
- goal.operator.builtin === "Prime"
569
- ) {
554
+ if (isBuiltinApply(goal, "Prime")) {
570
555
  const inner = exposeConnective(context, goal.args[0]);
571
556
  const prime = (expression: Expr) => applyBuiltin("Prime", [expression], expression);
572
557
  if (inner.kind === "Quant") {
@@ -626,7 +611,7 @@ export const createGenerator = (
626
611
  return { ...proof, steps };
627
612
  };
628
613
 
629
- const simplify = (context: Hyp[], goal: Expr, original: Proof): Proof => {
614
+ const simplify = (context: Hyp[], goal: Expr, original: Proof, time: Time): Proof => {
630
615
  const proof = expandAt(original);
631
616
  switch (proof.kind) {
632
617
  case "Obvious":
@@ -651,7 +636,7 @@ export const createGenerator = (
651
636
  usable: { facts: [shiftExpr(index, fact)], defs: [] },
652
637
  isOnly: false,
653
638
  location: fact.location,
654
- isSuppressed: proof.isSuppressed,
639
+ useLocation: proof.location,
655
640
  }));
656
641
  const forget: Step[] = proof.isOnly
657
642
  ? [{ kind: "Forget", count: usable.facts.length, location: proof.location }]
@@ -665,7 +650,7 @@ export const createGenerator = (
665
650
  kind: "Obvious",
666
651
  location: proof.location,
667
652
  step: getAnonymous(level),
668
- isSuppressed: proof.isSuppressed,
653
+ method: proof.method,
669
654
  };
670
655
  return {
671
656
  kind: "Steps",
@@ -673,50 +658,55 @@ export const createGenerator = (
673
658
  qed: { proof: qedProof, location: qedProof.location, step: qedProof.step },
674
659
  location: proof.location,
675
660
  step: proof.step,
676
- isSuppressed: proof.isSuppressed,
677
661
  };
678
662
  }
679
663
  case "Steps": {
680
- let currentContext = context;
681
- let currentGoal = goal;
682
- const steps = proof.steps.flatMap((step) => {
683
- const [nextContext, nextGoal, simplified] = simplifyStep(
684
- currentContext,
685
- currentGoal,
686
- step,
687
- );
688
- currentContext = nextContext;
689
- currentGoal = nextGoal;
690
- return simplified;
691
- });
692
- const qedProof = simplify(currentContext, currentGoal, proof.qed.proof);
693
- return { ...proof, steps, qed: { ...proof.qed, proof: qedProof } };
664
+ const [inner, steps] = mapAccumulate(
665
+ { context, goal, time },
666
+ proof.steps,
667
+ (state, step) => {
668
+ const [nextContext, nextGoal, simplified, nextTime] = simplifyStep(
669
+ state.context,
670
+ state.goal,
671
+ step,
672
+ state.time,
673
+ );
674
+ return [{ context: nextContext, goal: nextGoal, time: nextTime }, simplified];
675
+ },
676
+ );
677
+ const qedProof = simplify(inner.context, inner.goal, proof.qed.proof, inner.time);
678
+ return { ...proof, steps: steps.flat(), qed: { ...proof.qed, proof: qedProof } };
694
679
  }
695
680
  }
696
681
  };
697
682
 
698
- const simplifyStep = (context: Hyp[], goal: Expr, step: Step): [Hyp[], Expr, Step[]] => {
683
+ const simplifyStep = (
684
+ context: Hyp[],
685
+ goal: Expr,
686
+ step: Step,
687
+ time: Time,
688
+ ): [Hyp[], Expr, Step[], Time] => {
699
689
  const level = getLevel(step.step);
700
690
  switch (step.kind) {
701
691
  case "Forget":
702
- return [context, goal, [step]];
692
+ return [context, goal, [step], time];
703
693
  case "Assert": {
704
- const inner = proveAssertion(context, step.sequent, step);
694
+ const inner = proveAssertion(context, step.sequent, step, time);
705
695
  const simplified: Step = {
706
696
  ...step,
707
- proof: simplify(inner.context, inner.active, step.proof),
697
+ proof: simplify(inner.context, inner.active, step.proof, inner.time),
708
698
  };
709
- const next = useAssertion(false, context, goal, step.sequent, simplified);
710
- return [next.context, next.active, [simplified]];
699
+ const next = useAssertion(false, context, goal, step.sequent, simplified, time);
700
+ return [next.context, next.active, [simplified], time];
711
701
  }
712
702
  case "Suffices": {
713
- const inner = useAssertion(true, context, goal, step.sequent, step);
703
+ const inner = useAssertion(true, context, goal, step.sequent, step, time);
714
704
  const simplified: Step = {
715
705
  ...step,
716
- proof: simplify(inner.context, inner.active, step.proof),
706
+ proof: simplify(inner.context, inner.active, step.proof, time),
717
707
  };
718
- const next = proveAssertion(context, step.sequent, simplified);
719
- return [next.context, next.active, [simplified]];
708
+ const next = proveAssertion(context, step.sequent, simplified, time);
709
+ return [next.context, next.active, [simplified], next.time];
720
710
  }
721
711
  case "Use": {
722
712
  const byProof: Proof = {
@@ -725,21 +715,19 @@ export const createGenerator = (
725
715
  isOnly: step.isOnly,
726
716
  location: step.location,
727
717
  step: step.step,
728
- isSuppressed: step.isSuppressed,
718
+ method: step.method,
729
719
  };
730
- const simplified = simplify(context, goal, byProof);
720
+ const simplified = simplify(context, goal, byProof, time);
731
721
  if (simplified.kind !== "Steps")
732
722
  throw new TlaProofError("simplifying BY does not produce a non-leaf proof!");
733
- const assumed = step.usable.facts.map((): Hyp => ({
734
- kind: "Fact",
735
- expression: AT_NOWHERE,
736
- visibility: "Visible",
737
- location: step.location,
738
- }));
723
+ const assumed = step.usable.facts.map(() =>
724
+ getFact(AT_NOWHERE, "Visible", time, step.location),
725
+ );
739
726
  return [
740
727
  [...context, ...assumed],
741
728
  shiftExpr(step.usable.facts.length, goal),
742
729
  simplified.steps,
730
+ time,
743
731
  ];
744
732
  }
745
733
  case "Hide": {
@@ -759,7 +747,7 @@ export const createGenerator = (
759
747
  : entry,
760
748
  );
761
749
  }, context);
762
- return [hidden, goal, [step]];
750
+ return [hidden, goal, [step], time];
763
751
  }
764
752
  case "Define":
765
753
  return [
@@ -768,7 +756,7 @@ export const createGenerator = (
768
756
  ...step.definitions.map((definition): Hyp => ({
769
757
  kind: "Defn",
770
758
  definition,
771
- whereDefined: "Proof",
759
+ whereDefined: { kind: "Proof", time },
772
760
  visibility: "Visible",
773
761
  isLocal: true,
774
762
  location: step.location,
@@ -776,18 +764,13 @@ export const createGenerator = (
776
764
  ],
777
765
  shiftExpr(step.definitions.length, goal),
778
766
  [step],
767
+ time,
779
768
  ];
780
769
  case "Have": {
781
770
  const connective = exposeConnective(context, goal);
782
- const fact: Hyp = {
783
- kind: "Fact",
784
- expression: step.expression,
785
- visibility: "Visible",
786
- location: step.location,
787
- };
788
771
  const isImplication = isBinary(connective, "Implies");
789
772
  const sequent: Sequent = {
790
- context: [fact],
773
+ context: [getFact(step.expression, "Visible", time, step.location)],
791
774
  active: isImplication ? shiftExpr(1, connective.args[1]) : connective,
792
775
  };
793
776
  const proof: Proof = isImplication
@@ -814,38 +797,33 @@ export const createGenerator = (
814
797
  location: step.location,
815
798
  step: step.step,
816
799
  });
817
- return simplifyStep(context, goal, suffices);
800
+ return simplifyStep(context, goal, suffices, time);
818
801
  }
819
802
  case "Take":
820
803
  return simplifyStep(
821
804
  context,
822
805
  goal,
823
806
  renumberStep(level, getTakeSuffices(context, goal, step)),
807
+ time,
824
808
  );
825
809
  case "Witness":
826
810
  return simplifyStep(
827
811
  context,
828
812
  goal,
829
813
  renumberStep(level, getWitnessSuffices(context, goal, step)),
814
+ time,
830
815
  );
831
816
  case "Pcase": {
832
817
  const assertion: Step = {
833
818
  kind: "Assert",
834
819
  sequent: {
835
- context: [
836
- {
837
- kind: "Fact",
838
- expression: step.expression,
839
- visibility: "Visible",
840
- location: step.location,
841
- },
842
- ],
820
+ context: [getFact(step.expression, "Visible", time, step.location)],
843
821
  active: shiftExpr(1, goal),
844
822
  },
845
823
  proof: step.proof,
846
824
  ...getProps(step),
847
825
  };
848
- return simplifyStep(context, goal, renumberStep(level, assertion));
826
+ return simplifyStep(context, goal, renumberStep(level, assertion), time);
849
827
  }
850
828
  case "Pick": {
851
829
  const existential: Expr = at(
@@ -853,31 +831,36 @@ export const createGenerator = (
853
831
  step,
854
832
  );
855
833
  const salted = getSalted(step.step, "ex");
856
- const [assertContext, assertGoal, asserted] = simplifyStep(context, goal, {
857
- kind: "Assert",
858
- sequent: { context: [], active: existential },
859
- proof: step.proof,
860
- ...getProps(step),
861
- step: salted,
862
- });
834
+ const [assertContext, assertGoal, asserted, assertTime] = simplifyStep(
835
+ context,
836
+ goal,
837
+ {
838
+ kind: "Assert",
839
+ sequent: { context: [], active: existential },
840
+ proof: step.proof,
841
+ ...getProps(step),
842
+ step: salted,
843
+ },
844
+ time,
845
+ );
863
846
  const shifted = shiftExpr(2, existential);
864
847
  if (shifted.kind !== "Quant") throw new TlaProofError("Proof.Simplify.simplify_step/PICK");
865
848
  const hyps = [
866
849
  ...getBoundHyps(shifted.bounds),
867
- {
868
- kind: "Fact",
869
- expression: shifted.body,
870
- visibility: "Visible",
871
- location: shifted.body.location,
872
- } satisfies Hyp,
850
+ getFact(shifted.body, "Visible", assertTime, shifted.body.location),
873
851
  ];
874
- const [nextContext, nextGoal, sufficed] = simplifyStep(assertContext, assertGoal, {
875
- kind: "Suffices",
876
- sequent: { context: hyps, active: shiftExpr(hyps.length, assertGoal) },
877
- proof: { kind: "Omitted", omission: "Elsewhere", ...getProps(step) },
878
- ...getProps(step),
879
- });
880
- return [nextContext, nextGoal, [...asserted, ...sufficed]];
852
+ const [nextContext, nextGoal, sufficed, nextTime] = simplifyStep(
853
+ assertContext,
854
+ assertGoal,
855
+ {
856
+ kind: "Suffices",
857
+ sequent: { context: hyps, active: shiftExpr(hyps.length, assertGoal) },
858
+ proof: { kind: "Omitted", omission: "Elsewhere", ...getProps(step) },
859
+ ...getProps(step),
860
+ },
861
+ assertTime,
862
+ );
863
+ return [nextContext, nextGoal, [...asserted, ...sufficed], nextTime];
881
864
  }
882
865
  }
883
866
  };
@@ -969,14 +952,7 @@ export const createGenerator = (
969
952
  return {
970
953
  kind: "Suffices",
971
954
  sequent: {
972
- context: [
973
- {
974
- kind: "Fact",
975
- expression: getTrue(goal),
976
- visibility: "Visible",
977
- location: step.location,
978
- },
979
- ],
955
+ context: [getFact(getTrue(goal), "Visible", "Now", step.location)],
980
956
  active: goal,
981
957
  },
982
958
  proof: { kind: "Error", message: stripped, ...getProps(step) },
@@ -1072,3 +1048,5 @@ export const createGenerator = (
1072
1048
 
1073
1049
  return { generate, collect, mutate, simplify };
1074
1050
  };
1051
+
1052
+ export type Generator = ReturnType<typeof createGenerator>;