tla-ts 0.0.4-dev.e4c2d0e → 0.0.4-dev.ee344a5

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 (311) hide show
  1. package/README.md +45 -1
  2. package/dist/deciders.cjs +366 -0
  3. package/dist/deciders.js +366 -0
  4. package/dist/index.cjs +1 -1
  5. package/dist/index.d.cts +35 -1
  6. package/dist/index.d.ts +35 -1
  7. package/dist/index.js +1 -1
  8. package/dist/parallel-worker.cjs +1 -4
  9. package/dist/parallel-worker.js +1 -4
  10. package/dist/prove-worker.cjs +9 -0
  11. package/dist/prove-worker.d.cts +9 -0
  12. package/dist/prove-worker.d.ts +9 -0
  13. package/dist/prove-worker.js +9 -0
  14. package/dist/prove.cjs +515 -0
  15. package/dist/prove.js +515 -0
  16. package/dist/run-cli.cjs +30 -47
  17. package/dist/run-cli.js +30 -47
  18. package/dist/tlapm.cjs +10 -0
  19. package/dist/tlapm.js +10 -0
  20. package/dist/transfer.cjs +38 -44
  21. package/dist/transfer.js +38 -44
  22. package/dist/worker.cjs +21 -0
  23. package/dist/worker.js +21 -0
  24. package/package.json +21 -12
  25. package/src/check.ts +1 -0
  26. package/src/codegen.ts +26 -7
  27. package/src/errors.ts +86 -0
  28. package/src/evaluate.ts +63 -20
  29. package/src/index.ts +10 -0
  30. package/src/{obligation-action.ts → obligations/action.ts} +258 -37
  31. package/src/{obligation-anon.ts → obligations/anon.ts} +13 -7
  32. package/src/obligations/ctx.ts +64 -0
  33. package/src/{obligation-deref.ts → obligations/deref.ts} +2 -2
  34. package/src/{obligation-expression.ts → obligations/expression.ts} +54 -8
  35. package/src/{obligation-generate.ts → obligations/generate.ts} +134 -61
  36. package/src/{obligations.ts → obligations/index.ts} +26 -12
  37. package/src/{obligation-levels.ts → obligations/levels.ts} +12 -2
  38. package/src/{obligation-module.ts → obligations/module.ts} +46 -20
  39. package/src/obligations/pickle.ts +100 -0
  40. package/src/obligations/pragma.ts +189 -0
  41. package/src/{obligation-printer.ts → obligations/printer.ts} +5 -59
  42. package/src/{obligation-proof.ts → obligations/proof.ts} +7 -1
  43. package/src/{obligation-source.ts → obligations/source.ts} +91 -35
  44. package/src/obligations/temporal.ts +319 -0
  45. package/src/{obligation-tuples.ts → obligations/tuples.ts} +1 -1
  46. package/src/parallel-worker.ts +2 -18
  47. package/src/parallel.ts +10 -43
  48. package/src/prove/decide-pool.ts +100 -0
  49. package/src/prove/deciders.ts +27 -0
  50. package/src/prove/isabelle/LICENSE +36 -0
  51. package/src/prove/isabelle/LICENSE-tlapm +26 -0
  52. package/src/prove/isabelle/decide.ts +47 -0
  53. package/src/prove/isabelle/encode.ts +477 -0
  54. package/src/prove/isabelle/isar/inner-syntax.ts +579 -0
  55. package/src/prove/isabelle/isar/method.ts +367 -0
  56. package/src/prove/isabelle/isar/proof.ts +28 -0
  57. package/src/prove/isabelle/isar/statement.ts +57 -0
  58. package/src/prove/isabelle/isar/theory.ts +192 -0
  59. package/src/prove/isabelle/isar/type-check.ts +278 -0
  60. package/src/prove/isabelle/provers/blast/blast.ts +258 -0
  61. package/src/prove/isabelle/provers/blast/branch.ts +322 -0
  62. package/src/prove/isabelle/provers/blast/prove.ts +347 -0
  63. package/src/prove/isabelle/provers/blast/rules.ts +330 -0
  64. package/src/prove/isabelle/provers/blast/state.ts +180 -0
  65. package/src/prove/isabelle/provers/blast/term.ts +547 -0
  66. package/src/prove/isabelle/provers/clasimp.ts +150 -0
  67. package/src/prove/isabelle/provers/classical.ts +389 -0
  68. package/src/prove/isabelle/provers/hypsubst.ts +441 -0
  69. package/src/prove/isabelle/pure/bicompose.ts +174 -0
  70. package/src/prove/isabelle/pure/consts.ts +32 -0
  71. package/src/prove/isabelle/pure/conv.ts +79 -0
  72. package/src/prove/isabelle/pure/drule.ts +264 -0
  73. package/src/prove/isabelle/pure/envir.ts +363 -0
  74. package/src/prove/isabelle/pure/goal.ts +53 -0
  75. package/src/prove/isabelle/pure/interrupt.ts +16 -0
  76. package/src/prove/isabelle/pure/list.ts +12 -0
  77. package/src/prove/isabelle/pure/logic.ts +402 -0
  78. package/src/prove/isabelle/pure/name.ts +110 -0
  79. package/src/prove/isabelle/pure/net.ts +262 -0
  80. package/src/prove/isabelle/pure/object-logic.ts +41 -0
  81. package/src/prove/isabelle/pure/pattern.ts +650 -0
  82. package/src/prove/isabelle/pure/raw-simplifier.ts +353 -0
  83. package/src/prove/isabelle/pure/rewriter.ts +602 -0
  84. package/src/prove/isabelle/pure/search.ts +68 -0
  85. package/src/prove/isabelle/pure/seq.ts +156 -0
  86. package/src/prove/isabelle/pure/simplifier.ts +112 -0
  87. package/src/prove/isabelle/pure/table.ts +208 -0
  88. package/src/prove/isabelle/pure/tactic.ts +276 -0
  89. package/src/prove/isabelle/pure/tactical.ts +347 -0
  90. package/src/prove/isabelle/pure/term-ord.ts +159 -0
  91. package/src/prove/isabelle/pure/term.ts +808 -0
  92. package/src/prove/isabelle/pure/thm.ts +806 -0
  93. package/src/prove/isabelle/pure/type.ts +133 -0
  94. package/src/prove/isabelle/pure/unify.ts +753 -0
  95. package/src/prove/isabelle/pure/variable.ts +25 -0
  96. package/src/prove/isabelle/tla/classical-setup.ts +101 -0
  97. package/src/prove/isabelle/tla/context.ts +74 -0
  98. package/src/prove/isabelle/tla/logic-data.ts +5 -0
  99. package/src/prove/isabelle/tla/logic.ts +215 -0
  100. package/src/prove/isabelle/tla/simpdata.ts +241 -0
  101. package/src/prove/isabelle/tools/intuitionistic.ts +132 -0
  102. package/src/prove/ocaml.ts +22 -0
  103. package/src/prove/prep/action.ts +520 -0
  104. package/src/prove/prep/defs.ts +27 -0
  105. package/src/prove/prep/elab.ts +156 -0
  106. package/src/prove/prep/enabled-axioms.ts +189 -0
  107. package/src/prove/prep/enabled.ts +43 -0
  108. package/src/prove/prep/fingerprint.ts +388 -0
  109. package/src/prove/prep/flatten.ts +70 -0
  110. package/src/prove/prep/level-comparison.ts +552 -0
  111. package/src/prove/prep/md5.ts +67 -0
  112. package/src/prove/prep/pragma.ts +221 -0
  113. package/src/prove/prep/trivial.ts +22 -0
  114. package/src/prove/prove-worker.ts +29 -0
  115. package/src/prove/prove.ts +417 -0
  116. package/src/prove/ptl/decide.ts +68 -0
  117. package/src/prove/ptl/encode.ts +256 -0
  118. package/src/prove/ptl/sat.ts +151 -0
  119. package/src/prove/ptl/tableau.ts +276 -0
  120. package/src/prove/smt/axiomatize.ts +69 -0
  121. package/src/prove/smt/axioms.ts +210 -0
  122. package/src/prove/smt/context.ts +108 -0
  123. package/src/prove/smt/data.ts +665 -0
  124. package/src/prove/smt/encode.ts +169 -0
  125. package/src/prove/smt/extensionality.ts +63 -0
  126. package/src/prove/smt/flatten.ts +127 -0
  127. package/src/prove/smt/format.ts +143 -0
  128. package/src/prove/smt/instances.ts +182 -0
  129. package/src/prove/smt/rewrite.ts +784 -0
  130. package/src/prove/smt/simplify.ts +57 -0
  131. package/src/prove/smt/solver/act-cache.ts +265 -0
  132. package/src/prove/smt/solver/arith-rewriter.ts +962 -0
  133. package/src/prove/smt/solver/array.ts +22 -0
  134. package/src/prove/smt/solver/asserted-formulas.ts +469 -0
  135. package/src/prove/smt/solver/ast-lt.ts +157 -0
  136. package/src/prove/smt/solver/ast-util.ts +147 -0
  137. package/src/prove/smt/solver/ast.ts +1315 -0
  138. package/src/prove/smt/solver/auf-solver.ts +572 -0
  139. package/src/prove/smt/solver/case-split-queue.ts +178 -0
  140. package/src/prove/smt/solver/cg-table.ts +175 -0
  141. package/src/prove/smt/solver/clause.ts +276 -0
  142. package/src/prove/smt/solver/conflict-resolution.ts +343 -0
  143. package/src/prove/smt/solver/context.ts +1292 -0
  144. package/src/prove/smt/solver/ctx-simplify.ts +334 -0
  145. package/src/prove/smt/solver/der.ts +224 -0
  146. package/src/prove/smt/solver/dyn-ack.ts +141 -0
  147. package/src/prove/smt/solver/e-matching.ts +659 -0
  148. package/src/prove/smt/solver/enode.ts +259 -0
  149. package/src/prove/smt/solver/expr-ref.ts +21 -0
  150. package/src/prove/smt/solver/expr-safe-replace.ts +172 -0
  151. package/src/prove/smt/solver/fingerprints.ts +92 -0
  152. package/src/prove/smt/solver/flat-literals.ts +51 -0
  153. package/src/prove/smt/solver/goal.ts +138 -0
  154. package/src/prove/smt/solver/hash.ts +173 -0
  155. package/src/prove/smt/solver/hashtable.ts +166 -0
  156. package/src/prove/smt/solver/internalizer.ts +1381 -0
  157. package/src/prove/smt/solver/lbool.ts +5 -0
  158. package/src/prove/smt/solver/literal.ts +24 -0
  159. package/src/prove/smt/solver/lp/bound-propagator.ts +391 -0
  160. package/src/prove/smt/solver/lp/constraints.ts +78 -0
  161. package/src/prove/smt/solver/lp/containers.ts +296 -0
  162. package/src/prove/smt/solver/lp/core-solver.ts +504 -0
  163. package/src/prove/smt/solver/lp/cross-nested.ts +224 -0
  164. package/src/prove/smt/solver/lp/dep-intervals.ts +656 -0
  165. package/src/prove/smt/solver/lp/dependency.ts +51 -0
  166. package/src/prove/smt/solver/lp/dioph-eq.ts +1181 -0
  167. package/src/prove/smt/solver/lp/explanation.ts +46 -0
  168. package/src/prove/smt/solver/lp/gomory.ts +255 -0
  169. package/src/prove/smt/solver/lp/hnf-cutter.ts +125 -0
  170. package/src/prove/smt/solver/lp/hnf.ts +281 -0
  171. package/src/prove/smt/solver/lp/int-cube.ts +295 -0
  172. package/src/prove/smt/solver/lp/int-solver.ts +514 -0
  173. package/src/prove/smt/solver/lp/lar-solver.ts +816 -0
  174. package/src/prove/smt/solver/lp/lar-term.ts +62 -0
  175. package/src/prove/smt/solver/lp/lp-settings.ts +91 -0
  176. package/src/prove/smt/solver/lp/maximize-term.ts +347 -0
  177. package/src/prove/smt/solver/lp/nex-creator.ts +381 -0
  178. package/src/prove/smt/solver/lp/nex.ts +120 -0
  179. package/src/prove/smt/solver/lp/nla-backoff.ts +43 -0
  180. package/src/prove/smt/solver/lp/nla-basics.ts +398 -0
  181. package/src/prove/smt/solver/lp/nla-core.ts +968 -0
  182. package/src/prove/smt/solver/lp/nla-divisions.ts +332 -0
  183. package/src/prove/smt/solver/lp/nla-emonics.ts +373 -0
  184. package/src/prove/smt/solver/lp/nla-factorization.ts +30 -0
  185. package/src/prove/smt/solver/lp/nla-grobner.ts +904 -0
  186. package/src/prove/smt/solver/lp/nla-horner.ts +126 -0
  187. package/src/prove/smt/solver/lp/nla-intervals.ts +265 -0
  188. package/src/prove/smt/solver/lp/nla-monomial-bounds.ts +715 -0
  189. package/src/prove/smt/solver/lp/nla-monotone.ts +59 -0
  190. package/src/prove/smt/solver/lp/nla-order.ts +307 -0
  191. package/src/prove/smt/solver/lp/nla-patcher.ts +112 -0
  192. package/src/prove/smt/solver/lp/nla-tangents.ts +251 -0
  193. package/src/prove/smt/solver/lp/nla-throttle.ts +85 -0
  194. package/src/prove/smt/solver/lp/nla-types.ts +124 -0
  195. package/src/prove/smt/solver/lp/nla-var-eqs.ts +141 -0
  196. package/src/prove/smt/solver/lp/nra-solver.ts +440 -0
  197. package/src/prove/smt/solver/lp/numeric-pair.ts +65 -0
  198. package/src/prove/smt/solver/lp/pdd-interval.ts +31 -0
  199. package/src/prove/smt/solver/lp/pdd-simplifier.ts +184 -0
  200. package/src/prove/smt/solver/lp/pdd-solver.ts +408 -0
  201. package/src/prove/smt/solver/lp/pdd.ts +971 -0
  202. package/src/prove/smt/solver/lp/random-updater.ts +138 -0
  203. package/src/prove/smt/solver/lp/static-matrix.ts +246 -0
  204. package/src/prove/smt/solver/lp/union-find.ts +96 -0
  205. package/src/prove/smt/solver/mam-compiler.ts +847 -0
  206. package/src/prove/smt/solver/mam-interpreter.ts +400 -0
  207. package/src/prove/smt/solver/maximize-ac-sharing.ts +118 -0
  208. package/src/prove/smt/solver/model-checker.ts +347 -0
  209. package/src/prove/smt/solver/model-evaluator.ts +262 -0
  210. package/src/prove/smt/solver/model-finder.ts +155 -0
  211. package/src/prove/smt/solver/model-generator.ts +97 -0
  212. package/src/prove/smt/solver/model-macro-solver.ts +728 -0
  213. package/src/prove/smt/solver/nlsat/algebraic.ts +1161 -0
  214. package/src/prove/smt/solver/nlsat/atoms.ts +238 -0
  215. package/src/prove/smt/solver/nlsat/evaluator.ts +303 -0
  216. package/src/prove/smt/solver/nlsat/explain.ts +607 -0
  217. package/src/prove/smt/solver/nlsat/interval-set.ts +351 -0
  218. package/src/prove/smt/solver/nlsat/levelwise.ts +740 -0
  219. package/src/prove/smt/solver/nlsat/mpbq.ts +161 -0
  220. package/src/prove/smt/solver/nlsat/polynomial.ts +1722 -0
  221. package/src/prove/smt/solver/nlsat/solver.ts +911 -0
  222. package/src/prove/smt/solver/nlsat/types.ts +43 -0
  223. package/src/prove/smt/solver/nlsat/upolynomial-factorization.ts +648 -0
  224. package/src/prove/smt/solver/nlsat/upolynomial.ts +996 -0
  225. package/src/prove/smt/solver/nnf.ts +469 -0
  226. package/src/prove/smt/solver/pattern-inference.ts +351 -0
  227. package/src/prove/smt/solver/poly-rewriter.ts +477 -0
  228. package/src/prove/smt/solver/propagate-values.ts +83 -0
  229. package/src/prove/smt/solver/proto-model.ts +551 -0
  230. package/src/prove/smt/solver/pull-quant.ts +139 -0
  231. package/src/prove/smt/solver/qe-lite-der.ts +526 -0
  232. package/src/prove/smt/solver/qe-lite-fm.ts +576 -0
  233. package/src/prove/smt/solver/qe-lite.ts +381 -0
  234. package/src/prove/smt/solver/qi-queue.ts +362 -0
  235. package/src/prove/smt/solver/quant-tactics.ts +117 -0
  236. package/src/prove/smt/solver/quantifier-analyzer.ts +562 -0
  237. package/src/prove/smt/solver/quantifier-manager.ts +186 -0
  238. package/src/prove/smt/solver/random-gen.ts +10 -0
  239. package/src/prove/smt/solver/rational.ts +165 -0
  240. package/src/prove/smt/solver/ref-vector.ts +62 -0
  241. package/src/prove/smt/solver/relevancy.ts +247 -0
  242. package/src/prove/smt/solver/rewriter-tpl.ts +1159 -0
  243. package/src/prove/smt/solver/rewriter.ts +843 -0
  244. package/src/prove/smt/solver/rlimit.ts +79 -0
  245. package/src/prove/smt/solver/smtlib-parser.ts +526 -0
  246. package/src/prove/smt/solver/solver.ts +71 -0
  247. package/src/prove/smt/solver/sort.ts +35 -0
  248. package/src/prove/smt/solver/sticky-generations.ts +69 -0
  249. package/src/prove/smt/solver/theory-lra-axioms.ts +340 -0
  250. package/src/prove/smt/solver/theory-lra-bounds.ts +226 -0
  251. package/src/prove/smt/solver/theory-lra-final-check.ts +252 -0
  252. package/src/prove/smt/solver/theory-lra-internalize.ts +476 -0
  253. package/src/prove/smt/solver/theory-lra-model.ts +243 -0
  254. package/src/prove/smt/solver/theory-lra-propagate.ts +405 -0
  255. package/src/prove/smt/solver/theory-lra-state.ts +43 -0
  256. package/src/prove/smt/solver/theory-lra.ts +56 -0
  257. package/src/prove/smt/solver/var-subst.ts +258 -0
  258. package/src/prove/smt/solver/z3-license.txt +10 -0
  259. package/src/prove/smt/table.ts +170 -0
  260. package/src/prove/tlapm/tlapm.ts +96 -0
  261. package/src/prove/tlaps-module.ts +510 -0
  262. package/src/prove/verdict.ts +13 -0
  263. package/src/prove/zenon/LICENSE +32 -0
  264. package/src/prove/zenon/check/check.ts +105 -0
  265. package/src/prove/zenon/check/definitions.ts +144 -0
  266. package/src/prove/zenon/check/equality.ts +182 -0
  267. package/src/prove/zenon/check/functions.ts +62 -0
  268. package/src/prove/zenon/check/keys.ts +125 -0
  269. package/src/prove/zenon/check/propositional.ts +104 -0
  270. package/src/prove/zenon/check/records.ts +188 -0
  271. package/src/prove/zenon/check/relations.ts +121 -0
  272. package/src/prove/zenon/check/rewrites.ts +224 -0
  273. package/src/prove/zenon/check/sets.ts +302 -0
  274. package/src/prove/zenon/check/terms.ts +127 -0
  275. package/src/prove/zenon/check/tla.ts +126 -0
  276. package/src/prove/zenon/decide.ts +113 -0
  277. package/src/prove/zenon/encode.ts +444 -0
  278. package/src/prove/zenon/eqrel.ts +300 -0
  279. package/src/prove/zenon/equality-rules.ts +435 -0
  280. package/src/prove/zenon/expr.ts +551 -0
  281. package/src/prove/zenon/index-table.ts +350 -0
  282. package/src/prove/zenon/isar-case.ts +513 -0
  283. package/src/prove/zenon/isar.ts +1249 -0
  284. package/src/prove/zenon/limits.ts +15 -0
  285. package/src/prove/zenon/llproof.ts +173 -0
  286. package/src/prove/zenon/mltoll.ts +1566 -0
  287. package/src/prove/zenon/node.ts +297 -0
  288. package/src/prove/zenon/ocaml.ts +169 -0
  289. package/src/prove/zenon/parse.ts +247 -0
  290. package/src/prove/zenon/phrase.ts +191 -0
  291. package/src/prove/zenon/proof.ts +198 -0
  292. package/src/prove/zenon/propositional-rules.ts +387 -0
  293. package/src/prove/zenon/rules.ts +94 -0
  294. package/src/prove/zenon/search.ts +288 -0
  295. package/src/prove/zenon/tla/functions.ts +151 -0
  296. package/src/prove/zenon/tla/llproof.ts +480 -0
  297. package/src/prove/zenon/tla/records.ts +225 -0
  298. package/src/prove/zenon/tla/rewrites.ts +447 -0
  299. package/src/prove/zenon/tla/sets.ts +304 -0
  300. package/src/prove/zenon/tla/terms.ts +181 -0
  301. package/src/prove/zenon/tla/tla.ts +506 -0
  302. package/src/run-cli.ts +73 -20
  303. package/src/standard-modules.ts +5 -2
  304. package/src/successors.ts +24 -5
  305. package/src/tlc-random.ts +55 -32
  306. package/src/tlc-version.ts +8 -7
  307. package/src/values.ts +85 -41
  308. package/src/worker.ts +65 -0
  309. package/dist/parallel.cjs +0 -12
  310. package/dist/parallel.js +0 -12
  311. /package/src/{obligation-format.ts → obligations/format.ts} +0 -0
