tla-ts 0.0.9 → 0.0.10-dev.b4a856304
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -1
- package/dist/compile.cjs +23 -0
- package/dist/compile.js +23 -0
- package/dist/deciders.cjs +28 -28
- package/dist/deciders.js +43 -43
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +72 -10
- package/dist/index.d.ts +72 -10
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +1 -1
- package/dist/prove-worker.cjs +1 -1
- package/dist/prove-worker.js +1 -1
- package/dist/prove.cjs +116 -36
- package/dist/prove.js +116 -36
- package/dist/run.cjs +143 -31
- package/dist/run.js +143 -31
- package/dist/tlapm.cjs +2 -2
- package/dist/tlapm.js +2 -2
- package/dist/transfer.cjs +128 -103
- package/dist/transfer.js +128 -103
- package/dist/worker.cjs +7 -7
- package/dist/worker.js +7 -7
- package/package.json +3 -1
- package/src/ast.ts +7 -21
- package/src/bags.ts +99 -99
- package/src/builtins.ts +44 -75
- package/src/bundled-modules.ts +1 -8
- package/src/check.ts +576 -300
- package/src/cli/options.ts +11 -6
- package/src/cli/run.ts +2 -2
- package/src/cli/runtime-invariants.ts +135 -0
- package/src/cli/shared.ts +20 -9
- package/src/cli/tlapm.ts +0 -12
- package/src/cli/tlc-arguments.ts +646 -0
- package/src/cli/tlc-usage.ts +362 -0
- package/src/cli/tlc.ts +538 -220
- package/src/cli/typescript.ts +23 -0
- package/src/cli/xml-exporter.ts +4 -16
- package/src/cli.ts +0 -1
- package/src/codegen.ts +191 -64
- package/src/config.ts +140 -109
- package/src/coverage.ts +837 -0
- package/src/dependencies.ts +6 -40
- package/src/dfid.ts +618 -0
- package/src/environment.ts +240 -118
- package/src/errors.ts +70 -55
- package/src/evaluate.ts +630 -297
- package/src/exit-codes.ts +37 -3
- package/src/fingerprints.ts +10 -10
- package/src/index.ts +3 -0
- package/src/instances.ts +79 -11
- package/src/java-overrides.ts +2 -12
- package/src/json-reader.ts +456 -0
- package/src/json.ts +262 -139
- package/src/levels.ts +2 -3
- package/src/lexer.ts +17 -26
- package/src/liveness-checker.ts +10 -18
- package/src/liveness.ts +121 -49
- package/src/obligations/action.ts +4 -28
- package/src/obligations/anonymize.ts +84 -80
- package/src/obligations/equality.ts +1 -1
- package/src/obligations/expression.ts +2 -19
- package/src/obligations/format.ts +1 -9
- package/src/obligations/generate.ts +1 -11
- package/src/obligations/index.ts +0 -11
- package/src/obligations/levels.ts +4 -8
- package/src/obligations/module.ts +1 -15
- package/src/obligations/normalize.ts +5 -24
- package/src/obligations/operators.ts +1 -2
- package/src/obligations/pragma.ts +1 -10
- package/src/obligations/printer.ts +47 -46
- package/src/obligations/proof.ts +1 -5
- package/src/obligations/regroup.ts +1 -4
- package/src/obligations/simplify.ts +3 -14
- package/src/obligations/source.ts +1 -21
- package/src/obligations/subexpression.ts +5 -11
- package/src/obligations/substitution.ts +1 -3
- package/src/obligations/temporal.ts +8 -14
- package/src/obligations/tuples.ts +3 -9
- package/src/parallel-worker.ts +29 -39
- package/src/parallel.ts +29 -13
- package/src/parser.ts +436 -90
- package/src/pcal/ast.ts +7 -28
- package/src/pcal/parse.ts +11 -39
- package/src/pcal/tokenize.ts +4 -20
- package/src/pcal/translate.ts +10 -42
- package/src/pcal/validate.ts +3 -21
- package/src/pretty-print.ts +1 -2
- package/src/prover/decide-pool.ts +5 -10
- package/src/prover/deciders.ts +0 -4
- package/src/prover/first-order.ts +0 -11
- package/src/prover/isabelle/decide.ts +0 -6
- package/src/prover/isabelle/encode.ts +11 -23
- package/src/prover/isabelle/isar/inner-syntax.ts +108 -114
- package/src/prover/isabelle/isar/method.ts +25 -38
- package/src/prover/isabelle/isar/proof.ts +1 -10
- package/src/prover/isabelle/isar/statement.ts +1 -6
- package/src/prover/isabelle/isar/theory.ts +15 -26
- package/src/prover/isabelle/isar/type-check.ts +11 -25
- package/src/prover/isabelle/provers/blast/blast.ts +10 -41
- package/src/prover/isabelle/provers/blast/branch.ts +1 -32
- package/src/prover/isabelle/provers/blast/prove.ts +1 -35
- package/src/prover/isabelle/provers/blast/rules.ts +6 -44
- package/src/prover/isabelle/provers/blast/state.ts +2 -28
- package/src/prover/isabelle/provers/blast/term.ts +9 -36
- package/src/prover/isabelle/provers/clasimp.ts +1 -13
- package/src/prover/isabelle/provers/classical.ts +14 -42
- package/src/prover/isabelle/provers/hypsubst.ts +11 -25
- package/src/prover/isabelle/pure/bicompose.ts +16 -13
- package/src/prover/isabelle/pure/consts.ts +1 -7
- package/src/prover/isabelle/pure/conv.ts +1 -9
- package/src/prover/isabelle/pure/drule.ts +24 -40
- package/src/prover/isabelle/pure/envir.ts +3 -52
- package/src/prover/isabelle/pure/goal.ts +1 -7
- package/src/prover/isabelle/pure/interrupt.ts +0 -5
- package/src/prover/isabelle/pure/list.ts +0 -3
- package/src/prover/isabelle/pure/logic.ts +1 -14
- package/src/prover/isabelle/pure/name.ts +2 -9
- package/src/prover/isabelle/pure/net.ts +3 -59
- package/src/prover/isabelle/pure/object-logic.ts +3 -10
- package/src/prover/isabelle/pure/pattern.ts +2 -19
- package/src/prover/isabelle/pure/raw-simplifier.ts +13 -49
- package/src/prover/isabelle/pure/rewriter.ts +26 -58
- package/src/prover/isabelle/pure/search.ts +3 -10
- package/src/prover/isabelle/pure/seq.ts +1 -10
- package/src/prover/isabelle/pure/simplifier.ts +4 -12
- package/src/prover/isabelle/pure/table.ts +1 -31
- package/src/prover/isabelle/pure/tactic.ts +12 -22
- package/src/prover/isabelle/pure/tactical.ts +6 -12
- package/src/prover/isabelle/pure/term-ord.ts +2 -6
- package/src/prover/isabelle/pure/term.ts +2 -43
- package/src/prover/isabelle/pure/thm.ts +13 -36
- package/src/prover/isabelle/pure/type.ts +2 -15
- package/src/prover/isabelle/pure/unify.ts +20 -30
- package/src/prover/isabelle/pure/variable.ts +3 -7
- package/src/prover/isabelle/tla/classical-setup.ts +9 -19
- package/src/prover/isabelle/tla/context.ts +8 -16
- package/src/prover/isabelle/tla/logic.ts +4 -11
- package/src/prover/isabelle/tla/simpdata.ts +46 -34
- package/src/prover/isabelle/tools/intuitionistic.ts +1 -10
- package/src/prover/ocaml.ts +0 -6
- package/src/prover/prep/action.ts +4 -36
- package/src/prover/prep/enabled-axioms.ts +12 -19
- package/src/prover/prep/fingerprint.ts +0 -16
- package/src/prover/prep/level-comparison.ts +8 -12
- package/src/prover/prep/md5.ts +0 -2
- package/src/prover/prep/methods.ts +9 -36
- package/src/prover/prep/normalize.ts +4 -28
- package/src/prover/prove-worker.ts +0 -2
- package/src/prover/prove.ts +0 -36
- package/src/prover/ptl/decide.ts +7 -12
- package/src/prover/ptl/encode.ts +14 -36
- package/src/prover/ptl/sat.ts +24 -32
- package/src/prover/ptl/tableau.ts +12 -26
- package/src/prover/smt/axioms.ts +0 -7
- package/src/prover/smt/context.ts +19 -26
- package/src/prover/smt/data.ts +51 -54
- package/src/prover/smt/encode.ts +14 -35
- package/src/prover/smt/extensionality.ts +0 -10
- package/src/prover/smt/flatten.ts +3 -22
- package/src/prover/smt/format.ts +5 -10
- package/src/prover/smt/instances.ts +0 -10
- package/src/prover/smt/rewrite.ts +66 -101
- package/src/prover/smt/solver/act-cache.ts +0 -15
- package/src/prover/smt/solver/arith-rewriter.ts +3 -48
- package/src/prover/smt/solver/array.ts +1 -3
- package/src/prover/smt/solver/asserted-formulas.ts +1 -43
- package/src/prover/smt/solver/ast-lt.ts +1 -11
- package/src/prover/smt/solver/ast-util.ts +1 -6
- package/src/prover/smt/solver/ast.ts +1 -143
- package/src/prover/smt/solver/auf-solver.ts +6 -39
- package/src/prover/smt/solver/case-split-queue.ts +1 -9
- package/src/prover/smt/solver/cg-table.ts +1 -18
- package/src/prover/smt/solver/clause.ts +1 -27
- package/src/prover/smt/solver/conflict-resolution.ts +0 -9
- package/src/prover/smt/solver/context.ts +4 -61
- package/src/prover/smt/solver/ctx-simplify.ts +14 -41
- package/src/prover/smt/solver/der.ts +2 -21
- package/src/prover/smt/solver/dyn-ack.ts +1 -11
- package/src/prover/smt/solver/e-matching.ts +3 -34
- package/src/prover/smt/solver/enode.ts +1 -21
- package/src/prover/smt/solver/expr-ref.ts +1 -5
- package/src/prover/smt/solver/expr-safe-replace.ts +0 -5
- package/src/prover/smt/solver/fingerprints.ts +1 -12
- package/src/prover/smt/solver/flat-literals.ts +1 -9
- package/src/prover/smt/solver/goal.ts +2 -14
- package/src/prover/smt/solver/hash.ts +0 -8
- package/src/prover/smt/solver/hashtable.ts +1 -12
- package/src/prover/smt/solver/internalizer.ts +6 -98
- package/src/prover/smt/solver/lbool.ts +1 -2
- package/src/prover/smt/solver/literal.ts +0 -3
- package/src/prover/smt/solver/lp/bound-propagator.ts +8 -26
- package/src/prover/smt/solver/lp/constraints.ts +2 -8
- package/src/prover/smt/solver/lp/containers.ts +12 -30
- package/src/prover/smt/solver/lp/core-solver.ts +10 -31
- package/src/prover/smt/solver/lp/cross-nested.ts +6 -20
- package/src/prover/smt/solver/lp/dep-intervals.ts +7 -22
- package/src/prover/smt/solver/lp/dependency.ts +1 -4
- package/src/prover/smt/solver/lp/dioph-eq.ts +12 -98
- package/src/prover/smt/solver/lp/explanation.ts +1 -6
- package/src/prover/smt/solver/lp/gomory.ts +9 -22
- package/src/prover/smt/solver/lp/hnf-cutter.ts +17 -23
- package/src/prover/smt/solver/lp/hnf.ts +11 -26
- package/src/prover/smt/solver/lp/int-cube.ts +15 -36
- package/src/prover/smt/solver/lp/int-solver.ts +4 -34
- package/src/prover/smt/solver/lp/lar-solver.ts +32 -81
- package/src/prover/smt/solver/lp/lar-term.ts +1 -5
- package/src/prover/smt/solver/lp/lp-settings.ts +1 -14
- package/src/prover/smt/solver/lp/maximize-term.ts +20 -45
- package/src/prover/smt/solver/lp/nex-creator.ts +5 -28
- package/src/prover/smt/solver/lp/nex.ts +1 -6
- package/src/prover/smt/solver/lp/nla-backoff.ts +1 -4
- package/src/prover/smt/solver/lp/nla-basics.ts +5 -30
- package/src/prover/smt/solver/lp/nla-core.ts +35 -130
- package/src/prover/smt/solver/lp/nla-divisions.ts +32 -42
- package/src/prover/smt/solver/lp/nla-emonics.ts +4 -21
- package/src/prover/smt/solver/lp/nla-factorization.ts +1 -4
- package/src/prover/smt/solver/lp/nla-grobner.ts +15 -69
- package/src/prover/smt/solver/lp/nla-horner.ts +3 -11
- package/src/prover/smt/solver/lp/nla-intervals.ts +2 -12
- package/src/prover/smt/solver/lp/nla-monomial-bounds.ts +16 -41
- package/src/prover/smt/solver/lp/nla-monotone.ts +2 -6
- package/src/prover/smt/solver/lp/nla-order.ts +2 -13
- package/src/prover/smt/solver/lp/nla-patcher.ts +4 -7
- package/src/prover/smt/solver/lp/nla-tangents.ts +1 -9
- package/src/prover/smt/solver/lp/nla-throttle.ts +1 -6
- package/src/prover/smt/solver/lp/nla-types.ts +1 -11
- package/src/prover/smt/solver/lp/nla-var-eqs.ts +4 -25
- package/src/prover/smt/solver/lp/nra-solver.ts +5 -52
- package/src/prover/smt/solver/lp/numeric-pair.ts +1 -4
- package/src/prover/smt/solver/lp/pdd-interval.ts +1 -3
- package/src/prover/smt/solver/lp/pdd-simplifier.ts +2 -14
- package/src/prover/smt/solver/lp/pdd-solver.ts +4 -33
- package/src/prover/smt/solver/lp/pdd.ts +7 -70
- package/src/prover/smt/solver/lp/random-updater.ts +1 -8
- package/src/prover/smt/solver/lp/static-matrix.ts +9 -19
- package/src/prover/smt/solver/lp/union-find.ts +1 -6
- package/src/prover/smt/solver/mam-compiler.ts +14 -56
- package/src/prover/smt/solver/mam-interpreter.ts +1 -21
- package/src/prover/smt/solver/maximize-ac-sharing.ts +2 -17
- package/src/prover/smt/solver/model-checker.ts +2 -36
- package/src/prover/smt/solver/model-evaluator.ts +3 -29
- package/src/prover/smt/solver/model-finder.ts +3 -15
- package/src/prover/smt/solver/model-generator.ts +1 -12
- package/src/prover/smt/solver/model-macro-solver.ts +12 -69
- package/src/prover/smt/solver/nlsat/algebraic.ts +55 -151
- package/src/prover/smt/solver/nlsat/atoms.ts +5 -19
- package/src/prover/smt/solver/nlsat/evaluator.ts +17 -22
- package/src/prover/smt/solver/nlsat/explain.ts +3 -47
- package/src/prover/smt/solver/nlsat/interval-set.ts +9 -50
- package/src/prover/smt/solver/nlsat/levelwise.ts +48 -129
- package/src/prover/smt/solver/nlsat/mpbq.ts +3 -14
- package/src/prover/smt/solver/nlsat/polynomial.ts +17 -156
- package/src/prover/smt/solver/nlsat/solver.ts +7 -67
- package/src/prover/smt/solver/nlsat/types.ts +1 -8
- package/src/prover/smt/solver/nlsat/upolynomial-factorization.ts +1 -44
- package/src/prover/smt/solver/nlsat/upolynomial.ts +11 -92
- package/src/prover/smt/solver/nnf.ts +3 -38
- package/src/prover/smt/solver/pattern-inference.ts +2 -15
- package/src/prover/smt/solver/poly-rewriter.ts +3 -23
- package/src/prover/smt/solver/propagate-values.ts +1 -10
- package/src/prover/smt/solver/proto-model.ts +3 -48
- package/src/prover/smt/solver/pull-quant.ts +1 -12
- package/src/prover/smt/solver/qe-lite-der.ts +1 -29
- package/src/prover/smt/solver/qe-lite-fm.ts +2 -25
- package/src/prover/smt/solver/qe-lite.ts +3 -33
- package/src/prover/smt/solver/qi-queue.ts +1 -16
- package/src/prover/smt/solver/quant-tactics.ts +5 -22
- package/src/prover/smt/solver/quantifier-analyzer.ts +17 -37
- package/src/prover/smt/solver/quantifier-manager.ts +1 -8
- package/src/prover/smt/solver/random-gen.ts +1 -2
- package/src/prover/smt/solver/rational.ts +1 -8
- package/src/prover/smt/solver/ref-vector.ts +1 -6
- package/src/prover/smt/solver/relevancy.ts +2 -15
- package/src/prover/smt/solver/rewriter-tpl.ts +3 -147
- package/src/prover/smt/solver/rewriter.ts +3 -85
- package/src/prover/smt/solver/rlimit.ts +2 -20
- package/src/prover/smt/solver/smtlib-parser.ts +2 -37
- package/src/prover/smt/solver/solver.ts +23 -34
- package/src/prover/smt/solver/sort.ts +1 -5
- package/src/prover/smt/solver/sticky-generations.ts +0 -5
- package/src/prover/smt/solver/theory-lra-axioms.ts +3 -24
- package/src/prover/smt/solver/theory-lra-bounds.ts +0 -5
- package/src/prover/smt/solver/theory-lra-final-check.ts +4 -22
- package/src/prover/smt/solver/theory-lra-internalize.ts +1 -27
- package/src/prover/smt/solver/theory-lra-model.ts +4 -19
- package/src/prover/smt/solver/theory-lra-propagate.ts +1 -15
- package/src/prover/smt/solver/theory-lra-state.ts +3 -8
- package/src/prover/smt/solver/theory-lra.ts +1 -8
- package/src/prover/smt/solver/var-subst.ts +2 -26
- package/src/prover/smt/table.ts +0 -8
- package/src/prover/tlapm/cache.ts +20 -25
- package/src/prover/tlapm/ocaml-marshal.ts +19 -21
- package/src/prover/tlapm/tlapm.ts +12 -17
- package/src/prover/verdict.ts +0 -2
- package/src/prover/zenon/check/check.ts +0 -9
- package/src/prover/zenon/check/definitions.ts +5 -15
- package/src/prover/zenon/check/equality.ts +0 -8
- package/src/prover/zenon/check/functions.ts +0 -4
- package/src/prover/zenon/check/keys.ts +0 -7
- package/src/prover/zenon/check/propositional.ts +0 -3
- package/src/prover/zenon/check/records.ts +0 -5
- package/src/prover/zenon/check/relations.ts +0 -13
- package/src/prover/zenon/check/rewrites.ts +0 -6
- package/src/prover/zenon/check/sets.ts +0 -3
- package/src/prover/zenon/check/terms.ts +0 -17
- package/src/prover/zenon/check/tla.ts +0 -6
- package/src/prover/zenon/decide.ts +0 -12
- package/src/prover/zenon/encode.ts +1 -8
- package/src/prover/zenon/eqrel.ts +0 -13
- package/src/prover/zenon/equality-rules.ts +0 -4
- package/src/prover/zenon/expr.ts +1 -26
- package/src/prover/zenon/index-table.ts +17 -38
- package/src/prover/zenon/isar-case.ts +9 -19
- package/src/prover/zenon/isar.ts +1 -29
- package/src/prover/zenon/limits.ts +0 -4
- package/src/prover/zenon/llproof.ts +0 -9
- package/src/prover/zenon/mltoll.ts +54 -76
- package/src/prover/zenon/node.ts +1 -11
- package/src/prover/zenon/ocaml.ts +1 -17
- package/src/prover/zenon/parse.ts +2 -7
- package/src/prover/zenon/phrase.ts +1 -11
- package/src/prover/zenon/proof.ts +0 -9
- package/src/prover/zenon/propositional-rules.ts +0 -5
- package/src/prover/zenon/rules.ts +2 -6
- package/src/prover/zenon/search.ts +1 -17
- package/src/prover/zenon/tla/functions.ts +57 -29
- package/src/prover/zenon/tla/llproof.ts +63 -70
- package/src/prover/zenon/tla/records.ts +56 -27
- package/src/prover/zenon/tla/rewrites.ts +12 -19
- package/src/prover/zenon/tla/sets.ts +68 -39
- package/src/prover/zenon/tla/terms.ts +0 -6
- package/src/prover/zenon/tla/tla.ts +59 -58
- package/src/randomization.ts +84 -35
- package/src/resolve.ts +18 -60
- package/src/runtime.ts +11 -4
- package/src/sany/builtins.ts +3 -4
- package/src/sany/generator.ts +119 -169
- package/src/sany/levels.ts +6 -30
- package/src/sany/lexer.ts +7 -23
- package/src/sany/linter.ts +1 -8
- package/src/sany/modules.ts +1 -5
- package/src/sany/nodes.ts +0 -31
- package/src/sany/parse-error.ts +39 -117
- package/src/sany/report.ts +29 -63
- package/src/sany/selectors.ts +15 -39
- package/src/sany/source.ts +1 -17
- package/src/sany/xml.ts +13 -63
- package/src/search.ts +494 -154
- package/src/simulate.ts +694 -0
- package/src/spec-description.ts +166 -48
- package/src/standard-definitions.ts +2 -3
- package/src/standard-modules.ts +264 -68
- package/src/state-graph.ts +51 -18
- package/src/subexpressions.ts +31 -5
- package/src/substitution-levels.ts +2 -3
- package/src/successors.ts +267 -77
- package/src/symmetry.ts +31 -8
- package/src/tableau.ts +27 -24
- package/src/tlc/fingerprint.ts +183 -61
- package/src/tlc/jar-data.ts +113 -6
- package/src/tlc/messages.ts +122 -37
- package/src/tlc/order.ts +33 -38
- package/src/tlc/random.ts +16 -16
- package/src/tlc/replay.ts +563 -211
- package/src/tlc/summary.ts +2 -4
- package/src/tlc/tlc-operators.ts +81 -36
- package/src/tlc/tlcext-operators.ts +138 -117
- package/src/tlc/trace-spec.ts +273 -0
- package/src/tlc/value-stream.ts +143 -0
- package/src/tlc/version.ts +2 -4
- package/src/transfer.ts +22 -25
- package/src/typescript/actions.ts +481 -0
- package/src/typescript/collections.ts +600 -0
- package/src/typescript/compile.ts +65 -0
- package/src/typescript/context.ts +94 -0
- package/src/typescript/emit.ts +121 -0
- package/src/typescript/expressions.ts +496 -0
- package/src/typescript/formula.ts +152 -0
- package/src/typescript/functions.ts +284 -0
- package/src/typescript/model.ts +163 -0
- package/src/typescript/names.ts +114 -0
- package/src/typescript/program.ts +48 -0
- package/src/typescript/properties.ts +139 -0
- package/src/typescript/scope.ts +112 -0
- package/src/typescript/steps.ts +165 -0
- package/src/typescript/types.ts +171 -0
- package/src/values.ts +826 -276
- package/src/worker.ts +7 -8
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
// Ported from Isabelle2025's Provers/clasimp.ML and
|
|
2
|
-
// Copyright (c) 1986-2025 University of Cambridge, Technische Universitaet Muenchen, and
|
|
3
|
-
// contributors, see LICENSE.
|
|
4
|
-
//
|
|
5
|
-
// The classical reasoner combined with the simplifier: auto, clarsimp and force.
|
|
1
|
+
// Ported from Isabelle2025's Provers/clasimp.ML and Pure/tactic.ML. Copyright (c) 1986-2025 University of Cambridge, Technische Universitaet Muenchen, and contributors, see LICENSE.
|
|
6
2
|
|
|
7
3
|
import { trivForallEquality } from "../pure/drule";
|
|
8
4
|
import { selectGoal } from "../pure/goal";
|
|
@@ -49,11 +45,9 @@ import {
|
|
|
49
45
|
export interface ClasimpContext {
|
|
50
46
|
readonly classical: ClassicalContext;
|
|
51
47
|
readonly simp: SimpContext;
|
|
52
|
-
// Blast.depth_tac, the Blast argument of the Clasimp functor.
|
|
53
48
|
readonly blastDepthTac: (context: ClassicalContext, limit: number) => GoalTactic;
|
|
54
49
|
}
|
|
55
50
|
|
|
56
|
-
// addss: the simplifier as an unsafe wrapper.
|
|
57
51
|
const addss = (context: ClasimpContext): ClassicalContext =>
|
|
58
52
|
withClaset(
|
|
59
53
|
context.classical,
|
|
@@ -62,7 +56,6 @@ const addss = (context: ClasimpContext): ClassicalContext =>
|
|
|
62
56
|
),
|
|
63
57
|
);
|
|
64
58
|
|
|
65
|
-
// addSss: the simplifier as a safe wrapper.
|
|
66
59
|
const addSss = (context: ClasimpContext): ClassicalContext =>
|
|
67
60
|
withClaset(
|
|
68
61
|
context.classical,
|
|
@@ -74,7 +67,6 @@ const addSss = (context: ClasimpContext): ClassicalContext =>
|
|
|
74
67
|
export const clarsimpTac = (context: ClasimpContext): GoalTactic =>
|
|
75
68
|
thenAllNew(safeAsmFullSimpTac(context.simp), clarifyTac(addSss(context)));
|
|
76
69
|
|
|
77
|
-
// A variant of Classical.depth_tac that keeps the simplifier from interfering with dup_step_tac.
|
|
78
70
|
const nodupDepthTac =
|
|
79
71
|
(context: ClassicalContext, limit: number): GoalTactic =>
|
|
80
72
|
(index) =>
|
|
@@ -97,7 +89,6 @@ const nodupDepthTac =
|
|
|
97
89
|
),
|
|
98
90
|
)(index)(state);
|
|
99
91
|
|
|
100
|
-
// prune_params_tac: drops the parameters that no goal uses.
|
|
101
92
|
const pruneParamsTac = (simp: SimpContext): Tactic => {
|
|
102
93
|
const empty = { ...simp, simpset: emptySimpset };
|
|
103
94
|
const context = { ...empty, simpset: addSimps(empty, [trivForallEquality]) };
|
|
@@ -125,8 +116,6 @@ const mkAutoTac = (context: ClasimpContext, depth: number, nodupDepth: number):
|
|
|
125
116
|
changed(nodupDepthTac(addss(context), nodupDepth)(index)),
|
|
126
117
|
);
|
|
127
118
|
return every([
|
|
128
|
-
// PARALLEL_ALLGOALS simplifies each goal on its own only when no goal has schematic variables,
|
|
129
|
-
// which gives the same result as simplifying them in turn.
|
|
130
119
|
determ(allGoals(asmFullSimpTac(context.simp))),
|
|
131
120
|
tryTac(safeTac(context.classical)),
|
|
132
121
|
repeatDeterm(firstGoalTac(mainTac)),
|
|
@@ -137,7 +126,6 @@ const mkAutoTac = (context: ClasimpContext, depth: number, nodupDepth: number):
|
|
|
137
126
|
|
|
138
127
|
export const autoTac = (context: ClasimpContext) => mkAutoTac(context, 4, 2);
|
|
139
128
|
|
|
140
|
-
// force_tac: aims to solve the goal outright, with clarify, the simplifier and best-first search.
|
|
141
129
|
export const forceTac = (context: ClasimpContext, atomizeRules: readonly Thm[]): GoalTactic => {
|
|
142
130
|
const classical = addss(context);
|
|
143
131
|
return selectGoal(
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
// Ported from Isabelle2025's Provers/classical.ML. Copyright (c) 1986-2025 University of
|
|
2
|
-
// Cambridge, Technische Universitaet Muenchen, and contributors, see LICENSE.
|
|
3
|
-
//
|
|
4
|
-
// The classical reasoner: rule sets of safe and unsafe introduction and elimination rules, and
|
|
5
|
-
// the tactics that search with them. The rules Isabelle/TLA+ declares come with the logic; a
|
|
6
|
-
// method adds more with intro: and dest:.
|
|
1
|
+
// Ported from Isabelle2025's Provers/classical.ML. Copyright (c) 1986-2025 University of Cambridge, Technische Universitaet Muenchen, and contributors, see LICENSE.
|
|
7
2
|
|
|
8
3
|
import { TlaIsabelleError } from "../../../errors";
|
|
9
4
|
import { revcutRl, thinRl, zeroVarIndexes, makeElim } from "../pure/drule";
|
|
10
5
|
import { selectGoal } from "../pure/goal";
|
|
11
|
-
import { aconv, sizeOfTerm } from "../pure/term";
|
|
6
|
+
import { aconv, sizeOfTerm, type Term } from "../pure/term";
|
|
12
7
|
import { stripAssumsConcl, stripAssumsHyp } from "../pure/logic";
|
|
13
8
|
import { listOfSeq, seqHead } from "../pure/seq";
|
|
14
9
|
import { trade } from "../pure/variable";
|
|
@@ -48,10 +43,17 @@ import {
|
|
|
48
43
|
type NetPair,
|
|
49
44
|
type TaggedRule,
|
|
50
45
|
} from "../pure/tactic";
|
|
51
|
-
import {
|
|
46
|
+
import {
|
|
47
|
+
assumption,
|
|
48
|
+
biresolution,
|
|
49
|
+
nprems,
|
|
50
|
+
premsOf,
|
|
51
|
+
rs,
|
|
52
|
+
rsn,
|
|
53
|
+
type BiresRule,
|
|
54
|
+
type Thm,
|
|
55
|
+
} from "../pure/thm";
|
|
52
56
|
|
|
53
|
-
// A rule as the user gave it, as the nets use it, and as the complete search duplicates it, each
|
|
54
|
-
// with its swapped forms for negated assumptions.
|
|
55
57
|
export interface ClassicalRule {
|
|
56
58
|
readonly rule: Thm;
|
|
57
59
|
readonly internal: Thm;
|
|
@@ -66,7 +68,6 @@ export interface Wrapper {
|
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
export interface Claset {
|
|
69
|
-
// Newest first, as Item_Net.content lists them.
|
|
70
71
|
readonly safeIs: readonly ClassicalRule[];
|
|
71
72
|
readonly safeEs: readonly ClassicalRule[];
|
|
72
73
|
readonly unsafeIs: readonly ClassicalRule[];
|
|
@@ -79,17 +80,11 @@ export interface Claset {
|
|
|
79
80
|
readonly dup: NetPair<TaggedRule>;
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
// CLASSICAL_DATA: the object logic's rules for the classical reasoner.
|
|
83
83
|
export interface ClassicalData {
|
|
84
|
-
// P --> Q ==> (~ R ==> P) ==> (Q ==> R) ==> R
|
|
85
84
|
readonly impElim: Thm;
|
|
86
|
-
// ~P ==> P ==> R
|
|
87
85
|
readonly notElim: Thm;
|
|
88
|
-
// ~ P ==> (~ R ==> P) ==> R
|
|
89
86
|
readonly swap: Thm;
|
|
90
|
-
// (~ P ==> P) ==> P
|
|
91
87
|
readonly classical: Thm;
|
|
92
|
-
// The object logic's Trueprop, which Object_Logic.elim_concl looks through.
|
|
93
88
|
readonly judgment: string;
|
|
94
89
|
readonly hypSubstTacs: readonly ((limits: Limits) => GoalTactic)[];
|
|
95
90
|
}
|
|
@@ -105,8 +100,6 @@ export const withClaset = (context: ClassicalContext, claset: Claset): Classical
|
|
|
105
100
|
claset,
|
|
106
101
|
});
|
|
107
102
|
|
|
108
|
-
// classical_rule: strengthens an elimination rule whose conclusion is a variable, so that the
|
|
109
|
-
// negated conclusion becomes available to every case.
|
|
110
103
|
const classicalRule = (data: ClassicalData, rule: Thm, limits: Limits): Thm => {
|
|
111
104
|
const concl = premsOf(rule).length === 0 ? rule.prop : stripAssumsConcl(rule.prop);
|
|
112
105
|
const body =
|
|
@@ -118,7 +111,7 @@ const classicalRule = (data: ClassicalData, rule: Thm, limits: Limits): Thm => {
|
|
|
118
111
|
if (!isElim) return rule;
|
|
119
112
|
const strengthened = rs(rule, data.classical);
|
|
120
113
|
const strengthenedConcl = stripAssumsConcl(strengthened.prop);
|
|
121
|
-
const isRedundant = (goal:
|
|
114
|
+
const isRedundant = (goal: Term) => {
|
|
122
115
|
if (aconv(strengthenedConcl, stripAssumsConcl(goal))) return true;
|
|
123
116
|
const hyps = stripAssumsHyp(goal);
|
|
124
117
|
return hyps.length > 0 && hyps.slice(1).some((hyp) => aconv(hyp, hyps[0]));
|
|
@@ -135,7 +128,6 @@ const classicalRule = (data: ClassicalData, rule: Thm, limits: Limits): Thm => {
|
|
|
135
128
|
return aconv(result.prop, rule.prop) ? rule : result;
|
|
136
129
|
};
|
|
137
130
|
|
|
138
|
-
// swapify: the rules that eliminate ~A from the rules that introduce A.
|
|
139
131
|
const swapify = (data: ClassicalData, rules: readonly Thm[]) =>
|
|
140
132
|
rules.flatMap((rule) =>
|
|
141
133
|
listOfSeq(biresolution(undefined, false, [{ isElim: false, rule }], 2, data.swap)),
|
|
@@ -143,8 +135,6 @@ const swapify = (data: ClassicalData, rules: readonly Thm[]) =>
|
|
|
143
135
|
|
|
144
136
|
const dupIntr = (data: ClassicalData, rule: Thm) => zeroVarIndexes(rs(rule, data.classical));
|
|
145
137
|
|
|
146
|
-
// Drule.rule_by_tactic: runs the tactic on the rule with its variables fixed.
|
|
147
|
-
// Tactic.rule_by_tactic
|
|
148
138
|
const ruleByTactic = (tactic: Tactic, rule: Thm): Thm =>
|
|
149
139
|
zeroVarIndexes(
|
|
150
140
|
trade((fixed) => {
|
|
@@ -163,8 +153,7 @@ const dupElim = (limits: Limits, rule: Thm) => {
|
|
|
163
153
|
);
|
|
164
154
|
};
|
|
165
155
|
|
|
166
|
-
|
|
167
|
-
const tagRules = (start: number, rules: readonly { isElim: boolean; rule: Thm }[]): TaggedRule[] =>
|
|
156
|
+
const tagRules = (start: number, rules: readonly BiresRule[]): TaggedRule[] =>
|
|
168
157
|
rules.map((brule, index) => ({ tag: 1000000 * subgoalsOfBrl(brule) + start + index, ...brule }));
|
|
169
158
|
|
|
170
159
|
const insertRules = (
|
|
@@ -181,7 +170,6 @@ const insertRules = (
|
|
|
181
170
|
const isMember = (rules: readonly ClassicalRule[], rule: ClassicalRule) =>
|
|
182
171
|
rules.some((other) => aconv(other.rule.prop, rule.rule.prop));
|
|
183
172
|
|
|
184
|
-
// addI: an unsafe introduction rule, which intro: declares.
|
|
185
173
|
export const addUnsafeIntro = (context: ClassicalContext, rule: Thm): Claset => {
|
|
186
174
|
const claset = context.claset;
|
|
187
175
|
if (
|
|
@@ -211,7 +199,6 @@ export const addUnsafeIntro = (context: ClassicalContext, rule: Thm): Claset =>
|
|
|
211
199
|
};
|
|
212
200
|
};
|
|
213
201
|
|
|
214
|
-
// addE: an unsafe elimination rule.
|
|
215
202
|
const addUnsafeElim = (context: ClassicalContext, rule: Thm): Claset => {
|
|
216
203
|
const claset = context.claset;
|
|
217
204
|
if (nprems(rule) < 1) throw new TlaIsabelleError("ERROR", "Ill-formed elimination rule");
|
|
@@ -233,25 +220,21 @@ const addUnsafeElim = (context: ClassicalContext, rule: Thm): Claset => {
|
|
|
233
220
|
};
|
|
234
221
|
};
|
|
235
222
|
|
|
236
|
-
// addD: an unsafe destruction rule, which dest: declares.
|
|
237
223
|
export const addUnsafeDest = (context: ClassicalContext, rule: Thm): Claset => {
|
|
238
224
|
if (nprems(rule) < 1) throw new TlaIsabelleError("ERROR", "Ill-formed destruction rule");
|
|
239
225
|
return addUnsafeElim(context, makeElim(rule));
|
|
240
226
|
};
|
|
241
227
|
|
|
242
|
-
// AList.update: replaces a wrapper of the same name in place, or adds it in front.
|
|
243
228
|
const updateWrappers = (wrappers: readonly Wrapper[], wrapper: Wrapper) =>
|
|
244
229
|
wrappers.some((other) => other.name === wrapper.name)
|
|
245
230
|
? wrappers.map((other) => (other.name === wrapper.name ? wrapper : other))
|
|
246
231
|
: [wrapper, ...wrappers];
|
|
247
232
|
|
|
248
|
-
// addSafter: a safe tactic to try after safe_step_tac fails.
|
|
249
233
|
export const addSafter = (claset: Claset, name: string, tactic: GoalTactic): Claset => ({
|
|
250
234
|
...claset,
|
|
251
235
|
swrappers: updateWrappers(claset.swrappers, { name, wrap: (inner) => orElseGoal(inner, tactic) }),
|
|
252
236
|
});
|
|
253
237
|
|
|
254
|
-
// addbefore: a tactic to try before the unsafe step tactic, with backtracking.
|
|
255
238
|
export const addbefore = (claset: Claset, name: string, tactic: GoalTactic): Claset => ({
|
|
256
239
|
...claset,
|
|
257
240
|
uwrappers: updateWrappers(claset.uwrappers, { name, wrap: (inner) => appendGoal(tactic, inner) }),
|
|
@@ -263,14 +246,12 @@ const appSWrappers = (context: ClassicalContext, tactic: GoalTactic) =>
|
|
|
263
246
|
export const appWrappers = (context: ClassicalContext, tactic: GoalTactic) =>
|
|
264
247
|
context.claset.uwrappers.reduce((result, wrapper) => wrapper.wrap(result), tactic);
|
|
265
248
|
|
|
266
|
-
// contr_tac: solves a goal that assumes both P and ~P.
|
|
267
249
|
const contrTac = (context: ClassicalContext): GoalTactic =>
|
|
268
250
|
thenGoal(
|
|
269
251
|
eresolveTac(context.limits, [context.data.notElim]),
|
|
270
252
|
orElseGoal(eqAssumeTac, assumeTac(context.limits)),
|
|
271
253
|
);
|
|
272
254
|
|
|
273
|
-
// eq_mp_tac: from P --> Q and P, keeps Q, without instantiating variables.
|
|
274
255
|
const eqMpTac =
|
|
275
256
|
(context: ClassicalContext): GoalTactic =>
|
|
276
257
|
(index) =>
|
|
@@ -279,7 +260,6 @@ const eqMpTac =
|
|
|
279
260
|
eqAssumeTac(index),
|
|
280
261
|
);
|
|
281
262
|
|
|
282
|
-
// safe_step_tac: one safe inference, by matching rather than unification.
|
|
283
263
|
const safeStepTac = (context: ClassicalContext): GoalTactic =>
|
|
284
264
|
appSWrappers(
|
|
285
265
|
context,
|
|
@@ -292,7 +272,6 @@ const safeStepTac = (context: ClassicalContext): GoalTactic =>
|
|
|
292
272
|
]),
|
|
293
273
|
);
|
|
294
274
|
|
|
295
|
-
// safe_steps_tac: safe inferences on goal index for as long as they apply.
|
|
296
275
|
export const safeStepsTac =
|
|
297
276
|
(context: ClassicalContext): GoalTactic =>
|
|
298
277
|
(index) =>
|
|
@@ -300,7 +279,6 @@ export const safeStepsTac =
|
|
|
300
279
|
condTac(hasFewerPrems(index), noTac, (state) => safeStepTac(context)(index)(state)),
|
|
301
280
|
);
|
|
302
281
|
|
|
303
|
-
// safe_tac: safe inferences on all goals for as long as they apply.
|
|
304
282
|
export const safeTac = (context: ClassicalContext): Tactic =>
|
|
305
283
|
repeatDeterm1(firstGoalTac(safeStepsTac(context)));
|
|
306
284
|
|
|
@@ -324,7 +302,6 @@ const eqContrTac =
|
|
|
324
302
|
const eqAssumeContrTac = (context: ClassicalContext) =>
|
|
325
303
|
orElseGoal(eqAssumeTac, eqContrTac(context));
|
|
326
304
|
|
|
327
|
-
// bimatch2_tac: two-way branching only where one branch closes at once.
|
|
328
305
|
const bimatch2Tac =
|
|
329
306
|
(context: ClassicalContext, netpair: NetPair<TaggedRule>): GoalTactic =>
|
|
330
307
|
(index) =>
|
|
@@ -345,7 +322,6 @@ const clarifyStepTac = (context: ClassicalContext): GoalTactic =>
|
|
|
345
322
|
]),
|
|
346
323
|
);
|
|
347
324
|
|
|
348
|
-
// clarify_tac: safe steps that do not split the goal.
|
|
349
325
|
export const clarifyTac = (context: ClassicalContext): GoalTactic =>
|
|
350
326
|
selectGoal(repeatDeterm(clarifyStepTac(context)(1)));
|
|
351
327
|
|
|
@@ -364,7 +340,6 @@ const instStepTac = (context: ClassicalContext): GoalTactic =>
|
|
|
364
340
|
export const unsafeStepTac = (context: ClassicalContext): GoalTactic =>
|
|
365
341
|
biresolveFromNetsTac(context.limits, context.claset.unsafe);
|
|
366
342
|
|
|
367
|
-
// step_tac: a safe step, or else an unsafe one.
|
|
368
343
|
const stepTac =
|
|
369
344
|
(context: ClassicalContext): GoalTactic =>
|
|
370
345
|
(index) =>
|
|
@@ -373,15 +348,12 @@ const stepTac =
|
|
|
373
348
|
appWrappers(context, orElseGoal(instStepTac(context), unsafeStepTac(context)))(index),
|
|
374
349
|
);
|
|
375
350
|
|
|
376
|
-
// Drule.size_of_thm, the sizef of Isabelle/TLA+'s Classical: the size of the proposition with its
|
|
377
|
-
// flex-flex pairs.
|
|
378
351
|
const sizeOfThm = (thm: Thm) =>
|
|
379
352
|
thm.tpairs.reduce(
|
|
380
353
|
(size, pair) => size + 2 + sizeOfTerm(pair[0]) + sizeOfTerm(pair[1]),
|
|
381
354
|
sizeOfTerm(thm.prop),
|
|
382
355
|
);
|
|
383
356
|
|
|
384
|
-
// first_best_tac: best-first search with step_tac on the first goal.
|
|
385
357
|
export const firstBestTac = (context: ClassicalContext, atomizeRules: readonly Thm[]): GoalTactic =>
|
|
386
358
|
thenGoal(
|
|
387
359
|
atomizePremsTac(context.limits, atomizeRules),
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
// Ported from Isabelle2025's Provers/hypsubst.ML. Copyright (c) 1986-2025 University of
|
|
2
|
-
// Cambridge, Technische Universitaet Muenchen, and contributors, see LICENSE.
|
|
3
|
-
//
|
|
4
|
-
// Substitution using an equality assumption x = t: eliminates x from the subgoal.
|
|
1
|
+
// Ported from Isabelle2025's Provers/hypsubst.ML. Copyright (c) 1986-2025 University of Cambridge, Technische Universitaet Muenchen, and contributors, see LICENSE.
|
|
5
2
|
|
|
6
3
|
import { TlaIsabelleError } from "../../../errors";
|
|
7
4
|
import { asmRl, compIncr, revcutRl, thinRl, zeroVarIndexes } from "../pure/drule";
|
|
@@ -77,9 +74,7 @@ interface HypsubstContext {
|
|
|
77
74
|
readonly data: HypsubstData;
|
|
78
75
|
}
|
|
79
76
|
|
|
80
|
-
// The equality offers no variable to eliminate.
|
|
81
77
|
class NoMatch {}
|
|
82
|
-
// The subgoal has no suitable equality.
|
|
83
78
|
class EqVar {}
|
|
84
79
|
|
|
85
80
|
const isTermError = (error: unknown) =>
|
|
@@ -87,7 +82,6 @@ const isTermError = (error: unknown) =>
|
|
|
87
82
|
const isThmError = (error: unknown) =>
|
|
88
83
|
error instanceof TlaIsabelleError && error.exception === "THM";
|
|
89
84
|
|
|
90
|
-
// The simplifier turns bound variables into special free variables; any bound variable will do.
|
|
91
85
|
const inspectContract = (term: Term) => {
|
|
92
86
|
const contracted = etaContract(term);
|
|
93
87
|
return contracted.kind === "Free" && isBoundName(contracted.name) ? mkBound(0) : contracted;
|
|
@@ -96,8 +90,6 @@ const inspectContract = (term: Term) => {
|
|
|
96
90
|
const hasVars = (term: Term) => (flagsOf(term) & HAS_VAR) !== 0;
|
|
97
91
|
const hasTVars = (term: Term) => existsType((type) => maxidxOfTyp(type) >= 0, term);
|
|
98
92
|
|
|
99
|
-
// inspect_pair: true to use the equality as it is, false to reorient it first, with the variable
|
|
100
|
-
// to substitute.
|
|
101
93
|
const inspectPair = (
|
|
102
94
|
isBound: boolean,
|
|
103
95
|
isNoVars: boolean,
|
|
@@ -127,8 +119,6 @@ const inspectPair = (
|
|
|
127
119
|
throw new NoMatch();
|
|
128
120
|
};
|
|
129
121
|
|
|
130
|
-
// eq_var: the number of assumptions before a substitutable equality, its orientation, and whether
|
|
131
|
-
// it eliminates a free variable.
|
|
132
122
|
const eqVar = (
|
|
133
123
|
data: HypsubstData,
|
|
134
124
|
isBound: boolean,
|
|
@@ -190,7 +180,6 @@ const withEqVar = (build: (goal: Term, index: number) => Tactic): GoalTactic =>
|
|
|
190
180
|
}
|
|
191
181
|
});
|
|
192
182
|
|
|
193
|
-
// mk_eqs: the equality as a rewrite rule that eliminates its variable.
|
|
194
183
|
const mkEqs = (data: HypsubstData, isBound: boolean, thm: Thm): Thm[] => {
|
|
195
184
|
try {
|
|
196
185
|
const [left, right] = data.destEq(data.destTrueprop(thm.prop));
|
|
@@ -253,7 +242,9 @@ const instSubstTac = (context: HypsubstContext, isLeft: boolean, rule: Thm): Goa
|
|
|
253
242
|
const conclusion = data.destTrueprop(stripAssumsConcl(goal));
|
|
254
243
|
const lifted = liftRule(goal, state.maxidx, rule);
|
|
255
244
|
const head = headOf(data.destTrueprop(stripAssumsConcl(lifted.prop)));
|
|
256
|
-
const [
|
|
245
|
+
const [leftVar, rightVar] = data.destEq(
|
|
246
|
+
data.destTrueprop(stripAssumsConcl(premsOf(lifted)[0])),
|
|
247
|
+
);
|
|
257
248
|
if (head.kind !== "Var") throw new TlaIsabelleError("TERM", "dest_Var");
|
|
258
249
|
const binders = binderTypes(head.type);
|
|
259
250
|
const paramTypes = binders.slice(0, -1);
|
|
@@ -277,9 +268,9 @@ const instSubstTac = (context: HypsubstContext, isLeft: boolean, rule: Thm): Goa
|
|
|
277
268
|
const motive = absParams(mkAbs("x", paramType, body));
|
|
278
269
|
const tyenv = matchTypes(lastType, paramType, emptyTyEnv);
|
|
279
270
|
if (tyenv === undefined) throw new TlaIsabelleError("TYPE", "Thm.match");
|
|
280
|
-
const
|
|
281
|
-
const
|
|
282
|
-
if (
|
|
271
|
+
const leftHead = headOf(leftVar);
|
|
272
|
+
const rightHead = headOf(rightVar);
|
|
273
|
+
if (leftHead.kind !== "Var" || rightHead.kind !== "Var")
|
|
283
274
|
throw new TlaIsabelleError("TERM", "dest_Var");
|
|
284
275
|
const instantiated = instantiate(
|
|
285
276
|
[
|
|
@@ -296,8 +287,8 @@ const instSubstTac = (context: HypsubstContext, isLeft: boolean, rule: Thm): Goa
|
|
|
296
287
|
},
|
|
297
288
|
{
|
|
298
289
|
variable: mkVar(
|
|
299
|
-
|
|
300
|
-
|
|
290
|
+
leftHead.name,
|
|
291
|
+
leftHead.index,
|
|
301
292
|
funTs(
|
|
302
293
|
paramTypes.map((type) => substType(tyenv, type)),
|
|
303
294
|
paramType,
|
|
@@ -307,8 +298,8 @@ const instSubstTac = (context: HypsubstContext, isLeft: boolean, rule: Thm): Goa
|
|
|
307
298
|
},
|
|
308
299
|
{
|
|
309
300
|
variable: mkVar(
|
|
310
|
-
|
|
311
|
-
|
|
301
|
+
rightHead.name,
|
|
302
|
+
rightHead.index,
|
|
312
303
|
funTs(
|
|
313
304
|
paramTypes.map((type) => substType(tyenv, type)),
|
|
314
305
|
paramType,
|
|
@@ -354,8 +345,6 @@ const revDupElim = (thm: Thm) => {
|
|
|
354
345
|
return result;
|
|
355
346
|
};
|
|
356
347
|
|
|
357
|
-
// hyp_subst_tac with hypsubst_thin off, its default: substitutes for free or bound variables and
|
|
358
|
-
// drops equalities on bound variables.
|
|
359
348
|
export const hypSubstTac =
|
|
360
349
|
(context: HypsubstContext): GoalTactic =>
|
|
361
350
|
(index) =>
|
|
@@ -386,7 +375,6 @@ const reverseNTac = (context: HypsubstContext, count: number, index: number): Ta
|
|
|
386
375
|
),
|
|
387
376
|
);
|
|
388
377
|
|
|
389
|
-
// all_imp_intr_tac: reintroduces the hypotheses, leaving the changed ones at the end.
|
|
390
378
|
const allImpIntrTac = (context: HypsubstContext, hyps: readonly Term[], index: number): Tactic => {
|
|
391
379
|
const imptac =
|
|
392
380
|
(count: number, remaining: readonly Term[]): Tactic =>
|
|
@@ -407,8 +395,6 @@ const allImpIntrTac = (context: HypsubstContext, hyps: readonly Term[], index: n
|
|
|
407
395
|
return imptac(0, [...hyps].reverse());
|
|
408
396
|
};
|
|
409
397
|
|
|
410
|
-
// blast_hyp_subst_tac: the version for blast, which moves the hypotheses the substitution changes
|
|
411
|
-
// to the front.
|
|
412
398
|
export const blastHypSubstTac = (context: HypsubstContext): GoalTactic =>
|
|
413
399
|
withEqVar((goal, index) => {
|
|
414
400
|
const [count, [orientation]] = eqVar(context.data, false, false, false, goal);
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
// Ported from Isabelle2025's Pure/thm.ML. Copyright (c) 1986-2025 University of Cambridge,
|
|
2
|
-
// Technische Universitaet Muenchen, and contributors, see LICENSE.
|
|
3
|
-
//
|
|
4
|
-
// The term operations behind Thm.bicompose, which builds the theorem itself in thm.ts.
|
|
1
|
+
// Ported from Isabelle2025's Pure/thm.ML. Copyright (c) 1986-2025 University of Cambridge, Technische Universitaet Muenchen, and contributors, see LICENSE.
|
|
5
2
|
|
|
6
3
|
import { TlaIsabelleError } from "../../../errors";
|
|
7
4
|
import { normTerm, type Envir } from "./envir";
|
|
@@ -54,8 +51,6 @@ const makeDistinct = (pairs: readonly [string, string][]) => {
|
|
|
54
51
|
return table;
|
|
55
52
|
};
|
|
56
53
|
|
|
57
|
-
// Thm.rename_bvars: renames bound variables and some unknowns of the new premises after the
|
|
58
|
-
// names in the disagreement pairs.
|
|
59
54
|
export const renameBvars = (
|
|
60
55
|
dpairs: readonly Tpair[],
|
|
61
56
|
tpairs: readonly Tpair[],
|
|
@@ -86,16 +81,24 @@ export const renameBvars = (
|
|
|
86
81
|
);
|
|
87
82
|
const delClashing = (
|
|
88
83
|
isClash: boolean,
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
clashed: Set<string>,
|
|
85
|
+
taken: Set<string>,
|
|
91
86
|
rest: readonly [string, string][],
|
|
92
87
|
kept: [string, string][],
|
|
93
88
|
): [string, string][] => {
|
|
94
|
-
if (rest.length === 0)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
89
|
+
if (rest.length === 0)
|
|
90
|
+
return isClash ? delClashing(false, clashed, new Set(clashed), kept, []) : kept;
|
|
91
|
+
const pair = rest[0];
|
|
92
|
+
const others = rest.slice(1);
|
|
93
|
+
if (taken.has(pair[1]))
|
|
94
|
+
return delClashing(
|
|
95
|
+
true,
|
|
96
|
+
new Set(clashed).add(pair[0]),
|
|
97
|
+
new Set(taken).add(pair[0]),
|
|
98
|
+
others,
|
|
99
|
+
kept,
|
|
100
|
+
);
|
|
101
|
+
return delClashing(isClash, clashed, new Set(taken).add(pair[1]), others, [pair, ...kept]);
|
|
99
102
|
};
|
|
100
103
|
const vars = makeDistinct(delClashing(false, unchanged, new Set(unchanged), distinct, []));
|
|
101
104
|
const bounds = makeDistinct(pairs);
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
// Ported from Isabelle2025's Pure/consts.ML. Copyright (c) 1986-2025 University of Cambridge,
|
|
2
|
-
// Technische Universitaet Muenchen, and contributors, see LICENSE.
|
|
3
|
-
//
|
|
4
|
-
// A constant's type arguments: the instances of the type variables of its declared type, which
|
|
5
|
-
// Consts.declare locates once so that Consts.typargs only has to look them up.
|
|
1
|
+
// Ported from Isabelle2025's Pure/consts.ML. Copyright (c) 1986-2025 University of Cambridge, Technische Universitaet Muenchen, and contributors, see LICENSE.
|
|
6
2
|
|
|
7
3
|
import { TlaIsabelleError } from "../../../errors";
|
|
8
4
|
import type { Typ } from "./term";
|
|
9
5
|
|
|
10
6
|
export type TypargPosition = readonly number[];
|
|
11
7
|
|
|
12
|
-
// Consts.typargs_of: the path to the first occurrence of each type variable.
|
|
13
8
|
export const typargsOf = (type: Typ): TypargPosition[] => {
|
|
14
9
|
const found = new Map<string, TypargPosition>();
|
|
15
10
|
const visit = (current: Typ, path: readonly number[]) => {
|
|
@@ -21,7 +16,6 @@ export const typargsOf = (type: Typ): TypargPosition[] => {
|
|
|
21
16
|
return [...found.values()];
|
|
22
17
|
};
|
|
23
18
|
|
|
24
|
-
// Consts.typargs: the type arguments of a constant at an instance of its declared type.
|
|
25
19
|
export const typargs = (positions: readonly TypargPosition[], type: Typ): Typ[] =>
|
|
26
20
|
positions.map((path) =>
|
|
27
21
|
path.reduce((current, index) => {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
// Ported from Isabelle2025's Pure/conv.ML
|
|
2
|
-
// it equals another. Copyright (c) 1986-2025 University of Cambridge, Technische Universitaet
|
|
3
|
-
// Muenchen, and contributors, see LICENSE.
|
|
1
|
+
// Ported from Isabelle2025's Pure/conv.ML. Copyright (c) 1986-2025 University of Cambridge, Technische Universitaet Muenchen, and contributors, see LICENSE.
|
|
4
2
|
|
|
5
3
|
import { TlaIsabelleError } from "../../../errors";
|
|
6
4
|
import { destEquals, destImplies, implies, isImplies } from "./logic";
|
|
@@ -24,11 +22,9 @@ const isReflexive = (eq: Thm) => {
|
|
|
24
22
|
return aconv(lhs, rhs);
|
|
25
23
|
};
|
|
26
24
|
|
|
27
|
-
// Drule.imp_cong_rule
|
|
28
25
|
export const impCongRule = (first: Thm, second: Thm) =>
|
|
29
26
|
combination(combination(reflexive(implies), first), second);
|
|
30
27
|
|
|
31
|
-
// Conv.prems_conv ~1: converts every premise.
|
|
32
28
|
export const premsConv =
|
|
33
29
|
(convert: Conversion): Conversion =>
|
|
34
30
|
(term) =>
|
|
@@ -36,8 +32,6 @@ export const premsConv =
|
|
|
36
32
|
? impCongRule(convert(destImplies(term)[0]), premsConv(convert)(destImplies(term)[1]))
|
|
37
33
|
: reflexive(term);
|
|
38
34
|
|
|
39
|
-
// Conv.params_conv ~1: converts the body under every outer parameter, fixed as a fresh free
|
|
40
|
-
// variable.
|
|
41
35
|
export const paramsConv = (convert: Conversion): Conversion => {
|
|
42
36
|
const under =
|
|
43
37
|
(names: NameContext): Conversion =>
|
|
@@ -60,7 +54,6 @@ export const paramsConv = (convert: Conversion): Conversion => {
|
|
|
60
54
|
return (term) => under(makeNameContext(addFreeNames(term, [])))(term);
|
|
61
55
|
};
|
|
62
56
|
|
|
63
|
-
// Conv.gconv_rule: converts goal index of a state.
|
|
64
57
|
export const gconvRule = (convert: Conversion, index: number, state: Thm): Thm => {
|
|
65
58
|
if (index < 1 || index > nprems(state)) throw new TlaIsabelleError("THM", `gconv_rule ${index}`);
|
|
66
59
|
const eq = convert(premOf(state, index));
|
|
@@ -72,7 +65,6 @@ export const gconvRule = (convert: Conversion, index: number, state: Thm): Thm =
|
|
|
72
65
|
return permutePrems(0, 1 - index, converted);
|
|
73
66
|
};
|
|
74
67
|
|
|
75
|
-
// Conv.fconv_rule: converts a theorem's proposition.
|
|
76
68
|
export const fconvRule = (convert: Conversion, thm: Thm): Thm => {
|
|
77
69
|
const eq = convert(thm.prop);
|
|
78
70
|
return isReflexive(eq) ? thm : equalElim(eq, thm);
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
// Ported from Isabelle2025's Pure/drule.ML, Pure/term_subst.ML and
|
|
2
|
-
// Copyright (c) 1986-2025 University of Cambridge, Technische Universitaet Muenchen, and
|
|
3
|
-
// contributors, see LICENSE.
|
|
1
|
+
// Ported from Isabelle2025's Pure/drule.ML, Pure/term_subst.ML and Pure/Pure.thy. Copyright (c) 1986-2025 University of Cambridge, Technische Universitaet Muenchen, and contributors, see LICENSE.
|
|
4
2
|
|
|
5
3
|
import { cleanName, emptyNameContext, variantList, variantName, type NameContext } from "./name";
|
|
6
4
|
import {
|
|
@@ -14,7 +12,7 @@ import {
|
|
|
14
12
|
import { TlaIsabelleError } from "../../../errors";
|
|
15
13
|
import { allConst, isProtected, mkEquals, mkImplies, mkTerm, protect } from "./logic";
|
|
16
14
|
import { listOfSeq } from "./seq";
|
|
17
|
-
import {
|
|
15
|
+
import { distinctThms } from "./tactical";
|
|
18
16
|
import {
|
|
19
17
|
foldVars,
|
|
20
18
|
foldAtyps,
|
|
@@ -47,13 +45,6 @@ import {
|
|
|
47
45
|
|
|
48
46
|
const propVar = (name: string) => mkVar(name, 0, propT);
|
|
49
47
|
|
|
50
|
-
// The basic rules of Pure.thy, with the variable names Isabelle gives them.
|
|
51
|
-
export const cutRl = axiomThm(
|
|
52
|
-
mkImplies(
|
|
53
|
-
mkImplies(propVar("psi"), propVar("theta")),
|
|
54
|
-
mkImplies(propVar("psi"), propVar("theta")),
|
|
55
|
-
),
|
|
56
|
-
);
|
|
57
48
|
export const revcutRl = axiomThm(
|
|
58
49
|
mkImplies(propVar("V"), mkImplies(mkImplies(propVar("V"), propVar("W")), propVar("W"))),
|
|
59
50
|
);
|
|
@@ -94,7 +85,6 @@ export const trivForallEquality = axiomThm(
|
|
|
94
85
|
mkEquals(mkApp(allConst(typeA), mkAbs("x", typeA, propVar("V"))), propVar("V")),
|
|
95
86
|
);
|
|
96
87
|
|
|
97
|
-
// Drule.norm_hhf_eq: (PROP ?phi ==> (!!x. PROP ?psi x)) == (!!x. PROP ?phi ==> PROP ?psi x).
|
|
98
88
|
export const normHhfEq = axiomThm(
|
|
99
89
|
mkEquals(
|
|
100
90
|
mkImplies(
|
|
@@ -115,7 +105,6 @@ export const normHhfEq = axiomThm(
|
|
|
115
105
|
),
|
|
116
106
|
);
|
|
117
107
|
|
|
118
|
-
// Drule.is_norm_hhf: no quantifier right of an implication and no beta redex.
|
|
119
108
|
export const isNormHhf = (isProtecting: boolean, term: Term): boolean => {
|
|
120
109
|
if (term.kind === "Const") return term.name !== "Pure.sort_constraint";
|
|
121
110
|
if (term.kind === "Abs") return isNormHhf(isProtecting, term.body);
|
|
@@ -134,7 +123,6 @@ export const isNormHhf = (isProtecting: boolean, term: Term): boolean => {
|
|
|
134
123
|
return isNormHhf(isProtecting, term.fun) && isNormHhf(isProtecting, term.arg);
|
|
135
124
|
};
|
|
136
125
|
|
|
137
|
-
// Drule.outer_params: the outermost parameters, named apart.
|
|
138
126
|
const outerParams = (term: Term) => {
|
|
139
127
|
const vars = stripAllVars(term);
|
|
140
128
|
const names = variantList(
|
|
@@ -144,7 +132,6 @@ const outerParams = (term: Term) => {
|
|
|
144
132
|
return vars.map((variable, index) => ({ name: names[index], type: variable.type }));
|
|
145
133
|
};
|
|
146
134
|
|
|
147
|
-
// Variable.gen_all: the outermost parameters become schematic variables.
|
|
148
135
|
export const genAll = (thm: Thm) => {
|
|
149
136
|
const index = Math.max(thm.maxidx, -1) + 1;
|
|
150
137
|
return outerParams(thm.prop).reduce(
|
|
@@ -153,9 +140,8 @@ export const genAll = (thm: Thm) => {
|
|
|
153
140
|
);
|
|
154
141
|
};
|
|
155
142
|
|
|
156
|
-
// Thm.forall_intr_vars: quantifies the schematic variables in order of appearance.
|
|
157
143
|
export const forallIntrVars = (thm: Thm) => {
|
|
158
|
-
const vars = fullProps(thm).reduce(
|
|
144
|
+
const vars = fullProps(thm).reduce<Var[]>(
|
|
159
145
|
(result, term) =>
|
|
160
146
|
foldVars(
|
|
161
147
|
(atom, current: Var[]) =>
|
|
@@ -165,7 +151,7 @@ export const forallIntrVars = (thm: Thm) => {
|
|
|
165
151
|
term,
|
|
166
152
|
result,
|
|
167
153
|
),
|
|
168
|
-
[]
|
|
154
|
+
[],
|
|
169
155
|
);
|
|
170
156
|
return vars.reduceRight((result, variable) => forallIntr(variable, result), thm);
|
|
171
157
|
};
|
|
@@ -175,7 +161,6 @@ const variantBound = (name: string, used: NameContext) =>
|
|
|
175
161
|
|
|
176
162
|
const fullProps = (thm: Thm) => [...thm.tpairs.flatMap((pair) => [pair[0], pair[1]]), thm.prop];
|
|
177
163
|
|
|
178
|
-
// Drule.zero_var_indexes: renames the schematic variables apart with index 0.
|
|
179
164
|
export const zeroVarIndexes = (thm: Thm): Thm => {
|
|
180
165
|
const terms = fullProps(thm);
|
|
181
166
|
const tvars = terms.reduce(
|
|
@@ -224,41 +209,40 @@ export const zeroVarIndexes = (thm: Thm): Thm => {
|
|
|
224
209
|
return instantiate(insts, instantiateTypes(tyenv, thm));
|
|
225
210
|
};
|
|
226
211
|
|
|
227
|
-
// Tactic.make_elim: turns a destruction rule into an elimination rule.
|
|
228
212
|
export const makeElim = (rule: Thm) => zeroVarIndexes(rs(rule, revcutRl));
|
|
229
213
|
|
|
230
|
-
// Drule.compose: resolves tha into premise index of thb without lifting, with a unique result.
|
|
231
214
|
const compose = (tha: Thm, index: number, thb: Thm): Thm => {
|
|
232
|
-
const results =
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
215
|
+
const results = distinctThms(
|
|
216
|
+
listOfSeq(
|
|
217
|
+
bicompose(
|
|
218
|
+
undefined,
|
|
219
|
+
{ flatten: true, match: false, incremented: true },
|
|
220
|
+
{ isElim: false, rule: tha, subgoals: 0 },
|
|
221
|
+
index,
|
|
222
|
+
thb,
|
|
223
|
+
),
|
|
239
224
|
),
|
|
240
|
-
)
|
|
225
|
+
);
|
|
241
226
|
if (results.length !== 1)
|
|
242
227
|
throw new TlaIsabelleError("THM", `compose: unique result expected ${index}`);
|
|
243
228
|
return results[0];
|
|
244
229
|
};
|
|
245
230
|
|
|
246
|
-
// COMP_INCR
|
|
247
231
|
export const compIncr = (tha: Thm, thb: Thm) =>
|
|
248
232
|
compose(tha, 1, incrIndexesThm(tha.maxidx + 1, thb));
|
|
249
233
|
|
|
250
|
-
// Drule.comp_no_flatten: composes th, keeping its first count premises, into premise index of
|
|
251
|
-
// rule.
|
|
252
234
|
export const compNoFlatten = (thm: Thm, count: number, index: number, rule: Thm): Thm => {
|
|
253
|
-
const results =
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
235
|
+
const results = distinctThms(
|
|
236
|
+
listOfSeq(
|
|
237
|
+
bicompose(
|
|
238
|
+
undefined,
|
|
239
|
+
{ flatten: false, match: false, incremented: true },
|
|
240
|
+
{ isElim: false, rule: thm, subgoals: count },
|
|
241
|
+
index,
|
|
242
|
+
incrIndexesThm(thm.maxidx + 1, rule),
|
|
243
|
+
),
|
|
260
244
|
),
|
|
261
|
-
)
|
|
245
|
+
);
|
|
262
246
|
if (results.length !== 1) throw new TlaIsabelleError("THM", `comp_no_flatten ${index}`);
|
|
263
247
|
return results[0];
|
|
264
248
|
};
|