tla-ts 0.0.9 → 0.0.10-dev.28c823e4b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (390) hide show
  1. package/README.md +29 -1
  2. package/dist/compile.cjs +23 -0
  3. package/dist/compile.js +23 -0
  4. package/dist/deciders.cjs +28 -28
  5. package/dist/deciders.js +43 -43
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.cts +106 -10
  8. package/dist/index.d.ts +106 -10
  9. package/dist/index.js +1 -1
  10. package/dist/parallel-worker.cjs +1 -1
  11. package/dist/parallel-worker.js +1 -1
  12. package/dist/prove-worker.cjs +1 -1
  13. package/dist/prove-worker.js +1 -1
  14. package/dist/prove.cjs +116 -36
  15. package/dist/prove.js +116 -36
  16. package/dist/run.cjs +143 -31
  17. package/dist/run.js +143 -31
  18. package/dist/tlapm.cjs +2 -2
  19. package/dist/tlapm.js +2 -2
  20. package/dist/transfer.cjs +129 -104
  21. package/dist/transfer.js +129 -104
  22. package/dist/worker.cjs +7 -7
  23. package/dist/worker.js +7 -7
  24. package/package.json +3 -1
  25. package/src/ast.ts +4 -23
  26. package/src/bags.ts +99 -102
  27. package/src/builtins.ts +40 -78
  28. package/src/bundled-modules.ts +1 -8
  29. package/src/check.ts +599 -388
  30. package/src/cli/options.ts +11 -6
  31. package/src/cli/run.ts +0 -2
  32. package/src/cli/runtime-invariants.ts +136 -0
  33. package/src/cli/shared.ts +18 -11
  34. package/src/cli/tlapm.ts +0 -12
  35. package/src/cli/tlc-arguments.ts +640 -0
  36. package/src/cli/tlc-usage.ts +361 -0
  37. package/src/cli/tlc.ts +538 -220
  38. package/src/cli/typescript.ts +23 -0
  39. package/src/cli/xml-exporter.ts +4 -16
  40. package/src/cli.ts +0 -1
  41. package/src/codegen.ts +191 -64
  42. package/src/config.ts +140 -109
  43. package/src/coverage.ts +837 -0
  44. package/src/dependencies.ts +6 -40
  45. package/src/dfid.ts +618 -0
  46. package/src/environment.ts +240 -118
  47. package/src/errors.ts +70 -55
  48. package/src/evaluate.ts +596 -339
  49. package/src/exit-codes.ts +37 -3
  50. package/src/fingerprints.ts +10 -10
  51. package/src/index.ts +3 -0
  52. package/src/instances.ts +79 -11
  53. package/src/java-overrides.ts +4 -19
  54. package/src/json-reader.ts +455 -0
  55. package/src/json.ts +255 -139
  56. package/src/levels.ts +8 -17
  57. package/src/lexer.ts +80 -100
  58. package/src/liveness-checker.ts +82 -119
  59. package/src/liveness.ts +112 -64
  60. package/src/obligations/action.ts +4 -28
  61. package/src/obligations/anonymize.ts +84 -80
  62. package/src/obligations/equality.ts +1 -1
  63. package/src/obligations/expression.ts +2 -19
  64. package/src/obligations/format.ts +1 -9
  65. package/src/obligations/generate.ts +1 -11
  66. package/src/obligations/index.ts +0 -11
  67. package/src/obligations/levels.ts +4 -8
  68. package/src/obligations/module.ts +1 -15
  69. package/src/obligations/normalize.ts +5 -24
  70. package/src/obligations/operators.ts +1 -2
  71. package/src/obligations/pragma.ts +1 -10
  72. package/src/obligations/printer.ts +47 -46
  73. package/src/obligations/proof.ts +1 -5
  74. package/src/obligations/regroup.ts +1 -4
  75. package/src/obligations/simplify.ts +3 -14
  76. package/src/obligations/source.ts +1 -21
  77. package/src/obligations/subexpression.ts +5 -11
  78. package/src/obligations/substitution.ts +1 -3
  79. package/src/obligations/temporal.ts +8 -14
  80. package/src/obligations/tuples.ts +3 -9
  81. package/src/parallel-worker.ts +29 -39
  82. package/src/parallel.ts +53 -44
  83. package/src/parser.ts +565 -282
  84. package/src/pcal/ast.ts +53 -86
  85. package/src/pcal/parse.ts +144 -219
  86. package/src/pcal/tokenize.ts +91 -131
  87. package/src/pcal/translate.ts +83 -130
  88. package/src/pcal/validate.ts +48 -68
  89. package/src/pretty-print.ts +7 -8
  90. package/src/prover/decide-pool.ts +5 -10
  91. package/src/prover/deciders.ts +0 -4
  92. package/src/prover/first-order.ts +0 -11
  93. package/src/prover/isabelle/decide.ts +0 -6
  94. package/src/prover/isabelle/encode.ts +11 -23
  95. package/src/prover/isabelle/isar/inner-syntax.ts +108 -114
  96. package/src/prover/isabelle/isar/method.ts +25 -38
  97. package/src/prover/isabelle/isar/proof.ts +1 -10
  98. package/src/prover/isabelle/isar/statement.ts +1 -6
  99. package/src/prover/isabelle/isar/theory.ts +15 -26
  100. package/src/prover/isabelle/isar/type-check.ts +11 -25
  101. package/src/prover/isabelle/provers/blast/blast.ts +10 -41
  102. package/src/prover/isabelle/provers/blast/branch.ts +1 -32
  103. package/src/prover/isabelle/provers/blast/prove.ts +1 -35
  104. package/src/prover/isabelle/provers/blast/rules.ts +6 -44
  105. package/src/prover/isabelle/provers/blast/state.ts +2 -28
  106. package/src/prover/isabelle/provers/blast/term.ts +9 -36
  107. package/src/prover/isabelle/provers/clasimp.ts +1 -13
  108. package/src/prover/isabelle/provers/classical.ts +14 -42
  109. package/src/prover/isabelle/provers/hypsubst.ts +11 -25
  110. package/src/prover/isabelle/pure/bicompose.ts +16 -13
  111. package/src/prover/isabelle/pure/consts.ts +1 -7
  112. package/src/prover/isabelle/pure/conv.ts +1 -9
  113. package/src/prover/isabelle/pure/drule.ts +24 -40
  114. package/src/prover/isabelle/pure/envir.ts +3 -52
  115. package/src/prover/isabelle/pure/goal.ts +1 -7
  116. package/src/prover/isabelle/pure/interrupt.ts +0 -5
  117. package/src/prover/isabelle/pure/list.ts +0 -3
  118. package/src/prover/isabelle/pure/logic.ts +1 -14
  119. package/src/prover/isabelle/pure/name.ts +2 -9
  120. package/src/prover/isabelle/pure/net.ts +3 -59
  121. package/src/prover/isabelle/pure/object-logic.ts +3 -10
  122. package/src/prover/isabelle/pure/pattern.ts +2 -19
  123. package/src/prover/isabelle/pure/raw-simplifier.ts +13 -49
  124. package/src/prover/isabelle/pure/rewriter.ts +26 -58
  125. package/src/prover/isabelle/pure/search.ts +3 -10
  126. package/src/prover/isabelle/pure/seq.ts +1 -10
  127. package/src/prover/isabelle/pure/simplifier.ts +4 -12
  128. package/src/prover/isabelle/pure/table.ts +1 -31
  129. package/src/prover/isabelle/pure/tactic.ts +12 -22
  130. package/src/prover/isabelle/pure/tactical.ts +6 -12
  131. package/src/prover/isabelle/pure/term-ord.ts +2 -6
  132. package/src/prover/isabelle/pure/term.ts +2 -43
  133. package/src/prover/isabelle/pure/thm.ts +13 -36
  134. package/src/prover/isabelle/pure/type.ts +2 -15
  135. package/src/prover/isabelle/pure/unify.ts +20 -30
  136. package/src/prover/isabelle/pure/variable.ts +3 -7
  137. package/src/prover/isabelle/tla/classical-setup.ts +9 -19
  138. package/src/prover/isabelle/tla/context.ts +8 -16
  139. package/src/prover/isabelle/tla/logic.ts +4 -11
  140. package/src/prover/isabelle/tla/simpdata.ts +46 -34
  141. package/src/prover/isabelle/tools/intuitionistic.ts +1 -10
  142. package/src/prover/ocaml.ts +0 -6
  143. package/src/prover/prep/action.ts +4 -36
  144. package/src/prover/prep/enabled-axioms.ts +12 -19
  145. package/src/prover/prep/fingerprint.ts +0 -16
  146. package/src/prover/prep/level-comparison.ts +8 -12
  147. package/src/prover/prep/md5.ts +0 -2
  148. package/src/prover/prep/methods.ts +9 -36
  149. package/src/prover/prep/normalize.ts +4 -28
  150. package/src/prover/prove-worker.ts +0 -2
  151. package/src/prover/prove.ts +0 -36
  152. package/src/prover/ptl/decide.ts +7 -12
  153. package/src/prover/ptl/encode.ts +14 -36
  154. package/src/prover/ptl/sat.ts +24 -32
  155. package/src/prover/ptl/tableau.ts +12 -26
  156. package/src/prover/smt/axioms.ts +0 -7
  157. package/src/prover/smt/context.ts +19 -26
  158. package/src/prover/smt/data.ts +51 -54
  159. package/src/prover/smt/encode.ts +14 -35
  160. package/src/prover/smt/extensionality.ts +0 -10
  161. package/src/prover/smt/flatten.ts +3 -22
  162. package/src/prover/smt/format.ts +5 -10
  163. package/src/prover/smt/instances.ts +0 -10
  164. package/src/prover/smt/rewrite.ts +66 -101
  165. package/src/prover/smt/solver/act-cache.ts +0 -15
  166. package/src/prover/smt/solver/arith-rewriter.ts +3 -48
  167. package/src/prover/smt/solver/array.ts +1 -3
  168. package/src/prover/smt/solver/asserted-formulas.ts +1 -43
  169. package/src/prover/smt/solver/ast-lt.ts +1 -11
  170. package/src/prover/smt/solver/ast-util.ts +1 -6
  171. package/src/prover/smt/solver/ast.ts +1 -143
  172. package/src/prover/smt/solver/auf-solver.ts +6 -39
  173. package/src/prover/smt/solver/case-split-queue.ts +1 -9
  174. package/src/prover/smt/solver/cg-table.ts +1 -18
  175. package/src/prover/smt/solver/clause.ts +1 -27
  176. package/src/prover/smt/solver/conflict-resolution.ts +0 -9
  177. package/src/prover/smt/solver/context.ts +4 -61
  178. package/src/prover/smt/solver/ctx-simplify.ts +14 -41
  179. package/src/prover/smt/solver/der.ts +2 -21
  180. package/src/prover/smt/solver/dyn-ack.ts +1 -11
  181. package/src/prover/smt/solver/e-matching.ts +3 -34
  182. package/src/prover/smt/solver/enode.ts +1 -21
  183. package/src/prover/smt/solver/expr-ref.ts +1 -5
  184. package/src/prover/smt/solver/expr-safe-replace.ts +0 -5
  185. package/src/prover/smt/solver/fingerprints.ts +1 -12
  186. package/src/prover/smt/solver/flat-literals.ts +1 -9
  187. package/src/prover/smt/solver/goal.ts +2 -14
  188. package/src/prover/smt/solver/hash.ts +0 -8
  189. package/src/prover/smt/solver/hashtable.ts +1 -12
  190. package/src/prover/smt/solver/internalizer.ts +6 -98
  191. package/src/prover/smt/solver/lbool.ts +1 -2
  192. package/src/prover/smt/solver/literal.ts +0 -3
  193. package/src/prover/smt/solver/lp/bound-propagator.ts +8 -26
  194. package/src/prover/smt/solver/lp/constraints.ts +2 -8
  195. package/src/prover/smt/solver/lp/containers.ts +12 -30
  196. package/src/prover/smt/solver/lp/core-solver.ts +10 -31
  197. package/src/prover/smt/solver/lp/cross-nested.ts +6 -20
  198. package/src/prover/smt/solver/lp/dep-intervals.ts +7 -22
  199. package/src/prover/smt/solver/lp/dependency.ts +1 -4
  200. package/src/prover/smt/solver/lp/dioph-eq.ts +12 -98
  201. package/src/prover/smt/solver/lp/explanation.ts +1 -6
  202. package/src/prover/smt/solver/lp/gomory.ts +9 -22
  203. package/src/prover/smt/solver/lp/hnf-cutter.ts +17 -23
  204. package/src/prover/smt/solver/lp/hnf.ts +11 -26
  205. package/src/prover/smt/solver/lp/int-cube.ts +15 -36
  206. package/src/prover/smt/solver/lp/int-solver.ts +4 -34
  207. package/src/prover/smt/solver/lp/lar-solver.ts +32 -81
  208. package/src/prover/smt/solver/lp/lar-term.ts +1 -5
  209. package/src/prover/smt/solver/lp/lp-settings.ts +1 -14
  210. package/src/prover/smt/solver/lp/maximize-term.ts +20 -45
  211. package/src/prover/smt/solver/lp/nex-creator.ts +5 -28
  212. package/src/prover/smt/solver/lp/nex.ts +1 -6
  213. package/src/prover/smt/solver/lp/nla-backoff.ts +1 -4
  214. package/src/prover/smt/solver/lp/nla-basics.ts +5 -30
  215. package/src/prover/smt/solver/lp/nla-core.ts +35 -130
  216. package/src/prover/smt/solver/lp/nla-divisions.ts +32 -42
  217. package/src/prover/smt/solver/lp/nla-emonics.ts +4 -21
  218. package/src/prover/smt/solver/lp/nla-factorization.ts +1 -4
  219. package/src/prover/smt/solver/lp/nla-grobner.ts +15 -69
  220. package/src/prover/smt/solver/lp/nla-horner.ts +3 -11
  221. package/src/prover/smt/solver/lp/nla-intervals.ts +2 -12
  222. package/src/prover/smt/solver/lp/nla-monomial-bounds.ts +16 -41
  223. package/src/prover/smt/solver/lp/nla-monotone.ts +2 -6
  224. package/src/prover/smt/solver/lp/nla-order.ts +2 -13
  225. package/src/prover/smt/solver/lp/nla-patcher.ts +4 -7
  226. package/src/prover/smt/solver/lp/nla-tangents.ts +1 -9
  227. package/src/prover/smt/solver/lp/nla-throttle.ts +1 -6
  228. package/src/prover/smt/solver/lp/nla-types.ts +1 -11
  229. package/src/prover/smt/solver/lp/nla-var-eqs.ts +4 -25
  230. package/src/prover/smt/solver/lp/nra-solver.ts +5 -52
  231. package/src/prover/smt/solver/lp/numeric-pair.ts +1 -4
  232. package/src/prover/smt/solver/lp/pdd-interval.ts +1 -3
  233. package/src/prover/smt/solver/lp/pdd-simplifier.ts +2 -14
  234. package/src/prover/smt/solver/lp/pdd-solver.ts +4 -33
  235. package/src/prover/smt/solver/lp/pdd.ts +7 -70
  236. package/src/prover/smt/solver/lp/random-updater.ts +1 -8
  237. package/src/prover/smt/solver/lp/static-matrix.ts +9 -19
  238. package/src/prover/smt/solver/lp/union-find.ts +1 -6
  239. package/src/prover/smt/solver/mam-compiler.ts +14 -56
  240. package/src/prover/smt/solver/mam-interpreter.ts +1 -21
  241. package/src/prover/smt/solver/maximize-ac-sharing.ts +2 -17
  242. package/src/prover/smt/solver/model-checker.ts +2 -36
  243. package/src/prover/smt/solver/model-evaluator.ts +3 -29
  244. package/src/prover/smt/solver/model-finder.ts +3 -15
  245. package/src/prover/smt/solver/model-generator.ts +1 -12
  246. package/src/prover/smt/solver/model-macro-solver.ts +12 -69
  247. package/src/prover/smt/solver/nlsat/algebraic.ts +55 -151
  248. package/src/prover/smt/solver/nlsat/atoms.ts +5 -19
  249. package/src/prover/smt/solver/nlsat/evaluator.ts +17 -22
  250. package/src/prover/smt/solver/nlsat/explain.ts +3 -47
  251. package/src/prover/smt/solver/nlsat/interval-set.ts +9 -50
  252. package/src/prover/smt/solver/nlsat/levelwise.ts +48 -129
  253. package/src/prover/smt/solver/nlsat/mpbq.ts +3 -14
  254. package/src/prover/smt/solver/nlsat/polynomial.ts +17 -156
  255. package/src/prover/smt/solver/nlsat/solver.ts +7 -67
  256. package/src/prover/smt/solver/nlsat/types.ts +1 -8
  257. package/src/prover/smt/solver/nlsat/upolynomial-factorization.ts +1 -44
  258. package/src/prover/smt/solver/nlsat/upolynomial.ts +11 -92
  259. package/src/prover/smt/solver/nnf.ts +3 -38
  260. package/src/prover/smt/solver/pattern-inference.ts +2 -15
  261. package/src/prover/smt/solver/poly-rewriter.ts +3 -23
  262. package/src/prover/smt/solver/propagate-values.ts +1 -10
  263. package/src/prover/smt/solver/proto-model.ts +3 -48
  264. package/src/prover/smt/solver/pull-quant.ts +1 -12
  265. package/src/prover/smt/solver/qe-lite-der.ts +1 -29
  266. package/src/prover/smt/solver/qe-lite-fm.ts +2 -25
  267. package/src/prover/smt/solver/qe-lite.ts +3 -33
  268. package/src/prover/smt/solver/qi-queue.ts +1 -16
  269. package/src/prover/smt/solver/quant-tactics.ts +5 -22
  270. package/src/prover/smt/solver/quantifier-analyzer.ts +17 -37
  271. package/src/prover/smt/solver/quantifier-manager.ts +1 -8
  272. package/src/prover/smt/solver/random-gen.ts +1 -2
  273. package/src/prover/smt/solver/rational.ts +1 -8
  274. package/src/prover/smt/solver/ref-vector.ts +1 -6
  275. package/src/prover/smt/solver/relevancy.ts +2 -15
  276. package/src/prover/smt/solver/rewriter-tpl.ts +3 -147
  277. package/src/prover/smt/solver/rewriter.ts +3 -85
  278. package/src/prover/smt/solver/rlimit.ts +2 -20
  279. package/src/prover/smt/solver/smtlib-parser.ts +2 -37
  280. package/src/prover/smt/solver/solver.ts +23 -34
  281. package/src/prover/smt/solver/sort.ts +1 -5
  282. package/src/prover/smt/solver/sticky-generations.ts +0 -5
  283. package/src/prover/smt/solver/theory-lra-axioms.ts +3 -24
  284. package/src/prover/smt/solver/theory-lra-bounds.ts +0 -5
  285. package/src/prover/smt/solver/theory-lra-final-check.ts +4 -22
  286. package/src/prover/smt/solver/theory-lra-internalize.ts +1 -27
  287. package/src/prover/smt/solver/theory-lra-model.ts +4 -19
  288. package/src/prover/smt/solver/theory-lra-propagate.ts +1 -15
  289. package/src/prover/smt/solver/theory-lra-state.ts +3 -8
  290. package/src/prover/smt/solver/theory-lra.ts +1 -8
  291. package/src/prover/smt/solver/var-subst.ts +2 -26
  292. package/src/prover/smt/table.ts +0 -8
  293. package/src/prover/tlapm/cache.ts +20 -25
  294. package/src/prover/tlapm/ocaml-marshal.ts +19 -21
  295. package/src/prover/tlapm/tlapm.ts +12 -17
  296. package/src/prover/verdict.ts +0 -2
  297. package/src/prover/zenon/check/check.ts +0 -9
  298. package/src/prover/zenon/check/definitions.ts +5 -15
  299. package/src/prover/zenon/check/equality.ts +0 -8
  300. package/src/prover/zenon/check/functions.ts +0 -4
  301. package/src/prover/zenon/check/keys.ts +0 -7
  302. package/src/prover/zenon/check/propositional.ts +0 -3
  303. package/src/prover/zenon/check/records.ts +0 -5
  304. package/src/prover/zenon/check/relations.ts +0 -13
  305. package/src/prover/zenon/check/rewrites.ts +0 -6
  306. package/src/prover/zenon/check/sets.ts +0 -3
  307. package/src/prover/zenon/check/terms.ts +0 -17
  308. package/src/prover/zenon/check/tla.ts +0 -6
  309. package/src/prover/zenon/decide.ts +0 -12
  310. package/src/prover/zenon/encode.ts +1 -8
  311. package/src/prover/zenon/eqrel.ts +0 -13
  312. package/src/prover/zenon/equality-rules.ts +0 -4
  313. package/src/prover/zenon/expr.ts +1 -26
  314. package/src/prover/zenon/index-table.ts +17 -38
  315. package/src/prover/zenon/isar-case.ts +9 -19
  316. package/src/prover/zenon/isar.ts +1 -29
  317. package/src/prover/zenon/limits.ts +0 -4
  318. package/src/prover/zenon/llproof.ts +0 -9
  319. package/src/prover/zenon/mltoll.ts +54 -76
  320. package/src/prover/zenon/node.ts +1 -11
  321. package/src/prover/zenon/ocaml.ts +1 -17
  322. package/src/prover/zenon/parse.ts +2 -7
  323. package/src/prover/zenon/phrase.ts +1 -11
  324. package/src/prover/zenon/proof.ts +0 -9
  325. package/src/prover/zenon/propositional-rules.ts +0 -5
  326. package/src/prover/zenon/rules.ts +2 -6
  327. package/src/prover/zenon/search.ts +1 -17
  328. package/src/prover/zenon/tla/functions.ts +57 -29
  329. package/src/prover/zenon/tla/llproof.ts +63 -70
  330. package/src/prover/zenon/tla/records.ts +56 -27
  331. package/src/prover/zenon/tla/rewrites.ts +12 -19
  332. package/src/prover/zenon/tla/sets.ts +68 -39
  333. package/src/prover/zenon/tla/terms.ts +0 -6
  334. package/src/prover/zenon/tla/tla.ts +59 -58
  335. package/src/randomization.ts +81 -35
  336. package/src/resolve.ts +12 -112
  337. package/src/runtime.ts +22 -22
  338. package/src/sany/builtins.ts +2 -5
  339. package/src/sany/generator.ts +149 -252
  340. package/src/sany/levels.ts +6 -34
  341. package/src/sany/lexer.ts +41 -61
  342. package/src/sany/linter.ts +1 -9
  343. package/src/sany/modules.ts +1 -5
  344. package/src/sany/nodes.ts +0 -31
  345. package/src/sany/parse-error.ts +39 -117
  346. package/src/sany/report.ts +29 -63
  347. package/src/sany/selectors.ts +15 -39
  348. package/src/sany/source.ts +1 -17
  349. package/src/sany/xml.ts +13 -63
  350. package/src/search.ts +495 -155
  351. package/src/simulate.ts +685 -0
  352. package/src/spec-description.ts +176 -69
  353. package/src/standard-definitions.ts +0 -4
  354. package/src/standard-modules.ts +254 -69
  355. package/src/state-graph.ts +50 -24
  356. package/src/subexpressions.ts +69 -52
  357. package/src/substitution-levels.ts +2 -3
  358. package/src/successors.ts +263 -94
  359. package/src/symmetry.ts +33 -25
  360. package/src/tableau.ts +27 -24
  361. package/src/tlc/fingerprint.ts +183 -67
  362. package/src/tlc/jar-data.ts +112 -6
  363. package/src/tlc/messages.ts +110 -44
  364. package/src/tlc/order.ts +37 -60
  365. package/src/tlc/random.ts +33 -45
  366. package/src/tlc/replay.ts +549 -217
  367. package/src/tlc/summary.ts +36 -47
  368. package/src/tlc/tlc-operators.ts +76 -41
  369. package/src/tlc/tlcext-operators.ts +139 -122
  370. package/src/tlc/trace-spec.ts +269 -0
  371. package/src/tlc/value-stream.ts +139 -0
  372. package/src/tlc/version.ts +1 -4
  373. package/src/transfer.ts +22 -25
  374. package/src/typescript/actions.ts +481 -0
  375. package/src/typescript/collections.ts +600 -0
  376. package/src/typescript/compile.ts +65 -0
  377. package/src/typescript/context.ts +94 -0
  378. package/src/typescript/emit.ts +121 -0
  379. package/src/typescript/expressions.ts +496 -0
  380. package/src/typescript/formula.ts +152 -0
  381. package/src/typescript/functions.ts +284 -0
  382. package/src/typescript/model.ts +163 -0
  383. package/src/typescript/names.ts +114 -0
  384. package/src/typescript/program.ts +48 -0
  385. package/src/typescript/properties.ts +139 -0
  386. package/src/typescript/scope.ts +112 -0
  387. package/src/typescript/steps.ts +165 -0
  388. package/src/typescript/types.ts +171 -0
  389. package/src/values.ts +780 -337
  390. package/src/worker.ts +7 -8
