tla-ts 0.0.9-dev.8298a52 → 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 +7 -0
  2. package/dist/compile.cjs +3 -3
  3. package/dist/compile.js +3 -3
  4. package/dist/deciders.cjs +28 -28
  5. package/dist/deciders.js +52 -52
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.cts +105 -10
  8. package/dist/index.d.ts +105 -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 +1 -1
  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 +1 -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 +564 -366
  30. package/src/cli/options.ts +10 -5
  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 +525 -216
  38. package/src/cli/typescript.ts +0 -3
  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 +237 -119
  47. package/src/errors.ts +56 -56
  48. package/src/evaluate.ts +543 -341
  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 +38 -31
  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 +77 -117
  59. package/src/liveness.ts +106 -62
  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 +24 -33
  82. package/src/parallel.ts +48 -40
  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 +1 -16
  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 +260 -91
  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 +8 -21
  375. package/src/typescript/collections.ts +0 -15
  376. package/src/typescript/compile.ts +0 -5
  377. package/src/typescript/context.ts +0 -12
  378. package/src/typescript/emit.ts +0 -1
  379. package/src/typescript/expressions.ts +0 -12
  380. package/src/typescript/formula.ts +4 -12
  381. package/src/typescript/functions.ts +6 -17
  382. package/src/typescript/model.ts +10 -11
  383. package/src/typescript/names.ts +0 -2
  384. package/src/typescript/program.ts +0 -3
  385. package/src/typescript/properties.ts +6 -8
  386. package/src/typescript/scope.ts +0 -5
  387. package/src/typescript/steps.ts +0 -10
  388. package/src/typescript/types.ts +1 -8
  389. package/src/values.ts +749 -330
  390. package/src/worker.ts +7 -8
@@ -1,7 +1,4 @@
1
- // Ported from Z3 (src/smt/mam.cpp), MIT license, see z3-license.txt. The code trees of Z3's matching
2
- // abstract machine and the compiler that builds them: each pattern becomes a sequence of
3
- // instructions, and the patterns that start with the same label share the instructions they have
4
- // in common, so a term is matched against all of them at once and the matches come in Z3's order.
1
+ // Ported from Z3 (src/smt/mam.cpp), MIT license, see z3-license.txt.
5
2
  import { KIND_VAR, type AstManager } from "./ast";
6
3
  import type { Context } from "./context";
7
4
  import type { Enode } from "./enode";
@@ -26,8 +23,6 @@ export const JOINT_GROUND = 1;
26
23
  export const JOINT_VAR = 2;
27
24
  export const JOINT_NESTED = 3;
28
25
 
