tla-ts 0.0.4-dev.4819fb7 → 0.0.4-dev.55f2117
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 +37 -126
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/deciders.cjs +366 -0
- package/dist/deciders.js +366 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +33 -1
- package/dist/index.d.ts +33 -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.cjs +45 -0
- package/dist/run.js +45 -0
- 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/ast.ts +2 -2
- package/src/check.ts +8 -7
- package/src/{cli-options.ts → cli/options.ts} +1 -1
- package/src/{run-cli.ts → cli/run.ts} +302 -100
- package/src/cli.ts +1 -1
- package/src/codegen.ts +26 -7
- package/src/config.ts +2 -2
- package/src/environment.ts +9 -9
- package/src/errors.ts +89 -30
- package/src/evaluate.ts +58 -23
- package/src/index.ts +10 -0
- package/src/levels.ts +1 -1
- package/src/live-check.ts +1 -1
- package/src/liveness.ts +1 -1
- package/src/{obligation-action.ts → obligations/action.ts} +247 -69
- package/src/{obligation-anon.ts → obligations/anon.ts} +49 -47
- package/src/obligations/ctx.ts +64 -0
- package/src/{obligation-deref.ts → obligations/deref.ts} +51 -92
- package/src/{obligation-expression.ts → obligations/expression.ts} +117 -57
- package/src/{obligation-format.ts → obligations/format.ts} +7 -8
- package/src/{obligation-generate.ts → obligations/generate.ts} +170 -192
- package/src/{obligations.ts → obligations/index.ts} +32 -16
- package/src/{obligation-levels.ts → obligations/levels.ts} +26 -28
- package/src/{obligation-module.ts → obligations/module.ts} +113 -121
- 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 -2
- package/src/{obligation-source.ts → obligations/source.ts} +154 -99
- package/src/obligations/temporal.ts +321 -0
- package/src/{obligation-tuples.ts → obligations/tuples.ts} +38 -54
- package/src/parallel-worker.ts +4 -20
- package/src/parallel.ts +13 -46
- package/src/parser.ts +1 -1
- package/src/{pcal-ast.ts → pcal/ast.ts} +2 -2
- package/src/{pcal-parse.ts → pcal/parse.ts} +3 -3
- package/src/{pcal-tokenize.ts → pcal/tokenize.ts} +2 -2
- package/src/{pcal-translate.ts → pcal/translate.ts} +2 -2
- package/src/{pcal-validate.ts → pcal/validate.ts} +6 -6
- package/src/prove/decide-pool.ts +95 -0
- package/src/prove/deciders.ts +33 -0
- package/src/prove/first-order.ts +78 -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 +446 -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 +546 -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 +433 -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 +331 -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 +330 -0
- package/src/prove/isabelle/pure/name.ts +98 -0
- package/src/prove/isabelle/pure/net.ts +215 -0
- package/src/prove/isabelle/pure/object-logic.ts +41 -0
- package/src/prove/isabelle/pure/pattern.ts +631 -0
- package/src/prove/isabelle/pure/raw-simplifier.ts +338 -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 +133 -0
- package/src/prove/isabelle/pure/simplifier.ts +106 -0
- package/src/prove/isabelle/pure/table.ts +201 -0
- package/src/prove/isabelle/pure/tactic.ts +168 -0
- package/src/prove/isabelle/pure/tactical.ts +264 -0
- package/src/prove/isabelle/pure/term-ord.ts +105 -0
- package/src/prove/isabelle/pure/term.ts +688 -0
- package/src/prove/isabelle/pure/thm.ts +783 -0
- package/src/prove/isabelle/pure/type.ts +121 -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 +508 -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 +529 -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 +22 -0
- package/src/prove/prove.ts +498 -0
- package/src/prove/ptl/decide.ts +68 -0
- package/src/prove/ptl/encode.ts +255 -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 +209 -0
- package/src/prove/smt/context.ts +108 -0
- package/src/prove/smt/data.ts +636 -0
- package/src/prove/smt/encode.ts +164 -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 +181 -0
- package/src/prove/smt/rewrite.ts +772 -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 +91 -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 +642 -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 +737 -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/cache.ts +236 -0
- package/src/prove/tlapm/ocaml-marshal.ts +166 -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 +379 -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 +162 -0
- package/src/prove/zenon/tla/tla.ts +506 -0
- package/src/randomization.ts +1 -1
- package/src/resolve.ts +1 -1
- package/src/runtime.ts +2 -2
- package/src/{sany-builtins.ts → sany/builtins.ts} +1 -1
- package/src/{sany-generator.ts → sany/generator.ts} +14 -14
- package/src/{sany-levels.ts → sany/levels.ts} +2 -2
- package/src/{sany-lexer.ts → sany/lexer.ts} +1 -1
- package/src/{sany-linter.ts → sany/linter.ts} +1 -1
- package/src/{sany-modules.ts → sany/modules.ts} +2 -2
- package/src/{sany-parse-error.ts → sany/parse-error.ts} +2 -2
- package/src/{sany-report.ts → sany/report.ts} +15 -15
- package/src/{sany-selectors.ts → sany/selectors.ts} +3 -3
- package/src/{sany-source.ts → sany/source.ts} +6 -6
- package/src/{sany-xml.ts → sany/xml.ts} +5 -5
- package/src/spec-description.ts +1 -1
- package/src/{standard-levels.ts → standard/levels.ts} +1 -1
- package/src/{standard-modules.ts → standard/modules.ts} +17 -14
- package/src/{standard-ranges.ts → standard/ranges.ts} +1 -1
- package/src/state-graph.ts +1 -1
- package/src/successors.ts +25 -6
- package/src/symmetry.ts +1 -1
- package/src/{tlc-messages.ts → tlc/messages.ts} +2 -2
- package/src/{tlc-order.ts → tlc/order.ts} +7 -7
- package/src/{tlc-random.ts → tlc/random.ts} +58 -35
- package/src/{tlc-replay.ts → tlc/replay.ts} +5 -5
- package/src/{tlc-module.ts → tlc/tlc-operators.ts} +9 -9
- package/src/{tlc-ext.ts → tlc/tlcext-operators.ts} +14 -8
- package/src/{tlc-version.ts → tlc/version.ts} +8 -7
- package/src/values.ts +81 -36
- package/src/worker.ts +65 -0
- package/dist/parallel.cjs +0 -12
- package/dist/parallel.js +0 -12
- package/dist/run-cli.cjs +0 -55
- package/dist/run-cli.js +0 -55
- package/src/value-sources.ts +0 -29
- /package/src/{sany-nodes.ts → sany/nodes.ts} +0 -0
- /package/src/{tlc-modules.ts → tlc/jar-data.ts} +0 -0
- /package/src/{tlc-summary.ts → tlc/summary.ts} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// A port of tlapm's anonymization (Expr.Anon, Elab.desugar and Proof.Anon): names become de Bruijn
|
|
2
2
|
// indices into the context, builtin definitions are inlined, and anonymous steps get names.
|
|
3
3
|
|
|
4
|
-
import { TlapmBugError, TlaProofError } from "
|
|
4
|
+
import { TlapmBugError, TlaProofError } from "../errors";
|
|
5
5
|
import {
|
|
6
6
|
adjoin,
|
|
7
7
|
adjoinAll,
|
|
@@ -10,8 +10,10 @@ import {
|
|
|
10
10
|
consSubstitution,
|
|
11
11
|
exprifySequent,
|
|
12
12
|
findNamed,
|
|
13
|
+
getBoundFresh,
|
|
13
14
|
getErrorNote,
|
|
14
15
|
getFresh,
|
|
16
|
+
getLocalDefn,
|
|
15
17
|
getLocusPrefix,
|
|
16
18
|
getScopeAt,
|
|
17
19
|
isEqualExpr,
|
|
@@ -29,14 +31,15 @@ import {
|
|
|
29
31
|
type Expr,
|
|
30
32
|
type ExprCore,
|
|
31
33
|
type Hyp,
|
|
32
|
-
type
|
|
34
|
+
type Warn,
|
|
33
35
|
type ParenForm,
|
|
34
36
|
type Scope,
|
|
35
37
|
type Selector,
|
|
36
38
|
type Sequent,
|
|
37
39
|
type WhereDefined,
|
|
38
|
-
} from "./
|
|
39
|
-
import { resolveSubexpression } from "./
|
|
40
|
+
} from "./expression";
|
|
41
|
+
import { resolveSubexpression } from "./deref";
|
|
42
|
+
import { getTime } from "./temporal";
|
|
40
43
|
import {
|
|
41
44
|
getStepName,
|
|
42
45
|
getUnique,
|
|
@@ -46,12 +49,13 @@ import {
|
|
|
46
49
|
type StepNumber,
|
|
47
50
|
type UseDef,
|
|
48
51
|
type Usable,
|
|
49
|
-
} from "./
|
|
52
|
+
} from "./proof";
|
|
50
53
|
|
|
51
54
|
const DUMMY_FACT: Hyp = {
|
|
52
55
|
kind: "Fact",
|
|
53
56
|
expression: { kind: "At", isExcept: false },
|
|
54
57
|
visibility: "Visible",
|
|
58
|
+
time: "Always",
|
|
55
59
|
};
|
|
56
60
|
|
|
57
61
|
const ANON_SELECTOR_FAILURES = {
|
|
@@ -61,7 +65,7 @@ const ANON_SELECTOR_FAILURES = {
|
|
|
61
65
|
Instance: "1INST",
|
|
62
66
|
Left: "1",
|
|
63
67
|
Right: "1",
|
|
64
|
-
}
|
|
68
|
+
};
|
|
65
69
|
|
|
66
70
|
const BAD_EXPRESSION: Expr = { kind: "Opaque", name: "$badexp" };
|
|
67
71
|
|
|
@@ -76,11 +80,13 @@ export const createAnonymizer = (
|
|
|
76
80
|
scope: Scope | undefined,
|
|
77
81
|
definition: Extract<Defn, { kind: "Instance" }>,
|
|
78
82
|
) => Defn[],
|
|
79
|
-
onWarning:
|
|
83
|
+
onWarning: Warn,
|
|
80
84
|
) => {
|
|
81
85
|
// Elab.desugar's current_at: the value @ stands for inside an EXCEPT, and the context size there.
|
|
82
86
|
let currentAt: { expression: Expr; size: number } | undefined;
|
|
83
87
|
|
|
88
|
+
const getContext = (scope: Scope | undefined): AnonContext => ({ warnedSteps: [], scope });
|
|
89
|
+
|
|
84
90
|
const getSize = (context: AnonContext) => context.scope?.size ?? 0;
|
|
85
91
|
|
|
86
92
|
const expr = (context: AnonContext, expression: Expr): Expr => {
|
|
@@ -217,7 +223,7 @@ export const createAnonymizer = (
|
|
|
217
223
|
mapSelectorArgs(selector, (arg) => expr(context, arg)),
|
|
218
224
|
);
|
|
219
225
|
const args = inner.args.map((arg) => expr(context, arg));
|
|
220
|
-
const bangContext =
|
|
226
|
+
const bangContext = getContext(context.scope);
|
|
221
227
|
return resolveBang(bangContext, inner.operator.name, args, selectors, false, expression);
|
|
222
228
|
}
|
|
223
229
|
return expr(context, {
|
|
@@ -273,13 +279,12 @@ export const createAnonymizer = (
|
|
|
273
279
|
const adjoinContext = (context: AnonContext, hyp: Hyp) =>
|
|
274
280
|
withScope(context, adjoin(context.scope, hyp));
|
|
275
281
|
|
|
282
|
+
const adjoinBounds = (context: AnonContext, items: Bound[]) =>
|
|
283
|
+
withScope(context, adjoinAll(context.scope, items.map(getBoundFresh)));
|
|
284
|
+
|
|
276
285
|
const bounds = (context: AnonContext, items: Bound[]): [AnonContext, Bound[]] => {
|
|
277
286
|
const mapped = mapBoundDomains(items, (domain) => expr(context, domain));
|
|
278
|
-
|
|
279
|
-
(current, bound) => adjoinContext(current, getFresh(bound.name, bound.level)),
|
|
280
|
-
context,
|
|
281
|
-
);
|
|
282
|
-
return [inner, mapped];
|
|
287
|
+
return [adjoinBounds(context, mapped), mapped];
|
|
283
288
|
};
|
|
284
289
|
|
|
285
290
|
// Visit.map, apart from the definitions an ASSUME or a LET binds.
|
|
@@ -325,13 +330,7 @@ export const createAnonymizer = (
|
|
|
325
330
|
continue;
|
|
326
331
|
}
|
|
327
332
|
const result = defn(current, definition);
|
|
328
|
-
current = adjoinContext(current, {
|
|
329
|
-
kind: "Defn",
|
|
330
|
-
definition: result,
|
|
331
|
-
whereDefined: "User",
|
|
332
|
-
visibility: "Visible",
|
|
333
|
-
isLocal: true,
|
|
334
|
-
});
|
|
333
|
+
current = adjoinContext(current, { ...getLocalDefn(result), isConstnessUnset: true });
|
|
335
334
|
mapped.push(result);
|
|
336
335
|
}
|
|
337
336
|
return [current, mapped];
|
|
@@ -346,8 +345,10 @@ export const createAnonymizer = (
|
|
|
346
345
|
return item;
|
|
347
346
|
case "Defn":
|
|
348
347
|
return { ...item, definition: defn(context, item.definition) };
|
|
349
|
-
case "Fact":
|
|
350
|
-
|
|
348
|
+
case "Fact": {
|
|
349
|
+
const expression = expr(context, item.expression);
|
|
350
|
+
return { ...item, expression, time: getTime(context.scope, expression) };
|
|
351
|
+
}
|
|
351
352
|
}
|
|
352
353
|
})();
|
|
353
354
|
return [adjoinContext(context, mapped), mapped];
|
|
@@ -363,13 +364,14 @@ export const createAnonymizer = (
|
|
|
363
364
|
scope: context.scope,
|
|
364
365
|
});
|
|
365
366
|
|
|
366
|
-
const
|
|
367
|
+
const adjoinStep = (context: AnonContext, step: StepNumber, body: Expr, from: Step) =>
|
|
367
368
|
adjoinContext(context, {
|
|
368
369
|
kind: "Defn",
|
|
369
370
|
definition: { kind: "Operator", name: getStepName(step), body, location: from.location },
|
|
370
|
-
whereDefined: "Proof",
|
|
371
|
+
whereDefined: { kind: "Proof", time: "Always" },
|
|
371
372
|
visibility: "Visible",
|
|
372
373
|
isLocal: true,
|
|
374
|
+
isConstnessUnset: true,
|
|
373
375
|
location: from.location,
|
|
374
376
|
});
|
|
375
377
|
|
|
@@ -458,22 +460,22 @@ export const createAnonymizer = (
|
|
|
458
460
|
const [, mapped] = sequent(context, item.sequent);
|
|
459
461
|
const assumptions = mapped.context.reduce(adjoinContext, context);
|
|
460
462
|
const withTuple = bumpContext(
|
|
461
|
-
|
|
463
|
+
adjoinStep(bumpContext(assumptions, 1), number, at(tupleForm(mapped), item), item),
|
|
462
464
|
1,
|
|
463
465
|
);
|
|
464
466
|
const inner = mapped.context.length === 0 ? pushWarnedStep(withTuple, number) : withTuple;
|
|
465
467
|
const result: Step = { ...item, sequent: mapped, proof: proof(inner, item.proof) };
|
|
466
468
|
return [
|
|
467
|
-
bumpContext(
|
|
469
|
+
bumpContext(adjoinStep(context, number, at(exprifySequent(mapped), item), item), 1),
|
|
468
470
|
result,
|
|
469
471
|
];
|
|
470
472
|
}
|
|
471
473
|
case "Pcase": {
|
|
472
474
|
const expression = expr(context, item.expression);
|
|
473
475
|
const tuple = at({ kind: "Tuple", elements: [shiftExpr(2, expression)] }, item);
|
|
474
|
-
const inner = bumpContext(
|
|
476
|
+
const inner = bumpContext(adjoinStep(bumpContext(context, 2), number, tuple, item), 1);
|
|
475
477
|
const result: Step = { ...item, expression, proof: proof(inner, item.proof) };
|
|
476
|
-
const after =
|
|
478
|
+
const after = adjoinStep(
|
|
477
479
|
context,
|
|
478
480
|
number,
|
|
479
481
|
at({ kind: "Tuple", elements: [expression] }, item),
|
|
@@ -484,17 +486,20 @@ export const createAnonymizer = (
|
|
|
484
486
|
case "Suffices": {
|
|
485
487
|
const [, mapped] = sequent(context, item.sequent);
|
|
486
488
|
const fact = at({ kind: "Tuple", elements: [at(exprifySequent(mapped), item)] }, item);
|
|
487
|
-
const inner = bumpContext(
|
|
489
|
+
const inner = bumpContext(adjoinStep(context, number, fact, item), 1);
|
|
488
490
|
const result: Step = { ...item, sequent: mapped, proof: proof(inner, item.proof) };
|
|
489
491
|
const assumptions = mapped.context.reduce(adjoinContext, context);
|
|
490
492
|
const tuple = at({ kind: "Tuple", elements: [at(tupleForm(mapped), item)] }, item);
|
|
491
|
-
return [
|
|
493
|
+
return [
|
|
494
|
+
bumpContext(adjoinStep(bumpContext(assumptions, 1), number, tuple, item), 1),
|
|
495
|
+
result,
|
|
496
|
+
];
|
|
492
497
|
}
|
|
493
498
|
case "Have": {
|
|
494
499
|
const expression = expr(context, item.expression);
|
|
495
500
|
const tuple = at({ kind: "Tuple", elements: [shiftExpr(2, expression)] }, item);
|
|
496
501
|
return [
|
|
497
|
-
bumpContext(
|
|
502
|
+
bumpContext(adjoinStep(bumpContext(context, 2), number, tuple, item), 1),
|
|
498
503
|
{ ...item, expression },
|
|
499
504
|
];
|
|
500
505
|
}
|
|
@@ -505,7 +510,7 @@ export const createAnonymizer = (
|
|
|
505
510
|
item,
|
|
506
511
|
);
|
|
507
512
|
return [
|
|
508
|
-
bumpContext(
|
|
513
|
+
bumpContext(adjoinStep(bumpContext(inner, 1), number, universal, item), 1),
|
|
509
514
|
{ ...item, bounds: mapped },
|
|
510
515
|
];
|
|
511
516
|
}
|
|
@@ -513,7 +518,7 @@ export const createAnonymizer = (
|
|
|
513
518
|
const expressions = item.expressions.map((expression) => expr(context, expression));
|
|
514
519
|
const tuple = at({ kind: "Tuple", elements: expressions }, item);
|
|
515
520
|
return [
|
|
516
|
-
bumpContext(
|
|
521
|
+
bumpContext(adjoinStep(bumpContext(context, 1), number, tuple, item), 1),
|
|
517
522
|
{ ...item, expressions },
|
|
518
523
|
];
|
|
519
524
|
}
|
|
@@ -525,7 +530,7 @@ export const createAnonymizer = (
|
|
|
525
530
|
item,
|
|
526
531
|
);
|
|
527
532
|
const inner = pushWarnedStep(
|
|
528
|
-
bumpContext(
|
|
533
|
+
bumpContext(adjoinStep(bumpContext(context, 1), number, existential, item), 1),
|
|
529
534
|
number,
|
|
530
535
|
);
|
|
531
536
|
const result: Step = {
|
|
@@ -534,12 +539,12 @@ export const createAnonymizer = (
|
|
|
534
539
|
expression,
|
|
535
540
|
proof: proof(inner, item.proof),
|
|
536
541
|
};
|
|
537
|
-
const declared = mapped
|
|
538
|
-
(current, bound) => adjoinContext(current, getFresh(bound.name, bound.level)),
|
|
539
|
-
bumpContext(context, 2),
|
|
540
|
-
);
|
|
542
|
+
const declared = adjoinBounds(bumpContext(context, 2), mapped);
|
|
541
543
|
const shifted = shiftExpr(4 + mapped.length, existential);
|
|
542
|
-
return [
|
|
544
|
+
return [
|
|
545
|
+
bumpContext(adjoinStep(bumpContext(declared, 2), number, shifted, item), 1),
|
|
546
|
+
result,
|
|
547
|
+
];
|
|
543
548
|
}
|
|
544
549
|
case "Use": {
|
|
545
550
|
const mapped = usable(context, item.usable);
|
|
@@ -557,14 +562,11 @@ export const createAnonymizer = (
|
|
|
557
562
|
};
|
|
558
563
|
|
|
559
564
|
return {
|
|
560
|
-
expr: (scope: Scope | undefined, expression: Expr) =>
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
sequent({ warnedSteps: [], scope }, item)[1],
|
|
566
|
-
usable: (scope: Scope | undefined, item: Usable) => usable({ warnedSteps: [], scope }, item),
|
|
567
|
-
proof: (scope: Scope | undefined, item: Proof) => proof({ warnedSteps: [], scope }, item),
|
|
565
|
+
expr: (scope: Scope | undefined, expression: Expr) => expr(getContext(scope), expression),
|
|
566
|
+
defn: (scope: Scope | undefined, definition: Defn) => defn(getContext(scope), definition),
|
|
567
|
+
sequent: (scope: Scope | undefined, item: Sequent) => sequent(getContext(scope), item)[1],
|
|
568
|
+
usable: (scope: Scope | undefined, item: Usable) => usable(getContext(scope), item),
|
|
569
|
+
proof: (scope: Scope | undefined, item: Proof) => proof(getContext(scope), item),
|
|
568
570
|
};
|
|
569
571
|
};
|
|
570
572
|
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// tlapm's Ctx, which names each binder apart from the names in scope by adding a salt, as a
|
|
2
|
+
// mutable stack: printers bind and unbind names in strict nesting order.
|
|
3
|
+
|
|
4
|
+
interface Ident {
|
|
5
|
+
rep: string;
|
|
6
|
+
salt: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface Context {
|
|
10
|
+
stack: Ident[];
|
|
11
|
+
idents: Map<string, Ident[]>;
|
|
12
|
+
defined: Map<string, number>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const getIdentName = (ident: Ident) =>
|
|
16
|
+
ident.salt === 0 ? ident.rep : `${ident.rep}_${ident.salt}`;
|
|
17
|
+
|
|
18
|
+
export const createContext = (): Context => ({
|
|
19
|
+
stack: [],
|
|
20
|
+
idents: new Map(),
|
|
21
|
+
defined: new Map(),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// The name of the binder index places in, counting from 1 for the innermost.
|
|
25
|
+
export const getBoundName = (context: Context, index: number) => {
|
|
26
|
+
const ident = context.stack[context.stack.length - index];
|
|
27
|
+
return ident && getIdentName(ident);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const pushName = (context: Context, rep: string) => {
|
|
31
|
+
const previous = context.idents.get(rep)?.at(-1);
|
|
32
|
+
let ident: Ident = previous ? { rep, salt: previous.salt + 1 } : { rep, salt: 0 };
|
|
33
|
+
while (context.defined.has(getIdentName(ident))) ident = { rep, salt: ident.salt + 1 };
|
|
34
|
+
context.stack.push(ident);
|
|
35
|
+
const idents = context.idents.get(rep);
|
|
36
|
+
if (idents) idents.push(ident);
|
|
37
|
+
else context.idents.set(rep, [ident]);
|
|
38
|
+
const key = getIdentName(ident);
|
|
39
|
+
context.defined.set(key, (context.defined.get(key) ?? 0) + 1);
|
|
40
|
+
return key;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const popNames = (context: Context, count: number) => {
|
|
44
|
+
for (let index = 0; index < count; index++) {
|
|
45
|
+
const ident = context.stack.pop();
|
|
46
|
+
if (!ident) return;
|
|
47
|
+
context.idents.get(ident.rep)?.pop();
|
|
48
|
+
const key = getIdentName(ident);
|
|
49
|
+
const remaining = (context.defined.get(key) ?? 1) - 1;
|
|
50
|
+
if (remaining === 0) context.defined.delete(key);
|
|
51
|
+
else context.defined.set(key, remaining);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const withNames = <Result>(
|
|
56
|
+
context: Context,
|
|
57
|
+
names: string[],
|
|
58
|
+
body: (idents: string[]) => Result,
|
|
59
|
+
) => {
|
|
60
|
+
const idents = names.map((name) => pushName(context, name));
|
|
61
|
+
const result = body(idents);
|
|
62
|
+
popNames(context, names.length);
|
|
63
|
+
return result;
|
|
64
|
+
};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
// A port of tlapm's Expr.Deref: a subexpression reference such as Op!2!<< resolves to the
|
|
2
2
|
// subexpression it names, abstracted over the bound names it uses.
|
|
3
3
|
|
|
4
|
-
import { TlaProofError, TlapmBugError } from "
|
|
4
|
+
import { TlaProofError, TlapmBugError } from "../errors";
|
|
5
5
|
import {
|
|
6
6
|
at,
|
|
7
7
|
consAll,
|
|
8
8
|
consSubstitution,
|
|
9
9
|
getErrorNote,
|
|
10
|
+
getBoundFresh,
|
|
10
11
|
getChildren,
|
|
11
12
|
getFresh,
|
|
13
|
+
getParamFresh,
|
|
12
14
|
mapChildren,
|
|
13
15
|
mapSelectorArgs,
|
|
14
16
|
shift,
|
|
@@ -17,10 +19,10 @@ import {
|
|
|
17
19
|
type Defn,
|
|
18
20
|
type Expr,
|
|
19
21
|
type Hyp,
|
|
20
|
-
type
|
|
22
|
+
type Warn,
|
|
21
23
|
type Param,
|
|
22
24
|
type Selector,
|
|
23
|
-
} from "./
|
|
25
|
+
} from "./expression";
|
|
24
26
|
|
|
25
27
|
interface Deref {
|
|
26
28
|
params: Param[];
|
|
@@ -70,7 +72,7 @@ const findLabel = (expression: Expr, label: string, context: Hyp[]): Label | und
|
|
|
70
72
|
(found, bound) =>
|
|
71
73
|
found ?? (bound.domain.kind === "Domain" ? search(bound.domain.expression) : undefined),
|
|
72
74
|
undefined,
|
|
73
|
-
) ?? search(body, [...context, ...bounds.map(
|
|
75
|
+
) ?? search(body, [...context, ...bounds.map(getBoundFresh)]);
|
|
74
76
|
switch (expression.kind) {
|
|
75
77
|
case "Parens":
|
|
76
78
|
if (expression.form.kind !== "Xlabel") return search(expression.expression);
|
|
@@ -78,10 +80,7 @@ const findLabel = (expression: Expr, label: string, context: Hyp[]): Label | und
|
|
|
78
80
|
? { context, expression: expression.expression, indices: expression.form.indices }
|
|
79
81
|
: undefined;
|
|
80
82
|
case "Lambda":
|
|
81
|
-
return search(expression.body, [
|
|
82
|
-
...context,
|
|
83
|
-
...expression.params.map((param) => getFresh(param.name, "Unknown", param.shape)),
|
|
84
|
-
]);
|
|
83
|
+
return search(expression.body, [...context, ...expression.params.map(getParamFresh)]);
|
|
85
84
|
case "Let": {
|
|
86
85
|
const inner = [...context];
|
|
87
86
|
for (const definition of expression.definitions) {
|
|
@@ -144,11 +143,7 @@ const getReversal = (count: number, paramCount: number) =>
|
|
|
144
143
|
const getIndices = (count: number) =>
|
|
145
144
|
Array.from({ length: count }, (_item, index): Expr => ({ kind: "Ix", index: count - index }));
|
|
146
145
|
|
|
147
|
-
const instantiate = (
|
|
148
|
-
onWarning: (warning: ObligationWarning) => void,
|
|
149
|
-
expression: Expr,
|
|
150
|
-
args: Expr[],
|
|
151
|
-
): Expr => {
|
|
146
|
+
const instantiate = (onWarning: Warn, expression: Expr, args: Expr[]): Expr => {
|
|
152
147
|
switch (expression.kind) {
|
|
153
148
|
case "Quant":
|
|
154
149
|
case "Fcn":
|
|
@@ -214,11 +209,7 @@ const instantiate = (
|
|
|
214
209
|
}
|
|
215
210
|
};
|
|
216
211
|
|
|
217
|
-
const abstract = (
|
|
218
|
-
onWarning: (warning: ObligationWarning) => void,
|
|
219
|
-
definitionCount: number,
|
|
220
|
-
expression: Expr,
|
|
221
|
-
): [Param[], Expr] => {
|
|
212
|
+
const abstract = (onWarning: Warn, definitionCount: number, expression: Expr): [Param[], Expr] => {
|
|
222
213
|
const params = ((): Param[] => {
|
|
223
214
|
switch (expression.kind) {
|
|
224
215
|
case "Quant":
|
|
@@ -244,8 +235,7 @@ const abstract = (
|
|
|
244
235
|
};
|
|
245
236
|
|
|
246
237
|
const getNumbered = (
|
|
247
|
-
onWarning:
|
|
248
|
-
definitions: Defn[],
|
|
238
|
+
onWarning: Warn,
|
|
249
239
|
expression: Expr,
|
|
250
240
|
position: number,
|
|
251
241
|
origin: Expr,
|
|
@@ -260,7 +250,10 @@ const getNumbered = (
|
|
|
260
250
|
checkAtMost(items.length);
|
|
261
251
|
return items[position - 1];
|
|
262
252
|
};
|
|
263
|
-
|
|
253
|
+
if (expression.kind === "With") {
|
|
254
|
+
return getNumbered(onWarning, expression.expression, position, origin, message);
|
|
255
|
+
}
|
|
256
|
+
const result = ((): Expr => {
|
|
264
257
|
switch (expression.kind) {
|
|
265
258
|
case "Sequent": {
|
|
266
259
|
const sequent = expression.sequent;
|
|
@@ -287,102 +280,78 @@ const getNumbered = (
|
|
|
287
280
|
{ failure: "Expr.Deref.deref_num" },
|
|
288
281
|
);
|
|
289
282
|
}
|
|
290
|
-
return
|
|
283
|
+
return shifted;
|
|
291
284
|
}
|
|
292
285
|
case "Apply":
|
|
293
|
-
return
|
|
294
|
-
case "With":
|
|
295
|
-
return getNumbered(
|
|
296
|
-
onWarning,
|
|
297
|
-
definitions,
|
|
298
|
-
expression.expression,
|
|
299
|
-
position,
|
|
300
|
-
origin,
|
|
301
|
-
message,
|
|
302
|
-
);
|
|
286
|
+
return pick(expression.args);
|
|
303
287
|
case "If":
|
|
304
|
-
return [
|
|
305
|
-
definitions,
|
|
306
|
-
pick([expression.condition, expression.consequent, expression.alternative]),
|
|
307
|
-
];
|
|
288
|
+
return pick([expression.condition, expression.consequent, expression.alternative]);
|
|
308
289
|
case "List":
|
|
309
|
-
return
|
|
290
|
+
return pick(expression.items);
|
|
310
291
|
case "SetEnum":
|
|
311
292
|
case "Tuple":
|
|
312
|
-
return
|
|
293
|
+
return pick(expression.elements);
|
|
313
294
|
case "Product":
|
|
314
|
-
return
|
|
295
|
+
return pick(expression.factors);
|
|
315
296
|
case "Let":
|
|
316
297
|
checkAtMost(1);
|
|
317
|
-
return
|
|
298
|
+
return expression.body;
|
|
318
299
|
case "Quant":
|
|
319
300
|
case "SetOf":
|
|
320
301
|
case "Fcn":
|
|
321
|
-
return
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
expression.bounds.flatMap((bound) =>
|
|
325
|
-
bound.domain.kind === "Domain" ? [bound.domain.expression] : [],
|
|
326
|
-
),
|
|
302
|
+
return pick(
|
|
303
|
+
expression.bounds.flatMap((bound) =>
|
|
304
|
+
bound.domain.kind === "Domain" ? [bound.domain.expression] : [],
|
|
327
305
|
),
|
|
328
|
-
|
|
306
|
+
);
|
|
329
307
|
case "Choose":
|
|
330
308
|
case "SetSt":
|
|
331
309
|
if (!expression.domain) break;
|
|
332
|
-
return
|
|
310
|
+
return pick([expression.domain]);
|
|
333
311
|
case "Arrow":
|
|
334
|
-
return
|
|
312
|
+
return pick([expression.domain, expression.range]);
|
|
335
313
|
case "FcnApp": {
|
|
336
314
|
const argument =
|
|
337
315
|
expression.args.length === 1
|
|
338
316
|
? expression.args[0]
|
|
339
317
|
: at({ kind: "Tuple", elements: expression.args }, expression);
|
|
340
|
-
return
|
|
318
|
+
return pick([expression.function, argument]);
|
|
341
319
|
}
|
|
342
320
|
case "Rect":
|
|
343
321
|
case "Record":
|
|
344
|
-
return
|
|
322
|
+
return pick(expression.fields.map((field) => field.value));
|
|
345
323
|
case "Dot":
|
|
346
|
-
return [
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
at({ kind: "String", value: expression.field }, expression),
|
|
351
|
-
]),
|
|
352
|
-
];
|
|
324
|
+
return pick([
|
|
325
|
+
expression.expression,
|
|
326
|
+
at({ kind: "String", value: expression.field }, expression),
|
|
327
|
+
]);
|
|
353
328
|
case "Except":
|
|
354
|
-
return [
|
|
355
|
-
definitions,
|
|
356
|
-
pick([expression.function, ...expression.specs.map((spec) => spec.value)]),
|
|
357
|
-
];
|
|
329
|
+
return pick([expression.function, ...expression.specs.map((spec) => spec.value)]);
|
|
358
330
|
case "Sub":
|
|
359
331
|
case "Tsub":
|
|
360
|
-
return
|
|
332
|
+
return pick([expression.action, expression.subscript]);
|
|
361
333
|
case "Fair":
|
|
362
|
-
return
|
|
334
|
+
return pick([expression.subscript, expression.action]);
|
|
363
335
|
case "Case":
|
|
364
|
-
return [
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
)
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
: []),
|
|
373
|
-
]),
|
|
374
|
-
];
|
|
336
|
+
return pick([
|
|
337
|
+
...expression.arms.map((arm) =>
|
|
338
|
+
at({ kind: "Tuple", elements: [arm.condition, arm.body] }, arm.body),
|
|
339
|
+
),
|
|
340
|
+
...(expression.other
|
|
341
|
+
? [at({ kind: "Tuple", elements: [BAD, expression.other] }, expression.other)]
|
|
342
|
+
: []),
|
|
343
|
+
]);
|
|
375
344
|
}
|
|
376
345
|
const emptyMessage = "Expression has no subexpressions";
|
|
377
346
|
onWarning(getErrorNote(expression.location, emptyMessage));
|
|
378
347
|
throw new TlaProofError(emptyMessage, { failure: "Expr.Deref.deref_num" });
|
|
379
348
|
})();
|
|
380
|
-
if (isBad(result
|
|
349
|
+
if (isBad(result)) {
|
|
381
350
|
const badMessage = `Cannot resolve subexpression reference !${position}`;
|
|
382
351
|
onWarning(getErrorNote(expression.location, badMessage));
|
|
383
352
|
throw new TlaProofError(badMessage, { failure: "Expr.Deref.deref_num" });
|
|
384
353
|
}
|
|
385
|
-
return result;
|
|
354
|
+
return [expression.kind === "Let" ? expression.definitions : [], result];
|
|
386
355
|
};
|
|
387
356
|
|
|
388
357
|
// Reorders label arguments given in source order to the order of the label's de Bruijn indices.
|
|
@@ -397,7 +366,7 @@ const permute = (indices: number[], args: Expr[]) => {
|
|
|
397
366
|
};
|
|
398
367
|
|
|
399
368
|
const resolveLabel = (
|
|
400
|
-
onWarning:
|
|
369
|
+
onWarning: Warn,
|
|
401
370
|
definitionCount: number,
|
|
402
371
|
expression: Expr,
|
|
403
372
|
label: string,
|
|
@@ -460,7 +429,7 @@ const resolveLabel = (
|
|
|
460
429
|
};
|
|
461
430
|
|
|
462
431
|
const resolveLetOperator = (
|
|
463
|
-
onWarning:
|
|
432
|
+
onWarning: Warn,
|
|
464
433
|
definitionCount: number,
|
|
465
434
|
expression: Expr,
|
|
466
435
|
label: string,
|
|
@@ -516,12 +485,7 @@ const resolveLetOperator = (
|
|
|
516
485
|
);
|
|
517
486
|
};
|
|
518
487
|
|
|
519
|
-
const deref = (
|
|
520
|
-
onWarning: (warning: ObligationWarning) => void,
|
|
521
|
-
isLabel: boolean,
|
|
522
|
-
state: Deref,
|
|
523
|
-
selectors: Selector[],
|
|
524
|
-
): Expr => {
|
|
488
|
+
const deref = (onWarning: Warn, isLabel: boolean, state: Deref, selectors: Selector[]): Expr => {
|
|
525
489
|
const [selector, ...rest] = selectors;
|
|
526
490
|
if (!selector) {
|
|
527
491
|
const withDefinitions =
|
|
@@ -547,7 +511,6 @@ const deref = (
|
|
|
547
511
|
const numbered = (position: number, message: string) => {
|
|
548
512
|
const [definitions, inner] = getNumbered(
|
|
549
513
|
onWarning,
|
|
550
|
-
[],
|
|
551
514
|
expression,
|
|
552
515
|
position,
|
|
553
516
|
state.expression,
|
|
@@ -608,11 +571,7 @@ const deref = (
|
|
|
608
571
|
);
|
|
609
572
|
};
|
|
610
573
|
|
|
611
|
-
const getInitialDeref = (
|
|
612
|
-
onWarning: (warning: ObligationWarning) => void,
|
|
613
|
-
operator: Expr,
|
|
614
|
-
args: Expr[],
|
|
615
|
-
): Deref => {
|
|
574
|
+
const getInitialDeref = (onWarning: Warn, operator: Expr, args: Expr[]): Deref => {
|
|
616
575
|
if (args.length > 0) {
|
|
617
576
|
return { params: [], definitions: [], expression: instantiate(onWarning, operator, args) };
|
|
618
577
|
}
|
|
@@ -622,7 +581,7 @@ const getInitialDeref = (
|
|
|
622
581
|
};
|
|
623
582
|
|
|
624
583
|
export const resolveSubexpression = (
|
|
625
|
-
onWarning:
|
|
584
|
+
onWarning: Warn,
|
|
626
585
|
operator: Expr,
|
|
627
586
|
args: Expr[],
|
|
628
587
|
selectors: Selector[],
|