tla-ts 0.0.10-dev.a4b81b6d0 → 0.0.10-dev.a5705bfbf
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 +31 -31
- package/dist/deciders.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -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 +42 -42
- package/dist/prove.js +30 -30
- package/dist/run.cjs +42 -42
- package/dist/run.js +42 -42
- package/dist/transfer.cjs +31 -29
- package/dist/transfer.js +43 -41
- package/dist/worker.cjs +4 -4
- package/dist/worker.js +4 -4
- package/package.json +1 -1
- package/src/ast.ts +10 -1
- package/src/check-failure.ts +5 -6
- package/src/check-trace.ts +4 -4
- package/src/check.ts +78 -90
- package/src/cli/tlc-output.ts +16 -2
- package/src/cli/tlc.ts +2 -2
- package/src/codegen.ts +10 -16
- package/src/coverage.ts +190 -1
- package/src/dependencies.ts +14 -2
- package/src/dfid.ts +80 -27
- package/src/environment.ts +30 -1
- package/src/evaluate.ts +223 -47
- package/src/exit-codes.ts +3 -4
- package/src/instances.ts +11 -1
- package/src/levels.ts +48 -7
- package/src/liveness-checker.ts +123 -70
- package/src/liveness.ts +4 -1
- package/src/obligations/source.ts +2 -0
- package/src/parser.ts +3 -0
- package/src/prover/smt/solver/card2bv.ts +7 -4
- package/src/prover/smt/solver/context.ts +20 -4
- package/src/prover/smt/solver/dependent-expr-state.ts +18 -12
- package/src/prover/smt/solver/dt2bv-tactic.ts +36 -20
- package/src/prover/smt/solver/fd-solver.ts +146 -39
- package/src/prover/smt/solver/maxcore.ts +2 -1
- package/src/prover/smt/solver/maxsmt-base.ts +1 -0
- package/src/prover/smt/solver/model-checker.ts +1 -1
- package/src/prover/smt/solver/muz/dl-context.ts +12 -40
- package/src/prover/smt/solver/muz/dl-mk-coi-filter.ts +1 -1
- package/src/prover/smt/solver/muz/dl-rule.ts +6 -7
- package/src/prover/smt/solver/muz/hnf.ts +2 -2
- package/src/prover/smt/solver/muz/horn-tactic.ts +14 -1
- package/src/prover/smt/solver/muz/rule-properties.ts +22 -0
- package/src/prover/smt/solver/muz/spacer-prop-solver.ts +1 -1
- package/src/prover/smt/solver/opt-context.ts +1 -0
- package/src/prover/smt/solver/opt-solver.ts +1 -1
- package/src/prover/smt/solver/parallel-tactic.ts +1 -1
- package/src/prover/smt/solver/qsat.ts +7 -2
- package/src/prover/smt/solver/rewriter-tpl.ts +7 -6
- package/src/prover/smt/solver/sat/inc-sat-solver.ts +45 -26
- package/src/prover/smt/solver/sat/sat-tactic.ts +4 -2
- package/src/prover/smt/solver/sat/sat2goal.ts +10 -7
- package/src/prover/smt/solver/smt-consequences.ts +1 -1
- package/src/prover/smt/solver/smt-kernel.ts +9 -2
- package/src/prover/smt/solver/smtlib-parser.ts +6 -2
- package/src/prover/smt/solver/smtlib-script.ts +197 -73
- package/src/prover/smt/solver/tactic.ts +64 -37
- package/src/resolve.ts +143 -39
- package/src/sany/generator-expressions.ts +2 -0
- package/src/sany/generator-proofs.ts +1 -0
- package/src/search.ts +109 -23
- package/src/simulate.ts +114 -124
- package/src/spec-description.ts +3 -0
- package/src/subexpressions.ts +168 -63
- package/src/successors.ts +30 -10
- package/src/tlc/replay.ts +45 -29
- package/src/trace-liveness.ts +529 -0
- package/src/typed-tier.ts +14 -4
- package/src/values.ts +15 -1
package/src/liveness-checker.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
type Solution,
|
|
23
23
|
type Tableau,
|
|
24
24
|
} from "./tableau";
|
|
25
|
+
import { findTraceLasso, type TraceLasso } from "./trace-liveness";
|
|
25
26
|
import { isSameValue, type Value } from "./values";
|
|
26
27
|
|
|
27
28
|
export interface LiveSuccessor<State = Value[]> {
|
|
@@ -51,9 +52,14 @@ export interface LivenessChecker {
|
|
|
51
52
|
getViolatedProperties: (path: Value[][], cycleStart: number) => string[];
|
|
52
53
|
}
|
|
53
54
|
|
|
55
|
+
export interface TraceViolation extends TraceLasso {
|
|
56
|
+
properties: string[];
|
|
57
|
+
failures: TlaEvaluationError[];
|
|
58
|
+
}
|
|
59
|
+
|
|
54
60
|
export interface LivenessChecks {
|
|
55
61
|
solutions: Solution[];
|
|
56
|
-
|
|
62
|
+
findTraceViolation: (trace: Value[][], fingerprints: bigint[]) => TraceViolation | undefined;
|
|
57
63
|
}
|
|
58
64
|
|
|
59
65
|
export interface LiveGraph<State> {
|
|
@@ -77,9 +83,15 @@ export interface SearchGraph<State> {
|
|
|
77
83
|
index: number,
|
|
78
84
|
state: State,
|
|
79
85
|
onSuccessors: (successors: LiveSuccessor<State>[]) => void,
|
|
86
|
+
replay?: Environment,
|
|
80
87
|
) => void;
|
|
81
88
|
}
|
|
82
89
|
|
|
90
|
+
interface Tracing {
|
|
91
|
+
atoms: LiveAtoms<Value[]>;
|
|
92
|
+
replay: Environment | undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
83
95
|
export interface LiveEvaluation<State> {
|
|
84
96
|
atoms: LiveAtoms<State>;
|
|
85
97
|
// Whether a check's result for a state holds for every step from it.
|
|
@@ -261,13 +273,14 @@ const getLiveFormula = (
|
|
|
261
273
|
const fairness = temporals.map((item) =>
|
|
262
274
|
toLiveExpression(item.expression, item.scope, environment),
|
|
263
275
|
);
|
|
264
|
-
const
|
|
265
|
-
|
|
276
|
+
const checks = properties.map((property) =>
|
|
277
|
+
toLiveExpression(property.expression, property.scope, environment),
|
|
266
278
|
);
|
|
279
|
+
const negations = checks.map((check) => createUnary("Not", check));
|
|
267
280
|
const violation = negations.length === 1 ? negations[0] : createJunction("Or", negations);
|
|
268
281
|
const formula =
|
|
269
282
|
fairness.length === 0 ? violation : createJunction("And", [...fairness, violation]);
|
|
270
|
-
return { formula,
|
|
283
|
+
return { formula, checks };
|
|
271
284
|
};
|
|
272
285
|
|
|
273
286
|
export type LiveAtom = LiveState | LiveEnabled | LiveAction;
|
|
@@ -322,80 +335,68 @@ export const getLiveExpressions = (solutions: Solution[]) =>
|
|
|
322
335
|
getAtomExpressions(atom).map((item) => item.expression),
|
|
323
336
|
);
|
|
324
337
|
|
|
325
|
-
|
|
326
|
-
properties: TemporalProperty[],
|
|
327
|
-
temporals: ScopedExpression[],
|
|
328
|
-
environment: Environment,
|
|
329
|
-
): LivenessChecks | undefined => {
|
|
330
|
-
if (properties.length === 0) return undefined;
|
|
331
|
-
const live = getLiveFormula(properties, temporals, environment);
|
|
332
|
-
// A check evaluated once for a state shows what TLC shows when no check repeats an effect. A
|
|
333
|
-
// definition TLC evaluates as it starts repeats nothing, but a scope can bind any definition.
|
|
338
|
+
const isSharingResults = (formula: LiveExpression, environment: Environment) => {
|
|
334
339
|
const formulaAtoms = new Set<LiveAtom>();
|
|
335
|
-
collectAtoms(
|
|
340
|
+
collectAtoms(formula, formulaAtoms);
|
|
336
341
|
const checked = [...formulaAtoms].flatMap(getAtomExpressions);
|
|
337
|
-
|
|
342
|
+
return checked.every((item) => item.scope === undefined)
|
|
338
343
|
? !isExpressionImpure(
|
|
339
344
|
checked.map((item) => item.expression),
|
|
340
345
|
environment,
|
|
341
346
|
"repeated",
|
|
342
347
|
)
|
|
343
348
|
: !hasRepeatedEffects(environment);
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
evaluateFrom: (source, evaluate) => {
|
|
358
|
-
environment.runtime.setLivenessSource(source);
|
|
359
|
-
try {
|
|
360
|
-
return evaluate();
|
|
361
|
-
} finally {
|
|
362
|
-
environment.runtime.setLivenessSource(undefined);
|
|
363
|
-
}
|
|
364
|
-
},
|
|
365
|
-
},
|
|
366
|
-
search,
|
|
367
|
-
environment.runtime.version !== "1.7.4",
|
|
368
|
-
);
|
|
369
|
-
const traceWith = <Result>(replay: Environment | undefined, run: () => Result) => {
|
|
370
|
-
if (replay === undefined) return run();
|
|
371
|
-
tracing.atoms = getInterpretedAtoms(replay);
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
const getViolatedProperties = (
|
|
352
|
+
properties: TemporalProperty[],
|
|
353
|
+
checks: LiveExpression[],
|
|
354
|
+
path: Value[][],
|
|
355
|
+
cycleStart: number,
|
|
356
|
+
environment: Environment,
|
|
357
|
+
failures?: TlaEvaluationError[],
|
|
358
|
+
) => [
|
|
359
|
+
...new Set(
|
|
360
|
+
properties
|
|
361
|
+
.filter((_property, position) => {
|
|
372
362
|
try {
|
|
373
|
-
return
|
|
374
|
-
}
|
|
375
|
-
|
|
363
|
+
return !evaluateOnLasso(checks[position], path, cycleStart, 0, environment);
|
|
364
|
+
} catch (error) {
|
|
365
|
+
if (!failures || !(error instanceof TlaEvaluationError)) throw error;
|
|
366
|
+
failures.push(error);
|
|
367
|
+
return false;
|
|
376
368
|
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
369
|
+
})
|
|
370
|
+
.map((property) => property.name),
|
|
371
|
+
),
|
|
372
|
+
];
|
|
373
|
+
|
|
374
|
+
export const createLivenessChecks = (
|
|
375
|
+
properties: TemporalProperty[],
|
|
376
|
+
temporals: ScopedExpression[],
|
|
377
|
+
environment: Environment,
|
|
378
|
+
): LivenessChecks | undefined => {
|
|
379
|
+
if (properties.length === 0) return undefined;
|
|
380
|
+
const live = getLiveFormula(properties, temporals, environment);
|
|
381
|
+
const solutions = getSolutions(live.formula);
|
|
382
|
+
const atoms = getInterpretedAtoms(environment);
|
|
383
|
+
const isShared = isSharingResults(live.formula, environment);
|
|
384
|
+
return {
|
|
385
|
+
solutions,
|
|
386
|
+
findTraceViolation: (trace, fingerprints) => {
|
|
387
|
+
const lasso = findTraceLasso(trace, fingerprints, solutions, atoms, isShared);
|
|
388
|
+
if (!lasso) return undefined;
|
|
389
|
+
// Liveness#findViolatedProperties reports a property it fails to evaluate on the lasso and goes on.
|
|
390
|
+
const failures: TlaEvaluationError[] = [];
|
|
391
|
+
const violated = getViolatedProperties(
|
|
392
|
+
properties,
|
|
393
|
+
live.checks,
|
|
394
|
+
lasso.positions.map((position) => trace[position]),
|
|
395
|
+
lasso.cyclePosition - 1,
|
|
396
|
+
environment,
|
|
397
|
+
failures,
|
|
398
|
+
);
|
|
399
|
+
return { ...lasso, properties: violated, failures };
|
|
399
400
|
},
|
|
400
401
|
};
|
|
401
402
|
};
|
|
@@ -406,8 +407,60 @@ export const createLivenessChecker = (
|
|
|
406
407
|
environment: Environment,
|
|
407
408
|
search: SearchGraph<Value[]>,
|
|
408
409
|
): LivenessChecker | undefined => {
|
|
409
|
-
|
|
410
|
-
|
|
410
|
+
if (properties.length === 0) return undefined;
|
|
411
|
+
const live = getLiveFormula(properties, temporals, environment);
|
|
412
|
+
const isShared = isSharingResults(live.formula, environment);
|
|
413
|
+
const solutions = getSolutions(live.formula);
|
|
414
|
+
const tracing: Tracing = { atoms: getInterpretedAtoms(environment), replay: undefined };
|
|
415
|
+
const graph = createLiveGraph(
|
|
416
|
+
solutions,
|
|
417
|
+
{
|
|
418
|
+
atoms: {
|
|
419
|
+
holdsState: (atom, state) => tracing.atoms.holdsState(atom, state),
|
|
420
|
+
holdsAction: (atom, state, next) => tracing.atoms.holdsAction(atom, state, next),
|
|
421
|
+
},
|
|
422
|
+
isShared,
|
|
423
|
+
isSame: isSameState,
|
|
424
|
+
evaluateFrom: (source, evaluate) => {
|
|
425
|
+
environment.runtime.setLivenessSource(source);
|
|
426
|
+
try {
|
|
427
|
+
return evaluate();
|
|
428
|
+
} finally {
|
|
429
|
+
environment.runtime.setLivenessSource(undefined);
|
|
430
|
+
}
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
getFingerprint: search.getFingerprint,
|
|
435
|
+
forEachActionSuccessors: (index, state, onSuccessors) =>
|
|
436
|
+
search.forEachActionSuccessors(index, state, onSuccessors, tracing.replay),
|
|
437
|
+
},
|
|
438
|
+
environment.runtime.version !== "1.7.4",
|
|
439
|
+
);
|
|
440
|
+
const traceWith = <Result>(replay: Environment | undefined, run: () => Result) => {
|
|
441
|
+
if (replay === undefined) return run();
|
|
442
|
+
tracing.atoms = getInterpretedAtoms(replay);
|
|
443
|
+
tracing.replay = replay;
|
|
444
|
+
try {
|
|
445
|
+
return run();
|
|
446
|
+
} finally {
|
|
447
|
+
tracing.atoms = getInterpretedAtoms(environment);
|
|
448
|
+
tracing.replay = undefined;
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
return {
|
|
452
|
+
branches: graph.branches,
|
|
453
|
+
solutions,
|
|
454
|
+
addInitialState: (index, state, replay) =>
|
|
455
|
+
traceWith(replay, () => graph.addInitialState(index, state)),
|
|
456
|
+
addState: (index, state, successors, replay) =>
|
|
457
|
+
traceWith(replay, () => graph.addState(index, state, successors, replay !== undefined)),
|
|
458
|
+
storeState: graph.storeState,
|
|
459
|
+
getStateCounts: graph.getStateCounts,
|
|
460
|
+
findViolation: graph.findViolation,
|
|
461
|
+
getViolatedProperties: (path, cycleStart) =>
|
|
462
|
+
getViolatedProperties(properties, live.checks, path, cycleStart, environment),
|
|
463
|
+
};
|
|
411
464
|
};
|
|
412
465
|
|
|
413
466
|
export const createLiveGraph = <State>(
|
package/src/liveness.ts
CHANGED
|
@@ -244,6 +244,7 @@ export const expandTemporal = (
|
|
|
244
244
|
return expression.operands.flatMap((operand) => expand(operand, scope, describeRange(operand)));
|
|
245
245
|
}
|
|
246
246
|
if (expression.kind === "Label") return expand(expression.body, scope);
|
|
247
|
+
if (expression.kind === "Selection") return expand(expression.expression, scope);
|
|
247
248
|
if (expression.kind === "Let") {
|
|
248
249
|
return expand(expression.body, bindLetDefinitions(expression, scope, environment));
|
|
249
250
|
}
|
|
@@ -539,6 +540,8 @@ export const toLiveExpression = (
|
|
|
539
540
|
switch (expression.kind) {
|
|
540
541
|
case "Label":
|
|
541
542
|
return convert(expression.body, scope);
|
|
543
|
+
case "Selection":
|
|
544
|
+
return convert(expression.expression, scope);
|
|
542
545
|
case "Let":
|
|
543
546
|
return convert(expression.body, bindLetDefinitions(expression, scope, environment));
|
|
544
547
|
case "Apply": {
|
|
@@ -674,7 +677,7 @@ export const getInterpretedAtoms = (environment: Environment): LiveAtoms<Value[]
|
|
|
674
677
|
},
|
|
675
678
|
});
|
|
676
679
|
|
|
677
|
-
const evaluateLive = <State>(
|
|
680
|
+
export const evaluateLive = <State>(
|
|
678
681
|
expression: LiveExpression,
|
|
679
682
|
state: State,
|
|
680
683
|
next: State | undefined,
|
|
@@ -643,6 +643,8 @@ export const createModuleConverter = (
|
|
|
643
643
|
},
|
|
644
644
|
{ location },
|
|
645
645
|
);
|
|
646
|
+
case "Selection":
|
|
647
|
+
return recurse(expression.expression);
|
|
646
648
|
case "Subexpression": {
|
|
647
649
|
const [head, ...selectors] = expression.selectors;
|
|
648
650
|
if (head.kind !== "Name") throw new TlaProofError("Unexpected subexpression reference");
|
package/src/parser.ts
CHANGED
|
@@ -478,6 +478,8 @@ const getOperatorApplication = (
|
|
|
478
478
|
}
|
|
479
479
|
};
|
|
480
480
|
|
|
481
|
+
export const parenthesizedRanges = new WeakMap<Expression, SourceRange>();
|
|
482
|
+
|
|
481
483
|
export const extractModule = (source: string, name: string) => {
|
|
482
484
|
const header = new RegExp(`^-{4,}\\s*MODULE\\s+${name}\\s*-{3,}$`);
|
|
483
485
|
const lines = source.replace(/\r?\n$/, "").split(/\r?\n/);
|
|
@@ -1344,6 +1346,7 @@ const parse = (
|
|
|
1344
1346
|
case "(": {
|
|
1345
1347
|
const expression = withBracketLayout(() => parseExpression());
|
|
1346
1348
|
expect(")");
|
|
1349
|
+
parenthesizedRanges.set(expression, getRange(start));
|
|
1347
1350
|
return expression;
|
|
1348
1351
|
}
|
|
1349
1352
|
case "[":
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import type { Goal } from "./goal";
|
|
18
18
|
import { Rational } from "./rational";
|
|
19
19
|
import { Rewriter, type RewriterOptions } from "./rewriter";
|
|
20
|
-
import { runSimplifier } from "./dependent-expr-state";
|
|
20
|
+
import { type DependentExprState, runSimplifier } from "./dependent-expr-state";
|
|
21
21
|
import { RewriterTpl } from "./rewriter-tpl";
|
|
22
22
|
|
|
23
23
|
interface Bound {
|
|
@@ -99,8 +99,8 @@ class CardPbRewriter extends RewriterTpl {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
export const
|
|
103
|
-
|
|
102
|
+
export const createCard2Bv =
|
|
103
|
+
(manager: AstManager, options: RewriterOptions) => (state: DependentExprState) => {
|
|
104
104
|
const rewriter = new Rewriter(manager, options);
|
|
105
105
|
const pbRewriter = new CardPbRewriter(manager);
|
|
106
106
|
let simplified = -1;
|
|
@@ -121,4 +121,7 @@ export const card2bv = (manager: AstManager, goal: Goal, options: RewriterOption
|
|
|
121
121
|
pbRewriter.release();
|
|
122
122
|
},
|
|
123
123
|
};
|
|
124
|
-
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export const card2bv = (manager: AstManager, goal: Goal, options: RewriterOptions) =>
|
|
127
|
+
runSimplifier(goal, false, createCard2Bv(manager, options));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SmtInvariantError } from "../../../errors";
|
|
1
2
|
import type { AssertedFormulas } from "./asserted-formulas";
|
|
2
3
|
import {
|
|
3
4
|
AstManager,
|
|
@@ -1286,6 +1287,9 @@ export class Context extends Internalizer {
|
|
|
1286
1287
|
}
|
|
1287
1288
|
|
|
1288
1289
|
private mkProtoModel() {
|
|
1290
|
+
const failure = this.lastSearchFailure;
|
|
1291
|
+
if (this.hasCaseSplits() || failure === FAILURE_CANCELED || failure === FAILURE_NUM_CONFLICTS)
|
|
1292
|
+
return undefined;
|
|
1289
1293
|
if (this.modelState.kind !== "none") this.modelState.generated.model.decRef();
|
|
1290
1294
|
const generated = mkModel(this);
|
|
1291
1295
|
generated.model.incRef();
|
|
@@ -1328,9 +1332,11 @@ export class Context extends Internalizer {
|
|
|
1328
1332
|
}
|
|
1329
1333
|
|
|
1330
1334
|
getModel() {
|
|
1335
|
+
if (this.isInconsistent()) return undefined;
|
|
1331
1336
|
if (this.modelState.kind === "final") return this.modelState.model;
|
|
1332
1337
|
const generated =
|
|
1333
1338
|
this.modelState.kind === "proto" ? this.modelState.generated : this.mkProtoModel();
|
|
1339
|
+
if (generated === undefined) return undefined;
|
|
1334
1340
|
const model = generated.model.mkModel();
|
|
1335
1341
|
model.addRecFuns();
|
|
1336
1342
|
model.incRef();
|
|
@@ -1338,6 +1344,12 @@ export class Context extends Internalizer {
|
|
|
1338
1344
|
return model;
|
|
1339
1345
|
}
|
|
1340
1346
|
|
|
1347
|
+
getSatModel() {
|
|
1348
|
+
const model = this.getModel();
|
|
1349
|
+
if (model === undefined) throw new SmtInvariantError("a sat answer without a model");
|
|
1350
|
+
return model;
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1341
1353
|
validateModel(model: ProtoModel) {
|
|
1342
1354
|
const manager = this.manager;
|
|
1343
1355
|
for (const literal of this.assignedLiterals) {
|
|
@@ -1367,7 +1379,10 @@ export class Context extends Internalizer {
|
|
|
1367
1379
|
)
|
|
1368
1380
|
return status;
|
|
1369
1381
|
const generated = this.mkProtoModel();
|
|
1370
|
-
if (
|
|
1382
|
+
if (
|
|
1383
|
+
generated === undefined ||
|
|
1384
|
+
qmanager.checkModel(generated.model, generated.root2value) !== CHECK_MODEL_RESTART
|
|
1385
|
+
)
|
|
1371
1386
|
return status;
|
|
1372
1387
|
this.lastSearchFailure = FAILURE_OK;
|
|
1373
1388
|
status = L_UNDEF;
|
|
@@ -1377,9 +1392,10 @@ export class Context extends Internalizer {
|
|
|
1377
1392
|
if (status === L_TRUE && qmanager.quantifiers.length === 0) return L_TRUE;
|
|
1378
1393
|
if (status === L_TRUE) {
|
|
1379
1394
|
const generated = this.mkProtoModel();
|
|
1380
|
-
const result =
|
|
1381
|
-
|
|
1382
|
-
|
|
1395
|
+
const result =
|
|
1396
|
+
generated !== undefined && qmanager.isModelBased()
|
|
1397
|
+
? qmanager.checkModel(generated.model, generated.root2value)
|
|
1398
|
+
: CHECK_MODEL_UNKNOWN;
|
|
1383
1399
|
if (result === CHECK_MODEL_SAT) return L_TRUE;
|
|
1384
1400
|
if (result === CHECK_MODEL_UNKNOWN) {
|
|
1385
1401
|
this.lastSearchFailure = FAILURE_QUANTIFIERS;
|
|
@@ -36,15 +36,18 @@ export class DependentExprState {
|
|
|
36
36
|
const manager = this.manager;
|
|
37
37
|
const goal = this.goal;
|
|
38
38
|
let rewritten = -1;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
try {
|
|
40
|
+
this.forEachIndex((index) => {
|
|
41
|
+
const form = this.get(index);
|
|
42
|
+
const next = rewrite(form);
|
|
43
|
+
if (next === -1) return;
|
|
44
|
+
if (rewritten !== -1) manager.decRef(rewritten);
|
|
45
|
+
rewritten = next;
|
|
46
|
+
if (rewritten !== form) goal.update(index, rewritten, goal.getDependency(index));
|
|
47
|
+
});
|
|
48
|
+
} finally {
|
|
43
49
|
if (rewritten !== -1) manager.decRef(rewritten);
|
|
44
|
-
|
|
45
|
-
if (rewritten !== form) goal.update(index, rewritten, goal.getDependency(index));
|
|
46
|
-
});
|
|
47
|
-
if (rewritten !== -1) manager.decRef(rewritten);
|
|
50
|
+
}
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
hasQuantifiers() {
|
|
@@ -79,8 +82,11 @@ export const runSimplifier = (
|
|
|
79
82
|
) => {
|
|
80
83
|
const state = new DependentExprState(goal.manager, goal);
|
|
81
84
|
const simplifier = create(state);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
try {
|
|
86
|
+
if (!goal.isProofsEnabled || isSupportingProofs) simplifier.reduce();
|
|
87
|
+
finishSimplifier(goal);
|
|
88
|
+
} finally {
|
|
89
|
+
simplifier.release();
|
|
90
|
+
state.release();
|
|
91
|
+
}
|
|
86
92
|
};
|
|
@@ -228,33 +228,49 @@ export const createDt2BvTactic = (manager: AstManager) => {
|
|
|
228
228
|
else argsCannotBeFd(expr);
|
|
229
229
|
}
|
|
230
230
|
for (const sort of nonFdSorts) fdSorts.delete(sort);
|
|
231
|
-
if (fdSorts.size > 0)
|
|
231
|
+
if (fdSorts.size > 0)
|
|
232
|
+
runEnum2Bv(
|
|
233
|
+
manager,
|
|
234
|
+
goal,
|
|
235
|
+
(visit) => {
|
|
236
|
+
const size = goal.forms.size;
|
|
237
|
+
for (let index = 0; index < size && !goal.isInconsistent; index++) visit(index);
|
|
238
|
+
},
|
|
239
|
+
fdSorts,
|
|
240
|
+
);
|
|
232
241
|
goal.depth++;
|
|
233
242
|
return [goal];
|
|
234
243
|
};
|
|
235
244
|
};
|
|
236
245
|
|
|
237
|
-
export const runEnum2Bv = (
|
|
246
|
+
export const runEnum2Bv = (
|
|
247
|
+
manager: AstManager,
|
|
248
|
+
goal: Goal,
|
|
249
|
+
forEachIndex: (visit: (index: number) => void) => void,
|
|
250
|
+
fdSorts?: Set<number>,
|
|
251
|
+
) => {
|
|
238
252
|
const rewriter = new Enum2BvRewriter(manager, fdSorts);
|
|
239
253
|
let rewritten = -1;
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
254
|
+
try {
|
|
255
|
+
forEachIndex((index) => {
|
|
256
|
+
const next = rewriter.rewrite(goal.forms.items[index]);
|
|
257
|
+
release(manager, rewritten);
|
|
258
|
+
rewritten = next;
|
|
259
|
+
goal.update(index, rewritten);
|
|
260
|
+
});
|
|
261
|
+
const bounds = new RefVector(manager);
|
|
262
|
+
for (const bound of rewriter.bounds.items) bounds.push(bound);
|
|
263
|
+
rewriter.bounds.reset();
|
|
264
|
+
for (const bound of bounds.items) goal.assert(bound);
|
|
265
|
+
const definitions: Definition[] = [];
|
|
266
|
+
for (const entry of rewriter.enumIndexes)
|
|
267
|
+
definitions.push({ decl: rewriter.enumBvs[entry[1]], def: -1 });
|
|
268
|
+
for (const entry of rewriter.enumIndexes)
|
|
269
|
+
definitions.push({ decl: entry[0], def: rewriter.enumDefs.items[entry[1]] });
|
|
270
|
+
if (definitions.length > 0) goal.addDefinitions(definitions);
|
|
271
|
+
bounds.reset();
|
|
272
|
+
} finally {
|
|
243
273
|
release(manager, rewritten);
|
|
244
|
-
|
|
245
|
-
goal.update(index, rewritten);
|
|
274
|
+
rewriter.release();
|
|
246
275
|
}
|
|
247
|
-
const bounds = new RefVector(manager);
|
|
248
|
-
for (const bound of rewriter.bounds.items) bounds.push(bound);
|
|
249
|
-
rewriter.bounds.reset();
|
|
250
|
-
for (const bound of bounds.items) goal.assert(bound);
|
|
251
|
-
const definitions: Definition[] = [];
|
|
252
|
-
for (const entry of rewriter.enumIndexes)
|
|
253
|
-
definitions.push({ decl: rewriter.enumBvs[entry[1]], def: -1 });
|
|
254
|
-
for (const entry of rewriter.enumIndexes)
|
|
255
|
-
definitions.push({ decl: entry[0], def: rewriter.enumDefs.items[entry[1]] });
|
|
256
|
-
if (definitions.length > 0) goal.addDefinitions(definitions);
|
|
257
|
-
bounds.reset();
|
|
258
|
-
release(manager, rewritten);
|
|
259
|
-
rewriter.release();
|
|
260
276
|
};
|