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.
Files changed (172) hide show
  1. package/dist/compile.cjs +6 -6
  2. package/dist/compile.js +10 -10
  3. package/dist/deciders.cjs +29 -29
  4. package/dist/deciders.js +40 -40
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/parallel-worker.cjs +1 -1
  8. package/dist/parallel-worker.js +1 -1
  9. package/dist/prove-worker.cjs +1 -1
  10. package/dist/prove-worker.js +1 -1
  11. package/dist/prove.cjs +54 -54
  12. package/dist/prove.js +52 -52
  13. package/dist/run.cjs +42 -42
  14. package/dist/run.js +44 -44
  15. package/dist/tlapm.cjs +2 -2
  16. package/dist/tlapm.js +2 -2
  17. package/dist/transfer.cjs +39 -39
  18. package/dist/transfer.js +41 -41
  19. package/dist/worker.cjs +4 -4
  20. package/dist/worker.js +4 -4
  21. package/package.json +1 -1
  22. package/src/ast.ts +44 -39
  23. package/src/builtins.ts +4 -13
  24. package/src/check-failure.ts +116 -0
  25. package/src/check-trace.ts +282 -0
  26. package/src/check.ts +152 -518
  27. package/src/cli/options.ts +6 -31
  28. package/src/cli/shared.ts +1 -1
  29. package/src/cli/tlapm.ts +14 -13
  30. package/src/cli/tlc-arguments.ts +222 -210
  31. package/src/cli/tlc-output.ts +687 -0
  32. package/src/cli/tlc-usage.ts +1 -1
  33. package/src/cli/tlc.ts +34 -701
  34. package/src/cli/xml-exporter.ts +23 -33
  35. package/src/codegen.ts +5 -10
  36. package/src/coverage.ts +3 -10
  37. package/src/dependencies.ts +8 -13
  38. package/src/dfid.ts +16 -16
  39. package/src/environment-config.ts +315 -0
  40. package/src/environment.ts +45 -333
  41. package/src/errors.ts +3 -2
  42. package/src/evaluate.ts +5 -4
  43. package/src/fingerprints.ts +65 -1
  44. package/src/instances.ts +47 -10
  45. package/src/java-hash.ts +7 -0
  46. package/src/json.ts +4 -7
  47. package/src/levels.ts +39 -42
  48. package/src/liveness-checker.ts +24 -37
  49. package/src/liveness.ts +47 -54
  50. package/src/obligations/action.ts +4 -11
  51. package/src/obligations/anonymize.ts +4 -2
  52. package/src/obligations/expression.ts +18 -2
  53. package/src/obligations/generate.ts +45 -38
  54. package/src/obligations/index.ts +2 -2
  55. package/src/obligations/module.ts +27 -38
  56. package/src/obligations/normalize.ts +2 -1
  57. package/src/obligations/simplify.ts +39 -44
  58. package/src/obligations/source.ts +47 -57
  59. package/src/obligations/temporal.ts +5 -5
  60. package/src/parallel-worker.ts +10 -30
  61. package/src/parallel.ts +22 -45
  62. package/src/parser.ts +19 -34
  63. package/src/prover/decide-pool.ts +3 -3
  64. package/src/prover/deciders.ts +3 -3
  65. package/src/prover/isabelle/encode.ts +1 -1
  66. package/src/prover/isabelle/isar/inner-syntax.ts +9 -4
  67. package/src/prover/isabelle/isar/method.ts +14 -25
  68. package/src/prover/isabelle/isar/theory.ts +11 -10
  69. package/src/prover/isabelle/isar/type-check.ts +6 -6
  70. package/src/prover/isabelle/provers/blast/blast.ts +7 -63
  71. package/src/prover/isabelle/provers/hypsubst.ts +17 -26
  72. package/src/prover/isabelle/pure/bicompose.ts +9 -25
  73. package/src/prover/isabelle/pure/conv.ts +2 -8
  74. package/src/prover/isabelle/pure/drule.ts +9 -2
  75. package/src/prover/isabelle/pure/logic.ts +1 -1
  76. package/src/prover/isabelle/pure/raw-simplifier.ts +4 -13
  77. package/src/prover/isabelle/pure/rewriter.ts +5 -9
  78. package/src/prover/isabelle/pure/table.ts +2 -1
  79. package/src/prover/isabelle/pure/tactical.ts +42 -35
  80. package/src/prover/isabelle/pure/thm.ts +14 -11
  81. package/src/prover/isabelle/tla/classical-setup.ts +17 -14
  82. package/src/prover/isabelle/tla/context.ts +7 -2
  83. package/src/prover/isabelle/tla/logic.ts +10 -21
  84. package/src/prover/isabelle/tla/simpdata.ts +1 -10
  85. package/src/prover/prep/action.ts +11 -19
  86. package/src/prover/prep/fingerprint.ts +2 -5
  87. package/src/prover/prep/methods.ts +24 -3
  88. package/src/prover/prove.ts +87 -64
  89. package/src/prover/smt/context.ts +1 -2
  90. package/src/prover/smt/data.ts +418 -406
  91. package/src/prover/smt/encode.ts +30 -18
  92. package/src/prover/smt/rewrite.ts +657 -626
  93. package/src/prover/smt/solver/ast.ts +0 -22
  94. package/src/prover/smt/solver/auf-solver.ts +2 -5
  95. package/src/prover/smt/solver/context.ts +3 -3
  96. package/src/prover/smt/solver/e-matching.ts +1 -1
  97. package/src/prover/smt/solver/expr-safe-replace.ts +1 -1
  98. package/src/prover/smt/solver/internalizer.ts +1 -2
  99. package/src/prover/smt/solver/lp/dioph-eq.ts +1 -8
  100. package/src/prover/smt/solver/lp/hnf-cutter.ts +1 -1
  101. package/src/prover/smt/solver/lp/nla-core.ts +2 -6
  102. package/src/prover/smt/solver/mam-compiler.ts +4 -2
  103. package/src/prover/smt/solver/model-checker.ts +1 -1
  104. package/src/prover/smt/solver/model-finder.ts +12 -17
  105. package/src/prover/smt/solver/model-macro-solver.ts +11 -19
  106. package/src/prover/smt/solver/nlsat/algebraic.ts +9 -9
  107. package/src/prover/smt/solver/nlsat/atoms.ts +20 -4
  108. package/src/prover/smt/solver/nlsat/explain.ts +7 -22
  109. package/src/prover/smt/solver/nlsat/levelwise.ts +1 -6
  110. package/src/prover/smt/solver/nlsat/polynomial.ts +12 -3
  111. package/src/prover/smt/solver/nlsat/solver.ts +12 -24
  112. package/src/prover/smt/solver/nlsat/upolynomial-factorization.ts +1 -1
  113. package/src/prover/smt/solver/proto-model.ts +0 -4
  114. package/src/prover/smt/solver/quantifier-analyzer.ts +10 -10
  115. package/src/prover/smt/solver/quantifier-manager.ts +1 -5
  116. package/src/prover/smt/solver/smtlib-parser.ts +78 -94
  117. package/src/prover/smt/solver/theory-lra-bounds.ts +1 -2
  118. package/src/prover/smt/solver/theory-lra-internalize.ts +5 -16
  119. package/src/prover/tlapm/cache.ts +28 -18
  120. package/src/prover/tlapm/tlapm.ts +15 -9
  121. package/src/prover/verdict.ts +7 -0
  122. package/src/prover/zenon/check/check.ts +1 -2
  123. package/src/prover/zenon/check/records.ts +1 -1
  124. package/src/prover/zenon/check/relations.ts +2 -1
  125. package/src/prover/zenon/check/rewrites.ts +2 -15
  126. package/src/prover/zenon/check/sets.ts +40 -58
  127. package/src/prover/zenon/check/terms.ts +1 -2
  128. package/src/prover/zenon/eqrel.ts +2 -0
  129. package/src/prover/zenon/expr.ts +7 -0
  130. package/src/prover/zenon/index-table.ts +9 -19
  131. package/src/prover/zenon/isar.ts +35 -35
  132. package/src/prover/zenon/llproof.ts +2 -11
  133. package/src/prover/zenon/mltoll.ts +12 -28
  134. package/src/prover/zenon/parse.ts +3 -6
  135. package/src/prover/zenon/search.ts +4 -14
  136. package/src/prover/zenon/tla/functions.ts +2 -2
  137. package/src/prover/zenon/tla/llproof.ts +9 -11
  138. package/src/prover/zenon/tla/records.ts +1 -6
  139. package/src/prover/zenon/tla/sets.ts +15 -14
  140. package/src/prover/zenon/tla/tla.ts +7 -6
  141. package/src/resolve.ts +55 -72
  142. package/src/sany/generation.ts +394 -0
  143. package/src/sany/generator-def-entries.ts +210 -0
  144. package/src/sany/generator-definitions.ts +686 -0
  145. package/src/sany/generator-expressions.ts +1100 -0
  146. package/src/sany/generator-proofs.ts +662 -0
  147. package/src/sany/generator.ts +155 -2625
  148. package/src/sany/lexer.ts +17 -16
  149. package/src/sany/nodes.ts +6 -13
  150. package/src/sany/report.ts +3 -6
  151. package/src/sany/selectors.ts +35 -38
  152. package/src/sany/xml.ts +23 -55
  153. package/src/search.ts +65 -27
  154. package/src/simulate.ts +157 -133
  155. package/src/spec-description.ts +33 -48
  156. package/src/standard-modules.ts +16 -32
  157. package/src/state-graph.ts +2 -7
  158. package/src/substitution-levels.ts +5 -4
  159. package/src/successors.ts +5 -7
  160. package/src/tlc/messages.ts +20 -15
  161. package/src/tlc/order.ts +2 -9
  162. package/src/tlc/random.ts +4 -4
  163. package/src/tlc/replay.ts +8 -15
  164. package/src/tlc/tlc-operators.ts +2 -3
  165. package/src/tlc/trace-spec.ts +25 -45
  166. package/src/typescript/actions.ts +2 -4
  167. package/src/typescript/collections.ts +34 -20
  168. package/src/typescript/compile.ts +1 -3
  169. package/src/typescript/formula.ts +5 -3
  170. package/src/typescript/model.ts +4 -5
  171. package/src/typescript/steps.ts +20 -18
  172. package/src/values.ts +63 -158
