tla-ts 0.0.9 → 0.0.10
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 +28 -28
- package/dist/deciders.js +43 -43
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +72 -10
- package/dist/index.d.ts +72 -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 +116 -36
- 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 +128 -103
- package/dist/transfer.js +128 -103
- package/dist/worker.cjs +7 -7
- package/dist/worker.js +7 -7
- package/package.json +3 -1
- package/src/ast.ts +7 -21
- package/src/bags.ts +99 -99
- package/src/builtins.ts +44 -75
- package/src/bundled-modules.ts +1 -8
- package/src/check.ts +576 -300
- package/src/cli/options.ts +11 -6
- package/src/cli/run.ts +2 -2
- package/src/cli/runtime-invariants.ts +135 -0
- package/src/cli/shared.ts +20 -9
- package/src/cli/tlapm.ts +0 -12
- package/src/cli/tlc-arguments.ts +646 -0
- package/src/cli/tlc-usage.ts +362 -0
- package/src/cli/tlc.ts +538 -220
- package/src/cli/typescript.ts +23 -0
- package/src/cli/xml-exporter.ts +4 -16
- package/src/cli.ts +0 -1
- package/src/codegen.ts +191 -64
- package/src/config.ts +140 -109
- package/src/coverage.ts +837 -0
- package/src/dependencies.ts +6 -40
- package/src/dfid.ts +618 -0
- package/src/environment.ts +240 -118
- package/src/errors.ts +70 -55
- package/src/evaluate.ts +630 -297
- package/src/exit-codes.ts +37 -3
- package/src/fingerprints.ts +10 -10
- package/src/index.ts +3 -0
- package/src/instances.ts +79 -11
- package/src/java-overrides.ts +2 -12
- package/src/json-reader.ts +456 -0
- package/src/json.ts +262 -139
- package/src/levels.ts +2 -3
- package/src/lexer.ts +17 -26
- package/src/liveness-checker.ts +10 -18
- package/src/liveness.ts +121 -49
- package/src/obligations/action.ts +4 -28
- package/src/obligations/anonymize.ts +84 -80
- package/src/obligations/equality.ts +1 -1
- package/src/obligations/expression.ts +2 -19
- package/src/obligations/format.ts +1 -9
- package/src/obligations/generate.ts +1 -11
- package/src/obligations/index.ts +0 -11
- package/src/obligations/levels.ts +4 -8
- package/src/obligations/module.ts +1 -15
- package/src/obligations/normalize.ts +5 -24
- 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 +3 -14
- package/src/obligations/source.ts +1 -21
- package/src/obligations/subexpression.ts +5 -11
- package/src/obligations/substitution.ts +1 -3
- package/src/obligations/temporal.ts +8 -14
- package/src/obligations/tuples.ts +3 -9
- package/src/parallel-worker.ts +29 -39
- package/src/parallel.ts +29 -13
- package/src/parser.ts +436 -90
- package/src/pcal/ast.ts +7 -28
- package/src/pcal/parse.ts +11 -39
- package/src/pcal/tokenize.ts +4 -20
- package/src/pcal/translate.ts +10 -42
- package/src/pcal/validate.ts +3 -21
- package/src/pretty-print.ts +1 -2
- package/src/prover/decide-pool.ts +5 -10
- package/src/prover/deciders.ts +0 -4
- 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 +108 -114
- package/src/prover/isabelle/isar/method.ts +25 -38
- 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 +15 -26
- package/src/prover/isabelle/isar/type-check.ts +11 -25
- package/src/prover/isabelle/provers/blast/blast.ts +10 -41
- 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 +11 -25
- package/src/prover/isabelle/pure/bicompose.ts +16 -13
- package/src/prover/isabelle/pure/consts.ts +1 -7
- package/src/prover/isabelle/pure/conv.ts +1 -9
- package/src/prover/isabelle/pure/drule.ts +24 -40
- 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 +1 -14
- 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 +13 -49
- package/src/prover/isabelle/pure/rewriter.ts +26 -58
- 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 +1 -31
- package/src/prover/isabelle/pure/tactic.ts +12 -22
- package/src/prover/isabelle/pure/tactical.ts +6 -12
- 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 +13 -36
- 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 +9 -19
- package/src/prover/isabelle/tla/context.ts +8 -16
- package/src/prover/isabelle/tla/logic.ts +4 -11
- package/src/prover/isabelle/tla/simpdata.ts +46 -34
- package/src/prover/isabelle/tools/intuitionistic.ts +1 -10
- package/src/prover/ocaml.ts +0 -6
- package/src/prover/prep/action.ts +4 -36
- package/src/prover/prep/enabled-axioms.ts +12 -19
- package/src/prover/prep/fingerprint.ts +0 -16
- package/src/prover/prep/level-comparison.ts +8 -12
- package/src/prover/prep/md5.ts +0 -2
- package/src/prover/prep/methods.ts +9 -36
- package/src/prover/prep/normalize.ts +4 -28
- package/src/prover/prove-worker.ts +0 -2
- package/src/prover/prove.ts +0 -36
- 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 +19 -26
- package/src/prover/smt/data.ts +51 -54
- package/src/prover/smt/encode.ts +14 -35
- 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 +66 -101
- 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 -143
- package/src/prover/smt/solver/auf-solver.ts +6 -39
- 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 +4 -61
- 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 +3 -34
- 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 +0 -5
- 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 +6 -98
- 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 +12 -98
- 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 +35 -130
- 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 +14 -56
- 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 +2 -36
- package/src/prover/smt/solver/model-evaluator.ts +3 -29
- package/src/prover/smt/solver/model-finder.ts +3 -15
- package/src/prover/smt/solver/model-generator.ts +1 -12
- package/src/prover/smt/solver/model-macro-solver.ts +12 -69
- package/src/prover/smt/solver/nlsat/algebraic.ts +55 -151
- package/src/prover/smt/solver/nlsat/atoms.ts +5 -19
- package/src/prover/smt/solver/nlsat/evaluator.ts +17 -22
- package/src/prover/smt/solver/nlsat/explain.ts +3 -47
- package/src/prover/smt/solver/nlsat/interval-set.ts +9 -50
- package/src/prover/smt/solver/nlsat/levelwise.ts +48 -129
- package/src/prover/smt/solver/nlsat/mpbq.ts +3 -14
- package/src/prover/smt/solver/nlsat/polynomial.ts +17 -156
- package/src/prover/smt/solver/nlsat/solver.ts +7 -67
- package/src/prover/smt/solver/nlsat/types.ts +1 -8
- package/src/prover/smt/solver/nlsat/upolynomial-factorization.ts +1 -44
- 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 -48
- 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 +17 -37
- package/src/prover/smt/solver/quantifier-manager.ts +1 -8
- 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 +2 -37
- 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 +0 -5
- package/src/prover/smt/solver/theory-lra-final-check.ts +4 -22
- package/src/prover/smt/solver/theory-lra-internalize.ts +1 -27
- 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 +20 -25
- package/src/prover/tlapm/ocaml-marshal.ts +19 -21
- package/src/prover/tlapm/tlapm.ts +12 -17
- package/src/prover/verdict.ts +0 -2
- package/src/prover/zenon/check/check.ts +0 -9
- 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 +0 -5
- package/src/prover/zenon/check/relations.ts +0 -13
- package/src/prover/zenon/check/rewrites.ts +0 -6
- package/src/prover/zenon/check/sets.ts +0 -3
- package/src/prover/zenon/check/terms.ts +0 -17
- 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 +0 -13
- package/src/prover/zenon/equality-rules.ts +0 -4
- package/src/prover/zenon/expr.ts +1 -26
- package/src/prover/zenon/index-table.ts +17 -38
- package/src/prover/zenon/isar-case.ts +9 -19
- package/src/prover/zenon/isar.ts +1 -29
- package/src/prover/zenon/limits.ts +0 -4
- package/src/prover/zenon/llproof.ts +0 -9
- package/src/prover/zenon/mltoll.ts +54 -76
- package/src/prover/zenon/node.ts +1 -11
- package/src/prover/zenon/ocaml.ts +1 -17
- package/src/prover/zenon/parse.ts +2 -7
- 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 +1 -17
- package/src/prover/zenon/tla/functions.ts +57 -29
- package/src/prover/zenon/tla/llproof.ts +63 -70
- package/src/prover/zenon/tla/records.ts +56 -27
- package/src/prover/zenon/tla/rewrites.ts +12 -19
- package/src/prover/zenon/tla/sets.ts +68 -39
- package/src/prover/zenon/tla/terms.ts +0 -6
- package/src/prover/zenon/tla/tla.ts +59 -58
- package/src/randomization.ts +84 -35
- package/src/resolve.ts +18 -60
- package/src/runtime.ts +11 -4
- package/src/sany/builtins.ts +3 -4
- package/src/sany/generator.ts +119 -169
- package/src/sany/levels.ts +6 -30
- package/src/sany/lexer.ts +7 -23
- package/src/sany/linter.ts +1 -8
- package/src/sany/modules.ts +1 -5
- package/src/sany/nodes.ts +0 -31
- package/src/sany/parse-error.ts +39 -117
- package/src/sany/report.ts +29 -63
- package/src/sany/selectors.ts +15 -39
- package/src/sany/source.ts +1 -17
- package/src/sany/xml.ts +13 -63
- package/src/search.ts +494 -154
- package/src/simulate.ts +694 -0
- package/src/spec-description.ts +166 -48
- package/src/standard-definitions.ts +2 -3
- package/src/standard-modules.ts +264 -68
- package/src/state-graph.ts +51 -18
- package/src/subexpressions.ts +31 -5
- package/src/substitution-levels.ts +2 -3
- package/src/successors.ts +267 -77
- package/src/symmetry.ts +31 -8
- package/src/tableau.ts +27 -24
- package/src/tlc/fingerprint.ts +183 -61
- package/src/tlc/jar-data.ts +113 -6
- package/src/tlc/messages.ts +122 -37
- package/src/tlc/order.ts +33 -38
- package/src/tlc/random.ts +16 -16
- package/src/tlc/replay.ts +563 -211
- package/src/tlc/summary.ts +2 -4
- package/src/tlc/tlc-operators.ts +81 -36
- package/src/tlc/tlcext-operators.ts +138 -117
- package/src/tlc/trace-spec.ts +273 -0
- package/src/tlc/value-stream.ts +143 -0
- package/src/tlc/version.ts +2 -4
- package/src/transfer.ts +22 -25
- package/src/typescript/actions.ts +481 -0
- package/src/typescript/collections.ts +600 -0
- package/src/typescript/compile.ts +65 -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 +152 -0
- package/src/typescript/functions.ts +284 -0
- package/src/typescript/model.ts +163 -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 +165 -0
- package/src/typescript/types.ts +171 -0
- package/src/values.ts +826 -276
- package/src/worker.ts +7 -8
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
// Ported from Zenon's index.ml, as shipped in tlapm. Copyright 2004 INRIA, see LICENSE.
|
|
2
|
-
//
|
|
3
|
-
// The formulas on the current branch, indexed by head symbol, by the sides of equalities and
|
|
4
|
-
// transitive relations, and the cache of proved lemmas. Formulas are added and removed in LIFO
|
|
5
|
-
// order as the search descends and backtracks. Lists keep Zenon's order, latest first.
|
|
6
2
|
|
|
7
3
|
import {
|
|
8
4
|
isNegatedRelation,
|
|
@@ -27,7 +23,6 @@ interface Suspect {
|
|
|
27
23
|
records: LemmaRecord[];
|
|
28
24
|
}
|
|
29
25
|
|
|
30
|
-
// A stack of values per key, as a Hashtbl with Hashtbl.add and Hashtbl.remove.
|
|
31
26
|
const pushValue = <Key, Value>(table: Map<Key, Value[]>, key: Key, value: Value) => {
|
|
32
27
|
const values = table.get(key);
|
|
33
28
|
if (values === undefined) table.set(key, [value]);
|
|
@@ -44,7 +39,6 @@ const popValue = <Key, Value>(table: Map<Key, Value[]>, key: Key) => {
|
|
|
44
39
|
const getLatestFirst = <Key, Value>(table: Map<Key, Value[]>, key: Key) =>
|
|
45
40
|
[...(table.get(key) ?? [])].reverse();
|
|
46
41
|
|
|
47
|
-
// Zenon's head of a term, or undefined for No_head. Taus and metavariables are heads by identity.
|
|
48
42
|
type Head = string | Expr;
|
|
49
43
|
|
|
50
44
|
export const getHead = (expression: Expr): Head | undefined => {
|
|
@@ -68,19 +62,10 @@ export const getHead = (expression: Expr): Head | undefined => {
|
|
|
68
62
|
}
|
|
69
63
|
};
|
|
70
64
|
|
|
71
|
-
// Zenon indexes formulas by head under a string; every tau shares "t." and every metavariable "".
|
|
72
65
|
const getHeadKey = (head: Head) =>
|
|
73
66
|
typeof head === "string" ? head : head.kind === "tau" ? "t." : "";
|
|
74
67
|
|
|
75
|
-
//
|
|
76
|
-
// drops the key whatever the element, as Zenon does.
|
|
77
|
-
const addElement = <Key, Value>(table: Map<Key, Value[]>, key: Key, value: Value) => {
|
|
78
|
-
const values = table.get(key);
|
|
79
|
-
if (values === undefined) table.set(key, [value]);
|
|
80
|
-
else values.push(value);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
// False stands for Zenon's Not_found.
|
|
68
|
+
// Removing from a one-element list drops the key whatever the element, as Zenon does.
|
|
84
69
|
const removeElement = <Key, Value>(table: Map<Key, Value[]>, key: Key, value: Value) => {
|
|
85
70
|
const values = table.get(key);
|
|
86
71
|
if (values === undefined) return false;
|
|
@@ -89,9 +74,6 @@ const removeElement = <Key, Value>(table: Map<Key, Value[]>, key: Key, value: Va
|
|
|
89
74
|
return true;
|
|
90
75
|
};
|
|
91
76
|
|
|
92
|
-
const getValues = <Key, Value>(table: Map<Key, Value[]>, key: Key) => getLatestFirst(table, key);
|
|
93
|
-
|
|
94
|
-
// Keys pair a relation with a head. Heads that are expressions are told apart by identity.
|
|
95
77
|
const getHeadId = (head: Head) => (typeof head === "string" ? `s${head}` : `e${head.id}`);
|
|
96
78
|
|
|
97
79
|
const getRelationKey = (relation: string, head: Head) => `${relation}\u0000${getHeadId(head)}`;
|
|
@@ -129,7 +111,6 @@ export const createIndex = (exprs: Expressions) => {
|
|
|
129
111
|
const withGoalness = <Formula extends Expr>(list: Formula[]): [Formula, number][] =>
|
|
130
112
|
list.map((formula) => [formula, getGoalness(formula)]);
|
|
131
113
|
|
|
132
|
-
// Zenon's negpos: a negation under the head of its operand, anything else under its own head.
|
|
133
114
|
const actOnHead = (
|
|
134
115
|
formula: Expr,
|
|
135
116
|
action: <Formula extends Expr>(
|
|
@@ -187,7 +168,7 @@ export const createIndex = (exprs: Expressions) => {
|
|
|
187
168
|
]);
|
|
188
169
|
formulaCount++;
|
|
189
170
|
topFormulaCount = Math.max(topFormulaCount, formulaCount);
|
|
190
|
-
actOnHead(formula,
|
|
171
|
+
actOnHead(formula, pushValue);
|
|
191
172
|
const lemma = lemmas.get(formula);
|
|
192
173
|
if (lemma !== undefined) lemma.isPresent = true;
|
|
193
174
|
newFormulas.unshift(formula);
|
|
@@ -240,14 +221,13 @@ export const createIndex = (exprs: Expressions) => {
|
|
|
240
221
|
if (lemma !== undefined) lemma.isPresent = false;
|
|
241
222
|
};
|
|
242
223
|
|
|
243
|
-
// Zenon's add_trans, which stops at the first side without a head. False means No_head.
|
|
244
224
|
const addTrans = (formula: RelationExpr) => {
|
|
245
225
|
const leftHead = getHead(formula.args[0]);
|
|
246
226
|
if (leftHead === undefined) return false;
|
|
247
|
-
|
|
227
|
+
pushValue(transLeft, getRelationKey(formula.symbol, leftHead), formula);
|
|
248
228
|
const rightHead = getHead(formula.args[1]);
|
|
249
229
|
if (rightHead === undefined) return false;
|
|
250
|
-
|
|
230
|
+
pushValue(transRight, getRelationKey(formula.symbol, rightHead), formula);
|
|
251
231
|
return true;
|
|
252
232
|
};
|
|
253
233
|
|
|
@@ -255,13 +235,13 @@ export const createIndex = (exprs: Expressions) => {
|
|
|
255
235
|
const relation = formula.args[0];
|
|
256
236
|
const leftHead = getHead(relation.args[0]);
|
|
257
237
|
if (leftHead !== undefined) {
|
|
258
|
-
|
|
259
|
-
|
|
238
|
+
pushValue(negTransLeft, getRelationKey(relation.symbol, leftHead), formula);
|
|
239
|
+
pushValue(allNegTransLeft, getHeadId(leftHead), formula);
|
|
260
240
|
}
|
|
261
241
|
const rightHead = getHead(relation.args[1]);
|
|
262
242
|
if (rightHead !== undefined) {
|
|
263
|
-
|
|
264
|
-
|
|
243
|
+
pushValue(negTransRight, getRelationKey(relation.symbol, rightHead), formula);
|
|
244
|
+
pushValue(allNegTransRight, getHeadId(rightHead), formula);
|
|
265
245
|
}
|
|
266
246
|
};
|
|
267
247
|
|
|
@@ -276,8 +256,6 @@ export const createIndex = (exprs: Expressions) => {
|
|
|
276
256
|
suspects.unshift([{ proof, cursor: 0, records }]);
|
|
277
257
|
};
|
|
278
258
|
|
|
279
|
-
// A cached lemma whose conclusions are all on the branch. A lemma waits on the first conclusion
|
|
280
|
-
// that is missing, and is checked again when that formula comes back.
|
|
281
259
|
const searchLemma = (): Proof | undefined => {
|
|
282
260
|
for (const formula of newFormulas) {
|
|
283
261
|
const record = lemmas.get(formula);
|
|
@@ -312,8 +290,8 @@ export const createIndex = (exprs: Expressions) => {
|
|
|
312
290
|
remove,
|
|
313
291
|
isMember,
|
|
314
292
|
getGoalness,
|
|
315
|
-
findPositive: (symbol: string) => withGoalness(
|
|
316
|
-
findNegative: (symbol: string) => withGoalness(
|
|
293
|
+
findPositive: (symbol: string) => withGoalness(getLatestFirst(positive, symbol)),
|
|
294
|
+
findNegative: (symbol: string) => withGoalness(getLatestFirst(negative, symbol)),
|
|
317
295
|
findEqualRight: (term: Expr) => getLatestFirst(equalLeftRight, term),
|
|
318
296
|
findEqualLeft: (term: Expr) => getLatestFirst(equalRightLeft, term),
|
|
319
297
|
findDisequalities: (term: Expr) => [
|
|
@@ -329,16 +307,17 @@ export const createIndex = (exprs: Expressions) => {
|
|
|
329
307
|
addTrans,
|
|
330
308
|
addNegTrans,
|
|
331
309
|
findTransLeft: (relation: string, head: Head) =>
|
|
332
|
-
withGoalness(
|
|
310
|
+
withGoalness(getLatestFirst(transLeft, getRelationKey(relation, head))),
|
|
333
311
|
findTransRight: (relation: string, head: Head) =>
|
|
334
|
-
withGoalness(
|
|
312
|
+
withGoalness(getLatestFirst(transRight, getRelationKey(relation, head))),
|
|
335
313
|
findNegTransLeft: (relation: string, head: Head) =>
|
|
336
|
-
withGoalness(
|
|
314
|
+
withGoalness(getLatestFirst(negTransLeft, getRelationKey(relation, head))),
|
|
337
315
|
findNegTransRight: (relation: string, head: Head) =>
|
|
338
|
-
withGoalness(
|
|
339
|
-
findAllNegTransLeft: (head: Head) =>
|
|
316
|
+
withGoalness(getLatestFirst(negTransRight, getRelationKey(relation, head))),
|
|
317
|
+
findAllNegTransLeft: (head: Head) =>
|
|
318
|
+
withGoalness(getLatestFirst(allNegTransLeft, getHeadId(head))),
|
|
340
319
|
findAllNegTransRight: (head: Head) =>
|
|
341
|
-
withGoalness(
|
|
320
|
+
withGoalness(getLatestFirst(allNegTransRight, getHeadId(head))),
|
|
342
321
|
addLemma,
|
|
343
322
|
searchLemma,
|
|
344
323
|
addDefinition: (definition: Definition) => definitions.set(definition.symbol, definition),
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
// Ported from Zenon's isar_case.ml and enum.ml, as shipped in tlapm. Copyright 2009 INRIA, see
|
|
2
|
-
// LICENSE.
|
|
3
|
-
//
|
|
4
|
-
// The lemmas for CASE expressions and record sets with more arms or fields than Zenon.thy covers.
|
|
5
|
-
// Each one is a template that Zenon's Enum expands for the arity: the text between @@@ and ...
|
|
6
|
-
// repeats counting up, the text between ... and @@@ repeats counting down.
|
|
1
|
+
// Ported from Zenon's isar_case.ml and enum.ml, as shipped in tlapm. Copyright 2009 INRIA, see LICENSE.
|
|
7
2
|
|
|
8
3
|
import { TlaZenonError } from "../../errors";
|
|
9
4
|
|
|
10
|
-
// A run of digits or of other characters.
|
|
11
5
|
interface Lexeme {
|
|
12
6
|
isNumber: boolean;
|
|
13
7
|
text: string;
|
|
14
8
|
}
|
|
15
9
|
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
interface Progression {
|
|
11
|
+
base: number;
|
|
12
|
+
step: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type Piece = string | Progression;
|
|
18
16
|
|
|
19
17
|
interface Pattern {
|
|
20
18
|
pieces: Piece[];
|
|
@@ -26,7 +24,6 @@ const isDigit = (char: string | undefined) => char !== undefined && char >= "0"
|
|
|
26
24
|
const lex = (text: string): Lexeme[] =>
|
|
27
25
|
text.match(/[0-9]+|[^0-9]+/g)?.map((run) => ({ isNumber: isDigit(run[0]), text: run })) ?? [];
|
|
28
26
|
|
|
29
|
-
// The repeated text and the separator of a pattern without numbers: its two equal halves.
|
|
30
27
|
const splitText = (text: string): Pattern => {
|
|
31
28
|
const half = Math.floor(text.length / 2);
|
|
32
29
|
const odd = text.length % 2;
|
|
@@ -50,8 +47,6 @@ const correlate = (first: Lexeme[], second: Lexeme[]): Piece[] | undefined => {
|
|
|
50
47
|
return pieces.every((piece) => piece !== undefined) ? pieces : undefined;
|
|
51
48
|
};
|
|
52
49
|
|
|
53
|
-
// Zenon's split_sep: the separator inside the middle text, after the end of the first instance's
|
|
54
|
-
// last lexeme and before the start of the second instance's first.
|
|
55
50
|
const splitSeparator = (
|
|
56
51
|
before: Lexeme,
|
|
57
52
|
middle: string,
|
|
@@ -69,7 +64,6 @@ const splitSeparator = (
|
|
|
69
64
|
];
|
|
70
65
|
};
|
|
71
66
|
|
|
72
|
-
// Zenon's split_sep2, for two instances that meet between two numbers.
|
|
73
67
|
const splitSeparatorBetween = (
|
|
74
68
|
before: Lexeme,
|
|
75
69
|
first: Lexeme,
|
|
@@ -95,7 +89,6 @@ const splitSeparatorBetween = (
|
|
|
95
89
|
throw new TlaZenonError("Zenon: a template whose instances don't meet");
|
|
96
90
|
};
|
|
97
91
|
|
|
98
|
-
// Zenon's Enum.parse: a template's text holds two instances of the pattern and the separator.
|
|
99
92
|
const parsePattern = (text: string): Pattern | undefined => {
|
|
100
93
|
const lexemes = lex(text);
|
|
101
94
|
const length = lexemes.length;
|
|
@@ -132,10 +125,9 @@ const parsePattern = (text: string): Pattern | undefined => {
|
|
|
132
125
|
return pieces === undefined ? undefined : { pieces, separator: split[1] };
|
|
133
126
|
};
|
|
134
127
|
|
|
135
|
-
const getInstance = (pieces: Piece[],
|
|
136
|
-
pieces.map((piece) => (typeof piece === "string" ? piece : String(
|
|
128
|
+
const getInstance = (pieces: Piece[], getValue: (piece: Progression) => number) =>
|
|
129
|
+
pieces.map((piece) => (typeof piece === "string" ? piece : String(getValue(piece)))).join("");
|
|
137
130
|
|
|
138
|
-
// Zenon's expand_string and expand_string_rev: the pattern repeated count times.
|
|
139
131
|
const expandPattern = (count: number, text: string, isReversed: boolean) => {
|
|
140
132
|
const pattern = parsePattern(text);
|
|
141
133
|
if (pattern === undefined) return undefined;
|
|
@@ -153,7 +145,6 @@ const expandPattern = (count: number, text: string, isReversed: boolean) => {
|
|
|
153
145
|
.join(pattern.separator);
|
|
154
146
|
};
|
|
155
147
|
|
|
156
|
-
// Zenon's read_suffix: a count adjustment such as [n-1] after the end marker.
|
|
157
148
|
const readAdjustment = (text: string, position: number): [number, number] => {
|
|
158
149
|
const match = /^\[n(?:\]|([+-])([0-9]*)\])/.exec(text.slice(position));
|
|
159
150
|
if (match === null) return [0, position];
|
|
@@ -168,7 +159,6 @@ const trimNewlines = (text: string) => {
|
|
|
168
159
|
throw new TlaZenonError("Zenon: a bad template");
|
|
169
160
|
};
|
|
170
161
|
|
|
171
|
-
// Zenon's Enum.expand_text.
|
|
172
162
|
const expandTemplate = (count: number, template: string) => {
|
|
173
163
|
const parts: string[] = [];
|
|
174
164
|
let position = 0;
|
package/src/prover/zenon/isar.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
// Ported from Zenon's lltoisar.ml and the -oisar path of main.ml, as shipped in tlapm. Copyright
|
|
2
|
-
// 2008 INRIA, see LICENSE.
|
|
3
|
-
//
|
|
4
|
-
// Prints a proof as the Isar text that Zenon writes with -oisar, which tlapm checks with Isabelle.
|
|
5
|
-
// Zenon numbers each formula the first time it prints or names it: z_H<n> names a hypothesis and
|
|
6
|
-
// ?z_h<n> abbreviates a formula that an earlier (is "...") pattern bound.
|
|
1
|
+
// Ported from Zenon's lltoisar.ml and the -oisar path of main.ml, as shipped in tlapm. Copyright 2008 INRIA, see LICENSE.
|
|
7
2
|
|
|
8
3
|
import { TlaZenonError } from "../../errors";
|
|
9
4
|
import { FALSE, GOAL_NAME, TRUE, type BinderExpr, type Expr, type Expressions } from "./expr";
|
|
@@ -50,7 +45,6 @@ const PREFIXES: Record<string, string> = {
|
|
|
50
45
|
"TLA.box": "isa'box",
|
|
51
46
|
};
|
|
52
47
|
|
|
53
|
-
// Zenon drops the namespace of the symbols it doesn't rename.
|
|
54
48
|
const stripNamespace = (symbol: string) =>
|
|
55
49
|
symbol.length > 4 && symbol.startsWith("TLA.")
|
|
56
50
|
? symbol.slice(4)
|
|
@@ -58,7 +52,6 @@ const stripNamespace = (symbol: string) =>
|
|
|
58
52
|
? symbol.slice(6)
|
|
59
53
|
: symbol;
|
|
60
54
|
|
|
61
|
-
// Zenon's Misc.base26.
|
|
62
55
|
const toBase26 = (number: number): string =>
|
|
63
56
|
number < 26
|
|
64
57
|
? String.fromCharCode(97 + number)
|
|
@@ -70,7 +63,6 @@ const getPairs = <Item>(items: Item[]): [Item, Item][] =>
|
|
|
70
63
|
items[2 * position + 1],
|
|
71
64
|
]);
|
|
72
65
|
|
|
73
|
-
// The numeral that Zenon prints for 0 and its successors, up to 15.
|
|
74
66
|
const getNumeral = (expression: Expr, limit: number): number | undefined => {
|
|
75
67
|
if (limit < 0) return undefined;
|
|
76
68
|
if (expression.kind === "var" && expression.symbol === "0") return 0;
|
|
@@ -99,12 +91,8 @@ const getLastBranchIsOther = (branches: Expr[][]) => {
|
|
|
99
91
|
return last.length === 2;
|
|
100
92
|
};
|
|
101
93
|
|
|
102
|
-
// Zenon's iinc: the indentation stops growing at 15.
|
|
103
94
|
const increment = (indent: number) => (indent >= 15 ? indent : indent + 1);
|
|
104
95
|
|
|
105
|
-
// What the search knew when it found a proof: the .znn file's phrases, the proofs that it reused
|
|
106
|
-
// and the properties of relations that the hypotheses stated. The printer stops at the search's
|
|
107
|
-
// limits.
|
|
108
96
|
interface IsarContext {
|
|
109
97
|
exprs: Expressions;
|
|
110
98
|
phrases: Phrase[];
|
|
@@ -113,12 +101,9 @@ interface IsarContext {
|
|
|
113
101
|
limits: Limits;
|
|
114
102
|
}
|
|
115
103
|
|
|
116
|
-
// The Isar text that Zenon prints with -oisar for a proof that the search found, or undefined when
|
|
117
|
-
// the limits stop the printer first.
|
|
118
104
|
export const printIsar = (proof: MlProof, context: IsarContext): string | undefined => {
|
|
119
105
|
const exprs = context.exprs;
|
|
120
106
|
const numbers = new Map<Expr, number>();
|
|
121
|
-
// Zenon's Index.get_number.
|
|
122
107
|
const getNumber = (expression: Expr) => {
|
|
123
108
|
const existing = numbers.get(expression);
|
|
124
109
|
if (existing !== undefined) return existing;
|
|
@@ -149,8 +134,6 @@ export const printIsar = (proof: MlProof, context: IsarContext): string | undefi
|
|
|
149
134
|
return exprs.elam(binder.args[0], binder.symbol, binder.args[1]);
|
|
150
135
|
};
|
|
151
136
|
|
|
152
|
-
// The formulas that (is "...") patterns bound, as a persistent set: a version is the length of
|
|
153
|
-
// the log, and a version only reads the log's prefix, which later additions from it don't change.
|
|
154
137
|
const dictLog: number[] = [];
|
|
155
138
|
const dictPositions = new Map<number, number>();
|
|
156
139
|
const isBound = (dict: number, number: number) => {
|
|
@@ -164,7 +147,6 @@ export const printIsar = (proof: MlProof, context: IsarContext): string | undefi
|
|
|
164
147
|
return dict + 1;
|
|
165
148
|
};
|
|
166
149
|
|
|
167
|
-
// Zenon's p_expr: the bound variables are those that a pattern can't abbreviate.
|
|
168
150
|
const printExpr = (env: string[], dict: number, expression: Expr): string => {
|
|
169
151
|
const number = getNumber(expression);
|
|
170
152
|
if (isBound(dict, number) && !expression.freeVars.some((name) => env.includes(name)))
|
|
@@ -257,7 +239,6 @@ export const printIsar = (proof: MlProof, context: IsarContext): string | undefi
|
|
|
257
239
|
|
|
258
240
|
const expr = (dict: number, expression: Expr) => printExpr([], dict, expression);
|
|
259
241
|
|
|
260
|
-
// Zenon's p_apply: the instance of a lambda, through the lambda's abbreviation if it has one.
|
|
261
242
|
const printApply = (dict: number, lambda: Expr, argument: Expr) => {
|
|
262
243
|
const number = getNumber(lambda);
|
|
263
244
|
return isBound(dict, number)
|
|
@@ -265,14 +246,12 @@ export const printIsar = (proof: MlProof, context: IsarContext): string | undefi
|
|
|
265
246
|
: expr(dict, exprs.apply(lambda, argument));
|
|
266
247
|
};
|
|
267
248
|
|
|
268
|
-
// Zenon's mk_pat: a pattern variable for a formula that has none yet.
|
|
269
249
|
const makePattern = (dict: number, expression: Expr): [string, number] => {
|
|
270
250
|
if (expression.kind === "var" && !isMetaName(expression.symbol)) return ["_", dict];
|
|
271
251
|
const number = getNumber(expression);
|
|
272
252
|
return isBound(dict, number) ? ["_", dict] : [vname(expression), bind(dict, number)];
|
|
273
253
|
};
|
|
274
254
|
|
|
275
|
-
// Zenon's p_is: binds the formula's parts to pattern variables.
|
|
276
255
|
const printIs = (dict: number, formula: Expr): number => {
|
|
277
256
|
const binary = (prefix: string, left: Expr, operator: string, right: Expr, suffix: string) => {
|
|
278
257
|
const first = makePattern(dict, left);
|
|
@@ -340,7 +319,6 @@ export const printIsar = (proof: MlProof, context: IsarContext): string | undefi
|
|
|
340
319
|
return printIs(current, formula);
|
|
341
320
|
}, dict);
|
|
342
321
|
|
|
343
|
-
// Zenon's p_sub: each branch assumes its formulas and proves FALSE.
|
|
344
322
|
const printBranches = (
|
|
345
323
|
indent: number,
|
|
346
324
|
dict: number,
|
|
@@ -359,7 +337,6 @@ export const printIsar = (proof: MlProof, context: IsarContext): string | undefi
|
|
|
359
337
|
});
|
|
360
338
|
};
|
|
361
339
|
|
|
362
|
-
// A have for each formula of the branch that the subproof uses, then the subproof.
|
|
363
340
|
const printHaves = (
|
|
364
341
|
indent: number,
|
|
365
342
|
dict: number,
|
|
@@ -410,7 +387,6 @@ export const printIsar = (proof: MlProof, context: IsarContext): string | undefi
|
|
|
410
387
|
printBranches(indent, dict, branches, proof.subproofs);
|
|
411
388
|
};
|
|
412
389
|
|
|
413
|
-
// Zenon's p_gamma and p_delta: the instance of a quantified formula.
|
|
414
390
|
const printInstance = (
|
|
415
391
|
indent: number,
|
|
416
392
|
dict: number,
|
|
@@ -436,7 +412,6 @@ export const printIsar = (proof: MlProof, context: IsarContext): string | undefi
|
|
|
436
412
|
printTree(indent, next, subproof);
|
|
437
413
|
};
|
|
438
414
|
|
|
439
|
-
// Zenon's p_sub_equal: proves an argument equal to the other, unless the subproof needn't.
|
|
440
415
|
const printSubEqual = (
|
|
441
416
|
indent: number,
|
|
442
417
|
dict: number,
|
|
@@ -460,7 +435,6 @@ export const printIsar = (proof: MlProof, context: IsarContext): string | undefi
|
|
|
460
435
|
return next;
|
|
461
436
|
};
|
|
462
437
|
|
|
463
|
-
// Zenon's p_subst: rewrites the arguments that differ one at a time.
|
|
464
438
|
const printSubstitution = (
|
|
465
439
|
indent: number,
|
|
466
440
|
dict: number,
|
|
@@ -811,7 +785,6 @@ export const printIsar = (proof: MlProof, context: IsarContext): string | undefi
|
|
|
811
785
|
);
|
|
812
786
|
};
|
|
813
787
|
|
|
814
|
-
// A hypothesis of a product or record set's rules, and its negation, each in its own branch.
|
|
815
788
|
const printNegatedHaves = (
|
|
816
789
|
indent: number,
|
|
817
790
|
dict: number,
|
|
@@ -1200,7 +1173,6 @@ export const printIsar = (proof: MlProof, context: IsarContext): string | undefi
|
|
|
1200
1173
|
line(indent, "qed\n");
|
|
1201
1174
|
};
|
|
1202
1175
|
|
|
1203
|
-
// Zenon's p_theorem.
|
|
1204
1176
|
const theorem = lemmas[lemmas.length - 1];
|
|
1205
1177
|
const hypotheses = context.phrases.flatMap((phrase) => (phrase.kind === "hyp" ? [phrase] : []));
|
|
1206
1178
|
const negatedGoal =
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
// When Zenon gives up: past the deadline, a time from Date.now(), or once the signal aborts. tlapm
|
|
2
|
-
// kills Zenon at its deadline whether Zenon is searching or printing the proof, so the search, the
|
|
3
|
-
// checker and the printer each check the limits at every step.
|
|
4
1
|
export interface Limits {
|
|
5
2
|
deadline: number;
|
|
6
3
|
signal: AbortSignal | undefined;
|
|
7
4
|
}
|
|
8
5
|
|
|
9
|
-
// Why the limits stop Zenon now, if they do.
|
|
10
6
|
export const getLimitFailure = (limits: Limits) =>
|
|
11
7
|
Date.now() > limits.deadline
|
|
12
8
|
? "time limit"
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
// Ported from Zenon's llproof.ml, as shipped in tlapm. Copyright 2004 INRIA, see LICENSE.
|
|
2
|
-
//
|
|
3
|
-
// The low-level proofs that Zenon prints: each node's conclusions are the formulas its subproofs
|
|
4
|
-
// leave open, and the proof is a list of lemmas, the theorem last.
|
|
5
2
|
|
|
6
3
|
import { TlaZenonError } from "../../errors";
|
|
7
4
|
import { FALSE, TRUE, type Expr, type Expressions } from "./expr";
|
|
@@ -17,7 +14,6 @@ export type LlRule =
|
|
|
17
14
|
| { kind: "eqsym"; left: Expr; right: Expr }
|
|
18
15
|
| { kind: "notnot"; formula: Expr }
|
|
19
16
|
| { kind: "connect" | "notconnect"; connective: Connective; left: Expr; right: Expr }
|
|
20
|
-
// The quantified formula, and the witness or the term that instantiates it.
|
|
21
17
|
| { kind: "ex" | "all" | "notex" | "notall"; quantified: Expr; term: Expr }
|
|
22
18
|
| { kind: "pnotp"; positive: Expr; negative: Expr }
|
|
23
19
|
| { kind: "notequal"; left: Expr; right: Expr }
|
|
@@ -37,7 +33,6 @@ export interface LlProof {
|
|
|
37
33
|
subproofs: LlProof[];
|
|
38
34
|
}
|
|
39
35
|
|
|
40
|
-
// A lemma's parameters pair each free tau or metavariable with its type.
|
|
41
36
|
export interface Lemma {
|
|
42
37
|
name: string;
|
|
43
38
|
params: [string, Expr][];
|
|
@@ -65,7 +60,6 @@ const makeLeaf = (conclusions: Expr[], rule: LlRule): LlProof => ({
|
|
|
65
60
|
subproofs: [],
|
|
66
61
|
});
|
|
67
62
|
|
|
68
|
-
// Zenon's direct_close: a node that closes the conclusions at once, if one does.
|
|
69
63
|
const getDirectClose = (exprs: Expressions, conclusions: Expr[]): LlProof | undefined => {
|
|
70
64
|
for (const [position, formula] of conclusions.entries()) {
|
|
71
65
|
const rest = conclusions.slice(position + 1);
|
|
@@ -90,7 +84,6 @@ const getDirectClose = (exprs: Expressions, conclusions: Expr[]): LlProof | unde
|
|
|
90
84
|
return undefined;
|
|
91
85
|
};
|
|
92
86
|
|
|
93
|
-
// The formulas that a rule takes from its conclusions.
|
|
94
87
|
const getEliminated = (exprs: Expressions, lemmas: Map<string, Lemma>, rule: LlRule): Expr[] => {
|
|
95
88
|
const equal = (left: Expr, right: Expr) => exprs.eapp("=", [left, right]);
|
|
96
89
|
switch (rule.kind) {
|
|
@@ -135,8 +128,6 @@ const getEliminated = (exprs: Expressions, lemmas: Map<string, Lemma>, rule: LlR
|
|
|
135
128
|
}
|
|
136
129
|
};
|
|
137
130
|
|
|
138
|
-
// Zenon's Llproof.optimise: drops the conclusions that no rule uses and the nodes whose subproof
|
|
139
|
-
// already proves their conclusions.
|
|
140
131
|
export const optimise = (exprs: Expressions, proof: Lemma[]): Lemma[] => {
|
|
141
132
|
const lemmas = new Map<string, Lemma>();
|
|
142
133
|
const optimiseTree = (tree: LlProof): LlProof => {
|