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,10 +1,8 @@
|
|
|
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 {
|
|
4
|
+
getStringName,
|
|
5
|
+
isApp,
|
|
8
6
|
isNegatedRelation,
|
|
9
7
|
isRelation,
|
|
10
8
|
type Expr,
|
|
@@ -27,7 +25,6 @@ interface Suspect {
|
|
|
27
25
|
records: LemmaRecord[];
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
// A stack of values per key, as a Hashtbl with Hashtbl.add and Hashtbl.remove.
|
|
31
28
|
const pushValue = <Key, Value>(table: Map<Key, Value[]>, key: Key, value: Value) => {
|
|
32
29
|
const values = table.get(key);
|
|
33
30
|
if (values === undefined) table.set(key, [value]);
|
|
@@ -44,7 +41,6 @@ const popValue = <Key, Value>(table: Map<Key, Value[]>, key: Key) => {
|
|
|
44
41
|
const getLatestFirst = <Key, Value>(table: Map<Key, Value[]>, key: Key) =>
|
|
45
42
|
[...(table.get(key) ?? [])].reverse();
|
|
46
43
|
|
|
47
|
-
// Zenon's head of a term, or undefined for No_head. Taus and metavariables are heads by identity.
|
|
48
44
|
type Head = string | Expr;
|
|
49
45
|
|
|
50
46
|
export const getHead = (expression: Expr): Head | undefined => {
|
|
@@ -68,19 +64,10 @@ export const getHead = (expression: Expr): Head | undefined => {
|
|
|
68
64
|
}
|
|
69
65
|
};
|
|
70
66
|
|
|
71
|
-
// Zenon indexes formulas by head under a string; every tau shares "t." and every metavariable "".
|
|
72
67
|
const getHeadKey = (head: Head) =>
|
|
73
68
|
typeof head === "string" ? head : head.kind === "tau" ? "t." : "";
|
|
74
69
|
|
|
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.
|
|
70
|
+
// Removing from a one-element list drops the key whatever the element, as Zenon does.
|
|
84
71
|
const removeElement = <Key, Value>(table: Map<Key, Value[]>, key: Key, value: Value) => {
|
|
85
72
|
const values = table.get(key);
|
|
86
73
|
if (values === undefined) return false;
|
|
@@ -89,9 +76,6 @@ const removeElement = <Key, Value>(table: Map<Key, Value[]>, key: Key, value: Va
|
|
|
89
76
|
return true;
|
|
90
77
|
};
|
|
91
78
|
|
|
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
79
|
const getHeadId = (head: Head) => (typeof head === "string" ? `s${head}` : `e${head.id}`);
|
|
96
80
|
|
|
97
81
|
const getRelationKey = (relation: string, head: Head) => `${relation}\u0000${getHeadId(head)}`;
|
|
@@ -129,7 +113,6 @@ export const createIndex = (exprs: Expressions) => {
|
|
|
129
113
|
const withGoalness = <Formula extends Expr>(list: Formula[]): [Formula, number][] =>
|
|
130
114
|
list.map((formula) => [formula, getGoalness(formula)]);
|
|
131
115
|
|
|
132
|
-
// Zenon's negpos: a negation under the head of its operand, anything else under its own head.
|
|
133
116
|
const actOnHead = (
|
|
134
117
|
formula: Expr,
|
|
135
118
|
action: <Formula extends Expr>(
|
|
@@ -147,35 +130,23 @@ export const createIndex = (exprs: Expressions) => {
|
|
|
147
130
|
if (head !== undefined) action(positive, getHeadKey(head), formula);
|
|
148
131
|
};
|
|
149
132
|
|
|
150
|
-
const getStringLiteral = (expression: Expr) =>
|
|
151
|
-
expression.kind === "app" &&
|
|
152
|
-
expression.symbol === "$string" &&
|
|
153
|
-
expression.args.length === 1 &&
|
|
154
|
-
expression.args[0].kind === "var"
|
|
155
|
-
? expression.args[0].symbol
|
|
156
|
-
: undefined;
|
|
157
|
-
|
|
158
133
|
const getStringEquality = (formula: Expr) => {
|
|
159
|
-
if (formula
|
|
160
|
-
|
|
161
|
-
const rightString = getStringLiteral(formula.args[1]);
|
|
134
|
+
if (!isApp(formula, "=", 2)) return undefined;
|
|
135
|
+
const rightString = getStringName(formula.args[1]);
|
|
162
136
|
if (rightString !== undefined)
|
|
163
137
|
return { isReversed: false, term: formula.args[0], value: rightString };
|
|
164
|
-
const leftString =
|
|
138
|
+
const leftString = getStringName(formula.args[0]);
|
|
165
139
|
return leftString === undefined
|
|
166
140
|
? undefined
|
|
167
141
|
: { isReversed: true, term: formula.args[1], value: leftString };
|
|
168
142
|
};
|
|
169
143
|
|
|
170
|
-
const isEquality = (formula: Expr) =>
|
|
171
|
-
formula.kind === "app" && formula.symbol === "=" && formula.args.length === 2;
|
|
172
|
-
|
|
173
144
|
const add = (formula: Expr, goalness: number) => {
|
|
174
145
|
pushValue(formulas, formula, goalness);
|
|
175
|
-
if (
|
|
146
|
+
if (isApp(formula, "=", 2)) {
|
|
176
147
|
pushValue(equalLeftRight, formula.args[0], formula.args[1]);
|
|
177
148
|
pushValue(equalRightLeft, formula.args[1], formula.args[0]);
|
|
178
|
-
} else if (formula.kind === "not" &&
|
|
149
|
+
} else if (formula.kind === "not" && isApp(formula.args[0], "=", 2)) {
|
|
179
150
|
pushValue(unequalLeftRight, formula.args[0].args[0], formula.args[0].args[1]);
|
|
180
151
|
pushValue(unequalRightLeft, formula.args[0].args[1], formula.args[0].args[0]);
|
|
181
152
|
}
|
|
@@ -187,7 +158,7 @@ export const createIndex = (exprs: Expressions) => {
|
|
|
187
158
|
]);
|
|
188
159
|
formulaCount++;
|
|
189
160
|
topFormulaCount = Math.max(topFormulaCount, formulaCount);
|
|
190
|
-
actOnHead(formula,
|
|
161
|
+
actOnHead(formula, pushValue);
|
|
191
162
|
const lemma = lemmas.get(formula);
|
|
192
163
|
if (lemma !== undefined) lemma.isPresent = true;
|
|
193
164
|
newFormulas.unshift(formula);
|
|
@@ -228,10 +199,10 @@ export const createIndex = (exprs: Expressions) => {
|
|
|
228
199
|
const stringEquality = getStringEquality(formula);
|
|
229
200
|
if (stringEquality !== undefined)
|
|
230
201
|
(stringEquality.isReversed ? reversedStringEqualities : stringEqualities).shift();
|
|
231
|
-
if (
|
|
202
|
+
if (isApp(formula, "=", 2)) {
|
|
232
203
|
popValue(equalLeftRight, formula.args[0]);
|
|
233
204
|
popValue(equalRightLeft, formula.args[1]);
|
|
234
|
-
} else if (formula.kind === "not" &&
|
|
205
|
+
} else if (formula.kind === "not" && isApp(formula.args[0], "=", 2)) {
|
|
235
206
|
popValue(unequalLeftRight, formula.args[0].args[0]);
|
|
236
207
|
popValue(unequalRightLeft, formula.args[0].args[1]);
|
|
237
208
|
}
|
|
@@ -240,14 +211,13 @@ export const createIndex = (exprs: Expressions) => {
|
|
|
240
211
|
if (lemma !== undefined) lemma.isPresent = false;
|
|
241
212
|
};
|
|
242
213
|
|
|
243
|
-
// Zenon's add_trans, which stops at the first side without a head. False means No_head.
|
|
244
214
|
const addTrans = (formula: RelationExpr) => {
|
|
245
215
|
const leftHead = getHead(formula.args[0]);
|
|
246
216
|
if (leftHead === undefined) return false;
|
|
247
|
-
|
|
217
|
+
pushValue(transLeft, getRelationKey(formula.symbol, leftHead), formula);
|
|
248
218
|
const rightHead = getHead(formula.args[1]);
|
|
249
219
|
if (rightHead === undefined) return false;
|
|
250
|
-
|
|
220
|
+
pushValue(transRight, getRelationKey(formula.symbol, rightHead), formula);
|
|
251
221
|
return true;
|
|
252
222
|
};
|
|
253
223
|
|
|
@@ -255,13 +225,13 @@ export const createIndex = (exprs: Expressions) => {
|
|
|
255
225
|
const relation = formula.args[0];
|
|
256
226
|
const leftHead = getHead(relation.args[0]);
|
|
257
227
|
if (leftHead !== undefined) {
|
|
258
|
-
|
|
259
|
-
|
|
228
|
+
pushValue(negTransLeft, getRelationKey(relation.symbol, leftHead), formula);
|
|
229
|
+
pushValue(allNegTransLeft, getHeadId(leftHead), formula);
|
|
260
230
|
}
|
|
261
231
|
const rightHead = getHead(relation.args[1]);
|
|
262
232
|
if (rightHead !== undefined) {
|
|
263
|
-
|
|
264
|
-
|
|
233
|
+
pushValue(negTransRight, getRelationKey(relation.symbol, rightHead), formula);
|
|
234
|
+
pushValue(allNegTransRight, getHeadId(rightHead), formula);
|
|
265
235
|
}
|
|
266
236
|
};
|
|
267
237
|
|
|
@@ -276,8 +246,6 @@ export const createIndex = (exprs: Expressions) => {
|
|
|
276
246
|
suspects.unshift([{ proof, cursor: 0, records }]);
|
|
277
247
|
};
|
|
278
248
|
|
|
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
249
|
const searchLemma = (): Proof | undefined => {
|
|
282
250
|
for (const formula of newFormulas) {
|
|
283
251
|
const record = lemmas.get(formula);
|
|
@@ -312,8 +280,8 @@ export const createIndex = (exprs: Expressions) => {
|
|
|
312
280
|
remove,
|
|
313
281
|
isMember,
|
|
314
282
|
getGoalness,
|
|
315
|
-
findPositive: (symbol: string) => withGoalness(
|
|
316
|
-
findNegative: (symbol: string) => withGoalness(
|
|
283
|
+
findPositive: (symbol: string) => withGoalness(getLatestFirst(positive, symbol)),
|
|
284
|
+
findNegative: (symbol: string) => withGoalness(getLatestFirst(negative, symbol)),
|
|
317
285
|
findEqualRight: (term: Expr) => getLatestFirst(equalLeftRight, term),
|
|
318
286
|
findEqualLeft: (term: Expr) => getLatestFirst(equalRightLeft, term),
|
|
319
287
|
findDisequalities: (term: Expr) => [
|
|
@@ -329,16 +297,17 @@ export const createIndex = (exprs: Expressions) => {
|
|
|
329
297
|
addTrans,
|
|
330
298
|
addNegTrans,
|
|
331
299
|
findTransLeft: (relation: string, head: Head) =>
|
|
332
|
-
withGoalness(
|
|
300
|
+
withGoalness(getLatestFirst(transLeft, getRelationKey(relation, head))),
|
|
333
301
|
findTransRight: (relation: string, head: Head) =>
|
|
334
|
-
withGoalness(
|
|
302
|
+
withGoalness(getLatestFirst(transRight, getRelationKey(relation, head))),
|
|
335
303
|
findNegTransLeft: (relation: string, head: Head) =>
|
|
336
|
-
withGoalness(
|
|
304
|
+
withGoalness(getLatestFirst(negTransLeft, getRelationKey(relation, head))),
|
|
337
305
|
findNegTransRight: (relation: string, head: Head) =>
|
|
338
|
-
withGoalness(
|
|
339
|
-
findAllNegTransLeft: (head: Head) =>
|
|
306
|
+
withGoalness(getLatestFirst(negTransRight, getRelationKey(relation, head))),
|
|
307
|
+
findAllNegTransLeft: (head: Head) =>
|
|
308
|
+
withGoalness(getLatestFirst(allNegTransLeft, getHeadId(head))),
|
|
340
309
|
findAllNegTransRight: (head: Head) =>
|
|
341
|
-
withGoalness(
|
|
310
|
+
withGoalness(getLatestFirst(allNegTransRight, getHeadId(head))),
|
|
342
311
|
addLemma,
|
|
343
312
|
searchLemma,
|
|
344
313
|
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";
|
|
@@ -15,42 +10,41 @@ import { isMetaName, translateProof, type MlProof } from "./mltoll";
|
|
|
15
10
|
import type { Phrase } from "./parse";
|
|
16
11
|
import { postprocessTla } from "./tla/llproof";
|
|
17
12
|
|
|
18
|
-
const INFIXES
|
|
19
|
-
"="
|
|
20
|
-
"TLA.cup"
|
|
21
|
-
"TLA.cap"
|
|
22
|
-
"TLA.setminus"
|
|
23
|
-
"TLA.in"
|
|
24
|
-
"TLA.subseteq"
|
|
25
|
-
"arith.natrange"
|
|
26
|
-
"arith.add"
|
|
27
|
-
"arith.sub"
|
|
28
|
-
"arith.mul"
|
|
29
|
-
"arith.le"
|
|
30
|
-
"arith.lt"
|
|
31
|
-
"TLA.concat"
|
|
32
|
-
"TLA.oneArg"
|
|
33
|
-
"TLA.extend"
|
|
34
|
-
|
|
13
|
+
const INFIXES = new Map([
|
|
14
|
+
["=", "="],
|
|
15
|
+
["TLA.cup", " \\\\cup "],
|
|
16
|
+
["TLA.cap", " \\\\cap "],
|
|
17
|
+
["TLA.setminus", " \\\\ "],
|
|
18
|
+
["TLA.in", " \\\\in "],
|
|
19
|
+
["TLA.subseteq", " \\\\subseteq "],
|
|
20
|
+
["arith.natrange", ".."],
|
|
21
|
+
["arith.add", " + "],
|
|
22
|
+
["arith.sub", " - "],
|
|
23
|
+
["arith.mul", " * "],
|
|
24
|
+
["arith.le", " <= "],
|
|
25
|
+
["arith.lt", " < "],
|
|
26
|
+
["TLA.concat", " \\\\circ "],
|
|
27
|
+
["TLA.oneArg", " :> "],
|
|
28
|
+
["TLA.extend", " @@ "],
|
|
29
|
+
]);
|
|
35
30
|
|
|
36
|
-
const CONSTANTS
|
|
37
|
-
"TLA.emptyset"
|
|
38
|
-
"arith.N"
|
|
39
|
-
"arith.Z"
|
|
40
|
-
"arith.R"
|
|
41
|
-
"arith.Infinity"
|
|
42
|
-
|
|
31
|
+
const CONSTANTS = new Map([
|
|
32
|
+
["TLA.emptyset", "{}"],
|
|
33
|
+
["arith.N", "Nat"],
|
|
34
|
+
["arith.Z", "Int"],
|
|
35
|
+
["arith.R", "isReal"],
|
|
36
|
+
["arith.Infinity", "isInfinity"],
|
|
37
|
+
]);
|
|
43
38
|
|
|
44
|
-
const PREFIXES
|
|
45
|
-
"arith.div"
|
|
46
|
-
"arith.euclidiv"
|
|
47
|
-
"arith.mod"
|
|
48
|
-
"arith.minus"
|
|
49
|
-
"arith.intrange"
|
|
50
|
-
"TLA.box"
|
|
51
|
-
|
|
39
|
+
const PREFIXES = new Map([
|
|
40
|
+
["arith.div", "isa'slash"],
|
|
41
|
+
["arith.euclidiv", "isa'div"],
|
|
42
|
+
["arith.mod", "isa'pc"],
|
|
43
|
+
["arith.minus", " -."],
|
|
44
|
+
["arith.intrange", "isa'dotdot"],
|
|
45
|
+
["TLA.box", "isa'box"],
|
|
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)))
|
|
@@ -177,7 +159,7 @@ export const printIsar = (proof: MlProof, context: IsarContext): string | undefi
|
|
|
177
159
|
case "var":
|
|
178
160
|
return isMetaName(expression.symbol)
|
|
179
161
|
? "(CHOOSE x : TRUE)"
|
|
180
|
-
: (CONSTANTS
|
|
162
|
+
: (CONSTANTS.get(expression.symbol) ?? stripNamespace(expression.symbol));
|
|
181
163
|
case "app": {
|
|
182
164
|
const args = expression.args;
|
|
183
165
|
switch (expression.symbol) {
|
|
@@ -210,11 +192,11 @@ export const printIsar = (proof: MlProof, context: IsarContext): string | undefi
|
|
|
210
192
|
if (numeral !== undefined) return String(numeral + 1);
|
|
211
193
|
return `(${print(args[0])}[${print(args[1])}])`;
|
|
212
194
|
}
|
|
213
|
-
const infix = INFIXES
|
|
195
|
+
const infix = INFIXES.get(expression.symbol);
|
|
214
196
|
if (infix !== undefined && args.length === 2)
|
|
215
197
|
return `(${print(args[0])}${infix}${print(args[1])})`;
|
|
216
198
|
if (args.length === 0) return expression.symbol;
|
|
217
|
-
return `${PREFIXES
|
|
199
|
+
return `${PREFIXES.get(expression.symbol) ?? stripNamespace(expression.symbol)}(${printList(args)})`;
|
|
218
200
|
}
|
|
219
201
|
case "not": {
|
|
220
202
|
const operand = expression.args[0];
|
|
@@ -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,22 +33,12 @@ 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][];
|
|
44
39
|
proof: LlProof;
|
|
45
40
|
}
|
|
46
41
|
|
|
47
|
-
export const connect = (exprs: Expressions, connective: Connective, left: Expr, right: Expr) =>
|
|
48
|
-
connective === "and"
|
|
49
|
-
? exprs.eand(left, right)
|
|
50
|
-
: connective === "or"
|
|
51
|
-
? exprs.eor(left, right)
|
|
52
|
-
: connective === "imply"
|
|
53
|
-
? exprs.eimply(left, right)
|
|
54
|
-
: exprs.eequiv(left, right);
|
|
55
|
-
|
|
56
42
|
const getLemma = (lemmas: Map<string, Lemma>, name: string) => {
|
|
57
43
|
const lemma = lemmas.get(name);
|
|
58
44
|
if (lemma === undefined) throw new TlaZenonError(`Zenon: no lemma ${name}`);
|
|
@@ -65,7 +51,6 @@ const makeLeaf = (conclusions: Expr[], rule: LlRule): LlProof => ({
|
|
|
65
51
|
subproofs: [],
|
|
66
52
|
});
|
|
67
53
|
|
|
68
|
-
// Zenon's direct_close: a node that closes the conclusions at once, if one does.
|
|
69
54
|
const getDirectClose = (exprs: Expressions, conclusions: Expr[]): LlProof | undefined => {
|
|
70
55
|
for (const [position, formula] of conclusions.entries()) {
|
|
71
56
|
const rest = conclusions.slice(position + 1);
|
|
@@ -90,7 +75,6 @@ const getDirectClose = (exprs: Expressions, conclusions: Expr[]): LlProof | unde
|
|
|
90
75
|
return undefined;
|
|
91
76
|
};
|
|
92
77
|
|
|
93
|
-
// The formulas that a rule takes from its conclusions.
|
|
94
78
|
const getEliminated = (exprs: Expressions, lemmas: Map<string, Lemma>, rule: LlRule): Expr[] => {
|
|
95
79
|
const equal = (left: Expr, right: Expr) => exprs.eapp("=", [left, right]);
|
|
96
80
|
switch (rule.kind) {
|
|
@@ -109,9 +93,9 @@ const getEliminated = (exprs: Expressions, lemmas: Map<string, Lemma>, rule: LlR
|
|
|
109
93
|
case "notnot":
|
|
110
94
|
return [exprs.enot(exprs.enot(rule.formula))];
|
|
111
95
|
case "connect":
|
|
112
|
-
return [
|
|
96
|
+
return [exprs.binary(rule.connective, rule.left, rule.right)];
|
|
113
97
|
case "notconnect":
|
|
114
|
-
return [exprs.enot(
|
|
98
|
+
return [exprs.enot(exprs.binary(rule.connective, rule.left, rule.right))];
|
|
115
99
|
case "ex":
|
|
116
100
|
case "all":
|
|
117
101
|
return [rule.quantified];
|
|
@@ -135,8 +119,6 @@ const getEliminated = (exprs: Expressions, lemmas: Map<string, Lemma>, rule: LlR
|
|
|
135
119
|
}
|
|
136
120
|
};
|
|
137
121
|
|
|
138
|
-
// Zenon's Llproof.optimise: drops the conclusions that no rule uses and the nodes whose subproof
|
|
139
|
-
// already proves their conclusions.
|
|
140
122
|
export const optimise = (exprs: Expressions, proof: Lemma[]): Lemma[] => {
|
|
141
123
|
const lemmas = new Map<string, Lemma>();
|
|
142
124
|
const optimiseTree = (tree: LlProof): LlProof => {
|