tla-ts 0.0.4-dev.2be6058 → 0.0.4-dev.43f28be
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 +517 -47
- package/dist/run-cli.js +517 -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 +255 -56
- 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-format.ts → obligations/format.ts} +6 -5
- package/src/{obligation-generate.ts → obligations/generate.ts} +134 -61
- package/src/{obligations.ts → obligations/index.ts} +28 -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} +9 -63
- 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/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 +508 -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 +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 +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 +27 -0
- package/src/prove/prove.ts +518 -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 +97 -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 +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 +338 -62
- package/src/standard-modules.ts +5 -2
- package/src/successors.ts +25 -6
- package/src/tlapm-cache.ts +244 -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,7 +1,7 @@
|
|
|
1
1
|
// A port of tlapm's proof simplification (Proof.Simplify) and obligation generation (Proof.Gen):
|
|
2
2
|
// leaf proofs become obligations whose context is everything the proof may use at that point.
|
|
3
3
|
|
|
4
|
-
import { TlapmBugError, TlaProofError } from "
|
|
4
|
+
import { TlapmBugError, TlaProofError } from "../errors";
|
|
5
5
|
import {
|
|
6
6
|
applyBuiltin,
|
|
7
7
|
at,
|
|
@@ -22,12 +22,15 @@ import {
|
|
|
22
22
|
type Locus,
|
|
23
23
|
type ObligationWarning,
|
|
24
24
|
type Sequent,
|
|
25
|
+
type Time,
|
|
25
26
|
type Visibility,
|
|
26
27
|
mapChildren,
|
|
27
28
|
stripProps,
|
|
28
|
-
} from "./
|
|
29
|
-
import { format, renderDoc, type Doc } from "./
|
|
30
|
-
import { printExpression } from "./
|
|
29
|
+
} from "./expression";
|
|
30
|
+
import { format, renderDoc, type Doc } from "./format";
|
|
31
|
+
import { printExpression } from "./printer";
|
|
32
|
+
import type { OldMethod } from "./pragma";
|
|
33
|
+
import { getScopeTime } from "./temporal";
|
|
31
34
|
import {
|
|
32
35
|
getStepName,
|
|
33
36
|
getUnique,
|
|
@@ -39,7 +42,7 @@ import {
|
|
|
39
42
|
type StepNumber,
|
|
40
43
|
type UseDef,
|
|
41
44
|
type Usable,
|
|
42
|
-
} from "./
|
|
45
|
+
} from "./proof";
|
|
43
46
|
|
|
44
47
|
const AT_NOWHERE: Expr = { kind: "At", isExcept: false };
|
|
45
48
|
|
|
@@ -48,6 +51,7 @@ const getProps = (from: Step) => ({
|
|
|
48
51
|
location: from.location,
|
|
49
52
|
step: from.step,
|
|
50
53
|
isSuppressed: from.isSuppressed,
|
|
54
|
+
method: from.method,
|
|
51
55
|
});
|
|
52
56
|
|
|
53
57
|
const isAnonymous = (step: StepNumber | undefined) => step?.kind === "Named" && step.isAnonymous;
|
|
@@ -101,24 +105,27 @@ const getAssumedFacts = (offset: number, sequent: Sequent) =>
|
|
|
101
105
|
: [],
|
|
102
106
|
);
|
|
103
107
|
|
|
104
|
-
const getStepDefinition = (step: Step, body: Expr): Hyp => {
|
|
108
|
+
const getStepDefinition = (step: Step, body: Expr, time: Time): Hyp => {
|
|
105
109
|
if (!step.step) throw new TlapmBugError();
|
|
106
110
|
return {
|
|
107
111
|
kind: "Defn",
|
|
108
112
|
definition: { kind: "Operator", name: getStepName(step.step), body, location: step.location },
|
|
109
|
-
whereDefined: "Proof",
|
|
113
|
+
whereDefined: { kind: "Proof", time },
|
|
110
114
|
visibility: "Visible",
|
|
111
115
|
isLocal: true,
|
|
112
116
|
location: step.location,
|
|
113
117
|
};
|
|
114
118
|
};
|
|
115
119
|
|
|
116
|
-
|
|
120
|
+
// The proof of an assertion leaves the always scope when the assertion assumes a fact that holds
|
|
121
|
+
// only now.
|
|
122
|
+
const proveAssertion = (context: Hyp[], sequent: Sequent, step: Step, time: Time) => {
|
|
117
123
|
const visibility: Visibility = isAnonymous(step.step) ? "Visible" : "Hidden";
|
|
118
124
|
const hyps = sequent.context.map((hyp): Hyp =>
|
|
119
125
|
hyp.kind === "Fact" ? { ...hyp, visibility } : hyp,
|
|
120
126
|
);
|
|
121
127
|
const body = at({ kind: "List", bullet: "Refs", items: getAssumedFacts(2, sequent) }, step);
|
|
128
|
+
const scopeTime = getScopeTime(sequent.context, time);
|
|
122
129
|
return {
|
|
123
130
|
context: [
|
|
124
131
|
...context,
|
|
@@ -127,17 +134,20 @@ const proveAssertion = (context: Hyp[], sequent: Sequent, step: Step) => {
|
|
|
127
134
|
kind: "Fact",
|
|
128
135
|
expression: getTrue(step),
|
|
129
136
|
visibility: "Hidden",
|
|
137
|
+
time,
|
|
130
138
|
location: step.location,
|
|
131
139
|
},
|
|
132
|
-
getStepDefinition(step, body),
|
|
140
|
+
getStepDefinition(step, body, scopeTime),
|
|
133
141
|
{
|
|
134
142
|
kind: "Fact",
|
|
135
143
|
expression: at({ kind: "Ix", index: 1 }, step),
|
|
136
144
|
visibility: "Hidden",
|
|
145
|
+
time: scopeTime,
|
|
137
146
|
location: step.location,
|
|
138
147
|
},
|
|
139
148
|
] satisfies Hyp[],
|
|
140
149
|
active: shiftExpr(3, sequent.active),
|
|
150
|
+
time: scopeTime,
|
|
141
151
|
};
|
|
142
152
|
};
|
|
143
153
|
|
|
@@ -147,16 +157,18 @@ const useAssertion = (
|
|
|
147
157
|
goal: Expr,
|
|
148
158
|
sequent: Sequent,
|
|
149
159
|
step: Step,
|
|
160
|
+
time: Time,
|
|
150
161
|
) => {
|
|
151
162
|
const visibility: Visibility = isSuffices || isAnonymous(step.step) ? "Visible" : "Hidden";
|
|
152
163
|
return {
|
|
153
164
|
context: [
|
|
154
165
|
...context,
|
|
155
|
-
getStepDefinition(step, at(exprifySequent(sequent), step)),
|
|
166
|
+
getStepDefinition(step, at(exprifySequent(sequent), step), time),
|
|
156
167
|
{
|
|
157
168
|
kind: "Fact",
|
|
158
169
|
expression: at({ kind: "Ix", index: 1 }, step),
|
|
159
170
|
visibility,
|
|
171
|
+
time,
|
|
160
172
|
location: step.location,
|
|
161
173
|
},
|
|
162
174
|
] satisfies Hyp[],
|
|
@@ -164,7 +176,18 @@ const useAssertion = (
|
|
|
164
176
|
};
|
|
165
177
|
};
|
|
166
178
|
|
|
167
|
-
|
|
179
|
+
// A cited step or definition keeps the scope it was proved in, and any other fact takes the
|
|
180
|
+
// current one.
|
|
181
|
+
const getFactTime = (context: Hyp[], fact: Expr, time: Time): Time => {
|
|
182
|
+
if (fact.kind !== "Ix") return time;
|
|
183
|
+
const hyp = context[context.length - fact.index];
|
|
184
|
+
if (hyp?.kind === "Fact") return hyp.time;
|
|
185
|
+
return hyp?.kind === "Defn" && typeof hyp.whereDefined === "object"
|
|
186
|
+
? hyp.whereDefined.time
|
|
187
|
+
: "Always";
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export const setDefinition = (visibility: Visibility, context: Hyp[], def: UseDef): Hyp[] => {
|
|
168
191
|
if (def.kind !== "Dx") throw new TlaProofError(`Unknown definition ${def.name}`);
|
|
169
192
|
const index = context.length - def.index;
|
|
170
193
|
const hyp = context[index];
|
|
@@ -181,7 +204,7 @@ const isDomainMatch = (fact: Expr, domain: Expr) =>
|
|
|
181
204
|
fact.args[0].index === 0 &&
|
|
182
205
|
isEqualExpr(domain, fact.args[1]);
|
|
183
206
|
|
|
184
|
-
const setExpression = (
|
|
207
|
+
export const setExpression = (
|
|
185
208
|
onWarning: (warning: ObligationWarning) => void,
|
|
186
209
|
visibility: Visibility,
|
|
187
210
|
fact: Expr,
|
|
@@ -216,7 +239,7 @@ export interface LineRange {
|
|
|
216
239
|
}
|
|
217
240
|
|
|
218
241
|
export interface Generator {
|
|
219
|
-
generate: (sequent: Sequent, proof: Proof) => Proof;
|
|
242
|
+
generate: (sequent: Sequent, proof: Proof, time: Time) => Proof;
|
|
220
243
|
collect: (proof: Proof) => Obligation[];
|
|
221
244
|
mutate: (
|
|
222
245
|
context: Hyp[],
|
|
@@ -224,7 +247,7 @@ export interface Generator {
|
|
|
224
247
|
usable: Usable,
|
|
225
248
|
location: Locus | undefined,
|
|
226
249
|
) => [Hyp[], Obligation[]];
|
|
227
|
-
simplify: (context: Hyp[], goal: Expr, proof: Proof) => Proof;
|
|
250
|
+
simplify: (context: Hyp[], goal: Expr, proof: Proof, time: Time) => Proof;
|
|
228
251
|
}
|
|
229
252
|
|
|
230
253
|
// The bounds after a witnessed one, where a ditto takes the witnessed domain.
|
|
@@ -254,6 +277,7 @@ const getWitnessProof = (step: Step, aux: Expr[]): Proof => {
|
|
|
254
277
|
usable: { facts: [shiftExpr(3, active)], defs: [] },
|
|
255
278
|
isOnly: false,
|
|
256
279
|
location: item.location,
|
|
280
|
+
method: step.method,
|
|
257
281
|
},
|
|
258
282
|
location: item.location,
|
|
259
283
|
};
|
|
@@ -262,11 +286,13 @@ const getWitnessProof = (step: Step, aux: Expr[]): Proof => {
|
|
|
262
286
|
at({ kind: "Ix", index: 2 * aux.length + 2 }, step),
|
|
263
287
|
...aux.map((_item, index) => at({ kind: "Ix", index: 2 * (aux.length - index) }, step)),
|
|
264
288
|
];
|
|
289
|
+
// tlapm removes the method from the QED.
|
|
265
290
|
const qedProof: Proof = {
|
|
266
291
|
kind: "By",
|
|
267
292
|
usable: { facts, defs: [] },
|
|
268
293
|
isOnly: true,
|
|
269
294
|
...getProps(step),
|
|
295
|
+
method: undefined,
|
|
270
296
|
};
|
|
271
297
|
return {
|
|
272
298
|
kind: "Steps",
|
|
@@ -278,9 +304,9 @@ const getWitnessProof = (step: Step, aux: Expr[]): Proof => {
|
|
|
278
304
|
|
|
279
305
|
const obligate = (
|
|
280
306
|
sequent: Sequent,
|
|
281
|
-
from: { location?: Locus },
|
|
307
|
+
from: { location?: Locus; method?: OldMethod },
|
|
282
308
|
kind: ObligationKind,
|
|
283
|
-
): Obligation => ({ sequent, location: from.location, kind });
|
|
309
|
+
): Obligation => ({ sequent, location: from.location, kind, method: from.method });
|
|
284
310
|
|
|
285
311
|
export interface ProofSummary {
|
|
286
312
|
total: number;
|
|
@@ -336,7 +362,7 @@ export const createGenerator = (
|
|
|
336
362
|
lines: LineRange,
|
|
337
363
|
onWarning: (warning: ObligationWarning) => void,
|
|
338
364
|
): Generator => {
|
|
339
|
-
const generate = (sequent: Sequent, proof: Proof): Proof => {
|
|
365
|
+
const generate = (sequent: Sequent, proof: Proof, time: Time): Proof => {
|
|
340
366
|
const location = proof.location;
|
|
341
367
|
if (
|
|
342
368
|
!location ||
|
|
@@ -361,14 +387,17 @@ export const createGenerator = (
|
|
|
361
387
|
case "By":
|
|
362
388
|
throw new TlaProofError("Proof.Gen.generate");
|
|
363
389
|
case "Steps": {
|
|
364
|
-
const [inner, steps] = mapAccumulate(sequent, proof.steps,
|
|
365
|
-
|
|
390
|
+
const [inner, steps] = mapAccumulate({ sequent, time }, proof.steps, (state, step) => {
|
|
391
|
+
const [next, generated, nextTime] = generateStep(state.sequent, step, state.time);
|
|
392
|
+
return [{ sequent: next, time: nextTime }, generated];
|
|
393
|
+
});
|
|
394
|
+
const qedProof = generate(inner.sequent, proof.qed.proof, inner.time);
|
|
366
395
|
return { ...proof, steps, qed: { ...proof.qed, proof: qedProof } };
|
|
367
396
|
}
|
|
368
397
|
}
|
|
369
398
|
};
|
|
370
399
|
|
|
371
|
-
const generateStep = (sequent: Sequent, step: Step): [Sequent, Step] => {
|
|
400
|
+
const generateStep = (sequent: Sequent, step: Step, time: Time): [Sequent, Step, Time] => {
|
|
372
401
|
switch (step.kind) {
|
|
373
402
|
case "Forget": {
|
|
374
403
|
const count = sequent.context.length;
|
|
@@ -377,7 +406,7 @@ export const createGenerator = (
|
|
|
377
406
|
? { ...hyp, visibility: "Hidden" }
|
|
378
407
|
: hyp,
|
|
379
408
|
);
|
|
380
|
-
return [{ ...sequent, context }, step];
|
|
409
|
+
return [{ ...sequent, context }, step, time];
|
|
381
410
|
}
|
|
382
411
|
case "Use": {
|
|
383
412
|
const usable = step.usable;
|
|
@@ -388,11 +417,19 @@ export const createGenerator = (
|
|
|
388
417
|
{
|
|
389
418
|
context: [
|
|
390
419
|
...sequent.context,
|
|
391
|
-
{
|
|
420
|
+
{
|
|
421
|
+
kind: "Fact",
|
|
422
|
+
expression: fact,
|
|
423
|
+
visibility: "Visible",
|
|
424
|
+
time: getFactTime(sequent.context, fact, time),
|
|
425
|
+
location: fact.location,
|
|
426
|
+
useLocation: step.useLocation,
|
|
427
|
+
},
|
|
392
428
|
],
|
|
393
429
|
active: shiftExpr(1, sequent.active),
|
|
394
430
|
},
|
|
395
431
|
{ ...step, obligations: [obligation] },
|
|
432
|
+
time,
|
|
396
433
|
];
|
|
397
434
|
}
|
|
398
435
|
if (usable.facts.length > 0)
|
|
@@ -401,7 +438,7 @@ export const createGenerator = (
|
|
|
401
438
|
(current, def) => setDefinition("Visible", current, def),
|
|
402
439
|
sequent.context,
|
|
403
440
|
);
|
|
404
|
-
return [{ ...sequent, context }, step];
|
|
441
|
+
return [{ ...sequent, context }, step, time];
|
|
405
442
|
}
|
|
406
443
|
case "Hide": {
|
|
407
444
|
const hidden = step.usable.defs.reduce(
|
|
@@ -412,7 +449,7 @@ export const createGenerator = (
|
|
|
412
449
|
(current, fact) => setExpression(onWarning, "Hidden", fact, current),
|
|
413
450
|
hidden,
|
|
414
451
|
);
|
|
415
|
-
return [{ ...sequent, context }, step];
|
|
452
|
+
return [{ ...sequent, context }, step, time];
|
|
416
453
|
}
|
|
417
454
|
case "Define":
|
|
418
455
|
return [
|
|
@@ -431,22 +468,27 @@ export const createGenerator = (
|
|
|
431
468
|
active: shiftExpr(step.definitions.length, sequent.active),
|
|
432
469
|
},
|
|
433
470
|
step,
|
|
471
|
+
time,
|
|
434
472
|
];
|
|
435
473
|
case "Assert": {
|
|
436
|
-
const
|
|
474
|
+
const inner = proveAssertion(sequent.context, step.sequent, step, time);
|
|
475
|
+
const proof = generate(inner, step.proof, inner.time);
|
|
437
476
|
const generated: Step = { ...step, proof };
|
|
438
477
|
return [
|
|
439
|
-
useAssertion(false, sequent.context, sequent.active, step.sequent, generated),
|
|
478
|
+
useAssertion(false, sequent.context, sequent.active, step.sequent, generated, time),
|
|
440
479
|
generated,
|
|
480
|
+
time,
|
|
441
481
|
];
|
|
442
482
|
}
|
|
443
483
|
case "Suffices": {
|
|
444
484
|
const proof = generate(
|
|
445
|
-
useAssertion(true, sequent.context, sequent.active, step.sequent, step),
|
|
485
|
+
useAssertion(true, sequent.context, sequent.active, step.sequent, step, time),
|
|
446
486
|
step.proof,
|
|
487
|
+
time,
|
|
447
488
|
);
|
|
448
489
|
const generated: Step = { ...step, proof };
|
|
449
|
-
|
|
490
|
+
const next = proveAssertion(sequent.context, step.sequent, generated, time);
|
|
491
|
+
return [next, generated, next.time];
|
|
450
492
|
}
|
|
451
493
|
default:
|
|
452
494
|
throw new TlaProofError("Proof.Gen.gen_step");
|
|
@@ -463,8 +505,9 @@ export const createGenerator = (
|
|
|
463
505
|
const [sequent, generated] = generateStep(
|
|
464
506
|
{ context, active: { ...AT_NOWHERE, location } },
|
|
465
507
|
mode === "Use"
|
|
466
|
-
? { kind: "Use", usable, isOnly: false, location, step }
|
|
508
|
+
? { kind: "Use", usable, isOnly: false, location, step, useLocation: location }
|
|
467
509
|
: { kind: "Hide", usable, location, step },
|
|
510
|
+
"Always",
|
|
468
511
|
);
|
|
469
512
|
return [sequent.context, generated.obligations ?? []];
|
|
470
513
|
};
|
|
@@ -626,7 +669,7 @@ export const createGenerator = (
|
|
|
626
669
|
return { ...proof, steps };
|
|
627
670
|
};
|
|
628
671
|
|
|
629
|
-
const simplify = (context: Hyp[], goal: Expr, original: Proof): Proof => {
|
|
672
|
+
const simplify = (context: Hyp[], goal: Expr, original: Proof, time: Time): Proof => {
|
|
630
673
|
const proof = expandAt(original);
|
|
631
674
|
switch (proof.kind) {
|
|
632
675
|
case "Obvious":
|
|
@@ -652,6 +695,7 @@ export const createGenerator = (
|
|
|
652
695
|
isOnly: false,
|
|
653
696
|
location: fact.location,
|
|
654
697
|
isSuppressed: proof.isSuppressed,
|
|
698
|
+
useLocation: proof.location,
|
|
655
699
|
}));
|
|
656
700
|
const forget: Step[] = proof.isOnly
|
|
657
701
|
? [{ kind: "Forget", count: usable.facts.length, location: proof.location }]
|
|
@@ -666,6 +710,7 @@ export const createGenerator = (
|
|
|
666
710
|
location: proof.location,
|
|
667
711
|
step: getAnonymous(level),
|
|
668
712
|
isSuppressed: proof.isSuppressed,
|
|
713
|
+
method: proof.method,
|
|
669
714
|
};
|
|
670
715
|
return {
|
|
671
716
|
kind: "Steps",
|
|
@@ -679,44 +724,52 @@ export const createGenerator = (
|
|
|
679
724
|
case "Steps": {
|
|
680
725
|
let currentContext = context;
|
|
681
726
|
let currentGoal = goal;
|
|
727
|
+
let currentTime = time;
|
|
682
728
|
const steps = proof.steps.flatMap((step) => {
|
|
683
|
-
const [nextContext, nextGoal, simplified] = simplifyStep(
|
|
729
|
+
const [nextContext, nextGoal, simplified, nextTime] = simplifyStep(
|
|
684
730
|
currentContext,
|
|
685
731
|
currentGoal,
|
|
686
732
|
step,
|
|
733
|
+
currentTime,
|
|
687
734
|
);
|
|
688
735
|
currentContext = nextContext;
|
|
689
736
|
currentGoal = nextGoal;
|
|
737
|
+
currentTime = nextTime;
|
|
690
738
|
return simplified;
|
|
691
739
|
});
|
|
692
|
-
const qedProof = simplify(currentContext, currentGoal, proof.qed.proof);
|
|
740
|
+
const qedProof = simplify(currentContext, currentGoal, proof.qed.proof, currentTime);
|
|
693
741
|
return { ...proof, steps, qed: { ...proof.qed, proof: qedProof } };
|
|
694
742
|
}
|
|
695
743
|
}
|
|
696
744
|
};
|
|
697
745
|
|
|
698
|
-
const simplifyStep = (
|
|
746
|
+
const simplifyStep = (
|
|
747
|
+
context: Hyp[],
|
|
748
|
+
goal: Expr,
|
|
749
|
+
step: Step,
|
|
750
|
+
time: Time,
|
|
751
|
+
): [Hyp[], Expr, Step[], Time] => {
|
|
699
752
|
const level = getLevel(step.step);
|
|
700
753
|
switch (step.kind) {
|
|
701
754
|
case "Forget":
|
|
702
|
-
return [context, goal, [step]];
|
|
755
|
+
return [context, goal, [step], time];
|
|
703
756
|
case "Assert": {
|
|
704
|
-
const inner = proveAssertion(context, step.sequent, step);
|
|
757
|
+
const inner = proveAssertion(context, step.sequent, step, time);
|
|
705
758
|
const simplified: Step = {
|
|
706
759
|
...step,
|
|
707
|
-
proof: simplify(inner.context, inner.active, step.proof),
|
|
760
|
+
proof: simplify(inner.context, inner.active, step.proof, inner.time),
|
|
708
761
|
};
|
|
709
|
-
const next = useAssertion(false, context, goal, step.sequent, simplified);
|
|
710
|
-
return [next.context, next.active, [simplified]];
|
|
762
|
+
const next = useAssertion(false, context, goal, step.sequent, simplified, time);
|
|
763
|
+
return [next.context, next.active, [simplified], time];
|
|
711
764
|
}
|
|
712
765
|
case "Suffices": {
|
|
713
|
-
const inner = useAssertion(true, context, goal, step.sequent, step);
|
|
766
|
+
const inner = useAssertion(true, context, goal, step.sequent, step, time);
|
|
714
767
|
const simplified: Step = {
|
|
715
768
|
...step,
|
|
716
|
-
proof: simplify(inner.context, inner.active, step.proof),
|
|
769
|
+
proof: simplify(inner.context, inner.active, step.proof, time),
|
|
717
770
|
};
|
|
718
|
-
const next = proveAssertion(context, step.sequent, simplified);
|
|
719
|
-
return [next.context, next.active, [simplified]];
|
|
771
|
+
const next = proveAssertion(context, step.sequent, simplified, time);
|
|
772
|
+
return [next.context, next.active, [simplified], next.time];
|
|
720
773
|
}
|
|
721
774
|
case "Use": {
|
|
722
775
|
const byProof: Proof = {
|
|
@@ -726,20 +779,23 @@ export const createGenerator = (
|
|
|
726
779
|
location: step.location,
|
|
727
780
|
step: step.step,
|
|
728
781
|
isSuppressed: step.isSuppressed,
|
|
782
|
+
method: step.method,
|
|
729
783
|
};
|
|
730
|
-
const simplified = simplify(context, goal, byProof);
|
|
784
|
+
const simplified = simplify(context, goal, byProof, time);
|
|
731
785
|
if (simplified.kind !== "Steps")
|
|
732
786
|
throw new TlaProofError("simplifying BY does not produce a non-leaf proof!");
|
|
733
787
|
const assumed = step.usable.facts.map((): Hyp => ({
|
|
734
788
|
kind: "Fact",
|
|
735
789
|
expression: AT_NOWHERE,
|
|
736
790
|
visibility: "Visible",
|
|
791
|
+
time,
|
|
737
792
|
location: step.location,
|
|
738
793
|
}));
|
|
739
794
|
return [
|
|
740
795
|
[...context, ...assumed],
|
|
741
796
|
shiftExpr(step.usable.facts.length, goal),
|
|
742
797
|
simplified.steps,
|
|
798
|
+
time,
|
|
743
799
|
];
|
|
744
800
|
}
|
|
745
801
|
case "Hide": {
|
|
@@ -759,7 +815,7 @@ export const createGenerator = (
|
|
|
759
815
|
: entry,
|
|
760
816
|
);
|
|
761
817
|
}, context);
|
|
762
|
-
return [hidden, goal, [step]];
|
|
818
|
+
return [hidden, goal, [step], time];
|
|
763
819
|
}
|
|
764
820
|
case "Define":
|
|
765
821
|
return [
|
|
@@ -768,7 +824,7 @@ export const createGenerator = (
|
|
|
768
824
|
...step.definitions.map((definition): Hyp => ({
|
|
769
825
|
kind: "Defn",
|
|
770
826
|
definition,
|
|
771
|
-
whereDefined: "Proof",
|
|
827
|
+
whereDefined: { kind: "Proof", time },
|
|
772
828
|
visibility: "Visible",
|
|
773
829
|
isLocal: true,
|
|
774
830
|
location: step.location,
|
|
@@ -776,6 +832,7 @@ export const createGenerator = (
|
|
|
776
832
|
],
|
|
777
833
|
shiftExpr(step.definitions.length, goal),
|
|
778
834
|
[step],
|
|
835
|
+
time,
|
|
779
836
|
];
|
|
780
837
|
case "Have": {
|
|
781
838
|
const connective = exposeConnective(context, goal);
|
|
@@ -783,6 +840,7 @@ export const createGenerator = (
|
|
|
783
840
|
kind: "Fact",
|
|
784
841
|
expression: step.expression,
|
|
785
842
|
visibility: "Visible",
|
|
843
|
+
time,
|
|
786
844
|
location: step.location,
|
|
787
845
|
};
|
|
788
846
|
const isImplication = isBinary(connective, "Implies");
|
|
@@ -814,19 +872,21 @@ export const createGenerator = (
|
|
|
814
872
|
location: step.location,
|
|
815
873
|
step: step.step,
|
|
816
874
|
});
|
|
817
|
-
return simplifyStep(context, goal, suffices);
|
|
875
|
+
return simplifyStep(context, goal, suffices, time);
|
|
818
876
|
}
|
|
819
877
|
case "Take":
|
|
820
878
|
return simplifyStep(
|
|
821
879
|
context,
|
|
822
880
|
goal,
|
|
823
881
|
renumberStep(level, getTakeSuffices(context, goal, step)),
|
|
882
|
+
time,
|
|
824
883
|
);
|
|
825
884
|
case "Witness":
|
|
826
885
|
return simplifyStep(
|
|
827
886
|
context,
|
|
828
887
|
goal,
|
|
829
888
|
renumberStep(level, getWitnessSuffices(context, goal, step)),
|
|
889
|
+
time,
|
|
830
890
|
);
|
|
831
891
|
case "Pcase": {
|
|
832
892
|
const assertion: Step = {
|
|
@@ -837,6 +897,7 @@ export const createGenerator = (
|
|
|
837
897
|
kind: "Fact",
|
|
838
898
|
expression: step.expression,
|
|
839
899
|
visibility: "Visible",
|
|
900
|
+
time,
|
|
840
901
|
location: step.location,
|
|
841
902
|
},
|
|
842
903
|
],
|
|
@@ -845,7 +906,7 @@ export const createGenerator = (
|
|
|
845
906
|
proof: step.proof,
|
|
846
907
|
...getProps(step),
|
|
847
908
|
};
|
|
848
|
-
return simplifyStep(context, goal, renumberStep(level, assertion));
|
|
909
|
+
return simplifyStep(context, goal, renumberStep(level, assertion), time);
|
|
849
910
|
}
|
|
850
911
|
case "Pick": {
|
|
851
912
|
const existential: Expr = at(
|
|
@@ -853,13 +914,18 @@ export const createGenerator = (
|
|
|
853
914
|
step,
|
|
854
915
|
);
|
|
855
916
|
const salted = getSalted(step.step, "ex");
|
|
856
|
-
const [assertContext, assertGoal, asserted] = simplifyStep(
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
917
|
+
const [assertContext, assertGoal, asserted, assertTime] = simplifyStep(
|
|
918
|
+
context,
|
|
919
|
+
goal,
|
|
920
|
+
{
|
|
921
|
+
kind: "Assert",
|
|
922
|
+
sequent: { context: [], active: existential },
|
|
923
|
+
proof: step.proof,
|
|
924
|
+
...getProps(step),
|
|
925
|
+
step: salted,
|
|
926
|
+
},
|
|
927
|
+
time,
|
|
928
|
+
);
|
|
863
929
|
const shifted = shiftExpr(2, existential);
|
|
864
930
|
if (shifted.kind !== "Quant") throw new TlaProofError("Proof.Simplify.simplify_step/PICK");
|
|
865
931
|
const hyps = [
|
|
@@ -868,16 +934,22 @@ export const createGenerator = (
|
|
|
868
934
|
kind: "Fact",
|
|
869
935
|
expression: shifted.body,
|
|
870
936
|
visibility: "Visible",
|
|
937
|
+
time: assertTime,
|
|
871
938
|
location: shifted.body.location,
|
|
872
939
|
} satisfies Hyp,
|
|
873
940
|
];
|
|
874
|
-
const [nextContext, nextGoal, sufficed] = simplifyStep(
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
941
|
+
const [nextContext, nextGoal, sufficed, nextTime] = simplifyStep(
|
|
942
|
+
assertContext,
|
|
943
|
+
assertGoal,
|
|
944
|
+
{
|
|
945
|
+
kind: "Suffices",
|
|
946
|
+
sequent: { context: hyps, active: shiftExpr(hyps.length, assertGoal) },
|
|
947
|
+
proof: { kind: "Omitted", omission: "Elsewhere", ...getProps(step) },
|
|
948
|
+
...getProps(step),
|
|
949
|
+
},
|
|
950
|
+
assertTime,
|
|
951
|
+
);
|
|
952
|
+
return [nextContext, nextGoal, [...asserted, ...sufficed], nextTime];
|
|
881
953
|
}
|
|
882
954
|
}
|
|
883
955
|
};
|
|
@@ -974,6 +1046,7 @@ export const createGenerator = (
|
|
|
974
1046
|
kind: "Fact",
|
|
975
1047
|
expression: getTrue(goal),
|
|
976
1048
|
visibility: "Visible",
|
|
1049
|
+
time: "Now",
|
|
977
1050
|
location: step.location,
|
|
978
1051
|
},
|
|
979
1052
|
],
|
|
@@ -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;
|
|
@@ -39,7 +41,11 @@ export interface ObligationSource {
|
|
|
39
41
|
export interface PrintedObligation {
|
|
40
42
|
id: number;
|
|
41
43
|
location: string;
|
|
44
|
+
locus: Locus | undefined;
|
|
42
45
|
text: string;
|
|
46
|
+
kind: ObligationKind;
|
|
47
|
+
sequent: Sequent;
|
|
48
|
+
method?: OldMethod;
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
export interface ModuleObligations {
|
|
@@ -307,7 +313,17 @@ export const getObligations = (
|
|
|
307
313
|
obligation.kind.kind === "Error"
|
|
308
314
|
? obligation.kind.message
|
|
309
315
|
: `${formatObligation(obligation.sequent)}\n`;
|
|
310
|
-
return [
|
|
316
|
+
return [
|
|
317
|
+
{
|
|
318
|
+
id: index + 1,
|
|
319
|
+
location: formatLocus(location),
|
|
320
|
+
locus: location,
|
|
321
|
+
text,
|
|
322
|
+
kind: obligation.kind,
|
|
323
|
+
sequent: obligation.sequent,
|
|
324
|
+
method: obligation.method,
|
|
325
|
+
},
|
|
326
|
+
];
|
|
311
327
|
});
|
|
312
328
|
return [
|
|
313
329
|
{ 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
|
}
|