package/src/values.ts CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  TlaModuleError,
7
7
  TlaSetBoundError,
8
8
  } from "./errors";
9
+ import { getJavaHashCode } from "./java-hash";
9
10
  import { prettyPrint } from "./pretty-print";
10
11
  import { isEvalException } from "./tlc/messages";
11
12
  import type { TlcVersion } from "./tlc/version";
@@ -358,18 +359,17 @@ interface StringOrder {
358
359
  unorderedString: string | undefined;
359
360
  }
360
361
 
361
- const stringOrder: StringOrder = {
362
+ const createStringOrder = (): StringOrder => ({
362
363
  ranks: Object.create(null),
363
364
  size: 0,
364
365
  searchRank: undefined,
365
366
  unorderedString: undefined,
366
- };
367
+ });
368
+
369
+ const stringOrder = createStringOrder();
367
370
 
368
371
  export const setStringOrder = (texts: Iterable<string>) => {
369
- stringOrder.ranks = Object.create(null);
370
- stringOrder.size = 0;
371
- stringOrder.searchRank = undefined;
372
- stringOrder.unorderedString = undefined;
372
+ Object.assign(stringOrder, createStringOrder());
373
373
  modelValues.clear();
374
374
  for (const text of texts) rankString(text);
375
375
  };
@@ -843,26 +843,11 @@ const toTlcRecord = (value: Value) => {
843
843
  return isRecordDomain(functionValue.domain) ? functionValue : undefined;
844
844
  };
