tla-ts 0.0.10-dev.28c823e4b → 0.0.10-dev.63a6693bd
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/compile.cjs +6 -6
- package/dist/compile.js +10 -10
- package/dist/deciders.cjs +29 -29
- package/dist/deciders.js +40 -40
- package/dist/index.cjs +1 -1
- 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 +54 -54
- package/dist/prove.js +52 -52
- package/dist/run.cjs +42 -42
- package/dist/run.js +44 -44
- package/dist/tlapm.cjs +2 -2
- package/dist/tlapm.js +2 -2
- package/dist/transfer.cjs +39 -39
- package/dist/transfer.js +41 -41
- package/dist/worker.cjs +4 -4
- package/dist/worker.js +4 -4
- package/package.json +1 -1
- package/src/ast.ts +44 -39
- package/src/builtins.ts +4 -13
- package/src/check-failure.ts +116 -0
- package/src/check-trace.ts +282 -0
- package/src/check.ts +152 -518
- package/src/cli/options.ts +6 -31
- package/src/cli/shared.ts +1 -1
- package/src/cli/tlapm.ts +14 -13
- package/src/cli/tlc-arguments.ts +222 -210
- package/src/cli/tlc-output.ts +687 -0
- package/src/cli/tlc-usage.ts +1 -1
- package/src/cli/tlc.ts +34 -701
- package/src/cli/xml-exporter.ts +23 -33
- package/src/codegen.ts +5 -10
- package/src/coverage.ts +3 -10
- package/src/dependencies.ts +8 -13
- package/src/dfid.ts +16 -16
- package/src/environment-config.ts +315 -0
- package/src/environment.ts +45 -333
- package/src/errors.ts +3 -2
- package/src/evaluate.ts +5 -4
- package/src/fingerprints.ts +65 -1
- package/src/instances.ts +47 -10
- package/src/java-hash.ts +7 -0
- package/src/json.ts +4 -7
- package/src/levels.ts +39 -42
- package/src/liveness-checker.ts +24 -37
- package/src/liveness.ts +47 -54
- package/src/obligations/action.ts +4 -11
- package/src/obligations/anonymize.ts +4 -2
- package/src/obligations/expression.ts +18 -2
- package/src/obligations/generate.ts +45 -38
- package/src/obligations/index.ts +2 -2
- package/src/obligations/module.ts +27 -38
- package/src/obligations/normalize.ts +2 -1
- package/src/obligations/simplify.ts +39 -44
- package/src/obligations/source.ts +47 -57
- package/src/obligations/temporal.ts +5 -5
- package/src/parallel-worker.ts +10 -30
- package/src/parallel.ts +22 -45
- package/src/parser.ts +19 -34
- package/src/prover/decide-pool.ts +3 -3
- package/src/prover/deciders.ts +3 -3
- package/src/prover/isabelle/encode.ts +1 -1
- package/src/prover/isabelle/isar/inner-syntax.ts +9 -4
- package/src/prover/isabelle/isar/method.ts +14 -25
- package/src/prover/isabelle/isar/theory.ts +11 -10
- package/src/prover/isabelle/isar/type-check.ts +6 -6
- package/src/prover/isabelle/provers/blast/blast.ts +7 -63
- package/src/prover/isabelle/provers/hypsubst.ts +17 -26
- package/src/prover/isabelle/pure/bicompose.ts +9 -25
- package/src/prover/isabelle/pure/conv.ts +2 -8
- package/src/prover/isabelle/pure/drule.ts +9 -2
- package/src/prover/isabelle/pure/logic.ts +1 -1
- package/src/prover/isabelle/pure/raw-simplifier.ts +4 -13
- package/src/prover/isabelle/pure/rewriter.ts +5 -9
- package/src/prover/isabelle/pure/table.ts +2 -1
- package/src/prover/isabelle/pure/tactical.ts +42 -35
- package/src/prover/isabelle/pure/thm.ts +14 -11
- package/src/prover/isabelle/tla/classical-setup.ts +17 -14
- package/src/prover/isabelle/tla/context.ts +7 -2
- package/src/prover/isabelle/tla/logic.ts +10 -21
- package/src/prover/isabelle/tla/simpdata.ts +1 -10
- package/src/prover/prep/action.ts +11 -19
- package/src/prover/prep/fingerprint.ts +2 -5
- package/src/prover/prep/methods.ts +24 -3
- package/src/prover/prove.ts +87 -64
- package/src/prover/smt/context.ts +1 -2
- package/src/prover/smt/data.ts +418 -406
- package/src/prover/smt/encode.ts +30 -18
- package/src/prover/smt/rewrite.ts +657 -626
- package/src/prover/smt/solver/ast.ts +0 -22
- package/src/prover/smt/solver/auf-solver.ts +2 -5
- package/src/prover/smt/solver/context.ts +3 -3
- package/src/prover/smt/solver/e-matching.ts +1 -1
- package/src/prover/smt/solver/expr-safe-replace.ts +1 -1
- package/src/prover/smt/solver/internalizer.ts +1 -2
- package/src/prover/smt/solver/lp/dioph-eq.ts +1 -8
- package/src/prover/smt/solver/lp/hnf-cutter.ts +1 -1
- package/src/prover/smt/solver/lp/nla-core.ts +2 -6
- package/src/prover/smt/solver/mam-compiler.ts +4 -2
- package/src/prover/smt/solver/model-checker.ts +1 -1
- package/src/prover/smt/solver/model-finder.ts +12 -17
- package/src/prover/smt/solver/model-macro-solver.ts +11 -19
- package/src/prover/smt/solver/nlsat/algebraic.ts +9 -9
- package/src/prover/smt/solver/nlsat/atoms.ts +20 -4
- package/src/prover/smt/solver/nlsat/explain.ts +7 -22
- package/src/prover/smt/solver/nlsat/levelwise.ts +1 -6
- package/src/prover/smt/solver/nlsat/polynomial.ts +12 -3
- package/src/prover/smt/solver/nlsat/solver.ts +12 -24
- package/src/prover/smt/solver/nlsat/upolynomial-factorization.ts +1 -1
- package/src/prover/smt/solver/proto-model.ts +0 -4
- package/src/prover/smt/solver/quantifier-analyzer.ts +10 -10
- package/src/prover/smt/solver/quantifier-manager.ts +1 -5
- package/src/prover/smt/solver/smtlib-parser.ts +78 -94
- package/src/prover/smt/solver/theory-lra-bounds.ts +1 -2
- package/src/prover/smt/solver/theory-lra-internalize.ts +5 -16
- package/src/prover/tlapm/cache.ts +28 -18
- package/src/prover/tlapm/tlapm.ts +15 -9
- package/src/prover/verdict.ts +7 -0
- package/src/prover/zenon/check/check.ts +1 -2
- package/src/prover/zenon/check/records.ts +1 -1
- package/src/prover/zenon/check/relations.ts +2 -1
- package/src/prover/zenon/check/rewrites.ts +2 -15
- package/src/prover/zenon/check/sets.ts +40 -58
- package/src/prover/zenon/check/terms.ts +1 -2
- package/src/prover/zenon/eqrel.ts +2 -0
- package/src/prover/zenon/expr.ts +7 -0
- package/src/prover/zenon/index-table.ts +9 -19
- package/src/prover/zenon/isar.ts +35 -35
- package/src/prover/zenon/llproof.ts +2 -11
- package/src/prover/zenon/mltoll.ts +12 -28
- package/src/prover/zenon/parse.ts +3 -6
- package/src/prover/zenon/search.ts +4 -14
- package/src/prover/zenon/tla/functions.ts +2 -2
- package/src/prover/zenon/tla/llproof.ts +9 -11
- package/src/prover/zenon/tla/records.ts +1 -6
- package/src/prover/zenon/tla/sets.ts +15 -14
- package/src/prover/zenon/tla/tla.ts +7 -6
- package/src/resolve.ts +55 -72
- package/src/sany/generation.ts +394 -0
- package/src/sany/generator-def-entries.ts +210 -0
- package/src/sany/generator-definitions.ts +686 -0
- package/src/sany/generator-expressions.ts +1100 -0
- package/src/sany/generator-proofs.ts +662 -0
- package/src/sany/generator.ts +155 -2625
- package/src/sany/lexer.ts +17 -16
- package/src/sany/nodes.ts +6 -13
- package/src/sany/report.ts +3 -6
- package/src/sany/selectors.ts +35 -38
- package/src/sany/xml.ts +23 -55
- package/src/search.ts +65 -27
- package/src/simulate.ts +157 -133
- package/src/spec-description.ts +33 -48
- package/src/standard-modules.ts +16 -32
- package/src/state-graph.ts +2 -7
- package/src/substitution-levels.ts +5 -4
- package/src/successors.ts +5 -7
- package/src/tlc/messages.ts +20 -15
- package/src/tlc/order.ts +2 -9
- package/src/tlc/random.ts +4 -4
- package/src/tlc/replay.ts +8 -15
- package/src/tlc/tlc-operators.ts +2 -3
- package/src/tlc/trace-spec.ts +25 -45
- package/src/typescript/actions.ts +2 -4
- package/src/typescript/collections.ts +34 -20
- package/src/typescript/compile.ts +1 -3
- package/src/typescript/formula.ts +5 -3
- package/src/typescript/model.ts +4 -5
- package/src/typescript/steps.ts +20 -18
- package/src/values.ts +63 -158
package/src/sany/lexer.ts
CHANGED
|
@@ -290,34 +290,35 @@ const getMatchLength = (pattern: RegExp, source: string, offset: number) => {
|
|
|
290
290
|
return pattern.exec(source)?.[0].length ?? 0;
|
|
291
291
|
};
|
|
292
292
|
|
|
293
|
+
interface TokenMatch {
|
|
294
|
+
kind: number;
|
|
295
|
+
length: number;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const getLongerMatch = (best: TokenMatch, match: TokenMatch) =>
|
|
299
|
+
match.length > best.length || (match.length === best.length && match.kind < best.kind)
|
|
300
|
+
? match
|
|
301
|
+
: best;
|
|
302
|
+
|
|
293
303
|
const matchPatterns = (patterns: [string, RegExp[]][], source: string, offset: number) =>
|
|
294
304
|
patterns
|
|
295
305
|
.map(([name, regexes]) => ({
|
|
296
306
|
kind: getKind(name),
|
|
297
307
|
length: Math.max(...regexes.map((regex) => getMatchLength(regex, source, offset))),
|
|
298
308
|
}))
|
|
299
|
-
.reduce(
|
|
300
|
-
(best, match) =>
|
|
301
|
-
match.length > best.length || (match.length === best.length && match.kind < best.kind)
|
|
302
|
-
? match
|
|
303
|
-
: best,
|
|
304
|
-
{ kind: -1, length: 0 },
|
|
305
|
-
);
|
|
309
|
+
.reduce(getLongerMatch, { kind: -1, length: 0 });
|
|
306
310
|
|
|
307
311
|
const matchSpecToken = (source: string, offset: number) => {
|
|
308
312
|
const literalLength = LITERAL_LENGTHS.find((length) =>
|
|
309
313
|
LITERALS.has(source.slice(offset, offset + length)),
|
|
310
314
|
);
|
|
311
315
|
const pattern = matchPatterns(SPEC_PATTERNS, source, offset);
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
(literal.length === pattern.length && literal.kind < pattern.kind)
|
|
319
|
-
? literal
|
|
320
|
-
: pattern;
|
|
316
|
+
return literalLength === undefined
|
|
317
|
+
? pattern
|
|
318
|
+
: getLongerMatch(pattern, {
|
|
319
|
+
kind: LITERALS.get(source.slice(offset, offset + literalLength)) ?? -1,
|
|
320
|
+
length: literalLength,
|
|
321
|
+
});
|
|
321
322
|
};
|
|
322
323
|
|
|
323
324
|
export const getTabStop = (column: number) => column + 8 - (column % 8);
|
package/src/sany/nodes.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getJavaHashCode } from "../java-hash";
|
|
2
|
+
|
|
1
3
|
export interface SanyLocation {
|
|
2
4
|
file: string;
|
|
3
5
|
beginLine: number;
|
|
@@ -151,12 +153,11 @@ export interface OpApplNode extends LevelFields {
|
|
|
151
153
|
tupleOrs: boolean[] | undefined;
|
|
152
154
|
ranges: ExprNode[];
|
|
153
155
|
location: SanyLocation;
|
|
154
|
-
|
|
155
|
-
isAbsent?: boolean;
|
|
156
|
+
nullKind?: "null" | "absent";
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
export const isAbsent = (node: LevelNode | undefined) =>
|
|
159
|
-
node?.kind === "OpAppl" && node.
|
|
160
|
+
node?.kind === "OpAppl" && node.nullKind === "absent";
|
|
160
161
|
|
|
161
162
|
export interface NumeralNode extends LevelFields {
|
|
162
163
|
kind: "Numeral";
|
|
@@ -343,14 +344,6 @@ interface JavaHashtable {
|
|
|
343
344
|
threshold: number;
|
|
344
345
|
}
|
|
345
346
|
|
|
346
|
-
const getJavaHash = (text: string) => {
|
|
347
|
-
let hash = 0;
|
|
348
|
-
for (let index = 0; index < text.length; index++) {
|
|
349
|
-
hash = (Math.imul(hash, 31) + text.charCodeAt(index)) | 0;
|
|
350
|
-
}
|
|
351
|
-
return hash;
|
|
352
|
-
};
|
|
353
|
-
|
|
354
347
|
const createJavaHashtable = (): JavaHashtable => ({
|
|
355
348
|
buckets: Array.from({ length: 11 }, () => []),
|
|
356
349
|
count: 0,
|
|
@@ -372,12 +365,12 @@ const rehash = (table: JavaHashtable) => {
|
|
|
372
365
|
};
|
|
373
366
|
|
|
374
367
|
const getHashtableValue = (table: JavaHashtable, key: string, hashKey = key) =>
|
|
375
|
-
table.buckets[getBucketIndex(
|
|
368
|
+
table.buckets[getBucketIndex(getJavaHashCode(hashKey), table.buckets.length)].find(
|
|
376
369
|
(entry) => entry.key === key,
|
|
377
370
|
)?.value;
|
|
378
371
|
|
|
379
372
|
const putHashtableValue = (table: JavaHashtable, key: string, value: SymbolNode, hashKey = key) => {
|
|
380
|
-
const hash =
|
|
373
|
+
const hash = getJavaHashCode(hashKey);
|
|
381
374
|
const existing = table.buckets[getBucketIndex(hash, table.buckets.length)].find(
|
|
382
375
|
(entry) => entry.key === key,
|
|
383
376
|
);
|
package/src/sany/report.ts
CHANGED
|
@@ -109,9 +109,8 @@ export const getSanyReport = (
|
|
|
109
109
|
const rootName = basename(rootPath, ".tla");
|
|
110
110
|
const standardModules = getSanyStandardModules(options.version);
|
|
111
111
|
const name = options.fileName ?? rootName;
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
: standardModules.get(rootName);
|
|
112
|
+
const isRootFile = existsSync(rootPath);
|
|
113
|
+
const source = isRootFile ? readFileSync(rootPath, "utf8") : standardModules.get(rootName);
|
|
115
114
|
const lines: string[] = [];
|
|
116
115
|
const write = (text: string) => {
|
|
117
116
|
lines.push(text);
|
|
@@ -124,9 +123,7 @@ export const getSanyReport = (
|
|
|
124
123
|
if (!options.isXmlExport) log(text);
|
|
125
124
|
};
|
|
126
125
|
const describeFile = options.describeFile;
|
|
127
|
-
const origins = new Map<string, SanyModuleOrigin>([
|
|
128
|
-
[rootName, existsSync(rootPath) ? "file" : "standard"],
|
|
129
|
-
]);
|
|
126
|
+
const origins = new Map<string, SanyModuleOrigin>([[rootName, isRootFile ? "file" : "standard"]]);
|
|
130
127
|
let isFailed = false;
|
|
131
128
|
const parseMessages: SanyMessage[] = [];
|
|
132
129
|
let isParseReported = false;
|
package/src/sany/selectors.ts
CHANGED
|
@@ -176,7 +176,6 @@ export const createSelectorResolver =
|
|
|
176
176
|
const substInPrefix: SubstInNode[] = [];
|
|
177
177
|
const params: FormalParamNode[] = [];
|
|
178
178
|
const allArgs: ExprOrOpArgNode[] = [];
|
|
179
|
-
const getItemLocation = (itemIndex: number) => items[itemIndex].location ?? location;
|
|
180
179
|
const walk: SelectorWalk = {
|
|
181
180
|
name: undefined,
|
|
182
181
|
nameLocation: undefined,
|
|
@@ -189,6 +188,7 @@ export const createSelectorResolver =
|
|
|
189
188
|
definitionArgs: [],
|
|
190
189
|
isInSuffices: false,
|
|
191
190
|
};
|
|
191
|
+
const getItemLocation = () => items[walk.index].location ?? location;
|
|
192
192
|
const getArgs = (item: SelectorItem) => item.args ?? [];
|
|
193
193
|
|
|
194
194
|
while (walk.index < items.length) {
|
|
@@ -198,7 +198,7 @@ export const createSelectorResolver =
|
|
|
198
198
|
item.args !== undefined
|
|
199
199
|
) {
|
|
200
200
|
return generator.addError(
|
|
201
|
-
getItemLocation(
|
|
201
|
+
getItemLocation(),
|
|
202
202
|
`Selector \`${item.name}' should not have argument(s).`,
|
|
203
203
|
);
|
|
204
204
|
}
|
|
@@ -217,7 +217,7 @@ export const createSelectorResolver =
|
|
|
217
217
|
: undefined;
|
|
218
218
|
if (walk.name === undefined && current.op !== "Name") {
|
|
219
219
|
return generator.addError(
|
|
220
|
-
getItemLocation(
|
|
220
|
+
getItemLocation(),
|
|
221
221
|
`Need name or step number here, not \`${current.name}'.`,
|
|
222
222
|
);
|
|
223
223
|
}
|
|
@@ -230,7 +230,7 @@ export const createSelectorResolver =
|
|
|
230
230
|
if (symbol === undefined) {
|
|
231
231
|
if (newName !== undefined) {
|
|
232
232
|
walk.name = newName;
|
|
233
|
-
walk.nameLocation = extendLocation(walk.nameLocation, getItemLocation(
|
|
233
|
+
walk.nameLocation = extendLocation(walk.nameLocation, getItemLocation());
|
|
234
234
|
}
|
|
235
235
|
collectedArgs.push(...getArgs(current));
|
|
236
236
|
walk.index++;
|
|
@@ -239,7 +239,7 @@ export const createSelectorResolver =
|
|
|
239
239
|
if (symbol === undefined && generator.version === "1.7.4") {
|
|
240
240
|
const lastIndex = items.length - 1;
|
|
241
241
|
return generator.addError(
|
|
242
|
-
|
|
242
|
+
items[lastIndex].location ?? location,
|
|
243
243
|
`Unknown operator: \`${getSelectorItemName(items[lastIndex])}'.`,
|
|
244
244
|
);
|
|
245
245
|
}
|
|
@@ -251,16 +251,16 @@ export const createSelectorResolver =
|
|
|
251
251
|
}
|
|
252
252
|
if (symbol.kind === "Module") {
|
|
253
253
|
return generator.addError(
|
|
254
|
-
getItemLocation(
|
|
254
|
+
getItemLocation(),
|
|
255
255
|
`Module name (${items[walk.index].name}) not allowed here.`,
|
|
256
256
|
);
|
|
257
257
|
}
|
|
258
258
|
walk.node = symbol;
|
|
259
|
-
walk.nameLocation = extendLocation(walk.nameLocation, getItemLocation(
|
|
259
|
+
walk.nameLocation = extendLocation(walk.nameLocation, getItemLocation());
|
|
260
260
|
walk.name = newName;
|
|
261
261
|
if (isDeclarationLike(symbol) && items.length !== 1) {
|
|
262
262
|
return generator.addError(
|
|
263
|
-
getItemLocation(
|
|
263
|
+
getItemLocation(),
|
|
264
264
|
`Cannot take subexpression of \`${walk.name}'.`,
|
|
265
265
|
);
|
|
266
266
|
}
|
|
@@ -279,7 +279,7 @@ export const createSelectorResolver =
|
|
|
279
279
|
symbol,
|
|
280
280
|
argumentIndex + walk.definitionArityFound,
|
|
281
281
|
argument,
|
|
282
|
-
getItemLocation(
|
|
282
|
+
getItemLocation(),
|
|
283
283
|
),
|
|
284
284
|
),
|
|
285
285
|
);
|
|
@@ -288,7 +288,7 @@ export const createSelectorResolver =
|
|
|
288
288
|
if (symbol.kind === "OpDef" && symbol.defKind === "ModuleInstance") {
|
|
289
289
|
if (walk.index === items.length - 1 && !(isDef || isFact)) {
|
|
290
290
|
return generator.addError(
|
|
291
|
-
getItemLocation(
|
|
291
|
+
getItemLocation(),
|
|
292
292
|
`Operator name ${walk.name} is incomplete.`,
|
|
293
293
|
);
|
|
294
294
|
}
|
|
@@ -305,7 +305,7 @@ export const createSelectorResolver =
|
|
|
305
305
|
items.length !== 1
|
|
306
306
|
) {
|
|
307
307
|
return generator.addError(
|
|
308
|
-
getItemLocation(
|
|
308
|
+
getItemLocation(),
|
|
309
309
|
`Subexpression of \`${walk.name}' used inside the operator's definition.`,
|
|
310
310
|
);
|
|
311
311
|
}
|
|
@@ -340,21 +340,18 @@ export const createSelectorResolver =
|
|
|
340
340
|
? owner.labels.get(item.name)
|
|
341
341
|
: undefined;
|
|
342
342
|
if (label === undefined)
|
|
343
|
-
return generator.addError(
|
|
344
|
-
getItemLocation(walk.index),
|
|
345
|
-
`Cannot find label \`${item.name}'.`,
|
|
346
|
-
);
|
|
343
|
+
return generator.addError(getItemLocation(), `Cannot find label \`${item.name}'.`);
|
|
347
344
|
walk.node = label;
|
|
348
345
|
if (generator.isOutOfLabelScope(label)) {
|
|
349
346
|
return generator.addError(
|
|
350
|
-
getItemLocation(
|
|
347
|
+
getItemLocation(),
|
|
351
348
|
`Accessing subexpression labeled \`${item.name}' of ASSUME/PROVE clause within the scope of a declaration\n from outside that declaration's scope.`,
|
|
352
349
|
);
|
|
353
350
|
}
|
|
354
351
|
if (expectedArity === 0) {
|
|
355
352
|
if (label.params.length !== getArgs(item).length) {
|
|
356
353
|
return generator.addError(
|
|
357
|
-
getItemLocation(
|
|
354
|
+
getItemLocation(),
|
|
358
355
|
`Label \`${item.name}' used with wrong number of arguments.`,
|
|
359
356
|
);
|
|
360
357
|
}
|
|
@@ -371,7 +368,7 @@ export const createSelectorResolver =
|
|
|
371
368
|
const node = walk.node;
|
|
372
369
|
const addNonexistentError = () =>
|
|
373
370
|
generator.addError(
|
|
374
|
-
getItemLocation(
|
|
371
|
+
getItemLocation(),
|
|
375
372
|
`Nonexistent operand specified by \`${getSelectorItemName(item)}'.`,
|
|
376
373
|
);
|
|
377
374
|
if (item.op === ":") {
|
|
@@ -381,19 +378,19 @@ export const createSelectorResolver =
|
|
|
381
378
|
(walk.index < items.length - 1 && items[walk.index + 1].op === "Name"));
|
|
382
379
|
if (!isAllowed) {
|
|
383
380
|
return generator.addError(
|
|
384
|
-
getItemLocation(
|
|
381
|
+
getItemLocation(),
|
|
385
382
|
"`!:' can be used only after a name and either at the end after an\noperator name or before an operator name.",
|
|
386
383
|
);
|
|
387
384
|
}
|
|
388
385
|
} else if (node === undefined) {
|
|
389
386
|
return generator.addError(
|
|
390
|
-
getItemLocation(
|
|
387
|
+
getItemLocation(),
|
|
391
388
|
"Subexpression selection failed, probably due to an error in the selected expression.",
|
|
392
389
|
);
|
|
393
390
|
} else if (node.kind === "LetIn") {
|
|
394
391
|
if (getArgNumber(item.op, 1) !== 1)
|
|
395
392
|
return generator.addError(
|
|
396
|
-
getItemLocation(
|
|
393
|
+
getItemLocation(),
|
|
397
394
|
"A LET/IN expression has only one operand.",
|
|
398
395
|
);
|
|
399
396
|
walk.node = node.body;
|
|
@@ -406,7 +403,7 @@ export const createSelectorResolver =
|
|
|
406
403
|
(operator.kind === "OpDef" && operator.defKind === "UserDefined");
|
|
407
404
|
const addNotPairError = () =>
|
|
408
405
|
generator.addError(
|
|
409
|
-
getItemLocation(
|
|
406
|
+
getItemLocation(),
|
|
410
407
|
"Internal error: Expecting $Pair and didn't find it.",
|
|
411
408
|
);
|
|
412
409
|
const isPair = (pair: ExprOrOpArgNode | undefined): pair is OpApplNode =>
|
|
@@ -425,7 +422,7 @@ export const createSelectorResolver =
|
|
|
425
422
|
} else if (operator.name === "$Case") {
|
|
426
423
|
if (walk.index === items.length - 1) {
|
|
427
424
|
return generator.addError(
|
|
428
|
-
getItemLocation(
|
|
425
|
+
getItemLocation(),
|
|
429
426
|
"Subexpression of CASE must have form !i!j.",
|
|
430
427
|
);
|
|
431
428
|
}
|
|
@@ -436,20 +433,20 @@ export const createSelectorResolver =
|
|
|
436
433
|
const number = getArgNumber(items[walk.index].op, 2);
|
|
437
434
|
if (number === -1) {
|
|
438
435
|
return generator.addError(
|
|
439
|
-
getItemLocation(
|
|
436
|
+
getItemLocation(),
|
|
440
437
|
"Second selector for CASE subexpression must specify one of two operands.",
|
|
441
438
|
);
|
|
442
439
|
}
|
|
443
440
|
walk.node = pair.operands[number - 1];
|
|
444
441
|
if (walk.node === undefined)
|
|
445
442
|
return generator.addError(
|
|
446
|
-
getItemLocation(
|
|
443
|
+
getItemLocation(),
|
|
447
444
|
"Selecting OTHER in a CASE statement.",
|
|
448
445
|
);
|
|
449
446
|
} else if (operator.name === "$Except") {
|
|
450
447
|
if (operandNumber > 1) {
|
|
451
448
|
return generator.addError(
|
|
452
|
-
getItemLocation(
|
|
449
|
+
getItemLocation(),
|
|
453
450
|
"Selecting subexpression of an EXCEPT not yet implemented.",
|
|
454
451
|
);
|
|
455
452
|
}
|
|
@@ -464,7 +461,7 @@ export const createSelectorResolver =
|
|
|
464
461
|
if (item.op === "Null") {
|
|
465
462
|
if (getArgs(item).length !== symbols.length) {
|
|
466
463
|
return generator.addError(
|
|
467
|
-
getItemLocation(
|
|
464
|
+
getItemLocation(),
|
|
468
465
|
`Selector with ${getArgs(item).length} argument(s) used for quantifier with ${symbols.length} bound identifier(s).`,
|
|
469
466
|
);
|
|
470
467
|
}
|
|
@@ -478,7 +475,7 @@ export const createSelectorResolver =
|
|
|
478
475
|
}
|
|
479
476
|
} else {
|
|
480
477
|
return generator.addError(
|
|
481
|
-
getItemLocation(
|
|
478
|
+
getItemLocation(),
|
|
482
479
|
`Choosing operand \`${item.name}' of subexpression with no operands.`,
|
|
483
480
|
);
|
|
484
481
|
}
|
|
@@ -486,7 +483,7 @@ export const createSelectorResolver =
|
|
|
486
483
|
if (node.isSuffices && !walk.isInSuffices) {
|
|
487
484
|
if (getArgNumber(item.op, 1) !== 1) {
|
|
488
485
|
return generator.addError(
|
|
489
|
-
getItemLocation(
|
|
486
|
+
getItemLocation(),
|
|
490
487
|
"Accessing non-existent subexpression of a SUFFICES",
|
|
491
488
|
);
|
|
492
489
|
}
|
|
@@ -497,7 +494,7 @@ export const createSelectorResolver =
|
|
|
497
494
|
if (number === -1) return addNonexistentError();
|
|
498
495
|
if (generator.isOutOfClauseScope(node, number)) {
|
|
499
496
|
return generator.addError(
|
|
500
|
-
getItemLocation(
|
|
497
|
+
getItemLocation(),
|
|
501
498
|
"Accessing ASSUME/PROVE clause within the scope of a declaration\n from outside that declaration's scope.",
|
|
502
499
|
);
|
|
503
500
|
}
|
|
@@ -505,7 +502,7 @@ export const createSelectorResolver =
|
|
|
505
502
|
walk.node = node.assumptions[number - 1];
|
|
506
503
|
if (walk.node.kind === "NewSymb" && walk.index !== items.length - 1) {
|
|
507
504
|
return generator.addError(
|
|
508
|
-
getItemLocation(
|
|
505
|
+
getItemLocation(),
|
|
509
506
|
"Selected a subexpression of a NEW clause of an ASSUME.",
|
|
510
507
|
);
|
|
511
508
|
}
|
|
@@ -515,20 +512,20 @@ export const createSelectorResolver =
|
|
|
515
512
|
const lambda = node.op;
|
|
516
513
|
if (lambda.kind !== "OpDef" || lambda.name !== "LAMBDA") {
|
|
517
514
|
return generator.addError(
|
|
518
|
-
getItemLocation(
|
|
515
|
+
getItemLocation(),
|
|
519
516
|
"Trying to select subexpression of an operator argument.",
|
|
520
517
|
);
|
|
521
518
|
}
|
|
522
519
|
if (item.op !== "Null" && item.op !== "@") {
|
|
523
520
|
return generator.addError(
|
|
524
|
-
getItemLocation(
|
|
521
|
+
getItemLocation(),
|
|
525
522
|
`Cannot use !${item.name} to select subexpression of a LAMBDA.`,
|
|
526
523
|
);
|
|
527
524
|
}
|
|
528
525
|
if (item.op === "Null") {
|
|
529
526
|
if (lambda.arity !== getArgs(item).length) {
|
|
530
527
|
return generator.addError(
|
|
531
|
-
getItemLocation(
|
|
528
|
+
getItemLocation(),
|
|
532
529
|
`Selector with ${getArgs(item).length} arguments used for LAMBDA expression taking ${lambda.arity} arguments.`,
|
|
533
530
|
);
|
|
534
531
|
}
|
|
@@ -541,13 +538,13 @@ export const createSelectorResolver =
|
|
|
541
538
|
walk.index--;
|
|
542
539
|
} else {
|
|
543
540
|
return generator.addError(
|
|
544
|
-
getItemLocation(
|
|
541
|
+
getItemLocation(),
|
|
545
542
|
"Selecting subexpression of expression that has none.",
|
|
546
543
|
);
|
|
547
544
|
}
|
|
548
545
|
if (walk.node === undefined)
|
|
549
546
|
return generator.addError(
|
|
550
|
-
getItemLocation(
|
|
547
|
+
getItemLocation(),
|
|
551
548
|
`An unexpected null node specified by '${item.name}'.\nThis is probably due to a previous error.`,
|
|
552
549
|
);
|
|
553
550
|
if (walk.index !== items.length - 1) {
|
|
@@ -556,7 +553,7 @@ export const createSelectorResolver =
|
|
|
556
553
|
while (walk.node?.kind === "Label") walk.node = walk.node.body;
|
|
557
554
|
if (walk.node?.kind !== "LetIn") {
|
|
558
555
|
return generator.addError(
|
|
559
|
-
getItemLocation(
|
|
556
|
+
getItemLocation(),
|
|
560
557
|
"A name selector here must be from a LET clause.",
|
|
561
558
|
);
|
|
562
559
|
}
|
|
@@ -564,7 +561,7 @@ export const createSelectorResolver =
|
|
|
564
561
|
walk.mode = "FindingOpName";
|
|
565
562
|
} else if (next.op === ":") {
|
|
566
563
|
return generator.addError(
|
|
567
|
-
getItemLocation(
|
|
564
|
+
getItemLocation(),
|
|
568
565
|
"!: should not follow an operand selector.",
|
|
569
566
|
);
|
|
570
567
|
}
|
package/src/sany/xml.ts
CHANGED
|
@@ -367,6 +367,10 @@ export interface XmlExportOptions {
|
|
|
367
367
|
isTerse: boolean;
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
+
interface LocatedLevelFields extends LevelFields {
|
|
371
|
+
location: SanyLocation | undefined;
|
|
372
|
+
}
|
|
373
|
+
|
|
370
374
|
const exportSpecification = (
|
|
371
375
|
modules: ModuleNode[],
|
|
372
376
|
root: ModuleNode,
|
|
@@ -424,13 +428,9 @@ const exportSpecification = (
|
|
|
424
428
|
return createElement(getReferenceTag(node), [createText("UID", node.id)]);
|
|
425
429
|
};
|
|
426
430
|
|
|
427
|
-
const withLevel = (
|
|
428
|
-
element: XmlElement,
|
|
429
|
-
node: LevelFields,
|
|
430
|
-
location: SanyLocation | undefined,
|
|
431
|
-
) => {
|
|
431
|
+
const withLevel = (element: XmlElement, node: LocatedLevelFields) => {
|
|
432
432
|
const level = node.levelChecked === 0 ? [] : [createText("level", node.level)];
|
|
433
|
-
const head = location ? [getLocationElement(location), ...level] : level;
|
|
433
|
+
const head = node.location ? [getLocationElement(node.location), ...level] : level;
|
|
434
434
|
return { ...element, children: [...head, ...element.children] };
|
|
435
435
|
};
|
|
436
436
|
|
|
@@ -467,7 +467,6 @@ const exportSpecification = (
|
|
|
467
467
|
createText("arity", node.arity),
|
|
468
468
|
]),
|
|
469
469
|
node,
|
|
470
|
-
node.location,
|
|
471
470
|
);
|
|
472
471
|
case "OpDecl":
|
|
473
472
|
return withLevel(
|
|
@@ -477,7 +476,6 @@ const exportSpecification = (
|
|
|
477
476
|
createText("kind", node.declKind),
|
|
478
477
|
]),
|
|
479
478
|
node,
|
|
480
|
-
node.location,
|
|
481
479
|
);
|
|
482
480
|
case "OpDef": {
|
|
483
481
|
if (node.defKind === "NumberedProofStep") {
|
|
@@ -495,7 +493,6 @@ const exportSpecification = (
|
|
|
495
493
|
...(node.isLocal && !isTlc174 ? [createElement("local")] : []),
|
|
496
494
|
]),
|
|
497
495
|
node,
|
|
498
|
-
node.location,
|
|
499
496
|
);
|
|
500
497
|
}
|
|
501
498
|
const params = node.params ?? [];
|
|
@@ -509,7 +506,6 @@ const exportSpecification = (
|
|
|
509
506
|
: []),
|
|
510
507
|
]),
|
|
511
508
|
node,
|
|
512
|
-
node.location,
|
|
513
509
|
);
|
|
514
510
|
}
|
|
515
511
|
const body = node.body;
|
|
@@ -518,38 +514,28 @@ const exportSpecification = (
|
|
|
518
514
|
if (body === undefined || module === undefined) {
|
|
519
515
|
throw new Error(`The definition of ${node.name} has no body`);
|
|
520
516
|
}
|
|
521
|
-
if (isTlc174) {
|
|
522
|
-
return withLevel(
|
|
523
|
-
createElement("UserDefinedOpKind", [
|
|
524
|
-
createText("uniquename", node.name),
|
|
525
|
-
createText("arity", node.arity),
|
|
526
|
-
createElement("body", [exportExpression(body, JAVA_CALLS.body)]),
|
|
527
|
-
...(node.params
|
|
528
|
-
? [getParamsElement(params, node.isLeibnizArg, JAVA_CALLS.param)]
|
|
529
|
-
: []),
|
|
530
|
-
...(node.inRecursive ? [createElement("recursive")] : []),
|
|
531
|
-
]),
|
|
532
|
-
node,
|
|
533
|
-
node.location,
|
|
534
|
-
);
|
|
535
|
-
}
|
|
536
517
|
return withLevel(
|
|
537
518
|
createElement("UserDefinedOpKind", [
|
|
538
519
|
createText("uniquename", node.name),
|
|
539
520
|
createText("arity", node.arity),
|
|
540
|
-
|
|
541
|
-
|
|
521
|
+
...(isTlc174
|
|
522
|
+
? []
|
|
523
|
+
: [
|
|
524
|
+
createElement("originalOperator", [getReference(node.source ?? node)]),
|
|
525
|
+
createElement("originallyDefinedInModule", [getReference(module)]),
|
|
526
|
+
]),
|
|
542
527
|
createElement("body", [exportExpression(body, JAVA_CALLS.body)]),
|
|
543
|
-
|
|
544
|
-
|
|
528
|
+
...(node.params || !isTlc174
|
|
529
|
+
? [getParamsElement(params, node.isLeibnizArg, JAVA_CALLS.param)]
|
|
530
|
+
: []),
|
|
531
|
+
...(isTlc174 ? [] : getPreCommentsElement(node.preComments)),
|
|
545
532
|
...(node.inRecursive ? [createElement("recursive")] : []),
|
|
546
|
-
...(node.recursiveSection >= 0
|
|
533
|
+
...(node.recursiveSection >= 0 && !isTlc174
|
|
547
534
|
? [createText("recursiveSection", node.recursiveSection)]
|
|
548
535
|
: []),
|
|
549
|
-
...(node.isLocal ? [createElement("local")] : []),
|
|
536
|
+
...(node.isLocal && !isTlc174 ? [createElement("local")] : []),
|
|
550
537
|
]),
|
|
551
538
|
node,
|
|
552
|
-
node.location,
|
|
553
539
|
);
|
|
554
540
|
}
|
|
555
541
|
case "ThmOrAssumpDef":
|
|
@@ -559,7 +545,6 @@ const exportSpecification = (
|
|
|
559
545
|
exportExpression(node.body, JAVA_CALLS.theoremDefinitionBody),
|
|
560
546
|
]),
|
|
561
547
|
node,
|
|
562
|
-
node.location,
|
|
563
548
|
);
|
|
564
549
|
case "Module":
|
|
565
550
|
return createElement("ModuleNode", [
|
|
@@ -581,7 +566,6 @@ const exportSpecification = (
|
|
|
581
566
|
...(node.isSuffices ? [createElement("suffices")] : []),
|
|
582
567
|
]),
|
|
583
568
|
node,
|
|
584
|
-
node.location,
|
|
585
569
|
);
|
|
586
570
|
case "Assume":
|
|
587
571
|
return createElement("AssumeNode", [
|
|
@@ -643,7 +627,7 @@ const exportSpecification = (
|
|
|
643
627
|
);
|
|
644
628
|
|
|
645
629
|
const exportApplication = (node: OpApplNode) => {
|
|
646
|
-
if (node.
|
|
630
|
+
if (node.nullKind !== undefined && isTlc174) {
|
|
647
631
|
throw getJavaException(getUnsupportedKind(0), [
|
|
648
632
|
JAVA_CALLS.operator,
|
|
649
633
|
...getDefinitionFrames("OpDef", IN_BUILTINS),
|
|
@@ -706,7 +690,7 @@ const exportSpecification = (
|
|
|
706
690
|
call: JavaFrame | JavaExpressionCall,
|
|
707
691
|
): XmlElement => {
|
|
708
692
|
if (!isTlc174) return exportLevelNode(node);
|
|
709
|
-
if (node.kind === "OpAppl" && node.
|
|
693
|
+
if (node.kind === "OpAppl" && node.nullKind === "absent" && "nullType" in call) {
|
|
710
694
|
throw getNullPointerException(call);
|
|
711
695
|
}
|
|
712
696
|
return withFrames(
|
|
@@ -722,18 +706,13 @@ const exportSpecification = (
|
|
|
722
706
|
const exportLevelNode = (node: ExportedNode): XmlElement => {
|
|
723
707
|
switch (node.kind) {
|
|
724
708
|
case "OpAppl":
|
|
725
|
-
return withLevel(exportApplication(node), node
|
|
709
|
+
return withLevel(exportApplication(node), node);
|
|
726
710
|
case "Numeral":
|
|
727
|
-
return withLevel(
|
|
728
|
-
createElement("NumeralNode", [createText("IntValue", node.value)]),
|
|
729
|
-
node,
|
|
730
|
-
node.location,
|
|
731
|
-
);
|
|
711
|
+
return withLevel(createElement("NumeralNode", [createText("IntValue", node.value)]), node);
|
|
732
712
|
case "String":
|
|
733
713
|
return withLevel(
|
|
734
714
|
createElement("StringNode", [createText("StringValue", node.value)]),
|
|
735
715
|
node,
|
|
736
|
-
node.location,
|
|
737
716
|
);
|
|
738
717
|
case "Decimal":
|
|
739
718
|
return withLevel(
|
|
@@ -748,7 +727,6 @@ const exportSpecification = (
|
|
|
748
727
|
]),
|
|
749
728
|
]),
|
|
750
729
|
node,
|
|
751
|
-
node.location,
|
|
752
730
|
);
|
|
753
731
|
case "LetIn": {
|
|
754
732
|
const body = exportExpression(node.body, JAVA_CALLS.letBody);
|
|
@@ -761,7 +739,6 @@ const exportSpecification = (
|
|
|
761
739
|
),
|
|
762
740
|
]),
|
|
763
741
|
node,
|
|
764
|
-
node.location,
|
|
765
742
|
);
|
|
766
743
|
}
|
|
767
744
|
case "Label":
|
|
@@ -776,7 +753,6 @@ const exportSpecification = (
|
|
|
776
753
|
),
|
|
777
754
|
]),
|
|
778
755
|
node,
|
|
779
|
-
node.location,
|
|
780
756
|
);
|
|
781
757
|
case "OpArg":
|
|
782
758
|
return withLevel(
|
|
@@ -784,7 +760,6 @@ const exportSpecification = (
|
|
|
784
760
|
createElement("argument", [getReference(node.op, JAVA_CALLS.argument)]),
|
|
785
761
|
]),
|
|
786
762
|
node,
|
|
787
|
-
node.location,
|
|
788
763
|
);
|
|
789
764
|
case "At": {
|
|
790
765
|
const object = node.except.operands[0];
|
|
@@ -798,7 +773,6 @@ const exportSpecification = (
|
|
|
798
773
|
exportExpression(components, JAVA_CALLS.exceptComponents),
|
|
799
774
|
]),
|
|
800
775
|
node,
|
|
801
|
-
node.location,
|
|
802
776
|
);
|
|
803
777
|
}
|
|
804
778
|
case "SubstIn":
|
|
@@ -814,7 +788,6 @@ const exportSpecification = (
|
|
|
814
788
|
createElement("instTo", [getReference(node.instantiatedModule, calls.to)]),
|
|
815
789
|
]),
|
|
816
790
|
node,
|
|
817
|
-
node.location,
|
|
818
791
|
);
|
|
819
792
|
}
|
|
820
793
|
case "Instance": {
|
|
@@ -845,7 +818,6 @@ const exportSpecification = (
|
|
|
845
818
|
...(node.isHide ? [createElement("hide")] : []),
|
|
846
819
|
]),
|
|
847
820
|
node,
|
|
848
|
-
node.location,
|
|
849
821
|
);
|
|
850
822
|
case "NewSymb":
|
|
851
823
|
return withLevel(
|
|
@@ -856,7 +828,6 @@ const exportSpecification = (
|
|
|
856
828
|
: []),
|
|
857
829
|
]),
|
|
858
830
|
node,
|
|
859
|
-
node.location,
|
|
860
831
|
);
|
|
861
832
|
case "AssumeProve":
|
|
862
833
|
return withLevel(
|
|
@@ -872,7 +843,6 @@ const exportSpecification = (
|
|
|
872
843
|
...(node.isBoxed ? [createElement("boxed")] : []),
|
|
873
844
|
]),
|
|
874
845
|
node,
|
|
875
|
-
node.location,
|
|
876
846
|
);
|
|
877
847
|
case "LeafProof": {
|
|
878
848
|
const isObvious = node.facts.length === 0 && node.defs.length === 0;
|
|
@@ -891,7 +861,7 @@ const exportSpecification = (
|
|
|
891
861
|
),
|
|
892
862
|
...(node.isOnly ? [createElement("only")] : []),
|
|
893
863
|
]);
|
|
894
|
-
return withLevel(element, node
|
|
864
|
+
return withLevel(element, node);
|
|
895
865
|
}
|
|
896
866
|
case "NonLeafProof":
|
|
897
867
|
return withLevel(
|
|
@@ -904,7 +874,6 @@ const exportSpecification = (
|
|
|
904
874
|
),
|
|
905
875
|
]),
|
|
906
876
|
node,
|
|
907
|
-
node.location,
|
|
908
877
|
);
|
|
909
878
|
case "DefStep":
|
|
910
879
|
return withLevel(
|
|
@@ -913,7 +882,6 @@ const exportSpecification = (
|
|
|
913
882
|
node.defs.map((definition) => getReference(definition, JAVA_CALLS.defStep)),
|
|
914
883
|
),
|
|
915
884
|
node,
|
|
916
|
-
node.location,
|
|
917
885
|
);
|
|
918
886
|
}
|
|
919
887
|
};
|