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

Assignment cover analysis #261

Merged
merged 4 commits into from
Oct 14, 2020
Merged

Assignment cover analysis #261

merged 4 commits into from
Oct 14, 2020

Conversation

Kukovec
Copy link
Collaborator

@Kukovec Kukovec commented Oct 8, 2020

No description provided.

Copy link
Collaborator

@konnov konnov left a comment

Choose a reason for hiding this comment

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

I like the idea a lot. However, it would be really cool to lift this analysis to the operator level. I imagine a command similar to the typecheck command that analyses operator definitions one-by-one, in order to compute to which variables each operator is potentially assigning. You could merge this info in Next to figure out, whether the assignments are complete. It would be quite useful for the user to see the variables that are assigned in each operator.

@@ -81,6 +81,10 @@ class CheckerExceptionAdapter @Inject()(sourceStore: SourceStore,
case err: MalformedTlaError =>
val msg = "%s: unexpected TLA+ expression: %s".format(findLoc(err.causeExpr), err.getMessage)
FailureMessage(msg)

case err: CoverData.CoverException =>
val msg = "Incomplete assignment cover: \n%s\n".format(err.getMessage)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we write a more comprehensible error message and point to the manual?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Any suggestions as to what such a message would look like? (other than the points-to-manual part)

Copy link
Collaborator

Choose a reason for hiding this comment

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

For instance: "Unable to find assignments for all state variables"


val nextName = options.getOrElse("checker", "next", "Next")
val nextBody = findBodyOf(nextName, inModule.declarations: _*)
// We only check for manual assignments in Next
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why only in Next? Once this feature is out, the users will use them in Init as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Technically, Init never has assignments (no primes)

Copy link
Collaborator

Choose a reason for hiding this comment

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

We produce InitPrimed in one of the first passes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Exactly, therefore it has no manual assignments to check for

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why cannot we write x := foo in Init?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's still not an assignment, x' := foo is (in InitPrime). The real question is, do you want a manual assignment (e.g. of x) in InitPrime to force you to manually assign all instances of x in Next? I think not.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think, yes. Once we tell the users that they can manually annotate the spec with assignments, it would be hard to explain them why they cannot manually annotate Init.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll add the check if you want, just keep in mind that if anyone ever manually assigns to a variable in Init they will have to manually assign all assignments to that same variable in Next.

@konnov
Copy link
Collaborator

konnov commented Oct 9, 2020

What I have in mind, the analyses that impose constraints on the input language (e.g., assignments, type annotations) should be triggered as early as possible, without doing too much preprocessing. Not only it will give the user better feedback, but also this analysis can be used independently of our model checker.

@Kukovec
Copy link
Collaborator Author

Kukovec commented Oct 9, 2020

I like the idea a lot. However, it would be really cool to lift this analysis to the operator level. I imagine a command similar to the typecheck command that analyses operator definitions one-by-one, in order to compute to which variables each operator is potentially assigning. You could merge this info in Next to figure out, whether the assignments are complete. It would be quite useful for the user to see the variables that are assigned in each operator.

Well, that is what the analysis does. It outputs what each operator covers in out-cover.txt.

@konnov
Copy link
Collaborator

konnov commented Oct 9, 2020

From reading the code, I had the impression that it assumes all operator bodies being inlined. Is not it the case?

@Kukovec
Copy link
Collaborator Author

Kukovec commented Oct 9, 2020

It was designed to be done just before the assignment phase so it does assume only nullary operators, but it runs the check over every operator body (now presumed inlined). The part where it checks Next is just to get the set of manually assigned variables. I made a comment on the potential inefficiency of this, but I wouldn't bother fixing it unless we see a performance issue.

@konnov
Copy link
Collaborator

konnov commented Oct 9, 2020

Our preprocessing phase does a lot of stuff. How hard is it to write this new analysis without assuming any preprocessing? I don't see where the need for nullary operators is coming from.

@Kukovec
Copy link
Collaborator Author

Kukovec commented Oct 13, 2020

Our preprocessing phase does a lot of stuff. How hard is it to write this new analysis without assuming any preprocessing? I don't see where the need for nullary operators is coming from.

Not that hard. To do this kind of analysis, the nullary operator assumption isn't strictly necessary, but since I originally wrote the cover check to happen around the assignment phase it was a convenient simplifying assumption.

@konnov
Copy link
Collaborator

konnov commented Oct 13, 2020

I think we should do it in two phases: merge this PR (provided that we resolve the discussion about Init) and create a new issue for doing cover analysis independently of the preprocessing.

@Kukovec
Copy link
Collaborator Author

Kukovec commented Oct 14, 2020

Alright, I'll just update the error message and IntPrime code pass before that.

@Kukovec Kukovec merged commit 944d2b0 into unstable Oct 14, 2020
@Kukovec Kukovec deleted the jk/AsgnOrder branch October 14, 2020 11:25
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.

2 participants