845
845
 
846
- const compareModelValueWith = (modelValue: ModelValue, other: Value) => {
847
- checkModelValueTypes(other, modelValue, false);
846
+ const compareModelValueWith = (modelValue: ModelValue, other: Value, isEquality: boolean) => {
847
+ checkModelValueTypes(other, modelValue, isEquality);
848
848
  return 1;
849
849
  };
850
850
 
851
- const equalsModelValueWith = (modelValue: ModelValue, other: Value) => {
852
- checkModelValueTypes(other, modelValue, true);
853
- return false;
854
- };
855
-
856
- const compareModelValue = (left: ModelValue, right: Value) => {
857
- if (left.type !== undefined) checkModelValueTypes(left, right, false);
858
- return isModelValue(right) ? left.rank - right.rank : -1;
859
- };
860
-
861
- const equalsModelValue = (left: ModelValue, right: Value) => {
862
- if (left.type !== undefined) checkModelValueTypes(left, right, true);
863
- return isModelValue(right) && left.name === right.name;
864
- };
865
-
866
851
  const SCALAR_KINDS = {
867
852
  number: { name: "integer", other: "non-integer", equality: "check equality of" },
868
853
  string: { name: "string", other: "non-string", equality: "check equality of" },
@@ -881,31 +866,40 @@ const describeScalarMismatch = (
881
866
  return `Attempted to ${isEquality ? kind.equality : "compare"} ${kind.name} ${formatValue(left)} with ${kind.other}:\n${formatValue(right)}`;
882
867
  };
883
868
 
884
- const compareTlcFunctions = (functionValue: TlcFunction, left: Value, right: Value) => {
869
+ const getComparisonVerb = (isEquality: boolean) => (isEquality ? "check equality of" : "compare");
870
+
871
+ const compareTlcFunctions = (
872
+ functionValue: TlcFunction,
873
+ left: Value,
874
+ right: Value,
875
+ isEquality: boolean,
876
+ ) => {
885
877
  const other = toTlcFunction(right);
886
878
  if (!other) {
887
- if (isModelValue(right)) return compareModelValueWith(right, left);
879
+ if (isModelValue(right)) return compareModelValueWith(right, left, isEquality);
888
880
  throw new TlaEvaluationError(
889
- `Attempted to compare the function ${formatValue(left)} with the value:\n${formatValue(right)}`,
881
+ `Attempted to ${getComparisonVerb(isEquality)} the function ${formatValue(left)} with the value:\n${formatValue(right)}`,
890
882
  );
891
883
  }
892
884
  if (functionValue.range.length !== other.range.length)
893
885
  return functionValue.range.length - other.range.length;
894
- const compareRanges = () => compareElementsLikeTlc(functionValue.range, other.range);
886
+ const compareRanges = () => compareElementsLikeTlc(functionValue.range, other.range, isEquality);
895
887
  if (functionValue.low !== undefined && functionValue.range.length === 0) return 0;
896
888
  if (functionValue.low !== undefined && other.low !== undefined) {
897
889
  return functionValue.low === other.low ? compareRanges() : functionValue.low - other.low;
898
890
  }
899
891
  const intervalLow = functionValue.low ?? other.low;
900
892
  if (intervalLow === undefined) {
901
- return compareElementsLikeTlc(functionValue.domain, other.domain) || compareRanges();
893
+ return (
894
+ compareElementsLikeTlc(functionValue.domain, other.domain, isEquality) || compareRanges()
895
+ );
902
896
  }
903
897
  const keys = functionValue.low === undefined ? functionValue.domain : other.domain;
904
898
  for (let index = 0; index < keys.length; index++) {
905
899
  const key = keys[index];
906
900
  if (typeof key !== "number") {
907
901
  throw new TlaEvaluationError(
908
- `Attempted to compare integer with non-integer${functionValue.low === undefined ? "" : ":"}\n${formatValue(key)}.`,
902
+ `Attempted to compare ${isEquality ? "an " : ""}integer with non-integer${isEquality || functionValue.low !== undefined ? ":" : ""}\n${formatValue(key)}.`,
909
903
  );
910
904
  }
911
905
  const difference =
@@ -915,42 +909,47 @@ const compareTlcFunctions = (functionValue: TlcFunction, left: Value, right: Val
915
909
  return compareRanges();
916
910
  };
917
911
 
918
- const compareElementsLikeTlc = (left: Value[], right: Value[]) => {
912
+ const compareElementsLikeTlc = (left: Value[], right: Value[], isEquality: boolean) => {
919
913
  for (let index = 0; index < left.length; index++) {
920
- const comparison = compareLikeTlc(left[index], right[index]);
914
+ const comparison = compareOrEqualLikeTlc(left[index], right[index], isEquality);
921
915
  if (comparison !== 0) return comparison;
922
916
  }
923
917
  return 0;
924
918
  };
925
919
 
926
- const compareFunctionLikeTlc = (left: FunctionValue | LazyFunctionValue, right: Value) => {
920
+ const compareFunctionLikeTlc = (
921
+ left: FunctionValue | LazyFunctionValue,
922
+ right: Value,
923
+ isEquality: boolean,
924
+ ) => {
927
925
  const functionValue = toFiniteFunction(left);
928
926
  if (getFunctionClass(left) === "tuple") {
929
927
  const tuple = isFunctionValue(right) ? getSequenceElements(right) : undefined;
930
- if (!tuple) return compareTlcFunctions({ ...functionValue, low: 1 }, left, right);
928
+ if (!tuple) return compareTlcFunctions({ ...functionValue, low: 1 }, left, right, isEquality);
931
929
  return (
932
930
  functionValue.range.length - tuple.length ||
933
- compareElementsLikeTlc(functionValue.range, tuple)
931
+ compareElementsLikeTlc(functionValue.range, tuple, isEquality)
934
932
  );
935
933
  }
936
934
  if (getFunctionClass(left) === "record") {
937
935
  const record = toTlcRecord(right);
938
936
  if (!record) {
939
- if (isModelValue(right)) return compareModelValueWith(right, left);
937
+ if (isModelValue(right)) return compareModelValueWith(right, left, isEquality);
940
938
  throw new TlaEvaluationError(
941
- `Attempted to compare record:\n${formatValue(left)}\nwith non-record\n${formatValue(right)}`,
939
+ `Attempted to ${getComparisonVerb(isEquality)} record:\n${formatValue(left)}\nwith non-record\n${formatValue(right)}`,
942
940
  );
943
941
  }
944
942
  return (
945
943
  functionValue.domain.length - record.domain.length ||
946
- compareElementsLikeTlc(functionValue.domain, record.domain) ||
947
- compareElementsLikeTlc(functionValue.range, record.range)
944
+ compareElementsLikeTlc(functionValue.domain, record.domain, isEquality) ||
945
+ compareElementsLikeTlc(functionValue.range, record.range, isEquality)
948
946
  );
949
947
  }
950
948
  return compareTlcFunctions(
951
949
  { ...functionValue, low: getIntervalLow(left, functionValue.domain) },
952
950
  left,
953
951
  right,
952
+ isEquality,
954
953
  );
955
954
  };
956
955
 
@@ -970,128 +969,47 @@ const getSetElementsLikeTlc = (left: SetValue | MixedSetValue, right: Value) =>
970
969
  return { elements: toFiniteSet(left).elements, otherElements: toFiniteSet(other).elements };
971
970
  };
972
971
 
973
- const compareSetLikeTlc = (left: ObjectValue, right: Value): number => {
974
- if (isComparedByClass(left, right)) return compareValues(left, right);
975
- if (!isEnumeratedSet(left)) return compareSetLikeTlc(toFiniteSet(left), right);
972
+ const compareSetLikeTlc = (left: ObjectValue, right: Value, isEquality: boolean): number => {
973
+ if (isComparedByClass(left, right)) {
974
+ if (!isEquality) return compareValues(left, right);
975
+ return valuesEqual(left, right) ? 0 : 1;
976
+ }
977
+ if (!isEnumeratedSet(left)) return compareSetLikeTlc(toFiniteSet(left), right, isEquality);
976
978
  if (!isSetValue(right)) {
977
- if (isModelValue(right)) return compareModelValueWith(right, left);
979
+ if (isModelValue(right)) return compareModelValueWith(right, left, isEquality);
978
980
  throw new TlaEvaluationError(
979
- `Attempted to compare the set ${formatValue(left)} with the value:\n${formatValue(right)}`,
981
+ `Attempted to ${getComparisonVerb(isEquality)} the set ${formatValue(left)} with the value:\n${formatValue(right)}`,
980
982
  );
981
983
  }
982
984
  const sets = getSetElementsLikeTlc(left, right);
983
985
  return (
984
986
  sets.elements.length - sets.otherElements.length ||
985
- compareElementsLikeTlc(sets.elements, sets.otherElements)
987
+ compareElementsLikeTlc(sets.elements, sets.otherElements, isEquality)
986
988
  );
987
989
  };
988
990
 
989
- const compareLikeTlc = (left: Value, right: Value): number => {
991
+ const compareOrEqualLikeTlc = (left: Value, right: Value, isEquality: boolean): number => {
990
992
  if (typeof left !== "object") {
991
- if (typeof right === typeof left) return compareValues(left, right);
992
- if (isModelValue(right)) return compareModelValueWith(right, left);
993
- throw new TlaEvaluationError(describeScalarMismatch(left, right, false));
994
- }
995
- if (left.kind === "ModelValue") return compareModelValue(left, right);
996
- if (isFunctionValue(left)) return compareFunctionLikeTlc(left, right);
997
- return compareSetLikeTlc(left, right);
998
- };
999
-
1000
- const equalsElementsLikeTlc = (left: Value[], right: Value[]) =>
1001
- left.every((element, index) => equalsLikeTlc(element, right[index]));
1002
-
1003
- const equalsTlcFunctions = (functionValue: TlcFunction, left: Value, right: Value) => {
1004
- const other = toTlcFunction(right);
1005
- if (!other) {
1006
- if (isModelValue(right)) return equalsModelValueWith(right, left);
1007
- throw new TlaEvaluationError(
1008
- `Attempted to check equality of the function ${formatValue(left)} with the value:\n${formatValue(right)}`,
1009
- );
1010
- }
1011
- if (functionValue.range.length !== other.range.length) return false;
1012
- if (functionValue.low !== undefined && other.low !== undefined) {
1013
- return (
1014
- (functionValue.range.length === 0 || functionValue.low === other.low) &&
1015
- equalsElementsLikeTlc(functionValue.range, other.range)
1016
- );
1017
- }
1018
- const intervalLow = functionValue.low ?? other.low;
1019
- if (intervalLow === undefined) {
1020
- return (
1021
- equalsElementsLikeTlc(functionValue.domain, other.domain) &&
1022
- equalsElementsLikeTlc(functionValue.range, other.range)
1023
- );
1024
- }
1025
- const keys = functionValue.low === undefined ? functionValue.domain : other.domain;
1026
- return (
1027
- keys.every((key, index) => {
1028
- if (typeof key !== "number") {
1029
- throw new TlaEvaluationError(
1030
- `Attempted to compare an integer with non-integer:\n${formatValue(key)}.`,
1031
- );
1032
- }
1033
- return key === intervalLow + index;
1034
- }) && equalsElementsLikeTlc(functionValue.range, other.range)
1035
- );
1036
- };
1037
-
1038
- const equalsFunctionLikeTlc = (left: FunctionValue | LazyFunctionValue, right: Value) => {
1039
- const functionValue = toFiniteFunction(left);
1040
- if (getFunctionClass(left) === "tuple") {
1041
- const tuple = isFunctionValue(right) ? getSequenceElements(right) : undefined;
1042
- if (!tuple) return equalsTlcFunctions({ ...functionValue, low: 1 }, left, right);
1043
- return (
1044
- functionValue.range.length === tuple.length &&
1045
- equalsElementsLikeTlc(functionValue.range, tuple)
1046
- );
1047
- }
1048
- if (getFunctionClass(left) === "record") {
1049
- const record = toTlcRecord(right);
1050
- if (!record) {
1051
- if (isModelValue(right)) return equalsModelValueWith(right, left);
1052
- throw new TlaEvaluationError(
1053
- `Attempted to check equality of record:\n${formatValue(left)}\nwith non-record\n${formatValue(right)}`,
1054
- );
993
+ if (typeof right === typeof left) {
994
+ if (!isEquality) return compareValues(left, right);
995
+ return left === right ? 0 : 1;
1055
996
  }
1056
- return (
1057
- functionValue.domain.length === record.domain.length &&
1058
- equalsElementsLikeTlc(functionValue.domain, record.domain) &&
1059
- equalsElementsLikeTlc(functionValue.range, record.range)
1060
- );
997
+ if (isModelValue(right)) return compareModelValueWith(right, left, isEquality);
998
+ throw new TlaEvaluationError(describeScalarMismatch(left, right, isEquality));
1061
999
  }
1062
- return equalsTlcFunctions(
1063
- { ...functionValue, low: getIntervalLow(left, functionValue.domain) },
1064
- left,
1065
- right,
1066
- );
1067
- };
1068
-
1069
- const equalsSetLikeTlc = (left: ObjectValue, right: Value): boolean => {
1070
- if (isComparedByClass(left, right)) return valuesEqual(left, right);
1071
- if (!isEnumeratedSet(left)) return equalsSetLikeTlc(toFiniteSet(left), right);
1072
- if (!isSetValue(right)) {
1073
- if (isModelValue(right)) return equalsModelValueWith(right, left);
1074
- throw new TlaEvaluationError(
1075
- `Attempted to check equality of the set ${formatValue(left)} with the value:\n${formatValue(right)}`,
1076
- );
1000
+ if (left.kind === "ModelValue") {
1001
+ if (left.type !== undefined) checkModelValueTypes(left, right, isEquality);
1002
+ if (!isModelValue(right)) return -1;
1003
+ if (!isEquality) return left.rank - right.rank;
1004
+ return left.name === right.name ? 0 : 1;
1077
1005
  }
1078
- const sets = getSetElementsLikeTlc(left, right);
1079
- return (
1080
- sets.elements.length === sets.otherElements.length &&
1081
- equalsElementsLikeTlc(sets.elements, sets.otherElements)
1082
- );
1006
+ if (isFunctionValue(left)) return compareFunctionLikeTlc(left, right, isEquality);
1007
+ return compareSetLikeTlc(left, right, isEquality);
1083
1008
  };
1084
1009
 
1085
- const equalsLikeTlc = (left: Value, right: Value): boolean => {
1086
- if (typeof left !== "object") {
1087
- if (typeof right === typeof left) return left === right;
1088
- if (isModelValue(right)) return equalsModelValueWith(right, left);
1089
- throw new TlaEvaluationError(describeScalarMismatch(left, right, true));
1090
- }
1091
- if (left.kind === "ModelValue") return equalsModelValue(left, right);
1092
- if (isFunctionValue(left)) return equalsFunctionLikeTlc(left, right);
1093
- return equalsSetLikeTlc(left, right);
1094
- };
1010
+ const compareLikeTlc = (left: Value, right: Value) => compareOrEqualLikeTlc(left, right, false);
1011
+
1012
+ const equalsLikeTlc = (left: Value, right: Value) => compareOrEqualLikeTlc(left, right, true) === 0;
1095
1013
 
1096
1014
  const sortLikeTlc = (elements: Value[]) => {
1097
1015
  const sorted: Value[] = [];
@@ -2894,14 +2812,7 @@ const PRINTED_ESCAPES: Record<string, string> = {
2894
2812
  const formatString = (value: string) =>
2895
2813
  `"${value.replace(/["\\\t\n\f\r]/g, (character) => PRINTED_ESCAPES[character])}"`;
2896
2814
 
2897
- type LazySetValue =
2898
- | SubsetValue
2899
- | FunctionSetValue
2900
- | RecordSetValue
2901
- | ProductSetValue
2902
- | SetOperationValue
2903
- | FilteredSetValue
2904
- | UnionValue;
2815
+ type LazySetValue = Exclude<ConvertibleSetValue, MixedSetValue | SequenceSetValue>;
2905
2816
 
2906
2817
  const MAXIMUM_EXPANDED_SUBSET_BASE = 6;
2907
2818
  const MAXIMUM_EXPANDED_PRODUCT = 1999;
@@ -3123,12 +3034,6 @@ const isUnchanged = (previous: Value | undefined, value: Value) => {
3123
3034
 
3124
3035
  const JAVA_FORMAT_SPECIFIER = /%(\d+\$)?([-#+ 0,(<]*)(\d+)?(\.\d+)?(.?)/gs;
3125
3036
 
3126
- const getJavaHashCode = (text: string) =>
3127
- Array.from({ length: text.length }, (_value, index) => text.charCodeAt(index)).reduce(
3128
- (hash, unit) => (Math.imul(hash, 31) + unit) | 0,
3129
- 0,
3130
- );
3131
-
3132
3037
  const formatJava = (format: string, args: string[]) => {
3133
3038
  let nextIndex = 0;
3134
3039
  let lastIndex = -1;