tla-ts 0.0.10-dev.28c823e4b → 0.0.10-dev.63a6693bd
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/dist/compile.cjs +6 -6
- package/dist/compile.js +10 -10
- package/dist/deciders.cjs +29 -29
- package/dist/deciders.js +40 -40
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +1 -1
- package/dist/prove-worker.cjs +1 -1
- package/dist/prove-worker.js +1 -1
- package/dist/prove.cjs +54 -54
- package/dist/prove.js +52 -52
- package/dist/run.cjs +42 -42
- package/dist/run.js +44 -44
- package/dist/tlapm.cjs +2 -2
- package/dist/tlapm.js +2 -2
- package/dist/transfer.cjs +39 -39
- package/dist/transfer.js +41 -41
- package/dist/worker.cjs +4 -4
- package/dist/worker.js +4 -4
- package/package.json +1 -1
- package/src/ast.ts +44 -39
- package/src/builtins.ts +4 -13
- package/src/check-failure.ts +116 -0
- package/src/check-trace.ts +282 -0
- package/src/check.ts +152 -518
- package/src/cli/options.ts +6 -31
- package/src/cli/shared.ts +1 -1
- package/src/cli/tlapm.ts +14 -13
- package/src/cli/tlc-arguments.ts +222 -210
- package/src/cli/tlc-output.ts +687 -0
- package/src/cli/tlc-usage.ts +1 -1
- package/src/cli/tlc.ts +34 -701
- package/src/cli/xml-exporter.ts +23 -33
- package/src/codegen.ts +5 -10
- package/src/coverage.ts +3 -10
- package/src/dependencies.ts +8 -13
- package/src/dfid.ts +16 -16
- package/src/environment-config.ts +315 -0
- package/src/environment.ts +45 -333
- package/src/errors.ts +3 -2
- package/src/evaluate.ts +5 -4
- package/src/fingerprints.ts +65 -1
- package/src/instances.ts +47 -10
- package/src/java-hash.ts +7 -0
- package/src/json.ts +4 -7
- package/src/levels.ts +39 -42
- package/src/liveness-checker.ts +24 -37
- package/src/liveness.ts +47 -54
- package/src/obligations/action.ts +4 -11
- package/src/obligations/anonymize.ts +4 -2
- package/src/obligations/expression.ts +18 -2
- package/src/obligations/generate.ts +45 -38
- package/src/obligations/index.ts +2 -2
- package/src/obligations/module.ts +27 -38
- package/src/obligations/normalize.ts +2 -1
- package/src/obligations/simplify.ts +39 -44
- package/src/obligations/source.ts +47 -57
- package/src/obligations/temporal.ts +5 -5
- package/src/parallel-worker.ts +10 -30
- package/src/parallel.ts +22 -45
- package/src/parser.ts +19 -34
- package/src/prover/decide-pool.ts +3 -3
- package/src/prover/deciders.ts +3 -3
- package/src/prover/isabelle/encode.ts +1 -1
- package/src/prover/isabelle/isar/inner-syntax.ts +9 -4
- package/src/prover/isabelle/isar/method.ts +14 -25
- package/src/prover/isabelle/isar/theory.ts +11 -10
- package/src/prover/isabelle/isar/type-check.ts +6 -6
- package/src/prover/isabelle/provers/blast/blast.ts +7 -63
- package/src/prover/isabelle/provers/hypsubst.ts +17 -26
- package/src/prover/isabelle/pure/bicompose.ts +9 -25
- package/src/prover/isabelle/pure/conv.ts +2 -8
- package/src/prover/isabelle/pure/drule.ts +9 -2
- package/src/prover/isabelle/pure/logic.ts +1 -1
- package/src/prover/isabelle/pure/raw-simplifier.ts +4 -13
- package/src/prover/isabelle/pure/rewriter.ts +5 -9
- package/src/prover/isabelle/pure/table.ts +2 -1
- package/src/prover/isabelle/pure/tactical.ts +42 -35
- package/src/prover/isabelle/pure/thm.ts +14 -11
- package/src/prover/isabelle/tla/classical-setup.ts +17 -14
- package/src/prover/isabelle/tla/context.ts +7 -2
- package/src/prover/isabelle/tla/logic.ts +10 -21
- package/src/prover/isabelle/tla/simpdata.ts +1 -10
- package/src/prover/prep/action.ts +11 -19
- package/src/prover/prep/fingerprint.ts +2 -5
- package/src/prover/prep/methods.ts +24 -3
- package/src/prover/prove.ts +87 -64
- package/src/prover/smt/context.ts +1 -2
- package/src/prover/smt/data.ts +418 -406
- package/src/prover/smt/encode.ts +30 -18
- package/src/prover/smt/rewrite.ts +657 -626
- package/src/prover/smt/solver/ast.ts +0 -22
- package/src/prover/smt/solver/auf-solver.ts +2 -5
- package/src/prover/smt/solver/context.ts +3 -3
- package/src/prover/smt/solver/e-matching.ts +1 -1
- package/src/prover/smt/solver/expr-safe-replace.ts +1 -1
- package/src/prover/smt/solver/internalizer.ts +1 -2
- package/src/prover/smt/solver/lp/dioph-eq.ts +1 -8
- package/src/prover/smt/solver/lp/hnf-cutter.ts +1 -1
- package/src/prover/smt/solver/lp/nla-core.ts +2 -6
- package/src/prover/smt/solver/mam-compiler.ts +4 -2
- package/src/prover/smt/solver/model-checker.ts +1 -1
- package/src/prover/smt/solver/model-finder.ts +12 -17
- package/src/prover/smt/solver/model-macro-solver.ts +11 -19
- package/src/prover/smt/solver/nlsat/algebraic.ts +9 -9
- package/src/prover/smt/solver/nlsat/atoms.ts +20 -4
- package/src/prover/smt/solver/nlsat/explain.ts +7 -22
- package/src/prover/smt/solver/nlsat/levelwise.ts +1 -6
- package/src/prover/smt/solver/nlsat/polynomial.ts +12 -3
- package/src/prover/smt/solver/nlsat/solver.ts +12 -24
- package/src/prover/smt/solver/nlsat/upolynomial-factorization.ts +1 -1
- package/src/prover/smt/solver/proto-model.ts +0 -4
- package/src/prover/smt/solver/quantifier-analyzer.ts +10 -10
- package/src/prover/smt/solver/quantifier-manager.ts +1 -5
- package/src/prover/smt/solver/smtlib-parser.ts +78 -94
- package/src/prover/smt/solver/theory-lra-bounds.ts +1 -2
- package/src/prover/smt/solver/theory-lra-internalize.ts +5 -16
- package/src/prover/tlapm/cache.ts +28 -18
- package/src/prover/tlapm/tlapm.ts +15 -9
- package/src/prover/verdict.ts +7 -0
- package/src/prover/zenon/check/check.ts +1 -2
- package/src/prover/zenon/check/records.ts +1 -1
- package/src/prover/zenon/check/relations.ts +2 -1
- package/src/prover/zenon/check/rewrites.ts +2 -15
- package/src/prover/zenon/check/sets.ts +40 -58
- package/src/prover/zenon/check/terms.ts +1 -2
- package/src/prover/zenon/eqrel.ts +2 -0
- package/src/prover/zenon/expr.ts +7 -0
- package/src/prover/zenon/index-table.ts +9 -19
- package/src/prover/zenon/isar.ts +35 -35
- package/src/prover/zenon/llproof.ts +2 -11
- package/src/prover/zenon/mltoll.ts +12 -28
- package/src/prover/zenon/parse.ts +3 -6
- package/src/prover/zenon/search.ts +4 -14
- package/src/prover/zenon/tla/functions.ts +2 -2
- package/src/prover/zenon/tla/llproof.ts +9 -11
- package/src/prover/zenon/tla/records.ts +1 -6
- package/src/prover/zenon/tla/sets.ts +15 -14
- package/src/prover/zenon/tla/tla.ts +7 -6
- package/src/resolve.ts +55 -72
- package/src/sany/generation.ts +394 -0
- package/src/sany/generator-def-entries.ts +210 -0
- package/src/sany/generator-definitions.ts +686 -0
- package/src/sany/generator-expressions.ts +1100 -0
- package/src/sany/generator-proofs.ts +662 -0
- package/src/sany/generator.ts +155 -2625
- package/src/sany/lexer.ts +17 -16
- package/src/sany/nodes.ts +6 -13
- package/src/sany/report.ts +3 -6
- package/src/sany/selectors.ts +35 -38
- package/src/sany/xml.ts +23 -55
- package/src/search.ts +65 -27
- package/src/simulate.ts +157 -133
- package/src/spec-description.ts +33 -48
- package/src/standard-modules.ts +16 -32
- package/src/state-graph.ts +2 -7
- package/src/substitution-levels.ts +5 -4
- package/src/successors.ts +5 -7
- package/src/tlc/messages.ts +20 -15
- package/src/tlc/order.ts +2 -9
- package/src/tlc/random.ts +4 -4
- package/src/tlc/replay.ts +8 -15
- package/src/tlc/tlc-operators.ts +2 -3
- package/src/tlc/trace-spec.ts +25 -45
- package/src/typescript/actions.ts +2 -4
- package/src/typescript/collections.ts +34 -20
- package/src/typescript/compile.ts +1 -3
- package/src/typescript/formula.ts +5 -3
- package/src/typescript/model.ts +4 -5
- package/src/typescript/steps.ts +20 -18
- package/src/values.ts +63 -158
|
@@ -48,36 +48,38 @@ import {
|
|
|
48
48
|
type Usable,
|
|
49
49
|
} from "./proof";
|
|
50
50
|
|
|
51
|
-
const BUILTINS
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
51
|
+
const BUILTINS = new Map<string, Builtin>(
|
|
52
|
+
Object.entries({
|
|
53
|
+
"=>": "Implies",
|
|
54
|
+
"<=>": "Equiv",
|
|
55
|
+
"/\\": "Conj",
|
|
56
|
+
"\\/": "Disj",
|
|
57
|
+
"~": "Neg",
|
|
58
|
+
"=": "Eq",
|
|
59
|
+
"#": "Neq",
|
|
60
|
+
SUBSET: "SUBSET",
|
|
61
|
+
UNION: "UNION",
|
|
62
|
+
DOMAIN: "DOMAIN",
|
|
63
|
+
"\\subseteq": "Subseteq",
|
|
64
|
+
"\\in": "Mem",
|
|
65
|
+
"\\notin": "Notmem",
|
|
66
|
+
"\\": "Setminus",
|
|
67
|
+
"\\cap": "Cap",
|
|
68
|
+
"\\cup": "Cup",
|
|
69
|
+
"'": "Prime",
|
|
70
|
+
"~>": "Leadsto",
|
|
71
|
+
ENABLED: "ENABLED",
|
|
72
|
+
UNCHANGED: "UNCHANGED",
|
|
73
|
+
"\\cdot": "Cdot",
|
|
74
|
+
"-+->": "Actplus",
|
|
75
|
+
"[]": "BoxTrue",
|
|
76
|
+
"<>": "Diamond",
|
|
77
|
+
TRUE: "TRUE",
|
|
78
|
+
FALSE: "FALSE",
|
|
79
|
+
BOOLEAN: "BOOLEAN",
|
|
80
|
+
STRING: "STRING",
|
|
81
|
+
}),
|
|
82
|
+
);
|
|
81
83
|
|
|
82
84
|
const getCanonicalName = (name: string) => lookupOperator(name).name;
|
|
83
85
|
|
|
@@ -105,7 +107,7 @@ const TUPLY_FAILURE = "use instead the class`E_visit.iter_concrete`";
|
|
|
105
107
|
const isDitto = (bounds: QuantifierExpression["bounds"], index: number) =>
|
|
106
108
|
index > 0 && bounds[index - 1].set === bounds[index].set;
|
|
107
109
|
|
|
108
|
-
export const
|
|
110
|
+
export const createModuleConverter = (
|
|
109
111
|
file: string,
|
|
110
112
|
text: string,
|
|
111
113
|
counter: Counter,
|
|
@@ -158,7 +160,7 @@ export const createSource = (
|
|
|
158
160
|
|
|
159
161
|
const convertOperator = (name: string, location: Locus | undefined): Expr => {
|
|
160
162
|
const canonical = getCanonicalName(name);
|
|
161
|
-
const builtin = BUILTINS
|
|
163
|
+
const builtin = BUILTINS.get(canonical);
|
|
162
164
|
return at(builtin ? { kind: "Internal", builtin } : { kind: "Opaque", name: canonical }, {
|
|
163
165
|
location,
|
|
164
166
|
});
|
|
@@ -174,7 +176,7 @@ export const createSource = (
|
|
|
174
176
|
const operator = at({ kind: "Opaque", name }, { location });
|
|
175
177
|
return at({ kind: "Bang", expression: operator, selectors: [] }, { location });
|
|
176
178
|
}
|
|
177
|
-
const builtin = BUILTINS
|
|
179
|
+
const builtin = BUILTINS.get(name);
|
|
178
180
|
if (builtin && args.length === 0) return at({ kind: "Internal", builtin }, { location });
|
|
179
181
|
const names = name.split("!");
|
|
180
182
|
if (names.length === 1) {
|
|
@@ -552,22 +554,14 @@ export const createSource = (
|
|
|
552
554
|
case "Always":
|
|
553
555
|
case "Eventually": {
|
|
554
556
|
const inner = expression.expression;
|
|
555
|
-
if (
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
modal: "Box",
|
|
560
|
-
action: recurse(inner.action),
|
|
561
|
-
subscript: recurse(inner.subscript),
|
|
562
|
-
},
|
|
563
|
-
{ location },
|
|
564
|
-
);
|
|
565
|
-
}
|
|
566
|
-
if (expression.kind === "Eventually" && inner.kind === "AngleAction") {
|
|
557
|
+
if (
|
|
558
|
+
(expression.kind === "Always" && inner.kind === "BoxAction") ||
|
|
559
|
+
(expression.kind === "Eventually" && inner.kind === "AngleAction")
|
|
560
|
+
) {
|
|
567
561
|
return at(
|
|
568
562
|
{
|
|
569
563
|
kind: "Tsub",
|
|
570
|
-
modal: "Dia",
|
|
564
|
+
modal: expression.kind === "Always" ? "Box" : "Dia",
|
|
571
565
|
action: recurse(inner.action),
|
|
572
566
|
subscript: recurse(inner.subscript),
|
|
573
567
|
},
|
|
@@ -672,20 +666,16 @@ export const createSource = (
|
|
|
672
666
|
? "-."
|
|
673
667
|
: getCanonicalName(definition.name);
|
|
674
668
|
const body = convertExpression(definition.body, isExcept);
|
|
675
|
-
if (definition.kind === "Function" && hasTuple(definition.bounds)) {
|
|
676
|
-
return {
|
|
677
|
-
kind: "Operator",
|
|
678
|
-
name,
|
|
679
|
-
body: expandTuples(expandFcn(getTuplyBounds(definition.bounds, isExcept), body), location),
|
|
680
|
-
location,
|
|
681
|
-
};
|
|
682
|
-
}
|
|
683
669
|
if (definition.kind === "Function") {
|
|
684
|
-
const bounds = convertBounds(definition.bounds, isExcept);
|
|
685
670
|
return {
|
|
686
671
|
kind: "Operator",
|
|
687
672
|
name,
|
|
688
|
-
body:
|
|
673
|
+
body: hasTuple(definition.bounds)
|
|
674
|
+
? expandTuples(expandFcn(getTuplyBounds(definition.bounds, isExcept), body), location)
|
|
675
|
+
: at(
|
|
676
|
+
{ kind: "Fcn", bounds: convertBounds(definition.bounds, isExcept), body },
|
|
677
|
+
{ location },
|
|
678
|
+
),
|
|
689
679
|
location,
|
|
690
680
|
};
|
|
691
681
|
}
|
|
@@ -1018,5 +1008,5 @@ export const createSource = (
|
|
|
1018
1008
|
}),
|
|
1019
1009
|
});
|
|
1020
1010
|
|
|
1021
|
-
return
|
|
1011
|
+
return convertModule;
|
|
1022
1012
|
};
|
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
getFresh,
|
|
9
9
|
getLocalDefn,
|
|
10
10
|
getScopeAt,
|
|
11
|
+
getTrue,
|
|
12
|
+
isBuiltinApply,
|
|
11
13
|
mapChildren,
|
|
12
14
|
type Builtin,
|
|
13
15
|
type Expr,
|
|
@@ -30,7 +32,7 @@ export const rewriteUnchanged = (expression: Expr): Expr => {
|
|
|
30
32
|
const flatten = (inner: Expr): Expr[] =>
|
|
31
33
|
inner.kind === "Tuple" ? inner.elements.flatMap(flatten) : [inner];
|
|
32
34
|
const items = flatten(expression);
|
|
33
|
-
if (items.length === 0) return
|
|
35
|
+
if (items.length === 0) return getTrue(expression);
|
|
34
36
|
if (items.length === 1) return getEquality(items[0]);
|
|
35
37
|
return at({ kind: "List", bullet: "And", items: items.map(getEquality) }, expression);
|
|
36
38
|
};
|
|
@@ -43,7 +45,7 @@ const rewrite =
|
|
|
43
45
|
};
|
|
44
46
|
|
|
45
47
|
export const expandLeadsto = rewrite((expression, recurse) =>
|
|
46
|
-
|
|
48
|
+
isBuiltinApply(expression, "Leadsto")
|
|
47
49
|
? applyBuiltin(
|
|
48
50
|
"BoxTrue",
|
|
49
51
|
[
|
|
@@ -103,9 +105,7 @@ export const expandAction = rewrite((expression, recurse) => {
|
|
|
103
105
|
});
|
|
104
106
|
|
|
105
107
|
const expandUnchanged = rewrite((expression) =>
|
|
106
|
-
expression
|
|
107
|
-
? rewriteUnchanged(expression.args[0])
|
|
108
|
-
: undefined,
|
|
108
|
+
isBuiltinApply(expression, "UNCHANGED") ? rewriteUnchanged(expression.args[0]) : undefined,
|
|
109
109
|
);
|
|
110
110
|
|
|
111
111
|
const TEMPORAL_BUILTINS: Builtin[] = [
|
package/src/parallel-worker.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createEnvironment } from "./environment";
|
|
2
1
|
import {
|
|
3
2
|
createFingerprintTable,
|
|
4
3
|
insertSharedFingerprint,
|
|
@@ -6,20 +5,11 @@ import {
|
|
|
6
5
|
writeStateFingerprint,
|
|
7
6
|
} from "./fingerprints";
|
|
8
7
|
import type { CoordinatorMessage, StartMessage, WorkerMessage } from "./parallel";
|
|
9
|
-
import { createSearch } from "./search";
|
|
8
|
+
import { createCheckEnvironment, createSearch } from "./search";
|
|
10
9
|
import { getSuccessors, type Successor } from "./successors";
|
|
11
|
-
import { setFingerprintPolynomial } from "./tlc/fingerprint";
|
|
12
|
-
import { createTlcOrder } from "./tlc/order";
|
|
13
10
|
import { OUT_DEGREE_BUCKETS } from "./tlc/summary";
|
|
14
11
|
import { createStateDecoder, createStateEncoder, type EncodedStates } from "./transfer";
|
|
15
|
-
import {
|
|
16
|
-
createCanonicalizer,
|
|
17
|
-
freezeStringOrder,
|
|
18
|
-
getUnorderedString,
|
|
19
|
-
setStringOrder,
|
|
20
|
-
setValueOptions,
|
|
21
|
-
type Value,
|
|
22
|
-
} from "./values";
|
|
12
|
+
import { createCanonicalizer, getUnorderedString, type Value } from "./values";
|
|
23
13
|
import { createBreak, getParentPort, type Port } from "./worker";
|
|
24
14
|
|
|
25
15
|
const LOCKED = -1;
|
|
@@ -43,26 +33,16 @@ const runWorker = (start: StartMessage, parent: Port) => {
|
|
|
43
33
|
const modules = new Map(start.modules);
|
|
44
34
|
const loadModule = (name: string) => modules.get(name);
|
|
45
35
|
const classes = new Map(start.classes);
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
loadModule,
|
|
54
|
-
order,
|
|
55
|
-
loadClass: (name) => classes.get(name),
|
|
56
|
-
print: () => {},
|
|
57
|
-
files: { readFile: undefined, writeFile: undefined, makeDirectory: undefined },
|
|
58
|
-
isTool: start.isTool,
|
|
59
|
-
traceFile: start.traceFile,
|
|
60
|
-
isWarningEnabled: start.isWarningEnabled,
|
|
61
|
-
version: start.version,
|
|
62
|
-
});
|
|
36
|
+
const created = createCheckEnvironment(
|
|
37
|
+
start.config,
|
|
38
|
+
{ ...start, loadModule, loadClass: (name) => classes.get(name), seed: undefined },
|
|
39
|
+
() => {},
|
|
40
|
+
true,
|
|
41
|
+
);
|
|
42
|
+
const specification = created.specification;
|
|
63
43
|
const environment = specification.environment;
|
|
64
44
|
const search = createSearch(start.config, environment, specification.variableLocations, () =>
|
|
65
|
-
order.getDeclarationOrder("variable"),
|
|
45
|
+
created.order.getDeclarationOrder("variable"),
|
|
66
46
|
);
|
|
67
47
|
const nextAction = search?.spec.next;
|
|
68
48
|
if (!search || nextAction === undefined)
|
package/src/parallel.ts
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
type InitialStates,
|
|
8
8
|
} from "./check";
|
|
9
9
|
import { parseConfig, type ModelConfig } from "./config";
|
|
10
|
-
import { createEnvironment } from "./environment";
|
|
11
10
|
import { TlaEvaluationError } from "./errors";
|
|
12
11
|
import { isImpure } from "./evaluate";
|
|
13
12
|
import {
|
|
@@ -19,43 +18,36 @@ import {
|
|
|
19
18
|
type SharedFingerprints,
|
|
20
19
|
} from "./fingerprints";
|
|
21
20
|
import {
|
|
21
|
+
createCheckEnvironment,
|
|
22
22
|
createSearch,
|
|
23
23
|
findAssumptionViolation,
|
|
24
24
|
reportInitialStatesProgress,
|
|
25
25
|
reportStartup,
|
|
26
26
|
} from "./search";
|
|
27
27
|
import { getInitialStates } from "./successors";
|
|
28
|
-
import { setFingerprintPolynomial } from "./tlc/fingerprint";
|
|
29
|
-
import { createTlcOrder } from "./tlc/order";
|
|
30
28
|
import { getFingerprintDistance, OUT_DEGREE_BUCKETS } from "./tlc/summary";
|
|
31
29
|
import { createStateEncoder, type EncodedStates } from "./transfer";
|
|
32
|
-
import type
|
|
33
|
-
import {
|
|
34
|
-
createCanonicalizer,
|
|
35
|
-
freezeStringOrder,
|
|
36
|
-
getUnorderedString,
|
|
37
|
-
setStringOrder,
|
|
38
|
-
setValueOptions,
|
|
39
|
-
type Value,
|
|
40
|
-
} from "./values";
|
|
30
|
+
import { createCanonicalizer, getUnorderedString, type Value } from "./values";
|
|
41
31
|
import { spawnWorker, type Port } from "./worker";
|
|
42
32
|
|
|
43
|
-
export interface StartMessage
|
|
33
|
+
export interface StartMessage extends Pick<
|
|
34
|
+
CheckOptions,
|
|
35
|
+
| "source"
|
|
36
|
+
| "isTool"
|
|
37
|
+
| "traceSpec"
|
|
38
|
+
| "isWarningEnabled"
|
|
39
|
+
| "version"
|
|
40
|
+
| "fingerprintPolynomial"
|
|
41
|
+
| "maxSetSize"
|
|
42
|
+
| "isLazyValueExpanded"
|
|
43
|
+
> {
|
|
44
44
|
type: "start";
|
|
45
|
-
source: string;
|
|
46
45
|
config: ModelConfig;
|
|
47
46
|
modules: [string, string | undefined][];
|
|
48
47
|
classes: [string, Uint8Array | undefined][];
|
|
49
48
|
index: number;
|
|
50
49
|
ports: (Port | undefined)[];
|
|
51
50
|
seed: EncodedStates;
|
|
52
|
-
isTool: boolean | undefined;
|
|
53
|
-
traceFile: string | undefined;
|
|
54
|
-
isWarningEnabled: boolean | undefined;
|
|
55
|
-
version: TlcVersion | undefined;
|
|
56
|
-
fingerprintPolynomial: number | undefined;
|
|
57
|
-
maxSetSize: number | undefined;
|
|
58
|
-
isLazyValueExpanded: boolean | undefined;
|
|
59
51
|
fingerprints: SharedFingerprints;
|
|
60
52
|
requests: Int32Array;
|
|
61
53
|
remaining: Int32Array;
|
|
@@ -136,38 +128,23 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
136
128
|
classes.set(name, bytes);
|
|
137
129
|
return bytes;
|
|
138
130
|
};
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
freezeStringOrder();
|
|
144
|
-
const specification = createEnvironment(config, {
|
|
145
|
-
source: options.source,
|
|
146
|
-
loadModule,
|
|
147
|
-
order,
|
|
148
|
-
loadClass,
|
|
149
|
-
print: (text) => {
|
|
131
|
+
const created = createCheckEnvironment(
|
|
132
|
+
config,
|
|
133
|
+
{ ...options, loadModule, loadClass, seed: undefined, moduleOperators: undefined },
|
|
134
|
+
(text) => {
|
|
150
135
|
printedCount++;
|
|
151
136
|
print(text);
|
|
152
137
|
},
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
makeDirectory: options.makeDirectory,
|
|
157
|
-
},
|
|
158
|
-
isTool: options.isTool,
|
|
159
|
-
traceFile: options.traceSpec?.traceFile,
|
|
160
|
-
isSanyReported: options.isSanyReported,
|
|
161
|
-
isWarningEnabled: options.isWarningEnabled,
|
|
162
|
-
version: options.version,
|
|
163
|
-
});
|
|
138
|
+
true,
|
|
139
|
+
);
|
|
140
|
+
const specification = created.specification;
|
|
164
141
|
reportStartup(specification, config, report);
|
|
165
142
|
const environment = specification.environment;
|
|
166
143
|
const search = createSearch(
|
|
167
144
|
config,
|
|
168
145
|
environment,
|
|
169
146
|
specification.variableLocations,
|
|
170
|
-
() => order.getDeclarationOrder("variable"),
|
|
147
|
+
() => created.order.getDeclarationOrder("variable"),
|
|
171
148
|
report,
|
|
172
149
|
);
|
|
173
150
|
if (findAssumptionViolation(specification.assumptions, environment)) return fallBack();
|
|
@@ -302,7 +279,7 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
302
279
|
ports,
|
|
303
280
|
seed,
|
|
304
281
|
isTool: options.isTool,
|
|
305
|
-
|
|
282
|
+
traceSpec: options.traceSpec,
|
|
306
283
|
isWarningEnabled: options.isWarningEnabled,
|
|
307
284
|
version: options.version,
|
|
308
285
|
fingerprintPolynomial: options.fingerprintPolynomial,
|
package/src/parser.ts
CHANGED
|
@@ -1316,17 +1316,11 @@ const parse = (
|
|
|
1316
1316
|
location,
|
|
1317
1317
|
};
|
|
1318
1318
|
case "[]":
|
|
1319
|
-
advance();
|
|
1320
|
-
return { kind: "Always", expression: parsePrefixOperand(token, 4, 15), location };
|
|
1321
1319
|
case "<>":
|
|
1322
|
-
advance();
|
|
1323
|
-
return { kind: "Eventually", expression: parsePrefixOperand(token, 4, 15), location };
|
|
1324
1320
|
case "ENABLED":
|
|
1325
|
-
advance();
|
|
1326
|
-
return { kind: "Enabled", expression: parsePrefixOperand(token, 4, 15), location };
|
|
1327
1321
|
case "UNCHANGED":
|
|
1328
1322
|
advance();
|
|
1329
|
-
return
|
|
1323
|
+
return getOperatorApplication(token.text, parsePrefixOperand(token, 4, 15), location);
|
|
1330
1324
|
case "SUBSET":
|
|
1331
1325
|
case "UNION":
|
|
1332
1326
|
case "DOMAIN":
|
|
@@ -2166,9 +2160,22 @@ const parse = (
|
|
|
2166
2160
|
return nested.proof;
|
|
2167
2161
|
};
|
|
2168
2162
|
|
|
2169
|
-
const addFactDefinition = (
|
|
2170
|
-
|
|
2171
|
-
|
|
2163
|
+
const addFactDefinition = (
|
|
2164
|
+
module: Module,
|
|
2165
|
+
name: string,
|
|
2166
|
+
body: Expression,
|
|
2167
|
+
location: SourceLocation,
|
|
2168
|
+
) => {
|
|
2169
|
+
if (module.definitions.some((other) => other.name === name)) return;
|
|
2170
|
+
module.definitions.push({
|
|
2171
|
+
kind: "Operator",
|
|
2172
|
+
name,
|
|
2173
|
+
params: [],
|
|
2174
|
+
body,
|
|
2175
|
+
isLocal: false,
|
|
2176
|
+
isRecursive: false,
|
|
2177
|
+
location,
|
|
2178
|
+
});
|
|
2172
2179
|
};
|
|
2173
2180
|
|
|
2174
2181
|
const parseFactName = () => {
|
|
@@ -2196,21 +2203,7 @@ const parse = (
|
|
|
2196
2203
|
module.theorems.push(theorem);
|
|
2197
2204
|
module.units.push({ kind: "Theorem", theorem });
|
|
2198
2205
|
if (name === undefined || statement.kind === "AssumeProve") return;
|
|
2199
|
-
addFactDefinition(
|
|
2200
|
-
module,
|
|
2201
|
-
withRange(
|
|
2202
|
-
{
|
|
2203
|
-
kind: "Operator",
|
|
2204
|
-
name,
|
|
2205
|
-
params: [],
|
|
2206
|
-
body: statement,
|
|
2207
|
-
isLocal: false,
|
|
2208
|
-
isRecursive: false,
|
|
2209
|
-
location: getLocation(keyword),
|
|
2210
|
-
},
|
|
2211
|
-
start,
|
|
2212
|
-
),
|
|
2213
|
-
);
|
|
2206
|
+
addFactDefinition(module, name, statement, theorem.location);
|
|
2214
2207
|
};
|
|
2215
2208
|
|
|
2216
2209
|
const parseAssumption = (): Assumption => {
|
|
@@ -2312,15 +2305,7 @@ const parse = (
|
|
|
2312
2305
|
module.assumptions.push(assumption);
|
|
2313
2306
|
module.units.push({ kind: "Assumption", assumption });
|
|
2314
2307
|
if (assumption.name !== undefined) {
|
|
2315
|
-
addFactDefinition(module,
|
|
2316
|
-
kind: "Operator",
|
|
2317
|
-
name: assumption.name,
|
|
2318
|
-
params: [],
|
|
2319
|
-
body: assumption.expression,
|
|
2320
|
-
isLocal: false,
|
|
2321
|
-
isRecursive: false,
|
|
2322
|
-
location: assumption.location,
|
|
2323
|
-
});
|
|
2308
|
+
addFactDefinition(module, assumption.name, assumption.expression, assumption.location);
|
|
2324
2309
|
}
|
|
2325
2310
|
continue;
|
|
2326
2311
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { TlaProverError } from "../errors";
|
|
2
2
|
import { spawnWorker, type WorkerHandle } from "../worker";
|
|
3
|
-
import type { DecideOptions, Decision } from "./verdict";
|
|
3
|
+
import type { Backend, DecideOptions, Decision } from "./verdict";
|
|
4
4
|
|
|
5
5
|
export interface DecideRequest {
|
|
6
|
-
prover:
|
|
6
|
+
prover: Backend;
|
|
7
7
|
text: string;
|
|
8
8
|
timeLimitMs: number;
|
|
9
9
|
}
|
|
@@ -19,7 +19,7 @@ interface PendingDecision {
|
|
|
19
19
|
|
|
20
20
|
export interface DecidePool {
|
|
21
21
|
decide: (
|
|
22
|
-
prover:
|
|
22
|
+
prover: Backend,
|
|
23
23
|
text: string,
|
|
24
24
|
options: DecideOptions,
|
|
25
25
|
priority: number,
|
package/src/prover/deciders.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { SmtParseError, TlaProverError } from "../errors";
|
|
|
2
2
|
import { decideIsabelle } from "./isabelle/decide";
|
|
3
3
|
import { decidePtl } from "./ptl/decide";
|
|
4
4
|
import { decideSmt } from "./smt/solver/solver";
|
|
5
|
-
import type { DecideOptions, Decision, Verdict } from "./verdict";
|
|
5
|
+
import type { Backend, DecideOptions, Decision, Verdict } from "./verdict";
|
|
6
6
|
import { decideZenon } from "./zenon/decide";
|
|
7
7
|
|
|
8
8
|
const decideZ3 = (text: string, options: DecideOptions) => {
|
|
@@ -14,7 +14,7 @@ const decideZ3 = (text: string, options: DecideOptions) => {
|
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
const DECIDERS: Record<Backend, (text: string, options: DecideOptions) => Verdict> = {
|
|
18
18
|
smt: decideZ3,
|
|
19
19
|
z3: decideZ3,
|
|
20
20
|
zenon: (text, options) => decideZenon(text, options).verdict,
|
|
@@ -22,7 +22,7 @@ export const DECIDERS: Record<string, (text: string, options: DecideOptions) =>
|
|
|
22
22
|
ls4: decidePtl,
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
export const decide = (prover:
|
|
25
|
+
export const decide = (prover: Backend, text: string, options: DecideOptions): Decision => {
|
|
26
26
|
const start = performance.now();
|
|
27
27
|
const verdict = DECIDERS[prover](text, options);
|
|
28
28
|
return { verdict, timeUsedMs: performance.now() - start };
|
|
@@ -145,7 +145,7 @@ const printLemma = (sequent: Sequent) => {
|
|
|
145
145
|
case "Ix": {
|
|
146
146
|
const name = getBoundName(context, operator.index);
|
|
147
147
|
if (operator.index <= 0 || name === undefined) throw new TlapmBugError();
|
|
148
|
-
return args.length === 0 ? name :
|
|
148
|
+
return args.length === 0 ? name : printNonfix(name, args);
|
|
149
149
|
}
|
|
150
150
|
case "Opaque": {
|
|
151
151
|
const name = pickle(operator.name);
|
|
@@ -70,6 +70,11 @@ const tokenize = (text: string): Token[] => {
|
|
|
70
70
|
}
|
|
71
71
|
if (text.startsWith("\\<", position) && isLetter(text[position + 2] ?? "")) {
|
|
72
72
|
const end = text.indexOf(">", position);
|
|
73
|
+
if (end < 0)
|
|
74
|
+
throw new TlaIsabelleError(
|
|
75
|
+
"ERROR",
|
|
76
|
+
`Inner lexical error at: ${text.slice(position, position + 20)}`,
|
|
77
|
+
);
|
|
73
78
|
tokens.push({ kind: "delimiter", text: text.slice(position, end + 1) });
|
|
74
79
|
position = end + 1;
|
|
75
80
|
continue;
|
|
@@ -274,11 +279,11 @@ class Parser {
|
|
|
274
279
|
throw new TlaIsabelleError("ERROR", `Undefined type name: ${name}`);
|
|
275
280
|
}
|
|
276
281
|
|
|
277
|
-
private parseBinders(
|
|
282
|
+
private parseBinders(): TypedName[] {
|
|
278
283
|
const binders: TypedName[] = [];
|
|
279
284
|
while (this.peek().kind === "id") {
|
|
280
285
|
const name = this.parseIdentifier();
|
|
281
|
-
if (
|
|
286
|
+
if (this.isDelimiter("::")) {
|
|
282
287
|
this.position += 1;
|
|
283
288
|
binders.push({ name, type: this.parseType() });
|
|
284
289
|
} else binders.push({ name, type: undefined });
|
|
@@ -418,7 +423,7 @@ class Parser {
|
|
|
418
423
|
case "%":
|
|
419
424
|
case "\\<lambda>": {
|
|
420
425
|
if (minimum > 3) throw this.syntaxError();
|
|
421
|
-
const binders = this.parseBinders(
|
|
426
|
+
const binders = this.parseBinders();
|
|
422
427
|
this.expect(".");
|
|
423
428
|
const body = this.parseLogic(3);
|
|
424
429
|
return toTerm(
|
|
@@ -436,7 +441,7 @@ class Parser {
|
|
|
436
441
|
}
|
|
437
442
|
case "\\<And>": {
|
|
438
443
|
if (minimum > 0) throw this.syntaxError();
|
|
439
|
-
const binders = this.parseBinders(
|
|
444
|
+
const binders = this.parseBinders();
|
|
440
445
|
this.expect(".");
|
|
441
446
|
const body = this.parseProp(0);
|
|
442
447
|
return {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { TlaIsabelleError } from "../../../errors";
|
|
4
4
|
import { asmRl, isNormHhf, normHhfEq, reflexiveThm, termI } from "../pure/drule";
|
|
5
|
-
import { isEquals, stripImpPrems, stripAssumsConcl } from "../pure/logic";
|
|
5
|
+
import { isEquals, isImplies, stripImpPrems, stripAssumsConcl } from "../pure/logic";
|
|
6
6
|
import { makeSimpContext, type Simpset } from "../pure/raw-simplifier";
|
|
7
7
|
import { genericRewriteGoalTac } from "../pure/rewriter";
|
|
8
8
|
import { filterSeq, mapsSeq, singleSeq, type Seq } from "../pure/seq";
|
|
@@ -12,6 +12,7 @@ import type { Limits } from "../pure/interrupt";
|
|
|
12
12
|
import { assumeTac, eresolveTac, flexflexTac, matchTac, resolveTac } from "../pure/tactic";
|
|
13
13
|
import {
|
|
14
14
|
allGoals,
|
|
15
|
+
allTac,
|
|
15
16
|
appendGoal,
|
|
16
17
|
changedProp,
|
|
17
18
|
noTac,
|
|
@@ -21,6 +22,7 @@ import {
|
|
|
21
22
|
thenAllNew,
|
|
22
23
|
thenGoal,
|
|
23
24
|
thenTac,
|
|
25
|
+
tryTac,
|
|
24
26
|
type GoalTactic,
|
|
25
27
|
type Tactic,
|
|
26
28
|
} from "../pure/tactical";
|
|
@@ -44,7 +46,7 @@ import {
|
|
|
44
46
|
} from "../provers/classical";
|
|
45
47
|
import { proverTac, type IntuitionisticContext } from "../tools/intuitionistic";
|
|
46
48
|
import { insertTac } from "./proof";
|
|
47
|
-
import type
|
|
49
|
+
import { syntaxError, type OuterToken } from "./theory";
|
|
48
50
|
|
|
49
51
|
interface Modifier {
|
|
50
52
|
readonly kind: "intro" | "dest";
|
|
@@ -77,12 +79,6 @@ export interface ProofContext {
|
|
|
77
79
|
readonly getFact: (name: string) => readonly Thm[];
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
const syntaxError = (token: OuterToken | undefined) =>
|
|
81
|
-
new TlaIsabelleError(
|
|
82
|
-
"ERROR",
|
|
83
|
-
`Outer syntax error at: ${token === undefined ? "end of input" : token.text}`,
|
|
84
|
-
);
|
|
85
|
-
|
|
86
82
|
export const parseProofText = (tokens: readonly OuterToken[]): ProofText => {
|
|
87
83
|
let position = 0;
|
|
88
84
|
const peek = () => tokens[position];
|
|
@@ -138,22 +134,18 @@ export const parseProofText = (tokens: readonly OuterToken[]): ProofText => {
|
|
|
138
134
|
};
|
|
139
135
|
const readParenthesized = (): MethodText => {
|
|
140
136
|
expectSymbol("(");
|
|
141
|
-
const elements = [
|
|
142
|
-
readSuffixed(isSymbol("(") ? readParenthesized() : readMethod(readWord(), true)),
|
|
143
|
-
];
|
|
137
|
+
const elements = [readElement(true)];
|
|
144
138
|
while (isSymbol(",")) {
|
|
145
139
|
position += 1;
|
|
146
|
-
elements.push(
|
|
147
|
-
readSuffixed(isSymbol("(") ? readParenthesized() : readMethod(readWord(), true)),
|
|
148
|
-
);
|
|
140
|
+
elements.push(readElement(true));
|
|
149
141
|
}
|
|
150
142
|
expectSymbol(")");
|
|
151
143
|
return elements.length === 1 ? elements[0] : { kind: "then", methods: elements };
|
|
152
144
|
};
|
|
153
|
-
const
|
|
154
|
-
readSuffixed(isSymbol("(") ? readParenthesized() : readMethod(readWord(),
|
|
155
|
-
const initial =
|
|
156
|
-
const terminal = position < tokens.length ?
|
|
145
|
+
const readElement = (hasArgs: boolean) =>
|
|
146
|
+
readSuffixed(isSymbol("(") ? readParenthesized() : readMethod(readWord(), hasArgs));
|
|
147
|
+
const initial = readElement(false);
|
|
148
|
+
const terminal = position < tokens.length ? readElement(false) : undefined;
|
|
157
149
|
if (position !== tokens.length) throw syntaxError(peek());
|
|
158
150
|
return { initial, terminal };
|
|
159
151
|
};
|
|
@@ -246,7 +238,7 @@ const evaluate = (context: ProofContext, text: MethodText): Method => {
|
|
|
246
238
|
}
|
|
247
239
|
case "try": {
|
|
248
240
|
const method = evaluate(context, text.method);
|
|
249
|
-
return (facts) =>
|
|
241
|
+
return (facts) => tryTac(method(facts));
|
|
250
242
|
}
|
|
251
243
|
}
|
|
252
244
|
};
|
|
@@ -257,7 +249,7 @@ const normHhfTac = (limits: Limits): GoalTactic => {
|
|
|
257
249
|
resolveTac(limits, [asmRl]),
|
|
258
250
|
subgoal((goal, index) =>
|
|
259
251
|
isNormHhf(false, goal)
|
|
260
|
-
?
|
|
252
|
+
? allTac
|
|
261
253
|
: genericRewriteGoalTac(
|
|
262
254
|
{ simprem: true, useprem: false, mutsimp: false },
|
|
263
255
|
() => undefined,
|
|
@@ -284,11 +276,8 @@ const assumeRuleTac = (limits: Limits): GoalTactic =>
|
|
|
284
276
|
);
|
|
285
277
|
const rules = stripImpPrems(body).filter(
|
|
286
278
|
(prem) =>
|
|
287
|
-
prem
|
|
288
|
-
(
|
|
289
|
-
prem.fun.fun.kind === "Const" &&
|
|
290
|
-
prem.fun.fun.name === "Pure.imp") ||
|
|
291
|
-
(prem.fun.kind === "Const" && prem.fun.name === "Pure.all")),
|
|
279
|
+
isImplies(prem) ||
|
|
280
|
+
(prem.kind === "App" && prem.fun.kind === "Const" && prem.fun.name === "Pure.all"),
|
|
292
281
|
);
|
|
293
282
|
return rules.reduceRight<GoalTactic>(
|
|
294
283
|
(tactic, rule) =>
|