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.
- package/README.md +31 -6
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/deciders.cjs +27 -27
- package/dist/deciders.js +34 -34
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +12 -14
- package/dist/index.d.ts +12 -14
- 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 +37 -27
- package/dist/prove.js +39 -29
- package/dist/run.cjs +45 -0
- package/dist/run.js +45 -0
- package/dist/tlapm.cjs +2 -2
- package/dist/tlapm.js +2 -2
- package/dist/transfer.cjs +76 -86
- package/dist/transfer.js +73 -83
- package/dist/worker.cjs +6 -6
- package/dist/worker.js +6 -6
- package/package.json +1 -1
- package/src/ast.ts +2 -2
- package/src/bags.ts +22 -23
- package/src/builtins.ts +16 -8
- package/src/check.ts +131 -1154
- package/src/{cli-options.ts → cli/options.ts} +54 -9
- package/src/cli/run.ts +63 -0
- package/src/cli/shared.ts +106 -0
- package/src/cli/tlapm.ts +374 -0
- package/src/cli/tlc.ts +941 -0
- package/src/cli/xml-exporter.ts +221 -0
- package/src/cli.ts +1 -1
- package/src/codegen.ts +17 -15
- package/src/config.ts +5 -5
- package/src/dependencies.ts +4 -6
- package/src/environment.ts +55 -60
- package/src/errors.ts +12 -36
- package/src/evaluate.ts +81 -101
- package/src/exit-codes.ts +1 -1
- package/src/fingerprints.ts +3 -3
- package/src/instances.ts +56 -46
- package/src/java-overrides.ts +79 -41
- package/src/json.ts +31 -36
- package/src/levels.ts +10 -13
- package/src/{live-check.ts → liveness-checker.ts} +169 -142
- package/src/liveness.ts +38 -34
- package/src/obligations/action.ts +9 -45
- package/src/obligations/{anon.ts → anonymize.ts} +13 -25
- package/src/obligations/equality.ts +260 -0
- package/src/obligations/expression.ts +42 -517
- package/src/obligations/generate.ts +88 -778
- package/src/obligations/index.ts +20 -22
- package/src/obligations/levels.ts +36 -41
- package/src/obligations/module.ts +88 -708
- package/src/obligations/normalize.ts +554 -0
- package/src/obligations/operators.ts +176 -0
- package/src/obligations/pragma.ts +21 -15
- package/src/obligations/printer.ts +81 -188
- package/src/obligations/proof.ts +0 -1
- package/src/obligations/regroup.ts +100 -0
- package/src/obligations/simplify.ts +668 -0
- package/src/obligations/source.ts +25 -131
- package/src/obligations/{deref.ts → subexpression.ts} +48 -56
- package/src/obligations/substitution.ts +261 -0
- package/src/obligations/temporal.ts +28 -26
- package/src/obligations/tuples.ts +37 -53
- package/src/parallel-worker.ts +37 -33
- package/src/parallel.ts +30 -24
- package/src/parser.ts +67 -74
- package/src/{pcal-ast.ts → pcal/ast.ts} +2 -17
- package/src/{pcal-parse.ts → pcal/parse.ts} +28 -64
- package/src/{pcal-tokenize.ts → pcal/tokenize.ts} +10 -39
- package/src/{pcal-translate.ts → pcal/translate.ts} +30 -109
- package/src/{pcal-validate.ts → pcal/validate.ts} +10 -20
- package/src/prove/decide-pool.ts +7 -12
- package/src/{obligations/pickle.ts → prove/first-order.ts} +79 -2
- package/src/prove/isabelle/decide.ts +3 -6
- package/src/prove/isabelle/encode.ts +35 -93
- package/src/prove/isabelle/isar/inner-syntax.ts +1 -1
- package/src/prove/isabelle/isar/method.ts +3 -3
- package/src/prove/isabelle/isar/type-check.ts +1 -1
- package/src/prove/isabelle/provers/blast/blast.ts +1 -1
- package/src/prove/isabelle/provers/blast/branch.ts +1 -1
- package/src/prove/isabelle/provers/blast/term.ts +3 -4
- package/src/prove/isabelle/provers/clasimp.ts +1 -1
- package/src/prove/isabelle/provers/classical.ts +3 -3
- package/src/prove/isabelle/provers/hypsubst.ts +1 -9
- package/src/prove/isabelle/pure/conv.ts +1 -1
- package/src/prove/isabelle/pure/drule.ts +2 -2
- package/src/prove/isabelle/pure/envir.ts +3 -35
- package/src/prove/isabelle/pure/logic.ts +4 -76
- package/src/prove/isabelle/pure/name.ts +1 -13
- package/src/prove/isabelle/pure/net.ts +2 -49
- package/src/prove/isabelle/pure/pattern.ts +3 -22
- package/src/prove/isabelle/pure/raw-simplifier.ts +3 -18
- package/src/prove/isabelle/pure/seq.ts +0 -23
- package/src/prove/isabelle/pure/simplifier.ts +2 -8
- package/src/prove/isabelle/pure/table.ts +1 -8
- package/src/prove/isabelle/pure/tactic.ts +5 -113
- package/src/prove/isabelle/pure/tactical.ts +1 -84
- package/src/prove/isabelle/pure/term-ord.ts +1 -55
- package/src/prove/isabelle/pure/term.ts +8 -128
- package/src/prove/isabelle/pure/thm.ts +4 -27
- package/src/prove/isabelle/pure/type.ts +0 -12
- package/src/prove/isabelle/pure/unify.ts +1 -1
- package/src/prove/isabelle/tla/classical-setup.ts +1 -1
- package/src/prove/ocaml.ts +1 -1
- package/src/prove/prep/action.ts +23 -36
- package/src/prove/prep/enabled-axioms.ts +2 -2
- package/src/prove/prep/fingerprint.ts +3 -3
- package/src/prove/prep/level-comparison.ts +9 -37
- package/src/prove/prep/md5.ts +2 -9
- package/src/prove/prep/normalize.ts +309 -0
- package/src/prove/prove-worker.ts +2 -5
- package/src/prove/prove.ts +98 -111
- package/src/prove/ptl/encode.ts +19 -31
- package/src/prove/smt/axioms.ts +45 -58
- package/src/prove/smt/encode.ts +124 -15
- package/src/prove/smt/instances.ts +2 -3
- package/src/prove/smt/rewrite.ts +24 -31
- package/src/prove/smt/solver/ast-util.ts +0 -56
- package/src/prove/smt/solver/case-split-queue.ts +1 -1
- package/src/prove/smt/solver/enode.ts +1 -1
- package/src/prove/smt/solver/lp/dep-intervals.ts +0 -14
- package/src/prove/smt/solver/model-macro-solver.ts +1 -1
- package/src/prove/smt/solver/nlsat/algebraic.ts +3 -3
- package/src/prove/smt/solver/nlsat/atoms.ts +1 -1
- package/src/prove/smt/solver/nlsat/explain.ts +1 -1
- package/src/prove/smt/solver/nlsat/interval-set.ts +1 -1
- package/src/prove/smt/solver/nlsat/levelwise.ts +4 -7
- package/src/prove/smt/solver/nlsat/polynomial.ts +4 -4
- package/src/prove/smt/solver/nlsat/upolynomial.ts +2 -2
- package/src/prove/smt/solver/pattern-inference.ts +1 -1
- package/src/prove/smt/solver/relevancy.ts +2 -2
- package/src/prove/smt/solver/rewriter.ts +1 -1
- package/src/prove/smt/solver/solver.ts +2 -2
- package/src/{tlapm-cache.ts → prove/tlapm/cache.ts} +11 -11
- package/src/{ocaml-marshal.ts → prove/tlapm/ocaml-marshal.ts} +1 -1
- package/src/prove/verdict.ts +0 -5
- package/src/prove/zenon/decide.ts +5 -11
- package/src/prove/zenon/encode.ts +21 -80
- package/src/prove/zenon/eqrel.ts +1 -1
- package/src/prove/zenon/equality-rules.ts +1 -1
- package/src/prove/zenon/expr.ts +2 -2
- package/src/prove/zenon/index-table.ts +1 -1
- package/src/prove/zenon/isar.ts +1 -1
- package/src/prove/zenon/llproof.ts +1 -1
- package/src/prove/zenon/mltoll.ts +1 -1
- package/src/prove/zenon/node.ts +1 -1
- package/src/prove/zenon/search.ts +1 -1
- package/src/prove/zenon/tla/terms.ts +1 -20
- package/src/prove/zenon/tla/tla.ts +1 -1
- package/src/randomization.ts +19 -24
- package/src/resolve.ts +15 -22
- package/src/runtime.ts +8 -8
- package/src/{sany-builtins.ts → sany/builtins.ts} +1 -1
- package/src/{sany-generator.ts → sany/generator.ts} +38 -55
- package/src/{sany-levels.ts → sany/levels.ts} +45 -48
- package/src/{sany-lexer.ts → sany/lexer.ts} +2 -3
- package/src/{sany-linter.ts → sany/linter.ts} +1 -1
- package/src/{sany-modules.ts → sany/modules.ts} +2 -2
- package/src/{sany-nodes.ts → sany/nodes.ts} +2 -2
- package/src/{sany-parse-error.ts → sany/parse-error.ts} +2 -2
- package/src/{sany-report.ts → sany/report.ts} +16 -17
- package/src/{sany-selectors.ts → sany/selectors.ts} +3 -5
- package/src/{sany-source.ts → sany/source.ts} +6 -7
- package/src/{sany-xml.ts → sany/xml.ts} +5 -6
- package/src/search.ts +969 -0
- package/src/spec-description.ts +26 -20
- package/src/{standard-levels.ts → standard-definitions.ts} +118 -2
- package/src/standard-modules.ts +16 -20
- package/src/state-graph.ts +9 -8
- package/src/substitution-levels.ts +2 -2
- package/src/successors.ts +16 -19
- package/src/symmetry.ts +1 -1
- package/src/tableau.ts +6 -7
- package/src/tlc/fingerprint.ts +214 -0
- package/src/{tlc-messages.ts → tlc/messages.ts} +119 -7
- package/src/{tlc-order.ts → tlc/order.ts} +7 -7
- package/src/{tlc-random.ts → tlc/random.ts} +3 -213
- package/src/{tlc-replay.ts → tlc/replay.ts} +40 -36
- package/src/{tlc-module.ts → tlc/tlc-operators.ts} +9 -9
- package/src/{tlc-ext.ts → tlc/tlcext-operators.ts} +30 -25
- package/src/transfer.ts +32 -32
- package/src/values.ts +72 -67
- package/src/worker.ts +1 -4
- package/dist/run-cli.cjs +0 -45
- package/dist/run-cli.js +0 -45
- package/src/canonical.ts +0 -40
- package/src/obligations/ctx.ts +0 -64
- package/src/prove/prep/defs.ts +0 -33
- package/src/prove/prep/elab.ts +0 -156
- package/src/prove/prep/enabled.ts +0 -43
- package/src/prove/prep/flatten.ts +0 -70
- package/src/prove/prep/trivial.ts +0 -22
- package/src/prove/smt/axiomatize.ts +0 -69
- package/src/prove/smt/simplify.ts +0 -57
- package/src/run-cli.ts +0 -1806
- package/src/standard-ranges.ts +0 -116
- package/src/value-sources.ts +0 -29
- /package/src/prove/prep/{pragma.ts → methods.ts} +0 -0
- /package/src/{tlc-modules.ts → tlc/jar-data.ts} +0 -0
- /package/src/{tlc-summary.ts → tlc/summary.ts} +0 -0
- /package/src/{tlc-version.ts → tlc/version.ts} +0 -0
|
@@ -90,18 +90,6 @@ export const matchTypes = (pattern: Typ, object: Typ, tyenv: TyEnv): TyEnv | und
|
|
|
90
90
|
return object.kind === "TFree" && object.name === pattern.name ? tyenv : undefined;
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
-
// Type.could_unify
|
|
94
|
-
export const couldUnifyTypes = (left: Typ, right: Typ): boolean => {
|
|
95
|
-
if (left.kind === "TVar" || right.kind === "TVar") return true;
|
|
96
|
-
if (left.kind === "Type" && right.kind === "Type")
|
|
97
|
-
return (
|
|
98
|
-
left.name === right.name &&
|
|
99
|
-
left.args.length === right.args.length &&
|
|
100
|
-
left.args.every((arg, index) => couldUnifyTypes(arg, right.args[index]))
|
|
101
|
-
);
|
|
102
|
-
return left.kind === "TFree" && right.kind === "TFree" && left.name === right.name;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
93
|
// Envir.norm_type: instantiates the assigned type variables, chasing chains.
|
|
106
94
|
export const normType = (tyenv: TyEnv, type: Typ): Typ => {
|
|
107
95
|
if (type.kind === "TFree") return type;
|
|
@@ -653,7 +653,7 @@ const addFfpair = (dpair: Dpair, envir: Envir, tpairs: readonly Tpair[]): [Envir
|
|
|
653
653
|
: cleanFfpair({ binders: dpair.binders, left, right }, envir, tpairs);
|
|
654
654
|
};
|
|
655
655
|
|
|
656
|
-
|
|
656
|
+
interface Unifier {
|
|
657
657
|
readonly envir: Envir;
|
|
658
658
|
readonly tpairs: readonly Tpair[];
|
|
659
659
|
}
|
|
@@ -37,7 +37,7 @@ const destBinary = (name: string, term: Term): [Term, Term] => {
|
|
|
37
37
|
throw new TlaIsabelleError("TERM", `dest ${name}`);
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
const destTrueprop = (term: Term): Term => {
|
|
41
41
|
if (
|
|
42
42
|
term.kind === "App" &&
|
|
43
43
|
term.fun.kind === "Const" &&
|
package/src/prove/ocaml.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The parts of OCaml's standard library whose exact order steers what tlapm prints.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
type OcamlValue = number | string | OcamlValue[];
|
|
4
4
|
|
|
5
5
|
// String.compare: byte by byte, on the UTF-8 bytes. Code units order the same way for the ASCII
|
|
6
6
|
// names tlapm compares.
|
package/src/prove/prep/action.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// down to the variables (Symbol_commute), and what remains modal becomes opaque (Coalesce).
|
|
4
4
|
|
|
5
5
|
import { TlapmBugError } from "../../errors";
|
|
6
|
-
import { rewriteUnchanged } from "../../obligations/
|
|
6
|
+
import { rewriteUnchanged } from "../../obligations/temporal";
|
|
7
7
|
import {
|
|
8
8
|
adjoin,
|
|
9
9
|
adjoinAll,
|
|
@@ -11,7 +11,10 @@ import {
|
|
|
11
11
|
at,
|
|
12
12
|
createContextMap,
|
|
13
13
|
getBoundedFresh,
|
|
14
|
+
getBoundFresh,
|
|
14
15
|
getFresh,
|
|
16
|
+
getLocalDefn,
|
|
17
|
+
getParamFresh,
|
|
15
18
|
getScopeAt,
|
|
16
19
|
getScopeHyps,
|
|
17
20
|
mapAccumulate,
|
|
@@ -82,7 +85,7 @@ const expandUnchanged: Rewrite = (scope, expression) =>
|
|
|
82
85
|
? rewriteUnchanged(expression.args[0])
|
|
83
86
|
: mapScoped(scope, expression, expandUnchanged, adjoin, "all");
|
|
84
87
|
|
|
85
|
-
const
|
|
88
|
+
const applyModal = (builtin: Builtin, expression: Expr) =>
|
|
86
89
|
applyBuiltin(builtin, [expression], expression);
|
|
87
90
|
|
|
88
91
|
// prime_commuter: a prime distributes down to the declarations that are not constant.
|
|
@@ -96,7 +99,7 @@ const commutePrime: Rewrite = (scope, expression) => {
|
|
|
96
99
|
getLevel(getScopeAt(scope, expression.index), hyp.definition.body) === 0
|
|
97
100
|
)
|
|
98
101
|
return expression;
|
|
99
|
-
return
|
|
102
|
+
return applyModal("Prime", expression);
|
|
100
103
|
}
|
|
101
104
|
if (
|
|
102
105
|
isBuiltin(expression, ["ENABLED"]) ||
|
|
@@ -104,7 +107,7 @@ const commutePrime: Rewrite = (scope, expression) => {
|
|
|
104
107
|
expression.kind === "Sequent" ||
|
|
105
108
|
expression.kind === "Let"
|
|
106
109
|
)
|
|
107
|
-
return
|
|
110
|
+
return applyModal("Prime", expression);
|
|
108
111
|
if (
|
|
109
112
|
isBuiltin(expression, [
|
|
110
113
|
"UNCHANGED",
|
|
@@ -137,7 +140,7 @@ const getModalCommuter = (builtin: "BoxTrue" | "Diamond"): Rewrite => {
|
|
|
137
140
|
expression.quantifier === quantifier);
|
|
138
141
|
return isDistributed
|
|
139
142
|
? mapScoped(scope, expression, commute, adjoin)
|
|
140
|
-
:
|
|
143
|
+
: applyModal(builtin, expression);
|
|
141
144
|
};
|
|
142
145
|
return commute;
|
|
143
146
|
};
|
|
@@ -160,9 +163,9 @@ const commuteSymbols: Rewrite = (scope, expression) => {
|
|
|
160
163
|
return mapScoped(scope, expression, commuteSymbols, adjoin, "all");
|
|
161
164
|
};
|
|
162
165
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
+
// The prefix rename_with_loc gives a declaration of each level, and a definition by the number of
|
|
167
|
+
// its body's level.
|
|
168
|
+
export const LEVEL_PREFIXES: Record<Level, string> = {
|
|
166
169
|
Constant: "CONSTANT",
|
|
167
170
|
State: "STATE",
|
|
168
171
|
Action: "ACTION",
|
|
@@ -170,6 +173,8 @@ const FRESH_KINDS: Record<Level, string> = {
|
|
|
170
173
|
Unknown: "Unknown",
|
|
171
174
|
};
|
|
172
175
|
|
|
176
|
+
export const LEVEL_NUMBER_PREFIXES = ["CONSTANT", "STATE", "ACTION", "TEMPORAL"];
|
|
177
|
+
|
|
173
178
|
const getRenamed = (kind: string, name: string) => `${kind}_${name}_`;
|
|
174
179
|
|
|
175
180
|
interface RenameState {
|
|
@@ -186,7 +191,7 @@ const renameDefn = (scope: Scope | undefined, definition: Defn, level?: number):
|
|
|
186
191
|
: definition;
|
|
187
192
|
}
|
|
188
193
|
const body = rename(scope, definition.body);
|
|
189
|
-
const kind =
|
|
194
|
+
const kind = LEVEL_NUMBER_PREFIXES[level ?? getLevel(scope, body)];
|
|
190
195
|
if (kind === undefined) throw new TlapmBugError();
|
|
191
196
|
return { ...definition, name: getRenamed(kind, definition.name), body };
|
|
192
197
|
};
|
|
@@ -196,7 +201,7 @@ const renameHyp = (scope: Scope | undefined, hyp: Hyp, level?: number): Hyp => {
|
|
|
196
201
|
case "Fresh":
|
|
197
202
|
return {
|
|
198
203
|
...hyp,
|
|
199
|
-
name: getRenamed(
|
|
204
|
+
name: getRenamed(LEVEL_PREFIXES[hyp.level], hyp.name),
|
|
200
205
|
domain: hyp.domain && rename(scope, hyp.domain),
|
|
201
206
|
};
|
|
202
207
|
case "Flex":
|
|
@@ -264,10 +269,7 @@ const rename: Rewrite = (scope, expression) => {
|
|
|
264
269
|
...param,
|
|
265
270
|
name: getRenamed("Unknown", param.name),
|
|
266
271
|
}));
|
|
267
|
-
const inner = adjoinAll(
|
|
268
|
-
scope,
|
|
269
|
-
params.map((param) => getFresh(param.name, "Unknown", param.shape)),
|
|
270
|
-
);
|
|
272
|
+
const inner = adjoinAll(scope, params.map(getParamFresh));
|
|
271
273
|
return { ...expression, params, body: rename(inner, expression.body) };
|
|
272
274
|
}
|
|
273
275
|
case "Tquant": {
|
|
@@ -294,16 +296,13 @@ const rename: Rewrite = (scope, expression) => {
|
|
|
294
296
|
case "SetOf": {
|
|
295
297
|
const bounds = expression.bounds.map((bound) => ({
|
|
296
298
|
...bound,
|
|
297
|
-
name: getRenamed(
|
|
299
|
+
name: getRenamed(LEVEL_PREFIXES[bound.level], bound.name),
|
|
298
300
|
domain:
|
|
299
301
|
bound.domain.kind === "Domain"
|
|
300
302
|
? { kind: "Domain" as const, expression: rename(scope, bound.domain.expression) }
|
|
301
303
|
: bound.domain,
|
|
302
304
|
}));
|
|
303
|
-
const inner = adjoinAll(
|
|
304
|
-
scope,
|
|
305
|
-
bounds.map((bound) => getFresh(bound.name, bound.level)),
|
|
306
|
-
);
|
|
305
|
+
const inner = adjoinAll(scope, bounds.map(getBoundFresh));
|
|
307
306
|
return expression.kind === "SetOf"
|
|
308
307
|
? { ...expression, bounds, element: rename(inner, expression.element) }
|
|
309
308
|
: { ...expression, bounds, body: rename(inner, expression.body) };
|
|
@@ -314,14 +313,7 @@ const rename: Rewrite = (scope, expression) => {
|
|
|
314
313
|
expression.definitions,
|
|
315
314
|
(current, definition) => {
|
|
316
315
|
const renamed = renameDefn(current, definition);
|
|
317
|
-
|
|
318
|
-
kind: "Defn",
|
|
319
|
-
definition: renamed,
|
|
320
|
-
whereDefined: "User",
|
|
321
|
-
visibility: "Visible",
|
|
322
|
-
isLocal: true,
|
|
323
|
-
};
|
|
324
|
-
return [adjoin(current, hyp), renamed];
|
|
316
|
+
return [adjoin(current, getLocalDefn(renamed)), renamed];
|
|
325
317
|
},
|
|
326
318
|
);
|
|
327
319
|
return { ...expression, definitions, body: rename(inner, expression.body) };
|
|
@@ -342,10 +334,7 @@ const getSubstitutiveArgs = (scope: Scope | undefined, definition: Defn): boolea
|
|
|
342
334
|
if (cached) return cached;
|
|
343
335
|
const body = definition.kind === "Operator" ? definition.body : undefined;
|
|
344
336
|
if (body?.kind !== "Lambda") return [];
|
|
345
|
-
const inner = adjoinAll(
|
|
346
|
-
scope,
|
|
347
|
-
body.params.map((param) => getFresh(param.name, "Unknown", param.shape)),
|
|
348
|
-
);
|
|
337
|
+
const inner = adjoinAll(scope, body.params.map(getParamFresh));
|
|
349
338
|
const result = body.params.map((_param, index) =>
|
|
350
339
|
isSubstitutive(inner, body.body, index + 1, true),
|
|
351
340
|
);
|
|
@@ -415,13 +404,11 @@ const isSubstitutive = (
|
|
|
415
404
|
|
|
416
405
|
// Coalesce.crypthash: h and the first five hexadecimal digits of the MD5 of the expression as
|
|
417
406
|
// tlapm prints it.
|
|
418
|
-
const getHashName = (
|
|
419
|
-
|
|
420
|
-
return `h${getMd5(text).slice(0, 5)}`;
|
|
421
|
-
};
|
|
407
|
+
export const getHashName = (hyps: Hyp[], expression: Expr) =>
|
|
408
|
+
`h${getMd5(renderDoc(printExpression(hyps, expression))).slice(0, 5)}`;
|
|
422
409
|
|
|
423
410
|
const coalesce = (scope: Scope | undefined, expression: Expr): Expr =>
|
|
424
|
-
at({ kind: "Opaque", name: getHashName(scope, expression) }, expression);
|
|
411
|
+
at({ kind: "Opaque", name: getHashName(getScopeHyps(scope), expression) }, expression);
|
|
425
412
|
|
|
426
413
|
// coalesce_operator: an operator applied to arguments that are not all substitutive is opaque,
|
|
427
414
|
// hiding the arguments that are constant or substitutive.
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// from facts of the form the rule needs.
|
|
3
3
|
|
|
4
4
|
import { TlapmBugError, TlaProverError } from "../../errors";
|
|
5
|
+
import { shiftExpr } from "../../obligations/substitution";
|
|
6
|
+
import { isEqualExpr } from "../../obligations/equality";
|
|
5
7
|
import {
|
|
6
8
|
adjoin,
|
|
7
9
|
adjoinAll,
|
|
8
10
|
getScopeAt,
|
|
9
|
-
isEqualExpr,
|
|
10
11
|
mapScoped,
|
|
11
|
-
shiftExpr,
|
|
12
12
|
type Builtin,
|
|
13
13
|
type Expr,
|
|
14
14
|
type Scope,
|
|
@@ -150,7 +150,7 @@ const getFreshLabel = (hyp: Extract<Hyp, { kind: "Fresh" }>) =>
|
|
|
150
150
|
// fp_sequent's text for an obligation, before its digest.
|
|
151
151
|
const getFingerprintText = (sequent: Sequent) => {
|
|
152
152
|
const stack: Entry[] = [];
|
|
153
|
-
const
|
|
153
|
+
const getEntry = (index: number) => {
|
|
154
154
|
const entry = stack[stack.length - index];
|
|
155
155
|
if (!entry) throw new TlapmBugError();
|
|
156
156
|
return entry;
|
|
@@ -197,7 +197,7 @@ const getFingerprintText = (sequent: Sequent) => {
|
|
|
197
197
|
entries.map((entry) => `${getVariableNumber(entry)}.`).join("");
|
|
198
198
|
switch (expression.kind) {
|
|
199
199
|
case "Ix": {
|
|
200
|
-
const entry =
|
|
200
|
+
const entry = getEntry(expression.index);
|
|
201
201
|
entry.isUsed = true;
|
|
202
202
|
const ident = entry.ident;
|
|
203
203
|
switch (ident.kind) {
|
|
@@ -234,7 +234,7 @@ const getFingerprintText = (sequent: Sequent) => {
|
|
|
234
234
|
return printSequent(expression.sequent);
|
|
235
235
|
case "Apply": {
|
|
236
236
|
const operator = expression.operator;
|
|
237
|
-
if (operator.kind === "Ix" &&
|
|
237
|
+
if (operator.kind === "Ix" && getEntry(operator.index).ident.kind === "Pragma") return "";
|
|
238
238
|
return `$OpApp(${print(operator)};${printList(expression.args)})`;
|
|
239
239
|
}
|
|
240
240
|
case "With":
|
|
@@ -7,7 +7,10 @@ import {
|
|
|
7
7
|
adjoin,
|
|
8
8
|
adjoinAll,
|
|
9
9
|
getBoundedFresh,
|
|
10
|
+
getBoundFresh,
|
|
10
11
|
getFresh,
|
|
12
|
+
getLocalDefn,
|
|
13
|
+
getParamFresh,
|
|
11
14
|
getScopeAt,
|
|
12
15
|
getScopeHyps,
|
|
13
16
|
type Bound,
|
|
@@ -64,28 +67,13 @@ const getDeclaration = (scope: Scope | undefined, index: number): Declaration =>
|
|
|
64
67
|
};
|
|
65
68
|
|
|
66
69
|
const bindBounds = (scope: Scope | undefined, bounds: Bound[]) =>
|
|
67
|
-
adjoinAll(
|
|
68
|
-
scope,
|
|
69
|
-
bounds.map((bound) => getFresh(bound.name, bound.level)),
|
|
70
|
-
);
|
|
70
|
+
adjoinAll(scope, bounds.map(getBoundFresh));
|
|
71
71
|
|
|
72
72
|
const bindParams = (scope: Scope | undefined, params: Param[]) =>
|
|
73
|
-
adjoinAll(
|
|
74
|
-
scope,
|
|
75
|
-
params.map((param) => getFresh(param.name, "Unknown", param.shape)),
|
|
76
|
-
);
|
|
73
|
+
adjoinAll(scope, params.map(getParamFresh));
|
|
77
74
|
|
|
78
75
|
const bindDefinitions = (scope: Scope | undefined, definitions: Defn[]) =>
|
|
79
|
-
adjoinAll(
|
|
80
|
-
scope,
|
|
81
|
-
definitions.map((definition) => ({
|
|
82
|
-
kind: "Defn",
|
|
83
|
-
definition,
|
|
84
|
-
whereDefined: "User",
|
|
85
|
-
visibility: "Visible",
|
|
86
|
-
isLocal: true,
|
|
87
|
-
})),
|
|
88
|
-
);
|
|
76
|
+
adjoinAll(scope, definitions.map(getLocalDefn));
|
|
89
77
|
|
|
90
78
|
const bindFlexible = (scope: Scope | undefined, names: string[]) =>
|
|
91
79
|
adjoinAll(
|
|
@@ -389,9 +377,8 @@ const compare = (
|
|
|
389
377
|
)
|
|
390
378
|
);
|
|
391
379
|
case "Choose":
|
|
392
|
-
return right.kind === "Choose" && isSameBinder(leftScope, rightScope, left, right);
|
|
393
380
|
case "SetSt":
|
|
394
|
-
return right.kind ===
|
|
381
|
+
return right.kind === left.kind && isSameBinder(leftScope, rightScope, left, right);
|
|
395
382
|
case "SetOf":
|
|
396
383
|
return (
|
|
397
384
|
right.kind === "SetOf" &&
|
|
@@ -432,18 +419,9 @@ const compare = (
|
|
|
432
419
|
case "Product":
|
|
433
420
|
return right.kind === "Product" && recurseList(left.factors, right.factors);
|
|
434
421
|
case "Rect":
|
|
435
|
-
return (
|
|
436
|
-
right.kind === "Rect" &&
|
|
437
|
-
isSameFields(
|
|
438
|
-
leftScope,
|
|
439
|
-
rightScope,
|
|
440
|
-
getSortedFields(left.fields),
|
|
441
|
-
getSortedFields(right.fields),
|
|
442
|
-
)
|
|
443
|
-
);
|
|
444
422
|
case "Record":
|
|
445
423
|
return (
|
|
446
|
-
right.kind ===
|
|
424
|
+
right.kind === left.kind &&
|
|
447
425
|
isSameFields(
|
|
448
426
|
leftScope,
|
|
449
427
|
rightScope,
|
|
@@ -477,15 +455,9 @@ const compare = (
|
|
|
477
455
|
left.field === right.field
|
|
478
456
|
);
|
|
479
457
|
case "Sub":
|
|
480
|
-
return (
|
|
481
|
-
right.kind === "Sub" &&
|
|
482
|
-
left.modal === right.modal &&
|
|
483
|
-
recurse(left.action, right.action) &&
|
|
484
|
-
recurse(left.subscript, right.subscript)
|
|
485
|
-
);
|
|
486
458
|
case "Tsub":
|
|
487
459
|
return (
|
|
488
|
-
right.kind ===
|
|
460
|
+
right.kind === left.kind &&
|
|
489
461
|
left.modal === right.modal &&
|
|
490
462
|
recurse(left.action, right.action) &&
|
|
491
463
|
recurse(left.subscript, right.subscript)
|
package/src/prove/prep/md5.ts
CHANGED
|
@@ -22,7 +22,7 @@ export const getMd5 = (text: string): string => {
|
|
|
22
22
|
const words = Array.from({ length: 16 }, (_value, index) =>
|
|
23
23
|
view.getUint32(offset + index * 4, true),
|
|
24
24
|
);
|
|
25
|
-
const
|
|
25
|
+
const mixedState = Array.from({ length: 64 }).reduce<number[]>(
|
|
26
26
|
([innerA, innerB, innerC, innerD], _value, index) => {
|
|
27
27
|
const round = Math.floor(index / 16);
|
|
28
28
|
const mixed =
|
|
@@ -51,14 +51,7 @@ export const getMd5 = (text: string): string => {
|
|
|
51
51
|
},
|
|
52
52
|
state,
|
|
53
53
|
);
|
|
54
|
-
state.splice(
|
|
55
|
-
0,
|
|
56
|
-
4,
|
|
57
|
-
(state[0] + a) | 0,
|
|
58
|
-
(state[1] + b) | 0,
|
|
59
|
-
(state[2] + c) | 0,
|
|
60
|
-
(state[3] + d) | 0,
|
|
61
|
-
);
|
|
54
|
+
state.splice(0, 4, ...state.map((word, index) => (word + mixedState[index]) | 0));
|
|
62
55
|
}
|
|
63
56
|
return state
|
|
64
57
|
.flatMap((word) => [word, word >>> 8, word >>> 16, word >>> 24])
|