tla-ts 0.0.8 → 0.0.9-dev.0dd11f695
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 +30 -0
- package/dist/compile.cjs +23 -0
- package/dist/compile.js +23 -0
- package/dist/deciders.cjs +15 -15
- package/dist/deciders.js +40 -40
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +98 -19
- package/dist/index.d.ts +98 -19
- 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 +116 -36
- package/dist/prove.js +116 -36
- package/dist/run.cjs +143 -31
- package/dist/run.js +143 -31
- package/dist/tlapm.cjs +2 -2
- package/dist/tlapm.js +1 -1
- package/dist/transfer.cjs +128 -106
- package/dist/transfer.js +128 -106
- package/dist/worker.cjs +7 -7
- package/dist/worker.js +7 -7
- package/package.json +3 -1
- package/src/ast.ts +7 -21
- package/src/bags.ts +99 -99
- package/src/builtins.ts +44 -75
- package/src/bundled-modules.ts +1 -8
- package/src/check.ts +605 -311
- package/src/cli/options.ts +12 -3
- package/src/cli/run.ts +2 -2
- package/src/cli/runtime-invariants.ts +135 -0
- package/src/cli/shared.ts +20 -9
- package/src/cli/tlc-arguments.ts +646 -0
- package/src/cli/tlc-usage.ts +362 -0
- package/src/cli/tlc.ts +571 -185
- package/src/cli/typescript.ts +26 -0
- package/src/cli/xml-exporter.ts +4 -10
- package/src/codegen.ts +190 -51
- package/src/config.ts +101 -68
- package/src/coverage.ts +855 -0
- package/src/dependencies.ts +340 -24
- package/src/dfid.ts +636 -0
- package/src/environment.ts +289 -109
- package/src/errors.ts +142 -45
- package/src/evaluate.ts +734 -980
- package/src/exit-codes.ts +37 -1
- package/src/index.ts +3 -0
- package/src/instances.ts +85 -9
- package/src/java-overrides.ts +2 -12
- package/src/json-reader.ts +456 -0
- package/src/json.ts +262 -139
- package/src/levels.ts +2 -3
- package/src/lexer.ts +150 -70
- package/src/liveness-checker.ts +10 -18
- package/src/liveness.ts +122 -64
- package/src/parallel-worker.ts +14 -10
- package/src/parallel.ts +41 -17
- package/src/parser.ts +436 -90
- package/src/pcal/ast.ts +7 -28
- package/src/pcal/parse.ts +11 -39
- package/src/pcal/tokenize.ts +4 -20
- package/src/pcal/translate.ts +10 -42
- package/src/pcal/validate.ts +3 -21
- package/src/pretty-print.ts +1 -2
- package/src/prover/smt/solver/solver.ts +31 -27
- package/src/randomization.ts +84 -35
- package/src/resolve.ts +18 -60
- package/src/runtime.ts +11 -4
- package/src/sany/builtins.ts +3 -4
- package/src/sany/generator.ts +128 -176
- package/src/sany/levels.ts +6 -30
- package/src/sany/lexer.ts +7 -23
- package/src/sany/linter.ts +31 -29
- package/src/sany/modules.ts +1 -5
- package/src/sany/nodes.ts +4 -28
- package/src/sany/parse-error.ts +44 -100
- package/src/sany/report.ts +25 -40
- package/src/sany/selectors.ts +8 -22
- package/src/sany/source.ts +8 -15
- package/src/sany/xml.ts +11 -42
- package/src/search.ts +550 -150
- package/src/simulate.ts +694 -0
- package/src/spec-description.ts +167 -49
- package/src/standard-definitions.ts +2 -3
- package/src/standard-modules.ts +264 -68
- package/src/state-graph.ts +51 -18
- package/src/subexpressions.ts +31 -5
- package/src/successors.ts +269 -85
- package/src/symmetry.ts +59 -147
- package/src/tableau.ts +1 -2
- package/src/tlc/fingerprint.ts +226 -151
- package/src/tlc/jar-data.ts +113 -6
- package/src/tlc/messages.ts +122 -37
- package/src/tlc/order.ts +56 -82
- package/src/tlc/random.ts +16 -16
- package/src/tlc/replay.ts +564 -212
- package/src/tlc/summary.ts +2 -4
- package/src/tlc/tlc-operators.ts +81 -36
- package/src/tlc/tlcext-operators.ts +138 -117
- package/src/tlc/trace-spec.ts +273 -0
- package/src/tlc/value-stream.ts +143 -0
- package/src/tlc/version.ts +2 -4
- package/src/typescript/actions.ts +494 -0
- package/src/typescript/collections.ts +615 -0
- package/src/typescript/compile.ts +70 -0
- package/src/typescript/context.ts +106 -0
- package/src/typescript/emit.ts +122 -0
- package/src/typescript/expressions.ts +508 -0
- package/src/typescript/formula.ts +160 -0
- package/src/typescript/functions.ts +295 -0
- package/src/typescript/model.ts +164 -0
- package/src/typescript/names.ts +116 -0
- package/src/typescript/program.ts +51 -0
- package/src/typescript/properties.ts +148 -0
- package/src/typescript/scope.ts +117 -0
- package/src/typescript/steps.ts +175 -0
- package/src/typescript/types.ts +178 -0
- package/src/values.ts +910 -318
package/src/resolve.ts
CHANGED
|
@@ -22,8 +22,7 @@ import {
|
|
|
22
22
|
} from "./ast";
|
|
23
23
|
import { formatRange, TlaSyntaxError, type SanyError } from "./errors";
|
|
24
24
|
|
|
25
|
-
//
|
|
26
|
-
// and a NEW symbol has a kind for each level.
|
|
25
|
+
// A parameter is also a bound name, and a NEW symbol has a kind for each level.
|
|
27
26
|
export type SymbolKind =
|
|
28
27
|
| "Builtin"
|
|
29
28
|
| "Constant"
|
|
@@ -34,8 +33,7 @@ export type SymbolKind =
|
|
|
34
33
|
| "Parameter"
|
|
35
34
|
| `New${NewSymbol["level"]}`;
|
|
36
35
|
|
|
37
|
-
//
|
|
38
|
-
// holds the arity of each parameter of a defined operator.
|
|
36
|
+
// Two symbols at one range are one node to SANY.
|
|
39
37
|
interface Binding {
|
|
40
38
|
kind: SymbolKind;
|
|
41
39
|
arity: number;
|
|
@@ -49,8 +47,6 @@ export interface ModuleSymbol extends Binding {
|
|
|
49
47
|
|
|
50
48
|
export type Symbols = Map<string, ModuleSymbol>;
|
|
51
49
|
|
|
52
|
-
// A named theorem or proof step whose parts a name such as foo!lab or <1>2!1 selects. isInProof
|
|
53
|
-
// holds while SANY analyzes the proof of the theorem or step.
|
|
54
50
|
interface Goal {
|
|
55
51
|
statement: Expression | AssumeProve;
|
|
56
52
|
isSuffices: boolean;
|
|
@@ -68,13 +64,11 @@ interface LocalName extends Binding {
|
|
|
68
64
|
isNonFact?: boolean;
|
|
69
65
|
}
|
|
70
66
|
|
|
71
|
-
// A name the module binds, from position on.
|
|
72
67
|
interface ModuleBinding extends Binding {
|
|
73
68
|
position: SourceLocation;
|
|
74
69
|
isPending?: boolean;
|
|
75
70
|
}
|
|
76
71
|
|
|
77
|
-
// What SANY reports while it goes on analyzing a unit of a module, and the scope it analyzes it in.
|
|
78
72
|
interface Unit {
|
|
79
73
|
imported: Symbols;
|
|
80
74
|
getInstance: (instance: Instance) => InstancedModule;
|
|
@@ -87,15 +81,11 @@ interface Unit {
|
|
|
87
81
|
bindings: Map<string, ModuleBinding>;
|
|
88
82
|
errors: SanyError[];
|
|
89
83
|
warnings: SanyError[];
|
|
90
|
-
// In a definition, a named theorem, or a numbered step.
|
|
91
84
|
hasLabelScope: boolean;
|
|
92
|
-
// In the scope of a NEW in a nested ASSUME.
|
|
93
85
|
isLabelForbidden: boolean;
|
|
94
86
|
isInExcept: boolean;
|
|
95
|
-
// The names bound since the innermost definition, label, or step, which a label must take.
|
|
96
87
|
labelParams: string[];
|
|
97
88
|
labels: Set<string>;
|
|
98
|
-
// In a definition generated for a LET INSTANCE, or a subexpression analyzed where it is defined.
|
|
99
89
|
isGenerated: boolean;
|
|
100
90
|
}
|
|
101
91
|
|
|
@@ -114,8 +104,6 @@ type Reference = Expression & { kind: "Identifier" | "Apply" | "Subexpression" }
|
|
|
114
104
|
|
|
115
105
|
export const LOCAL_RESOLUTION = { kind: "Local" } as const;
|
|
116
106
|
|
|
117
|
-
// The subexpressions that names select, and for a name that selects none, the error SANY reports and
|
|
118
|
-
// the arguments it analyzes before it.
|
|
119
107
|
export const selections = new WeakSet<Expression>();
|
|
120
108
|
export const selectionErrors = new WeakMap<Expression, SelectionError>();
|
|
121
109
|
|
|
@@ -151,8 +139,6 @@ const lookupLocal = (scope: LocalName | undefined, name: string) => {
|
|
|
151
139
|
return undefined;
|
|
152
140
|
};
|
|
153
141
|
|
|
154
|
-
// A name the module binds before the unit and before the range, which a copy of a subexpression
|
|
155
|
-
// that a reference selects keeps from its definition.
|
|
156
142
|
const getModuleBinding = (name: string, unit: Unit, range: SourceRange | undefined) => {
|
|
157
143
|
const binding = unit.bindings.get(name);
|
|
158
144
|
return binding &&
|
|
@@ -165,8 +151,7 @@ const getModuleBinding = (name: string, unit: Unit, range: SourceRange | undefin
|
|
|
165
151
|
const isSameRange = (left: SourceRange | undefined, right: SourceRange | undefined) =>
|
|
166
152
|
left !== undefined && right !== undefined && formatRange(left) === formatRange(right);
|
|
167
153
|
|
|
168
|
-
//
|
|
169
|
-
// or arity, and warns of any other duplicate. A symbol SANY never sees, such as a generated one, binds.
|
|
154
|
+
// A symbol SANY never sees, such as a generated one, binds.
|
|
170
155
|
const isBindable = (name: string, current: Binding | undefined, added: Binding, unit: Unit) => {
|
|
171
156
|
if (current === undefined) return true;
|
|
172
157
|
if (isSameRange(current.range, added.range)) return false;
|
|
@@ -214,7 +199,6 @@ const bindName = (
|
|
|
214
199
|
? { ...added, name, parent: scope }
|
|
215
200
|
: scope;
|
|
216
201
|
|
|
217
|
-
// Binds the names of a module from the unit on.
|
|
218
202
|
const bindModuleName = (name: string, added: Binding, unit: Unit) => {
|
|
219
203
|
if (isBindable(name, unit.bindings.get(name), added, unit)) {
|
|
220
204
|
unit.bindings.set(name, { ...added, position: unit.location });
|
|
@@ -276,7 +260,6 @@ const findSymbol = (name: string, unit: Unit): ModuleSymbol | undefined => {
|
|
|
276
260
|
const findBinding = (name: string, scope: LocalName | undefined, unit: Unit): Binding | undefined =>
|
|
277
261
|
lookupLocal(scope, name) ?? findSymbol(name, unit);
|
|
278
262
|
|
|
279
|
-
// SANY reports a name at the range of its text.
|
|
280
263
|
const getNameRange = (location: SourceLocation, name: string): SourceRange => ({
|
|
281
264
|
module: location.range?.module ?? "",
|
|
282
265
|
start: location,
|
|
@@ -315,8 +298,6 @@ export const getOperandIndex = (operand: number | "<<" | ">>", count: number) =>
|
|
|
315
298
|
return count === 2 ? 1 : -1;
|
|
316
299
|
};
|
|
317
300
|
|
|
318
|
-
// The parts of a name such as F(x)!l(y), each with its own arguments. counts holds the number each
|
|
319
|
-
// part takes, when a part before the last takes some.
|
|
320
301
|
export const getNameSelectors = (
|
|
321
302
|
name: string,
|
|
322
303
|
args: Expression[],
|
|
@@ -343,8 +324,6 @@ const getBoundSets = (bounds: Bound[]) =>
|
|
|
343
324
|
.filter((bound, index) => index === 0 || bounds[index - 1].set !== bound.set)
|
|
344
325
|
.map((bound) => bound.set);
|
|
345
326
|
|
|
346
|
-
// The names a binder binds, its body, and the sets it binds them to, which a selector such as !1
|
|
347
|
-
// chooses from.
|
|
348
327
|
export const getBinder = (
|
|
349
328
|
expression: Expression,
|
|
350
329
|
): { names: string[]; body: Expression; sets: Expression[] } | undefined => {
|
|
@@ -387,7 +366,6 @@ export const getBinder = (
|
|
|
387
366
|
}
|
|
388
367
|
};
|
|
389
368
|
|
|
390
|
-
// The operands that a selector such as !1 chooses from, where they do not depend on bound names.
|
|
391
369
|
export const getOperands = (expression: Expression): Expression[] | undefined => {
|
|
392
370
|
switch (expression.kind) {
|
|
393
371
|
case "Apply":
|
|
@@ -482,10 +460,9 @@ const getOperandName = (operand: number | "<<" | ">>") =>
|
|
|
482
460
|
|
|
483
461
|
const SCOPE_MESSAGE = "within the scope of a declaration\n from outside that declaration's scope.";
|
|
484
462
|
|
|
485
|
-
//
|
|
486
|
-
//
|
|
487
|
-
//
|
|
488
|
-
// selected depends on bound names. A fact may select an ASSUME/PROVE or a NEW clause.
|
|
463
|
+
// A part in the scope of a NEW in its ASSUME may be selected only within the theorem's proof, or
|
|
464
|
+
// only after the proof of a SUFFICES step. A label takes its own arguments, and an operand must
|
|
465
|
+
// exist, unless the part selected depends on bound names.
|
|
489
466
|
const checkSelection = (
|
|
490
467
|
reference: Reference,
|
|
491
468
|
selectors: Selector[],
|
|
@@ -689,7 +666,6 @@ const checkLabel = (label: LabelExpression, scope: LocalName | undefined, unit:
|
|
|
689
666
|
unit.labels.add(label.name);
|
|
690
667
|
};
|
|
691
668
|
|
|
692
|
-
// Checks a name that selects part of a theorem or step, and tells whether it is one.
|
|
693
669
|
const checkReference = (
|
|
694
670
|
expression: Expression,
|
|
695
671
|
scope: LocalName | undefined,
|
|
@@ -796,10 +772,9 @@ const markRecursiveConstructions = (expression: Expression, name: string): void
|
|
|
796
772
|
getChildren(expression).forEach((child) => markRecursiveConstructions(child, name));
|
|
797
773
|
};
|
|
798
774
|
|
|
799
|
-
//
|
|
800
|
-
//
|
|
801
|
-
//
|
|
802
|
-
// nothing else does. recursive holds the declarations of this level. Tells whether to bind the name.
|
|
775
|
+
// SANY binds the parameters, reports a name already bound unless a RECURSIVE declaration of this
|
|
776
|
+
// level awaits the definition, analyzes the body, and then binds the name. A function binds the
|
|
777
|
+
// bound names before it looks up the name, and binds the name only where nothing else does.
|
|
803
778
|
const resolveDefinition = (
|
|
804
779
|
definition: Definition,
|
|
805
780
|
scope: LocalName | undefined,
|
|
@@ -928,8 +903,8 @@ const findInstance = (name: string, scope: LocalName | undefined, unit: Unit) =>
|
|
|
928
903
|
return binding?.kind === "Instance" ? { name: prefix, arity: binding.arity } : undefined;
|
|
929
904
|
};
|
|
930
905
|
|
|
931
|
-
//
|
|
932
|
-
//
|
|
906
|
+
// SANY reports an INSTANCE given the wrong number of arguments at its name, as in K!C or
|
|
907
|
+
// K(1, 2)!C, and goes on without analyzing them.
|
|
933
908
|
const isInstanceArityReported = (
|
|
934
909
|
expression: Expression,
|
|
935
910
|
scope: LocalName | undefined,
|
|
@@ -955,9 +930,7 @@ const isInstanceArityReported = (
|
|
|
955
930
|
return true;
|
|
956
931
|
};
|
|
957
932
|
|
|
958
|
-
//
|
|
959
|
-
// takes an operator in its place, which a name, a built-in operator, or a LAMBDA of the parameter's
|
|
960
|
-
// arity must give. OpDefNode#match then reports each argument that gives no such operator, or one
|
|
933
|
+
// OpDefNode#match reports each argument that gives no operator of the parameter's arity, or one
|
|
961
934
|
// whose own parameters take operators. tla-ts lets an operator whose parameters it does not know
|
|
962
935
|
// take any argument.
|
|
963
936
|
const resolveApply = (
|
|
@@ -1063,13 +1036,11 @@ const resolveApply = (
|
|
|
1063
1036
|
});
|
|
1064
1037
|
};
|
|
1065
1038
|
|
|
1066
|
-
// An argument may name an operator that takes arguments of its own.
|
|
1067
1039
|
const resolveArgument = (arg: Expression, scope: LocalName | undefined, unit: Unit) => {
|
|
1068
1040
|
if (arg.kind === "Identifier") getSymbolArity(arg, arg.name, scope, unit);
|
|
1069
1041
|
else resolveExpression(arg, scope, unit);
|
|
1070
1042
|
};
|
|
1071
1043
|
|
|
1072
|
-
// Reports the error of a name that selects nothing, after the arguments SANY analyzes before it.
|
|
1073
1044
|
const isSelectionReported = (expression: Expression, scope: LocalName | undefined, unit: Unit) => {
|
|
1074
1045
|
const failed = selectionErrors.get(expression);
|
|
1075
1046
|
if (!failed) return false;
|
|
@@ -1245,9 +1216,8 @@ const resolveExpression = (
|
|
|
1245
1216
|
}
|
|
1246
1217
|
};
|
|
1247
1218
|
|
|
1248
|
-
//
|
|
1249
|
-
//
|
|
1250
|
-
// and analyzes any other fact as an expression.
|
|
1219
|
+
// A fact that is a name may also select an ASSUME/PROVE or a NEW clause or name a theorem or
|
|
1220
|
+
// assumption. SANY analyzes any other fact as an expression.
|
|
1251
1221
|
const checkFacts = (facts: Fact[], scope: LocalName | undefined, unit: Unit) =>
|
|
1252
1222
|
facts.forEach((fact) => {
|
|
1253
1223
|
if (
|
|
@@ -1314,8 +1284,6 @@ const resolveStatement = (
|
|
|
1314
1284
|
return scope;
|
|
1315
1285
|
};
|
|
1316
1286
|
|
|
1317
|
-
// SANY resolves the expressions of a proof, while its facts and DEF clauses may also name
|
|
1318
|
-
// theorems, assumptions, and modules.
|
|
1319
1287
|
const resolveProof = (proof: Proof | undefined, scope: LocalName | undefined, outer: Unit) => {
|
|
1320
1288
|
const unit = outer.hasLabelScope ? { ...outer, hasLabelScope: false } : outer;
|
|
1321
1289
|
if (proof?.kind === "By") checkFacts(proof.facts, scope, unit);
|
|
@@ -1440,16 +1408,12 @@ const resolveTheorem = (theorem: Theorem, unit: Unit) => {
|
|
|
1440
1408
|
if (goal) goal.isInProof = false;
|
|
1441
1409
|
};
|
|
1442
1410
|
|
|
1443
|
-
// The declarations of the module an INSTANCE instantiates, the names the INSTANCE adds, and the
|
|
1444
|
-
// module that instantiates it.
|
|
1445
1411
|
interface InstancedModule {
|
|
1446
1412
|
declarations: Declaration[];
|
|
1447
1413
|
symbols: Symbols;
|
|
1448
1414
|
instancer: string;
|
|
1449
1415
|
}
|
|
1450
1416
|
|
|
1451
|
-
// What SANY reports at a location as it links a module, such as a conflict between the modules it
|
|
1452
|
-
// extends.
|
|
1453
1417
|
export interface ModuleReport {
|
|
1454
1418
|
location: SourceLocation;
|
|
1455
1419
|
errors: SanyError[];
|
|
@@ -1459,13 +1423,10 @@ export interface ModuleReport {
|
|
|
1459
1423
|
export interface ModuleUnit {
|
|
1460
1424
|
imported: Symbols;
|
|
1461
1425
|
getInstance: (instance: Instance) => InstancedModule;
|
|
1462
|
-
// The built-in operators and the names of the enclosing and extended modules.
|
|
1463
1426
|
bound: Symbols;
|
|
1464
1427
|
definitions: Map<string, Definition>;
|
|
1465
1428
|
getKey: (definition: Definition) => string;
|
|
1466
|
-
// The names each INSTANCE adds.
|
|
1467
1429
|
instanced: Map<Instance, Symbols>;
|
|
1468
|
-
// The theorems and assumptions the extended and instantiated modules export.
|
|
1469
1430
|
facts: Set<string>;
|
|
1470
1431
|
reports: ModuleReport[];
|
|
1471
1432
|
warnings: SanyError[];
|
|
@@ -1579,7 +1540,6 @@ const resolveInstance = (instance: Instance, scope: LocalName | undefined, unit:
|
|
|
1579
1540
|
);
|
|
1580
1541
|
};
|
|
1581
1542
|
|
|
1582
|
-
// tla-ts reports what SANY goes on after with an INSTANCE of the module.
|
|
1583
1543
|
export const resolveSubstitutions = (
|
|
1584
1544
|
instance: Instance,
|
|
1585
1545
|
declarations: Declaration[],
|
|
@@ -1612,10 +1572,9 @@ export const resolveSubstitutions = (
|
|
|
1612
1572
|
});
|
|
1613
1573
|
};
|
|
1614
1574
|
|
|
1615
|
-
// SANY reports the errors of every unit
|
|
1616
|
-
//
|
|
1617
|
-
//
|
|
1618
|
-
// unit reported before it. Returns the errors.
|
|
1575
|
+
// SANY reports the errors of every unit in the order of the units, after the warnings. A unit
|
|
1576
|
+
// reports what SANY goes on after, and throws the error that stops it. An error tla-ts cannot
|
|
1577
|
+
// word as SANY does yields to the errors the unit reported before it.
|
|
1619
1578
|
export const collectSemanticErrors = (
|
|
1620
1579
|
units: {
|
|
1621
1580
|
location: SourceLocation;
|
|
@@ -1658,8 +1617,7 @@ export const collectSemanticErrors = (
|
|
|
1658
1617
|
return errors;
|
|
1659
1618
|
};
|
|
1660
1619
|
|
|
1661
|
-
// SANY
|
|
1662
|
-
// that no definition follows at the end. Returns the errors.
|
|
1620
|
+
// SANY reports a RECURSIVE declaration that no definition follows at the end.
|
|
1663
1621
|
export const resolveModule = (module: Module, unit: ModuleUnit) => {
|
|
1664
1622
|
const symbols = createSymbols(module, unit.imported);
|
|
1665
1623
|
const facts = new Set([
|
package/src/runtime.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getTlcFingerprint } from "./tlc/fingerprint";
|
|
2
2
|
import { createJavaRandom, type JavaRandom } from "./tlc/random";
|
|
3
3
|
import { createFunction, createRecord, type Value } from "./values";
|
|
4
|
+
import type { SpecAction } from "./spec-description";
|
|
4
5
|
import type { TlcVersion } from "./tlc/version";
|
|
5
6
|
|
|
6
7
|
export interface CheckerRuntime {
|
|
@@ -8,14 +9,16 @@ export interface CheckerRuntime {
|
|
|
8
9
|
getBehavior: (state: Value[]) => Value[][];
|
|
9
10
|
getSpecification: () => Value;
|
|
10
11
|
counterExample: Value | undefined;
|
|
12
|
+
deferred: ((next: Value[]) => void) | undefined;
|
|
11
13
|
setLivenessSource: (index: number | undefined) => void;
|
|
12
14
|
getCurrentState: () => Value[] | undefined;
|
|
13
15
|
getFingerprint: (state: Value[]) => bigint;
|
|
14
16
|
getRandom: () => JavaRandom;
|
|
17
|
+
getSimulationValue:
|
|
18
|
+
| ((key: string, state: (Value | undefined)[] | undefined) => Value | undefined)
|
|
19
|
+
| undefined;
|
|
15
20
|
evaluateAtStartup: <Result>(evaluate: () => Result) => Result;
|
|
16
|
-
pause: () => void;
|
|
17
|
-
// Prints a warning TLC raises while it evaluates, with its message code. TLC prints each
|
|
18
|
-
// distinct warning once.
|
|
21
|
+
pause: (() => void) | undefined;
|
|
19
22
|
warn: (code: number, text: string) => void;
|
|
20
23
|
// TLC's -nowarning turns the warnings off, and with them the shortcut that evaluates the rest
|
|
21
24
|
// of an action once it assigns every variable, since that shortcut skips a warning.
|
|
@@ -26,6 +29,7 @@ export interface CheckerRuntime {
|
|
|
26
29
|
version: TlcVersion;
|
|
27
30
|
seed: bigint;
|
|
28
31
|
isSeen: (state: Value[]) => boolean;
|
|
32
|
+
getSuccessorAction: (state: Value[], next: Value[]) => SpecAction | undefined;
|
|
29
33
|
generatedStates: number;
|
|
30
34
|
distinctStates: number;
|
|
31
35
|
initialStates: number;
|
|
@@ -54,10 +58,13 @@ export const createRuntime = (checkDeadlock: boolean, seed = 0n): CheckerRuntime
|
|
|
54
58
|
getBehavior: () => [],
|
|
55
59
|
getSpecification: () => createRecord([]),
|
|
56
60
|
counterExample: undefined,
|
|
61
|
+
deferred: undefined,
|
|
57
62
|
isSeen: () => false,
|
|
63
|
+
getSuccessorAction: () => undefined,
|
|
58
64
|
setLivenessSource: () => {},
|
|
59
65
|
getCurrentState: () => undefined,
|
|
60
66
|
getFingerprint: getTlcFingerprint,
|
|
67
|
+
getSimulationValue: undefined,
|
|
61
68
|
getRandom: () => {
|
|
62
69
|
const state = phase.isStartup ? undefined : runtime.getCurrentState();
|
|
63
70
|
if (state === undefined) return startupRandom;
|
|
@@ -76,7 +83,7 @@ export const createRuntime = (checkDeadlock: boolean, seed = 0n): CheckerRuntime
|
|
|
76
83
|
phase.isStartup = wasStartup;
|
|
77
84
|
}
|
|
78
85
|
},
|
|
79
|
-
pause:
|
|
86
|
+
pause: undefined,
|
|
80
87
|
warn: () => {},
|
|
81
88
|
isWarningEnabled: true,
|
|
82
89
|
isTool: false,
|
package/src/sany/builtins.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FormalParamNode, LevelFields, OpDefNode, SanyLocation } from "./nodes";
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
//
|
|
3
|
+
// Name, arity, level, maximum argument levels and argument weights. SANY leaves the levels of
|
|
4
|
+
// "." and \neg unset.
|
|
5
5
|
const BUILTIN_OPERATORS: [string, number, number, number[] | undefined, number[] | undefined][] = [
|
|
6
6
|
["STRING", 0, 0, [], []],
|
|
7
7
|
["FALSE", 0, 0, [], []],
|
|
@@ -98,8 +98,7 @@ export const createLevelFields = (id: number): LevelFields => ({
|
|
|
98
98
|
argLevelConstraints: new Map(),
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
-
//
|
|
102
|
-
// for a builtin numbers the operator, then its phony parameters.
|
|
101
|
+
// SANY's order: OpDefNode's constructor numbers each builtin, then its phony parameters.
|
|
103
102
|
export const createBuiltins = (getId: () => number) =>
|
|
104
103
|
BUILTIN_OPERATORS.map(([name, arity, level, maxLevels, weights]): OpDefNode => {
|
|
105
104
|
const id = getId();
|