tla-ts 0.0.10-dev.09e53c2a6 → 0.0.10-dev.1ebc153bd
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 +54 -54
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- 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 +43 -43
- package/dist/prove.js +78 -78
- package/dist/run.cjs +33 -35
- package/dist/run.js +44 -46
- package/dist/tlapm.cjs +1 -1
- package/dist/tlapm.js +2 -2
- package/dist/transfer.cjs +43 -43
- package/dist/transfer.js +38 -38
- package/dist/worker.cjs +6 -6
- package/dist/worker.js +6 -6
- package/package.json +1 -1
- package/src/ast.ts +1 -0
- package/src/bags.ts +46 -28
- package/src/check-trace.ts +2 -16
- package/src/check.ts +152 -64
- package/src/cli/runtime-invariants.ts +20 -56
- package/src/cli/tlc-arguments.ts +2 -2
- package/src/cli/tlc-output.ts +1 -2
- package/src/cli/tlc.ts +13 -8
- package/src/cli/xml-exporter.ts +1 -1
- package/src/codegen.ts +9 -5
- package/src/dependencies.ts +49 -9
- package/src/dfid.ts +9 -2
- package/src/environment.ts +57 -33
- package/src/errors.ts +7 -0
- package/src/evaluate.ts +92 -32
- package/src/exit-codes.ts +4 -2
- package/src/instances.ts +5 -5
- package/src/java-overrides.ts +2 -2
- package/src/levels.ts +138 -90
- package/src/liveness-checker.ts +43 -4
- package/src/liveness.ts +1 -1
- package/src/obligations/index.ts +1 -1
- package/src/obligations/normalize.ts +1 -4
- package/src/obligations/printer.ts +5 -5
- package/src/parallel-worker.ts +8 -2
- package/src/parallel.ts +5 -0
- package/src/parser.ts +106 -144
- 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/asserted-formulas.ts +66 -1
- package/src/prover/smt/solver/ast-lt.ts +1 -1
- package/src/prover/smt/solver/ast.ts +58 -11
- package/src/prover/smt/solver/blast-term-ite.ts +47 -0
- package/src/prover/smt/solver/bound-simplifier.ts +2 -3
- 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 +3 -5
- package/src/prover/smt/solver/cofactor-elim-term-ite.ts +2 -3
- package/src/prover/smt/solver/context.ts +24 -3
- 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 +9 -4
- package/src/prover/smt/solver/diff-neq.ts +1 -2
- package/src/prover/smt/solver/elim-term-ite-tactic.ts +48 -0
- package/src/prover/smt/solver/elim-uncnstr.ts +4 -7
- 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 -10
- 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 +2 -0
- 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/logic-tactics.ts +9 -2
- package/src/prover/smt/solver/lp/containers.ts +7 -1
- package/src/prover/smt/solver/lp/cross-nested.ts +1 -3
- package/src/prover/smt/solver/lp/lp-settings.ts +1 -1
- package/src/prover/smt/solver/lp/nex-creator.ts +3 -2
- package/src/prover/smt/solver/lp/nex.ts +2 -1
- 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/model-based-opt.ts +1 -1
- package/src/prover/smt/solver/model-generator.ts +3 -1
- 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 +10 -4
- package/src/prover/smt/solver/muz/dl-mk-slice.ts +3 -3
- package/src/prover/smt/solver/muz/dl-rule.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 +1 -1
- 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/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 +9 -3
- package/src/prover/smt/solver/opt-nlsat.ts +29 -18
- package/src/prover/smt/solver/opt-preprocess.ts +1 -1
- package/src/prover/smt/solver/opt-solver.ts +6 -3
- package/src/prover/smt/solver/optsmt.ts +1 -1
- package/src/prover/smt/solver/pb-rewriter.ts +1 -4
- package/src/prover/smt/solver/poly-rewriter.ts +74 -18
- package/src/prover/smt/solver/probes.ts +88 -23
- package/src/prover/smt/solver/proto-model.ts +4 -6
- 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/quantifier-manager.ts +14 -9
- package/src/prover/smt/solver/recfun-decl-plugin.ts +2 -1
- package/src/prover/smt/solver/rlimit.ts +4 -0
- package/src/prover/smt/solver/sat/config.ts +1 -1
- package/src/prover/smt/solver/sat/inc-sat-solver.ts +26 -1
- package/src/prover/smt/solver/sat/model-converter.ts +1 -1
- package/src/prover/smt/solver/sat/pb-solver.ts +1 -1
- package/src/prover/smt/solver/sat/sat-tactic.ts +4 -3
- package/src/prover/smt/solver/sat/simplifier.ts +1 -1
- package/src/prover/smt/solver/sat/solver.ts +25 -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 +4 -7
- 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-kernel.ts +9 -3
- package/src/prover/smt/solver/smt-setup.ts +68 -6
- package/src/prover/smt/solver/smtlib-parser.ts +558 -220
- package/src/prover/smt/solver/smtlib-script.ts +495 -153
- package/src/prover/smt/solver/solve-eqs.ts +13 -21
- package/src/prover/smt/solver/tactic.ts +219 -130
- package/src/prover/smt/solver/theory-bv.ts +2 -2
- package/src/prover/smt/solver/theory-lra-final-check.ts +1 -1
- package/src/prover/smt/solver/theory-lra-internalize.ts +1 -0
- package/src/prover/smt/solver/theory-lra-propagate.ts +6 -4
- package/src/prover/smt/solver/theory-lra.ts +0 -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/tlapm/cache.ts +8 -8
- package/src/prover/zenon/equality-rules.ts +24 -0
- package/src/prover/zenon/expr.ts +21 -0
- package/src/prover/zenon/index-table.ts +7 -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/prover/zenon/rules.ts +2 -1
- package/src/resolve.ts +624 -187
- package/src/runtime.ts +3 -1
- package/src/sany/builtins.ts +10 -10
- package/src/sany/generation.ts +2 -13
- package/src/sany/generator-definitions.ts +3 -1
- package/src/sany/generator-expressions.ts +36 -30
- package/src/sany/generator-proofs.ts +5 -3
- package/src/sany/generator.ts +2 -1
- package/src/sany/lexer.ts +3 -3
- 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 +51 -22
- package/src/spec-description.ts +2 -2
- package/src/subexpressions.ts +265 -94
- package/src/successors.ts +1 -0
- package/src/symmetry.ts +1 -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/tlc-operators.ts +3 -1
- package/src/tlc/tlcext-operators.ts +18 -5
- package/src/tlc/trace-spec.ts +5 -5
- package/src/typed-tier.ts +29 -23
- package/src/typescript/types.ts +2 -2
- package/src/values.ts +46 -27
|
@@ -1,22 +1,15 @@
|
|
|
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
10
|
import { AssertedFormulas } from "./asserted-formulas";
|
|
19
11
|
import { createAigTactic } from "./aig-tactic";
|
|
12
|
+
import { blastTermIte } from "./blast-term-ite";
|
|
20
13
|
import { card2bv } from "./card2bv";
|
|
21
14
|
import { Context, MBQI_MAX_ITERATIONS } from "./context";
|
|
22
15
|
import { ctxSimplify } from "./ctx-simplify";
|
|
@@ -32,6 +25,7 @@ import {
|
|
|
32
25
|
import type { AckrSolver } from "./lackr";
|
|
33
26
|
import { L_FALSE, L_TRUE, L_UNDEF } from "./lbool";
|
|
34
27
|
import { DerRewriter } from "./der";
|
|
28
|
+
import { finishSimplifier } from "./dependent-expr-state";
|
|
35
29
|
import { fixDlVar } from "./fix-dl-var";
|
|
36
30
|
import { runFpa2Bv } from "./fpa2bv-tactic";
|
|
37
31
|
import { type BitBlasterRewriter, runBitBlast } from "./bit-blast-tactic";
|
|
@@ -44,6 +38,7 @@ import { createSatTactic } from "./sat/sat-tactic";
|
|
|
44
38
|
import { mkThSolver } from "./euf/th-solvers";
|
|
45
39
|
import { createFdTactic } from "./fd-solver";
|
|
46
40
|
import { elimUncnstr } from "./elim-uncnstr";
|
|
41
|
+
import { runElimTermIte } from "./elim-term-ite-tactic";
|
|
47
42
|
import { rewriteUfbv } from "./demodulator";
|
|
48
43
|
import { distributeForall } from "./distribute-forall";
|
|
49
44
|
import { createDt2BvTactic } from "./dt2bv-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
|
|
|
@@ -339,6 +335,11 @@ export const getSatParams = (parameters: ReadonlyMap<string, string>) =>
|
|
|
339
335
|
}),
|
|
340
336
|
);
|
|
341
337
|
|
|
338
|
+
export const getSmtTacticFailure = (context: Context) =>
|
|
339
|
+
context.checkCanceled()
|
|
340
|
+
? "canceled"
|
|
341
|
+
: `smt tactic failed to show goal to be sat/unsat ${context.getLastFailureMessage()}`;
|
|
342
|
+
|
|
342
343
|
// sat_params reads what using-params leaves unset from the sat module's global parameters.
|
|
343
344
|
const getSatTacticParams = (environment: TacticEnvironment, params: TacticParams) =>
|
|
344
345
|
new Map([...getSatParams(environment.parameters), ...params]);
|
|
@@ -355,7 +356,7 @@ const runSmt = (environment: TacticEnvironment, params: TacticParams) => (goal:
|
|
|
355
356
|
? solveGoal(manager, goal.forms.items, kernelParams)
|
|
356
357
|
: solveAssuming(manager, extracted.clauses.items, extracted.assumptions, kernelParams);
|
|
357
358
|
extracted.clauses.reset();
|
|
358
|
-
if (solved.result === L_UNDEF) throw new SmtTacticError(solved.context
|
|
359
|
+
if (solved.result === L_UNDEF) throw new SmtTacticError(getSmtTacticFailure(solved.context));
|
|
359
360
|
goal.reset();
|
|
360
361
|
if (solved.result === L_FALSE)
|
|
361
362
|
goal.assert(environment.manager.falseExpr, mkCoreDependency(solved.context.unsatCore));
|
|
@@ -455,6 +456,39 @@ const inPlace = (run: (goal: Goal) => void) => (goal: Goal) => {
|
|
|
455
456
|
return [goal];
|
|
456
457
|
};
|
|
457
458
|
|
|
459
|
+
const selectClause = (goal: Goal, isLargest: boolean) => {
|
|
460
|
+
const manager = goal.manager;
|
|
461
|
+
let position = -1;
|
|
462
|
+
let length = 0;
|
|
463
|
+
for (let index = 0; index < goal.forms.size; index++) {
|
|
464
|
+
const form = goal.forms.items[index];
|
|
465
|
+
if (manager.getOp(form) !== OP_OR) continue;
|
|
466
|
+
const currentLength = manager.getNumArgs(form);
|
|
467
|
+
if (currentLength < 2) continue;
|
|
468
|
+
if (!isLargest) return index;
|
|
469
|
+
if (currentLength > length) {
|
|
470
|
+
position = index;
|
|
471
|
+
length = currentLength;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
return position;
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
const runSplitClause = (isLargest: boolean) => (goal: Goal) => {
|
|
478
|
+
const manager = goal.manager;
|
|
479
|
+
const position = selectClause(goal, isLargest);
|
|
480
|
+
if (position === -1)
|
|
481
|
+
throw new SmtTacticError("split-clause tactic failed, goal does not contain any clause");
|
|
482
|
+
if (goal.isProofsEnabled) throw new SmtUnsupportedError("the proofs of split-clause");
|
|
483
|
+
const dependency = goal.dependencies[position];
|
|
484
|
+
return manager.getArgs(goal.forms.items[position]).map((literal) => {
|
|
485
|
+
const subgoal = goal.copy();
|
|
486
|
+
subgoal.update(position, literal, dependency);
|
|
487
|
+
subgoal.depth++;
|
|
488
|
+
return subgoal;
|
|
489
|
+
});
|
|
490
|
+
};
|
|
491
|
+
|
|
458
492
|
const runDer = (manager: AstManager) => (goal: Goal) => {
|
|
459
493
|
const rewriter = new DerRewriter(manager);
|
|
460
494
|
const size = goal.forms.size;
|
|
@@ -463,9 +497,7 @@ const runDer = (manager: AstManager) => (goal: Goal) => {
|
|
|
463
497
|
goal.update(index, result);
|
|
464
498
|
manager.decRef(result);
|
|
465
499
|
}
|
|
466
|
-
goal
|
|
467
|
-
goal.elimRedundancies();
|
|
468
|
-
goal.depth++;
|
|
500
|
+
finishSimplifier(goal);
|
|
469
501
|
rewriter.der.release();
|
|
470
502
|
rewriter.release();
|
|
471
503
|
return [goal];
|
|
@@ -691,40 +723,30 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
691
723
|
]),
|
|
692
724
|
build: (environment, params) => {
|
|
693
725
|
const manager = environment.manager;
|
|
694
|
-
const snf = runNnf(manager, new Map());
|
|
695
726
|
const elimRemParams = new Map([...params, ["elim_rem", true]]);
|
|
696
|
-
return
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
727
|
+
return [
|
|
728
|
+
runNnf(manager, new Map()),
|
|
729
|
+
inPlace((goal) =>
|
|
730
|
+
simplifyGoal(manager, goal, getRewriterOptions(manager, elimRemParams)),
|
|
731
|
+
),
|
|
732
|
+
inPlace((goal) =>
|
|
733
|
+
purifyArith(manager, goal, {
|
|
734
|
+
isComplete: getBool(params, "complete", true),
|
|
735
|
+
isElimRootObjects: getBool(params, "elim_root_objects", true),
|
|
736
|
+
isElimInverses: getBool(params, "elim_inverses", true),
|
|
737
|
+
}),
|
|
738
|
+
),
|
|
739
|
+
inPlace((goal) => simplifyGoal(manager, goal, getRewriterOptions(manager, params))),
|
|
740
|
+
].reduceRight((second, first) => runAndThen(first, second));
|
|
707
741
|
},
|
|
708
742
|
},
|
|
709
743
|
],
|
|
710
744
|
[
|
|
711
745
|
"elim-term-ite",
|
|
712
746
|
{
|
|
747
|
+
isTrackingDependencies: true,
|
|
713
748
|
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
|
-
}),
|
|
749
|
+
build: (environment) => runElimTermIte(environment.manager),
|
|
728
750
|
},
|
|
729
751
|
],
|
|
730
752
|
[
|
|
@@ -752,7 +774,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
752
774
|
isEliminatingAnd: true,
|
|
753
775
|
isKeepingDistinct: false,
|
|
754
776
|
});
|
|
755
|
-
tseitinCnf(manager, goal);
|
|
777
|
+
if (!goal.isDecided()) tseitinCnf(manager, goal);
|
|
756
778
|
} finally {
|
|
757
779
|
original.reset();
|
|
758
780
|
}
|
|
@@ -764,14 +786,9 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
764
786
|
{
|
|
765
787
|
descrs: new Map(),
|
|
766
788
|
build: (environment) =>
|
|
767
|
-
inPlace((goal) =>
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
goal.elimTrue();
|
|
771
|
-
goal.elimRedundancies();
|
|
772
|
-
}
|
|
773
|
-
goal.depth++;
|
|
774
|
-
}),
|
|
789
|
+
inPlace((goal) =>
|
|
790
|
+
goal.isProofsEnabled ? finishSimplifier(goal) : applyQeLite(environment.manager, goal),
|
|
791
|
+
),
|
|
775
792
|
},
|
|
776
793
|
],
|
|
777
794
|
[
|
|
@@ -898,7 +915,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
898
915
|
"pb2bv",
|
|
899
916
|
{
|
|
900
917
|
descrs: new Map([
|
|
901
|
-
...[...REWRITER_DESCRS].filter((
|
|
918
|
+
...[...REWRITER_DESCRS].filter((entry) => BOOL_REWRITER_PARAMS.includes(entry[0])),
|
|
902
919
|
...getDescrs("", [
|
|
903
920
|
["max_memory", PARAM_UINT, UINT_MAX, true],
|
|
904
921
|
["pb2bv_all_clauses_limit", PARAM_UINT, 8, true],
|
|
@@ -1043,6 +1060,14 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1043
1060
|
},
|
|
1044
1061
|
],
|
|
1045
1062
|
["der", { descrs: new Map(), build: (environment) => runDer(environment.manager) }],
|
|
1063
|
+
[
|
|
1064
|
+
"blast-term-ite",
|
|
1065
|
+
{
|
|
1066
|
+
isTrackingDependencies: true,
|
|
1067
|
+
descrs: new Map(),
|
|
1068
|
+
build: (environment) => inPlace((goal) => blastTermIte(environment.manager, goal)),
|
|
1069
|
+
},
|
|
1070
|
+
],
|
|
1046
1071
|
[
|
|
1047
1072
|
"distribute-forall",
|
|
1048
1073
|
{
|
|
@@ -1104,6 +1129,15 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1104
1129
|
build: (environment) => inPlace((goal) => domSimplify(environment.manager, goal)),
|
|
1105
1130
|
},
|
|
1106
1131
|
],
|
|
1132
|
+
[
|
|
1133
|
+
"split-clause",
|
|
1134
|
+
{
|
|
1135
|
+
descrs: getDescrs("", [["split_largest_clause", PARAM_BOOL, false, true]]),
|
|
1136
|
+
isTrackingDependencies: true,
|
|
1137
|
+
build: (_environment, params) =>
|
|
1138
|
+
runSplitClause(getBool(params, "split_largest_clause", false)),
|
|
1139
|
+
},
|
|
1140
|
+
],
|
|
1107
1141
|
[
|
|
1108
1142
|
"occf",
|
|
1109
1143
|
{
|
|
@@ -1208,7 +1242,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1208
1242
|
const manager = environment.manager;
|
|
1209
1243
|
const preamble = createCommandReader(QFUFBV_ACKR_PREAMBLE).read() as SmtList;
|
|
1210
1244
|
return runAndThen(
|
|
1211
|
-
compile(environment, preamble,
|
|
1245
|
+
compile(environment, preamble, true).build(params),
|
|
1212
1246
|
runCond(
|
|
1213
1247
|
isQfufbv,
|
|
1214
1248
|
createQfufbvAckrTactic(manager, getRewriterOptions(manager, new Map()), true, () =>
|
|
@@ -1381,20 +1415,19 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1381
1415
|
|
|
1382
1416
|
const UNPORTED_TACTICS = new Set(
|
|
1383
1417
|
(
|
|
1384
|
-
"blast-term-ite " +
|
|
1385
1418
|
"bv-slice bvarray2uf collect-statistics " +
|
|
1386
1419
|
"degree-shift demodulator " +
|
|
1387
1420
|
"elim-predicates elim-uncnstr2 " +
|
|
1388
1421
|
"euf-completion ff-sat ff-simplify ff-solve ff-unique ff2bv fold-unfold fpa2bv " +
|
|
1389
1422
|
"horn-simplify injectivity pb-preprocess pqffd propagate-bv-bounds " +
|
|
1390
|
-
"propagate-bv-bounds2 propagate-values2 qfbv-sls
|
|
1423
|
+
"propagate-bv-bounds2 propagate-values2 qfbv-sls recover-01 reduce-args2 " +
|
|
1391
1424
|
"sat-preprocess sls-smt smtfd solver-subsumption special-relations " +
|
|
1392
|
-
"
|
|
1425
|
+
"subpaving symmetry-reduce"
|
|
1393
1426
|
).split(" "),
|
|
1394
1427
|
);
|
|
1395
1428
|
|
|
1396
|
-
const
|
|
1397
|
-
sexpr?.kind === "numeral" &&
|
|
1429
|
+
const isUnsignedNumeral = (sexpr: SExpr | undefined): sexpr is SmtToken =>
|
|
1430
|
+
sexpr?.kind === "numeral" && isUnsigned(sexpr.text);
|
|
1398
1431
|
|
|
1399
1432
|
const getParamName = (keyword: string) =>
|
|
1400
1433
|
keyword.replace(/^:/, "").toLowerCase().replaceAll("-", "_");
|
|
@@ -1415,7 +1448,7 @@ const parseParamValue = (kind: number, value: SExpr) =>
|
|
|
1415
1448
|
kind === PARAM_BOOL
|
|
1416
1449
|
? isSymbol(value, "true") || (isSymbol(value, "false") ? false : undefined)
|
|
1417
1450
|
: kind === PARAM_UINT
|
|
1418
|
-
?
|
|
1451
|
+
? isUnsignedNumeral(value)
|
|
1419
1452
|
? Number(value.text)
|
|
1420
1453
|
: undefined
|
|
1421
1454
|
: kind === PARAM_NUMERAL
|
|
@@ -1444,27 +1477,33 @@ const checkParams = (descrs: ParamDescrs, params: TacticParams) => {
|
|
|
1444
1477
|
}
|
|
1445
1478
|
};
|
|
1446
1479
|
|
|
1480
|
+
// sexpr2tactic reports an error at the s-expression: a list at its closing parenthesis.
|
|
1481
|
+
const getSexprPosition = (sexpr: SExpr) => (sexpr.kind === "list" ? sexpr.end : sexpr);
|
|
1482
|
+
|
|
1447
1483
|
const getParams = (
|
|
1448
1484
|
builder: TacticBuilder,
|
|
1449
1485
|
items: SExpr[],
|
|
1450
|
-
end: SmtToken,
|
|
1451
1486
|
isInternal: boolean,
|
|
1452
1487
|
): Map<string, TacticParam> => {
|
|
1453
1488
|
const params = new Map<string, TacticParam>();
|
|
1454
1489
|
for (let index = 2; index < items.length; index += 2) {
|
|
1455
1490
|
const keyword = items[index];
|
|
1456
1491
|
if (keyword.kind !== "keyword")
|
|
1457
|
-
throw new SmtParseError(
|
|
1492
|
+
throw new SmtParseError(
|
|
1493
|
+
"invalid using-params combinator, keyword expected",
|
|
1494
|
+
getSexprPosition(keyword),
|
|
1495
|
+
);
|
|
1458
1496
|
const value = items[index + 1];
|
|
1459
1497
|
if (value === undefined)
|
|
1460
|
-
throw new SmtParseError("invalid using-params combinator, parameter value expected",
|
|
1498
|
+
throw new SmtParseError("invalid using-params combinator, parameter value expected", keyword);
|
|
1461
1499
|
const found = findParam(builder.descrs, getParamName(keyword.text));
|
|
1462
1500
|
if (isInternal) {
|
|
1463
1501
|
const parsed =
|
|
1464
1502
|
found === undefined
|
|
1465
1503
|
? getUntypedParamValue(value)
|
|
1466
1504
|
: parseParamValue(found.descr.kind, value);
|
|
1467
|
-
if (parsed === undefined)
|
|
1505
|
+
if (parsed === undefined)
|
|
1506
|
+
throw new SmtParseError("invalid parameter value", getSexprPosition(value));
|
|
1468
1507
|
params.set(found?.name ?? getParamName(keyword.text), parsed);
|
|
1469
1508
|
continue;
|
|
1470
1509
|
}
|
|
@@ -1473,7 +1512,7 @@ const getParams = (
|
|
|
1473
1512
|
throw new SmtUnsupportedError(`the parameter ${keyword.text} of the tactic`);
|
|
1474
1513
|
throw new SmtParseError(
|
|
1475
1514
|
`invalid using-params combinator, unknown parameter ${getParamName(keyword.text)}`,
|
|
1476
|
-
|
|
1515
|
+
getSexprPosition(value),
|
|
1477
1516
|
);
|
|
1478
1517
|
}
|
|
1479
1518
|
const parsed = parseParamValue(found.descr.kind, value);
|
|
@@ -1486,7 +1525,7 @@ const getParams = (
|
|
|
1486
1525
|
: found.descr.kind === PARAM_NUMERAL
|
|
1487
1526
|
? "invalid parameter value, numeral expected"
|
|
1488
1527
|
: "invalid parameter value, symbol expected",
|
|
1489
|
-
|
|
1528
|
+
getSexprPosition(value),
|
|
1490
1529
|
);
|
|
1491
1530
|
if (isUnportedParam(found.descr, parsed))
|
|
1492
1531
|
throw new SmtUnsupportedError(`the parameter ${found.name} of the tactic`);
|
|
@@ -1505,19 +1544,30 @@ const isDecidedSat = (goals: Goal[]) => goals.length === 1 && goals[0].isDecided
|
|
|
1505
1544
|
|
|
1506
1545
|
const isDecidedUnsat = (goals: Goal[]) => goals.length === 1 && goals[0].isDecidedUnsat();
|
|
1507
1546
|
|
|
1547
|
+
// Deviation from Z3: and_then and repeat join the subgoals' cores, where Z3 answers an empty core.
|
|
1548
|
+
const assertUnsat = (goal: Goal, unsatGoals: Goal[]) => {
|
|
1549
|
+
goal.resetAll();
|
|
1550
|
+
goal.assert(
|
|
1551
|
+
goal.manager.falseExpr,
|
|
1552
|
+
unsatGoals.reduce<Dependency | undefined>(
|
|
1553
|
+
(core, unsatGoal) => joinDependencies(unsatGoal.getDependency(0), core),
|
|
1554
|
+
undefined,
|
|
1555
|
+
),
|
|
1556
|
+
);
|
|
1557
|
+
return [goal];
|
|
1558
|
+
};
|
|
1559
|
+
|
|
1508
1560
|
const runAndThen = (first: Tactic, second: Tactic) => (goal: Goal) => {
|
|
1509
1561
|
const goals = first(goal);
|
|
1510
1562
|
if (goals.length === 1) return goals[0].isDecided() ? goals : second(goals[0]);
|
|
1511
1563
|
const results: Goal[] = [];
|
|
1564
|
+
const unsatGoals: Goal[] = [];
|
|
1512
1565
|
for (const subgoal of goals) {
|
|
1513
1566
|
const subresults = second(subgoal);
|
|
1514
1567
|
if (isDecidedSat(subresults)) return subresults;
|
|
1515
|
-
|
|
1568
|
+
(isDecidedUnsat(subresults) ? unsatGoals : results).push(...subresults);
|
|
1516
1569
|
}
|
|
1517
|
-
|
|
1518
|
-
goal.resetAll();
|
|
1519
|
-
goal.assert(goal.manager.falseExpr);
|
|
1520
|
-
return [goal];
|
|
1570
|
+
return results.length > 0 ? results : assertUnsat(goal, unsatGoals);
|
|
1521
1571
|
};
|
|
1522
1572
|
|
|
1523
1573
|
const runOrElse = (tactics: Tactic[]) => (goal: Goal) => {
|
|
@@ -1531,7 +1581,7 @@ const runOrElse = (tactics: Tactic[]) => (goal: Goal) => {
|
|
|
1531
1581
|
goal.resetAll();
|
|
1532
1582
|
goal.copyFrom(original);
|
|
1533
1583
|
}
|
|
1534
|
-
return
|
|
1584
|
+
return tactics[tactics.length - 1](goal);
|
|
1535
1585
|
};
|
|
1536
1586
|
|
|
1537
1587
|
const isEqualGoal = (first: Goal, second: Goal) => {
|
|
@@ -1551,15 +1601,13 @@ const runRepeat = (tactic: Tactic, maxDepth: number) => {
|
|
|
1551
1601
|
if (goals.length === 1 && isEqualGoal(original, goals[0])) return goals;
|
|
1552
1602
|
if (goals.length === 1) return goals[0].isDecided() ? goals : run(depth + 1, goals[0]);
|
|
1553
1603
|
const results: Goal[] = [];
|
|
1604
|
+
const unsatGoals: Goal[] = [];
|
|
1554
1605
|
for (const subgoal of goals) {
|
|
1555
1606
|
const subresults = run(depth + 1, subgoal);
|
|
1556
1607
|
if (isDecidedSat(subresults)) return subresults;
|
|
1557
|
-
|
|
1608
|
+
(isDecidedUnsat(subresults) ? unsatGoals : results).push(...subresults);
|
|
1558
1609
|
}
|
|
1559
|
-
|
|
1560
|
-
goal.resetAll();
|
|
1561
|
-
goal.assert(goal.manager.falseExpr);
|
|
1562
|
-
return [goal];
|
|
1610
|
+
return results.length > 0 ? results : assertUnsat(goal, unsatGoals);
|
|
1563
1611
|
};
|
|
1564
1612
|
return (goal: Goal) => run(0, goal);
|
|
1565
1613
|
};
|
|
@@ -1567,22 +1615,21 @@ const runRepeat = (tactic: Tactic, maxDepth: number) => {
|
|
|
1567
1615
|
const runCond = (probe: Probe, onTrue: Tactic, onFalse: Tactic) => (goal: Goal) =>
|
|
1568
1616
|
probe(goal) === 0 ? onFalse(goal) : onTrue(goal);
|
|
1569
1617
|
|
|
1570
|
-
const checkHasArgument = (list: SmtList, combinator: string
|
|
1618
|
+
const checkHasArgument = (list: SmtList, combinator: string) => {
|
|
1571
1619
|
if (list.items.length < 2)
|
|
1572
1620
|
throw new SmtParseError(
|
|
1573
1621
|
`invalid ${combinator} combinator, at least one argument expected`,
|
|
1574
|
-
end,
|
|
1622
|
+
list.end,
|
|
1575
1623
|
);
|
|
1576
1624
|
};
|
|
1577
1625
|
|
|
1578
1626
|
const compile = (
|
|
1579
1627
|
environment: TacticEnvironment,
|
|
1580
1628
|
sexpr: SExpr,
|
|
1581
|
-
end: SmtToken,
|
|
1582
1629
|
isInternal: boolean,
|
|
1583
1630
|
): TacticBuilder => {
|
|
1584
1631
|
if (sexpr.kind !== "list") {
|
|
1585
|
-
if (!isSymbol(sexpr)) throw new SmtParseError("invalid tactic, unexpected input",
|
|
1632
|
+
if (!isSymbol(sexpr)) throw new SmtParseError("invalid tactic, unexpected input", sexpr);
|
|
1586
1633
|
const named = NAMED_TACTICS.get(sexpr.text);
|
|
1587
1634
|
if (named !== undefined)
|
|
1588
1635
|
return {
|
|
@@ -1600,7 +1647,7 @@ const compile = (
|
|
|
1600
1647
|
};
|
|
1601
1648
|
const strategy = LOGIC_TACTICS.get(sexpr.text);
|
|
1602
1649
|
if (strategy !== undefined)
|
|
1603
|
-
return compile(environment, createCommandReader(strategy).read() as SmtList,
|
|
1650
|
+
return compile(environment, createCommandReader(strategy).read() as SmtList, true);
|
|
1604
1651
|
if (UNPORTED_TACTICS.has(sexpr.text)) {
|
|
1605
1652
|
const error = new SmtUnsupportedError(`the tactic ${sexpr.text}`);
|
|
1606
1653
|
if (!isInternal) throw error;
|
|
@@ -1613,14 +1660,14 @@ const compile = (
|
|
|
1613
1660
|
},
|
|
1614
1661
|
};
|
|
1615
1662
|
}
|
|
1616
|
-
throw new SmtParseError(`invalid tactic, unknown tactic ${sexpr.text}`,
|
|
1663
|
+
throw new SmtParseError(`invalid tactic, unknown tactic ${sexpr.text}`, sexpr);
|
|
1617
1664
|
}
|
|
1618
1665
|
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);
|
|
1666
|
+
if (head === undefined) throw new SmtParseError("invalid tactic, arguments expected", sexpr.end);
|
|
1667
|
+
if (!isSymbol(head)) throw new SmtParseError("invalid tactic, symbol expected", sexpr.end);
|
|
1621
1668
|
const compileChildren = (combinator: string) => {
|
|
1622
|
-
checkHasArgument(sexpr, combinator
|
|
1623
|
-
return sexpr.items.slice(1).map((child) => compile(environment, child,
|
|
1669
|
+
checkHasArgument(sexpr, combinator);
|
|
1670
|
+
return sexpr.items.slice(1).map((child) => compile(environment, child, isInternal));
|
|
1624
1671
|
};
|
|
1625
1672
|
switch (head.text) {
|
|
1626
1673
|
case "then":
|
|
@@ -1670,27 +1717,43 @@ const compile = (
|
|
|
1670
1717
|
// The timeout is not ported, so the child runs to the end.
|
|
1671
1718
|
case "try-for": {
|
|
1672
1719
|
if (sexpr.items.length !== 3)
|
|
1673
|
-
throw new SmtParseError("invalid try-for combinator, two arguments expected", end);
|
|
1674
|
-
if (!
|
|
1720
|
+
throw new SmtParseError("invalid try-for combinator, two arguments expected", sexpr.end);
|
|
1721
|
+
if (!isUnsignedNumeral(sexpr.items[2]))
|
|
1675
1722
|
throw new SmtParseError(
|
|
1676
1723
|
"invalid try-for combinator, second argument must be an unsigned integer",
|
|
1677
|
-
end,
|
|
1724
|
+
sexpr.end,
|
|
1678
1725
|
);
|
|
1679
|
-
|
|
1726
|
+
const child = compile(environment, sexpr.items[1], isInternal);
|
|
1727
|
+
return {
|
|
1728
|
+
...child,
|
|
1729
|
+
build: (params) => {
|
|
1730
|
+
const tactic = child.build(params);
|
|
1731
|
+
return (goal) => {
|
|
1732
|
+
try {
|
|
1733
|
+
return tactic(goal);
|
|
1734
|
+
} catch (error) {
|
|
1735
|
+
if (error instanceof SmtDefaultError) throw new SmtTacticError(error.message);
|
|
1736
|
+
if (error instanceof SmtCanceledError)
|
|
1737
|
+
throw new SmtTacticError(goal.manager.limit.getCancelMessage());
|
|
1738
|
+
throw error;
|
|
1739
|
+
}
|
|
1740
|
+
};
|
|
1741
|
+
},
|
|
1742
|
+
};
|
|
1680
1743
|
}
|
|
1681
1744
|
case "fail-if-branching": {
|
|
1682
1745
|
if (sexpr.items.length !== 3 && sexpr.items.length !== 2)
|
|
1683
1746
|
throw new SmtParseError(
|
|
1684
1747
|
"invalid fail-if-branching combinator, one or two arguments expected",
|
|
1685
|
-
end,
|
|
1748
|
+
sexpr.end,
|
|
1686
1749
|
);
|
|
1687
1750
|
const bound = sexpr.items[2];
|
|
1688
|
-
if (bound !== undefined && !
|
|
1751
|
+
if (bound !== undefined && !isUnsignedNumeral(bound))
|
|
1689
1752
|
throw new SmtParseError(
|
|
1690
1753
|
"invalid fail-if-branching combinator, second argument must be an unsigned integer",
|
|
1691
|
-
end,
|
|
1754
|
+
sexpr.end,
|
|
1692
1755
|
);
|
|
1693
|
-
const child = compile(environment, sexpr.items[1],
|
|
1756
|
+
const child = compile(environment, sexpr.items[1], isInternal);
|
|
1694
1757
|
const threshold = bound === undefined ? 1 : Number(bound.text);
|
|
1695
1758
|
return {
|
|
1696
1759
|
...mergeDescrs([child]),
|
|
@@ -1708,11 +1771,17 @@ const compile = (
|
|
|
1708
1771
|
case "if-no-unsat-cores":
|
|
1709
1772
|
case "if-no-models": {
|
|
1710
1773
|
if (sexpr.items.length !== 2)
|
|
1711
|
-
throw new SmtParseError(
|
|
1712
|
-
|
|
1774
|
+
throw new SmtParseError(
|
|
1775
|
+
`invalid ${head.text} combinator, one argument expected`,
|
|
1776
|
+
sexpr.end,
|
|
1777
|
+
);
|
|
1778
|
+
const child = compile(environment, sexpr.items[1], isInternal);
|
|
1713
1779
|
const isSkipping = (goal: Goal) =>
|
|
1714
|
-
head.text === "if-no-models"
|
|
1715
|
-
|
|
1780
|
+
head.text === "if-no-models"
|
|
1781
|
+
? goal.isModelsEnabled
|
|
1782
|
+
: head.text === "if-no-proofs"
|
|
1783
|
+
? goal.isProofsEnabled
|
|
1784
|
+
: goal.isCoresEnabled;
|
|
1716
1785
|
return {
|
|
1717
1786
|
...mergeDescrs([child]),
|
|
1718
1787
|
build: (params) => {
|
|
@@ -1723,14 +1792,17 @@ const compile = (
|
|
|
1723
1792
|
}
|
|
1724
1793
|
case "repeat": {
|
|
1725
1794
|
if (sexpr.items.length !== 3 && sexpr.items.length !== 2)
|
|
1726
|
-
throw new SmtParseError(
|
|
1795
|
+
throw new SmtParseError(
|
|
1796
|
+
"invalid repeat combinator, one or two arguments expected",
|
|
1797
|
+
sexpr.end,
|
|
1798
|
+
);
|
|
1727
1799
|
const bound = sexpr.items[2];
|
|
1728
|
-
if (bound !== undefined && !
|
|
1800
|
+
if (bound !== undefined && !isUnsignedNumeral(bound))
|
|
1729
1801
|
throw new SmtParseError(
|
|
1730
1802
|
"invalid repeat combinator, second argument must be an unsigned integer",
|
|
1731
|
-
end,
|
|
1803
|
+
sexpr.end,
|
|
1732
1804
|
);
|
|
1733
|
-
const child = compile(environment, sexpr.items[1],
|
|
1805
|
+
const child = compile(environment, sexpr.items[1], isInternal);
|
|
1734
1806
|
const maxDepth = bound === undefined ? UINT_MAX : Number(bound.text);
|
|
1735
1807
|
return {
|
|
1736
1808
|
...mergeDescrs([child]),
|
|
@@ -1740,10 +1812,10 @@ const compile = (
|
|
|
1740
1812
|
case "!":
|
|
1741
1813
|
case "using-params":
|
|
1742
1814
|
case "with": {
|
|
1743
|
-
checkHasArgument(sexpr, "using-params"
|
|
1744
|
-
const child = compile(environment, sexpr.items[1],
|
|
1815
|
+
checkHasArgument(sexpr, "using-params");
|
|
1816
|
+
const child = compile(environment, sexpr.items[1], isInternal);
|
|
1745
1817
|
if (sexpr.items.length === 2) return child;
|
|
1746
|
-
const own = getParams(child, sexpr.items,
|
|
1818
|
+
const own = getParams(child, sexpr.items, isInternal);
|
|
1747
1819
|
return {
|
|
1748
1820
|
...mergeDescrs([child]),
|
|
1749
1821
|
build: (params) => child.build(new Map([...params, ...own])),
|
|
@@ -1751,8 +1823,11 @@ const compile = (
|
|
|
1751
1823
|
}
|
|
1752
1824
|
case "skip-if-failed": {
|
|
1753
1825
|
if (sexpr.items.length !== 2)
|
|
1754
|
-
throw new SmtParseError(
|
|
1755
|
-
|
|
1826
|
+
throw new SmtParseError(
|
|
1827
|
+
"invalid skip-if-failed combinator, one argument expected",
|
|
1828
|
+
sexpr.end,
|
|
1829
|
+
);
|
|
1830
|
+
const child = compile(environment, sexpr.items[1], isInternal);
|
|
1756
1831
|
return {
|
|
1757
1832
|
...mergeDescrs([child]),
|
|
1758
1833
|
build: (params) => runOrElse([child.build(params), (goal) => [goal]]),
|
|
@@ -1762,11 +1837,12 @@ const compile = (
|
|
|
1762
1837
|
case "ite":
|
|
1763
1838
|
case "cond": {
|
|
1764
1839
|
if (sexpr.items.length !== 4)
|
|
1765
|
-
throw new SmtParseError(
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1840
|
+
throw new SmtParseError(
|
|
1841
|
+
"invalid if/conditional combinator, three arguments expected",
|
|
1842
|
+
sexpr.end,
|
|
1843
|
+
);
|
|
1844
|
+
const probe = compileProbe(sexpr.items[1], isInternal);
|
|
1845
|
+
const children = sexpr.items.slice(2).map((child) => compile(environment, child, isInternal));
|
|
1770
1846
|
return {
|
|
1771
1847
|
...mergeDescrs(children),
|
|
1772
1848
|
build: (params) => runCond(probe, children[0].build(params), children[1].build(params)),
|
|
@@ -1774,9 +1850,9 @@ const compile = (
|
|
|
1774
1850
|
}
|
|
1775
1851
|
case "when": {
|
|
1776
1852
|
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],
|
|
1853
|
+
throw new SmtParseError("invalid when combinator, two arguments expected", sexpr.end);
|
|
1854
|
+
const probe = compileProbe(sexpr.items[1], isInternal);
|
|
1855
|
+
const child = compile(environment, sexpr.items[2], isInternal);
|
|
1780
1856
|
return {
|
|
1781
1857
|
...mergeDescrs([child]),
|
|
1782
1858
|
build: (params) => runCond(probe, child.build(params), (goal) => [goal]),
|
|
@@ -1784,8 +1860,8 @@ const compile = (
|
|
|
1784
1860
|
}
|
|
1785
1861
|
case "fail-if": {
|
|
1786
1862
|
if (sexpr.items.length !== 2)
|
|
1787
|
-
throw new SmtParseError("invalid fail-if tactic, one argument expected", end);
|
|
1788
|
-
const probe = compileProbe(sexpr.items[1],
|
|
1863
|
+
throw new SmtParseError("invalid fail-if tactic, one argument expected", sexpr.end);
|
|
1864
|
+
const probe = compileProbe(sexpr.items[1], isInternal);
|
|
1789
1865
|
return {
|
|
1790
1866
|
descrs: new Map(),
|
|
1791
1867
|
isRejectingUnknown: true,
|
|
@@ -1798,7 +1874,7 @@ const compile = (
|
|
|
1798
1874
|
}
|
|
1799
1875
|
case "echo": {
|
|
1800
1876
|
if (sexpr.items.length < 2)
|
|
1801
|
-
throw new SmtParseError("invalid echo tactic, must have at least one argument", end);
|
|
1877
|
+
throw new SmtParseError("invalid echo tactic, must have at least one argument", sexpr.end);
|
|
1802
1878
|
const pieces = sexpr.items.slice(1).map((piece, index, all): Tactic => {
|
|
1803
1879
|
const newline = index === all.length - 1 ? "\n" : "";
|
|
1804
1880
|
if (piece.kind === "string")
|
|
@@ -1806,7 +1882,7 @@ const compile = (
|
|
|
1806
1882
|
environment.write(piece.text + newline, false);
|
|
1807
1883
|
return [goal];
|
|
1808
1884
|
};
|
|
1809
|
-
const probe = compileProbe(piece,
|
|
1885
|
+
const probe = compileProbe(piece, isInternal);
|
|
1810
1886
|
return (goal) => {
|
|
1811
1887
|
environment.write(formatProbeValue(probe(goal)) + newline, true);
|
|
1812
1888
|
return [goal];
|
|
@@ -1820,7 +1896,7 @@ const compile = (
|
|
|
1820
1896
|
};
|
|
1821
1897
|
}
|
|
1822
1898
|
default:
|
|
1823
|
-
throw new SmtParseError(`invalid tactic, unknown tactic combinator ${head.text}`, end);
|
|
1899
|
+
throw new SmtParseError(`invalid tactic, unknown tactic combinator ${head.text}`, sexpr.end);
|
|
1824
1900
|
}
|
|
1825
1901
|
};
|
|
1826
1902
|
|
|
@@ -1868,19 +1944,18 @@ export const mkIncSatPreprocess = (manager: AstManager, bitBlaster: BitBlasterRe
|
|
|
1868
1944
|
),
|
|
1869
1945
|
].reduceRight((second, first) => runAndThen(first, second));
|
|
1870
1946
|
|
|
1871
|
-
export const compileTactic = (environment: TacticEnvironment, sexpr: SExpr
|
|
1872
|
-
compile(environment, sexpr,
|
|
1947
|
+
export const compileTactic = (environment: TacticEnvironment, sexpr: SExpr) =>
|
|
1948
|
+
compile(environment, sexpr, false);
|
|
1873
1949
|
|
|
1874
1950
|
export const compileInternalTactic = (environment: TacticEnvironment, text: string) => {
|
|
1875
1951
|
const list = createCommandReader(`(${text})`).read() as SmtList;
|
|
1876
|
-
return compile(environment, list.items[0],
|
|
1952
|
+
return compile(environment, list.items[0], true).build(new Map());
|
|
1877
1953
|
};
|
|
1878
1954
|
|
|
1879
1955
|
interface TacticCheck {
|
|
1880
1956
|
status: number;
|
|
1881
1957
|
model: ProtoModel | undefined;
|
|
1882
1958
|
core: Dependency | undefined;
|
|
1883
|
-
// What check_sat leaves in reason_unknown, or undefined where the port does not track it.
|
|
1884
1959
|
reasonUnknown: string | undefined;
|
|
1885
1960
|
}
|
|
1886
1961
|
|
|
@@ -1948,32 +2023,46 @@ export const convertModel = (goal: Goal, model: ProtoModel) =>
|
|
|
1948
2023
|
return converted;
|
|
1949
2024
|
}, model);
|
|
1950
2025
|
|
|
2026
|
+
const getConvertedModel = (goal: Goal) =>
|
|
2027
|
+
convertModel(goal, goal.model?.copy() ?? new ProtoModel(goal.manager).mkModel());
|
|
2028
|
+
|
|
1951
2029
|
export const checkSatUsing = (tactic: Tactic, goal: Goal): TacticCheck => {
|
|
1952
2030
|
const undecided = { status: L_UNDEF, model: undefined, core: undefined };
|
|
1953
2031
|
const goals = (() => {
|
|
1954
2032
|
try {
|
|
1955
2033
|
return tactic(goal);
|
|
1956
2034
|
} catch (error) {
|
|
1957
|
-
if (error instanceof SmtTacticError) return error.message;
|
|
2035
|
+
if (error instanceof SmtTacticError || error instanceof SmtDefaultError) return error.message;
|
|
1958
2036
|
if (error instanceof SmtCanceledError) return undefined;
|
|
1959
2037
|
throw error;
|
|
1960
2038
|
}
|
|
1961
2039
|
})();
|
|
2040
|
+
if (goals === undefined) return { ...undecided, reasonUnknown: undefined };
|
|
1962
2041
|
if (typeof goals === "string") return { ...undecided, reasonUnknown: goals };
|
|
1963
|
-
if (
|
|
1964
|
-
const model =
|
|
2042
|
+
if (isDecidedSat(goals)) {
|
|
2043
|
+
const model = getConvertedModel(goals[0]);
|
|
1965
2044
|
return goal.manager.limit.inc()
|
|
1966
2045
|
? { status: L_TRUE, model, core: undefined, reasonUnknown: "" }
|
|
1967
2046
|
: { ...undecided, model, reasonUnknown: "canceled" };
|
|
1968
2047
|
}
|
|
1969
|
-
if (
|
|
2048
|
+
if (isDecidedUnsat(goals))
|
|
1970
2049
|
return {
|
|
1971
2050
|
status: L_FALSE,
|
|
1972
2051
|
model: undefined,
|
|
1973
2052
|
core: goals[0].getDependency(0),
|
|
1974
2053
|
reasonUnknown: "",
|
|
1975
2054
|
};
|
|
1976
|
-
return {
|
|
2055
|
+
return {
|
|
2056
|
+
...undecided,
|
|
2057
|
+
model:
|
|
2058
|
+
goal.isModelsEnabled &&
|
|
2059
|
+
goals.length > 0 &&
|
|
2060
|
+
(goals[0].model !== undefined || goals[0].converters.length > 0)
|
|
2061
|
+
? getConvertedModel(goals[0])
|
|
2062
|
+
: undefined,
|
|
2063
|
+
reasonUnknown:
|
|
2064
|
+
goals.length === 1 && goals[0].reasonUnknown !== "" ? goals[0].reasonUnknown : "unknown",
|
|
2065
|
+
};
|
|
1977
2066
|
};
|
|
1978
2067
|
|
|
1979
2068
|
export const applyTactic = (tactic: Tactic, goal: Goal) => {
|