-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathDebuggingBasicProverEnvironment.java
More file actions
117 lines (100 loc) · 3.32 KB
/
DebuggingBasicProverEnvironment.java
File metadata and controls
117 lines (100 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// This file is part of JavaSMT,
// an API wrapper for a collection of SMT solvers:
// https://github.com/sosy-lab/java-smt
//
// SPDX-FileCopyrightText: 2024 Dirk Beyer <https://www.sosy-lab.org>
//
// SPDX-License-Identifier: Apache-2.0
package org.sosy_lab.java_smt.delegate.debugging;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.sosy_lab.java_smt.api.BasicProverEnvironment;
import org.sosy_lab.java_smt.api.BooleanFormula;
import org.sosy_lab.java_smt.api.Model;
import org.sosy_lab.java_smt.api.SolverException;
import org.sosy_lab.java_smt.api.proofs.Proof;
class DebuggingBasicProverEnvironment<T> implements BasicProverEnvironment<T> {
private final BasicProverEnvironment<T> delegate;
private final DebuggingAssertions debugging;
DebuggingBasicProverEnvironment(
BasicProverEnvironment<T> pDelegate, DebuggingAssertions pDebugging) {
delegate = checkNotNull(pDelegate);
debugging = pDebugging;
}
@Override
public void pop() {
debugging.assertThreadLocal();
delegate.pop();
}
@Override
public @Nullable T addConstraint(BooleanFormula constraint) throws InterruptedException {
debugging.assertThreadLocal();
debugging.assertFormulaInContext(constraint);
return delegate.addConstraint(constraint);
}
@Override
public void push() throws InterruptedException {
debugging.assertThreadLocal();
delegate.push();
}
@Override
public int size() {
debugging.assertThreadLocal();
return delegate.size();
}
@Override
public boolean isUnsat() throws SolverException, InterruptedException {
debugging.assertThreadLocal();
return delegate.isUnsat();
}
@Override
public boolean isUnsatWithAssumptions(Collection<BooleanFormula> assumptions)
throws SolverException, InterruptedException {
debugging.assertThreadLocal();
for (BooleanFormula f : assumptions) {
debugging.assertFormulaInContext(f);
}
return delegate.isUnsatWithAssumptions(assumptions);
}
@SuppressWarnings("resource")
@Override
public Model getModel() throws SolverException {
debugging.assertThreadLocal();
return new DebuggingModel(delegate.getModel(), debugging);
}
@Override
public List<BooleanFormula> getUnsatCore() {
debugging.assertThreadLocal();
return delegate.getUnsatCore();
}
@Override
public Optional<List<BooleanFormula>> unsatCoreOverAssumptions(
Collection<BooleanFormula> assumptions) throws SolverException, InterruptedException {
debugging.assertThreadLocal();
for (BooleanFormula f : assumptions) {
debugging.assertFormulaInContext(f);
}
return delegate.unsatCoreOverAssumptions(assumptions);
}
@Override
public Proof getProof() throws SolverException, InterruptedException {
return delegate.getProof();
}
@Override
public void close() {
debugging.assertThreadLocal();
delegate.close();
}
@Override
public <R> R allSat(AllSatCallback<R> callback, List<BooleanFormula> important)
throws InterruptedException, SolverException {
debugging.assertThreadLocal();
for (BooleanFormula f : important) {
debugging.assertFormulaInContext(f);
}
return delegate.allSat(callback, important);
}
}