tla-ts 0.0.10-dev.a17d6d9fa → 0.0.10-dev.a5705bfbf
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/deciders.cjs +31 -31
- package/dist/deciders.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +1 -1
- package/dist/prove.cjs +64 -64
- package/dist/prove.js +76 -76
- package/dist/run.cjs +42 -42
- package/dist/run.js +44 -44
- package/dist/transfer.cjs +37 -35
- package/dist/transfer.js +43 -41
- package/dist/worker.cjs +7 -7
- package/dist/worker.js +7 -7
- package/package.json +1 -1
- package/src/ast.ts +10 -1
- package/src/check-failure.ts +12 -10
- package/src/check-trace.ts +36 -23
- package/src/check.ts +182 -135
- package/src/cli/tlc-output.ts +17 -2
- package/src/cli/tlc.ts +2 -2
- package/src/codegen.ts +15 -19
- package/src/coverage.ts +190 -1
- package/src/dependencies.ts +19 -6
- package/src/dfid.ts +80 -27
- package/src/environment.ts +30 -1
- package/src/evaluate.ts +254 -59
- package/src/exit-codes.ts +25 -13
- package/src/instances.ts +11 -1
- package/src/levels.ts +48 -7
- package/src/liveness-checker.ts +98 -27
- package/src/liveness.ts +4 -1
- package/src/obligations/source.ts +2 -0
- package/src/parser.ts +3 -0
- package/src/prover/smt/solver/card2bv.ts +7 -4
- package/src/prover/smt/solver/context.ts +20 -4
- package/src/prover/smt/solver/dependent-expr-state.ts +18 -12
- package/src/prover/smt/solver/dt2bv-tactic.ts +36 -20
- package/src/prover/smt/solver/fd-solver.ts +146 -39
- package/src/prover/smt/solver/maxcore.ts +2 -1
- package/src/prover/smt/solver/maxsmt-base.ts +1 -0
- package/src/prover/smt/solver/model-checker.ts +1 -1
- package/src/prover/smt/solver/muz/dl-context.ts +12 -40
- package/src/prover/smt/solver/muz/dl-mk-coi-filter.ts +1 -1
- package/src/prover/smt/solver/muz/dl-rule.ts +6 -7
- package/src/prover/smt/solver/muz/hnf.ts +2 -2
- package/src/prover/smt/solver/muz/horn-tactic.ts +14 -1
- package/src/prover/smt/solver/muz/rule-properties.ts +22 -0
- package/src/prover/smt/solver/muz/spacer-prop-solver.ts +1 -1
- package/src/prover/smt/solver/opt-context.ts +1 -0
- package/src/prover/smt/solver/opt-solver.ts +1 -1
- package/src/prover/smt/solver/parallel-tactic.ts +1 -1
- package/src/prover/smt/solver/qsat.ts +7 -2
- package/src/prover/smt/solver/rewriter-tpl.ts +7 -6
- package/src/prover/smt/solver/sat/inc-sat-solver.ts +45 -26
- package/src/prover/smt/solver/sat/sat-tactic.ts +4 -2
- package/src/prover/smt/solver/sat/sat2goal.ts +10 -7
- package/src/prover/smt/solver/smt-consequences.ts +1 -1
- package/src/prover/smt/solver/smt-kernel.ts +9 -2
- package/src/prover/smt/solver/smtlib-parser.ts +6 -2
- package/src/prover/smt/solver/smtlib-script.ts +197 -73
- package/src/prover/smt/solver/tactic.ts +64 -37
- package/src/resolve.ts +143 -39
- package/src/sany/generator-expressions.ts +2 -0
- package/src/sany/generator-proofs.ts +1 -0
- package/src/search.ts +156 -37
- package/src/simulate.ts +143 -150
- package/src/spec-description.ts +3 -0
- package/src/standard-modules.ts +41 -16
- package/src/subexpressions.ts +168 -63
- package/src/successors.ts +33 -11
- package/src/symmetry.ts +1 -0
- package/src/tlc/replay.ts +64 -41
- package/src/trace-liveness.ts +529 -0
- package/src/typed-tier.ts +20 -6
- package/src/values.ts +15 -1
package/src/search.ts
CHANGED
|
@@ -17,7 +17,11 @@ import type {
|
|
|
17
17
|
import { parseConfig, type ConfigValue, type ModelConfig } from "./config";
|
|
18
18
|
import {
|
|
19
19
|
addCoverageRelation,
|
|
20
|
+
buildCoverage,
|
|
21
|
+
createCoverage,
|
|
22
|
+
createCoverageEnvironment,
|
|
20
23
|
getCoverageLabel,
|
|
24
|
+
getCoverageReport,
|
|
21
25
|
runAtCoverageNode,
|
|
22
26
|
type Coverage,
|
|
23
27
|
type CoverageKind,
|
|
@@ -67,10 +71,12 @@ import { expandTemporal, getLevel, type ScopedExpression, type TemporalProperty
|
|
|
67
71
|
import { getLiveExpressions } from "./liveness-checker";
|
|
68
72
|
import { prettyPrint } from "./pretty-print";
|
|
69
73
|
import { getPossibleCounts, type CheckerRuntime } from "./runtime";
|
|
74
|
+
import { createIncompleteSuccessorError } from "./successors";
|
|
70
75
|
import {
|
|
71
76
|
getSpecDescription,
|
|
72
77
|
getSpecificationValue,
|
|
73
78
|
getSubscriptVariables,
|
|
79
|
+
type SpecAction,
|
|
74
80
|
type SpecDescription,
|
|
75
81
|
} from "./spec-description";
|
|
76
82
|
import { getRepresentative, getSymmetryGroup, type Images } from "./symmetry";
|
|
@@ -83,6 +89,7 @@ import {
|
|
|
83
89
|
withHeadline,
|
|
84
90
|
} from "./tlc/messages";
|
|
85
91
|
import { createTlcOrder } from "./tlc/order";
|
|
92
|
+
import { getPrimedRanges, walkSuccessors } from "./tlc/replay";
|
|
86
93
|
import { getTlcFingerprint, getTlcFingerprints, setFingerprintPolynomial } from "./tlc/fingerprint";
|
|
87
94
|
import type { TlcVersion } from "./tlc/version";
|
|
88
95
|
import {
|
|
@@ -680,7 +687,7 @@ const getStateChecks = (named: NamedExpression[], environment: Environment): Sta
|
|
|
680
687
|
);
|
|
681
688
|
});
|
|
682
689
|
|
|
683
|
-
const isUnchangedFor = (stateCheck: StateCheck, state:
|
|
690
|
+
const isUnchangedFor = (stateCheck: StateCheck, state: State, parent: Value[] | undefined) => {
|
|
684
691
|
const variables = stateCheck.variables;
|
|
685
692
|
if (!parent || !variables) return false;
|
|
686
693
|
for (let index = 0; index < variables.length; index++) {
|
|
@@ -698,23 +705,34 @@ const isWideConfigValue = (value: ConfigValue): boolean =>
|
|
|
698
705
|
? WIDE_CHARACTER.test(value.value)
|
|
699
706
|
: value.kind === "Set" && value.elements.some(isWideConfigValue);
|
|
700
707
|
|
|
701
|
-
const isWideExpression = (expression: Expression): boolean =>
|
|
702
|
-
(expression.kind === "
|
|
703
|
-
|
|
704
|
-
|
|
708
|
+
const isWideExpression = (expression: Expression, checked: Set<Expression>): boolean => {
|
|
709
|
+
if (expression.kind === "Selection") {
|
|
710
|
+
if (checked.has(expression.expression)) return false;
|
|
711
|
+
checked.add(expression.expression);
|
|
712
|
+
}
|
|
713
|
+
return (
|
|
714
|
+
(expression.kind === "String" && WIDE_CHARACTER.test(expression.value)) ||
|
|
715
|
+
(expression.kind === "Apply" && DESERIALIZERS.has(expression.operator)) ||
|
|
716
|
+
getChildren(expression).some((child) => isWideExpression(child, checked))
|
|
717
|
+
);
|
|
718
|
+
};
|
|
705
719
|
|
|
706
720
|
// TLC fingerprints a string by the low byte of each character, so it merges states whose strings differ only above U+00FF.
|
|
707
|
-
const hasWideString = (config: ModelConfig, environment: Environment) =>
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
(definition
|
|
716
|
-
definition.
|
|
721
|
+
const hasWideString = (config: ModelConfig, environment: Environment) => {
|
|
722
|
+
const checked = new Set<Expression>();
|
|
723
|
+
return (
|
|
724
|
+
config.constants.some(
|
|
725
|
+
(constant) =>
|
|
726
|
+
isWideConfigValue(constant.value) || (constant.args ?? []).some(isWideConfigValue),
|
|
727
|
+
) ||
|
|
728
|
+
[...environment.definitions.values()].some(
|
|
729
|
+
(definition) =>
|
|
730
|
+
isWideExpression(definition.body, checked) ||
|
|
731
|
+
(definition.kind === "Function" &&
|
|
732
|
+
definition.bounds.some((bound) => isWideExpression(bound.set, checked))),
|
|
733
|
+
)
|
|
717
734
|
);
|
|
735
|
+
};
|
|
718
736
|
|
|
719
737
|
export interface Search {
|
|
720
738
|
properties: Properties;
|
|
@@ -760,10 +778,10 @@ export interface Search {
|
|
|
760
778
|
tracing: Environment,
|
|
761
779
|
addFingerprint: () => boolean,
|
|
762
780
|
) => boolean;
|
|
763
|
-
satisfiesConstraints: (state:
|
|
781
|
+
satisfiesConstraints: (state: State, parent?: Value[]) => boolean;
|
|
764
782
|
findFailedInitialPredicate: (state: Value[]) => NamedExpression | undefined;
|
|
765
783
|
findViolatedActionProperty: (state: Value[], next: Value[]) => ActionProperty | undefined;
|
|
766
|
-
satisfiesActionConstraints: (state: Value[], next:
|
|
784
|
+
satisfiesActionConstraints: (state: Value[], next: State) => boolean;
|
|
767
785
|
getExcludingConstraints: (state: Value[], next: Value[]) => string[];
|
|
768
786
|
trackStatePossible: (state: Value[]) => void;
|
|
769
787
|
trackActionPossible: (state: Value[], next: Value[]) => void;
|
|
@@ -916,7 +934,13 @@ export const prepareSearch = (options: CheckOptions) => {
|
|
|
916
934
|
const created = createCheckEnvironment(config, options, options.onPrint ?? console.log);
|
|
917
935
|
const specification = created.specification;
|
|
918
936
|
reportStartup(specification, config, options.onProgress);
|
|
919
|
-
const
|
|
937
|
+
const coverage =
|
|
938
|
+
options.coverage === undefined
|
|
939
|
+
? undefined
|
|
940
|
+
: createCoverage(specification.environment.variables.length);
|
|
941
|
+
const environment = coverage
|
|
942
|
+
? createCoverageEnvironment(specification.environment, coverage)
|
|
943
|
+
: specification.environment;
|
|
920
944
|
let description: SpecDescription | undefined;
|
|
921
945
|
const getDescription = () =>
|
|
922
946
|
(description ??= getSpecDescription(config, environment, specification.instanceActions));
|
|
@@ -931,9 +955,71 @@ export const prepareSearch = (options: CheckOptions) => {
|
|
|
931
955
|
specification.moduleOperators,
|
|
932
956
|
specification.runtimeInvariants,
|
|
933
957
|
);
|
|
934
|
-
|
|
958
|
+
const getCoverage = () =>
|
|
959
|
+
coverage &&
|
|
960
|
+
getCoverageReport(
|
|
961
|
+
coverage,
|
|
962
|
+
environment,
|
|
963
|
+
specification.variableLocations,
|
|
964
|
+
search?.getTlcOrder() ?? [],
|
|
965
|
+
);
|
|
966
|
+
return { config, specification, environment, search, getDescription, coverage, getCoverage };
|
|
967
|
+
};
|
|
968
|
+
|
|
969
|
+
export interface CoveredAction extends SpecAction {
|
|
970
|
+
node: number;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
export const STOP_WALK = new Error("The walk stopped");
|
|
974
|
+
|
|
975
|
+
export const addActionCoverage = (
|
|
976
|
+
coverage: Coverage,
|
|
977
|
+
environment: Environment,
|
|
978
|
+
description: SpecDescription,
|
|
979
|
+
) => {
|
|
980
|
+
const addRelations = (kind: "init" | "next", actions: SpecAction[]) =>
|
|
981
|
+
actions.map((action): CoveredAction => ({
|
|
982
|
+
...action,
|
|
983
|
+
node: addCoverageRelation(
|
|
984
|
+
coverage,
|
|
985
|
+
kind,
|
|
986
|
+
getCoverageLabel(action.name, action.expression, environment),
|
|
987
|
+
action.expression,
|
|
988
|
+
action.scope,
|
|
989
|
+
),
|
|
990
|
+
}));
|
|
991
|
+
const inits = addRelations("init", description.inits);
|
|
992
|
+
const actions = addRelations("next", description.actions);
|
|
993
|
+
buildCoverage(coverage, environment, getPrimedRanges(actions, environment));
|
|
994
|
+
return { inits, actions };
|
|
935
995
|
};
|
|
936
996
|
|
|
997
|
+
export const walkCoveredSuccessors = (
|
|
998
|
+
coverage: Coverage,
|
|
999
|
+
action: CoveredAction,
|
|
1000
|
+
state: Value[],
|
|
1001
|
+
environment: Environment,
|
|
1002
|
+
onState: (successor: Value[]) => void,
|
|
1003
|
+
onIncomplete = (partial: State, name: string | undefined): void => {
|
|
1004
|
+
throw createIncompleteSuccessorError(partial, name, environment);
|
|
1005
|
+
},
|
|
1006
|
+
) =>
|
|
1007
|
+
walkSuccessors(
|
|
1008
|
+
action,
|
|
1009
|
+
action.node,
|
|
1010
|
+
state,
|
|
1011
|
+
environment,
|
|
1012
|
+
(successor) => {
|
|
1013
|
+
coverage.primary[action.node]++;
|
|
1014
|
+
onState(successor);
|
|
1015
|
+
},
|
|
1016
|
+
(partial) => {
|
|
1017
|
+
coverage.primary[action.node]++;
|
|
1018
|
+
onIncomplete(partial, action.name);
|
|
1019
|
+
return true;
|
|
1020
|
+
},
|
|
1021
|
+
);
|
|
1022
|
+
|
|
937
1023
|
export const reportAssumptionViolation = (
|
|
938
1024
|
assumptions: Assumption[],
|
|
939
1025
|
environment: Environment,
|
|
@@ -1070,6 +1156,12 @@ export const createSearch = (
|
|
|
1070
1156
|
);
|
|
1071
1157
|
const coveredActionConstraints = getCoveredChecks("constraint", actionConstraints);
|
|
1072
1158
|
const coveredConstraints = getCoveredChecks("constraint", namedConstraints);
|
|
1159
|
+
const coveredConstraintChecks = new Map(
|
|
1160
|
+
coveredConstraints.map((check) => [check.expression, check]),
|
|
1161
|
+
);
|
|
1162
|
+
const constraintPredicates = [
|
|
1163
|
+
...new Map(constraints.map((constraint) => [constraint.predicate, constraint])).values(),
|
|
1164
|
+
];
|
|
1073
1165
|
const coveredInitialPredicates = getCoveredChecks("implied", properties.initialPredicates, false);
|
|
1074
1166
|
const coveredActionProperties = getCoveredChecks(
|
|
1075
1167
|
"implied",
|
|
@@ -1079,8 +1171,8 @@ export const createSearch = (
|
|
|
1079
1171
|
const evaluateCovered = (
|
|
1080
1172
|
covered: Coverage,
|
|
1081
1173
|
check: CoveredCheck,
|
|
1082
|
-
state:
|
|
1083
|
-
next:
|
|
1174
|
+
state: State,
|
|
1175
|
+
next: State | undefined,
|
|
1084
1176
|
) => {
|
|
1085
1177
|
try {
|
|
1086
1178
|
return runAtCoverageNode(covered, check.node, () =>
|
|
@@ -1090,7 +1182,15 @@ export const createSearch = (
|
|
|
1090
1182
|
return undefined;
|
|
1091
1183
|
}
|
|
1092
1184
|
};
|
|
1093
|
-
const
|
|
1185
|
+
const holdsReplayed = (
|
|
1186
|
+
covered: CoveredCheck | undefined,
|
|
1187
|
+
expression: Expression,
|
|
1188
|
+
context: Context,
|
|
1189
|
+
) =>
|
|
1190
|
+
coverage && covered
|
|
1191
|
+
? runAtCoverageNode(coverage, covered.node, () => holdsLikeTlc(covered.expression, context))
|
|
1192
|
+
: holdsLikeTlc(expression, context);
|
|
1193
|
+
const satisfiesCovered = (checks: CoveredCheck[], state: State, next?: State) => {
|
|
1094
1194
|
if (!coverage) return undefined;
|
|
1095
1195
|
for (const check of checks) {
|
|
1096
1196
|
const value = evaluateCovered(coverage, check, state, next);
|
|
@@ -1244,7 +1344,7 @@ export const createSearch = (
|
|
|
1244
1344
|
)
|
|
1245
1345
|
.join("")
|
|
1246
1346
|
: prettyPrint(formatValue(getViewValue(expression, state)));
|
|
1247
|
-
const holdsActionConstraint = (constraint: NamedExpression, state: Value[], next:
|
|
1347
|
+
const holdsActionConstraint = (constraint: NamedExpression, state: Value[], next: State) =>
|
|
1248
1348
|
holdsLikeTlc(
|
|
1249
1349
|
constraint.expression,
|
|
1250
1350
|
getContext(environment, state, next),
|
|
@@ -1376,43 +1476,62 @@ export const createSearch = (
|
|
|
1376
1476
|
}
|
|
1377
1477
|
},
|
|
1378
1478
|
checkReplayedInitialState: (state, tracing, addFingerprint, onViolated) => {
|
|
1379
|
-
const holdsIn = (
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1479
|
+
const holdsIn = (
|
|
1480
|
+
covered: CoveredCheck | undefined,
|
|
1481
|
+
expression: Expression,
|
|
1482
|
+
scope: Scope | undefined,
|
|
1483
|
+
) => holdsReplayed(covered, expression, getContext(tracing, state, undefined, scope));
|
|
1484
|
+
const isInModel = constraintPredicates.every((constraint) =>
|
|
1485
|
+
holdsIn(
|
|
1486
|
+
coveredConstraintChecks.get(constraint.predicate),
|
|
1487
|
+
constraint.predicate,
|
|
1488
|
+
constraint.scope,
|
|
1489
|
+
),
|
|
1490
|
+
);
|
|
1491
|
+
if (isInModel) addFingerprint();
|
|
1384
1492
|
for (const invariant of invariantPredicates) {
|
|
1385
|
-
|
|
1493
|
+
const covered = coveredInvariantChecks.get(invariant.predicate);
|
|
1494
|
+
if (holdsIn(covered, invariant.predicate, invariant.scope)) continue;
|
|
1386
1495
|
onViolated({ status: "invariant-violation", name: invariant.name });
|
|
1387
1496
|
}
|
|
1388
1497
|
const predicate = properties.initialPredicates.find(
|
|
1389
|
-
(check) => !holdsIn(check.expression, check.scope),
|
|
1498
|
+
(check, index) => !holdsIn(coveredInitialPredicates[index], check.expression, check.scope),
|
|
1390
1499
|
);
|
|
1391
1500
|
if (predicate) onViolated({ status: "liveness-violation", name: predicate.name });
|
|
1392
1501
|
},
|
|
1393
1502
|
checkReplayedSuccessor: (state, next, tracing, addFingerprint) => {
|
|
1394
1503
|
const isInModel =
|
|
1395
|
-
|
|
1396
|
-
|
|
1504
|
+
constraintPredicates.every((constraint) =>
|
|
1505
|
+
holdsReplayed(
|
|
1506
|
+
coveredConstraintChecks.get(constraint.predicate),
|
|
1397
1507
|
constraint.predicate,
|
|
1398
1508
|
getContext(tracing, next, undefined, constraint.scope),
|
|
1399
1509
|
),
|
|
1400
1510
|
) &&
|
|
1401
|
-
actionConstraints.every((constraint) =>
|
|
1402
|
-
|
|
1511
|
+
actionConstraints.every((constraint, index) =>
|
|
1512
|
+
holdsReplayed(
|
|
1513
|
+
coveredActionConstraints[index],
|
|
1514
|
+
constraint.expression,
|
|
1515
|
+
getContext(tracing, state, next, constraint.scope),
|
|
1516
|
+
),
|
|
1403
1517
|
);
|
|
1404
1518
|
// TLC checks the invariants of a successor it has not seen, even outside the model.
|
|
1405
1519
|
const isUnseen = isInModel ? addFingerprint() : true;
|
|
1406
1520
|
return (
|
|
1407
1521
|
(!isUnseen ||
|
|
1408
1522
|
invariantPredicates.every((invariant) =>
|
|
1409
|
-
|
|
1523
|
+
holdsReplayed(
|
|
1524
|
+
coveredInvariantChecks.get(invariant.predicate),
|
|
1410
1525
|
invariant.predicate,
|
|
1411
1526
|
getContext(tracing, next, undefined, invariant.scope),
|
|
1412
1527
|
),
|
|
1413
1528
|
)) &&
|
|
1414
|
-
actionProperties.every((property) =>
|
|
1415
|
-
|
|
1529
|
+
actionProperties.every((property, index) =>
|
|
1530
|
+
holdsReplayed(
|
|
1531
|
+
coveredActionProperties[index],
|
|
1532
|
+
property.box,
|
|
1533
|
+
getContext(tracing, state, next, property.scope),
|
|
1534
|
+
),
|
|
1416
1535
|
)
|
|
1417
1536
|
);
|
|
1418
1537
|
},
|