tla-ts 0.0.4-dev.a0009b7 → 0.0.4-dev.a11a30a
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.
- package/README.md +32 -143
- package/dist/deciders.cjs +366 -0
- package/dist/deciders.js +366 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +35 -1
- package/dist/index.d.ts +35 -1
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -4
- package/dist/parallel-worker.js +1 -4
- package/dist/prove-worker.cjs +9 -0
- package/dist/prove-worker.d.cts +9 -0
- package/dist/prove-worker.d.ts +9 -0
- package/dist/prove-worker.js +9 -0
- package/dist/prove.cjs +996 -0
- package/dist/prove.js +996 -0
- package/dist/run-cli.cjs +37 -47
- package/dist/run-cli.js +37 -47
- package/dist/tlapm.cjs +10 -0
- package/dist/tlapm.js +10 -0
- package/dist/transfer.cjs +38 -44
- package/dist/transfer.js +38 -44
- package/dist/worker.cjs +21 -0
- package/dist/worker.js +21 -0
- package/package.json +21 -12
- package/src/check.ts +1 -0
- package/src/codegen.ts +26 -7
- package/src/errors.ts +86 -0
- package/src/evaluate.ts +63 -20
- package/src/index.ts +10 -0
- package/src/{obligation-action.ts → obligations/action.ts} +247 -69
- package/src/{obligation-anon.ts → obligations/anon.ts} +49 -47
- package/src/obligations/ctx.ts +64 -0
- package/src/{obligation-deref.ts → obligations/deref.ts} +51 -92
- package/src/{obligation-expression.ts → obligations/expression.ts} +117 -57
- package/src/{obligation-format.ts → obligations/format.ts} +7 -8
- package/src/{obligation-generate.ts → obligations/generate.ts} +170 -192
- package/src/{obligations.ts → obligations/index.ts} +32 -16
- package/src/{obligation-levels.ts → obligations/levels.ts} +26 -28
- package/src/{obligation-module.ts → obligations/module.ts} +113 -121
- package/src/obligations/pickle.ts +98 -0
- package/src/obligations/pragma.ts +189 -0
- package/src/{obligation-printer.ts → obligations/printer.ts} +22 -80
- package/src/{obligation-proof.ts → obligations/proof.ts} +7 -2
- package/src/{obligation-source.ts → obligations/source.ts} +154 -99
- package/src/obligations/temporal.ts +321 -0
- package/src/{obligation-tuples.ts → obligations/tuples.ts} +38 -54
- package/src/ocaml-marshal.ts +166 -0
- package/src/parallel-worker.ts +2 -18
- package/src/parallel.ts +10 -43
- package/src/prove/decide-pool.ts +95 -0
- package/src/prove/deciders.ts +33 -0
- package/src/prove/first-order.ts +78 -0
- package/src/prove/isabelle/LICENSE +36 -0
- package/src/prove/isabelle/LICENSE-tlapm +26 -0
- package/src/prove/isabelle/decide.ts +47 -0
- package/src/prove/isabelle/encode.ts +446 -0
- package/src/prove/isabelle/isar/inner-syntax.ts +579 -0
- package/src/prove/isabelle/isar/method.ts +367 -0
- package/src/prove/isabelle/isar/proof.ts +28 -0
- package/src/prove/isabelle/isar/statement.ts +57 -0
- package/src/prove/isabelle/isar/theory.ts +192 -0
- package/src/prove/isabelle/isar/type-check.ts +278 -0
- package/src/prove/isabelle/provers/blast/blast.ts +258 -0
- package/src/prove/isabelle/provers/blast/branch.ts +322 -0
- package/src/prove/isabelle/provers/blast/prove.ts +347 -0
- package/src/prove/isabelle/provers/blast/rules.ts +330 -0
- package/src/prove/isabelle/provers/blast/state.ts +180 -0
- package/src/prove/isabelle/provers/blast/term.ts +547 -0
- package/src/prove/isabelle/provers/clasimp.ts +150 -0
- package/src/prove/isabelle/provers/classical.ts +389 -0
- package/src/prove/isabelle/provers/hypsubst.ts +441 -0
- package/src/prove/isabelle/pure/bicompose.ts +174 -0
- package/src/prove/isabelle/pure/consts.ts +32 -0
- package/src/prove/isabelle/pure/conv.ts +79 -0
- package/src/prove/isabelle/pure/drule.ts +264 -0
- package/src/prove/isabelle/pure/envir.ts +363 -0
- package/src/prove/isabelle/pure/goal.ts +53 -0
- package/src/prove/isabelle/pure/interrupt.ts +16 -0
- package/src/prove/isabelle/pure/list.ts +12 -0
- package/src/prove/isabelle/pure/logic.ts +402 -0
- package/src/prove/isabelle/pure/name.ts +110 -0
- package/src/prove/isabelle/pure/net.ts +262 -0
- package/src/prove/isabelle/pure/object-logic.ts +41 -0
- package/src/prove/isabelle/pure/pattern.ts +650 -0
- package/src/prove/isabelle/pure/raw-simplifier.ts +353 -0
- package/src/prove/isabelle/pure/rewriter.ts +602 -0
- package/src/prove/isabelle/pure/search.ts +68 -0
- package/src/prove/isabelle/pure/seq.ts +156 -0
- package/src/prove/isabelle/pure/simplifier.ts +112 -0
- package/src/prove/isabelle/pure/table.ts +208 -0
- package/src/prove/isabelle/pure/tactic.ts +276 -0
- package/src/prove/isabelle/pure/tactical.ts +347 -0
- package/src/prove/isabelle/pure/term-ord.ts +159 -0
- package/src/prove/isabelle/pure/term.ts +808 -0
- package/src/prove/isabelle/pure/thm.ts +806 -0
- package/src/prove/isabelle/pure/type.ts +133 -0
- package/src/prove/isabelle/pure/unify.ts +753 -0
- package/src/prove/isabelle/pure/variable.ts +25 -0
- package/src/prove/isabelle/tla/classical-setup.ts +101 -0
- package/src/prove/isabelle/tla/context.ts +74 -0
- package/src/prove/isabelle/tla/logic-data.ts +5 -0
- package/src/prove/isabelle/tla/logic.ts +215 -0
- package/src/prove/isabelle/tla/simpdata.ts +241 -0
- package/src/prove/isabelle/tools/intuitionistic.ts +132 -0
- package/src/prove/ocaml.ts +22 -0
- package/src/prove/prep/action.ts +508 -0
- package/src/prove/prep/defs.ts +33 -0
- package/src/prove/prep/elab.ts +156 -0
- package/src/prove/prep/enabled-axioms.ts +189 -0
- package/src/prove/prep/enabled.ts +43 -0
- package/src/prove/prep/fingerprint.ts +388 -0
- package/src/prove/prep/flatten.ts +70 -0
- package/src/prove/prep/level-comparison.ts +529 -0
- package/src/prove/prep/md5.ts +67 -0
- package/src/prove/prep/pragma.ts +221 -0
- package/src/prove/prep/trivial.ts +22 -0
- package/src/prove/prove-worker.ts +22 -0
- package/src/prove/prove.ts +498 -0
- package/src/prove/ptl/decide.ts +68 -0
- package/src/prove/ptl/encode.ts +255 -0
- package/src/prove/ptl/sat.ts +151 -0
- package/src/prove/ptl/tableau.ts +276 -0
- package/src/prove/smt/axiomatize.ts +69 -0
- package/src/prove/smt/axioms.ts +209 -0
- package/src/prove/smt/context.ts +108 -0
- package/src/prove/smt/data.ts +636 -0
- package/src/prove/smt/encode.ts +164 -0
- package/src/prove/smt/extensionality.ts +65 -0
- package/src/prove/smt/flatten.ts +112 -0
- package/src/prove/smt/format.ts +154 -0
- package/src/prove/smt/instances.ts +181 -0
- package/src/prove/smt/rewrite.ts +772 -0
- package/src/prove/smt/simplify.ts +57 -0
- package/src/prove/smt/solver/act-cache.ts +265 -0
- package/src/prove/smt/solver/arith-rewriter.ts +962 -0
- package/src/prove/smt/solver/array.ts +22 -0
- package/src/prove/smt/solver/asserted-formulas.ts +469 -0
- package/src/prove/smt/solver/ast-lt.ts +157 -0
- package/src/prove/smt/solver/ast-util.ts +147 -0
- package/src/prove/smt/solver/ast.ts +1315 -0
- package/src/prove/smt/solver/auf-solver.ts +572 -0
- package/src/prove/smt/solver/case-split-queue.ts +178 -0
- package/src/prove/smt/solver/cg-table.ts +175 -0
- package/src/prove/smt/solver/clause.ts +276 -0
- package/src/prove/smt/solver/conflict-resolution.ts +343 -0
- package/src/prove/smt/solver/context.ts +1292 -0
- package/src/prove/smt/solver/ctx-simplify.ts +334 -0
- package/src/prove/smt/solver/der.ts +224 -0
- package/src/prove/smt/solver/dyn-ack.ts +141 -0
- package/src/prove/smt/solver/e-matching.ts +659 -0
- package/src/prove/smt/solver/enode.ts +259 -0
- package/src/prove/smt/solver/expr-ref.ts +21 -0
- package/src/prove/smt/solver/expr-safe-replace.ts +172 -0
- package/src/prove/smt/solver/fingerprints.ts +92 -0
- package/src/prove/smt/solver/flat-literals.ts +51 -0
- package/src/prove/smt/solver/goal.ts +138 -0
- package/src/prove/smt/solver/hash.ts +173 -0
- package/src/prove/smt/solver/hashtable.ts +166 -0
- package/src/prove/smt/solver/internalizer.ts +1381 -0
- package/src/prove/smt/solver/lbool.ts +5 -0
- package/src/prove/smt/solver/literal.ts +24 -0
- package/src/prove/smt/solver/lp/bound-propagator.ts +391 -0
- package/src/prove/smt/solver/lp/constraints.ts +78 -0
- package/src/prove/smt/solver/lp/containers.ts +296 -0
- package/src/prove/smt/solver/lp/core-solver.ts +504 -0
- package/src/prove/smt/solver/lp/cross-nested.ts +224 -0
- package/src/prove/smt/solver/lp/dep-intervals.ts +656 -0
- package/src/prove/smt/solver/lp/dependency.ts +51 -0
- package/src/prove/smt/solver/lp/dioph-eq.ts +1181 -0
- package/src/prove/smt/solver/lp/explanation.ts +46 -0
- package/src/prove/smt/solver/lp/gomory.ts +255 -0
- package/src/prove/smt/solver/lp/hnf-cutter.ts +125 -0
- package/src/prove/smt/solver/lp/hnf.ts +281 -0
- package/src/prove/smt/solver/lp/int-cube.ts +295 -0
- package/src/prove/smt/solver/lp/int-solver.ts +514 -0
- package/src/prove/smt/solver/lp/lar-solver.ts +816 -0
- package/src/prove/smt/solver/lp/lar-term.ts +62 -0
- package/src/prove/smt/solver/lp/lp-settings.ts +91 -0
- package/src/prove/smt/solver/lp/maximize-term.ts +347 -0
- package/src/prove/smt/solver/lp/nex-creator.ts +381 -0
- package/src/prove/smt/solver/lp/nex.ts +120 -0
- package/src/prove/smt/solver/lp/nla-backoff.ts +43 -0
- package/src/prove/smt/solver/lp/nla-basics.ts +398 -0
- package/src/prove/smt/solver/lp/nla-core.ts +968 -0
- package/src/prove/smt/solver/lp/nla-divisions.ts +332 -0
- package/src/prove/smt/solver/lp/nla-emonics.ts +373 -0
- package/src/prove/smt/solver/lp/nla-factorization.ts +30 -0
- package/src/prove/smt/solver/lp/nla-grobner.ts +904 -0
- package/src/prove/smt/solver/lp/nla-horner.ts +126 -0
- package/src/prove/smt/solver/lp/nla-intervals.ts +265 -0
- package/src/prove/smt/solver/lp/nla-monomial-bounds.ts +715 -0
- package/src/prove/smt/solver/lp/nla-monotone.ts +59 -0
- package/src/prove/smt/solver/lp/nla-order.ts +307 -0
- package/src/prove/smt/solver/lp/nla-patcher.ts +112 -0
- package/src/prove/smt/solver/lp/nla-tangents.ts +251 -0
- package/src/prove/smt/solver/lp/nla-throttle.ts +85 -0
- package/src/prove/smt/solver/lp/nla-types.ts +124 -0
- package/src/prove/smt/solver/lp/nla-var-eqs.ts +141 -0
- package/src/prove/smt/solver/lp/nra-solver.ts +440 -0
- package/src/prove/smt/solver/lp/numeric-pair.ts +65 -0
- package/src/prove/smt/solver/lp/pdd-interval.ts +31 -0
- package/src/prove/smt/solver/lp/pdd-simplifier.ts +184 -0
- package/src/prove/smt/solver/lp/pdd-solver.ts +408 -0
- package/src/prove/smt/solver/lp/pdd.ts +971 -0
- package/src/prove/smt/solver/lp/random-updater.ts +138 -0
- package/src/prove/smt/solver/lp/static-matrix.ts +246 -0
- package/src/prove/smt/solver/lp/union-find.ts +96 -0
- package/src/prove/smt/solver/mam-compiler.ts +847 -0
- package/src/prove/smt/solver/mam-interpreter.ts +400 -0
- package/src/prove/smt/solver/maximize-ac-sharing.ts +118 -0
- package/src/prove/smt/solver/model-checker.ts +347 -0
- package/src/prove/smt/solver/model-evaluator.ts +262 -0
- package/src/prove/smt/solver/model-finder.ts +155 -0
- package/src/prove/smt/solver/model-generator.ts +97 -0
- package/src/prove/smt/solver/model-macro-solver.ts +728 -0
- package/src/prove/smt/solver/nlsat/algebraic.ts +1161 -0
- package/src/prove/smt/solver/nlsat/atoms.ts +238 -0
- package/src/prove/smt/solver/nlsat/evaluator.ts +303 -0
- package/src/prove/smt/solver/nlsat/explain.ts +607 -0
- package/src/prove/smt/solver/nlsat/interval-set.ts +351 -0
- package/src/prove/smt/solver/nlsat/levelwise.ts +740 -0
- package/src/prove/smt/solver/nlsat/mpbq.ts +161 -0
- package/src/prove/smt/solver/nlsat/polynomial.ts +1722 -0
- package/src/prove/smt/solver/nlsat/solver.ts +911 -0
- package/src/prove/smt/solver/nlsat/types.ts +43 -0
- package/src/prove/smt/solver/nlsat/upolynomial-factorization.ts +648 -0
- package/src/prove/smt/solver/nlsat/upolynomial.ts +996 -0
- package/src/prove/smt/solver/nnf.ts +469 -0
- package/src/prove/smt/solver/pattern-inference.ts +351 -0
- package/src/prove/smt/solver/poly-rewriter.ts +477 -0
- package/src/prove/smt/solver/propagate-values.ts +83 -0
- package/src/prove/smt/solver/proto-model.ts +551 -0
- package/src/prove/smt/solver/pull-quant.ts +139 -0
- package/src/prove/smt/solver/qe-lite-der.ts +526 -0
- package/src/prove/smt/solver/qe-lite-fm.ts +576 -0
- package/src/prove/smt/solver/qe-lite.ts +381 -0
- package/src/prove/smt/solver/qi-queue.ts +362 -0
- package/src/prove/smt/solver/quant-tactics.ts +117 -0
- package/src/prove/smt/solver/quantifier-analyzer.ts +562 -0
- package/src/prove/smt/solver/quantifier-manager.ts +186 -0
- package/src/prove/smt/solver/random-gen.ts +10 -0
- package/src/prove/smt/solver/rational.ts +165 -0
- package/src/prove/smt/solver/ref-vector.ts +62 -0
- package/src/prove/smt/solver/relevancy.ts +247 -0
- package/src/prove/smt/solver/rewriter-tpl.ts +1159 -0
- package/src/prove/smt/solver/rewriter.ts +843 -0
- package/src/prove/smt/solver/rlimit.ts +79 -0
- package/src/prove/smt/solver/smtlib-parser.ts +526 -0
- package/src/prove/smt/solver/solver.ts +71 -0
- package/src/prove/smt/solver/sort.ts +35 -0
- package/src/prove/smt/solver/sticky-generations.ts +69 -0
- package/src/prove/smt/solver/theory-lra-axioms.ts +340 -0
- package/src/prove/smt/solver/theory-lra-bounds.ts +226 -0
- package/src/prove/smt/solver/theory-lra-final-check.ts +252 -0
- package/src/prove/smt/solver/theory-lra-internalize.ts +476 -0
- package/src/prove/smt/solver/theory-lra-model.ts +243 -0
- package/src/prove/smt/solver/theory-lra-propagate.ts +405 -0
- package/src/prove/smt/solver/theory-lra-state.ts +43 -0
- package/src/prove/smt/solver/theory-lra.ts +56 -0
- package/src/prove/smt/solver/var-subst.ts +258 -0
- package/src/prove/smt/solver/z3-license.txt +10 -0
- package/src/prove/smt/table.ts +170 -0
- package/src/prove/tlapm/tlapm.ts +96 -0
- package/src/prove/tlaps-module.ts +510 -0
- package/src/prove/verdict.ts +18 -0
- package/src/prove/zenon/LICENSE +32 -0
- package/src/prove/zenon/check/check.ts +105 -0
- package/src/prove/zenon/check/definitions.ts +144 -0
- package/src/prove/zenon/check/equality.ts +182 -0
- package/src/prove/zenon/check/functions.ts +62 -0
- package/src/prove/zenon/check/keys.ts +125 -0
- package/src/prove/zenon/check/propositional.ts +104 -0
- package/src/prove/zenon/check/records.ts +188 -0
- package/src/prove/zenon/check/relations.ts +121 -0
- package/src/prove/zenon/check/rewrites.ts +224 -0
- package/src/prove/zenon/check/sets.ts +302 -0
- package/src/prove/zenon/check/terms.ts +127 -0
- package/src/prove/zenon/check/tla.ts +126 -0
- package/src/prove/zenon/decide.ts +113 -0
- package/src/prove/zenon/encode.ts +379 -0
- package/src/prove/zenon/eqrel.ts +300 -0
- package/src/prove/zenon/equality-rules.ts +435 -0
- package/src/prove/zenon/expr.ts +551 -0
- package/src/prove/zenon/index-table.ts +350 -0
- package/src/prove/zenon/isar-case.ts +513 -0
- package/src/prove/zenon/isar.ts +1249 -0
- package/src/prove/zenon/limits.ts +15 -0
- package/src/prove/zenon/llproof.ts +173 -0
- package/src/prove/zenon/mltoll.ts +1566 -0
- package/src/prove/zenon/node.ts +297 -0
- package/src/prove/zenon/ocaml.ts +169 -0
- package/src/prove/zenon/parse.ts +247 -0
- package/src/prove/zenon/phrase.ts +191 -0
- package/src/prove/zenon/proof.ts +198 -0
- package/src/prove/zenon/propositional-rules.ts +387 -0
- package/src/prove/zenon/rules.ts +94 -0
- package/src/prove/zenon/search.ts +288 -0
- package/src/prove/zenon/tla/functions.ts +151 -0
- package/src/prove/zenon/tla/llproof.ts +480 -0
- package/src/prove/zenon/tla/records.ts +225 -0
- package/src/prove/zenon/tla/rewrites.ts +447 -0
- package/src/prove/zenon/tla/sets.ts +304 -0
- package/src/prove/zenon/tla/terms.ts +181 -0
- package/src/prove/zenon/tla/tla.ts +506 -0
- package/src/run-cli.ts +283 -81
- package/src/standard-modules.ts +5 -2
- package/src/successors.ts +24 -5
- package/src/tlapm-cache.ts +236 -0
- package/src/tlc-random.ts +55 -32
- package/src/tlc-version.ts +8 -7
- package/src/values.ts +97 -47
- package/src/worker.ts +65 -0
- package/dist/parallel.cjs +0 -12
- package/dist/parallel.js +0 -12
package/src/run-cli.ts
CHANGED
|
@@ -5,10 +5,9 @@ import {
|
|
|
5
5
|
readFileSync,
|
|
6
6
|
readSync,
|
|
7
7
|
realpathSync,
|
|
8
|
+
rmSync,
|
|
8
9
|
writeFileSync,
|
|
9
10
|
} from "node:fs";
|
|
10
|
-
import { spawnSync } from "node:child_process";
|
|
11
|
-
import { createHash } from "node:crypto";
|
|
12
11
|
import { basename, delimiter, dirname, isAbsolute, join, resolve } from "node:path";
|
|
13
12
|
import { arch, availableParallelism, release, tmpdir, type } from "node:os";
|
|
14
13
|
import { pathToFileURL } from "node:url";
|
|
@@ -43,11 +42,26 @@ import {
|
|
|
43
42
|
TlaUnsupportedError,
|
|
44
43
|
} from "./errors";
|
|
45
44
|
import { EXIT_STATUS, setExitCode } from "./exit-codes";
|
|
46
|
-
import type { LineRange } from "./
|
|
47
|
-
import { getAtPrefix, getLocusText } from "./
|
|
48
|
-
import {
|
|
45
|
+
import type { LineRange } from "./obligations/generate";
|
|
46
|
+
import { getAtPrefix, getLocusText } from "./obligations/expression";
|
|
47
|
+
import {
|
|
48
|
+
formatSummary,
|
|
49
|
+
getObligations,
|
|
50
|
+
WHOLE_MODULE,
|
|
51
|
+
type ModuleObligations,
|
|
52
|
+
type PrintedObligation,
|
|
53
|
+
} from "./obligations";
|
|
54
|
+
import { format, renderDoc } from "./obligations/format";
|
|
55
|
+
import { printSequent } from "./obligations/printer";
|
|
49
56
|
import { check } from "./parallel";
|
|
50
57
|
import { parseModule } from "./parser";
|
|
58
|
+
import {
|
|
59
|
+
encodeProofTheory,
|
|
60
|
+
formatNormalized,
|
|
61
|
+
proveObligations,
|
|
62
|
+
type ProofAttempt,
|
|
63
|
+
} from "./prove/prove";
|
|
64
|
+
import { TLAPS_MODULE } from "./prove/tlaps-module";
|
|
51
65
|
import type { StateDump } from "./state-graph";
|
|
52
66
|
import {
|
|
53
67
|
formatProbability,
|
|
@@ -55,10 +69,18 @@ import {
|
|
|
55
69
|
getOptimisticProbability,
|
|
56
70
|
getOutDegreeSummary,
|
|
57
71
|
} from "./tlc-summary";
|
|
72
|
+
import { getTlapmPaths } from "./prove/tlapm/tlapm";
|
|
73
|
+
import {
|
|
74
|
+
getKnownResults,
|
|
75
|
+
loadFingerprints,
|
|
76
|
+
saveHistory,
|
|
77
|
+
type FingerprintTable,
|
|
78
|
+
} from "./tlapm-cache";
|
|
58
79
|
import type { SanySpecification } from "./sany-generator";
|
|
59
80
|
import { SANY_174_STANDARD_MODULES, SANY_STANDARD_MODULES } from "./sany-modules";
|
|
60
81
|
import { getSanyModuleName, getSanyReport, type SanyModuleOrigin } from "./sany-report";
|
|
61
82
|
import { exportSanyXml, XML_EXPORT_EXIT_CODE, type XmlExportOptions } from "./sany-xml";
|
|
83
|
+
import { getTlcFingerprint } from "./tlc-random";
|
|
62
84
|
import { getTlcVersion, type TlcVersion } from "./tlc-version";
|
|
63
85
|
import {
|
|
64
86
|
createMessagePrinter,
|
|
@@ -101,16 +123,28 @@ const CHECK_COMMAND = defineCommand("tla-ts <Spec.tla|Spec.cfg|glob>... {options
|
|
|
101
123
|
{ flag: "-workers <count|auto>" },
|
|
102
124
|
]);
|
|
103
125
|
|
|
104
|
-
const
|
|
105
|
-
{ flag: "-N"
|
|
126
|
+
const TLAPM_COMMAND = defineCommand("tla-ts tlapm {options} <Module.tla|glob>...", [
|
|
127
|
+
{ flag: "-N" },
|
|
128
|
+
{ flag: "--summary" },
|
|
129
|
+
{ flag: "--strict" },
|
|
106
130
|
{ flag: "--toolbox <start> <end>" },
|
|
107
131
|
{ flag: "--line <num>" },
|
|
108
132
|
{ flag: "--printallobs" },
|
|
109
|
-
{ flag: "--
|
|
110
|
-
{ flag: "--
|
|
133
|
+
{ flag: "--threads <num>" },
|
|
134
|
+
{ flag: "--version" },
|
|
111
135
|
{ flag: "-I <directory>", isRepeatable: true },
|
|
136
|
+
{ flag: "-k" },
|
|
137
|
+
{ flag: "--noproving" },
|
|
138
|
+
{ flag: "--nofp" },
|
|
139
|
+
{ flag: "--nofpl <start> <end>" },
|
|
140
|
+
{ flag: "--safefp" },
|
|
141
|
+
{ flag: "--cleanfp" },
|
|
142
|
+
{ flag: "--usefp <file>" },
|
|
143
|
+
{ flag: "--cache-dir <directory>" },
|
|
112
144
|
]);
|
|
113
145
|
|
|
146
|
+
const TLAPM_INTEGER_OPTIONS = new Set(["--toolbox", "--line", "--threads", "--nofpl"]);
|
|
147
|
+
|
|
114
148
|
const XML_EXPORT_FLAGS = new Set(["-o", "-t", "-r", "-u"]);
|
|
115
149
|
|
|
116
150
|
const XML_EXPORT_174_FLAGS = new Set(["-o"]);
|
|
@@ -165,8 +199,7 @@ const XML_EXPORT_USAGE = (() => {
|
|
|
165
199
|
|
|
166
200
|
const USAGE = [
|
|
167
201
|
`Usage: ${CHECK_COMMAND.usage}`,
|
|
168
|
-
` ${
|
|
169
|
-
" tla-ts prove [<tlapm option>]... <Module.tla|glob>...",
|
|
202
|
+
` ${TLAPM_COMMAND.usage}`,
|
|
170
203
|
" tla-ts [<JVM option>]... tlc2.TLC <TLC option>... <Spec>",
|
|
171
204
|
" (-cp tla2tools.jar or -Dtla-ts.tlc=1.7.4 picks the TLC to reproduce)",
|
|
172
205
|
" tla-ts [<JVM option>]... tla2sany.xml.XMLExporter [-I <directory>]... [-o] [-t] [-r] [-u] <Module.tla>",
|
|
@@ -705,9 +738,9 @@ const getStandardModulesUrl = (jar: string) =>
|
|
|
705
738
|
`jar:file:${pathToFileURL(resolve(jar)).pathname}!/tla2sany/StandardModules/`;
|
|
706
739
|
|
|
707
740
|
// Java's Files.createTempDirectory names a directory by a random unsigned long. tla-ts derives it
|
|
708
|
-
// from what the directory holds, so that each run of a spec prints the same
|
|
709
|
-
|
|
710
|
-
|
|
741
|
+
// from TLC's fingerprint of what the directory holds, so that each run of a spec prints the same
|
|
742
|
+
// files.
|
|
743
|
+
const getTemporaryName = (contents: string) => getTlcFingerprint([contents]).toString();
|
|
711
744
|
|
|
712
745
|
// The file TLC's SANY says it parses each module from: the real path of a module's own file, or a
|
|
713
746
|
// copy in a temporary directory of a module from the root module's file or from the jar on the
|
|
@@ -1041,51 +1074,42 @@ const runEach = async (
|
|
|
1041
1074
|
return exitCodes.find((exitCode) => exitCode !== EXIT_STATUS.success) ?? EXIT_STATUS.success;
|
|
1042
1075
|
};
|
|
1043
1076
|
|
|
1044
|
-
// tlapm
|
|
1045
|
-
// bin/tlapm.
|
|
1046
|
-
const
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
.map((directory) => join(directory, "tlapm"))
|
|
1050
|
-
.filter((path) => existsSync(path));
|
|
1051
|
-
|
|
1052
|
-
const getTlapmLibrary = () =>
|
|
1053
|
-
getTlapmPaths()
|
|
1077
|
+
// tlapm searches the current directory, then its standard library at lib/tlapm/stdlib beside
|
|
1078
|
+
// bin/tlapm, then each -I directory, the last given first.
|
|
1079
|
+
const getLibraryDirectories = (parsed: ParsedArgs) => [
|
|
1080
|
+
".",
|
|
1081
|
+
...getTlapmPaths()
|
|
1054
1082
|
.map((path) => join(dirname(dirname(realpathSync(path))), "lib/tlapm/stdlib"))
|
|
1055
|
-
.
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
const proveWithTlapm = (args: string[]) => {
|
|
1061
|
-
const tlapm = getTlapmPaths()[0];
|
|
1062
|
-
if (tlapm === undefined) {
|
|
1063
|
-
console.error(
|
|
1064
|
-
"Error: tla-ts prove runs tlapm to prove obligations, but tlapm isn't on your PATH. Install tlapm, or pass -N to only generate the obligations.",
|
|
1065
|
-
);
|
|
1066
|
-
return 1;
|
|
1067
|
-
}
|
|
1068
|
-
return spawnSync(tlapm, expandGlobs(args), { stdio: "inherit" }).status ?? 1;
|
|
1069
|
-
};
|
|
1070
|
-
|
|
1071
|
-
const readModule = (path: string) =>
|
|
1072
|
-
existsSync(path) ? { file: path, source: readFileSync(path, "utf8") } : undefined;
|
|
1083
|
+
.filter((path) => existsSync(path))
|
|
1084
|
+
.slice(0, 1),
|
|
1085
|
+
...parsed.options.flatMap((option) => (option.name === "-I" ? option.values : [])).toReversed(),
|
|
1086
|
+
];
|
|
1073
1087
|
|
|
1074
1088
|
// A message of tlapm's toolbox protocol, which it writes to stderr.
|
|
1075
1089
|
const printToolboxMessage = (fields: string[]) =>
|
|
1076
1090
|
console.error(`@!!BEGIN\n${fields.map((field) => `@!!${field}\n`).join("")}@!!END\n`);
|
|
1077
1091
|
|
|
1078
|
-
const
|
|
1092
|
+
const printObligationMessage = (obligation: PrintedObligation, status: string, fields: string[]) =>
|
|
1093
|
+
printToolboxMessage([
|
|
1094
|
+
"type:obligation",
|
|
1095
|
+
`id:${obligation.id}`,
|
|
1096
|
+
`loc:${obligation.location}`,
|
|
1097
|
+
`status:${status}`,
|
|
1098
|
+
...fields,
|
|
1099
|
+
]);
|
|
1100
|
+
|
|
1101
|
+
const TLAPM_VERSION = "9ed0376";
|
|
1079
1102
|
|
|
1080
1103
|
const quoteArgument = (arg: string) =>
|
|
1081
1104
|
/^[+,\-./0-9:=@A-Z_a-z]+$/.test(arg) ? arg : `'${arg.replaceAll("'", "'\\''")}'`;
|
|
1082
1105
|
|
|
1083
1106
|
const printToolboxHeader = (args: string[]) =>
|
|
1084
1107
|
console.log(
|
|
1085
|
-
`\n\\* TLAPM version ${TLAPM_VERSION}\n\\* launched at ${formatTlcDate(new Date())} with command line:\n\\* ${["tla-ts", "
|
|
1108
|
+
`\n\\* TLAPM version ${TLAPM_VERSION}\n\\* launched at ${formatTlcDate(new Date())} with command line:\n\\* ${["tla-ts", "tlapm", ...args].map(quoteArgument).join(" ")}\n`,
|
|
1086
1109
|
);
|
|
1087
1110
|
|
|
1088
|
-
|
|
1111
|
+
// The most severe first.
|
|
1112
|
+
const STRICT_EXIT_STATUS = { failed: 10, incomplete: 11, emptyTarget: 12 };
|
|
1089
1113
|
|
|
1090
1114
|
const checkStrictly = (result: ModuleObligations, isTargeted: boolean, isSummary: boolean) => {
|
|
1091
1115
|
const summary = result.summary;
|
|
@@ -1113,6 +1137,17 @@ const checkStrictly = (result: ModuleObligations, isTargeted: boolean, isSummary
|
|
|
1113
1137
|
|
|
1114
1138
|
const TLAPM_FAILURE_STATUS = 3;
|
|
1115
1139
|
|
|
1140
|
+
const UNPROVED_ENDING = [
|
|
1141
|
+
' tlapm ending abnormally with Failure("backend errors: there are unproved obligations")',
|
|
1142
|
+
'Raised at Stdlib.failwith in file "stdlib.ml", line 29, characters 17-33',
|
|
1143
|
+
'Called from Tlapm_lib.process_module in file "src/tlapm_lib.ml", lines 492-493, characters 12-37',
|
|
1144
|
+
'Called from Tlapm_lib.main.f in file "src/tlapm_lib.ml", line 640, characters 23-43',
|
|
1145
|
+
'Called from Stdlib__List.fold_left in file "list.ml", line 125, characters 24-34',
|
|
1146
|
+
'Called from Tlapm_lib.main in file "src/tlapm_lib.ml", line 643, characters 13-40',
|
|
1147
|
+
'Called from Tlapm_lib.init in file "src/tlapm_lib.ml", line 659, characters 8-59',
|
|
1148
|
+
"",
|
|
1149
|
+
].join("\n");
|
|
1150
|
+
|
|
1116
1151
|
const generateObligations = (generate: () => ModuleObligations[]) => {
|
|
1117
1152
|
try {
|
|
1118
1153
|
return generate();
|
|
@@ -1123,12 +1158,114 @@ const generateObligations = (generate: () => ModuleObligations[]) => {
|
|
|
1123
1158
|
}
|
|
1124
1159
|
};
|
|
1125
1160
|
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
const
|
|
1129
|
-
const
|
|
1161
|
+
// Toolbox.print_res_aux.
|
|
1162
|
+
const printAttempt = (obligation: PrintedObligation, attempt: ProofAttempt) => {
|
|
1163
|
+
const limit = attempt.method.timeLimitMs;
|
|
1164
|
+
const used =
|
|
1165
|
+
attempt.timeUsedMs === undefined
|
|
1166
|
+
? ""
|
|
1167
|
+
: `; time-used: ${(attempt.timeUsedMs / 1000).toFixed(1)} (${Math.round((100 * attempt.timeUsedMs) / limit)}%)`;
|
|
1168
|
+
const times =
|
|
1169
|
+
limit === 0
|
|
1170
|
+
? ""
|
|
1171
|
+
: `time-limit: ${limit === Infinity ? "inf" : Number((limit / 1000).toPrecision(6))}${used}`;
|
|
1172
|
+
const method = [attempt.method.tactic, times].filter(Boolean).join("; ");
|
|
1173
|
+
const isSmt = attempt.method.prover === "smt" || attempt.method.prover === "z3";
|
|
1174
|
+
const note =
|
|
1175
|
+
isSmt && attempt.reason === "false" && attempt.verdict
|
|
1176
|
+
? `(* SMT failed with status = ${attempt.verdict}\n *)\n`
|
|
1177
|
+
: "";
|
|
1178
|
+
printObligationMessage(obligation, attempt.isProved ? "proved" : "failed", [
|
|
1179
|
+
`prover:${attempt.method.prover}`,
|
|
1180
|
+
...(method === "" ? [] : [`meth:${method}`]),
|
|
1181
|
+
...(attempt.reason === undefined ? [] : [`reason:${attempt.reason}`]),
|
|
1182
|
+
`already:${attempt.isReused}`,
|
|
1183
|
+
...(attempt.isProved
|
|
1184
|
+
? []
|
|
1185
|
+
: [
|
|
1186
|
+
`obl:${attempt.isReused ? "" : `\n${note}`}${formatNormalized(obligation, attempt.isReused)}`,
|
|
1187
|
+
]),
|
|
1188
|
+
]);
|
|
1189
|
+
};
|
|
1190
|
+
|
|
1191
|
+
// Method.Fail, for an error obligation or one no method was tried on.
|
|
1192
|
+
const printFailure = (obligation: PrintedObligation, reason: string) =>
|
|
1193
|
+
printObligationMessage(obligation, "failed", [
|
|
1194
|
+
"prover:fail",
|
|
1195
|
+
"meth:time-limit: inf",
|
|
1196
|
+
`reason:${reason}`,
|
|
1197
|
+
"already:false",
|
|
1198
|
+
`obl:${obligation.text}`,
|
|
1199
|
+
]);
|
|
1200
|
+
|
|
1201
|
+
interface ProvingSettings {
|
|
1202
|
+
isToolbox: boolean;
|
|
1203
|
+
isProving: boolean;
|
|
1204
|
+
workers: number;
|
|
1205
|
+
isFingerprinted: (obligation: PrintedObligation) => boolean;
|
|
1206
|
+
fingerprints: FingerprintTable;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
// Tlapm_lib.process_obs. Returns whether some obligation failed.
|
|
1210
|
+
const proveModule = async (
|
|
1211
|
+
result: ModuleObligations,
|
|
1212
|
+
theoryPath: string,
|
|
1213
|
+
fingerprintsPath: string,
|
|
1214
|
+
settings: ProvingSettings,
|
|
1215
|
+
) => {
|
|
1216
|
+
const known = getKnownResults(settings.fingerprints);
|
|
1217
|
+
const reports = await proveObligations(result.obligations, {
|
|
1218
|
+
workers: settings.workers,
|
|
1219
|
+
results: known.results,
|
|
1220
|
+
isFingerprinted: settings.isFingerprinted,
|
|
1221
|
+
isProving: settings.isProving,
|
|
1222
|
+
onReport: (report, obligation) => {
|
|
1223
|
+
if (!settings.isToolbox) return;
|
|
1224
|
+
if (report.obligation.status === "trivial")
|
|
1225
|
+
return printObligationMessage(obligation, "trivial", ["prover:tlapm", "already:false"]);
|
|
1226
|
+
if (obligation.kind.kind === "Error") return printFailure(obligation, "user error");
|
|
1227
|
+
report.attempts.forEach((attempt) => printAttempt(obligation, attempt));
|
|
1228
|
+
},
|
|
1229
|
+
});
|
|
1230
|
+
writeFileSync(theoryPath, encodeProofTheory(result.name, reports, result.obligations));
|
|
1231
|
+
console.log(`(* created new ${JSON.stringify(theoryPath)} *)`);
|
|
1232
|
+
known.save(fingerprintsPath);
|
|
1233
|
+
console.log(`(* fingerprints written in ${JSON.stringify(fingerprintsPath)} *)`);
|
|
1234
|
+
if (!settings.isProving) return false;
|
|
1235
|
+
const unproved = reports.flatMap((report, index) =>
|
|
1236
|
+
"reason" in report.obligation ? [{ report, obligation: result.obligations[index] }] : [],
|
|
1237
|
+
);
|
|
1238
|
+
if (settings.isToolbox) {
|
|
1239
|
+
unproved
|
|
1240
|
+
.filter(
|
|
1241
|
+
(entry) => entry.report.attempts.length === 0 && entry.obligation.kind.kind !== "Error",
|
|
1242
|
+
)
|
|
1243
|
+
.forEach((entry) => printFailure(entry.obligation, "unexpected error"));
|
|
1244
|
+
}
|
|
1245
|
+
unproved
|
|
1246
|
+
.toReversed()
|
|
1247
|
+
.forEach((entry) =>
|
|
1248
|
+
console.error(
|
|
1249
|
+
`${getAtPrefix(entry.obligation.locus)}${renderDoc(format("[ERROR]: @[<v2>Could not prove or check:@,%a@]", printSequent(entry.obligation.sequent)), 35)}`,
|
|
1250
|
+
),
|
|
1251
|
+
);
|
|
1252
|
+
const total = `${result.obligations.length} obligation${result.obligations.length > 1 ? "s" : ""}`;
|
|
1253
|
+
console.error(
|
|
1254
|
+
unproved.length === 0
|
|
1255
|
+
? `${getAtPrefix(result.location)}[INFO]: All ${total} proved.`
|
|
1256
|
+
: `${getAtPrefix(result.location)}[ERROR]: ${unproved.length}/${total} failed.\nThere were backend errors processing module \`${JSON.stringify(result.name)}\`.`,
|
|
1257
|
+
);
|
|
1258
|
+
return unproved.length > 0;
|
|
1259
|
+
};
|
|
1260
|
+
|
|
1261
|
+
const runTlapm = async (args: string[]) => {
|
|
1262
|
+
const parsed = TLAPM_COMMAND.parse(args);
|
|
1263
|
+
const isProcessing = !parsed.has("-N") && !parsed.has("--summary");
|
|
1264
|
+
const unsupported =
|
|
1265
|
+
parsed.unknown[0] ??
|
|
1266
|
+
(isProcessing && parsed.has("--printallobs") ? "--printallobs" : undefined);
|
|
1130
1267
|
if (unsupported !== undefined) {
|
|
1131
|
-
console.error(`Error: tla-ts
|
|
1268
|
+
console.error(`Error: tla-ts tlapm does not support the tlapm option ${unsupported}.`);
|
|
1132
1269
|
return 1;
|
|
1133
1270
|
}
|
|
1134
1271
|
if (parsed.incomplete) {
|
|
@@ -1136,13 +1273,19 @@ const prove = (args: string[]) => {
|
|
|
1136
1273
|
return 1;
|
|
1137
1274
|
}
|
|
1138
1275
|
const nonInteger = parsed.options.find(
|
|
1139
|
-
(option) =>
|
|
1276
|
+
(option) =>
|
|
1277
|
+
TLAPM_INTEGER_OPTIONS.has(option.name) &&
|
|
1278
|
+
option.values.some((value) => !/^-?\d+$/.test(value)),
|
|
1140
1279
|
);
|
|
1141
1280
|
if (nonInteger) {
|
|
1142
1281
|
console.error(`Error: option '${nonInteger.name}' expects an integer.`);
|
|
1143
1282
|
return 1;
|
|
1144
1283
|
}
|
|
1145
|
-
|
|
1284
|
+
if (parsed.has("--version")) {
|
|
1285
|
+
console.log(TLAPM_VERSION);
|
|
1286
|
+
return EXIT_STATUS.success;
|
|
1287
|
+
}
|
|
1288
|
+
const files = getInputPaths(parsed.positionals).map((input) => input.path);
|
|
1146
1289
|
const modulePaths = files.map((path) => (path.endsWith(".tla") ? path : `${path}.tla`));
|
|
1147
1290
|
if (modulePaths.length === 0) {
|
|
1148
1291
|
console.error(USAGE);
|
|
@@ -1157,15 +1300,12 @@ const prove = (args: string[]) => {
|
|
|
1157
1300
|
if (option.name === "--line") return start === 0 ? WHOLE_MODULE : { start, end: start };
|
|
1158
1301
|
return range;
|
|
1159
1302
|
}, WHOLE_MODULE);
|
|
1160
|
-
// tlapm searches
|
|
1161
|
-
// directory, the last given first.
|
|
1162
|
-
const tlapmLibrary = getTlapmLibrary();
|
|
1163
|
-
const includes = parsed.options.flatMap((option) => (option.name === "-I" ? option.values : []));
|
|
1303
|
+
// tlapm also searches each module's directory. Without tlapm, TLAPS is tla-ts's copy.
|
|
1164
1304
|
const directories = modulePaths.reduce(
|
|
1165
1305
|
(found, path) => (found.includes(dirname(path)) ? found : [dirname(path), ...found]),
|
|
1166
|
-
|
|
1306
|
+
getLibraryDirectories(parsed),
|
|
1167
1307
|
);
|
|
1168
|
-
|
|
1308
|
+
const moduleNames = new Set<string>();
|
|
1169
1309
|
const results = generateObligations(() => {
|
|
1170
1310
|
const missingIndex = modulePaths.findIndex((path) => !existsSync(path));
|
|
1171
1311
|
if (missingIndex !== -1) {
|
|
@@ -1175,8 +1315,16 @@ const prove = (args: string[]) => {
|
|
|
1175
1315
|
}
|
|
1176
1316
|
return getObligations(
|
|
1177
1317
|
modulePaths.map((path) => ({ file: `./${path}`, source: readFileSync(path, "utf8") })),
|
|
1178
|
-
(name) =>
|
|
1179
|
-
|
|
1318
|
+
(name) => {
|
|
1319
|
+
moduleNames.add(name);
|
|
1320
|
+
// tlapm names each file it reads by joining a search directory and the name, as in
|
|
1321
|
+
// ./Module.tla.
|
|
1322
|
+
const file = directories
|
|
1323
|
+
.map((directory) => `${directory}/${name}.tla`)
|
|
1324
|
+
.find((path) => existsSync(path));
|
|
1325
|
+
if (file !== undefined) return { file, source: readFileSync(file, "utf8") };
|
|
1326
|
+
return name === "TLAPS" ? { file: "TLAPS.tla", source: TLAPS_MODULE } : undefined;
|
|
1327
|
+
},
|
|
1180
1328
|
{
|
|
1181
1329
|
lines,
|
|
1182
1330
|
onWarning: (warning) => {
|
|
@@ -1191,26 +1339,80 @@ const prove = (args: string[]) => {
|
|
|
1191
1339
|
);
|
|
1192
1340
|
});
|
|
1193
1341
|
if (!results) return TLAPM_FAILURE_STATUS;
|
|
1194
|
-
const
|
|
1342
|
+
const cacheDirectory =
|
|
1343
|
+
parsed.get("--cache-dir")?.[0] ?? process.env.TLAPM_CACHE_DIR ?? ".tlacache";
|
|
1344
|
+
const forgottenLines = parsed.get("--nofpl")?.map(Number) ?? [0, 0];
|
|
1345
|
+
const settings: ProvingSettings = {
|
|
1346
|
+
isToolbox,
|
|
1347
|
+
isProving: !parsed.has("--noproving"),
|
|
1348
|
+
workers: Math.max(1, Number(parsed.get("--threads")?.[0] ?? availableParallelism())),
|
|
1349
|
+
isFingerprinted: (obligation) =>
|
|
1350
|
+
!parsed.has("--nofp") &&
|
|
1351
|
+
!(
|
|
1352
|
+
obligation.locus &&
|
|
1353
|
+
obligation.locus.startLine >= forgottenLines[0] &&
|
|
1354
|
+
obligation.locus.endLine <= forgottenLines[1]
|
|
1355
|
+
),
|
|
1356
|
+
fingerprints: new Map(),
|
|
1357
|
+
};
|
|
1358
|
+
const statuses: number[] = [];
|
|
1359
|
+
for (const [index, result] of results.entries()) {
|
|
1360
|
+
// Tlapm_lib.mkdir_tlaps.
|
|
1361
|
+
const directory = `${cacheDirectory}/${result.name}.tlaps`;
|
|
1362
|
+
const fingerprintsPath = `${directory}/fingerprints`;
|
|
1363
|
+
const loadedPath = parsed.get("--usefp")?.[0] ?? fingerprintsPath;
|
|
1364
|
+
mkdirSync(directory, { recursive: true });
|
|
1365
|
+
if (parsed.has("--cleanfp") && existsSync(fingerprintsPath)) {
|
|
1366
|
+
rmSync(fingerprintsPath);
|
|
1367
|
+
console.log(`(* fingerprints file ${JSON.stringify(fingerprintsPath)} removed *)`);
|
|
1368
|
+
}
|
|
1369
|
+
if (!parsed.has("--cleanfp") && existsSync(loadedPath) && result.summary.total !== 0) {
|
|
1370
|
+
console.log(
|
|
1371
|
+
parsed.has("--nofp")
|
|
1372
|
+
? `(* will not use fingerprints (because of option \`--nofp\`), but will now load fingerprints from the file \`${loadedPath}\`, in order to overwrite with the new fingerprints, and then save the results at the end. *)`
|
|
1373
|
+
: `(* loading fingerprints in ${JSON.stringify(loadedPath)} *)`,
|
|
1374
|
+
);
|
|
1375
|
+
loadFingerprints(settings.fingerprints, loadedPath, parsed.has("--safefp"));
|
|
1376
|
+
}
|
|
1195
1377
|
if (parsed.has("--summary")) console.log(formatSummary(result));
|
|
1196
1378
|
if (isToolbox) {
|
|
1197
1379
|
result.obligations.forEach((obligation) =>
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
`
|
|
1202
|
-
|
|
1203
|
-
...(parsed.has("--printallobs") ? [`obl:${obligation.text}`] : []),
|
|
1204
|
-
]),
|
|
1380
|
+
printObligationMessage(
|
|
1381
|
+
obligation,
|
|
1382
|
+
"to be proved",
|
|
1383
|
+
parsed.has("--printallobs") ? [`obl:${obligation.text}`] : [],
|
|
1384
|
+
),
|
|
1205
1385
|
);
|
|
1206
1386
|
printToolboxMessage(["type:obligationsnumber", `count:${result.obligations.length}`]);
|
|
1207
1387
|
}
|
|
1208
|
-
if (
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1388
|
+
if (parsed.has("--strict"))
|
|
1389
|
+
statuses.push(
|
|
1390
|
+
...checkStrictly(result, lines.start > 0 || lines.end < Infinity, parsed.has("--summary")),
|
|
1391
|
+
);
|
|
1392
|
+
if (!isProcessing) continue;
|
|
1393
|
+
// tlapm's history holds the source of each module read so far.
|
|
1394
|
+
saveHistory(
|
|
1395
|
+
fingerprintsPath,
|
|
1396
|
+
[...moduleNames, ...results.slice(0, index + 1).map((innerResult) => innerResult.name)].map(
|
|
1397
|
+
(name) => `${name}.tla`,
|
|
1398
|
+
),
|
|
1399
|
+
);
|
|
1400
|
+
const isFailed = await proveModule(
|
|
1401
|
+
result,
|
|
1402
|
+
`${directory}/${result.name}.thy`,
|
|
1403
|
+
fingerprintsPath,
|
|
1404
|
+
settings,
|
|
1405
|
+
);
|
|
1406
|
+
if (isFailed && parsed.has("--strict")) statuses.push(STRICT_EXIT_STATUS.failed);
|
|
1407
|
+
if (isFailed && !parsed.has("--strict") && !isToolbox) {
|
|
1408
|
+
console.error(UNPROVED_ENDING);
|
|
1409
|
+
return TLAPM_FAILURE_STATUS;
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
return (
|
|
1413
|
+
Object.values(STRICT_EXIT_STATUS).find((status) => statuses.includes(status)) ??
|
|
1414
|
+
EXIT_STATUS.success
|
|
1415
|
+
);
|
|
1214
1416
|
};
|
|
1215
1417
|
|
|
1216
1418
|
const checkSpecs = async (args: string[], java: JavaProperties) => {
|
|
@@ -1247,7 +1449,7 @@ const checkSpecs = async (args: string[], java: JavaProperties) => {
|
|
|
1247
1449
|
? path
|
|
1248
1450
|
: (java.libraries.map((directory) => join(directory, path)).find(existsSync) ?? path);
|
|
1249
1451
|
const paths = [...new Set(specPaths.map(findSpec))];
|
|
1250
|
-
const tlcVersion =
|
|
1452
|
+
const tlcVersion = java.tlcVersion ?? "master";
|
|
1251
1453
|
return runEach(
|
|
1252
1454
|
paths,
|
|
1253
1455
|
(path, printer) => {
|
|
@@ -1488,9 +1690,6 @@ interface JavaProperties {
|
|
|
1488
1690
|
const getJar = (java: JavaProperties) =>
|
|
1489
1691
|
java.classPath?.split(delimiter).find((entry) => entry.endsWith(".jar"));
|
|
1490
1692
|
|
|
1491
|
-
// The TLC that -Dtla-ts.tlc names, or else the one of the jar on the class path.
|
|
1492
|
-
const getJavaTlcVersion = (java: JavaProperties) => java.tlcVersion ?? getTlcVersion(getJar(java));
|
|
1493
|
-
|
|
1494
1693
|
interface JavaLaunch {
|
|
1495
1694
|
mainClass: string;
|
|
1496
1695
|
args: string[];
|
|
@@ -1525,7 +1724,7 @@ const runJavaClass = (launch: JavaLaunch) => {
|
|
|
1525
1724
|
if (launch.mainClass === "tlc2.TLC") return checkSpecs(launch.args, launch.java);
|
|
1526
1725
|
if (launch.mainClass === "tla2sany.xml.XMLExporter") {
|
|
1527
1726
|
return reportErrors(() =>
|
|
1528
|
-
|
|
1727
|
+
launch.java.tlcVersion === "1.7.4"
|
|
1529
1728
|
? exportXml174(launch.args, getJar(launch.java))
|
|
1530
1729
|
: exportXml(launch.args),
|
|
1531
1730
|
);
|
|
@@ -1537,9 +1736,12 @@ const runJavaClass = (launch: JavaLaunch) => {
|
|
|
1537
1736
|
};
|
|
1538
1737
|
|
|
1539
1738
|
const run = async (args: string[]) => {
|
|
1540
|
-
if (args[0] === "
|
|
1739
|
+
if (args[0] === "tlapm") return reportErrors(() => runTlapm(args.slice(1)));
|
|
1541
1740
|
const launch = getJavaLaunch(args);
|
|
1542
|
-
|
|
1741
|
+
if (launch === undefined) return checkSpecs(args, { libraries: [] });
|
|
1742
|
+
// The TLC that -Dtla-ts.tlc names, or else the one of the jar on the class path.
|
|
1743
|
+
launch.java.tlcVersion ??= await getTlcVersion(getJar(launch.java));
|
|
1744
|
+
return runJavaClass(launch);
|
|
1543
1745
|
};
|
|
1544
1746
|
|
|
1545
1747
|
export const runCli = async () => {
|
package/src/standard-modules.ts
CHANGED
|
@@ -162,8 +162,11 @@ export const CORE_OPERATORS: Builtin[] = [
|
|
|
162
162
|
: differenceSorted;
|
|
163
163
|
// The merge compares the elements, which TLC tests for membership one by one instead.
|
|
164
164
|
return computeLikeTlcOnFailure(
|
|
165
|
-
() => merge(toFiniteSet(
|
|
166
|
-
() =>
|
|
165
|
+
(finiteLeft, finiteRight) => merge(toFiniteSet(finiteLeft), toFiniteSet(finiteRight)),
|
|
166
|
+
(reducibleLeft, reducibleRight) =>
|
|
167
|
+
combineReducible(operator, reducibleLeft, reducibleRight),
|
|
168
|
+
left,
|
|
169
|
+
right,
|
|
167
170
|
);
|
|
168
171
|
}
|
|
169
172
|
if (isReducibleSet(left)) return combineReducible(operator, left, right);
|
package/src/successors.ts
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
toKeepLazyContext,
|
|
26
26
|
getDefinition,
|
|
27
27
|
getContextElements,
|
|
28
|
+
getEntryEvaluator,
|
|
28
29
|
getReevaluatedDefinitions,
|
|
29
30
|
lookupScope,
|
|
30
31
|
resolveApplyOperator,
|
|
@@ -32,6 +33,7 @@ import {
|
|
|
32
33
|
toUnspecifiedSubscriptError,
|
|
33
34
|
type Context,
|
|
34
35
|
type Environment,
|
|
36
|
+
type Evaluator,
|
|
35
37
|
type Scope,
|
|
36
38
|
type State,
|
|
37
39
|
} from "./evaluate";
|
|
@@ -129,12 +131,24 @@ const getIfConditionMessage = (run: Run, value: Value, expression: Expression) =
|
|
|
129
131
|
return `In computing ${getComputation(run)}, a non-boolean expression (${kind}) was used as the condition of an IF.${run.isInit ? "\n" : ""}${range}`;
|
|
130
132
|
};
|
|
131
133
|
|
|
132
|
-
const holds = (run: Run, expression: Expression, context: Context, isWalked = true) =>
|
|
133
|
-
|
|
134
|
+
const holds = (run: Run, expression: Expression, context: Context, isWalked = true) =>
|
|
135
|
+
holdsValue(run, expression, evaluate(expression, context), isWalked);
|
|
136
|
+
|
|
137
|
+
const holdsValue = (run: Run, expression: Expression, value: Value, isWalked = true) => {
|
|
134
138
|
if (typeof value === "boolean") return value;
|
|
135
139
|
throw createRunError(run, getNonBooleanMessage(run, value, expression, isWalked));
|
|
136
140
|
};
|
|
137
141
|
|
|
142
|
+
const evaluateCached = (
|
|
143
|
+
evaluators: (Evaluator | undefined)[],
|
|
144
|
+
index: number,
|
|
145
|
+
expression: Expression,
|
|
146
|
+
context: Context,
|
|
147
|
+
) =>
|
|
148
|
+
context.environment.callStack
|
|
149
|
+
? evaluate(expression, context)
|
|
150
|
+
: (evaluators[index] ??= getEntryEvaluator(expression, context.environment))(context);
|
|
151
|
+
|
|
138
152
|
const isAssignmentOperator = (operator: string) =>
|
|
139
153
|
operator === "=" || operator === "\\in" || operator === "\\subseteq";
|
|
140
154
|
|
|
@@ -357,6 +371,8 @@ const compileConjunction = (
|
|
|
357
371
|
isInit: boolean,
|
|
358
372
|
): Runner => {
|
|
359
373
|
const conjuncts = operands.map((operand) => toConjunct(operand, environment, isInit));
|
|
374
|
+
const evaluators: (Evaluator | undefined)[] = [];
|
|
375
|
+
const restEvaluators: (Evaluator | undefined)[] = [];
|
|
360
376
|
const runFrom = (
|
|
361
377
|
start: number,
|
|
362
378
|
run: Run,
|
|
@@ -372,7 +388,9 @@ const compileConjunction = (
|
|
|
372
388
|
if (index > 0 && isShortcut && isComplete(current)) {
|
|
373
389
|
context ??= getContext(run, scope, current);
|
|
374
390
|
for (let rest = index; rest < conjuncts.length; rest++) {
|
|
375
|
-
|
|
391
|
+
const expression = conjuncts[rest].expression;
|
|
392
|
+
const value = evaluateCached(restEvaluators, rest, expression, context);
|
|
393
|
+
if (!holdsValue(run, expression, value, false)) return;
|
|
376
394
|
}
|
|
377
395
|
onComplete(current, action);
|
|
378
396
|
return;
|
|
@@ -380,12 +398,13 @@ const compileConjunction = (
|
|
|
380
398
|
const conjunct = conjuncts[index];
|
|
381
399
|
if (conjunct.kind === "Guard") {
|
|
382
400
|
context ??= getContext(run, scope, current);
|
|
383
|
-
|
|
401
|
+
const value = evaluateCached(evaluators, index, conjunct.expression, context);
|
|
402
|
+
if (!holdsValue(run, conjunct.expression, value)) return;
|
|
384
403
|
continue;
|
|
385
404
|
}
|
|
386
405
|
if (conjunct.kind === "Assign") {
|
|
387
406
|
context ??= getContext(run, scope, current);
|
|
388
|
-
const value =
|
|
407
|
+
const value = evaluateCached(evaluators, index, conjunct.value, context);
|
|
389
408
|
const assigned = current[conjunct.index];
|
|
390
409
|
if (assigned === undefined) {
|
|
391
410
|
current = assign(current, conjunct.index, value);
|