@@ -1,8 +1,5 @@
1
- // Ported from Z3 (src/smt/mam.cpp), MIT license, see z3-license.txt. Matching of quantifier
2
- // patterns against the E-graph with Z3's matching abstract machine: the patterns are compiled into
3
- // code trees, new relevant terms become candidates of the tree for their label, and the inverted
4
- // path index with approximate label sets finds the candidates that a merge creates.
5
- import { AstManager, KIND_VAR } from "./ast";
1
+ // Ported from Z3 (src/smt/mam.cpp), MIT license, see z3-license.txt.
2
+ import { type AstManager, KIND_VAR } from "./ast";
6
3
  import type { Context } from "./context";
7
4
  import type { Enode } from "./enode";
8
5
  import { hashU, mkMix } from "./hash";
@@ -10,8 +7,6 @@ import { type CodeTree, Compiler, hasHash, type LabelHasher } from "./mam-compil
10
7
  import { Interpreter, type OnMatch } from "./mam-interpreter";
11
8
  import { setAt, shrink } from "./array";
12
9
 
13
- // A step from a term to its parent: the parent's label, the position of the term in it, and an
14
- // optional ground argument the parent must also have.
15
10
  interface Path {
16
11
  label: number;
17
12
  argIndex: number;
@@ -21,8 +16,6 @@ interface Path {
21
16
  child: Path | null;
22
17
  }
23
18
 
24
- // The inverted path index shares the prefixes of paths. Siblings are alternatives for the same step,
25
- // the first child is the next step, and a code receives the terms where a path ends.
26
19
  interface PathTree {
27
20
  label: number;
28
21
  argIndex: number;
@@ -33,7 +26,6 @@ interface PathTree {
33
26
  code: CodeTree | null;
34
27
  firstChild: PathTree | null;
35
28
  sibling: PathTree | null;
36
- // The roots that collect_parents visits at this node, while it walks the tree.
37
29
  todo: Enode[] | null;
38
30
  }
39
31
 
@@ -54,7 +46,6 @@ const isEqualPath = (first: Path, second: Path): boolean => {
54
46
  }
55
47
  };
56
48
 
57
- // A multi-pattern of a quantifier: the terms of one of its patterns.
58
49
  interface MultiPattern {
59
50
  quantifier: number;
60
51
  patterns: number[];
@@ -62,7 +53,6 @@ interface MultiPattern {
62
53
 
63
54
  export class Mam implements LabelHasher {
64
55
  private trees = new Map<number, CodeTree>();
65
- // m_shared_enodes: the ground terms of the patterns.
66
56
  private sharedEnodes = new Set<Enode>();
67
57
  private toMatch: CodeTree[] = [];
68
58
  private newPatterns: MultiPattern[] = [];
@@ -72,12 +62,9 @@ export class Mam implements LabelHasher {
72
62
  private clbls = new Set<number>();
73
63
  private r1: Enode | null = null;
74
64
  private r2: Enode | null = null;
75
- // The nodes that collect_parents marks, to unmark at the end of each level.
76
65
  private visitedParents: Enode[] = [];
77
66
  private queuedRoots: Enode[] = [];
78
67
  private labelHashes: (number | undefined)[] = [];
79
- // m_trail_stack: the matcher undoes its changes with a trail of its own, which the quantifier
80
- // manager pops before the context pops its trail.
81
68
  private trail: (() => void)[] = [];
82
69
  private trailScopes: number[] = [];
83
70
  private compiler: Compiler;
@@ -95,7 +82,6 @@ export class Mam implements LabelHasher {
95
82
  return this.context.manager;
96
83
  }
97
84
 
98
- // label_hasher: Bob Jenkins' mix of the small id of a declaration, in [0, 64).
99
85
  getLabelHash(decl: number) {
100
86
  const cached = this.labelHashes[decl];
101
87
  if (cached !== undefined) return cached;
@@ -104,9 +90,7 @@ export class Mam implements LabelHasher {
104
90
  return hash;
105
91
  }
106
92
 
107
- // enode::set_lbl_hash: a ground term of a pattern hashes its id, and its root's labels take it.
108
- // The context's trail undoes both. Z3 pops it after the matcher's trail, so the labels of a root
109
- // can keep a hash that a merge undone by the matcher's trail added.
93
+ // Z3 undoes this on the context's trail, popped after the matcher's, so a root can keep a hash that an undone merge added.
110
94
  private setLblHash(node: Enode) {
111
95
  const hash = hashU(this.manager.ids[node.owner]) & 63;
112
96
  node.lblHash = hash;
@@ -184,12 +168,10 @@ export class Mam implements LabelHasher {
184
168
  if (this.context.isRelevant(node.owner)) this.updateLbls(node, hash);
185
169
  }
186
170
 
187
- // mk_code: the code tree of a path, which runs each candidate once.
188
171
  private mkCode(mp: MultiPattern, patternIndex: number) {
189
172
  return this.compiler.mkTree(mp.quantifier, mp.patterns, patternIndex, true);
190
173
  }
191
174
 
192
- // mk_path_tree: a chain of path tree nodes whose last one has a code for the path's pattern.
193
175
  private mkPathTree(path: Path, mp: MultiPattern): PathTree {
194
176
  const tree: PathTree = {
195
177
  label: path.label,
@@ -211,7 +193,6 @@ export class Mam implements LabelHasher {
211
193
  return tree;
212
194
  }
213
195
 
214
- // compiler::insert for path trees.
215
196
  private insertPath(head: PathTree, path: Path, mp: MultiPattern) {
216
197
  let isLabelFound = false;
217
198
  let last = head;
@@ -388,7 +369,6 @@ export class Mam implements LabelHasher {
388
369
  patterns.forEach((pattern, index) => this.updateFilters(pattern, null, index, varPaths, mp));
389
370
  this.collectGroundExprs(quantifier, patterns);
390
371
  this.newPatterns.push(mp);
391
- // code_tree_map::add_pattern for each pattern as the first one.
392
372
  patterns.forEach((pattern, firstIndex) => {
393
373
  if (manager.isGround(pattern)) return;
394
374
  const label = manager.decls[pattern];
@@ -403,8 +383,6 @@ export class Mam implements LabelHasher {
403
383
  });
404
384
  }
405
385
 
406
- // collect_ground_exprs: the ground patterns become relevant enodes, and the ground subterms of the
407
- // other patterns become enodes that theory combination treats as shared.
408
386
  private collectGroundExprs(quantifier: number, patterns: number[]) {
409
387
  const manager = this.manager;
410
388
  const todo: number[] = [];
@@ -440,8 +418,6 @@ export class Mam implements LabelHasher {
440
418
  return this.sharedEnodes.has(node);
441
419
  }
442
420
 
443
- // add_candidate, with compress_candidates, which keeps the first of each candidate once there are
444
- // many, as match does.
445
421
  private addCandidateTo(tree: CodeTree, node: Enode) {
446
422
  if (tree.candidates.length === 0) this.toMatch.push(tree);
447
423
  tree.candidates.push(node);
@@ -470,9 +446,6 @@ export class Mam implements LabelHasher {
470
446
  );
471
447
  }
472
448
 
473
- // collect_parents: walks the path tree level by level from the merged class, visiting each parent
474
- // once per level, and hands the terms where a path ends to that path's code. The mark of a parent
475
- // says it was visited at this level, and the second mark of a root says it is queued for the next.
476
449
  private collectParents(start: Enode, head: PathTree | null | undefined) {
477
450
  if (head === null || head === undefined) return;
478
451
  const context = this.context;
@@ -569,7 +542,6 @@ export class Mam implements LabelHasher {
569
542
  }
570
543
  }
571
544
 
572
- // add_eq_eh: r2's labels take r1's after the paths are followed.
573
545
  addEqEh(r1: Enode, r2: Enode) {
574
546
  this.r1 = r1;
575
547
  this.r2 = r2;
@@ -603,8 +575,6 @@ export class Mam implements LabelHasher {
603
575
  if (this.newPatterns.length > 0) this.matchNewPatterns();
604
576
  }
605
577
 
606
- // match_new_patterns: one temporary tree per label, in the order the labels first appear, run
607
- // against the relevant terms with the label.
608
578
  private matchNewPatterns() {
609
579
  const context = this.context;
610
580
  const manager = this.manager;
@@ -627,7 +597,6 @@ export class Mam implements LabelHasher {
627
597
  this.newPatterns = [];
628
598
  }
629
599
 
630
- // rematch: every code tree, in the order of their labels' small ids, against every relevant term.
631
600
  rematch() {
632
601
  const context = this.context;
633
602
  const funcDecls = this.manager.funcDecls;
@@ -1,5 +1,4 @@
1
- // Ported from Z3 (src/smt/smt_enode.h, src/smt/smt_eq_justification.h, src/smt/smt_justification.h),
2
- // MIT license, see z3-license.txt. E-graph nodes and the justifications for their equalities.
1
+ // Ported from Z3 (src/smt/smt_enode.h, src/smt/smt_eq_justification.h, src/smt/smt_justification.h), MIT license, see z3-license.txt.
3
2
  import type { Literal } from "./literal";
4
3
 
5
4
  interface Antecedents {
@@ -14,7 +13,6 @@ export abstract class Justification {
14
13
  abstract getAntecedents(antecedents: Antecedents): void;
15
14
  }
16
15
 
17
- // eq_justification: why two nodes on a transitivity branch are equal.
18
16
  export type EqJustification =
19
17
  | { kind: "axiom" }
20
18
  | { kind: "congruence"; isCommutative: boolean }
@@ -23,15 +21,11 @@ export type EqJustification =
23
21
 
24
22
  export const AXIOM_EQ_JUSTIFICATION: EqJustification = { kind: "axiom" };
25
23
 
26
- // The congruence justifications, which carry no data of their own and so are shared.
27
24
  export const CONGRUENCE_JUSTIFICATIONS: readonly EqJustification[] = [
28
25
  { kind: "congruence", isCommutative: false },
29
26
  { kind: "congruence", isCommutative: true },
30
27
  ];
31
28
 
32
- // The parents of a node without any, and the arguments past the second of a node with at most two.
33
- // Nothing adds to it: addParent gives a node its own list, so that a node with one parent holds one
34
- // entry instead of V8's sixteen.
35
29
  export const NO_ENODES: Enode[] = [];
36
30
 
37
31
  const IS_EQ = 1;
@@ -41,7 +35,6 @@ const IS_CGC_ENABLED = 8;
41
35
  const IS_MARKED = 16;
42
36
  const IS_MARKED2 = 32;
43
37
  const IS_INTERPRETED = 64;
44
- // The number of arguments, in the bits of flags above the Boolean fields.
45
38
  const NUM_ARGS_SHIFT = 7;
46
39
 
47
40
  export class Enode {
@@ -50,26 +43,19 @@ export class Enode {
50
43
  cg: Enode = this;
51
44
  classSize = 1;
52
45
  parents: Enode[] = NO_ENODES;
53
- // m_trans: the next node on the transitivity branch toward the root of the proof tree, and why the
54
- // two are equal.
55
46
  transTarget: Enode | null = null;
56
47
  transJustification: EqJustification = AXIOM_EQ_JUSTIFICATION;
57
48
  thVar = -1;
58
- // The approximate label sets of the class, 64 bits in two words: the low 32 bits, then the high.
59
49
  lbls = 0;
60
50
  lblsHigh = 0;
61
51
  plbls = 0;
62
52
  plblsHigh = 0;
63
53
  lblHash = -1;
64
- // The Boolean fields, one bit each, so a node takes 48 bytes less, and the number of arguments.
65
54
  private flags: number;
66
- // m_args: the first two arguments inline, like Z3's arguments after the node, and the rest in an
67
- // array. A missing argument is the node itself.
68
55
  private readonly arg0: Enode;
69
56
  private readonly arg1: Enode;
70
57
  private readonly moreArgs: Enode[];
71
58
 
72
- // moreArgs are the arguments past the second, and arg0 and arg1 are null when there are fewer.
73
59
  constructor(
74
60
  readonly owner: number,
75
61
  readonly decl: number,
@@ -169,7 +155,6 @@ export class Enode {
169
155
  }
170
156
  }
171
157
 
172
- // eq_propagation_justification: the equality atom is true because its sides are in one class.
173
158
  export class EqPropagationJustification extends Justification {
174
159
  constructor(
175
160
  private first: Enode,
@@ -183,7 +168,6 @@ export class EqPropagationJustification extends Justification {
183
168
  }
184
169
  }
185
170
 
186
- // eq_root_propagation_justification: a Boolean node merged with true or false.
187
171
  export class EqRootPropagationJustification extends Justification {
188
172
  constructor(private node: Enode) {
189
173
  super();
@@ -194,7 +178,6 @@ export class EqRootPropagationJustification extends Justification {
194
178
  }
195
179
  }
196
180
 
197
- // eq_conflict_justification: two interpreted roots, such as two numerals, were merged.
198
181
  export class EqConflictJustification extends Justification {
199
182
  constructor(
200
183
  private first: Enode,
@@ -211,7 +194,6 @@ export class EqConflictJustification extends Justification {
211
194
  }
212
195
  }
213
196
 
214
- // mp_iff_justification: a Boolean node takes the value of an equal node.
215
197
  export class MpIffJustification extends Justification {
216
198
  constructor(
217
199
  private first: Enode,
@@ -227,7 +209,6 @@ export class MpIffJustification extends Justification {
227
209
  }
228
210
  }
229
211
 
230
- // unit_resolution_justification: a clause simplified with literals that were false.
231
212
  export class UnitResolutionJustification extends Justification {
232
213
  constructor(
233
214
  private justification: Justification | null,
@@ -242,7 +223,6 @@ export class UnitResolutionJustification extends Justification {
242
223
  }
243
224
  }
244
225
 
245
- // ext_theory_propagation_justification: theory reasoning from literals and equalities.
246
226
  export class TheoryJustification extends Justification {
247
227
  constructor(
248
228
  private literals: Literal[],
@@ -1,16 +1,12 @@
1
- // Ported from Z3 (src/ast/ast.h), MIT license, see z3-license.txt. The assignments of expr_ref, for
2
- // code that keeps Z3's reference counts by hand so that expressions are created and deleted in Z3's
3
- // order. -1 stands for a null expression.
1
+ // Ported from Z3 (src/ast/ast.h), MIT license, see z3-license.txt.
4
2
  import type { AstManager } from "./ast";
5
3
 
6
- // expr_ref's assignment: the new value gains a reference before the old one loses its own.
7
4
  export const assign = (manager: AstManager, old: number, value: number) => {
8
5
  if (value !== -1) manager.incRef(value);
9
6
  if (old !== -1) manager.decRef(old);
10
7
  return value;
11
8
  };
12
9
 
13
- // expr_ref's move assignment of a value the caller owns.
14
10
  export const assignOwned = (manager: AstManager, old: number, value: number) => {
15
11
  if (old !== -1) manager.decRef(old);
16
12
  return value;
@@ -1,6 +1,4 @@
1
1
  // Ported from Z3 (src/ast/rewriter/expr_safe_replace.cpp), MIT license, see z3-license.txt.
2
- // Replaces subterms by terms, under quantifiers too, without rewriting. Like Z3, it visits the
3
- // arguments of an application from the last one, and holds the expressions it creates.
4
2
  import { SmtInvariantError } from "../../../errors";
5
3
  import { KIND_APP, KIND_VAR, type AstManager } from "./ast";
6
4
  import { RefVector } from "./ref-vector";
@@ -25,7 +23,6 @@ export class ExprSafeReplace {
25
23
  this.cache.clear();
26
24
  }
27
25
 
28
- // operator(): the result comes with a reference, which the caller releases.
29
26
  apply(expr: number) {
30
27
  const manager = this.manager;
31
28
  if (this.sources.size === 0) {
@@ -79,7 +76,6 @@ export class ExprSafeReplace {
79
76
  return result;
80
77
  }
81
78
 
82
- // Replaces the quantifier, or pushes the children it still needs.
83
79
  private applyQuantifier(quantifier: number, todo: number[]) {
84
80
  const manager = this.manager;
85
81
  const data = manager.getQuantifier(quantifier);
@@ -162,7 +158,6 @@ export class ExprSafeReplace {
162
158
  manager.decRef(body);
163
159
  }
164
160
 
165
- // ~expr_safe_replace.
166
161
  release() {
167
162
  this.cache.clear();
168
163
  this.refs.reset();
@@ -1,30 +1,20 @@
1
- // Ported from Z3 (src/smt/fingerprints.cpp), MIT license, see z3-license.txt. The set of
2
- // quantifier instances already found, so a match on equal terms is not instantiated twice. Scopes
3
- // undo the insertions.
1
+ // Ported from Z3 (src/smt/fingerprints.cpp), MIT license, see z3-license.txt.
4
2
  import type { AstManager } from "./ast";
5
3
  import type { Enode } from "./enode";
6
4
  import { getCompositeHash } from "./hash";
7
5
  import { shrink } from "./array";
8
6
 
9
7
  export class FingerprintSet {
10
- // The quantifier, hash and roots of each fingerprint, in the order of insertion.
11
8
  private quantifiers: number[] = [];
12
9
  private hashes: number[] = [];
13
10
  private roots: Enode[][] = [];
14
- // Open addressing with linear probing over the indices of the fingerprints, -1 for an empty slot.
15
- // Scopes remove the newest fingerprints first, and the table grows by inserting them in order, so
16
- // emptying the slot of a removed fingerprint never cuts the probe of one that remains.
17
11
  private slots = new Int32Array(1024).fill(-1);
18
12
  private scopes: number[] = [];
19
- // The hashes and the roots of the bindings of the instance being inserted.
20
13
  private bindingHashes: number[] = [];
21
14
  private bindingRoots: Enode[] = [];
22
15
 
23
16
  constructor(private manager: AstManager) {}
24
17
 
25
- // fingerprint_set::insert: the roots of the bindings, which a new fingerprint keeps, or null when
26
- // the instance is already in the set. The hash comes from the bindings themselves, and the set is
27
- // searched with the bindings and then with their roots.
28
18
  insert(quantifier: number, bindings: Enode[]) {
29
19
  const manager = this.manager;
30
20
  const bindingHashes = this.bindingHashes;
@@ -50,7 +40,6 @@ export class FingerprintSet {
50
40
  return roots;
51
41
  }
52
42
 
53
- // The empty slot that ends the probe for the fingerprint, or -1 when the set has it.
54
43
  private find(quantifier: number, hash: number, args: Enode[]) {
55
44
  const mask = this.slots.length - 1;
56
45
  let slot = hash & mask;
@@ -1,9 +1,4 @@
1
- // Ported from Z3 (src/ast/rewriter/bool_rewriter.cpp), MIT license, see z3-license.txt. The
2
- // literals of a flattened conjunction or disjunction, without duplicates. Like the expr_fast_mark1
3
- // and expr_fast_mark2 of mk_nflat_and_core, it marks the literals and the negated atoms it holds,
4
- // here with a stamp for each use, so it finds a complementary pair without creating each negation.
5
- // Its manager owns the one instance that its rewriters share: a list is filled and read before any
6
- // other starts, so like Z3's ptr_buffer it reuses one array.
1
+ // Ported from Z3 (src/ast/rewriter/bool_rewriter.cpp), MIT license, see z3-license.txt.
7
2
  import { shrink } from "./array";
8
3
  import type { AstManager } from "./ast";
9
4
 
@@ -15,14 +10,11 @@ export class FlatLiterals {
15
10
 
16
11
  constructor(private manager: AstManager) {}
17
12
 
18
- // Starts a new, empty list.
19
13
  clear() {
20
14
  shrink(this.list, 0);
21
15
  this.stamp++;
22
16
  }
23
17
 
24
- // Adds a literal, and returns whether its complement is already there. An expression's arguments
25
- // are older than it, so their ids are smaller.
26
18
  add(literal: number) {
27
19
  const manager = this.manager;
28
20
  if (literal >= this.literalStamps.length) {
@@ -1,5 +1,4 @@
1
- // Ported from Z3 (src/tactic/goal.cpp), MIT license, see z3-license.txt. The formulas that a tactic
2
- // transforms, kept split into conjuncts. Like Z3's goal, it holds a reference to each formula.
1
+ // Ported from Z3 (src/tactic/goal.cpp), MIT license, see z3-license.txt.
3
2
  import { OP_AND, OP_NOT, OP_OR, SORT_BOOL, type AstManager } from "./ast";
4
3
  import { RefVector } from "./ref-vector";
5
4
 
@@ -16,7 +15,6 @@ export class Goal {
16
15
  this.forms = new RefVector(manager);
17
16
  }
18
17
 
19
- // push_back: a false formula replaces the whole goal.
20
18
  private pushBack(form: number) {
21
19
  const manager = this.manager;
22
20
  if (manager.isTrue(form)) return;
@@ -27,9 +25,6 @@ export class Goal {
27
25
  this.forms.push(form);
28
26
  }
29
27
 
30
- // quick_process: splits conjunctions and negated disjunctions in order. With isSavingFirst, the
31
- // first conjunct is returned instead of added. The formula comes with a reference, and so does
32
- // the result. The negations it creates are held until it returns.
33
28
  private quickProcess(form: number, isSavingFirst: boolean) {
34
29
  const manager = this.manager;
35
30
  const op = manager.getOp(form);
@@ -66,7 +61,6 @@ export class Goal {
66
61
  return first;
67
62
  }
68
63
 
69
- // assert_expr.
70
64
  assert(form: number) {
71
65
  const manager = this.manager;
72
66
  manager.incRef(form);
@@ -77,9 +71,7 @@ export class Goal {
77
71
  manager.decRef(form);
78
72
  }
79
73
 
80
- // update: the first conjunct replaces the formula and the others are added at the end. When the
81
- // first conjunct is false, Z3 adds the whole formula (goal.cpp:312), and this adds false, so the
82
- // goal becomes inconsistent.
74
+ // When the first conjunct is false, Z3 adds the whole formula (goal.cpp:312), where this adds false.
83
75
  update(index: number, form: number) {
84
76
  const manager = this.manager;
85
77
  if (this.isInconsistent) return;
@@ -92,12 +84,10 @@ export class Goal {
92
84
  manager.decRef(first);
93
85
  }
94
86
 
95
- // shrink: drops the formulas from size on, the last one first.
96
87
  private shrink(size: number) {
97
88
  while (this.forms.size > size) this.forms.pop();
98
89
  }
99
90
 
100
- // elim_true.
101
91
  elimTrue() {
102
92
  const manager = this.manager;
103
93
  let kept = 0;
@@ -109,8 +99,6 @@ export class Goal {
109
99
  this.shrink(kept);
110
100
  }
111
101
 
112
- // elim_redundancies: drops true and repeated literals, and finds a complementary pair. The marks
113
- // hold the literals until it returns.
114
102
  elimRedundancies() {
115
103
  const manager = this.manager;
116
104
  if (this.isInconsistent) return;
@@ -1,6 +1,4 @@
1
1
  // Ported from Z3 (src/util/hash.h, src/util/hash.cpp), MIT license, see z3-license.txt.
2
- // Bob Jenkins' hash functions, on unsigned 32-bit integers. Z3 hashes every AST with them, and its
3
- // hash tables iterate in hash order, so matching the hashes matches Z3's iteration order.
4
2
  const GOLDEN_RATIO = 0x9e3779b9;
5
3
 
6
4
  const mix = (state: Uint32Array) => {
@@ -30,8 +28,6 @@ const mix = (state: Uint32Array) => {
30
28
  state[2] = c;
31
29
  };
32
30
 
33
- // The a, b and c of Z3's mix, which wrap like its unsigned integers. No hash function calls another
34
- // while it uses the state, so they share one rather than allocating one per hash.
35
31
  const sharedState = new Uint32Array(3);
36
32
 
37
33
  const mkState = (a: number, b: number, c: number) => {
@@ -63,7 +59,6 @@ export const combineHash = (first: number, second: number) =>
63
59
 
64
60
  const encoder = new TextEncoder();
65
61
 
66
- // string_hash, over the bytes of a string or of a number's digits.
67
62
  export const bytesHash = (data: Uint8Array, initValue: number) => {
68
63
  const readUnsigned = (offset: number) =>
69
64
  (data[offset] |
@@ -94,7 +89,6 @@ export const bytesHash = (data: Uint8Array, initValue: number) => {
94
89
  export const stringHash = (text: string, initValue: number) =>
95
90
  bytesHash(encoder.encode(text), initValue);
96
91
 
97
- // get_composite_hash over child hashes, with the default kind hash of 17.
98
92
  export const getCompositeHash = (childHashes: number[], kindHash = 17) => {
99
93
  const count = childHashes.length;
100
94
  const state = mkState(GOLDEN_RATIO, GOLDEN_RATIO, 11);
@@ -137,8 +131,6 @@ export const getCompositeHash = (childHashes: number[], kindHash = 17) => {
137
131
  }
138
132
  };
139
133
 
140
- // ast_array_hash: the hash of an AST from the hashes of its children, each looked up in hashes like
141
- // Z3's get_hash.
142
134
  export const astArrayHash = (items: number[], hashes: ArrayLike<number>, initValue: number) => {
143
135
  const count = items.length;
144
136
  switch (count) {
@@ -1,6 +1,4 @@
1
- // Ported from Z3 (src/util/hashtable.h, src/util/obj_hashtable.h), MIT license, see
2
- // z3-license.txt. Z3's open-addressing table with linear probing. Its iteration order is the slot
3
- // order, which the model finder depends on, so the AST maps that Z3 iterates use this table.
1
+ // Ported from Z3 (src/util/hashtable.h, src/util/obj_hashtable.h), MIT license, see z3-license.txt.
4
2
  import { SmtInvariantError } from "../../../errors";
5
3
 
6
4
  const INITIAL_CAPACITY = 8;
@@ -9,7 +7,6 @@ const FREE = 0;
9
7
  const DELETED = 1;
10
8
  const USED = 2;
11
9
 
12
- // u_hash: an unsigned key is its own hash.
13
10
  export const getIdentityHash = (key: number) => key;
14
11
 
15
12
  export class ObjMap<V> {
@@ -33,7 +30,6 @@ export class ObjMap<V> {
33
30
  return -1;
34
31
  }
35
32
 
36
- // move_table: reinserts the used slots, in slot order, into a table of the new capacity.
37
33
  private moveTable(capacity: number) {
38
34
  const states = this.states;
39
35
  const keys = this.slotKeys;
@@ -63,7 +59,6 @@ export class ObjMap<V> {
63
59
  return slot === -1 ? undefined : this.values[slot];
64
60
  }
65
61
 
66
- // find_core and an assignment to the entry: unlike insert, never grows the table.
67
62
  replace(key: number, value: V) {
68
63
  const slot = this.findSlot(key);
69
64
  if (slot !== -1) this.values[slot] = value;
@@ -108,7 +103,6 @@ export class ObjMap<V> {
108
103
  this.moveTable(this.capacity);
109
104
  }
110
105
 
111
- // reset: empties the table, halving it when most slots were in use.
112
106
  clear() {
113
107
  if (this.size === 0 && this.numDeleted === 0) return;
114
108
  let overhead = 0;
@@ -136,7 +130,6 @@ export class ObjMap<V> {
136
130
  }
137
131
  }
138
132
 
139
- // obj_hashtable: a set of ASTs in Z3's slot order.
140
133
  export class ObjHashtable {
141
134
  private map: ObjMap<true>;
142
135
 
@@ -156,10 +149,6 @@ export class ObjHashtable {
156
149
  this.map.set(key, true);
157
150
  }
158
151
 
159
- delete(key: number) {
160
- this.map.delete(key);
161
- }
162
-
163
152
  [Symbol.iterator]() {
164
153
  return this.map.keys();
165
154
  }