Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for new property check for requirements called State-Recoverability #645

Open
wants to merge 24 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
33d9103
Add support for new property check for requirements called
Tob1as864 Aug 15, 2023
6c8af66
Update trunk/source/Library-UltimateModel/src/de/uni_freiburg/informa…
Tob1as864 Aug 15, 2023
3de1715
Update trunk/source/PEAtoBoogie/src/de/uni_freiburg/informatik/ultima…
Tob1as864 Aug 15, 2023
b531f42
Update trunk/source/PEAtoBoogie/src/de/uni_freiburg/informatik/ultima…
Tob1as864 Aug 15, 2023
b4aa9f5
Update trunk/source/PEAtoBoogie/src/de/uni_freiburg/informatik/ultima…
Tob1as864 Aug 15, 2023
3096f1e
Update trunk/source/PEAtoBoogie/src/de/uni_freiburg/informatik/ultima…
Tob1as864 Aug 15, 2023
9d4e8be
Update trunk/source/PEAtoBoogie/src/de/uni_freiburg/informatik/ultima…
Tob1as864 Aug 15, 2023
3ed0ed0
Update trunk/source/PEAtoBoogie/src/de/uni_freiburg/informatik/ultima…
Tob1as864 Aug 15, 2023
39b357f
Update trunk/source/PEAtoBoogie/src/de/uni_freiburg/informatik/ultima…
Tob1as864 Aug 15, 2023
177838a
Fixes for pull request
Tob1as864 Aug 15, 2023
ba1afa3
Merge remote-tracking branch 'origin/NewPropertyForRequirementsCheck'
Tob1as864 Aug 15, 2023
a485799
Fixes for review
Tob1as864 Aug 15, 2023
3eac26a
Review fix
Tob1as864 Aug 28, 2023
76c1170
Review fix
Tob1as864 Aug 28, 2023
d9cf93c
Review fix
Tob1as864 Aug 28, 2023
661a8b7
Review fix
Tob1as864 Aug 29, 2023
503cb86
Bugfix
Tob1as864 Aug 29, 2023
bb7fa8e
Bugfix
Tob1as864 Aug 30, 2023
d6637ba
Removed import
Tob1as864 Aug 30, 2023
6c6b86a
Verification Condition as Expression
Tob1as864 Aug 31, 2023
a767340
Review fix
Tob1as864 Aug 31, 2023
b55702b
Bugfix for property check without any assertations
Tob1as864 Sep 3, 2023
f09372a
Bugfix
Tob1as864 Sep 23, 2023
7d75049
Resolve Boogie data type issue
Tob1as864 Nov 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,21 @@ private static Expression constructBinExprWithLiteralOpsBitvector(final ILocatio
throw new AssertionError("unknown operator " + operator);
}
}

public static Expression constructIfThenExpression(final ILocation loc, final Expression condition,
final Expression thenPart) {
if (condition instanceof BooleanLiteral) {
final boolean value = ((BooleanLiteral) condition).getValue();
if (value) {
return thenPart;
}
}
final BoogieType type = TypeCheckHelper.typeCheckIfThenElseExpression((BoogieType) condition.getType(),
(BoogieType) thenPart.getType(), (BoogieType) thenPart.getType(), new TypeErrorReporter(loc));
return new IfThenElseExpression(loc, type, condition, thenPart, null);
Tob1as864 marked this conversation as resolved.
Show resolved Hide resolved

}

