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

Dafny Encounters internal translation error for nested quantifier expressions when a subtitute is required #5250

Open
arminvakil opened this issue Mar 26, 2024 · 0 comments
Labels
during 2: compilation of correct program Dafny rejects a valid program during compilation kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: verifier Translation from Dafny to Boogie (translator) priority: next Will consider working on this after in progress work is done

Comments

@arminvakil
Copy link
Contributor

arminvakil commented Mar 26, 2024

Dafny version

4.5.0.0

Code to produce this issue

ghost predicate bar(x:int, y:int)    

ghost predicate foo(s:seq<int>)
{
    forall i: int | 0 <= i < |s| - 1 :: 
        var current: int, next: int := s[i], s[i + 1]; 
        && bar(current, next)
        && exists m | m in s :: true
}

Command to run and resulting output

dafny error.dfy
error.dfy(6,49): Error: undeclared identifier: _t#0#0
error.dfy(6,49): Error: undeclared identifier: _t#0#0
error.dfy(6,49): Error: undeclared identifier: _t#0#0
error.dfy(6,49): Error: undeclared identifier: _t#0#0
error.dfy(6,49): Error: undeclared identifier: _t#0#0
error.dfy(6,49): Error: undeclared identifier: _t#0#0
6 name resolution errors detected in /tmp/error__module.bpl

*** Encountered internal translation error - re-running Boogie to get better debug information

/tmp/error__module.bpl(3233,99): Error: undeclared identifier: _t#0#0
/tmp/error__module.bpl(3239,101): Error: undeclared identifier: _t#0#0
/tmp/error__module.bpl(3252,109): Error: undeclared identifier: _t#0#0
/tmp/error__module.bpl(3258,111): Error: undeclared identifier: _t#0#0
/tmp/error__module.bpl(3354,101): Error: undeclared identifier: _t#0#0
/tmp/error__module.bpl(3361,99): Error: undeclared identifier: _t#0#0
6 name resolution errors detected in /tmp/error__module.bpl

What happened?

In the forallExpr, dafny chooses s[i] as selected trigger, and it next tries to substitute s[i+1] with _t#0 when calling PostCyclicityResolve function (

rewriter.PostCyclicityResolve(module, Reporter);
) for TriggerGeneratingRewriter.

Some comments regarding this approach is mentioned here:

// rewrite quantifier to avoid matching loops

This eventually calls to the Substitute function in ExprSubstituter class and instead of adding this variable to the forallExpr, it is added to the nested existsExpr and causes an error in boogie because of undeclared identifier in the forallExpr body.

What type of operating system are you experiencing the problem on?

Linux

@arminvakil arminvakil added the kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label label Mar 26, 2024
@arminvakil arminvakil changed the title Dafny Encounters internal translation error for nested quantifier expressions when a subtitute is required for a trigger Dafny Encounters internal translation error for nested quantifier expressions when a subtitute is required Mar 26, 2024
@keyboardDrummer keyboardDrummer added part: verifier Translation from Dafny to Boogie (translator) during 2: compilation of correct program Dafny rejects a valid program during compilation labels Mar 26, 2024
@keyboardDrummer keyboardDrummer added the priority: next Will consider working on this after in progress work is done label Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
during 2: compilation of correct program Dafny rejects a valid program during compilation kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: verifier Translation from Dafny to Boogie (translator) priority: next Will consider working on this after in progress work is done
Projects
None yet
Development

No branches or pull requests

2 participants