tla-ts 0.0.9 → 0.0.10-dev.63a6693bd
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 +29 -1
- package/dist/compile.cjs +23 -0
- package/dist/compile.js +23 -0
- package/dist/deciders.cjs +29 -29
- package/dist/deciders.js +42 -42
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +106 -10
- package/dist/index.d.ts +106 -10
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +1 -1
- package/dist/prove-worker.cjs +1 -1
- package/dist/prove-worker.js +1 -1
- package/dist/prove.cjs +117 -37
- package/dist/prove.js +116 -36
- package/dist/run.cjs +143 -31
- package/dist/run.js +143 -31
- package/dist/tlapm.cjs +2 -2
- package/dist/tlapm.js +2 -2
- package/dist/transfer.cjs +129 -104
- package/dist/transfer.js +129 -104
- package/dist/worker.cjs +7 -7
- package/dist/worker.js +7 -7
- package/package.json +3 -1
- package/src/ast.ts +48 -62
- package/src/bags.ts +99 -102
- package/src/builtins.ts +28 -75
- package/src/bundled-modules.ts +1 -8
- package/src/check-failure.ts +116 -0
- package/src/check-trace.ts +282 -0
- package/src/check.ts +599 -754
- package/src/cli/options.ts +12 -32
- package/src/cli/run.ts +0 -2
- package/src/cli/runtime-invariants.ts +136 -0
- package/src/cli/shared.ts +19 -12
- package/src/cli/tlapm.ts +14 -25
- package/src/cli/tlc-arguments.ts +652 -0
- package/src/cli/tlc-output.ts +687 -0
- package/src/cli/tlc-usage.ts +361 -0
- package/src/cli/tlc.ts +309 -658
- package/src/cli/typescript.ts +23 -0
- package/src/cli/xml-exporter.ts +27 -49
- package/src/cli.ts +0 -1
- package/src/codegen.ts +196 -74
- package/src/config.ts +140 -109
- package/src/coverage.ts +830 -0
- package/src/dependencies.ts +14 -53
- package/src/dfid.ts +618 -0
- package/src/environment-config.ts +315 -0
- package/src/environment.ts +169 -335
- package/src/errors.ts +71 -55
- package/src/evaluate.ts +598 -340
- package/src/exit-codes.ts +37 -3
- package/src/fingerprints.ts +75 -11
- package/src/index.ts +3 -0
- package/src/instances.ts +126 -21
- package/src/java-hash.ts +7 -0
- package/src/java-overrides.ts +4 -19
- package/src/json-reader.ts +455 -0
- package/src/json.ts +252 -139
- package/src/levels.ts +46 -58
- package/src/lexer.ts +80 -100
- package/src/liveness-checker.ts +103 -153
- package/src/liveness.ts +150 -109
- package/src/obligations/action.ts +8 -39
- package/src/obligations/anonymize.ts +88 -82
- package/src/obligations/equality.ts +1 -1
- package/src/obligations/expression.ts +20 -21
- package/src/obligations/format.ts +1 -9
- package/src/obligations/generate.ts +46 -49
- package/src/obligations/index.ts +2 -13
- package/src/obligations/levels.ts +4 -8
- package/src/obligations/module.ts +28 -53
- package/src/obligations/normalize.ts +7 -25
- package/src/obligations/operators.ts +1 -2
- package/src/obligations/pragma.ts +1 -10
- package/src/obligations/printer.ts +47 -46
- package/src/obligations/proof.ts +1 -5
- package/src/obligations/regroup.ts +1 -4
- package/src/obligations/simplify.ts +42 -58
- package/src/obligations/source.ts +48 -78
- package/src/obligations/subexpression.ts +5 -11
- package/src/obligations/substitution.ts +1 -3
- package/src/obligations/temporal.ts +13 -19
- package/src/obligations/tuples.ts +3 -9
- package/src/parallel-worker.ts +30 -60
- package/src/parallel.ts +57 -71
- package/src/parser.ts +584 -316
- package/src/pcal/ast.ts +53 -86
- package/src/pcal/parse.ts +144 -219
- package/src/pcal/tokenize.ts +91 -131
- package/src/pcal/translate.ts +83 -130
- package/src/pcal/validate.ts +48 -68
- package/src/pretty-print.ts +7 -8
- package/src/prover/decide-pool.ts +8 -13
- package/src/prover/deciders.ts +3 -7
- package/src/prover/first-order.ts +0 -11
- package/src/prover/isabelle/decide.ts +0 -6
- package/src/prover/isabelle/encode.ts +11 -23
- package/src/prover/isabelle/isar/inner-syntax.ts +114 -115
- package/src/prover/isabelle/isar/method.ts +29 -53
- package/src/prover/isabelle/isar/proof.ts +1 -10
- package/src/prover/isabelle/isar/statement.ts +1 -6
- package/src/prover/isabelle/isar/theory.ts +26 -36
- package/src/prover/isabelle/isar/type-check.ts +17 -31
- package/src/prover/isabelle/provers/blast/blast.ts +17 -104
- package/src/prover/isabelle/provers/blast/branch.ts +1 -32
- package/src/prover/isabelle/provers/blast/prove.ts +1 -35
- package/src/prover/isabelle/provers/blast/rules.ts +6 -44
- package/src/prover/isabelle/provers/blast/state.ts +2 -28
- package/src/prover/isabelle/provers/blast/term.ts +9 -36
- package/src/prover/isabelle/provers/clasimp.ts +1 -13
- package/src/prover/isabelle/provers/classical.ts +14 -42
- package/src/prover/isabelle/provers/hypsubst.ts +28 -51
- package/src/prover/isabelle/pure/bicompose.ts +25 -38
- package/src/prover/isabelle/pure/consts.ts +1 -7
- package/src/prover/isabelle/pure/conv.ts +3 -17
- package/src/prover/isabelle/pure/drule.ts +33 -42
- package/src/prover/isabelle/pure/envir.ts +3 -52
- package/src/prover/isabelle/pure/goal.ts +1 -7
- package/src/prover/isabelle/pure/interrupt.ts +0 -5
- package/src/prover/isabelle/pure/list.ts +0 -3
- package/src/prover/isabelle/pure/logic.ts +2 -15
- package/src/prover/isabelle/pure/name.ts +2 -9
- package/src/prover/isabelle/pure/net.ts +3 -59
- package/src/prover/isabelle/pure/object-logic.ts +3 -10
- package/src/prover/isabelle/pure/pattern.ts +2 -19
- package/src/prover/isabelle/pure/raw-simplifier.ts +17 -62
- package/src/prover/isabelle/pure/rewriter.ts +31 -67
- package/src/prover/isabelle/pure/search.ts +3 -10
- package/src/prover/isabelle/pure/seq.ts +1 -10
- package/src/prover/isabelle/pure/simplifier.ts +4 -12
- package/src/prover/isabelle/pure/table.ts +3 -32
- package/src/prover/isabelle/pure/tactic.ts +12 -22
- package/src/prover/isabelle/pure/tactical.ts +48 -47
- package/src/prover/isabelle/pure/term-ord.ts +2 -6
- package/src/prover/isabelle/pure/term.ts +2 -43
- package/src/prover/isabelle/pure/thm.ts +27 -47
- package/src/prover/isabelle/pure/type.ts +2 -15
- package/src/prover/isabelle/pure/unify.ts +20 -30
- package/src/prover/isabelle/pure/variable.ts +3 -7
- package/src/prover/isabelle/tla/classical-setup.ts +17 -24
- package/src/prover/isabelle/tla/context.ts +15 -18
- package/src/prover/isabelle/tla/logic.ts +14 -32
- package/src/prover/isabelle/tla/simpdata.ts +46 -43
- package/src/prover/isabelle/tools/intuitionistic.ts +1 -10
- package/src/prover/ocaml.ts +0 -6
- package/src/prover/prep/action.ts +14 -54
- package/src/prover/prep/enabled-axioms.ts +12 -19
- package/src/prover/prep/fingerprint.ts +2 -21
- package/src/prover/prep/level-comparison.ts +8 -12
- package/src/prover/prep/md5.ts +0 -2
- package/src/prover/prep/methods.ts +33 -39
- package/src/prover/prep/normalize.ts +4 -28
- package/src/prover/prove-worker.ts +0 -2
- package/src/prover/prove.ts +87 -100
- package/src/prover/ptl/decide.ts +7 -12
- package/src/prover/ptl/encode.ts +14 -36
- package/src/prover/ptl/sat.ts +24 -32
- package/src/prover/ptl/tableau.ts +12 -26
- package/src/prover/smt/axioms.ts +0 -7
- package/src/prover/smt/context.ts +20 -28
- package/src/prover/smt/data.ts +433 -424
- package/src/prover/smt/encode.ts +43 -52
- package/src/prover/smt/extensionality.ts +0 -10
- package/src/prover/smt/flatten.ts +3 -22
- package/src/prover/smt/format.ts +5 -10
- package/src/prover/smt/instances.ts +0 -10
- package/src/prover/smt/rewrite.ts +663 -667
- package/src/prover/smt/solver/act-cache.ts +0 -15
- package/src/prover/smt/solver/arith-rewriter.ts +3 -48
- package/src/prover/smt/solver/array.ts +1 -3
- package/src/prover/smt/solver/asserted-formulas.ts +1 -43
- package/src/prover/smt/solver/ast-lt.ts +1 -11
- package/src/prover/smt/solver/ast-util.ts +1 -6
- package/src/prover/smt/solver/ast.ts +1 -165
- package/src/prover/smt/solver/auf-solver.ts +8 -44
- package/src/prover/smt/solver/case-split-queue.ts +1 -9
- package/src/prover/smt/solver/cg-table.ts +1 -18
- package/src/prover/smt/solver/clause.ts +1 -27
- package/src/prover/smt/solver/conflict-resolution.ts +0 -9
- package/src/prover/smt/solver/context.ts +7 -64
- package/src/prover/smt/solver/ctx-simplify.ts +14 -41
- package/src/prover/smt/solver/der.ts +2 -21
- package/src/prover/smt/solver/dyn-ack.ts +1 -11
- package/src/prover/smt/solver/e-matching.ts +4 -35
- package/src/prover/smt/solver/enode.ts +1 -21
- package/src/prover/smt/solver/expr-ref.ts +1 -5
- package/src/prover/smt/solver/expr-safe-replace.ts +1 -6
- package/src/prover/smt/solver/fingerprints.ts +1 -12
- package/src/prover/smt/solver/flat-literals.ts +1 -9
- package/src/prover/smt/solver/goal.ts +2 -14
- package/src/prover/smt/solver/hash.ts +0 -8
- package/src/prover/smt/solver/hashtable.ts +1 -12
- package/src/prover/smt/solver/internalizer.ts +7 -100
- package/src/prover/smt/solver/lbool.ts +1 -2
- package/src/prover/smt/solver/literal.ts +0 -3
- package/src/prover/smt/solver/lp/bound-propagator.ts +8 -26
- package/src/prover/smt/solver/lp/constraints.ts +2 -8
- package/src/prover/smt/solver/lp/containers.ts +12 -30
- package/src/prover/smt/solver/lp/core-solver.ts +10 -31
- package/src/prover/smt/solver/lp/cross-nested.ts +6 -20
- package/src/prover/smt/solver/lp/dep-intervals.ts +7 -22
- package/src/prover/smt/solver/lp/dependency.ts +1 -4
- package/src/prover/smt/solver/lp/dioph-eq.ts +9 -102
- package/src/prover/smt/solver/lp/explanation.ts +1 -6
- package/src/prover/smt/solver/lp/gomory.ts +9 -22
- package/src/prover/smt/solver/lp/hnf-cutter.ts +17 -23
- package/src/prover/smt/solver/lp/hnf.ts +11 -26
- package/src/prover/smt/solver/lp/int-cube.ts +15 -36
- package/src/prover/smt/solver/lp/int-solver.ts +4 -34
- package/src/prover/smt/solver/lp/lar-solver.ts +32 -81
- package/src/prover/smt/solver/lp/lar-term.ts +1 -5
- package/src/prover/smt/solver/lp/lp-settings.ts +1 -14
- package/src/prover/smt/solver/lp/maximize-term.ts +20 -45
- package/src/prover/smt/solver/lp/nex-creator.ts +5 -28
- package/src/prover/smt/solver/lp/nex.ts +1 -6
- package/src/prover/smt/solver/lp/nla-backoff.ts +1 -4
- package/src/prover/smt/solver/lp/nla-basics.ts +5 -30
- package/src/prover/smt/solver/lp/nla-core.ts +36 -135
- package/src/prover/smt/solver/lp/nla-divisions.ts +32 -42
- package/src/prover/smt/solver/lp/nla-emonics.ts +4 -21
- package/src/prover/smt/solver/lp/nla-factorization.ts +1 -4
- package/src/prover/smt/solver/lp/nla-grobner.ts +15 -69
- package/src/prover/smt/solver/lp/nla-horner.ts +3 -11
- package/src/prover/smt/solver/lp/nla-intervals.ts +2 -12
- package/src/prover/smt/solver/lp/nla-monomial-bounds.ts +16 -41
- package/src/prover/smt/solver/lp/nla-monotone.ts +2 -6
- package/src/prover/smt/solver/lp/nla-order.ts +2 -13
- package/src/prover/smt/solver/lp/nla-patcher.ts +4 -7
- package/src/prover/smt/solver/lp/nla-tangents.ts +1 -9
- package/src/prover/smt/solver/lp/nla-throttle.ts +1 -6
- package/src/prover/smt/solver/lp/nla-types.ts +1 -11
- package/src/prover/smt/solver/lp/nla-var-eqs.ts +4 -25
- package/src/prover/smt/solver/lp/nra-solver.ts +5 -52
- package/src/prover/smt/solver/lp/numeric-pair.ts +1 -4
- package/src/prover/smt/solver/lp/pdd-interval.ts +1 -3
- package/src/prover/smt/solver/lp/pdd-simplifier.ts +2 -14
- package/src/prover/smt/solver/lp/pdd-solver.ts +4 -33
- package/src/prover/smt/solver/lp/pdd.ts +7 -70
- package/src/prover/smt/solver/lp/random-updater.ts +1 -8
- package/src/prover/smt/solver/lp/static-matrix.ts +9 -19
- package/src/prover/smt/solver/lp/union-find.ts +1 -6
- package/src/prover/smt/solver/mam-compiler.ts +18 -58
- package/src/prover/smt/solver/mam-interpreter.ts +1 -21
- package/src/prover/smt/solver/maximize-ac-sharing.ts +2 -17
- package/src/prover/smt/solver/model-checker.ts +3 -37
- package/src/prover/smt/solver/model-evaluator.ts +3 -29
- package/src/prover/smt/solver/model-finder.ts +15 -32
- package/src/prover/smt/solver/model-generator.ts +1 -12
- package/src/prover/smt/solver/model-macro-solver.ts +23 -88
- package/src/prover/smt/solver/nlsat/algebraic.ts +63 -159
- package/src/prover/smt/solver/nlsat/atoms.ts +25 -23
- package/src/prover/smt/solver/nlsat/evaluator.ts +17 -22
- package/src/prover/smt/solver/nlsat/explain.ts +10 -69
- package/src/prover/smt/solver/nlsat/interval-set.ts +9 -50
- package/src/prover/smt/solver/nlsat/levelwise.ts +49 -135
- package/src/prover/smt/solver/nlsat/mpbq.ts +3 -14
- package/src/prover/smt/solver/nlsat/polynomial.ts +29 -159
- package/src/prover/smt/solver/nlsat/solver.ts +18 -90
- package/src/prover/smt/solver/nlsat/types.ts +1 -8
- package/src/prover/smt/solver/nlsat/upolynomial-factorization.ts +2 -45
- package/src/prover/smt/solver/nlsat/upolynomial.ts +11 -92
- package/src/prover/smt/solver/nnf.ts +3 -38
- package/src/prover/smt/solver/pattern-inference.ts +2 -15
- package/src/prover/smt/solver/poly-rewriter.ts +3 -23
- package/src/prover/smt/solver/propagate-values.ts +1 -10
- package/src/prover/smt/solver/proto-model.ts +3 -52
- package/src/prover/smt/solver/pull-quant.ts +1 -12
- package/src/prover/smt/solver/qe-lite-der.ts +1 -29
- package/src/prover/smt/solver/qe-lite-fm.ts +2 -25
- package/src/prover/smt/solver/qe-lite.ts +3 -33
- package/src/prover/smt/solver/qi-queue.ts +1 -16
- package/src/prover/smt/solver/quant-tactics.ts +5 -22
- package/src/prover/smt/solver/quantifier-analyzer.ts +27 -47
- package/src/prover/smt/solver/quantifier-manager.ts +2 -13
- package/src/prover/smt/solver/random-gen.ts +1 -2
- package/src/prover/smt/solver/rational.ts +1 -8
- package/src/prover/smt/solver/ref-vector.ts +1 -6
- package/src/prover/smt/solver/relevancy.ts +2 -15
- package/src/prover/smt/solver/rewriter-tpl.ts +3 -147
- package/src/prover/smt/solver/rewriter.ts +3 -85
- package/src/prover/smt/solver/rlimit.ts +2 -20
- package/src/prover/smt/solver/smtlib-parser.ts +80 -131
- package/src/prover/smt/solver/solver.ts +23 -34
- package/src/prover/smt/solver/sort.ts +1 -5
- package/src/prover/smt/solver/sticky-generations.ts +0 -5
- package/src/prover/smt/solver/theory-lra-axioms.ts +3 -24
- package/src/prover/smt/solver/theory-lra-bounds.ts +1 -7
- package/src/prover/smt/solver/theory-lra-final-check.ts +4 -22
- package/src/prover/smt/solver/theory-lra-internalize.ts +6 -43
- package/src/prover/smt/solver/theory-lra-model.ts +4 -19
- package/src/prover/smt/solver/theory-lra-propagate.ts +1 -15
- package/src/prover/smt/solver/theory-lra-state.ts +3 -8
- package/src/prover/smt/solver/theory-lra.ts +1 -8
- package/src/prover/smt/solver/var-subst.ts +2 -26
- package/src/prover/smt/table.ts +0 -8
- package/src/prover/tlapm/cache.ts +45 -40
- package/src/prover/tlapm/ocaml-marshal.ts +19 -21
- package/src/prover/tlapm/tlapm.ts +21 -20
- package/src/prover/verdict.ts +7 -2
- package/src/prover/zenon/check/check.ts +1 -11
- package/src/prover/zenon/check/definitions.ts +5 -15
- package/src/prover/zenon/check/equality.ts +0 -8
- package/src/prover/zenon/check/functions.ts +0 -4
- package/src/prover/zenon/check/keys.ts +0 -7
- package/src/prover/zenon/check/propositional.ts +0 -3
- package/src/prover/zenon/check/records.ts +1 -6
- package/src/prover/zenon/check/relations.ts +2 -14
- package/src/prover/zenon/check/rewrites.ts +2 -21
- package/src/prover/zenon/check/sets.ts +40 -61
- package/src/prover/zenon/check/terms.ts +1 -19
- package/src/prover/zenon/check/tla.ts +0 -6
- package/src/prover/zenon/decide.ts +0 -12
- package/src/prover/zenon/encode.ts +1 -8
- package/src/prover/zenon/eqrel.ts +2 -13
- package/src/prover/zenon/equality-rules.ts +0 -4
- package/src/prover/zenon/expr.ts +8 -26
- package/src/prover/zenon/index-table.ts +26 -57
- package/src/prover/zenon/isar-case.ts +9 -19
- package/src/prover/zenon/isar.ts +36 -64
- package/src/prover/zenon/limits.ts +0 -4
- package/src/prover/zenon/llproof.ts +2 -20
- package/src/prover/zenon/mltoll.ts +66 -104
- package/src/prover/zenon/node.ts +1 -11
- package/src/prover/zenon/ocaml.ts +1 -17
- package/src/prover/zenon/parse.ts +4 -12
- package/src/prover/zenon/phrase.ts +1 -11
- package/src/prover/zenon/proof.ts +0 -9
- package/src/prover/zenon/propositional-rules.ts +0 -5
- package/src/prover/zenon/rules.ts +2 -6
- package/src/prover/zenon/search.ts +5 -31
- package/src/prover/zenon/tla/functions.ts +59 -31
- package/src/prover/zenon/tla/llproof.ts +67 -76
- package/src/prover/zenon/tla/records.ts +57 -33
- package/src/prover/zenon/tla/rewrites.ts +12 -19
- package/src/prover/zenon/tla/sets.ts +83 -53
- package/src/prover/zenon/tla/terms.ts +0 -6
- package/src/prover/zenon/tla/tla.ts +66 -64
- package/src/randomization.ts +81 -35
- package/src/resolve.ts +67 -184
- package/src/runtime.ts +22 -22
- package/src/sany/builtins.ts +2 -5
- package/src/sany/generation.ts +394 -0
- package/src/sany/generator-def-entries.ts +210 -0
- package/src/sany/generator-definitions.ts +686 -0
- package/src/sany/generator-expressions.ts +1100 -0
- package/src/sany/generator-proofs.ts +662 -0
- package/src/sany/generator.ts +191 -2764
- package/src/sany/levels.ts +6 -34
- package/src/sany/lexer.ts +58 -77
- package/src/sany/linter.ts +1 -9
- package/src/sany/modules.ts +1 -5
- package/src/sany/nodes.ts +5 -43
- package/src/sany/parse-error.ts +39 -117
- package/src/sany/report.ts +32 -69
- package/src/sany/selectors.ts +49 -76
- package/src/sany/source.ts +1 -17
- package/src/sany/xml.ts +35 -117
- package/src/search.ts +541 -163
- package/src/simulate.ts +709 -0
- package/src/spec-description.ts +192 -100
- package/src/standard-definitions.ts +0 -4
- package/src/standard-modules.ts +264 -95
- package/src/state-graph.ts +52 -31
- package/src/subexpressions.ts +69 -52
- package/src/substitution-levels.ts +7 -7
- package/src/successors.ts +266 -99
- package/src/symmetry.ts +33 -25
- package/src/tableau.ts +27 -24
- package/src/tlc/fingerprint.ts +183 -67
- package/src/tlc/jar-data.ts +112 -6
- package/src/tlc/messages.ts +125 -54
- package/src/tlc/order.ts +39 -69
- package/src/tlc/random.ts +37 -49
- package/src/tlc/replay.ts +553 -228
- package/src/tlc/summary.ts +36 -47
- package/src/tlc/tlc-operators.ts +78 -44
- package/src/tlc/tlcext-operators.ts +139 -122
- package/src/tlc/trace-spec.ts +249 -0
- package/src/tlc/value-stream.ts +139 -0
- package/src/tlc/version.ts +1 -4
- package/src/transfer.ts +22 -25
- package/src/typescript/actions.ts +479 -0
- package/src/typescript/collections.ts +614 -0
- package/src/typescript/compile.ts +63 -0
- package/src/typescript/context.ts +94 -0
- package/src/typescript/emit.ts +121 -0
- package/src/typescript/expressions.ts +496 -0
- package/src/typescript/formula.ts +154 -0
- package/src/typescript/functions.ts +284 -0
- package/src/typescript/model.ts +162 -0
- package/src/typescript/names.ts +114 -0
- package/src/typescript/program.ts +48 -0
- package/src/typescript/properties.ts +139 -0
- package/src/typescript/scope.ts +112 -0
- package/src/typescript/steps.ts +167 -0
- package/src/typescript/types.ts +171 -0
- package/src/values.ts +832 -484
- package/src/worker.ts +7 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// tlapm's expression IR (E_t)
|
|
1
|
+
// A port of tlapm's expression IR (E_t) and its visitors (Visit).
|
|
2
2
|
|
|
3
3
|
import type { OldMethod, PragmaSetting } from "./pragma";
|
|
4
4
|
|
|
@@ -158,7 +158,6 @@ export interface Param {
|
|
|
158
158
|
location?: Locus;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
// isAtomic is Expr.Deref.atomic: a resolved subexpression reference, which has no subexpressions.
|
|
162
161
|
interface ExprProps {
|
|
163
162
|
location?: Locus;
|
|
164
163
|
isAtomic?: boolean;
|
|
@@ -224,10 +223,8 @@ type DefnCore =
|
|
|
224
223
|
|
|
225
224
|
export type Visibility = "Visible" | "Hidden";
|
|
226
225
|
|
|
227
|
-
// When a fact holds: at every point of a behavior, or only at the current one.
|
|
228
226
|
export type Time = "Now" | "Always";
|
|
229
227
|
|
|
230
|
-
// A step or a DEFINE in a proof keeps the time of the scope it is made in.
|
|
231
228
|
export type WhereDefined = "Builtin" | "User" | { kind: "Proof"; time: Time };
|
|
232
229
|
|
|
233
230
|
export type Hyp = HypCore & { location?: Locus };
|
|
@@ -248,8 +245,6 @@ type HypCore =
|
|
|
248
245
|
whereDefined: WhereDefined;
|
|
249
246
|
visibility: Visibility;
|
|
250
247
|
isLocal: boolean;
|
|
251
|
-
// Module.Elab judges whether each module definition is constant. One that anonymization meets
|
|
252
|
-
// in a proof, such as a step or a DEFINE, has no judgment, so tlapm never counts it constant.
|
|
253
248
|
isConstnessUnset?: boolean;
|
|
254
249
|
}
|
|
255
250
|
| { kind: "Fact"; expression: Expr; visibility: Visibility; time: Time; useLocation?: Locus };
|
|
@@ -259,12 +254,15 @@ export interface Sequent {
|
|
|
259
254
|
active: Expr;
|
|
260
255
|
}
|
|
261
256
|
|
|
262
|
-
// tlapm's core @@ from, which takes the properties of from.
|
|
263
257
|
export const at = (core: ExprCore, from: ExprProps): Expr => {
|
|
264
258
|
const located = from.location ? { ...core, location: from.location } : core;
|
|
265
259
|
return from.isAtomic ? { ...located, isAtomic: true } : located;
|
|
266
260
|
};
|
|
267
261
|
|
|
262
|
+
export const AT_NOWHERE: Expr = { kind: "At", isExcept: false };
|
|
263
|
+
|
|
264
|
+
export const getTrue = (from: ExprProps) => at({ kind: "Internal", builtin: "TRUE" }, from);
|
|
265
|
+
|
|
268
266
|
export const getHypName = (hyp: Hyp) => {
|
|
269
267
|
switch (hyp.kind) {
|
|
270
268
|
case "Fresh":
|
|
@@ -291,7 +289,6 @@ export const applyBuiltin = (builtin: Builtin, args: Expr[], from: ExprProps): E
|
|
|
291
289
|
export const exprifySequent = (sequent: Sequent): ExprCore =>
|
|
292
290
|
sequent.context.length === 0 ? sequent.active : { kind: "Sequent", sequent };
|
|
293
291
|
|
|
294
|
-
// A persistent context, newest hypothesis first, so binders extend it without copying.
|
|
295
292
|
export interface Scope {
|
|
296
293
|
hyp: Hyp;
|
|
297
294
|
rest: Scope | undefined;
|
|
@@ -342,7 +339,6 @@ export const mapAccumulate = <State, Item, Result>(
|
|
|
342
339
|
return [final, results];
|
|
343
340
|
};
|
|
344
341
|
|
|
345
|
-
// A mapped context prefix: the hypothesis its last key maps to, if any, and the state after it.
|
|
346
342
|
interface MappedPrefix<State> {
|
|
347
343
|
state: State;
|
|
348
344
|
hyp: Hyp | undefined;
|
|
@@ -350,9 +346,6 @@ interface MappedPrefix<State> {
|
|
|
350
346
|
next: WeakMap<Hyp, MappedPrefix<State>>;
|
|
351
347
|
}
|
|
352
348
|
|
|
353
|
-
// mapAccumulate over a context that maps each prefix of keys once, as the obligations of a module
|
|
354
|
-
// share most of their context by identity. The input at each position must depend on the keys up
|
|
355
|
-
// to it alone, and the step on the input, its key, and the state.
|
|
356
349
|
export const createContextMap = <State>(
|
|
357
350
|
initial: State,
|
|
358
351
|
step: (state: State, input: Hyp, key: Hyp) => [State, Hyp | undefined],
|
|
@@ -405,8 +398,14 @@ export const getFact = (
|
|
|
405
398
|
location: Locus | undefined,
|
|
406
399
|
) => ({ kind: "Fact", expression, visibility, time, location }) satisfies Hyp;
|
|
407
400
|
|
|
408
|
-
|
|
409
|
-
|
|
401
|
+
export const getDefinitionHyp = (
|
|
402
|
+
definition: Defn,
|
|
403
|
+
whereDefined: WhereDefined,
|
|
404
|
+
visibility: Visibility,
|
|
405
|
+
isLocal: boolean,
|
|
406
|
+
location: Locus | undefined,
|
|
407
|
+
) => ({ kind: "Defn", definition, whereDefined, visibility, isLocal, location }) satisfies Hyp;
|
|
408
|
+
|
|
410
409
|
export const getBoundFresh = (bound: Bound) => getFresh(bound.name, bound.level);
|
|
411
410
|
|
|
412
411
|
export const getParamFresh = (param: Param) => getFresh(param.name, "Unknown", param.shape);
|
|
@@ -420,7 +419,6 @@ export const getLocalDefn = (definition: Defn) =>
|
|
|
420
419
|
isLocal: true,
|
|
421
420
|
}) satisfies Hyp;
|
|
422
421
|
|
|
423
|
-
// The node without its properties, as tlapm's e.core.
|
|
424
422
|
export const stripProps = (expression: Expr): ExprCore => {
|
|
425
423
|
if (!expression.location && !expression.isAtomic) return expression;
|
|
426
424
|
const { location: _location, isAtomic: _isAtomic, ...core } = expression;
|
|
@@ -460,9 +458,7 @@ export const mapHyp = (hyp: Hyp, map: (inner: Expr) => Expr, hyps: "visible" | "
|
|
|
460
458
|
return { ...hyp, expression: map(hyp.expression) };
|
|
461
459
|
};
|
|
462
460
|
|
|
463
|
-
//
|
|
464
|
-
// binds hidden hypotheses without visiting them, and Visit.map visits them too. Children map in
|
|
465
|
-
// OCaml evaluation order, last constructor argument first, which decides the error tlapm reports.
|
|
461
|
+
// Children map in OCaml's order, last argument first, which decides the error tlapm reports.
|
|
466
462
|
export const mapScoped = <State>(
|
|
467
463
|
state: State,
|
|
468
464
|
expression: Expr,
|
|
@@ -598,14 +594,17 @@ export const mapScoped = <State>(
|
|
|
598
594
|
}
|
|
599
595
|
};
|
|
600
596
|
|
|
601
|
-
|
|
602
|
-
|
|
597
|
+
export const mapChildren = (
|
|
598
|
+
expression: Expr,
|
|
599
|
+
map: (inner: Expr) => Expr,
|
|
600
|
+
hyps: "visible" | "all" = "all",
|
|
601
|
+
): Expr =>
|
|
603
602
|
mapScoped(
|
|
604
603
|
undefined,
|
|
605
604
|
expression,
|
|
606
605
|
(_state, inner) => map(inner),
|
|
607
606
|
() => undefined,
|
|
608
|
-
|
|
607
|
+
hyps,
|
|
609
608
|
);
|
|
610
609
|
|
|
611
610
|
export const getChildren = (expression: Expr) => {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
// A port of OCaml's Format module, which tlapm uses to lay out obligations.
|
|
2
|
-
// reaches are ported: boxes, breaks, forced newlines and text.
|
|
1
|
+
// A port of OCaml's Format module, which tlapm uses to lay out obligations.
|
|
3
2
|
|
|
4
3
|
type BoxKind = "h" | "v" | "hv" | "hov" | "b" | "fits";
|
|
5
4
|
|
|
@@ -238,7 +237,6 @@ const flush = (formatter: Formatter) => {
|
|
|
238
237
|
return formatter.output.join("");
|
|
239
238
|
};
|
|
240
239
|
|
|
241
|
-
// pp_print_newline: flush, print a newline, and start over with no open boxes.
|
|
242
240
|
const flushNewline = (formatter: Formatter) => {
|
|
243
241
|
flush(formatter);
|
|
244
242
|
const output = [...formatter.output, "\n"];
|
|
@@ -246,8 +244,6 @@ const flushNewline = (formatter: Formatter) => {
|
|
|
246
244
|
formatter.output = output;
|
|
247
245
|
};
|
|
248
246
|
|
|
249
|
-
// Printers build a document of layout commands first and render it once, so names resolve while
|
|
250
|
-
// the printer still knows the context they were bound in.
|
|
251
247
|
type Command =
|
|
252
248
|
| { kind: "Open"; box: BoxKind; indent: number }
|
|
253
249
|
| { kind: "Close" }
|
|
@@ -262,7 +258,6 @@ const BOX_KINDS: Record<string, BoxKind> = { h: "h", v: "v", hv: "hv", hov: "hov
|
|
|
262
258
|
|
|
263
259
|
const getText = (value: string): Command => ({ kind: "Text", text: value, size: getLength(value) });
|
|
264
260
|
|
|
265
|
-
// Prints a string as is, where format would read @ and % in it as directives.
|
|
266
261
|
export const text = (value: string): Doc => (value === "" ? [] : [getText(value)]);
|
|
267
262
|
|
|
268
263
|
const SPACE: Command = { kind: "Break", width: 1, offset: 0 };
|
|
@@ -278,8 +273,6 @@ const parseOpen = (directive: string): Command => {
|
|
|
278
273
|
};
|
|
279
274
|
};
|
|
280
275
|
|
|
281
|
-
// Interprets the subset of OCaml format strings that tlapm's printers use, so ported printers read
|
|
282
|
-
// like the OCaml they come from. Each %s or %a consumes one argument.
|
|
283
276
|
export const format = (pattern: string, ...args: (string | Doc)[]): Doc => {
|
|
284
277
|
const doc: Doc = [];
|
|
285
278
|
let argumentIndex = 0;
|
|
@@ -397,7 +390,6 @@ const renderInto = (formatter: Formatter, doc: Doc) => {
|
|
|
397
390
|
}
|
|
398
391
|
};
|
|
399
392
|
|
|
400
|
-
// 68 is Format's default maximum indent; tlapm's stderr formatter allows 35.
|
|
401
393
|
export const renderDoc = (doc: Doc, maxIndent = 68) => {
|
|
402
394
|
const formatter = createFormatter(maxIndent);
|
|
403
395
|
renderInto(formatter, doc);
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
// A port of tlapm's obligation generation (Proof.Gen and Module.Gen)
|
|
2
|
-
// whose context is everything the proof may use at that point.
|
|
1
|
+
// A port of tlapm's obligation generation (Proof.Gen and Module.Gen).
|
|
3
2
|
|
|
4
3
|
import { TlapmBugError, TlaProofError } from "../errors";
|
|
5
4
|
import { isEqualExpr } from "./equality";
|
|
6
5
|
import {
|
|
6
|
+
AT_NOWHERE,
|
|
7
7
|
at,
|
|
8
8
|
exprifySequent,
|
|
9
|
+
getDefinitionHyp,
|
|
9
10
|
getErrorNote,
|
|
10
11
|
getFact,
|
|
12
|
+
getLocalDefn,
|
|
13
|
+
getTrue,
|
|
11
14
|
isBuiltinApply,
|
|
12
15
|
mapAccumulate,
|
|
13
16
|
type Expr,
|
|
@@ -33,14 +36,8 @@ import {
|
|
|
33
36
|
import { shiftExpr } from "./substitution";
|
|
34
37
|
import { getScopeTime } from "./temporal";
|
|
35
38
|
|
|
36
|
-
export const AT_NOWHERE: Expr = { kind: "At", isExcept: false };
|
|
37
|
-
|
|
38
39
|
const isAnonymous = (step: StepNumber | undefined) => step?.kind === "Named" && step.isAnonymous;
|
|
39
40
|
|
|
40
|
-
export const getTrue = (from: { location?: Locus }) =>
|
|
41
|
-
at({ kind: "Internal", builtin: "TRUE" }, from);
|
|
42
|
-
|
|
43
|
-
// Each visible fact of the sequent, shifted past the hypotheses after it.
|
|
44
41
|
const getAssumedFacts = (offset: number, sequent: Sequent) =>
|
|
45
42
|
sequent.context.flatMap((hyp, index) =>
|
|
46
43
|
hyp.kind === "Fact" && hyp.visibility === "Visible"
|
|
@@ -50,18 +47,15 @@ const getAssumedFacts = (offset: number, sequent: Sequent) =>
|
|
|
50
47
|
|
|
51
48
|
const getStepDefinition = (step: Step, body: Expr, time: Time): Hyp => {
|
|
52
49
|
if (!step.step) throw new TlapmBugError();
|
|
53
|
-
return
|
|
54
|
-
kind: "
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
};
|
|
50
|
+
return getDefinitionHyp(
|
|
51
|
+
{ kind: "Operator", name: getStepName(step.step), body, location: step.location },
|
|
52
|
+
{ kind: "Proof", time },
|
|
53
|
+
"Visible",
|
|
54
|
+
true,
|
|
55
|
+
step.location,
|
|
56
|
+
);
|
|
61
57
|
};
|
|
62
58
|
|
|
63
|
-
// The proof of an assertion leaves the always scope when the assertion assumes a fact that holds
|
|
64
|
-
// only now.
|
|
65
59
|
export const proveAssertion = (context: Hyp[], sequent: Sequent, step: Step, time: Time) => {
|
|
66
60
|
const visibility: Visibility = isAnonymous(step.step) ? "Visible" : "Hidden";
|
|
67
61
|
const hyps = sequent.context.map((hyp): Hyp =>
|
|
@@ -101,8 +95,6 @@ export const useAssertion = (
|
|
|
101
95
|
};
|
|
102
96
|
};
|
|
103
97
|
|
|
104
|
-
// A cited step or definition keeps the scope it was proved in, and any other fact takes the
|
|
105
|
-
// current one.
|
|
106
98
|
const getFactTime = (context: Hyp[], fact: Expr, time: Time): Time => {
|
|
107
99
|
if (fact.kind !== "Ix") return time;
|
|
108
100
|
const hyp = context[context.length - fact.index];
|
|
@@ -157,7 +149,6 @@ const setExpression = (
|
|
|
157
149
|
return result;
|
|
158
150
|
};
|
|
159
151
|
|
|
160
|
-
// The lines of tlapm's --toolbox and --line options, which select the proofs to generate.
|
|
161
152
|
export interface LineRange {
|
|
162
153
|
start: number;
|
|
163
154
|
end: number;
|
|
@@ -211,6 +202,12 @@ export interface ModuleSummary extends ProofSummary {
|
|
|
211
202
|
theorems: TheoremSummary[];
|
|
212
203
|
}
|
|
213
204
|
|
|
205
|
+
interface GeneratedStep {
|
|
206
|
+
sequent: Sequent;
|
|
207
|
+
step: Step;
|
|
208
|
+
time: Time;
|
|
209
|
+
}
|
|
210
|
+
|
|
214
211
|
export const createGenerator = (inputFiles: Set<string>, lines: LineRange, onWarning: Warn) => {
|
|
215
212
|
const generate = (sequent: Sequent, proof: Proof, time: Time): Proof => {
|
|
216
213
|
const location = proof.location;
|
|
@@ -238,8 +235,8 @@ export const createGenerator = (inputFiles: Set<string>, lines: LineRange, onWar
|
|
|
238
235
|
throw new TlaProofError("Proof.Gen.generate");
|
|
239
236
|
case "Steps": {
|
|
240
237
|
const [inner, steps] = mapAccumulate({ sequent, time }, proof.steps, (state, step) => {
|
|
241
|
-
const
|
|
242
|
-
return [
|
|
238
|
+
const next = generateStep(state.sequent, step, state.time);
|
|
239
|
+
return [next, next.step];
|
|
243
240
|
});
|
|
244
241
|
const qedProof = generate(inner.sequent, proof.qed.proof, inner.time);
|
|
245
242
|
return { ...proof, steps, qed: { ...proof.qed, proof: qedProof } };
|
|
@@ -247,7 +244,7 @@ export const createGenerator = (inputFiles: Set<string>, lines: LineRange, onWar
|
|
|
247
244
|
}
|
|
248
245
|
};
|
|
249
246
|
|
|
250
|
-
const generateStep = (sequent: Sequent, step: Step, time: Time):
|
|
247
|
+
const generateStep = (sequent: Sequent, step: Step, time: Time): GeneratedStep => {
|
|
251
248
|
switch (step.kind) {
|
|
252
249
|
case "Forget": {
|
|
253
250
|
const count = sequent.context.length;
|
|
@@ -256,15 +253,15 @@ export const createGenerator = (inputFiles: Set<string>, lines: LineRange, onWar
|
|
|
256
253
|
? { ...hyp, visibility: "Hidden" }
|
|
257
254
|
: hyp,
|
|
258
255
|
);
|
|
259
|
-
return
|
|
256
|
+
return { sequent: { ...sequent, context }, step, time };
|
|
260
257
|
}
|
|
261
258
|
case "Use": {
|
|
262
259
|
const usable = step.usable;
|
|
263
260
|
if (usable.defs.length === 0 && usable.facts.length === 1) {
|
|
264
261
|
const fact = usable.facts[0];
|
|
265
262
|
const obligation = obligate({ ...sequent, active: fact }, step, { kind: "Support" });
|
|
266
|
-
return
|
|
267
|
-
{
|
|
263
|
+
return {
|
|
264
|
+
sequent: {
|
|
268
265
|
context: [
|
|
269
266
|
...sequent.context,
|
|
270
267
|
{
|
|
@@ -279,9 +276,9 @@ export const createGenerator = (inputFiles: Set<string>, lines: LineRange, onWar
|
|
|
279
276
|
],
|
|
280
277
|
active: shiftExpr(1, sequent.active),
|
|
281
278
|
},
|
|
282
|
-
{ ...step, obligations: [obligation] },
|
|
279
|
+
step: { ...step, obligations: [obligation] },
|
|
283
280
|
time,
|
|
284
|
-
|
|
281
|
+
};
|
|
285
282
|
}
|
|
286
283
|
if (usable.facts.length > 0)
|
|
287
284
|
throw new TlaProofError("Proof.Gen.gen_step: USE with facts and definitions");
|
|
@@ -289,7 +286,7 @@ export const createGenerator = (inputFiles: Set<string>, lines: LineRange, onWar
|
|
|
289
286
|
(current, def) => setDefinition("Visible", current, def),
|
|
290
287
|
sequent.context,
|
|
291
288
|
);
|
|
292
|
-
return
|
|
289
|
+
return { sequent: { ...sequent, context }, step, time };
|
|
293
290
|
}
|
|
294
291
|
case "Hide": {
|
|
295
292
|
const hidden = step.usable.defs.reduce(
|
|
@@ -300,19 +297,15 @@ export const createGenerator = (inputFiles: Set<string>, lines: LineRange, onWar
|
|
|
300
297
|
(current, fact) => setExpression(onWarning, "Hidden", fact, current),
|
|
301
298
|
hidden,
|
|
302
299
|
);
|
|
303
|
-
return
|
|
300
|
+
return { sequent: { ...sequent, context }, step, time };
|
|
304
301
|
}
|
|
305
302
|
case "Define":
|
|
306
|
-
return
|
|
307
|
-
{
|
|
303
|
+
return {
|
|
304
|
+
sequent: {
|
|
308
305
|
context: [
|
|
309
306
|
...sequent.context,
|
|
310
307
|
...step.definitions.map((definition): Hyp => ({
|
|
311
|
-
|
|
312
|
-
definition,
|
|
313
|
-
whereDefined: "User",
|
|
314
|
-
visibility: "Visible",
|
|
315
|
-
isLocal: true,
|
|
308
|
+
...getLocalDefn(definition),
|
|
316
309
|
location: definition.location,
|
|
317
310
|
})),
|
|
318
311
|
],
|
|
@@ -320,16 +313,23 @@ export const createGenerator = (inputFiles: Set<string>, lines: LineRange, onWar
|
|
|
320
313
|
},
|
|
321
314
|
step,
|
|
322
315
|
time,
|
|
323
|
-
|
|
316
|
+
};
|
|
324
317
|
case "Assert": {
|
|
325
318
|
const inner = proveAssertion(sequent.context, step.sequent, step, time);
|
|
326
319
|
const proof = generate(inner, step.proof, inner.time);
|
|
327
320
|
const generated: Step = { ...step, proof };
|
|
328
|
-
return
|
|
329
|
-
useAssertion(
|
|
330
|
-
|
|
321
|
+
return {
|
|
322
|
+
sequent: useAssertion(
|
|
323
|
+
false,
|
|
324
|
+
sequent.context,
|
|
325
|
+
sequent.active,
|
|
326
|
+
step.sequent,
|
|
327
|
+
generated,
|
|
328
|
+
time,
|
|
329
|
+
),
|
|
330
|
+
step: generated,
|
|
331
331
|
time,
|
|
332
|
-
|
|
332
|
+
};
|
|
333
333
|
}
|
|
334
334
|
case "Suffices": {
|
|
335
335
|
const proof = generate(
|
|
@@ -339,7 +339,7 @@ export const createGenerator = (inputFiles: Set<string>, lines: LineRange, onWar
|
|
|
339
339
|
);
|
|
340
340
|
const generated: Step = { ...step, proof };
|
|
341
341
|
const next = proveAssertion(sequent.context, step.sequent, generated, time);
|
|
342
|
-
return
|
|
342
|
+
return { sequent: next, step: generated, time: next.time };
|
|
343
343
|
}
|
|
344
344
|
default:
|
|
345
345
|
throw new TlaProofError("Proof.Gen.gen_step");
|
|
@@ -353,17 +353,16 @@ export const createGenerator = (inputFiles: Set<string>, lines: LineRange, onWar
|
|
|
353
353
|
location: Locus | undefined,
|
|
354
354
|
): [Hyp[], Obligation[]] => {
|
|
355
355
|
const step: StepNumber = { kind: "Unnamed", level: 0, id: 0 };
|
|
356
|
-
const
|
|
356
|
+
const generated = generateStep(
|
|
357
357
|
{ context, active: { ...AT_NOWHERE, location } },
|
|
358
358
|
mode === "Use"
|
|
359
359
|
? { kind: "Use", usable, isOnly: false, location, step, useLocation: location }
|
|
360
360
|
: { kind: "Hide", usable, location, step },
|
|
361
361
|
"Always",
|
|
362
362
|
);
|
|
363
|
-
return [sequent.context, generated.obligations ?? []];
|
|
363
|
+
return [generated.sequent.context, generated.step.obligations ?? []];
|
|
364
364
|
};
|
|
365
365
|
|
|
366
|
-
// The definitions go first, then each fact on its own, shifting the facts after it.
|
|
367
366
|
const mutate = (
|
|
368
367
|
context: Hyp[],
|
|
369
368
|
mode: "Use" | "Hide",
|
|
@@ -384,7 +383,6 @@ export const createGenerator = (inputFiles: Set<string>, lines: LineRange, onWar
|
|
|
384
383
|
return [last, [...first, ...others]];
|
|
385
384
|
};
|
|
386
385
|
|
|
387
|
-
// collect: a QED's obligations come before its sibling steps', and a step's own before its proof's.
|
|
388
386
|
const collect = (proof: Proof): Obligation[] => {
|
|
389
387
|
const obligations: Obligation[] = [];
|
|
390
388
|
const visitProof = (item: Proof) => {
|
|
@@ -403,7 +401,6 @@ export const createGenerator = (inputFiles: Set<string>, lines: LineRange, onWar
|
|
|
403
401
|
return obligations;
|
|
404
402
|
};
|
|
405
403
|
|
|
406
|
-
// Module.Gen.generate.
|
|
407
404
|
const generateModule = (
|
|
408
405
|
context: Hyp[],
|
|
409
406
|
module: Mule,
|
package/src/obligations/index.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// Generates the proof obligations tlapm prints for a module, in tlapm's order and layout.
|
|
2
|
-
|
|
3
1
|
import { TlaProofError, TlaSyntaxError, type SyntaxFailure } from "../errors";
|
|
4
2
|
import { createAnonymizer } from "./anonymize";
|
|
5
3
|
import {
|
|
@@ -23,7 +21,7 @@ import { formatObligation } from "./printer";
|
|
|
23
21
|
import type { Counter, ObligationKind } from "./proof";
|
|
24
22
|
import type { OldMethod } from "./pragma";
|
|
25
23
|
import { createSimplifier } from "./simplify";
|
|
26
|
-
import {
|
|
24
|
+
import { createModuleConverter } from "./source";
|
|
27
25
|
import { tokenize } from "../lexer";
|
|
28
26
|
import { parseTlapmModule } from "../parser";
|
|
29
27
|
import type { Module } from "../ast";
|
|
@@ -120,7 +118,6 @@ const parseSource = (source: string): Module | SyntaxFailure[] => {
|
|
|
120
118
|
return isSyntaxFailure(parsed) ? [parsed] : parsed;
|
|
121
119
|
};
|
|
122
120
|
|
|
123
|
-
// Module.Save.parse_file warns when a module's name differs from its file's, then renames it.
|
|
124
121
|
const loadMule = (
|
|
125
122
|
input: ObligationSource,
|
|
126
123
|
counter: Counter,
|
|
@@ -140,7 +137,7 @@ const loadMule = (
|
|
|
140
137
|
onWarning({ text: `${errorPrefix}Error: ${message}`, channel: "stderr" });
|
|
141
138
|
throw new TlaProofError(message, { failure: "Module.Parser.parse_file" });
|
|
142
139
|
}
|
|
143
|
-
const mule =
|
|
140
|
+
const mule = createModuleConverter(input.file, input.source, counter, isMain)(parsed);
|
|
144
141
|
const fileName = input.file.slice(input.file.lastIndexOf("/") + 1);
|
|
145
142
|
const name = fileName.replace(/\.tla$/, "");
|
|
146
143
|
if (mule.name === name) return mule;
|
|
@@ -151,7 +148,6 @@ const loadMule = (
|
|
|
151
148
|
return { ...mule, name };
|
|
152
149
|
};
|
|
153
150
|
|
|
154
|
-
// Module.Dep.schedule: dependencies first, visiting modules and their dependencies by name.
|
|
155
151
|
const schedule = (modules: Map<string, Mule>) => {
|
|
156
152
|
const dependencies = new Map(
|
|
157
153
|
[...modules].map(([name, module]) => [name, getDependencies(module).dependencies]),
|
|
@@ -220,8 +216,6 @@ export const formatSummary = (result: ModuleObligations) => {
|
|
|
220
216
|
].join("\n");
|
|
221
217
|
};
|
|
222
218
|
|
|
223
|
-
// Each main module is one file given to tlapm. They load into one context and report in schedule
|
|
224
|
-
// order, each numbering its obligations from 1.
|
|
225
219
|
export const getObligations = (
|
|
226
220
|
mains: ObligationSource[],
|
|
227
221
|
loadModule: (name: string) => ObligationSource | undefined,
|
|
@@ -238,9 +232,7 @@ export const getObligations = (
|
|
|
238
232
|
};
|
|
239
233
|
modules.set(module.name, module);
|
|
240
234
|
});
|
|
241
|
-
// Module.Save.complete_load: breadth first from every known module, by name.
|
|
242
235
|
const queue = [...modules.values()].sort((left, right) => compareNames(left.name, right.name));
|
|
243
|
-
// A missing module is fine only if some loaded module declares it as a submodule.
|
|
244
236
|
const requested = new Map<string, Locus | undefined>();
|
|
245
237
|
const found = new Set<string>();
|
|
246
238
|
for (let index = 0; index < queue.length; index++) {
|
|
@@ -249,7 +241,6 @@ export const getObligations = (
|
|
|
249
241
|
found.add(name);
|
|
250
242
|
if (!modules.has(name)) modules.set(name, submodule);
|
|
251
243
|
});
|
|
252
|
-
// A file named like a standard module replaces it, and is read again for each module citing it.
|
|
253
244
|
for (const name of result.dependencies) {
|
|
254
245
|
if (modules.has(name) && !STANDARD_MODULES.has(name)) continue;
|
|
255
246
|
const input = loadModule(name);
|
|
@@ -292,14 +283,12 @@ export const getObligations = (
|
|
|
292
283
|
module.isStandard ? module : flatten(modules, module, new Set()),
|
|
293
284
|
);
|
|
294
285
|
const generateModule = createGenerator(new Set(mains.map((main) => main.file)), lines, onWarning);
|
|
295
|
-
// Instances see each module as flattened, and as normalized once its turn has come.
|
|
296
286
|
const normalized = new Map(order.map((module) => [module.name, module]));
|
|
297
287
|
return order.flatMap((module): ModuleObligations[] => {
|
|
298
288
|
if (module.isStandard) return [];
|
|
299
289
|
const result = normalize(pipeline, normalized, undefined, module);
|
|
300
290
|
if (!module.isImportant) return [];
|
|
301
291
|
const generated = generateModule([], result);
|
|
302
|
-
// tlapm numbers the obligations, then drops the omitted ones and those outside the lines.
|
|
303
292
|
const obligations = generated.obligations.flatMap((obligation, index): PrintedObligation[] => {
|
|
304
293
|
const location = obligation.location;
|
|
305
294
|
if (
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
// the weights of an operator's arguments, and the declared names the level depends on.
|
|
1
|
+
// A port of tlapm's Expr.Levels.
|
|
3
2
|
|
|
4
3
|
import { TlaProofError, TlapmBugError } from "../errors";
|
|
5
4
|
import {
|
|
@@ -114,15 +113,14 @@ export const LEVEL_NUMBERS: Record<Level, number> = {
|
|
|
114
113
|
Unknown: 0,
|
|
115
114
|
};
|
|
116
115
|
|
|
117
|
-
const
|
|
116
|
+
const getUnion = (sets: Set<string>[]) => new Set(sets.flatMap((set) => [...set]));
|
|
118
117
|
|
|
119
118
|
const combineLevels = (infos: LevelInfo[]): LevelInfo => ({
|
|
120
119
|
level: Math.max(0, ...infos.map((info) => info.level)),
|
|
121
120
|
weights: [],
|
|
122
|
-
params:
|
|
121
|
+
params: getUnion(infos.map((info) => info.params)),
|
|
123
122
|
});
|
|
124
123
|
|
|
125
|
-
// The level of each hypothesis depends only on the scope before it.
|
|
126
124
|
const hypLevels = new WeakMap<Scope, LevelInfo>();
|
|
127
125
|
|
|
128
126
|
const computeHypLevel = (scope: Scope): LevelInfo => {
|
|
@@ -170,7 +168,7 @@ const applyOperator = (operator: LevelInfo, args: LevelInfo[]): LevelInfo => {
|
|
|
170
168
|
return {
|
|
171
169
|
level: Math.max(operator.level, ...weighted.map((arg) => arg.level)),
|
|
172
170
|
weights: [],
|
|
173
|
-
params:
|
|
171
|
+
params: getUnion([operator.params, ...weighted.map((arg) => arg.params)]),
|
|
174
172
|
};
|
|
175
173
|
};
|
|
176
174
|
|
|
@@ -205,8 +203,6 @@ export const getLevelInfo = (scope: Scope | undefined, expression: Expr): LevelI
|
|
|
205
203
|
}
|
|
206
204
|
case "Apply": {
|
|
207
205
|
const operator = expression.operator;
|
|
208
|
-
// The action frontend commutes a prime onto an operator, and tlapm keeps the level that
|
|
209
|
-
// the application had.
|
|
210
206
|
if (isBuiltinApply(operator, "Prime") && operator.args.length === 1) {
|
|
211
207
|
return recurse({ ...expression, operator: operator.args[0] });
|
|
212
208
|
}
|