tla-ts 0.0.10-dev.d618a2d79 → 0.0.10-dev.e3e5dd576
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 +49 -44
- package/dist/transfer.js +48 -43
- package/dist/worker.cjs +7 -7
- package/dist/worker.js +7 -7
- package/package.json +1 -1
- package/src/ast.ts +14 -2
- package/src/bags.ts +50 -29
- package/src/builtins.ts +4 -3
- package/src/check-failure.ts +13 -11
- package/src/check-trace.ts +116 -64
- package/src/check.ts +516 -280
- 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 +190 -1
- package/src/dependencies.ts +68 -15
- package/src/dfid.ts +101 -36
- package/src/environment.ts +123 -38
- package/src/errors.ts +7 -0
- package/src/evaluate.ts +370 -99
- package/src/exit-codes.ts +28 -14
- package/src/instances.ts +135 -11
- 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 +51 -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/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 +27 -1
- 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/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 +1 -2
- 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 +1 -2
- package/src/prover/smt/solver/dt2bv-tactic.ts +57 -21
- 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 +5 -8
- 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 +1 -2
- 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/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/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 +1 -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/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/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/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/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 +65 -12
- package/src/prover/smt/solver/sat/inc-sat-solver.ts +129 -43
- 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 +17 -7
- package/src/prover/smt/solver/sat/sat2goal.ts +72 -48
- 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 +713 -210
- package/src/prover/smt/solver/solve-eqs.ts +36 -37
- package/src/prover/smt/solver/solver.ts +18 -3
- package/src/prover/smt/solver/tactic.ts +350 -195
- 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 +11 -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 +1 -0
- 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 +1274 -257
- package/src/runtime.ts +7 -1
- 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 +18 -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 +11 -6
- package/src/sany/xml.ts +2 -3
- package/src/search.ts +319 -135
- package/src/simulate.ts +235 -182
- package/src/spec-description.ts +8 -6
- package/src/standard-definitions.ts +1 -0
- package/src/standard-modules.ts +56 -22
- package/src/subexpressions.ts +564 -138
- package/src/successors.ts +37 -13
- 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 +67 -43
- 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,8 @@ 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
|
+
["random_seed", PARAM_UINT, 0, true],
|
|
281
|
+
["auto_config", PARAM_BOOL, true, true],
|
|
283
282
|
]);
|
|
284
283
|
|
|
285
284
|
// The dependencies are assertion names, which are Boolean constants, so each one is its own
|
|
@@ -287,13 +286,26 @@ const SMT_DESCRS = getDescrs("smt", [
|
|
|
287
286
|
const getKernelParams = (environment: TacticEnvironment, params: TacticParams, goal: Goal) => {
|
|
288
287
|
const manager = environment.manager;
|
|
289
288
|
const hasQuantifiers = goal.forms.items.some((form) => manager.hasQuantifierFlags[form]);
|
|
289
|
+
// smt_params ands the auto_config of the tactic with the global one, which smt does not scope.
|
|
290
|
+
const setup = {
|
|
291
|
+
...environment.setup,
|
|
292
|
+
isAutoConfig:
|
|
293
|
+
getBool(
|
|
294
|
+
params,
|
|
295
|
+
"auto_config",
|
|
296
|
+
getParameter(environment, "smt.auto_config", "true") !== "false",
|
|
297
|
+
) && getParameter(environment, "auto_config", "true") !== "false",
|
|
298
|
+
};
|
|
290
299
|
return {
|
|
291
|
-
isMbqi:
|
|
292
|
-
getBool(params, "mbqi", environment.isMbqi) ||
|
|
293
|
-
isMbqiByFeatures(environment.setup, hasQuantifiers),
|
|
300
|
+
isMbqi: getBool(params, "mbqi", environment.isMbqi) || isMbqiByFeatures(setup, hasQuantifiers),
|
|
294
301
|
mbqiMaxIterations: getUint(params, "mbqi.max_iterations", environment.mbqiMaxIterations),
|
|
295
302
|
isFindingMacros: environment.isFindingMacros,
|
|
296
|
-
setup
|
|
303
|
+
setup,
|
|
304
|
+
randomSeed: getUint(
|
|
305
|
+
params,
|
|
306
|
+
"random_seed",
|
|
307
|
+
Number(getParameter(environment, "smt.random_seed", "0")),
|
|
308
|
+
),
|
|
297
309
|
};
|
|
298
310
|
};
|
|
299
311
|
|
|
@@ -339,6 +351,11 @@ export const getSatParams = (parameters: ReadonlyMap<string, string>) =>
|
|
|
339
351
|
}),
|
|
340
352
|
);
|
|
341
353
|
|
|
354
|
+
export const getSmtTacticFailure = (context: Context) =>
|
|
355
|
+
context.checkCanceled()
|
|
356
|
+
? "canceled"
|
|
357
|
+
: `smt tactic failed to show goal to be sat/unsat ${context.getLastFailureMessage()}`;
|
|
358
|
+
|
|
342
359
|
// sat_params reads what using-params leaves unset from the sat module's global parameters.
|
|
343
360
|
const getSatTacticParams = (environment: TacticEnvironment, params: TacticParams) =>
|
|
344
361
|
new Map([...getSatParams(environment.parameters), ...params]);
|
|
@@ -355,11 +372,15 @@ const runSmt = (environment: TacticEnvironment, params: TacticParams) => (goal:
|
|
|
355
372
|
? solveGoal(manager, goal.forms.items, kernelParams)
|
|
356
373
|
: solveAssuming(manager, extracted.clauses.items, extracted.assumptions, kernelParams);
|
|
357
374
|
extracted.clauses.reset();
|
|
358
|
-
if (solved.result === L_UNDEF)
|
|
375
|
+
if (solved.result === L_UNDEF)
|
|
376
|
+
throw new SmtTacticError(solved.reasonUnknown ?? getSmtTacticFailure(solved.context));
|
|
359
377
|
goal.reset();
|
|
360
|
-
if (solved.result === L_FALSE)
|
|
378
|
+
if (solved.result === L_FALSE) {
|
|
361
379
|
goal.assert(environment.manager.falseExpr, mkCoreDependency(solved.context.unsatCore));
|
|
362
|
-
|
|
380
|
+
return [goal];
|
|
381
|
+
}
|
|
382
|
+
if (goal.isModelsEnabled) goal.model = solved.context.getModel();
|
|
383
|
+
if (solved.context.checkCanceled()) throw new SmtTacticError("canceled");
|
|
363
384
|
return [goal];
|
|
364
385
|
};
|
|
365
386
|
|
|
@@ -423,30 +444,42 @@ const createTacticSolver = (manager: AstManager, getTactic: () => Tactic): AckrS
|
|
|
423
444
|
// Each clause gets a fresh context, where Z3 pushes a scope on one context.
|
|
424
445
|
const runUnitSubsume = (environment: TacticEnvironment) => (goal: Goal) => {
|
|
425
446
|
const manager = environment.manager;
|
|
447
|
+
const kernel = new SmtKernel(manager, {
|
|
448
|
+
isMbqi: environment.isMbqi,
|
|
449
|
+
mbqiMaxIterations: environment.mbqiMaxIterations,
|
|
450
|
+
isFindingMacros: false,
|
|
451
|
+
});
|
|
452
|
+
const trail = new RefVector(manager);
|
|
426
453
|
const clauses = goal.forms.items.map(() => manager.mkFreshConst("#clause", SORT_BOOL));
|
|
427
|
-
const
|
|
428
|
-
|
|
454
|
+
for (const clause of clauses) trail.push(clause);
|
|
455
|
+
kernel.push();
|
|
456
|
+
for (const [index, form] of goal.forms.items.entries()) {
|
|
457
|
+
const definition = manager.mkEq(clauses[index], form);
|
|
458
|
+
trail.push(definition);
|
|
459
|
+
kernel.assertExpr(definition);
|
|
460
|
+
}
|
|
461
|
+
kernel.push();
|
|
462
|
+
const isDeleted = clauses.map(() => false);
|
|
429
463
|
const deleted: number[] = [];
|
|
430
464
|
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);
|
|
465
|
+
kernel.push();
|
|
438
466
|
for (const [other, otherClause] of clauses.entries())
|
|
439
|
-
if (other === index)
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
467
|
+
if (other === index) {
|
|
468
|
+
const negated = manager.mkNot(clause);
|
|
469
|
+
trail.push(negated);
|
|
470
|
+
kernel.assertExpr(negated);
|
|
471
|
+
} else if (!isDeleted[other]) kernel.assertExpr(otherClause);
|
|
472
|
+
kernel.push();
|
|
473
|
+
const isUnsat = kernel.context.isInconsistent();
|
|
474
|
+
kernel.pop(2);
|
|
475
|
+
if (!isUnsat) continue;
|
|
476
|
+
isDeleted[index] = true;
|
|
477
|
+
deleted.push(index);
|
|
446
478
|
}
|
|
447
479
|
for (const index of deleted) goal.update(index, manager.trueExpr);
|
|
448
480
|
goal.elimTrue();
|
|
449
|
-
|
|
481
|
+
kernel.pop(2);
|
|
482
|
+
trail.reset();
|
|
450
483
|
return [goal];
|
|
451
484
|
};
|
|
452
485
|
|
|
@@ -455,19 +488,50 @@ const inPlace = (run: (goal: Goal) => void) => (goal: Goal) => {
|
|
|
455
488
|
return [goal];
|
|
456
489
|
};
|
|
457
490
|
|
|
458
|
-
const
|
|
459
|
-
const
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
goal.
|
|
464
|
-
manager.
|
|
491
|
+
const selectClause = (goal: Goal, isLargest: boolean) => {
|
|
492
|
+
const manager = goal.manager;
|
|
493
|
+
let position = -1;
|
|
494
|
+
let length = 0;
|
|
495
|
+
for (let index = 0; index < goal.forms.size; index++) {
|
|
496
|
+
const form = goal.forms.items[index];
|
|
497
|
+
if (manager.getOp(form) !== OP_OR) continue;
|
|
498
|
+
const currentLength = manager.getNumArgs(form);
|
|
499
|
+
if (currentLength < 2) continue;
|
|
500
|
+
if (!isLargest) return index;
|
|
501
|
+
if (currentLength > length) {
|
|
502
|
+
position = index;
|
|
503
|
+
length = currentLength;
|
|
504
|
+
}
|
|
465
505
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
506
|
+
return position;
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
const runSplitClause = (isLargest: boolean) => (goal: Goal) => {
|
|
510
|
+
const manager = goal.manager;
|
|
511
|
+
const position = selectClause(goal, isLargest);
|
|
512
|
+
if (position === -1)
|
|
513
|
+
throw new SmtTacticError("split-clause tactic failed, goal does not contain any clause");
|
|
514
|
+
if (goal.isProofsEnabled) throw new SmtUnsupportedError("the proofs of split-clause");
|
|
515
|
+
const dependency = goal.dependencies[position];
|
|
516
|
+
return manager.getArgs(goal.forms.items[position]).map((literal) => {
|
|
517
|
+
const subgoal = goal.copy();
|
|
518
|
+
subgoal.update(position, literal, dependency);
|
|
519
|
+
subgoal.depth++;
|
|
520
|
+
return subgoal;
|
|
521
|
+
});
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
const runDer = (manager: AstManager) => (goal: Goal) => {
|
|
525
|
+
runSimplifier(goal, true, (state) => {
|
|
526
|
+
const rewriter = new DerRewriter(manager);
|
|
527
|
+
return {
|
|
528
|
+
reduce: () => state.rewriteEach((form) => rewriter.rewrite(form)),
|
|
529
|
+
release: () => {
|
|
530
|
+
rewriter.der.release();
|
|
531
|
+
rewriter.release();
|
|
532
|
+
},
|
|
533
|
+
};
|
|
534
|
+
});
|
|
471
535
|
return [goal];
|
|
472
536
|
};
|
|
473
537
|
|
|
@@ -507,10 +571,16 @@ const runNnf = (manager: AstManager, params: TacticParams) => (goal: Goal) => {
|
|
|
507
571
|
const nnf = new Nnf(manager, names, mode, getBool(params, "ignore_labels", false));
|
|
508
572
|
const definitions = new RefVector(manager);
|
|
509
573
|
const size = goal.forms.size;
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
574
|
+
try {
|
|
575
|
+
for (let index = 0; !goal.isInconsistent && index < size; index++) {
|
|
576
|
+
const result = nnf.apply(goal.forms.items[index], definitions);
|
|
577
|
+
goal.update(index, result);
|
|
578
|
+
manager.decRef(result);
|
|
579
|
+
}
|
|
580
|
+
} catch (error) {
|
|
581
|
+
// Z3's nnf stops at the limit with a default_exception, which or-else lets pass.
|
|
582
|
+
if (!(error instanceof SmtCanceledError)) throw error;
|
|
583
|
+
throw new SmtDefaultError(manager.limit.getCancelMessage());
|
|
514
584
|
}
|
|
515
585
|
for (const definition of definitions.items) {
|
|
516
586
|
if (goal.isInconsistent) break;
|
|
@@ -691,40 +761,30 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
691
761
|
]),
|
|
692
762
|
build: (environment, params) => {
|
|
693
763
|
const manager = environment.manager;
|
|
694
|
-
const snf = runNnf(manager, new Map());
|
|
695
764
|
const elimRemParams = new Map([...params, ["elim_rem", true]]);
|
|
696
|
-
return
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
765
|
+
return [
|
|
766
|
+
runNnf(manager, new Map()),
|
|
767
|
+
inPlace((goal) =>
|
|
768
|
+
simplifyGoal(manager, goal, getRewriterOptions(manager, elimRemParams)),
|
|
769
|
+
),
|
|
770
|
+
inPlace((goal) =>
|
|
771
|
+
purifyArith(manager, goal, {
|
|
772
|
+
isComplete: getBool(params, "complete", true),
|
|
773
|
+
isElimRootObjects: getBool(params, "elim_root_objects", true),
|
|
774
|
+
isElimInverses: getBool(params, "elim_inverses", true),
|
|
775
|
+
}),
|
|
776
|
+
),
|
|
777
|
+
inPlace((goal) => simplifyGoal(manager, goal, getRewriterOptions(manager, params))),
|
|
778
|
+
].reduceRight((second, first) => runAndThen(first, second));
|
|
707
779
|
},
|
|
708
780
|
},
|
|
709
781
|
],
|
|
710
782
|
[
|
|
711
783
|
"elim-term-ite",
|
|
712
784
|
{
|
|
785
|
+
isTrackingDependencies: true,
|
|
713
786
|
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
|
-
}),
|
|
787
|
+
build: (environment) => runElimTermIte(environment.manager),
|
|
728
788
|
},
|
|
729
789
|
],
|
|
730
790
|
[
|
|
@@ -752,7 +812,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
752
812
|
isEliminatingAnd: true,
|
|
753
813
|
isKeepingDistinct: false,
|
|
754
814
|
});
|
|
755
|
-
tseitinCnf(manager, goal);
|
|
815
|
+
if (!goal.isDecided()) tseitinCnf(manager, goal);
|
|
756
816
|
} finally {
|
|
757
817
|
original.reset();
|
|
758
818
|
}
|
|
@@ -764,14 +824,9 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
764
824
|
{
|
|
765
825
|
descrs: new Map(),
|
|
766
826
|
build: (environment) =>
|
|
767
|
-
inPlace((goal) =>
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
goal.elimTrue();
|
|
771
|
-
goal.elimRedundancies();
|
|
772
|
-
}
|
|
773
|
-
goal.depth++;
|
|
774
|
-
}),
|
|
827
|
+
inPlace((goal) =>
|
|
828
|
+
goal.isProofsEnabled ? finishSimplifier(goal) : applyQeLite(environment.manager, goal),
|
|
829
|
+
),
|
|
775
830
|
},
|
|
776
831
|
],
|
|
777
832
|
[
|
|
@@ -803,6 +858,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
803
858
|
[
|
|
804
859
|
"elim-uncnstr",
|
|
805
860
|
{
|
|
861
|
+
isTrackingDependencies: true,
|
|
806
862
|
descrs: getDescrs("", [
|
|
807
863
|
["max_memory", PARAM_UINT, UINT_MAX, true],
|
|
808
864
|
["max_steps", PARAM_UINT, UINT_MAX],
|
|
@@ -898,7 +954,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
898
954
|
"pb2bv",
|
|
899
955
|
{
|
|
900
956
|
descrs: new Map([
|
|
901
|
-
...[...REWRITER_DESCRS].filter((
|
|
957
|
+
...[...REWRITER_DESCRS].filter((entry) => BOOL_REWRITER_PARAMS.includes(entry[0])),
|
|
902
958
|
...getDescrs("", [
|
|
903
959
|
["max_memory", PARAM_UINT, UINT_MAX, true],
|
|
904
960
|
["pb2bv_all_clauses_limit", PARAM_UINT, 8, true],
|
|
@@ -1043,6 +1099,14 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1043
1099
|
},
|
|
1044
1100
|
],
|
|
1045
1101
|
["der", { descrs: new Map(), build: (environment) => runDer(environment.manager) }],
|
|
1102
|
+
[
|
|
1103
|
+
"blast-term-ite",
|
|
1104
|
+
{
|
|
1105
|
+
isTrackingDependencies: true,
|
|
1106
|
+
descrs: new Map(),
|
|
1107
|
+
build: (environment) => inPlace((goal) => blastTermIte(environment.manager, goal)),
|
|
1108
|
+
},
|
|
1109
|
+
],
|
|
1046
1110
|
[
|
|
1047
1111
|
"distribute-forall",
|
|
1048
1112
|
{
|
|
@@ -1104,6 +1168,15 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1104
1168
|
build: (environment) => inPlace((goal) => domSimplify(environment.manager, goal)),
|
|
1105
1169
|
},
|
|
1106
1170
|
],
|
|
1171
|
+
[
|
|
1172
|
+
"split-clause",
|
|
1173
|
+
{
|
|
1174
|
+
descrs: getDescrs("", [["split_largest_clause", PARAM_BOOL, false, true]]),
|
|
1175
|
+
isTrackingDependencies: true,
|
|
1176
|
+
build: (_environment, params) =>
|
|
1177
|
+
runSplitClause(getBool(params, "split_largest_clause", false)),
|
|
1178
|
+
},
|
|
1179
|
+
],
|
|
1107
1180
|
[
|
|
1108
1181
|
"occf",
|
|
1109
1182
|
{
|
|
@@ -1208,7 +1281,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1208
1281
|
const manager = environment.manager;
|
|
1209
1282
|
const preamble = createCommandReader(QFUFBV_ACKR_PREAMBLE).read() as SmtList;
|
|
1210
1283
|
return runAndThen(
|
|
1211
|
-
compile(environment, preamble,
|
|
1284
|
+
compile(environment, preamble, true).build(params),
|
|
1212
1285
|
runCond(
|
|
1213
1286
|
isQfufbv,
|
|
1214
1287
|
createQfufbvAckrTactic(manager, getRewriterOptions(manager, new Map()), true, () =>
|
|
@@ -1289,7 +1362,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1289
1362
|
{
|
|
1290
1363
|
descrs: new Map(),
|
|
1291
1364
|
isRejectingUnknown: false,
|
|
1292
|
-
build: (environment) => runQsat(environment
|
|
1365
|
+
build: (environment) => runQsat(environment, QSAT_SAT),
|
|
1293
1366
|
},
|
|
1294
1367
|
],
|
|
1295
1368
|
[
|
|
@@ -1297,7 +1370,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1297
1370
|
{
|
|
1298
1371
|
descrs: new Map(),
|
|
1299
1372
|
isRejectingUnknown: false,
|
|
1300
|
-
build: (environment) => runQsat(environment
|
|
1373
|
+
build: (environment) => runQsat(environment, QSAT_QE),
|
|
1301
1374
|
},
|
|
1302
1375
|
],
|
|
1303
1376
|
[
|
|
@@ -1305,7 +1378,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1305
1378
|
{
|
|
1306
1379
|
descrs: new Map(),
|
|
1307
1380
|
isRejectingUnknown: false,
|
|
1308
|
-
build: (environment) => runQsat(environment
|
|
1381
|
+
build: (environment) => runQsat(environment, QSAT_QE_REC),
|
|
1309
1382
|
},
|
|
1310
1383
|
],
|
|
1311
1384
|
[
|
|
@@ -1381,20 +1454,19 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1381
1454
|
|
|
1382
1455
|
const UNPORTED_TACTICS = new Set(
|
|
1383
1456
|
(
|
|
1384
|
-
"blast-term-ite " +
|
|
1385
1457
|
"bv-slice bvarray2uf collect-statistics " +
|
|
1386
1458
|
"degree-shift demodulator " +
|
|
1387
1459
|
"elim-predicates elim-uncnstr2 " +
|
|
1388
1460
|
"euf-completion ff-sat ff-simplify ff-solve ff-unique ff2bv fold-unfold fpa2bv " +
|
|
1389
1461
|
"horn-simplify injectivity pb-preprocess pqffd propagate-bv-bounds " +
|
|
1390
|
-
"propagate-bv-bounds2 propagate-values2 qfbv-sls
|
|
1462
|
+
"propagate-bv-bounds2 propagate-values2 qfbv-sls recover-01 reduce-args2 " +
|
|
1391
1463
|
"sat-preprocess sls-smt smtfd solver-subsumption special-relations " +
|
|
1392
|
-
"
|
|
1464
|
+
"subpaving symmetry-reduce"
|
|
1393
1465
|
).split(" "),
|
|
1394
1466
|
);
|
|
1395
1467
|
|
|
1396
|
-
const
|
|
1397
|
-
sexpr?.kind === "numeral" &&
|
|
1468
|
+
const isUnsignedNumeral = (sexpr: SExpr | undefined): sexpr is SmtToken =>
|
|
1469
|
+
sexpr?.kind === "numeral" && isUnsigned(sexpr.text);
|
|
1398
1470
|
|
|
1399
1471
|
const getParamName = (keyword: string) =>
|
|
1400
1472
|
keyword.replace(/^:/, "").toLowerCase().replaceAll("-", "_");
|
|
@@ -1415,7 +1487,7 @@ const parseParamValue = (kind: number, value: SExpr) =>
|
|
|
1415
1487
|
kind === PARAM_BOOL
|
|
1416
1488
|
? isSymbol(value, "true") || (isSymbol(value, "false") ? false : undefined)
|
|
1417
1489
|
: kind === PARAM_UINT
|
|
1418
|
-
?
|
|
1490
|
+
? isUnsignedNumeral(value)
|
|
1419
1491
|
? Number(value.text)
|
|
1420
1492
|
: undefined
|
|
1421
1493
|
: kind === PARAM_NUMERAL
|
|
@@ -1444,27 +1516,33 @@ const checkParams = (descrs: ParamDescrs, params: TacticParams) => {
|
|
|
1444
1516
|
}
|
|
1445
1517
|
};
|
|
1446
1518
|
|
|
1519
|
+
// sexpr2tactic reports an error at the s-expression: a list at its closing parenthesis.
|
|
1520
|
+
const getSexprPosition = (sexpr: SExpr) => (sexpr.kind === "list" ? sexpr.end : sexpr);
|
|
1521
|
+
|
|
1447
1522
|
const getParams = (
|
|
1448
1523
|
builder: TacticBuilder,
|
|
1449
1524
|
items: SExpr[],
|
|
1450
|
-
end: SmtToken,
|
|
1451
1525
|
isInternal: boolean,
|
|
1452
1526
|
): Map<string, TacticParam> => {
|
|
1453
1527
|
const params = new Map<string, TacticParam>();
|
|
1454
1528
|
for (let index = 2; index < items.length; index += 2) {
|
|
1455
1529
|
const keyword = items[index];
|
|
1456
1530
|
if (keyword.kind !== "keyword")
|
|
1457
|
-
throw new SmtParseError(
|
|
1531
|
+
throw new SmtParseError(
|
|
1532
|
+
"invalid using-params combinator, keyword expected",
|
|
1533
|
+
getSexprPosition(keyword),
|
|
1534
|
+
);
|
|
1458
1535
|
const value = items[index + 1];
|
|
1459
1536
|
if (value === undefined)
|
|
1460
|
-
throw new SmtParseError("invalid using-params combinator, parameter value expected",
|
|
1537
|
+
throw new SmtParseError("invalid using-params combinator, parameter value expected", keyword);
|
|
1461
1538
|
const found = findParam(builder.descrs, getParamName(keyword.text));
|
|
1462
1539
|
if (isInternal) {
|
|
1463
1540
|
const parsed =
|
|
1464
1541
|
found === undefined
|
|
1465
1542
|
? getUntypedParamValue(value)
|
|
1466
1543
|
: parseParamValue(found.descr.kind, value);
|
|
1467
|
-
if (parsed === undefined)
|
|
1544
|
+
if (parsed === undefined)
|
|
1545
|
+
throw new SmtParseError("invalid parameter value", getSexprPosition(value));
|
|
1468
1546
|
params.set(found?.name ?? getParamName(keyword.text), parsed);
|
|
1469
1547
|
continue;
|
|
1470
1548
|
}
|
|
@@ -1473,7 +1551,7 @@ const getParams = (
|
|
|
1473
1551
|
throw new SmtUnsupportedError(`the parameter ${keyword.text} of the tactic`);
|
|
1474
1552
|
throw new SmtParseError(
|
|
1475
1553
|
`invalid using-params combinator, unknown parameter ${getParamName(keyword.text)}`,
|
|
1476
|
-
|
|
1554
|
+
getSexprPosition(value),
|
|
1477
1555
|
);
|
|
1478
1556
|
}
|
|
1479
1557
|
const parsed = parseParamValue(found.descr.kind, value);
|
|
@@ -1486,7 +1564,7 @@ const getParams = (
|
|
|
1486
1564
|
: found.descr.kind === PARAM_NUMERAL
|
|
1487
1565
|
? "invalid parameter value, numeral expected"
|
|
1488
1566
|
: "invalid parameter value, symbol expected",
|
|
1489
|
-
|
|
1567
|
+
getSexprPosition(value),
|
|
1490
1568
|
);
|
|
1491
1569
|
if (isUnportedParam(found.descr, parsed))
|
|
1492
1570
|
throw new SmtUnsupportedError(`the parameter ${found.name} of the tactic`);
|
|
@@ -1505,19 +1583,30 @@ const isDecidedSat = (goals: Goal[]) => goals.length === 1 && goals[0].isDecided
|
|
|
1505
1583
|
|
|
1506
1584
|
const isDecidedUnsat = (goals: Goal[]) => goals.length === 1 && goals[0].isDecidedUnsat();
|
|
1507
1585
|
|
|
1586
|
+
// Deviation from Z3: and_then and repeat join the subgoals' cores, where Z3 answers an empty core.
|
|
1587
|
+
const assertUnsat = (goal: Goal, unsatGoals: Goal[]) => {
|
|
1588
|
+
goal.resetAll();
|
|
1589
|
+
goal.assert(
|
|
1590
|
+
goal.manager.falseExpr,
|
|
1591
|
+
unsatGoals.reduce<Dependency | undefined>(
|
|
1592
|
+
(core, unsatGoal) => joinDependencies(unsatGoal.getDependency(0), core),
|
|
1593
|
+
undefined,
|
|
1594
|
+
),
|
|
1595
|
+
);
|
|
1596
|
+
return [goal];
|
|
1597
|
+
};
|
|
1598
|
+
|
|
1508
1599
|
const runAndThen = (first: Tactic, second: Tactic) => (goal: Goal) => {
|
|
1509
1600
|
const goals = first(goal);
|
|
1510
1601
|
if (goals.length === 1) return goals[0].isDecided() ? goals : second(goals[0]);
|
|
1511
1602
|
const results: Goal[] = [];
|
|
1603
|
+
const unsatGoals: Goal[] = [];
|
|
1512
1604
|
for (const subgoal of goals) {
|
|
1513
1605
|
const subresults = second(subgoal);
|
|
1514
1606
|
if (isDecidedSat(subresults)) return subresults;
|
|
1515
|
-
|
|
1607
|
+
(isDecidedUnsat(subresults) ? unsatGoals : results).push(...subresults);
|
|
1516
1608
|
}
|
|
1517
|
-
|
|
1518
|
-
goal.resetAll();
|
|
1519
|
-
goal.assert(goal.manager.falseExpr);
|
|
1520
|
-
return [goal];
|
|
1609
|
+
return results.length > 0 ? results : assertUnsat(goal, unsatGoals);
|
|
1521
1610
|
};
|
|
1522
1611
|
|
|
1523
1612
|
const runOrElse = (tactics: Tactic[]) => (goal: Goal) => {
|
|
@@ -1526,12 +1615,12 @@ const runOrElse = (tactics: Tactic[]) => (goal: Goal) => {
|
|
|
1526
1615
|
try {
|
|
1527
1616
|
return tactic(goal);
|
|
1528
1617
|
} catch (error) {
|
|
1529
|
-
if (!(error instanceof SmtTacticError)) throw error;
|
|
1618
|
+
if (!(error instanceof SmtTacticError || error instanceof SmtCanceledError)) throw error;
|
|
1530
1619
|
}
|
|
1531
1620
|
goal.resetAll();
|
|
1532
1621
|
goal.copyFrom(original);
|
|
1533
1622
|
}
|
|
1534
|
-
return
|
|
1623
|
+
return tactics[tactics.length - 1](goal);
|
|
1535
1624
|
};
|
|
1536
1625
|
|
|
1537
1626
|
const isEqualGoal = (first: Goal, second: Goal) => {
|
|
@@ -1551,15 +1640,13 @@ const runRepeat = (tactic: Tactic, maxDepth: number) => {
|
|
|
1551
1640
|
if (goals.length === 1 && isEqualGoal(original, goals[0])) return goals;
|
|
1552
1641
|
if (goals.length === 1) return goals[0].isDecided() ? goals : run(depth + 1, goals[0]);
|
|
1553
1642
|
const results: Goal[] = [];
|
|
1643
|
+
const unsatGoals: Goal[] = [];
|
|
1554
1644
|
for (const subgoal of goals) {
|
|
1555
1645
|
const subresults = run(depth + 1, subgoal);
|
|
1556
1646
|
if (isDecidedSat(subresults)) return subresults;
|
|
1557
|
-
|
|
1647
|
+
(isDecidedUnsat(subresults) ? unsatGoals : results).push(...subresults);
|
|
1558
1648
|
}
|
|
1559
|
-
|
|
1560
|
-
goal.resetAll();
|
|
1561
|
-
goal.assert(goal.manager.falseExpr);
|
|
1562
|
-
return [goal];
|
|
1649
|
+
return results.length > 0 ? results : assertUnsat(goal, unsatGoals);
|
|
1563
1650
|
};
|
|
1564
1651
|
return (goal: Goal) => run(0, goal);
|
|
1565
1652
|
};
|
|
@@ -1567,22 +1654,21 @@ const runRepeat = (tactic: Tactic, maxDepth: number) => {
|
|
|
1567
1654
|
const runCond = (probe: Probe, onTrue: Tactic, onFalse: Tactic) => (goal: Goal) =>
|
|
1568
1655
|
probe(goal) === 0 ? onFalse(goal) : onTrue(goal);
|
|
1569
1656
|
|
|
1570
|
-
const checkHasArgument = (list: SmtList, combinator: string
|
|
1657
|
+
const checkHasArgument = (list: SmtList, combinator: string) => {
|
|
1571
1658
|
if (list.items.length < 2)
|
|
1572
1659
|
throw new SmtParseError(
|
|
1573
1660
|
`invalid ${combinator} combinator, at least one argument expected`,
|
|
1574
|
-
end,
|
|
1661
|
+
list.end,
|
|
1575
1662
|
);
|
|
1576
1663
|
};
|
|
1577
1664
|
|
|
1578
1665
|
const compile = (
|
|
1579
1666
|
environment: TacticEnvironment,
|
|
1580
1667
|
sexpr: SExpr,
|
|
1581
|
-
end: SmtToken,
|
|
1582
1668
|
isInternal: boolean,
|
|
1583
1669
|
): TacticBuilder => {
|
|
1584
1670
|
if (sexpr.kind !== "list") {
|
|
1585
|
-
if (!isSymbol(sexpr)) throw new SmtParseError("invalid tactic, unexpected input",
|
|
1671
|
+
if (!isSymbol(sexpr)) throw new SmtParseError("invalid tactic, unexpected input", sexpr);
|
|
1586
1672
|
const named = NAMED_TACTICS.get(sexpr.text);
|
|
1587
1673
|
if (named !== undefined)
|
|
1588
1674
|
return {
|
|
@@ -1600,7 +1686,7 @@ const compile = (
|
|
|
1600
1686
|
};
|
|
1601
1687
|
const strategy = LOGIC_TACTICS.get(sexpr.text);
|
|
1602
1688
|
if (strategy !== undefined)
|
|
1603
|
-
return compile(environment, createCommandReader(strategy).read() as SmtList,
|
|
1689
|
+
return compile(environment, createCommandReader(strategy).read() as SmtList, true);
|
|
1604
1690
|
if (UNPORTED_TACTICS.has(sexpr.text)) {
|
|
1605
1691
|
const error = new SmtUnsupportedError(`the tactic ${sexpr.text}`);
|
|
1606
1692
|
if (!isInternal) throw error;
|
|
@@ -1613,14 +1699,14 @@ const compile = (
|
|
|
1613
1699
|
},
|
|
1614
1700
|
};
|
|
1615
1701
|
}
|
|
1616
|
-
throw new SmtParseError(`invalid tactic, unknown tactic ${sexpr.text}`,
|
|
1702
|
+
throw new SmtParseError(`invalid tactic, unknown tactic ${sexpr.text}`, sexpr);
|
|
1617
1703
|
}
|
|
1618
1704
|
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);
|
|
1705
|
+
if (head === undefined) throw new SmtParseError("invalid tactic, arguments expected", sexpr.end);
|
|
1706
|
+
if (!isSymbol(head)) throw new SmtParseError("invalid tactic, symbol expected", sexpr.end);
|
|
1621
1707
|
const compileChildren = (combinator: string) => {
|
|
1622
|
-
checkHasArgument(sexpr, combinator
|
|
1623
|
-
return sexpr.items.slice(1).map((child) => compile(environment, child,
|
|
1708
|
+
checkHasArgument(sexpr, combinator);
|
|
1709
|
+
return sexpr.items.slice(1).map((child) => compile(environment, child, isInternal));
|
|
1624
1710
|
};
|
|
1625
1711
|
switch (head.text) {
|
|
1626
1712
|
case "then":
|
|
@@ -1670,27 +1756,43 @@ const compile = (
|
|
|
1670
1756
|
// The timeout is not ported, so the child runs to the end.
|
|
1671
1757
|
case "try-for": {
|
|
1672
1758
|
if (sexpr.items.length !== 3)
|
|
1673
|
-
throw new SmtParseError("invalid try-for combinator, two arguments expected", end);
|
|
1674
|
-
if (!
|
|
1759
|
+
throw new SmtParseError("invalid try-for combinator, two arguments expected", sexpr.end);
|
|
1760
|
+
if (!isUnsignedNumeral(sexpr.items[2]))
|
|
1675
1761
|
throw new SmtParseError(
|
|
1676
1762
|
"invalid try-for combinator, second argument must be an unsigned integer",
|
|
1677
|
-
end,
|
|
1763
|
+
sexpr.end,
|
|
1678
1764
|
);
|
|
1679
|
-
|
|
1765
|
+
const child = compile(environment, sexpr.items[1], isInternal);
|
|
1766
|
+
return {
|
|
1767
|
+
...child,
|
|
1768
|
+
build: (params) => {
|
|
1769
|
+
const tactic = child.build(params);
|
|
1770
|
+
return (goal) => {
|
|
1771
|
+
try {
|
|
1772
|
+
return tactic(goal);
|
|
1773
|
+
} catch (error) {
|
|
1774
|
+
if (error instanceof SmtDefaultError) throw new SmtTacticError(error.message);
|
|
1775
|
+
if (error instanceof SmtCanceledError)
|
|
1776
|
+
throw new SmtTacticError(goal.manager.limit.getCancelMessage());
|
|
1777
|
+
throw error;
|
|
1778
|
+
}
|
|
1779
|
+
};
|
|
1780
|
+
},
|
|
1781
|
+
};
|
|
1680
1782
|
}
|
|
1681
1783
|
case "fail-if-branching": {
|
|
1682
1784
|
if (sexpr.items.length !== 3 && sexpr.items.length !== 2)
|
|
1683
1785
|
throw new SmtParseError(
|
|
1684
1786
|
"invalid fail-if-branching combinator, one or two arguments expected",
|
|
1685
|
-
end,
|
|
1787
|
+
sexpr.end,
|
|
1686
1788
|
);
|
|
1687
1789
|
const bound = sexpr.items[2];
|
|
1688
|
-
if (bound !== undefined && !
|
|
1790
|
+
if (bound !== undefined && !isUnsignedNumeral(bound))
|
|
1689
1791
|
throw new SmtParseError(
|
|
1690
1792
|
"invalid fail-if-branching combinator, second argument must be an unsigned integer",
|
|
1691
|
-
end,
|
|
1793
|
+
sexpr.end,
|
|
1692
1794
|
);
|
|
1693
|
-
const child = compile(environment, sexpr.items[1],
|
|
1795
|
+
const child = compile(environment, sexpr.items[1], isInternal);
|
|
1694
1796
|
const threshold = bound === undefined ? 1 : Number(bound.text);
|
|
1695
1797
|
return {
|
|
1696
1798
|
...mergeDescrs([child]),
|
|
@@ -1708,11 +1810,17 @@ const compile = (
|
|
|
1708
1810
|
case "if-no-unsat-cores":
|
|
1709
1811
|
case "if-no-models": {
|
|
1710
1812
|
if (sexpr.items.length !== 2)
|
|
1711
|
-
throw new SmtParseError(
|
|
1712
|
-
|
|
1813
|
+
throw new SmtParseError(
|
|
1814
|
+
`invalid ${head.text} combinator, one argument expected`,
|
|
1815
|
+
sexpr.end,
|
|
1816
|
+
);
|
|
1817
|
+
const child = compile(environment, sexpr.items[1], isInternal);
|
|
1713
1818
|
const isSkipping = (goal: Goal) =>
|
|
1714
|
-
head.text === "if-no-models"
|
|
1715
|
-
|
|
1819
|
+
head.text === "if-no-models"
|
|
1820
|
+
? goal.isModelsEnabled
|
|
1821
|
+
: head.text === "if-no-proofs"
|
|
1822
|
+
? goal.isProofsEnabled
|
|
1823
|
+
: goal.isCoresEnabled;
|
|
1716
1824
|
return {
|
|
1717
1825
|
...mergeDescrs([child]),
|
|
1718
1826
|
build: (params) => {
|
|
@@ -1723,14 +1831,17 @@ const compile = (
|
|
|
1723
1831
|
}
|
|
1724
1832
|
case "repeat": {
|
|
1725
1833
|
if (sexpr.items.length !== 3 && sexpr.items.length !== 2)
|
|
1726
|
-
throw new SmtParseError(
|
|
1834
|
+
throw new SmtParseError(
|
|
1835
|
+
"invalid repeat combinator, one or two arguments expected",
|
|
1836
|
+
sexpr.end,
|
|
1837
|
+
);
|
|
1727
1838
|
const bound = sexpr.items[2];
|
|
1728
|
-
if (bound !== undefined && !
|
|
1839
|
+
if (bound !== undefined && !isUnsignedNumeral(bound))
|
|
1729
1840
|
throw new SmtParseError(
|
|
1730
1841
|
"invalid repeat combinator, second argument must be an unsigned integer",
|
|
1731
|
-
end,
|
|
1842
|
+
sexpr.end,
|
|
1732
1843
|
);
|
|
1733
|
-
const child = compile(environment, sexpr.items[1],
|
|
1844
|
+
const child = compile(environment, sexpr.items[1], isInternal);
|
|
1734
1845
|
const maxDepth = bound === undefined ? UINT_MAX : Number(bound.text);
|
|
1735
1846
|
return {
|
|
1736
1847
|
...mergeDescrs([child]),
|
|
@@ -1740,10 +1851,10 @@ const compile = (
|
|
|
1740
1851
|
case "!":
|
|
1741
1852
|
case "using-params":
|
|
1742
1853
|
case "with": {
|
|
1743
|
-
checkHasArgument(sexpr, "using-params"
|
|
1744
|
-
const child = compile(environment, sexpr.items[1],
|
|
1854
|
+
checkHasArgument(sexpr, "using-params");
|
|
1855
|
+
const child = compile(environment, sexpr.items[1], isInternal);
|
|
1745
1856
|
if (sexpr.items.length === 2) return child;
|
|
1746
|
-
const own = getParams(child, sexpr.items,
|
|
1857
|
+
const own = getParams(child, sexpr.items, isInternal);
|
|
1747
1858
|
return {
|
|
1748
1859
|
...mergeDescrs([child]),
|
|
1749
1860
|
build: (params) => child.build(new Map([...params, ...own])),
|
|
@@ -1751,8 +1862,11 @@ const compile = (
|
|
|
1751
1862
|
}
|
|
1752
1863
|
case "skip-if-failed": {
|
|
1753
1864
|
if (sexpr.items.length !== 2)
|
|
1754
|
-
throw new SmtParseError(
|
|
1755
|
-
|
|
1865
|
+
throw new SmtParseError(
|
|
1866
|
+
"invalid skip-if-failed combinator, one argument expected",
|
|
1867
|
+
sexpr.end,
|
|
1868
|
+
);
|
|
1869
|
+
const child = compile(environment, sexpr.items[1], isInternal);
|
|
1756
1870
|
return {
|
|
1757
1871
|
...mergeDescrs([child]),
|
|
1758
1872
|
build: (params) => runOrElse([child.build(params), (goal) => [goal]]),
|
|
@@ -1762,11 +1876,12 @@ const compile = (
|
|
|
1762
1876
|
case "ite":
|
|
1763
1877
|
case "cond": {
|
|
1764
1878
|
if (sexpr.items.length !== 4)
|
|
1765
|
-
throw new SmtParseError(
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1879
|
+
throw new SmtParseError(
|
|
1880
|
+
"invalid if/conditional combinator, three arguments expected",
|
|
1881
|
+
sexpr.end,
|
|
1882
|
+
);
|
|
1883
|
+
const probe = compileProbe(sexpr.items[1], isInternal);
|
|
1884
|
+
const children = sexpr.items.slice(2).map((child) => compile(environment, child, isInternal));
|
|
1770
1885
|
return {
|
|
1771
1886
|
...mergeDescrs(children),
|
|
1772
1887
|
build: (params) => runCond(probe, children[0].build(params), children[1].build(params)),
|
|
@@ -1774,9 +1889,9 @@ const compile = (
|
|
|
1774
1889
|
}
|
|
1775
1890
|
case "when": {
|
|
1776
1891
|
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],
|
|
1892
|
+
throw new SmtParseError("invalid when combinator, two arguments expected", sexpr.end);
|
|
1893
|
+
const probe = compileProbe(sexpr.items[1], isInternal);
|
|
1894
|
+
const child = compile(environment, sexpr.items[2], isInternal);
|
|
1780
1895
|
return {
|
|
1781
1896
|
...mergeDescrs([child]),
|
|
1782
1897
|
build: (params) => runCond(probe, child.build(params), (goal) => [goal]),
|
|
@@ -1784,8 +1899,8 @@ const compile = (
|
|
|
1784
1899
|
}
|
|
1785
1900
|
case "fail-if": {
|
|
1786
1901
|
if (sexpr.items.length !== 2)
|
|
1787
|
-
throw new SmtParseError("invalid fail-if tactic, one argument expected", end);
|
|
1788
|
-
const probe = compileProbe(sexpr.items[1],
|
|
1902
|
+
throw new SmtParseError("invalid fail-if tactic, one argument expected", sexpr.end);
|
|
1903
|
+
const probe = compileProbe(sexpr.items[1], isInternal);
|
|
1789
1904
|
return {
|
|
1790
1905
|
descrs: new Map(),
|
|
1791
1906
|
isRejectingUnknown: true,
|
|
@@ -1798,7 +1913,7 @@ const compile = (
|
|
|
1798
1913
|
}
|
|
1799
1914
|
case "echo": {
|
|
1800
1915
|
if (sexpr.items.length < 2)
|
|
1801
|
-
throw new SmtParseError("invalid echo tactic, must have at least one argument", end);
|
|
1916
|
+
throw new SmtParseError("invalid echo tactic, must have at least one argument", sexpr.end);
|
|
1802
1917
|
const pieces = sexpr.items.slice(1).map((piece, index, all): Tactic => {
|
|
1803
1918
|
const newline = index === all.length - 1 ? "\n" : "";
|
|
1804
1919
|
if (piece.kind === "string")
|
|
@@ -1806,7 +1921,7 @@ const compile = (
|
|
|
1806
1921
|
environment.write(piece.text + newline, false);
|
|
1807
1922
|
return [goal];
|
|
1808
1923
|
};
|
|
1809
|
-
const probe = compileProbe(piece,
|
|
1924
|
+
const probe = compileProbe(piece, isInternal);
|
|
1810
1925
|
return (goal) => {
|
|
1811
1926
|
environment.write(formatProbeValue(probe(goal)) + newline, true);
|
|
1812
1927
|
return [goal];
|
|
@@ -1820,7 +1935,7 @@ const compile = (
|
|
|
1820
1935
|
};
|
|
1821
1936
|
}
|
|
1822
1937
|
default:
|
|
1823
|
-
throw new SmtParseError(`invalid tactic, unknown tactic combinator ${head.text}`, end);
|
|
1938
|
+
throw new SmtParseError(`invalid tactic, unknown tactic combinator ${head.text}`, sexpr.end);
|
|
1824
1939
|
}
|
|
1825
1940
|
};
|
|
1826
1941
|
|
|
@@ -1868,27 +1983,27 @@ export const mkIncSatPreprocess = (manager: AstManager, bitBlaster: BitBlasterRe
|
|
|
1868
1983
|
),
|
|
1869
1984
|
].reduceRight((second, first) => runAndThen(first, second));
|
|
1870
1985
|
|
|
1871
|
-
export const compileTactic = (environment: TacticEnvironment, sexpr: SExpr
|
|
1872
|
-
compile(environment, sexpr,
|
|
1986
|
+
export const compileTactic = (environment: TacticEnvironment, sexpr: SExpr) =>
|
|
1987
|
+
compile(environment, sexpr, false);
|
|
1873
1988
|
|
|
1874
1989
|
export const compileInternalTactic = (environment: TacticEnvironment, text: string) => {
|
|
1875
1990
|
const list = createCommandReader(`(${text})`).read() as SmtList;
|
|
1876
|
-
return compile(environment, list.items[0],
|
|
1991
|
+
return compile(environment, list.items[0], true).build(new Map());
|
|
1877
1992
|
};
|
|
1878
1993
|
|
|
1879
1994
|
interface TacticCheck {
|
|
1880
1995
|
status: number;
|
|
1881
1996
|
model: ProtoModel | undefined;
|
|
1882
1997
|
core: Dependency | undefined;
|
|
1883
|
-
// What check_sat leaves in reason_unknown, or undefined where the port does not track it.
|
|
1884
1998
|
reasonUnknown: string | undefined;
|
|
1999
|
+
isConversionCanceled: boolean;
|
|
1885
2000
|
}
|
|
1886
2001
|
|
|
1887
2002
|
// The port's declarations of division by zero leave out their domain; Z3's have two arguments.
|
|
1888
2003
|
const DIVISION_BY_ZERO_DECLS = new Set([OP_DIV0, OP_IDIV0, OP_MOD0, OP_POWER0]);
|
|
1889
2004
|
|
|
1890
2005
|
// A constant of an uninterpreted sort the model lacks puts its value in that sort's universe.
|
|
1891
|
-
const applyDefinitions = (definitions: Definition[], model: ProtoModel) => {
|
|
2006
|
+
export const applyDefinitions = (definitions: readonly Definition[], model: ProtoModel) => {
|
|
1892
2007
|
const manager = model.manager;
|
|
1893
2008
|
const universe: number[] = [];
|
|
1894
2009
|
let evaluator = new ModelEvaluator(manager, model);
|
|
@@ -1940,47 +2055,87 @@ const applyDefinitions = (definitions: Definition[], model: ProtoModel) => {
|
|
|
1940
2055
|
return model;
|
|
1941
2056
|
};
|
|
1942
2057
|
|
|
2058
|
+
const applyConverter = (entry: Goal["converters"][number], model: ProtoModel) => {
|
|
2059
|
+
if ("convert" in entry) return entry.convert(model);
|
|
2060
|
+
if ("definitions" in entry) return applyDefinitions(entry.definitions, model);
|
|
2061
|
+
model.unregisterDecl(entry.decl);
|
|
2062
|
+
return model;
|
|
2063
|
+
};
|
|
2064
|
+
|
|
1943
2065
|
export const convertModel = (goal: Goal, model: ProtoModel) =>
|
|
1944
|
-
goal.converters.reduceRight((converted, entry) =>
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
2066
|
+
goal.converters.reduceRight((converted, entry) => applyConverter(entry, converted), model);
|
|
2067
|
+
|
|
2068
|
+
const getConvertedModel = (goal: Goal) => {
|
|
2069
|
+
let model = goal.model?.copy() ?? new ProtoModel(goal.manager).mkModel();
|
|
2070
|
+
for (let index = goal.converters.length - 1; index >= 0; index--) {
|
|
2071
|
+
try {
|
|
2072
|
+
model = applyConverter(goal.converters[index], model);
|
|
2073
|
+
} catch (error) {
|
|
2074
|
+
if (!(error instanceof SmtCanceledError)) throw error;
|
|
2075
|
+
return { model, isCanceled: true };
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
return { model, isCanceled: false };
|
|
2079
|
+
};
|
|
2080
|
+
|
|
2081
|
+
const getTacticCheck = (goal: Goal, goals: Goal[] | string | undefined): TacticCheck => {
|
|
2082
|
+
const undecided = {
|
|
2083
|
+
status: L_UNDEF,
|
|
2084
|
+
model: undefined,
|
|
2085
|
+
core: undefined,
|
|
2086
|
+
isConversionCanceled: false,
|
|
2087
|
+
};
|
|
2088
|
+
if (goals === undefined) return { ...undecided, reasonUnknown: undefined };
|
|
2089
|
+
if (typeof goals === "string") return { ...undecided, reasonUnknown: goals };
|
|
2090
|
+
if (isDecidedUnsat(goals))
|
|
2091
|
+
return { ...undecided, status: L_FALSE, core: goals[0].getDependency(0), reasonUnknown: "" };
|
|
2092
|
+
const isSat = isDecidedSat(goals);
|
|
2093
|
+
const converted =
|
|
2094
|
+
isSat ||
|
|
2095
|
+
(goal.isModelsEnabled &&
|
|
2096
|
+
goals.length > 0 &&
|
|
2097
|
+
(goals[0].model !== undefined || goals[0].converters.length > 0))
|
|
2098
|
+
? getConvertedModel(goals[0])
|
|
2099
|
+
: undefined;
|
|
2100
|
+
const model = converted?.model;
|
|
2101
|
+
if (converted?.isCanceled === true)
|
|
2102
|
+
return { ...undecided, model, reasonUnknown: undefined, isConversionCanceled: true };
|
|
2103
|
+
if (isSat)
|
|
2104
|
+
return goal.manager.limit.inc()
|
|
2105
|
+
? { ...undecided, status: L_TRUE, model, reasonUnknown: "" }
|
|
2106
|
+
: { ...undecided, model, reasonUnknown: "canceled" };
|
|
2107
|
+
return {
|
|
2108
|
+
...undecided,
|
|
2109
|
+
model,
|
|
2110
|
+
reasonUnknown:
|
|
2111
|
+
goals.length === 1 && goals[0].reasonUnknown !== "" ? goals[0].reasonUnknown : "unknown",
|
|
2112
|
+
};
|
|
2113
|
+
};
|
|
2114
|
+
|
|
2115
|
+
export const checkSatUsing = (tactic: Tactic, goal: Goal) => {
|
|
1953
2116
|
const goals = (() => {
|
|
1954
2117
|
try {
|
|
1955
2118
|
return tactic(goal);
|
|
1956
2119
|
} catch (error) {
|
|
1957
|
-
if (error instanceof SmtTacticError) return error.message;
|
|
2120
|
+
if (error instanceof SmtTacticError || error instanceof SmtDefaultError) return error.message;
|
|
1958
2121
|
if (error instanceof SmtCanceledError) return undefined;
|
|
1959
2122
|
throw error;
|
|
1960
2123
|
}
|
|
1961
2124
|
})();
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
: { ...undecided, model, reasonUnknown: "canceled" };
|
|
2125
|
+
try {
|
|
2126
|
+
return getTacticCheck(goal, goals);
|
|
2127
|
+
} finally {
|
|
2128
|
+
goal.reset();
|
|
2129
|
+
if (Array.isArray(goals)) for (const result of goals) result.reset();
|
|
1968
2130
|
}
|
|
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
2131
|
};
|
|
1978
2132
|
|
|
1979
2133
|
export const applyTactic = (tactic: Tactic, goal: Goal) => {
|
|
1980
2134
|
try {
|
|
1981
2135
|
return tactic(goal);
|
|
1982
2136
|
} catch (error) {
|
|
1983
|
-
if (error instanceof SmtCanceledError)
|
|
2137
|
+
if (error instanceof SmtCanceledError)
|
|
2138
|
+
throw new SmtTacticError(goal.manager.limit.getCancelMessage());
|
|
1984
2139
|
throw error;
|
|
1985
2140
|
}
|
|
1986
2141
|
};
|