tla-ts 0.0.10-dev.b4a856304 → 0.0.10-dev.f16792fed

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.
Files changed (72) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.d.cts +34 -0
  3. package/dist/index.d.ts +34 -0
  4. package/dist/index.js +1 -1
  5. package/dist/parallel-worker.cjs +1 -1
  6. package/dist/parallel-worker.js +1 -1
  7. package/dist/prove.cjs +48 -48
  8. package/dist/prove.js +29 -29
  9. package/dist/run.cjs +40 -40
  10. package/dist/run.js +31 -31
  11. package/dist/transfer.cjs +36 -36
  12. package/dist/transfer.js +40 -40
  13. package/package.json +1 -1
  14. package/src/ast.ts +0 -5
  15. package/src/bags.ts +2 -5
  16. package/src/builtins.ts +1 -8
  17. package/src/check.ts +128 -193
  18. package/src/cli/options.ts +1 -1
  19. package/src/cli/run.ts +0 -2
  20. package/src/cli/runtime-invariants.ts +8 -7
  21. package/src/cli/shared.ts +0 -4
  22. package/src/cli/tlc-arguments.ts +24 -30
  23. package/src/cli/tlc-usage.ts +2 -3
  24. package/src/coverage.ts +3 -8
  25. package/src/evaluate.ts +26 -102
  26. package/src/java-hash.ts +7 -0
  27. package/src/java-overrides.ts +4 -9
  28. package/src/json-reader.ts +1 -2
  29. package/src/json.ts +4 -11
  30. package/src/levels.ts +7 -15
  31. package/src/lexer.ts +72 -83
  32. package/src/liveness-checker.ts +77 -106
  33. package/src/liveness.ts +10 -34
  34. package/src/parallel.ts +26 -33
  35. package/src/parser.ts +163 -226
  36. package/src/pcal/ast.ts +53 -65
  37. package/src/pcal/parse.ts +144 -191
  38. package/src/pcal/tokenize.ts +91 -115
  39. package/src/pcal/translate.ts +83 -98
  40. package/src/pcal/validate.ts +48 -50
  41. package/src/pretty-print.ts +6 -6
  42. package/src/randomization.ts +1 -4
  43. package/src/resolve.ts +12 -70
  44. package/src/runtime.ts +11 -18
  45. package/src/sany/builtins.ts +1 -3
  46. package/src/sany/generator.ts +74 -127
  47. package/src/sany/levels.ts +5 -9
  48. package/src/sany/lexer.ts +40 -44
  49. package/src/sany/linter.ts +0 -1
  50. package/src/sany/nodes.ts +4 -10
  51. package/src/search.ts +1 -1
  52. package/src/simulate.ts +50 -59
  53. package/src/spec-description.ts +23 -34
  54. package/src/standard-definitions.ts +0 -3
  55. package/src/standard-modules.ts +1 -12
  56. package/src/state-graph.ts +3 -15
  57. package/src/subexpressions.ts +38 -47
  58. package/src/successors.ts +14 -35
  59. package/src/symmetry.ts +4 -19
  60. package/src/tlc/fingerprint.ts +15 -21
  61. package/src/tlc/jar-data.ts +0 -1
  62. package/src/tlc/messages.ts +2 -21
  63. package/src/tlc/order.ts +22 -47
  64. package/src/tlc/random.ts +18 -30
  65. package/src/tlc/replay.ts +13 -33
  66. package/src/tlc/summary.ts +36 -45
  67. package/src/tlc/tlc-operators.ts +4 -14
  68. package/src/tlc/tlcext-operators.ts +11 -15
  69. package/src/tlc/trace-spec.ts +4 -9
  70. package/src/tlc/value-stream.ts +9 -13
  71. package/src/tlc/version.ts +0 -1
  72. package/src/values.ts +74 -186
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tla-ts",
3
- "version": "0.0.10-dev.b4a856304",
3
+ "version": "0.0.10-dev.f16792fed",
4
4
  "description": "A TLA+ interpreter and model checker in TypeScript, 2× faster than TLC",
