tla-ts 0.0.9 → 0.0.10-dev.63a6693bd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -1
- package/dist/compile.cjs +23 -0
- package/dist/compile.js +23 -0
- package/dist/deciders.cjs +29 -29
- package/dist/deciders.js +42 -42
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +106 -10
- package/dist/index.d.ts +106 -10
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +1 -1
- package/dist/prove-worker.cjs +1 -1
- package/dist/prove-worker.js +1 -1
- package/dist/prove.cjs +117 -37
- package/dist/prove.js +116 -36
- package/dist/run.cjs +143 -31
- package/dist/run.js +143 -31
- package/dist/tlapm.cjs +2 -2
- package/dist/tlapm.js +2 -2
- package/dist/transfer.cjs +129 -104
- package/dist/transfer.js +129 -104
- package/dist/worker.cjs +7 -7
- package/dist/worker.js +7 -7
- package/package.json +3 -1
- package/src/ast.ts +48 -62
- package/src/bags.ts +99 -102
- package/src/builtins.ts +28 -75
- package/src/bundled-modules.ts +1 -8
- package/src/check-failure.ts +116 -0
- package/src/check-trace.ts +282 -0
- package/src/check.ts +599 -754
- package/src/cli/options.ts +12 -32
- package/src/cli/run.ts +0 -2
- package/src/cli/runtime-invariants.ts +136 -0
- package/src/cli/shared.ts +19 -12
- package/src/cli/tlapm.ts +14 -25
- package/src/cli/tlc-arguments.ts +652 -0
- package/src/cli/tlc-output.ts +687 -0
- package/src/cli/tlc-usage.ts +361 -0
- package/src/cli/tlc.ts +309 -658
- package/src/cli/typescript.ts +23 -0
- package/src/cli/xml-exporter.ts +27 -49
- package/src/cli.ts +0 -1
- package/src/codegen.ts +196 -74
- package/src/config.ts +140 -109
- package/src/coverage.ts +830 -0
- package/src/dependencies.ts +14 -53
- package/src/dfid.ts +618 -0
- package/src/environment-config.ts +315 -0
- package/src/environment.ts +169 -335
- package/src/errors.ts +71 -55
- package/src/evaluate.ts +598 -340
- package/src/exit-codes.ts +37 -3
- package/src/fingerprints.ts +75 -11
- package/src/index.ts +3 -0
- package/src/instances.ts +126 -21
- package/src/java-hash.ts +7 -0
- package/src/java-overrides.ts +4 -19
- package/src/json-reader.ts +455 -0
- package/src/json.ts +252 -139
- package/src/levels.ts +46 -58
- package/src/lexer.ts +80 -100
- package/src/liveness-checker.ts +103 -153
- package/src/liveness.ts +150 -109
- package/src/obligations/action.ts +8 -39
- package/src/obligations/anonymize.ts +88 -82
- package/src/obligations/equality.ts +1 -1
- package/src/obligations/expression.ts +20 -21
- package/src/obligations/format.ts +1 -9
- package/src/obligations/generate.ts +46 -49
- package/src/obligations/index.ts +2 -13
- package/src/obligations/levels.ts +4 -8
- package/src/obligations/module.ts +28 -53
- package/src/obligations/normalize.ts +7 -25
- package/src/obligations/operators.ts +1 -2
- package/src/obligations/pragma.ts +1 -10
- package/src/obligations/printer.ts +47 -46
- package/src/obligations/proof.ts +1 -5
- package/src/obligations/regroup.ts +1 -4
- package/src/obligations/simplify.ts +42 -58
- package/src/obligations/source.ts +48 -78
- package/src/obligations/subexpression.ts +5 -11
- package/src/obligations/substitution.ts +1 -3
- package/src/obligations/temporal.ts +13 -19
- package/src/obligations/tuples.ts +3 -9
- package/src/parallel-worker.ts +30 -60
- package/src/parallel.ts +57 -71
- package/src/parser.ts +584 -316
- package/src/pcal/ast.ts +53 -86
- package/src/pcal/parse.ts +144 -219
- package/src/pcal/tokenize.ts +91 -131
- package/src/pcal/translate.ts +83 -130
- package/src/pcal/validate.ts +48 -68
- package/src/pretty-print.ts +7 -8
- package/src/prover/decide-pool.ts +8 -13
- package/src/prover/deciders.ts +3 -7
- package/src/prover/first-order.ts +0 -11
- package/src/prover/isabelle/decide.ts +0 -6
- package/src/prover/isabelle/encode.ts +11 -23
- package/src/prover/isabelle/isar/inner-syntax.ts +114 -115
- package/src/prover/isabelle/isar/method.ts +29 -53
- package/src/prover/isabelle/isar/proof.ts +1 -10
- package/src/prover/isabelle/isar/statement.ts +1 -6
- package/src/prover/isabelle/isar/theory.ts +26 -36
- package/src/prover/isabelle/isar/type-check.ts +17 -31
- package/src/prover/isabelle/provers/blast/blast.ts +17 -104
- package/src/prover/isabelle/provers/blast/branch.ts +1 -32
- package/src/prover/isabelle/provers/blast/prove.ts +1 -35
- package/src/prover/isabelle/provers/blast/rules.ts +6 -44
- package/src/prover/isabelle/provers/blast/state.ts +2 -28
- package/src/prover/isabelle/provers/blast/term.ts +9 -36
- package/src/prover/isabelle/provers/clasimp.ts +1 -13
- package/src/prover/isabelle/provers/classical.ts +14 -42
- package/src/prover/isabelle/provers/hypsubst.ts +28 -51
- package/src/prover/isabelle/pure/bicompose.ts +25 -38
- package/src/prover/isabelle/pure/consts.ts +1 -7
- package/src/prover/isabelle/pure/conv.ts +3 -17
- package/src/prover/isabelle/pure/drule.ts +33 -42
- package/src/prover/isabelle/pure/envir.ts +3 -52
- package/src/prover/isabelle/pure/goal.ts +1 -7
- package/src/prover/isabelle/pure/interrupt.ts +0 -5
- package/src/prover/isabelle/pure/list.ts +0 -3
- package/src/prover/isabelle/pure/logic.ts +2 -15
- package/src/prover/isabelle/pure/name.ts +2 -9
- package/src/prover/isabelle/pure/net.ts +3 -59
- package/src/prover/isabelle/pure/object-logic.ts +3 -10
- package/src/prover/isabelle/pure/pattern.ts +2 -19
- package/src/prover/isabelle/pure/raw-simplifier.ts +17 -62
- package/src/prover/isabelle/pure/rewriter.ts +31 -67
- package/src/prover/isabelle/pure/search.ts +3 -10
- package/src/prover/isabelle/pure/seq.ts +1 -10
- package/src/prover/isabelle/pure/simplifier.ts +4 -12
- package/src/prover/isabelle/pure/table.ts +3 -32
- package/src/prover/isabelle/pure/tactic.ts +12 -22
- package/src/prover/isabelle/pure/tactical.ts +48 -47
- package/src/prover/isabelle/pure/term-ord.ts +2 -6
- package/src/prover/isabelle/pure/term.ts +2 -43
- package/src/prover/isabelle/pure/thm.ts +27 -47
- package/src/prover/isabelle/pure/type.ts +2 -15
- package/src/prover/isabelle/pure/unify.ts +20 -30
- package/src/prover/isabelle/pure/variable.ts +3 -7
- package/src/prover/isabelle/tla/classical-setup.ts +17 -24
- package/src/prover/isabelle/tla/context.ts +15 -18
- package/src/prover/isabelle/tla/logic.ts +14 -32
- package/src/prover/isabelle/tla/simpdata.ts +46 -43
- package/src/prover/isabelle/tools/intuitionistic.ts +1 -10
- package/src/prover/ocaml.ts +0 -6
- package/src/prover/prep/action.ts +14 -54
- package/src/prover/prep/enabled-axioms.ts +12 -19
- package/src/prover/prep/fingerprint.ts +2 -21
- package/src/prover/prep/level-comparison.ts +8 -12
- package/src/prover/prep/md5.ts +0 -2
- package/src/prover/prep/methods.ts +33 -39
- package/src/prover/prep/normalize.ts +4 -28
- package/src/prover/prove-worker.ts +0 -2
- package/src/prover/prove.ts +87 -100
- package/src/prover/ptl/decide.ts +7 -12
- package/src/prover/ptl/encode.ts +14 -36
- package/src/prover/ptl/sat.ts +24 -32
- package/src/prover/ptl/tableau.ts +12 -26
- package/src/prover/smt/axioms.ts +0 -7
- package/src/prover/smt/context.ts +20 -28
- package/src/prover/smt/data.ts +433 -424
- package/src/prover/smt/encode.ts +43 -52
- package/src/prover/smt/extensionality.ts +0 -10
- package/src/prover/smt/flatten.ts +3 -22
- package/src/prover/smt/format.ts +5 -10
- package/src/prover/smt/instances.ts +0 -10
- package/src/prover/smt/rewrite.ts +663 -667
- package/src/prover/smt/solver/act-cache.ts +0 -15
- package/src/prover/smt/solver/arith-rewriter.ts +3 -48
- package/src/prover/smt/solver/array.ts +1 -3
- package/src/prover/smt/solver/asserted-formulas.ts +1 -43
- package/src/prover/smt/solver/ast-lt.ts +1 -11
- package/src/prover/smt/solver/ast-util.ts +1 -6
- package/src/prover/smt/solver/ast.ts +1 -165
- package/src/prover/smt/solver/auf-solver.ts +8 -44
- package/src/prover/smt/solver/case-split-queue.ts +1 -9
- package/src/prover/smt/solver/cg-table.ts +1 -18
- package/src/prover/smt/solver/clause.ts +1 -27
- package/src/prover/smt/solver/conflict-resolution.ts +0 -9
- package/src/prover/smt/solver/context.ts +7 -64
- package/src/prover/smt/solver/ctx-simplify.ts +14 -41
- package/src/prover/smt/solver/der.ts +2 -21
- package/src/prover/smt/solver/dyn-ack.ts +1 -11
- package/src/prover/smt/solver/e-matching.ts +4 -35
- package/src/prover/smt/solver/enode.ts +1 -21
- package/src/prover/smt/solver/expr-ref.ts +1 -5
- package/src/prover/smt/solver/expr-safe-replace.ts +1 -6
- package/src/prover/smt/solver/fingerprints.ts +1 -12
- package/src/prover/smt/solver/flat-literals.ts +1 -9
- package/src/prover/smt/solver/goal.ts +2 -14
- package/src/prover/smt/solver/hash.ts +0 -8
- package/src/prover/smt/solver/hashtable.ts +1 -12
- package/src/prover/smt/solver/internalizer.ts +7 -100
- package/src/prover/smt/solver/lbool.ts +1 -2
- package/src/prover/smt/solver/literal.ts +0 -3
- package/src/prover/smt/solver/lp/bound-propagator.ts +8 -26
- package/src/prover/smt/solver/lp/constraints.ts +2 -8
- package/src/prover/smt/solver/lp/containers.ts +12 -30
- package/src/prover/smt/solver/lp/core-solver.ts +10 -31
- package/src/prover/smt/solver/lp/cross-nested.ts +6 -20
- package/src/prover/smt/solver/lp/dep-intervals.ts +7 -22
- package/src/prover/smt/solver/lp/dependency.ts +1 -4
- package/src/prover/smt/solver/lp/dioph-eq.ts +9 -102
- package/src/prover/smt/solver/lp/explanation.ts +1 -6
- package/src/prover/smt/solver/lp/gomory.ts +9 -22
- package/src/prover/smt/solver/lp/hnf-cutter.ts +17 -23
- package/src/prover/smt/solver/lp/hnf.ts +11 -26
- package/src/prover/smt/solver/lp/int-cube.ts +15 -36
- package/src/prover/smt/solver/lp/int-solver.ts +4 -34
- package/src/prover/smt/solver/lp/lar-solver.ts +32 -81
- package/src/prover/smt/solver/lp/lar-term.ts +1 -5
- package/src/prover/smt/solver/lp/lp-settings.ts +1 -14
- package/src/prover/smt/solver/lp/maximize-term.ts +20 -45
- package/src/prover/smt/solver/lp/nex-creator.ts +5 -28
- package/src/prover/smt/solver/lp/nex.ts +1 -6
- package/src/prover/smt/solver/lp/nla-backoff.ts +1 -4
- package/src/prover/smt/solver/lp/nla-basics.ts +5 -30
- package/src/prover/smt/solver/lp/nla-core.ts +36 -135
- package/src/prover/smt/solver/lp/nla-divisions.ts +32 -42
- package/src/prover/smt/solver/lp/nla-emonics.ts +4 -21
- package/src/prover/smt/solver/lp/nla-factorization.ts +1 -4
- package/src/prover/smt/solver/lp/nla-grobner.ts +15 -69
- package/src/prover/smt/solver/lp/nla-horner.ts +3 -11
- package/src/prover/smt/solver/lp/nla-intervals.ts +2 -12
- package/src/prover/smt/solver/lp/nla-monomial-bounds.ts +16 -41
- package/src/prover/smt/solver/lp/nla-monotone.ts +2 -6
- package/src/prover/smt/solver/lp/nla-order.ts +2 -13
- package/src/prover/smt/solver/lp/nla-patcher.ts +4 -7
- package/src/prover/smt/solver/lp/nla-tangents.ts +1 -9
- package/src/prover/smt/solver/lp/nla-throttle.ts +1 -6
- package/src/prover/smt/solver/lp/nla-types.ts +1 -11
- package/src/prover/smt/solver/lp/nla-var-eqs.ts +4 -25
- package/src/prover/smt/solver/lp/nra-solver.ts +5 -52
- package/src/prover/smt/solver/lp/numeric-pair.ts +1 -4
- package/src/prover/smt/solver/lp/pdd-interval.ts +1 -3
- package/src/prover/smt/solver/lp/pdd-simplifier.ts +2 -14
- package/src/prover/smt/solver/lp/pdd-solver.ts +4 -33
- package/src/prover/smt/solver/lp/pdd.ts +7 -70
- package/src/prover/smt/solver/lp/random-updater.ts +1 -8
- package/src/prover/smt/solver/lp/static-matrix.ts +9 -19
- package/src/prover/smt/solver/lp/union-find.ts +1 -6
- package/src/prover/smt/solver/mam-compiler.ts +18 -58
- package/src/prover/smt/solver/mam-interpreter.ts +1 -21
- package/src/prover/smt/solver/maximize-ac-sharing.ts +2 -17
- package/src/prover/smt/solver/model-checker.ts +3 -37
- package/src/prover/smt/solver/model-evaluator.ts +3 -29
- package/src/prover/smt/solver/model-finder.ts +15 -32
- package/src/prover/smt/solver/model-generator.ts +1 -12
- package/src/prover/smt/solver/model-macro-solver.ts +23 -88
- package/src/prover/smt/solver/nlsat/algebraic.ts +63 -159
- package/src/prover/smt/solver/nlsat/atoms.ts +25 -23
- package/src/prover/smt/solver/nlsat/evaluator.ts +17 -22
- package/src/prover/smt/solver/nlsat/explain.ts +10 -69
- package/src/prover/smt/solver/nlsat/interval-set.ts +9 -50
- package/src/prover/smt/solver/nlsat/levelwise.ts +49 -135
- package/src/prover/smt/solver/nlsat/mpbq.ts +3 -14
- package/src/prover/smt/solver/nlsat/polynomial.ts +29 -159
- package/src/prover/smt/solver/nlsat/solver.ts +18 -90
- package/src/prover/smt/solver/nlsat/types.ts +1 -8
- package/src/prover/smt/solver/nlsat/upolynomial-factorization.ts +2 -45
- package/src/prover/smt/solver/nlsat/upolynomial.ts +11 -92
- package/src/prover/smt/solver/nnf.ts +3 -38
- package/src/prover/smt/solver/pattern-inference.ts +2 -15
- package/src/prover/smt/solver/poly-rewriter.ts +3 -23
- package/src/prover/smt/solver/propagate-values.ts +1 -10
- package/src/prover/smt/solver/proto-model.ts +3 -52
- package/src/prover/smt/solver/pull-quant.ts +1 -12
- package/src/prover/smt/solver/qe-lite-der.ts +1 -29
- package/src/prover/smt/solver/qe-lite-fm.ts +2 -25
- package/src/prover/smt/solver/qe-lite.ts +3 -33
- package/src/prover/smt/solver/qi-queue.ts +1 -16
- package/src/prover/smt/solver/quant-tactics.ts +5 -22
- package/src/prover/smt/solver/quantifier-analyzer.ts +27 -47
- package/src/prover/smt/solver/quantifier-manager.ts +2 -13
- package/src/prover/smt/solver/random-gen.ts +1 -2
- package/src/prover/smt/solver/rational.ts +1 -8
- package/src/prover/smt/solver/ref-vector.ts +1 -6
- package/src/prover/smt/solver/relevancy.ts +2 -15
- package/src/prover/smt/solver/rewriter-tpl.ts +3 -147
- package/src/prover/smt/solver/rewriter.ts +3 -85
- package/src/prover/smt/solver/rlimit.ts +2 -20
- package/src/prover/smt/solver/smtlib-parser.ts +80 -131
- package/src/prover/smt/solver/solver.ts +23 -34
- package/src/prover/smt/solver/sort.ts +1 -5
- package/src/prover/smt/solver/sticky-generations.ts +0 -5
- package/src/prover/smt/solver/theory-lra-axioms.ts +3 -24
- package/src/prover/smt/solver/theory-lra-bounds.ts +1 -7
- package/src/prover/smt/solver/theory-lra-final-check.ts +4 -22
- package/src/prover/smt/solver/theory-lra-internalize.ts +6 -43
- package/src/prover/smt/solver/theory-lra-model.ts +4 -19
- package/src/prover/smt/solver/theory-lra-propagate.ts +1 -15
- package/src/prover/smt/solver/theory-lra-state.ts +3 -8
- package/src/prover/smt/solver/theory-lra.ts +1 -8
- package/src/prover/smt/solver/var-subst.ts +2 -26
- package/src/prover/smt/table.ts +0 -8
- package/src/prover/tlapm/cache.ts +45 -40
- package/src/prover/tlapm/ocaml-marshal.ts +19 -21
- package/src/prover/tlapm/tlapm.ts +21 -20
- package/src/prover/verdict.ts +7 -2
- package/src/prover/zenon/check/check.ts +1 -11
- package/src/prover/zenon/check/definitions.ts +5 -15
- package/src/prover/zenon/check/equality.ts +0 -8
- package/src/prover/zenon/check/functions.ts +0 -4
- package/src/prover/zenon/check/keys.ts +0 -7
- package/src/prover/zenon/check/propositional.ts +0 -3
- package/src/prover/zenon/check/records.ts +1 -6
- package/src/prover/zenon/check/relations.ts +2 -14
- package/src/prover/zenon/check/rewrites.ts +2 -21
- package/src/prover/zenon/check/sets.ts +40 -61
- package/src/prover/zenon/check/terms.ts +1 -19
- package/src/prover/zenon/check/tla.ts +0 -6
- package/src/prover/zenon/decide.ts +0 -12
- package/src/prover/zenon/encode.ts +1 -8
- package/src/prover/zenon/eqrel.ts +2 -13
- package/src/prover/zenon/equality-rules.ts +0 -4
- package/src/prover/zenon/expr.ts +8 -26
- package/src/prover/zenon/index-table.ts +26 -57
- package/src/prover/zenon/isar-case.ts +9 -19
- package/src/prover/zenon/isar.ts +36 -64
- package/src/prover/zenon/limits.ts +0 -4
- package/src/prover/zenon/llproof.ts +2 -20
- package/src/prover/zenon/mltoll.ts +66 -104
- package/src/prover/zenon/node.ts +1 -11
- package/src/prover/zenon/ocaml.ts +1 -17
- package/src/prover/zenon/parse.ts +4 -12
- package/src/prover/zenon/phrase.ts +1 -11
- package/src/prover/zenon/proof.ts +0 -9
- package/src/prover/zenon/propositional-rules.ts +0 -5
- package/src/prover/zenon/rules.ts +2 -6
- package/src/prover/zenon/search.ts +5 -31
- package/src/prover/zenon/tla/functions.ts +59 -31
- package/src/prover/zenon/tla/llproof.ts +67 -76
- package/src/prover/zenon/tla/records.ts +57 -33
- package/src/prover/zenon/tla/rewrites.ts +12 -19
- package/src/prover/zenon/tla/sets.ts +83 -53
- package/src/prover/zenon/tla/terms.ts +0 -6
- package/src/prover/zenon/tla/tla.ts +66 -64
- package/src/randomization.ts +81 -35
- package/src/resolve.ts +67 -184
- package/src/runtime.ts +22 -22
- package/src/sany/builtins.ts +2 -5
- package/src/sany/generation.ts +394 -0
- package/src/sany/generator-def-entries.ts +210 -0
- package/src/sany/generator-definitions.ts +686 -0
- package/src/sany/generator-expressions.ts +1100 -0
- package/src/sany/generator-proofs.ts +662 -0
- package/src/sany/generator.ts +191 -2764
- package/src/sany/levels.ts +6 -34
- package/src/sany/lexer.ts +58 -77
- package/src/sany/linter.ts +1 -9
- package/src/sany/modules.ts +1 -5
- package/src/sany/nodes.ts +5 -43
- package/src/sany/parse-error.ts +39 -117
- package/src/sany/report.ts +32 -69
- package/src/sany/selectors.ts +49 -76
- package/src/sany/source.ts +1 -17
- package/src/sany/xml.ts +35 -117
- package/src/search.ts +541 -163
- package/src/simulate.ts +709 -0
- package/src/spec-description.ts +192 -100
- package/src/standard-definitions.ts +0 -4
- package/src/standard-modules.ts +264 -95
- package/src/state-graph.ts +52 -31
- package/src/subexpressions.ts +69 -52
- package/src/substitution-levels.ts +7 -7
- package/src/successors.ts +266 -99
- package/src/symmetry.ts +33 -25
- package/src/tableau.ts +27 -24
- package/src/tlc/fingerprint.ts +183 -67
- package/src/tlc/jar-data.ts +112 -6
- package/src/tlc/messages.ts +125 -54
- package/src/tlc/order.ts +39 -69
- package/src/tlc/random.ts +37 -49
- package/src/tlc/replay.ts +553 -228
- package/src/tlc/summary.ts +36 -47
- package/src/tlc/tlc-operators.ts +78 -44
- package/src/tlc/tlcext-operators.ts +139 -122
- package/src/tlc/trace-spec.ts +249 -0
- package/src/tlc/value-stream.ts +139 -0
- package/src/tlc/version.ts +1 -4
- package/src/transfer.ts +22 -25
- package/src/typescript/actions.ts +479 -0
- package/src/typescript/collections.ts +614 -0
- package/src/typescript/compile.ts +63 -0
- package/src/typescript/context.ts +94 -0
- package/src/typescript/emit.ts +121 -0
- package/src/typescript/expressions.ts +496 -0
- package/src/typescript/formula.ts +154 -0
- package/src/typescript/functions.ts +284 -0
- package/src/typescript/model.ts +162 -0
- package/src/typescript/names.ts +114 -0
- package/src/typescript/program.ts +48 -0
- package/src/typescript/properties.ts +139 -0
- package/src/typescript/scope.ts +112 -0
- package/src/typescript/steps.ts +167 -0
- package/src/typescript/types.ts +171 -0
- package/src/values.ts +832 -484
- package/src/worker.ts +7 -8
package/src/prover/smt/encode.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// Encodes a prepared proof obligation in SMT-LIB as tlapm's SMT backend does (encode/ and
|
|
2
|
-
// backend/smtlib.ml): TLA+ values share one sort Idv, set membership is the predicate TLA__Mem,
|
|
3
|
-
// and each symbol the obligation uses brings the symbols and axioms encode/n_data.ml lists for it.
|
|
4
|
-
|
|
5
1
|
import {
|
|
6
2
|
applyBuiltin,
|
|
7
3
|
at,
|
|
@@ -15,7 +11,19 @@ import { createPrinter } from "./context";
|
|
|
15
11
|
import { getSymbolSpec, type CollectState, type SymbolSpec } from "./data";
|
|
16
12
|
import type { Entry } from "./flatten";
|
|
17
13
|
import { declare, getTlaName, MEM } from "./format";
|
|
18
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
createEncoder,
|
|
16
|
+
encodeBool,
|
|
17
|
+
encodeIdv,
|
|
18
|
+
getEntries,
|
|
19
|
+
getUniqueName,
|
|
20
|
+
push,
|
|
21
|
+
type Binding,
|
|
22
|
+
type Encoder,
|
|
23
|
+
type EncodingSession,
|
|
24
|
+
type Env,
|
|
25
|
+
type Mode,
|
|
26
|
+
} from "./rewrite";
|
|
19
27
|
import { compareAxioms, getAxiomKey, type Axiom } from "./table";
|
|
20
28
|
|
|
21
29
|
type RecordExpr = Extract<Expr, { kind: "Record" }>;
|
|
@@ -25,7 +33,6 @@ const isSameFieldSet = (left: RecordExpr, right: RecordExpr) =>
|
|
|
25
33
|
left.fields.every((field) => right.fields.some((other) => other.name === field.name)) &&
|
|
26
34
|
right.fields.every((field) => left.fields.some((other) => other.name === field.name));
|
|
27
35
|
|
|
28
|
-
// mk_conj: e1 /\ (e2 /\ ...).
|
|
29
36
|
const conjoinRight = (items: Expr[]): Expr =>
|
|
30
37
|
items.length === 1
|
|
31
38
|
? items[0]
|
|
@@ -45,8 +52,6 @@ const decompose = (left: Expr, right: Expr, from: Expr): Expr => {
|
|
|
45
52
|
);
|
|
46
53
|
};
|
|
47
54
|
|
|
48
|
-
// N_rewrite.simpl_receq, before Type.Synthesize: an equality of two record constructors with the same fields is the conjunction of
|
|
49
|
-
// the equalities of their fields, paired by name.
|
|
50
55
|
const simplifyRecordEqualities = (expression: Expr): Expr => {
|
|
51
56
|
const inner = mapChildren(expression, simplifyRecordEqualities);
|
|
52
57
|
if (
|
|
@@ -61,8 +66,7 @@ const simplifyRecordEqualities = (expression: Expr): Expr => {
|
|
|
61
66
|
return at(decompose(inner.args[0], inner.args[1], inner), inner);
|
|
62
67
|
};
|
|
63
68
|
|
|
64
|
-
//
|
|
65
|
-
// field values, so a record inside a record keeps the order it's written in.
|
|
69
|
+
// tlapm doesn't visit the field values, so a record inside a record keeps its written order.
|
|
66
70
|
const sortRecordFields = (expression: Expr): Expr =>
|
|
67
71
|
expression.kind === "Record" || expression.kind === "Rect"
|
|
68
72
|
? {
|
|
@@ -71,8 +75,6 @@ const sortRecordFields = (expression: Expr): Expr =>
|
|
|
71
75
|
}
|
|
72
76
|
: mapChildren(expression, sortRecordFields);
|
|
73
77
|
|
|
74
|
-
// N_axiomatize.collect: each symbol the obligation uses, in the order tlapm visits them, brings
|
|
75
|
-
// the symbols and axioms it depends on, smallest name first.
|
|
76
78
|
const collectSymbols = (entries: Entry[], encoder: Encoder) => {
|
|
77
79
|
const state: CollectState = {
|
|
78
80
|
recordFields: encoder.recordFields,
|
|
@@ -98,8 +100,6 @@ const collectSymbols = (entries: Entry[], encoder: Encoder) => {
|
|
|
98
100
|
spec.axioms.forEach((entry) => axioms.set(getAxiomKey(entry), entry));
|
|
99
101
|
}
|
|
100
102
|
};
|
|
101
|
-
// A flattened symbol stands for a builtin applied to its first-order arguments and then its
|
|
102
|
-
// higher-order ones, so its higher-order text is visited after its arguments.
|
|
103
103
|
const visit = (text: string) => {
|
|
104
104
|
const tokens = text.match(/[()]|[^\s()]+/g) ?? [];
|
|
105
105
|
const pending: { depth: number; text: string }[] = [];
|
|
@@ -109,7 +109,7 @@ const collectSymbols = (entries: Entry[], encoder: Encoder) => {
|
|
|
109
109
|
if (pending.at(-1)?.depth === depth) visit(pending.pop()?.text ?? "");
|
|
110
110
|
return depth - 1;
|
|
111
111
|
}
|
|
112
|
-
const flat = encoder.flattened.get(token);
|
|
112
|
+
const flat = encoder.flattener.flattened.get(token);
|
|
113
113
|
if (!flat) {
|
|
114
114
|
const builtin = getTlaName(token);
|
|
115
115
|
if (builtin !== undefined) add(builtin);
|
|
@@ -128,16 +128,12 @@ const collectSymbols = (entries: Entry[], encoder: Encoder) => {
|
|
|
128
128
|
return { symbols, axioms };
|
|
129
129
|
};
|
|
130
130
|
|
|
131
|
-
type Encoder = ReturnType<typeof createEncoder>;
|
|
132
|
-
|
|
133
131
|
const HYPOTHESIS: Mode = { isOmitted: false, polarity: "Negative", at: undefined, depth: 0 };
|
|
134
132
|
|
|
135
|
-
// Prep.expand_defs substitutes visible definitions and pragmas, so they declare nothing.
|
|
136
133
|
const isExpanded = (hyp: Extract<Hyp, { kind: "Defn" }>) =>
|
|
137
134
|
hyp.definition.kind === "Bpragma" ||
|
|
138
135
|
(hyp.definition.kind === "Operator" && hyp.visibility === "Visible");
|
|
139
136
|
|
|
140
|
-
// Smtlib.is_sndord_fact: an ASSUME that declares an operator, which tlapm leaves out.
|
|
141
137
|
const isSecondOrder = (expression: Expr) =>
|
|
142
138
|
expression.kind === "Sequent" &&
|
|
143
139
|
expression.sequent.context.some((hyp) => hyp.kind === "Fresh" && hyp.shape > 0);
|
|
@@ -147,32 +143,30 @@ interface EncodedContext {
|
|
|
147
143
|
entries: Entry[];
|
|
148
144
|
}
|
|
149
145
|
|
|
150
|
-
// Declares each hypothesis's names and asserts its facts, in order, as Smtlib.pp_print_obligation.
|
|
151
146
|
const encodeContext = (context: Hyp[], encoder: Encoder) =>
|
|
152
147
|
context.reduce<EncodedContext>(
|
|
153
148
|
(state, hyp) => {
|
|
154
|
-
const
|
|
155
|
-
env:
|
|
149
|
+
const extend = (binding: Binding, entries: Entry[] = []) => ({
|
|
150
|
+
env: push(state.env, binding),
|
|
156
151
|
entries: [...state.entries, ...entries],
|
|
157
152
|
});
|
|
158
153
|
switch (hyp.kind) {
|
|
159
154
|
case "Fresh": {
|
|
160
|
-
const symbol =
|
|
155
|
+
const symbol = getUniqueName(encoder, hyp.name);
|
|
161
156
|
const binding: Binding =
|
|
162
157
|
hyp.shape === 0
|
|
163
158
|
? { kind: "constant", symbol }
|
|
164
159
|
: { kind: "operator", symbol, arity: hyp.shape };
|
|
165
160
|
const declaration = declare(symbol, hyp.shape);
|
|
166
|
-
if (!hyp.domain || hyp.domainVisibility === "Hidden")
|
|
167
|
-
|
|
168
|
-
const fact = `(assert (${MEM} ${symbol} ${
|
|
169
|
-
return
|
|
161
|
+
if (!hyp.domain || hyp.domainVisibility === "Hidden")
|
|
162
|
+
return extend(binding, [declaration]);
|
|
163
|
+
const fact = `(assert (${MEM} ${symbol} ${encodeIdv(encoder, hyp.domain, state.env, HYPOTHESIS)}))`;
|
|
164
|
+
return extend(binding, [declaration, ...getEntries(encoder, fact)]);
|
|
170
165
|
}
|
|
171
|
-
// Rewrite.elim_flex: a variable is two constants, the second for its primed value.
|
|
172
166
|
case "Flex": {
|
|
173
|
-
const symbol =
|
|
174
|
-
const primed =
|
|
175
|
-
return
|
|
167
|
+
const symbol = getUniqueName(encoder, hyp.name);
|
|
168
|
+
const primed = getUniqueName(encoder, `${hyp.name}_prime`);
|
|
169
|
+
return extend({ kind: "variable", name: hyp.name, symbol, primed }, [
|
|
176
170
|
declare(symbol, 0),
|
|
177
171
|
declare(primed, 0),
|
|
178
172
|
]);
|
|
@@ -180,38 +174,39 @@ const encodeContext = (context: Hyp[], encoder: Encoder) =>
|
|
|
180
174
|
case "Defn": {
|
|
181
175
|
const definition = hyp.definition;
|
|
182
176
|
if (isExpanded(hyp))
|
|
183
|
-
return
|
|
177
|
+
return extend({ kind: "unsupported", reason: "an expanded definition" });
|
|
184
178
|
if (definition.kind === "Instance")
|
|
185
|
-
return
|
|
179
|
+
return extend({ kind: "unsupported", reason: "an instance" });
|
|
186
180
|
if (definition.kind === "Recursive") {
|
|
187
|
-
const symbol =
|
|
188
|
-
return
|
|
181
|
+
const symbol = getUniqueName(encoder, `CONSTANT_${definition.name}_`);
|
|
182
|
+
return extend({ kind: "operator", symbol, arity: definition.shape }, [
|
|
189
183
|
declare(symbol, definition.shape),
|
|
190
184
|
]);
|
|
191
185
|
}
|
|
192
186
|
if (definition.kind !== "Operator")
|
|
193
|
-
return
|
|
187
|
+
return extend({ kind: "unsupported", reason: "a definition" });
|
|
194
188
|
const body = definition.body;
|
|
195
189
|
const params = body.kind === "Lambda" ? body.params : [];
|
|
196
190
|
if (params.some((param) => param.shape > 0))
|
|
197
|
-
return
|
|
191
|
+
return extend({
|
|
198
192
|
kind: "secondOrder",
|
|
199
193
|
name: definition.name,
|
|
200
194
|
shapes: params.map((param) => param.shape),
|
|
201
195
|
});
|
|
202
|
-
const symbol =
|
|
203
|
-
return
|
|
196
|
+
const symbol = getUniqueName(encoder, definition.name);
|
|
197
|
+
return extend({ kind: "operator", symbol, arity: params.length }, [
|
|
204
198
|
declare(symbol, params.length),
|
|
205
199
|
]);
|
|
206
200
|
}
|
|
207
201
|
case "Fact": {
|
|
208
202
|
const binding: Binding = { kind: "unsupported", reason: "a reference to a fact" };
|
|
209
|
-
if (hyp.visibility === "Hidden") return
|
|
203
|
+
if (hyp.visibility === "Hidden") return extend(binding);
|
|
210
204
|
const isOmitted = isSecondOrder(hyp.expression);
|
|
211
|
-
const entries =
|
|
212
|
-
|
|
205
|
+
const entries = getEntries(
|
|
206
|
+
encoder,
|
|
207
|
+
`(assert ${encodeBool(encoder, hyp.expression, state.env, { ...HYPOTHESIS, isOmitted })})`,
|
|
213
208
|
);
|
|
214
|
-
return
|
|
209
|
+
return extend(
|
|
215
210
|
binding,
|
|
216
211
|
isOmitted
|
|
217
212
|
? entries.map((entry) => (typeof entry === "string" ? { omitted: entry } : entry))
|
|
@@ -223,9 +218,6 @@ const encodeContext = (context: Hyp[], encoder: Encoder) =>
|
|
|
223
218
|
{ env: undefined, entries: [] },
|
|
224
219
|
);
|
|
225
220
|
|
|
226
|
-
// Smtlib.pp_print_obligation: the logic, the sort, the builtin symbols by name, their axioms,
|
|
227
|
-
// then the hypotheses in order, the goal last. It throws a TlaUnsupportedError for what the
|
|
228
|
-
// encoding can't express, where tlapm's encoder fails.
|
|
229
221
|
export const encodeSmt = (prepared: Sequent, session: EncodingSession) => {
|
|
230
222
|
const simplified = sortRecordFields(
|
|
231
223
|
simplifyRecordEqualities({ kind: "Sequent", sequent: prepared }),
|
|
@@ -235,11 +227,12 @@ export const encodeSmt = (prepared: Sequent, session: EncodingSession) => {
|
|
|
235
227
|
const context = encodeContext(sequent.context, encoder);
|
|
236
228
|
const goal = isSecondOrder(sequent.active)
|
|
237
229
|
? []
|
|
238
|
-
:
|
|
239
|
-
|
|
230
|
+
: getEntries(
|
|
231
|
+
encoder,
|
|
232
|
+
`(assert (! (not ${encodeBool(encoder, sequent.active, context.env, { ...HYPOTHESIS, polarity: "Positive" })}) :named |Goal|))`,
|
|
240
233
|
);
|
|
241
234
|
const entries = [...context.entries, ...goal];
|
|
242
|
-
const
|
|
235
|
+
const resolve = createPrinter(encoder.declared);
|
|
243
236
|
const collected = collectSymbols(entries, encoder);
|
|
244
237
|
const declarations = [...collected.symbols]
|
|
245
238
|
.toSorted((left, right) => compareStrings(left[0], right[0]))
|
|
@@ -258,8 +251,6 @@ export const encodeSmt = (prepared: Sequent, session: EncodingSession) => {
|
|
|
258
251
|
return "omitted" in entry ? [] : entry.getLines(keys);
|
|
259
252
|
}),
|
|
260
253
|
];
|
|
261
|
-
// Smtlib.collect_sorts declares Idv only when a symbol or a bound variable has that sort.
|
|
262
|
-
// Type.Synthesize gives that sort to each definition left in the context, though none is printed.
|
|
263
254
|
const isIdvUsed =
|
|
264
255
|
lines.some((line) => /\bIdv\b/.test(line)) ||
|
|
265
256
|
sequent.context.some(
|
|
@@ -269,7 +260,7 @@ export const encodeSmt = (prepared: Sequent, session: EncodingSession) => {
|
|
|
269
260
|
!isExpanded(hyp),
|
|
270
261
|
);
|
|
271
262
|
return ["(set-logic UFNIA)", ...(isIdvUsed ? ["(declare-sort Idv 0)"] : []), ...lines]
|
|
272
|
-
.map(
|
|
263
|
+
.map(resolve)
|
|
273
264
|
.concat("(check-sat)", "(exit)")
|
|
274
265
|
.join("\n");
|
|
275
266
|
};
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// Standardize.set_extensionality_visitor: an equality of sets where it may need proving triggers
|
|
2
|
-
// the set extensionality axiom, through TrigEq.
|
|
3
|
-
|
|
4
1
|
import {
|
|
5
2
|
CAP,
|
|
6
3
|
CUP,
|
|
@@ -16,14 +13,10 @@ import {
|
|
|
16
13
|
|
|
17
14
|
export type Polarity = "Positive" | "Negative" | "Neither";
|
|
18
15
|
|
|
19
|
-
// The head of a set equality whose polarity keeps it from triggering set extensionality unless a
|
|
20
|
-
// cast encloses it: (?trigger triggered kept).
|
|
21
16
|
const UNRESOLVED_TRIGGER = "?trigger";
|
|
22
17
|
|
|
23
18
|
const SET_HEADS = new Set([UNION, SUBSET, CUP, CAP, SET_MINUS, INT_RANGE, FUN_SET, SEQ]);
|
|
24
19
|
|
|
25
|
-
// Standardize.is_set: the applications of constructors whose values are sets. Standardize leaves
|
|
26
|
-
// BOOLEAN, STRING, Int, and Nat as bare symbols, which is_set doesn't match.
|
|
27
20
|
const isSetTerm = (text: string) => {
|
|
28
21
|
const head = /^\(?([^\s()]+)/.exec(text)?.[1] ?? "";
|
|
29
22
|
return (
|
|
@@ -34,7 +27,6 @@ const isSetTerm = (text: string) => {
|
|
|
34
27
|
);
|
|
35
28
|
};
|
|
36
29
|
|
|
37
|
-
// Picks the triggered or the kept form of each unresolved set equality in text.
|
|
38
30
|
export const resolveTriggers = (text: string, isTriggered: boolean): string => {
|
|
39
31
|
const start = text.indexOf(`(${UNRESOLVED_TRIGGER} `);
|
|
40
32
|
if (start === -1) return text;
|
|
@@ -47,7 +39,6 @@ export const resolveTriggers = (text: string, isTriggered: boolean): string => {
|
|
|
47
39
|
return text.slice(0, start) + chosen + resolveTriggers(text.slice(keptEnd + 1), isTriggered);
|
|
48
40
|
};
|
|
49
41
|
|
|
50
|
-
// The equality, or disequality, of two Idv terms at a polarity.
|
|
51
42
|
export const getEquality = (
|
|
52
43
|
left: string,
|
|
53
44
|
right: string,
|
|
@@ -58,7 +49,6 @@ export const getEquality = (
|
|
|
58
49
|
const kept = isNegated ? `(distinct ${left} ${right})` : `(= ${left} ${right})`;
|
|
59
50
|
if (!isSetTerm(left) && !isSetTerm(right)) return kept;
|
|
60
51
|
const text = isNegated ? `(not ${triggered})` : triggered;
|
|
61
|
-
// A cast around the equality may still trigger it, so both forms wait for resolveTriggers.
|
|
62
52
|
return polarity === (isNegated ? "Positive" : "Negative")
|
|
63
53
|
? `(${UNRESOLVED_TRIGGER} ${text} ${kept})`
|
|
64
54
|
: text;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
// encode/n_flatten.ml: each application of a second-order construct becomes a fresh first-order
|
|
2
|
-
// symbol, declared with its axioms before the fact that uses it.
|
|
3
|
-
|
|
4
1
|
import { declare, formatName, getClosing } from "./format";
|
|
5
2
|
import type { Axiom } from "./table";
|
|
6
3
|
|
|
7
|
-
// A symbol that Flatten introduces, with the text tlapm's collect pass visits for its
|
|
8
|
-
// higher-order arguments.
|
|
9
4
|
export interface Flattened {
|
|
10
5
|
symbol: string;
|
|
11
6
|
kind: string;
|
|
@@ -13,20 +8,16 @@ export interface Flattened {
|
|
|
13
8
|
getLines: (axioms: Set<string>) => string[];
|
|
14
9
|
}
|
|
15
10
|
|
|
16
|
-
// A fact that tlapm encodes, so its symbols bring their axioms, but leaves out of the text.
|
|
17
11
|
interface OmittedFact {
|
|
18
12
|
omitted: string;
|
|
19
13
|
}
|
|
20
14
|
|
|
21
15
|
export type Entry = string | Flattened | OmittedFact;
|
|
22
16
|
|
|
23
|
-
// A bound variable's placeholder: its name and its depth, which the printer names in scope.
|
|
24
17
|
export const getVariable = (name: string, depth: number) => `${name}#${depth}`;
|
|
25
18
|
|
|
26
19
|
export const getDepth = (variable: string) => Number(variable.slice(variable.lastIndexOf("#") + 1));
|
|
27
20
|
|
|
28
|
-
// The head that marks the Unprimable WITNESS wraps around its witness, which Prep never removes:
|
|
29
|
-
// (?unprimable term). Flatten.compare_expr tells it apart, and the printed text drops it.
|
|
30
21
|
export const UNPRIMABLE = "?unprimable";
|
|
31
22
|
|
|
32
23
|
export const removeUnprimable = (text: string): string => {
|
|
@@ -40,9 +31,6 @@ export const removeUnprimable = (text: string): string => {
|
|
|
40
31
|
);
|
|
41
32
|
};
|
|
42
33
|
|
|
43
|
-
// Flatten.compare_expr: an application matches an earlier one with the same higher-order
|
|
44
|
-
// arguments, whatever the variables bound outside them. It can't compare quantifiers or
|
|
45
|
-
// conditionals, so an argument with one matches nothing.
|
|
46
34
|
const getFlatKey = (text: string, depth: number) =>
|
|
47
35
|
/\((forall|exists|ite) /.test(text)
|
|
48
36
|
? undefined
|
|
@@ -50,20 +38,15 @@ const getFlatKey = (text: string, depth: number) =>
|
|
|
50
38
|
Number(found) < depth ? "#" : `#${Number(found) - depth}`,
|
|
51
39
|
);
|
|
52
40
|
|
|
53
|
-
// Where an application occurs: its depth of bound variables, and whether it's in a fact that
|
|
54
|
-
// Smtlib leaves out, which Flatten doesn't enter.
|
|
55
41
|
interface Site {
|
|
56
42
|
depth: number;
|
|
57
43
|
isOmitted: boolean;
|
|
58
44
|
}
|
|
59
45
|
|
|
60
|
-
// The state of Flatten.main over one obligation: its blueprint count, which init_bp_count resets
|
|
61
|
-
// for each obligation, and the symbols it introduced.
|
|
62
46
|
export const createFlattener = () => {
|
|
63
47
|
const flattened = new Map<string, Flattened>();
|
|
64
48
|
const flatKeys = new Map<string, Flattened>();
|
|
65
|
-
|
|
66
|
-
// The symbols that the fact being encoded introduces, declared before it.
|
|
49
|
+
let blueprintCount = 0;
|
|
67
50
|
const introduced: Flattened[] = [];
|
|
68
51
|
|
|
69
52
|
const flatten = (
|
|
@@ -74,8 +57,6 @@ export const createFlattener = () => {
|
|
|
74
57
|
arity: number,
|
|
75
58
|
name = `TLA__${kind}`,
|
|
76
59
|
) => {
|
|
77
|
-
// Flatten.find_hoapp skips a second-order ASSUME, so the application stays and only
|
|
78
|
-
// N_axiomatize.collect, which runs before Flatten, visits it.
|
|
79
60
|
if (site.isOmitted) {
|
|
80
61
|
const symbol = formatName(`${name}_omitted_${flattened.size}`);
|
|
81
62
|
flattened.set(symbol, { symbol, kind, visit: removeUnprimable(visit), getLines: () => [] });
|
|
@@ -83,10 +64,10 @@ export const createFlattener = () => {
|
|
|
83
64
|
}
|
|
84
65
|
const key = getFlatKey(`${name} ${visit}`, site.depth);
|
|
85
66
|
// Flatten.new_bp_id counts every application, even one that reuses an earlier symbol.
|
|
86
|
-
|
|
67
|
+
blueprintCount++;
|
|
87
68
|
const known = key === undefined ? undefined : flatKeys.get(key);
|
|
88
69
|
if (known) return known.symbol;
|
|
89
|
-
const raw = `${name}_flatnd_${
|
|
70
|
+
const raw = `${name}_flatnd_${blueprintCount}`;
|
|
90
71
|
const symbol = formatName(raw);
|
|
91
72
|
const flat: Flattened = {
|
|
92
73
|
symbol,
|
package/src/prover/smt/format.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
// backend/smtlib.ml's names and the SMT-LIB terms the encoding builds.
|
|
2
|
-
|
|
3
1
|
import type { Builtin } from "../../obligations/expression";
|
|
4
2
|
|
|
5
|
-
// Smtlib.format_smt: spells out each special character, then doubles each underscore.
|
|
6
3
|
const SPELLED: Record<string, string> = {
|
|
7
4
|
"\\": "backslash_",
|
|
8
5
|
"+": "plussign_",
|
|
@@ -39,7 +36,6 @@ const SPELLED_WORDS = new RegExp(`(${[...UNSPELLED.keys()].join("|")})`, "g");
|
|
|
39
36
|
|
|
40
37
|
export const tla = (name: string) => formatName(`TLA__${name}`);
|
|
41
38
|
|
|
42
|
-
// The builtin a symbol that tla names stands for, or undefined for any other symbol.
|
|
43
39
|
export const getTlaName = (symbol: string) =>
|
|
44
40
|
symbol.startsWith(TLA_PREFIX)
|
|
45
41
|
? symbol
|
|
@@ -139,13 +135,12 @@ export const call = (symbol: string, args: string[]) =>
|
|
|
139
135
|
export const declare = (symbol: string, arity: number, sort = "Idv", argSort = "Idv") =>
|
|
140
136
|
`(declare-fun ${symbol} (${Array.from({ length: arity }, () => argSort).join(" ")}) ${sort})`;
|
|
141
137
|
|
|
142
|
-
// The index of the parenthesis that closes the one at from.
|
|
143
138
|
export const getClosing = (text: string, from: number) => {
|
|
144
|
-
|
|
145
|
-
for (;
|
|
146
|
-
if (text[
|
|
147
|
-
if (text[
|
|
148
|
-
if (
|
|
139
|
+
let depth = 0;
|
|
140
|
+
for (let index = from; index < text.length; index++) {
|
|
141
|
+
if (text[index] === "(") depth++;
|
|
142
|
+
if (text[index] === ")") depth--;
|
|
143
|
+
if (depth === 0) return index;
|
|
149
144
|
}
|
|
150
145
|
return text.length;
|
|
151
146
|
};
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// Flatten.instantiate: the axioms of encode/n_axioms.ml for a second-order construct, instantiated
|
|
2
|
-
// for one flattened symbol. Each takes the symbol's name, the bound variables its argument uses,
|
|
3
|
-
// which become its last arguments, and the argument's text with the variable it binds.
|
|
4
|
-
|
|
5
1
|
import {
|
|
6
2
|
APPEND,
|
|
7
3
|
call,
|
|
@@ -24,7 +20,6 @@ import {
|
|
|
24
20
|
} from "./format";
|
|
25
21
|
import { axiom, getAxiomKey } from "./table";
|
|
26
22
|
|
|
27
|
-
// SetStDef for { x \in a : body }.
|
|
28
23
|
export const getSetStAxioms = (name: string, free: string[], body: string, variable: string) => {
|
|
29
24
|
const set = call(name, ["a", ...free]);
|
|
30
25
|
return [
|
|
@@ -40,7 +35,6 @@ export const getSetStAxioms = (name: string, free: string[], body: string, varia
|
|
|
40
35
|
];
|
|
41
36
|
};
|
|
42
37
|
|
|
43
|
-
// SetOfIntro, SetOfElim, and AssertIsSetOf for { element : y1 \in a1, ..., yn \in an }.
|
|
44
38
|
export const getSetOfAxioms = (name: string, free: string[], element: string, bound: string[]) => {
|
|
45
39
|
const count = bound.length;
|
|
46
40
|
const sets = getNames("a", count);
|
|
@@ -80,8 +74,6 @@ export const getSetOfAxioms = (name: string, free: string[], element: string, bo
|
|
|
80
74
|
];
|
|
81
75
|
};
|
|
82
76
|
|
|
83
|
-
// FunConstrIsafcn, FunDomDef, FunAppDef, and FunTyping when collect brought it, for
|
|
84
|
-
// [x \in a |-> body].
|
|
85
77
|
export const getFunctionAxioms = (
|
|
86
78
|
name: string,
|
|
87
79
|
free: string[],
|
|
@@ -119,7 +111,6 @@ export const getFunctionAxioms = (
|
|
|
119
111
|
];
|
|
120
112
|
};
|
|
121
113
|
|
|
122
|
-
// ChooseDef for CHOOSE x : body.
|
|
123
114
|
export const getChooseAxioms = (name: string, free: string[], body: string, variable: string) => [
|
|
124
115
|
axiom(
|
|
125
116
|
"ChooseDef",
|
|
@@ -131,7 +122,6 @@ export const getChooseAxioms = (name: string, free: string[], body: string, vari
|
|
|
131
122
|
),
|
|
132
123
|
];
|
|
133
124
|
|
|
134
|
-
// The SeqSelectseq axioms for SelectSeq(s, LAMBDA x : body).
|
|
135
125
|
export const getSelectSeqAxioms = (
|
|
136
126
|
name: string,
|
|
137
127
|
free: string[],
|