tla-ts 0.0.4-dev.702eb98 → 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 +1 -0
- package/dist/deciders.cjs +1 -1
- package/dist/deciders.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/prove-worker.cjs +1 -1
- package/dist/prove-worker.js +1 -1
- package/dist/prove.cjs +498 -17
- package/dist/prove.js +506 -25
- package/dist/run-cli.cjs +515 -28
- package/dist/run-cli.js +515 -28
- package/package.json +1 -1
- package/src/obligations/format.ts +6 -5
- package/src/obligations/index.ts +2 -0
- package/src/obligations/printer.ts +4 -4
- package/src/ocaml-marshal.ts +172 -0
- package/src/prove/decide-pool.ts +9 -9
- package/src/prove/deciders.ts +7 -1
- package/src/prove/isabelle/encode.ts +57 -22
- package/src/prove/prep/defs.ts +19 -13
- package/src/prove/prove-worker.ts +2 -4
- package/src/prove/prove.ts +212 -101
- package/src/prove/verdict.ts +6 -0
- package/src/run-cli.ts +277 -34
- package/src/tlapm-cache.ts +250 -0
package/package.json
CHANGED
|
@@ -60,7 +60,7 @@ const getSentinel = (): ScanElement => ({
|
|
|
60
60
|
element: { size: UNKNOWN, token: { kind: "Text", text: "" }, length: 0 },
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
const createFormatter = (): Formatter => {
|
|
63
|
+
const createFormatter = (maxIndent: number): Formatter => {
|
|
64
64
|
const systemBox: QueueElement = {
|
|
65
65
|
size: UNKNOWN,
|
|
66
66
|
token: { kind: "Begin", indent: 0, box: "hov" },
|
|
@@ -72,7 +72,7 @@ const createFormatter = (): Formatter => {
|
|
|
72
72
|
scanStack: [getSentinel(), { leftTotal: 1, element: systemBox }],
|
|
73
73
|
formatStack: [],
|
|
74
74
|
margin: 78,
|
|
75
|
-
maxIndent
|
|
75
|
+
maxIndent,
|
|
76
76
|
spaceLeft: 78,
|
|
77
77
|
currentIndent: 0,
|
|
78
78
|
isNewLine: true,
|
|
@@ -242,7 +242,7 @@ const flush = (formatter: Formatter) => {
|
|
|
242
242
|
const flushNewline = (formatter: Formatter) => {
|
|
243
243
|
flush(formatter);
|
|
244
244
|
const output = [...formatter.output, "\n"];
|
|
245
|
-
Object.assign(formatter, createFormatter());
|
|
245
|
+
Object.assign(formatter, createFormatter(formatter.maxIndent));
|
|
246
246
|
formatter.output = output;
|
|
247
247
|
};
|
|
248
248
|
|
|
@@ -399,8 +399,9 @@ const renderInto = (formatter: Formatter, doc: Doc) => {
|
|
|
399
399
|
}
|
|
400
400
|
};
|
|
401
401
|
|
|
402
|
-
|
|
403
|
-
|
|
402
|
+
// OCaml's formatters indent at most 68 columns, and tlapm's stderr at most 35.
|
|
403
|
+
export const renderDoc = (doc: Doc, maxIndent = 68) => {
|
|
404
|
+
const formatter = createFormatter(maxIndent);
|
|
404
405
|
renderInto(formatter, doc);
|
|
405
406
|
return flush(formatter);
|
|
406
407
|
};
|
package/src/obligations/index.ts
CHANGED
|
@@ -41,6 +41,7 @@ export interface ObligationSource {
|
|
|
41
41
|
export interface PrintedObligation {
|
|
42
42
|
id: number;
|
|
43
43
|
location: string;
|
|
44
|
+
locus: Locus | undefined;
|
|
44
45
|
text: string;
|
|
45
46
|
kind: ObligationKind;
|
|
46
47
|
sequent: Sequent;
|
|
@@ -316,6 +317,7 @@ export const getObligations = (
|
|
|
316
317
|
{
|
|
317
318
|
id: index + 1,
|
|
318
319
|
location: formatLocus(location),
|
|
320
|
+
locus: location,
|
|
319
321
|
text,
|
|
320
322
|
kind: obligation.kind,
|
|
321
323
|
sequent: obligation.sequent,
|
|
@@ -829,7 +829,7 @@ const createPrinter = (hyps: Hyp[] = []) => {
|
|
|
829
829
|
export const printExpression = (hyps: Hyp[], expression: Expr) =>
|
|
830
830
|
createPrinter(hyps).printExpr(expression);
|
|
831
831
|
|
|
832
|
-
export const
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
832
|
+
export const printSequent = (sequent: Sequent) => createPrinter().printSequent(sequent);
|
|
833
|
+
|
|
834
|
+
export const formatObligation = (sequent: Sequent) =>
|
|
835
|
+
renderDoc(format("@[<b0>%a@]", printSequent(sequent))).trimEnd();
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// OCaml's Marshal format, ported from runtime/intern.c and runtime/extern.c, for the values tlapm
|
|
2
|
+
// keeps in its fingerprints file: integers, strings, floats and blocks. It writes no sharing, which
|
|
3
|
+
// OCaml reads the same.
|
|
4
|
+
|
|
5
|
+
import { TlaProofError } from "./errors";
|
|
6
|
+
|
|
7
|
+
export interface OcamlBlock {
|
|
8
|
+
tag: number;
|
|
9
|
+
fields: OcamlValue[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface OcamlFloat {
|
|
13
|
+
float: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type OcamlValue = number | string | OcamlBlock | OcamlFloat;
|
|
17
|
+
|
|
18
|
+
const MAGIC_NUMBER_SMALL = 0x8495a6be;
|
|
19
|
+
|
|
20
|
+
const CODE = {
|
|
21
|
+
int8: 0x0,
|
|
22
|
+
int16: 0x1,
|
|
23
|
+
int32: 0x2,
|
|
24
|
+
int64: 0x3,
|
|
25
|
+
shared8: 0x4,
|
|
26
|
+
shared16: 0x5,
|
|
27
|
+
shared32: 0x6,
|
|
28
|
+
block32: 0x8,
|
|
29
|
+
string8: 0x9,
|
|
30
|
+
string32: 0xa,
|
|
31
|
+
doubleBig: 0xb,
|
|
32
|
+
doubleLittle: 0xc,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const PREFIX = { smallInt: 0x40, smallString: 0x20, smallBlock: 0x80 };
|
|
36
|
+
|
|
37
|
+
const HEADER_SIZE = 20;
|
|
38
|
+
|
|
39
|
+
export const block = (tag: number, ...fields: OcamlValue[]): OcamlBlock => ({ tag, fields });
|
|
40
|
+
|
|
41
|
+
export const isBlock = (value: OcamlValue): value is OcamlBlock =>
|
|
42
|
+
typeof value === "object" && "tag" in value;
|
|
43
|
+
|
|
44
|
+
// Reads the value marshaled at offset, and returns where the next one starts.
|
|
45
|
+
export const readMarshaled = (bytes: Uint8Array, offset: number) => {
|
|
46
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
47
|
+
if (bytes.length < offset + HEADER_SIZE || view.getUint32(offset) !== MAGIC_NUMBER_SMALL)
|
|
48
|
+
throw new TlaProofError("corrupted fingerprint file");
|
|
49
|
+
const end = offset + HEADER_SIZE + view.getUint32(offset + 4);
|
|
50
|
+
const objects: OcamlValue[] = [];
|
|
51
|
+
const state = { position: offset + HEADER_SIZE };
|
|
52
|
+
const take = (length: number) => {
|
|
53
|
+
const start = state.position;
|
|
54
|
+
state.position += length;
|
|
55
|
+
if (state.position > end) throw new TlaProofError("corrupted fingerprint file");
|
|
56
|
+
return start;
|
|
57
|
+
};
|
|
58
|
+
const decoder = new TextDecoder();
|
|
59
|
+
const readString = (length: number) => {
|
|
60
|
+
const start = take(length);
|
|
61
|
+
const value = decoder.decode(bytes.subarray(start, start + length));
|
|
62
|
+
objects.push(value);
|
|
63
|
+
return value;
|
|
64
|
+
};
|
|
65
|
+
const readBlock = (tag: number, size: number): OcamlBlock => {
|
|
66
|
+
const value = block(tag);
|
|
67
|
+
if (size > 0) objects.push(value);
|
|
68
|
+
for (let index = 0; index < size; index++) value.fields.push(read());
|
|
69
|
+
return value;
|
|
70
|
+
};
|
|
71
|
+
const readShared = (distance: number) => objects[objects.length - distance];
|
|
72
|
+
const read = (): OcamlValue => {
|
|
73
|
+
const code = bytes[take(1)];
|
|
74
|
+
if (code >= PREFIX.smallBlock) return readBlock(code & 0xf, (code >> 4) & 0x7);
|
|
75
|
+
if (code >= PREFIX.smallInt) return code & 0x3f;
|
|
76
|
+
if (code >= PREFIX.smallString) return readString(code & 0x1f);
|
|
77
|
+
switch (code) {
|
|
78
|
+
case CODE.int8:
|
|
79
|
+
return view.getInt8(take(1));
|
|
80
|
+
case CODE.int16:
|
|
81
|
+
return view.getInt16(take(2));
|
|
82
|
+
case CODE.int32:
|
|
83
|
+
return view.getInt32(take(4));
|
|
84
|
+
case CODE.int64:
|
|
85
|
+
return Number(view.getBigInt64(take(8)));
|
|
86
|
+
case CODE.shared8:
|
|
87
|
+
return readShared(view.getUint8(take(1)));
|
|
88
|
+
case CODE.shared16:
|
|
89
|
+
return readShared(view.getUint16(take(2)));
|
|
90
|
+
case CODE.shared32:
|
|
91
|
+
return readShared(view.getUint32(take(4)));
|
|
92
|
+
case CODE.block32: {
|
|
93
|
+
const header = view.getUint32(take(4));
|
|
94
|
+
return readBlock(header & 0xff, header >>> 10);
|
|
95
|
+
}
|
|
96
|
+
case CODE.string8:
|
|
97
|
+
return readString(view.getUint8(take(1)));
|
|
98
|
+
case CODE.string32:
|
|
99
|
+
return readString(view.getUint32(take(4)));
|
|
100
|
+
case CODE.doubleBig:
|
|
101
|
+
case CODE.doubleLittle: {
|
|
102
|
+
const value = { float: view.getFloat64(take(8), code === CODE.doubleLittle) };
|
|
103
|
+
objects.push(value);
|
|
104
|
+
return value;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
throw new TlaProofError("corrupted fingerprint file");
|
|
108
|
+
};
|
|
109
|
+
return { value: read(), next: end };
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const writeMarshaled = (value: OcamlValue) => {
|
|
113
|
+
const bytes: number[] = [];
|
|
114
|
+
const sizes = { objects: 0, words32: 0, words64: 0 };
|
|
115
|
+
const pushInteger = (integer: number, length: number) => {
|
|
116
|
+
for (let shift = (length - 1) * 8; shift >= 0; shift -= 8)
|
|
117
|
+
bytes.push((integer >>> shift) & 0xff);
|
|
118
|
+
};
|
|
119
|
+
const encoder = new TextEncoder();
|
|
120
|
+
const write = (inner: OcamlValue) => {
|
|
121
|
+
if (typeof inner === "number") {
|
|
122
|
+
if (inner >= 0 && inner < 0x40) return bytes.push(PREFIX.smallInt + inner);
|
|
123
|
+
if (inner >= -0x80 && inner < 0x80) return bytes.push(CODE.int8, inner & 0xff);
|
|
124
|
+
if (inner >= -0x8000 && inner < 0x8000) {
|
|
125
|
+
bytes.push(CODE.int16);
|
|
126
|
+
return pushInteger(inner, 2);
|
|
127
|
+
}
|
|
128
|
+
bytes.push(CODE.int32);
|
|
129
|
+
return pushInteger(inner, 4);
|
|
130
|
+
}
|
|
131
|
+
sizes.objects++;
|
|
132
|
+
if (typeof inner === "string") {
|
|
133
|
+
const encoded = encoder.encode(inner);
|
|
134
|
+
if (encoded.length < 0x20) bytes.push(PREFIX.smallString + encoded.length);
|
|
135
|
+
else if (encoded.length < 0x100) bytes.push(CODE.string8, encoded.length);
|
|
136
|
+
else {
|
|
137
|
+
bytes.push(CODE.string32);
|
|
138
|
+
pushInteger(encoded.length, 4);
|
|
139
|
+
}
|
|
140
|
+
bytes.push(...encoded);
|
|
141
|
+
sizes.words32 += 1 + Math.floor((encoded.length + 4) / 4);
|
|
142
|
+
sizes.words64 += 1 + Math.floor((encoded.length + 8) / 8);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (!isBlock(inner)) {
|
|
146
|
+
const float = new DataView(new ArrayBuffer(8));
|
|
147
|
+
float.setFloat64(0, inner.float, true);
|
|
148
|
+
bytes.push(CODE.doubleLittle, ...new Uint8Array(float.buffer));
|
|
149
|
+
sizes.words32 += 3;
|
|
150
|
+
sizes.words64 += 2;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const size = inner.fields.length;
|
|
154
|
+
if (size === 0) sizes.objects--;
|
|
155
|
+
else {
|
|
156
|
+
sizes.words32 += 1 + size;
|
|
157
|
+
sizes.words64 += 1 + size;
|
|
158
|
+
}
|
|
159
|
+
if (inner.tag < 16 && size < 8) bytes.push(PREFIX.smallBlock + inner.tag + (size << 4));
|
|
160
|
+
else {
|
|
161
|
+
bytes.push(CODE.block32);
|
|
162
|
+
pushInteger(size * 1024 + inner.tag, 4);
|
|
163
|
+
}
|
|
164
|
+
inner.fields.forEach(write);
|
|
165
|
+
};
|
|
166
|
+
write(value);
|
|
167
|
+
const header = new DataView(new ArrayBuffer(HEADER_SIZE));
|
|
168
|
+
[MAGIC_NUMBER_SMALL, bytes.length, sizes.objects, sizes.words32, sizes.words64].forEach(
|
|
169
|
+
(field, index) => header.setUint32(index * 4, field),
|
|
170
|
+
);
|
|
171
|
+
return new Uint8Array([...new Uint8Array(header.buffer), ...bytes]);
|
|
172
|
+
};
|
package/src/prove/decide-pool.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { TlaProverError, TlaUnsupportedError } from "../errors";
|
|
4
4
|
import { spawnWorker, type WorkerHandle } from "../worker";
|
|
5
|
-
import type { DecideOptions,
|
|
5
|
+
import type { DecideOptions, Decision } from "./verdict";
|
|
6
6
|
|
|
7
7
|
export interface DecideRequest {
|
|
8
8
|
prover: string;
|
|
@@ -10,15 +10,15 @@ export interface DecideRequest {
|
|
|
10
10
|
timeLimitMs: number;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
// A backend's
|
|
13
|
+
// A backend's decision, or the error that prove turns into a result.
|
|
14
14
|
export type DecideResponse =
|
|
15
|
-
|
|
|
15
|
+
| Decision
|
|
16
16
|
| { error: { name: "TlaProverError" | "TlaUnsupportedError"; message: string } };
|
|
17
17
|
|
|
18
|
-
interface
|
|
18
|
+
interface PendingDecision {
|
|
19
19
|
request: DecideRequest;
|
|
20
20
|
priority: number;
|
|
21
|
-
resolve: (
|
|
21
|
+
resolve: (decision: Decision) => void;
|
|
22
22
|
reject: (error: unknown) => void;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -28,15 +28,15 @@ export interface DecidePool {
|
|
|
28
28
|
text: string,
|
|
29
29
|
options: DecideOptions,
|
|
30
30
|
priority: number,
|
|
31
|
-
) => Promise<
|
|
31
|
+
) => Promise<Decision>;
|
|
32
32
|
// Rejects every decision not yet made with reason, and stops the workers.
|
|
33
33
|
terminate: (reason: unknown) => void;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export const createDecidePool = async (count: number): Promise<DecidePool> => {
|
|
37
37
|
const workers: WorkerHandle[] = [];
|
|
38
|
-
const queue:
|
|
39
|
-
const running = new Map<number,
|
|
38
|
+
const queue: PendingDecision[] = [];
|
|
39
|
+
const running = new Map<number, PendingDecision>();
|
|
40
40
|
const idle: number[] = [];
|
|
41
41
|
const state: { failure: { reason: unknown } | undefined } = { failure: undefined };
|
|
42
42
|
const dispatch = () => {
|
|
@@ -56,7 +56,7 @@ export const createDecidePool = async (count: number): Promise<DecidePool> => {
|
|
|
56
56
|
const decision = running.get(index);
|
|
57
57
|
running.delete(index);
|
|
58
58
|
idle.push(index);
|
|
59
|
-
if ("verdict" in response) decision?.resolve(response
|
|
59
|
+
if ("verdict" in response) decision?.resolve(response);
|
|
60
60
|
else {
|
|
61
61
|
const ErrorClass =
|
|
62
62
|
response.error.name === "TlaProverError" ? TlaProverError : TlaUnsupportedError;
|
package/src/prove/deciders.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { SmtParseError, TlaProverError } from "../errors";
|
|
|
5
5
|
import { decideIsabelle } from "./isabelle/decide";
|
|
6
6
|
import { decidePtl } from "./ptl/decide";
|
|
7
7
|
import { decideSmt } from "./smt/solver/solver";
|
|
8
|
-
import type { DecideOptions, Verdict } from "./verdict";
|
|
8
|
+
import type { DecideOptions, Decision, Verdict } from "./verdict";
|
|
9
9
|
import { decideZenon } from "./zenon/decide";
|
|
10
10
|
|
|
11
11
|
// Z3 rejects malformed input with an error, and tlapm counts that as a failure.
|
|
@@ -25,3 +25,9 @@ export const DECIDERS: Record<string, (text: string, options: DecideOptions) =>
|
|
|
25
25
|
isabelle: decideIsabelle,
|
|
26
26
|
ls4: decidePtl,
|
|
27
27
|
};
|
|
28
|
+
|
|
29
|
+
export const decide = (prover: string, text: string, options: DecideOptions): Decision => {
|
|
30
|
+
const start = performance.now();
|
|
31
|
+
const verdict = DECIDERS[prover](text, options);
|
|
32
|
+
return { verdict, timeUsedMs: performance.now() - start };
|
|
33
|
+
};
|
|
@@ -128,14 +128,18 @@ const getSuccessors = (integer: string) => {
|
|
|
128
128
|
return `${"succ[".repeat(count)}0${"]".repeat(count)}`;
|
|
129
129
|
};
|
|
130
130
|
|
|
131
|
-
//
|
|
132
|
-
//
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
131
|
+
// thy_header: the theory's first lines, which in the theory of a module's proofs include one for
|
|
132
|
+
// Isabelle to print once it parses the theory.
|
|
133
|
+
const getTheoryHeader = (name: string, isVerbose: boolean) => [
|
|
134
|
+
"(* automatically generated -- do not edit manually *)",
|
|
135
|
+
`theory ${name} imports Constant Zenon begin`,
|
|
136
|
+
...(isVerbose ? ['ML_command \\<open> writeln ("*** TLAPS PARSED\\n"); \\<close>'] : []),
|
|
137
|
+
HEADER,
|
|
138
|
+
];
|
|
139
|
+
|
|
140
|
+
// pp_print_expr on an obligation, after Backend.Prep has shipped it: the lemma, and whether it
|
|
141
|
+
// assumes anything.
|
|
142
|
+
const printLemma = (sequent: Sequent) => {
|
|
139
143
|
const context = createContext();
|
|
140
144
|
const adjoin = (name: string) => pushName(context, pickle(name));
|
|
141
145
|
const bump = () => pushName(context, "");
|
|
@@ -411,7 +415,7 @@ export const encodeIsabelle = (
|
|
|
411
415
|
|
|
412
416
|
// pp_print_sequent_outer: the obligation's sequent as the fixes, assumes and shows of a lemma. A
|
|
413
417
|
// pragma's definition ends it, without the goal.
|
|
414
|
-
const
|
|
418
|
+
const printSequent = (sequent: Sequent) => {
|
|
415
419
|
const lines: string[] = [];
|
|
416
420
|
for (const hyp of sequent.context) {
|
|
417
421
|
switch (hyp.kind) {
|
|
@@ -453,25 +457,56 @@ export const encodeIsabelle = (
|
|
|
453
457
|
return [...lines, `shows "${printExpr(sequent.active)}"`].join("\n");
|
|
454
458
|
};
|
|
455
459
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
460
|
+
try {
|
|
461
|
+
return { text: printSequent(sequent), isAssumed: state.isAssumed };
|
|
462
|
+
} catch (error) {
|
|
463
|
+
if (!(error instanceof TlaUnsupportedError)) throw error;
|
|
464
|
+
throw new TlaProverError(`isabelle : unsupported operator ${error.message}`);
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
// thy_temp: the theory tlapm writes for Isabelle to prove obligation id, with the tactic of the
|
|
469
|
+
// method that selects Isabelle.
|
|
470
|
+
export const encodeIsabelle = (
|
|
471
|
+
id: number,
|
|
472
|
+
sequent: Sequent,
|
|
473
|
+
tactic: string,
|
|
474
|
+
theoryName: string,
|
|
475
|
+
): string => {
|
|
476
|
+
const lemma = printLemma(sequent);
|
|
464
477
|
return [
|
|
465
|
-
|
|
466
|
-
`theory ${theoryName} imports Constant Zenon begin`,
|
|
467
|
-
HEADER,
|
|
478
|
+
...getTheoryHeader(theoryName, false),
|
|
468
479
|
`lemma ob'${id}:`,
|
|
469
|
-
`${lemma}(is "PROP ?ob'${id}")`,
|
|
480
|
+
`${lemma.text}(is "PROP ?ob'${id}")`,
|
|
470
481
|
"proof -",
|
|
471
482
|
`show "PROP ?ob'${id}"`,
|
|
472
|
-
`${
|
|
483
|
+
`${lemma.isAssumed ? "using assms " : ""}by ${tactic}`,
|
|
473
484
|
"qed",
|
|
474
485
|
"end",
|
|
475
486
|
"",
|
|
476
487
|
].join("\n");
|
|
477
488
|
};
|
|
489
|
+
|
|
490
|
+
interface IsabelleProof {
|
|
491
|
+
id: number;
|
|
492
|
+
sequent: Sequent;
|
|
493
|
+
tactic: string;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// Isabelle.thy_init, thy_write and thy_close: the theory of the proofs Isabelle found for a
|
|
497
|
+
// module's obligations, which tlapm writes beside its fingerprints for -C to check.
|
|
498
|
+
export const encodeIsabelleTheory = (name: string, proofs: IsabelleProof[]) =>
|
|
499
|
+
[
|
|
500
|
+
...getTheoryHeader(name, true),
|
|
501
|
+
...proofs.flatMap((proof) => [
|
|
502
|
+
`lemma ob'${proof.id}:`,
|
|
503
|
+
`${printLemma(proof.sequent).text}(is "PROP ?ob'${proof.id}")`,
|
|
504
|
+
"proof -",
|
|
505
|
+
`ML_command \\<open> writeln "*** TLAPS ENTER ${proof.id}"; \\<close>`,
|
|
506
|
+
`show "PROP ?ob'${proof.id}"`,
|
|
507
|
+
`using assms by ${proof.tactic}`,
|
|
508
|
+
`ML_command \\<open> writeln "*** TLAPS EXIT ${proof.id}"; \\<close> qed`,
|
|
509
|
+
]),
|
|
510
|
+
"end",
|
|
511
|
+
"",
|
|
512
|
+
].join("\n");
|
package/src/prove/prep/defs.ts
CHANGED
|
@@ -8,20 +8,26 @@ import {
|
|
|
8
8
|
type Sequent,
|
|
9
9
|
} from "../../obligations/expression";
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
(hyp.definition.kind === "
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
const createExpander = (isPragmaExpanded: boolean) =>
|
|
12
|
+
createContextMap(shift(0), (current, hyp) => {
|
|
13
|
+
if (
|
|
14
|
+
hyp.kind === "Defn" &&
|
|
15
|
+
((isPragmaExpanded && hyp.definition.kind === "Bpragma") ||
|
|
16
|
+
(hyp.definition.kind === "Operator" && hyp.visibility === "Visible"))
|
|
17
|
+
) {
|
|
18
|
+
return [consSubstitution(substituteExpr(current, hyp.definition.body), current), undefined];
|
|
19
|
+
}
|
|
20
|
+
return [bumpBy(1, current), substituteHyp(current, hyp)];
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const expandWithPragmas = createExpander(true);
|
|
24
|
+
|
|
25
|
+
const expandOperators = createExpander(false);
|
|
21
26
|
|
|
22
27
|
// expand_defs: each visible operator definition and each pragma, whatever its visibility,
|
|
23
|
-
// substitutes into the rest of the obligation and leaves the context.
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
// substitutes into the rest of the obligation and leaves the context. Toolbox.expand_defs, an older
|
|
29
|
+
// copy, leaves the pragmas.
|
|
30
|
+
export const expandDefs = (sequent: Sequent, isPragmaExpanded = true): Sequent => {
|
|
31
|
+
const expanded = (isPragmaExpanded ? expandWithPragmas : expandOperators)(sequent.context);
|
|
26
32
|
return { context: expanded.context, active: substituteExpr(expanded.state, sequent.active) };
|
|
27
33
|
};
|
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import { TlaProverError, TlaUnsupportedError } 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
12
|
if (error instanceof TlaProverError) {
|
|
15
13
|
return { error: { name: "TlaProverError", message: error.message } };
|