29
- // A joint of a CONTINUE argument: a ground term, the register of a bound variable, or a depth-2
30
- // joint (f ... (g ... X ...) ...), with g, the position of X in it, and X's register.
31
26
  export interface Joint {
32
27
  kind: number;
33
28
  enode: Enode | null;
@@ -36,9 +31,6 @@ export interface Joint {
36
31
  argPos: number;
37
32
  }
38
33
 
39
- // instruction and its subclasses in one shape. The fields an opcode does not use keep their
40
- // defaults. reg is the register of CHECK, COMPARE (m_reg1), the filters, and the input register of
41
- // BIND and IS_CGR. regs holds the input registers of GET_CGR and IS_CGR and the bindings of YIELD.
42
34
  export interface Instruction {
43
35
  op: number;
44
36
  next: Instruction | null;
@@ -57,24 +49,18 @@ export interface Instruction {
57
49
  }
58
50
 
59
51
  export interface CodeTree {
60
- rootLabel: number;
61
52
  numArgs: number;
62
53
  isFilteringCandidates: boolean;
63
54
  numRegs: number;
64
55
  numChoices: number;
65
56
  root: Instruction;
66
57
  candidates: Enode[];
67
- // code_tree::m_candidate_gc_threshold: the number of candidates at which duplicates are dropped.
68
58
  candidateGcThreshold: number;
69
59
  }
70
60
 
71
- // What the compiler needs from the matching abstract machine.
72
61
  export interface LabelHasher {
73
- // label_hasher.
74
62
  getLabelHash(decl: number): number;
75
- // mk_enode: the enode of a ground term, internalized at the quantifier's generation if needed.
76
63
  getGroundEnode(expr: number, quantifier: number): Enode | null;
77
- // The label hash of a ground term's enode, which set_lbl_hash gives it if it has none.
78
64
  getLblHash(node: Enode): number;
79
65
  }
80
66
 
@@ -82,7 +68,6 @@ const NOT_CHECKED = 0;
82
68
  const CHECK_SET = 1;
83
69
  const CHECK_SINGLETON = 2;
84
70
 
85
- // FIND_BEST_CHILD_THRESHOLD and SIMPLE_SEQ_THRESHOLD.
86
71
  const FIND_BEST_CHILD_THRESHOLD = 64;
87
72
  const SIMPLE_SEQ_THRESHOLD = 4;
88
73
 
@@ -103,7 +88,14 @@ const mkInstruction = (op: number): Instruction => ({
103
88
  joints: [],
104
89
  });
105
90
 
106
- // approx_set over 64 bits, in two words.
91
+ const mkNullJoint = (): Joint => ({
92
+ kind: JOINT_NULL,
93
+ enode: null,
94
+ reg: 0,
95
+ decl: -1,
96
+ argPos: 0,
97
+ });
98
+
107
99
  export const hasHash = (low: number, high: number, hash: number) =>
108
100
  ((hash < 32 ? low : high) & (1 << hash)) !== 0;
109
101
 
@@ -158,19 +150,14 @@ const mkInit = (numArgs: number) => {
158
150
  return instr;
159
151
  };
160
152
 
161
- // The patterns are the terms of a multi-pattern, and firstIndex picks the one the tree starts with.
162
153
  export class Compiler {
163
- // The pattern each register holds, -1 for none.
164
154
  private registers: number[] = [];
165
- // m_todo: the registers whose patterns are still to be processed.
166
155
  private todo: number[] = [];
167
156
  private aux: number[] = [];
168
- // The register of each variable by de Bruijn index, -1 while it is unbound.
169
157
  private vars: number[] = [];
170
158
  private quantifier = -1;
171
159
  private patterns: number[] = [];
172
160
  private tree: CodeTree = {
173
- rootLabel: -1,
174
161
  numArgs: 0,
175
162
  isFilteringCandidates: false,
176
163
  numRegs: 0,
@@ -229,7 +216,6 @@ export class Compiler {
229
216
  this.vars.fill(-1, 0, numDecls);
230
217
  }
231
218
 
232
- // all_args_are_bound_vars.
233
219
  private isAllArgsBoundVars(expr: number) {
234
220
  const manager = this.manager;
235
221
  return manager.everyArg(
@@ -238,7 +224,6 @@ export class Compiler {
238
224
  );
239
225
  }
240
226
 
241
- // get_stats: the size of a pattern and its number of unbound variables.
242
227
  private getStats(expr: number) {
243
228
  const manager = this.manager;
244
229
  let size = 0;
@@ -258,8 +243,6 @@ export class Compiler {
258
243
  return { size, numUnboundVars };
259
244
  }
260
245
 
261
- // linearise_core: the registers in m_todo that do not need a BIND are processed first, then a
262
- // single BIND or IS_CGR is produced, and the registers left and the new ones become m_todo.
263
246
  private lineariseCore() {
264
247
  const manager = this.manager;
265
248
  const hasher = this.hasher;
@@ -348,7 +331,6 @@ export class Compiler {
348
331
  this.aux = todo;
349
332
  }
350
333
 
351
- // get_num_bound_vars: the number of bound variables in a pattern, and whether it has unbound ones.
352
334
  private getNumBoundVars(expr: number) {
353
335
  const manager = this.manager;
354
336
  let count = 0;
@@ -366,8 +348,6 @@ export class Compiler {
366
348
  return { count, hasUnboundVars };
367
349
  }
368
350
 
369
- // gen_mp_filter: compiles a pattern whose variables are all bound, and returns the register that
370
- // gets the enode congruent to it.
371
351
  private genMpFilter(expr: number): number {
372
352
  const manager = this.manager;
373
353
  if (manager.isGround(expr)) {
@@ -394,8 +374,6 @@ export class Compiler {
394
374
  return oreg;
395
375
  }
396
376
 
397
- // linearise_multi_pattern: the other patterns of a multi-pattern, the one with the most bound
398
- // variables first.
399
377
  private lineariseMultiPattern() {
400
378
  const manager = this.manager;
401
379
  const patterns = this.patterns;
@@ -439,35 +417,28 @@ export class Compiler {
439
417
  )
440
418
  hasDepth1Joint = true;
441
419
  }
442
- const nullJoint = (): Joint => ({
443
- kind: JOINT_NULL,
444
- enode: null,
445
- reg: 0,
446
- decl: -1,
447
- argPos: 0,
448
- });
449
420
  const joints = manager.mapArgs(best, (arg): Joint => {
450
421
  if (hasDepth1Joint) {
451
422
  if (manager.kinds[arg] === KIND_VAR) {
452
423
  const reg = this.vars[manager.values[arg]];
453
- return reg >= 0 ? { ...nullJoint(), kind: JOINT_VAR, reg } : nullJoint();
424
+ return reg >= 0 ? { ...mkNullJoint(), kind: JOINT_VAR, reg } : mkNullJoint();
454
425
  }
455
426
  if (manager.isGround(arg))
456
427
  return {
457
- ...nullJoint(),
428
+ ...mkNullJoint(),
458
429
  kind: JOINT_GROUND,
459
430
  enode: this.hasher.getGroundEnode(arg, this.quantifier),
460
431
  };
461
- return nullJoint();
432
+ return mkNullJoint();
462
433
  }
463
- if (manager.kinds[arg] === KIND_VAR) return nullJoint();
434
+ if (manager.kinds[arg] === KIND_VAR) return mkNullJoint();
464
435
  let argPos = -1;
465
436
  for (let index = 0; index < manager.getNumArgs(arg) && argPos === -1; index++) {
466
437
  const innerArg = manager.getArg(arg, index);
467
438
  if (manager.kinds[innerArg] === KIND_VAR && this.vars[manager.values[innerArg]] >= 0)
468
439
  argPos = index;
469
440
  }
470
- if (argPos === -1) return nullJoint();
441
+ if (argPos === -1) return mkNullJoint();
471
442
  return {
472
443
  kind: JOINT_NESTED,
473
444
  enode: null,
@@ -488,7 +459,6 @@ export class Compiler {
488
459
  }
489
460
  }
490
461
 
491
- // linearise: the instructions for the registers in m_todo, appended after head.
492
462
  private linearise(head: Instruction, firstIndex: number) {
493
463
  this.seq = [];
494
464
  this.matchedExprs.clear();
@@ -562,7 +532,6 @@ export class Compiler {
562
532
  return instr.enode !== null && node !== null && instr.enode.root === node.root;
563
533
  }
564
534
 
565
- // get_pat_lbl_hash: a ground pattern is a constant, hashed by its enode.
566
535
  private getPatLblHash(reg: number) {
567
536
  const expr = this.registers[reg];
568
537
  if (this.manager.isGround(expr)) {
@@ -609,8 +578,6 @@ export class Compiler {
609
578
  );
610
579
  }
611
580
 
612
- // get_compatibility_measure: how many instructions of the branch at child are compatible with the
613
- // patterns in the registers, and whether the branch is too simple to look at.
614
581
  private getCompatibilityMeasure(child: Instruction) {
615
582
  const manager = this.manager;
616
583
  this.toReset.length = 0;
@@ -660,8 +627,6 @@ export class Compiler {
660
627
  if (index !== -1) this.todo.splice(index, 1);
661
628
  }
662
629
 
663
- // compiler::insert: follows the instructions compatible with the new pattern, then branches off
664
- // with a CHOOSE where they stop.
665
630
  private insertAt(start: Instruction, firstIndex: number) {
666
631
  const manager = this.manager;
667
632
  let head = start;
@@ -729,7 +694,6 @@ export class Compiler {
729
694
  const hash = this.getPatLblHash(curr.reg);
730
695
  this.setMark(curr.reg, CHECK_SET);
731
696
  if (countBits(curr.lblLow) + countBits(curr.lblHigh) > 1) {
732
- // insert_new_lbl_hash.
733
697
  const filter = curr;
734
698
  const low = filter.lblLow;
735
699
  const high = filter.lblHigh;
@@ -757,7 +721,6 @@ export class Compiler {
757
721
  if (curr === null) return;
758
722
  const bestChild = this.findBestChild(curr);
759
723
  if (bestChild === null) {
760
- // head -> ... -> last -> new_child: CHOOSE(first_child) -> linearise.
761
724
  const newChild = mkChoose(curr);
762
725
  this.numChoices++;
763
726
  this.setNext(last, newChild);
@@ -767,8 +730,6 @@ export class Compiler {
767
730
  head = bestChild;
768
731
  continue;
769
732
  }
770
- // head -> compatible -> new_child_head1: CHOOSE(new_child_head2) -> incompatible -> curr, and
771
- // new_child_head2: NOOP -> linearise.
772
733
  const firstChildHead = curr;
773
734
  const newChildHead2 = mkInstruction(OP_NOOP);
774
735
  const newChildHead1 = mkChoose(newChildHead2);
@@ -791,7 +752,6 @@ export class Compiler {
791
752
  }
792
753
  }
793
754
 
794
- // mk_tree: a new code tree for a quantifier, which starts with the pattern at firstIndex.
795
755
  mkTree(
796
756
  quantifier: number,
797
757
  patterns: number[],
@@ -801,7 +761,6 @@ export class Compiler {
801
761
  const pattern = patterns[firstIndex];
802
762
  const numArgs = this.manager.getNumArgs(pattern);
803
763
  const tree: CodeTree = {
804
- rootLabel: this.manager.decls[pattern],
805
764
  numArgs,
806
765
  isFilteringCandidates,
807
766
  numRegs: numArgs + 1,
@@ -816,7 +775,6 @@ export class Compiler {
816
775
  return tree;
817
776
  }
818
777
 
819
- // insert: adds a pattern to a code tree. A temporary tree records no trail.
820
778
  insert(
821
779
  tree: CodeTree,
822
780
  quantifier: number,
@@ -1,6 +1,4 @@
1
- // Ported from Z3 (src/smt/mam.cpp), MIT license, see z3-license.txt. The interpreter of Z3's
2
- // matching abstract machine: it runs a code tree against a term, backtracking through the choices
3
- // of BIND, CONTINUE and CHOOSE, and reports each match.
1
+ // Ported from Z3 (src/smt/mam.cpp), MIT license, see z3-license.txt.
4
2
  import type { Context } from "./context";
5
3
  import type { Enode } from "./enode";
6
4
  import {
@@ -30,8 +28,6 @@ import { shrink } from "./array";
30
28
 
31
29
  export type OnMatch = (quantifier: number, bindings: Enode[], maxGeneration: number) => void;
32
30
 
33
- // backtrack_point: the instruction to resume, the generation to restore, the term a BIND is at,
34
- // and the terms a CONTINUE goes through.
35
31
  interface BacktrackPoint {
36
32
  instr: Instruction;
37
33
  oldMaxGeneration: number;
@@ -41,16 +37,13 @@ interface BacktrackPoint {
41
37
  end: number;
42
38
  }
43
39
 
44
- // GET_CGR1 to GET_CGR6 filter their arguments by the parent labels, GET_CGRN does not.
45
40
  const MAX_FILTERED_GET_CGR_ARGS = 6;
46
41
 
47
42
  export class Interpreter {
48
43
  private registers: (Enode | null)[] = [];
49
- // m_bindings: the terms a YIELD reports, which the match callback does not keep.
50
44
  private bindings: Enode[] = [];
51
45
  private backtrackStack: BacktrackPoint[] = [];
52
46
  private top = 0;
53
- // m_max_generation: the largest generation of a term the match went through.
54
47
  private maxGeneration = 0;
55
48
 
56
49
  constructor(
@@ -74,7 +67,6 @@ export class Interpreter {
74
67
  return point;
75
68
  }
76
69
 
77
- // get_first_f_app and get_next_f_app: the next congruence root with the label in the class.
78
70
  private getNextFApp(label: number, numArgs: number, first: Enode, start: Enode | null) {
79
71
  let curr = start === null ? first : start.next;
80
72
  if (start !== null && curr === first) return null;
@@ -88,7 +80,6 @@ export class Interpreter {
88
80
  return null;
89
81
  }
90
82
 
91
- // exec_is_cgr: whether the class has a term with the label and the arguments of the registers.
92
83
  private isCgr(instr: Instruction) {
93
84
  const registers = this.registers;
94
85
  const args: Enode[] = [];
@@ -124,8 +115,6 @@ export class Interpreter {
124
115
  );
125
116
  }
126
117
 
127
- // mk_depth1_vector: the relevant decl-parents of the class of node where it is argument argIndex.
128
- // init_continue drops a vector of limit terms or more, so this stops at limit and returns null.
129
118
  private getDepth1Vector(node: Enode, decl: number, argIndex: number, limit: number) {
130
119
  const root = node.root;
131
120
  const result: Enode[] = [];
@@ -137,7 +126,6 @@ export class Interpreter {
137
126
  return result;
138
127
  }
139
128
 
140
- // mk_depth2_vector, which stops at limit like getDepth1Vector.
141
129
  private getDepth2Vector(joint: Joint, decl: number, argIndex: number, limit: number) {
142
130
  const node = this.registers[joint.reg];
143
131
  if (node === null || node === undefined) return null;
@@ -156,7 +144,6 @@ export class Interpreter {
156
144
  return result;
157
145
  }
158
146
 
159
- // SET_VAR's filter: whether the class of each input register has a parent with the label.
160
147
  private hasParentLabels(instr: Instruction) {
161
148
  for (const reg of instr.regs) {
162
149
  const root = (this.registers[reg] as Enode).root;
@@ -171,7 +158,6 @@ export class Interpreter {
171
158
  return null;
172
159
  }
173
160
 
174
- // init_continue: the smallest candidate vector among the joints, or all terms with the label.
175
161
  private initContinue(instr: Instruction) {
176
162
  const context = this.context;
177
163
  const label = instr.label;
@@ -224,8 +210,6 @@ export class Interpreter {
224
210
  for (let index = 0; index < numArgs; index++) this.registers[oreg + index] = node.getArg(index);
225
211
  }
226
212
 
227
- // The backtracking step of execute_core: the instruction to resume at, or null when the top choice
228
- // is exhausted and was popped.
229
213
  private resume(point: BacktrackPoint): Instruction | null {
230
214
  const instr = point.instr;
231
215
  if (instr.op === OP_CHOOSE) {
@@ -260,8 +244,6 @@ export class Interpreter {
260
244
  return null;
261
245
  }
262
246
 
263
- // execute_core: runs the tree against a term, one instruction at a time, and backtracks when an
264
- // instruction fails. It returns false when the search is canceled.
265
247
  executeCore(tree: CodeTree, node: Enode) {
266
248
  const context = this.context;
267
249
  const registers = this.registers;
@@ -385,8 +367,6 @@ export class Interpreter {
385
367
  }
386
368
  }
387
369
 
388
- // execute: runs the tree against its candidates. A tree that filters its candidates runs each
389
- // term once.
390
370
  execute(tree: CodeTree) {
391
371
  const context = this.context;
392
372
  const seen = tree.isFilteringCandidates ? new Set<Enode>() : null;
@@ -1,7 +1,5 @@
1
1
  // Ported from Z3 (src/ast/rewriter/maximize_ac_sharing.cpp), MIT license, see z3-license.txt.
2
- // maximize_bv_sharing_rw: an associative application of more than two arguments becomes a tree of
3
- // binary applications that reuses the pairs it made before.
4
- import { OP_ADD, OP_OR, type AstManager } from "./ast";
2
+ import { OP_ADD, OP_OR } from "./ast";
5
3
  import { RewriterTpl } from "./rewriter-tpl";
6
4
  import { shrink } from "./array";
7
5
 
@@ -11,32 +9,21 @@ interface SharingEntry {
11
9
  second: number;
12
10
  }
13
11
 
14
- // MAX_NUM_ARGS_FOR_OPT: pairs are reused only for fewer arguments.
15
12
  const MAX_NUM_ARGS_FOR_OPT = 128;
16
13
 
17
14
  export class MaxBvSharing extends RewriterTpl {
18
- // Z3 registers the kinds of bvadd, bvmul, bvor and bvand when the first scope is pushed, and
19
- // compares the kind without the family. bvmul has the kind of or and of +, so those are shared.
15
+ // Z3 compares the kind without the family, and bvmul has the kind of or and of +, so those are shared.
20
16
  private isInit = false;
21
- // m_entries and m_cache: the pairs made, which hold their arguments. The cache maps a declaration
22
- // and the lower of two arguments to the higher ones, so a pair matches in either order.
23
17
  private entries: SharingEntry[] = [];
24
18
  private pairCache = new Map<number, Map<number, Set<number>>>();
25
19
  private pairScopes: number[] = [];
26
20
 
27
- constructor(manager: AstManager) {
28
- super(manager);
29
- }
30
-
31
21
  reduceApp(decl: number, args: number[], sort: number) {
32
22
  const manager = this.manager;
33
23
  const op = manager.funcDecls[decl].op;
34
24
  if (!this.isInit || (op !== OP_OR && op !== OP_ADD) || args.length <= 2) return -1;
35
25
  return manager.withTemporaries(() => {
36
26
  const pending = [...args];
37
- // Reuses the pairs made before, the first pair found first. Z3 scans every pair again after
38
- // each reuse, but no pair is made meanwhile, so before the reused pair only the pairs with
39
- // the argument it became can match.
40
27
  for (let merged = 0; pending.length > 1 && pending.length < MAX_NUM_ARGS_FOR_OPT;) {
41
28
  let pairFirst = -1;
42
29
  let pairSecond = -1;
@@ -72,7 +59,6 @@ export class MaxBvSharing extends RewriterTpl {
72
59
  });
73
60
  }
74
61
 
75
- // entry orders its arguments by id, and pop_scope releases them in that order.
76
62
  private insert(decl: number, first: number, second: number) {
77
63
  const isOrdered = this.manager.ids[first] <= this.manager.ids[second];
78
64
  this.entries.push({
@@ -101,7 +87,6 @@ export class MaxBvSharing extends RewriterTpl {
101
87
  this.pairScopes.push(this.entries.length);
102
88
  }
103
89
 
104
- // pop_scope: releases the pairs made since the matching push, the last first.
105
90
  popScope() {
106
91
  const size = this.pairScopes.pop() as number;
107
92
  for (let index = this.entries.length - 1; index >= size; index--) {
@@ -1,7 +1,4 @@
1
- // Ported from Z3 (src/smt/smt_model_checker.cpp), MIT license, see z3-license.txt. Checks whether
2
- // the candidate model satisfies each relevant quantifier: the negated body, with the model's
3
- // interpretations in place of the uninterpreted symbols, goes to an auxiliary context. A model of it
4
- // is a counterexample that becomes an instance of the quantifier.
1
+ // Ported from Z3 (src/smt/smt_model_checker.cpp), MIT license, see z3-license.txt.
5
2
  import { SmtInvariantError } from "../../../errors";
6
3
  import { KIND_APP, OP_NOT, OP_OR, SORT_BOOL, type AstManager } from "./ast";
7
4
  import { AssertedFormulas } from "./asserted-formulas";
@@ -14,32 +11,21 @@ import type { DefaultQuantifierManager } from "./quantifier-manager";
14
11
  import { RefVector } from "./ref-vector";
15
12
  import { VarSubst } from "./var-subst";
16
13
 
17
- // qi_params' mbqi_max_cexs and mbqi_max_iterations.
18
14
  const MBQI_MAX_CEXS = 1;
19
15
  const MBQI_MAX_ITERATIONS = 1000;
20
16
 
21
- // An instance whose bindings start at offset in m_pinned_exprs.
22
17
  interface Instance {
23
18
  quantifier: number;
24
19
  offset: number;
25
20
  generation: number;
26
21
  }
27
22
 
28
- // The auxiliary context: Z3 keeps one context for every check and pushes a scope per check, so the
29
- // restricted checks continue from the complete check, with its phases and activities. It runs without
30
- // MBQI and with relevancy level 0, and preprocesses the assertions of a check together.
31
23
  class AuxContext {
32
24
  private context: Context;
33
25
  private asserted: AssertedFormulas;
34
- // theory_polymorphism's m_qhead: the number of formulas when it last added an assumption. Its
35
- // trail restores it when the scope is popped, and no formula is asserted outside the scopes.
36
26
  private polyQhead = 0;
37
- // theory_polymorphism's m_assumption, which holds its last assumption.
38
27
  private polyAssumption = -1;
39
28
 
40
- // The context makes its asserted formulas first. Its theories hold only constants that exist by
41
- // now, so setup_context can run at once. init_aux_context copies the kernel's smt_params, so the
42
- // context has a model finder too, though it never sees a quantifier.
43
29
  constructor(private manager: AstManager) {
44
30
  this.asserted = new AssertedFormulas(manager);
45
31
  this.context = new Context(manager, { isMbqi: true, relevancyLevel: 0 });
@@ -57,15 +43,11 @@ class AuxContext {
57
43
  this.polyQhead = 0;
58
44
  }
59
45
 
60
- // assert_expr_core: outside the search, the scopes of the last search are popped first.
61
46
  assert(formula: number) {
62
47
  this.context.popToBaseLevel();
63
48
  this.asserted.assertExpr(formula);
64
49
  }
65
50
 
66
- // A model of the assertions, or whether they are unsatisfiable or undecided. Z3 registers
67
- // theory_polymorphism, which assumes a fresh constant whenever formulas were asserted since its
68
- // last assumption.
69
51
  check() {
70
52
  const context = this.context;
71
53
  context.popToBaseLevel();
@@ -90,7 +72,6 @@ export class ModelChecker {
90
72
  private maxCexs = MBQI_MAX_CEXS;
91
73
  private iterationIndex = 0;
92
74
  private newInstances: Instance[] = [];
93
- // m_pinned_exprs: the bindings and quantifier of each new instance, held until they are asserted.
94
75
  private pinnedExprs: RefVector;
95
76
  private root2value = new Map<Enode, number>();
96
77
  private value2expr: Map<number, number> | null = null;
@@ -120,8 +101,6 @@ export class ModelChecker {
120
101
  return value2expr;
121
102
  }
122
103
 
123
- // enode::get_eq_enode_with_min_gen: the first node of the class with generation 0, or else the
124
- // first with the least generation.
125
104
  private getEqEnodeWithMinGen(root: Enode) {
126
105
  const context = this.context;
127
106
  let result = root;
@@ -139,8 +118,6 @@ export class ModelChecker {
139
118
  return result;
140
119
  }
141
120
 
142
- // get_type_compatible_term: a term of the context that stands for a value, which may be a fresh
143
- // constant.
144
121
  private getTypeCompatibleTerm(value: number): number {
145
122
  const manager = this.manager;
146
123
  let freshTerm: number;
@@ -164,8 +141,6 @@ export class ModelChecker {
164
141
  return freshTerm;
165
142
  }
166
143
 
167
- // assert_neg_q_m: asserts the negated body under the model, with fresh constants for the
168
- // variables, which sks holds.
169
144
  private assertNegQM(aux: AuxContext, quantifier: number, model: ProtoModel, sks: RefVector) {
170
145
  const manager = this.manager;
171
146
  const data = manager.getQuantifier(quantifier);
@@ -177,8 +152,8 @@ export class ModelChecker {
177
152
  const sk = manager.mkFreshConst(null, sort);
178
153
  sks.set(numDecls - index - 1, sk);
179
154
  if (model.isFinite(sort)) {
180
- // restrict_to_universe: ast_manager::mk_or, which keeps a single disjunct in an or.
181
155
  const universe = model.getKnownUniverse(sort).map((value) => manager.mkEq(sk, value));
156
+ // ast_manager::mk_or keeps a single disjunct in an or.
182
157
  const constraint = manager.mkApp(OP_OR, universe, SORT_BOOL);
183
158
  manager.incRef(constraint);
184
159
  aux.assert(constraint);
@@ -226,13 +201,11 @@ export class ModelChecker {
226
201
  return true;
227
202
  }
228
203
 
229
- // check(q): whether the model satisfies the quantifier. A counterexample becomes an instance.
230
204
  private checkQuantifier(quantifier: number, model: ProtoModel) {
231
205
  const manager = this.manager;
232
206
  const aux = this.aux ?? new AuxContext(manager);
233
207
  this.aux = aux;
234
208
  aux.push();
235
- // sks: the fresh constants of the variables, which are released before the scope is popped.
236
209
  const sks = new RefVector(manager);
237
210
  const isSatisfied = this.checkInScope(aux, quantifier, model, sks);
238
211
  sks.reset();
@@ -247,9 +220,7 @@ export class ModelChecker {
247
220
  const completeCex = aux.check();
248
221
  if (completeCex === "unsat") return true;
249
222
  if (completeCex === "unknown") return false;
250
- // complete_cex and cex hold their models.
251
223
  completeCex.incRef();
252
- // Try to find instances from the instantiation sets first.
253
224
  this.modelFinder.restrictSksToInstSet(quantifier, sks, (expr) => aux.assert(expr));
254
225
  let numNewInstances = 0;
255
226
  for (;;) {
@@ -267,7 +238,6 @@ export class ModelChecker {
267
238
  return false;
268
239
  }
269
240
 
270
- // add_blocking_clause: diseqs and blocking_clause hold their terms until it is asserted.
271
241
  private addBlockingClause(aux: AuxContext, cex: ProtoModel, sks: number[]) {
272
242
  const manager = this.manager;
273
243
  const diseqs = new RefVector(manager);
@@ -285,7 +255,6 @@ export class ModelChecker {
285
255
  let isFoundRelevant = false;
286
256
  let numFailures = 0;
287
257
  for (const quantifier of this.qmanager.quantifiers) {
288
- // Z3's resource limit cancels the checks, and the search gives up.
289
258
  if (context.checkCanceled()) return { isFoundRelevant, numFailures: numFailures + 1 };
290
259
  if (
291
260
  !context.isRelevant(quantifier) ||
@@ -298,7 +267,6 @@ export class ModelChecker {
298
267
  return { isFoundRelevant, numFailures };
299
268
  }
300
269
 
301
- // check(md, root2value): whether the model satisfies every relevant quantifier.
302
270
  check(model: ProtoModel, root2value: Map<Enode, number>) {
303
271
  this.root2value = root2value;
304
272
  if (this.qmanager.quantifiers.length === 0) return true;
@@ -324,7 +292,6 @@ export class ModelChecker {
324
292
  return this.newInstances.length > 0;
325
293
  }
326
294
 
327
- // restart_eh: assert_new_instances.
328
295
  restartEh() {
329
296
  const context = this.context;
330
297
  for (const instance of this.newInstances) {
@@ -340,7 +307,6 @@ export class ModelChecker {
340
307
  });
341
308
  this.qmanager.addInstance(instance.quantifier, nodes, instance.generation);
342
309
  }
343
- // reset_new_instances.
344
310
  this.pinnedExprs.reset();
345
311
  this.newInstances = [];
346
312
  }