tla-ts 0.0.2 → 0.0.3-dev.037ac3b

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 (63) hide show
  1. package/README.md +78 -12
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.d.cts +60 -1
  4. package/dist/index.d.ts +60 -1
  5. package/dist/index.js +1 -1
  6. package/dist/parallel-worker.cjs +2 -2
  7. package/dist/parallel-worker.js +2 -2
  8. package/dist/parallel.cjs +1 -1
  9. package/dist/parallel.js +2 -2
  10. package/dist/run-cli.cjs +21 -2
  11. package/dist/run-cli.js +21 -2
  12. package/dist/transfer.cjs +27 -15
  13. package/dist/transfer.js +27 -15
  14. package/package.json +3 -1
  15. package/src/ast.ts +134 -4
  16. package/src/check.ts +280 -80
  17. package/src/cli-options.ts +64 -0
  18. package/src/codegen.ts +9 -19
  19. package/src/dependencies.ts +2 -2
  20. package/src/environment.ts +75 -16
  21. package/src/errors.ts +46 -3
  22. package/src/evaluate.ts +88 -143
  23. package/src/exit-codes.ts +21 -43
  24. package/src/fingerprints.ts +46 -11
  25. package/src/instances.ts +15 -14
  26. package/src/levels.ts +8 -8
  27. package/src/lexer.ts +11 -2
  28. package/src/live-check.ts +692 -0
  29. package/src/liveness.ts +54 -535
  30. package/src/obligation-action.ts +384 -0
  31. package/src/obligation-anon.ts +575 -0
  32. package/src/obligation-deref.ts +637 -0
  33. package/src/obligation-expression.ts +1060 -0
  34. package/src/obligation-format.ts +406 -0
  35. package/src/obligation-generate.ts +1074 -0
  36. package/src/obligation-levels.ts +329 -0
  37. package/src/obligation-module.ts +1042 -0
  38. package/src/obligation-printer.ts +889 -0
  39. package/src/obligation-proof.ts +76 -0
  40. package/src/obligation-source.ts +1084 -0
  41. package/src/obligation-tuples.ts +184 -0
  42. package/src/obligations.ts +316 -0
  43. package/src/parallel-worker.ts +166 -210
  44. package/src/parallel.ts +76 -35
  45. package/src/parser.ts +297 -53
  46. package/src/resolve.ts +16 -15
  47. package/src/run-cli.ts +353 -40
  48. package/src/runtime.ts +3 -1
  49. package/src/spec-description.ts +18 -6
  50. package/src/standard-levels.ts +3 -3
  51. package/src/standard-modules.ts +2 -7
  52. package/src/state-graph.ts +157 -0
  53. package/src/subexpressions.ts +10 -10
  54. package/src/successors.ts +77 -13
  55. package/src/symmetry.ts +14 -2
  56. package/src/tableau.ts +50 -23
  57. package/src/tlc-ext.ts +29 -12
  58. package/src/tlc-module.ts +9 -28
  59. package/src/tlc-order.ts +17 -3
  60. package/src/tlc-random.ts +9 -6
  61. package/src/tlc-summary.ts +20 -5
  62. package/src/transfer.ts +22 -1
  63. package/src/values.ts +118 -34
@@ -0,0 +1,76 @@
1
+ // tlapm's proof IR (P_t).
2
+
3
+ import type { Bound, Defn, Expr, Locus, Sequent } from "./obligation-expression";
4
+
5
+ export type StepNumber =
6
+ | { kind: "Named"; level: number; label: string; isAnonymous: boolean }
7
+ | { kind: "Unnamed"; level: number; id: number };
8
+
9
+ export type UseDef = ({ kind: "Dvar"; name: string } | { kind: "Dx"; index: number }) & {
10
+ location?: Locus;
11
+ };
12
+
13
+ export interface Usable {
14
+ facts: Expr[];
15
+ defs: UseDef[];
16
+ }
17
+
18
+ type Omission = "Implicit" | "Explicit" | "Elsewhere";
19
+
20
+ export type ObligationKind =
21
+ | { kind: "Main" }
22
+ | { kind: "Support" }
23
+ | { kind: "Error"; message: string }
24
+ | { kind: "Omitted"; omission: Omission };
25
+
26
+ export interface Obligation {
27
+ sequent: Sequent;
28
+ location: Locus | undefined;
29
+ kind: ObligationKind;
30
+ }
31
+
32
+ interface ProofProps {
33
+ location?: Locus;
34
+ step?: StepNumber;
35
+ isSuppressed?: boolean;
36
+ obligations?: Obligation[];
37
+ }
38
+
39
+ export type Proof = ProofCore & ProofProps;
40
+
41
+ type ProofCore =
42
+ | { kind: "Obvious" }
43
+ | { kind: "Omitted"; omission: Omission }
44
+ | { kind: "By"; usable: Usable; isOnly: boolean }
45
+ | { kind: "Steps"; steps: Step[]; qed: QedStep }
46
+ | { kind: "Error"; message: string };
47
+
48
+ interface QedStep extends ProofProps {
49
+ proof: Proof;
50
+ }
51
+
52
+ export type Step = StepCore & ProofProps;
53
+
54
+ type StepCore =
55
+ | { kind: "Hide"; usable: Usable }
56
+ | { kind: "Define"; definitions: Defn[] }
57
+ | { kind: "Assert"; sequent: Sequent; proof: Proof }
58
+ | { kind: "Suffices"; sequent: Sequent; proof: Proof }
59
+ | { kind: "Pcase"; expression: Expr; proof: Proof }
60
+ | { kind: "Pick"; bounds: Bound[]; expression: Expr; proof: Proof }
61
+ | { kind: "Use"; usable: Usable; isOnly: boolean }
62
+ | { kind: "Have"; expression: Expr }
63
+ | { kind: "Take"; bounds: Bound[] }
64
+ | { kind: "Witness"; expressions: Expr[] }
65
+ | { kind: "Forget"; count: number };
66
+
67
+ export const getStepName = (step: StepNumber) =>
68
+ step.kind === "Named" ? `<${step.level}>${step.label}` : `<${step.level}>`;
69
+
70
+ // Std.unique: one counter for the whole run, shared by the parser, anonymization, and
71
+ // simplification, so anonymous step names match tlapm's.
72
+ export interface Counter {
73
+ value: number;
74
+ }
75
+
76
+ export const getUnique = (counter: Counter) => ++counter.value;