tla-ts 0.0.4-dev.e4c2d0e → 0.0.4-dev.e92649a
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 +26 -141
- package/dist/deciders.cjs +366 -0
- package/dist/deciders.js +366 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +35 -1
- package/dist/index.d.ts +35 -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 +515 -0
- package/dist/prove.js +515 -0
- package/dist/run-cli.cjs +30 -47
- package/dist/run-cli.js +30 -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} +258 -37
- package/src/{obligation-anon.ts → obligations/anon.ts} +13 -7
- package/src/obligations/ctx.ts +64 -0
- package/src/{obligation-deref.ts → obligations/deref.ts} +2 -2
- package/src/{obligation-expression.ts → obligations/expression.ts} +54 -8
- package/src/{obligation-generate.ts → obligations/generate.ts} +134 -61
- package/src/{obligations.ts → obligations/index.ts} +26 -12
- package/src/{obligation-levels.ts → obligations/levels.ts} +12 -2
- package/src/{obligation-module.ts → obligations/module.ts} +46 -20
- package/src/obligations/pickle.ts +100 -0
- package/src/obligations/pragma.ts +189 -0
- package/src/{obligation-printer.ts → obligations/printer.ts} +5 -59
- package/src/{obligation-proof.ts → obligations/proof.ts} +7 -1
- package/src/{obligation-source.ts → obligations/source.ts} +91 -35
- package/src/obligations/temporal.ts +319 -0
- package/src/{obligation-tuples.ts → obligations/tuples.ts} +1 -1
- 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 +27 -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 +477 -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 +520 -0
- package/src/prove/prep/defs.ts +27 -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 +552 -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 +29 -0
- package/src/prove/prove.ts +417 -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 +210 -0
- package/src/prove/smt/context.ts +108 -0
- package/src/prove/smt/data.ts +665 -0
- package/src/prove/smt/encode.ts +169 -0
- package/src/prove/smt/extensionality.ts +63 -0
- package/src/prove/smt/flatten.ts +127 -0
- package/src/prove/smt/format.ts +143 -0
- package/src/prove/smt/instances.ts +182 -0
- package/src/prove/smt/rewrite.ts +784 -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 +13 -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 +444 -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 +73 -20
- package/src/standard-modules.ts +5 -2
- package/src/successors.ts +24 -5
- package/src/tlc-random.ts +55 -32
- package/src/tlc-version.ts +8 -7
- package/src/values.ts +85 -41
- package/src/worker.ts +65 -0
- package/dist/parallel.cjs +0 -12
- package/dist/parallel.js +0 -12
- /package/src/{obligation-format.ts → obligations/format.ts} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generates the proof obligations tlapm prints for a module, in tlapm's order and layout.
|
|
2
2
|
|
|
3
|
-
import { TlaProofError, TlaSyntaxError, type SyntaxFailure } from "
|
|
4
|
-
import { createAnonymizer } from "./
|
|
3
|
+
import { TlaProofError, TlaSyntaxError, type SyntaxFailure } from "../errors";
|
|
4
|
+
import { createAnonymizer } from "./anon";
|
|
5
5
|
import {
|
|
6
6
|
getAtPrefix,
|
|
7
7
|
getErrorNote,
|
|
@@ -9,8 +9,9 @@ import {
|
|
|
9
9
|
getLocusPrefix,
|
|
10
10
|
type Locus,
|
|
11
11
|
type ObligationWarning,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
type Sequent,
|
|
13
|
+
} from "./expression";
|
|
14
|
+
import { createGenerator, type LineRange } from "./generate";
|
|
14
15
|
import {
|
|
15
16
|
compareNames,
|
|
16
17
|
expandInstance,
|
|
@@ -23,13 +24,14 @@ import {
|
|
|
23
24
|
type Mule,
|
|
24
25
|
type TheoremSummary,
|
|
25
26
|
type Pipeline,
|
|
26
|
-
} from "./
|
|
27
|
-
import { formatObligation } from "./
|
|
28
|
-
import type { Counter } from "./
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import
|
|
27
|
+
} from "./module";
|
|
28
|
+
import { formatObligation } from "./printer";
|
|
29
|
+
import type { Counter, ObligationKind } from "./proof";
|
|
30
|
+
import type { OldMethod } from "./pragma";
|
|
31
|
+
import { createSource } from "./source";
|
|
32
|
+
import { tokenize } from "../lexer";
|
|
33
|
+
import { parseTlapmModule } from "../parser";
|
|
34
|
+
import type { Module } from "../ast";
|
|
33
35
|
|
|
34
36
|
export interface ObligationSource {
|
|
35
37
|
file: string;
|
|
@@ -40,6 +42,9 @@ export interface PrintedObligation {
|
|
|
40
42
|
id: number;
|
|
41
43
|
location: string;
|
|
42
44
|
text: string;
|
|
45
|
+
kind: ObligationKind;
|
|
46
|
+
sequent: Sequent;
|
|
47
|
+
method?: OldMethod;
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
export interface ModuleObligations {
|
|
@@ -307,7 +312,16 @@ export const getObligations = (
|
|
|
307
312
|
obligation.kind.kind === "Error"
|
|
308
313
|
? obligation.kind.message
|
|
309
314
|
: `${formatObligation(obligation.sequent)}\n`;
|
|
310
|
-
return [
|
|
315
|
+
return [
|
|
316
|
+
{
|
|
317
|
+
id: index + 1,
|
|
318
|
+
location: formatLocus(location),
|
|
319
|
+
text,
|
|
320
|
+
kind: obligation.kind,
|
|
321
|
+
sequent: obligation.sequent,
|
|
322
|
+
method: obligation.method,
|
|
323
|
+
},
|
|
324
|
+
];
|
|
311
325
|
});
|
|
312
326
|
return [
|
|
313
327
|
{ name: module.name, location: module.location, obligations, summary: generated.summary },
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// 3 temporal, 4 undefined), the weights of an operator's arguments, and the declared names the
|
|
3
3
|
// level depends on.
|
|
4
4
|
|
|
5
|
-
import { TlaProofError, TlapmBugError } from "
|
|
5
|
+
import { TlaProofError, TlapmBugError } from "../errors";
|
|
6
6
|
import {
|
|
7
7
|
adjoin,
|
|
8
8
|
getBoundedFresh,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
type Expr,
|
|
15
15
|
type Level,
|
|
16
16
|
type Scope,
|
|
17
|
-
} from "./
|
|
17
|
+
} from "./expression";
|
|
18
18
|
|
|
19
19
|
interface LevelInfo {
|
|
20
20
|
level: number;
|
|
@@ -203,6 +203,16 @@ export const getLevelInfo = (scope: Scope | undefined, expression: Expr): LevelI
|
|
|
203
203
|
}
|
|
204
204
|
case "Apply": {
|
|
205
205
|
const operator = expression.operator;
|
|
206
|
+
// The action frontend commutes a prime onto an operator, and tlapm keeps the level that
|
|
207
|
+
// the application had.
|
|
208
|
+
if (
|
|
209
|
+
operator.kind === "Apply" &&
|
|
210
|
+
operator.operator.kind === "Internal" &&
|
|
211
|
+
operator.operator.builtin === "Prime" &&
|
|
212
|
+
operator.args.length === 1
|
|
213
|
+
) {
|
|
214
|
+
return recurse({ ...expression, operator: operator.args[0] });
|
|
215
|
+
}
|
|
206
216
|
if (operator.kind === "Opaque") {
|
|
207
217
|
return applyOperator(getInfo(0, expression.args.length), expression.args.map(recurse));
|
|
208
218
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// A port of tlapm's module pipeline: flattening EXTENDS (Module.Flatten), normalization
|
|
2
2
|
// (Module.Elab.normalize) and obligation generation (Module.Gen).
|
|
3
3
|
|
|
4
|
-
import { TlaProofError, TlapmBugError } from "
|
|
5
|
-
import { lambdify } from "./
|
|
6
|
-
import type { Anonymizer } from "./
|
|
4
|
+
import { TlaProofError, TlapmBugError } from "../errors";
|
|
5
|
+
import { lambdify } from "./action";
|
|
6
|
+
import type { Anonymizer } from "./anon";
|
|
7
7
|
import {
|
|
8
8
|
adjoinAll,
|
|
9
9
|
at,
|
|
@@ -38,21 +38,16 @@ import {
|
|
|
38
38
|
type Substitution,
|
|
39
39
|
type Visibility,
|
|
40
40
|
type WhereDefined,
|
|
41
|
-
} from "./
|
|
41
|
+
} from "./expression";
|
|
42
42
|
import {
|
|
43
43
|
EMPTY_SUMMARY,
|
|
44
44
|
getProofSummary,
|
|
45
45
|
joinSummaries,
|
|
46
46
|
type Generator,
|
|
47
47
|
type ProofSummary,
|
|
48
|
-
} from "./
|
|
49
|
-
import {
|
|
50
|
-
|
|
51
|
-
type Counter,
|
|
52
|
-
type Obligation,
|
|
53
|
-
type Proof,
|
|
54
|
-
type Usable,
|
|
55
|
-
} from "./obligation-proof";
|
|
48
|
+
} from "./generate";
|
|
49
|
+
import { getUnique, type Counter, type Obligation, type Proof, type Usable } from "./proof";
|
|
50
|
+
import { getScopeTime } from "./temporal";
|
|
56
51
|
|
|
57
52
|
export type ModuleUnit = ModuleUnitCore & { location?: Locus };
|
|
58
53
|
|
|
@@ -242,7 +237,15 @@ const getUnitHyps = (unit: ModuleUnit): Hyp[] => {
|
|
|
242
237
|
];
|
|
243
238
|
case "Axiom":
|
|
244
239
|
return unit.name === undefined
|
|
245
|
-
? [
|
|
240
|
+
? [
|
|
241
|
+
{
|
|
242
|
+
kind: "Fact",
|
|
243
|
+
expression: unit.expression,
|
|
244
|
+
visibility: "Hidden",
|
|
245
|
+
time: "Always",
|
|
246
|
+
location,
|
|
247
|
+
},
|
|
248
|
+
]
|
|
246
249
|
: getNamedFact(unit.name, unit.expression, location);
|
|
247
250
|
case "Theorem": {
|
|
248
251
|
const sequent = substituteSequent(shift(-unit.axiomCount), {
|
|
@@ -251,7 +254,7 @@ const getUnitHyps = (unit: ModuleUnit): Hyp[] => {
|
|
|
251
254
|
});
|
|
252
255
|
const body = at(exprifySequent(sequent), unit);
|
|
253
256
|
return unit.name === undefined
|
|
254
|
-
? [{ kind: "Fact", expression: body, visibility: "Hidden", location }]
|
|
257
|
+
? [{ kind: "Fact", expression: body, visibility: "Hidden", time: "Always", location }]
|
|
255
258
|
: getNamedFact(unit.name, body, location);
|
|
256
259
|
}
|
|
257
260
|
case "Mutate":
|
|
@@ -260,6 +263,7 @@ const getUnitHyps = (unit: ModuleUnit): Hyp[] => {
|
|
|
260
263
|
kind: "Fact",
|
|
261
264
|
expression: shiftExpr(index, fact),
|
|
262
265
|
visibility: "Visible",
|
|
266
|
+
time: "Always",
|
|
263
267
|
location,
|
|
264
268
|
}))
|
|
265
269
|
: [];
|
|
@@ -285,7 +289,13 @@ const getNamedFact = (name: string, expression: Expr, location: Locus | undefine
|
|
|
285
289
|
isLocal: false,
|
|
286
290
|
location,
|
|
287
291
|
},
|
|
288
|
-
{
|
|
292
|
+
{
|
|
293
|
+
kind: "Fact",
|
|
294
|
+
expression: { kind: "Ix", index: 1, location },
|
|
295
|
+
visibility: "Hidden",
|
|
296
|
+
time: "Always",
|
|
297
|
+
location,
|
|
298
|
+
},
|
|
289
299
|
];
|
|
290
300
|
|
|
291
301
|
// Module.Flatten.exports: what an extending module sees, with local definitions inlined like
|
|
@@ -681,7 +691,7 @@ const localizeAxioms = (units: ModuleUnit[]) => {
|
|
|
681
691
|
body.push({
|
|
682
692
|
kind: "Definition",
|
|
683
693
|
definition: { kind: "Operator", name: unit.name, body: unit.expression, location },
|
|
684
|
-
whereDefined: "Proof",
|
|
694
|
+
whereDefined: { kind: "Proof", time: "Always" },
|
|
685
695
|
visibility: "Visible",
|
|
686
696
|
isLocal: false,
|
|
687
697
|
location,
|
|
@@ -694,6 +704,7 @@ const localizeAxioms = (units: ModuleUnit[]) => {
|
|
|
694
704
|
? shiftExpr(1, unit.expression)
|
|
695
705
|
: at({ kind: "Ix", index: 2 }, unit),
|
|
696
706
|
visibility: "Visible",
|
|
707
|
+
time: "Always",
|
|
697
708
|
location,
|
|
698
709
|
};
|
|
699
710
|
let distance = 0;
|
|
@@ -808,7 +819,7 @@ const bindTheoremName = (
|
|
|
808
819
|
body: at(exprifySequent(sequent), { location }),
|
|
809
820
|
location,
|
|
810
821
|
},
|
|
811
|
-
whereDefined: "Proof",
|
|
822
|
+
whereDefined: { kind: "Proof", time: "Always" },
|
|
812
823
|
visibility: "Visible",
|
|
813
824
|
isLocal: false,
|
|
814
825
|
location,
|
|
@@ -950,13 +961,20 @@ export const normalize = (
|
|
|
950
961
|
pipeline.latestModules = new Map(modules);
|
|
951
962
|
const sequent = pipeline.anonymizer.sequent(current, unit.sequent);
|
|
952
963
|
const binding = bindTheoremName(name, sequent, unit.location);
|
|
953
|
-
const proofScope = adjoinAll(
|
|
964
|
+
const proofScope = adjoinAll(
|
|
965
|
+
adjoinAll(
|
|
966
|
+
current,
|
|
967
|
+
binding.hyps.map((hyp) => ({ ...hyp, isConstnessUnset: true })),
|
|
968
|
+
),
|
|
969
|
+
binding.sequent.context,
|
|
970
|
+
);
|
|
954
971
|
const anonymized = pipeline.anonymizer.proof(proofScope, proof);
|
|
955
972
|
const simplified = module.isImportant
|
|
956
973
|
? pipeline.generator.simplify(
|
|
957
974
|
getScopeHyps(proofScope),
|
|
958
975
|
binding.sequent.active,
|
|
959
976
|
anonymized,
|
|
977
|
+
getScopeTime(binding.sequent.context, "Always"),
|
|
960
978
|
)
|
|
961
979
|
: anonymized;
|
|
962
980
|
emit({ ...unit, name, sequent, proof: simplified });
|
|
@@ -999,9 +1017,11 @@ export const generate = (
|
|
|
999
1017
|
case "Theorem": {
|
|
1000
1018
|
const binding = bindTheoremName(unit.name, unit.sequent, unit.location);
|
|
1001
1019
|
const named = [...current, ...binding.hyps];
|
|
1020
|
+
const context = [...named, ...binding.sequent.context];
|
|
1002
1021
|
const proof = pipeline.generator.generate(
|
|
1003
|
-
{ context
|
|
1022
|
+
{ context, active: binding.sequent.active },
|
|
1004
1023
|
unit.proof,
|
|
1024
|
+
getScopeTime(context, "Always"),
|
|
1005
1025
|
);
|
|
1006
1026
|
obligations.push(...pipeline.generator.collect(proof));
|
|
1007
1027
|
const theorem = getProofSummary(proof);
|
|
@@ -1013,7 +1033,13 @@ export const generate = (
|
|
|
1013
1033
|
: { kind: "Ix", index: 1, location: unit.location };
|
|
1014
1034
|
current = [
|
|
1015
1035
|
...named,
|
|
1016
|
-
{
|
|
1036
|
+
{
|
|
1037
|
+
kind: "Fact",
|
|
1038
|
+
expression: fact,
|
|
1039
|
+
visibility: "Hidden",
|
|
1040
|
+
time: "Always",
|
|
1041
|
+
location: unit.location,
|
|
1042
|
+
},
|
|
1017
1043
|
];
|
|
1018
1044
|
continue;
|
|
1019
1045
|
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// tlapm's Tla_parser.pickle, which turns a TLA+ identifier into one every backend accepts: a name
|
|
2
|
+
// with a character other than a letter or digit, one that starts or ends with a non-letter, or one
|
|
3
|
+
// that a prover reserves becomes a_, the name with each special character spelled out, and a.
|
|
4
|
+
|
|
5
|
+
import { TlapmBugError } from "../errors";
|
|
6
|
+
|
|
7
|
+
const CHARACTER_NAMES: Record<string, string> = {
|
|
8
|
+
"!": "excl_",
|
|
9
|
+
"#": "hash_",
|
|
10
|
+
$: "doll_",
|
|
11
|
+
"%": "perc_",
|
|
12
|
+
"&": "ampe_",
|
|
13
|
+
"'": "quot_",
|
|
14
|
+
"(": "lpar_",
|
|
15
|
+
")": "rpar_",
|
|
16
|
+
"*": "star_",
|
|
17
|
+
"+": "plus_",
|
|
18
|
+
"-": "dash_",
|
|
19
|
+
".": "peri_",
|
|
20
|
+
"/": "slas_",
|
|
21
|
+
":": "colo_",
|
|
22
|
+
"<": "less_",
|
|
23
|
+
"=": "equa_",
|
|
24
|
+
">": "more_",
|
|
25
|
+
"?": "ques_",
|
|
26
|
+
"@": "atsi_",
|
|
27
|
+
"[": "lbrk_",
|
|
28
|
+
"\\": "bksl_",
|
|
29
|
+
"]": "rbrk_",
|
|
30
|
+
"^": "care_",
|
|
31
|
+
_: "unde_",
|
|
32
|
+
"|": "vert_",
|
|
33
|
+
"~": "tild_",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// isabelle_tlaplus_keys, then Isabelle_keywords.v, then other_keys.
|
|
37
|
+
const FORBIDDEN = new Set(
|
|
38
|
+
[
|
|
39
|
+
"All Append Bijections Case CaseArm CaseOther Char Choice EnumFuncSet Ex Fcn FuncSet INTER Id",
|
|
40
|
+
"Image Injections Injective InjectiveOn Int Inverse Len Let Monotonic Nat Nibble Not PeanoAxioms",
|
|
41
|
+
"Pred Product Range Seq String Succ Surjections Surjective TYPE Trueprop Zero abs addElt addnat",
|
|
42
|
+
"all antisymmetric any aprop arbitrary args arith_add asms bAll bChoice bEx boolify c cap cargs",
|
|
43
|
+
"case_arm case_arms cases_conj cases_equal cases_forall cases_implies char cidts classes cond",
|
|
44
|
+
"conj conjunction converse cs cup default diff diffnat disj div divmodNat divmod_rel domrng",
|
|
45
|
+
"domrngs dummy dummy_pattern dvd emptySeq eq equivalence except extend fapply float_const",
|
|
46
|
+
"float_token fun geq gfp greater id idt idts iff imp in index infinity irreflexive isAFcn isASeq",
|
|
47
|
+
"isBool isNeg isPos itself leq less letbind letbinds lfp logic longid minus mod mult multnat",
|
|
48
|
+
"natInterval num num_const oneArg prod prop psubset psupset pttrn pttrns reflexive rel_comp",
|
|
49
|
+
"rel_domain rel_image rel_range setOfAll setOfPairs setminus sgn sort sort_constraint struct",
|
|
50
|
+
"subsetOf subseteq symmetric term tid tpl transitive tvar type types upair upto var xcpt xnum",
|
|
51
|
+
"xstr",
|
|
52
|
+
"ML ML_command ML_export ML_file ML_file_debug ML_file_no_debug ML_prf ML_val ROOTS_file",
|
|
53
|
+
"SML_export SML_file SML_file_debug SML_file_no_debug SML_import abbreviation abbrevs alias also",
|
|
54
|
+
"and apply apply_end assume assumes attribute_setup axiomatization back begin bibtex_file binder",
|
|
55
|
+
"bundle by case chapter class class_deps code_datatype compile_generated_files consider",
|
|
56
|
+
"constrains consts context corollary declaration declare default_sort defer define defines",
|
|
57
|
+
"definition done end experiment export_files export_generated_files export_prefix external_file",
|
|
58
|
+
"external_files extract extract_type finally find_consts find_theorems fix fixes for from",
|
|
59
|
+
"full_prf generate_file global_interpretation guess have help hence hide_class hide_const",
|
|
60
|
+
"hide_fact hide_type if imports in include includes including infix infixl infixr instance",
|
|
61
|
+
"instantiation interpret interpretation is judgment keywords lemma lemmas let local_setup locale",
|
|
62
|
+
"locale_deps method_setup moreover named_theorems next no_notation no_syntax no_translations",
|
|
63
|
+
"no_type_notation nonterminal notation note notepad notes obtain obtains oops open opening oracle",
|
|
64
|
+
"output overloaded overloading paragraph parse_ast_translation parse_translation pervasive prefer",
|
|
65
|
+
"premises presume prf print_ML_antiquotations print_abbrevs print_antiquotations",
|
|
66
|
+
"print_ast_translation print_attributes print_bundles print_cases print_classes print_codesetup",
|
|
67
|
+
"print_commands print_context print_definitions print_defn_rules print_facts print_interps",
|
|
68
|
+
"print_locale print_locales print_methods print_options print_rules print_simpset print_state",
|
|
69
|
+
"print_statement print_syntax print_term_bindings print_theorems print_theory print_trans_rules",
|
|
70
|
+
"print_translation private proof prop proposition qed qualified realizability realizers rewrites",
|
|
71
|
+
"schematic_goal section setup show shows simproc_setup sorry structure subclass subgoal sublocale",
|
|
72
|
+
"subparagraph subsection subsubsection supply syntax syntax_declaration term text text_raw then",
|
|
73
|
+
"theorem theory thm thm_deps thm_oracles thus thy_deps translations txt typ type_alias",
|
|
74
|
+
"type_notation type_synonym typed_print_translation typedecl ultimately unbundle unchecked",
|
|
75
|
+
"unfolding unused_thms using welcome when where with write",
|
|
76
|
+
"O max status",
|
|
77
|
+
]
|
|
78
|
+
.join(" ")
|
|
79
|
+
.split(" "),
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const isLetter = (character: string) => /^[A-Za-z]$/.test(character);
|
|
83
|
+
|
|
84
|
+
const getCharacterName = (character: string) => {
|
|
85
|
+
if (/^[A-Za-z0-9]$/.test(character)) return undefined;
|
|
86
|
+
const name = CHARACTER_NAMES[character];
|
|
87
|
+
if (name === undefined) throw new TlapmBugError();
|
|
88
|
+
return name;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const pickle = (name: string) => {
|
|
92
|
+
const characters = [...name];
|
|
93
|
+
const isPlain =
|
|
94
|
+
isLetter(characters[0] ?? "") &&
|
|
95
|
+
isLetter(characters.at(-1) ?? "") &&
|
|
96
|
+
characters.every((character) => getCharacterName(character) === undefined) &&
|
|
97
|
+
!FORBIDDEN.has(name);
|
|
98
|
+
if (isPlain) return name;
|
|
99
|
+
return `a_${characters.map((character) => getCharacterName(character) ?? character).join("")}a`;
|
|
100
|
+
};
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// tlapm's method pragmas: the (*{ by (prover:"zenon"; timeout:@) }*) after a definition, which
|
|
2
|
+
// E_parser.read_new_method reads, and which makes the definition a Bpragma, and the older
|
|
3
|
+
// (*{ by (zenon) }*), which Method_prs reads.
|
|
4
|
+
|
|
5
|
+
export type PragmaValue =
|
|
6
|
+
| { kind: "Default" }
|
|
7
|
+
| { kind: "String"; value: string }
|
|
8
|
+
| { kind: "Float"; value: number };
|
|
9
|
+
|
|
10
|
+
export interface PragmaSetting {
|
|
11
|
+
hint: string;
|
|
12
|
+
value: PragmaValue;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface Position {
|
|
16
|
+
line: number;
|
|
17
|
+
column: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type Token =
|
|
21
|
+
| { kind: "Ident"; text: string }
|
|
22
|
+
| { kind: "String"; text: string }
|
|
23
|
+
| { kind: "Number"; text: string }
|
|
24
|
+
| { kind: "Punct"; text: string };
|
|
25
|
+
|
|
26
|
+
const PUNCTUATION = ["(", ")", ";", ":", "@", ","];
|
|
27
|
+
|
|
28
|
+
const isBlank = (character: string | undefined) =>
|
|
29
|
+
character === " " || character === "\r" || character === "\t";
|
|
30
|
+
|
|
31
|
+
// The tokens of the pragma that starts at position, after blanks and line ends.
|
|
32
|
+
const tokenizePragma = (lines: string[], start: Position) => {
|
|
33
|
+
const position = { ...start };
|
|
34
|
+
const skipBlanks = () => {
|
|
35
|
+
while (position.line < lines.length) {
|
|
36
|
+
const line = lines[position.line];
|
|
37
|
+
while (isBlank(line[position.column])) position.column++;
|
|
38
|
+
if (position.column < line.length) return;
|
|
39
|
+
position.line++;
|
|
40
|
+
position.column = 0;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
skipBlanks();
|
|
44
|
+
if (!(lines[position.line] ?? "").startsWith("(*{", position.column)) return undefined;
|
|
45
|
+
position.column += 3;
|
|
46
|
+
const tokens: Token[] = [];
|
|
47
|
+
for (skipBlanks(); position.line < lines.length; skipBlanks()) {
|
|
48
|
+
const rest = lines[position.line].slice(position.column);
|
|
49
|
+
if (rest.startsWith("}*)")) return tokens;
|
|
50
|
+
const match =
|
|
51
|
+
/^[A-Za-z_][A-Za-z0-9_]*/.exec(rest) ??
|
|
52
|
+
/^\d+(\.\d+)?/.exec(rest) ??
|
|
53
|
+
/^"(\\.|[^"\\])*"/.exec(rest);
|
|
54
|
+
if (match) {
|
|
55
|
+
const text = match[0];
|
|
56
|
+
tokens.push(
|
|
57
|
+
text.startsWith('"')
|
|
58
|
+
? { kind: "String", text: JSON.parse(text) }
|
|
59
|
+
: /^\d/.test(text)
|
|
60
|
+
? { kind: "Number", text }
|
|
61
|
+
: { kind: "Ident", text },
|
|
62
|
+
);
|
|
63
|
+
position.column += text.length;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (!PUNCTUATION.includes(rest[0])) return undefined;
|
|
67
|
+
tokens.push({ kind: "Punct", text: rest[0] });
|
|
68
|
+
position.column++;
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const getValue = (token: Token | undefined): PragmaValue | undefined => {
|
|
74
|
+
if (token?.kind === "String") return { kind: "String", value: token.text };
|
|
75
|
+
if (token?.kind === "Number") return { kind: "Float", value: Number.parseFloat(token.text) };
|
|
76
|
+
return token?.kind === "Punct" && token.text === "@" ? { kind: "Default" } : undefined;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// The methods of Method_prs's old pragma syntax, by the name Method.prover_meth_of_tac gives them.
|
|
80
|
+
const OLD_METHODS = new Map([
|
|
81
|
+
["smt", "smt"],
|
|
82
|
+
["cvc3", "cvc4"],
|
|
83
|
+
["yices", "yices"],
|
|
84
|
+
["z3", "z3"],
|
|
85
|
+
["cooper", "cooper"],
|
|
86
|
+
["presburger", "cooper"],
|
|
87
|
+
["fail", "fail"],
|
|
88
|
+
["smt2lib", "smt"],
|
|
89
|
+
["smt2z3", "z3"],
|
|
90
|
+
["smt3", "smt"],
|
|
91
|
+
["z33", "z3"],
|
|
92
|
+
["cvc33", "cvc4"],
|
|
93
|
+
["yices3", "yices"],
|
|
94
|
+
["verit", "verit"],
|
|
95
|
+
["zipper", "zipper"],
|
|
96
|
+
["spass", "spass"],
|
|
97
|
+
["tptp", "tptp"],
|
|
98
|
+
["ls4", "ls4"],
|
|
99
|
+
["expandenabled", "expandenabled"],
|
|
100
|
+
["expandcdot", "expandcdot"],
|
|
101
|
+
["autouse", "autouse"],
|
|
102
|
+
["lambdify", "lambdify"],
|
|
103
|
+
["enabledaxioms", "enabledaxioms"],
|
|
104
|
+
["levelcomparison", "levelcomparison"],
|
|
105
|
+
["trivial", "trivial"],
|
|
106
|
+
]);
|
|
107
|
+
|
|
108
|
+
// An old-style method, with the tactic an isabelle method takes and the timeout in seconds an
|
|
109
|
+
// isabelle or zenon method may take.
|
|
110
|
+
export interface OldMethod {
|
|
111
|
+
name: string;
|
|
112
|
+
tactic?: string;
|
|
113
|
+
timeout?: number;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Method_prs.read_method: the (*{ by (zenon) }*) after a BY, OBVIOUS, proof step, theorem, or
|
|
117
|
+
// axiom, which names one method, isabelle with a tactic, or zenon with a timeout and a fallback.
|
|
118
|
+
export const readOldMethod = (lines: string[], start: Position) => {
|
|
119
|
+
const tokens = tokenizePragma(lines, start);
|
|
120
|
+
if (!tokens) return undefined;
|
|
121
|
+
let index = 0;
|
|
122
|
+
const isPunct = (text: string) => tokens[index]?.kind === "Punct" && tokens[index].text === text;
|
|
123
|
+
const readTimeout = () => {
|
|
124
|
+
const token = tokens[index];
|
|
125
|
+
if (token?.kind !== "Number") return {};
|
|
126
|
+
index++;
|
|
127
|
+
return { timeout: Number.parseFloat(token.text) };
|
|
128
|
+
};
|
|
129
|
+
const readMethod = (): OldMethod | undefined => {
|
|
130
|
+
if (!isPunct("(")) return undefined;
|
|
131
|
+
index++;
|
|
132
|
+
const name = tokens[index++];
|
|
133
|
+
if (name?.kind !== "Ident") return undefined;
|
|
134
|
+
const method = ((): OldMethod | undefined => {
|
|
135
|
+
if (name.text === "isabelle") {
|
|
136
|
+
const tactic = tokens[index];
|
|
137
|
+
if (tactic?.kind !== "String") return undefined;
|
|
138
|
+
index++;
|
|
139
|
+
return { name: name.text, tactic: tactic.text, ...readTimeout() };
|
|
140
|
+
}
|
|
141
|
+
if (name.text === "zenon") {
|
|
142
|
+
const timeout = readTimeout();
|
|
143
|
+
if (isPunct("(") && !readMethod()) return undefined;
|
|
144
|
+
return { name: name.text, ...timeout };
|
|
145
|
+
}
|
|
146
|
+
const known = OLD_METHODS.get(name.text);
|
|
147
|
+
return known === undefined ? undefined : { name: known };
|
|
148
|
+
})();
|
|
149
|
+
if (!method || !isPunct(")")) return undefined;
|
|
150
|
+
index++;
|
|
151
|
+
return method;
|
|
152
|
+
};
|
|
153
|
+
if (tokens[index]?.kind !== "Ident" || tokens[index++].text !== "by") return undefined;
|
|
154
|
+
const method = readMethod();
|
|
155
|
+
return index === tokens.length ? method : undefined;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// read_new_method: by (hint: value; ...), repeated, where a value is a string, a number, or @ for
|
|
159
|
+
// the argument the definition is applied to.
|
|
160
|
+
export const readNewMethod = (lines: string[], start: Position) => {
|
|
161
|
+
const tokens = tokenizePragma(lines, start);
|
|
162
|
+
if (!tokens) return undefined;
|
|
163
|
+
let index = 0;
|
|
164
|
+
const isPunct = (text: string) => tokens[index]?.kind === "Punct" && tokens[index].text === text;
|
|
165
|
+
const groups: PragmaSetting[][] = [];
|
|
166
|
+
while (index < tokens.length) {
|
|
167
|
+
const keyword = tokens[index++];
|
|
168
|
+
if (keyword.kind !== "Ident" || (keyword.text !== "by" && keyword.text !== "set")) {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
if (!isPunct("(")) return undefined;
|
|
172
|
+
index++;
|
|
173
|
+
const settings: PragmaSetting[] = [];
|
|
174
|
+
for (;;) {
|
|
175
|
+
const hint = tokens[index++];
|
|
176
|
+
if (hint?.kind !== "Ident" || !isPunct(":")) return undefined;
|
|
177
|
+
index++;
|
|
178
|
+
const value = getValue(tokens[index++]);
|
|
179
|
+
if (!value) return undefined;
|
|
180
|
+
settings.push({ hint: hint.text, value });
|
|
181
|
+
if (isPunct(")")) break;
|
|
182
|
+
if (!isPunct(";")) return undefined;
|
|
183
|
+
index++;
|
|
184
|
+
}
|
|
185
|
+
index++;
|
|
186
|
+
groups.push(settings);
|
|
187
|
+
}
|
|
188
|
+
return groups;
|
|
189
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// A port of tlapm's obligation printer: E_fmt with Fmtutil's minimal parenthesization, the
|
|
2
2
|
// operator table in Optable, and the identifier renaming in Ctx.
|
|
3
3
|
|
|
4
|
-
import { TlaProofError } from "
|
|
4
|
+
import { TlaProofError } from "../errors";
|
|
5
5
|
import {
|
|
6
6
|
getHypName,
|
|
7
7
|
type Bound,
|
|
@@ -13,8 +13,9 @@ import {
|
|
|
13
13
|
type Selector,
|
|
14
14
|
type Sequent,
|
|
15
15
|
type Shape,
|
|
16
|
-
} from "./
|
|
17
|
-
import {
|
|
16
|
+
} from "./expression";
|
|
17
|
+
import { createContext, getBoundName, popNames, pushName, withNames } from "./ctx";
|
|
18
|
+
import { format, formatDelimited, renderDoc, text, type Doc } from "./format";
|
|
18
19
|
|
|
19
20
|
export type Fixity = "Nonfix" | "Prefix" | "Postfix" | "InfixLeft" | "InfixNon" | "InfixRight";
|
|
20
21
|
|
|
@@ -189,59 +190,6 @@ const getStandardForm = (builtin: Builtin): Operator => {
|
|
|
189
190
|
return name ? lookupOperator(name) : getNonfix(builtin);
|
|
190
191
|
};
|
|
191
192
|
|
|
192
|
-
interface Ident {
|
|
193
|
-
rep: string;
|
|
194
|
-
salt: number;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const getIdentName = (ident: Ident) =>
|
|
198
|
-
ident.salt === 0 ? ident.rep : `${ident.rep}_${ident.salt}`;
|
|
199
|
-
|
|
200
|
-
// Ctx as a mutable stack: printing binds and unbinds names in strict nesting order.
|
|
201
|
-
interface Context {
|
|
202
|
-
stack: Ident[];
|
|
203
|
-
idents: Map<string, Ident[]>;
|
|
204
|
-
defined: Map<string, number>;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const createContext = (): Context => ({ stack: [], idents: new Map(), defined: new Map() });
|
|
208
|
-
|
|
209
|
-
const pushName = (context: Context, rep: string) => {
|
|
210
|
-
const previous = context.idents.get(rep)?.at(-1);
|
|
211
|
-
let ident: Ident = previous ? { rep, salt: previous.salt + 1 } : { rep, salt: 0 };
|
|
212
|
-
while (context.defined.has(getIdentName(ident))) ident = { rep, salt: ident.salt + 1 };
|
|
213
|
-
context.stack.push(ident);
|
|
214
|
-
const idents = context.idents.get(rep);
|
|
215
|
-
if (idents) idents.push(ident);
|
|
216
|
-
else context.idents.set(rep, [ident]);
|
|
217
|
-
const key = getIdentName(ident);
|
|
218
|
-
context.defined.set(key, (context.defined.get(key) ?? 0) + 1);
|
|
219
|
-
return key;
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
const popNames = (context: Context, count: number) => {
|
|
223
|
-
for (let index = 0; index < count; index++) {
|
|
224
|
-
const ident = context.stack.pop();
|
|
225
|
-
if (!ident) return;
|
|
226
|
-
context.idents.get(ident.rep)?.pop();
|
|
227
|
-
const key = getIdentName(ident);
|
|
228
|
-
const remaining = (context.defined.get(key) ?? 1) - 1;
|
|
229
|
-
if (remaining === 0) context.defined.delete(key);
|
|
230
|
-
else context.defined.set(key, remaining);
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
const withNames = <Result>(
|
|
235
|
-
context: Context,
|
|
236
|
-
names: string[],
|
|
237
|
-
body: (idents: string[]) => Result,
|
|
238
|
-
) => {
|
|
239
|
-
const idents = names.map((name) => pushName(context, name));
|
|
240
|
-
const result = body(idents);
|
|
241
|
-
popNames(context, names.length);
|
|
242
|
-
return result;
|
|
243
|
-
};
|
|
244
|
-
|
|
245
193
|
type Assoc = "Left" | "Non" | "Right";
|
|
246
194
|
|
|
247
195
|
type Minimal =
|
|
@@ -419,9 +367,7 @@ const createPrinter = (hyps: Hyp[] = []) => {
|
|
|
419
367
|
const getIndexName = (index: number) => {
|
|
420
368
|
if (index < 0) return `#$$${Math.abs(index)}`;
|
|
421
369
|
if (index === 0) return "#$0";
|
|
422
|
-
if (index <= context.stack.length)
|
|
423
|
-
return getIdentName(context.stack[context.stack.length - index]);
|
|
424
|
-
}
|
|
370
|
+
if (index <= context.stack.length) return getBoundName(context, index);
|
|
425
371
|
const hyp = hyps[hyps.length - (index - context.stack.length)];
|
|
426
372
|
if (hyp) return getHypName(hyp) ?? "??? FACT ???";
|
|
427
373
|
return `#$${index}`;
|
|
@@ -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;
|