
org.sosy_lab.solver.logging.LoggingProverEnvironment Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-smt Show documentation
Show all versions of java-smt Show documentation
Unified acccess layer to SMT solvers
/*
* JavaSMT is an API wrapper for a collection of SMT solvers.
* This file is part of JavaSMT.
*
* Copyright (C) 2007-2015 Dirk Beyer
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sosy_lab.solver.logging;
import static com.google.common.base.Preconditions.checkNotNull;
import org.sosy_lab.common.log.LogManager;
import org.sosy_lab.solver.SolverException;
import org.sosy_lab.solver.api.BooleanFormula;
import org.sosy_lab.solver.api.Model;
import org.sosy_lab.solver.api.ProverEnvironment;
import java.util.List;
import java.util.logging.Level;
/**
* Wraps a prover environment with a logging object.
*/
public class LoggingProverEnvironment implements ProverEnvironment {
private final ProverEnvironment wrapped;
private final LogManager logger;
int level = 0;
public LoggingProverEnvironment(LogManager logger, ProverEnvironment pe) {
this.wrapped = checkNotNull(pe);
this.logger = checkNotNull(logger);
}
@Override
public Void push(BooleanFormula f) {
logger.log(Level.FINE, "up to level " + level++);
logger.log(Level.FINE, "formula pushed:", f);
return wrapped.push(f);
}
@Override
public void pop() {
logger.log(Level.FINER, "down to level " + level--);
wrapped.pop();
}
@Override
public Void addConstraint(BooleanFormula constraint) {
return wrapped.addConstraint(constraint);
}
@Override
public void push() {
logger.log(Level.FINE, "up to level " + level++);
wrapped.push();
}
@Override
public boolean isUnsat() throws SolverException, InterruptedException {
boolean result = wrapped.isUnsat();
logger.log(Level.FINE, "unsat-check returned:", result);
return result;
}
@Override
public Model getModel() throws SolverException {
Model m = wrapped.getModel();
logger.log(Level.FINE, "model", m);
return m;
}
@Override
public List getUnsatCore() {
List unsatCore = wrapped.getUnsatCore();
logger.log(Level.FINE, "unsat-core", unsatCore);
return unsatCore;
}
@Override
public T allSat(AllSatCallback callback, List important)
throws InterruptedException, SolverException {
T result = wrapped.allSat(callback, important);
logger.log(Level.FINE, "allsat-result:", result);
return result;
}
@Override
public void close() {
wrapped.close();
logger.log(Level.FINER, "closed");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy