Skip to content

Commit

Permalink
Provide values for infinite counterexamples
Browse files Browse the repository at this point in the history
* Refactoring-free solution that encodes the loop of the lasso
  program in the postcondition of a TraceCheck.
* Provides only values for the stem.
* Works only for fixpoints (not for geometrical nontermination
  arguments).
* Solution that provides values for the loop requires probably
  an extension of the TraceCheck.
  • Loading branch information
Heizmann committed Sep 27, 2022
1 parent b709f18 commit 2b22b30
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import de.uni_freiburg.informatik.ultimate.lassoranker.NonterminationArgumentStatistics;
import de.uni_freiburg.informatik.ultimate.lassoranker.nontermination.GeometricNonTerminationArgument;
import de.uni_freiburg.informatik.ultimate.lassoranker.nontermination.InfiniteFixpointRepetition;
import de.uni_freiburg.informatik.ultimate.lassoranker.nontermination.InfiniteFixpointRepetitionWithExecution;
import de.uni_freiburg.informatik.ultimate.lassoranker.nontermination.NonTerminationArgument;
import de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.cfg.IcfgPetrifier;
import de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.cfg.IcfgProgramExecution;
Expand Down Expand Up @@ -249,10 +250,14 @@ private void reportNonTermination(final BuchiCegarLoopResult<IcfgEdge> result, f
if (result.getStem().length() == 0) {
stemPE = IcfgProgramExecution.create(IcfgEdge.class);
} else {
stemPE = TraceCheckUtils.computeSomeIcfgProgramExecutionWithoutValues(result.getStem());
if (result.getNonTerminationArgument() instanceof InfiniteFixpointRepetitionWithExecution) {
stemPE = (IcfgProgramExecution<IcfgEdge>) ((InfiniteFixpointRepetitionWithExecution) result
.getNonTerminationArgument()).getStemExecution();
} else {
stemPE = TraceCheckUtils.computeSomeIcfgProgramExecutionWithoutValues(result.getStem());
}
}
final IcfgProgramExecution<IcfgEdge> loopPE =
TraceCheckUtils.computeSomeIcfgProgramExecutionWithoutValues(result.getLoop());
final IcfgProgramExecution<IcfgEdge> loopPE = TraceCheckUtils.computeSomeIcfgProgramExecutionWithoutValues(result.getLoop());
final IcfgEdge hondaAction = result.getLoop().getSymbol(0);

if (ltlAnnot == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import de.uni_freiburg.informatik.ultimate.lassoranker.nontermination.DefaultNonTerminationAnalysisSettings;
import de.uni_freiburg.informatik.ultimate.lassoranker.nontermination.FixpointCheck;
import de.uni_freiburg.informatik.ultimate.lassoranker.nontermination.FixpointCheck.HasFixpoint;
import de.uni_freiburg.informatik.ultimate.lassoranker.nontermination.FixpointCheck2;
import de.uni_freiburg.informatik.ultimate.lassoranker.nontermination.NonTerminationAnalysisSettings;
import de.uni_freiburg.informatik.ultimate.lassoranker.nontermination.NonTerminationArgument;
import de.uni_freiburg.informatik.ultimate.lassoranker.termination.DefaultTerminationAnalysisSettings;
Expand Down Expand Up @@ -128,6 +129,8 @@ enum LassoPart {

private static final boolean AVOID_NONTERMINATION_CHECK_IF_ARRAYS_ARE_CONTAINED = true;

private static final boolean TRACE_CHECK_BASED_FIXPOINT_CHECK = true;

/**
* If true we check if the loop is terminating even if the stem or the concatenation of stem and loop are already
* infeasible. This allows us to use refineFinite and refineBuchi in the same iteration.
Expand Down Expand Up @@ -552,7 +555,12 @@ private SynthesisResult synthesize(final boolean withStem, UnmodifiableTransForm
mModifiableGlobalsAtHonda, stemTF, loopTF);
if (fixpointCheck.getResult() == HasFixpoint.YES) {
if (withStem) {
mNonterminationArgument = fixpointCheck.getTerminationArgument();
if (TRACE_CHECK_BASED_FIXPOINT_CHECK) {
final FixpointCheck2<L> fixpointCheck2 = new FixpointCheck2<L>(mServices, mLogger, mCsToolkit, mPredicateFactory, mCounterexample.getStem(), loopTF);
mNonterminationArgument = fixpointCheck2.getTerminationArgument();
} else {
mNonterminationArgument = fixpointCheck.getTerminationArgument();
}
}
return SynthesisResult.NONTERMINATING;
}
Expand Down
2 changes: 2 additions & 0 deletions trunk/source/Library-LassoRanker/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Require-Bundle: de.uni_freiburg.informatik.ultimate.lib.core,
de.uni_freiburg.informatik.ultimate.smtinterpol;resolution:=optional,
de.uni_freiburg.informatik.ultimate.smtsolver.external,
de.uni_freiburg.informatik.ultimate.lib.icfgtransformer,
de.uni_freiburg.informatik.ultimate.lib.automata,
de.uni_freiburg.informatik.ultimate.lib.tracecheckerutils,
org.apache.commons.lang
Bundle-RequiredExecutionEnvironment: JavaSE-11
Export-Package: de.uni_freiburg.informatik.ultimate.lassoranker,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
* Copyright (C) 2022 Matthias Heizmann ([email protected])
* Copyright (C) 2022 University of Freiburg
*
* This file is part of the ULTIMATE LassoRanker Library.
*
* The ULTIMATE LassoRanker 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 LassoRanker 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 LassoRanker Library. If not, see <http://www.gnu.org/licenses/>.
*
* Additional permission under GNU GPL version 3 section 7:
* If you modify the ULTIMATE LassoRanker 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 LassoRanker Library grant you additional permission
* to convey the resulting work.
*/
package de.uni_freiburg.informatik.ultimate.lassoranker.nontermination;

import java.util.Collections;
import java.util.SortedMap;

import de.uni_freiburg.informatik.ultimate.automata.nestedword.NestedRun;
import de.uni_freiburg.informatik.ultimate.core.model.services.ILogger;
import de.uni_freiburg.informatik.ultimate.core.model.services.IUltimateServiceProvider;
import de.uni_freiburg.informatik.ultimate.lassoranker.nontermination.FixpointCheck.HasFixpoint;
import de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.cfg.CfgSmtToolkit;
import de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.cfg.structure.IIcfgTransition;
import de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.cfg.transitions.TransFormula;
import de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.cfg.transitions.TransFormulaUtils;
import de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.cfg.transitions.UnmodifiableTransFormula;
import de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.smt.predicates.BasicPredicateFactory;
import de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.smt.predicates.IPredicate;
import de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.smt.tracecheck.ITraceCheckPreferences.AssertCodeBlockOrder;
import de.uni_freiburg.informatik.ultimate.lib.smtlibutils.ManagedScript;
import de.uni_freiburg.informatik.ultimate.lib.smtlibutils.SmtUtils;
import de.uni_freiburg.informatik.ultimate.lib.smtlibutils.SmtUtils.SimplificationTechnique;
import de.uni_freiburg.informatik.ultimate.lib.smtlibutils.quantifier.PartialQuantifierElimination;
import de.uni_freiburg.informatik.ultimate.lib.tracecheckerutils.singletracecheck.TraceCheck;
import de.uni_freiburg.informatik.ultimate.logic.QuantifiedFormula;
import de.uni_freiburg.informatik.ultimate.logic.Term;

/**
* Additional fixpoint check also shows values. <br>
* Work in progress. This is a workaround that encodes the loop in a predicate
* and utilizes the {@link TraceCheck} for the stem. Hence this calls cannot yet
* provide values for the loop. I think if we want to provide values for the loop
* we have to extend the {@link TraceCheck}.
*
* @author Matthias Heizmann ([email protected])
*
*/
public class FixpointCheck2<L extends IIcfgTransition<?>> {

private final IUltimateServiceProvider mServices;
private final ILogger mLogger;
private final CfgSmtToolkit mCsToolkit;
private final NestedRun<L, IPredicate> mStem;
private final TransFormula mLoop;
private final HasFixpoint mResult;
private InfiniteFixpointRepetitionWithExecution<L> mTerminationArgument;

public FixpointCheck2(final IUltimateServiceProvider services, final ILogger logger, final CfgSmtToolkit csToolkit,
final BasicPredicateFactory pf, final NestedRun<L, IPredicate> stem,
final UnmodifiableTransFormula loopTF) {
mServices = services;
mLogger = logger;
mCsToolkit = csToolkit;
mStem = stem;
mLoop = loopTF;

// 20220926 Matthias: As precondition, we might need that global vars and
// oldvars of the initial procedure coincide. But this seems to be a mistake
// that we do in many places that that only is only problematic if the Boogie
// program uses the `old` operator.
final IPredicate precondition = pf.newPredicate(csToolkit.getManagedScript().getScript().term("true"));
final IPredicate postcondition = constructNegatedLoopPredicate(services, csToolkit.getManagedScript(), pf,
mLoop);
final SortedMap<Integer, IPredicate> pendingContexts = Collections.emptySortedMap();
final TraceCheck<L> tc = new TraceCheck<L>(precondition, postcondition, pendingContexts, mStem.getWord(),
services, csToolkit, AssertCodeBlockOrder.NOT_INCREMENTALLY, true, false);
switch (tc.isCorrect()) {
case SAT:
mResult = HasFixpoint.YES;
if (!tc.providesRcfgProgramExecution()) {
throw new AssertionError("TraceCheck has to provide an execution");
}
mTerminationArgument = new InfiniteFixpointRepetitionWithExecution<>(tc.getRcfgProgramExecution());
break;
case UNKNOWN:
mResult = HasFixpoint.UNKNOWN;
break;
case UNSAT:
mResult = HasFixpoint.NO;
break;
default:
throw new AssertionError();
}

}

private static IPredicate constructNegatedLoopPredicate(final IUltimateServiceProvider services,
final ManagedScript mgdScript, final BasicPredicateFactory pf, final TransFormula loop) {
final Term inVarsRenamed = TransFormulaUtils.renameInvarsToDefaultVars(loop, mgdScript, loop.getFormula());
final Term allRenamed = TransFormulaUtils.renameOutvarsToDefaultVars(loop, mgdScript, inVarsRenamed);
final Term withoutAuxVars = SmtUtils.quantifier(mgdScript.getScript(), QuantifiedFormula.EXISTS,
loop.getAuxVars(), allRenamed);
final Term elim = PartialQuantifierElimination.eliminate(services, mgdScript, withoutAuxVars,
SimplificationTechnique.SIMPLIFY_DDA);
return pf.newPredicate(SmtUtils.not(mgdScript.getScript(), elim));
}

public HasFixpoint getResult() {
return mResult;
}

public InfiniteFixpointRepetitionWithExecution<L> getTerminationArgument() {
return mTerminationArgument;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (C) 2022 Matthias Heizmann ([email protected])
* Copyright (C) 2022 University of Freiburg
*
* This file is part of the ULTIMATE LassoRanker Library.
*
* The ULTIMATE LassoRanker 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 LassoRanker 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 LassoRanker Library. If not, see <http://www.gnu.org/licenses/>.
*
* Additional permission under GNU GPL version 3 section 7:
* If you modify the ULTIMATE LassoRanker 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 LassoRanker Library grant you additional permission
* to convey the resulting work.
*/
package de.uni_freiburg.informatik.ultimate.lassoranker.nontermination;

import java.io.Serializable;

import de.uni_freiburg.informatik.ultimate.core.model.translation.IProgramExecution;
import de.uni_freiburg.informatik.ultimate.lib.modelcheckerutils.cfg.structure.IIcfgTransition;
import de.uni_freiburg.informatik.ultimate.logic.Term;


/**
* Represents a non-termination argument for a lasso program. <br>
* This is work in progress and should probably replace
* {@link InfiniteFixpointRepetition}. Currently, we have only an execution for
* the stem because we cannot yet compute an execution for the loop.
*
* @author Matthias Heizmann ([email protected]
*/
public class InfiniteFixpointRepetitionWithExecution<L extends IIcfgTransition<?>> extends NonTerminationArgument implements Serializable {

private static final long serialVersionUID = -4391252776990865865L;

private final IProgramExecution<L, Term> mStemExecution;

public InfiniteFixpointRepetitionWithExecution(final IProgramExecution<L, Term> stemExecution) {
super();
mStemExecution = stemExecution;
}

public IProgramExecution<L, Term> getStemExecution() {
return mStemExecution;
}

}

0 comments on commit 2b22b30

Please sign in to comment.