tla-ts 0.0.4-dev.c4929d7 → 0.0.4-dev.ca40dfe

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 (207) hide show
  1. package/README.md +31 -6
  2. package/dist/cli.cjs +1 -1
  3. package/dist/cli.js +1 -1
  4. package/dist/deciders.cjs +27 -27
  5. package/dist/deciders.js +34 -34
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.cts +12 -14
  8. package/dist/index.d.ts +12 -14
  9. package/dist/index.js +1 -1
  10. package/dist/parallel-worker.cjs +1 -1
  11. package/dist/parallel-worker.js +1 -1
  12. package/dist/prove-worker.cjs +1 -1
  13. package/dist/prove-worker.js +1 -1
  14. package/dist/prove.cjs +37 -27
  15. package/dist/prove.js +39 -29
  16. package/dist/run.cjs +45 -0
  17. package/dist/run.js +45 -0
  18. package/dist/tlapm.cjs +2 -2
  19. package/dist/tlapm.js +2 -2
  20. package/dist/transfer.cjs +76 -86
  21. package/dist/transfer.js +73 -83
  22. package/dist/worker.cjs +6 -6
  23. package/dist/worker.js +6 -6
  24. package/package.json +1 -1
  25. package/src/ast.ts +2 -2
  26. package/src/bags.ts +22 -23
  27. package/src/builtins.ts +16 -8
  28. package/src/check.ts +131 -1154
  29. package/src/{cli-options.ts → cli/options.ts} +54 -9
  30. package/src/cli/run.ts +63 -0
  31. package/src/cli/shared.ts +106 -0
  32. package/src/cli/tlapm.ts +374 -0
  33. package/src/cli/tlc.ts +941 -0
  34. package/src/cli/xml-exporter.ts +221 -0
  35. package/src/cli.ts +1 -1
  36. package/src/codegen.ts +17 -15
  37. package/src/config.ts +5 -5
  38. package/src/dependencies.ts +4 -6
  39. package/src/environment.ts +55 -60
  40. package/src/errors.ts +12 -36
  41. package/src/evaluate.ts +81 -101
  42. package/src/exit-codes.ts +1 -1
  43. package/src/fingerprints.ts +3 -3
  44. package/src/instances.ts +56 -46
  45. package/src/java-overrides.ts +79 -41
  46. package/src/json.ts +31 -36
  47. package/src/levels.ts +10 -13
  48. package/src/{live-check.ts → liveness-checker.ts} +169 -142
  49. package/src/liveness.ts +38 -34
  50. package/src/obligations/action.ts +9 -45
  51. package/src/obligations/{anon.ts → anonymize.ts} +13 -25
  52. package/src/obligations/equality.ts +260 -0
  53. package/src/obligations/expression.ts +42 -517
  54. package/src/obligations/generate.ts +88 -778
  55. package/src/obligations/index.ts +20 -22
  56. package/src/obligations/levels.ts +36 -41
  57. package/src/obligations/module.ts +88 -708
  58. package/src/obligations/normalize.ts +554 -0
  59. package/src/obligations/operators.ts +176 -0
  60. package/src/obligations/pragma.ts +21 -15
  61. package/src/obligations/printer.ts +81 -188
  62. package/src/obligations/proof.ts +0 -1
  63. package/src/obligations/regroup.ts +100 -0
  64. package/src/obligations/simplify.ts +668 -0
  65. package/src/obligations/source.ts +25 -131
  66. package/src/obligations/{deref.ts → subexpression.ts} +48 -56
  67. package/src/obligations/substitution.ts +261 -0
  68. package/src/obligations/temporal.ts +28 -26
  69. package/src/obligations/tuples.ts +37 -53
  70. package/src/parallel-worker.ts +37 -33
  71. package/src/parallel.ts +30 -24
  72. package/src/parser.ts +67 -74
  73. package/src/{pcal-ast.ts → pcal/ast.ts} +2 -17
  74. package/src/{pcal-parse.ts → pcal/parse.ts} +28 -64
  75. package/src/{pcal-tokenize.ts → pcal/tokenize.ts} +10 -39
  76. package/src/{pcal-translate.ts → pcal/translate.ts} +30 -109
  77. package/src/{pcal-validate.ts → pcal/validate.ts} +10 -20
  78. package/src/prove/decide-pool.ts +7 -12
  79. package/src/{obligations/pickle.ts → prove/first-order.ts} +79 -2
  80. package/src/prove/isabelle/decide.ts +3 -6
  81. package/src/prove/isabelle/encode.ts +35 -93
  82. package/src/prove/isabelle/isar/inner-syntax.ts +1 -1
  83. package/src/prove/isabelle/isar/method.ts +3 -3
  84. package/src/prove/isabelle/isar/type-check.ts +1 -1
  85. package/src/prove/isabelle/provers/blast/blast.ts +1 -1
  86. package/src/prove/isabelle/provers/blast/branch.ts +1 -1
  87. package/src/prove/isabelle/provers/blast/term.ts +3 -4
  88. package/src/prove/isabelle/provers/clasimp.ts +1 -1
  89. package/src/prove/isabelle/provers/classical.ts +3 -3
  90. package/src/prove/isabelle/provers/hypsubst.ts +1 -9
  91. package/src/prove/isabelle/pure/conv.ts +1 -1
  92. package/src/prove/isabelle/pure/drule.ts +2 -2
  93. package/src/prove/isabelle/pure/envir.ts +3 -35
  94. package/src/prove/isabelle/pure/logic.ts +4 -76
  95. package/src/prove/isabelle/pure/name.ts +1 -13
  96. package/src/prove/isabelle/pure/net.ts +2 -49
  97. package/src/prove/isabelle/pure/pattern.ts +3 -22
  98. package/src/prove/isabelle/pure/raw-simplifier.ts +3 -18
  99. package/src/prove/isabelle/pure/seq.ts +0 -23
  100. package/src/prove/isabelle/pure/simplifier.ts +2 -8
  101. package/src/prove/isabelle/pure/table.ts +1 -8
  102. package/src/prove/isabelle/pure/tactic.ts +5 -113
  103. package/src/prove/isabelle/pure/tactical.ts +1 -84
  104. package/src/prove/isabelle/pure/term-ord.ts +1 -55
  105. package/src/prove/isabelle/pure/term.ts +8 -128
  106. package/src/prove/isabelle/pure/thm.ts +4 -27
  107. package/src/prove/isabelle/pure/type.ts +0 -12
  108. package/src/prove/isabelle/pure/unify.ts +1 -1
  109. package/src/prove/isabelle/tla/classical-setup.ts +1 -1
  110. package/src/prove/ocaml.ts +1 -1
  111. package/src/prove/prep/action.ts +23 -36
  112. package/src/prove/prep/enabled-axioms.ts +2 -2
  113. package/src/prove/prep/fingerprint.ts +3 -3
  114. package/src/prove/prep/level-comparison.ts +9 -37
  115. package/src/prove/prep/md5.ts +2 -9
  116. package/src/prove/prep/normalize.ts +309 -0
  117. package/src/prove/prove-worker.ts +2 -5
  118. package/src/prove/prove.ts +98 -111
  119. package/src/prove/ptl/encode.ts +19 -31
  120. package/src/prove/smt/axioms.ts +45 -58
  121. package/src/prove/smt/encode.ts +124 -15
  122. package/src/prove/smt/instances.ts +2 -3
  123. package/src/prove/smt/rewrite.ts +24 -31
  124. package/src/prove/smt/solver/ast-util.ts +0 -56
  125. package/src/prove/smt/solver/case-split-queue.ts +1 -1
  126. package/src/prove/smt/solver/enode.ts +1 -1
  127. package/src/prove/smt/solver/lp/dep-intervals.ts +0 -14
  128. package/src/prove/smt/solver/model-macro-solver.ts +1 -1
  129. package/src/prove/smt/solver/nlsat/algebraic.ts +3 -3
  130. package/src/prove/smt/solver/nlsat/atoms.ts +1 -1
  131. package/src/prove/smt/solver/nlsat/explain.ts +1 -1
  132. package/src/prove/smt/solver/nlsat/interval-set.ts +1 -1
  133. package/src/prove/smt/solver/nlsat/levelwise.ts +4 -7
  134. package/src/prove/smt/solver/nlsat/polynomial.ts +4 -4
  135. package/src/prove/smt/solver/nlsat/upolynomial.ts +2 -2
  136. package/src/prove/smt/solver/pattern-inference.ts +1 -1
  137. package/src/prove/smt/solver/relevancy.ts +2 -2
  138. package/src/prove/smt/solver/rewriter.ts +1 -1
  139. package/src/prove/smt/solver/solver.ts +2 -2
  140. package/src/{tlapm-cache.ts → prove/tlapm/cache.ts} +11 -11
  141. package/src/{ocaml-marshal.ts → prove/tlapm/ocaml-marshal.ts} +1 -1
  142. package/src/prove/verdict.ts +0 -5
  143. package/src/prove/zenon/decide.ts +5 -11
  144. package/src/prove/zenon/encode.ts +21 -80
  145. package/src/prove/zenon/eqrel.ts +1 -1
  146. package/src/prove/zenon/equality-rules.ts +1 -1
  147. package/src/prove/zenon/expr.ts +2 -2
  148. package/src/prove/zenon/index-table.ts +1 -1
  149. package/src/prove/zenon/isar.ts +1 -1
  150. package/src/prove/zenon/llproof.ts +1 -1
  151. package/src/prove/zenon/mltoll.ts +1 -1
  152. package/src/prove/zenon/node.ts +1 -1
  153. package/src/prove/zenon/search.ts +1 -1
  154. package/src/prove/zenon/tla/terms.ts +1 -20
  155. package/src/prove/zenon/tla/tla.ts +1 -1
  156. package/src/randomization.ts +19 -24
  157. package/src/resolve.ts +15 -22
  158. package/src/runtime.ts +8 -8
  159. package/src/{sany-builtins.ts → sany/builtins.ts} +1 -1
  160. package/src/{sany-generator.ts → sany/generator.ts} +38 -55
  161. package/src/{sany-levels.ts → sany/levels.ts} +45 -48
  162. package/src/{sany-lexer.ts → sany/lexer.ts} +2 -3
  163. package/src/{sany-linter.ts → sany/linter.ts} +1 -1
  164. package/src/{sany-modules.ts → sany/modules.ts} +2 -2
  165. package/src/{sany-nodes.ts → sany/nodes.ts} +2 -2
  166. package/src/{sany-parse-error.ts → sany/parse-error.ts} +2 -2
  167. package/src/{sany-report.ts → sany/report.ts} +16 -17
  168. package/src/{sany-selectors.ts → sany/selectors.ts} +3 -5
  169. package/src/{sany-source.ts → sany/source.ts} +6 -7
  170. package/src/{sany-xml.ts → sany/xml.ts} +5 -6
  171. package/src/search.ts +969 -0
  172. package/src/spec-description.ts +26 -20
  173. package/src/{standard-levels.ts → standard-definitions.ts} +118 -2
  174. package/src/standard-modules.ts +16 -20
  175. package/src/state-graph.ts +9 -8
  176. package/src/substitution-levels.ts +2 -2
  177. package/src/successors.ts +16 -19
  178. package/src/symmetry.ts +1 -1
  179. package/src/tableau.ts +6 -7
  180. package/src/tlc/fingerprint.ts +214 -0
  181. package/src/{tlc-messages.ts → tlc/messages.ts} +119 -7
  182. package/src/{tlc-order.ts → tlc/order.ts} +7 -7
  183. package/src/{tlc-random.ts → tlc/random.ts} +3 -213
  184. package/src/{tlc-replay.ts → tlc/replay.ts} +40 -36
  185. package/src/{tlc-module.ts → tlc/tlc-operators.ts} +9 -9
  186. package/src/{tlc-ext.ts → tlc/tlcext-operators.ts} +30 -25
  187. package/src/transfer.ts +32 -32
  188. package/src/values.ts +72 -67
  189. package/src/worker.ts +1 -4
  190. package/dist/run-cli.cjs +0 -45
  191. package/dist/run-cli.js +0 -45
  192. package/src/canonical.ts +0 -40
  193. package/src/obligations/ctx.ts +0 -64
  194. package/src/prove/prep/defs.ts +0 -33
  195. package/src/prove/prep/elab.ts +0 -156
  196. package/src/prove/prep/enabled.ts +0 -43
  197. package/src/prove/prep/flatten.ts +0 -70
  198. package/src/prove/prep/trivial.ts +0 -22
  199. package/src/prove/smt/axiomatize.ts +0 -69
  200. package/src/prove/smt/simplify.ts +0 -57
  201. package/src/run-cli.ts +0 -1806
  202. package/src/standard-ranges.ts +0 -116
  203. package/src/value-sources.ts +0 -29
  204. /package/src/prove/prep/{pragma.ts → methods.ts} +0 -0
  205. /package/src/{tlc-modules.ts → tlc/jar-data.ts} +0 -0
  206. /package/src/{tlc-summary.ts → tlc/summary.ts} +0 -0
  207. /package/src/{tlc-version.ts → tlc/version.ts} +0 -0
