tla-ts 0.0.10-dev.e3e5dd576 → 0.0.10-dev.e5c8dc315
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/deciders.cjs +1 -1
- package/dist/deciders.js +1 -1
- package/dist/index.cjs +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 +10 -10
- package/dist/prove.js +57 -57
- package/dist/run.cjs +26 -26
- package/dist/run.js +32 -32
- package/dist/transfer.cjs +94 -94
- package/dist/transfer.js +83 -83
- package/package.json +1 -1
- package/src/ast.ts +16 -0
- package/src/check-trace.ts +43 -42
- package/src/check.ts +2 -1
- package/src/coverage.ts +66 -18
- package/src/environment.ts +34 -30
- package/src/evaluate.ts +57 -39
- package/src/instances.ts +17 -14
- package/src/liveness.ts +4 -0
- package/src/prover/smt/solver/ackermannize-bv-tactic.ts +3 -2
- package/src/prover/smt/solver/bit-blast-tactic.ts +1 -1
- package/src/prover/smt/solver/bv1-blast.ts +1 -1
- package/src/prover/smt/solver/card2bv.ts +1 -1
- package/src/prover/smt/solver/ctx-simplify.ts +8 -2
- package/src/prover/smt/solver/diff-neq.ts +8 -6
- package/src/prover/smt/solver/dt2bv-tactic.ts +10 -8
- package/src/prover/smt/solver/elim-uncnstr.ts +26 -20
- package/src/prover/smt/solver/eq2bv-tactic.ts +15 -6
- package/src/prover/smt/solver/fd-solver.ts +1 -1
- package/src/prover/smt/solver/fix-dl-var.ts +1 -1
- package/src/prover/smt/solver/fm-tactic.ts +9 -7
- package/src/prover/smt/solver/fpa2bv-tactic.ts +1 -1
- package/src/prover/smt/solver/lia2pb.ts +1 -1
- package/src/prover/smt/solver/nlqsat.ts +1 -0
- package/src/prover/smt/solver/normalize-bounds.ts +2 -2
- package/src/prover/smt/solver/occf.ts +1 -1
- package/src/prover/smt/solver/pb2bv-tactic.ts +9 -3
- package/src/prover/smt/solver/purify-arith.ts +51 -49
- package/src/prover/smt/solver/reduce-args.ts +2 -2
- package/src/prover/smt/solver/sat/goal2sat.ts +12 -2
- package/src/prover/smt/solver/sat/inc-sat-solver.ts +21 -5
- package/src/prover/smt/solver/sat/sat-tactic.ts +51 -32
- package/src/prover/smt/solver/sat/sat2goal.ts +4 -3
- package/src/prover/smt/solver/smtlib-script.ts +6 -4
- package/src/prover/smt/solver/solver.ts +0 -1
- package/src/prover/smt/solver/tactic.ts +40 -5
- package/src/prover/smt/solver/theory-lra-propagate.ts +1 -0
- package/src/prover/smt/solver/tseitin-cnf.ts +14 -5
- package/src/resolve.ts +54 -28
- package/src/runtime.ts +14 -1
- package/src/sany/generator-proofs.ts +1 -0
- package/src/sany/selectors.ts +1 -0
- package/src/search.ts +3 -1
- package/src/simulate.ts +26 -17
- package/src/spec-description.ts +8 -2
- package/src/subexpressions.ts +138 -45
- package/src/successors.ts +13 -7
- package/src/tlc/replay.ts +80 -3
|
@@ -570,7 +570,7 @@ export const purifyArith = (manager: AstManager, goal: Goal, options: PurifyOpti
|
|
|
570
570
|
const pin = (expr: number) => state.pin(expr);
|
|
571
571
|
for (let index = 0; !goal.isInconsistent && index < goal.forms.size; index++) {
|
|
572
572
|
const rewritten = rewriter.engine.rewrite(goal.forms.items[index]);
|
|
573
|
-
goal.update(index, rewritten);
|
|
573
|
+
goal.update(index, rewritten, goal.getDependency(index));
|
|
574
574
|
manager.decRef(rewritten);
|
|
575
575
|
}
|
|
576
576
|
rewriter.release();
|
|
@@ -578,54 +578,56 @@ export const purifyArith = (manager: AstManager, goal: Goal, options: PurifyOpti
|
|
|
578
578
|
mkCongruence(state, state.divs, goal);
|
|
579
579
|
mkCongruence(state, state.mods, goal);
|
|
580
580
|
mkCongruence(state, state.idivs, goal);
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
581
|
+
if (goal.isModelsEnabled) {
|
|
582
|
+
const definitions: Definition[] = [...state.appToFresh.entries()].map((entry) => ({
|
|
583
|
+
decl: manager.decls[entry[1]],
|
|
584
|
+
def: -1,
|
|
585
|
+
}));
|
|
586
|
+
if (state.divs.length > 0)
|
|
587
|
+
definitions.push({ decl: OP_DIV0, def: mkTable(state, state.divs, SORT_REAL) });
|
|
588
|
+
if (state.mods.length > 0) {
|
|
589
|
+
const body = mkTable(state, state.mods, SORT_INT);
|
|
590
|
+
definitions.push({ decl: OP_MOD0, def: body });
|
|
591
|
+
const isNonneg = pin(
|
|
592
|
+
manager.mkApp(
|
|
593
|
+
OP_GE,
|
|
594
|
+
[pin(manager.mkVar(1, SORT_INT)), pin(manager.mkNumeralOfSort(Rational.zero, SORT_INT))],
|
|
595
|
+
SORT_BOOL,
|
|
596
|
+
),
|
|
597
|
+
);
|
|
598
|
+
const negated = pin(manager.mkApp(OP_UMINUS, [body], SORT_INT));
|
|
599
|
+
definitions.push({
|
|
600
|
+
decl: OP_MOD0,
|
|
601
|
+
def: pin(manager.mkApp(OP_ITE, [isNonneg, body, negated], SORT_INT)),
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
if (state.idivs.length > 0)
|
|
605
|
+
definitions.push({ decl: OP_IDIV0, def: mkTable(state, state.idivs, SORT_INT) });
|
|
606
|
+
if (state.ipower0 !== -1) definitions.push({ decl: OP_POWER0, def: state.ipower0 });
|
|
607
|
+
if (state.rpower0 !== -1) definitions.push({ decl: OP_POWER0, def: state.rpower0 });
|
|
608
|
+
goal.addDefinitions(definitions);
|
|
609
|
+
if (state.sinCos.size > 0) {
|
|
610
|
+
const zero = pin(manager.mkRealNumeral(Rational.zero));
|
|
611
|
+
goal.addDefinitions(
|
|
612
|
+
[...state.sinCos.entries()].map((entry) => {
|
|
613
|
+
const [sin, cos] = entry[1];
|
|
614
|
+
const isNonneg = pin(manager.mkApp(OP_GE, [sin, zero], SORT_BOOL));
|
|
615
|
+
const acos = pin(manager.mkApp(OP_ACOS, [cos], SORT_REAL));
|
|
616
|
+
const negated = pin(manager.mkApp(OP_UMINUS, [cos], SORT_REAL));
|
|
617
|
+
const shifted = pin(
|
|
618
|
+
manager.mkApp(
|
|
619
|
+
OP_ADD,
|
|
620
|
+
[pin(manager.mkApp(OP_ACOS, [negated], SORT_REAL)), manager.piExpr],
|
|
621
|
+
SORT_REAL,
|
|
622
|
+
),
|
|
623
|
+
);
|
|
624
|
+
return {
|
|
625
|
+
decl: manager.decls[entry[0]],
|
|
626
|
+
def: pin(manager.mkApp(OP_ITE, [isNonneg, acos, shifted], SORT_REAL)),
|
|
627
|
+
};
|
|
628
|
+
}),
|
|
629
|
+
);
|
|
630
|
+
}
|
|
629
631
|
}
|
|
630
632
|
goal.depth++;
|
|
631
633
|
state.pinned.reset();
|
|
@@ -207,8 +207,8 @@ const reduce = (manager: AstManager, goal: Goal) => {
|
|
|
207
207
|
goal.update(index, rewritten);
|
|
208
208
|
manager.decRef(rewritten);
|
|
209
209
|
}
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
if (goal.isModelsEnabled)
|
|
211
|
+
goal.addDefinitions(getDefinitions(manager, declToArgs, rewriter.declToArgFuncs));
|
|
212
212
|
rewriter.release();
|
|
213
213
|
for (const argFuncs of rewriter.declToArgFuncs.entries())
|
|
214
214
|
for (const [app, newDecl] of argFuncs[1].funcs.entries()) {
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
} from "../ast";
|
|
18
18
|
import { EufSolver, type EufInternalizer, type ThSolverFactory } from "../euf/euf-solver";
|
|
19
19
|
import { getDependencyValues, type Goal } from "../goal";
|
|
20
|
+
import type { ObjMap } from "../hashtable";
|
|
20
21
|
import { DEFAULT_PRINT_OPTIONS, printExpr } from "../smt2-printer";
|
|
21
22
|
import { NULL_LITERAL } from "./clause";
|
|
22
23
|
import { PbSolver, type SatInternalizer } from "./pb-solver";
|
|
@@ -116,6 +117,8 @@ export class Goal2Sat implements SatInternalizer, EufInternalizer {
|
|
|
116
117
|
this.app2lit.delete(expr);
|
|
117
118
|
this.lit2app.delete(lit);
|
|
118
119
|
}
|
|
120
|
+
for (let index = cacheLim; index < this.cacheTrail.length; index++)
|
|
121
|
+
manager.decRef(this.cacheTrail[index]);
|
|
119
122
|
this.cacheTrail.length = cacheLim;
|
|
120
123
|
this.cacheLim.length -= remaining;
|
|
121
124
|
}
|
|
@@ -511,10 +514,11 @@ export class Goal2Sat implements SatInternalizer, EufInternalizer {
|
|
|
511
514
|
this.forcePush();
|
|
512
515
|
this.app2lit.set(expr, lit);
|
|
513
516
|
this.lit2app.set(lit, expr);
|
|
517
|
+
this.manager.incRef(expr);
|
|
514
518
|
this.cacheTrail.push(expr);
|
|
515
519
|
}
|
|
516
520
|
|
|
517
|
-
private insertDep(dep: number, dep2asm: Map<number, number>) {
|
|
521
|
+
private insertDep(dep: number, dep2asm: Map<number, number> | ObjMap<number>) {
|
|
518
522
|
const manager = this.manager;
|
|
519
523
|
const isSign = manager.isNot(dep);
|
|
520
524
|
const atom = isSign ? manager.getArg(dep, 0) : dep;
|
|
@@ -544,7 +548,7 @@ export class Goal2Sat implements SatInternalizer, EufInternalizer {
|
|
|
544
548
|
}
|
|
545
549
|
}
|
|
546
550
|
|
|
547
|
-
runGoal(goal: Goal, dep2asm: Map<number, number>) {
|
|
551
|
+
runGoal(goal: Goal, dep2asm: Map<number, number> | ObjMap<number>) {
|
|
548
552
|
const manager = this.manager;
|
|
549
553
|
if (this.mkThSolver !== null) this.ensureEuf();
|
|
550
554
|
try {
|
|
@@ -576,4 +580,10 @@ export class Goal2Sat implements SatInternalizer, EufInternalizer {
|
|
|
576
580
|
this.app2lit = new Map();
|
|
577
581
|
this.lit2app = new Map();
|
|
578
582
|
}
|
|
583
|
+
|
|
584
|
+
release() {
|
|
585
|
+
for (let index = 0; index < this.cacheTrail.length; index++)
|
|
586
|
+
this.manager.decRef(this.cacheTrail[index]);
|
|
587
|
+
this.cacheTrail = [];
|
|
588
|
+
}
|
|
579
589
|
}
|
|
@@ -61,6 +61,7 @@ export class IncSatSolver {
|
|
|
61
61
|
private readonly internalized: RefVector;
|
|
62
62
|
private hasUninterpreted = false;
|
|
63
63
|
private models: ProtoModel[] = [];
|
|
64
|
+
private subgoals: Goal[] = [];
|
|
64
65
|
private scopes: Scope[] = [];
|
|
65
66
|
reasonUnknown = "no reason given";
|
|
66
67
|
wasUnknown = false;
|
|
@@ -193,6 +194,7 @@ export class IncSatSolver {
|
|
|
193
194
|
private internalizeGoal(goal: Goal) {
|
|
194
195
|
this.solver.popToBaseLevel();
|
|
195
196
|
if (this.solver.isInconsistent) return L_FALSE;
|
|
197
|
+
this.resetSubgoals();
|
|
196
198
|
const bitBlaster = this.getBitBlaster();
|
|
197
199
|
const subgoals = (() => {
|
|
198
200
|
if (this.isCnf) return [goal];
|
|
@@ -213,6 +215,8 @@ export class IncSatSolver {
|
|
|
213
215
|
return undefined;
|
|
214
216
|
}
|
|
215
217
|
})();
|
|
218
|
+
this.subgoals = subgoals ?? [];
|
|
219
|
+
if (!this.subgoals.includes(goal)) goal.reset();
|
|
216
220
|
if (subgoals?.length !== 1) return L_UNDEF;
|
|
217
221
|
const subgoal = subgoals[0];
|
|
218
222
|
this.converters.converters = [...this.converters.converters, ...subgoal.converters];
|
|
@@ -385,7 +389,7 @@ export class IncSatSolver {
|
|
|
385
389
|
return this.core.items;
|
|
386
390
|
}
|
|
387
391
|
|
|
388
|
-
|
|
392
|
+
mkModel() {
|
|
389
393
|
const manager = this.manager;
|
|
390
394
|
if (!this.solver.isModelCurrent || this.fmls.size > this.fmlsHead) return null;
|
|
391
395
|
const euf = this.goal2sat.euf;
|
|
@@ -397,10 +401,15 @@ export class IncSatSolver {
|
|
|
397
401
|
else if (value === L_FALSE) model.registerConst(manager.decls[expr], manager.falseExpr);
|
|
398
402
|
}
|
|
399
403
|
if (this.satConverter.entries.length > 0) applyDefinitions(this.satConverter.entries, model);
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
+
return convertModel(this.converters, euf === null ? model : euf.updateModel(model));
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
getModel() {
|
|
408
|
+
const model = this.mkModel();
|
|
409
|
+
if (model === null) return null;
|
|
410
|
+
model.incRef();
|
|
411
|
+
this.models.push(model);
|
|
412
|
+
return model;
|
|
404
413
|
}
|
|
405
414
|
|
|
406
415
|
findMutexes(vars: readonly number[]) {
|
|
@@ -445,15 +454,22 @@ export class IncSatSolver {
|
|
|
445
454
|
: [];
|
|
446
455
|
}
|
|
447
456
|
|
|
457
|
+
private resetSubgoals() {
|
|
458
|
+
for (const subgoal of this.subgoals) subgoal.reset();
|
|
459
|
+
this.subgoals = [];
|
|
460
|
+
}
|
|
461
|
+
|
|
448
462
|
release() {
|
|
449
463
|
for (const model of this.models) model.decRef();
|
|
450
464
|
this.models = [];
|
|
465
|
+
this.resetSubgoals();
|
|
451
466
|
this.fmls.reset();
|
|
452
467
|
this.names.reset();
|
|
453
468
|
this.core.reset();
|
|
454
469
|
this.internalized.reset();
|
|
455
470
|
this.satConverter.release();
|
|
456
471
|
this.releaseBitBlaster();
|
|
472
|
+
this.goal2sat.release();
|
|
457
473
|
}
|
|
458
474
|
|
|
459
475
|
private releaseBitBlaster() {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { SmtCanceledError, SmtTacticError } from "../../../../errors";
|
|
2
2
|
import type { AstManager } from "../ast";
|
|
3
3
|
import type { ThSolverFactory } from "../euf/euf-solver";
|
|
4
|
-
import { OVER, type Goal } from "../goal";
|
|
4
|
+
import { joinDependencies, mkDependencyLeaf, OVER, type Dependency, type Goal } from "../goal";
|
|
5
|
+
import { ObjMap } from "../hashtable";
|
|
5
6
|
import { L_FALSE, L_TRUE, L_UNDEF } from "../lbool";
|
|
6
7
|
import { ProtoModel } from "../proto-model";
|
|
7
8
|
import type { SatParams } from "./config";
|
|
@@ -17,37 +18,55 @@ export const createSatTactic =
|
|
|
17
18
|
goal.elimRedundancies();
|
|
18
19
|
const solver = new Solver(params, manager.limit);
|
|
19
20
|
const goal2sat = new Goal2Sat(manager, solver, params.get("ite_extra") !== false, mkThSolver);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
try {
|
|
22
|
+
const dep2asm = new ObjMap<number>((expr) => manager.hashes[expr]);
|
|
23
|
+
goal2sat.runGoal(goal, dep2asm);
|
|
24
|
+
goal.reset();
|
|
25
|
+
const result = (() => {
|
|
26
|
+
try {
|
|
27
|
+
return solver.check([...dep2asm.values()]);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
if (error instanceof SmtCanceledError) throw new SmtTacticError("canceled");
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
})();
|
|
33
|
+
if (result === L_UNDEF) goal.reasonUnknown = solver.reasonUnknown;
|
|
34
|
+
const unhandledFuns = goal2sat.euf?.unhandledFunctions ?? goal2sat.unhandledFuns;
|
|
35
|
+
if (result === L_FALSE) {
|
|
36
|
+
const asm2dep = new Map<number, number>();
|
|
37
|
+
for (const [dep, lit] of dep2asm) asm2dep.set(lit, dep);
|
|
38
|
+
goal.assert(
|
|
39
|
+
manager.falseExpr,
|
|
40
|
+
goal.isCoresEnabled
|
|
41
|
+
? solver.core.reduce<Dependency | undefined>(
|
|
42
|
+
(core, lit) => joinDependencies(core, mkDependencyLeaf(asm2dep.get(lit) as number)),
|
|
43
|
+
undefined,
|
|
44
|
+
)
|
|
45
|
+
: undefined,
|
|
46
|
+
);
|
|
47
|
+
} else if (result === L_TRUE && unhandledFuns.length === 0) {
|
|
48
|
+
if (goal.isModelsEnabled) {
|
|
49
|
+
const model = new ProtoModel(manager).mkModel();
|
|
50
|
+
for (const [expr, boolVar] of goal2sat.atoms) {
|
|
51
|
+
if (!manager.isUninterpretedConst(expr)) continue;
|
|
52
|
+
const value = solver.model[boolVar];
|
|
53
|
+
if (value === L_TRUE) model.registerConst(manager.decls[expr], manager.trueExpr);
|
|
54
|
+
else if (value === L_FALSE) model.registerConst(manager.decls[expr], manager.falseExpr);
|
|
55
|
+
}
|
|
56
|
+
const euf = goal2sat.euf;
|
|
57
|
+
goal.model = euf?.updateModel(model) ?? model;
|
|
58
|
+
euf?.validateModel(goal.model);
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
solver.popToBaseLevel();
|
|
62
|
+
const converter = new Sat2GoalConverter(manager);
|
|
63
|
+
sat2goal(manager, solver, goal2sat.atoms, goal, converter);
|
|
64
|
+
if (goal.isModelsEnabled) goal.addDefinitions(converter.entries);
|
|
65
|
+
if (goal.isCoresEnabled || unhandledFuns.length > 0) goal.updatePrecision(OVER);
|
|
28
66
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
else if (result === L_TRUE && unhandledFuns.length === 0) {
|
|
34
|
-
const model = new ProtoModel(manager).mkModel();
|
|
35
|
-
for (const [expr, boolVar] of goal2sat.atoms) {
|
|
36
|
-
if (!manager.isUninterpretedConst(expr)) continue;
|
|
37
|
-
const value = solver.model[boolVar];
|
|
38
|
-
if (value === L_TRUE) model.registerConst(manager.decls[expr], manager.trueExpr);
|
|
39
|
-
else if (value === L_FALSE) model.registerConst(manager.decls[expr], manager.falseExpr);
|
|
40
|
-
}
|
|
41
|
-
const euf = goal2sat.euf;
|
|
42
|
-
goal.model = euf?.updateModel(model) ?? model;
|
|
43
|
-
euf?.validateModel(goal.model);
|
|
44
|
-
} else {
|
|
45
|
-
solver.popToBaseLevel();
|
|
46
|
-
const converter = new Sat2GoalConverter(manager);
|
|
47
|
-
sat2goal(manager, solver, goal2sat.atoms, goal, converter);
|
|
48
|
-
goal.addDefinitions(converter.entries);
|
|
49
|
-
if (unhandledFuns.length > 0) goal.updatePrecision(OVER);
|
|
67
|
+
goal.depth++;
|
|
68
|
+
return [goal];
|
|
69
|
+
} finally {
|
|
70
|
+
goal2sat.release();
|
|
50
71
|
}
|
|
51
|
-
goal.depth++;
|
|
52
|
-
return [goal];
|
|
53
72
|
};
|
|
@@ -135,7 +135,8 @@ export const sat2goal = (
|
|
|
135
135
|
goal.assert(manager.falseExpr);
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
|
-
|
|
138
|
+
const isProducingModels = goal.isModelsEnabled;
|
|
139
|
+
if (isProducingModels) converter.flushSmc(solver, atoms);
|
|
139
140
|
const lit2expr = new RefVector(manager);
|
|
140
141
|
lit2expr.resize(2 * solver.numVars());
|
|
141
142
|
for (const [expr, boolVar] of atoms) {
|
|
@@ -145,10 +146,10 @@ export const sat2goal = (
|
|
|
145
146
|
const getExpr = (lit: number) => {
|
|
146
147
|
if (lit2expr.items[lit] === -1) {
|
|
147
148
|
const boolVar = lit >> 1;
|
|
148
|
-
let aux = converter.var2expr.items[boolVar] ?? -1;
|
|
149
|
+
let aux = isProducingModels ? (converter.var2expr.items[boolVar] ?? -1) : -1;
|
|
149
150
|
if (aux === -1) {
|
|
150
151
|
aux = manager.mkFreshConst(null, SORT_BOOL);
|
|
151
|
-
converter.insert(boolVar, aux);
|
|
152
|
+
if (isProducingModels) converter.insert(boolVar, aux);
|
|
152
153
|
}
|
|
153
154
|
lit2expr.set(2 * boolVar, aux);
|
|
154
155
|
lit2expr.set(2 * boolVar + 1, mkNot(manager, aux));
|
|
@@ -714,7 +714,7 @@ export const runSmtlibScript = (
|
|
|
714
714
|
isFromTactic: !isKernelChecking,
|
|
715
715
|
reasonUnknown:
|
|
716
716
|
error instanceof SmtDefaultError
|
|
717
|
-
? error.message
|
|
717
|
+
? ((isKernelChecking ? undefined : reasonUnknown) ?? error.message)
|
|
718
718
|
: getReasonUnknown({ result: L_UNDEF, context, reasonUnknown }, deadline),
|
|
719
719
|
});
|
|
720
720
|
print("unknown");
|
|
@@ -741,6 +741,7 @@ export const runSmtlibScript = (
|
|
|
741
741
|
? new ProtoModel(state.manager)
|
|
742
742
|
: context.getModel();
|
|
743
743
|
if (model === undefined) throw new SmtParseError("model is not available", list.end);
|
|
744
|
+
if (check.fdSolver !== undefined) return model;
|
|
744
745
|
model.incRef();
|
|
745
746
|
check.model = model;
|
|
746
747
|
return model;
|
|
@@ -1986,9 +1987,10 @@ export const runSmtlibScript = (
|
|
|
1986
1987
|
const booleanOption = BOOLEAN_PRINT_OPTIONS.get(optionName);
|
|
1987
1988
|
if (booleanOption !== undefined) settings.printOptions[booleanOption] = isTrue;
|
|
1988
1989
|
if (
|
|
1989
|
-
optionName.startsWith(":pp.") &&
|
|
1990
|
-
|
|
1991
|
-
|
|
1990
|
+
(optionName.startsWith(":pp.") &&
|
|
1991
|
+
numericOption === undefined &&
|
|
1992
|
+
booleanOption === undefined) ||
|
|
1993
|
+
optionName.startsWith(":lp.")
|
|
1992
1994
|
)
|
|
1993
1995
|
throw new SmtUnsupportedError(`the option ${optionName}`);
|
|
1994
1996
|
},
|
|
@@ -99,7 +99,6 @@ export const solveAssuming = (
|
|
|
99
99
|
return { result: L_UNDEF, context, reasonUnknown: "canceled" };
|
|
100
100
|
}
|
|
101
101
|
context.setupContext(params.setup, false, asserted);
|
|
102
|
-
context.internalizeAssertions(asserted);
|
|
103
102
|
const result = context.checkResearching(asserted, assumptions);
|
|
104
103
|
manager.limit.release();
|
|
105
104
|
return { result, context };
|
|
@@ -277,6 +277,7 @@ const SMT_DESCRS = getDescrs("smt", [
|
|
|
277
277
|
["mbqi", PARAM_BOOL, true, true],
|
|
278
278
|
["mbqi.max_iterations", PARAM_UINT, MBQI_MAX_ITERATIONS, true],
|
|
279
279
|
["arith.nl.rounds", PARAM_UINT, 1024, true],
|
|
280
|
+
["arith.branch_cut_ratio", PARAM_UINT, 2, true],
|
|
280
281
|
["random_seed", PARAM_UINT, 0, true],
|
|
281
282
|
["auto_config", PARAM_BOOL, true, true],
|
|
282
283
|
]);
|
|
@@ -574,7 +575,7 @@ const runNnf = (manager: AstManager, params: TacticParams) => (goal: Goal) => {
|
|
|
574
575
|
try {
|
|
575
576
|
for (let index = 0; !goal.isInconsistent && index < size; index++) {
|
|
576
577
|
const result = nnf.apply(goal.forms.items[index], definitions);
|
|
577
|
-
goal.update(index, result);
|
|
578
|
+
goal.update(index, result, goal.getDependency(index));
|
|
578
579
|
manager.decRef(result);
|
|
579
580
|
}
|
|
580
581
|
} catch (error) {
|
|
@@ -717,6 +718,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
717
718
|
["max_depth", PARAM_UINT, 1024, true],
|
|
718
719
|
["propagate_eq", PARAM_BOOL, false],
|
|
719
720
|
]),
|
|
721
|
+
isTrackingDependencies: true,
|
|
720
722
|
build: (environment, params) =>
|
|
721
723
|
inPlace((goal) =>
|
|
722
724
|
ctxSimplify(
|
|
@@ -759,6 +761,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
759
761
|
["elim_inverses", PARAM_BOOL, true, true],
|
|
760
762
|
]),
|
|
761
763
|
]),
|
|
764
|
+
isTrackingDependencies: true,
|
|
762
765
|
build: (environment, params) => {
|
|
763
766
|
const manager = environment.manager;
|
|
764
767
|
const elimRemParams = new Map([...params, ["elim_rem", true]]);
|
|
@@ -791,6 +794,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
791
794
|
"tseitin-cnf-core",
|
|
792
795
|
{
|
|
793
796
|
descrs: TSEITIN_DESCRS,
|
|
797
|
+
isTrackingDependencies: true,
|
|
794
798
|
build: (environment) => inPlace((goal) => tseitinCnf(environment.manager, goal)),
|
|
795
799
|
},
|
|
796
800
|
],
|
|
@@ -798,6 +802,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
798
802
|
"tseitin-cnf",
|
|
799
803
|
{
|
|
800
804
|
descrs: TSEITIN_DESCRS,
|
|
805
|
+
isTrackingDependencies: true,
|
|
801
806
|
build: (environment, params) =>
|
|
802
807
|
inPlace((goal) => {
|
|
803
808
|
const manager = environment.manager;
|
|
@@ -894,6 +899,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
894
899
|
["pb.solver", PARAM_SYMBOL, "solver", true],
|
|
895
900
|
["cardinality.encoding", PARAM_SYMBOL, "none", true],
|
|
896
901
|
]),
|
|
902
|
+
isTrackingDependencies: true,
|
|
897
903
|
build: (environment, params) =>
|
|
898
904
|
inPlace((goal) => {
|
|
899
905
|
checkParams(REWRITER_DESCRS, params);
|
|
@@ -908,6 +914,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
908
914
|
["produce_models", PARAM_BOOL, false, true],
|
|
909
915
|
["norm_int_only", PARAM_BOOL, true, true],
|
|
910
916
|
]),
|
|
917
|
+
isTrackingDependencies: true,
|
|
911
918
|
build: (environment, params) =>
|
|
912
919
|
inPlace((goal) => {
|
|
913
920
|
checkParams(REWRITER_DESCRS, params);
|
|
@@ -1111,6 +1118,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1111
1118
|
"distribute-forall",
|
|
1112
1119
|
{
|
|
1113
1120
|
descrs: new Map(),
|
|
1121
|
+
isTrackingDependencies: true,
|
|
1114
1122
|
build: (environment) => inPlace((goal) => distributeForall(environment.manager, goal)),
|
|
1115
1123
|
},
|
|
1116
1124
|
],
|
|
@@ -1181,6 +1189,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1181
1189
|
"occf",
|
|
1182
1190
|
{
|
|
1183
1191
|
descrs: new Map(),
|
|
1192
|
+
isTrackingDependencies: true,
|
|
1184
1193
|
build: (environment) => inPlace((goal) => occf(environment.manager, goal)),
|
|
1185
1194
|
},
|
|
1186
1195
|
],
|
|
@@ -1208,8 +1217,22 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1208
1217
|
),
|
|
1209
1218
|
},
|
|
1210
1219
|
],
|
|
1211
|
-
[
|
|
1212
|
-
|
|
1220
|
+
[
|
|
1221
|
+
"dt2bv",
|
|
1222
|
+
{
|
|
1223
|
+
descrs: new Map(),
|
|
1224
|
+
isTrackingDependencies: true,
|
|
1225
|
+
build: (environment) => createDt2BvTactic(environment.manager),
|
|
1226
|
+
},
|
|
1227
|
+
],
|
|
1228
|
+
[
|
|
1229
|
+
"eq2bv",
|
|
1230
|
+
{
|
|
1231
|
+
descrs: new Map(),
|
|
1232
|
+
isTrackingDependencies: true,
|
|
1233
|
+
build: (environment) => createEq2BvTactic(environment.manager),
|
|
1234
|
+
},
|
|
1235
|
+
],
|
|
1213
1236
|
[
|
|
1214
1237
|
"bit-blast",
|
|
1215
1238
|
{
|
|
@@ -1221,6 +1244,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1221
1244
|
["blast_quant", PARAM_BOOL, false, true],
|
|
1222
1245
|
["blast_full", PARAM_BOOL, false, true],
|
|
1223
1246
|
]),
|
|
1247
|
+
isTrackingDependencies: true,
|
|
1224
1248
|
build: (environment, params) =>
|
|
1225
1249
|
runBitBlast(environment.manager, {
|
|
1226
1250
|
isBlastingMul: getBool(params, "blast_mul", true),
|
|
@@ -1232,7 +1256,11 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1232
1256
|
],
|
|
1233
1257
|
[
|
|
1234
1258
|
"max-bv-sharing",
|
|
1235
|
-
{
|
|
1259
|
+
{
|
|
1260
|
+
descrs: new Map(),
|
|
1261
|
+
isTrackingDependencies: true,
|
|
1262
|
+
build: (environment) => runMaxBvSharing(environment.manager),
|
|
1263
|
+
},
|
|
1236
1264
|
],
|
|
1237
1265
|
[
|
|
1238
1266
|
"bv_bound_chk",
|
|
@@ -1386,6 +1414,7 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1386
1414
|
{
|
|
1387
1415
|
descrs: SAT_DESCRS,
|
|
1388
1416
|
isRejectingUnknown: false,
|
|
1417
|
+
isTrackingDependencies: true,
|
|
1389
1418
|
build: (environment, params) =>
|
|
1390
1419
|
createSatTactic(environment.manager, getSatTacticParams(environment, params)),
|
|
1391
1420
|
},
|
|
@@ -1404,18 +1433,24 @@ const NAMED_TACTICS = new Map<string, NamedTactic>([
|
|
|
1404
1433
|
{
|
|
1405
1434
|
descrs: SAT_DESCRS,
|
|
1406
1435
|
isRejectingUnknown: false,
|
|
1436
|
+
isTrackingDependencies: true,
|
|
1407
1437
|
build: (environment, params) =>
|
|
1408
1438
|
createSatTactic(environment.manager, getSatTacticParams(environment, params)),
|
|
1409
1439
|
},
|
|
1410
1440
|
],
|
|
1411
1441
|
[
|
|
1412
1442
|
"snf",
|
|
1413
|
-
{
|
|
1443
|
+
{
|
|
1444
|
+
descrs: NNF_DESCRS,
|
|
1445
|
+
isTrackingDependencies: true,
|
|
1446
|
+
build: (environment, params) => runNnf(environment.manager, params),
|
|
1447
|
+
},
|
|
1414
1448
|
],
|
|
1415
1449
|
[
|
|
1416
1450
|
"nnf",
|
|
1417
1451
|
{
|
|
1418
1452
|
descrs: NNF_DESCRS,
|
|
1453
|
+
isTrackingDependencies: true,
|
|
1419
1454
|
build: (environment, params) =>
|
|
1420
1455
|
runNnf(environment.manager, new Map([...params, ["mode", "full"]])),
|
|
1421
1456
|
},
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
OP_XOR,
|
|
15
15
|
SORT_BOOL,
|
|
16
16
|
} from "./ast";
|
|
17
|
-
import type { Goal } from "./goal";
|
|
17
|
+
import type { Dependency, Goal } from "./goal";
|
|
18
18
|
import { RefVector } from "./ref-vector";
|
|
19
19
|
import { Rewriter, TACTIC_REWRITER_OPTIONS } from "./rewriter";
|
|
20
20
|
|
|
@@ -63,6 +63,8 @@ export const tseitinCnf = (manager: AstManager, goal: Goal) => {
|
|
|
63
63
|
const rewriter = new Rewriter(manager, { ...TACTIC_REWRITER_OPTIONS, isFlatAndOr: false });
|
|
64
64
|
const pinned = new RefVector(manager);
|
|
65
65
|
const clauses = new RefVector(manager);
|
|
66
|
+
const clauseDependencies: (Dependency | undefined)[] = [];
|
|
67
|
+
let dependency: Dependency | undefined;
|
|
66
68
|
const cache = new Map<number, number>();
|
|
67
69
|
const freshDecls: number[] = [];
|
|
68
70
|
const frames: Frame[] = [];
|
|
@@ -146,7 +148,10 @@ export const tseitinCnf = (manager: AstManager, goal: Goal) => {
|
|
|
146
148
|
const visitAll = (exprs: readonly number[]) =>
|
|
147
149
|
exprs.reduce((isVisited, expr) => visit(expr) && isVisited, true);
|
|
148
150
|
|
|
149
|
-
const mkClause = (literals: number[]) =>
|
|
151
|
+
const mkClause = (literals: number[]) => {
|
|
152
|
+
clauses.push(pin(rewriter.mkOr(literals)));
|
|
153
|
+
if (goal.isCoresEnabled) clauseDependencies.push(dependency);
|
|
154
|
+
};
|
|
150
155
|
|
|
151
156
|
const mkFresh = () => {
|
|
152
157
|
const fresh = manager.mkFreshConst(null, SORT_BOOL);
|
|
@@ -464,7 +469,10 @@ export const tseitinCnf = (manager: AstManager, goal: Goal) => {
|
|
|
464
469
|
};
|
|
465
470
|
|
|
466
471
|
try {
|
|
467
|
-
for (
|
|
472
|
+
for (let index = 0; index < goal.forms.size; index++) {
|
|
473
|
+
dependency = goal.getDependency(index);
|
|
474
|
+
process(goal.forms.items[index]);
|
|
475
|
+
}
|
|
468
476
|
} catch (error) {
|
|
469
477
|
pinned.reset();
|
|
470
478
|
clauses.reset();
|
|
@@ -473,10 +481,11 @@ export const tseitinCnf = (manager: AstManager, goal: Goal) => {
|
|
|
473
481
|
}
|
|
474
482
|
goal.reset();
|
|
475
483
|
const added = new Set<number>();
|
|
476
|
-
for (
|
|
484
|
+
for (let index = 0; index < clauses.size; index++) {
|
|
485
|
+
const clause = clauses.items[index];
|
|
477
486
|
if (added.has(clause)) continue;
|
|
478
487
|
added.add(clause);
|
|
479
|
-
goal.assert(clause);
|
|
488
|
+
goal.assert(clause, clauseDependencies[index]);
|
|
480
489
|
}
|
|
481
490
|
for (const decl of freshDecls) goal.addConverter(decl);
|
|
482
491
|
goal.depth++;
|