Skip to content

Commit

Permalink
Merge pull request #211 from DecwLK/export_fixes
Browse files Browse the repository at this point in the history
fix region not being applied correctly when exporting
  • Loading branch information
crissNb authored Mar 19, 2024
2 parents a860b98 + a7fef23 commit 0feebf1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
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

0 comments on commit 0feebf1

Please sign in to comment.