@@ -1,7 +1,8 @@
1
1
  // tlapm's expression IR (E_t) with de Bruijn indices, and its substitutions (E_subst) and
2
2
  // alpha-equivalence (E_eq).
3
3
 
4
- import { TlaProofError } from "./errors";
4
+ import { TlaProofError } from "../errors";
5
+ import type { OldMethod, PragmaSetting } from "./pragma";
5
6
 
6
7
  export interface Locus {
7
8
  file: string;
@@ -171,7 +172,7 @@ export type ExprCore =
171
172
  | { kind: "Sequent"; sequent: Sequent }
172
173
  | { kind: "Bang"; expression: Expr; selectors: Selector[] }
173
174
  | { kind: "Apply"; operator: Expr; args: Expr[] }
174
- | { kind: "With"; expression: Expr; method: string }
175
+ | { kind: "With"; expression: Expr; method: OldMethod }
175
176
  | { kind: "If"; condition: Expr; consequent: Expr; alternative: Expr }
176
177
  | { kind: "List"; bullet: "And" | "Or" | "Refs"; items: Expr[] }
177
178
  | { kind: "Let"; definitions: Defn[]; body: Expr }
@@ -217,12 +218,16 @@ type DefnCore =
217
218
  | { kind: "Recursive"; name: string; shape: Shape }
218
219
  | { kind: "Operator"; name: string; body: Expr }
219
220
  | { kind: "Instance"; name: string; instance: InstanceDefinition }
220
- | { kind: "Bpragma"; name: string; body: Expr };
221
-
222
- export type WhereDefined = "Builtin" | "Proof" | "User";
221
+ | { kind: "Bpragma"; name: string; body: Expr; methods: PragmaSetting[][] };
223
222
 
224
223
  export type Visibility = "Visible" | "Hidden";
225
224
 
225
+ // When a fact holds: at every point of a behavior, or only at the current one.
226
+ export type Time = "Now" | "Always";
227
+
228
+ // A step or a DEFINE in a proof keeps the time of the scope it is made in.
229
+ export type WhereDefined = "Builtin" | "User" | { kind: "Proof"; time: Time };
230
+
226
231
  export type Hyp = HypCore & { location?: Locus };
227
232
 
228
233
  type HypCore =
@@ -241,8 +246,11 @@ type HypCore =
241
246
  whereDefined: WhereDefined;
242
247
  visibility: Visibility;
243
248
  isLocal: boolean;
249
+ // Module.Elab judges whether each module definition is constant. One that anonymization meets
250
+ // in a proof, such as a step or a DEFINE, has no judgment, so tlapm never counts it constant.
251
+ isConstnessUnset?: boolean;
244
252
  }
