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

fix region not being applied correctly when exporting #211

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 6 additions & 3 deletions src/main/java/org/gecko/io/AutomatonFileSerializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ private Contract applyRegionsToContract(List<Region> relevantRegions, Contract c
return newContract;
}
List<Condition> newConditions = andConditions(relevantRegions);
newContract.setPreCondition(newConditions.getFirst());
newContract.setPostCondition(newConditions.get(1));
newContract.setPreCondition(newConditions.getFirst().and(newContract.getPreCondition()));
newContract.setPostCondition(newConditions.get(1).and(newContract.getPostCondition()));
return newContract;
}

Expand All @@ -191,8 +191,11 @@ private List<Condition> andConditions(List<Region> regions) {
} catch (ModelException e) {
throw new RuntimeException("Failed to build conditions out of other valid conditions", e);
}
newPre = newPre.and(first.getInvariant());
newPost = newPost.and(first.getInvariant());

for (Region region : regions) {
for (int i = 1; i < regions.size(); i++) {
Region region = regions.get(i);
newPre = newPre.and(region.getPreAndPostCondition().getPreCondition());
newPre = newPre.and(region.getInvariant());
newPost = newPost.and(region.getPreAndPostCondition().getPostCondition());
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/org/gecko/model/Condition.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,15 @@ public void setCondition(@NonNull String condition) throws ModelException {

@JsonIgnore
public Condition and(Condition other) {
String newCondition;
if (other.getCondition().equals(TRUE_CONDITION)) {
newCondition = condition;
} else {
newCondition = AND_CONDITIONS.formatted(condition, other.condition);
}
try {
// This and other are always valid
return new Condition(AND_CONDITIONS.formatted(condition, other.condition));
return new Condition(newCondition);
} catch (ModelException e) {
return null;
}
Expand Down