Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,17 @@ private VCImplication simplify(VCImplication implication, Set<String> keptTrueBi
if (next == null)
return null;

return withNext(implication, next);
}

/**
* Copies a VC node followed by its simplified suffix, leaving out a suffix that became just true
*/
private VCImplication withNext(VCImplication implication, VCImplication next) {
VCImplication result = copyWithRefinement(implication, implication.getRefinement().clone());
result.setNext(next);
// Found reads its rows as a conjunction, so P && true -> P: a trailing true row only reads as the value above
if (!isPlainTrue(next))
result.setNext(next);
return result;
}

Expand Down Expand Up @@ -119,6 +128,14 @@ private boolean isTrueBinder(VCImplication implication) {
return implication.hasBinder() && isTrue(implication.getRefinement().getExpression());
}

/**
* Checks whether a VC node is a last implication without binder refined with true
*/
private boolean isPlainTrue(VCImplication implication) {
return !implication.hasBinder() && !implication.hasNext()
&& isTrue(implication.getRefinement().getExpression());
}

/**
* Checks whether a VC node is a binder refined with false
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@ void ignoresNonBinderBooleanLiterals() {
assertSimplificationSteps(binderSimplification, vc("true", "false"), step("true", "false"));
}

@Test
void removesLastTrueBinderWithoutLeavingTrue() {
assertSimplificationSteps(binderSimplification, vc("∀p:boolean. p || q", "∀x:Object. true"), step("p || q"));
}

@Test
void removesLastTrueBinderAfterNestedConditionsWithoutLeavingTrue() {
assertSimplificationSteps(binderSimplification, vc("∀p:boolean. p", "∀q:boolean. !q", "∀x:Object. true"),
step("p", "!q"));
}

@Test
void collapsedFalseBinderLeavesNoTrueAfterAnotherRow() {
assertSimplificationSteps(binderSimplification, vc("∀x:int. x > 0", "∀y:int. false", "z > 0"), step("x > 0"));
}

@Test
void trueBinderWithoutSuffixBecomesPlainTrue() {
assertSimplificationSteps(binderSimplification, vc("∀x:int. true"), step("true"));
Expand Down
Loading