5
5
  "keywords": [
6
6
  "formal verification",
package/src/ast.ts CHANGED
@@ -42,8 +42,6 @@ export interface IdentifierExpression {
42
42
  resolution?: LocalResolution;
43
43
  }
44
44
 
45
- // spelling holds the text of an operator written as a synonym, such as (+) for \oplus, which SANY
46
- // reports as written.
47
45
  export interface ApplyExpression {
48
46
  kind: "Apply";
49
47
  operator: string;
@@ -77,8 +75,6 @@ export interface JunctionExpression {
77
75
  kind: "And" | "Or";
78
76
  operands: Expression[];
79
77
  isBulleted?: boolean;
80
- // SANY parses A /\ B /\ C as (A /\ B) /\ C, whose node of each prefix of two or more operands ends
81
- // after the parentheses of its last operand.
82
78
  prefixEnds?: SourceLocation[];
83
79
  location: SourceLocation;
84
80
  }
@@ -245,7 +241,6 @@ export interface FunctionApplicationExpression {
245
241
  location: SourceLocation;
246
242
  }
247
243
 
248
- // SANY parses [e1, ..., en] as a function application without the function, and rejects it.
249
244
  export interface BracketExpression {
250
245
  kind: "Bracket";
251
246
  args: Expression[];
package/src/bags.ts CHANGED
@@ -85,8 +85,6 @@ const findCount = (functionValue: FunctionValue, element: Value) => {
85
85
  return position === -1 ? undefined : functionValue.range[position];
86
86
  };
87
87
 
88
- // Bags.java casts each count to IntValue, so a count that isn't an integer fails with a
89
- // ClassCastException.
90
88
  const toCount = (value: Value) => {
91
89
  if (typeof value === "number") return value;
92
90
  const javaClass = `tlc2.value.impl.${getJavaClassName(value)}`;
@@ -101,7 +99,7 @@ const addCounts = (left: Value, right: Value) => {
101
99
  return sum;
102
100
  };
103
101
 
104
- // Bags.java subtracts counts as Java ints, which wrap, where the - of the TLA+ definition overflows.
102
+ // Deviation from TLC: Bags.java subtracts counts as Java ints, which wrap; this overflows like -.
105
103
  const subtractCounts = (functionValue: FunctionValue, index: number, other: FunctionValue) => {
106
104
  const count = toCount(functionValue.range[index]);
107
105
  const removed = findCount(other, functionValue.domain[index]);
@@ -123,7 +121,6 @@ const getPairs = (functionValue: FunctionValue) =>
123
121
 
124
122
  const EMPTY_BAG = createSortedFunction([], []);
125
123
 
126
- // SubBag compares the counts with the >= of Naturals, which Integers replaces when TLC loads it.
127
124
  export const createBagsOperators = (builtins: ReadonlyMap<string, Builtin>): Builtin[] => [
128
125
  defineConstant("EmptyBag", EMPTY_BAG),
129
126
  defineOperator("IsABag", 1, (args) => {
@@ -242,7 +239,7 @@ export const createBagsOperators = (builtins: ReadonlyMap<string, Builtin>): Bui
242
239
  (subBags, key, index) =>
243
240
  subBags.flatMap((entries) => [
244
241
  entries,
245
- ...Array.from({ length: counts[index] }, (_, copies): [Value, Value][] => [
242
+ ...Array.from({ length: counts[index] }, (_value, copies): [Value, Value][] => [
246
243
  ...entries,
247
244
  [key, copies + 1],
248
245
  ]),
package/src/builtins.ts CHANGED
@@ -18,8 +18,6 @@ import {
18
18
  type Value,
19
19
  } from "./values";
20
20
 
21
- // TLC evaluates these in its core, or its Java code takes integers, so a wrong argument is an
22
- // evaluation failure. Every other standard-module operator raises an EvalException.
23
21
  const CORE_OPERATOR_NAMES = new Set([
24
22
  "=",
25
23
  "#",
@@ -229,12 +227,9 @@ export const getKindString = (value: Value) => KIND_STRINGS[getJavaClassName(val
229
227
  const getJavaOverrideMessage = (signature: string, message: string) =>
230
228
  `Attempted to apply the operator overridden by the Java method\n${signature},\nbut it produced the following error:\n${message}`;
231
229
 
232
- export const createJavaOverrideError = (signature: string, message: string) =>
230
+ const createJavaOverrideError = (signature: string, message: string) =>
233
231
  new TlaEvaluationError(getJavaOverrideMessage(signature, message));
234
232
 
235
- // TLC reports a failure inside an operator's Java method as a failure of the method, except an
236
- // EvalException the method raises itself, and a NullPointerException as an EvalException. A method
237
- // that evaluates its own arguments reports every failure as a failure of the method.
238
233
  export const overrideWithJava = (builtin: Builtin, signature: string): Builtin => {
239
234
  const reportAsJavaFailure =
240
235
  <Arguments extends unknown[]>(compute: (...args: Arguments) => Value) =>
@@ -247,7 +242,6 @@ export const overrideWithJava = (builtin: Builtin, signature: string): Builtin =
247
242
  throw error;
248
243
  }
249
244
  const isFingerprinted = isFingerprintedSince(depth);
250
- // The wrapping error replaces the FingerprintException.
251
245
  if (setTrace.sets) setTrace.sets.length = depth;
252
246
  const isWrapped =
253
247
  builtin.isLazy === true || !(error instanceof TlaModuleError) || isFingerprinted;
@@ -311,7 +305,6 @@ const getIntegerArgument = (value: Value, position: string, name: string) => {
311
305
  return value;
312
306
  };
313
307
 
314
- // The error of an argument that isn't an integer names the operator as TLC's method does.
315
308
  export const defineComparison = (
316
309
  name: string,
317
310
  compare: (left: number, right: number) => boolean,