-
Notifications
You must be signed in to change notification settings - Fork 40
MCE annotation #724
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
MCE annotation #724
Changes from 5 commits
8d6209f
38879f8
658f293
67ecb96
1e3c903
1856253
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,8 +32,8 @@ import viper.silicon.utils.Counter | |
| import viper.silver.ast.{BackendType, Member} | ||
| import viper.silver.ast.utility.rewriter.Traverse | ||
| import viper.silver.cfg.silver.SilverCfg | ||
| import viper.silver.reporter.{ConfigurationConfirmation, ExecutionTraceReport, Reporter, VerificationResultMessage, VerificationTerminationMessage, QuantifierChosenTriggersMessage, WarningsDuringTypechecking} | ||
| import viper.silver.verifier.TypecheckerWarning | ||
| import viper.silver.reporter.{AnnotationWarning, ConfigurationConfirmation, ExecutionTraceReport, QuantifierChosenTriggersMessage, Reporter, VerificationResultMessage, VerificationTerminationMessage, WarningsDuringVerification} | ||
| import viper.silver.verifier.VerifierWarning | ||
|
|
||
| /* TODO: Extract a suitable MainVerifier interface, probably including | ||
| * - def verificationPoolManager: VerificationPoolManager) | ||
|
|
@@ -166,13 +166,13 @@ class DefaultMainVerifier(config: Config, | |
| case forall: ast.Forall if forall.isPure => | ||
| val res = viper.silicon.utils.ast.autoTrigger(forall, forall.autoTrigger) | ||
| if (res.triggers.isEmpty) | ||
| reporter.report(WarningsDuringTypechecking(Seq(TypecheckerWarning("No triggers provided or inferred for quantifier.", res.pos)))) | ||
| reporter.report(WarningsDuringVerification(Seq(VerifierWarning("No triggers provided or inferred for quantifier.", res.pos)))) | ||
| reporter report QuantifierChosenTriggersMessage(res, res.triggers) | ||
| res | ||
| case exists: ast.Exists => | ||
| val res = viper.silicon.utils.ast.autoTrigger(exists, exists.autoTrigger) | ||
| if (res.triggers.isEmpty) | ||
| reporter.report(WarningsDuringTypechecking(Seq(TypecheckerWarning("No triggers provided or inferred for quantifier.", res.pos)))) | ||
| reporter.report(WarningsDuringVerification(Seq(VerifierWarning("No triggers provided or inferred for quantifier.", res.pos)))) | ||
| reporter report QuantifierChosenTriggersMessage(res, res.triggers) | ||
| res | ||
| }, Traverse.BottomUp) | ||
|
|
@@ -303,6 +303,21 @@ class DefaultMainVerifier(config: Config, | |
| case r => r | ||
| } | ||
|
|
||
| val mce = member.info.getUniqueInfo[ast.AnnotationInfo] match { | ||
| case Some(ai) if ai.values.contains("exhaleMode") => | ||
| ai.values("exhaleMode") match { | ||
| case Seq("0") | Seq("greedy") => | ||
| if (Verifier.config.counterexample.isSupplied) | ||
| reporter report AnnotationWarning(s"Member ${member.name} has exhaleMode annotation that may interfere with counterexample generation.") | ||
| false | ||
| case Seq("1") | Seq("mce") | Seq("moreCompleteExhale") => true | ||
| case v => | ||
| reporter report AnnotationWarning(s"Member ${member.name} has invalid exhaleMode annotation value $v. Annotation will be ignored.") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would reject this one via a consistency check instead of reporting a warning (I think it might be very easy for a front-end developer to miss the warning otherwise)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mh I'm not sure. A consistency check is an AST-level check that's usually independent of the backend, right, and this is a backend-specific annotation. So we'd either need to build in checks regarding what a correct annotation is right into the AnnotationInfo AST node, which seems wrong to me, since annotations should in principle allow you to add all kinds of stuff in a flexible way. Or it wouldn't be a consistency check and we'd return an AnnotationError here instead, so you wouldn't be able to ignore it.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you are right about reporting consistency errors for annotations. At first sight, reporting an
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I can see that. Actually the more I think about it the more a backend-specific consistency check would also make sense. But I think this is just something we need to discuss and decide once and for all, for annotations in general. I think it's not super clear what's best. IMO warnings could also make sense:
So I'd suggest going with the warning for now and making sure we discuss this asap. Changing this to an error would be super quick and simple of course. |
||
| Verifier.config.exhaleMode == ExhaleMode.MoreComplete | ||
| } | ||
| case _ => Verifier.config.exhaleMode == ExhaleMode.MoreComplete | ||
| } | ||
|
|
||
| State(program = program, | ||
| functionData = functionData, | ||
| predicateData = predicateData, | ||
|
|
@@ -313,7 +328,7 @@ class DefaultMainVerifier(config: Config, | |
| predicateFormalVarMap = predSnapGenerator.formalVarMap, | ||
| currentMember = Some(member), | ||
| heapDependentTriggers = resourceTriggers, | ||
| moreCompleteExhale = Verifier.config.exhaleMode == ExhaleMode.MoreComplete) | ||
| moreCompleteExhale = mce) | ||
| } | ||
|
|
||
| private def createInitialState(@unused cfg: SilverCfg, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that we wouldn't be able to annotate Viper to use moreCompleteExhale on demand for a method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Basically, MCE on demand is a global setting; if that's set, Silicon will always switch to MCE on retry. This annotation sets the default for the given method.
I could change that though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the router package in SCION, I have an example where I want the package to be verified with mce, except for a particular method where
mceOnDemandis useful. With the current approach, I would need to set-up the mode as mce on demand and potentially have to annotate almost all methods with mce (which is fine, only a bit verbose). If adding the option for mce on demand requires only small changes to silicon, I would be grateful for that feature. Otherwise, I wouldn't bother changing it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.