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

Groebner extension #53

Open
wants to merge 613 commits into
base: master
Choose a base branch
from
Open

Groebner extension #53

wants to merge 613 commits into from

Conversation

yizhou7
Copy link
Member

@yizhou7 yizhou7 commented Feb 8, 2022

No description provided.

Chris-Hawblitzel and others added 30 commits December 10, 2020 22:26
a special exception on the `inout` branch for the "_default" module vs.
the original master code, due to the presence of rank_is_less_than.
Rustan then made the original logic more complex in support of
"Revise export reference types", commit 3a9524f.
Copy link

@parno parno left a comment

Choose a reason for hiding this comment

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

Do all of those examples go through? If so, that's really cool! I'm also impressed you could whip this together so quickly!

}

string OpacifySubExpr(Expression expr) {
if (expr is SeqSelectExpr) {
Copy link

Choose a reason for hiding this comment

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

C# will let you write:

if (expr is SeqSelectExpr seqSelExpr) {
  ...

i.e., you can combine the test with the naming of the new variable. The name scoping is annoying though, each new variable needs to be unique, so you can't just call them all e, for example.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah that's good to know. Thanks for the tip!

}
var seq = this.OpacifySubExpr(seqSelExpr.Seq);
var index = this.OpacifySubExpr(seqSelExpr.E0);
return String.Format("{0}[{1}]", seq, index);
Copy link

Choose a reason for hiding this comment

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

It seems like this is going to emit something like x[5] to Singular. Won't that confuse it?

Copy link

Choose a reason for hiding this comment

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

Oh wait, I see. The goal is just to create a unique string 'key' to use later in the opaqueExprs dictionary?

Copy link
Member Author

@yizhou7 yizhou7 Feb 8, 2022

Choose a reason for hiding this comment

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

Ah yes, exactly. We create a temp variable in place of the expression, and when the exact same expression shows up again, we will just use the temp variable. Singular will have next to no understanding of the expression, only knowing that it is some integer.

var mod = this.EncodeSubExpr(appplyExpr.Args[2]);
// add the mod to the generators
polys.Add(mod);
return this.EncodeEqualityPoly(appplyExpr.Args[0], appplyExpr.Args[1]);
Copy link

Choose a reason for hiding this comment

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

Why aren't Args[0] and Args[1] encoded here? They were encoded in EncodeGeneratorPoly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh in this case we are encoding the "question": is it true that Args[0] and Args[1] are congruent modulo Args[2]? So Args[2] goes into the ideal, while Args[0] - Args[1] becomes the query.

Copy link

Choose a reason for hiding this comment

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

Right, but I was expecting something like:

return this.EncodeEqualityPoly(this.EncodeSubExpr(appplyExpr.Args[0]),this.EncodeSubExpr(appplyExpr.Args[1]));

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh in this case the Args[2] needs to go into the ideal. The rest of the polys in the generators are effectively all 0, except this one. Then if the difference Args[0] - Args[1] can be written in terms of a linear combination of the generators, it must be a multiple of Args[2], proving the congruence.

}
}

string EncodeQueryPoly(Expression expr) {
Copy link

Choose a reason for hiding this comment

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

This looks very similar to EncodeGeneratorPoly. Would it make sense to factor out the common bits?

Copy link
Member Author

Choose a reason for hiding this comment

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

That is true, I will try extract some common bits.

} else if (ss is AssumeStmt) {
this.EncodeGeneratorPoly((ss as AssumeStmt).Expr);
} else {
Console.WriteLine("Error: Unexpected Grobner poorf body statement {0}", ss);
Copy link

Choose a reason for hiding this comment

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

"proof body"

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. I can't English :)

var assumeFalse = new AssumeStmt(stmt.Tok, stmt.EndTok, falseBody, null);
assertStmt.Proof.Body.Add(assumeFalse);
}
TrStmt(assertStmt.Proof, proofBuilder, locals, etran);
Copy link

Choose a reason for hiding this comment

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

Just to confirm, this is a Dafny level change that adds a Dafny-level "assume false" to the proof body that's supplied in the by { ... } clause of the assert? And it's added at the end of the body, so that Dafny will check the assertions the developer wrote, since Singular trusts that they are correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that is exactly my intention.

Copy link

Choose a reason for hiding this comment

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

It might be worth adding a small comment explaining the overall intent, or even showing a "before" and "after" version of some sample Dafny code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, will do.

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.

7 participants