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

chore: Remove Dafny trigger warnings #160

Merged
merged 5 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/reusable-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Generate Report
run: find . -name '*.csv' -print0 | xargs -0 --verbose dafny-reportgenerator summarize-csv-results --max-resource-count 40000000

- uses: actions/upload-artifact@v2 # upload test results
- uses: actions/upload-artifact@v4 # upload test results
with:
name: verification-results
path: '**/TestResults/*.trx'
Expand Down
20 changes: 10 additions & 10 deletions src/NonlinearArithmetic/DivMod.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ module {:options "-functionSyntax:4"} DivMod {
ensures forall a: int, b: int, d: int, R: int {:trigger d * ((a + b) / d) - R, d*(a/d) + d*(b/d)}
:: 0 < d && R == a%d + b%d - (a+b)%d ==> d*((a+b)/d) - R == d*(a/d) + d*(b/d)
{
forall (a: int, b: int, d: int, R: int | 0< d && R == a%d + b%d - (a+b)%d)
forall (a: int, b: int, d: int, R: int {:trigger d * ((a + b) / d) - R, d*(a/d) + d*(b/d)} | 0< d && R == a%d + b%d - (a+b)%d)
Copy link
Member

Choose a reason for hiding this comment

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

I think you can't use interpreted functions, like any of the arithmetic or logical operators, in a trigger. Sorry that there is no automatic feedback on this, or even good documentation. And to be honest I'm not sure what the right trigger for this forall would be. @MikaelMayer @atomb ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can run Dafny and it will give you some help, but also {:nowarn} works in newer versions of Dafny, and that gets me what I want!

Copy link
Member

Choose a reason for hiding this comment

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

Please use {:nowarn} everywhere then. These triggers are not valid triggers because they map to builtin operators that do not work with pattern matching.

ensures d*((a+b)/d) - R == d*(a/d) + d*(b/d)
{
LemmaDividingSums(a, b, d, R);
Expand Down Expand Up @@ -724,7 +724,7 @@ module {:options "-functionSyntax:4"} DivMod {
ensures forall x: int, a: int, d: int {:trigger a / d, x * d, x * a}
:: 0 < x && 0 <= a && 0 < d ==> 0 < x * d && a / d == (x * a) / (x * d)
{
forall x: int, a: int, d: int | 0 < x && 0 <= a && 0 < d
forall x: int, a: int, d: int {:trigger a / d, x * d, x * a} | 0 < x && 0 <= a && 0 < d
ensures 0 < x * d && a / d == (x * a) / (x * d)
{
LemmaDivMultiplesVanishQuotient(x, a, d);
Expand All @@ -747,7 +747,7 @@ module {:options "-functionSyntax:4"} DivMod {
ensures forall a: int, r: int, d: int {:trigger d * ((a + r) / d)}
:: 0 < d && a % d == 0 && 0 <= r < d ==> a == d * ((a + r) / d)
{
forall a: int, r: int, d: int | 0 < d && a % d == 0 && 0 <= r < d
forall a: int, r: int, d: int {:trigger d * ((a + r) / d)} | 0 < d && a % d == 0 && 0 <= r < d
ensures a == d * ((a + r) / d)
{
LemmaRoundDown(a, r, d);
Expand All @@ -770,7 +770,7 @@ module {:options "-functionSyntax:4"} DivMod {
ensures forall x: int, b: int, d: int {:trigger (d * x + b) / d}
:: 0 < d && 0 <= b < d ==> (d * x + b) / d == x
{
forall x: int, b: int, d: int | 0 < d && 0 <= b < d
forall x: int, b: int, d: int {:trigger (d * x + b) / d} | 0 < d && 0 <= b < d
ensures (d * x + b) / d == x
{
LemmaDivMultiplesVanishFancy(x, b, d);
Expand Down Expand Up @@ -936,7 +936,7 @@ module {:options "-functionSyntax:4"} DivMod {
ensures forall a: int, b: int, c: int {:trigger b * (a / b) % (b * c)}
:: 0 <= a && 0 < b && 0 < c ==> 0 < b * c && (b * (a / b) % (b * c)) <= b * (c - 1)
{
forall a: int, b: int, c: int | 0 <= a && 0 < b && 0 < c
forall a: int, b: int, c: int {:trigger b * (a / b) % (b * c)} | 0 <= a && 0 < b && 0 < c
ensures 0 < b * c && (b * (a / b) % (b * c)) <= b * (c - 1)
{
LemmaPartBound1(a, b, c);
Expand Down Expand Up @@ -1205,7 +1205,7 @@ module {:options "-functionSyntax:4"} DivMod {
ensures forall x: int, y: int, m: int {:trigger (x + y) % m}
:: 0 < m ==> (x + (y % m)) % m == (x + y) % m
{
forall x: int, y: int, m: int | 0 < m
forall x: int, y: int, m: int {:trigger (x + y) % m} | 0 < m
ensures (x + (y % m)) % m == (x + y) % m
{
LemmaAddModNoopRight(x, y, m);
Expand Down Expand Up @@ -1243,7 +1243,7 @@ module {:options "-functionSyntax:4"} DivMod {
ensures forall x: int, y: int, m: int {:trigger (x - y) % m}
:: 0 < m ==> (x - (y % m)) % m == (x - y) % m
{
forall x: int, y: int, m: int | 0 < m
forall x: int, y: int, m: int {:trigger (x - y) % m} | 0 < m
ensures (x - (y % m)) % m == (x - y) % m
{
LemmaSubModNoopRight(x, y, m);
Expand Down Expand Up @@ -1306,7 +1306,7 @@ module {:options "-functionSyntax:4"} DivMod {
ensures forall x: int, d: int, q: int, r: int {:trigger q * d + r, x % d}
:: d != 0 && 0 <= r < d && x == q * d + r ==> q == x / d && r == x % d
{
forall x: int, d: int, q: int, r: int | d != 0 && 0 <= r < d && x == q * d + r
forall x: int, d: int, q: int, r: int {:trigger q * d + r, x % d} | d != 0 && 0 <= r < d && x == q * d + r
ensures q == x / d && r == x % d
{
LemmaFundamentalDivModConverse(x, d, q, r);
Expand Down Expand Up @@ -1499,7 +1499,7 @@ module {:options "-functionSyntax:4"} DivMod {
ensures forall x: int, k: int, d: int {:trigger x % (d * k)}
:: 1 < d && 0 < k ==> 0 < d * k && x % d <= x % (d * k)
{
forall x: int, k: int, d: int | 1 < d && 0 < k
forall x: int, k: int, d: int {:trigger x % (d * k)} | 1 < d && 0 < k
ensures d * k > 0 && x % d <= x % (d * k)
{
LemmaModOrdering(x, k, d);
Expand Down Expand Up @@ -1563,7 +1563,7 @@ module {:options "-functionSyntax:4"} DivMod {
ensures forall x: int, y: int, z: int {:trigger y * z, x % y}
:: 0 <= x && 0 < y && 0 < z ==> y * z > 0 && (x % y) % (y * z) < y
{
forall x: int, y: int, z: int | 0 <= x && 0 < y && 0 < z
forall x: int, y: int, z: int {:trigger y * z, x % y} | 0 <= x && 0 < y && 0 < z
ensures y * z > 0 && (x % y) % (y * z) < y
{
LemmaPartBound2(x, y, z);
Expand Down
Loading