tla-ts 0.0.10-dev.d618a2d79 → 0.0.10-dev.e5c8dc315
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/dist/compile.cjs +3 -3
- package/dist/compile.js +1 -1
- package/dist/deciders.cjs +36 -36
- package/dist/deciders.js +53 -53
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +18 -4
- package/dist/index.d.ts +18 -4
- 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 +56 -56
- package/dist/prove.js +78 -78
- package/dist/run.cjs +40 -44
- package/dist/run.js +42 -46
- package/dist/tlapm.cjs +1 -1
- package/dist/tlapm.js +2 -2
- package/dist/transfer.cjs +97 -92
- package/dist/transfer.js +97 -92
- package/dist/worker.cjs +7 -7
- package/dist/worker.js +7 -7
- package/package.json +1 -1
- package/src/ast.ts +31 -3
- package/src/bags.ts +50 -29
- package/src/builtins.ts +4 -3
- package/src/check-failure.ts +13 -11
- package/src/check-trace.ts +146 -93
- package/src/check.ts +518 -281
- package/src/cli/runtime-invariants.ts +20 -56
- package/src/cli/tlc-arguments.ts +2 -2
- package/src/cli/tlc-output.ts +18 -4
- package/src/cli/tlc.ts +18 -12
- package/src/cli/xml-exporter.ts +1 -1
- package/src/codegen.ts +23 -10
- package/src/coverage.ts +255 -18
- package/src/dependencies.ts +68 -15
- package/src/dfid.ts +101 -36
- package/src/environment.ts +155 -66
- package/src/errors.ts +7 -0
- package/src/evaluate.ts +424 -135
- package/src/exit-codes.ts +28 -14
- package/src/instances.ts +152 -25
- package/src/java-hash.ts +14 -0
- package/src/java-overrides.ts +2 -2
- package/src/levels.ts +675 -236
- package/src/lexer.ts +12 -2
- package/src/liveness-checker.ts +179 -60
- package/src/liveness.ts +55 -10
- package/src/obligations/index.ts +1 -1
- package/src/obligations/normalize.ts +1 -4
- package/src/obligations/printer.ts +5 -5
- package/src/obligations/source.ts +2 -0
- package/src/parallel-worker.ts +8 -2
- package/src/parallel.ts +5 -0
- package/src/parser.ts +180 -149
- package/src/prover/isabelle/isar/attrib.ts +4 -4
- package/src/prover/isabelle/isar/rule-cases.ts +8 -6
- package/src/prover/isabelle/provers/clasimp.ts +1 -1
- package/src/prover/isabelle/provers/hypsubst.ts +2 -2
- package/src/prover/isabelle/pure/rewriter.ts +3 -3
- package/src/prover/isabelle/pure/term.ts +3 -3
- package/src/prover/prep/md5.ts +26 -29
- package/src/prover/smt/rewrite.ts +2 -7
- package/src/prover/smt/simplify.ts +1 -1
- package/src/prover/smt/solver/ackermannize-bv-tactic.ts +3 -2
- package/src/prover/smt/solver/arith-rewriter.ts +11 -3
- package/src/prover/smt/solver/array-rewriter.ts +12 -2
- package/src/prover/smt/solver/asserted-formulas.ts +171 -58
- package/src/prover/smt/solver/ast-lt.ts +1 -1
- package/src/prover/smt/solver/ast.ts +66 -14
- package/src/prover/smt/solver/auf-solver.ts +23 -12
- package/src/prover/smt/solver/bit-blast-tactic.ts +28 -2
- package/src/prover/smt/solver/blast-term-ite.ts +47 -0
- package/src/prover/smt/solver/bound-simplifier.ts +11 -13
- package/src/prover/smt/solver/bv-decl-plugin.ts +13 -10
- package/src/prover/smt/solver/bv-rewriter.ts +1 -1
- package/src/prover/smt/solver/bv1-blast.ts +1 -1
- package/src/prover/smt/solver/card2bv.ts +35 -18
- package/src/prover/smt/solver/cofactor-elim-term-ite.ts +39 -24
- package/src/prover/smt/solver/context.ts +84 -15
- package/src/prover/smt/solver/ctx-simplify.ts +9 -4
- package/src/prover/smt/solver/datatype-decl-plugin.ts +15 -7
- package/src/prover/smt/solver/dependent-expr-state.ts +28 -16
- package/src/prover/smt/solver/diff-neq.ts +9 -8
- package/src/prover/smt/solver/dt2bv-tactic.ts +66 -28
- package/src/prover/smt/solver/elim-bounds.ts +89 -0
- package/src/prover/smt/solver/elim-term-ite-tactic.ts +48 -0
- package/src/prover/smt/solver/elim-uncnstr.ts +31 -28
- package/src/prover/smt/solver/eq2bv-tactic.ts +15 -6
- package/src/prover/smt/solver/euf/arith-internalize.ts +1 -1
- package/src/prover/smt/solver/euf/array-internalize.ts +1 -1
- package/src/prover/smt/solver/euf/bv-internalize.ts +1 -1
- package/src/prover/smt/solver/euf/egraph.ts +4 -11
- package/src/prover/smt/solver/euf/euf-solver.ts +1 -2
- package/src/prover/smt/solver/euf/mam.ts +1 -5
- package/src/prover/smt/solver/euf/q-ematch.ts +1 -2
- package/src/prover/smt/solver/euf/th-solver.ts +0 -7
- package/src/prover/smt/solver/expr2polynomial.ts +204 -79
- package/src/prover/smt/solver/factor.ts +36 -14
- package/src/prover/smt/solver/fd-solver.ts +608 -139
- package/src/prover/smt/solver/fix-dl-var.ts +2 -3
- package/src/prover/smt/solver/fm-tactic.ts +9 -7
- package/src/prover/smt/solver/fpa-rewriter.ts +1 -2
- package/src/prover/smt/solver/fpa2bv-converter.ts +3 -1
- package/src/prover/smt/solver/fpa2bv-rewriter.ts +1 -0
- package/src/prover/smt/solver/fpa2bv-tactic.ts +1 -1
- package/src/prover/smt/solver/goal.ts +6 -3
- package/src/prover/smt/solver/goal2nlsat.ts +57 -30
- package/src/prover/smt/solver/hashtable.ts +4 -0
- package/src/prover/smt/solver/internalizer.ts +1 -1
- package/src/prover/smt/solver/lia2pb.ts +1 -1
- package/src/prover/smt/solver/logic-tactics.ts +15 -5
- package/src/prover/smt/solver/lp/core-solver.ts +12 -8
- package/src/prover/smt/solver/lp/lar-solver.ts +1 -1
- package/src/prover/smt/solver/lp/lp-settings.ts +6 -2
- package/src/prover/smt/solver/lp/nla-core.ts +1 -1
- package/src/prover/smt/solver/lp/nla-grobner.ts +158 -80
- package/src/prover/smt/solver/lp/nra-solver.ts +45 -39
- package/src/prover/smt/solver/lp/pdd-interval.ts +6 -2
- package/src/prover/smt/solver/lp/pdd-simplifier.ts +60 -20
- package/src/prover/smt/solver/lp/pdd-solver.ts +72 -39
- package/src/prover/smt/solver/lp/pdd.ts +725 -290
- package/src/prover/smt/solver/lp/union-find.ts +1 -1
- package/src/prover/smt/solver/mam-compiler.ts +1 -1
- package/src/prover/smt/solver/maxcore.ts +2 -1
- package/src/prover/smt/solver/maxsmt-base.ts +1 -0
- package/src/prover/smt/solver/model-based-opt.ts +1 -1
- package/src/prover/smt/solver/model-checker.ts +1 -1
- package/src/prover/smt/solver/model-evaluator.ts +2 -0
- package/src/prover/smt/solver/model-generator.ts +85 -43
- package/src/prover/smt/solver/mpf.ts +2 -4
- package/src/prover/smt/solver/mus.ts +2 -3
- package/src/prover/smt/solver/muz/dl-context.ts +22 -44
- package/src/prover/smt/solver/muz/dl-mk-coi-filter.ts +1 -1
- package/src/prover/smt/solver/muz/dl-mk-slice.ts +3 -3
- package/src/prover/smt/solver/muz/dl-rule.ts +8 -9
- package/src/prover/smt/solver/muz/hnf.ts +2 -2
- package/src/prover/smt/solver/muz/horn-subsume-model-converter.ts +1 -1
- package/src/prover/smt/solver/muz/horn-tactic.ts +15 -2
- package/src/prover/smt/solver/muz/rule-properties.ts +22 -0
- package/src/prover/smt/solver/muz/spacer-context.ts +2 -4
- package/src/prover/smt/solver/muz/spacer-pdr.ts +1 -0
- package/src/prover/smt/solver/muz/spacer-prop-solver.ts +1 -1
- package/src/prover/smt/solver/nlqsat.ts +2 -1
- package/src/prover/smt/solver/nlsat/algebraic.ts +196 -92
- package/src/prover/smt/solver/nlsat/atoms.ts +52 -33
- package/src/prover/smt/solver/nlsat/explain.ts +375 -217
- package/src/prover/smt/solver/nlsat/levelwise.ts +460 -240
- package/src/prover/smt/solver/nlsat/polynomial.ts +2366 -681
- package/src/prover/smt/solver/nlsat/solver.ts +74 -64
- package/src/prover/smt/solver/nlsat/transcendentals.ts +41 -17
- package/src/prover/smt/solver/nlsat/upolynomial-factorization.ts +8 -4
- package/src/prover/smt/solver/nlsat/upolynomial.ts +41 -18
- package/src/prover/smt/solver/nlsat-tactic.ts +1 -1
- package/src/prover/smt/solver/nnf.ts +6 -2
- package/src/prover/smt/solver/normalize-bounds.ts +2 -2
- package/src/prover/smt/solver/occf.ts +1 -1
- package/src/prover/smt/solver/opt-context.ts +21 -7
- package/src/prover/smt/solver/opt-nlsat.ts +29 -18
- package/src/prover/smt/solver/opt-pareto.ts +19 -0
- package/src/prover/smt/solver/opt-preprocess.ts +1 -1
- package/src/prover/smt/solver/opt-solver.ts +10 -6
- package/src/prover/smt/solver/optsmt.ts +1 -1
- package/src/prover/smt/solver/parallel-tactic.ts +1 -1
- package/src/prover/smt/solver/pb-rewriter.ts +1 -4
- package/src/prover/smt/solver/pb2bv-tactic.ts +9 -3
- package/src/prover/smt/solver/poly-rewriter.ts +75 -18
- package/src/prover/smt/solver/probes.ts +88 -23
- package/src/prover/smt/solver/proto-model.ts +8 -8
- package/src/prover/smt/solver/purify-arith.ts +51 -49
- package/src/prover/smt/solver/push-app-ite.ts +37 -0
- package/src/prover/smt/solver/qe-arith-plugin.ts +2 -4
- package/src/prover/smt/solver/qe-lite.ts +2 -2
- package/src/prover/smt/solver/qe.ts +3 -2
- package/src/prover/smt/solver/qsat.ts +23 -8
- package/src/prover/smt/solver/quantifier-manager.ts +14 -9
- package/src/prover/smt/solver/recfun-decl-plugin.ts +2 -1
- package/src/prover/smt/solver/reduce-args.ts +2 -2
- package/src/prover/smt/solver/rewriter-tpl.ts +7 -6
- package/src/prover/smt/solver/rewriter.ts +31 -25
- package/src/prover/smt/solver/rlimit.ts +7 -3
- package/src/prover/smt/solver/sat/config.ts +1 -1
- package/src/prover/smt/solver/sat/goal2sat.ts +75 -12
- package/src/prover/smt/solver/sat/inc-sat-solver.ts +149 -47
- package/src/prover/smt/solver/sat/model-converter.ts +1 -1
- package/src/prover/smt/solver/sat/pb-constraint.ts +7 -0
- package/src/prover/smt/solver/sat/pb-solver.ts +26 -7
- package/src/prover/smt/solver/sat/sat-tactic.ts +54 -25
- package/src/prover/smt/solver/sat/sat2goal.ts +75 -50
- package/src/prover/smt/solver/sat/simplifier.ts +1 -1
- package/src/prover/smt/solver/sat/solver.ts +27 -47
- package/src/prover/smt/solver/seq-axioms.ts +20 -35
- package/src/prover/smt/solver/seq-decl-plugin.ts +1 -1
- package/src/prover/smt/solver/seq-derive.ts +2 -2
- package/src/prover/smt/solver/seq-eq-solver.ts +2 -2
- package/src/prover/smt/solver/seq-monadic.ts +7 -5
- package/src/prover/smt/solver/seq-re-rewriter.ts +2 -1
- package/src/prover/smt/solver/seq-re-util.ts +1 -1
- package/src/prover/smt/solver/seq-regex-bisim.ts +1 -1
- package/src/prover/smt/solver/seq-regex-live.ts +2 -2
- package/src/prover/smt/solver/seq-rewriter.ts +31 -29
- package/src/prover/smt/solver/seq-skolem.ts +0 -23
- package/src/prover/smt/solver/seq-view-witness.ts +4 -4
- package/src/prover/smt/solver/smt-consequences.ts +1 -1
- package/src/prover/smt/solver/smt-kernel.ts +48 -7
- package/src/prover/smt/solver/smt-setup.ts +106 -13
- package/src/prover/smt/solver/smtlib-parser.ts +589 -224
- package/src/prover/smt/solver/smtlib-script.ts +718 -213
- package/src/prover/smt/solver/solve-eqs.ts +36 -37
- package/src/prover/smt/solver/solver.ts +18 -4
- package/src/prover/smt/solver/tactic.ts +389 -199
- package/src/prover/smt/solver/theory-bv.ts +13 -3
- package/src/prover/smt/solver/theory-fpa.ts +1 -1
- package/src/prover/smt/solver/theory-lra-final-check.ts +1 -0
- package/src/prover/smt/solver/theory-lra-internalize.ts +2 -0
- package/src/prover/smt/solver/theory-lra-propagate.ts +12 -3
- package/src/prover/smt/solver/theory-lra-state.ts +1 -1
- package/src/prover/smt/solver/theory-lra.ts +1 -1
- package/src/prover/smt/solver/theory-pb.ts +24 -7
- package/src/prover/smt/solver/theory-seq-solve.ts +1 -1
- package/src/prover/smt/solver/theory-seq-state.ts +2 -21
- package/src/prover/smt/solver/theory-without-terms.ts +24 -0
- package/src/prover/smt/solver/tseitin-cnf.ts +15 -5
- package/src/prover/tlapm/cache.ts +8 -8
- package/src/prover/zenon/index-table.ts +5 -2
- package/src/prover/zenon/isar-case.ts +1 -1
- package/src/prover/zenon/isar.ts +2 -2
- package/src/prover/zenon/phrase.ts +1 -1
- package/src/resolve.ts +1311 -268
- package/src/runtime.ts +21 -2
- package/src/sany/builtins.ts +10 -10
- package/src/sany/generation.ts +5 -15
- package/src/sany/generator-def-entries.ts +123 -36
- package/src/sany/generator-definitions.ts +5 -3
- package/src/sany/generator-expressions.ts +60 -37
- package/src/sany/generator-proofs.ts +19 -12
- package/src/sany/generator.ts +12 -6
- package/src/sany/lexer.ts +15 -7
- package/src/sany/modules.ts +4 -2
- package/src/sany/nodes.ts +1 -1
- package/src/sany/selectors.ts +12 -6
- package/src/sany/xml.ts +2 -3
- package/src/search.ts +321 -135
- package/src/simulate.ts +247 -185
- package/src/spec-description.ts +15 -7
- package/src/standard-definitions.ts +1 -0
- package/src/standard-modules.ts +56 -22
- package/src/subexpressions.ts +666 -147
- package/src/successors.ts +50 -20
- package/src/symmetry.ts +2 -1
- package/src/tlc/jar-data.ts +10 -0
- package/src/tlc/messages.ts +3 -3
- package/src/tlc/order.ts +14 -3
- package/src/tlc/random.ts +2 -1
- package/src/tlc/replay.ts +147 -46
- package/src/tlc/tlc-operators.ts +10 -8
- package/src/tlc/tlcext-operators.ts +44 -15
- package/src/tlc/trace-spec.ts +9 -22
- package/src/trace-liveness.ts +529 -0
- package/src/typed-tier.ts +52 -31
- package/src/typescript/types.ts +2 -2
- package/src/values.ts +150 -79
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SmtCanceledError,
|
|
3
3
|
SmtParseError,
|
|
4
|
+
SmtDefaultError,
|
|
4
5
|
SmtTacticError,
|
|
5
6
|
SmtUnsupportedError,
|
|
6
7
|
} from "../../../errors";
|
|
7
|
-
import {
|
|
8
|
-
type AstManager,
|
|
9
|
-
KIND_APP,
|
|
10
|
-
OP_DIV0,
|
|
11
|
-
OP_IDIV0,
|
|
12
|
-
OP_ITE,
|
|
13
|
-
OP_MOD0,
|
|
14
|
-
OP_POWER0,
|
|
15
|
-
SORT_BOOL,
|
|
16
|
-
} from "./ast";
|
|
8
|
+
import { type AstManager, OP_DIV0, OP_IDIV0, OP_MOD0, OP_OR, OP_POWER0, SORT_BOOL } from "./ast";
|
|
17
9
|
import { createQfufbvAckrTactic, runAckermannizeBv } from "./ackermannize-bv-tactic";
|
|
18
|
-
import { AssertedFormulas } from "./asserted-formulas";
|
|
19
10
|
import { createAigTactic } from "./aig-tactic";
|
|
11
|
+
import { blastTermIte } from "./blast-term-ite";
|
|
20
12
|
import { card2bv } from "./card2bv";
|
|
21
|
-
import { Context, MBQI_MAX_ITERATIONS } from "./context";
|
|
13
|
+
import { type Context, MBQI_MAX_ITERATIONS } from "./context";
|
|
22
14
|
import { ctxSimplify } from "./ctx-simplify";
|
|
23
15
|
import { createCtxSolverSimplify } from "./ctx-solver-simplify";
|
|
24
16
|
import {
|
|
@@ -32,6 +24,7 @@ import {
|
|
|
32
24
|
import type { AckrSolver } from "./lackr";
|
|
33
25
|
import { L_FALSE, L_TRUE, L_UNDEF } from "./lbool";
|
|
34
26
|
import { DerRewriter } from "./der";
|
|
27
|
+
import { finishSimplifier, runSimplifier } from "./dependent-expr-state";
|
|
35
28
|
import { fixDlVar } from "./fix-dl-var";
|
|
36
29
|
import { runFpa2Bv } from "./fpa2bv-tactic";
|
|
37
30
|
import { type BitBlasterRewriter, runBitBlast } from "./bit-blast-tactic";
|
|
@@ -44,6 +37,7 @@ import { createSatTactic } from "./sat/sat-tactic";
|
|
|
44
37
|
import { mkThSolver } from "./euf/th-solvers";
|
|
45
38
|
import { createFdTactic } from "./fd-solver";
|
|
46
39
|
import { elimUncnstr } from "./elim-uncnstr";
|
|
40
|
+
import { runElimTermIte } from "./elim-term-ite-tactic";
|
|
47
41
|
import { rewriteUfbv } from "./demodulator";
|
|
48
42
|
import { distributeForall } from "./distribute-forall";
|
|
49
43
|
import { createDt2BvTactic } from "./dt2bv-tactic";
|
|
@@ -72,6 +66,7 @@ import { propagateValues } from "./propagate-values";
|
|
|
72
66
|
import { purifyArith } from "./purify-arith";
|
|
73
67
|
import { ModelEvaluator } from "./model-evaluator";
|
|
74
68
|
import { FuncInterp, ProtoModel } from "./proto-model";
|
|
69
|
+
import { SmtKernel } from "./smt-kernel";
|
|
75
70
|
import { isMbqiByFeatures, type SmtSetup } from "./smt-setup";
|
|
76
71
|
import { compileProbe, formatProbeValue, isQfufbv, type Probe } from "./probes";
|
|
77
72
|
import { runHorn } from "./muz/horn-tactic";
|
|
@@ -87,6 +82,7 @@ import { LOGIC_TACTICS, QFAUFBV, QFUFBV_ACKR_PREAMBLE } from "./logic-tactics";
|
|
|
87
82
|
import {
|
|
88
83
|
createCommandReader,
|
|
89
84
|
isSymbol,
|
|
85
|
+
isUnsigned,
|
|
90
86
|
type SExpr,
|
|
91
87
|
type SmtList,
|
|
92
88
|
type SmtToken,
|
|
@@ -145,9 +141,9 @@ interface NamedTactic {
|
|
|
145
141
|
|
|
146
142
|
const getDescrs = (module: string, entries: [string, number, TacticParam, boolean?][]) =>
|
|
147
143
|
new Map(
|
|
148
|
-
entries.map((
|
|
149
|
-
|
|
150
|
-
{ kind, module, defaultValue, isPorted:
|
|
144
|
+
entries.map((entry) => [
|
|
145
|
+
entry[0],
|
|
146
|
+
{ kind: entry[1], module, defaultValue: entry[2], isPorted: entry[3] ?? false },
|
|
151
147
|
]),
|
|
152
148
|
);
|
|
153
149
|
|
|
@@ -176,7 +172,7 @@ const REWRITER_DESCRS = getDescrs("rewriter", [
|
|
|
176
172
|
["sort_sums", PARAM_BOOL, false, true],
|
|
177
173
|
["gcd_rounding", PARAM_BOOL, false, true],
|
|
178
174
|
["arith_lhs", PARAM_BOOL, false, true],
|
|
179
|
-
["arith_ineq_lhs", PARAM_BOOL, false],
|
|
175
|
+
["arith_ineq_lhs", PARAM_BOOL, false, true],
|
|
180
176
|
["elim_to_real", PARAM_BOOL, false],
|
|
181
177
|
["push_to_real", PARAM_BOOL, true],
|
|
182
178
|
["eq2ineq", PARAM_BOOL, false],
|
|
@@ -255,7 +251,8 @@ export const getRewriterOptions = (manager: AstManager, params: TacticParams): R
|
|
|
255
251
|
arith: {
|
|
256
252
|
isSom: getBool(params, "flat", true) && getBool(params, "som", false),
|
|
257
253
|
isSortSums: getBool(params, "sort_sums", false),
|
|
258
|
-
|
|
254
|
+
isArithLhs: getBool(params, "arith_lhs", false),
|
|
255
|
+
isArithIneqLhs: getBool(params, "arith_ineq_lhs", false),
|
|
259
256
|
isGcdRounding: getBool(params, "gcd_rounding", false),
|
|
260
257
|
isAnumSimp: getBool(params, "algebraic_number_evaluator", true),
|
|
261
258
|
isExpandPower: getBool(params, "expand_power", false),
|
|
@@ -280,6 +277,9 @@ const SMT_DESCRS = getDescrs("smt", [
|
|
|
280
277
|
["mbqi", PARAM_BOOL, true, true],
|
|
281
278
|
["mbqi.max_iterations", PARAM_UINT, MBQI_MAX_ITERATIONS, true],
|
|
282
279
|
["arith.nl.rounds", PARAM_UINT, 1024, true],
|
|
280
|
+
["arith.branch_cut_ratio", PARAM_UINT, 2, true],
|
|
281
|
+
["random_seed", PARAM_UINT, 0, true],
|
|
282
|
+
["auto_config", PARAM_BOOL, true, true],
|
|
283
283
|
]);
|
|
284
284
|
|
|
285
285
|
// The dependencies are assertion names, which are Boolean constants, so each one is its own
|
|
@@ -287,13 +287,26 @@ const SMT_DESCRS = getDescrs("smt", [
|
|
|
287
287
|
const getKernelParams = (environment: TacticEnvironment, params: TacticParams, goal: Goal) => {
|
|
288
288
|
const manager = environment.manager;
|
|
289
289
|
const hasQuantifiers = goal.forms.items.some((form) => manager.hasQuantifierFlags[form]);
|
|
290
|
+
// smt_params ands the auto_config of the tactic with the global one, which smt does not scope.
|
|
291
|
+
const setup = {
|
|
292
|
+
...environment.setup,
|
|
293
|
+
isAutoConfig:
|
|
294
|
+
getBool(
|
|
295
|
+
params,
|
|
296
|
+
"auto_config",
|
|
297
|
+
getParameter(environment, "smt.auto_config", "true") !== "false",
|
|
298
|
+
) && getParameter(environment, "auto_config", "true") !== "false",
|
|
299
|
+
};
|
|
290
300
|
return {
|
|
291
|
-
isMbqi:
|
|
292
|
-
getBool(params, "mbqi", environment.isMbqi) ||
|
|
293
|
-
isMbqiByFeatures(environment.setup, hasQuantifiers),
|
|
301
|
+
isMbqi: getBool(params, "mbqi", environment.isMbqi) || isMbqiByFeatures(setup, hasQuantifiers),
|
|
294
302
|
mbqiMaxIterations: getUint(params, "mbqi.max_iterations", environment.mbqiMaxIterations),
|
|
295
303
|
isFindingMacros: environment.isFindingMacros,
|
|
296
|
-
setup
|
|
304
|
+
setup,
|
|
305
|
+
randomSeed: getUint(
|
|
306
|
+
params,
|
|
307
|
+
"random_seed",
|
|
308
|
+
Number(getParameter(environment, "smt.random_seed", "0")),
|
|
309
|
+
),
|
|
297
310
|
};
|
|
298
311
|
};
|
|
299
312
|
|
|
@@ -339,6 +352,11 @@ export const getSatParams = (parameters: ReadonlyMap<string, string>) =>
|
|
|
339
352
|
}),
|
|
340
353
|
);
|
|
341
354
|
|
|
355
|
+
export const getSmtTacticFailure = (context: Context) =>
|
|
356
|
+
context.checkCanceled()
|
|
357
|
+
? "canceled"
|
|
358
|
+
: `smt tactic failed to show goal to be sat/unsat ${context.getLastFailureMessage()}`;
|
|
359
|
+
|
|
342
360
|
// sat_params reads what using-params leaves unset from the sat module's global parameters.
|
|
343
361
|
const getSatTacticParams = (environment: TacticEnvironment, params: TacticParams) =>
|
|
344
362
|
new Map([...getSatParams(environment.parameters), ...params]);
|
|
@@ -355,11 +373,15 @@ const runSmt = (environment: TacticEnvironment, params: TacticParams) => (goal:
|
|
|
355
373
|
? solveGoal(manager, goal.forms.items, kernelParams)
|
|
356
374
|
: solveAssuming(manager, extracted.clauses.items, extracted.assumptions, kernelParams);
|
|
357
375
|
extracted.clauses.reset();
|
|
358
|
-
if (solved.result === L_UNDEF)
|
|
376
|
+
if (solved.result === L_UNDEF)
|
|
377
|
+
throw new SmtTacticError(solved.reasonUnknown ?? getSmtTacticFailure(solved.context));
|
|
359
378
|
goal.reset();
|
|
360
|
-
if (solved.result === L_FALSE)
|
|
379
|
+
if (solved.result === L_FALSE) {
|
|
361
380
|
goal.assert(environment.manager.falseExpr, mkCoreDependency(solved.context.unsatCore));
|
|
362
|
-
|
|
381
|
+
return [goal];
|
|
382
|
+
}
|
|
383
|
+
if (goal.isModelsEnabled) goal.model = solved.context.getModel();
|
|
384
|
+
if (solved.context.checkCanceled()) throw new SmtTacticError("canceled");
|
|
363
385
|
return [goal];
|
|
364
386
|
};
|
|
365
387
|
|
|
@@ -423,30 +445,42 @@ const createTacticSolver = (manager: AstManager, getTactic: () => Tactic): AckrS
|
|
|
423
445
|
// Each clause gets a fresh context, where Z3 pushes a scope on one context.
|
|
424
446
|
const runUnitSubsume = (environment: TacticEnvironment) => (goal: Goal) => {
|
|
425
447
|
const manager = environment.manager;
|
|
448
|
+
const kernel = new SmtKernel(manager, {
|
|
449
|
+
isMbqi: environment.isMbqi,
|
|
450
|
+
mbqiMaxIterations: environment.mbqiMaxIterations,
|
|
451
|
+
isFindingMacros: false,
|
|
452
|
+
});
|
|
453
|
+
const trail = new RefVector(manager);
|
|
426
454
|
const clauses = goal.forms.items.map(() => manager.mkFreshConst("#clause", SORT_BOOL));
|
|
427
|
-
const
|
|
428
|
-
|
|
455
|
+
for (const clause of clauses) trail.push(clause);
|
|
456
|
+
kernel.push();
|
|
457
|
+
for (const [index, form] of goal.forms.items.entries()) {
|
|
458
|
+
const definition = manager.mkEq(clauses[index], form);
|
|
459
|
+
trail.push(definition);
|
|
460
|
+
kernel.assertExpr(definition);
|
|
461
|
+
}
|
|
462
|
+
kernel.push();
|
|
463
|
+
const isDeleted = clauses.map(() => false);
|
|
429
464
|
const deleted: number[] = [];
|
|
430
465
|
for (const [index, clause] of clauses.entries()) {
|
|
431
|
-
|
|
432
|
-
const context = new Context(manager, {
|
|
433
|
-
isMbqi: environment.isMbqi,
|
|
434
|
-
mbqiMaxIterations: environment.mbqiMaxIterations,
|
|
435
|
-
relevancyLevel: 2,
|
|
436
|
-
});
|
|
437
|
-
for (const definition of definitions) asserted.assertExpr(definition);
|
|
466
|
+
kernel.push();
|
|
438
467
|
for (const [other, otherClause] of clauses.entries())
|
|
439
|
-
if (other === index)
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
468
|
+
if (other === index) {
|
|
469
|
+
const negated = manager.mkNot(clause);
|
|
470
|
+
trail.push(negated);
|
|
471
|
+
kernel.assertExpr(negated);
|
|
472
|
+
} else if (!isDeleted[other]) kernel.assertExpr(otherClause);
|
|
473
|
+
kernel.push();
|
|
474
|
+
const isUnsat = kernel.context.isInconsistent();
|
|
475
|
+
kernel.pop(2);
|
|
476
|
+
if (!isUnsat) continue;
|
|
477
|
+
isDeleted[index] = true;
|
|
478
|
+
deleted.push(index);
|
|
446
479
|
}
|
|
447
480
|
for (const index of deleted) goal.update(index, manager.trueExpr);
|
|
448
481
|
goal.elimTrue();
|
|
449
|
-
|
|
482
|
+
kernel.pop(2);
|
|
483
|
+
trail.reset();
|
|
450
484
|
return [goal];
|
|
451
485
|
};
|
|
452
486
|
|
|
@@ -455,19 +489,50 @@ const inPlace = (run: (goal: Goal) => void) => (goal: Goal) => {
|
|
|
455
489
|
return [goal];
|
|
456
490
|
};
|
|
457
491
|
|
|
458
|
-
const
|
|
459
|
-
const
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
goal.
|
|
464
|
-
manager.
|
|
492
|
+
const selectClause = (goal: Goal, isLargest: boolean) => {
|
|
493
|
+
const manager = goal.manager;
|
|
494
|
+
let position = -1;
|
|
495
|
+
let length = 0;
|
|
496
|
+
for (let index = 0; index < goal.forms.size; index++) {
|
|
497
|
+
const form = goal.forms.items[index];
|
|
498
|
+
if (manager.getOp(form) !== OP_OR) continue;
|
|
499
|
+
const currentLength = manager.getNumArgs(form);
|
|
500
|
+
if (currentLength < 2) continue;
|
|
501
|
+
if (!isLargest) return index;
|
|
502
|
+
if (currentLength > length) {
|
|
503
|
+
position = index;
|
|
504
|
+
length = currentLength;
|
|
505
|
+
}
|
|
465
506
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
507
|
+
return position;
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
const runSplitClause = (isLargest: boolean) => (goal: Goal) => {
|
|
511
|
+
const manager = goal.manager;
|
|
512
|
+
const position = selectClause(goal, isLargest);
|
|
513
|
+
if (position === -1)
|
|
514
|
+
throw new SmtTacticError("split-clause tactic failed, goal does not contain any clause");
|
|
515
|
+
if (goal.isProofsEnabled) throw new SmtUnsupportedError("the proofs of split-clause");
|
|
516
|
+
const dependency = goal.dependencies[position];
|
|
517
|
+
return manager.getArgs(goal.forms.items[position]).map((literal) => {
|
|
518
|
+
const subgoal = goal.copy();
|
|
519
|
+
subgoal.update(position, literal, dependency);
|
|
520
|
+
subgoal.depth++;
|
|
521
|
+
return subgoal;
|
|
522
|
+
});
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
const runDer = (manager: AstManager) => (goal: Goal) => {
|
|
526
|
+
runSimplifier(goal, true, (state) => {
|
|
527
|
+
const rewriter = new DerRewriter(manager);
|
|
528
|
+
return {
|
|
529
|
+
reduce: () => state.rewriteEach((form) => rewriter.rewrite(form)),
|
|
530
|
+
release: () => {
|
|
531
|
+
rewriter.der.release();
|
|
532
|
+
rewriter.release();
|
|
533
|
+
},
|
|
534
|
+
};
|
|
535
|
+
});
|
|
471
536
|
return [goal];
|
|
472
537
|
};
|
|
473
538
|
|
|
@@ -507,10 +572,16 @@ const runNnf = (manager: AstManager, params: TacticParams) => (goal: Goal) => {
|
|
|
507
572
|
const nnf = new Nnf(manager, names, mode, getBool(params, "ignore_labels", false));
|
|
508
573
|
const definitions = new RefVector(manager);
|
|
509
574
|
const size = goal.forms.size;
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
575
|
+
try {
|
|
576
|
+
for (let index = 0; !goal.isInconsistent && index < size; index++) {
|
|
577
|
+
const result = nnf.apply(goal.forms.items[index], definitions);
|
|
578
|
+
goal.update(index, result, goal.getDependency(index));
|
|
579
|
+
manager.decRef(result);
|
|
580
|
+
}
|
|
581
|
+
} catch (error) {
|
|
582
|
+
// Z3's nnf stops at the limit with a default_exception, which or-else lets pass.
|
|
583
|
+
if (!(error instanceof SmtCanceledError)) throw error;
|
|
584
|
+
throw new SmtDefaultError(manager.limit.getCancelMessage());
|
|
514
585
|
}
|
|
515
586
|
for (const definition of definitions.items) {
|
|
516
587
|
if (goal.isInconsistent) break;
|
|
@@ -647,6 +718,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
647
718
|
["max_depth", PARAM_UINT, 1024, true],
|
|
648
719
|
["propagate_eq", PARAM_BOOL, false],
|
|
649
720
|
]),
|
|
721
|
+
isTrackingDependencies: true,
|
|
650
722
|
build: (environment, params) =>
|
|
651
723
|
inPlace((goal) =>
|
|
652
724
|
ctxSimplify(
|
|
@@ -689,48 +761,40 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
689
761
|
["elim_inverses", PARAM_BOOL, true, true],
|
|
690
762
|
]),
|
|
691
763
|
]),
|
|
764
|
+
isTrackingDependencies: true,
|
|
692
765
|
build: (environment, params) => {
|
|
693
766
|
const manager = environment.manager;
|
|
694
|
-
const snf = runNnf(manager, new Map());
|
|
695
767
|
const elimRemParams = new Map([...params, ["elim_rem", true]]);
|
|
696
|
-
return
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
768
|
+
return [
|
|
769
|
+
runNnf(manager, new Map()),
|
|
770
|
+
inPlace((goal) =>
|
|
771
|
+
simplifyGoal(manager, goal, getRewriterOptions(manager, elimRemParams)),
|
|
772
|
+
),
|
|
773
|
+
inPlace((goal) =>
|
|
774
|
+
purifyArith(manager, goal, {
|
|
775
|
+
isComplete: getBool(params, "complete", true),
|
|
776
|
+
isElimRootObjects: getBool(params, "elim_root_objects", true),
|
|
777
|
+
isElimInverses: getBool(params, "elim_inverses", true),
|
|
778
|
+
}),
|
|
779
|
+
),
|
|
780
|
+
inPlace((goal) => simplifyGoal(manager, goal, getRewriterOptions(manager, params))),
|
|
781
|
+
].reduceRight((second, first) => runAndThen(first, second));
|
|
707
782
|
},
|
|
708
783
|
},
|
|
709
784
|
],
|
|
710
785
|
[
|
|
711
786
|
"elim-term-ite",
|
|
712
787
|
{
|
|
788
|
+
isTrackingDependencies: true,
|
|
713
789
|
descrs: getDescrs("", [["max_memory", PARAM_UINT, UINT_MAX, true]]),
|
|
714
|
-
build: (environment) =>
|
|
715
|
-
inPlace((goal) => {
|
|
716
|
-
const manager = environment.manager;
|
|
717
|
-
const seen = new Set<number>();
|
|
718
|
-
const todo = [...goal.forms.items];
|
|
719
|
-
for (let expr = todo.pop(); expr !== undefined; expr = todo.pop()) {
|
|
720
|
-
if (seen.has(expr) || manager.kinds[expr] !== KIND_APP) continue;
|
|
721
|
-
seen.add(expr);
|
|
722
|
-
if (manager.getOp(expr) === OP_ITE && manager.sorts[expr] !== SORT_BOOL)
|
|
723
|
-
throw new SmtUnsupportedError("elim-term-ite on a goal it changes");
|
|
724
|
-
manager.pushArgs(expr, todo);
|
|
725
|
-
}
|
|
726
|
-
goal.depth++;
|
|
727
|
-
}),
|
|
790
|
+
build: (environment) => runElimTermIte(environment.manager),
|
|
728
791
|
},
|
|
729
792
|
],
|
|
730
793
|
[
|
|
731
794
|
"tseitin-cnf-core",
|
|
732
795
|
{
|
|
733
796
|
descrs: TSEITIN_DESCRS,
|
|
797
|
+
isTrackingDependencies: true,
|
|
734
798
|
build: (environment) => inPlace((goal) => tseitinCnf(environment.manager, goal)),
|
|
735
799
|
},
|
|
736
800
|
],
|
|
@@ -738,6 +802,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
738
802
|
"tseitin-cnf",
|
|
739
803
|
{
|
|
740
804
|
descrs: TSEITIN_DESCRS,
|
|
805
|
+
isTrackingDependencies: true,
|
|
741
806
|
build: (environment, params) =>
|
|
742
807
|
inPlace((goal) => {
|
|
743
808
|
const manager = environment.manager;
|
|
@@ -752,7 +817,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
752
817
|
isEliminatingAnd: true,
|
|
753
818
|
isKeepingDistinct: false,
|
|
754
819
|
});
|
|
755
|
-
tseitinCnf(manager, goal);
|
|
820
|
+
if (!goal.isDecided()) tseitinCnf(manager, goal);
|
|
756
821
|
} finally {
|
|
757
822
|
original.reset();
|
|
758
823
|
}
|
|
@@ -764,14 +829,9 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
764
829
|
{
|
|
765
830
|
descrs: new Map(),
|
|
766
831
|
build: (environment) =>
|
|
767
|
-
inPlace((goal) =>
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
goal.elimTrue();
|
|
771
|
-
goal.elimRedundancies();
|
|
772
|
-
}
|
|
773
|
-
goal.depth++;
|
|
774
|
-
}),
|
|
832
|
+
inPlace((goal) =>
|
|
833
|
+
goal.isProofsEnabled ? finishSimplifier(goal) : applyQeLite(environment.manager, goal),
|
|
834
|
+
),
|
|
775
835
|
},
|
|
776
836
|
],
|
|
777
837
|
[
|
|
@@ -803,6 +863,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
803
863
|
[
|
|
804
864
|
"elim-uncnstr",
|
|
805
865
|
{
|
|
866
|
+
isTrackingDependencies: true,
|
|
806
867
|
descrs: getDescrs("", [
|
|
807
868
|
["max_memory", PARAM_UINT, UINT_MAX, true],
|
|
808
869
|
["max_steps", PARAM_UINT, UINT_MAX],
|
|
@@ -838,6 +899,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
838
899
|
["pb.solver", PARAM_SYMBOL, "solver", true],
|
|
839
900
|
["cardinality.encoding", PARAM_SYMBOL, "none", true],
|
|
840
901
|
]),
|
|
902
|
+
isTrackingDependencies: true,
|
|
841
903
|
build: (environment, params) =>
|
|
842
904
|
inPlace((goal) => {
|
|
843
905
|
checkParams(REWRITER_DESCRS, params);
|
|
@@ -852,6 +914,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
852
914
|
["produce_models", PARAM_BOOL, false, true],
|
|
853
915
|
["norm_int_only", PARAM_BOOL, true, true],
|
|
854
916
|
]),
|
|
917
|
+
isTrackingDependencies: true,
|
|
855
918
|
build: (environment, params) =>
|
|
856
919
|
inPlace((goal) => {
|
|
857
920
|
checkParams(REWRITER_DESCRS, params);
|
|
@@ -898,7 +961,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
898
961
|
"pb2bv",
|
|
899
962
|
{
|
|
900
963
|
descrs: new Map([
|
|
901
|
-
...[...REWRITER_DESCRS].filter((
|
|
964
|
+
...[...REWRITER_DESCRS].filter((entry) => BOOL_REWRITER_PARAMS.includes(entry[0])),
|
|
902
965
|
...getDescrs("", [
|
|
903
966
|
["max_memory", PARAM_UINT, UINT_MAX, true],
|
|
904
967
|
["pb2bv_all_clauses_limit", PARAM_UINT, 8, true],
|
|
@@ -1043,10 +1106,19 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1043
1106
|
},
|
|
1044
1107
|
],
|
|
1045
1108
|
["der", { descrs: new Map(), build: (environment) => runDer(environment.manager) }],
|
|
1109
|
+
[
|
|
1110
|
+
"blast-term-ite",
|
|
1111
|
+
{
|
|
1112
|
+
isTrackingDependencies: true,
|
|
1113
|
+
descrs: new Map(),
|
|
1114
|
+
build: (environment) => inPlace((goal) => blastTermIte(environment.manager, goal)),
|
|
1115
|
+
},
|
|
1116
|
+
],
|
|
1046
1117
|
[
|
|
1047
1118
|
"distribute-forall",
|
|
1048
1119
|
{
|
|
1049
1120
|
descrs: new Map(),
|
|
1121
|
+
isTrackingDependencies: true,
|
|
1050
1122
|
build: (environment) => inPlace((goal) => distributeForall(environment.manager, goal)),
|
|
1051
1123
|
},
|
|
1052
1124
|
],
|
|
@@ -1104,10 +1176,20 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1104
1176
|
build: (environment) => inPlace((goal) => domSimplify(environment.manager, goal)),
|
|
1105
1177
|
},
|
|
1106
1178
|
],
|
|
1179
|
+
[
|
|
1180
|
+
"split-clause",
|
|
1181
|
+
{
|
|
1182
|
+
descrs: getDescrs("", [["split_largest_clause", PARAM_BOOL, false, true]]),
|
|
1183
|
+
isTrackingDependencies: true,
|
|
1184
|
+
build: (_environment, params) =>
|
|
1185
|
+
runSplitClause(getBool(params, "split_largest_clause", false)),
|
|
1186
|
+
},
|
|
1187
|
+
],
|
|
1107
1188
|
[
|
|
1108
1189
|
"occf",
|
|
1109
1190
|
{
|
|
1110
1191
|
descrs: new Map(),
|
|
1192
|
+
isTrackingDependencies: true,
|
|
1111
1193
|
build: (environment) => inPlace((goal) => occf(environment.manager, goal)),
|
|
1112
1194
|
},
|
|
1113
1195
|
],
|
|
@@ -1135,8 +1217,22 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1135
1217
|
),
|
|
1136
1218
|
},
|
|
1137
1219
|
],
|
|
1138
|
-
[
|
|
1139
|
-
|
|
1220
|
+
[
|
|
1221
|
+
"dt2bv",
|
|
1222
|
+
{
|
|
1223
|
+
descrs: new Map(),
|
|
1224
|
+
isTrackingDependencies: true,
|
|
1225
|
+
build: (environment) => createDt2BvTactic(environment.manager),
|
|
1226
|
+
},
|
|
1227
|
+
],
|
|
1228
|
+
[
|
|
1229
|
+
"eq2bv",
|
|
1230
|
+
{
|
|
1231
|
+
descrs: new Map(),
|
|
1232
|
+
isTrackingDependencies: true,
|
|
1233
|
+
build: (environment) => createEq2BvTactic(environment.manager),
|
|
1234
|
+
},
|
|
1235
|
+
],
|
|
1140
1236
|
[
|
|
1141
1237
|
"bit-blast",
|
|
1142
1238
|
{
|
|
@@ -1148,6 +1244,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1148
1244
|
["blast_quant", PARAM_BOOL, false, true],
|
|
1149
1245
|
["blast_full", PARAM_BOOL, false, true],
|
|
1150
1246
|
]),
|
|
1247
|
+
isTrackingDependencies: true,
|
|
1151
1248
|
build: (environment, params) =>
|
|
1152
1249
|
runBitBlast(environment.manager, {
|
|
1153
1250
|
isBlastingMul: getBool(params, "blast_mul", true),
|
|
@@ -1159,7 +1256,11 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1159
1256
|
],
|
|
1160
1257
|
[
|
|
1161
1258
|
"max-bv-sharing",
|
|
1162
|
-
{
|
|
1259
|
+
{
|
|
1260
|
+
descrs: new Map(),
|
|
1261
|
+
isTrackingDependencies: true,
|
|
1262
|
+
build: (environment) => runMaxBvSharing(environment.manager),
|
|
1263
|
+
},
|
|
1163
1264
|
],
|
|
1164
1265
|
[
|
|
1165
1266
|
"bv_bound_chk",
|
|
@@ -1208,7 +1309,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1208
1309
|
const manager = environment.manager;
|
|
1209
1310
|
const preamble = createCommandReader(QFUFBV_ACKR_PREAMBLE).read() as SmtList;
|
|
1210
1311
|
return runAndThen(
|
|
1211
|
-
compile(environment, preamble,
|
|
1312
|
+
compile(environment, preamble, true).build(params),
|
|
1212
1313
|
runCond(
|
|
1213
1314
|
isQfufbv,
|
|
1214
1315
|
createQfufbvAckrTactic(manager, getRewriterOptions(manager, new Map()), true, () =>
|
|
@@ -1289,7 +1390,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1289
1390
|
{
|
|
1290
1391
|
descrs: new Map(),
|
|
1291
1392
|
isRejectingUnknown: false,
|
|
1292
|
-
build: (environment) => runQsat(environment
|
|
1393
|
+
build: (environment) => runQsat(environment, QSAT_SAT),
|
|
1293
1394
|
},
|
|
1294
1395
|
],
|
|
1295
1396
|
[
|
|
@@ -1297,7 +1398,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1297
1398
|
{
|
|
1298
1399
|
descrs: new Map(),
|
|
1299
1400
|
isRejectingUnknown: false,
|
|
1300
|
-
build: (environment) => runQsat(environment
|
|
1401
|
+
build: (environment) => runQsat(environment, QSAT_QE),
|
|
1301
1402
|
},
|
|
1302
1403
|
],
|
|
1303
1404
|
[
|
|
@@ -1305,7 +1406,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1305
1406
|
{
|
|
1306
1407
|
descrs: new Map(),
|
|
1307
1408
|
isRejectingUnknown: false,
|
|
1308
|
-
build: (environment) => runQsat(environment
|
|
1409
|
+
build: (environment) => runQsat(environment, QSAT_QE_REC),
|
|
1309
1410
|
},
|
|
1310
1411
|
],
|
|
1311
1412
|
[
|
|
@@ -1313,6 +1414,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1313
1414
|
{
|
|
1314
1415
|
descrs: SAT_DESCRS,
|
|
1315
1416
|
isRejectingUnknown: false,
|
|
1417
|
+
isTrackingDependencies: true,
|
|
1316
1418
|
build: (environment, params) =>
|
|
1317
1419
|
createSatTactic(environment.manager, getSatTacticParams(environment, params)),
|
|
1318
1420
|
},
|
|
@@ -1331,18 +1433,24 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1331
1433
|
{
|
|
1332
1434
|
descrs: SAT_DESCRS,
|
|
1333
1435
|
isRejectingUnknown: false,
|
|
1436
|
+
isTrackingDependencies: true,
|
|
1334
1437
|
build: (environment, params) =>
|
|
1335
1438
|
createSatTactic(environment.manager, getSatTacticParams(environment, params)),
|
|
1336
1439
|
},
|
|
1337
1440
|
],
|
|
1338
1441
|
[
|
|
1339
1442
|
"snf",
|
|
1340
|
-
{
|
|
1443
|
+
{
|
|
1444
|
+
descrs: NNF_DESCRS,
|
|
1445
|
+
isTrackingDependencies: true,
|
|
1446
|
+
build: (environment, params) => runNnf(environment.manager, params),
|
|
1447
|
+
},
|
|
1341
1448
|
],
|
|
1342
1449
|
[
|
|
1343
1450
|
"nnf",
|
|
1344
1451
|
{
|
|
1345
1452
|
descrs: NNF_DESCRS,
|
|
1453
|
+
isTrackingDependencies: true,
|
|
1346
1454
|
build: (environment, params) =>
|
|
1347
1455
|
runNnf(environment.manager, new Map([...params, ["mode", "full"]])),
|
|
1348
1456
|
},
|
|
@@ -1381,20 +1489,19 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1381
1489
|
|
|
1382
1490
|
const UNPORTED_TACTICS = new Set(
|
|
1383
1491
|
(
|
|
1384
|
-
"blast-term-ite " +
|
|
1385
1492
|
"bv-slice bvarray2uf collect-statistics " +
|
|
1386
1493
|
"degree-shift demodulator " +
|
|
1387
1494
|
"elim-predicates elim-uncnstr2 " +
|
|
1388
1495
|
"euf-completion ff-sat ff-simplify ff-solve ff-unique ff2bv fold-unfold fpa2bv " +
|
|
1389
1496
|
"horn-simplify injectivity pb-preprocess pqffd propagate-bv-bounds " +
|
|
1390
|
-
"propagate-bv-bounds2 propagate-values2 qfbv-sls
|
|
1497
|
+
"propagate-bv-bounds2 propagate-values2 qfbv-sls recover-01 reduce-args2 " +
|
|
1391
1498
|
"sat-preprocess sls-smt smtfd solver-subsumption special-relations " +
|
|
1392
|
-
"
|
|
1499
|
+
"subpaving symmetry-reduce"
|
|
1393
1500
|
).split(" "),
|
|
1394
1501
|
);
|
|
1395
1502
|
|
|
1396
|
-
const
|
|
1397
|
-
sexpr?.kind === "numeral" &&
|
|
1503
|
+
const isUnsignedNumeral = (sexpr: SExpr | undefined): sexpr is SmtToken =>
|
|
1504
|
+
sexpr?.kind === "numeral" && isUnsigned(sexpr.text);
|
|
1398
1505
|
|
|
1399
1506
|
const getParamName = (keyword: string) =>
|
|
1400
1507
|
keyword.replace(/^:/, "").toLowerCase().replaceAll("-", "_");
|
|
@@ -1415,7 +1522,7 @@ const parseParamValue = (kind: number, value: SExpr) =>
|
|
|
1415
1522
|
kind === PARAM_BOOL
|
|
1416
1523
|
? isSymbol(value, "true") || (isSymbol(value, "false") ? false : undefined)
|
|
1417
1524
|
: kind === PARAM_UINT
|
|
1418
|
-
?
|
|
1525
|
+
? isUnsignedNumeral(value)
|
|
1419
1526
|
? Number(value.text)
|
|
1420
1527
|
: undefined
|
|
1421
1528
|
: kind === PARAM_NUMERAL
|
|
@@ -1444,27 +1551,33 @@ const checkParams = (descrs: ParamDescrs, params: TacticParams) => {
|
|
|
1444
1551
|
}
|
|
1445
1552
|
};
|
|
1446
1553
|
|
|
1554
|
+
// sexpr2tactic reports an error at the s-expression: a list at its closing parenthesis.
|
|
1555
|
+
const getSexprPosition = (sexpr: SExpr) => (sexpr.kind === "list" ? sexpr.end : sexpr);
|
|
1556
|
+
|
|
1447
1557
|
const getParams = (
|
|
1448
1558
|
builder: TacticBuilder,
|
|
1449
1559
|
items: SExpr[],
|
|
1450
|
-
end: SmtToken,
|
|
1451
1560
|
isInternal: boolean,
|
|
1452
1561
|
): Map<string, TacticParam> => {
|
|
1453
1562
|
const params = new Map<string, TacticParam>();
|
|
1454
1563
|
for (let index = 2; index < items.length; index += 2) {
|
|
1455
1564
|
const keyword = items[index];
|
|
1456
1565
|
if (keyword.kind !== "keyword")
|
|
1457
|
-
throw new SmtParseError(
|
|
1566
|
+
throw new SmtParseError(
|
|
1567
|
+
"invalid using-params combinator, keyword expected",
|
|
1568
|
+
getSexprPosition(keyword),
|
|
1569
|
+
);
|
|
1458
1570
|
const value = items[index + 1];
|
|
1459
1571
|
if (value === undefined)
|
|
1460
|
-
throw new SmtParseError("invalid using-params combinator, parameter value expected",
|
|
1572
|
+
throw new SmtParseError("invalid using-params combinator, parameter value expected", keyword);
|
|
1461
1573
|
const found = findParam(builder.descrs, getParamName(keyword.text));
|
|
1462
1574
|
if (isInternal) {
|
|
1463
1575
|
const parsed =
|
|
1464
1576
|
found === undefined
|
|
1465
1577
|
? getUntypedParamValue(value)
|
|
1466
1578
|
: parseParamValue(found.descr.kind, value);
|
|
1467
|
-
if (parsed === undefined)
|
|
1579
|
+
if (parsed === undefined)
|
|
1580
|
+
throw new SmtParseError("invalid parameter value", getSexprPosition(value));
|
|
1468
1581
|
params.set(found?.name ?? getParamName(keyword.text), parsed);
|
|
1469
1582
|
continue;
|
|
1470
1583
|
}
|
|
@@ -1473,7 +1586,7 @@ const getParams = (
|
|
|
1473
1586
|
throw new SmtUnsupportedError(`the parameter ${keyword.text} of the tactic`);
|
|
1474
1587
|
throw new SmtParseError(
|
|
1475
1588
|
`invalid using-params combinator, unknown parameter ${getParamName(keyword.text)}`,
|
|
1476
|
-
|
|
1589
|
+
getSexprPosition(value),
|
|
1477
1590
|
);
|
|
1478
1591
|
}
|
|
1479
1592
|
const parsed = parseParamValue(found.descr.kind, value);
|
|
@@ -1486,7 +1599,7 @@ const getParams = (
|
|
|
1486
1599
|
: found.descr.kind === PARAM_NUMERAL
|
|
1487
1600
|
? "invalid parameter value, numeral expected"
|
|
1488
1601
|
: "invalid parameter value, symbol expected",
|
|
1489
|
-
|
|
1602
|
+
getSexprPosition(value),
|
|
1490
1603
|
);
|
|
1491
1604
|
if (isUnportedParam(found.descr, parsed))
|
|
1492
1605
|
throw new SmtUnsupportedError(`the parameter ${found.name} of the tactic`);
|
|
@@ -1505,19 +1618,30 @@ const isDecidedSat = (goals: Goal[]) => goals.length === 1 && goals[0].isDecided
|
|
|
1505
1618
|
|
|
1506
1619
|
const isDecidedUnsat = (goals: Goal[]) => goals.length === 1 && goals[0].isDecidedUnsat();
|
|
1507
1620
|
|
|
1621
|
+
// Deviation from Z3: and_then and repeat join the subgoals' cores, where Z3 answers an empty core.
|
|
1622
|
+
const assertUnsat = (goal: Goal, unsatGoals: Goal[]) => {
|
|
1623
|
+
goal.resetAll();
|
|
1624
|
+
goal.assert(
|
|
1625
|
+
goal.manager.falseExpr,
|
|
1626
|
+
unsatGoals.reduce<Dependency | undefined>(
|
|
1627
|
+
(core, unsatGoal) => joinDependencies(unsatGoal.getDependency(0), core),
|
|
1628
|
+
undefined,
|
|
1629
|
+
),
|
|
1630
|
+
);
|
|
1631
|
+
return [goal];
|
|
1632
|
+
};
|
|
1633
|
+
|
|
1508
1634
|
const runAndThen = (first: Tactic, second: Tactic) => (goal: Goal) => {
|
|
1509
1635
|
const goals = first(goal);
|
|
1510
1636
|
if (goals.length === 1) return goals[0].isDecided() ? goals : second(goals[0]);
|
|
1511
1637
|
const results: Goal[] = [];
|
|
1638
|
+
const unsatGoals: Goal[] = [];
|
|
1512
1639
|
for (const subgoal of goals) {
|
|
1513
1640
|
const subresults = second(subgoal);
|
|
1514
1641
|
if (isDecidedSat(subresults)) return subresults;
|
|
1515
|
-
|
|
1642
|
+
(isDecidedUnsat(subresults) ? unsatGoals : results).push(...subresults);
|
|
1516
1643
|
}
|
|
1517
|
-
|
|
1518
|
-
goal.resetAll();
|
|
1519
|
-
goal.assert(goal.manager.falseExpr);
|
|
1520
|
-
return [goal];
|
|
1644
|
+
return results.length > 0 ? results : assertUnsat(goal, unsatGoals);
|
|
1521
1645
|
};
|
|
1522
1646
|
|
|
1523
1647
|
const runOrElse = (tactics: Tactic[]) => (goal: Goal) => {
|
|
@@ -1526,12 +1650,12 @@ const runOrElse = (tactics: Tactic[]) => (goal: Goal) => {
|
|
|
1526
1650
|
try {
|
|
1527
1651
|
return tactic(goal);
|
|
1528
1652
|
} catch (error) {
|
|
1529
|
-
if (!(error instanceof SmtTacticError)) throw error;
|
|
1653
|
+
if (!(error instanceof SmtTacticError || error instanceof SmtCanceledError)) throw error;
|
|
1530
1654
|
}
|
|
1531
1655
|
goal.resetAll();
|
|
1532
1656
|
goal.copyFrom(original);
|
|
1533
1657
|
}
|
|
1534
|
-
return
|
|
1658
|
+
return tactics[tactics.length - 1](goal);
|
|
1535
1659
|
};
|
|
1536
1660
|
|
|
1537
1661
|
const isEqualGoal = (first: Goal, second: Goal) => {
|
|
@@ -1551,15 +1675,13 @@ const runRepeat = (tactic: Tactic, maxDepth: number) => {
|
|
|
1551
1675
|
if (goals.length === 1 && isEqualGoal(original, goals[0])) return goals;
|
|
1552
1676
|
if (goals.length === 1) return goals[0].isDecided() ? goals : run(depth + 1, goals[0]);
|
|
1553
1677
|
const results: Goal[] = [];
|
|
1678
|
+
const unsatGoals: Goal[] = [];
|
|
1554
1679
|
for (const subgoal of goals) {
|
|
1555
1680
|
const subresults = run(depth + 1, subgoal);
|
|
1556
1681
|
if (isDecidedSat(subresults)) return subresults;
|
|
1557
|
-
|
|
1682
|
+
(isDecidedUnsat(subresults) ? unsatGoals : results).push(...subresults);
|
|
1558
1683
|
}
|
|
1559
|
-
|
|
1560
|
-
goal.resetAll();
|
|
1561
|
-
goal.assert(goal.manager.falseExpr);
|
|
1562
|
-
return [goal];
|
|
1684
|
+
return results.length > 0 ? results : assertUnsat(goal, unsatGoals);
|
|
1563
1685
|
};
|
|
1564
1686
|
return (goal: Goal) => run(0, goal);
|
|
1565
1687
|
};
|
|
@@ -1567,22 +1689,21 @@ const runRepeat = (tactic: Tactic, maxDepth: number) => {
|
|
|
1567
1689
|
const runCond = (probe: Probe, onTrue: Tactic, onFalse: Tactic) => (goal: Goal) =>
|
|
1568
1690
|
probe(goal) === 0 ? onFalse(goal) : onTrue(goal);
|
|
1569
1691
|
|
|
1570
|
-
const checkHasArgument = (list: SmtList, combinator: string
|
|
1692
|
+
const checkHasArgument = (list: SmtList, combinator: string) => {
|
|
1571
1693
|
if (list.items.length < 2)
|
|
1572
1694
|
throw new SmtParseError(
|
|
1573
1695
|
`invalid ${combinator} combinator, at least one argument expected`,
|
|
1574
|
-
end,
|
|
1696
|
+
list.end,
|
|
1575
1697
|
);
|
|
1576
1698
|
};
|
|
1577
1699
|
|
|
1578
1700
|
const compile = (
|
|
1579
1701
|
environment: TacticEnvironment,
|
|
1580
1702
|
sexpr: SExpr,
|
|
1581
|
-
end: SmtToken,
|
|
1582
1703
|
isInternal: boolean,
|
|
1583
1704
|
): TacticBuilder => {
|
|
1584
1705
|
if (sexpr.kind !== "list") {
|
|
1585
|
-
if (!isSymbol(sexpr)) throw new SmtParseError("invalid tactic, unexpected input",
|
|
1706
|
+
if (!isSymbol(sexpr)) throw new SmtParseError("invalid tactic, unexpected input", sexpr);
|
|
1586
1707
|
const named = NAMED_TACTICS.get(sexpr.text);
|
|
1587
1708
|
if (named !== undefined)
|
|
1588
1709
|
return {
|
|
@@ -1600,7 +1721,7 @@ const compile = (
|
|
|
1600
1721
|
};
|
|
1601
1722
|
const strategy = LOGIC_TACTICS.get(sexpr.text);
|
|
1602
1723
|
if (strategy !== undefined)
|
|
1603
|
-
return compile(environment, createCommandReader(strategy).read() as SmtList,
|
|
1724
|
+
return compile(environment, createCommandReader(strategy).read() as SmtList, true);
|
|
1604
1725
|
if (UNPORTED_TACTICS.has(sexpr.text)) {
|
|
1605
1726
|
const error = new SmtUnsupportedError(`the tactic ${sexpr.text}`);
|
|
1606
1727
|
if (!isInternal) throw error;
|
|
@@ -1613,14 +1734,14 @@ const compile = (
|
|
|
1613
1734
|
},
|
|
1614
1735
|
};
|
|
1615
1736
|
}
|
|
1616
|
-
throw new SmtParseError(`invalid tactic, unknown tactic ${sexpr.text}`,
|
|
1737
|
+
throw new SmtParseError(`invalid tactic, unknown tactic ${sexpr.text}`, sexpr);
|
|
1617
1738
|
}
|
|
1618
1739
|
const head = sexpr.items[0];
|
|
1619
|
-
if (head === undefined) throw new SmtParseError("invalid tactic, arguments expected", end);
|
|
1620
|
-
if (!isSymbol(head)) throw new SmtParseError("invalid tactic, symbol expected", end);
|
|
1740
|
+
if (head === undefined) throw new SmtParseError("invalid tactic, arguments expected", sexpr.end);
|
|
1741
|
+
if (!isSymbol(head)) throw new SmtParseError("invalid tactic, symbol expected", sexpr.end);
|
|
1621
1742
|
const compileChildren = (combinator: string) => {
|
|
1622
|
-
checkHasArgument(sexpr, combinator
|
|
1623
|
-
return sexpr.items.slice(1).map((child) => compile(environment, child,
|
|
1743
|
+
checkHasArgument(sexpr, combinator);
|
|
1744
|
+
return sexpr.items.slice(1).map((child) => compile(environment, child, isInternal));
|
|
1624
1745
|
};
|
|
1625
1746
|
switch (head.text) {
|
|
1626
1747
|
case "then":
|
|
@@ -1670,27 +1791,43 @@ const compile = (
|
|
|
1670
1791
|
// The timeout is not ported, so the child runs to the end.
|
|
1671
1792
|
case "try-for": {
|
|
1672
1793
|
if (sexpr.items.length !== 3)
|
|
1673
|
-
throw new SmtParseError("invalid try-for combinator, two arguments expected", end);
|
|
1674
|
-
if (!
|
|
1794
|
+
throw new SmtParseError("invalid try-for combinator, two arguments expected", sexpr.end);
|
|
1795
|
+
if (!isUnsignedNumeral(sexpr.items[2]))
|
|
1675
1796
|
throw new SmtParseError(
|
|
1676
1797
|
"invalid try-for combinator, second argument must be an unsigned integer",
|
|
1677
|
-
end,
|
|
1798
|
+
sexpr.end,
|
|
1678
1799
|
);
|
|
1679
|
-
|
|
1800
|
+
const child = compile(environment, sexpr.items[1], isInternal);
|
|
1801
|
+
return {
|
|
1802
|
+
...child,
|
|
1803
|
+
build: (params) => {
|
|
1804
|
+
const tactic = child.build(params);
|
|
1805
|
+
return (goal) => {
|
|
1806
|
+
try {
|
|
1807
|
+
return tactic(goal);
|
|
1808
|
+
} catch (error) {
|
|
1809
|
+
if (error instanceof SmtDefaultError) throw new SmtTacticError(error.message);
|
|
1810
|
+
if (error instanceof SmtCanceledError)
|
|
1811
|
+
throw new SmtTacticError(goal.manager.limit.getCancelMessage());
|
|
1812
|
+
throw error;
|
|
1813
|
+
}
|
|
1814
|
+
};
|
|
1815
|
+
},
|
|
1816
|
+
};
|
|
1680
1817
|
}
|
|
1681
1818
|
case "fail-if-branching": {
|
|
1682
1819
|
if (sexpr.items.length !== 3 && sexpr.items.length !== 2)
|
|
1683
1820
|
throw new SmtParseError(
|
|
1684
1821
|
"invalid fail-if-branching combinator, one or two arguments expected",
|
|
1685
|
-
end,
|
|
1822
|
+
sexpr.end,
|
|
1686
1823
|
);
|
|
1687
1824
|
const bound = sexpr.items[2];
|
|
1688
|
-
if (bound !== undefined && !
|
|
1825
|
+
if (bound !== undefined && !isUnsignedNumeral(bound))
|
|
1689
1826
|
throw new SmtParseError(
|
|
1690
1827
|
"invalid fail-if-branching combinator, second argument must be an unsigned integer",
|
|
1691
|
-
end,
|
|
1828
|
+
sexpr.end,
|
|
1692
1829
|
);
|
|
1693
|
-
const child = compile(environment, sexpr.items[1],
|
|
1830
|
+
const child = compile(environment, sexpr.items[1], isInternal);
|
|
1694
1831
|
const threshold = bound === undefined ? 1 : Number(bound.text);
|
|
1695
1832
|
return {
|
|
1696
1833
|
...mergeDescrs([child]),
|
|
@@ -1708,11 +1845,17 @@ const compile = (
|
|
|
1708
1845
|
case "if-no-unsat-cores":
|
|
1709
1846
|
case "if-no-models": {
|
|
1710
1847
|
if (sexpr.items.length !== 2)
|
|
1711
|
-
throw new SmtParseError(
|
|
1712
|
-
|
|
1848
|
+
throw new SmtParseError(
|
|
1849
|
+
`invalid ${head.text} combinator, one argument expected`,
|
|
1850
|
+
sexpr.end,
|
|
1851
|
+
);
|
|
1852
|
+
const child = compile(environment, sexpr.items[1], isInternal);
|
|
1713
1853
|
const isSkipping = (goal: Goal) =>
|
|
1714
|
-
head.text === "if-no-models"
|
|
1715
|
-
|
|
1854
|
+
head.text === "if-no-models"
|
|
1855
|
+
? goal.isModelsEnabled
|
|
1856
|
+
: head.text === "if-no-proofs"
|
|
1857
|
+
? goal.isProofsEnabled
|
|
1858
|
+
: goal.isCoresEnabled;
|
|
1716
1859
|
return {
|
|
1717
1860
|
...mergeDescrs([child]),
|
|
1718
1861
|
build: (params) => {
|
|
@@ -1723,14 +1866,17 @@ const compile = (
|
|
|
1723
1866
|
}
|
|
1724
1867
|
case "repeat": {
|
|
1725
1868
|
if (sexpr.items.length !== 3 && sexpr.items.length !== 2)
|
|
1726
|
-
throw new SmtParseError(
|
|
1869
|
+
throw new SmtParseError(
|
|
1870
|
+
"invalid repeat combinator, one or two arguments expected",
|
|
1871
|
+
sexpr.end,
|
|
1872
|
+
);
|
|
1727
1873
|
const bound = sexpr.items[2];
|
|
1728
|
-
if (bound !== undefined && !
|
|
1874
|
+
if (bound !== undefined && !isUnsignedNumeral(bound))
|
|
1729
1875
|
throw new SmtParseError(
|
|
1730
1876
|
"invalid repeat combinator, second argument must be an unsigned integer",
|
|
1731
|
-
end,
|
|
1877
|
+
sexpr.end,
|
|
1732
1878
|
);
|
|
1733
|
-
const child = compile(environment, sexpr.items[1],
|
|
1879
|
+
const child = compile(environment, sexpr.items[1], isInternal);
|
|
1734
1880
|
const maxDepth = bound === undefined ? UINT_MAX : Number(bound.text);
|
|
1735
1881
|
return {
|
|
1736
1882
|
...mergeDescrs([child]),
|
|
@@ -1740,10 +1886,10 @@ const compile = (
|
|
|
1740
1886
|
case "!":
|
|
1741
1887
|
case "using-params":
|
|
1742
1888
|
case "with": {
|
|
1743
|
-
checkHasArgument(sexpr, "using-params"
|
|
1744
|
-
const child = compile(environment, sexpr.items[1],
|
|
1889
|
+
checkHasArgument(sexpr, "using-params");
|
|
1890
|
+
const child = compile(environment, sexpr.items[1], isInternal);
|
|
1745
1891
|
if (sexpr.items.length === 2) return child;
|
|
1746
|
-
const own = getParams(child, sexpr.items,
|
|
1892
|
+
const own = getParams(child, sexpr.items, isInternal);
|
|
1747
1893
|
return {
|
|
1748
1894
|
...mergeDescrs([child]),
|
|
1749
1895
|
build: (params) => child.build(new Map([...params, ...own])),
|
|
@@ -1751,8 +1897,11 @@ const compile = (
|
|
|
1751
1897
|
}
|
|
1752
1898
|
case "skip-if-failed": {
|
|
1753
1899
|
if (sexpr.items.length !== 2)
|
|
1754
|
-
throw new SmtParseError(
|
|
1755
|
-
|
|
1900
|
+
throw new SmtParseError(
|
|
1901
|
+
"invalid skip-if-failed combinator, one argument expected",
|
|
1902
|
+
sexpr.end,
|
|
1903
|
+
);
|
|
1904
|
+
const child = compile(environment, sexpr.items[1], isInternal);
|
|
1756
1905
|
return {
|
|
1757
1906
|
...mergeDescrs([child]),
|
|
1758
1907
|
build: (params) => runOrElse([child.build(params), (goal) => [goal]]),
|
|
@@ -1762,11 +1911,12 @@ const compile = (
|
|
|
1762
1911
|
case "ite":
|
|
1763
1912
|
case "cond": {
|
|
1764
1913
|
if (sexpr.items.length !== 4)
|
|
1765
|
-
throw new SmtParseError(
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1914
|
+
throw new SmtParseError(
|
|
1915
|
+
"invalid if/conditional combinator, three arguments expected",
|
|
1916
|
+
sexpr.end,
|
|
1917
|
+
);
|
|
1918
|
+
const probe = compileProbe(sexpr.items[1], isInternal);
|
|
1919
|
+
const children = sexpr.items.slice(2).map((child) => compile(environment, child, isInternal));
|
|
1770
1920
|
return {
|
|
1771
1921
|
...mergeDescrs(children),
|
|
1772
1922
|
build: (params) => runCond(probe, children[0].build(params), children[1].build(params)),
|
|
@@ -1774,9 +1924,9 @@ const compile = (
|
|
|
1774
1924
|
}
|
|
1775
1925
|
case "when": {
|
|
1776
1926
|
if (sexpr.items.length !== 3)
|
|
1777
|
-
throw new SmtParseError("invalid when combinator, two arguments expected", end);
|
|
1778
|
-
const probe = compileProbe(sexpr.items[1],
|
|
1779
|
-
const child = compile(environment, sexpr.items[2],
|
|
1927
|
+
throw new SmtParseError("invalid when combinator, two arguments expected", sexpr.end);
|
|
1928
|
+
const probe = compileProbe(sexpr.items[1], isInternal);
|
|
1929
|
+
const child = compile(environment, sexpr.items[2], isInternal);
|
|
1780
1930
|
return {
|
|
1781
1931
|
...mergeDescrs([child]),
|
|
1782
1932
|
build: (params) => runCond(probe, child.build(params), (goal) => [goal]),
|
|
@@ -1784,8 +1934,8 @@ const compile = (
|
|
|
1784
1934
|
}
|
|
1785
1935
|
case "fail-if": {
|
|
1786
1936
|
if (sexpr.items.length !== 2)
|
|
1787
|
-
throw new SmtParseError("invalid fail-if tactic, one argument expected", end);
|
|
1788
|
-
const probe = compileProbe(sexpr.items[1],
|
|
1937
|
+
throw new SmtParseError("invalid fail-if tactic, one argument expected", sexpr.end);
|
|
1938
|
+
const probe = compileProbe(sexpr.items[1], isInternal);
|
|
1789
1939
|
return {
|
|
1790
1940
|
descrs: new Map(),
|
|
1791
1941
|
isRejectingUnknown: true,
|
|
@@ -1798,7 +1948,7 @@ const compile = (
|
|
|
1798
1948
|
}
|
|
1799
1949
|
case "echo": {
|
|
1800
1950
|
if (sexpr.items.length < 2)
|
|
1801
|
-
throw new SmtParseError("invalid echo tactic, must have at least one argument", end);
|
|
1951
|
+
throw new SmtParseError("invalid echo tactic, must have at least one argument", sexpr.end);
|
|
1802
1952
|
const pieces = sexpr.items.slice(1).map((piece, index, all): Tactic => {
|
|
1803
1953
|
const newline = index === all.length - 1 ? "\n" : "";
|
|
1804
1954
|
if (piece.kind === "string")
|
|
@@ -1806,7 +1956,7 @@ const compile = (
|
|
|
1806
1956
|
environment.write(piece.text + newline, false);
|
|
1807
1957
|
return [goal];
|
|
1808
1958
|
};
|
|
1809
|
-
const probe = compileProbe(piece,
|
|
1959
|
+
const probe = compileProbe(piece, isInternal);
|
|
1810
1960
|
return (goal) => {
|
|
1811
1961
|
environment.write(formatProbeValue(probe(goal)) + newline, true);
|
|
1812
1962
|
return [goal];
|
|
@@ -1820,7 +1970,7 @@ const compile = (
|
|
|
1820
1970
|
};
|
|
1821
1971
|
}
|
|
1822
1972
|
default:
|
|
1823
|
-
throw new SmtParseError(`invalid tactic, unknown tactic combinator ${head.text}`, end);
|
|
1973
|
+
throw new SmtParseError(`invalid tactic, unknown tactic combinator ${head.text}`, sexpr.end);
|
|
1824
1974
|
}
|
|
1825
1975
|
};
|
|
1826
1976
|
|
|
@@ -1868,27 +2018,27 @@ export const mkIncSatPreprocess = (manager: AstManager, bitBlaster: BitBlasterRe
|
|
|
1868
2018
|
),
|
|
1869
2019
|
].reduceRight((second, first) => runAndThen(first, second));
|
|
1870
2020
|
|
|
1871
|
-
export const compileTactic = (environment: TacticEnvironment, sexpr: SExpr
|
|
1872
|
-
compile(environment, sexpr,
|
|
2021
|
+
export const compileTactic = (environment: TacticEnvironment, sexpr: SExpr) =>
|
|
2022
|
+
compile(environment, sexpr, false);
|
|
1873
2023
|
|
|
1874
2024
|
export const compileInternalTactic = (environment: TacticEnvironment, text: string) => {
|
|
1875
2025
|
const list = createCommandReader(`(${text})`).read() as SmtList;
|
|
1876
|
-
return compile(environment, list.items[0],
|
|
2026
|
+
return compile(environment, list.items[0], true).build(new Map());
|
|
1877
2027
|
};
|
|
1878
2028
|
|
|
1879
2029
|
interface TacticCheck {
|
|
1880
2030
|
status: number;
|
|
1881
2031
|
model: ProtoModel | undefined;
|
|
1882
2032
|
core: Dependency | undefined;
|
|
1883
|
-
// What check_sat leaves in reason_unknown, or undefined where the port does not track it.
|
|
1884
2033
|
reasonUnknown: string | undefined;
|
|
2034
|
+
isConversionCanceled: boolean;
|
|
1885
2035
|
}
|
|
1886
2036
|
|
|
1887
2037
|
// The port's declarations of division by zero leave out their domain; Z3's have two arguments.
|
|
1888
2038
|
const DIVISION_BY_ZERO_DECLS = new Set([OP_DIV0, OP_IDIV0, OP_MOD0, OP_POWER0]);
|
|
1889
2039
|
|
|
1890
2040
|
// A constant of an uninterpreted sort the model lacks puts its value in that sort's universe.
|
|
1891
|
-
const applyDefinitions = (definitions: Definition[], model: ProtoModel) => {
|
|
2041
|
+
export const applyDefinitions = (definitions: readonly Definition[], model: ProtoModel) => {
|
|
1892
2042
|
const manager = model.manager;
|
|
1893
2043
|
const universe: number[] = [];
|
|
1894
2044
|
let evaluator = new ModelEvaluator(manager, model);
|
|
@@ -1940,47 +2090,87 @@ const applyDefinitions = (definitions: Definition[], model: ProtoModel) => {
|
|
|
1940
2090
|
return model;
|
|
1941
2091
|
};
|
|
1942
2092
|
|
|
2093
|
+
const applyConverter = (entry: Goal["converters"][number], model: ProtoModel) => {
|
|
2094
|
+
if ("convert" in entry) return entry.convert(model);
|
|
2095
|
+
if ("definitions" in entry) return applyDefinitions(entry.definitions, model);
|
|
2096
|
+
model.unregisterDecl(entry.decl);
|
|
2097
|
+
return model;
|
|
2098
|
+
};
|
|
2099
|
+
|
|
1943
2100
|
export const convertModel = (goal: Goal, model: ProtoModel) =>
|
|
1944
|
-
goal.converters.reduceRight((converted, entry) =>
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
2101
|
+
goal.converters.reduceRight((converted, entry) => applyConverter(entry, converted), model);
|
|
2102
|
+
|
|
2103
|
+
const getConvertedModel = (goal: Goal) => {
|
|
2104
|
+
let model = goal.model?.copy() ?? new ProtoModel(goal.manager).mkModel();
|
|
2105
|
+
for (let index = goal.converters.length - 1; index >= 0; index--) {
|
|
2106
|
+
try {
|
|
2107
|
+
model = applyConverter(goal.converters[index], model);
|
|
2108
|
+
} catch (error) {
|
|
2109
|
+
if (!(error instanceof SmtCanceledError)) throw error;
|
|
2110
|
+
return { model, isCanceled: true };
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
return { model, isCanceled: false };
|
|
2114
|
+
};
|
|
2115
|
+
|
|
2116
|
+
const getTacticCheck = (goal: Goal, goals: Goal[] | string | undefined): TacticCheck => {
|
|
2117
|
+
const undecided = {
|
|
2118
|
+
status: L_UNDEF,
|
|
2119
|
+
model: undefined,
|
|
2120
|
+
core: undefined,
|
|
2121
|
+
isConversionCanceled: false,
|
|
2122
|
+
};
|
|
2123
|
+
if (goals === undefined) return { ...undecided, reasonUnknown: undefined };
|
|
2124
|
+
if (typeof goals === "string") return { ...undecided, reasonUnknown: goals };
|
|
2125
|
+
if (isDecidedUnsat(goals))
|
|
2126
|
+
return { ...undecided, status: L_FALSE, core: goals[0].getDependency(0), reasonUnknown: "" };
|
|
2127
|
+
const isSat = isDecidedSat(goals);
|
|
2128
|
+
const converted =
|
|
2129
|
+
isSat ||
|
|
2130
|
+
(goal.isModelsEnabled &&
|
|
2131
|
+
goals.length > 0 &&
|
|
2132
|
+
(goals[0].model !== undefined || goals[0].converters.length > 0))
|
|
2133
|
+
? getConvertedModel(goals[0])
|
|
2134
|
+
: undefined;
|
|
2135
|
+
const model = converted?.model;
|
|
2136
|
+
if (converted?.isCanceled === true)
|
|
2137
|
+
return { ...undecided, model, reasonUnknown: undefined, isConversionCanceled: true };
|
|
2138
|
+
if (isSat)
|
|
2139
|
+
return goal.manager.limit.inc()
|
|
2140
|
+
? { ...undecided, status: L_TRUE, model, reasonUnknown: "" }
|
|
2141
|
+
: { ...undecided, model, reasonUnknown: "canceled" };
|
|
2142
|
+
return {
|
|
2143
|
+
...undecided,
|
|
2144
|
+
model,
|
|
2145
|
+
reasonUnknown:
|
|
2146
|
+
goals.length === 1 && goals[0].reasonUnknown !== "" ? goals[0].reasonUnknown : "unknown",
|
|
2147
|
+
};
|
|
2148
|
+
};
|
|
2149
|
+
|
|
2150
|
+
export const checkSatUsing = (tactic: Tactic, goal: Goal) => {
|
|
1953
2151
|
const goals = (() => {
|
|
1954
2152
|
try {
|
|
1955
2153
|
return tactic(goal);
|
|
1956
2154
|
} catch (error) {
|
|
1957
|
-
if (error instanceof SmtTacticError) return error.message;
|
|
2155
|
+
if (error instanceof SmtTacticError || error instanceof SmtDefaultError) return error.message;
|
|
1958
2156
|
if (error instanceof SmtCanceledError) return undefined;
|
|
1959
2157
|
throw error;
|
|
1960
2158
|
}
|
|
1961
2159
|
})();
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
: { ...undecided, model, reasonUnknown: "canceled" };
|
|
2160
|
+
try {
|
|
2161
|
+
return getTacticCheck(goal, goals);
|
|
2162
|
+
} finally {
|
|
2163
|
+
goal.reset();
|
|
2164
|
+
if (Array.isArray(goals)) for (const result of goals) result.reset();
|
|
1968
2165
|
}
|
|
1969
|
-
if (goals !== undefined && isDecidedUnsat(goals))
|
|
1970
|
-
return {
|
|
1971
|
-
status: L_FALSE,
|
|
1972
|
-
model: undefined,
|
|
1973
|
-
core: goals[0].getDependency(0),
|
|
1974
|
-
reasonUnknown: "",
|
|
1975
|
-
};
|
|
1976
|
-
return { ...undecided, reasonUnknown: undefined };
|
|
1977
2166
|
};
|
|
1978
2167
|
|
|
1979
2168
|
export const applyTactic = (tactic: Tactic, goal: Goal) => {
|
|
1980
2169
|
try {
|
|
1981
2170
|
return tactic(goal);
|
|
1982
2171
|
} catch (error) {
|
|
1983
|
-
if (error instanceof SmtCanceledError)
|
|
2172
|
+
if (error instanceof SmtCanceledError)
|
|
2173
|
+
throw new SmtTacticError(goal.manager.limit.getCancelMessage());
|
|
1984
2174
|
throw error;
|
|
1985
2175
|
}
|
|
1986
2176
|
};
|