tla-ts 0.0.10-dev.96638cd93 → 0.0.10-dev.a17d6d9fa
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/deciders.cjs +30 -30
- package/dist/deciders.js +30 -30
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +1 -1
- package/dist/prove.cjs +60 -60
- package/dist/prove.js +73 -73
- package/dist/run.cjs +42 -42
- package/dist/run.js +42 -42
- package/dist/transfer.cjs +34 -34
- package/dist/transfer.js +29 -29
- package/dist/worker.cjs +1 -1
- package/dist/worker.js +1 -1
- package/package.json +1 -1
- package/src/bags.ts +5 -2
- package/src/builtins.ts +4 -3
- package/src/check-failure.ts +1 -1
- package/src/check-trace.ts +90 -51
- package/src/check.ts +251 -133
- package/src/cli/tlc.ts +3 -2
- package/src/codegen.ts +18 -5
- package/src/dfid.ts +13 -8
- package/src/environment.ts +1 -0
- package/src/evaluate.ts +25 -9
- package/src/exit-codes.ts +1 -0
- package/src/java-hash.ts +14 -0
- package/src/liveness-checker.ts +63 -31
- package/src/liveness.ts +48 -10
- package/src/parser.ts +6 -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 +109 -63
- package/src/prover/smt/solver/ast.ts +5 -3
- package/src/prover/smt/solver/auf-solver.ts +23 -12
- package/src/prover/smt/solver/bit-blast-tactic.ts +26 -0
- package/src/prover/smt/solver/bound-simplifier.ts +10 -11
- package/src/prover/smt/solver/card2bv.ts +31 -15
- package/src/prover/smt/solver/cofactor-elim-term-ite.ts +39 -23
- package/src/prover/smt/solver/context.ts +24 -7
- package/src/prover/smt/solver/dependent-expr-state.ts +1 -1
- package/src/prover/smt/solver/elim-bounds.ts +89 -0
- package/src/prover/smt/solver/elim-uncnstr.ts +1 -1
- package/src/prover/smt/solver/internalizer.ts +1 -1
- package/src/prover/smt/solver/lp/lp-settings.ts +4 -0
- package/src/prover/smt/solver/model-evaluator.ts +2 -0
- package/src/prover/smt/solver/model-generator.ts +82 -42
- package/src/prover/smt/solver/opt-context.ts +11 -4
- package/src/prover/smt/solver/opt-pareto.ts +19 -0
- package/src/prover/smt/solver/opt-solver.ts +3 -2
- package/src/prover/smt/solver/poly-rewriter.ts +1 -0
- package/src/prover/smt/solver/proto-model.ts +4 -2
- package/src/prover/smt/solver/push-app-ite.ts +37 -0
- package/src/prover/smt/solver/qsat.ts +16 -6
- package/src/prover/smt/solver/rewriter.ts +31 -25
- package/src/prover/smt/solver/sat/goal2sat.ts +0 -1
- package/src/prover/smt/solver/sat/inc-sat-solver.ts +13 -4
- package/src/prover/smt/solver/sat/sat-tactic.ts +9 -2
- package/src/prover/smt/solver/smt-kernel.ts +30 -2
- package/src/prover/smt/solver/smt-setup.ts +28 -4
- package/src/prover/smt/solver/smtlib-parser.ts +26 -3
- package/src/prover/smt/solver/smtlib-script.ts +34 -21
- package/src/prover/smt/solver/solve-eqs.ts +24 -17
- package/src/prover/smt/solver/solver.ts +18 -3
- package/src/prover/smt/solver/tactic.ts +68 -41
- package/src/prover/smt/solver/theory-bv.ts +11 -1
- 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 +1 -0
- package/src/prover/smt/solver/theory-lra-propagate.ts +7 -1
- package/src/prover/smt/solver/theory-lra.ts +1 -0
- package/src/prover/smt/solver/tseitin-cnf.ts +1 -0
- package/src/resolve.ts +120 -52
- package/src/runtime.ts +4 -0
- package/src/search.ts +117 -81
- package/src/simulate.ts +110 -50
- package/src/spec-description.ts +3 -4
- package/src/standard-modules.ts +15 -6
- package/src/subexpressions.ts +34 -9
- package/src/successors.ts +3 -2
- package/src/tlc/random.ts +2 -1
- package/src/tlc/replay.ts +3 -2
- package/src/tlc/tlc-operators.ts +7 -7
- package/src/tlc/tlcext-operators.ts +26 -10
- package/src/tlc/trace-spec.ts +6 -20
- package/src/typed-tier.ts +3 -2
- package/src/values.ts +95 -57
|
@@ -36,7 +36,7 @@ import { getSubterms } from "./recfun-decl-plugin";
|
|
|
36
36
|
import { RefVector } from "./ref-vector";
|
|
37
37
|
import { Rewriter, type RewriterOptions } from "./rewriter";
|
|
38
38
|
import { RewriterTpl } from "./rewriter-tpl";
|
|
39
|
-
import { finishSimplifier } from "./dependent-expr-state";
|
|
39
|
+
import { DependentExprState, finishSimplifier } from "./dependent-expr-state";
|
|
40
40
|
|
|
41
41
|
interface SolveEqsOptions {
|
|
42
42
|
isTheorySolver: boolean;
|
|
@@ -108,6 +108,7 @@ export class SolveEqs {
|
|
|
108
108
|
private orPositive = new Set<number>();
|
|
109
109
|
private orNegative = new Set<number>();
|
|
110
110
|
private rewriter: Rewriter;
|
|
111
|
+
private state: DependentExprState;
|
|
111
112
|
|
|
112
113
|
constructor(
|
|
113
114
|
private manager: AstManager,
|
|
@@ -119,6 +120,7 @@ export class SolveEqs {
|
|
|
119
120
|
this.bounds = new BoundManager(manager);
|
|
120
121
|
this.substitution = new ObjMap((expr) => manager.hashes[expr]);
|
|
121
122
|
this.rewriter = new Rewriter(manager, options.rewriter);
|
|
123
|
+
this.state = new DependentExprState(manager, goal);
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
private pin(expr: number) {
|
|
@@ -516,12 +518,15 @@ export class SolveEqs {
|
|
|
516
518
|
|
|
517
519
|
private getEqs() {
|
|
518
520
|
const eqs: DependentEq[] = [];
|
|
519
|
-
const
|
|
520
|
-
if (!this.goal.isProofsEnabled)
|
|
521
|
-
|
|
521
|
+
const state = this.state;
|
|
522
|
+
if (!this.goal.isProofsEnabled)
|
|
523
|
+
state.forEachIndex((index) => this.getArithEqs(state.get(index), eqs));
|
|
524
|
+
state.forEachIndex((index) => this.getBasicEqs(state.get(index), eqs));
|
|
522
525
|
if (!this.goal.isProofsEnabled) {
|
|
523
|
-
|
|
524
|
-
|
|
526
|
+
state.forEachIndex((index) => this.getBvEqs(state.get(index), eqs));
|
|
527
|
+
state.forEachIndex((index) => this.checkArrayEqs(state.get(index)));
|
|
528
|
+
// ff_extract_eq finds no equations without finite fields, but its pass still counts steps.
|
|
529
|
+
state.forEachIndex(() => {});
|
|
525
530
|
}
|
|
526
531
|
return eqs;
|
|
527
532
|
}
|
|
@@ -593,7 +598,7 @@ export class SolveEqs {
|
|
|
593
598
|
const replacer = new SubstReplacer(manager, this.substitution);
|
|
594
599
|
this.substIds.sort((first, second) => this.id2level[second] - this.id2level[first]);
|
|
595
600
|
for (const id of this.substIds) {
|
|
596
|
-
manager.limit.
|
|
601
|
+
if (!manager.limit.inc()) break;
|
|
597
602
|
const eq = this.next[id][0];
|
|
598
603
|
const definition = replacer.rewrite(eq.term);
|
|
599
604
|
this.pinned.pushOwned(definition);
|
|
@@ -605,19 +610,19 @@ export class SolveEqs {
|
|
|
605
610
|
}
|
|
606
611
|
|
|
607
612
|
private applySubst() {
|
|
608
|
-
if (this.substIds.length === 0) return;
|
|
609
613
|
const manager = this.manager;
|
|
614
|
+
if (!manager.limit.inc() || this.substIds.length === 0) return;
|
|
610
615
|
const replacer = new SubstReplacer(manager, this.substitution);
|
|
611
616
|
const goal = this.goal;
|
|
612
|
-
const
|
|
613
|
-
|
|
614
|
-
const form =
|
|
617
|
+
const state = this.state;
|
|
618
|
+
state.forEachIndex((index) => {
|
|
619
|
+
const form = state.get(index);
|
|
615
620
|
const replaced = replacer.rewrite(form);
|
|
616
621
|
const simplified = this.rewriter.rewrite(replaced);
|
|
617
622
|
manager.decRef(replaced);
|
|
618
623
|
if (simplified !== form) goal.update(index, simplified);
|
|
619
624
|
manager.decRef(simplified);
|
|
620
|
-
}
|
|
625
|
+
});
|
|
621
626
|
replacer.release();
|
|
622
627
|
}
|
|
623
628
|
|
|
@@ -655,12 +660,13 @@ export class SolveEqs {
|
|
|
655
660
|
this.markPositive(form);
|
|
656
661
|
this.bounds.add(form);
|
|
657
662
|
}
|
|
658
|
-
|
|
663
|
+
const limit = this.manager.limit;
|
|
664
|
+
let count = 0;
|
|
665
|
+
do {
|
|
659
666
|
this.runRound(() => this.getEqs());
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
if (this.options.isContextSolve && !goal.isProofsEnabled)
|
|
667
|
+
count++;
|
|
668
|
+
} while (this.substIds.length > 0 && count < 20 && limit.inc());
|
|
669
|
+
if (limit.inc() && this.options.isContextSolve && !goal.isProofsEnabled)
|
|
664
670
|
this.runRound(() => this.collectNestedEqualities());
|
|
665
671
|
this.eqTerms.reset();
|
|
666
672
|
finishSimplifier(goal, this.definitions);
|
|
@@ -914,6 +920,7 @@ export class SolveEqs {
|
|
|
914
920
|
}
|
|
915
921
|
|
|
916
922
|
release() {
|
|
923
|
+
this.state.release();
|
|
917
924
|
this.rewriter.release();
|
|
918
925
|
this.pinned.reset();
|
|
919
926
|
this.eqTerms.reset();
|
|
@@ -9,7 +9,7 @@ import type { DecideOptions, Verdict } from "../../verdict";
|
|
|
9
9
|
import { AssertedFormulas } from "./asserted-formulas";
|
|
10
10
|
import { AstManager } from "./ast";
|
|
11
11
|
import { Context, MBQI_MAX_ITERATIONS } from "./context";
|
|
12
|
-
import { L_FALSE, L_TRUE } from "./lbool";
|
|
12
|
+
import { L_FALSE, L_TRUE, L_UNDEF } from "./lbool";
|
|
13
13
|
import { applyUfniaTactic } from "./quant-tactics";
|
|
14
14
|
import { ResourceLimit } from "./rlimit";
|
|
15
15
|
import { parseSmtlib } from "./smtlib-parser";
|
|
@@ -20,6 +20,8 @@ export interface KernelParams {
|
|
|
20
20
|
mbqiMaxIterations: number;
|
|
21
21
|
isFindingMacros: boolean;
|
|
22
22
|
relevancyLevel?: 0 | 2;
|
|
23
|
+
isCoreMinimizing?: boolean;
|
|
24
|
+
randomSeed?: number;
|
|
23
25
|
// A kernel without a setup runs as with auto_config false.
|
|
24
26
|
setup?: SmtSetup;
|
|
25
27
|
}
|
|
@@ -30,6 +32,11 @@ const DEFAULT_KERNEL_PARAMS: KernelParams = {
|
|
|
30
32
|
isFindingMacros: false,
|
|
31
33
|
};
|
|
32
34
|
|
|
35
|
+
const assertForms = (context: Context, asserted: AssertedFormulas, forms: number[]) => {
|
|
36
|
+
for (const form of forms) if (!context.checkCanceled()) asserted.assertExpr(form);
|
|
37
|
+
return !context.checkCanceled();
|
|
38
|
+
};
|
|
39
|
+
|
|
33
40
|
interface SmtCheck {
|
|
34
41
|
verdict: Verdict;
|
|
35
42
|
numInstances: number;
|
|
@@ -43,8 +50,12 @@ export const solveGoal = (manager: AstManager, forms: number[], params: KernelPa
|
|
|
43
50
|
isMbqi: params.isMbqi,
|
|
44
51
|
mbqiMaxIterations: params.mbqiMaxIterations,
|
|
45
52
|
relevancyLevel: 2,
|
|
53
|
+
randomSeed: params.randomSeed,
|
|
46
54
|
});
|
|
47
|
-
|
|
55
|
+
if (!assertForms(context, asserted, forms)) {
|
|
56
|
+
manager.limit.release();
|
|
57
|
+
return { result: L_UNDEF, context, reasonUnknown: "canceled" };
|
|
58
|
+
}
|
|
48
59
|
context.setupContext(params.setup, true, asserted);
|
|
49
60
|
context.internalizeAssertions(asserted);
|
|
50
61
|
const theoryAssumptions: number[] = [];
|
|
@@ -81,8 +92,12 @@ export const solveAssuming = (
|
|
|
81
92
|
isMbqi: params.isMbqi,
|
|
82
93
|
mbqiMaxIterations: params.mbqiMaxIterations,
|
|
83
94
|
relevancyLevel: 2,
|
|
95
|
+
randomSeed: params.randomSeed,
|
|
84
96
|
});
|
|
85
|
-
|
|
97
|
+
if (!assertForms(context, asserted, assertions)) {
|
|
98
|
+
manager.limit.release();
|
|
99
|
+
return { result: L_UNDEF, context, reasonUnknown: "canceled" };
|
|
100
|
+
}
|
|
86
101
|
context.setupContext(params.setup, false, asserted);
|
|
87
102
|
context.internalizeAssertions(asserted);
|
|
88
103
|
const result = context.checkResearching(asserted, assumptions);
|
|
@@ -7,11 +7,10 @@ import {
|
|
|
7
7
|
} from "../../../errors";
|
|
8
8
|
import { type AstManager, OP_DIV0, OP_IDIV0, OP_MOD0, OP_OR, OP_POWER0, SORT_BOOL } from "./ast";
|
|
9
9
|
import { createQfufbvAckrTactic, runAckermannizeBv } from "./ackermannize-bv-tactic";
|
|
10
|
-
import { AssertedFormulas } from "./asserted-formulas";
|
|
11
10
|
import { createAigTactic } from "./aig-tactic";
|
|
12
11
|
import { blastTermIte } from "./blast-term-ite";
|
|
13
12
|
import { card2bv } from "./card2bv";
|
|
14
|
-
import { Context, MBQI_MAX_ITERATIONS } from "./context";
|
|
13
|
+
import { type Context, MBQI_MAX_ITERATIONS } from "./context";
|
|
15
14
|
import { ctxSimplify } from "./ctx-simplify";
|
|
16
15
|
import { createCtxSolverSimplify } from "./ctx-solver-simplify";
|
|
17
16
|
import {
|
|
@@ -25,7 +24,7 @@ import {
|
|
|
25
24
|
import type { AckrSolver } from "./lackr";
|
|
26
25
|
import { L_FALSE, L_TRUE, L_UNDEF } from "./lbool";
|
|
27
26
|
import { DerRewriter } from "./der";
|
|
28
|
-
import { finishSimplifier } from "./dependent-expr-state";
|
|
27
|
+
import { finishSimplifier, runSimplifier } from "./dependent-expr-state";
|
|
29
28
|
import { fixDlVar } from "./fix-dl-var";
|
|
30
29
|
import { runFpa2Bv } from "./fpa2bv-tactic";
|
|
31
30
|
import { type BitBlasterRewriter, runBitBlast } from "./bit-blast-tactic";
|
|
@@ -67,6 +66,7 @@ import { propagateValues } from "./propagate-values";
|
|
|
67
66
|
import { purifyArith } from "./purify-arith";
|
|
68
67
|
import { ModelEvaluator } from "./model-evaluator";
|
|
69
68
|
import { FuncInterp, ProtoModel } from "./proto-model";
|
|
69
|
+
import { SmtKernel } from "./smt-kernel";
|
|
70
70
|
import { isMbqiByFeatures, type SmtSetup } from "./smt-setup";
|
|
71
71
|
import { compileProbe, formatProbeValue, isQfufbv, type Probe } from "./probes";
|
|
72
72
|
import { runHorn } from "./muz/horn-tactic";
|
|
@@ -172,7 +172,7 @@ const REWRITER_DESCRS = getDescrs("rewriter", [
|
|
|
172
172
|
["sort_sums", PARAM_BOOL, false, true],
|
|
173
173
|
["gcd_rounding", PARAM_BOOL, false, true],
|
|
174
174
|
["arith_lhs", PARAM_BOOL, false, true],
|
|
175
|
-
["arith_ineq_lhs", PARAM_BOOL, false],
|
|
175
|
+
["arith_ineq_lhs", PARAM_BOOL, false, true],
|
|
176
176
|
["elim_to_real", PARAM_BOOL, false],
|
|
177
177
|
["push_to_real", PARAM_BOOL, true],
|
|
178
178
|
["eq2ineq", PARAM_BOOL, false],
|
|
@@ -251,7 +251,8 @@ export const getRewriterOptions = (manager: AstManager, params: TacticParams): R
|
|
|
251
251
|
arith: {
|
|
252
252
|
isSom: getBool(params, "flat", true) && getBool(params, "som", false),
|
|
253
253
|
isSortSums: getBool(params, "sort_sums", false),
|
|
254
|
-
|
|
254
|
+
isArithLhs: getBool(params, "arith_lhs", false),
|
|
255
|
+
isArithIneqLhs: getBool(params, "arith_ineq_lhs", false),
|
|
255
256
|
isGcdRounding: getBool(params, "gcd_rounding", false),
|
|
256
257
|
isAnumSimp: getBool(params, "algebraic_number_evaluator", true),
|
|
257
258
|
isExpandPower: getBool(params, "expand_power", false),
|
|
@@ -276,6 +277,7 @@ const SMT_DESCRS = getDescrs("smt", [
|
|
|
276
277
|
["mbqi", PARAM_BOOL, true, true],
|
|
277
278
|
["mbqi.max_iterations", PARAM_UINT, MBQI_MAX_ITERATIONS, true],
|
|
278
279
|
["arith.nl.rounds", PARAM_UINT, 1024, true],
|
|
280
|
+
["random_seed", PARAM_UINT, 0, true],
|
|
279
281
|
]);
|
|
280
282
|
|
|
281
283
|
// The dependencies are assertion names, which are Boolean constants, so each one is its own
|
|
@@ -290,6 +292,11 @@ const getKernelParams = (environment: TacticEnvironment, params: TacticParams, g
|
|
|
290
292
|
mbqiMaxIterations: getUint(params, "mbqi.max_iterations", environment.mbqiMaxIterations),
|
|
291
293
|
isFindingMacros: environment.isFindingMacros,
|
|
292
294
|
setup: environment.setup,
|
|
295
|
+
randomSeed: getUint(
|
|
296
|
+
params,
|
|
297
|
+
"random_seed",
|
|
298
|
+
Number(getParameter(environment, "smt.random_seed", "0")),
|
|
299
|
+
),
|
|
293
300
|
};
|
|
294
301
|
};
|
|
295
302
|
|
|
@@ -356,7 +363,8 @@ const runSmt = (environment: TacticEnvironment, params: TacticParams) => (goal:
|
|
|
356
363
|
? solveGoal(manager, goal.forms.items, kernelParams)
|
|
357
364
|
: solveAssuming(manager, extracted.clauses.items, extracted.assumptions, kernelParams);
|
|
358
365
|
extracted.clauses.reset();
|
|
359
|
-
if (solved.result === L_UNDEF)
|
|
366
|
+
if (solved.result === L_UNDEF)
|
|
367
|
+
throw new SmtTacticError(solved.reasonUnknown ?? getSmtTacticFailure(solved.context));
|
|
360
368
|
goal.reset();
|
|
361
369
|
if (solved.result === L_FALSE)
|
|
362
370
|
goal.assert(environment.manager.falseExpr, mkCoreDependency(solved.context.unsatCore));
|
|
@@ -424,30 +432,42 @@ const createTacticSolver = (manager: AstManager, getTactic: () => Tactic): AckrS
|
|
|
424
432
|
// Each clause gets a fresh context, where Z3 pushes a scope on one context.
|
|
425
433
|
const runUnitSubsume = (environment: TacticEnvironment) => (goal: Goal) => {
|
|
426
434
|
const manager = environment.manager;
|
|
435
|
+
const kernel = new SmtKernel(manager, {
|
|
436
|
+
isMbqi: environment.isMbqi,
|
|
437
|
+
mbqiMaxIterations: environment.mbqiMaxIterations,
|
|
438
|
+
isFindingMacros: false,
|
|
439
|
+
});
|
|
440
|
+
const trail = new RefVector(manager);
|
|
427
441
|
const clauses = goal.forms.items.map(() => manager.mkFreshConst("#clause", SORT_BOOL));
|
|
428
|
-
const
|
|
429
|
-
|
|
442
|
+
for (const clause of clauses) trail.push(clause);
|
|
443
|
+
kernel.push();
|
|
444
|
+
for (const [index, form] of goal.forms.items.entries()) {
|
|
445
|
+
const definition = manager.mkEq(clauses[index], form);
|
|
446
|
+
trail.push(definition);
|
|
447
|
+
kernel.assertExpr(definition);
|
|
448
|
+
}
|
|
449
|
+
kernel.push();
|
|
450
|
+
const isDeleted = clauses.map(() => false);
|
|
430
451
|
const deleted: number[] = [];
|
|
431
452
|
for (const [index, clause] of clauses.entries()) {
|
|
432
|
-
|
|
433
|
-
const context = new Context(manager, {
|
|
434
|
-
isMbqi: environment.isMbqi,
|
|
435
|
-
mbqiMaxIterations: environment.mbqiMaxIterations,
|
|
436
|
-
relevancyLevel: 2,
|
|
437
|
-
});
|
|
438
|
-
for (const definition of definitions) asserted.assertExpr(definition);
|
|
453
|
+
kernel.push();
|
|
439
454
|
for (const [other, otherClause] of clauses.entries())
|
|
440
|
-
if (other === index)
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
455
|
+
if (other === index) {
|
|
456
|
+
const negated = manager.mkNot(clause);
|
|
457
|
+
trail.push(negated);
|
|
458
|
+
kernel.assertExpr(negated);
|
|
459
|
+
} else if (!isDeleted[other]) kernel.assertExpr(otherClause);
|
|
460
|
+
kernel.push();
|
|
461
|
+
const isUnsat = kernel.context.isInconsistent();
|
|
462
|
+
kernel.pop(2);
|
|
463
|
+
if (!isUnsat) continue;
|
|
464
|
+
isDeleted[index] = true;
|
|
465
|
+
deleted.push(index);
|
|
447
466
|
}
|
|
448
467
|
for (const index of deleted) goal.update(index, manager.trueExpr);
|
|
449
468
|
goal.elimTrue();
|
|
450
|
-
|
|
469
|
+
kernel.pop(2);
|
|
470
|
+
trail.reset();
|
|
451
471
|
return [goal];
|
|
452
472
|
};
|
|
453
473
|
|
|
@@ -490,16 +510,16 @@ const runSplitClause = (isLargest: boolean) => (goal: Goal) => {
|
|
|
490
510
|
};
|
|
491
511
|
|
|
492
512
|
const runDer = (manager: AstManager) => (goal: Goal) => {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
513
|
+
runSimplifier(goal, true, (state) => {
|
|
514
|
+
const rewriter = new DerRewriter(manager);
|
|
515
|
+
return {
|
|
516
|
+
reduce: () => state.rewriteEach((form) => rewriter.rewrite(form)),
|
|
517
|
+
release: () => {
|
|
518
|
+
rewriter.der.release();
|
|
519
|
+
rewriter.release();
|
|
520
|
+
},
|
|
521
|
+
};
|
|
522
|
+
});
|
|
503
523
|
return [goal];
|
|
504
524
|
};
|
|
505
525
|
|
|
@@ -539,10 +559,16 @@ const runNnf = (manager: AstManager, params: TacticParams) => (goal: Goal) => {
|
|
|
539
559
|
const nnf = new Nnf(manager, names, mode, getBool(params, "ignore_labels", false));
|
|
540
560
|
const definitions = new RefVector(manager);
|
|
541
561
|
const size = goal.forms.size;
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
562
|
+
try {
|
|
563
|
+
for (let index = 0; !goal.isInconsistent && index < size; index++) {
|
|
564
|
+
const result = nnf.apply(goal.forms.items[index], definitions);
|
|
565
|
+
goal.update(index, result);
|
|
566
|
+
manager.decRef(result);
|
|
567
|
+
}
|
|
568
|
+
} catch (error) {
|
|
569
|
+
// Z3's nnf stops at the limit with a default_exception, which or-else lets pass.
|
|
570
|
+
if (!(error instanceof SmtCanceledError)) throw error;
|
|
571
|
+
throw new SmtDefaultError(manager.limit.getCancelMessage());
|
|
546
572
|
}
|
|
547
573
|
for (const definition of definitions.items) {
|
|
548
574
|
if (goal.isInconsistent) break;
|
|
@@ -820,6 +846,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
820
846
|
[
|
|
821
847
|
"elim-uncnstr",
|
|
822
848
|
{
|
|
849
|
+
isTrackingDependencies: true,
|
|
823
850
|
descrs: getDescrs("", [
|
|
824
851
|
["max_memory", PARAM_UINT, UINT_MAX, true],
|
|
825
852
|
["max_steps", PARAM_UINT, UINT_MAX],
|
|
@@ -1323,7 +1350,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1323
1350
|
{
|
|
1324
1351
|
descrs: new Map(),
|
|
1325
1352
|
isRejectingUnknown: false,
|
|
1326
|
-
build: (environment) => runQsat(environment
|
|
1353
|
+
build: (environment) => runQsat(environment, QSAT_SAT),
|
|
1327
1354
|
},
|
|
1328
1355
|
],
|
|
1329
1356
|
[
|
|
@@ -1331,7 +1358,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1331
1358
|
{
|
|
1332
1359
|
descrs: new Map(),
|
|
1333
1360
|
isRejectingUnknown: false,
|
|
1334
|
-
build: (environment) => runQsat(environment
|
|
1361
|
+
build: (environment) => runQsat(environment, QSAT_QE),
|
|
1335
1362
|
},
|
|
1336
1363
|
],
|
|
1337
1364
|
[
|
|
@@ -1339,7 +1366,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1339
1366
|
{
|
|
1340
1367
|
descrs: new Map(),
|
|
1341
1368
|
isRejectingUnknown: false,
|
|
1342
|
-
build: (environment) => runQsat(environment
|
|
1369
|
+
build: (environment) => runQsat(environment, QSAT_QE_REC),
|
|
1343
1370
|
},
|
|
1344
1371
|
],
|
|
1345
1372
|
[
|
|
@@ -1576,7 +1603,7 @@ const runOrElse = (tactics: Tactic[]) => (goal: Goal) => {
|
|
|
1576
1603
|
try {
|
|
1577
1604
|
return tactic(goal);
|
|
1578
1605
|
} catch (error) {
|
|
1579
|
-
if (!(error instanceof SmtTacticError)) throw error;
|
|
1606
|
+
if (!(error instanceof SmtTacticError || error instanceof SmtCanceledError)) throw error;
|
|
1580
1607
|
}
|
|
1581
1608
|
goal.resetAll();
|
|
1582
1609
|
goal.copyFrom(original);
|
|
@@ -75,6 +75,7 @@ import {
|
|
|
75
75
|
TRUE_LITERAL,
|
|
76
76
|
} from "./literal";
|
|
77
77
|
import { UnionFind } from "./lp/union-find";
|
|
78
|
+
import type { ProtoModel } from "./proto-model";
|
|
78
79
|
import { Rewriter, TACTIC_REWRITER_OPTIONS } from "./rewriter";
|
|
79
80
|
import { Theory } from "./theory";
|
|
80
81
|
|
|
@@ -247,6 +248,7 @@ export class TheoryBv extends Theory {
|
|
|
247
248
|
private propQueue: number[] = [];
|
|
248
249
|
private mergeAux: [number[], number[]] = [[], []];
|
|
249
250
|
private bv2ints: Enode[] = [];
|
|
251
|
+
private model: ProtoModel | undefined;
|
|
250
252
|
|
|
251
253
|
constructor(context: Context) {
|
|
252
254
|
super(context, FAMILY_BV);
|
|
@@ -1193,8 +1195,16 @@ export class TheoryBv extends Theory {
|
|
|
1193
1195
|
this.dropAll(clause);
|
|
1194
1196
|
}
|
|
1195
1197
|
|
|
1198
|
+
initModel(model: ProtoModel) {
|
|
1199
|
+
this.model = model;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1196
1202
|
mkValue(node: Enode) {
|
|
1203
|
+
const model = this.model;
|
|
1204
|
+
if (model === undefined) throw new SmtInvariantError("the model was not initialized");
|
|
1197
1205
|
const thVar = this.getThVar(node);
|
|
1198
|
-
|
|
1206
|
+
const value = this.manager.mkBvNumeral(this.getFixedValue(thVar).value, this.getBvSize(thVar));
|
|
1207
|
+
model.registerValue(value);
|
|
1208
|
+
return value;
|
|
1199
1209
|
}
|
|
1200
1210
|
}
|
|
@@ -48,7 +48,7 @@ const CONVERTED_OPS = new Set([
|
|
|
48
48
|
export const mkFpaConversion = (manager: AstManager) => {
|
|
49
49
|
const theoryRewriter = new Rewriter(manager, {
|
|
50
50
|
isEliminatingAnd: false,
|
|
51
|
-
arith: { ...TACTIC_ARITH_OPTIONS,
|
|
51
|
+
arith: { ...TACTIC_ARITH_OPTIONS, isArithLhs: true },
|
|
52
52
|
isRewritingPatterns: true,
|
|
53
53
|
});
|
|
54
54
|
const simp = new Rewriter(manager, {
|
|
@@ -177,6 +177,7 @@ export abstract class TheoryLraFinalCheck extends TheoryLraModel {
|
|
|
177
177
|
const literals = lemma.ineqs.map((ineq) => negate(this.mkNlaLiteral(ineq)));
|
|
178
178
|
this.resetEvidence();
|
|
179
179
|
this.coreLiterals.push(...literals);
|
|
180
|
+
this.numConflicts++;
|
|
180
181
|
for (const constraint of lemma.expl) this.setEvidence(constraint);
|
|
181
182
|
const clause: Literal[] = [];
|
|
182
183
|
for (const literal of this.coreLiterals) {
|
|
@@ -91,6 +91,7 @@ export abstract class TheoryLraInternalize extends TheoryLraAxioms {
|
|
|
91
91
|
this.realOneVar = this.addConst(manager.mkRealNumeral(Rational.one));
|
|
92
92
|
this.zeroVar = this.addConst(manager.mkNumeral(0n));
|
|
93
93
|
this.realZeroVar = this.addConst(manager.mkRealNumeral(Rational.zero));
|
|
94
|
+
this.solver.settings.setRandomSeed(this.context.params.randomSeed ?? 0);
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
private addConst(expr: number) {
|
|
@@ -37,6 +37,7 @@ export abstract class TheoryLraPropagate extends TheoryLraBounds {
|
|
|
37
37
|
private upperTerms: (TermBound | undefined)[] = [];
|
|
38
38
|
protected isModelInitialized = false;
|
|
39
39
|
private activeInfEpsConstraints: number[] = [];
|
|
40
|
+
protected numConflicts = 0;
|
|
40
41
|
|
|
41
42
|
canPropagate() {
|
|
42
43
|
return (
|
|
@@ -136,7 +137,8 @@ export abstract class TheoryLraPropagate extends TheoryLraBounds {
|
|
|
136
137
|
}
|
|
137
138
|
|
|
138
139
|
protected isPropagatingEqs() {
|
|
139
|
-
|
|
140
|
+
const config = this.context.config;
|
|
141
|
+
return config.isArithPropagatingEqs && this.numConflicts < config.arithPropagationThreshold;
|
|
140
142
|
}
|
|
141
143
|
|
|
142
144
|
private propagateEqs(
|
|
@@ -302,6 +304,9 @@ export abstract class TheoryLraPropagate extends TheoryLraBounds {
|
|
|
302
304
|
}
|
|
303
305
|
|
|
304
306
|
private propagateBoundsWithLpSolver() {
|
|
307
|
+
const config = this.context.config;
|
|
308
|
+
if (!config.isArithBoundPropagating || this.numConflicts >= config.arithPropagationThreshold)
|
|
309
|
+
return;
|
|
305
310
|
this.bp.init();
|
|
306
311
|
this.bp.propagateBoundsForTouchedRows();
|
|
307
312
|
if (this.context.checkCanceled()) return;
|
|
@@ -385,6 +390,7 @@ export abstract class TheoryLraPropagate extends TheoryLraBounds {
|
|
|
385
390
|
|
|
386
391
|
protected setConflict() {
|
|
387
392
|
this.resetEvidence();
|
|
393
|
+
this.numConflicts++;
|
|
388
394
|
for (const constraint of this.explanation) this.setEvidence(constraint);
|
|
389
395
|
this.context.setConflict(new TheoryJustification(this.id, this.coreLiterals, []), null);
|
|
390
396
|
}
|