tla-ts 0.0.3-dev.d9ff6f2 → 0.0.3-dev.e8bef80
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/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +166 -40
- package/dist/index.d.ts +166 -40
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +2 -2
- package/dist/parallel.cjs +1 -1
- package/dist/parallel.js +2 -2
- package/dist/run-cli.cjs +1351 -22
- package/dist/run-cli.js +1351 -22
- package/dist/transfer.cjs +83 -34
- package/dist/transfer.js +83 -34
- package/package.json +5 -1
- package/src/ast.ts +55 -7
- package/src/bags.ts +4 -7
- package/src/builtins.ts +29 -11
- package/src/bundled-modules.ts +3 -3
- package/src/canonical.ts +4 -3
- package/src/check.ts +1331 -367
- package/src/cli.ts +8 -1
- package/src/codegen.ts +68 -21
- package/src/config.ts +226 -207
- package/src/environment.ts +423 -127
- package/src/errors.ts +168 -9
- package/src/evaluate.ts +720 -177
- package/src/exit-codes.ts +6 -24
- package/src/index.ts +1 -0
- package/src/instances.ts +3 -1
- package/src/java-overrides.ts +104 -25
- package/src/levels.ts +149 -31
- package/src/lexer.ts +122 -29
- package/src/live-check.ts +204 -148
- package/src/liveness.ts +191 -122
- package/src/obligation-expression.ts +2 -2
- package/src/obligation-source.ts +2 -0
- package/src/parallel-worker.ts +6 -1
- package/src/parallel.ts +57 -6
- package/src/parser.ts +428 -141
- package/src/pcal-ast.ts +770 -0
- package/src/pcal-parse.ts +1523 -0
- package/src/pcal-tokenize.ts +516 -0
- package/src/pcal-translate.ts +1230 -0
- package/src/pcal-validate.ts +454 -0
- package/src/randomization.ts +24 -7
- package/src/resolve.ts +1436 -459
- package/src/run-cli.ts +1166 -181
- package/src/runtime.ts +16 -0
- package/src/sany-builtins.ts +147 -0
- package/src/sany-generator.ts +3128 -0
- package/src/sany-levels.ts +1208 -0
- package/src/sany-lexer.ts +545 -0
- package/src/sany-linter.ts +122 -0
- package/src/sany-modules.ts +1398 -0
- package/src/sany-nodes.ts +463 -0
- package/src/sany-parse-error.ts +2161 -0
- package/src/sany-report.ts +356 -0
- package/src/sany-selectors.ts +738 -0
- package/src/sany-source.ts +248 -0
- package/src/sany-xml.ts +1017 -0
- package/src/spec-description.ts +25 -5
- package/src/standard-modules.ts +203 -146
- package/src/standard-ranges.ts +116 -0
- package/src/state-graph.ts +29 -6
- package/src/subexpressions.ts +221 -161
- package/src/substitution-levels.ts +38 -17
- package/src/successors.ts +161 -167
- package/src/symmetry.ts +168 -50
- package/src/tableau.ts +3 -1
- package/src/tlc-ext.ts +13 -17
- package/src/tlc-messages.ts +329 -0
- package/src/tlc-module.ts +49 -21
- package/src/tlc-modules.ts +0 -4
- package/src/tlc-order.ts +55 -9
- package/src/tlc-random.ts +28 -3
- package/src/tlc-replay.ts +655 -0
- package/src/tlc-version.ts +18 -0
- package/src/transfer.ts +15 -3
- package/src/value-sources.ts +29 -0
- package/src/values.ts +680 -255
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { Declaration, Definition, Expression, SourceLocation } from "./ast";
|
|
2
|
-
import {
|
|
1
|
+
import type { Declaration, Definition, Expression, SourceLocation, Theorem } from "./ast";
|
|
2
|
+
import { createSanyError, formatRange } from "./errors";
|
|
3
3
|
import {
|
|
4
|
+
ACTION_LEVEL,
|
|
5
|
+
analyzeAssumeProve,
|
|
4
6
|
createLevelAnalyzer,
|
|
5
7
|
getArgumentKey,
|
|
6
8
|
MAX_LEVEL,
|
|
@@ -24,6 +26,7 @@ interface ModuleContext {
|
|
|
24
26
|
variables: string[];
|
|
25
27
|
definitions: Definition[];
|
|
26
28
|
assumptions: Expression[];
|
|
29
|
+
theorems: Theorem[];
|
|
27
30
|
getDefinition: (name: string) => Definition | undefined;
|
|
28
31
|
}
|
|
29
32
|
|
|
@@ -46,10 +49,7 @@ interface Substituted {
|
|
|
46
49
|
const getMaxLevel = (operator: OperatorLevels, index: number) =>
|
|
47
50
|
operator.maxLevels[index] ?? MAX_LEVEL;
|
|
48
51
|
|
|
49
|
-
export const
|
|
50
|
-
checks: InstanceCheck[],
|
|
51
|
-
getModule: (name: string) => ModuleContext,
|
|
52
|
-
) => {
|
|
52
|
+
export const createInstanceChecker = (getModule: (name: string) => ModuleContext) => {
|
|
53
53
|
const analyzers = new Map<string, ReturnType<typeof createLevelAnalyzer>>();
|
|
54
54
|
const getAnalyzer = (name: string) => {
|
|
55
55
|
const cached = analyzers.get(name);
|
|
@@ -101,17 +101,38 @@ export const checkInstances = (
|
|
|
101
101
|
definition.formals.every((formal) => formal.name !== operator && formal.name !== param),
|
|
102
102
|
),
|
|
103
103
|
);
|
|
104
|
+
const addAssumedLevels = (data: ReturnType<typeof analyzeAssumeProve>) => {
|
|
105
|
+
addLevels(data, () => true);
|
|
106
|
+
module.constants.forEach((constant) => {
|
|
107
|
+
if (data.params.has(constant.name)) {
|
|
108
|
+
putConstraint(levels.constraints, constant.name, ACTION_LEVEL);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
};
|
|
104
112
|
module.assumptions.forEach((assumption) =>
|
|
105
|
-
|
|
113
|
+
addAssumedLevels(analyzer.analyze(assumption, new Map())),
|
|
114
|
+
);
|
|
115
|
+
module.theorems.forEach((theorem) =>
|
|
116
|
+
theorem.statement.kind === "AssumeProve"
|
|
117
|
+
? addAssumedLevels(analyzeAssumeProve(theorem.statement, new Map(), analyzer))
|
|
118
|
+
: addLevels(analyzer.analyze(theorem.statement, new Map()), () => true),
|
|
106
119
|
);
|
|
107
120
|
moduleLevels.set(name, levels);
|
|
108
121
|
return levels;
|
|
109
122
|
};
|
|
110
123
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const
|
|
124
|
+
return (check: InstanceCheck) => {
|
|
125
|
+
const errors = new Map<string, { location: string; message: string }>();
|
|
126
|
+
// SANY reports each error at the whole instance.
|
|
127
|
+
const location = formatRange(
|
|
128
|
+
check.location.range ?? {
|
|
129
|
+
module: check.instancer,
|
|
130
|
+
start: check.location,
|
|
131
|
+
end: check.location,
|
|
132
|
+
},
|
|
133
|
+
);
|
|
134
|
+
const addMessage = (message: string) =>
|
|
135
|
+
errors.set(`${location}\n${message}`, { location, message });
|
|
115
136
|
const instancee = getModule(check.module);
|
|
116
137
|
const levels = getModuleLevels(check.module);
|
|
117
138
|
const analyzer = getAnalyzer(check.instancer);
|
|
@@ -141,14 +162,14 @@ export const checkInstances = (
|
|
|
141
162
|
];
|
|
142
163
|
});
|
|
143
164
|
const getLevelMessage = (name: string, level: number) =>
|
|
144
|
-
`Level error in instantiating module '${check.module}'
|
|
165
|
+
`Level error in instantiating module '${check.module}':\nThe level of the expression or operator substituted for '${name}' \nmust be at most ${level}.`;
|
|
145
166
|
substituted.forEach((item) => {
|
|
146
167
|
if (!levels.isConstant && item.level > item.maximumLevel) {
|
|
147
168
|
addMessage(getLevelMessage(item.name, item.maximumLevel));
|
|
148
169
|
}
|
|
149
170
|
if (!item.isLeibniz) {
|
|
150
171
|
addMessage(
|
|
151
|
-
`Error in instantiating module '${check.module}'
|
|
172
|
+
`Error in instantiating module '${check.module}':\n A non-Leibniz operator substituted for '${item.name}'.`,
|
|
152
173
|
);
|
|
153
174
|
}
|
|
154
175
|
});
|
|
@@ -162,7 +183,7 @@ export const checkInstances = (
|
|
|
162
183
|
const minimum = levels.argConstraints.get(getArgumentKey(item.name, index));
|
|
163
184
|
if (minimum !== undefined && getMaxLevel(operator, index) < minimum) {
|
|
164
185
|
addMessage(
|
|
165
|
-
`Level error in instantiating module '${check.module}'
|
|
186
|
+
`Level error in instantiating module '${check.module}':\nThe level of the argument ${index + 1} of the operator ${operator.name} \nmust be at least ${minimum}.`,
|
|
166
187
|
);
|
|
167
188
|
}
|
|
168
189
|
});
|
|
@@ -175,10 +196,10 @@ export const checkInstances = (
|
|
|
175
196
|
const maximum = getMaxLevel(operator, parameter.index);
|
|
176
197
|
if (argument.level > maximum) {
|
|
177
198
|
addMessage(
|
|
178
|
-
`Level error when instantiating module '${check.module}'
|
|
199
|
+
`Level error when instantiating module '${check.module}':\nThe level of the argument ${parameter.index} of the operator ${parameter.operator}' \nmust be at most ${maximum}.`,
|
|
179
200
|
);
|
|
180
201
|
}
|
|
181
202
|
});
|
|
182
|
-
|
|
183
|
-
|
|
203
|
+
if (errors.size > 0) throw createSanyError([...errors.values()]);
|
|
204
|
+
};
|
|
184
205
|
};
|