tla-ts 0.0.4-dev.a0009b7 → 0.0.4-dev.c4929d7
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 +27 -141
- package/dist/deciders.cjs +366 -0
- package/dist/deciders.js +366 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +37 -1
- package/dist/index.d.ts +37 -1
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -4
- package/dist/parallel-worker.js +1 -4
- package/dist/prove-worker.cjs +9 -0
- package/dist/prove-worker.d.cts +9 -0
- package/dist/prove-worker.d.ts +9 -0
- package/dist/prove-worker.js +9 -0
- package/dist/prove.cjs +996 -0
- package/dist/prove.js +996 -0
- package/dist/run-cli.cjs +37 -47
- package/dist/run-cli.js +37 -47
- package/dist/tlapm.cjs +10 -0
- package/dist/tlapm.js +10 -0
- package/dist/transfer.cjs +38 -44
- package/dist/transfer.js +38 -44
- package/dist/worker.cjs +21 -0
- package/dist/worker.js +21 -0
- package/package.json +21 -12
- package/src/check.ts +1 -0
- package/src/codegen.ts +26 -7
- package/src/errors.ts +86 -0
- package/src/evaluate.ts +63 -20
- package/src/index.ts +10 -0
- package/src/{obligation-action.ts → obligations/action.ts} +265 -55
- package/src/{obligation-anon.ts → obligations/anon.ts} +47 -37
- package/src/obligations/ctx.ts +64 -0
- package/src/{obligation-deref.ts → obligations/deref.ts} +38 -61
- package/src/{obligation-expression.ts → obligations/expression.ts} +78 -45
- package/src/{obligation-format.ts → obligations/format.ts} +7 -8
- package/src/{obligation-generate.ts → obligations/generate.ts} +147 -74
- package/src/{obligations.ts → obligations/index.ts} +29 -13
- package/src/{obligation-levels.ts → obligations/levels.ts} +14 -5
- package/src/{obligation-module.ts → obligations/module.ts} +56 -33
- package/src/obligations/pickle.ts +98 -0
- package/src/obligations/pragma.ts +189 -0
- package/src/{obligation-printer.ts → obligations/printer.ts} +22 -80
- package/src/{obligation-proof.ts → obligations/proof.ts} +7 -1
- package/src/{obligation-source.ts → obligations/source.ts} +159 -97
- package/src/obligations/temporal.ts +319 -0
- package/src/{obligation-tuples.ts → obligations/tuples.ts} +1 -1
- package/src/ocaml-marshal.ts +166 -0
- package/src/parallel-worker.ts +2 -18
- package/src/parallel.ts +10 -43
- package/src/prove/decide-pool.ts +100 -0
- package/src/prove/deciders.ts +33 -0
- package/src/prove/isabelle/LICENSE +36 -0
- package/src/prove/isabelle/LICENSE-tlapm +26 -0
- package/src/prove/isabelle/decide.ts +47 -0
- package/src/prove/isabelle/encode.ts +503 -0
- package/src/prove/isabelle/isar/inner-syntax.ts +579 -0
- package/src/prove/isabelle/isar/method.ts +367 -0
- package/src/prove/isabelle/isar/proof.ts +28 -0
- package/src/prove/isabelle/isar/statement.ts +57 -0
- package/src/prove/isabelle/isar/theory.ts +192 -0
- package/src/prove/isabelle/isar/type-check.ts +278 -0
- package/src/prove/isabelle/provers/blast/blast.ts +258 -0
- package/src/prove/isabelle/provers/blast/branch.ts +322 -0
- package/src/prove/isabelle/provers/blast/prove.ts +347 -0
- package/src/prove/isabelle/provers/blast/rules.ts +330 -0
- package/src/prove/isabelle/provers/blast/state.ts +180 -0
- package/src/prove/isabelle/provers/blast/term.ts +547 -0
- package/src/prove/isabelle/provers/clasimp.ts +150 -0
- package/src/prove/isabelle/provers/classical.ts +389 -0
- package/src/prove/isabelle/provers/hypsubst.ts +441 -0
- package/src/prove/isabelle/pure/bicompose.ts +174 -0
- package/src/prove/isabelle/pure/consts.ts +32 -0
- package/src/prove/isabelle/pure/conv.ts +79 -0
- package/src/prove/isabelle/pure/drule.ts +264 -0
- package/src/prove/isabelle/pure/envir.ts +363 -0
- package/src/prove/isabelle/pure/goal.ts +53 -0
- package/src/prove/isabelle/pure/interrupt.ts +16 -0
- package/src/prove/isabelle/pure/list.ts +12 -0
- package/src/prove/isabelle/pure/logic.ts +402 -0
- package/src/prove/isabelle/pure/name.ts +110 -0
- package/src/prove/isabelle/pure/net.ts +262 -0
- package/src/prove/isabelle/pure/object-logic.ts +41 -0
- package/src/prove/isabelle/pure/pattern.ts +650 -0
- package/src/prove/isabelle/pure/raw-simplifier.ts +353 -0
- package/src/prove/isabelle/pure/rewriter.ts +602 -0
- package/src/prove/isabelle/pure/search.ts +68 -0
- package/src/prove/isabelle/pure/seq.ts +156 -0
- package/src/prove/isabelle/pure/simplifier.ts +112 -0
- package/src/prove/isabelle/pure/table.ts +208 -0
- package/src/prove/isabelle/pure/tactic.ts +276 -0
- package/src/prove/isabelle/pure/tactical.ts +347 -0
- package/src/prove/isabelle/pure/term-ord.ts +159 -0
- package/src/prove/isabelle/pure/term.ts +808 -0
- package/src/prove/isabelle/pure/thm.ts +806 -0
- package/src/prove/isabelle/pure/type.ts +133 -0
- package/src/prove/isabelle/pure/unify.ts +753 -0
- package/src/prove/isabelle/pure/variable.ts +25 -0
- package/src/prove/isabelle/tla/classical-setup.ts +101 -0
- package/src/prove/isabelle/tla/context.ts +74 -0
- package/src/prove/isabelle/tla/logic-data.ts +5 -0
- package/src/prove/isabelle/tla/logic.ts +215 -0
- package/src/prove/isabelle/tla/simpdata.ts +241 -0
- package/src/prove/isabelle/tools/intuitionistic.ts +132 -0
- package/src/prove/ocaml.ts +22 -0
- package/src/prove/prep/action.ts +521 -0
- package/src/prove/prep/defs.ts +33 -0
- package/src/prove/prep/elab.ts +156 -0
- package/src/prove/prep/enabled-axioms.ts +189 -0
- package/src/prove/prep/enabled.ts +43 -0
- package/src/prove/prep/fingerprint.ts +388 -0
- package/src/prove/prep/flatten.ts +70 -0
- package/src/prove/prep/level-comparison.ts +557 -0
- package/src/prove/prep/md5.ts +67 -0
- package/src/prove/prep/pragma.ts +221 -0
- package/src/prove/prep/trivial.ts +22 -0
- package/src/prove/prove-worker.ts +25 -0
- package/src/prove/prove.ts +505 -0
- package/src/prove/ptl/decide.ts +68 -0
- package/src/prove/ptl/encode.ts +256 -0
- package/src/prove/ptl/sat.ts +151 -0
- package/src/prove/ptl/tableau.ts +276 -0
- package/src/prove/smt/axiomatize.ts +69 -0
- package/src/prove/smt/axioms.ts +222 -0
- package/src/prove/smt/context.ts +108 -0
- package/src/prove/smt/data.ts +636 -0
- package/src/prove/smt/encode.ts +166 -0
- package/src/prove/smt/extensionality.ts +65 -0
- package/src/prove/smt/flatten.ts +112 -0
- package/src/prove/smt/format.ts +154 -0
- package/src/prove/smt/instances.ts +182 -0
- package/src/prove/smt/rewrite.ts +773 -0
- package/src/prove/smt/simplify.ts +57 -0
- package/src/prove/smt/solver/act-cache.ts +265 -0
- package/src/prove/smt/solver/arith-rewriter.ts +962 -0
- package/src/prove/smt/solver/array.ts +22 -0
- package/src/prove/smt/solver/asserted-formulas.ts +469 -0
- package/src/prove/smt/solver/ast-lt.ts +157 -0
- package/src/prove/smt/solver/ast-util.ts +147 -0
- package/src/prove/smt/solver/ast.ts +1315 -0
- package/src/prove/smt/solver/auf-solver.ts +572 -0
- package/src/prove/smt/solver/case-split-queue.ts +178 -0
- package/src/prove/smt/solver/cg-table.ts +175 -0
- package/src/prove/smt/solver/clause.ts +276 -0
- package/src/prove/smt/solver/conflict-resolution.ts +343 -0
- package/src/prove/smt/solver/context.ts +1292 -0
- package/src/prove/smt/solver/ctx-simplify.ts +334 -0
- package/src/prove/smt/solver/der.ts +224 -0
- package/src/prove/smt/solver/dyn-ack.ts +141 -0
- package/src/prove/smt/solver/e-matching.ts +659 -0
- package/src/prove/smt/solver/enode.ts +259 -0
- package/src/prove/smt/solver/expr-ref.ts +21 -0
- package/src/prove/smt/solver/expr-safe-replace.ts +172 -0
- package/src/prove/smt/solver/fingerprints.ts +92 -0
- package/src/prove/smt/solver/flat-literals.ts +51 -0
- package/src/prove/smt/solver/goal.ts +138 -0
- package/src/prove/smt/solver/hash.ts +173 -0
- package/src/prove/smt/solver/hashtable.ts +166 -0
- package/src/prove/smt/solver/internalizer.ts +1381 -0
- package/src/prove/smt/solver/lbool.ts +5 -0
- package/src/prove/smt/solver/literal.ts +24 -0
- package/src/prove/smt/solver/lp/bound-propagator.ts +391 -0
- package/src/prove/smt/solver/lp/constraints.ts +78 -0
- package/src/prove/smt/solver/lp/containers.ts +296 -0
- package/src/prove/smt/solver/lp/core-solver.ts +504 -0
- package/src/prove/smt/solver/lp/cross-nested.ts +224 -0
- package/src/prove/smt/solver/lp/dep-intervals.ts +656 -0
- package/src/prove/smt/solver/lp/dependency.ts +51 -0
- package/src/prove/smt/solver/lp/dioph-eq.ts +1181 -0
- package/src/prove/smt/solver/lp/explanation.ts +46 -0
- package/src/prove/smt/solver/lp/gomory.ts +255 -0
- package/src/prove/smt/solver/lp/hnf-cutter.ts +125 -0
- package/src/prove/smt/solver/lp/hnf.ts +281 -0
- package/src/prove/smt/solver/lp/int-cube.ts +295 -0
- package/src/prove/smt/solver/lp/int-solver.ts +514 -0
- package/src/prove/smt/solver/lp/lar-solver.ts +816 -0
- package/src/prove/smt/solver/lp/lar-term.ts +62 -0
- package/src/prove/smt/solver/lp/lp-settings.ts +91 -0
- package/src/prove/smt/solver/lp/maximize-term.ts +347 -0
- package/src/prove/smt/solver/lp/nex-creator.ts +381 -0
- package/src/prove/smt/solver/lp/nex.ts +120 -0
- package/src/prove/smt/solver/lp/nla-backoff.ts +43 -0
- package/src/prove/smt/solver/lp/nla-basics.ts +398 -0
- package/src/prove/smt/solver/lp/nla-core.ts +968 -0
- package/src/prove/smt/solver/lp/nla-divisions.ts +332 -0
- package/src/prove/smt/solver/lp/nla-emonics.ts +373 -0
- package/src/prove/smt/solver/lp/nla-factorization.ts +30 -0
- package/src/prove/smt/solver/lp/nla-grobner.ts +904 -0
- package/src/prove/smt/solver/lp/nla-horner.ts +126 -0
- package/src/prove/smt/solver/lp/nla-intervals.ts +265 -0
- package/src/prove/smt/solver/lp/nla-monomial-bounds.ts +715 -0
- package/src/prove/smt/solver/lp/nla-monotone.ts +59 -0
- package/src/prove/smt/solver/lp/nla-order.ts +307 -0
- package/src/prove/smt/solver/lp/nla-patcher.ts +112 -0
- package/src/prove/smt/solver/lp/nla-tangents.ts +251 -0
- package/src/prove/smt/solver/lp/nla-throttle.ts +85 -0
- package/src/prove/smt/solver/lp/nla-types.ts +124 -0
- package/src/prove/smt/solver/lp/nla-var-eqs.ts +141 -0
- package/src/prove/smt/solver/lp/nra-solver.ts +440 -0
- package/src/prove/smt/solver/lp/numeric-pair.ts +65 -0
- package/src/prove/smt/solver/lp/pdd-interval.ts +31 -0
- package/src/prove/smt/solver/lp/pdd-simplifier.ts +184 -0
- package/src/prove/smt/solver/lp/pdd-solver.ts +408 -0
- package/src/prove/smt/solver/lp/pdd.ts +971 -0
- package/src/prove/smt/solver/lp/random-updater.ts +138 -0
- package/src/prove/smt/solver/lp/static-matrix.ts +246 -0
- package/src/prove/smt/solver/lp/union-find.ts +96 -0
- package/src/prove/smt/solver/mam-compiler.ts +847 -0
- package/src/prove/smt/solver/mam-interpreter.ts +400 -0
- package/src/prove/smt/solver/maximize-ac-sharing.ts +118 -0
- package/src/prove/smt/solver/model-checker.ts +347 -0
- package/src/prove/smt/solver/model-evaluator.ts +262 -0
- package/src/prove/smt/solver/model-finder.ts +155 -0
- package/src/prove/smt/solver/model-generator.ts +97 -0
- package/src/prove/smt/solver/model-macro-solver.ts +728 -0
- package/src/prove/smt/solver/nlsat/algebraic.ts +1161 -0
- package/src/prove/smt/solver/nlsat/atoms.ts +238 -0
- package/src/prove/smt/solver/nlsat/evaluator.ts +303 -0
- package/src/prove/smt/solver/nlsat/explain.ts +607 -0
- package/src/prove/smt/solver/nlsat/interval-set.ts +351 -0
- package/src/prove/smt/solver/nlsat/levelwise.ts +740 -0
- package/src/prove/smt/solver/nlsat/mpbq.ts +161 -0
- package/src/prove/smt/solver/nlsat/polynomial.ts +1722 -0
- package/src/prove/smt/solver/nlsat/solver.ts +911 -0
- package/src/prove/smt/solver/nlsat/types.ts +43 -0
- package/src/prove/smt/solver/nlsat/upolynomial-factorization.ts +648 -0
- package/src/prove/smt/solver/nlsat/upolynomial.ts +996 -0
- package/src/prove/smt/solver/nnf.ts +469 -0
- package/src/prove/smt/solver/pattern-inference.ts +351 -0
- package/src/prove/smt/solver/poly-rewriter.ts +477 -0
- package/src/prove/smt/solver/propagate-values.ts +83 -0
- package/src/prove/smt/solver/proto-model.ts +551 -0
- package/src/prove/smt/solver/pull-quant.ts +139 -0
- package/src/prove/smt/solver/qe-lite-der.ts +526 -0
- package/src/prove/smt/solver/qe-lite-fm.ts +576 -0
- package/src/prove/smt/solver/qe-lite.ts +381 -0
- package/src/prove/smt/solver/qi-queue.ts +362 -0
- package/src/prove/smt/solver/quant-tactics.ts +117 -0
- package/src/prove/smt/solver/quantifier-analyzer.ts +562 -0
- package/src/prove/smt/solver/quantifier-manager.ts +186 -0
- package/src/prove/smt/solver/random-gen.ts +10 -0
- package/src/prove/smt/solver/rational.ts +165 -0
- package/src/prove/smt/solver/ref-vector.ts +62 -0
- package/src/prove/smt/solver/relevancy.ts +247 -0
- package/src/prove/smt/solver/rewriter-tpl.ts +1159 -0
- package/src/prove/smt/solver/rewriter.ts +843 -0
- package/src/prove/smt/solver/rlimit.ts +79 -0
- package/src/prove/smt/solver/smtlib-parser.ts +526 -0
- package/src/prove/smt/solver/solver.ts +71 -0
- package/src/prove/smt/solver/sort.ts +35 -0
- package/src/prove/smt/solver/sticky-generations.ts +69 -0
- package/src/prove/smt/solver/theory-lra-axioms.ts +340 -0
- package/src/prove/smt/solver/theory-lra-bounds.ts +226 -0
- package/src/prove/smt/solver/theory-lra-final-check.ts +252 -0
- package/src/prove/smt/solver/theory-lra-internalize.ts +476 -0
- package/src/prove/smt/solver/theory-lra-model.ts +243 -0
- package/src/prove/smt/solver/theory-lra-propagate.ts +405 -0
- package/src/prove/smt/solver/theory-lra-state.ts +43 -0
- package/src/prove/smt/solver/theory-lra.ts +56 -0
- package/src/prove/smt/solver/var-subst.ts +258 -0
- package/src/prove/smt/solver/z3-license.txt +10 -0
- package/src/prove/smt/table.ts +170 -0
- package/src/prove/tlapm/tlapm.ts +96 -0
- package/src/prove/tlaps-module.ts +510 -0
- package/src/prove/verdict.ts +18 -0
- package/src/prove/zenon/LICENSE +32 -0
- package/src/prove/zenon/check/check.ts +105 -0
- package/src/prove/zenon/check/definitions.ts +144 -0
- package/src/prove/zenon/check/equality.ts +182 -0
- package/src/prove/zenon/check/functions.ts +62 -0
- package/src/prove/zenon/check/keys.ts +125 -0
- package/src/prove/zenon/check/propositional.ts +104 -0
- package/src/prove/zenon/check/records.ts +188 -0
- package/src/prove/zenon/check/relations.ts +121 -0
- package/src/prove/zenon/check/rewrites.ts +224 -0
- package/src/prove/zenon/check/sets.ts +302 -0
- package/src/prove/zenon/check/terms.ts +127 -0
- package/src/prove/zenon/check/tla.ts +126 -0
- package/src/prove/zenon/decide.ts +113 -0
- package/src/prove/zenon/encode.ts +437 -0
- package/src/prove/zenon/eqrel.ts +300 -0
- package/src/prove/zenon/equality-rules.ts +435 -0
- package/src/prove/zenon/expr.ts +551 -0
- package/src/prove/zenon/index-table.ts +350 -0
- package/src/prove/zenon/isar-case.ts +513 -0
- package/src/prove/zenon/isar.ts +1249 -0
- package/src/prove/zenon/limits.ts +15 -0
- package/src/prove/zenon/llproof.ts +173 -0
- package/src/prove/zenon/mltoll.ts +1566 -0
- package/src/prove/zenon/node.ts +297 -0
- package/src/prove/zenon/ocaml.ts +169 -0
- package/src/prove/zenon/parse.ts +247 -0
- package/src/prove/zenon/phrase.ts +191 -0
- package/src/prove/zenon/proof.ts +198 -0
- package/src/prove/zenon/propositional-rules.ts +387 -0
- package/src/prove/zenon/rules.ts +94 -0
- package/src/prove/zenon/search.ts +288 -0
- package/src/prove/zenon/tla/functions.ts +151 -0
- package/src/prove/zenon/tla/llproof.ts +480 -0
- package/src/prove/zenon/tla/records.ts +225 -0
- package/src/prove/zenon/tla/rewrites.ts +447 -0
- package/src/prove/zenon/tla/sets.ts +304 -0
- package/src/prove/zenon/tla/terms.ts +181 -0
- package/src/prove/zenon/tla/tla.ts +506 -0
- package/src/run-cli.ts +334 -75
- package/src/standard-modules.ts +5 -2
- package/src/successors.ts +24 -5
- package/src/tlapm-cache.ts +236 -0
- package/src/tlc-random.ts +55 -32
- package/src/tlc-version.ts +8 -7
- package/src/values.ts +97 -47
- package/src/worker.ts +65 -0
- package/dist/parallel.cjs +0 -12
- package/dist/parallel.js +0 -12
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// tlapm's proof IR (P_t).
|
|
2
2
|
|
|
3
|
-
import type { Bound, Defn, Expr, Locus, Sequent } from "./
|
|
3
|
+
import type { Bound, Defn, Expr, Locus, Sequent } from "./expression";
|
|
4
|
+
import type { OldMethod } from "./pragma";
|
|
4
5
|
|
|
5
6
|
export type StepNumber =
|
|
6
7
|
| { kind: "Named"; level: number; label: string; isAnonymous: boolean }
|
|
@@ -23,17 +24,22 @@ export type ObligationKind =
|
|
|
23
24
|
| { kind: "Error"; message: string }
|
|
24
25
|
| { kind: "Omitted"; omission: Omission };
|
|
25
26
|
|
|
27
|
+
// method is the one an old-style pragma names, which keeps find_meth from choosing.
|
|
26
28
|
export interface Obligation {
|
|
27
29
|
sequent: Sequent;
|
|
28
30
|
location: Locus | undefined;
|
|
29
31
|
kind: ObligationKind;
|
|
32
|
+
method?: OldMethod;
|
|
30
33
|
}
|
|
31
34
|
|
|
35
|
+
// useLocation is where a USE step comes from, so find_meth can tell apart the facts of each BY.
|
|
32
36
|
interface ProofProps {
|
|
33
37
|
location?: Locus;
|
|
34
38
|
step?: StepNumber;
|
|
35
39
|
isSuppressed?: boolean;
|
|
36
40
|
obligations?: Obligation[];
|
|
41
|
+
method?: OldMethod;
|
|
42
|
+
useLocation?: Locus;
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
export type Proof = ProofCore & ProofProps;
|
|
@@ -14,8 +14,8 @@ import type {
|
|
|
14
14
|
SourceLocation,
|
|
15
15
|
SourceRange,
|
|
16
16
|
UseOrHide,
|
|
17
|
-
} from "
|
|
18
|
-
import { TlaProofError, TlaUnsupportedError } from "
|
|
17
|
+
} from "../ast";
|
|
18
|
+
import { TlaProofError, TlaUnsupportedError } from "../errors";
|
|
19
19
|
import {
|
|
20
20
|
at,
|
|
21
21
|
type Bound,
|
|
@@ -27,8 +27,9 @@ import {
|
|
|
27
27
|
type Locus,
|
|
28
28
|
type Selector,
|
|
29
29
|
type Sequent,
|
|
30
|
-
} from "./
|
|
31
|
-
import type { ModuleUnit, Mule } from "./
|
|
30
|
+
} from "./expression";
|
|
31
|
+
import type { ModuleUnit, Mule } from "./module";
|
|
32
|
+
import { readNewMethod, readOldMethod } from "./pragma";
|
|
32
33
|
import {
|
|
33
34
|
expandChoose,
|
|
34
35
|
expandFcn,
|
|
@@ -37,8 +38,8 @@ import {
|
|
|
37
38
|
expandSetSt,
|
|
38
39
|
getUnbounded,
|
|
39
40
|
type TuplyBound,
|
|
40
|
-
} from "./
|
|
41
|
-
import { lookupOperator, type Fixity, type Operator } from "./
|
|
41
|
+
} from "./tuples";
|
|
42
|
+
import { lookupOperator, type Fixity, type Operator } from "./printer";
|
|
42
43
|
import {
|
|
43
44
|
getUnique,
|
|
44
45
|
type Counter,
|
|
@@ -47,7 +48,7 @@ import {
|
|
|
47
48
|
type StepNumber,
|
|
48
49
|
type UseDef,
|
|
49
50
|
type Usable,
|
|
50
|
-
} from "./
|
|
51
|
+
} from "./proof";
|
|
51
52
|
|
|
52
53
|
const BUILTINS: Record<string, Builtin> = {
|
|
53
54
|
"=>": "Implies",
|
|
@@ -80,9 +81,7 @@ const BUILTINS: Record<string, Builtin> = {
|
|
|
80
81
|
STRING: "STRING",
|
|
81
82
|
};
|
|
82
83
|
|
|
83
|
-
|
|
84
|
-
const getCanonicalName = (name: string, isPrefix = false) =>
|
|
85
|
-
isPrefix && name === "-" ? "-." : lookupOperator(name).name;
|
|
84
|
+
const getCanonicalName = (name: string) => lookupOperator(name).name;
|
|
86
85
|
|
|
87
86
|
const STEP_PATTERN = /^<(\d+|\*|\+)>([A-Za-z0-9_]*)\.*$/;
|
|
88
87
|
|
|
@@ -202,6 +201,9 @@ const regroup = (expression: Extract<Expression, { kind: "Apply" }>): Expression
|
|
|
202
201
|
|
|
203
202
|
const TUPLY_FAILURE = "use instead the class`E_visit.iter_concrete`";
|
|
204
203
|
|
|
204
|
+
const isDitto = (bounds: QuantifierExpression["bounds"], index: number) =>
|
|
205
|
+
index > 0 && bounds[index - 1].set === bounds[index].set;
|
|
206
|
+
|
|
205
207
|
export const createSource = (file: string, text: string, counter: Counter, isExpanded: boolean) => {
|
|
206
208
|
const lines = text.split("\n");
|
|
207
209
|
|
|
@@ -231,24 +233,32 @@ export const createSource = (file: string, text: string, counter: Counter, isExp
|
|
|
231
233
|
return locus;
|
|
232
234
|
};
|
|
233
235
|
|
|
234
|
-
const
|
|
236
|
+
const getMethod = (range: SourceRange | undefined) =>
|
|
237
|
+
range && readOldMethod(lines, { line: range.end.line - 1, column: range.end.column });
|
|
238
|
+
|
|
239
|
+
// A method pragma belongs to the node it follows, whose locus then takes it in.
|
|
240
|
+
const withMethod = (range: SourceRange) => {
|
|
241
|
+
const method = getMethod(range);
|
|
242
|
+
const location = getRangeLocus(range);
|
|
243
|
+
return method ? { location: withPragma(location), method } : { location };
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
// Module.Parser's with_meth, which wraps the expression a method follows.
|
|
247
|
+
const withExpressionMethod = (expression: Expr, range: SourceRange | undefined): Expr => {
|
|
248
|
+
const method = getMethod(range);
|
|
249
|
+
return method ? at({ kind: "With", expression, method }, expression) : expression;
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
const getPointLocus = (location: SourceLocation, length: number): Locus => ({
|
|
235
253
|
file,
|
|
236
254
|
startLine: location.line,
|
|
237
255
|
startColumn: location.column,
|
|
238
256
|
endLine: location.line,
|
|
239
|
-
endColumn: location.column +
|
|
257
|
+
endColumn: location.column + length,
|
|
240
258
|
});
|
|
241
259
|
|
|
242
260
|
const getLocus = (location: SourceLocation): Locus =>
|
|
243
|
-
location.range
|
|
244
|
-
? getRangeLocus(location.range)
|
|
245
|
-
: {
|
|
246
|
-
file,
|
|
247
|
-
startLine: location.line,
|
|
248
|
-
startColumn: location.column,
|
|
249
|
-
endLine: location.line,
|
|
250
|
-
endColumn: location.column + 1,
|
|
251
|
-
};
|
|
261
|
+
location.range ? getRangeLocus(location.range) : getPointLocus(location, 1);
|
|
252
262
|
|
|
253
263
|
const getOperator = (name: string, location: Locus | undefined): Expr => {
|
|
254
264
|
const canonical = getCanonicalName(name);
|
|
@@ -304,11 +314,10 @@ export const createSource = (file: string, text: string, counter: Counter, isExp
|
|
|
304
314
|
bounds.map((bound, index) => {
|
|
305
315
|
if (bound.pattern.kind === "Tuple")
|
|
306
316
|
throw new TlaProofError("Unexpected tuple declaration", { failure: TUPLY_FAILURE });
|
|
307
|
-
const isDitto = index > 0 && bounds[index - 1].set === bound.set;
|
|
308
317
|
return {
|
|
309
318
|
name: bound.pattern.name,
|
|
310
319
|
level: "Constant",
|
|
311
|
-
domain: isDitto
|
|
320
|
+
domain: isDitto(bounds, index)
|
|
312
321
|
? { kind: "Ditto" }
|
|
313
322
|
: { kind: "Domain", expression: convertExpression(bound.set, isExcept) },
|
|
314
323
|
};
|
|
@@ -322,18 +331,17 @@ export const createSource = (file: string, text: string, counter: Counter, isExp
|
|
|
322
331
|
const domain = convertExpression(bound.set, isExcept);
|
|
323
332
|
if (bound.pattern.kind === "Tuple")
|
|
324
333
|
return { kind: "Tuple", names: bound.pattern.names, domain };
|
|
325
|
-
const isDitto = index > 0 && bounds[index - 1].set === bound.set;
|
|
326
334
|
return {
|
|
327
335
|
kind: "Name",
|
|
328
336
|
name: bound.pattern.name,
|
|
329
|
-
domain: isDitto ? { kind: "Ditto" } : { kind: "Domain", expression: domain },
|
|
337
|
+
domain: isDitto(bounds, index) ? { kind: "Ditto" } : { kind: "Domain", expression: domain },
|
|
330
338
|
};
|
|
331
339
|
});
|
|
332
340
|
|
|
333
|
-
const expandTuples = (
|
|
341
|
+
const expandTuples = (expanded: Expr, location: Locus) => {
|
|
334
342
|
if (!isExpanded)
|
|
335
343
|
throw new TlaProofError("Unexpected tuple declaration", { failure: TUPLY_FAILURE });
|
|
336
|
-
return at(
|
|
344
|
+
return at(expanded, { location });
|
|
337
345
|
};
|
|
338
346
|
|
|
339
347
|
const hasTuple = (bounds: QuantifierExpression["bounds"]) =>
|
|
@@ -376,8 +384,14 @@ export const createSource = (file: string, text: string, counter: Counter, isExp
|
|
|
376
384
|
const [integer, fraction] = expression.text.split(".");
|
|
377
385
|
return at({ kind: "Num", integer, fraction }, { location });
|
|
378
386
|
}
|
|
379
|
-
case "String":
|
|
380
|
-
|
|
387
|
+
case "String": {
|
|
388
|
+
// tlapm's lexer keeps a string's escapes as written. The location ends at the closing
|
|
389
|
+
// quote.
|
|
390
|
+
const written = /"((?:[^"\\]|\\.)*)"$/.exec(
|
|
391
|
+
(lines[location.endLine - 1] ?? "").slice(0, location.endColumn - 1),
|
|
392
|
+
);
|
|
393
|
+
return at({ kind: "String", value: written?.[1] ?? expression.value }, { location });
|
|
394
|
+
}
|
|
381
395
|
case "Identifier":
|
|
382
396
|
return getName(expression.name, [], location);
|
|
383
397
|
case "Apply": {
|
|
@@ -470,9 +484,14 @@ export const createSource = (file: string, text: string, counter: Counter, isExp
|
|
|
470
484
|
case "Forall":
|
|
471
485
|
case "Exists":
|
|
472
486
|
if (hasTuple(expression.bounds)) {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
487
|
+
return expandTuples(
|
|
488
|
+
expandQuant(
|
|
489
|
+
expression.kind,
|
|
490
|
+
getTuplyBounds(expression.bounds, isExcept),
|
|
491
|
+
recurse(expression.body),
|
|
492
|
+
),
|
|
493
|
+
location,
|
|
494
|
+
);
|
|
476
495
|
}
|
|
477
496
|
return at(
|
|
478
497
|
{
|
|
@@ -495,10 +514,14 @@ export const createSource = (file: string, text: string, counter: Counter, isExp
|
|
|
495
514
|
}
|
|
496
515
|
case "Choose":
|
|
497
516
|
if (expression.pattern.kind === "Tuple") {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
517
|
+
return expandTuples(
|
|
518
|
+
expandChoose(
|
|
519
|
+
expression.pattern.names,
|
|
520
|
+
expression.set && recurse(expression.set),
|
|
521
|
+
recurse(expression.body),
|
|
522
|
+
),
|
|
523
|
+
location,
|
|
524
|
+
);
|
|
502
525
|
}
|
|
503
526
|
return at(
|
|
504
527
|
{
|
|
@@ -513,10 +536,14 @@ export const createSource = (file: string, text: string, counter: Counter, isExp
|
|
|
513
536
|
return at({ kind: "SetEnum", elements: expression.elements.map(recurse) }, { location });
|
|
514
537
|
case "SetFilter":
|
|
515
538
|
if (expression.bound.pattern.kind === "Tuple") {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
539
|
+
return expandTuples(
|
|
540
|
+
expandSetSt(
|
|
541
|
+
expression.bound.pattern.names,
|
|
542
|
+
recurse(expression.bound.set),
|
|
543
|
+
recurse(expression.predicate),
|
|
544
|
+
),
|
|
545
|
+
location,
|
|
546
|
+
);
|
|
520
547
|
}
|
|
521
548
|
return at(
|
|
522
549
|
{
|
|
@@ -529,9 +556,13 @@ export const createSource = (file: string, text: string, counter: Counter, isExp
|
|
|
529
556
|
);
|
|
530
557
|
case "SetMap":
|
|
531
558
|
if (hasTuple(expression.bounds)) {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
559
|
+
return expandTuples(
|
|
560
|
+
expandSetOf(
|
|
561
|
+
recurse(expression.expression),
|
|
562
|
+
getTuplyBounds(expression.bounds, isExcept),
|
|
563
|
+
),
|
|
564
|
+
location,
|
|
565
|
+
);
|
|
535
566
|
}
|
|
536
567
|
return at(
|
|
537
568
|
{
|
|
@@ -556,9 +587,10 @@ export const createSource = (file: string, text: string, counter: Counter, isExp
|
|
|
556
587
|
);
|
|
557
588
|
case "FunctionConstruction":
|
|
558
589
|
if (hasTuple(expression.bounds)) {
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
590
|
+
return expandTuples(
|
|
591
|
+
expandFcn(getTuplyBounds(expression.bounds, isExcept), recurse(expression.body)),
|
|
592
|
+
location,
|
|
593
|
+
);
|
|
562
594
|
}
|
|
563
595
|
return at(
|
|
564
596
|
{
|
|
@@ -745,17 +777,17 @@ export const createSource = (file: string, text: string, counter: Counter, isExp
|
|
|
745
777
|
location,
|
|
746
778
|
};
|
|
747
779
|
}
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
definition.kind === "Operator" && definition.params.length === 1 && definition.name === "-"
|
|
751
|
-
|
|
780
|
+
// A prefix minus is the operator -.
|
|
781
|
+
const name =
|
|
782
|
+
definition.kind === "Operator" && definition.params.length === 1 && definition.name === "-"
|
|
783
|
+
? "-."
|
|
784
|
+
: getCanonicalName(definition.name);
|
|
752
785
|
const body = convertExpression(definition.body, isExcept);
|
|
753
786
|
if (definition.kind === "Function" && hasTuple(definition.bounds)) {
|
|
754
|
-
const bounds = getTuplyBounds(definition.bounds, isExcept);
|
|
755
787
|
return {
|
|
756
788
|
kind: "Operator",
|
|
757
789
|
name,
|
|
758
|
-
body: expandTuples(
|
|
790
|
+
body: expandTuples(expandFcn(getTuplyBounds(definition.bounds, isExcept), body), location),
|
|
759
791
|
location,
|
|
760
792
|
};
|
|
761
793
|
}
|
|
@@ -768,24 +800,28 @@ export const createSource = (file: string, text: string, counter: Counter, isExp
|
|
|
768
800
|
location,
|
|
769
801
|
};
|
|
770
802
|
}
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
803
|
+
const operatorBody =
|
|
804
|
+
definition.params.length === 0
|
|
805
|
+
? body
|
|
806
|
+
: at(
|
|
807
|
+
{
|
|
808
|
+
kind: "Lambda",
|
|
809
|
+
params: definition.params.map((param) => ({
|
|
810
|
+
name: getCanonicalName(param.name),
|
|
811
|
+
shape: param.arity,
|
|
812
|
+
...(param.location && {
|
|
813
|
+
location: getPointLocus(param.location, param.name.length),
|
|
814
|
+
}),
|
|
815
|
+
})),
|
|
816
|
+
body,
|
|
817
|
+
},
|
|
818
|
+
{ location },
|
|
819
|
+
);
|
|
820
|
+
const end = definition.location.range?.end;
|
|
821
|
+
const methods = end && readNewMethod(lines, { line: end.line - 1, column: end.column });
|
|
822
|
+
return methods
|
|
823
|
+
? { kind: "Bpragma", name, body: operatorBody, methods, location }
|
|
824
|
+
: { kind: "Operator", name, body: operatorBody, location };
|
|
789
825
|
};
|
|
790
826
|
|
|
791
827
|
const convertNewSymbol = (symbol: NewSymbol): Hyp => {
|
|
@@ -802,23 +838,27 @@ export const createSource = (file: string, text: string, counter: Counter, isExp
|
|
|
802
838
|
};
|
|
803
839
|
};
|
|
804
840
|
|
|
841
|
+
// Anonymization judges the time of each assumption once it resolves the names in it.
|
|
805
842
|
const convertSequent = (statement: Expression | AssumeProve): Sequent => {
|
|
806
843
|
if (statement.kind !== "AssumeProve")
|
|
807
844
|
return { context: [], active: convertExpression(statement, false) };
|
|
808
845
|
return {
|
|
809
846
|
context: statement.assumptions.map((assumption): Hyp => {
|
|
810
847
|
if (assumption.kind === "NewSymbol") return convertNewSymbol(assumption);
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
848
|
+
const expression =
|
|
849
|
+
assumption.kind === "AssumeProve"
|
|
850
|
+
? at(
|
|
851
|
+
{ kind: "Sequent", sequent: convertSequent(assumption) },
|
|
852
|
+
{ location: getLocus(assumption.location) },
|
|
853
|
+
)
|
|
854
|
+
: convertFactLabel(assumption);
|
|
855
|
+
return {
|
|
856
|
+
kind: "Fact",
|
|
857
|
+
expression,
|
|
858
|
+
visibility: "Visible",
|
|
859
|
+
time: "Now",
|
|
860
|
+
location: expression.location,
|
|
861
|
+
};
|
|
822
862
|
}),
|
|
823
863
|
active: convertExpression(statement.conclusion, false),
|
|
824
864
|
};
|
|
@@ -864,12 +904,10 @@ export const createSource = (file: string, text: string, counter: Counter, isExp
|
|
|
864
904
|
defs: use.defs.map(convertDef),
|
|
865
905
|
});
|
|
866
906
|
|
|
867
|
-
const getStepNumber = (token: RegExpExecArray | null, level: number): StepNumber =>
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
: { kind: "Named", level, label, isAnonymous: false };
|
|
872
|
-
};
|
|
907
|
+
const getStepNumber = (token: RegExpExecArray | null, level: number): StepNumber =>
|
|
908
|
+
token?.[2]
|
|
909
|
+
? { kind: "Named", level, label: token[2], isAnonymous: false }
|
|
910
|
+
: { kind: "Unnamed", level, id: getUnique(counter) };
|
|
873
911
|
|
|
874
912
|
// to_proof: a missing proof is implicitly omitted where the enclosing step is.
|
|
875
913
|
const convertProof = (
|
|
@@ -880,7 +918,7 @@ export const createSource = (file: string, text: string, counter: Counter, isExp
|
|
|
880
918
|
if (!proof) return { kind: "Omitted", omission: "Implicit", location: enclosing };
|
|
881
919
|
switch (proof.kind) {
|
|
882
920
|
case "Obvious":
|
|
883
|
-
return { kind: "Obvious",
|
|
921
|
+
return { kind: "Obvious", ...withMethod(proof.keyword) };
|
|
884
922
|
case "Omitted":
|
|
885
923
|
return {
|
|
886
924
|
kind: "Omitted",
|
|
@@ -894,6 +932,7 @@ export const createSource = (file: string, text: string, counter: Counter, isExp
|
|
|
894
932
|
isOnly: proof.isOnly,
|
|
895
933
|
location: getRangeLocus(proof.keyword),
|
|
896
934
|
step: { kind: "Unnamed", level, id: 0 },
|
|
935
|
+
method: getMethod(proof.location.range),
|
|
897
936
|
};
|
|
898
937
|
case "Steps": {
|
|
899
938
|
// A <*> first step takes the enclosing level only after PROOF, and the top level
|
|
@@ -936,7 +975,11 @@ export const createSource = (file: string, text: string, counter: Counter, isExp
|
|
|
936
975
|
const proof = convertProof(step.proof, level + 1, head);
|
|
937
976
|
return { ...make(proof), location: mergeLoci(head, proof.location), step: number };
|
|
938
977
|
};
|
|
939
|
-
const
|
|
978
|
+
const withStepMethod = (converted: Step): Step => ({
|
|
979
|
+
...converted,
|
|
980
|
+
...withMethod(step.head),
|
|
981
|
+
step: number,
|
|
982
|
+
});
|
|
940
983
|
switch (body.kind) {
|
|
941
984
|
case "Use":
|
|
942
985
|
case "Hide": {
|
|
@@ -946,26 +989,38 @@ export const createSource = (file: string, text: string, counter: Counter, isExp
|
|
|
946
989
|
);
|
|
947
990
|
const usable = convertUsable(body);
|
|
948
991
|
return body.kind === "Use"
|
|
949
|
-
? {
|
|
992
|
+
? {
|
|
993
|
+
kind: "Use",
|
|
994
|
+
usable,
|
|
995
|
+
isOnly: body.isOnly,
|
|
996
|
+
location,
|
|
997
|
+
step: number,
|
|
998
|
+
method: getMethod(body.location.range),
|
|
999
|
+
}
|
|
950
1000
|
: { kind: "Hide", usable, location, step: number };
|
|
951
1001
|
}
|
|
952
1002
|
case "Instance":
|
|
953
1003
|
throw new TlaProofError("Unexpected keyword INSTANCE");
|
|
954
1004
|
case "Define":
|
|
955
|
-
return
|
|
1005
|
+
return {
|
|
956
1006
|
kind: "Define",
|
|
957
1007
|
definitions: body.definitions.map((definition) => convertDefinition(definition)),
|
|
958
|
-
|
|
1008
|
+
location: head,
|
|
1009
|
+
step: number,
|
|
1010
|
+
};
|
|
959
1011
|
case "Have":
|
|
960
|
-
return
|
|
1012
|
+
return withStepMethod({
|
|
1013
|
+
kind: "Have",
|
|
1014
|
+
expression: convertExpression(body.expression, false),
|
|
1015
|
+
});
|
|
961
1016
|
case "Take":
|
|
962
|
-
return
|
|
1017
|
+
return withStepMethod({
|
|
963
1018
|
kind: "Take",
|
|
964
1019
|
bounds:
|
|
965
1020
|
body.names.length > 0 ? getUnbounded(body.names) : convertBounds(body.bounds, false),
|
|
966
1021
|
});
|
|
967
1022
|
case "Witness":
|
|
968
|
-
return
|
|
1023
|
+
return withStepMethod({
|
|
969
1024
|
kind: "Witness",
|
|
970
1025
|
expressions: body.expressions.map((expression) => convertExpression(expression, false)),
|
|
971
1026
|
});
|
|
@@ -1048,17 +1103,24 @@ export const createSource = (file: string, text: string, counter: Counter, isExp
|
|
|
1048
1103
|
return {
|
|
1049
1104
|
kind: "Axiom",
|
|
1050
1105
|
name: unit.assumption.name,
|
|
1051
|
-
expression:
|
|
1106
|
+
expression: withExpressionMethod(
|
|
1107
|
+
convertExpression(unit.assumption.expression, false),
|
|
1108
|
+
unit.assumption.location.range,
|
|
1109
|
+
),
|
|
1052
1110
|
location: getLocus(unit.assumption.location),
|
|
1053
1111
|
};
|
|
1054
1112
|
case "Theorem": {
|
|
1055
1113
|
const theorem = unit.theorem;
|
|
1056
1114
|
const location = getLocus(theorem.location);
|
|
1057
1115
|
const end = withPragma(location);
|
|
1116
|
+
const sequent = convertSequent(theorem.statement);
|
|
1058
1117
|
return {
|
|
1059
1118
|
kind: "Theorem",
|
|
1060
1119
|
name: theorem.name,
|
|
1061
|
-
sequent:
|
|
1120
|
+
sequent: {
|
|
1121
|
+
...sequent,
|
|
1122
|
+
active: withExpressionMethod(sequent.active, theorem.statement.location.range),
|
|
1123
|
+
},
|
|
1062
1124
|
axiomCount: 0,
|
|
1063
1125
|
proof: convertProof(theorem.proof, 0, {
|
|
1064
1126
|
...end,
|