public static Expression constructIfThenElseExpression(final ILocation loc, final Expression condition,
final Expression thenPart, final Expression elsePart) {
if (condition instanceof BooleanLiteral) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ public enum Spec {
* Check for requirements. Checks for incompleteness.
*/
INCOMPLETE,
/**
* Check for requirements. Checks for state recoverability.
*/
STATE_RECOVERABILITY,
/**
* Check if a petrified ICFG does provide enough thread instances.
*/
Expand Down Expand Up @@ -261,6 +265,8 @@ public static String getDefaultPositiveMessage(final Spec spec) {
return "consistent";
case INCOMPLETE:
return "complete";
case STATE_RECOVERABILITY:
return "state recoverable";
case SUFFICIENT_THREAD_INSTANCES:
return "petrification did provide enough thread instances (tool internal message, not intended for end users)";
case DATA_RACE:
Expand Down Expand Up @@ -316,6 +322,8 @@ public static String getDefaultNegativeMessage(final Spec spec) {
return "inconsistent";
case INCOMPLETE:
return "incomplete";
case STATE_RECOVERABILITY:
return "not recoverable";
case SUFFICIENT_THREAD_INSTANCES:
return "petrification did not provide enough thread instances (tool internal message, not intended for end users)";
case DATA_RACE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import de.uni_freiburg.informatik.ultimate.core.model.IController;

Expand Down Expand Up @@ -157,6 +159,7 @@ public interface IUltimatePreferenceItemValidator<T> {
IntegerValidator ONLY_POSITIVE = new IntegerValidator(0, Integer.MAX_VALUE);
IntegerValidator ONLY_POSITIVE_NON_ZERO = new IntegerValidator(1, Integer.MAX_VALUE);
IntegerValidator GEQ_TWO = new IntegerValidator(2, Integer.MAX_VALUE);
StringValidator EXPR_PAIR = new StringValidator("\\s{0,1}((\\w+)\\s*([<>=!][=]*)\\s*(\\w+))\\s{0,1}$");

boolean isValid(T value);

Expand Down Expand Up @@ -203,6 +206,38 @@ public String getInvalidValueErrorMessage(final Double value) {
return "Valid range is " + mMin + " <= value <= " + mMax;
}
}

public class StringValidator implements IUltimatePreferenceItemValidator<String> {

private final String mPattern;

public StringValidator(String pattern) {
mPattern = pattern;
}

@Override
public boolean isValid(final String string) {
String[]exprPairs = string.split(",");
Tob1as864 marked this conversation as resolved.
Show resolved Hide resolved
Tob1as864 marked this conversation as resolved.
Show resolved Hide resolved
for(String exprPair : exprPairs) {
Matcher m = match(exprPair, mPattern);
if(!m.matches()) {
return false;
}
}
return true;
}

@Override
public String getInvalidValueErrorMessage(final String string) {
return "Expression pairs " + string + " is not in the format <Variable<Operator>VALUE, ...>";
}
}

default Matcher match(String s, String pattern) {
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(s);
return m;
}
}

}
1 change: 1 addition & 0 deletions trunk/source/PEAtoBoogie/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ Require-Bundle: com.github.jhoenicke.javacup,
de.uni_freiburg.informatik.ultimate.lib.automata
Export-Package: de.uni_freiburg.informatik.ultimate.pea2boogie,
de.uni_freiburg.informatik.ultimate.pea2boogie.results,
de.uni_freiburg.informatik.ultimate.pea2boogie.staterecoverability,
de.uni_freiburg.informatik.ultimate.pea2boogie.testgen
Automatic-Module-Name: de.uni.freiburg.informatik.ultimate.pea2boogie
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@
import de.uni_freiburg.informatik.ultimate.boogie.ast.Expression;
import de.uni_freiburg.informatik.ultimate.boogie.ast.IdentifierExpression;
import de.uni_freiburg.informatik.ultimate.boogie.ast.VariableLHS;
import de.uni_freiburg.informatik.ultimate.boogie.type.BoogieType;
import de.uni_freiburg.informatik.ultimate.core.model.models.IBoogieType;
import de.uni_freiburg.informatik.ultimate.lib.pea.PhaseEventAutomata;
import de.uni_freiburg.informatik.ultimate.lib.srparse.pattern.PatternType;
import de.uni_freiburg.informatik.ultimate.pea2boogie.staterecoverability.AuxStatementContainer;
import de.uni_freiburg.informatik.ultimate.util.datastructures.UnionFind;

public interface IReqSymbolTable {
Expand Down Expand Up @@ -65,6 +67,10 @@ public interface IReqSymbolTable {
Set<String> getClockVars();

Set<String> getStateVars();

Set<String> getAuxVars();

AuxStatementContainer getAuxStatementContainer();
Tob1as864 marked this conversation as resolved.
Show resolved Hide resolved

/**
* Given a variable name, return the name of the primed version of this variable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import de.uni_freiburg.informatik.ultimate.pea2boogie.preferences.Pea2BoogiePreferences;
import de.uni_freiburg.informatik.ultimate.pea2boogie.preferences.Pea2BoogiePreferences.PEATransformerMode;
import de.uni_freiburg.informatik.ultimate.pea2boogie.testgen.Req2CauseTrackingPeaTransformer;
import de.uni_freiburg.informatik.ultimate.pea2boogie.testgen.Req2ModifySymbolTablePeaTransformer;
import de.uni_freiburg.informatik.ultimate.pea2boogie.testgen.ReqTestResultUtil;
import de.uni_freiburg.informatik.ultimate.pea2boogie.translator.Req2BoogieTranslator;

Expand Down Expand Up @@ -55,22 +56,36 @@ private IElement generateBoogie(final List<PatternType<?>> patterns) {
if (mode == PEATransformerMode.REQ_CHECK) {
return generateReqCheckBoogie(patterns);
}
if(mode == PEATransformerMode.REQ_PARAM_CHECK) {
return generateReqParamCheckBoogie(patterns);
Tob1as864 marked this conversation as resolved.
Show resolved Hide resolved
}
if (mode == PEATransformerMode.REQ_TEST) {
return generateReqTestBoogie(patterns);
}
return null;
}

private IElement generateReqCheckBoogie(final List<PatternType<?>> patterns) {
final Req2BoogieTranslator translator =
new Req2BoogieTranslator(mServices, mLogger, patterns, Collections.emptyList());
final Req2BoogieTranslator translator = new Req2BoogieTranslator(mServices, mLogger, patterns, Collections.emptyList());
Tob1as864 marked this conversation as resolved.
Show resolved Hide resolved
final VerificationResultTransformer reporter =
new VerificationResultTransformer(mLogger, mServices, translator.getReqSymbolTable());
// register CEX transformer that removes program executions from CEX.
final UnaryOperator<IResult> resultTransformer = reporter::convertTraceAbstractionResult;
mServices.getResultService().registerTransformer("CexReducer", resultTransformer);
return translator.getUnit();
}

private IElement generateReqParamCheckBoogie(final List<PatternType<?>> patterns) {
final Req2ModifySymbolTablePeaTransformer transformer = new Req2ModifySymbolTablePeaTransformer(mServices, mLogger);

final Req2BoogieTranslator translator = new Req2BoogieTranslator(mServices, mLogger, patterns, Collections.singletonList(transformer));

final VerificationResultTransformer reporter = new VerificationResultTransformer(mLogger, mServices, translator.getReqSymbolTable());
// register CEX transformer that removes program executions from CEX.
final UnaryOperator<IResult> resultTransformer = reporter::convertTraceAbstractionResult;
mServices.getResultService().registerTransformer("CexReducer", resultTransformer);
return translator.getUnit();
}

private IElement generateReqTestBoogie(final List<PatternType<?>> patterns) {
// TODO: would it be nicer to get the symbol table via annotations?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
import de.uni_freiburg.informatik.ultimate.pea2boogie.results.ReqCheck;
import de.uni_freiburg.informatik.ultimate.pea2boogie.results.ReqCheckFailResult;
import de.uni_freiburg.informatik.ultimate.pea2boogie.results.ReqCheckRtInconsistentResult;
import de.uni_freiburg.informatik.ultimate.pea2boogie.results.ReqCheckStateRecoverabilityResult;
import de.uni_freiburg.informatik.ultimate.pea2boogie.results.ReqCheckSuccessResult;
import de.uni_freiburg.informatik.ultimate.pea2boogie.translator.Req2BoogieTranslator;
import de.uni_freiburg.informatik.ultimate.pea2boogie.translator.ReqSymboltableBuilder;
Expand Down Expand Up @@ -153,7 +154,7 @@ public IResult convertTraceAbstractionResult(final IResult result) {
final Spec spec = specs.iterator().next();
dieIfUnsupported(spec);

if (spec == Spec.CONSISTENCY || spec == Spec.VACUOUS) {
if (spec == Spec.CONSISTENCY || spec == Spec.VACUOUS || spec == Spec.STATE_RECOVERABILITY) {
// a counterexample for consistency and vacuity means that the requirements are consistent or
// non-vacuous
isPositive = !isPositive;
Expand Down Expand Up @@ -189,6 +190,12 @@ public IResult convertTraceAbstractionResult(final IResult result) {
final String failurePath = formatTimeSequenceMap(delta2var2value);
return new ReqCheckRtInconsistentResult<>(element, plugin, translatorSequence, failurePath);
}

if(spec == Spec.STATE_RECOVERABILITY) {
IBacktranslationService translatorSequenceStRec = oldRes.getCurrentBacktranslation();
return new ReqCheckStateRecoverabilityResult<>(element, plugin, translatorSequenceStRec, reqCheck.getMessage());
}

return new ReqCheckFailResult<>(element, plugin, translatorSequence);
}

Expand Down Expand Up @@ -557,6 +564,7 @@ private static void dieIfUnsupported(final Spec spec) {
case CONSISTENCY:
case VACUOUS:
case RTINCONSISTENT:
case STATE_RECOVERABILITY:
return;
default:
throw new UnsupportedOperationException("Unknown spec type " + spec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ private static Script buildSolver(final IUltimateServiceProvider services) throw
*
*/
public Expression generateNonDeadlockCondition(final PhaseEventAutomata[] automata) {
if (PRINT_PEA_DOT) {
//if (PRINT_PEA_DOT) {
if (true) {
Tob1as864 marked this conversation as resolved.
Show resolved Hide resolved
mLogger.info("### Printing DOT for Peas ###");
for (int i = 0; i < automata.length; ++i) {
final PhaseEventAutomata pea = automata[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class Pea2BoogiePreferences extends UltimatePreferenceInitializer {
public static final String LABEL_CHECK_RT_INCONSISTENCY = "Check rt-inconsistency";
private static final boolean DEF_CHECK_RT_INCONSISTENCY = true;
private static final String DESC_CHECK_RT_INCONSISTENCY = null;

Tob1as864 marked this conversation as resolved.
Show resolved Hide resolved
public static final String LABEL_USE_EPSILON = "Use epsilon transformation during rt-inconsistency check";
private static final boolean DEF_USE_EPSILON = true;
private static final String DESC_USE_EPSILON = null;
Expand All @@ -81,6 +81,14 @@ public class Pea2BoogiePreferences extends UltimatePreferenceInitializer {
+ " are treated as separate requirements. If enabled, each rt-inconsistency check is of the form "
+ "Invariants ∧ (check over all remaining requirements). If disabled, invariants are not treated separately.";

public static final String LABEL_CHECK_STATE_RECOVERABILITY = "Check state recoverability";
private static final boolean DEF_CHECK_STATE_RECOVERABILITY = true;
private static final String DESC_CHECK_STATE_RECOVERABILITY = null;
Tob1as864 marked this conversation as resolved.
Show resolved Hide resolved

public static final String LABEL_STATE_RECOVERABILITY_VER_EXPR = "State recoverability expressions";
private static final String DEF_STATE_RECOVERABILITY_VER_EXPR = "ENG_READY==true, ENG_START==false";
private static final String DESC_STATE_RECOVERABILITY_VER_STRING = "Enter the expressions for which state recoverability should be valid";

public static final String LABEL_GUESS_IN_OUT =
"Use heuristic to find input/output definitions (if none are given)";
private static final boolean DEF_GUESS_IN_OUT = true;
Expand All @@ -99,7 +107,7 @@ public class Pea2BoogiePreferences extends UltimatePreferenceInitializer {
+ "step independend of length or usefulness.";

public enum PEATransformerMode {
REQ_CHECK, REQ_TEST
REQ_CHECK, REQ_PARAM_CHECK, REQ_TEST
}

public Pea2BoogiePreferences() {
Expand Down Expand Up @@ -128,6 +136,11 @@ protected UltimatePreferenceItem<?>[] initDefaultPreferences() {
new UltimatePreferenceItem<>(LABEL_RT_INCONSISTENCY_USE_ALL_INVARIANTS,
DEF_RT_INCONSISTENCY_USE_ALL_INVARIANTS, DESC_RT_INCONSISTENCY_USE_ALL_INVARIANTS,
PreferenceType.Boolean),
new UltimatePreferenceItem<>(LABEL_CHECK_STATE_RECOVERABILITY, DEF_CHECK_STATE_RECOVERABILITY, DESC_CHECK_STATE_RECOVERABILITY,
PreferenceType.Boolean),
new UltimatePreferenceItem<>(LABEL_STATE_RECOVERABILITY_VER_EXPR, DEF_STATE_RECOVERABILITY_VER_EXPR,
DESC_STATE_RECOVERABILITY_VER_STRING, PreferenceType.String,
IUltimatePreferenceItemValidator.EXPR_PAIR),
new UltimatePreferenceItem<>(LABEL_GUESS_IN_OUT, DEF_GUESS_IN_OUT, DESC_GUESS_IN_OUT,
PreferenceType.Boolean),
new UltimatePreferenceItem<>(LABEL_GUESS_INITIAL, DEF_GUESS_INITIAL, DESC_GUESS_INITIAL,
Expand Down
Loading