tla-ts 0.0.4-dev.6dec595 → 0.0.4-dev.7b5087a
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 +27 -141
- 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 +517 -47
- package/dist/run-cli.js +517 -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/errors.ts +86 -0
- package/src/evaluate.ts +28 -7
- package/src/index.ts +10 -0
- package/src/{obligation-action.ts → obligations/action.ts} +258 -37
- package/src/{obligation-anon.ts → obligations/anon.ts} +13 -7
- package/src/obligations/ctx.ts +64 -0
- package/src/{obligation-deref.ts → obligations/deref.ts} +2 -2
- package/src/{obligation-expression.ts → obligations/expression.ts} +54 -8
- package/src/{obligation-format.ts → obligations/format.ts} +6 -5
- package/src/{obligation-generate.ts → obligations/generate.ts} +134 -61
- package/src/{obligations.ts → obligations/index.ts} +28 -12
- package/src/{obligation-levels.ts → obligations/levels.ts} +12 -2
- package/src/{obligation-module.ts → obligations/module.ts} +46 -20
- package/src/obligations/pickle.ts +100 -0
- package/src/obligations/pragma.ts +189 -0
- package/src/{obligation-printer.ts → obligations/printer.ts} +9 -63
- package/src/{obligation-proof.ts → obligations/proof.ts} +7 -1
- package/src/{obligation-source.ts → obligations/source.ts} +91 -35
- package/src/obligations/temporal.ts +319 -0
- package/src/{obligation-tuples.ts → obligations/tuples.ts} +1 -1
- package/src/ocaml-marshal.ts +172 -0
- package/src/parallel-worker.ts +2 -18
- package/src/parallel.ts +10 -43
- package/src/prove/decide-pool.ts +100 -0
- package/src/prove/deciders.ts +33 -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 +512 -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 +520 -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 +552 -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 +27 -0
- package/src/prove/prove.ts +528 -0
- package/src/prove/ptl/decide.ts +68 -0
- package/src/prove/ptl/encode.ts +256 -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 +210 -0
- package/src/prove/smt/context.ts +108 -0
- package/src/prove/smt/data.ts +665 -0
- package/src/prove/smt/encode.ts +169 -0
- package/src/prove/smt/extensionality.ts +63 -0
- package/src/prove/smt/flatten.ts +127 -0
- package/src/prove/smt/format.ts +143 -0
- package/src/prove/smt/instances.ts +182 -0
- package/src/prove/smt/rewrite.ts +784 -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 +97 -0
- package/src/prove/tlaps-module.ts +510 -0
- package/src/prove/verdict.ts +19 -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 +444 -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 +338 -52
- package/src/tlapm-cache.ts +250 -0
- package/src/values.ts +8 -3
- 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,9 +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
11
|
import { basename, delimiter, dirname, isAbsolute, join, resolve } from "node:path";
|
|
12
12
|
import { arch, availableParallelism, release, tmpdir, type } from "node:os";
|
|
13
13
|
import { pathToFileURL } from "node:url";
|
|
@@ -42,11 +42,30 @@ import {
|
|
|
42
42
|
TlaUnsupportedError,
|
|
43
43
|
} from "./errors";
|
|
44
44
|
import { EXIT_STATUS, setExitCode } from "./exit-codes";
|
|
45
|
-
import type { LineRange } from "./
|
|
46
|
-
import { getAtPrefix, getLocusText } from "./
|
|
47
|
-
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";
|
|
48
56
|
import { check } from "./parallel";
|
|
49
57
|
import { parseModule } from "./parser";
|
|
58
|
+
import {
|
|
59
|
+
encodeProofTheory,
|
|
60
|
+
formatNormalized,
|
|
61
|
+
isProveBackend,
|
|
62
|
+
prove,
|
|
63
|
+
proveObligations,
|
|
64
|
+
PROVE_BACKENDS,
|
|
65
|
+
type ProofAttempt,
|
|
66
|
+
type ProofStatus,
|
|
67
|
+
} from "./prove/prove";
|
|
68
|
+
import { TLAPS_MODULE } from "./prove/tlaps-module";
|
|
50
69
|
import type { StateDump } from "./state-graph";
|
|
51
70
|
import {
|
|
52
71
|
formatProbability,
|
|
@@ -54,6 +73,15 @@ import {
|
|
|
54
73
|
getOptimisticProbability,
|
|
55
74
|
getOutDegreeSummary,
|
|
56
75
|
} from "./tlc-summary";
|
|
76
|
+
import { getTlapmPaths } from "./prove/tlapm/tlapm";
|
|
77
|
+
import {
|
|
78
|
+
getKnownResults,
|
|
79
|
+
loadFingerprints,
|
|
80
|
+
saveFingerprints,
|
|
81
|
+
saveHistory,
|
|
82
|
+
updateFingerprints,
|
|
83
|
+
type FingerprintTable,
|
|
84
|
+
} from "./tlapm-cache";
|
|
57
85
|
import type { SanySpecification } from "./sany-generator";
|
|
58
86
|
import { SANY_174_STANDARD_MODULES, SANY_STANDARD_MODULES } from "./sany-modules";
|
|
59
87
|
import { getSanyModuleName, getSanyReport, type SanyModuleOrigin } from "./sany-report";
|
|
@@ -101,14 +129,33 @@ const CHECK_COMMAND = defineCommand("tla-ts <Spec.tla|Spec.cfg|glob>... {options
|
|
|
101
129
|
{ flag: "-workers <count|auto>" },
|
|
102
130
|
]);
|
|
103
131
|
|
|
104
|
-
|
|
105
|
-
|
|
132
|
+
// -k changes nothing, as in tlapm.
|
|
133
|
+
const TLAPM_COMMAND = defineCommand("tla-ts tlapm {options} <Module.tla|glob>...", [
|
|
134
|
+
{ flag: "-N" },
|
|
135
|
+
{ flag: "--summary" },
|
|
136
|
+
{ flag: "--strict" },
|
|
106
137
|
{ flag: "--toolbox <start> <end>" },
|
|
107
138
|
{ flag: "--line <num>" },
|
|
108
139
|
{ flag: "--printallobs" },
|
|
109
|
-
{ flag: "--
|
|
110
|
-
{ flag: "--
|
|
140
|
+
{ flag: "--threads <num>" },
|
|
141
|
+
{ flag: "--version" },
|
|
142
|
+
{ flag: "-I <directory>", isRepeatable: true },
|
|
143
|
+
{ flag: "-k" },
|
|
144
|
+
{ flag: "--noproving" },
|
|
145
|
+
{ flag: "--nofp" },
|
|
146
|
+
{ flag: "--nofpl <start> <end>" },
|
|
147
|
+
{ flag: "--safefp" },
|
|
148
|
+
{ flag: "--cleanfp" },
|
|
149
|
+
{ flag: "--usefp <file>" },
|
|
150
|
+
{ flag: "--cache-dir <directory>" },
|
|
151
|
+
]);
|
|
152
|
+
|
|
153
|
+
const TLAPM_INTEGER_OPTIONS = new Set(["--toolbox", "--line", "--threads", "--nofpl"]);
|
|
154
|
+
|
|
155
|
+
const PROVE_COMMAND = defineCommand("tla-ts prove {options} <Module.tla|glob>...", [
|
|
156
|
+
{ flag: `--backend <${PROVE_BACKENDS.join("|")}>` },
|
|
111
157
|
{ flag: "-I <directory>", isRepeatable: true },
|
|
158
|
+
{ flag: "-workers <count|auto>" },
|
|
112
159
|
]);
|
|
113
160
|
|
|
114
161
|
const XML_EXPORT_FLAGS = new Set(["-o", "-t", "-r", "-u"]);
|
|
@@ -166,7 +213,7 @@ const XML_EXPORT_USAGE = (() => {
|
|
|
166
213
|
const USAGE = [
|
|
167
214
|
`Usage: ${CHECK_COMMAND.usage}`,
|
|
168
215
|
` ${PROVE_COMMAND.usage}`,
|
|
169
|
-
|
|
216
|
+
` ${TLAPM_COMMAND.usage}`,
|
|
170
217
|
" tla-ts [<JVM option>]... tlc2.TLC <TLC option>... <Spec>",
|
|
171
218
|
" (-cp tla2tools.jar or -Dtla-ts.tlc=1.7.4 picks the TLC to reproduce)",
|
|
172
219
|
" tla-ts [<JVM option>]... tla2sany.xml.XMLExporter [-I <directory>]... [-o] [-t] [-r] [-u] <Module.tla>",
|
|
@@ -1043,12 +1090,6 @@ const runEach = async (
|
|
|
1043
1090
|
|
|
1044
1091
|
// tlapm installs its standard library, with modules such as TLAPS, at lib/tlapm/stdlib beside
|
|
1045
1092
|
// bin/tlapm.
|
|
1046
|
-
const getTlapmPaths = () =>
|
|
1047
|
-
(process.env.PATH ?? "")
|
|
1048
|
-
.split(delimiter)
|
|
1049
|
-
.map((directory) => join(directory, "tlapm"))
|
|
1050
|
-
.filter((path) => existsSync(path));
|
|
1051
|
-
|
|
1052
1093
|
const getTlapmLibrary = () =>
|
|
1053
1094
|
getTlapmPaths()
|
|
1054
1095
|
.map((path) => join(dirname(dirname(realpathSync(path))), "lib/tlapm/stdlib"))
|
|
@@ -1057,17 +1098,6 @@ const getTlapmLibrary = () =>
|
|
|
1057
1098
|
const expandGlobs = (paths: string[]) =>
|
|
1058
1099
|
paths.flatMap((path) => (GLOB_CHARACTERS.test(path) ? globSync(path).sort() : [path]));
|
|
1059
1100
|
|
|
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
1101
|
const readModule = (path: string) =>
|
|
1072
1102
|
existsSync(path) ? { file: path, source: readFileSync(path, "utf8") } : undefined;
|
|
1073
1103
|
|
|
@@ -1075,17 +1105,27 @@ const readModule = (path: string) =>
|
|
|
1075
1105
|
const printToolboxMessage = (fields: string[]) =>
|
|
1076
1106
|
console.error(`@!!BEGIN\n${fields.map((field) => `@!!${field}\n`).join("")}@!!END\n`);
|
|
1077
1107
|
|
|
1078
|
-
const
|
|
1108
|
+
const printObligationMessage = (obligation: PrintedObligation, status: string, fields: string[]) =>
|
|
1109
|
+
printToolboxMessage([
|
|
1110
|
+
"type:obligation",
|
|
1111
|
+
`id:${obligation.id}`,
|
|
1112
|
+
`loc:${obligation.location}`,
|
|
1113
|
+
`status:${status}`,
|
|
1114
|
+
...fields,
|
|
1115
|
+
]);
|
|
1116
|
+
|
|
1117
|
+
const TLAPM_VERSION = "9ed0376";
|
|
1079
1118
|
|
|
1080
1119
|
const quoteArgument = (arg: string) =>
|
|
1081
1120
|
/^[+,\-./0-9:=@A-Z_a-z]+$/.test(arg) ? arg : `'${arg.replaceAll("'", "'\\''")}'`;
|
|
1082
1121
|
|
|
1083
1122
|
const printToolboxHeader = (args: string[]) =>
|
|
1084
1123
|
console.log(
|
|
1085
|
-
`\n\\* TLAPM version ${TLAPM_VERSION}\n\\* launched at ${formatTlcDate(new Date())} with command line:\n\\* ${["tla-ts", "
|
|
1124
|
+
`\n\\* TLAPM version ${TLAPM_VERSION}\n\\* launched at ${formatTlcDate(new Date())} with command line:\n\\* ${["tla-ts", "tlapm", ...args].map(quoteArgument).join(" ")}\n`,
|
|
1086
1125
|
);
|
|
1087
1126
|
|
|
1088
|
-
|
|
1127
|
+
// The most severe first, as tlapm exits with the most severe status --strict noted.
|
|
1128
|
+
const STRICT_EXIT_STATUS = { failed: 10, incomplete: 11, emptyTarget: 12 };
|
|
1089
1129
|
|
|
1090
1130
|
const checkStrictly = (result: ModuleObligations, isTargeted: boolean, isSummary: boolean) => {
|
|
1091
1131
|
const summary = result.summary;
|
|
@@ -1113,6 +1153,19 @@ const checkStrictly = (result: ModuleObligations, isTargeted: boolean, isSummary
|
|
|
1113
1153
|
|
|
1114
1154
|
const TLAPM_FAILURE_STATUS = 3;
|
|
1115
1155
|
|
|
1156
|
+
// What tlapm prints when a module has unproved obligations outside toolbox mode, OCaml's backtrace
|
|
1157
|
+
// included.
|
|
1158
|
+
const UNPROVED_ENDING = [
|
|
1159
|
+
' tlapm ending abnormally with Failure("backend errors: there are unproved obligations")',
|
|
1160
|
+
'Raised at Stdlib.failwith in file "stdlib.ml", line 29, characters 17-33',
|
|
1161
|
+
'Called from Tlapm_lib.process_module in file "src/tlapm_lib.ml", lines 492-493, characters 12-37',
|
|
1162
|
+
'Called from Tlapm_lib.main.f in file "src/tlapm_lib.ml", line 640, characters 23-43',
|
|
1163
|
+
'Called from Stdlib__List.fold_left in file "list.ml", line 125, characters 24-34',
|
|
1164
|
+
'Called from Tlapm_lib.main in file "src/tlapm_lib.ml", line 643, characters 13-40',
|
|
1165
|
+
'Called from Tlapm_lib.init in file "src/tlapm_lib.ml", line 659, characters 8-59',
|
|
1166
|
+
"",
|
|
1167
|
+
].join("\n");
|
|
1168
|
+
|
|
1116
1169
|
const generateObligations = (generate: () => ModuleObligations[]) => {
|
|
1117
1170
|
try {
|
|
1118
1171
|
return generate();
|
|
@@ -1123,12 +1176,175 @@ const generateObligations = (generate: () => ModuleObligations[]) => {
|
|
|
1123
1176
|
}
|
|
1124
1177
|
};
|
|
1125
1178
|
|
|
1126
|
-
|
|
1127
|
-
|
|
1179
|
+
// tla-ts prove: proves each module with prove, printing each obligation as it ends.
|
|
1180
|
+
const proveModules = (args: string[]) => {
|
|
1128
1181
|
const parsed = PROVE_COMMAND.parse(args);
|
|
1129
|
-
const
|
|
1182
|
+
const backend = parsed.get("--backend")?.[0];
|
|
1183
|
+
if (
|
|
1184
|
+
parsed.unknown[0] !== undefined ||
|
|
1185
|
+
parsed.incomplete ||
|
|
1186
|
+
(backend !== undefined && !isProveBackend(backend))
|
|
1187
|
+
) {
|
|
1188
|
+
console.error(`Usage: ${PROVE_COMMAND.usage}`);
|
|
1189
|
+
return 1;
|
|
1190
|
+
}
|
|
1191
|
+
const modulePaths = expandGlobs(parsed.positionals).map((path) =>
|
|
1192
|
+
path.endsWith(".tla") ? path : `${path}.tla`,
|
|
1193
|
+
);
|
|
1194
|
+
if (modulePaths.length === 0) {
|
|
1195
|
+
console.error(`Usage: ${PROVE_COMMAND.usage}`);
|
|
1196
|
+
return 1;
|
|
1197
|
+
}
|
|
1198
|
+
const tlapmLibrary = getTlapmLibrary();
|
|
1199
|
+
const includes = parsed.options.flatMap((option) => (option.name === "-I" ? option.values : []));
|
|
1200
|
+
return runEach(
|
|
1201
|
+
modulePaths,
|
|
1202
|
+
async (path) => {
|
|
1203
|
+
const directories = [
|
|
1204
|
+
dirname(path),
|
|
1205
|
+
".",
|
|
1206
|
+
...(tlapmLibrary ? [tlapmLibrary] : []),
|
|
1207
|
+
...includes.toReversed(),
|
|
1208
|
+
];
|
|
1209
|
+
const result = await prove({
|
|
1210
|
+
source: readFileSync(path, "utf8"),
|
|
1211
|
+
loadModule: (name) =>
|
|
1212
|
+
directories.map((directory) => readModule(`${directory}/${name}.tla`)).find(Boolean)
|
|
1213
|
+
?.source,
|
|
1214
|
+
backend,
|
|
1215
|
+
workers: getWorkerCount(parsed.get("-workers")),
|
|
1216
|
+
onObligation: (obligation) =>
|
|
1217
|
+
console.log(
|
|
1218
|
+
`${path}:${obligation.location}: ${obligation.status}${obligation.status === "proved" ? ` by ${obligation.prover}` : ""}${obligation.status === "failed" || obligation.status === "unsupported" ? ` (${obligation.reason})` : ""}`,
|
|
1219
|
+
),
|
|
1220
|
+
});
|
|
1221
|
+
const counts = Map.groupBy(result.obligations, (obligation) => obligation.status);
|
|
1222
|
+
const getCount = (status: ProofStatus) => counts.get(status)?.length ?? 0;
|
|
1223
|
+
console.log(
|
|
1224
|
+
`${result.obligations.length} obligations: ${getCount("proved")} proved, ${getCount("trivial")} trivial, ${getCount("failed")} failed, ${getCount("unsupported")} unsupported`,
|
|
1225
|
+
);
|
|
1226
|
+
return getCount("failed") + getCount("unsupported") === 0 ? EXIT_STATUS.success : 1;
|
|
1227
|
+
},
|
|
1228
|
+
() => createMessagePrinter(false),
|
|
1229
|
+
);
|
|
1230
|
+
};
|
|
1231
|
+
|
|
1232
|
+
// Toolbox.print_res_aux: what one method concluded, with the obligation it failed on, as Prep
|
|
1233
|
+
// normalized it. Only a new SMT failure notes the solver's answer.
|
|
1234
|
+
const printAttempt = (obligation: PrintedObligation, attempt: ProofAttempt) => {
|
|
1235
|
+
const limit = attempt.method.timeLimitMs;
|
|
1236
|
+
const used =
|
|
1237
|
+
attempt.timeUsedMs === undefined
|
|
1238
|
+
? ""
|
|
1239
|
+
: `; time-used: ${(attempt.timeUsedMs / 1000).toFixed(1)} (${Math.round((100 * attempt.timeUsedMs) / limit)}%)`;
|
|
1240
|
+
const times =
|
|
1241
|
+
limit === 0
|
|
1242
|
+
? ""
|
|
1243
|
+
: `time-limit: ${limit === Infinity ? "inf" : Number((limit / 1000).toPrecision(6))}${used}`;
|
|
1244
|
+
const method = [attempt.method.tactic, times].filter(Boolean).join("; ");
|
|
1245
|
+
const isSmt = attempt.method.prover === "smt" || attempt.method.prover === "z3";
|
|
1246
|
+
const note =
|
|
1247
|
+
isSmt && attempt.reason === "false" && attempt.verdict
|
|
1248
|
+
? `(* SMT failed with status = ${attempt.verdict}\n *)\n`
|
|
1249
|
+
: "";
|
|
1250
|
+
printObligationMessage(obligation, attempt.isProved ? "proved" : "failed", [
|
|
1251
|
+
`prover:${attempt.method.prover}`,
|
|
1252
|
+
...(method === "" ? [] : [`meth:${method}`]),
|
|
1253
|
+
...(attempt.reason === undefined ? [] : [`reason:${attempt.reason}`]),
|
|
1254
|
+
`already:${attempt.isReused}`,
|
|
1255
|
+
...(attempt.isProved
|
|
1256
|
+
? []
|
|
1257
|
+
: [
|
|
1258
|
+
`obl:${attempt.isReused ? "" : `\n${note}`}${formatNormalized(obligation, attempt.isReused)}`,
|
|
1259
|
+
]),
|
|
1260
|
+
]);
|
|
1261
|
+
};
|
|
1262
|
+
|
|
1263
|
+
// tlapm fails with Method.Fail an obligation that is an error, and one no method was tried on.
|
|
1264
|
+
const printFailure = (obligation: PrintedObligation, reason: string) =>
|
|
1265
|
+
printObligationMessage(obligation, "failed", [
|
|
1266
|
+
"prover:fail",
|
|
1267
|
+
"meth:time-limit: inf",
|
|
1268
|
+
`reason:${reason}`,
|
|
1269
|
+
"already:false",
|
|
1270
|
+
`obl:${obligation.text}`,
|
|
1271
|
+
]);
|
|
1272
|
+
|
|
1273
|
+
interface ProvingSettings {
|
|
1274
|
+
isToolbox: boolean;
|
|
1275
|
+
isProving: boolean;
|
|
1276
|
+
workers: number;
|
|
1277
|
+
isFingerprinted: (obligation: PrintedObligation) => boolean;
|
|
1278
|
+
fingerprints: FingerprintTable;
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
// Tlapm_lib.process_obs: proves a module's obligations, printing each result in toolbox mode, and
|
|
1282
|
+
// writes the theory of their proofs and the fingerprints. Unless --noproving, it then prints those
|
|
1283
|
+
// tlapm couldn't prove, the last first. Returns whether some obligation failed.
|
|
1284
|
+
const proveModule = async (
|
|
1285
|
+
result: ModuleObligations,
|
|
1286
|
+
theoryPath: string,
|
|
1287
|
+
fingerprintsPath: string,
|
|
1288
|
+
sources: string[],
|
|
1289
|
+
settings: ProvingSettings,
|
|
1290
|
+
) => {
|
|
1291
|
+
saveHistory(fingerprintsPath, sources);
|
|
1292
|
+
const results = getKnownResults(settings.fingerprints);
|
|
1293
|
+
const reports = await proveObligations(result.obligations, {
|
|
1294
|
+
workers: settings.workers,
|
|
1295
|
+
results,
|
|
1296
|
+
isFingerprinted: settings.isFingerprinted,
|
|
1297
|
+
isProving: settings.isProving,
|
|
1298
|
+
onReport: (report, obligation) => {
|
|
1299
|
+
if (!settings.isToolbox) return;
|
|
1300
|
+
if (report.obligation.status === "trivial")
|
|
1301
|
+
return printObligationMessage(obligation, "trivial", ["prover:tlapm", "already:false"]);
|
|
1302
|
+
if (obligation.kind.kind === "Error") return printFailure(obligation, "user error");
|
|
1303
|
+
report.attempts.forEach((attempt) => printAttempt(obligation, attempt));
|
|
1304
|
+
},
|
|
1305
|
+
});
|
|
1306
|
+
writeFileSync(theoryPath, encodeProofTheory(result.name, reports, result.obligations));
|
|
1307
|
+
console.log(`(* created new ${JSON.stringify(theoryPath)} *)`);
|
|
1308
|
+
updateFingerprints(settings.fingerprints, results);
|
|
1309
|
+
saveFingerprints(settings.fingerprints, fingerprintsPath);
|
|
1310
|
+
console.log(`(* fingerprints written in ${JSON.stringify(fingerprintsPath)} *)`);
|
|
1311
|
+
if (!settings.isProving) return false;
|
|
1312
|
+
const unproved = reports.flatMap((report, index) =>
|
|
1313
|
+
"reason" in report.obligation ? [{ report, obligation: result.obligations[index] }] : [],
|
|
1314
|
+
);
|
|
1315
|
+
if (settings.isToolbox) {
|
|
1316
|
+
unproved
|
|
1317
|
+
.filter(
|
|
1318
|
+
(entry) => entry.report.attempts.length === 0 && entry.obligation.kind.kind !== "Error",
|
|
1319
|
+
)
|
|
1320
|
+
.forEach((entry) => printFailure(entry.obligation, "unexpected error"));
|
|
1321
|
+
}
|
|
1322
|
+
unproved
|
|
1323
|
+
.toReversed()
|
|
1324
|
+
.forEach((entry) =>
|
|
1325
|
+
console.error(
|
|
1326
|
+
`${getAtPrefix(entry.obligation.locus)}${renderDoc(format("[ERROR]: @[<v2>Could not prove or check:@,%a@]", printSequent(entry.obligation.sequent)), 35)}`,
|
|
1327
|
+
),
|
|
1328
|
+
);
|
|
1329
|
+
const total = `${result.obligations.length} obligation${result.obligations.length > 1 ? "s" : ""}`;
|
|
1330
|
+
console.error(
|
|
1331
|
+
unproved.length === 0
|
|
1332
|
+
? `${getAtPrefix(result.location)}[INFO]: All ${total} proved.`
|
|
1333
|
+
: `${getAtPrefix(result.location)}[ERROR]: ${unproved.length}/${total} failed.\nThere were backend errors processing module \`${JSON.stringify(result.name)}\`.`,
|
|
1334
|
+
);
|
|
1335
|
+
return unproved.length > 0;
|
|
1336
|
+
};
|
|
1337
|
+
|
|
1338
|
+
// tla-ts tlapm: tlapm's command line, proving with tla-ts's backends. -N and --summary only
|
|
1339
|
+
// generate the obligations.
|
|
1340
|
+
const runTlapm = async (args: string[]) => {
|
|
1341
|
+
const parsed = TLAPM_COMMAND.parse(args);
|
|
1342
|
+
const isProcessing = !parsed.has("-N") && !parsed.has("--summary");
|
|
1343
|
+
const unsupported =
|
|
1344
|
+
parsed.unknown[0] ??
|
|
1345
|
+
(isProcessing && parsed.has("--printallobs") ? "--printallobs" : undefined);
|
|
1130
1346
|
if (unsupported !== undefined) {
|
|
1131
|
-
console.error(`Error: tla-ts
|
|
1347
|
+
console.error(`Error: tla-ts tlapm does not support the tlapm option ${unsupported}.`);
|
|
1132
1348
|
return 1;
|
|
1133
1349
|
}
|
|
1134
1350
|
if (parsed.incomplete) {
|
|
@@ -1136,12 +1352,18 @@ const prove = (args: string[]) => {
|
|
|
1136
1352
|
return 1;
|
|
1137
1353
|
}
|
|
1138
1354
|
const nonInteger = parsed.options.find(
|
|
1139
|
-
(option) =>
|
|
1355
|
+
(option) =>
|
|
1356
|
+
TLAPM_INTEGER_OPTIONS.has(option.name) &&
|
|
1357
|
+
option.values.some((value) => !/^-?\d+$/.test(value)),
|
|
1140
1358
|
);
|
|
1141
1359
|
if (nonInteger) {
|
|
1142
1360
|
console.error(`Error: option '${nonInteger.name}' expects an integer.`);
|
|
1143
1361
|
return 1;
|
|
1144
1362
|
}
|
|
1363
|
+
if (parsed.has("--version")) {
|
|
1364
|
+
console.log(TLAPM_VERSION);
|
|
1365
|
+
return EXIT_STATUS.success;
|
|
1366
|
+
}
|
|
1145
1367
|
const files = expandGlobs(parsed.positionals);
|
|
1146
1368
|
const modulePaths = files.map((path) => (path.endsWith(".tla") ? path : `${path}.tla`));
|
|
1147
1369
|
if (modulePaths.length === 0) {
|
|
@@ -1158,7 +1380,7 @@ const prove = (args: string[]) => {
|
|
|
1158
1380
|
return range;
|
|
1159
1381
|
}, WHOLE_MODULE);
|
|
1160
1382
|
// tlapm searches the current directory and each module's, then its library, then each -I
|
|
1161
|
-
// directory, the last given first.
|
|
1383
|
+
// directory, the last given first. Without tlapm, TLAPS is the copy tla-ts bundles.
|
|
1162
1384
|
const tlapmLibrary = getTlapmLibrary();
|
|
1163
1385
|
const includes = parsed.options.flatMap((option) => (option.name === "-I" ? option.values : []));
|
|
1164
1386
|
const directories = modulePaths.reduce(
|
|
@@ -1166,6 +1388,7 @@ const prove = (args: string[]) => {
|
|
|
1166
1388
|
[".", ...(tlapmLibrary ? [tlapmLibrary] : []), ...includes.toReversed()],
|
|
1167
1389
|
);
|
|
1168
1390
|
// tlapm names each file it reads by joining a search directory and the name, as in ./Module.tla.
|
|
1391
|
+
const moduleNames = new Set<string>();
|
|
1169
1392
|
const results = generateObligations(() => {
|
|
1170
1393
|
const missingIndex = modulePaths.findIndex((path) => !existsSync(path));
|
|
1171
1394
|
if (missingIndex !== -1) {
|
|
@@ -1175,8 +1398,13 @@ const prove = (args: string[]) => {
|
|
|
1175
1398
|
}
|
|
1176
1399
|
return getObligations(
|
|
1177
1400
|
modulePaths.map((path) => ({ file: `./${path}`, source: readFileSync(path, "utf8") })),
|
|
1178
|
-
(name) =>
|
|
1179
|
-
|
|
1401
|
+
(name) => {
|
|
1402
|
+
moduleNames.add(name);
|
|
1403
|
+
return (
|
|
1404
|
+
directories.map((directory) => readModule(`${directory}/${name}.tla`)).find(Boolean) ??
|
|
1405
|
+
(name === "TLAPS" ? { file: "TLAPS.tla", source: TLAPS_MODULE } : undefined)
|
|
1406
|
+
);
|
|
1407
|
+
},
|
|
1180
1408
|
{
|
|
1181
1409
|
lines,
|
|
1182
1410
|
onWarning: (warning) => {
|
|
@@ -1191,26 +1419,83 @@ const prove = (args: string[]) => {
|
|
|
1191
1419
|
);
|
|
1192
1420
|
});
|
|
1193
1421
|
if (!results) return TLAPM_FAILURE_STATUS;
|
|
1194
|
-
const
|
|
1422
|
+
const cacheDirectory =
|
|
1423
|
+
parsed.get("--cache-dir")?.[0] ?? process.env.TLAPM_CACHE_DIR ?? ".tlacache";
|
|
1424
|
+
const forgottenLines = parsed.get("--nofpl")?.map(Number) ?? [0, 0];
|
|
1425
|
+
const settings: ProvingSettings = {
|
|
1426
|
+
isToolbox,
|
|
1427
|
+
isProving: !parsed.has("--noproving"),
|
|
1428
|
+
workers: Math.max(1, Number(parsed.get("--threads")?.[0] ?? availableParallelism())),
|
|
1429
|
+
isFingerprinted: (obligation) =>
|
|
1430
|
+
!parsed.has("--nofp") &&
|
|
1431
|
+
!(
|
|
1432
|
+
obligation.locus &&
|
|
1433
|
+
obligation.locus.startLine >= forgottenLines[0] &&
|
|
1434
|
+
obligation.locus.endLine <= forgottenLines[1]
|
|
1435
|
+
),
|
|
1436
|
+
fingerprints: new Map(),
|
|
1437
|
+
};
|
|
1438
|
+
const statuses: number[] = [];
|
|
1439
|
+
for (const [index, result] of results.entries()) {
|
|
1440
|
+
// Tlapm_lib.mkdir_tlaps, then --cleanfp removes the fingerprints file or tlapm loads the one
|
|
1441
|
+
// --usefp names, the module's own by default.
|
|
1442
|
+
const directory = `${cacheDirectory}/${result.name}.tlaps`;
|
|
1443
|
+
const fingerprintsPath = `${directory}/fingerprints`;
|
|
1444
|
+
const loadedPath = parsed.get("--usefp")?.[0] ?? fingerprintsPath;
|
|
1445
|
+
mkdirSync(directory, { recursive: true });
|
|
1446
|
+
if (parsed.has("--cleanfp")) {
|
|
1447
|
+
if (existsSync(fingerprintsPath)) {
|
|
1448
|
+
rmSync(fingerprintsPath);
|
|
1449
|
+
console.log(`(* fingerprints file ${JSON.stringify(fingerprintsPath)} removed *)`);
|
|
1450
|
+
}
|
|
1451
|
+
} else if (existsSync(loadedPath) && result.summary.total !== 0) {
|
|
1452
|
+
console.log(
|
|
1453
|
+
parsed.has("--nofp")
|
|
1454
|
+
? `(* 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. *)`
|
|
1455
|
+
: `(* loading fingerprints in ${JSON.stringify(loadedPath)} *)`,
|
|
1456
|
+
);
|
|
1457
|
+
loadFingerprints(settings.fingerprints, loadedPath, parsed.has("--safefp"));
|
|
1458
|
+
}
|
|
1195
1459
|
if (parsed.has("--summary")) console.log(formatSummary(result));
|
|
1196
1460
|
if (isToolbox) {
|
|
1197
1461
|
result.obligations.forEach((obligation) =>
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
`
|
|
1202
|
-
|
|
1203
|
-
...(parsed.has("--printallobs") ? [`obl:${obligation.text}`] : []),
|
|
1204
|
-
]),
|
|
1462
|
+
printObligationMessage(
|
|
1463
|
+
obligation,
|
|
1464
|
+
"to be proved",
|
|
1465
|
+
parsed.has("--printallobs") ? [`obl:${obligation.text}`] : [],
|
|
1466
|
+
),
|
|
1205
1467
|
);
|
|
1206
1468
|
printToolboxMessage(["type:obligationsnumber", `count:${result.obligations.length}`]);
|
|
1207
1469
|
}
|
|
1208
|
-
if (
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1470
|
+
if (parsed.has("--strict"))
|
|
1471
|
+
statuses.push(
|
|
1472
|
+
...checkStrictly(result, lines.start > 0 || lines.end < Infinity, parsed.has("--summary")),
|
|
1473
|
+
);
|
|
1474
|
+
if (!isProcessing) continue;
|
|
1475
|
+
// tlapm copies into the history the source in the current directory of each module it has
|
|
1476
|
+
// read so far.
|
|
1477
|
+
const sources = [
|
|
1478
|
+
...moduleNames,
|
|
1479
|
+
...results.slice(0, index + 1).map((innerResult) => innerResult.name),
|
|
1480
|
+
].map((name) => `${name}.tla`);
|
|
1481
|
+
const isFailed = await proveModule(
|
|
1482
|
+
result,
|
|
1483
|
+
`${directory}/${result.name}.thy`,
|
|
1484
|
+
fingerprintsPath,
|
|
1485
|
+
sources,
|
|
1486
|
+
settings,
|
|
1487
|
+
);
|
|
1488
|
+
if (!isFailed) continue;
|
|
1489
|
+
if (parsed.has("--strict")) statuses.push(STRICT_EXIT_STATUS.failed);
|
|
1490
|
+
else if (!isToolbox) {
|
|
1491
|
+
console.error(UNPROVED_ENDING);
|
|
1492
|
+
return TLAPM_FAILURE_STATUS;
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
return (
|
|
1496
|
+
Object.values(STRICT_EXIT_STATUS).find((status) => statuses.includes(status)) ??
|
|
1497
|
+
EXIT_STATUS.success
|
|
1498
|
+
);
|
|
1214
1499
|
};
|
|
1215
1500
|
|
|
1216
1501
|
const checkSpecs = async (args: string[], java: JavaProperties) => {
|
|
@@ -1534,7 +1819,8 @@ const runJavaClass = (launch: JavaLaunch) => {
|
|
|
1534
1819
|
};
|
|
1535
1820
|
|
|
1536
1821
|
const run = async (args: string[]) => {
|
|
1537
|
-
if (args[0] === "prove") return reportErrors(() =>
|
|
1822
|
+
if (args[0] === "prove") return reportErrors(() => proveModules(args.slice(1)));
|
|
1823
|
+
if (args[0] === "tlapm") return reportErrors(() => runTlapm(args.slice(1)));
|
|
1538
1824
|
const launch = getJavaLaunch(args);
|
|
1539
1825
|
if (launch === undefined) return checkSpecs(args, { libraries: [] });
|
|
1540
1826
|
// The TLC that -Dtla-ts.tlc names, or else the one of the jar on the class path.
|