tla-ts 0.0.9 → 0.0.10-dev.06b481ee0
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 +30 -1
- package/dist/compile.cjs +23 -0
- package/dist/compile.js +23 -0
- package/dist/deciders.cjs +41 -37
- package/dist/deciders.js +48 -44
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +122 -12
- package/dist/index.d.ts +122 -12
- 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 +2746 -410
- package/dist/prove.js +2745 -409
- package/dist/run.cjs +144 -31
- package/dist/run.js +144 -31
- package/dist/tlapm.cjs +2 -2
- package/dist/tlapm.js +2 -2
- package/dist/transfer.cjs +134 -104
- package/dist/transfer.js +134 -104
- package/dist/worker.cjs +7 -7
- package/dist/worker.js +7 -7
- package/package.json +3 -1
- package/src/ast.ts +56 -60
- package/src/bags.ts +128 -110
- package/src/builtins.ts +31 -77
- package/src/bundled-modules.ts +1 -8
- package/src/check-failure.ts +118 -0
- package/src/check-trace.ts +320 -0
- package/src/check.ts +1156 -888
- package/src/cli/options.ts +12 -32
- package/src/cli/run.ts +0 -2
- package/src/cli/runtime-invariants.ts +100 -0
- package/src/cli/shared.ts +19 -12
- package/src/cli/tlapm.ts +433 -82
- package/src/cli/tlc-arguments.ts +652 -0
- package/src/cli/tlc-output.ts +701 -0
- package/src/cli/tlc-usage.ts +360 -0
- package/src/cli/tlc.ts +330 -659
- 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 +217 -82
- package/src/config.ts +140 -109
- package/src/coverage.ts +1019 -0
- package/src/dependencies.ts +101 -66
- package/src/dfid.ts +683 -0
- package/src/environment-config.ts +315 -0
- package/src/environment.ts +263 -370
- package/src/errors.ts +107 -57
- package/src/evaluate.ts +898 -369
- package/src/exit-codes.ts +63 -13
- package/src/fingerprints.ts +75 -11
- package/src/index.ts +3 -0
- package/src/instances.ts +137 -22
- package/src/java-hash.ts +21 -0
- package/src/java-overrides.ts +6 -21
- package/src/json-reader.ts +455 -0
- package/src/json.ts +252 -139
- package/src/levels.ts +231 -154
- package/src/lexer.ts +83 -101
- package/src/liveness-checker.ts +743 -322
- package/src/liveness.ts +230 -133
- package/src/obligations/action.ts +17 -44
- package/src/obligations/anonymize.ts +120 -95
- package/src/obligations/enabled-axioms.ts +218 -0
- package/src/obligations/equality.ts +1 -3
- package/src/obligations/expression.ts +37 -26
- package/src/obligations/format.ts +0 -10
- package/src/obligations/generate.ts +66 -64
- package/src/obligations/index.ts +39 -20
- package/src/obligations/levels.ts +27 -18
- package/src/obligations/module.ts +28 -55
- package/src/obligations/normalize.ts +31 -41
- package/src/obligations/operators.ts +0 -3
- package/src/obligations/pragma.ts +52 -24
- package/src/obligations/printer.ts +94 -63
- package/src/obligations/proof.ts +3 -6
- package/src/obligations/regroup.ts +0 -5
- package/src/obligations/simplify.ts +57 -63
- package/src/obligations/source.ts +121 -95
- package/src/obligations/subexpression.ts +49 -28
- package/src/obligations/substitution.ts +1 -5
- package/src/obligations/temporal.ts +12 -20
- package/src/obligations/tuples.ts +2 -10
- package/src/parallel-worker.ts +36 -60
- package/src/parallel.ts +64 -73
- package/src/parser.ts +1184 -531
- 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 +12 -13
- package/src/prover/first-order.ts +0 -11
- package/src/prover/isabelle/decide.ts +3 -31
- package/src/prover/isabelle/encode.ts +82 -64
- package/src/prover/isabelle/isar/attrib.ts +250 -0
- package/src/prover/isabelle/isar/context.ts +335 -0
- package/src/prover/isabelle/isar/induct.ts +382 -0
- package/src/prover/isabelle/isar/inner-syntax.ts +262 -117
- package/src/prover/isabelle/isar/method.ts +510 -226
- package/src/prover/isabelle/isar/proof.ts +570 -23
- package/src/prover/isabelle/isar/rule-cases.ts +226 -0
- package/src/prover/isabelle/isar/theory.ts +488 -88
- package/src/prover/isabelle/isar/toplevel.ts +331 -0
- package/src/prover/isabelle/isar/type-check.ts +99 -38
- package/src/prover/isabelle/provers/blast/blast.ts +16 -105
- package/src/prover/isabelle/provers/blast/branch.ts +0 -33
- package/src/prover/isabelle/provers/blast/prove.ts +0 -36
- package/src/prover/isabelle/provers/blast/rules.ts +5 -45
- package/src/prover/isabelle/provers/blast/state.ts +1 -29
- package/src/prover/isabelle/provers/blast/term.ts +8 -37
- package/src/prover/isabelle/provers/clasimp.ts +1 -15
- package/src/prover/isabelle/provers/classical.ts +58 -61
- package/src/prover/isabelle/provers/hypsubst.ts +29 -54
- package/src/prover/isabelle/pure/bicompose.ts +24 -39
- package/src/prover/isabelle/pure/consts.ts +0 -8
- package/src/prover/isabelle/pure/conv.ts +2 -18
- package/src/prover/isabelle/pure/drule.ts +95 -45
- package/src/prover/isabelle/pure/envir.ts +2 -53
- package/src/prover/isabelle/pure/goal.ts +1 -9
- 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 -16
- package/src/prover/isabelle/pure/name.ts +1 -10
- package/src/prover/isabelle/pure/net.ts +2 -60
- package/src/prover/isabelle/pure/object-logic.ts +15 -16
- package/src/prover/isabelle/pure/pattern.ts +1 -20
- package/src/prover/isabelle/pure/raw-simplifier.ts +16 -63
- package/src/prover/isabelle/pure/rewriter.ts +34 -77
- package/src/prover/isabelle/pure/search.ts +2 -11
- package/src/prover/isabelle/pure/seq.ts +0 -11
- package/src/prover/isabelle/pure/simplifier.ts +27 -16
- package/src/prover/isabelle/pure/table.ts +2 -33
- package/src/prover/isabelle/pure/tactic.ts +11 -23
- package/src/prover/isabelle/pure/tactical.ts +47 -48
- package/src/prover/isabelle/pure/term-ord.ts +1 -7
- package/src/prover/isabelle/pure/term.ts +4 -47
- package/src/prover/isabelle/pure/thm.ts +26 -48
- package/src/prover/isabelle/pure/type.ts +1 -16
- package/src/prover/isabelle/pure/unify.ts +19 -31
- package/src/prover/isabelle/pure/variable.ts +2 -8
- package/src/prover/isabelle/tla/classical-setup.ts +17 -25
- package/src/prover/isabelle/tla/context.ts +65 -26
- package/src/prover/isabelle/tla/logic-data.ts +1 -1
- package/src/prover/isabelle/tla/logic.ts +53 -32
- package/src/prover/isabelle/tla/simpdata.ts +45 -44
- package/src/prover/isabelle/tools/intuitionistic.ts +28 -21
- package/src/prover/ocaml.ts +4 -7
- package/src/prover/prep/action.ts +33 -66
- package/src/prover/prep/enabled-axioms.ts +22 -20
- package/src/prover/prep/fingerprint.ts +2 -21
- package/src/prover/prep/level-comparison.ts +8 -12
- package/src/prover/prep/md5.ts +26 -31
- package/src/prover/prep/methods.ts +189 -86
- package/src/prover/prep/normalize.ts +42 -37
- package/src/prover/prove-worker.ts +0 -2
- package/src/prover/prove.ts +398 -133
- package/src/prover/ptl/decide.ts +96 -56
- package/src/prover/ptl/encode.ts +15 -38
- package/src/prover/ptl/sat.ts +24 -32
- package/src/prover/ptl/tableau.ts +40 -28
- package/src/prover/smt/arithmetic.ts +310 -0
- package/src/prover/smt/axioms.ts +12 -15
- package/src/prover/smt/context.ts +60 -32
- package/src/prover/smt/data.ts +517 -401
- package/src/prover/smt/encode.ts +155 -85
- package/src/prover/smt/extensionality.ts +5 -13
- package/src/prover/smt/flatten.ts +7 -28
- package/src/prover/smt/format.ts +33 -14
- package/src/prover/smt/instances.ts +7 -11
- package/src/prover/smt/layout.ts +91 -0
- package/src/prover/smt/rewrite.ts +1021 -658
- package/src/prover/smt/simplify.ts +441 -0
- package/src/prover/smt/solver/ackermannize-bv-tactic.ts +61 -0
- package/src/prover/smt/solver/ackr-helper.ts +179 -0
- package/src/prover/smt/solver/ackr-model-converter.ts +105 -0
- package/src/prover/smt/solver/act-cache.ts +0 -16
- package/src/prover/smt/solver/add-bounds-tactic.ts +59 -0
- package/src/prover/smt/solver/aig-tactic.ts +52 -0
- package/src/prover/smt/solver/aig.ts +889 -0
- package/src/prover/smt/solver/arith-rewriter.ts +626 -56
- package/src/prover/smt/solver/arith-terms.ts +121 -0
- package/src/prover/smt/solver/array-decl-plugin.ts +175 -0
- package/src/prover/smt/solver/array-rewriter.ts +319 -0
- package/src/prover/smt/solver/array.ts +1 -3
- package/src/prover/smt/solver/asserted-formulas.ts +241 -99
- package/src/prover/smt/solver/ast-lt.ts +165 -21
- package/src/prover/smt/solver/ast-util.ts +160 -7
- package/src/prover/smt/solver/ast.ts +1480 -184
- package/src/prover/smt/solver/auf-solver.ts +30 -56
- package/src/prover/smt/solver/bit-blast-tactic.ts +608 -0
- package/src/prover/smt/solver/bit-blaster.ts +871 -0
- package/src/prover/smt/solver/blast-term-ite.ts +47 -0
- package/src/prover/smt/solver/bound-manager.ts +196 -0
- package/src/prover/smt/solver/bound-simplifier.ts +598 -0
- package/src/prover/smt/solver/bv-bound-chk.ts +492 -0
- package/src/prover/smt/solver/bv-decl-plugin.ts +341 -0
- package/src/prover/smt/solver/bv-divrem-bounds.ts +95 -0
- package/src/prover/smt/solver/bv-rewriter.ts +1901 -0
- package/src/prover/smt/solver/bv1-blast.ts +214 -0
- package/src/prover/smt/solver/bv2fpa-converter.ts +174 -0
- package/src/prover/smt/solver/bv2int-rewriter.ts +544 -0
- package/src/prover/smt/solver/bv2real-rewriter.ts +533 -0
- package/src/prover/smt/solver/card2bv.ts +127 -0
- package/src/prover/smt/solver/case-split-queue.ts +0 -10
- package/src/prover/smt/solver/cg-table.ts +39 -42
- package/src/prover/smt/solver/check-logic.ts +330 -0
- package/src/prover/smt/solver/clause.ts +0 -27
- package/src/prover/smt/solver/cofactor-elim-term-ite.ts +293 -0
- package/src/prover/smt/solver/conflict-resolution.ts +78 -11
- package/src/prover/smt/solver/context.ts +600 -187
- package/src/prover/smt/solver/ctx-simplify.ts +34 -52
- package/src/prover/smt/solver/ctx-solver-simplify.ts +122 -0
- package/src/prover/smt/solver/datatype-decl-plugin.ts +580 -0
- package/src/prover/smt/solver/datatype-rewriter.ts +82 -0
- package/src/prover/smt/solver/demodulator.ts +786 -0
- package/src/prover/smt/solver/dependent-expr-state.ts +93 -0
- package/src/prover/smt/solver/der.ts +39 -30
- package/src/prover/smt/solver/diff-neq.ts +205 -0
- package/src/prover/smt/solver/distribute-forall.ts +57 -0
- package/src/prover/smt/solver/dom-simplify.ts +511 -0
- package/src/prover/smt/solver/dt2bv-tactic.ts +296 -0
- package/src/prover/smt/solver/dyn-ack.ts +0 -11
- package/src/prover/smt/solver/e-matching.ts +9 -41
- package/src/prover/smt/solver/elim-bounds.ts +89 -0
- package/src/prover/smt/solver/elim-small-bv-tactic.ts +129 -0
- package/src/prover/smt/solver/elim-term-ite-tactic.ts +48 -0
- package/src/prover/smt/solver/elim-uncnstr.ts +542 -0
- package/src/prover/smt/solver/enode.ts +100 -23
- package/src/prover/smt/solver/eq2bv-tactic.ts +218 -0
- package/src/prover/smt/solver/euf/arith-axioms.ts +403 -0
- package/src/prover/smt/solver/euf/arith-internalize.ts +653 -0
- package/src/prover/smt/solver/euf/arith-solver.ts +889 -0
- package/src/prover/smt/solver/euf/array-axioms.ts +527 -0
- package/src/prover/smt/solver/euf/array-internalize.ts +428 -0
- package/src/prover/smt/solver/euf/array-solver.ts +306 -0
- package/src/prover/smt/solver/euf/bv-ackerman.ts +162 -0
- package/src/prover/smt/solver/euf/bv-internalize.ts +748 -0
- package/src/prover/smt/solver/euf/bv-solver.ts +449 -0
- package/src/prover/smt/solver/euf/dt-solver.ts +618 -0
- package/src/prover/smt/solver/euf/egraph.ts +901 -0
- package/src/prover/smt/solver/euf/euf-solver.ts +1204 -0
- package/src/prover/smt/solver/euf/fpa-solver.ts +317 -0
- package/src/prover/smt/solver/euf/mam.ts +1046 -0
- package/src/prover/smt/solver/euf/q-ematch.ts +829 -0
- package/src/prover/smt/solver/euf/q-mbi.ts +587 -0
- package/src/prover/smt/solver/euf/q-model-fixer.ts +296 -0
- package/src/prover/smt/solver/euf/q-solver.ts +361 -0
- package/src/prover/smt/solver/euf/th-solver.ts +328 -0
- package/src/prover/smt/solver/euf/th-solvers.ts +30 -0
- package/src/prover/smt/solver/expr-ref.ts +0 -5
- package/src/prover/smt/solver/expr-safe-replace.ts +26 -7
- package/src/prover/smt/solver/expr2polynomial.ts +271 -0
- package/src/prover/smt/solver/factor.ts +163 -0
- package/src/prover/smt/solver/fd-solver.ts +734 -0
- package/src/prover/smt/solver/fingerprints.ts +15 -26
- package/src/prover/smt/solver/fix-dl-var.ts +147 -0
- package/src/prover/smt/solver/flat-literals.ts +0 -9
- package/src/prover/smt/solver/fm-tactic.ts +884 -0
- package/src/prover/smt/solver/fpa-decl-plugin.ts +618 -0
- package/src/prover/smt/solver/fpa-rewriter.ts +639 -0
- package/src/prover/smt/solver/fpa2bv-converter.ts +2251 -0
- package/src/prover/smt/solver/fpa2bv-rewriter.ts +349 -0
- package/src/prover/smt/solver/fpa2bv-tactic.ts +73 -0
- package/src/prover/smt/solver/goal.ts +179 -28
- package/src/prover/smt/solver/goal2nlsat.ts +216 -0
- package/src/prover/smt/solver/guard-set.ts +219 -0
- package/src/prover/smt/solver/hash.ts +0 -9
- package/src/prover/smt/solver/hashtable.ts +30 -23
- package/src/prover/smt/solver/inf-eps.ts +63 -0
- package/src/prover/smt/solver/inj-axiom.ts +101 -0
- package/src/prover/smt/solver/internalizer.ts +113 -133
- package/src/prover/smt/solver/lackr.ts +381 -0
- package/src/prover/smt/solver/lbool.ts +0 -2
- package/src/prover/smt/solver/lia2card.ts +268 -0
- package/src/prover/smt/solver/lia2pb.ts +154 -0
- package/src/prover/smt/solver/literal.ts +0 -4
- package/src/prover/smt/solver/logic-tactics.ts +355 -0
- package/src/prover/smt/solver/lp/bound-propagator.ts +7 -26
- package/src/prover/smt/solver/lp/constraints.ts +1 -8
- package/src/prover/smt/solver/lp/containers.ts +18 -31
- package/src/prover/smt/solver/lp/core-solver.ts +35 -37
- package/src/prover/smt/solver/lp/cross-nested.ts +4 -21
- package/src/prover/smt/solver/lp/dep-intervals.ts +6 -24
- package/src/prover/smt/solver/lp/dependency.ts +0 -5
- package/src/prover/smt/solver/lp/dioph-eq.ts +8 -103
- package/src/prover/smt/solver/lp/explanation.ts +0 -6
- package/src/prover/smt/solver/lp/gomory.ts +8 -22
- package/src/prover/smt/solver/lp/hnf-cutter.ts +16 -23
- package/src/prover/smt/solver/lp/hnf.ts +10 -28
- package/src/prover/smt/solver/lp/int-cube.ts +17 -39
- package/src/prover/smt/solver/lp/int-solver.ts +3 -35
- package/src/prover/smt/solver/lp/lar-solver.ts +70 -83
- package/src/prover/smt/solver/lp/lar-term.ts +0 -5
- package/src/prover/smt/solver/lp/lp-settings.ts +6 -16
- package/src/prover/smt/solver/lp/maximize-term.ts +76 -52
- package/src/prover/smt/solver/lp/nex-creator.ts +7 -30
- package/src/prover/smt/solver/lp/nex.ts +2 -7
- package/src/prover/smt/solver/lp/nla-backoff.ts +0 -5
- package/src/prover/smt/solver/lp/nla-basics.ts +48 -30
- package/src/prover/smt/solver/lp/nla-core.ts +92 -136
- package/src/prover/smt/solver/lp/nla-divisions.ts +31 -43
- package/src/prover/smt/solver/lp/nla-emonics.ts +3 -21
- package/src/prover/smt/solver/lp/nla-factorization.ts +0 -4
- package/src/prover/smt/solver/lp/nla-grobner.ts +177 -149
- package/src/prover/smt/solver/lp/nla-horner.ts +2 -12
- package/src/prover/smt/solver/lp/nla-intervals.ts +1 -12
- package/src/prover/smt/solver/lp/nla-monomial-bounds.ts +15 -42
- package/src/prover/smt/solver/lp/nla-monotone.ts +1 -6
- package/src/prover/smt/solver/lp/nla-order.ts +0 -13
- package/src/prover/smt/solver/lp/nla-patcher.ts +3 -7
- package/src/prover/smt/solver/lp/nla-powers.ts +220 -0
- package/src/prover/smt/solver/lp/nla-tangents.ts +0 -10
- package/src/prover/smt/solver/lp/nla-throttle.ts +0 -6
- package/src/prover/smt/solver/lp/nla-transcendentals.ts +324 -0
- package/src/prover/smt/solver/lp/nla-types.ts +0 -12
- package/src/prover/smt/solver/lp/nla-var-eqs.ts +4 -26
- package/src/prover/smt/solver/lp/nra-solver.ts +164 -147
- package/src/prover/smt/solver/lp/numeric-pair.ts +0 -4
- package/src/prover/smt/solver/lp/pdd-interval.ts +6 -5
- package/src/prover/smt/solver/lp/pdd-simplifier.ts +61 -34
- package/src/prover/smt/solver/lp/pdd-solver.ts +74 -72
- package/src/prover/smt/solver/lp/pdd.ts +730 -358
- package/src/prover/smt/solver/lp/random-updater.ts +0 -9
- package/src/prover/smt/solver/lp/static-matrix.ts +8 -19
- package/src/prover/smt/solver/lp/union-find.ts +5 -5
- package/src/prover/smt/solver/macro-finder.ts +530 -0
- package/src/prover/smt/solver/mam-compiler.ts +129 -139
- package/src/prover/smt/solver/mam-interpreter.ts +0 -21
- package/src/prover/smt/solver/max-bv-sharing-tactic.ts +17 -0
- package/src/prover/smt/solver/max-cliques.ts +105 -0
- package/src/prover/smt/solver/maxcore.ts +310 -0
- package/src/prover/smt/solver/maximize-ac-sharing.ts +8 -21
- package/src/prover/smt/solver/maxlex.ts +115 -0
- package/src/prover/smt/solver/maxsmt-base.ts +106 -0
- package/src/prover/smt/solver/maxsmt.ts +92 -0
- package/src/prover/smt/solver/mbp/mbp-arith.ts +467 -0
- package/src/prover/smt/solver/mbp/mbp-basic-tg.ts +101 -0
- package/src/prover/smt/solver/mbp/mbp-plugin.ts +287 -0
- package/src/prover/smt/solver/mbp/mbp-qel.ts +48 -0
- package/src/prover/smt/solver/mbp/mbp-solve-plugin.ts +271 -0
- package/src/prover/smt/solver/mbp/mbp-term-graph.ts +606 -0
- package/src/prover/smt/solver/model-based-opt.ts +844 -0
- package/src/prover/smt/solver/model-checker.ts +20 -63
- package/src/prover/smt/solver/model-evaluator.ts +192 -40
- package/src/prover/smt/solver/model-finder.ts +14 -32
- package/src/prover/smt/solver/model-generator.ts +104 -46
- package/src/prover/smt/solver/model-macro-solver.ts +60 -114
- package/src/prover/smt/solver/model-printer.ts +214 -0
- package/src/prover/smt/solver/mpf.ts +709 -0
- package/src/prover/smt/solver/mus.ts +50 -0
- package/src/prover/smt/solver/muz/dl-context.ts +382 -0
- package/src/prover/smt/solver/muz/dl-mk-bit-blast.ts +97 -0
- package/src/prover/smt/solver/muz/dl-mk-coi-filter.ts +167 -0
- package/src/prover/smt/solver/muz/dl-mk-elim-term-ite.ts +125 -0
- package/src/prover/smt/solver/muz/dl-mk-interp-tail-simplifier.ts +299 -0
- package/src/prover/smt/solver/muz/dl-mk-rule-inliner.ts +455 -0
- package/src/prover/smt/solver/muz/dl-mk-slice.ts +340 -0
- package/src/prover/smt/solver/muz/dl-mk-subsumption-checker.ts +163 -0
- package/src/prover/smt/solver/muz/dl-rule-set.ts +273 -0
- package/src/prover/smt/solver/muz/dl-rule-transformer.ts +123 -0
- package/src/prover/smt/solver/muz/dl-rule.ts +495 -0
- package/src/prover/smt/solver/muz/hnf.ts +201 -0
- package/src/prover/smt/solver/muz/horn-subsume-model-converter.ts +176 -0
- package/src/prover/smt/solver/muz/horn-tactic.ts +214 -0
- package/src/prover/smt/solver/muz/rule-properties.ts +359 -0
- package/src/prover/smt/solver/muz/spacer-context.ts +1404 -0
- package/src/prover/smt/solver/muz/spacer-dl-interface.ts +52 -0
- package/src/prover/smt/solver/muz/spacer-generalizers.ts +241 -0
- package/src/prover/smt/solver/muz/spacer-manager.ts +127 -0
- package/src/prover/smt/solver/muz/spacer-pdr.ts +219 -0
- package/src/prover/smt/solver/muz/spacer-prop-solver.ts +333 -0
- package/src/prover/smt/solver/muz/spacer-util.ts +282 -0
- package/src/prover/smt/solver/muz/substitution.ts +203 -0
- package/src/prover/smt/solver/nla2bv-tactic.ts +285 -0
- package/src/prover/smt/solver/nlqsat.ts +484 -0
- package/src/prover/smt/solver/nlsat/algebraic.ts +357 -236
- package/src/prover/smt/solver/nlsat/atoms.ts +73 -54
- package/src/prover/smt/solver/nlsat/evaluator.ts +16 -22
- package/src/prover/smt/solver/nlsat/explain.ts +429 -275
- package/src/prover/smt/solver/nlsat/interval-set.ts +9 -51
- package/src/prover/smt/solver/nlsat/levelwise.ts +477 -344
- package/src/prover/smt/solver/nlsat/mpbq.ts +47 -14
- package/src/prover/smt/solver/nlsat/polynomial.ts +2385 -832
- package/src/prover/smt/solver/nlsat/solver.ts +297 -156
- package/src/prover/smt/solver/nlsat/transcendental-eval.ts +310 -0
- package/src/prover/smt/solver/nlsat/transcendentals.ts +391 -0
- package/src/prover/smt/solver/nlsat/types.ts +0 -9
- package/src/prover/smt/solver/nlsat/upolynomial-factorization.ts +9 -51
- package/src/prover/smt/solver/nlsat/upolynomial.ts +49 -109
- package/src/prover/smt/solver/nlsat-tactic.ts +82 -0
- package/src/prover/smt/solver/nnf.ts +112 -61
- package/src/prover/smt/solver/normalize-bounds.ts +53 -0
- package/src/prover/smt/solver/occf.ts +97 -0
- package/src/prover/smt/solver/opt-context.ts +801 -0
- package/src/prover/smt/solver/opt-nlsat.ts +386 -0
- package/src/prover/smt/solver/opt-pareto.ts +301 -0
- package/src/prover/smt/solver/opt-preprocess.ts +101 -0
- package/src/prover/smt/solver/opt-solver.ts +312 -0
- package/src/prover/smt/solver/opt-value.ts +55 -0
- package/src/prover/smt/solver/optsmt.ts +692 -0
- package/src/prover/smt/solver/parallel-tactic.ts +299 -0
- package/src/prover/smt/solver/pattern-inference.ts +21 -26
- package/src/prover/smt/solver/pb-rewriter.ts +281 -0
- package/src/prover/smt/solver/pb2bv-tactic.ts +540 -0
- package/src/prover/smt/solver/poly-rewriter.ts +261 -79
- package/src/prover/smt/solver/probes.ts +577 -0
- package/src/prover/smt/solver/propagate-values.ts +37 -30
- package/src/prover/smt/solver/proto-model.ts +650 -66
- package/src/prover/smt/solver/pull-quant.ts +28 -23
- package/src/prover/smt/solver/purify-arith.ts +632 -0
- package/src/prover/smt/solver/push-app-ite.ts +37 -0
- package/src/prover/smt/solver/qe-arith-plugin.ts +1096 -0
- package/src/prover/smt/solver/qe-lite-der.ts +2 -31
- package/src/prover/smt/solver/qe-lite-fm.ts +4 -28
- package/src/prover/smt/solver/qe-lite.ts +41 -51
- package/src/prover/smt/solver/qe-mbp.ts +270 -0
- package/src/prover/smt/solver/qe.ts +1499 -0
- package/src/prover/smt/solver/qel.ts +25 -0
- package/src/prover/smt/solver/qi-queue.ts +0 -16
- package/src/prover/smt/solver/qsat.ts +829 -0
- package/src/prover/smt/solver/quant-hoist.ts +196 -0
- package/src/prover/smt/solver/quant-tactics.ts +17 -74
- package/src/prover/smt/solver/quantifier-analyzer.ts +26 -47
- package/src/prover/smt/solver/quantifier-manager.ts +22 -32
- package/src/prover/smt/solver/quasi-macros.ts +243 -0
- package/src/prover/smt/solver/random-gen.ts +0 -2
- package/src/prover/smt/solver/rational.ts +45 -8
- package/src/prover/smt/solver/recfun-decl-plugin.ts +262 -0
- package/src/prover/smt/solver/recfun-rewriter.ts +107 -0
- package/src/prover/smt/solver/reduce-args.ts +225 -0
- package/src/prover/smt/solver/reduce-bv-size.ts +119 -0
- package/src/prover/smt/solver/ref-vector.ts +0 -6
- package/src/prover/smt/solver/relevancy.ts +2 -16
- package/src/prover/smt/solver/rewriter-tpl.ts +59 -135
- package/src/prover/smt/solver/rewriter.ts +507 -144
- package/src/prover/smt/solver/rlimit.ts +46 -24
- package/src/prover/smt/solver/sat/asymm-branch.ts +325 -0
- package/src/prover/smt/solver/sat/big.ts +177 -0
- package/src/prover/smt/solver/sat/clause-use-list.ts +71 -0
- package/src/prover/smt/solver/sat/clause.ts +203 -0
- package/src/prover/smt/solver/sat/cleaner.ts +94 -0
- package/src/prover/smt/solver/sat/config.ts +122 -0
- package/src/prover/smt/solver/sat/consequences.ts +203 -0
- package/src/prover/smt/solver/sat/elim-eqs.ts +142 -0
- package/src/prover/smt/solver/sat/goal2sat.ts +579 -0
- package/src/prover/smt/solver/sat/inc-sat-solver.ts +464 -0
- package/src/prover/smt/solver/sat/model-converter.ts +136 -0
- package/src/prover/smt/solver/sat/pb-constraint.ts +268 -0
- package/src/prover/smt/solver/sat/pb-solver.ts +1596 -0
- package/src/prover/smt/solver/sat/probing.ts +170 -0
- package/src/prover/smt/solver/sat/sat-tactic.ts +53 -0
- package/src/prover/smt/solver/sat/sat2goal.ts +189 -0
- package/src/prover/smt/solver/sat/scc.ts +142 -0
- package/src/prover/smt/solver/sat/simplifier.ts +1618 -0
- package/src/prover/smt/solver/sat/solver.ts +2107 -0
- package/src/prover/smt/solver/sat/var-queue.ts +117 -0
- package/src/prover/smt/solver/sat/watch-list.ts +140 -0
- package/src/prover/smt/solver/search-tree.ts +284 -0
- package/src/prover/smt/solver/seq-axioms.ts +995 -0
- package/src/prover/smt/solver/seq-decl-plugin.ts +819 -0
- package/src/prover/smt/solver/seq-derive.ts +1298 -0
- package/src/prover/smt/solver/seq-eq-approx.ts +236 -0
- package/src/prover/smt/solver/seq-eq-solver.ts +439 -0
- package/src/prover/smt/solver/seq-factory.ts +89 -0
- package/src/prover/smt/solver/seq-monadic.ts +730 -0
- package/src/prover/smt/solver/seq-range-predicate.ts +235 -0
- package/src/prover/smt/solver/seq-re-rewriter.ts +1171 -0
- package/src/prover/smt/solver/seq-re-util.ts +758 -0
- package/src/prover/smt/solver/seq-regex-bisim.ts +144 -0
- package/src/prover/smt/solver/seq-regex-live.ts +200 -0
- package/src/prover/smt/solver/seq-rewriter.ts +2404 -0
- package/src/prover/smt/solver/seq-skolem.ts +294 -0
- package/src/prover/smt/solver/seq-subset.ts +165 -0
- package/src/prover/smt/solver/seq-view-witness.ts +353 -0
- package/src/prover/smt/solver/smt-consequences.ts +297 -0
- package/src/prover/smt/solver/smt-kernel.ts +124 -0
- package/src/prover/smt/solver/smt-logics.ts +66 -0
- package/src/prover/smt/solver/smt-setup.ts +589 -0
- package/src/prover/smt/solver/smt2-printer.ts +765 -0
- package/src/prover/smt/solver/smtlib-parser.ts +3546 -406
- package/src/prover/smt/solver/smtlib-script.ts +2134 -0
- package/src/prover/smt/solver/solve-eqs.ts +928 -0
- package/src/prover/smt/solver/solver.ts +135 -40
- package/src/prover/smt/solver/sort.ts +1 -5
- package/src/prover/smt/solver/static-features.ts +314 -0
- package/src/prover/smt/solver/sticky-generations.ts +0 -6
- package/src/prover/smt/solver/tactic.ts +2141 -0
- package/src/prover/smt/solver/term-enumeration.ts +205 -0
- package/src/prover/smt/solver/theory-array.ts +1240 -0
- package/src/prover/smt/solver/theory-bv.ts +1210 -0
- package/src/prover/smt/solver/theory-char.ts +355 -0
- package/src/prover/smt/solver/theory-datatype.ts +598 -0
- package/src/prover/smt/solver/theory-finite-set.ts +30 -0
- package/src/prover/smt/solver/theory-fpa.ts +389 -0
- package/src/prover/smt/solver/theory-lra-axioms.ts +55 -25
- package/src/prover/smt/solver/theory-lra-bounds.ts +31 -11
- package/src/prover/smt/solver/theory-lra-final-check.ts +60 -91
- package/src/prover/smt/solver/theory-lra-internalize.ts +96 -53
- package/src/prover/smt/solver/theory-lra-model.ts +23 -53
- package/src/prover/smt/solver/theory-lra-propagate.ts +34 -42
- package/src/prover/smt/solver/theory-lra-state.ts +7 -28
- package/src/prover/smt/solver/theory-lra.ts +189 -9
- package/src/prover/smt/solver/theory-pb.ts +951 -0
- package/src/prover/smt/solver/theory-polymorphism.ts +58 -0
- package/src/prover/smt/solver/theory-recfun.ts +307 -0
- package/src/prover/smt/solver/theory-seq-regex.ts +867 -0
- package/src/prover/smt/solver/theory-seq-solve.ts +1373 -0
- package/src/prover/smt/solver/theory-seq-state.ts +852 -0
- package/src/prover/smt/solver/theory-seq.ts +961 -0
- package/src/prover/smt/solver/theory-without-terms.ts +24 -0
- package/src/prover/smt/solver/theory.ts +189 -0
- package/src/prover/smt/solver/tseitin-cnf.ts +486 -0
- package/src/prover/smt/solver/var-subst.ts +37 -39
- package/src/prover/smt/table.ts +3 -10
- package/src/prover/smt/types.ts +146 -0
- package/src/prover/tlapm/cache.ts +74 -48
- package/src/prover/tlapm/ocaml-marshal.ts +19 -21
- package/src/prover/tlapm/tlapm.ts +21 -20
- package/src/prover/tlapm-library.ts +3208 -0
- package/src/prover/verdict.ts +9 -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 +10 -19
- package/src/prover/zenon/encode.ts +0 -9
- package/src/prover/zenon/eqrel.ts +2 -15
- package/src/prover/zenon/equality-rules.ts +24 -6
- package/src/prover/zenon/expr.ts +29 -28
- package/src/prover/zenon/index-table.ts +33 -61
- package/src/prover/zenon/isar-case.ts +9 -21
- package/src/prover/zenon/isar.ts +37 -67
- package/src/prover/zenon/limits.ts +0 -4
- package/src/prover/zenon/llproof.ts +2 -22
- package/src/prover/zenon/mltoll.ts +66 -106
- package/src/prover/zenon/node.ts +20 -15
- package/src/prover/zenon/ocaml.ts +1 -17
- package/src/prover/zenon/parse.ts +9 -13
- package/src/prover/zenon/phrase.ts +2 -14
- package/src/prover/zenon/proof.ts +0 -11
- package/src/prover/zenon/propositional-rules.ts +0 -7
- package/src/prover/zenon/rules.ts +3 -8
- package/src/prover/zenon/search.ts +11 -35
- package/src/prover/zenon/tla/functions.ts +59 -33
- package/src/prover/zenon/tla/llproof.ts +67 -78
- package/src/prover/zenon/tla/records.ts +57 -35
- package/src/prover/zenon/tla/rewrites.ts +12 -21
- package/src/prover/zenon/tla/sets.ts +88 -59
- package/src/prover/zenon/tla/terms.ts +0 -8
- package/src/prover/zenon/tla/tla.ts +66 -66
- package/src/randomization.ts +81 -35
- package/src/resolve.ts +1132 -430
- package/src/runtime.ts +33 -23
- package/src/sany/builtins.ts +11 -14
- package/src/sany/generation.ts +383 -0
- package/src/sany/generator-def-entries.ts +210 -0
- package/src/sany/generator-definitions.ts +688 -0
- package/src/sany/generator-expressions.ts +1108 -0
- package/src/sany/generator-proofs.ts +665 -0
- package/src/sany/generator.ts +192 -2764
- package/src/sany/levels.ts +5 -35
- package/src/sany/lexer.ts +61 -80
- package/src/sany/linter.ts +0 -10
- package/src/sany/modules.ts +5 -7
- package/src/sany/nodes.ts +6 -44
- package/src/sany/parse-error.ts +39 -117
- package/src/sany/report.ts +32 -69
- package/src/sany/selectors.ts +60 -82
- package/src/sany/source.ts +1 -17
- package/src/sany/xml.ts +37 -120
- package/src/search.ts +913 -227
- package/src/simulate.ts +765 -0
- package/src/spec-description.ts +198 -104
- package/src/standard-definitions.ts +4 -4
- package/src/standard-modules.ts +302 -99
- package/src/state-graph.ts +52 -33
- package/src/subexpressions.ts +578 -166
- package/src/substitution-levels.ts +7 -7
- package/src/successors.ts +299 -108
- package/src/symmetry.ts +37 -28
- package/src/tableau.ts +29 -26
- package/src/tlc/fingerprint.ts +267 -79
- package/src/tlc/jar-data.ts +122 -6
- package/src/tlc/messages.ts +127 -56
- package/src/tlc/order.ts +53 -72
- package/src/tlc/random.ts +38 -49
- package/src/tlc/replay.ts +579 -230
- package/src/tlc/summary.ts +64 -60
- package/src/tlc/tlc-operators.ts +83 -47
- package/src/tlc/tlcext-operators.ts +205 -127
- package/src/tlc/trace-spec.ts +235 -0
- package/src/tlc/value-stream.ts +139 -0
- package/src/tlc/version.ts +1 -4
- package/src/trace-liveness.ts +529 -0
- package/src/transfer.ts +22 -25
- package/src/typed-tier.ts +6556 -0
- 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 +945 -526
- package/src/worker.ts +7 -8
- package/src/prover/isabelle/isar/statement.ts +0 -57
- package/src/prover/smt/solver/z3-license.txt +0 -10
- package/src/prover/tlaps-module.ts +0 -510
- package/src/prover/zenon/LICENSE +0 -32
package/src/prover/verdict.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
// A backend's answer to an obligation. tlapm frames an obligation as unsatisfiable when the backend
|
|
2
|
-
// proves it.
|
|
3
1
|
export type Verdict = "unsat" | "sat" | "unknown";
|
|
4
2
|
|
|
3
|
+
export const BACKENDS = ["zenon", "isabelle", "smt", "z3", "ls4"] as const;
|
|
4
|
+
|
|
5
|
+
export type Backend = (typeof BACKENDS)[number];
|
|
6
|
+
|
|
7
|
+
export const isBackend = (prover: string): prover is Backend =>
|
|
8
|
+
BACKENDS.some((backend) => backend === prover);
|
|
9
|
+
|
|
5
10
|
export interface Decision {
|
|
6
11
|
verdict: Verdict;
|
|
12
|
+
output?: string;
|
|
13
|
+
errorOutput?: string;
|
|
7
14
|
timeUsedMs: number;
|
|
8
15
|
}
|
|
9
16
|
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
// An independent check of the proofs that the Zenon port finds. It shares no code with the search:
|
|
2
|
-
// formulas compare by their own alpha-equivalence, substitution and unfolding are rebuilt here, and
|
|
3
|
-
// each rule's branches come from the lemma that justifies the rule in tlapm's Zenon.thy rather than
|
|
4
|
-
// from the prover. The check walks the proof bottom up and computes the formulas each subproof
|
|
5
|
-
// needs. A proof is valid when every rule is one of the lemmas and the root needs only hypotheses.
|
|
6
|
-
|
|
7
1
|
import { getLimitFailure, type Limits } from "../limits";
|
|
8
2
|
import type { PlainRuleName, Proof, RuleArgs } from "../proof";
|
|
9
3
|
import { getDefinitionSpec } from "./definitions";
|
|
@@ -57,8 +51,6 @@ const getRuleSpec = (proof: Proof<Term>, checker: Checker): RuleSpec => {
|
|
|
57
51
|
}
|
|
58
52
|
};
|
|
59
53
|
|
|
60
|
-
// True when the proof refutes the hypotheses.
|
|
61
|
-
// Whether the proof is valid, or false once the limits pass.
|
|
62
54
|
export const checkProof = (root: Proof<Term>, context: CheckContext, limits: Limits) => {
|
|
63
55
|
const keys = createKeys();
|
|
64
56
|
const hasRelation = createRelationProperties(context);
|
|
@@ -79,7 +71,6 @@ export const checkProof = (root: Proof<Term>, context: CheckContext, limits: Lim
|
|
|
79
71
|
return result;
|
|
80
72
|
};
|
|
81
73
|
try {
|
|
82
|
-
// Subproofs before their parents, without recursion: proofs can be deep.
|
|
83
74
|
const stack: [Proof<Term>, boolean][] = [[root, false]];
|
|
84
75
|
while (stack.length > 0) {
|
|
85
76
|
if (getLimitFailure(limits) !== undefined) return false;
|
|
@@ -96,8 +87,7 @@ export const checkProof = (root: Proof<Term>, context: CheckContext, limits: Lim
|
|
|
96
87
|
if (!needed.has(subproof)) stack.push([subproof, false]);
|
|
97
88
|
}
|
|
98
89
|
const hypotheses = new Set(context.hypotheses.map(keys.getTopKey));
|
|
99
|
-
|
|
100
|
-
return missing.length === 0;
|
|
90
|
+
return [...(needed.get(root) ?? [])].every((key) => hypotheses.has(key));
|
|
101
91
|
} catch (error) {
|
|
102
92
|
if (error instanceof UncheckedError) return false;
|
|
103
93
|
throw error;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// The check of unfolding a definition: a real definition from the input, or a pseudo-definition
|
|
2
|
-
// that Zenon reads off a hypothesis.
|
|
3
|
-
|
|
4
1
|
import type { Definition } from "../parse";
|
|
5
2
|
import {
|
|
6
3
|
app,
|
|
@@ -14,8 +11,6 @@ import {
|
|
|
14
11
|
type Term,
|
|
15
12
|
} from "./terms";
|
|
16
13
|
|
|
17
|
-
// Checks that `unfolded` is `folded` with occurrences of the defined symbol replaced by its body,
|
|
18
|
-
// going through applications and negations as Zenon does.
|
|
19
14
|
const isUnfolding = (
|
|
20
15
|
checker: Checker,
|
|
21
16
|
definition: Definition,
|
|
@@ -67,7 +62,6 @@ const getBound = (origin: Term) => {
|
|
|
67
62
|
return { bound, matrix };
|
|
68
63
|
};
|
|
69
64
|
|
|
70
|
-
// A pseudo-definition stands for its hypothesis, \A params : f(params) = body or <=> body.
|
|
71
65
|
const isDefinedBy = (checker: Checker, definition: Definition, origin: Term) => {
|
|
72
66
|
const quantified = getBound(origin);
|
|
73
67
|
const bound = quantified.bound;
|
|
@@ -85,14 +79,13 @@ const isDefinedBy = (checker: Checker, definition: Definition, origin: Term) =>
|
|
|
85
79
|
];
|
|
86
80
|
if (params.length === 0) heads.push(variable(definition.symbol));
|
|
87
81
|
const sides = matrix.args;
|
|
88
|
-
// The parameters are free in the head and the body, so compare them under the same names.
|
|
89
82
|
const env: Env = new Map(bound.map((name, index) => [name, index]));
|
|
90
|
-
const
|
|
91
|
-
const headKeys = heads.map(
|
|
92
|
-
const bodyKey =
|
|
83
|
+
const getBoundKey = (formula: Term) => checker.getKey(formula, env, bound.length);
|
|
84
|
+
const headKeys = heads.map(getBoundKey);
|
|
85
|
+
const bodyKey = getBoundKey(definition.body);
|
|
93
86
|
return (
|
|
94
|
-
(headKeys.includes(
|
|
95
|
-
(headKeys.includes(
|
|
87
|
+
(headKeys.includes(getBoundKey(sides[0])) && getBoundKey(sides[1]) === bodyKey) ||
|
|
88
|
+
(headKeys.includes(getBoundKey(sides[1])) && getBoundKey(sides[0]) === bodyKey)
|
|
96
89
|
);
|
|
97
90
|
};
|
|
98
91
|
|
|
@@ -102,7 +95,6 @@ const getFreeSymbols = (formula: Term, symbols: Set<string>) => {
|
|
|
102
95
|
return symbols;
|
|
103
96
|
};
|
|
104
97
|
|
|
105
|
-
// Real definitions are sound when each symbol has one and they don't refer to themselves.
|
|
106
98
|
const isWellFounded = (definition: Definition, definitions: Definition[]) => {
|
|
107
99
|
const reals = definitions.filter((candidate) => candidate.kind === "real");
|
|
108
100
|
const bySymbol = new Map(reals.map((candidate) => [candidate.symbol, candidate]));
|
|
@@ -130,8 +122,6 @@ export const getDefinitionSpec = (
|
|
|
130
122
|
): RuleSpec => {
|
|
131
123
|
const definitions = checker.context.definitions;
|
|
132
124
|
ensure(definitions.includes(definition));
|
|
133
|
-
// An equivalence only says the two sides have the same truth value, so it unfolds where a
|
|
134
|
-
// formula is expected, not inside a term.
|
|
135
125
|
const isEquivalence =
|
|
136
126
|
definition.kind === "pseudo" && getBound(definition.origin).matrix.kind === "equiv";
|
|
137
127
|
ensure(isUnfolding(checker, definition, args[0], args[1], isEquivalence));
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// The checks of Zenon's rules for equality, strings and the relations that the hypotheses make
|
|
2
|
-
// reflexive, symmetric or transitive.
|
|
3
|
-
|
|
4
1
|
import type { PlainRuleName, Rule, RelationRuleName } from "../proof";
|
|
5
2
|
import {
|
|
6
3
|
app,
|
|
@@ -20,8 +17,6 @@ import {
|
|
|
20
17
|
|
|
21
18
|
const relate = (symbol: string, left: Term, right: Term) => app(symbol, [left, right]);
|
|
22
19
|
|
|
23
|
-
// The two branches that the relation fails to link and the ends differ. The ends come from
|
|
24
|
-
// r(a, b) and ~r(c, d) in the order that Zenon's Trans or Trans_sym takes them.
|
|
25
20
|
const getTransitivitySpec = (
|
|
26
21
|
checker: Checker,
|
|
27
22
|
args: [Term, Term],
|
|
@@ -48,7 +43,6 @@ const getTransitivitySpec = (
|
|
|
48
43
|
};
|
|
49
44
|
};
|
|
50
45
|
|
|
51
|
-
// a = b against ~r(c, d), in the order of Zenon's TransEq, TransEq_sym or TransEq2.
|
|
52
46
|
const getTransitiveEqualitySpec = (
|
|
53
47
|
checker: Checker,
|
|
54
48
|
args: [Term, Term, Term],
|
|
@@ -83,7 +77,6 @@ const getTransitiveEqualitySpec = (
|
|
|
83
77
|
};
|
|
84
78
|
};
|
|
85
79
|
|
|
86
|
-
// Of t1 = s1 and t2 = s2 with distinct strings s1 and s2, in the order of the rule's sides.
|
|
87
80
|
const getStringDifferenceSpec = (args: Term[], sides: "ll" | "lr" | "rl" | "rr"): RuleSpec => {
|
|
88
81
|
const term1 = args[0];
|
|
89
82
|
const string1 = args[1];
|
|
@@ -99,7 +92,6 @@ const getStringDifferenceSpec = (args: Term[], sides: "ll" | "lr" | "rl" | "rr")
|
|
|
99
92
|
};
|
|
100
93
|
};
|
|
101
94
|
|
|
102
|
-
// Of f(a1, ..., an) and ~g(b1, ..., bn) with f and g the same: some argument differs.
|
|
103
95
|
const getArgumentsDifferSpec = (premises: Term[], left: Term, right: Term): RuleSpec => {
|
|
104
96
|
const leftArgs = expectKind(left, "app");
|
|
105
97
|
const rightArgs = expectKind(right, "app");
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// The checks of the TLA+ extension's rules for functions, after the lemmas in Zenon.thy that justify
|
|
2
|
-
// them.
|
|
3
|
-
|
|
4
1
|
import type { PlainRuleName } from "../proof";
|
|
5
2
|
import {
|
|
6
3
|
and,
|
|
@@ -18,7 +15,6 @@ import {
|
|
|
18
15
|
type Term,
|
|
19
16
|
} from "./terms";
|
|
20
17
|
|
|
21
|
-
// ~isAFcn(f) where f is built by a function constructor closes the branch.
|
|
22
18
|
const getNotFunctionSpec = (formula: Term, constructor: string, arity: number) => {
|
|
23
19
|
expectApp(expectApp(expectNot(formula), "TLA.isAFcn", 1)[0], constructor, arity);
|
|
24
20
|
return { premises: [formula], branches: [] };
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// Comparing formulas by their own alpha-equivalence: each formula prints to a key in which a bound
|
|
2
|
-
// variable is the number of binders between it and its own.
|
|
3
|
-
|
|
4
1
|
import { term, UncheckedError, variable, type Env, type Operators, type Term } from "./terms";
|
|
5
2
|
|
|
6
3
|
export const createKeys = () => {
|
|
@@ -8,8 +5,6 @@ export const createKeys = () => {
|
|
|
8
5
|
const topKeys = new WeakMap<Term, string>();
|
|
9
6
|
let freshCount = 0;
|
|
10
7
|
|
|
11
|
-
// The variables and applied symbols that a formula doesn't bind, which are the names an
|
|
12
|
-
// environment can change.
|
|
13
8
|
const getFreeNames = (formula: Term): Set<string> => {
|
|
14
9
|
const cached = freeNames.get(formula);
|
|
15
10
|
if (cached !== undefined) return cached;
|
|
@@ -33,7 +28,6 @@ export const createKeys = () => {
|
|
|
33
28
|
return names;
|
|
34
29
|
};
|
|
35
30
|
|
|
36
|
-
// `operators` replaces applied symbols, for definitions whose parameters are operators.
|
|
37
31
|
const getKey = (formula: Term, env: Env, depth: number, operators?: Operators): string => {
|
|
38
32
|
for (const name of getFreeNames(formula))
|
|
39
33
|
if (env.has(name) || operators?.has(name) === true)
|
|
@@ -107,7 +101,6 @@ export const createKeys = () => {
|
|
|
107
101
|
const getTopKey = (formula: Term) => {
|
|
108
102
|
const cached = topKeys.get(formula);
|
|
109
103
|
if (cached !== undefined) return cached;
|
|
110
|
-
// Keys count binders from the variable, so a formula's key doesn't depend on where it sits.
|
|
111
104
|
const key = getEnvKey(formula, new Map(), 0);
|
|
112
105
|
topKeys.set(formula, key);
|
|
113
106
|
return key;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// The checks of Zenon's rules for connectives, quantifiers and the cut.
|
|
2
|
-
|
|
3
1
|
import type { PlainRuleName } from "../proof";
|
|
4
2
|
import {
|
|
5
3
|
and,
|
|
@@ -39,7 +37,6 @@ const getDisjuncts = (formula: Term): Term[] => {
|
|
|
39
37
|
return [formula];
|
|
40
38
|
};
|
|
41
39
|
|
|
42
|
-
// The witness of an existential: Hilbert's epsilon of its body.
|
|
43
40
|
const getWitness = (exists: Term) => instantiate(exists, term("tau", exists.symbol, exists.args));
|
|
44
41
|
|
|
45
42
|
export const PROPOSITIONAL_RULES = {
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// The checks of the TLA+ extension's rules for tuples and records, after the lemmas in Zenon.thy
|
|
2
|
-
// that justify them.
|
|
3
|
-
|
|
4
1
|
import type { PlainRuleName } from "../proof";
|
|
5
2
|
import {
|
|
6
3
|
app,
|
|
@@ -21,7 +18,6 @@ import {
|
|
|
21
18
|
type Term,
|
|
22
19
|
} from "./terms";
|
|
23
20
|
|
|
24
|
-
// The fields of a record or a set of records, whose labels must be distinct string literals.
|
|
25
21
|
export const getFields = (record: Term, constructor: "TLA.record" | "TLA.recordset") => {
|
|
26
22
|
const fields = getPairs(expectApp(record, constructor));
|
|
27
23
|
const labels = fields.map((field) => getStringText(field[0]));
|
|
@@ -29,7 +25,7 @@ export const getFields = (record: Term, constructor: "TLA.record" | "TLA.records
|
|
|
29
25
|
return fields;
|
|
30
26
|
};
|
|
31
27
|
|
|
32
|
-
const getLabels = (fields: [Term, Term][]) =>
|
|
28
|
+
export const getLabels = (fields: [Term, Term][]) =>
|
|
33
29
|
app(
|
|
34
30
|
"TLA.set",
|
|
35
31
|
fields.map((field) => field[0]),
|
|
@@ -49,7 +45,6 @@ const getRecordInequalitySpec = (formula: Term, isRecordRight: boolean): RuleSpe
|
|
|
49
45
|
};
|
|
50
46
|
};
|
|
51
47
|
|
|
52
|
-
// Checks that the formulas list exactly the expected ones, and returns them as branches.
|
|
53
48
|
const expectSameSet = (checker: Checker, given: Term[], expected: Term[]) => {
|
|
54
49
|
const keys = new Set(expected.map(checker.getTopKey));
|
|
55
50
|
ensure(
|
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// three elements satisfies the ground instances of the hypotheses and breaks the property.
|
|
4
|
-
|
|
5
|
-
import type { CheckContext, RelationProperty, Term } from "./terms";
|
|
1
|
+
import type { RelationProperty } from "../eqrel";
|
|
2
|
+
import type { CheckContext, Term } from "./terms";
|
|
6
3
|
|
|
7
4
|
type Polarity = "positive" | "negative" | "both";
|
|
8
5
|
|
|
9
|
-
// A hypothesis as a test on how a relation holds among three elements: `values` gives the bound
|
|
10
|
-
// variables their elements and bit 3 * i + j of `holds` says whether the relation holds from
|
|
11
|
-
// element i to element j.
|
|
12
6
|
type GroundTest = (values: number[], holds: number) => boolean;
|
|
13
7
|
|
|
14
8
|
const ELEMENTS = [0, 1, 2];
|
|
15
9
|
|
|
16
|
-
// The type Zenon gives a variable that its binder leaves untyped, which ranges over everything.
|
|
17
10
|
const UNTYPED = "zenon_U";
|
|
18
11
|
|
|
19
|
-
// The ground instances of a hypothesis over three elements. A universal quantifier where the
|
|
20
|
-
// hypothesis asserts it, or an existential where it denies it, becomes a test over the three
|
|
21
|
-
// elements, which the hypothesis implies. Undefined when the hypothesis says anything but how the
|
|
22
|
-
// relation holds between bound variables, so that it's left out.
|
|
23
12
|
const getGroundTest = (
|
|
24
13
|
formula: Term,
|
|
25
14
|
symbol: string,
|
|
@@ -92,7 +81,6 @@ const getGroundTest = (
|
|
|
92
81
|
}
|
|
93
82
|
};
|
|
94
83
|
|
|
95
|
-
// = has every property. Another relation has the ones the hypotheses give it.
|
|
96
84
|
export const createRelationProperties = (context: CheckContext) => {
|
|
97
85
|
const cache = new Map<string, boolean>();
|
|
98
86
|
const hasProperty = (symbol: string, property: RelationProperty) => {
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
// The checks of the TLA+ extension's rules that rewrite a subterm in place: evaluating a function
|
|
2
|
-
// application, DOMAIN, IF, CASE, Len, or a formula used as a term. Each rule names the context of
|
|
3
|
-
// the subterm as a lambda, (\x. context).
|
|
4
|
-
|
|
5
1
|
import type { PlainRuleName } from "../proof";
|
|
6
|
-
import { getFields } from "./records";
|
|
2
|
+
import { getFields, getLabels } from "./records";
|
|
7
3
|
import {
|
|
8
4
|
and,
|
|
9
|
-
app,
|
|
10
5
|
domain,
|
|
11
6
|
ensure,
|
|
12
7
|
equal,
|
|
13
8
|
expectApp,
|
|
14
9
|
FALSE,
|
|
15
10
|
fapply,
|
|
16
|
-
getPairs,
|
|
17
11
|
getStringText,
|
|
18
12
|
instantiate,
|
|
19
13
|
isApp,
|
|
@@ -28,7 +22,6 @@ import {
|
|
|
28
22
|
type Term,
|
|
29
23
|
} from "./terms";
|
|
30
24
|
|
|
31
|
-
// The term that fills the hole of a context to give a formula.
|
|
32
25
|
const getFilled = (lambda: Term, formula: Term) => {
|
|
33
26
|
ensure(lambda.kind === "lam");
|
|
34
27
|
const hole = lambda.args[0].symbol;
|
|
@@ -68,7 +61,6 @@ const getCaseBranches = (lambda: Term, args: Term[], condition: Term): Term[][]
|
|
|
68
61
|
];
|
|
69
62
|
};
|
|
70
63
|
|
|
71
|
-
// A formula used as a term splits into the cases where it equals TRUE and FALSE.
|
|
72
64
|
const getBoolCaseSpec = (
|
|
73
65
|
checker: Checker,
|
|
74
66
|
args: Term[],
|
|
@@ -163,18 +155,7 @@ export const REWRITE_RULES = {
|
|
|
163
155
|
record_domain: (args, checker) =>
|
|
164
156
|
getRewriteSpec(checker, args[0], args[2], (filled) => {
|
|
165
157
|
const record = expectApp(filled, "TLA.DOMAIN", 1)[0];
|
|
166
|
-
|
|
167
|
-
return [
|
|
168
|
-
[
|
|
169
|
-
instantiate(
|
|
170
|
-
args[2],
|
|
171
|
-
app(
|
|
172
|
-
"TLA.set",
|
|
173
|
-
fields.map((field) => field[0]),
|
|
174
|
-
),
|
|
175
|
-
),
|
|
176
|
-
],
|
|
177
|
-
];
|
|
158
|
+
return [[instantiate(args[2], getLabels(getFields(record, "TLA.record")))]];
|
|
178
159
|
}),
|
|
179
160
|
boolcase_not: (args, checker) =>
|
|
180
161
|
getBoolCaseSpec(checker, args, (operand) => operand.kind === "not"),
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// The checks of the TLA+ extension's rules for set membership, set equality and subsets, after the
|
|
2
|
-
// lemmas in Zenon.thy that justify them.
|
|
3
|
-
|
|
4
1
|
import type { PlainRuleName } from "../proof";
|
|
5
2
|
import {
|
|
6
3
|
and,
|
|
@@ -43,6 +40,40 @@ const getSetEqualSpec = (formula: Term, isNegated: boolean, checker: Checker): R
|
|
|
43
40
|
return { premises: [formula], branches: [[isNegated ? not(extensional) : extensional]] };
|
|
44
41
|
};
|
|
45
42
|
|
|
43
|
+
const getUnionSpec = (formula: Term, isNegated: boolean, checker: Checker): RuleSpec => {
|
|
44
|
+
const spec = getMembershipSpec(formula, isNegated, "TLA.UNION", 1);
|
|
45
|
+
const exists = checker.bind("ex", "", (bound) =>
|
|
46
|
+
and(member(bound, spec.operands[0]), member(spec.element, bound)),
|
|
47
|
+
);
|
|
48
|
+
return { premises: [formula], branches: [[isNegated ? not(exists) : exists]] };
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const getSetOfAllSpec = (formula: Term, isNegated: boolean, checker: Checker): RuleSpec => {
|
|
52
|
+
const spec = getMembershipSpec(formula, isNegated, "TLA.setOfAll", 2);
|
|
53
|
+
const mapping = spec.operands[1];
|
|
54
|
+
ensure(mapping.kind === "lam");
|
|
55
|
+
const exists = checker.bind("ex", "", (bound) =>
|
|
56
|
+
and(member(bound, spec.operands[0]), equal(spec.element, instantiate(mapping, bound))),
|
|
57
|
+
);
|
|
58
|
+
return { premises: [formula], branches: [[isNegated ? not(exists) : exists]] };
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const getFuncSetSpec = (formula: Term, isNegated: boolean, checker: Checker): RuleSpec => {
|
|
62
|
+
const spec = getMembershipSpec(formula, isNegated, "TLA.FuncSet", 2);
|
|
63
|
+
const fcn = spec.element;
|
|
64
|
+
const conjuncts = [
|
|
65
|
+
app("TLA.isAFcn", [fcn]),
|
|
66
|
+
equal(domain(fcn), spec.operands[0]),
|
|
67
|
+
checker.bind("all", "", (bound) =>
|
|
68
|
+
imply(member(bound, spec.operands[0]), member(fapply(fcn, bound), spec.operands[1])),
|
|
69
|
+
),
|
|
70
|
+
];
|
|
71
|
+
return {
|
|
72
|
+
premises: [formula],
|
|
73
|
+
branches: isNegated ? conjuncts.map((inner) => [not(inner)]) : [conjuncts],
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
|
|
46
77
|
export const SET_RULES = {
|
|
47
78
|
in_emptyset: (args) => {
|
|
48
79
|
ensure(isVariable(expectApp(args[0], "TLA.in", 2)[1], "TLA.emptyset"));
|
|
@@ -115,20 +146,8 @@ export const SET_RULES = {
|
|
|
115
146
|
branches: [[not(app("TLA.subseteq", [spec.element, spec.operands[0]]))]],
|
|
116
147
|
};
|
|
117
148
|
},
|
|
118
|
-
in_UNION: (args, checker) =>
|
|
119
|
-
|
|
120
|
-
const exists = checker.bind("ex", "", (bound) =>
|
|
121
|
-
and(member(bound, spec.operands[0]), member(spec.element, bound)),
|
|
122
|
-
);
|
|
123
|
-
return { premises: [args[0]], branches: [[exists]] };
|
|
124
|
-
},
|
|
125
|
-
notin_UNION: (args, checker) => {
|
|
126
|
-
const spec = getMembershipSpec(args[0], true, "TLA.UNION", 1);
|
|
127
|
-
const exists = checker.bind("ex", "", (bound) =>
|
|
128
|
-
and(member(bound, spec.operands[0]), member(spec.element, bound)),
|
|
129
|
-
);
|
|
130
|
-
return { premises: [args[0]], branches: [[not(exists)]] };
|
|
131
|
-
},
|
|
149
|
+
in_UNION: (args, checker) => getUnionSpec(args[0], false, checker),
|
|
150
|
+
notin_UNION: (args, checker) => getUnionSpec(args[0], true, checker),
|
|
132
151
|
in_cup: (args) => {
|
|
133
152
|
const spec = getMembershipSpec(args[0], false, "TLA.cup", 2);
|
|
134
153
|
return {
|
|
@@ -197,50 +216,10 @@ export const SET_RULES = {
|
|
|
197
216
|
],
|
|
198
217
|
};
|
|
199
218
|
},
|
|
200
|
-
in_setofall: (args, checker) =>
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
const exists = checker.bind("ex", "", (bound) =>
|
|
205
|
-
and(member(bound, spec.operands[0]), equal(spec.element, instantiate(mapping, bound))),
|
|
206
|
-
);
|
|
207
|
-
return { premises: [args[0]], branches: [[exists]] };
|
|
208
|
-
},
|
|
209
|
-
notin_setofall: (args, checker) => {
|
|
210
|
-
const spec = getMembershipSpec(args[0], true, "TLA.setOfAll", 2);
|
|
211
|
-
const mapping = spec.operands[1];
|
|
212
|
-
ensure(mapping.kind === "lam");
|
|
213
|
-
const exists = checker.bind("ex", "", (bound) =>
|
|
214
|
-
and(member(bound, spec.operands[0]), equal(spec.element, instantiate(mapping, bound))),
|
|
215
|
-
);
|
|
216
|
-
return { premises: [args[0]], branches: [[not(exists)]] };
|
|
217
|
-
},
|
|
218
|
-
in_funcset: (args, checker) => {
|
|
219
|
-
const spec = getMembershipSpec(args[0], false, "TLA.FuncSet", 2);
|
|
220
|
-
const fcn = spec.element;
|
|
221
|
-
const maps = checker.bind("all", "", (bound) =>
|
|
222
|
-
imply(member(bound, spec.operands[0]), member(fapply(fcn, bound), spec.operands[1])),
|
|
223
|
-
);
|
|
224
|
-
return {
|
|
225
|
-
premises: [args[0]],
|
|
226
|
-
branches: [[app("TLA.isAFcn", [fcn]), equal(domain(fcn), spec.operands[0]), maps]],
|
|
227
|
-
};
|
|
228
|
-
},
|
|
229
|
-
notin_funcset: (args, checker) => {
|
|
230
|
-
const spec = getMembershipSpec(args[0], true, "TLA.FuncSet", 2);
|
|
231
|
-
const fcn = spec.element;
|
|
232
|
-
const maps = checker.bind("all", "", (bound) =>
|
|
233
|
-
imply(member(bound, spec.operands[0]), member(fapply(fcn, bound), spec.operands[1])),
|
|
234
|
-
);
|
|
235
|
-
return {
|
|
236
|
-
premises: [args[0]],
|
|
237
|
-
branches: [
|
|
238
|
-
[not(app("TLA.isAFcn", [fcn]))],
|
|
239
|
-
[not(equal(domain(fcn), spec.operands[0]))],
|
|
240
|
-
[not(maps)],
|
|
241
|
-
],
|
|
242
|
-
};
|
|
243
|
-
},
|
|
219
|
+
in_setofall: (args, checker) => getSetOfAllSpec(args[0], false, checker),
|
|
220
|
+
notin_setofall: (args, checker) => getSetOfAllSpec(args[0], true, checker),
|
|
221
|
+
in_funcset: (args, checker) => getFuncSetSpec(args[0], false, checker),
|
|
222
|
+
notin_funcset: (args, checker) => getFuncSetSpec(args[0], true, checker),
|
|
244
223
|
except_notin_funcset: (args) => {
|
|
245
224
|
const spec = getMembershipSpec(args[0], true, "TLA.FuncSet", 2);
|
|
246
225
|
const except = expectApp(spec.element, "TLA.except", 3);
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
// proof.
|
|
3
|
-
|
|
1
|
+
import type { RelationProperty } from "../eqrel";
|
|
4
2
|
import type { ExprKind } from "../expr";
|
|
5
3
|
import type { Definition } from "../parse";
|
|
6
4
|
import type { PlainRuleName, RuleArgs } from "../proof";
|
|
7
5
|
|
|
8
6
|
type TermKind = ExprKind | "subst";
|
|
9
7
|
|
|
10
|
-
// A formula as the checker sees it. The prover's expressions fit this shape. "subst" stands for
|
|
11
|
-
// its first argument with the variable named `symbol` replaced by its second argument.
|
|
12
8
|
export interface Term {
|
|
13
9
|
kind: TermKind;
|
|
14
10
|
symbol: string;
|
|
@@ -20,42 +16,30 @@ export interface CheckContext {
|
|
|
20
16
|
definitions: Definition[];
|
|
21
17
|
}
|
|
22
18
|
|
|
23
|
-
// What a rule needs on its branch: its premises, and the formulas each of its branches adds.
|
|
24
19
|
export interface RuleSpec {
|
|
25
20
|
premises: Term[];
|
|
26
21
|
branches: Term[][];
|
|
27
22
|
}
|
|
28
23
|
|
|
29
|
-
export type RelationProperty = "reflexive" | "symmetric" | "transitive";
|
|
30
|
-
|
|
31
|
-
// What a variable stands for while printing a key: the depth of its binder, or a term substituted
|
|
32
|
-
// for it with the environment where the substitution was made. A substituted term prints where it
|
|
33
|
-
// lands, so its own binders get depths below the binders around it.
|
|
34
24
|
export type Binding = number | { formula: Term; env: Env; operators?: Operators };
|
|
35
25
|
|
|
36
26
|
export type Env = Map<string, Binding>;
|
|
37
27
|
|
|
38
28
|
export type Operators = Map<string, Term>;
|
|
39
29
|
|
|
40
|
-
// One check of a proof, with the caches that last as long as it does.
|
|
41
30
|
export interface Checker {
|
|
42
31
|
context: CheckContext;
|
|
43
|
-
// A canonical text for a formula up to the names of bound variables.
|
|
44
32
|
getKey: (formula: Term, env: Env, depth: number, operators?: Operators) => string;
|
|
45
33
|
getTopKey: (formula: Term) => string;
|
|
46
34
|
isSame: (left: Term, right: Term) => boolean;
|
|
47
|
-
// A binder whose variable can't clash with any name in the input.
|
|
48
35
|
bind: (kind: "all" | "ex", type: string, build: (bound: Term) => Term) => Term;
|
|
49
|
-
// Rejects the proof unless the hypotheses give the relation these properties.
|
|
50
36
|
ensureRelation: (symbol: string, properties: RelationProperty[]) => void;
|
|
51
37
|
}
|
|
52
38
|
|
|
53
|
-
// The check of each rule, given the rule's arguments and the formulas the proof says it uses.
|
|
54
39
|
export type SpecTable<Name extends PlainRuleName> = {
|
|
55
40
|
[Key in Name]: (args: RuleArgs<Key, Term>, checker: Checker, uses: Term[]) => RuleSpec;
|
|
56
41
|
};
|
|
57
42
|
|
|
58
|
-
// Raised inside a rule check to reject the proof.
|
|
59
43
|
export class UncheckedError extends Error {}
|
|
60
44
|
|
|
61
45
|
export const ensure: (condition: boolean) => asserts condition = (condition) => {
|
|
@@ -81,7 +65,6 @@ export const domain = (fcn: Term) => app("TLA.DOMAIN", [fcn]);
|
|
|
81
65
|
export const TRUE = term("true", "", []);
|
|
82
66
|
export const FALSE = term("false", "", []);
|
|
83
67
|
|
|
84
|
-
// Instantiates the body of a binder with a term.
|
|
85
68
|
export const instantiate = (binder: Term, value: Term) =>
|
|
86
69
|
term("subst", binder.args[0].symbol, [binder.args[1], value]);
|
|
87
70
|
|
|
@@ -105,7 +88,6 @@ export const expectNot = (formula: Term) => expectKind(formula, "not")[0];
|
|
|
105
88
|
export const isVariable = (formula: Term, name: string) =>
|
|
106
89
|
formula.kind === "var" && formula.symbol === name;
|
|
107
90
|
|
|
108
|
-
// The text of a string literal. Escapes could spell one string two ways, so they don't count.
|
|
109
91
|
export const getStringText = (formula: Term) => {
|
|
110
92
|
ensure(isApp(formula, "$string", 1) && formula.args[0].kind === "var");
|
|
111
93
|
const text = formula.args[0].symbol;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// The checks of the TLA+ extension's rules for booleans, CHOOSE, natural numbers, bounded
|
|
2
|
-
// quantifiers and equal propositions, after the lemmas in Zenon.thy that justify them.
|
|
3
|
-
|
|
4
1
|
import type { PlainRuleName } from "../proof";
|
|
5
2
|
import {
|
|
6
3
|
ensure,
|
|
@@ -18,8 +15,6 @@ import {
|
|
|
18
15
|
type Term,
|
|
19
16
|
} from "./terms";
|
|
20
17
|
|
|
21
|
-
// From P and a = b, or ~P and a = b, where P is one side: P differs from that side, or the other
|
|
22
|
-
// side holds.
|
|
23
18
|
const getPropositionEqualitySpec = (
|
|
24
19
|
args: Term[],
|
|
25
20
|
isNegated: boolean,
|
|
@@ -77,7 +72,6 @@ export const TLA_RULES = {
|
|
|
77
72
|
);
|
|
78
73
|
return { premises: [args[0]], branches: [[differ]] };
|
|
79
74
|
},
|
|
80
|
-
// Zenon writes ~(P <=> Q) as $notequiv(P, Q).
|
|
81
75
|
notequivdef: (_args, _checker, uses) => {
|
|
82
76
|
ensure(uses.length === 1);
|
|
83
77
|
const sides = expectApp(uses[0], "$notequiv", 2);
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
// Ported from Zenon's main.ml, as shipped in tlapm. Copyright 1997 INRIA, see LICENSE.
|
|
2
|
-
//
|
|
3
|
-
// Runs Zenon on a .znn file as tlapm does, with -oisar. A proof counts only once the independent
|
|
4
|
-
// checker accepts it. tlapm passes -max-time 1d and kills Zenon at its own timeout instead, whether
|
|
5
|
-
// Zenon is still reading, searching or printing the proof.
|
|
6
|
-
|
|
7
1
|
import { TlaZenonError } from "../../errors";
|
|
8
|
-
import type { DecideOptions } from "../verdict";
|
|
2
|
+
import type { DecideOptions, Decision } from "../verdict";
|
|
9
3
|
import { checkProof } from "./check/check";
|
|
10
4
|
import { createRelations } from "./eqrel";
|
|
11
5
|
import { createExpressions } from "./expr";
|
|
@@ -20,11 +14,7 @@ import { getBuiltInDefinitions, PREDEFINED_SYMBOLS } from "./tla/tla";
|
|
|
20
14
|
|
|
21
15
|
interface ZenonRun {
|
|
22
16
|
proof: Proof | undefined;
|
|
23
|
-
// Why Zenon gave up: in the search, or at the limits while it checked or printed the proof.
|
|
24
|
-
// "zenon error" stands for the exceptions that stop Zenon mid-search.
|
|
25
17
|
failure: SearchFailure | "zenon error" | undefined;
|
|
26
|
-
// Zenon's -oisar output, once the checker accepts the proof and the printer ends within the
|
|
27
|
-
// limits.
|
|
28
18
|
isar: string | undefined;
|
|
29
19
|
nodesSearched: number;
|
|
30
20
|
maxBranchFormulas: number;
|
|
@@ -32,8 +22,6 @@ interface ZenonRun {
|
|
|
32
22
|
formulasCreated: number;
|
|
33
23
|
}
|
|
34
24
|
|
|
35
|
-
// The search and its statistics, which match the -stats output of the OCaml Zenon. Throws
|
|
36
|
-
// TlaZenonError when the text isn't a valid .znn file.
|
|
37
25
|
export const runZenon = (text: string, options: DecideOptions): ZenonRun => {
|
|
38
26
|
const limits = { deadline: Date.now() + options.timeLimitMs, signal: options.signal };
|
|
39
27
|
const exprs = createExpressions();
|
|
@@ -97,11 +85,14 @@ export const runZenon = (text: string, options: DecideOptions): ZenonRun => {
|
|
|
97
85
|
};
|
|
98
86
|
};
|
|
99
87
|
|
|
100
|
-
|
|
88
|
+
const FAILURE_ERRORS = new Map<ZenonRun["failure"], string>([
|
|
89
|
+
["exhausted", "Zenon error: exhausted search space without finding a proof\n"],
|
|
90
|
+
["memory limit", "Zenon error: could not find a proof within the memory size limit\n"],
|
|
91
|
+
]);
|
|
101
92
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
93
|
+
export const decideZenon = (text: string, options: DecideOptions): Omit<Decision, "timeUsedMs"> => {
|
|
94
|
+
const run = runZenon(text, options);
|
|
95
|
+
return run.isar === undefined
|
|
96
|
+
? { verdict: "unknown", errorOutput: FAILURE_ERRORS.get(run.failure) }
|
|
97
|
+
: { verdict: "unsat", output: run.isar };
|
|
107
98
|
};
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// A port of tlapm's Backend.Zenon: an obligation as the input of Zenon's TLA+ front end, a $hyp for
|
|
2
|
-
// each visible fact and a $goal, naming identifiers as Isabelle does.
|
|
3
|
-
|
|
4
1
|
import { TlapmBugError, TlaProverError, TlaUnsupportedError } from "../../errors";
|
|
5
2
|
import { createContext, getBoundName, popNames, pushName } from "../../obligations/printer";
|
|
6
3
|
import type { Bound, Builtin, Expr, Hyp, Sequent } from "../../obligations/expression";
|
|
@@ -74,9 +71,6 @@ const getSuccessors = (integer: string) => {
|
|
|
74
71
|
return `${"(TLA.fapply TLA.Succ ".repeat(count)}0${")".repeat(count)}`;
|
|
75
72
|
};
|
|
76
73
|
|
|
77
|
-
// pp_print_obligation: the text tlapm writes to the .znn file it hands Zenon, for an obligation
|
|
78
|
-
// that Backend.Prep has shipped. Unsupported in the goal fails the obligation and in a fact omits
|
|
79
|
-
// it.
|
|
80
74
|
export const encodeZenon = (id: number, sequent: Sequent) => {
|
|
81
75
|
const context = createContext();
|
|
82
76
|
const adjoin = (name: string) => pushName(context, pickle(name));
|
|
@@ -85,7 +79,6 @@ export const encodeZenon = (id: number, sequent: Sequent) => {
|
|
|
85
79
|
const delimited = (args: Expr[]) => formatDelimited(args, printExpr, SPACE);
|
|
86
80
|
const nonatomic = (name: string, args: Expr[]) => format("(%s %a)", name, delimited(args));
|
|
87
81
|
|
|
88
|
-
// A binder's name binds in the body, and what comes before prints outside it.
|
|
89
82
|
const printBinder = (name: string, before: Doc, body: Expr) => {
|
|
90
83
|
const bound = adjoin(name);
|
|
91
84
|
const doc = format("%a((%s) %a))", before, bound, printExpr(body));
|
|
@@ -163,7 +156,6 @@ export const encodeZenon = (id: number, sequent: Sequent) => {
|
|
|
163
156
|
);
|
|
164
157
|
};
|
|
165
158
|
|
|
166
|
-
// SetOf and Fcn take one bound, whose domain prints outside it.
|
|
167
159
|
const printOneBound = (name: string, bounds: Bound[], body: Expr, what: string) => {
|
|
168
160
|
if (bounds.length !== 1) throw new TlaUnsupportedError(`${what} (multiple declared constants)`);
|
|
169
161
|
const bound = bounds[0];
|
|
@@ -175,7 +167,6 @@ export const encodeZenon = (id: number, sequent: Sequent) => {
|
|
|
175
167
|
);
|
|
176
168
|
};
|
|
177
169
|
|
|
178
|
-
// A sequent inside an expression, as an implication under quantifiers.
|
|
179
170
|
const printNestedSequent = (sequent: Sequent): Doc => {
|
|
180
171
|
if (sequent.context.length === 0) return printExpr(sequent.active);
|
|
181
172
|
const hyp = sequent.context[0];
|