245
- | { kind: "Fact"; expression: Expr; visibility: Visibility };
253
+ | { kind: "Fact"; expression: Expr; visibility: Visibility; time: Time; useLocation?: Locus };
246
254
 
247
255
  export interface Sequent {
248
256
  context: Hyp[];
@@ -348,6 +356,44 @@ export const mapAccumulate = <State, Item, Result>(
348
356
  return [final, results];
349
357
  };
350
358
 
359
+ // A mapped context prefix: the hypothesis its last key maps to, if any, and the state after it.
360
+ interface MappedPrefix<State> {
361
+ state: State;
362
+ hyp: Hyp | undefined;
363
+ parent: MappedPrefix<State> | undefined;
364
+ next: WeakMap<Hyp, MappedPrefix<State>>;
365
+ }
366
+
367
+ // mapAccumulate over a context that maps each prefix of keys once, as the obligations of a module
368
+ // share most of their context by identity. The input at each position must depend on the keys up
369
+ // to it alone, and the step on the input, its key, and the state.
370
+ export const createContextMap = <State>(
371
+ initial: State,
372
+ step: (state: State, input: Hyp, key: Hyp) => [State, Hyp | undefined],
373
+ ) => {
374
+ const empty: MappedPrefix<State> = {
375
+ state: initial,
376
+ hyp: undefined,
377
+ parent: undefined,
378
+ next: new WeakMap(),
379
+ };
380
+ return (keys: Hyp[], inputs = keys) => {
381
+ const last = keys.reduce((prefix, key, index) => {
382
+ const known = prefix.next.get(key);
383
+ if (known) return known;
384
+ const [state, hyp] = step(prefix.state, inputs[index], key);
385
+ const mapped: MappedPrefix<State> = { state, hyp, parent: prefix, next: new WeakMap() };
386
+ prefix.next.set(key, mapped);
387
+ return mapped;
388
+ }, empty);
389
+ const context: Hyp[] = [];
390
+ for (let prefix: MappedPrefix<State> | undefined = last; prefix; prefix = prefix.parent) {
391
+ if (prefix.hyp) context.push(prefix.hyp);
392
+ }
393
+ return { state: last.state, context: context.reverse() };
394
+ };
395
+ };
396
+
351
397
  export const getFresh = (name: string, level: Level, shape = 0): Hyp => ({
352
398
  kind: "Fresh",
353
399
  name,
@@ -874,7 +920,7 @@ export const mapSelectorArgs = (selector: Selector, map: (arg: Expr) => Expr): S
874
920
  ? { ...selector, args: selector.args.map(map) }
875
921
  : selector;
876
922
 
877
- const mapExceptSpecs = (specs: ExceptSpec[], map: (inner: Expr) => Expr): ExceptSpec[] =>
923
+ export const mapExceptSpecs = (specs: ExceptSpec[], map: (inner: Expr) => Expr): ExceptSpec[] =>
878
924
  specs.map((spec) => {
879
925
  const value = map(spec.value);
880
926
  const trail = spec.trail.map((point): ExceptPoint =>
@@ -888,7 +934,7 @@ const mapDefnBody = (definition: Defn, map: (body: Expr) => Expr): Defn =>
888
934
  ? { ...definition, body: map(definition.body) }
889
935
  : definition;
890
936
 
891
- const mapHyp = (hyp: Hyp, map: (inner: Expr) => Expr, hyps: "visible" | "all"): Hyp => {
937
+ export const mapHyp = (hyp: Hyp, map: (inner: Expr) => Expr, hyps: "visible" | "all"): Hyp => {
892
938
  if (hyp.kind === "Fresh") return hyp.domain ? { ...hyp, domain: map(hyp.domain) } : hyp;
893
939
  if (hyp.kind === "Flex" || (hyps === "visible" && hyp.visibility === "Hidden")) return hyp;
894
940
  if (hyp.kind === "Defn") return { ...hyp, definition: mapDefnBody(hyp.definition, map) };
@@ -1,7 +1,7 @@
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,
@@ -22,12 +22,15 @@ import {
22
22
  type Locus,
23
23
  type ObligationWarning,
24
24
  type Sequent,
25
+ type Time,
25
26
  type Visibility,
26
27
  mapChildren,
27
28
  stripProps,
28
- } from "./obligation-expression";
29
- import { format, renderDoc, type Doc } from "./obligation-format";
30
- import { printExpression } from "./obligation-printer";
29
+ } from "./expression";
30
+ import { format, renderDoc, type Doc } from "./format";
31
+ import { printExpression } from "./printer";
32
+ import type { OldMethod } from "./pragma";
33
+ import { getScopeTime } from "./temporal";
31
34
  import {
32
35
  getStepName,
33
36
  getUnique,
@@ -39,7 +42,7 @@ import {
39
42
  type StepNumber,
40
43
  type UseDef,
41
44
  type Usable,
42
- } from "./obligation-proof";
45
+ } from "./proof";
43
46
 
44
47
  const AT_NOWHERE: Expr = { kind: "At", isExcept: false };
45
48
 
@@ -48,6 +51,7 @@ const getProps = (from: Step) => ({
48
51
  location: from.location,
49
52
  step: from.step,
50
53
  isSuppressed: from.isSuppressed,
54
+ method: from.method,
51
55
  });
52
56
 
53
57
  const isAnonymous = (step: StepNumber | undefined) => step?.kind === "Named" && step.isAnonymous;
@@ -101,24 +105,27 @@ const getAssumedFacts = (offset: number, sequent: Sequent) =>
101
105
  : [],
102
106
  );
103
107
 
104
- const getStepDefinition = (step: Step, body: Expr): Hyp => {
108
+ const getStepDefinition = (step: Step, body: Expr, time: Time): Hyp => {
105
109
  if (!step.step) throw new TlapmBugError();
106
110
  return {
107
111
  kind: "Defn",
108
112
  definition: { kind: "Operator", name: getStepName(step.step), body, location: step.location },
109
- whereDefined: "Proof",
113
+ whereDefined: { kind: "Proof", time },
110
114
  visibility: "Visible",
111
115
  isLocal: true,
112
116
  location: step.location,
113
117
  };
114
118
  };
115
119
 
116
- const proveAssertion = (context: Hyp[], sequent: Sequent, step: Step) => {
120
+ // The proof of an assertion leaves the always scope when the assertion assumes a fact that holds
121
+ // only now.
122
+ const proveAssertion = (context: Hyp[], sequent: Sequent, step: Step, time: Time) => {
117
123
  const visibility: Visibility = isAnonymous(step.step) ? "Visible" : "Hidden";
118
124
  const hyps = sequent.context.map((hyp): Hyp =>
119
125
  hyp.kind === "Fact" ? { ...hyp, visibility } : hyp,
120
126
  );
121
127
  const body = at({ kind: "List", bullet: "Refs", items: getAssumedFacts(2, sequent) }, step);
128
+ const scopeTime = getScopeTime(sequent.context, time);
122
129
  return {
123
130
  context: [
124
131
  ...context,
@@ -127,17 +134,20 @@ const proveAssertion = (context: Hyp[], sequent: Sequent, step: Step) => {
127
134
  kind: "Fact",
128
135
  expression: getTrue(step),
129
136
  visibility: "Hidden",
137
+ time,
130
138
  location: step.location,
131
139
  },
132
- getStepDefinition(step, body),
140
+ getStepDefinition(step, body, scopeTime),
133
141
  {
134
142
  kind: "Fact",
135
143
  expression: at({ kind: "Ix", index: 1 }, step),
136
144
  visibility: "Hidden",
145
+ time: scopeTime,
137
146
  location: step.location,
138
147
  },
139
148
  ] satisfies Hyp[],
140
149
  active: shiftExpr(3, sequent.active),
150
+ time: scopeTime,
141
151
  };
142
152
  };
143
153
 
@@ -147,16 +157,18 @@ const useAssertion = (
147
157
  goal: Expr,
148
158
  sequent: Sequent,
149
159
  step: Step,
160
+ time: Time,
150
161
  ) => {
151
162
  const visibility: Visibility = isSuffices || isAnonymous(step.step) ? "Visible" : "Hidden";
152
163
  return {
153
164
  context: [
154
165
  ...context,
155
- getStepDefinition(step, at(exprifySequent(sequent), step)),
166
+ getStepDefinition(step, at(exprifySequent(sequent), step), time),
156
167
  {
157
168
  kind: "Fact",
158
169
  expression: at({ kind: "Ix", index: 1 }, step),
159
170
  visibility,
171
+ time,
160
172
  location: step.location,
161
173
  },
162
174
  ] satisfies Hyp[],
@@ -164,7 +176,18 @@ const useAssertion = (
164
176
  };
165
177
  };
166
178
 
167
- const setDefinition = (visibility: Visibility, context: Hyp[], def: UseDef): Hyp[] => {
179
+ // A cited step or definition keeps the scope it was proved in, and any other fact takes the
180
+ // current one.
181
+ const getFactTime = (context: Hyp[], fact: Expr, time: Time): Time => {
182
+ if (fact.kind !== "Ix") return time;
183
+ const hyp = context[context.length - fact.index];
184
+ if (hyp?.kind === "Fact") return hyp.time;
185
+ return hyp?.kind === "Defn" && typeof hyp.whereDefined === "object"
186
+ ? hyp.whereDefined.time
187
+ : "Always";
188
+ };
189
+
190
+ export const setDefinition = (visibility: Visibility, context: Hyp[], def: UseDef): Hyp[] => {
168
191
  if (def.kind !== "Dx") throw new TlaProofError(`Unknown definition ${def.name}`);
169
192
  const index = context.length - def.index;
170
193
  const hyp = context[index];
@@ -181,7 +204,7 @@ const isDomainMatch = (fact: Expr, domain: Expr) =>
181
204
  fact.args[0].index === 0 &&
182
205
  isEqualExpr(domain, fact.args[1]);
183
206
 
184
- const setExpression = (
207
+ export const setExpression = (
185
208
  onWarning: (warning: ObligationWarning) => void,
186
209
  visibility: Visibility,
187
210
  fact: Expr,
@@ -216,7 +239,7 @@ export interface LineRange {
216
239
  }
217
240
 
218
241
  export interface Generator {
219
- generate: (sequent: Sequent, proof: Proof) => Proof;
242
+ generate: (sequent: Sequent, proof: Proof, time: Time) => Proof;
220
243
  collect: (proof: Proof) => Obligation[];
221
244
  mutate: (
222
245
  context: Hyp[],
@@ -224,7 +247,7 @@ export interface Generator {
224
247
  usable: Usable,
225
248
  location: Locus | undefined,
226
249
  ) => [Hyp[], Obligation[]];
227
- simplify: (context: Hyp[], goal: Expr, proof: Proof) => Proof;
250
+ simplify: (context: Hyp[], goal: Expr, proof: Proof, time: Time) => Proof;
228
251
  }
229
252
 
230
253
  // The bounds after a witnessed one, where a ditto takes the witnessed domain.
@@ -254,6 +277,7 @@ const getWitnessProof = (step: Step, aux: Expr[]): Proof => {
254
277
  usable: { facts: [shiftExpr(3, active)], defs: [] },
255
278
  isOnly: false,
256
279
  location: item.location,
280
+ method: step.method,
257
281
  },
258
282
  location: item.location,
259
283
  };
@@ -262,11 +286,13 @@ const getWitnessProof = (step: Step, aux: Expr[]): Proof => {
262
286
  at({ kind: "Ix", index: 2 * aux.length + 2 }, step),
263
287
  ...aux.map((_item, index) => at({ kind: "Ix", index: 2 * (aux.length - index) }, step)),
264
288
  ];
289
+ // tlapm removes the method from the QED.
265
290
  const qedProof: Proof = {
266
291
  kind: "By",
267
292
  usable: { facts, defs: [] },
268
293
  isOnly: true,
269
294
  ...getProps(step),
295
+ method: undefined,
270
296
  };
271
297
  return {
272
298
  kind: "Steps",
@@ -278,9 +304,9 @@ const getWitnessProof = (step: Step, aux: Expr[]): Proof => {
278
304
 
279
305
  const obligate = (
280
306
  sequent: Sequent,
281
- from: { location?: Locus },
307
+ from: { location?: Locus; method?: OldMethod },
282
308
  kind: ObligationKind,
283
- ): Obligation => ({ sequent, location: from.location, kind });
309
+ ): Obligation => ({ sequent, location: from.location, kind, method: from.method });
284
310
 
285
311
  export interface ProofSummary {
286
312
  total: number;
@@ -336,7 +362,7 @@ export const createGenerator = (
336
362
  lines: LineRange,
337
363
  onWarning: (warning: ObligationWarning) => void,
338
364
  ): Generator => {
339
- const generate = (sequent: Sequent, proof: Proof): Proof => {
365
+ const generate = (sequent: Sequent, proof: Proof, time: Time): Proof => {
340
366
  const location = proof.location;
341
367
  if (
342
368
  !location ||
@@ -361,14 +387,17 @@ export const createGenerator = (
361
387
  case "By":
362
388
  throw new TlaProofError("Proof.Gen.generate");
363
389
  case "Steps": {
364
- const [inner, steps] = mapAccumulate(sequent, proof.steps, generateStep);
365
- const qedProof = generate(inner, proof.qed.proof);
390
+ const [inner, steps] = mapAccumulate({ sequent, time }, proof.steps, (state, step) => {
391
+ const [next, generated, nextTime] = generateStep(state.sequent, step, state.time);
392
+ return [{ sequent: next, time: nextTime }, generated];
393
+ });
394
+ const qedProof = generate(inner.sequent, proof.qed.proof, inner.time);
366
395
  return { ...proof, steps, qed: { ...proof.qed, proof: qedProof } };
367
396
  }
368
397
  }
369
398
  };
370
399
 
371
- const generateStep = (sequent: Sequent, step: Step): [Sequent, Step] => {
400
+ const generateStep = (sequent: Sequent, step: Step, time: Time): [Sequent, Step, Time] => {
372
401
  switch (step.kind) {
373
402
  case "Forget": {
374
403
  const count = sequent.context.length;
@@ -377,7 +406,7 @@ export const createGenerator = (
377
406
  ? { ...hyp, visibility: "Hidden" }
378
407
  : hyp,
379
408
  );
380
- return [{ ...sequent, context }, step];
409
+ return [{ ...sequent, context }, step, time];
381
410
  }
382
411
  case "Use": {
383
412
  const usable = step.usable;
@@ -388,11 +417,19 @@ export const createGenerator = (
388
417
  {
389
418
  context: [
390
419
  ...sequent.context,
391
- { kind: "Fact", expression: fact, visibility: "Visible", location: fact.location },
420
+ {
421
+ kind: "Fact",
422
+ expression: fact,
423
+ visibility: "Visible",
424
+ time: getFactTime(sequent.context, fact, time),
425
+ location: fact.location,
426
+ useLocation: step.useLocation,
427
+ },
392
428
  ],
393
429
  active: shiftExpr(1, sequent.active),
394
430
  },
395
431
  { ...step, obligations: [obligation] },
432
+ time,
396
433
  ];
397
434
  }
398
435
  if (usable.facts.length > 0)
@@ -401,7 +438,7 @@ export const createGenerator = (
401
438
  (current, def) => setDefinition("Visible", current, def),
402
439
  sequent.context,
403
440
  );
404
- return [{ ...sequent, context }, step];
441
+ return [{ ...sequent, context }, step, time];
405
442
  }
406
443
  case "Hide": {
407
444
  const hidden = step.usable.defs.reduce(
@@ -412,7 +449,7 @@ export const createGenerator = (
412
449
  (current, fact) => setExpression(onWarning, "Hidden", fact, current),
413
450
  hidden,
414
451
  );
415
- return [{ ...sequent, context }, step];
452
+ return [{ ...sequent, context }, step, time];
416
453
  }
417
454
  case "Define":
418
455
  return [
@@ -431,22 +468,27 @@ export const createGenerator = (
431
468
  active: shiftExpr(step.definitions.length, sequent.active),
432
469
  },
433
470
  step,
471
+ time,
434
472
  ];
435
473
  case "Assert": {
436
- const proof = generate(proveAssertion(sequent.context, step.sequent, step), step.proof);
474
+ const inner = proveAssertion(sequent.context, step.sequent, step, time);
475
+ const proof = generate(inner, step.proof, inner.time);
437
476
  const generated: Step = { ...step, proof };
438
477
  return [
439
- useAssertion(false, sequent.context, sequent.active, step.sequent, generated),
478
+ useAssertion(false, sequent.context, sequent.active, step.sequent, generated, time),
440
479
  generated,
480
+ time,
441
481
  ];
442
482
  }
443
483
  case "Suffices": {
444
484
  const proof = generate(
445
- useAssertion(true, sequent.context, sequent.active, step.sequent, step),
485
+ useAssertion(true, sequent.context, sequent.active, step.sequent, step, time),
446
486
  step.proof,
487
+ time,
447
488
  );
448
489
  const generated: Step = { ...step, proof };
449
- return [proveAssertion(sequent.context, step.sequent, generated), generated];
490
+ const next = proveAssertion(sequent.context, step.sequent, generated, time);
491
+ return [next, generated, next.time];
450
492
  }
451
493
  default:
452
494
  throw new TlaProofError("Proof.Gen.gen_step");
@@ -463,8 +505,9 @@ export const createGenerator = (
463
505
  const [sequent, generated] = generateStep(
464
506
  { context, active: { ...AT_NOWHERE, location } },
465
507
  mode === "Use"
466
- ? { kind: "Use", usable, isOnly: false, location, step }
508
+ ? { kind: "Use", usable, isOnly: false, location, step, useLocation: location }
467
509
  : { kind: "Hide", usable, location, step },
510
+ "Always",
468
511
  );
469
512
  return [sequent.context, generated.obligations ?? []];
470
513
  };
@@ -626,7 +669,7 @@ export const createGenerator = (
626
669
  return { ...proof, steps };
627
670
  };
628
671
 
629
- const simplify = (context: Hyp[], goal: Expr, original: Proof): Proof => {
672
+ const simplify = (context: Hyp[], goal: Expr, original: Proof, time: Time): Proof => {
630
673
  const proof = expandAt(original);
631
674
  switch (proof.kind) {
632
675
  case "Obvious":
@@ -652,6 +695,7 @@ export const createGenerator = (
652
695
  isOnly: false,
653
696
  location: fact.location,
654
697
  isSuppressed: proof.isSuppressed,
698
+ useLocation: proof.location,
655
699
  }));
656
700
  const forget: Step[] = proof.isOnly
657
701
  ? [{ kind: "Forget", count: usable.facts.length, location: proof.location }]
@@ -666,6 +710,7 @@ export const createGenerator = (
666
710
  location: proof.location,
667
711
  step: getAnonymous(level),
668
712
  isSuppressed: proof.isSuppressed,
713
+ method: proof.method,
669
714
  };
670
715
  return {
671
716
  kind: "Steps",
@@ -679,44 +724,52 @@ export const createGenerator = (
679
724
  case "Steps": {
680
725
  let currentContext = context;
681
726
  let currentGoal = goal;
727
+ let currentTime = time;
682
728
  const steps = proof.steps.flatMap((step) => {
683
- const [nextContext, nextGoal, simplified] = simplifyStep(
729
+ const [nextContext, nextGoal, simplified, nextTime] = simplifyStep(
684
730
  currentContext,
685
731
  currentGoal,
686
732
  step,
733
+ currentTime,
687
734
  );
688
735
  currentContext = nextContext;
689
736
  currentGoal = nextGoal;
737
+ currentTime = nextTime;
690
738
  return simplified;
691
739
  });
692
- const qedProof = simplify(currentContext, currentGoal, proof.qed.proof);
740
+ const qedProof = simplify(currentContext, currentGoal, proof.qed.proof, currentTime);
693
741
  return { ...proof, steps, qed: { ...proof.qed, proof: qedProof } };
694
742
  }
695
743
  }
696
744
  };
697
745
 
698
- const simplifyStep = (context: Hyp[], goal: Expr, step: Step): [Hyp[], Expr, Step[]] => {
746
+ const simplifyStep = (
747
+ context: Hyp[],
748
+ goal: Expr,
749
+ step: Step,
750
+ time: Time,
751
+ ): [Hyp[], Expr, Step[], Time] => {
699
752
  const level = getLevel(step.step);
700
753
  switch (step.kind) {
701
754
  case "Forget":
702
- return [context, goal, [step]];
755
+ return [context, goal, [step], time];
703
756
  case "Assert": {
704
- const inner = proveAssertion(context, step.sequent, step);
757
+ const inner = proveAssertion(context, step.sequent, step, time);
705
758
  const simplified: Step = {
706
759
  ...step,
707
- proof: simplify(inner.context, inner.active, step.proof),
760
+ proof: simplify(inner.context, inner.active, step.proof, inner.time),
708
761
  };
709
- const next = useAssertion(false, context, goal, step.sequent, simplified);
710
- return [next.context, next.active, [simplified]];
762
+ const next = useAssertion(false, context, goal, step.sequent, simplified, time);
763
+ return [next.context, next.active, [simplified], time];
711
764
  }
712
765
  case "Suffices": {
713
- const inner = useAssertion(true, context, goal, step.sequent, step);
766
+ const inner = useAssertion(true, context, goal, step.sequent, step, time);
714
767
  const simplified: Step = {
715
768
  ...step,
716
- proof: simplify(inner.context, inner.active, step.proof),
769
+ proof: simplify(inner.context, inner.active, step.proof, time),
717
770
  };
718
- const next = proveAssertion(context, step.sequent, simplified);
719
- return [next.context, next.active, [simplified]];
771
+ const next = proveAssertion(context, step.sequent, simplified, time);
772
+ return [next.context, next.active, [simplified], next.time];
720
773
  }
721
774
  case "Use": {
722
775
  const byProof: Proof = {
@@ -726,20 +779,23 @@ export const createGenerator = (
726
779
  location: step.location,
727
780
  step: step.step,
728
781
  isSuppressed: step.isSuppressed,
782
+ method: step.method,
729
783
  };
730
- const simplified = simplify(context, goal, byProof);
784
+ const simplified = simplify(context, goal, byProof, time);
731
785
  if (simplified.kind !== "Steps")
732
786
  throw new TlaProofError("simplifying BY does not produce a non-leaf proof!");
733
787
  const assumed = step.usable.facts.map((): Hyp => ({
734
788
  kind: "Fact",
735
789
  expression: AT_NOWHERE,
736
790
  visibility: "Visible",
791
+ time,
737
792
  location: step.location,
738
793
  }));
739
794
  return [
740
795
  [...context, ...assumed],
741
796
  shiftExpr(step.usable.facts.length, goal),
742
797
  simplified.steps,
798
+ time,
743
799
  ];
744
800
  }
745
801
  case "Hide": {
@@ -759,7 +815,7 @@ export const createGenerator = (
759
815
  : entry,
760
816
  );
761
817
  }, context);
762
- return [hidden, goal, [step]];
818
+ return [hidden, goal, [step], time];
763
819
  }
764
820
  case "Define":
765
821
  return [
@@ -768,7 +824,7 @@ export const createGenerator = (
768
824
  ...step.definitions.map((definition): Hyp => ({
769
825
  kind: "Defn",
770
826
  definition,
771
- whereDefined: "Proof",
827
+ whereDefined: { kind: "Proof", time },
772
828
  visibility: "Visible",
773
829
  isLocal: true,
774
830
  location: step.location,
@@ -776,6 +832,7 @@ export const createGenerator = (
776
832
  ],
777
833
  shiftExpr(step.definitions.length, goal),
778
834
  [step],
835
+ time,
779
836
  ];
780
837
  case "Have": {
781
838
  const connective = exposeConnective(context, goal);
@@ -783,6 +840,7 @@ export const createGenerator = (
783
840
  kind: "Fact",
784
841
  expression: step.expression,
785
842
  visibility: "Visible",
843
+ time,
786
844
  location: step.location,
787
845
  };
788
846
  const isImplication = isBinary(connective, "Implies");
@@ -814,19 +872,21 @@ export const createGenerator = (
814
872
  location: step.location,
815
873
  step: step.step,
816
874
  });
817
- return simplifyStep(context, goal, suffices);
875
+ return simplifyStep(context, goal, suffices, time);
818
876
  }
819
877
  case "Take":
820
878
  return simplifyStep(
821
879
  context,
822
880
  goal,
823
881
  renumberStep(level, getTakeSuffices(context, goal, step)),
882
+ time,
824
883
  );
825
884
  case "Witness":
826
885
  return simplifyStep(
827
886
  context,
828
887
  goal,
829
888
  renumberStep(level, getWitnessSuffices(context, goal, step)),
889
+ time,
830
890
  );
831
891
  case "Pcase": {
832
892
  const assertion: Step = {
@@ -837,6 +897,7 @@ export const createGenerator = (
837
897
  kind: "Fact",
838
898
  expression: step.expression,
839
899
  visibility: "Visible",
900
+ time,
840
901
  location: step.location,
841
902
  },
842
903
  ],
@@ -845,7 +906,7 @@ export const createGenerator = (
845
906
  proof: step.proof,
846
907
  ...getProps(step),
847
908
  };
848
- return simplifyStep(context, goal, renumberStep(level, assertion));
909
+ return simplifyStep(context, goal, renumberStep(level, assertion), time);
849
910
  }
850
911
  case "Pick": {
851
912
  const existential: Expr = at(
@@ -853,13 +914,18 @@ export const createGenerator = (
853
914
  step,
854
915
  );
855
916
  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
- });
917
+ const [assertContext, assertGoal, asserted, assertTime] = simplifyStep(
918
+ context,
919
+ goal,
920
+ {
921
+ kind: "Assert",
922
+ sequent: { context: [], active: existential },
923
+ proof: step.proof,
924
+ ...getProps(step),
925
+ step: salted,
926
+ },
927
+ time,
928
+ );
863
929
  const shifted = shiftExpr(2, existential);
864
930
  if (shifted.kind !== "Quant") throw new TlaProofError("Proof.Simplify.simplify_step/PICK");
865
931
  const hyps = [
@@ -868,16 +934,22 @@ export const createGenerator = (
868
934
  kind: "Fact",
869
935
  expression: shifted.body,
870
936
  visibility: "Visible",
937
+ time: assertTime,
871
938
  location: shifted.body.location,
872
939
  } satisfies Hyp,
873
940
  ];
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]];
941
+ const [nextContext, nextGoal, sufficed, nextTime] = simplifyStep(
942
+ assertContext,
943
+ assertGoal,
944
+ {
945
+ kind: "Suffices",
946
+ sequent: { context: hyps, active: shiftExpr(hyps.length, assertGoal) },
947
+ proof: { kind: "Omitted", omission: "Elsewhere", ...getProps(step) },
948
+ ...getProps(step),
949
+ },
950
+ assertTime,
951
+ );
952
+ return [nextContext, nextGoal, [...asserted, ...sufficed], nextTime];
881
953
  }
882
954
  }
883
955
  };
@@ -974,6 +1046,7 @@ export const createGenerator = (
974
1046
  kind: "Fact",
975
1047
  expression: getTrue(goal),
976
1048
  visibility: "Visible",
1049
+ time: "Now",
977
1050
  location: step.location,
978
1051
  },
979
1052
  ],