/*
* Copyright (C) 2013-2015 Daniel Dietsch (dietsch@informatik.uni-freiburg.de)
* Copyright (C) 2013-2015 Matthias Heizmann (heizmann@informatik.uni-freiburg.de)
* Copyright (C) 2015 University of Freiburg
*
* This file is part of the ULTIMATE ModelCheckerUtils Library.
*
* The ULTIMATE ModelCheckerUtils Library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The ULTIMATE ModelCheckerUtils Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the ULTIMATE ModelCheckerUtils Library. If not, see .
*
* Additional permission under GNU GPL version 3 section 7:
* If you modify the ULTIMATE ModelCheckerUtils Library, or any covered work, by linking
* or combining it with Eclipse RCP (or a modified version of Eclipse RCP),
* containing parts covered by the terms of the Eclipse Public License, the
* licensors of the ULTIMATE ModelCheckerUtils Library grant you additional permission
* to convey the resulting work.
*/
package de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.cfg;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import de.uni_freiburg.informatik.ultimate.core.lib.results.NoBacktranslationValueProvider;
import de.uni_freiburg.informatik.ultimate.core.lib.translation.ProgramExecutionFormatter;
import de.uni_freiburg.informatik.ultimate.core.model.results.IRelevanceInformation;
import de.uni_freiburg.informatik.ultimate.core.model.translation.AtomicTraceElement;
import de.uni_freiburg.informatik.ultimate.core.model.translation.AtomicTraceElement.AtomicTraceElementBuilder;
import de.uni_freiburg.informatik.ultimate.core.model.translation.AtomicTraceElement.StepInfo;
import de.uni_freiburg.informatik.ultimate.core.model.translation.IBacktranslationValueProvider;
import de.uni_freiburg.informatik.ultimate.core.model.translation.IProgramExecution;
import de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.cfg.structure.IAction;
import de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.cfg.structure.IIcfgCallTransition;
import de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.cfg.structure.IIcfgForkTransitionThreadCurrent;
import de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.cfg.structure.IIcfgForkTransitionThreadOther;
import de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.cfg.structure.IIcfgJoinTransitionThreadCurrent;
import de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.cfg.structure.IIcfgJoinTransitionThreadOther;
import de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.cfg.structure.IIcfgReturnTransition;
import de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.cfg.structure.IIcfgTransition;
import de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.cfg.structure.IcfgForkThreadOtherTransition;
import de.uni_freiburg.informatik.ultimate.logic.Term;
import de.uni_freiburg.informatik.ultimate.logic.TermVariable;
/**
*
* @author Matthias Heizmann (heizmann@informatik.uni-freiburg.de)
* @author Daniel Dietsch (dietsch@informatik.uni-freiburg.de)
*
*/
public class IcfgProgramExecution implements IProgramExecution {
private final List> mTrace;
private final Map> mPartialProgramStateMapping;
private final Map[] mBranchEncoders;
private final boolean mIsConcurrent;
private final Class mTransitionClazz;
public IcfgProgramExecution(final List> trace,
final Map> partialProgramStateMapping,
final Map[] branchEncoders, final boolean isConcurrent,
final Class transitionClazz) {
assert partialProgramStateMapping != null;
assert branchEncoders != null;
assert trace != null;
assert partialProgramStateMapping.size() - 1 <= trace.size();
mIsConcurrent = isConcurrent;
mTrace = trace;
mPartialProgramStateMapping = partialProgramStateMapping;
assert isProgramStateMappingInRange(trace, partialProgramStateMapping);
mBranchEncoders = branchEncoders;
mTransitionClazz = transitionClazz;
}
private boolean isProgramStateMappingInRange(final List> trace,
final Map> partialProgramStateMapping) {
for (final Entry> entry : partialProgramStateMapping.entrySet()) {
if (entry.getKey() < -1) {
assert false : "Position of state below -1: " + entry;
return false;
} else if (entry.getKey() >= trace.size()) {
assert false : "Position of state above end of trace: " + entry;
return false;
}
// other positions are fine
}
// no violations, every entry is in range
return true;
}
@SuppressWarnings("unchecked")
public static IcfgProgramExecution create(final Class transitionClazz) {
return create(Collections.emptyList(), Collections.emptyMap(),
new ArrayList