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

Assertion expressions #690

Merged
merged 12 commits into from
Jun 19, 2024
Merged

Assertion expressions #690

merged 12 commits into from
Jun 19, 2024

Conversation

xeren
Copy link
Collaborator

@xeren xeren commented Jun 7, 2024

This PR replaces AbstractAssert with Expression. It primarily removes duplicated code. It also changes the handling of user assertions: PropertyEncoder now completely controls their encoding (as opposed to ModelChecker having to inject them into the spec field first).

xeren added 4 commits June 7, 2024 13:09
Add Program.getSpecificationType()
Add Program.hasReachabilitySpecification()
Add Program.setSpecification(SpecificationType,AbstractAssert)
Remove Program.setSpecification(AbstractAssert)
Remove AbstractAssert.getType()
Remove AbstractAssert.isSafetySpec()
Remove AbstractAssert.setType(String)
Remove AbstractAssert.toStringWithType()
Add ProgramBuilder.setAssertExists(AbstractAssert)
Add ProgramBuilder.setAssertForall(AbstractAssert)
Add ProgramBuilder.setAssertNotExists(AbstractAssert)
Remove ProgramBuilder.setAssert(AbstractAssert)
Replace AssertionHelper.parseAssertion(ProgramBuilder,String)
Add EncodingContext.encodeFinalExpressionAsBoolean(Expression)
…RuleContext,ParserRuleContext)

Remove AssertionHelper
@xeren xeren changed the base branch from master to development June 7, 2024 17:28
Copy link
Owner

@hernanponcedeleon hernanponcedeleon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love PRs that mostly remove code 😍

private String name;
private AbstractAssert spec;
private AbstractAssert filterSpec; // Acts like "assume" statements, filtering out executions
private SpecificationType specificationType = SpecificationType.ASSERT;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I understand correctly that by default we assume the specification type is inline assertions and all litmus parsers are supposed to set this to something different?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems so. I kinda dislike the distinction between forall and assert, since the latter is conceptually an instance of the former. But I guess it still is an improvement of what we had before.

Copy link
Collaborator

@ThomasHaas ThomasHaas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output format of the condition has regressed:

  • The output does not attach Tid prefixes, resulting in specs that look like (X == 4) && (X == 5) but actually mean (0:X == 4) && (1:X == 5).
  • A sequence of conditions A && B && C is now printed with parenthesis for all subexpressions: ((A && B) && C) which causes a lot visual overhead for many tests.

Comparison:

// Previously:
Condition exists (ok==bv64(1) && x==bv64(1) && y==bv64(1) && z==bv64(2) && 0:bv64 X2==bv64(0) && 0:bv64 X6==bv64(0) && 1:bv64 X1==bv64(1) && 1:bv64 X5==bv64(0) && 2:bv64 X2==bv64(1) && 2:bv64 X5==bv64(0))

// Now (notice the double occurence of X5):
Condition EXISTS ((((((((((ok == bv64(1)) && (x == bv64(1))) && (y == bv64(1))) && (z == bv64(2))) && (bv64 X2 == bv64(0))) && (bv64 X6 == bv64(0))) && (bv64 X1 == bv64(1))) && (bv64 X5 == bv64(0))) && (bv64 X2 == bv64(1))) && (bv64 X5 == bv64(0)))

I think we need a smart printer for expressions that avoids parenthesis for nested associative operations and prints function ids in front of registers (configurable).

dartagnan/src/main/java/com/dat3m/dartagnan/Dartagnan.java Outdated Show resolved Hide resolved
Copy link
Collaborator

@ThomasHaas ThomasHaas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hernanponcedeleon hernanponcedeleon merged commit 489f608 into development Jun 19, 2024
1 check passed
@hernanponcedeleon hernanponcedeleon deleted the assertion-expressions branch June 19, 2024 11:08
hernanponcedeleon pushed a commit that referenced this pull request Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants