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
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
exprifySequent,
|
|
14
14
|
findNamed,
|
|
15
15
|
getAtPrefix,
|
|
16
|
-
|
|
16
|
+
getFact,
|
|
17
|
+
getLocationText,
|
|
17
18
|
getLocusPrefix,
|
|
18
19
|
getScopeHyps,
|
|
19
20
|
mapAccumulate,
|
|
@@ -32,7 +33,7 @@ import {
|
|
|
32
33
|
type Hyp,
|
|
33
34
|
type InstanceDefinition,
|
|
34
35
|
type Locus,
|
|
35
|
-
type
|
|
36
|
+
type Warn,
|
|
36
37
|
type Scope,
|
|
37
38
|
type Sequent,
|
|
38
39
|
type Substitution,
|
|
@@ -70,7 +71,7 @@ type ModuleUnitCore =
|
|
|
70
71
|
proof: Proof;
|
|
71
72
|
}
|
|
72
73
|
| { kind: "Submod"; module: Mule }
|
|
73
|
-
| { kind: "Mutate"; mode: "Use" | "Hide";
|
|
74
|
+
| { kind: "Mutate"; mode: "Use" | "Hide"; usable: Usable }
|
|
74
75
|
| { kind: "Anoninst"; instance: InstanceDefinition; isLocal: boolean };
|
|
75
76
|
|
|
76
77
|
// depth is the size of the context the module was normalized in, which instantiation shifts
|
|
@@ -86,34 +87,29 @@ export interface Mule {
|
|
|
86
87
|
location?: Locus;
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
const
|
|
90
|
-
kind: "Definition",
|
|
91
|
-
definition: { kind: "Operator", name, body: { kind: "Internal", builtin } },
|
|
92
|
-
whereDefined: "Builtin",
|
|
93
|
-
visibility: "Visible",
|
|
94
|
-
isLocal: false,
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
const getBuiltinOperator = (arity: number, name: string, builtin: Builtin): ModuleUnit => ({
|
|
90
|
+
const getBuiltin = (arity: number, name: string, builtin: Builtin): ModuleUnit => ({
|
|
98
91
|
kind: "Definition",
|
|
99
92
|
definition: {
|
|
100
93
|
kind: "Operator",
|
|
101
94
|
name,
|
|
102
|
-
body:
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
95
|
+
body:
|
|
96
|
+
arity === 0
|
|
97
|
+
? { kind: "Internal", builtin }
|
|
98
|
+
: {
|
|
99
|
+
kind: "Lambda",
|
|
100
|
+
params: Array.from({ length: arity }, (_item, index) => ({
|
|
101
|
+
name: `x${index + 1}`,
|
|
102
|
+
shape: 0,
|
|
103
|
+
})),
|
|
104
|
+
body: {
|
|
105
|
+
kind: "Apply",
|
|
106
|
+
operator: { kind: "Internal", builtin },
|
|
107
|
+
args: Array.from({ length: arity }, (_item, index) => ({
|
|
108
|
+
kind: "Ix",
|
|
109
|
+
index: arity - index,
|
|
110
|
+
})),
|
|
111
|
+
},
|
|
112
|
+
},
|
|
117
113
|
},
|
|
118
114
|
whereDefined: "Builtin",
|
|
119
115
|
visibility: "Visible",
|
|
@@ -121,59 +117,55 @@ const getBuiltinOperator = (arity: number, name: string, builtin: Builtin): Modu
|
|
|
121
117
|
});
|
|
122
118
|
|
|
123
119
|
const NATURALS: ModuleUnit[] = [
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
120
|
+
getBuiltin(0, "Nat", "Nat"),
|
|
121
|
+
getBuiltin(2, "+", "Plus"),
|
|
122
|
+
getBuiltin(2, "-", "Minus"),
|
|
123
|
+
getBuiltin(2, "*", "Times"),
|
|
124
|
+
getBuiltin(2, "^", "Exp"),
|
|
125
|
+
getBuiltin(2, "<", "Lt"),
|
|
126
|
+
getBuiltin(2, ">", "Gt"),
|
|
127
|
+
getBuiltin(2, "=<", "Lteq"),
|
|
128
|
+
getBuiltin(2, ">=", "Gteq"),
|
|
129
|
+
getBuiltin(2, "%", "Remainder"),
|
|
130
|
+
getBuiltin(2, "\\div", "Quotient"),
|
|
131
|
+
getBuiltin(2, "..", "Range"),
|
|
136
132
|
];
|
|
137
133
|
|
|
138
|
-
const INTEGERS = [
|
|
139
|
-
...NATURALS,
|
|
140
|
-
getBuiltinConstant("Int", "Int"),
|
|
141
|
-
getBuiltinOperator(1, "-.", "Uminus"),
|
|
142
|
-
];
|
|
134
|
+
const INTEGERS = [...NATURALS, getBuiltin(0, "Int", "Int"), getBuiltin(1, "-.", "Uminus")];
|
|
143
135
|
|
|
144
136
|
const REALS = [
|
|
145
137
|
...INTEGERS,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
138
|
+
getBuiltin(0, "Real", "Real"),
|
|
139
|
+
getBuiltin(2, "/", "Ratio"),
|
|
140
|
+
getBuiltin(0, "Infinity", "Infinity"),
|
|
149
141
|
];
|
|
150
142
|
|
|
151
143
|
const SEQUENCES = [
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
144
|
+
getBuiltin(1, "Seq", "Seq"),
|
|
145
|
+
getBuiltin(1, "Len", "Len"),
|
|
146
|
+
getBuiltin(2, "BSeq", "BSeq"),
|
|
147
|
+
getBuiltin(2, "\\o", "Cat"),
|
|
148
|
+
getBuiltin(2, "Append", "Append"),
|
|
149
|
+
getBuiltin(1, "Head", "Head"),
|
|
150
|
+
getBuiltin(1, "Tail", "Tail"),
|
|
151
|
+
getBuiltin(3, "SubSeq", "SubSeq"),
|
|
152
|
+
getBuiltin(2, "SelectSeq", "SelectSeq"),
|
|
161
153
|
];
|
|
162
154
|
|
|
163
155
|
const TLC = [
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
156
|
+
getBuiltin(2, "Print", "Print"),
|
|
157
|
+
getBuiltin(1, "PrintT", "PrintT"),
|
|
158
|
+
getBuiltin(2, "Assert", "Assert"),
|
|
159
|
+
getBuiltin(0, "JavaTime", "JavaTime"),
|
|
160
|
+
getBuiltin(1, "TLCGet", "TLCGet"),
|
|
161
|
+
getBuiltin(2, "TLCSet", "TLCSet"),
|
|
162
|
+
getBuiltin(2, ":>", "OneArg"),
|
|
163
|
+
getBuiltin(2, "@@", "Extend"),
|
|
164
|
+
getBuiltin(1, "Permutations", "Permutations"),
|
|
165
|
+
getBuiltin(2, "SortSeq", "SortSeq"),
|
|
166
|
+
getBuiltin(1, "RandomElement", "RandomElement"),
|
|
167
|
+
getBuiltin(0, "Any", "Any"),
|
|
168
|
+
getBuiltin(1, "ToString", "ToString"),
|
|
177
169
|
];
|
|
178
170
|
|
|
179
171
|
const getStandard = (name: string, body: ModuleUnit[]): Mule => ({
|
|
@@ -236,36 +228,28 @@ const getUnitHyps = (unit: ModuleUnit): Hyp[] => {
|
|
|
236
228
|
},
|
|
237
229
|
];
|
|
238
230
|
case "Axiom":
|
|
239
|
-
return unit.name === undefined
|
|
240
|
-
? [
|
|
241
|
-
{
|
|
242
|
-
kind: "Fact",
|
|
243
|
-
expression: unit.expression,
|
|
244
|
-
visibility: "Hidden",
|
|
245
|
-
time: "Always",
|
|
246
|
-
location,
|
|
247
|
-
},
|
|
248
|
-
]
|
|
249
|
-
: getNamedFact(unit.name, unit.expression, location);
|
|
250
231
|
case "Theorem": {
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
232
|
+
const expression =
|
|
233
|
+
unit.kind === "Axiom"
|
|
234
|
+
? unit.expression
|
|
235
|
+
: at(
|
|
236
|
+
exprifySequent(
|
|
237
|
+
substituteSequent(shift(-unit.axiomCount), {
|
|
238
|
+
...unit.sequent,
|
|
239
|
+
context: unit.sequent.context.slice(unit.axiomCount),
|
|
240
|
+
}),
|
|
241
|
+
),
|
|
242
|
+
unit,
|
|
243
|
+
);
|
|
256
244
|
return unit.name === undefined
|
|
257
|
-
? [
|
|
258
|
-
: getNamedFact(unit.name,
|
|
245
|
+
? [getFact(expression, "Hidden", "Always", location)]
|
|
246
|
+
: getNamedFact(unit.name, expression, location);
|
|
259
247
|
}
|
|
260
248
|
case "Mutate":
|
|
261
249
|
return unit.mode === "Use"
|
|
262
|
-
? unit.usable.facts.map((fact, index) =>
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
visibility: "Visible",
|
|
266
|
-
time: "Always",
|
|
267
|
-
location,
|
|
268
|
-
}))
|
|
250
|
+
? unit.usable.facts.map((fact, index) =>
|
|
251
|
+
getFact(shiftExpr(index, fact), "Visible", "Always", location),
|
|
252
|
+
)
|
|
269
253
|
: [];
|
|
270
254
|
case "Submod":
|
|
271
255
|
case "Anoninst":
|
|
@@ -289,13 +273,7 @@ const getNamedFact = (name: string, expression: Expr, location: Locus | undefine
|
|
|
289
273
|
isLocal: false,
|
|
290
274
|
location,
|
|
291
275
|
},
|
|
292
|
-
{
|
|
293
|
-
kind: "Fact",
|
|
294
|
-
expression: { kind: "Ix", index: 1, location },
|
|
295
|
-
visibility: "Hidden",
|
|
296
|
-
time: "Always",
|
|
297
|
-
location,
|
|
298
|
-
},
|
|
276
|
+
getFact({ kind: "Ix", index: 1, location }, "Hidden", "Always", location),
|
|
299
277
|
];
|
|
300
278
|
|
|
301
279
|
// Module.Flatten.exports: what an extending module sees, with local definitions inlined like
|
|
@@ -363,11 +341,12 @@ export const getDependencies = (module: Mule) => {
|
|
|
363
341
|
}
|
|
364
342
|
Object.values(value).forEach(addInstances);
|
|
365
343
|
};
|
|
366
|
-
//
|
|
344
|
+
// Leaves out the proofs of theorems.
|
|
367
345
|
const visit = (unit: ModuleUnit) => {
|
|
368
|
-
if (unit.kind
|
|
369
|
-
|
|
370
|
-
|
|
346
|
+
if (unit.kind !== "Submod") {
|
|
347
|
+
addInstances(unit.kind === "Theorem" ? unit.sequent : unit);
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
371
350
|
locals.add(unit.module.name);
|
|
372
351
|
submodules.set(unit.module.name, unit.module);
|
|
373
352
|
addExtendees(unit.module);
|
|
@@ -400,7 +379,7 @@ export interface Pipeline {
|
|
|
400
379
|
generator: Generator;
|
|
401
380
|
salts: Counter;
|
|
402
381
|
latestModules: Map<string, Mule>;
|
|
403
|
-
onWarning:
|
|
382
|
+
onWarning: Warn;
|
|
404
383
|
}
|
|
405
384
|
|
|
406
385
|
const substituteUsable = (substitution: Substitution, usable: Usable): Usable => ({
|
|
@@ -489,7 +468,7 @@ const lambdifyTheorem = (
|
|
|
489
468
|
} catch (error) {
|
|
490
469
|
if (!(error instanceof TlaProofError) || error.failure === undefined) throw error;
|
|
491
470
|
const location = sequent.active.location;
|
|
492
|
-
const message = `${error.failure}\nCould not instantiate the theorem ${name === undefined ? "" : `named: ${name}, `}at: ${
|
|
471
|
+
const message = `${error.failure}\nCould not instantiate the theorem ${name === undefined ? "" : `named: ${name}, `}at: ${getLocationText(location)}`;
|
|
493
472
|
pipeline.onWarning({ text: `${getAtPrefix(location)}[ERROR]${message}`, channel: "stdout" });
|
|
494
473
|
pipeline.onWarning({ text: message, channel: "toolboxOnly" });
|
|
495
474
|
return { context: [], active: at({ kind: "Internal", builtin: "TRUE" }, sequent.active) };
|
|
@@ -697,16 +676,12 @@ const localizeAxioms = (units: ModuleUnit[]) => {
|
|
|
697
676
|
location,
|
|
698
677
|
});
|
|
699
678
|
}
|
|
700
|
-
const hyp
|
|
701
|
-
kind: "
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
? shiftExpr(1, unit.expression)
|
|
705
|
-
: at({ kind: "Ix", index: 2 }, unit),
|
|
706
|
-
visibility: "Visible",
|
|
707
|
-
time: "Always",
|
|
679
|
+
const hyp = getFact(
|
|
680
|
+
unit.name === undefined ? shiftExpr(1, unit.expression) : at({ kind: "Ix", index: 2 }, unit),
|
|
681
|
+
"Visible",
|
|
682
|
+
"Always",
|
|
708
683
|
location,
|
|
709
|
-
|
|
684
|
+
);
|
|
710
685
|
let distance = 0;
|
|
711
686
|
const inserted = tail.map((next): ModuleUnit => {
|
|
712
687
|
const size = distance;
|
|
@@ -1002,7 +977,7 @@ export interface ModuleSummary extends ProofSummary {
|
|
|
1002
977
|
theorems: TheoremSummary[];
|
|
1003
978
|
}
|
|
1004
979
|
|
|
1005
|
-
// Module.Gen.generate
|
|
980
|
+
// Module.Gen.generate.
|
|
1006
981
|
export const generate = (
|
|
1007
982
|
pipeline: Pipeline,
|
|
1008
983
|
context: Hyp[],
|
|
@@ -1031,16 +1006,7 @@ export const generate = (
|
|
|
1031
1006
|
unit.name === undefined
|
|
1032
1007
|
? at(exprifySequent(unit.sequent), unit)
|
|
1033
1008
|
: { kind: "Ix", index: 1, location: unit.location };
|
|
1034
|
-
current = [
|
|
1035
|
-
...named,
|
|
1036
|
-
{
|
|
1037
|
-
kind: "Fact",
|
|
1038
|
-
expression: fact,
|
|
1039
|
-
visibility: "Hidden",
|
|
1040
|
-
time: "Always",
|
|
1041
|
-
location: unit.location,
|
|
1042
|
-
},
|
|
1043
|
-
];
|
|
1009
|
+
current = [...named, getFact(fact, "Hidden", "Always", unit.location)];
|
|
1044
1010
|
continue;
|
|
1045
1011
|
}
|
|
1046
1012
|
case "Submod": {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
// with a character other than a letter or digit, one that starts or ends with a non-letter, or one
|
|
3
|
-
// that a prover reserves becomes a_, the name with each special character spelled out, and a.
|
|
1
|
+
// Tla_parser.pickle: renames an identifier that some backend would reject.
|
|
4
2
|
|
|
5
3
|
import { TlapmBugError } from "../errors";
|
|
6
4
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
// tlapm's method pragmas: the (*{ by (prover:"zenon"; timeout:@) }*) after a definition, which
|
|
2
|
-
// E_parser.read_new_method reads, and
|
|
3
|
-
// (*{ by (zenon) }*), which Method_prs reads.
|
|
1
|
+
// tlapm's method pragmas: the new (*{ by (prover:"zenon"; timeout:@) }*) after a definition, which
|
|
2
|
+
// E_parser.read_new_method reads into a Bpragma, and the old (*{ by (zenon) }*) of Method_prs.
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
type PragmaValue =
|
|
6
5
|
| { kind: "Default" }
|
|
7
6
|
| { kind: "String"; value: string }
|
|
8
7
|
| { kind: "Float"; value: number };
|
|
@@ -70,10 +69,13 @@ const tokenizePragma = (lines: string[], start: Position) => {
|
|
|
70
69
|
return undefined;
|
|
71
70
|
};
|
|
72
71
|
|
|
72
|
+
const isPunct = (token: Token | undefined, text: string) =>
|
|
73
|
+
token?.kind === "Punct" && token.text === text;
|
|
74
|
+
|
|
73
75
|
const getValue = (token: Token | undefined): PragmaValue | undefined => {
|
|
74
76
|
if (token?.kind === "String") return { kind: "String", value: token.text };
|
|
75
77
|
if (token?.kind === "Number") return { kind: "Float", value: Number.parseFloat(token.text) };
|
|
76
|
-
return token
|
|
78
|
+
return isPunct(token, "@") ? { kind: "Default" } : undefined;
|
|
77
79
|
};
|
|
78
80
|
|
|
79
81
|
// The methods of Method_prs's old pragma syntax, by the name Method.prover_meth_of_tac gives them.
|
|
@@ -119,7 +121,6 @@ export const readOldMethod = (lines: string[], start: Position) => {
|
|
|
119
121
|
const tokens = tokenizePragma(lines, start);
|
|
120
122
|
if (!tokens) return undefined;
|
|
121
123
|
let index = 0;
|
|
122
|
-
const isPunct = (text: string) => tokens[index]?.kind === "Punct" && tokens[index].text === text;
|
|
123
124
|
const readTimeout = () => {
|
|
124
125
|
const token = tokens[index];
|
|
125
126
|
if (token?.kind !== "Number") return {};
|
|
@@ -127,7 +128,7 @@ export const readOldMethod = (lines: string[], start: Position) => {
|
|
|
127
128
|
return { timeout: Number.parseFloat(token.text) };
|
|
128
129
|
};
|
|
129
130
|
const readMethod = (): OldMethod | undefined => {
|
|
130
|
-
if (!isPunct("(")) return undefined;
|
|
131
|
+
if (!isPunct(tokens[index], "(")) return undefined;
|
|
131
132
|
index++;
|
|
132
133
|
const name = tokens[index++];
|
|
133
134
|
if (name?.kind !== "Ident") return undefined;
|
|
@@ -140,13 +141,13 @@ export const readOldMethod = (lines: string[], start: Position) => {
|
|
|
140
141
|
}
|
|
141
142
|
if (name.text === "zenon") {
|
|
142
143
|
const timeout = readTimeout();
|
|
143
|
-
if (isPunct("(") && !readMethod()) return undefined;
|
|
144
|
+
if (isPunct(tokens[index], "(") && !readMethod()) return undefined;
|
|
144
145
|
return { name: name.text, ...timeout };
|
|
145
146
|
}
|
|
146
147
|
const known = OLD_METHODS.get(name.text);
|
|
147
148
|
return known === undefined ? undefined : { name: known };
|
|
148
149
|
})();
|
|
149
|
-
if (!method || !isPunct(")")) return undefined;
|
|
150
|
+
if (!method || !isPunct(tokens[index], ")")) return undefined;
|
|
150
151
|
index++;
|
|
151
152
|
return method;
|
|
152
153
|
};
|
|
@@ -161,25 +162,24 @@ export const readNewMethod = (lines: string[], start: Position) => {
|
|
|
161
162
|
const tokens = tokenizePragma(lines, start);
|
|
162
163
|
if (!tokens) return undefined;
|
|
163
164
|
let index = 0;
|
|
164
|
-
const isPunct = (text: string) => tokens[index]?.kind === "Punct" && tokens[index].text === text;
|
|
165
165
|
const groups: PragmaSetting[][] = [];
|
|
166
166
|
while (index < tokens.length) {
|
|
167
167
|
const keyword = tokens[index++];
|
|
168
168
|
if (keyword.kind !== "Ident" || (keyword.text !== "by" && keyword.text !== "set")) {
|
|
169
169
|
return undefined;
|
|
170
170
|
}
|
|
171
|
-
if (!isPunct("(")) return undefined;
|
|
171
|
+
if (!isPunct(tokens[index], "(")) return undefined;
|
|
172
172
|
index++;
|
|
173
173
|
const settings: PragmaSetting[] = [];
|
|
174
174
|
for (;;) {
|
|
175
175
|
const hint = tokens[index++];
|
|
176
|
-
if (hint?.kind !== "Ident" || !isPunct(":")) return undefined;
|
|
176
|
+
if (hint?.kind !== "Ident" || !isPunct(tokens[index], ":")) return undefined;
|
|
177
177
|
index++;
|
|
178
178
|
const value = getValue(tokens[index++]);
|
|
179
179
|
if (!value) return undefined;
|
|
180
180
|
settings.push({ hint: hint.text, value });
|
|
181
|
-
if (isPunct(")")) break;
|
|
182
|
-
if (!isPunct(";")) return undefined;
|
|
181
|
+
if (isPunct(tokens[index], ")")) break;
|
|
182
|
+
if (!isPunct(tokens[index], ";")) return undefined;
|
|
183
183
|
index++;
|
|
184
184
|
}
|
|
185
185
|
index++;
|
|
@@ -478,8 +478,9 @@ const createPrinter = (hyps: Hyp[] = []) => {
|
|
|
478
478
|
),
|
|
479
479
|
);
|
|
480
480
|
case "List": {
|
|
481
|
-
if (expression.bullet === "Refs" && expression.items.length === 0)
|
|
481
|
+
if (expression.bullet === "Refs" && expression.items.length === 0) {
|
|
482
482
|
return atom(format("TRUE"));
|
|
483
|
+
}
|
|
483
484
|
if (expression.bullet === "Refs" && expression.items.length === 1) {
|
|
484
485
|
return formatExpr(expression.items[0]);
|
|
485
486
|
}
|
|
@@ -603,23 +604,17 @@ const createPrinter = (hyps: Hyp[] = []) => {
|
|
|
603
604
|
case "Tuple":
|
|
604
605
|
return atom(format("@[<b2><<%a>>@]", formatDelimited(expression.elements, printExpr)));
|
|
605
606
|
case "Rect":
|
|
607
|
+
case "Record": {
|
|
608
|
+
const separator = expression.kind === "Rect" ? ":" : "|->";
|
|
606
609
|
return atom(
|
|
607
610
|
format(
|
|
608
611
|
"@[<b1>[%a]@]",
|
|
609
612
|
formatDelimited(expression.fields, (field) =>
|
|
610
|
-
format(
|
|
611
|
-
),
|
|
612
|
-
),
|
|
613
|
-
);
|
|
614
|
-
case "Record":
|
|
615
|
-
return atom(
|
|
616
|
-
format(
|
|
617
|
-
"@[<b1>[%a]@]",
|
|
618
|
-
formatDelimited(expression.fields, (field) =>
|
|
619
|
-
format("@[<h>%s |-> %a@]", field.name, printExpr(field.value)),
|
|
613
|
+
format(`@[<h>%s ${separator} %a@]`, field.name, printExpr(field.value)),
|
|
620
614
|
),
|
|
621
615
|
),
|
|
622
616
|
);
|
|
617
|
+
}
|
|
623
618
|
case "Except":
|
|
624
619
|
return atom(
|
|
625
620
|
format(
|
|
@@ -718,12 +713,13 @@ const createPrinter = (hyps: Hyp[] = []) => {
|
|
|
718
713
|
return atom(format(pattern, form.label, printMinimal(inner)));
|
|
719
714
|
}
|
|
720
715
|
const namesDoc = formatDelimited(names, text);
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
716
|
+
const pattern =
|
|
717
|
+
inner.kind === "Atm"
|
|
718
|
+
? "%s(%a)::%a"
|
|
719
|
+
: inner.kind === "Big"
|
|
720
|
+
? "%s(%a)::(%a)"
|
|
721
|
+
: "(%s(%a):: %a)";
|
|
722
|
+
return atom(format(pattern, form.label, namesDoc, printMinimal(inner)));
|
|
727
723
|
}
|
|
728
724
|
}
|
|
729
725
|
};
|
|
@@ -829,7 +825,7 @@ const createPrinter = (hyps: Hyp[] = []) => {
|
|
|
829
825
|
export const printExpression = (hyps: Hyp[], expression: Expr) =>
|
|
830
826
|
createPrinter(hyps).printExpr(expression);
|
|
831
827
|
|
|
832
|
-
export const
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
828
|
+
export const printSequent = (sequent: Sequent) => createPrinter().printSequent(sequent);
|
|
829
|
+
|
|
830
|
+
export const formatObligation = (sequent: Sequent) =>
|
|
831
|
+
renderDoc(format("@[<b0>%a@]", printSequent(sequent))).trimEnd();
|