tla-ts 0.0.9 → 0.0.10-dev.28c823e4b
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 +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 +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 +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 +4 -23
- package/src/bags.ts +99 -102
- package/src/builtins.ts +40 -78
- package/src/bundled-modules.ts +1 -8
- package/src/check.ts +599 -388
- package/src/cli/options.ts +11 -6
- package/src/cli/run.ts +0 -2
- package/src/cli/runtime-invariants.ts +136 -0
- package/src/cli/shared.ts +18 -11
- package/src/cli/tlapm.ts +0 -12
- package/src/cli/tlc-arguments.ts +640 -0
- package/src/cli/tlc-usage.ts +361 -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 +596 -339
- 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 +4 -19
- package/src/json-reader.ts +455 -0
- package/src/json.ts +255 -139
- package/src/levels.ts +8 -17
- package/src/lexer.ts +80 -100
- package/src/liveness-checker.ts +82 -119
- package/src/liveness.ts +112 -64
- 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 +53 -44
- package/src/parser.ts +565 -282
- 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 +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 +81 -35
- package/src/resolve.ts +12 -112
- package/src/runtime.ts +22 -22
- package/src/sany/builtins.ts +2 -5
- package/src/sany/generator.ts +149 -252
- package/src/sany/levels.ts +6 -34
- package/src/sany/lexer.ts +41 -61
- package/src/sany/linter.ts +1 -9
- 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 +495 -155
- package/src/simulate.ts +685 -0
- package/src/spec-description.ts +176 -69
- package/src/standard-definitions.ts +0 -4
- package/src/standard-modules.ts +254 -69
- package/src/state-graph.ts +50 -24
- package/src/subexpressions.ts +69 -52
- package/src/substitution-levels.ts +2 -3
- package/src/successors.ts +263 -94
- 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 +110 -44
- package/src/tlc/order.ts +37 -60
- package/src/tlc/random.ts +33 -45
- package/src/tlc/replay.ts +549 -217
- package/src/tlc/summary.ts +36 -47
- package/src/tlc/tlc-operators.ts +76 -41
- package/src/tlc/tlcext-operators.ts +139 -122
- package/src/tlc/trace-spec.ts +269 -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 +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 +780 -337
- package/src/worker.ts +7 -8
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
// Ported from Zenon's mltoll.ml, as shipped in tlapm. Copyright 2004 INRIA, see LICENSE.
|
|
2
|
-
//
|
|
3
|
-
// Translates the proof that the search finds into a low-level proof: the derived rules expand into
|
|
4
|
-
// core rules, and each proof that the search reused becomes a lemma.
|
|
5
2
|
|
|
6
3
|
import { TlaZenonError } from "../../errors";
|
|
7
4
|
import type { Direction, Origin, Relations } from "./eqrel";
|
|
@@ -18,8 +15,7 @@ import type { Definition, Phrase } from "./parse";
|
|
|
18
15
|
import type { Rule } from "./proof";
|
|
19
16
|
import { getTlaLlProof } from "./tla/llproof";
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
export type MlRule = Rule | { name: "notall" | "notallex"; args: [Expr] };
|
|
18
|
+
type MlRule = Rule | { name: "notall" | "notallex"; args: [Expr] };
|
|
23
19
|
|
|
24
20
|
export interface MlProof {
|
|
25
21
|
conclusions: Expr[];
|
|
@@ -27,22 +23,17 @@ export interface MlProof {
|
|
|
27
23
|
subproofs: MlProof[];
|
|
28
24
|
}
|
|
29
25
|
|
|
30
|
-
// A translated proof, with the hypotheses it uses that aren't conclusions of the node.
|
|
31
26
|
export type Translated = [LlProof, Expr[]];
|
|
32
27
|
|
|
33
28
|
interface TranslateContext {
|
|
34
29
|
exprs: Expressions;
|
|
35
|
-
// Zenon's Index.get_number, which also names the formulas in the Isar output.
|
|
36
30
|
getNumber: (expression: Expr) => number;
|
|
37
|
-
// The proofs that the search reused, which Zenon counts in mlrefc.
|
|
38
31
|
sharedProofs: ReadonlySet<MlProof>;
|
|
39
32
|
relations: Relations;
|
|
40
33
|
}
|
|
41
34
|
|
|
42
35
|
type RelationProperty = "reflexive" | "symmetric" | "transitive";
|
|
43
36
|
|
|
44
|
-
// Zenon's Eqrel.hyp_kind: how to prove a hypothesis about a relation. A relation is also
|
|
45
|
-
// symmetric or transitive when it's reflexive and transitive in the symmetric sense.
|
|
46
37
|
type HypothesisKind =
|
|
47
38
|
| { kind: "reflexive"; origin: Origin }
|
|
48
39
|
| { kind: "symmetric"; origin: Origin }
|
|
@@ -61,7 +52,6 @@ export const isMetaName = (name: string) => name.startsWith(META_PREFIX);
|
|
|
61
52
|
|
|
62
53
|
const isAlphanumeric = (char: string) => /^[A-Za-z0-9]$/.test(char);
|
|
63
54
|
|
|
64
|
-
// Zenon's type_to_ident.
|
|
65
55
|
const toIdentifier = (type: string) =>
|
|
66
56
|
[...type]
|
|
67
57
|
.map((char) =>
|
|
@@ -79,7 +69,6 @@ const getSingle = (proof: MlProof) => {
|
|
|
79
69
|
return proof.subproofs[0];
|
|
80
70
|
};
|
|
81
71
|
|
|
82
|
-
// Zenon's Mlproof.make_node: the node's conclusions and those its subproofs leave open.
|
|
83
72
|
const makeNode = (
|
|
84
73
|
conclusions: Expr[],
|
|
85
74
|
rule: MlRule,
|
|
@@ -119,7 +108,6 @@ const isDerived = (rule: MlRule) => {
|
|
|
119
108
|
}
|
|
120
109
|
};
|
|
121
110
|
|
|
122
|
-
// The rules that tr_rule translates directly: the core rules and the extension rules named "".
|
|
123
111
|
const CORE_RULES = new Set<string>([
|
|
124
112
|
"close",
|
|
125
113
|
"false",
|
|
@@ -150,7 +138,6 @@ const CORE_RULES = new Set<string>([
|
|
|
150
138
|
"stringdiffrr",
|
|
151
139
|
]);
|
|
152
140
|
|
|
153
|
-
// Zenon's Mltoll.translate: the lemmas in the order they were made, then the theorem.
|
|
154
141
|
export const translateProof = (
|
|
155
142
|
context: TranslateContext,
|
|
156
143
|
phrases: Phrase[],
|
|
@@ -165,7 +152,6 @@ export const translateProof = (
|
|
|
165
152
|
|
|
166
153
|
const equal = (left: Expr, right: Expr) => exprs.eapp("=", [left, right]);
|
|
167
154
|
|
|
168
|
-
// Zenon's tr_expr: metavariables become variables named after their quantifier.
|
|
169
155
|
const translateExpr = (expression: Expr): Expr => {
|
|
170
156
|
if (expression.metas.length === 0) return expression;
|
|
171
157
|
const cached = translatedExprs.get(expression);
|
|
@@ -219,31 +205,30 @@ export const translateProof = (
|
|
|
219
205
|
: exprs.elam(variable, type, body);
|
|
220
206
|
|
|
221
207
|
const translateRule = (rule: MlRule): LlRule => {
|
|
222
|
-
const tr = translateExpr;
|
|
223
208
|
switch (rule.name) {
|
|
224
209
|
case "close":
|
|
225
|
-
return { kind: "axiom", formula:
|
|
210
|
+
return { kind: "axiom", formula: translateExpr(rule.args[0]) };
|
|
226
211
|
case "close_refl":
|
|
227
|
-
return { kind: "noteq", term:
|
|
212
|
+
return { kind: "noteq", term: translateExpr(rule.args[0]) };
|
|
228
213
|
case "close_sym": {
|
|
229
|
-
const right =
|
|
230
|
-
return { kind: "eqsym", left:
|
|
214
|
+
const right = translateExpr(rule.args[1]);
|
|
215
|
+
return { kind: "eqsym", left: translateExpr(rule.args[0]), right };
|
|
231
216
|
}
|
|
232
217
|
case "false":
|
|
233
218
|
return { kind: "false" };
|
|
234
219
|
case "not_true":
|
|
235
220
|
return { kind: "nottrue" };
|
|
236
221
|
case "not_not":
|
|
237
|
-
return { kind: "notnot", formula:
|
|
222
|
+
return { kind: "notnot", formula: translateExpr(rule.args[0]) };
|
|
238
223
|
case "and":
|
|
239
224
|
case "or":
|
|
240
225
|
case "impl":
|
|
241
226
|
case "equiv": {
|
|
242
|
-
const right =
|
|
227
|
+
const right = translateExpr(rule.args[1]);
|
|
243
228
|
return {
|
|
244
229
|
kind: "connect",
|
|
245
230
|
connective: RULE_CONNECTIVES[rule.name],
|
|
246
|
-
left:
|
|
231
|
+
left: translateExpr(rule.args[0]),
|
|
247
232
|
right,
|
|
248
233
|
};
|
|
249
234
|
}
|
|
@@ -251,57 +236,59 @@ export const translateProof = (
|
|
|
251
236
|
case "not_impl":
|
|
252
237
|
case "not_and":
|
|
253
238
|
case "not_equiv": {
|
|
254
|
-
const right =
|
|
239
|
+
const right = translateExpr(rule.args[1]);
|
|
255
240
|
return {
|
|
256
241
|
kind: "notconnect",
|
|
257
242
|
connective: RULE_CONNECTIVES[rule.name],
|
|
258
|
-
left:
|
|
243
|
+
left: translateExpr(rule.args[0]),
|
|
259
244
|
right,
|
|
260
245
|
};
|
|
261
246
|
}
|
|
262
247
|
case "ex": {
|
|
263
248
|
const quantified = getBinder(rule.args[0], "ex");
|
|
264
|
-
const term =
|
|
265
|
-
|
|
249
|
+
const term = translateExpr(
|
|
250
|
+
exprs.etau(quantified.args[0], quantified.symbol, quantified.args[1]),
|
|
251
|
+
);
|
|
252
|
+
return { kind: "ex", quantified: translateExpr(quantified), term };
|
|
266
253
|
}
|
|
267
254
|
case "all": {
|
|
268
|
-
const term =
|
|
269
|
-
return { kind: "all", quantified:
|
|
255
|
+
const term = translateExpr(rule.args[1]);
|
|
256
|
+
return { kind: "all", quantified: translateExpr(rule.args[0]), term };
|
|
270
257
|
}
|
|
271
258
|
case "not_ex": {
|
|
272
259
|
const negation = rule.args[0];
|
|
273
260
|
if (negation.kind !== "not") throw new TlaZenonError("Zenon: not_ex without a negation");
|
|
274
|
-
const term =
|
|
275
|
-
return { kind: "notex", quantified:
|
|
261
|
+
const term = translateExpr(rule.args[1]);
|
|
262
|
+
return { kind: "notex", quantified: translateExpr(negation.args[0]), term };
|
|
276
263
|
}
|
|
277
264
|
case "p_not_p": {
|
|
278
|
-
const negative =
|
|
279
|
-
return { kind: "pnotp", positive:
|
|
265
|
+
const negative = translateExpr(rule.args[1]);
|
|
266
|
+
return { kind: "pnotp", positive: translateExpr(rule.args[0]), negative };
|
|
280
267
|
}
|
|
281
268
|
case "not_equal": {
|
|
282
|
-
const right =
|
|
283
|
-
return { kind: "notequal", left:
|
|
269
|
+
const right = translateExpr(rule.args[1]);
|
|
270
|
+
return { kind: "notequal", left: translateExpr(rule.args[0]), right };
|
|
284
271
|
}
|
|
285
272
|
case "definition": {
|
|
286
273
|
if (rule.definition.kind !== "real")
|
|
287
274
|
throw new TlaZenonError("Zenon: a pseudo-definition in tr_rule");
|
|
288
|
-
const unfolded =
|
|
275
|
+
const unfolded = translateExpr(rule.args[1]);
|
|
289
276
|
return {
|
|
290
277
|
kind: "definition",
|
|
291
278
|
name: rule.definition.name,
|
|
292
|
-
folded:
|
|
279
|
+
folded: translateExpr(rule.args[0]),
|
|
293
280
|
unfolded,
|
|
294
281
|
};
|
|
295
282
|
}
|
|
296
283
|
case "cut":
|
|
297
|
-
return { kind: "cut", formula:
|
|
284
|
+
return { kind: "cut", formula: translateExpr(rule.args[0]) };
|
|
298
285
|
case "congruence_lr":
|
|
299
286
|
case "congruence_rl": {
|
|
300
|
-
const right =
|
|
301
|
-
const left =
|
|
287
|
+
const right = translateExpr(rule.args[2]);
|
|
288
|
+
const left = translateExpr(rule.args[1]);
|
|
302
289
|
return {
|
|
303
290
|
kind: rule.name === "congruence_lr" ? "congruencelr" : "congruencerl",
|
|
304
|
-
context:
|
|
291
|
+
context: translateExpr(rule.args[0]),
|
|
305
292
|
left,
|
|
306
293
|
right,
|
|
307
294
|
};
|
|
@@ -309,10 +296,10 @@ export const translateProof = (
|
|
|
309
296
|
case "notall": {
|
|
310
297
|
const negation = rule.args[0];
|
|
311
298
|
const quantified = getBinder(negation.kind === "not" ? negation.args[0] : negation, "all");
|
|
312
|
-
const term =
|
|
299
|
+
const term = translateExpr(
|
|
313
300
|
exprs.etau(quantified.args[0], quantified.symbol, exprs.enot(quantified.args[1])),
|
|
314
301
|
);
|
|
315
|
-
return { kind: "notall", quantified:
|
|
302
|
+
return { kind: "notall", quantified: translateExpr(quantified), term };
|
|
316
303
|
}
|
|
317
304
|
case "notallex": {
|
|
318
305
|
const lambda = getBinder(rule.args[0], "lam");
|
|
@@ -344,7 +331,10 @@ export const translateProof = (
|
|
|
344
331
|
case "stringdifflr":
|
|
345
332
|
case "stringdiffrl":
|
|
346
333
|
case "stringdiffrr": {
|
|
347
|
-
const
|
|
334
|
+
const first = rule.args[0];
|
|
335
|
+
const firstValue = rule.args[1];
|
|
336
|
+
const second = rule.args[2];
|
|
337
|
+
const secondValue = rule.args[3];
|
|
348
338
|
const isFirstLeft = rule.name === "stringdiffll" || rule.name === "stringdifflr";
|
|
349
339
|
const isSecondLeft = rule.name === "stringdiffll" || rule.name === "stringdiffrl";
|
|
350
340
|
const firstConclusion = isFirstLeft ? equal(first, firstValue) : equal(firstValue, first);
|
|
@@ -366,7 +356,6 @@ export const translateProof = (
|
|
|
366
356
|
}
|
|
367
357
|
};
|
|
368
358
|
|
|
369
|
-
// Zenon's get_params: the free taus of a lemma's conclusions, each with its type.
|
|
370
359
|
const getParams = (accumulated: [string, Expr][], expression: Expr): [string, Expr][] => {
|
|
371
360
|
const merge = (type: string, term: Expr): [string, Expr][] =>
|
|
372
361
|
accumulated.some((param) => param[1] === term) ? accumulated : [[type, term], ...accumulated];
|
|
@@ -435,7 +424,6 @@ export const translateProof = (
|
|
|
435
424
|
const isSharedProof = (proof: MlProof) =>
|
|
436
425
|
context.sharedProofs.has(proof) && !lemmaNumbers.has(proof);
|
|
437
426
|
|
|
438
|
-
// Zenon's get_sub: the subproofs, and the union of their extras from the right.
|
|
439
427
|
const translateAll = (proofs: MlProof[]): [LlProof[], Expr[]] => {
|
|
440
428
|
const translated = proofs.map(translate);
|
|
441
429
|
return [
|
|
@@ -444,7 +432,6 @@ export const translateProof = (
|
|
|
444
432
|
];
|
|
445
433
|
};
|
|
446
434
|
|
|
447
|
-
// A node of recomp_conj, with the formulas it removes from its subproof's conclusions.
|
|
448
435
|
const recompose = (
|
|
449
436
|
conclusion: Expr,
|
|
450
437
|
rule: LlRule,
|
|
@@ -518,12 +505,11 @@ export const translateProof = (
|
|
|
518
505
|
}
|
|
519
506
|
};
|
|
520
507
|
|
|
521
|
-
// Zenon's recomp_disj: consumes the translated subproofs, one for each disjunct.
|
|
522
508
|
const recompDisj = (subs: Translated[], formula: Expr): [LlProof, Expr[], Translated[]] => {
|
|
523
509
|
const node = (
|
|
524
510
|
conclusion: Expr,
|
|
525
511
|
connectiveName: Connective,
|
|
526
|
-
|
|
512
|
+
isNegated: boolean,
|
|
527
513
|
left: Expr,
|
|
528
514
|
right: Expr,
|
|
529
515
|
first: [LlProof, Expr[], Translated[]],
|
|
@@ -540,7 +526,12 @@ export const translateProof = (
|
|
|
540
526
|
difference(second[0].conclusions, [secondRemoved]),
|
|
541
527
|
),
|
|
542
528
|
),
|
|
543
|
-
rule: {
|
|
529
|
+
rule: {
|
|
530
|
+
kind: isNegated ? "notconnect" : "connect",
|
|
531
|
+
connective: connectiveName,
|
|
532
|
+
left,
|
|
533
|
+
right,
|
|
534
|
+
},
|
|
544
535
|
subproofs: [first[0], second[0]],
|
|
545
536
|
},
|
|
546
537
|
difference(union(first[1], second[1]), [extra]),
|
|
@@ -643,7 +634,6 @@ export const translateProof = (
|
|
|
643
634
|
return [subs[0][0], subs[0][1], subs.slice(1)];
|
|
644
635
|
};
|
|
645
636
|
|
|
646
|
-
// The constructors of Zenon's Mlproof, for the proofs that the translation builds.
|
|
647
637
|
const makeClose = (formula: Expr) =>
|
|
648
638
|
makeNode([formula, exprs.enot(formula)], { name: "close", args: [formula] }, [], []);
|
|
649
639
|
const makeCloseRefl = (relation: string, term: Expr) =>
|
|
@@ -704,7 +694,6 @@ export const translateProof = (
|
|
|
704
694
|
const instance = exprs.substitute([[binder.args[0], terms[0]]], binder.args[1]);
|
|
705
695
|
return makeAll(quantified, terms[0], makeAlls(instance, terms.slice(1), subproof));
|
|
706
696
|
};
|
|
707
|
-
// Zenon's make_impls: the implications from `hypotheses` to `conclusion`, and their proof.
|
|
708
697
|
const makeImplies = (
|
|
709
698
|
hypotheses: Expr[],
|
|
710
699
|
conclusion: Expr,
|
|
@@ -737,8 +726,6 @@ export const translateProof = (
|
|
|
737
726
|
[first, second],
|
|
738
727
|
);
|
|
739
728
|
|
|
740
|
-
// Zenon's Eqrel.get_refl_hyp, get_sym_hyp and get_trans_hyp: the hypothesis that states a
|
|
741
|
-
// property of a relation, which the translation proves from the hypotheses that implied it.
|
|
742
729
|
const relationHypotheses = new Map<string, Expr>();
|
|
743
730
|
const hypothesisKinds = new Map<Expr, HypothesisKind>();
|
|
744
731
|
const getRelationHypothesis = (property: RelationProperty, relation: string) => {
|
|
@@ -795,7 +782,6 @@ export const translateProof = (
|
|
|
795
782
|
return hypothesis;
|
|
796
783
|
};
|
|
797
784
|
|
|
798
|
-
// Zenon's inst_nall: the instance of a negated universal at its counterexample.
|
|
799
785
|
const instantiateNegation = (negation: Expr): [Expr, Expr] => {
|
|
800
786
|
if (negation.kind !== "not") throw new TlaZenonError("Zenon: inst_nall without a negation");
|
|
801
787
|
const binder = getBinder(negation.args[0], "all");
|
|
@@ -804,7 +790,6 @@ export const translateProof = (
|
|
|
804
790
|
return [exprs.substitute([[binder.args[0], witness]], body), witness];
|
|
805
791
|
};
|
|
806
792
|
|
|
807
|
-
// Zenon's decompose_disj: closes each literal of a disjunction with one of `forms`.
|
|
808
793
|
const decomposeDisjunction = (formula: Expr, forms: Expr[]): MlProof => {
|
|
809
794
|
const visit = (disjunct: Expr) => decomposeDisjunction(disjunct, forms);
|
|
810
795
|
const getForm = (form: Expr) => {
|
|
@@ -867,8 +852,6 @@ export const translateProof = (
|
|
|
867
852
|
}
|
|
868
853
|
};
|
|
869
854
|
|
|
870
|
-
// Zenon's decompose_conj: follows `directions` to the conjunct that states a property, and
|
|
871
|
-
// instantiates the quantifiers at `variables` with `witnesses`, the others with metavariables.
|
|
872
855
|
const decomposeConjunction = (
|
|
873
856
|
position: number,
|
|
874
857
|
formula: Expr,
|
|
@@ -986,8 +969,6 @@ export const translateProof = (
|
|
|
986
969
|
return decomposeDisjunction(formula, forms);
|
|
987
970
|
};
|
|
988
971
|
|
|
989
|
-
// Zenon's Eqrel.get_proof: proves a relation hypothesis from the hypotheses that implied it,
|
|
990
|
-
// and returns the proof with those hypotheses.
|
|
991
972
|
const getRelationProof = (hypothesis: Expr): [MlProof, Expr[]] => {
|
|
992
973
|
const kind = hypothesisKinds.get(hypothesis);
|
|
993
974
|
if (kind === undefined)
|
|
@@ -1124,7 +1105,6 @@ export const translateProof = (
|
|
|
1124
1105
|
|
|
1125
1106
|
const relate = (relation: string, left: Expr, right: Expr) => exprs.eapp(relation, [left, right]);
|
|
1126
1107
|
|
|
1127
|
-
// Zenon's make_direct_trans: r(a, b), r(b, c) / r(a, c) / (proof).
|
|
1128
1108
|
const makeDirectTrans = (relation: string, a: Expr, b: Expr, c: Expr, proof: MlProof) => {
|
|
1129
1109
|
const hypothesis = getRelationHypothesis("transitive", relation);
|
|
1130
1110
|
const ab = relate(relation, a, b);
|
|
@@ -1137,21 +1117,18 @@ export const translateProof = (
|
|
|
1137
1117
|
);
|
|
1138
1118
|
return makeAlls(hypothesis, [a, b, c], implied[1]);
|
|
1139
1119
|
};
|
|
1140
|
-
// Zenon's make_direct_nsym: -r(a, b) / -r(b, a) / (proof).
|
|
1141
1120
|
const makeDirectNotSym = (relation: string, a: Expr, b: Expr, proof: MlProof) => {
|
|
1142
1121
|
const hypothesis = getRelationHypothesis("symmetric", relation);
|
|
1143
1122
|
const ab = relate(relation, a, b);
|
|
1144
1123
|
const ba = relate(relation, b, a);
|
|
1145
1124
|
return makeAlls(hypothesis, [b, a], makeImply(ba, ab, proof, makeClose(ab)));
|
|
1146
1125
|
};
|
|
1147
|
-
// Zenon's make_direct_sym_neq: a != b / b != a / (proof).
|
|
1148
1126
|
const makeSymmetricDisequality = (a: Expr, b: Expr, proof: MlProof) => {
|
|
1149
1127
|
const reflexive = equal(b, b);
|
|
1150
1128
|
const refuted = makeCloseRefl("=", b);
|
|
1151
1129
|
const swapped = makePNotP(reflexive, exprs.enot(equal(a, b)), [proof, refuted]);
|
|
1152
1130
|
return makeCut(reflexive, swapped, refuted);
|
|
1153
1131
|
};
|
|
1154
|
-
// Zenon's make_direct_sym_eq: a = b / b = a / (proof).
|
|
1155
1132
|
const makeSymmetricEquality = (a: Expr, b: Expr, proof: MlProof) => {
|
|
1156
1133
|
const ab = equal(a, b);
|
|
1157
1134
|
return makeCut(equal(b, a), proof, makeSymmetricDisequality(b, a, makeClose(ab)));
|
|
@@ -1265,7 +1242,6 @@ export const translateProof = (
|
|
|
1265
1242
|
return [proof.subproofs[0], proof.subproofs[1], proof.subproofs[2]];
|
|
1266
1243
|
};
|
|
1267
1244
|
|
|
1268
|
-
// A derived rule's expansion, with the hypotheses it relies on that no phrase may state.
|
|
1269
1245
|
const translateWith = (expanded: MlProof, hypotheses: Expr[]): Translated => {
|
|
1270
1246
|
const translated = translate(expanded);
|
|
1271
1247
|
return [translated[0], union(hypotheses, translated[1])];
|
|
@@ -1295,7 +1271,8 @@ export const translateProof = (
|
|
|
1295
1271
|
}
|
|
1296
1272
|
case "close_sym": {
|
|
1297
1273
|
const hypothesis = getRelationHypothesis("symmetric", rule.relation);
|
|
1298
|
-
const
|
|
1274
|
+
const a = rule.args[0];
|
|
1275
|
+
const b = rule.args[1];
|
|
1299
1276
|
const ab = relate(rule.relation, a, b);
|
|
1300
1277
|
const ba = relate(rule.relation, b, a);
|
|
1301
1278
|
const implied = makeImply(ab, ba, makeClose(ab), makeClose(ba));
|
|
@@ -1310,7 +1287,8 @@ export const translateProof = (
|
|
|
1310
1287
|
}
|
|
1311
1288
|
case "refl": {
|
|
1312
1289
|
const hypothesis = getRelationHypothesis("reflexive", rule.relation);
|
|
1313
|
-
const
|
|
1290
|
+
const a = rule.args[0];
|
|
1291
|
+
const b = rule.args[1];
|
|
1314
1292
|
const reflexive = relate(rule.relation, a, a);
|
|
1315
1293
|
const negated = exprs.enot(relate(rule.relation, a, b));
|
|
1316
1294
|
const closed = makePNotP(reflexive, negated, [makeCloseRefl("=", a), getSingle(proof)]);
|
|
@@ -1325,7 +1303,8 @@ export const translateProof = (
|
|
|
1325
1303
|
return translate(makeSymmetricDisequality(negative.args[0], negative.args[1], node));
|
|
1326
1304
|
}
|
|
1327
1305
|
const hypothesis = getRelationHypothesis("symmetric", rule.relation);
|
|
1328
|
-
const
|
|
1306
|
+
const a = positive.args[0];
|
|
1307
|
+
const b = positive.args[1];
|
|
1329
1308
|
const ba = relate(rule.relation, b, a);
|
|
1330
1309
|
const node = makePNotP(ba, rule.args[1], [proof.subproofs[0], proof.subproofs[1]]);
|
|
1331
1310
|
const implied = makeImply(rule.args[0], ba, makeClose(rule.args[0]), node);
|
|
@@ -1335,8 +1314,11 @@ export const translateProof = (
|
|
|
1335
1314
|
case "trans_sym": {
|
|
1336
1315
|
const positive = getRelation(rule.args[0]);
|
|
1337
1316
|
const relation = positive.symbol;
|
|
1338
|
-
const
|
|
1339
|
-
const
|
|
1317
|
+
const a = positive.args[0];
|
|
1318
|
+
const b = positive.args[1];
|
|
1319
|
+
const negative = getRelation(rule.args[1]);
|
|
1320
|
+
const c = negative.args[0];
|
|
1321
|
+
const d = negative.args[1];
|
|
1340
1322
|
const first = proof.subproofs[0];
|
|
1341
1323
|
const second = proof.subproofs[1];
|
|
1342
1324
|
if (relation === "=")
|
|
@@ -1365,7 +1347,8 @@ export const translateProof = (
|
|
|
1365
1347
|
case "trans_eq_sym": {
|
|
1366
1348
|
const negative = getRelation(rule.args[2]);
|
|
1367
1349
|
const relation = negative.symbol;
|
|
1368
|
-
const
|
|
1350
|
+
const c = negative.args[0];
|
|
1351
|
+
const d = negative.args[1];
|
|
1369
1352
|
const a = rule.args[0];
|
|
1370
1353
|
const b = rule.args[1];
|
|
1371
1354
|
const proofs = getThree(proof);
|
|
@@ -1402,7 +1385,6 @@ export const translateProof = (
|
|
|
1402
1385
|
}
|
|
1403
1386
|
};
|
|
1404
1387
|
|
|
1405
|
-
// Zenon's make_ex.
|
|
1406
1388
|
const makeExistential = (existential: Expr, subproof: MlProof) => {
|
|
1407
1389
|
const binder = getBinder(existential, "ex");
|
|
1408
1390
|
const witness = exprs.etau(binder.args[0], binder.symbol, binder.args[1]);
|
|
@@ -1410,7 +1392,6 @@ export const translateProof = (
|
|
|
1410
1392
|
return makeNode([existential], { name: "ex", args: [existential] }, [[instance]], [subproof]);
|
|
1411
1393
|
};
|
|
1412
1394
|
|
|
1413
|
-
// Zenon's find_diff: the context in which two formulas differ, and the two subterms.
|
|
1414
1395
|
const findDiff = (variable: VarExpr, left: Expr, right: Expr): [Expr, Expr, Expr] => {
|
|
1415
1396
|
if (left === right) throw new TlaZenonError("Zenon: find_diff on equal formulas");
|
|
1416
1397
|
if (left.kind === "app" && right.kind === "app" && left.symbol === right.symbol) {
|
|
@@ -1452,7 +1433,6 @@ export const translateProof = (
|
|
|
1452
1433
|
return [variable, left, right];
|
|
1453
1434
|
};
|
|
1454
1435
|
|
|
1455
|
-
// Zenon's translate_pseudo_def: instantiates the defining hypothesis, then rewrites with it.
|
|
1456
1436
|
const translatePseudoDefinition = (
|
|
1457
1437
|
proof: MlProof,
|
|
1458
1438
|
definition: Extract<Definition, { kind: "pseudo" }>,
|
|
@@ -1535,8 +1515,6 @@ export const translateProof = (
|
|
|
1535
1515
|
const translated = translate(proof);
|
|
1536
1516
|
const isCharged = (formula: Expr) =>
|
|
1537
1517
|
!phrases.some((phrase) => phrase.kind === "hyp" && phrase.formula === formula);
|
|
1538
|
-
// Zenon's discharge_extra: cuts each hypothesis about a relation that the phrases don't state,
|
|
1539
|
-
// and proves it from the hypotheses that do.
|
|
1540
1518
|
const discharged = translated[1].filter(isCharged).reduce((current: LlProof, extra): LlProof => {
|
|
1541
1519
|
const relationProof = getRelationProof(extra);
|
|
1542
1520
|
const proved = translate(relationProof[0]);
|
package/src/prover/zenon/node.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
// Ported from Zenon's node.ml and heap.ml, as shipped in tlapm. Copyright 2001-2004 INRIA, see
|
|
2
|
-
// LICENSE.
|
|
3
|
-
//
|
|
4
|
-
// Tableau nodes and the queue that orders them. The search keeps the queue of every open branch,
|
|
5
|
-
// so the queue is persistent: inserting or removing returns a new queue and shares the rest.
|
|
1
|
+
// Ported from Zenon's node.ml and heap.ml, as shipped in tlapm. Copyright 2001-2004 INRIA, see LICENSE.
|
|
6
2
|
|
|
7
3
|
import type { Expr } from "./expr";
|
|
8
4
|
import type { Rule } from "./proof";
|
|
@@ -32,7 +28,6 @@ const reverse = <Item>(list: List<Item>) => {
|
|
|
32
28
|
return result;
|
|
33
29
|
};
|
|
34
30
|
|
|
35
|
-
// A node in the instance heap, with the size of the term that instantiates its formula.
|
|
36
31
|
interface Entry {
|
|
37
32
|
node: Node;
|
|
38
33
|
size: number;
|
|
@@ -44,7 +39,6 @@ interface Tree {
|
|
|
44
39
|
right: Tree | undefined;
|
|
45
40
|
}
|
|
46
41
|
|
|
47
|
-
// Zenon's Heap: a persistent binary heap that alternates insertion paths.
|
|
48
42
|
interface Heap {
|
|
49
43
|
tree: Tree | undefined;
|
|
50
44
|
path: number;
|
|
@@ -101,8 +95,6 @@ export interface Queue {
|
|
|
101
95
|
instSize: List<[number, Heap]>;
|
|
102
96
|
instFront: List<Node>;
|
|
103
97
|
instBack: List<Node>;
|
|
104
|
-
// The nodes inserted since the root. Removed nodes still count, because the queues of the
|
|
105
|
-
// branches above keep them.
|
|
106
98
|
insertedCount: number;
|
|
107
99
|
}
|
|
108
100
|
|
|
@@ -212,8 +204,6 @@ const removeAt = (
|
|
|
212
204
|
return [removed[0], cons([list.head[0], removed[1]], list.tail)];
|
|
213
205
|
};
|
|
214
206
|
|
|
215
|
-
// On even states, the smallest instance of the most goal-directed formulas; on odd states, the
|
|
216
|
-
// smallest instance overall.
|
|
217
207
|
const removeByGoalness = (state: number, list: List<[number, Heap]>) => {
|
|
218
208
|
if (state % 2 === 0) return removeAt(0, list);
|
|
219
209
|
let best = 0;
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
// The parts of OCaml's standard library whose exact behavior steers Zenon's search.
|
|
2
|
-
//
|
|
3
|
-
// Hashtbl.hash on the values Zenon hashes: strings, and the (int, string list) pairs that Expr
|
|
4
|
-
// hashes. Zenon orders record fields by these hashes. Ints are 63-bit in OCaml, so an int is a
|
|
5
|
-
// high part in [-2^30, 2^30) and a low part in [0, 2^32).
|
|
6
|
-
|
|
7
1
|
const TWO_32 = 4294967296;
|
|
8
2
|
const TWO_31 = 2147483648;
|
|
9
3
|
const TWO_30 = 1073741824;
|
|
10
4
|
|
|
11
|
-
// A block's header with its color bits cleared: two fields and tag 0, for a pair or a list cell.
|
|
12
5
|
const PAIR_HEADER = 0x800;
|
|
13
6
|
|
|
14
7
|
const MEANINGFUL_LIMIT = 10;
|
|
@@ -28,8 +21,6 @@ const finalMix = (hash: number) => {
|
|
|
28
21
|
return ((second ^ (second >>> 16)) >>> 0) & 0x3fffffff;
|
|
29
22
|
};
|
|
30
23
|
|
|
31
|
-
// A string's UTF-8 bytes as the little-endian words that caml_hash_mix_string mixes, the last one
|
|
32
|
-
// partial.
|
|
33
24
|
interface StringWords {
|
|
34
25
|
words: number[];
|
|
35
26
|
length: number;
|
|
@@ -54,15 +45,12 @@ const mixWords = (hash: number, encoded: StringWords) => {
|
|
|
54
45
|
return mixed ^ encoded.length;
|
|
55
46
|
};
|
|
56
47
|
|
|
57
|
-
// caml_hash_mix_intnat on the tagged value 2n + 1 of the int n.
|
|
58
48
|
const mixInt = (hash: number, high: number, low: number) => {
|
|
59
49
|
const taggedLow = (low * 2 + 1) % TWO_32;
|
|
60
50
|
const taggedHigh = high * 2 + Math.floor((low * 2 + 1) / TWO_32);
|
|
61
51
|
return mix(hash, (taggedHigh ^ (taggedHigh < 0 ? -1 : 0) ^ taggedLow) | 0);
|
|
62
52
|
};
|
|
63
53
|
|
|
64
|
-
// Hashtbl.hash on strings and on (int, string list) pairs. It keeps each string's words and hash,
|
|
65
|
-
// because Zenon hashes the same variable names over and over.
|
|
66
54
|
export const createHasher = () => {
|
|
67
55
|
const stringWords = new Map<string, StringWords>();
|
|
68
56
|
const stringHashes = new Map<string, number>();
|
|
@@ -103,7 +91,6 @@ export interface Int63 {
|
|
|
103
91
|
low: number;
|
|
104
92
|
}
|
|
105
93
|
|
|
106
|
-
// Expr's combine: x + y * 131 + 1, wrapping like OCaml's 63-bit ints.
|
|
107
94
|
export const combine = (left: Int63, right: Int63): Int63 => {
|
|
108
95
|
const product = right.low * 131;
|
|
109
96
|
const productCarry = Math.floor(product / TWO_32);
|
|
@@ -117,8 +104,6 @@ export const combine = (left: Int63, right: Int63): Int63 => {
|
|
|
117
104
|
|
|
118
105
|
export const toInt63 = (value: number): Int63 => ({ high: 0, low: value });
|
|
119
106
|
|
|
120
|
-
// The merges of OCaml's List.stable_sort, on arrays. Each returns its result reversed, as OCaml's
|
|
121
|
-
// rev_merge and rev_merge_rev do.
|
|
122
107
|
const mergeReversed = <Item>(
|
|
123
108
|
first: Item[],
|
|
124
109
|
second: Item[],
|
|
@@ -136,8 +121,7 @@ const mergeReversed = <Item>(
|
|
|
136
121
|
return merged.reverse();
|
|
137
122
|
};
|
|
138
123
|
|
|
139
|
-
// OCaml's List.sort, step for step, so that a comparison that isn't a total order still gives
|
|
140
|
-
// Zenon's result.
|
|
124
|
+
// OCaml's List.sort, step for step, so that a comparison that isn't a total order still gives Zenon's result.
|
|
141
125
|
export const stableSort = <Item>(items: Item[], compare: (left: Item, right: Item) => number) => {
|
|
142
126
|
const sortRun = (count: number, start: number, isReversed: boolean): Item[] => {
|
|
143
127
|
const isBefore = (left: Item, right: Item) =>
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
// Ported from Zenon's lexzen.mll and parsezen.mly, as shipped in tlapm. Copyright 2005 INRIA, see
|
|
2
|
-
// LICENSE.
|
|
3
|
-
//
|
|
4
|
-
// Reads Zenon's native input format, the .znn files that tlapm writes.
|
|
1
|
+
// Ported from Zenon's lexzen.mll and parsezen.mly, as shipped in tlapm. Copyright 2005 INRIA, see LICENSE.
|
|
5
2
|
|
|
6
3
|
import { TlaZenonError } from "../../errors";
|
|
7
4
|
import {
|
|
@@ -109,7 +106,6 @@ const tokenize = (text: string) => {
|
|
|
109
106
|
return tokens;
|
|
110
107
|
};
|
|
111
108
|
|
|
112
|
-
// Zenon's myfold: an n-ary connective nests to the right.
|
|
113
109
|
const foldRight = (combine: (left: Expr, right: Expr) => Expr, first: Expr, rest: Expr[]): Expr =>
|
|
114
110
|
rest.length === 0 ? first : combine(first, foldRight(combine, rest[0], rest.slice(1)));
|
|
115
111
|
|
|
@@ -127,7 +123,7 @@ export const parseZenon = (exprs: Expressions, text: string): Phrase[] => {
|
|
|
127
123
|
};
|
|
128
124
|
const tokens = tokenize(text);
|
|
129
125
|
let position = 0;
|
|
130
|
-
const peek = (
|
|
126
|
+
const peek = () => tokens[position];
|
|
131
127
|
const next = () => tokens[position++];
|
|
132
128
|
const expect = (kind: TokenKind, value?: string) => {
|
|
133
129
|
const token = next();
|
|
@@ -138,7 +134,6 @@ export const parseZenon = (exprs: Expressions, text: string): Phrase[] => {
|
|
|
138
134
|
const isAt = (kind: TokenKind, value?: string) =>
|
|
139
135
|
peek().kind === kind && (value === undefined || peek().text === value);
|
|
140
136
|
|
|
141
|
-
// A lambda after its first parenthesis: ((x y "type") body).
|
|
142
137
|
const parseLambda = () => {
|
|
143
138
|
expect("open");
|
|
144
139
|
const names: string[] = [];
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
// Ported from Zenon's phrase.ml, as shipped in tlapm. Copyright 2004 INRIA, see LICENSE.
|
|
2
|
-
//
|
|
3
|
-
// Splits the input into definitions and hypotheses. A hypothesis that defines a symbol, such as
|
|
4
|
-
// x = e or \A a, b : f(a, b) <=> e, becomes a definition that the prover unfolds.
|
|
5
2
|
|
|
6
3
|
import type { Expr } from "./expr";
|
|
7
4
|
import type { Definition, Phrase } from "./parse";
|
|
@@ -13,7 +10,6 @@ export interface Hypothesis {
|
|
|
13
10
|
|
|
14
11
|
const hasName = (env: Expr[], name: string) => env.some((variable) => variable.symbol === name);
|
|
15
12
|
|
|
16
|
-
// Zenon's check_args: the arguments are variables, and exactly the quantified ones.
|
|
17
13
|
const isParameterList = (env: Expr[], args: Expr[]) => {
|
|
18
14
|
if (!args.every((arg) => arg.kind === "var")) return false;
|
|
19
15
|
const envNames = env.map((variable) => variable.symbol).sort();
|
|
@@ -50,8 +46,6 @@ interface Shape {
|
|
|
50
46
|
body: Expr;
|
|
51
47
|
}
|
|
52
48
|
|
|
53
|
-
// The ways a formula can define a symbol, in the order Zenon tries them: a definiendum that is an
|
|
54
|
-
// application with its parameters, or a constant.
|
|
55
49
|
const getShapes = (expression: Expr): Shape[] => {
|
|
56
50
|
const sides =
|
|
57
51
|
expression.kind === "equiv" || (expression.kind === "app" && expression.symbol === "=")
|
|
@@ -79,8 +73,7 @@ const stripForall = (expression: Expr, env: Expr[]): { env: Expr[]; body: Expr }
|
|
|
79
73
|
? stripForall(expression.args[1], [expression.args[0], ...env])
|
|
80
74
|
: { env, body: expression };
|
|
81
75
|
|
|
82
|
-
// Zenon's is_def
|
|
83
|
-
// that defines the symbol can differ from the one that qualifies the formula.
|
|
76
|
+
// Zenon's is_def and make_def try the shapes with different conditions, so the defining shape can differ from the qualifying one.
|
|
84
77
|
const getDefinition = (
|
|
85
78
|
predefined: string[],
|
|
86
79
|
hypothesis: Hypothesis,
|
|
@@ -145,8 +138,6 @@ const isLooping = (symbol: string, symbols: string[], dependencies: Dependency[]
|
|
|
145
138
|
(symbols.includes(symbol) ||
|
|
146
139
|
isLooping(symbol, followDependencies(symbols, dependencies), dependencies));
|
|
147
140
|
|
|
148
|
-
// Zenon's separate. Definitions come before hypotheses, each in input order, except where a
|
|
149
|
-
// symbol is defined twice: then neither formula defines it.
|
|
150
141
|
export const separate = (predefined: string[], phrases: Phrase[]) => {
|
|
151
142
|
let dependencies: Dependency[] = [];
|
|
152
143
|
const multiple: string[] = [];
|
|
@@ -165,7 +156,6 @@ export const separate = (predefined: string[], phrases: Phrase[]) => {
|
|
|
165
156
|
}
|
|
166
157
|
const symbol = definition.symbol;
|
|
167
158
|
const dependency: Dependency = [symbol, getFreeSymbols(definition.params, [], definition.body)];
|
|
168
|
-
// The lists are reversed, as in Zenon, so a definition's index 0 is the latest.
|
|
169
159
|
const previous = definitions.findIndex(
|
|
170
160
|
(existing) => existing.kind === "pseudo" && existing.symbol === symbol,
|
|
171
161
|
);
|