@@ -17,14 +17,12 @@ import {
17
17
  type Table,
18
18
  } from "./table";
19
19
  import {
20
- binderTypes as plainBinderTypes,
21
20
  flagsOf,
22
21
  funT,
23
22
  HAS_ETA_REDEX,
24
23
  HAS_REDEX,
25
24
  HAS_VAR,
26
25
  isDependent,
27
- listComb,
28
26
  maxidxOfTerm,
29
27
  mkAbs,
30
28
  mkApp,
@@ -33,8 +31,6 @@ import {
33
31
  substBound,
34
32
  updateAbs,
35
33
  updateApp,
36
- incrBoundvars,
37
- fastypeOf1,
38
34
  aconv,
39
35
  type Term,
40
36
  type Typ,
@@ -63,7 +59,7 @@ export const emptyEnvir = (maxidx: number): Envir => ({
63
59
  tyenv: emptyTyEnv,
64
60
  });
65
61
 
66
- export const initEnvir = emptyEnvir(-1);
62
+ const initEnvir = emptyEnvir(-1);
67
63
 
68
64
  export const isEmptyEnvir = (envir: Envir) => isEmptyTable(envir.tenv) && isEmptyTable(envir.tyenv);
69
65
 
@@ -146,7 +142,7 @@ export const vupdate = (variable: Var, term: Term, envir: Envir): Envir => {
146
142
  return update(variable, term, envir);
147
143
  };
148
144
 
149
- export const couldBetaContract = (term: Term) => (flagsOf(term) & HAS_REDEX) !== 0;
145
+ const couldBetaContract = (term: Term) => (flagsOf(term) & HAS_REDEX) !== 0;
150
146
 
151
147
  const normTerm1 = (tenv: TEnv, term: Term): Term => {
152
148
  if ((flagsOf(term) & (HAS_VAR | HAS_REDEX)) === 0) return term;
@@ -224,32 +220,6 @@ export const headNorm = (envir: Envir, term: Term): Term => {
224
220
  }
225
221
  };
226
222
 
227
- export const etaLong = (types: readonly Typ[], term: Term): Term => {
228
- if (term.kind === "Abs")
229
- return mkAbs(term.name, term.type, etaLong([term.type, ...types], term.body));
230
- const [head, args] = stripCombLocal(term);
231
- if (head.kind === "Abs") return etaLong(types, betaNorm(term));
232
- const binders = plainBinderTypes(fastypeOf1(types, term));
233
- const count = binders.length;
234
- const inner = [...binders].reverse().concat(types);
235
- const long = (current: Term) => etaLong(inner, current);
236
- const body = listComb(incrBoundvars(count, head), [
237
- ...args.map((arg) => long(incrBoundvars(count, arg))),
238
- ...binders.map((_type, position) => long(mkBound(count - 1 - position))),
239
- ]);
240
- return binders.reduceRight((result, type) => mkAbs("x", type, result), body);
241
- };
242
-
243
- const stripCombLocal = (term: Term): [Term, Term[]] => {
244
- const args: Term[] = [];
245
- let current = term;
246
- while (current.kind === "App") {
247
- args.unshift(current.arg);
248
- current = current.fun;
249
- }
250
- return [current, args];
251
- };
252
-
253
223
  const decrementLoose = (term: Term, level: number): Term => {
254
224
  switch (term.kind) {
255
225
  case "Bound":
@@ -263,7 +233,7 @@ const decrementLoose = (term: Term, level: number): Term => {
263
233
  }
264
234
  };
265
235
 
266
- export const couldEtaContract = (term: Term) => (flagsOf(term) & HAS_ETA_REDEX) !== 0;
236
+ const couldEtaContract = (term: Term) => (flagsOf(term) & HAS_ETA_REDEX) !== 0;
267
237
 
268
238
  const etaSame = (term: Term): Term => {
269
239
  if (!couldEtaContract(term)) return term;
@@ -283,8 +253,6 @@ const etaSame = (term: Term): Term => {
283
253
  // Envir.eta_contract
284
254
  export const etaContract = (term: Term) => (couldEtaContract(term) ? etaSame(term) : term);
285
255
 
286
- export const betaEtaContract = (term: Term) => etaContract(betaNorm(term));
287
-
288
256
  export const aeconv = (left: Term, right: Term) =>
289
257
  aconv(left, right) || aconv(etaContract(left), etaContract(right));
290
258
 
@@ -3,17 +3,13 @@
3
3
  // LICENSE.
4
4
 
5
5
  import { TlaIsabelleError } from "../../../errors";
6
- import { makeNameContext, variantList, variantNames } from "./name";
6
+ import { variantList } from "./name";
7
7
  import {
8
8
  aconv,
9
- addFreeNames,
10
9
  fastypeOf,
11
10
  funT,
12
11
  funTs,
13
12
  incrBoundvars,
14
- isDependent,
15
- abstractOver,
16
- termName,
17
13
  mapAtyps,
18
14
  mkAbs,
19
15
  mkApp,
@@ -24,7 +20,6 @@ import {
24
20
  mkVar,
25
21
  mayOccur,
26
22
  propT,
27
- substBounds,
28
23
  type App,
29
24
  type Term,
30
25
  type Typ,
@@ -45,12 +40,6 @@ export interface Binder {
45
40
 
46
41
  export const allConst = (type: Typ) => mkConst("Pure.all", funT(funT(type, propT), propT));
47
42
 
48
- export const isAll = (term: Term) =>
49
- term.kind === "App" &&
50
- term.fun.kind === "Const" &&
51
- term.fun.name === "Pure.all" &&
52
- term.arg.kind === "Abs";
53
-
54
43
  export const listAll = (vars: readonly Binder[], body: Term): Term =>
55
44
  vars.reduceRight<Term>(
56
45
  (result, variable) =>
@@ -58,15 +47,6 @@ export const listAll = (vars: readonly Binder[], body: Term): Term =>
58
47
  body,
59
48
  );
60
49
 
61
- // Logic.dependent_all_name
62
- export const dependentAllName = (name: string, variable: Term, body: Term) => {
63
- const abstracted = abstractOver(variable, body);
64
- const type = fastypeOf(variable);
65
- return isDependent(abstracted)
66
- ? mkApp(allConst(type), mkAbs(name === "" ? termName(variable) : name, type, abstracted))
67
- : body;
68
- };
69
-
70
50
  export const mkEquals = (left: Term, right: Term) => {
71
51
  const type = fastypeOf(left);
72
52
  return mkApp(mkApp(mkConst("Pure.eq", funTs([type, type], propT)), left), right);
@@ -134,25 +114,13 @@ export const stripPrems = (
134
114
 
135
115
  export const countPrems = (term: Term) => stripImpPrems(term).length;
136
116
 
137
- export const nthPrem = (index: number, term: Term): Term => {
138
- const premise = stripImpPrems(term)[index - 1];
139
- if (index < 1 || premise === undefined) throw new TlaIsabelleError("TERM", "nth_prem");
140
- return premise;
141
- };
142
-
143
- export const protectConst = mkConst("Pure.prop", funT(propT, propT));
117
+ const protectConst = mkConst("Pure.prop", funT(propT, propT));
144
118
 
145
119
  export const protect = (term: Term) => mkApp(protectConst, term);
146
120
 
147
121
  export const isProtected = (term: Term) =>
148
122
  term.kind === "App" && term.fun.kind === "Const" && term.fun.name === "Pure.prop";
149
123
 
150
- export const unprotect = (term: Term) => {
151
- if (term.kind !== "App" || term.fun.kind !== "Const" || term.fun.name !== "Pure.prop")
152
- throw new TlaIsabelleError("TERM", "unprotect");
153
- return term.arg;
154
- };
155
-
156
124
  export const mkTerm = (term: Term) =>
157
125
  mkApp(mkConst("Pure.term", funT(fastypeOf(term), propT)), term);
158
126
 
@@ -174,7 +142,7 @@ const incrTVar = (increment: number, type: Typ) =>
174
142
  );
175
143
 
176
144
  // Logic.incr_indexes_operation: lifts the variables over the types and increments their indexes.
177
- export const incrIndexesFixed = (
145
+ const incrIndexesFixed = (
178
146
  fixed: readonly string[],
179
147
  types: readonly Typ[],
180
148
  increment: number,
@@ -336,17 +304,6 @@ export const flattenParams = (index: number, term: Term) => {
336
304
  return listAll(vars, removeParams(vars.length, index, term));
337
305
  };
338
306
 
339
- export const listRenameParams = (names: readonly string[], term: Term): Term => {
340
- if (isConstApp2(term, "Pure.imp"))
341
- return mkImplies(term.fun.arg, listRenameParams(names, term.arg));
342
- if (names.length > 0 && isAllAbs(term))
343
- return mkApp(
344
- term.fun,
345
- mkAbs(names[0], term.arg.type, listRenameParams(names.slice(1), term.arg.body)),
346
- );
347
- return term;
348
- };
349
-
350
307
  // Logic.strip_assums_imp: strips at most count premises.
351
308
  const stripAssumsImp = (count: number, hyps: Term[], term: Term): [Term[], Term] => {
352
309
  if (count === 0) return [hyps, term];
@@ -360,15 +317,7 @@ const stripAssumsAll = (params: Binder[], term: Term): [Binder[], Term] =>
360
317
  ? stripAssumsAll([{ name: term.arg.name, type: term.arg.type }, ...params], term.arg.body)
361
318
  : [params, term];
362
319
 
363
- // Logic.assum_pairs: the disagreement pairs, one for each assumption of the lifted premise.
364
- export const assumPairs = (count: number, term: Term): [Term, Term][] => {
365
- const [params, body] = stripAssumsAll([], term);
366
- const [hyps, conclusion] = stripAssumsImp(count, [], body);
367
- const target = rlistAbs(params, conclusion);
368
- return [...hyps].reverse().map((hyp): [Term, Term] => [rlistAbs(params, hyp), target]);
369
- };
370
-
371
- export interface AssumProblems {
320
+ interface AssumProblems {
372
321
  readonly abstract: (term: Term) => Term;
373
322
  readonly hyps: Term[];
374
323
  readonly conclusion: Term;
@@ -379,24 +328,3 @@ export const assumProblems = (count: number, term: Term): AssumProblems => {
379
328
  const [hyps, conclusion] = stripAssumsImp(count, [], body);
380
329
  return { abstract: (inner) => rlistAbs(params, inner), hyps: [...hyps].reverse(), conclusion };
381
330
  };
382
-
383
- // Logic.goal_params
384
- export const goalParams = (state: Term, index: number): [Term, Term[]] => {
385
- const goal = nthPrem(index, state);
386
- const params = stripParams(goal);
387
- const names = variantNames(
388
- params.map((param) => param.name),
389
- makeNameContext(addFreeNames(goal, [])),
390
- );
391
- return [goal, params.map((param, position) => mkFree(names[position], param.type)).reverse()];
392
- };
393
-
394
- export const conclOfGoal = (state: Term, index: number) => {
395
- const [goal, frees] = goalParams(state, index);
396
- return substBounds(frees, stripAssumsConcl(goal));
397
- };
398
-
399
- export const premsOfGoal = (state: Term, index: number) => {
400
- const [goal, frees] = goalParams(state, index);
401
- return stripAssumsHyp(goal).map((hyp) => substBounds(frees, hyp));
402
- };
@@ -3,8 +3,7 @@
3
3
  // contributors, see LICENSE.
4
4
 
5
5
  // Symbol.explode: \<name> symbols count as one symbol.
6
- export const explodeSymbols = (text: string): string[] =>
7
- text.match(/\\<\^?[A-Za-z0-9_']*>|[^]/gu) ?? [];
6
+ const explodeSymbols = (text: string): string[] => text.match(/\\<\^?[A-Za-z0-9_']*>|[^]/gu) ?? [];
8
7
 
9
8
  const isRawSymbolic = (symbol: string) => symbol.startsWith("\\<") && !symbol.startsWith("\\<^");
10
9
 
@@ -92,17 +91,6 @@ export const variantNames = (names: readonly string[], context: NameContext) =>
92
91
  export const variantList = (used: readonly string[], names: readonly string[]) =>
93
92
  variantNames(names, makeNameContext(used));
94
93
 
95
- // Name.invent: count fresh names starting from name.
96
- export const inventNames = (context: NameContext, name: string, count: number) => {
97
- const names: string[] = [];
98
- let current = cleanName(name);
99
- while (names.length < count) {
100
- if (!context.has(current)) names.push(current);
101
- current = bumpString(current);
102
- }
103
- return names;
104
- };
105
-
106
94
  // Name.is_bound and Name.bound: the names of loose bound variables in nets and printing.
107
95
  // Name.is_bound: the names the simplifier gives the free variables standing for bound ones.
108
96
  export const isBoundName = (name: string) => name.startsWith(":");
@@ -8,14 +8,13 @@ import {
8
8
  foldTable,
9
9
  isEmptyTable,
10
10
  lookupTable,
11
- tableEntries,
12
11
  updateTable,
13
12
  deleteTable,
14
13
  type Table,
15
14
  } from "./table";
16
15
  import { headOf, type Term } from "./term";
17
16
 
18
- export type NetKey =
17
+ type NetKey =
19
18
  | { readonly kind: "Comb" }
20
19
  | { readonly kind: "Var" }
21
20
  | { readonly kind: "Atom"; readonly name: string };
@@ -105,18 +104,11 @@ export const insertNet = <Item>(
105
104
  export const insertTermNet = <Item>(term: Term, item: Item, net: Net<Item>) =>
106
105
  insertNet(() => false, keyOfTerm(term), item, net) ?? net;
107
106
 
108
- export const insertTermSafe = <Item>(
109
- isEqual: (left: Item, right: Item) => boolean,
110
- term: Term,
111
- item: Item,
112
- net: Net<Item>,
113
- ) => insertNet(isEqual, keyOfTerm(term), item, net) ?? net;
114
-
115
107
  const newNet = <Item>(node: Extract<Net<Item>, { kind: "Net" }>): Net<Item> =>
116
108
  isEmptyNet(node.comb) && isEmptyNet(node.var) && isEmptyTable(node.atoms) ? emptyNet : node;
117
109
 
118
110
  // Net.delete: undefined where Isabelle raises DELETE.
119
- export const deleteNet = <Item>(
111
+ const deleteNet = <Item>(
120
112
  isEqual: (left: Item, right: Item) => boolean,
121
113
  keys: readonly NetKey[],
122
114
  item: Item,
@@ -221,42 +213,3 @@ export const matchTermNet = <Item>(net: Net<Item>, term: Term) =>
221
213
 
222
214
  export const unifyTermNet = <Item>(net: Net<Item>, term: Term) =>
223
215
  extractLeaves(matching(true, term, net, undefined));
224
-
225
- // Net.content: every item, by the order of Net.dest.
226
- export const netContent = <Item>(net: Net<Item>): Item[] => {
227
- if (net.kind === "Leaf") return [...net.items];
228
- return [
229
- ...netContent(net.comb),
230
- ...netContent(net.var),
231
- ...tableEntries(net.atoms).flatMap((entry) => netContent(entry[1])),
232
- ];
233
- };
234
-
235
- // Net.subtract: the items of second that are not in first.
236
- export const subtractNet = <Item>(
237
- isEqual: (left: Item, right: Item) => boolean,
238
- first: Net<Item>,
239
- second: Net<Item>,
240
- ) => {
241
- const subtr = (left: Net<Item>, right: Net<Item>, result: Item[]): Item[] => {
242
- if (right.kind === "Leaf") {
243
- if (left.kind === "Net") return [...right.items, ...result];
244
- return right.items.reduceRight(
245
- (accumulated, item) =>
246
- left.items.some((other) => isEqual(other, item)) ? accumulated : [item, ...accumulated],
247
- result,
248
- );
249
- }
250
- if (left.kind === "Leaf") return subtr(makeNode(), right, result);
251
- const afterComb = subtr(left.comb, right.comb, result);
252
- const afterVar = subtr(left.var, right.var, afterComb);
253
- return tableEntries(right.atoms).reduce(
254
- (accumulated, entry) =>
255
- subtr(lookupTable(left.atoms, entry[0]) ?? makeNode(), entry[1], accumulated),
256
- afterVar,
257
- );
258
- };
259
- return subtr(first, second, []);
260
- };
261
-
262
- export const netEntries = <Item>(net: Net<Item>) => subtractNet(() => false, emptyNet, net);
@@ -6,18 +6,7 @@
6
6
  // functions return undefined instead.
7
7
 
8
8
  import { TlaIsabelleError } from "../../../errors";
9
- import {
10
- aeconv,
11
- emptyTEnv,
12
- genvar,
13
- headNorm,
14
- lookup,
15
- lookup1,
16
- substTerm,
17
- update,
18
- type Envir,
19
- type TEnv,
20
- } from "./envir";
9
+ import { aeconv, genvar, headNorm, lookup, lookup1, update, type Envir, type TEnv } from "./envir";
21
10
  import { hasKey, indexnameOrd, updateTable } from "./table";
22
11
  import {
23
12
  eqTyp,
@@ -31,14 +20,13 @@ import {
31
20
  mkAbs,
32
21
  mkApp,
33
22
  mkBound,
34
- renameAbs,
35
23
  stripComb,
36
24
  aconv,
37
25
  type Term,
38
26
  type Typ,
39
27
  type Var,
40
28
  } from "./term";
41
- import { emptyTyEnv, matchTypes, normType, substType, unifyTypes, type TyEnv } from "./type";
29
+ import { matchTypes, normType, substType, unifyTypes, type TyEnv } from "./type";
42
30
 
43
31
  class Unif {}
44
32
  class NotPattern {}
@@ -427,7 +415,7 @@ const flexRigid = (
427
415
  return update(variable, mkAbsOver(binders, indexes, projected), updated);
428
416
  };
429
417
 
430
- export type PatternUnifyResult =
418
+ type PatternUnifyResult =
431
419
  | { kind: "unified"; envir: Envir }
432
420
  | { kind: "clash" }
433
421
  | { kind: "not a pattern" };
@@ -641,10 +629,3 @@ export const isFirstOrder = (term: Term): boolean => {
641
629
  return term.fun.kind !== "Var" && isFirstOrder(term.fun) && isFirstOrder(term.arg);
642
630
  return true;
643
631
  };
644
-
645
- // Pattern.match_rew
646
- export const matchRew = (term: Term, lhs: Term, rhs: Term): [Term, Term] | undefined => {
647
- const renamed = renameAbs(lhs, term, rhs) ?? rhs;
648
- const env = matchPattern(lhs, term, { tyenv: emptyTyEnv, tenv: emptyTEnv });
649
- return env === undefined ? undefined : [substTerm(env.tyenv, env.tenv, renamed), renamed];
650
- };
@@ -8,7 +8,7 @@ import { TlaIsabelleError } from "../../../errors";
8
8
  import { etaContract } from "./envir";
9
9
  import { symmetricThm } from "./drule";
10
10
  import { destEquals, isEquals, occs, stripImpConcl, stripImpPrems } from "./logic";
11
- import { deleteTermSafe, emptyNet, insertNet, keyOfTerm, type Net } from "./net";
11
+ import { emptyNet, insertNet, keyOfTerm, type Net } from "./net";
12
12
  import { isFirstOrder, isPattern, matches } from "./pattern";
13
13
  import { emptyTable, type Table } from "./table";
14
14
  import { emptyTEnv } from "./envir";
@@ -118,11 +118,7 @@ const hasNewTVar = (type: Typ, keys: ReadonlySet<string>): boolean => {
118
118
 
119
119
  // rewrite_rule_extra_vars: whether the right-hand sides have variables outside the left-hand side
120
120
  // and the premises.
121
- export const rewriteRuleExtraVars = (
122
- prems: readonly Term[],
123
- elhs: Term,
124
- erhss: readonly Term[],
125
- ) => {
121
+ const rewriteRuleExtraVars = (prems: readonly Term[], elhs: Term, erhss: readonly Term[]) => {
126
122
  const terms = [elhs, ...prems];
127
123
  const vars = terms.flatMap(varsOf);
128
124
  const tvars = new Set<string>();
@@ -205,7 +201,7 @@ interface Decomposed {
205
201
  readonly perm: boolean;
206
202
  }
207
203
 
208
- export const decompSimp = (thm: Thm): Decomposed => {
204
+ const decompSimp = (thm: Thm): Decomposed => {
209
205
  const prems = stripImpPrems(thm.prop);
210
206
  const concl = stripImpConcl(thm.prop);
211
207
  if (!isEquals(concl)) throw new TlaIsabelleError("ERROR", "Rewrite rule not a meta-equality");
@@ -293,23 +289,12 @@ export const insertRrule = (raw: RawRrule, simpset: Simpset): Simpset => {
293
289
  return rules === undefined ? simpset : { ...simpset, rules };
294
290
  };
295
291
 
296
- export const delRrule = (raw: RawRrule, simpset: Simpset): Simpset => {
297
- const rrule = mkRrule2(raw.thm, raw.lhs, raw.elhs, raw.perm);
298
- return { ...simpset, rules: deleteTermSafe(eqRrule, rrule.elhs, rrule, simpset.rules) };
299
- };
300
-
301
292
  export const addSimps = (context: SimpContext, thms: readonly Thm[]): Simpset =>
302
293
  thms
303
294
  .flatMap((thm) => context.simpset.mkRews.mk(thm, context))
304
295
  .flatMap((rew) => mkRrule(context, rew))
305
296
  .reduce((simpset, raw) => insertRrule(raw, simpset), context.simpset);
306
297
 
307
- export const delSimps = (context: SimpContext, thms: readonly Thm[]): Simpset =>
308
- thms
309
- .flatMap((thm) => context.simpset.mkRews.mk(thm, context))
310
- .flatMap((rew) => mkRrule(context, rew))
311
- .reduce((simpset, raw) => delRrule(raw, simpset), context.simpset);
312
-
313
298
  // mk_procrule: the rewrite rule a simplification procedure proves.
314
299
  export const mkProcrule = (thm: Thm): Rrule[] => {
315
300
  const decomposed = decompSimp(thm);
@@ -91,12 +91,6 @@ export const mappSeq = <Item, Result>(
91
91
  return copy(first);
92
92
  };
93
93
 
94
- export const interleaveSeq = <Item>(first: Seq<Item>, second: Seq<Item>): Seq<Item> =>
95
- deferSeq(() => {
96
- const cell = first.pull();
97
- return cell === undefined ? second : [cell[0], interleaveSeq(second, cell[1])];
98
- });
99
-
100
94
  export const filterSeq = <Item>(predicate: (item: Item) => boolean, seq: Seq<Item>): Seq<Item> => {
101
95
  const copy = (current: Seq<Item>): Seq<Item> =>
102
96
  makeSeq(() => {
@@ -124,15 +118,6 @@ export const mapsSeq = <Item, Result>(
124
118
  return cell === undefined ? undefined : appendSeq(map(cell[0]), mapsSeq(map, cell[1]));
125
119
  });
126
120
 
127
- export const mapFilterSeq = <Item, Result>(
128
- map: (item: Item) => Result | undefined,
129
- seq: Seq<Item>,
130
- ): Seq<Result> =>
131
- mapsSeq((item) => {
132
- const result = map(item);
133
- return result === undefined ? emptySeq : singleSeq(result);
134
- }, seq);
135
-
136
121
  // Seq.it_right: accumulates lazily from the right.
137
122
  export const itRightSeq = <Item, Result>(
138
123
  combine: (item: Item, rest: Seq<Result>) => Seq<Result>,
@@ -146,11 +131,3 @@ export const itRightSeq = <Item, Result>(
146
131
  });
147
132
  return its(seq);
148
133
  };
149
-
150
- export const takeSeq = <Item>(count: number, seq: Seq<Item>): Seq<Item> =>
151
- count <= 0
152
- ? emptySeq
153
- : makeSeq(() => {
154
- const cell = seq.pull();
155
- return cell === undefined ? undefined : [cell[0], takeSeq(count - 1, cell[1])];
156
- });
@@ -48,7 +48,7 @@ const singleProver =
48
48
  solveAllTac(solvers, context)(thm).pull()?.[0];
49
49
 
50
50
  // generic_simp_tac
51
- export const genericSimpTac =
51
+ const genericSimpTac =
52
52
  (isSafe: boolean, mode: RewriteMode) =>
53
53
  (context: SimpContext): GoalTactic =>
54
54
  (index) => {
@@ -62,10 +62,7 @@ export const genericSimpTac =
62
62
  );
63
63
  return preferGoal(simpLoopTac(1))(index);
64
64
  };
65
-
66
- export const simpTac = genericSimpTac(false, { simprem: false, useprem: false, mutsimp: false });
67
65
  export const asmSimpTac = genericSimpTac(false, { simprem: false, useprem: true, mutsimp: false });
68
- export const fullSimpTac = genericSimpTac(false, { simprem: true, useprem: false, mutsimp: false });
69
66
  export const asmLrSimpTac = genericSimpTac(false, { simprem: true, useprem: true, mutsimp: false });
70
67
  export const asmFullSimpTac = genericSimpTac(false, {
71
68
  simprem: true,
@@ -79,7 +76,7 @@ export const safeAsmFullSimpTac = genericSimpTac(true, {
79
76
  });
80
77
 
81
78
  // Simplifier.simp_thm: simplifies a theorem's proposition.
82
- export const simpThm = (mode: RewriteMode, context: SimpContext, thm: Thm): Thm => {
79
+ const simpThm = (mode: RewriteMode, context: SimpContext, thm: Thm): Thm => {
83
80
  const prover = singleProver([...context.simpset.unsafeSolvers].reverse());
84
81
  return fconvRule((term) => rewriteCterm(mode, prover, context, term), thm);
85
82
  };
@@ -87,9 +84,6 @@ export const simpThm = (mode: RewriteMode, context: SimpContext, thm: Thm): Thm
87
84
  export const simplify = (context: SimpContext, thm: Thm) =>
88
85
  simpThm({ simprem: false, useprem: false, mutsimp: false }, context, thm);
89
86
 
90
- export const fullSimplify = (context: SimpContext, thm: Thm) =>
91
- simpThm({ simprem: true, useprem: false, mutsimp: false }, context, thm);
92
-
93
87
  // Raw_Simplifier.norm_hhf: moves the quantifiers of a theorem left of its implications, then makes
94
88
  // the outermost ones schematic. Drule.sort_constraint_eq, the other rule of hhf_ss, never applies:
95
89
  // tlapm's terms carry no sort constraints.
@@ -175,12 +175,6 @@ export const tableEntries = <Key, Value>(table: Table<Key, Value>) =>
175
175
  [],
176
176
  );
177
177
 
178
- export const tableSize = <Key, Value>(table: Table<Key, Value>): number => {
179
- const count = (node: Node<Key, Value>): number =>
180
- node ? 1 + count(node.left) + count(node.right) : 0;
181
- return count(table.root);
182
- };
183
-
184
178
  // fast_string_ord: shorter strings first, then by code units.
185
179
  export const fastStringOrd = (left: string, right: string) =>
186
180
  left === right
@@ -191,8 +185,7 @@ export const fastStringOrd = (left: string, right: string) =>
191
185
  ? -1
192
186
  : 1;
193
187
 
194
- export const stringOrd = (left: string, right: string) =>
195
- left === right ? 0 : left < right ? -1 : 1;
188
+ const stringOrd = (left: string, right: string) => (left === right ? 0 : left < right ? -1 : 1);
196
189
 
197
190
  export interface IndexKey {
198
191
  readonly name: string;