tla-ts 0.0.4-dev.8fefa42 → 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 +27 -130
- package/dist/deciders.cjs +1 -1
- package/dist/deciders.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -1
- package/dist/prove-worker.cjs +1 -1
- package/dist/prove-worker.js +1 -1
- package/dist/prove.cjs +506 -25
- package/dist/prove.js +506 -25
- package/dist/run-cli.cjs +35 -28
- package/dist/run-cli.js +35 -28
- package/dist/tlapm.cjs +2 -2
- package/dist/tlapm.js +2 -2
- package/package.json +1 -1
- package/src/obligations/action.ts +56 -99
- package/src/obligations/anon.ts +37 -41
- package/src/obligations/deref.ts +49 -90
- package/src/obligations/expression.ts +63 -49
- package/src/obligations/format.ts +7 -8
- package/src/obligations/generate.ts +60 -155
- package/src/obligations/index.ts +6 -4
- package/src/obligations/levels.ts +20 -32
- package/src/obligations/module.ts +93 -127
- package/src/obligations/pickle.ts +1 -3
- package/src/obligations/pragma.ts +14 -14
- package/src/obligations/printer.ts +17 -21
- package/src/obligations/proof.ts +0 -1
- package/src/obligations/source.ts +72 -73
- package/src/obligations/temporal.ts +29 -27
- package/src/obligations/tuples.ts +37 -53
- package/src/ocaml-marshal.ts +166 -0
- package/src/prove/decide-pool.ts +12 -17
- package/src/prove/deciders.ts +7 -1
- package/src/prove/first-order.ts +78 -0
- package/src/prove/isabelle/encode.ts +96 -127
- package/src/prove/ocaml.ts +1 -1
- package/src/prove/prep/action.ts +39 -51
- package/src/prove/prep/defs.ts +19 -13
- package/src/prove/prep/elab.ts +1 -1
- package/src/prove/prep/level-comparison.ts +15 -38
- package/src/prove/prep/pragma.ts +4 -4
- package/src/prove/prove-worker.ts +4 -11
- package/src/prove/prove.ts +230 -149
- package/src/prove/ptl/encode.ts +5 -6
- package/src/prove/smt/axioms.ts +78 -79
- package/src/prove/smt/data.ts +16 -45
- package/src/prove/smt/encode.ts +18 -23
- package/src/prove/smt/extensionality.ts +14 -12
- package/src/prove/smt/flatten.ts +3 -18
- package/src/prove/smt/format.ts +14 -3
- package/src/prove/smt/instances.ts +4 -5
- package/src/prove/smt/rewrite.ts +36 -48
- package/src/prove/smt/simplify.ts +10 -10
- package/src/prove/tlapm/tlapm.ts +13 -13
- package/src/prove/verdict.ts +5 -0
- package/src/prove/zenon/encode.ts +36 -101
- package/src/run-cli.ts +264 -115
- package/src/tlapm-cache.ts +236 -0
|
@@ -7,7 +7,10 @@ import {
|
|
|
7
7
|
adjoin,
|
|
8
8
|
adjoinAll,
|
|
9
9
|
getBoundedFresh,
|
|
10
|
+
getBoundFresh,
|
|
10
11
|
getFresh,
|
|
12
|
+
getLocalDefn,
|
|
13
|
+
getParamFresh,
|
|
11
14
|
getScopeAt,
|
|
12
15
|
getScopeHyps,
|
|
13
16
|
type Bound,
|
|
@@ -64,31 +67,18 @@ const getDeclaration = (scope: Scope | undefined, index: number): Declaration =>
|
|
|
64
67
|
};
|
|
65
68
|
|
|
66
69
|
const bindBounds = (scope: Scope | undefined, bounds: Bound[]) =>
|
|
67
|
-
|
|
70
|
+
adjoinAll(scope, bounds.map(getBoundFresh));
|
|
68
71
|
|
|
69
72
|
const bindParams = (scope: Scope | undefined, params: Param[]) =>
|
|
70
|
-
params.
|
|
71
|
-
(current, param) => adjoin(current, getFresh(param.name, "Unknown", param.shape)),
|
|
72
|
-
scope,
|
|
73
|
-
);
|
|
73
|
+
adjoinAll(scope, params.map(getParamFresh));
|
|
74
74
|
|
|
75
75
|
const bindDefinitions = (scope: Scope | undefined, definitions: Defn[]) =>
|
|
76
|
-
definitions.
|
|
77
|
-
(current, definition) =>
|
|
78
|
-
adjoin(current, {
|
|
79
|
-
kind: "Defn",
|
|
80
|
-
definition,
|
|
81
|
-
whereDefined: "User",
|
|
82
|
-
visibility: "Visible",
|
|
83
|
-
isLocal: true,
|
|
84
|
-
}),
|
|
85
|
-
scope,
|
|
86
|
-
);
|
|
76
|
+
adjoinAll(scope, definitions.map(getLocalDefn));
|
|
87
77
|
|
|
88
78
|
const bindFlexible = (scope: Scope | undefined, names: string[]) =>
|
|
89
|
-
|
|
90
|
-
(current, name) => adjoin(current, { kind: "Flex", name }),
|
|
79
|
+
adjoinAll(
|
|
91
80
|
scope,
|
|
81
|
+
names.map((name) => ({ kind: "Flex", name })),
|
|
92
82
|
);
|
|
93
83
|
|
|
94
84
|
// level_comparison#compare: the expressions match up to a renaming that maps each name one way,
|
|
@@ -140,7 +130,10 @@ const compare = (
|
|
|
140
130
|
const leftArgs = left.instance.args;
|
|
141
131
|
const rightArgs = right.instance.args;
|
|
142
132
|
const bindArgs = (scope: Scope | undefined, args: string[]) =>
|
|
143
|
-
|
|
133
|
+
adjoinAll(
|
|
134
|
+
scope,
|
|
135
|
+
args.map((name) => getFresh(name, "Unknown")),
|
|
136
|
+
);
|
|
144
137
|
const getFields = (definition: typeof left.instance) =>
|
|
145
138
|
getSortedFields(
|
|
146
139
|
definition.substitutions.map((entry) => ({ name: entry.name, value: entry.expression })),
|
|
@@ -384,9 +377,8 @@ const compare = (
|
|
|
384
377
|
)
|
|
385
378
|
);
|
|
386
379
|
case "Choose":
|
|
387
|
-
return right.kind === "Choose" && isSameBinder(leftScope, rightScope, left, right);
|
|
388
380
|
case "SetSt":
|
|
389
|
-
return right.kind ===
|
|
381
|
+
return right.kind === left.kind && isSameBinder(leftScope, rightScope, left, right);
|
|
390
382
|
case "SetOf":
|
|
391
383
|
return (
|
|
392
384
|
right.kind === "SetOf" &&
|
|
@@ -427,18 +419,9 @@ const compare = (
|
|
|
427
419
|
case "Product":
|
|
428
420
|
return right.kind === "Product" && recurseList(left.factors, right.factors);
|
|
429
421
|
case "Rect":
|
|
430
|
-
return (
|
|
431
|
-
right.kind === "Rect" &&
|
|
432
|
-
isSameFields(
|
|
433
|
-
leftScope,
|
|
434
|
-
rightScope,
|
|
435
|
-
getSortedFields(left.fields),
|
|
436
|
-
getSortedFields(right.fields),
|
|
437
|
-
)
|
|
438
|
-
);
|
|
439
422
|
case "Record":
|
|
440
423
|
return (
|
|
441
|
-
right.kind ===
|
|
424
|
+
right.kind === left.kind &&
|
|
442
425
|
isSameFields(
|
|
443
426
|
leftScope,
|
|
444
427
|
rightScope,
|
|
@@ -472,15 +455,9 @@ const compare = (
|
|
|
472
455
|
left.field === right.field
|
|
473
456
|
);
|
|
474
457
|
case "Sub":
|
|
475
|
-
return (
|
|
476
|
-
right.kind === "Sub" &&
|
|
477
|
-
left.modal === right.modal &&
|
|
478
|
-
recurse(left.action, right.action) &&
|
|
479
|
-
recurse(left.subscript, right.subscript)
|
|
480
|
-
);
|
|
481
458
|
case "Tsub":
|
|
482
459
|
return (
|
|
483
|
-
right.kind ===
|
|
460
|
+
right.kind === left.kind &&
|
|
484
461
|
left.modal === right.modal &&
|
|
485
462
|
recurse(left.action, right.action) &&
|
|
486
463
|
recurse(left.subscript, right.subscript)
|
package/src/prove/prep/pragma.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// obligation.
|
|
5
5
|
|
|
6
6
|
import { TlapmBugError, TlaProverError } from "../../errors";
|
|
7
|
-
import type { Expr,
|
|
7
|
+
import type { Expr, Locus, Sequent } from "../../obligations/expression";
|
|
8
8
|
import type { OldMethod, PragmaSetting } from "../../obligations/pragma";
|
|
9
9
|
|
|
10
10
|
// A method, named after the Method.t constructor tlapm reports it by. A Z3 resource budget turns
|
|
@@ -17,7 +17,7 @@ export interface Method {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
// The methods that rewrite an obligation in Prep.expand_enabled_cdot instead of proving it.
|
|
20
|
-
|
|
20
|
+
const FRONTENDS = new Set([
|
|
21
21
|
"expandenabled",
|
|
22
22
|
"expandcdot",
|
|
23
23
|
"autouse",
|
|
@@ -37,7 +37,7 @@ const RLIMIT_BASE = 3_000_000;
|
|
|
37
37
|
const MAX_RLIMIT = 0xffff_ffff;
|
|
38
38
|
|
|
39
39
|
// Params.default_method: what tlapm tries when a step cites no prover.
|
|
40
|
-
|
|
40
|
+
const DEFAULT_METHODS: Method[] = [
|
|
41
41
|
{ prover: "smt", timeLimitMs: SMT_SECONDS * 1000 },
|
|
42
42
|
{ prover: "zenon", timeLimitMs: ZENON_SECONDS * 1000 },
|
|
43
43
|
{ prover: "isabelle", timeLimitMs: ISABELLE_SECONDS * 1000, tactic: "auto" },
|
|
@@ -166,7 +166,7 @@ const getCitedMethods = (sequent: Sequent) => {
|
|
|
166
166
|
methods: [],
|
|
167
167
|
useLocation: null,
|
|
168
168
|
};
|
|
169
|
-
sequent.context.forEach((hyp
|
|
169
|
+
sequent.context.forEach((hyp, index) => {
|
|
170
170
|
const expression = hyp.kind === "Fact" && hyp.visibility === "Visible" && hyp.expression;
|
|
171
171
|
if (expression && expression.kind === "With") {
|
|
172
172
|
state.methods.push(getOldMethod(expression.method));
|
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
// A worker of the decide pool: it decides each request with the backend its prover selects.
|
|
2
2
|
|
|
3
|
-
import { TlaProverError
|
|
3
|
+
import { TlaProverError } from "../errors";
|
|
4
4
|
import { getParentPort } from "../worker";
|
|
5
|
-
import {
|
|
5
|
+
import { decide } from "./deciders";
|
|
6
6
|
import type { DecideRequest, DecideResponse } from "./decide-pool";
|
|
7
7
|
|
|
8
8
|
const getResponse = (request: DecideRequest): DecideResponse => {
|
|
9
9
|
try {
|
|
10
|
-
return {
|
|
11
|
-
verdict: DECIDERS[request.prover](request.text, { timeLimitMs: request.timeLimitMs }),
|
|
12
|
-
};
|
|
10
|
+
return decide(request.prover, request.text, { timeLimitMs: request.timeLimitMs });
|
|
13
11
|
} catch (error) {
|
|
14
|
-
if (error instanceof TlaProverError) {
|
|
15
|
-
return { error: { name: "TlaProverError", message: error.message } };
|
|
16
|
-
}
|
|
17
|
-
if (error instanceof TlaUnsupportedError) {
|
|
18
|
-
return { error: { name: "TlaUnsupportedError", message: error.message } };
|
|
19
|
-
}
|
|
12
|
+
if (error instanceof TlaProverError) return { error: error.message };
|
|
20
13
|
throw error;
|
|
21
14
|
}
|
|
22
15
|
};
|